HLE: GetProcAddress finds our pseudo modules' functions by ordinal #4541

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

@⁠breachato on GitHub · 2026-11-30 22:07 UTC · original
breachato:hle-getprocaddress-ordinals → main · +45 −11 · 1 files · 1 commits · open

[pr-fix]

What it changes

Our modules list their ordinal exports as #n (hle_export names; gameinput.dll's only export is #1, GameInputCreate, since titles import it by ordinal only), and import binding finds them by that name. GetProcAddress on a pseudo module's handle did not: every ordinal (MAKEINTRESOURCE(n), a value below 0x10000) logged a warning and returned NULL. So a title that loads gameinput.dll and looks up ordinal 1 got nothing where an import of the same ordinal works.

It now looks up #n like import binding does. Host modules are unchanged (host_override already maps their ordinals).

A function that is not there now sets the last error the host sets for the same miss on a real DLL: ERROR_INVALID_ORDINAL (182) for an ordinal, ERROR_PROC_NOT_FOUND (127) for a name. Before, the last error was left as it was, so a title checking it after a NULL saw whatever an earlier call left.

How it was tested

  • No GPU or game needed.
  • New test pseudo_modules_answer_ordinals_and_report_a_missing_function: LoadLibraryW("gameinput.dll") gives the pseudo module's handle; GetProcAddress(module, 1) equals what registry::lookup("gameinput.dll", "#1") binds; a missing ordinal (9999) and a missing name give NULL and the same last error as GetProcAddress(kernel32, ...) for the same miss.
  • Before (main): GetProcAddress(gameinput, 1) returned 0 (the test fails there). After: the bound address.
  • cargo test -p victory-hle --lib --locked modules::kernel: 19 passed.
  • cargo test -p victory-hle --lib --locked: 468 passed; two xmem tests failed in the full parallel run and pass alone (a_read_by_range_waits_only_for_a_remapping_that_meets_it, the known flake in #2420 and #2439, and large_default_allocations_honour_write_watch_switch).
  • cargo clippy -p victory-hle --no-deps --all-targets: nothing in kernel.rs.
  • cargo test passed for the crates it touches: yes

How to try it

cargo test -p victory-hle --lib --locked pseudo_modules_answer_ordinals.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: none for GetProcAddress ordinals.

Assisted by Claude.

**@⁠breachato** on GitHub · 2026-11-30 22:07 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4540) `breachato:hle-getprocaddress-ordinals` → `main` · +45 −11 · 1 files · 1 commits · open [pr-fix] ## What it changes Our modules list their ordinal exports as `#n` (`hle_export` names; `gameinput.dll`'s only export is `#1`, `GameInputCreate`, since titles import it by ordinal only), and import binding finds them by that name. `GetProcAddress` on a pseudo module's handle did not: every ordinal (`MAKEINTRESOURCE(n)`, a value below 0x10000) logged a warning and returned NULL. So a title that loads `gameinput.dll` and looks up ordinal 1 got nothing where an import of the same ordinal works. It now looks up `#n` like import binding does. Host modules are unchanged (`host_override` already maps their ordinals). A function that is not there now sets the last error the host sets for the same miss on a real DLL: `ERROR_INVALID_ORDINAL` (182) for an ordinal, `ERROR_PROC_NOT_FOUND` (127) for a name. Before, the last error was left as it was, so a title checking it after a NULL saw whatever an earlier call left. ## How it was tested - No GPU or game needed. - New test `pseudo_modules_answer_ordinals_and_report_a_missing_function`: `LoadLibraryW("gameinput.dll")` gives the pseudo module's handle; `GetProcAddress(module, 1)` equals what `registry::lookup("gameinput.dll", "#1")` binds; a missing ordinal (9999) and a missing name give NULL and the same last error as `GetProcAddress(kernel32, ...)` for the same miss. - Before (`main`): `GetProcAddress(gameinput, 1)` returned 0 (the test fails there). After: the bound address. - `cargo test -p victory-hle --lib --locked modules::kernel`: 19 passed. - `cargo test -p victory-hle --lib --locked`: 468 passed; two `xmem` tests failed in the full parallel run and pass alone (`a_read_by_range_waits_only_for_a_remapping_that_meets_it`, the known flake in #2420 and #2439, and `large_default_allocations_honour_write_watch_switch`). - `cargo clippy -p victory-hle --no-deps --all-targets`: nothing in `kernel.rs`. - `cargo test` passed for the crates it touches: yes ## How to try it `cargo test -p victory-hle --lib --locked pseudo_modules_answer_ordinals`. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: none for `GetProcAddress` ordinals. Assisted by Claude.
Our modules list ordinal exports as "#n", which import binding finds
(gameinput.dll is imported by ordinal only: "#1" is GameInputCreate).
GetProcAddress on a pseudo module's handle returned NULL for every
ordinal, so a title that loads gameinput.dll and looks up ordinal 1 got
nothing where an import of it works. It now looks up "#n" the same way.

A function that is not there now sets the host's last error for the same
miss: ERROR_INVALID_ORDINAL for an ordinal, ERROR_PROC_NOT_FOUND for a
name. Before, the last error was left as it was.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 22:08:12 +00:00
github-bot force-pushed github-bot/gh-4540 from 0dceb9e983 to ea5e29de80 2026-12-01 14:00:16 +00:00 Compare
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/4541/head:github-bot/gh-4540'
git switch 'github-bot/gh-4540'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-4540'
git switch 'github-bot/gh-4540'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-4540'
git switch 'github-bot/gh-4540'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-4540'
git switch 'main'
git merge --squash 'github-bot/gh-4540'
git switch 'main'
git merge --ff-only 'github-bot/gh-4540'
git switch 'main'
git merge 'github-bot/gh-4540'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!4541
No description provided.