hle(kernel): return FALSE from GetModuleHandleExW/A when module is not found #2879

Open
opened 2026-11-29 18:28:57 +00:00 by github-bot · 0 comments
Owner

@⁠RanoGames on GitHub · 2026-11-29 18:28 UTC · original

What it changes

Fixes GetModuleHandleExW and GetModuleHandleExA in crates/victory-hle/src/modules/kernel.rs:

  • give_module(out, module) previously returned 1 (TRUE) unconditionally whenever out was non-null, even when module was NULL (e.g. refused host DLLs, unloaded title DLLs, or unloaded host DLLs). It now returns i32::from(!module.is_null()) while still zeroing *out and preserving ERROR_MOD_NOT_FOUND.
  • Allow-listed host DLL lookups (ModuleLookup::Host) now forward to host::get_system_module_handle_ex (GetModuleHandleExW after is_bare_dll_name validation) instead of GetModuleHandleW, so reference counting, PIN/UNCHANGED_REFCOUNT flags, and missing-module FALSE returns behave as on Windows.
  • Added unit test modules::kernel::tests::module_handle_ex_returns_false_and_null_when_module_is_missing.

How it was tested

  • GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): N/A (unit-tested HLE kernel32 wrapper fix)
  • Before: GetModuleHandleExW/GetModuleHandleExA returned 1 (TRUE) with *out = NULL for refused, unloaded title, or unloaded host DLLs.
  • After: returns 0 (FALSE) with *out = NULL, and forwards allow-listed host DLLs through GetModuleHandleExW.
  • For shader changes, the wave sizes tested (32 and/or 64 lanes): N/A
  • cargo test passed for the crates it touches: yes (cargo test --locked -p victory-hle -- modules::kernel::tests: 17 passed, 0 failed; in full victory-hle run 423 passed with 1 unrelated timing flake in xasync::tests::terminate_waiting_from_its_own_callback_returns; cargo xtask policy --staged passed)

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.

Pull request details or commits were not available from GitHub; kept as an issue.

**@⁠RanoGames** on GitHub · 2026-11-29 18:28 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2879) ## What it changes Fixes `GetModuleHandleExW` and `GetModuleHandleExA` in `crates/victory-hle/src/modules/kernel.rs`: - `give_module(out, module)` previously returned `1` (`TRUE`) unconditionally whenever `out` was non-null, even when `module` was `NULL` (e.g. refused host DLLs, unloaded title DLLs, or unloaded host DLLs). It now returns `i32::from(!module.is_null())` while still zeroing `*out` and preserving `ERROR_MOD_NOT_FOUND`. - Allow-listed host DLL lookups (`ModuleLookup::Host`) now forward to `host::get_system_module_handle_ex` (`GetModuleHandleExW` after `is_bare_dll_name` validation) instead of `GetModuleHandleW`, so reference counting, `PIN`/`UNCHANGED_REFCOUNT` flags, and missing-module `FALSE` returns behave as on Windows. - Added unit test `modules::kernel::tests::module_handle_ex_returns_false_and_null_when_module_is_missing`. ## How it was tested - GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): N/A (unit-tested HLE `kernel32` wrapper fix) - Before: `GetModuleHandleExW`/`GetModuleHandleExA` returned `1` (`TRUE`) with `*out = NULL` for refused, unloaded title, or unloaded host DLLs. - After: returns `0` (`FALSE`) with `*out = NULL`, and forwards allow-listed host DLLs through `GetModuleHandleExW`. - For shader changes, the wave sizes tested (32 and/or 64 lanes): N/A - `cargo test` passed for the crates it touches: yes (`cargo test --locked -p victory-hle -- modules::kernel::tests`: 17 passed, 0 failed; in full `victory-hle` run 423 passed with 1 unrelated timing flake in `xasync::tests::terminate_waiting_from_its_own_callback_returns`; `cargo xtask policy --staged` passed) ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. *Pull request details or commits were not available from GitHub; kept as an issue.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 18:28:57 +00:00
github-bot changed title from [pr-fix] hle(kernel): return FALSE from GetModuleHandleExW/A when module is not found to hle(kernel): return FALSE from GetModuleHandleExW/A when module is not found 2026-11-29 18:34:44 +00:00
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA#2879
No description provided.