HLE: GetProcAddress on our modules sets the last error on a miss #161

Open
github-bot wants to merge 1 commit from github-bot/gh-161 into main AGit
Owner

@⁠Peppacodes on GitHub · 2026-11-24 22:03 UTC · original
Peppacodes:vf/getprocaddress-last-error → main · +27 −1 · 1 files · 1 commits · open

GetProcAddress on one of our pseudo modules returned NULL without setting the last error. That happened for a name the module does not export, and for any ordinal.

The host sets ERROR_PROC_NOT_FOUND (127). A caller that builds its failure from GetLastError() got 0, and HRESULT_FROM_WIN32(0) is S_OK. So a failed lookup could be reported as a success.

The fix sets ERROR_PROC_NOT_FOUND on both misses, as the host does.

Tested on this branch's base (2119b0e) plus this commit, on Windows 11:

  • New test: each of these after clearing the last error:
    • a missing name on kernel32, the host's, for comparison;
    • a missing name on xgameruntime.dll;
    • an ordinal on xgameruntime.dll.
  • cargo clippy --workspace --all-targets --locked -- -D warnings, with and without --all-features: clean.
  • cargo test -p victory-shader -p victory-hle -p victory-loader --locked: 337 passed, 0 failed, 2 ignored. This was with the two other PRs from this account applied as well.

AI-assisted (Claude Code).

**@⁠Peppacodes** on GitHub · 2026-11-24 22:03 UTC · [original](https://github.com/fxceless/victory-fork/pull/161) `Peppacodes:vf/getprocaddress-last-error` → `main` · +27 −1 · 1 files · 1 commits · open `GetProcAddress` on one of our pseudo modules returned NULL without setting the last error. That happened for a name the module does not export, and for any ordinal. The host sets `ERROR_PROC_NOT_FOUND` (127). A caller that builds its failure from `GetLastError()` got 0, and `HRESULT_FROM_WIN32(0)` is `S_OK`. So a failed lookup could be reported as a success. The fix sets `ERROR_PROC_NOT_FOUND` on both misses, as the host does. **Tested** on this branch's base (`2119b0e`) plus this commit, on Windows 11: - New test: each of these after clearing the last error: - a missing name on `kernel32`, the host's, for comparison; - a missing name on `xgameruntime.dll`; - an ordinal on `xgameruntime.dll`. - `cargo clippy --workspace --all-targets --locked -- -D warnings`, with and without `--all-features`: clean. - `cargo test -p victory-shader -p victory-hle -p victory-loader --locked`: 337 passed, 0 failed, 2 ignored. This was with the two other PRs from this account applied as well. AI-assisted (Claude Code).
GetProcAddress on one of our pseudo modules returned NULL for a name it
does not export, or for any ordinal, without setting the last error. The
host sets ERROR_PROC_NOT_FOUND (127), and a caller that builds its
failure from GetLastError() got 0, HRESULT_FROM_WIN32(0) being S_OK.

Test: a missing name on kernel32 (the host's, for comparison), and a
missing name and an ordinal on xgameruntime.dll, each after clearing
the last error.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit d0662f4952383a62423e26212e1053aa324ac427)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:37:16 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/161/head:github-bot/gh-161'
git switch 'github-bot/gh-161'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-161'
git switch 'github-bot/gh-161'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-161'
git switch 'github-bot/gh-161'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-161'
git switch 'main'
git merge --squash 'github-bot/gh-161'
git switch 'main'
git merge --ff-only 'github-bot/gh-161'
git switch 'main'
git merge 'github-bot/gh-161'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.