HLE: GetProcAddress on our pseudo modules returns NULL without setting the last error (fix on a fork) #764
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#764
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?
@Peppacodes on GitHub · 2026-11-24 09:55 UTC · original
What's wrong
GetProcAddresson one of our pseudo modules, such as the handleLoadLibrary("xgameruntime.dll")returns, can return NULL without setting the last error. That happens in two places incrates/victory-hle/src/modules/kernel.rs:158-175:Microsoft's docs for
GetProcAddresssay that on failure it returns NULL andGetLastErrorgives the reason. Windows setsERROR_PROC_NOT_FOUND(127). Code that turns the failure intoHRESULT_FROM_WIN32(GetLastError())getsHRESULT_FROM_WIN32(0)here, which isS_OK, and carries on as if the lookup worked.find_modulein the same file already setsERROR_MOD_NOT_FOUNDfor a missing module.I haven't seen a title depend on this. It's a small correctness fix.
Repro
Each call below comes after
SetLastError(0):GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "NotAnExport"), which goes to the host: NULL, last error 127.GetProcAddress(LoadLibraryA("xgameruntime.dll"), "NotAnExport"): NULL, last error 0.Fix
d0662f4, rebased onmain(ffe310e), 0 commits behind it. One file, with its test.Both failure paths now call
host::set_last_error(ERROR_PROC_NOT_FOUND)before returning NULL.Related: #512 makes ordinals resolve on pseudo-module handles, and unexported ordinals still return NULL there. This change sets the last error for those as well. The two touch neighbouring lines in the same function.
Test
a_missing_export_of_our_modules_sets_the_last_error, inkernel.rs's tests:xgameruntime.dll.main(left: 0,right: 127) and passes with the fix.Results on Windows 11 with Rust 1.98.1, using the CI's own commands:
cargo test --workspace --locked: 343 passed, 0 failed, 6 ignored.cargo clippy --workspace --all-targets --locked -- -D warnings, with and without--all-features: clean.rustfmt --edition 2024 --check kernel.rs: clean.cargo xtask policy: 154 files ok.PR creation is limited to collaborators right now, so this is an issue with the branch. I can open a PR when it reopens.
No game files used. AI use: Claude Code (Claude Opus 5.5) found this in an audit of the HLE modules, wrote the fix and the test, and ran everything above.
@MamaLeVrai on GitHub · 2026-11-24 19:42 UTC · original
@Peppacodes your fix for this issue is now in a pull request, #1603, together with the three others of yours (#762, #764, #765, #832): the branches are merged as they are, with your commits 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 #1603. AI-assisted (Claude Code); no game data.@Marvisak on GitHub · 2026-11-25 03:51 UTC · original
Automated triage for the maintainers.
Confirmed on
main:GetProcAddressincrates/victory-hle/src/modules/kernel.rsreturns NULL for an ordinal on a pseudo-module handle and for a name the module does not export, without callinghost::set_last_error, soGetLastErrorkeeps whatever was there (unlikefind_modulein the same file, which setsERROR_MOD_NOT_FOUND).Open pull request #1432 already sets
ERROR_PROC_NOT_FOUNDon both paths; please compare your branch with it and comment there, or open your own pull request if yours differs. The bundle #1603 mentioned above is not open.Generated by Claude Code