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

Open
Peppacodes wants to merge 1 commit from upstream-pr/161 into main
Peppacodes commented 2026-11-24 22:03:24 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Peppacodes on 2026-11-24T22:03:24Z.


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).

<!-- greyfinch-sync:fxceless/victory-fork:issue:6592306446 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/161). Originally posted by [Peppacodes](https://github.com/Peppacodes) on 2026-11-24T22:03:24Z. --- `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).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/161:upstream-pr/161'
git switch 'upstream-pr/161'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/161'
git switch 'upstream-pr/161'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/161'
git switch 'upstream-pr/161'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/161'
git switch 'main'
git merge --squash 'upstream-pr/161'
git switch 'main'
git merge --ff-only 'upstream-pr/161'
git switch 'main'
git merge 'upstream-pr/161'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
fxceless/victory-fork!161
No description provided.