fix(loader): share forwarder resolution with dynamic GetProcAddress #234

Merged
brainbudt merged 1 commit from upstream-pr/234 into main 2026-11-27 02:33:58 +00:00
brainbudt commented 2026-11-27 02:18:51 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by brainbudt on 2026-11-27T02:18:51Z.


Summary

When a title DLL exported a symbol forwarded to a host or HLE DLL (for example KERNEL32.SetLastError), static import binding resolved the forwarded target through the launch resolver, while dynamic GetProcAddress only looked up the target DLL in the title-DLL registry and returned NULL.

Changes

  • Share TitleDll::resolve_export and the launch NATIVE_TITLE_RESOLVER (preserving --strict / host policy) between static import binding and dynamic GetProcAddress.
  • Preserve provenance so title-DLL targets return their mapped addresses directly while host/HLE targets receive a title-callable win64 bridge.
  • Replace the fixed recursion depth with a flat loop + seen-set cycle check so cyclic or missing forwarders return NULL with ERROR_PROC_NOT_FOUND.
  • Extend the native probe DLL and tests to verify static + dynamic forwarded host/HLE calls, title-to-title aliases, cycles, and missing targets, and update docs/native-host.md.

Verification

  • cargo test -j4 -p victory-loader (16 passed, 3 ignored)
  • cargo test -p victory-hle --target x86_64-apple-darwin --lib modules::kernel (2 passed)
  • cargo clippy -j4 -p victory-loader -p victory-hle --all-targets --target x86_64-pc-windows-gnullvm -- -D warnings
  • cargo xtask policy
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:5520052538 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/234). Originally posted by [brainbudt](https://github.com/brainbudt) on 2026-11-27T02:18:51Z. --- ### Summary When a title DLL exported a symbol forwarded to a host or HLE DLL (for example `KERNEL32.SetLastError`), static import binding resolved the forwarded target through the launch resolver, while dynamic `GetProcAddress` only looked up the target DLL in the title-DLL registry and returned `NULL`. ### Changes - Share `TitleDll::resolve_export` and the launch `NATIVE_TITLE_RESOLVER` (preserving `--strict` / host policy) between static import binding and dynamic `GetProcAddress`. - Preserve provenance so title-DLL targets return their mapped addresses directly while host/HLE targets receive a title-callable win64 bridge. - Replace the fixed recursion depth with a flat loop + seen-set cycle check so cyclic or missing forwarders return `NULL` with `ERROR_PROC_NOT_FOUND`. - Extend the native probe DLL and tests to verify static + dynamic forwarded host/HLE calls, title-to-title aliases, cycles, and missing targets, and update `docs/native-host.md`. ### Verification - `cargo test -j4 -p victory-loader` (16 passed, 3 ignored) - `cargo test -p victory-hle --target x86_64-apple-darwin --lib modules::kernel` (2 passed) - `cargo clippy -j4 -p victory-loader -p victory-hle --all-targets --target x86_64-pc-windows-gnullvm -- -D warnings` - `cargo xtask policy`
LakshanSivakumar commented 2026-11-27 02:33:55 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T02:33:55Z.

Review: APPROVED


Reviewed and tested together with the other open PRs on main (macOS x86_64 workspace tests, the setup shell tests, and Windows clippy). Thanks!

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:review:6082739240 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/234#pullrequestreview-6082739240). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-27T02:33:55Z. **Review:** APPROVED --- Reviewed and tested together with the other open PRs on main (macOS x86_64 workspace tests, the setup shell tests, and Windows clippy). Thanks!
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
LakshanSivakumar/Native-Victory-macOS!234
No description provided.