HLE: LOAD_LIBRARY_AS_DATAFILE loads outside HostPolicy fail with ERROR_MOD_NOT_FOUND (fix on a fork) #805
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Imported from Marvisak/VIctory. Originally posted by davutsimsekk on 2026-11-24T11:19:38Z.
LoadLibraryExW(L"comctl32.dll", NULL, LOAD_LIBRARY_AS_DATAFILE)returns NULL withERROR_MOD_NOT_FOUND(126) onffe310e, while Windows returns a data-file handle. The same happens for any DLL outsideHostPolicyloaded withDONT_RESOLVE_DLL_REFERENCES,LOAD_LIBRARY_AS_DATAFILE(_EXCLUSIVE)orLOAD_LIBRARY_AS_IMAGE_RESOURCE.LoadLibraryExA/Walready computesruns_code(flags)and passes it tofind_moduleasload, butfind_modulestill applies the HostPolicy refusal at the end:That contradicts the comment above
runs_code: a load that runs no code can go to the host. The existing test atkernel.rs:680only asserts the result is not the title's mapped base, so NULL also passes it.Fix on a fork
343aa42onmainffe310e, one file (crates/victory-hle/src/modules/kernel.rs).runs_codevalue is passed intofind_module; when it is false and the name is not one of our pseudo modules or an already mapped image,find_modulereturnsNoneso the host loader maps the file as data. Code loads,GetModuleHandle, pseudo-module resolution and the HostPolicy checks are unchanged.Test
a_data_load_of_a_host_dll_reaches_the_hostloadscomctl32.dllas data:main: NULL, last error 126;FreeLibraryreturns 1.Also run on Windows 11, Rust 1.98.1 (MSVC):
cargo test -p victory-hle --lib: 95 passedcargo clippy -p victory-hle --all-targets --locked -- -D warnings: cleanrustfmt --edition 2024 --check crates/victory-hle/src/modules/kernel.rs: cleanPR creation is still restricted to collaborators, so the branch is here for review or cherry-pick.
Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-24T12:07:15Z.
Claiming this issue.
In
crates/victory-hle/src/modules/kernel.rs,LoadLibraryExWcomputesruns_code(flags)where flags likeLOAD_LIBRARY_AS_DATAFILE,LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE, andDONT_RESOLVE_DLL_REFERENCESevaluate tofalse.When
runs_codeis false, the DLL is mapped strictly as a passive data/resource file and will not execute any DllMain or code. However,find_modulecurrently enforcesHostPolicyrefusal unconditionally, causing data-file loads of standard Windows libraries (e.g.comctl32.dllfor UI icons/resources) to fail withERROR_MOD_NOT_FOUND(126).Passing
runs_codeintofind_moduleso passive data-file mappings are permitted to fall through to the host loader cleanly fixes this without weakening code-execution sandboxing.Preparing a clean branch with regression tests on fork.
Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-24T12:13:57Z.
Verified Patch Ready on Fork
The implementation is verified and available on my fork:
79cf805based onmain(ffe310e)Changes (
crates/victory-hle/src/modules/kernel.rs):LoadKind { Query, Code, Data }to clearly distinguish between querying loaded module handles (GetModuleHandle), executable library loads (LoadLibrary/runs_code == true), and passive data-file mappings (LOAD_LIBRARY_AS_DATAFILE,DONT_RESOLVE_DLL_REFERENCES/runs_code == false).LoadKind::Datais passed,find_modulereturnsNonefor DLLs outsideHostPolicy, allowing the host loader to map the DLL strictly as passive data/resources without running code or executingDllMain.LoadLibraryExW("comctl32.dll", NULL, LOAD_LIBRARY_AS_DATAFILE)succeeds on Windows.Verification:
rustfmt --edition 2024.cargo xtask policyclean).Imported from Marvisak/VIctory. Originally posted by MamaLeVrai on 2026-11-24T19:45:27Z.
@davutsimsekk your fix for this issue is now in a pull request, #1610, with seven other fixes from contributors' forks: the branch is merged as it is, with your commit(s) and your name unchanged, onto
mainffe310e. Clippy (both runs) andcargo test --workspacepass on the result. If you would rather open your own pull request for this one, say so and I will take it out of #1610. AI-assisted (Claude Code); no game data.Imported from Marvisak/VIctory. Originally posted by davutsimsekk on 2026-11-24T20:07:54Z.
Thanks — keep it in #1610. I fetched the bundle and confirmed it contains
343aa42unchanged (git merge-base --is-ancestor), with the commit and author intact.Since PR creation is still restricted for my account, carrying it in the bundle is the right path. I'm happy for it to be merged as-is; if
kernel.rsneeds a rebase later, I can take that.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T03:54:03Z.
Automated triage for the maintainers.
Confirmed on
main: incrates/victory-hle/src/modules/kernel.rs,LoadLibraryExA/Wpassruns_code(flags)tofind_module, butfind_moduleuses it only to decide whether to map a title DLL. A DLL outsideHostPolicyis refused withERROR_MOD_NOT_FOUNDwhatever the flags, so a data-file load ofcomctl32.dllreturns NULL.find_module's own doc comment describes that refusal, so whether loads that run no code should be exempt is a maintainer decision. Nothing in the thread shows the title making such a load.Open PR #1419 carries this change. Pull requests are open to everyone, so please compare the fork branches with it and comment there.
Generated by Claude Code