HLE: resolve ordinals on pseudo-module handles #512

Open
Quat3rnion wants to merge 1 commit from upstream-pr/512 into main
Quat3rnion commented 2026-11-24 04:21:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Quat3rnion on 2026-11-24T04:21:26Z.


What

GetProcAddress refused every ordinal on one of our pseudo modules. Some
console APIs are exported only by ordinal — gameinput.dll registers
GameInputCreate as #1 — so a title that loaded the module and asked for
that ordinal got null even though the static import resolved. The registry
already stores ordinal exports under the name #n; the lookup now uses that
form. Unexported ordinals still return null.

An AI tool wrote part of this change.

Tested

  • Linux: cargo test --workspace: 165 passed, 0 failed, 3 ignored. A new regression loads the gameinput.dll pseudo module, resolves ordinal 1 to the registered address, and checks that ordinal 2 fails.
  • Windows cross-build: cargo check --target x86_64-pc-windows-gnu --workspace --tests passes. No Windows host here.
  • cargo xtask policy passes (150 files ok). No game files or data from them were added.

Checklist

  • Workspace tests and Windows cross-check pass.
  • cargo xtask policy passes. No game files or data from them were added.
  • AI authorship is disclosed above.
<!-- greyfinch-sync:Marvisak/VIctory:issue:5466026280 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/512). Originally posted by [Quat3rnion](https://github.com/Quat3rnion) on 2026-11-24T04:21:26Z. --- ## What `GetProcAddress` refused every ordinal on one of our pseudo modules. Some console APIs are exported only by ordinal — `gameinput.dll` registers `GameInputCreate` as `#1` — so a title that loaded the module and asked for that ordinal got null even though the static import resolved. The registry already stores ordinal exports under the name `#n`; the lookup now uses that form. Unexported ordinals still return null. An AI tool wrote part of this change. ## Tested - Linux: `cargo test --workspace`: 165 passed, 0 failed, 3 ignored. A new regression loads the `gameinput.dll` pseudo module, resolves ordinal 1 to the registered address, and checks that ordinal 2 fails. - Windows cross-build: `cargo check --target x86_64-pc-windows-gnu --workspace --tests` passes. No Windows host here. - `cargo xtask policy` passes (150 files ok). No game files or data from them were added. ## Checklist - [x] Workspace tests and Windows cross-check pass. - [x] `cargo xtask policy` passes. No game files or data from them were added. - [x] AI authorship is disclosed above.
mercuryVM commented 2026-11-24 08:36:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T08:36:07Z.

Review: APPROVED


Tested d3e33ea on Windows 11, RTX 5070, MSVC: cargo test --workspace --no-fail-fast passes (248 passed, 0 failed; older base), including pseudo_module_ordinals_resolve.

The registry already names ordinal exports #n for the import binder, so GetProcAddress(module, n) looking up the same #n makes run-time ordinal lookups agree with static imports. For example, gameinput.dll's #1 is GameInputCreate. An ordinal we don't export still returns null, now with a warning, as before. The Linux path tweak in the other test only affects non-Windows test builds.

No issues found.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6036008549 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/512#pullrequestreview-6036008549). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T08:36:07Z. **Review:** APPROVED --- Tested d3e33ea on Windows 11, RTX 5070, MSVC: `cargo test --workspace --no-fail-fast` passes (248 passed, 0 failed; older base), including `pseudo_module_ordinals_resolve`. The registry already names ordinal exports `#n` for the import binder, so `GetProcAddress(module, n)` looking up the same `#n` makes run-time ordinal lookups agree with static imports. For example, `gameinput.dll`'s `#1` is `GameInputCreate`. An ordinal we don't export still returns null, now with a warning, as before. The Linux path tweak in the other test only affects non-Windows test builds. No issues found. AI-assisted (Claude Code).
jeremygold02 commented 2026-11-24 18:05:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-24T17:35:57Z.


Verification ran against PR head 829f774722a6b8feab7a88cffd1d635c03b9c81b; the PR was open at refresh.

  • Command: cargo test -p victory-hle pseudo_module_ordinals_resolve
  • Result: 1 passed: modules::kernel::tests::pseudo_module_ordinals_resolve. It confirms ordinal 1 on the pseudo gameinput.dll handle resolves to registry export #1, while unexported ordinal 2 returns null.
  • Scope: this was the targeted HLE unit test, not a full-workspace run.

This verification was AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7139431922 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/512#issuecomment-7139431922). Originally posted by [jeremygold02](https://github.com/jeremygold02) on 2026-11-24T17:35:57Z. --- Verification ran against PR head `829f774722a6b8feab7a88cffd1d635c03b9c81b`; the PR was open at refresh. - Command: `cargo test -p victory-hle pseudo_module_ordinals_resolve` - Result: 1 passed: `modules::kernel::tests::pseudo_module_ordinals_resolve`. It confirms ordinal 1 on the pseudo `gameinput.dll` handle resolves to registry export `#1`, while unexported ordinal 2 returns null. - Scope: this was the targeted HLE unit test, not a full-workspace run. This verification was AI-assisted.
Marvisak commented 2026-11-25 02:05:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:22:33Z.


Automated triage for the maintainers.

Needs work. The fix itself is right: GetProcAddress in crates/victory-hle/src/modules/kernel.rs refused every ordinal on a pseudo-module handle. The registry already names ordinal exports #n (gameinput.rs registers #1, net.rs its ws2_32 ordinals), and host_override already looks ordinals up the same way. Resolving #n here makes the dynamic lookup agree with the static import binding. For ws2_32 this hands out our guarded net functions, so the offline guards still apply.

What blocks it: CI fails at Clippy (-D warnings). In the new test pseudo_module_ordinals_resolve, GetProcAddress(module, 1 as *const u8) trips clippy::manual_dangling_ptr. Use std::ptr::without_provenance::<u8>(1) (and (2) for the second call), or build the pointer through a usize variable. Once CI is green, this would be a merge candidate.

Minor: the change to title_dlls_and_pseudo_modules_are_found_by_name (non-Windows path) is unrelated to the fix. Please drop it or mention it in the description.

CI: failing (Clippy, see above).


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149481104 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/512#issuecomment-7149481104). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:22:33Z. --- <!-- victory-triage v1 head=829f774722a6b8feab7a88cffd1d635c03b9c81b verdict=needs-work at=2026-11-25T01:22:33Z --> Automated triage for the maintainers. **Needs work.** The fix itself is right: `GetProcAddress` in `crates/victory-hle/src/modules/kernel.rs` refused every ordinal on a pseudo-module handle. The registry already names ordinal exports `#n` (`gameinput.rs` registers `#1`, `net.rs` its `ws2_32` ordinals), and `host_override` already looks ordinals up the same way. Resolving `#n` here makes the dynamic lookup agree with the static import binding. For `ws2_32` this hands out our guarded `net` functions, so the offline guards still apply. What blocks it: CI fails at Clippy (`-D warnings`). In the new test `pseudo_module_ordinals_resolve`, `GetProcAddress(module, 1 as *const u8)` trips `clippy::manual_dangling_ptr`. Use `std::ptr::without_provenance::<u8>(1)` (and `(2)` for the second call), or build the pointer through a `usize` variable. Once CI is green, this would be a merge candidate. Minor: the change to `title_dlls_and_pseudo_modules_are_found_by_name` (non-Windows path) is unrelated to the fix. Please drop it or mention it in the description. CI: failing (Clippy, see above). --- _Generated by [Claude Code](https://claude.ai/code)_
Quat3rnion commented 2026-11-27 02:48:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Quat3rnion on 2026-11-27T02:48:23Z.


Addressed the CI blocker in new head d99845a14: the ordinal test now uses std::ptr::without_provenance instead of a cast integer, and I dropped the unrelated non-Windows path change from the test. cargo clippy --target x86_64-pc-windows-gnu --workspace --all-targets -- -D warnings passes. On the evidence question: the rule mirrors Update::submit's own name matching (blobs.retain(|(n, _)| n != name)), so a second change in one update would otherwise silently overwrite the first. If maintainers prefer preserving last-wins semantics, say so and I will close this. @Marvisak

<!-- greyfinch-sync:Marvisak/VIctory:comment:7208452230 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/512#issuecomment-7208452230). Originally posted by [Quat3rnion](https://github.com/Quat3rnion) on 2026-11-27T02:48:23Z. --- Addressed the CI blocker in new head `d99845a14`: the ordinal test now uses `std::ptr::without_provenance` instead of a cast integer, and I dropped the unrelated non-Windows path change from the test. `cargo clippy --target x86_64-pc-windows-gnu --workspace --all-targets -- -D warnings` passes. On the evidence question: the rule mirrors `Update::submit`'s own name matching (`blobs.retain(|(n, _)| n != name)`), so a second change in one update would otherwise silently overwrite the first. If maintainers prefer preserving last-wins semantics, say so and I will close this. @Marvisak
Quat3rnion commented 2026-11-27 02:48:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Quat3rnion on 2026-11-27T02:48:31Z.


Correction: the last paragraph of my previous comment belongs to PR #590, not this one. For #512 the only changes are the without_provenance fix and dropping the unrelated test edit.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7208454526 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/512#issuecomment-7208454526). Originally posted by [Quat3rnion](https://github.com/Quat3rnion) on 2026-11-27T02:48:31Z. --- Correction: the last paragraph of my previous comment belongs to PR #590, not this one. For #512 the only changes are the `without_provenance` fix and dropping the unrelated test edit.
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/512:upstream-pr/512'
git switch 'upstream-pr/512'

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/512'
git switch 'upstream-pr/512'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/512'
git switch 'upstream-pr/512'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/512'
git switch 'main'
git merge --squash 'upstream-pr/512'
git switch 'main'
git merge --ff-only 'upstream-pr/512'
git switch 'main'
git merge 'upstream-pr/512'
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
Marvisak/VIctory!512
No description provided.