HLE: succeed DisableThreadLibraryCalls for pseudo-module handles #2743

Open
fuzeofficlal wants to merge 1 commit from upstream-pr/2745 into main
fuzeofficlal commented 2026-11-25 19:28:32 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T19:28:32Z.


Summary

Handle HLE pseudo-module handles in crates/victory-hle/src/modules/kernel.rs::DisableThreadLibraryCalls:

  • LoadLibraryA/W and GetModuleHandleA/W return &HleModule pointers as pseudo-module handles for console HLE DLLs (such as xgameruntime.dll, d3d12_xs.dll, dstorage_xs.dll, gameinput.dll).
  • FreeLibrary already recognizes pseudo-module handles (registry().iter().any(|m| handle(m) == module)) and returns 1, but DisableThreadLibraryCalls forwarded them directly to Windows' host DisableThreadLibraryCalls, which rejects pseudo-module handles with 0 (ERROR_INVALID_HANDLE).
  • Return 1 for registered HLE pseudo-module handles before delegating title/host modules to host::disable_thread_library_calls.

Tests

Added disable_thread_library_calls_accepts_pseudo_modules in crates/victory-hle/src/modules/kernel.rs.

Verification

  • cargo clippy --locked -p victory-hle --all-targets -- -D warnings and --all-features: 0 warnings.
  • cargo test --locked -p victory-hle --lib: 147 passed, 0 failed.
  • cargo xtask policy: 184 files ok.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6612076651 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2745). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T19:28:32Z. --- ## Summary Handle HLE pseudo-module handles in `crates/victory-hle/src/modules/kernel.rs::DisableThreadLibraryCalls`: - `LoadLibraryA/W` and `GetModuleHandleA/W` return `&HleModule` pointers as pseudo-module handles for console HLE DLLs (such as `xgameruntime.dll`, `d3d12_xs.dll`, `dstorage_xs.dll`, `gameinput.dll`). - `FreeLibrary` already recognizes pseudo-module handles (`registry().iter().any(|m| handle(m) == module)`) and returns `1`, but `DisableThreadLibraryCalls` forwarded them directly to Windows' host `DisableThreadLibraryCalls`, which rejects pseudo-module handles with `0` (`ERROR_INVALID_HANDLE`). - Return `1` for registered HLE pseudo-module handles before delegating title/host modules to `host::disable_thread_library_calls`. ## Tests Added `disable_thread_library_calls_accepts_pseudo_modules` in `crates/victory-hle/src/modules/kernel.rs`. ## Verification - `cargo clippy --locked -p victory-hle --all-targets -- -D warnings` and `--all-features`: 0 warnings. - `cargo test --locked -p victory-hle --lib`: **147 passed, 0 failed**. - `cargo xtask policy`: 184 files ok.
kotekompotek commented 2026-11-25 20:06:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T20:05:56Z.


Correct: pseudo-module handles (our registered title images) have no host HMODULE, so forwarding to host::disable_thread_library_calls failed - returning 1 for them matches the loader contract (title images hear thread notifications from us anyway). The test covers both the pseudo and null cases.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7173188227 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2745#issuecomment-7173188227). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T20:05:56Z. --- Correct: pseudo-module handles (our registered title images) have no host HMODULE, so forwarding to host::disable_thread_library_calls failed - returning 1 for them matches the loader contract (title images hear thread notifications from us anyway). The test covers both the pseudo and null cases.
oni-swr commented 2026-11-25 21:03:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T20:15:36Z.


Independent WARP/CPU verification for head 786165f1c2 against origin/main 13f91caee2. State check at start and again before posting: open, non-draft, mergeable, head unchanged; no prior oni-swr comment.

Environment: Windows 11 x64, Rust 1.98.1 (48a229cea 2026-09-01), cargo 1.98.1, Windows SDK dxil.dll 10.0.26100.0 (file version 1.8.2502.11). VICTORY_WARP=1 and VICTORY_D3D12_WARP=1 set (WARP only, no physical GPU); no game files. CARGO_TARGET_DIR=D:\victory-warp-2741-target. Tested commit: the PR head itself, which is exactly one commit on top of origin/main (merge-base = origin/main, so no temporary merge was needed).

Commands/results:

  • Baseline (origin/main): cargo test --locked -p victory-hle — lib 146 passed, 0 failed; the other test binaries also pass (0 failed anywhere). cargo clippy --locked -p victory-hle --all-targets -- -D warnings — pass.
  • PR: cargo test --locked -p victory-hle --lib disable_thread_library_calls — 1/1 passed. cargo test --locked -p victory-hle — lib 147 passed (+1), 0 failed, 0 ignored; other binaries pass. cargo clippy --locked -p victory-hle --all-targets -- -D warnings — pass.
  • Negative control: kept the new test, disabled the production branch (if false && registry()...); disable_thread_library_calls_accepts_pseudo_modules FAILED (assertion at kernel.rs:618, the pseudo-module handle fell through to the host call). Restored, tree clean.

Review: no blocker found. Pseudo-module handles come from our own registry and are not real loader modules, so forwarding them to the host's DisableThreadLibraryCalls could only fail; returning 1 for them and still forwarding everything else (null still returns 0, covered by the test) is the right split. Nit: the added doc line sits directly above the existing one, so the doc comment now reads as two unrelated summary sentences.

Not tested: physical GPU, retail title/game behavior, release build (debug profile only).

AI disclosure: Claude Code (Claude Sonnet 5.5).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7173407486 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2745#issuecomment-7173407486). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-25T20:15:36Z. --- Independent WARP/CPU verification for head 786165f1c29bcc08761a3238b7f468c26493cda6 against origin/main 13f91caee25f2fdf2c062be5f7a27f058e51cbca. State check at start and again before posting: open, non-draft, mergeable, head unchanged; no prior oni-swr comment. Environment: Windows 11 x64, Rust 1.98.1 (48a229cea 2026-09-01), cargo 1.98.1, Windows SDK dxil.dll 10.0.26100.0 (file version 1.8.2502.11). `VICTORY_WARP=1` and `VICTORY_D3D12_WARP=1` set (WARP only, no physical GPU); no game files. `CARGO_TARGET_DIR=D:\victory-warp-2741-target`. Tested commit: the PR head itself, which is exactly one commit on top of `origin/main` (merge-base = `origin/main`, so no temporary merge was needed). Commands/results: - Baseline (origin/main): `cargo test --locked -p victory-hle` — lib 146 passed, 0 failed; the other test binaries also pass (0 failed anywhere). `cargo clippy --locked -p victory-hle --all-targets -- -D warnings` — pass. - PR: `cargo test --locked -p victory-hle --lib disable_thread_library_calls` — 1/1 passed. `cargo test --locked -p victory-hle` — lib 147 passed (+1), 0 failed, 0 ignored; other binaries pass. `cargo clippy --locked -p victory-hle --all-targets -- -D warnings` — pass. - Negative control: kept the new test, disabled the production branch (`if false && registry()...`); `disable_thread_library_calls_accepts_pseudo_modules` FAILED (assertion at kernel.rs:618, the pseudo-module handle fell through to the host call). Restored, tree clean. Review: no blocker found. Pseudo-module handles come from our own registry and are not real loader modules, so forwarding them to the host's `DisableThreadLibraryCalls` could only fail; returning 1 for them and still forwarding everything else (null still returns 0, covered by the test) is the right split. Nit: the added doc line sits directly above the existing one, so the doc comment now reads as two unrelated summary sentences. Not tested: physical GPU, retail title/game behavior, release build (debug profile only). AI disclosure: Claude Code (Claude Sonnet 5.5).
Marvisak commented 2026-11-26 00:03:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T23:25:03Z.


Automated triage for the maintainers. DisableThreadLibraryCalls in crates/victory-hle/src/modules/kernel.rs now returns 1 for our registered pseudo-module handles instead of passing them to the host loader, which does not know them and fails. This matches how FreeLibrary already treats them. The new test covers both a pseudo handle and null. A small nit: the new doc line sits above the existing one, so the doc comment now reads as two unrelated sentences. CI: check passing. This is a recommendation for a maintainer to look, not an approval.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7177531000 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2745#issuecomment-7177531000). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T23:25:03Z. --- <!-- victory-triage v1 head=786165f1c29bcc08761a3238b7f468c26493cda6 verdict=merge-candidate at=2026-11-25T23:24:53Z --> Automated triage for the maintainers. `DisableThreadLibraryCalls` in `crates/victory-hle/src/modules/kernel.rs` now returns 1 for our registered pseudo-module handles instead of passing them to the host loader, which does not know them and fails. This matches how `FreeLibrary` already treats them. The new test covers both a pseudo handle and null. A small nit: the new doc line sits above the existing one, so the doc comment now reads as two unrelated sentences. CI: `check` passing. This is a recommendation for a maintainer to look, not an approval. --- _Generated by [Claude Code](https://claude.ai/code)_
Dukestar69 commented 2026-11-26 05:03:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T04:12:29Z.

Review: APPROVED


Tested merged onto origin/main (63bcca4) on Windows 11 x64:

  • cargo test -p victory-hle --lib modules::kernel::: 6 passed, 0 failed (including new disable_thread_library_calls_accepts_pseudo_modules).
  • cargo clippy -p victory-hle --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6068449722 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2745#pullrequestreview-6068449722). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T04:12:29Z. **Review:** APPROVED --- Tested merged onto `origin/main` (`63bcca4`) on Windows 11 x64: - `cargo test -p victory-hle --lib modules::kernel::`: **6 passed, 0 failed** (including new `disable_thread_library_calls_accepts_pseudo_modules`). - `cargo clippy -p victory-hle --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
futurepro62 commented 2026-11-26 14:01:51 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T13:25:13Z.


NVIDIA full-suite run, to go with the reports above by Dukestar69, oni-swr, since none of them names a GPU run. Tested exact head 786165f (on its base 13f91ca).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 774 passed, 0 failed, 9 ignored.
  • The new tests ran and passed: disable_thread_library_calls_accepts_pseudo_modules.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7193326124 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2745#issuecomment-7193326124). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-26T13:25:13Z. --- NVIDIA full-suite run, to go with the reports above by Dukestar69, oni-swr, since none of them names a GPU run. Tested exact head `786165f` (on its base `13f91ca`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **774 passed, 0 failed, 9 ignored**. - The new tests ran and passed: `disable_thread_library_calls_accepts_pseudo_modules`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2745:upstream-pr/2745'
git switch 'upstream-pr/2745'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2745'
git switch 'upstream-pr/2745'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2745'
git switch 'upstream-pr/2745'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2745'
git switch 'main'
git merge --squash 'upstream-pr/2745'
git switch 'main'
git merge --ff-only 'upstream-pr/2745'
git switch 'main'
git merge 'upstream-pr/2745'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!2743
No description provided.