HLE: GetModuleHandleEx finds the title's modules, not the host's #2506
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2506
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2506"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@cryst4lpepsi on GitHub · 2026-11-25 14:59 UTC · original
cryst4lpepsi:hle/get-module-handle-ex→main· +154 −1 · 2 files · 1 commits · openWhat
GetModuleHandleA/W,LoadLibrary*andGetProcAddressgive a title its own modules, butGetModuleHandleExA/Whad no override, so imports of them (andGetProcAddresslookups) were bound to the host:victory.exe, not the title's image.xgameruntime.dll) were looked up under host names, not ours.HostPolicywas found if anything in our process had loaded it.Both now use the same lookup as
GetModuleHandle. Lookups by address (FROM_ADDRESS), allowed host DLLs and invalid arguments still go to the host. No reference is taken on title images or pseudo modules, matchingFreeLibrary, which never drops one.I have no copy of the title, so I haven't checked whether it calls these.
An AI tool (Claude Code) wrote this change.
Tested
Windows 11, Rust 1.98.1, rebased on
940d32f:cargo test -p victory-hle --locked: all pass, three runs (144 unit tests, plus the integration tests). With the two exports removed, the new unit test fails. The no-name case has its own test process, because the main image is process-wide.cargo clippy --workspace --all-targets --locked -- -D warnings, with and without--all-features: clean.cargo test --workspace --locked: passes except invictory-gpu(aborts) andvictory-shader(6 hardware tests), neither of which depends onvictory-hle. Without this change,940d32ffails the same way on this machine (AMD Radeon iGPU + RTX 3050 Ti Laptop): the same 6 shader tests and the samevictory-gpuabort. Onevictory-gputest,null_3d_uav_is_accepted_by_the_device, was reported failed only in the run with the change.cargo xtask policy: asset policy: 183 files ok. Nothing from the game was used.@Marvisak on GitHub · 2026-11-25 15:56 UTC · original
Automated triage for the maintainers. Recommended for a look (not an approval).
Adds
GetModuleHandleExA/Woverrides incrates/victory-hle/src/modules/kernel.rsthat reusefind_module(andruntime::main_imagefor a null name), asGetModuleHandleA/Walready do; previously these went straight to the host, so a null name gave our exe and a DLL outsideHostPolicy(e.g. wininet) could be found if loaded. Address lookups and unsupported flags still go to the host; the unit test and the separate-process integration test cover title images, console modules, the refused-DLL case and the host fallbacks. CI (check) is passing.Generated by Claude Code
@fuzeofficlal on GitHub · 2026-11-26 00:52 UTC · original
Code review and Windows 11 verification at head
748efa86bf2emerged cleanly ontomain(63bcca43c6a0):crates/victory-hle/src/modules/kernel.rs:34-73):named_handlecleanly handles name-basedGetModuleHandleExA/Wcalls (flagsin0 | PIN | UNCHANGED_REFCOUNT,!out.is_null()): returnsruntime::main_image()forNULL, resolves title/console modules throughfind_module(&name, false)(rejecting disallowed host DLLs withERROR_MOD_NOT_FOUNDand writing null to*out), and forwards allowed host DLLs,FROM_ADDRESS, invalid flag combinations (PIN | UNCHANGED_REFCOUNT), and nulloutstraight to the host.#2902(does not modifyfind_module, so it inherits the trailing-dot fix automatically). Non-blocking note:GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESSagainst a manually mapped title DLL still delegates to host Ldr (matching existingcrash::module_ofscope).cargo xtask policy:192 files ok;cargo clippy -p victory-hle --all-targets --locked -- -D warnings(default +--all-features): 0 warningscargo test -p victory-hle --locked(default +--all-features): 153/153 lib + 1 subprocess (module_handle_ex_finds_what_module_handle_does) +fidelityfx+main_module_handle+no_dll_plantingall passed.LGTM.
@futurepro62 on GitHub · 2026-11-26 01:44 UTC · original
NVIDIA full-suite run, to go with the reports above by fuzeofficlal, since none of them names a GPU run. Tested exact head
748efa8(on its base940d32f).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo 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: 698 passed, 0 failed, 10 ignored.module_handle_ex_finds_what_module_handle_does,no_name_is_the_titles_exe.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#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_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
@cloph-dsp on GitHub · 2026-11-26 08:50 UTC · original
Independent local verification of head
748efa8on Windows 11, Rust 1.100.0/MSVC:cargo test --locked -p victory-hle --lib module_handle_ex_finds_what_module_handle_does— 1 passed, 0 failed.cargo test --locked -p victory-hle --test main_module_handle— 1 passed, 0 failed.One housekeeping issue:
git diff --check origin/main HEADfails because the branch is behind currentmain— it reportscrates/victory-formats/src/xma/tables.rs:410: new blank line at EOF. A rebase onto currentmainshould clear it; the module-handle changes themselves pass.Synthetic tests only; no game assets or DRM material used. AI-assisted (Hy4 flash).
@fuzeofficlal on GitHub · 2026-11-26 09:05 UTC · original · approved these changes
Checked all
GetModuleHandleExA/Wboundary cases incrates/victory-hle/src/modules/kernel.rs(748efa86):out, invalid flag combinations (e.g.PIN | UNCHANGED_REFCOUNT),FROM_ADDRESS, andHostPolicy-allowed host DLLs cleanly fall through to hostGetModuleHandleExA/W, preserving hostLastErrorand refcount semantics.namewith0 | PIN | UNCHANGED_REFCOUNTreturnsruntime::main_image(), and named lookups sharefind_module(&name, false)withGetModuleHandleA/W(covering title DLLs, console pseudo-modules, empty-string / disallowed host DLL rejection withERROR_MOD_NOT_FOUND+ null*out), while matchingFreeLibrary's no-decrement handling for title images and pseudo-modules.origin/main(63bcca43) viagit merge-tree. (Optional housekeeping: rebasing onto currentmainwould drop the stale base diff warning, and supportingFROM_ADDRESSfor title-mapped virtual ranges can be a separate follow-up if a title needs it.)Verified locally on Windows 11:
cargo clippy -p victory-hle --all-targets -- -D warnings(default and--all-features): cleancargo test -p victory-hle --lib -- modules::kernel::tests::: 6/6 passedcargo test -p victory-hle --test main_module_handle: 1/1 passedcargo xtask policy: cleanLGTM.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.