HLE: match host DLLs behind lifecycle and CRT API sets #3310

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

@⁠fuzeofficlal on GitHub · 2026-11-26 16:58 UTC · original
fuzeofficlal:fix/hle-host-dll-overrides → main · +113 −0 · 2 files · 1 commits · open

Summary

Add the backing host DLL names to lifecycle::module() and kernel::module() so GetProcAddress lookups on host-loaded API-set modules (and direct imports from the backing DLLs) reach Victory's HLE overrides:

  • crates/victory-hle/src/modules/lifecycle.rs: add "twinapi.appcore.dll" (backing api-ms-win-core-psm-appnotify-*) and "user32.dll" (backing ext-ms-win-rtcore-ntuser-window-*).
  • crates/victory-hle/src/modules/kernel.rs: add "ucrtbase.dll" (backing api-ms-win-crt-runtime-* for exit, abort, terminate, and _invalid_parameter_noinfo_noreturn; does not collide with files.rs stdio/file exports on ucrtbase.dll).

Root Cause

When a title loads an allowed API set (api-ms-win-core-psm-appnotify-l1-1-0.dll, ext-ms-win-rtcore-ntuser-window-l1-1-0.dll, or api-ms-win-crt-runtime-l1-1-0.dll) via LoadLibraryW/GetModuleHandleW and resolves symbols with GetProcAddress, Windows maps the handle to the backing host DLL (twinapi.appcore.dll, user32.dll, or ucrtbase.dll). kernel::host_override extracts that host filename via GetModuleFileNameW and queries registry::lookup(file, &symbol). Because lifecycle and kernel only listed the API-set patterns, dynamic GetProcAddress lookups (and direct imports from those backing DLLs) bypassed the lifecycle notification/window hooks and CRT termination logging.

Verification

  • Added 6 tests across lifecycle::tests and kernel::tests covering both static HleResolver::classify and live Windows LoadLibraryW + GetProcAddress resolution on all three API sets (confirmed RED 0/6 before the 3-line change, GREEN 6/6 after).
  • cargo test -p victory-hle --locked and --all-features: 158 unit + 2 integration tests passed.
  • cargo clippy -p victory-hle --all-targets --locked -- -D warnings (default and --all-features): clean.
  • cargo test -p xtask --locked policy::tests::repository_passes_policy: passed.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 16:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/3310) `fuzeofficlal:fix/hle-host-dll-overrides` → `main` · +113 −0 · 2 files · 1 commits · open ## Summary Add the backing host DLL names to `lifecycle::module()` and `kernel::module()` so `GetProcAddress` lookups on host-loaded API-set modules (and direct imports from the backing DLLs) reach Victory's HLE overrides: - **`crates/victory-hle/src/modules/lifecycle.rs`**: add `"twinapi.appcore.dll"` (backing `api-ms-win-core-psm-appnotify-*`) and `"user32.dll"` (backing `ext-ms-win-rtcore-ntuser-window-*`). - **`crates/victory-hle/src/modules/kernel.rs`**: add `"ucrtbase.dll"` (backing `api-ms-win-crt-runtime-*` for `exit`, `abort`, `terminate`, and `_invalid_parameter_noinfo_noreturn`; does not collide with `files.rs` stdio/file exports on `ucrtbase.dll`). ## Root Cause When a title loads an allowed API set (`api-ms-win-core-psm-appnotify-l1-1-0.dll`, `ext-ms-win-rtcore-ntuser-window-l1-1-0.dll`, or `api-ms-win-crt-runtime-l1-1-0.dll`) via `LoadLibraryW`/`GetModuleHandleW` and resolves symbols with `GetProcAddress`, Windows maps the handle to the backing host DLL (`twinapi.appcore.dll`, `user32.dll`, or `ucrtbase.dll`). `kernel::host_override` extracts that host filename via `GetModuleFileNameW` and queries `registry::lookup(file, &symbol)`. Because `lifecycle` and `kernel` only listed the API-set patterns, dynamic `GetProcAddress` lookups (and direct imports from those backing DLLs) bypassed the lifecycle notification/window hooks and CRT termination logging. ## Verification - Added 6 tests across `lifecycle::tests` and `kernel::tests` covering both static `HleResolver::classify` and live Windows `LoadLibraryW` + `GetProcAddress` resolution on all three API sets (confirmed RED 0/6 before the 3-line change, GREEN 6/6 after). - `cargo test -p victory-hle --locked` and `--all-features`: 158 unit + 2 integration tests passed. - `cargo clippy -p victory-hle --all-targets --locked -- -D warnings` (default and `--all-features`): clean. - `cargo test -p xtask --locked policy::tests::repository_passes_policy`: passed.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 17:03:23 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 17:07 UTC · original · approved these changes

Reviewed the diff and verified locally on Windows 11 x64:

  • Registering ucrtbase.dll, twinapi.appcore.dll, and user32.dll alongside their API-set patterns cleanly ensures GetProcAddress lookups on host DLLs resolved behind api-ms-win-crt-runtime-*, api-ms-win-core-psm-appnotify-*, and ext-ms-win-rtcore-ntuser-window-* hit the HLE overrides.
  • cargo test -p victory-hle --lib modules::kernel:: -- --test-threads=1: 7 passed, 0 failed.
  • cargo test -p victory-hle --lib modules::lifecycle:: -- --test-threads=1: 16 passed, 0 failed.
  • cargo clippy -p victory-hle --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 17:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/3310#pullrequestreview-6078076905) · **approved these changes** Reviewed the diff and verified locally on Windows 11 x64: - Registering `ucrtbase.dll`, `twinapi.appcore.dll`, and `user32.dll` alongside their API-set patterns cleanly ensures `GetProcAddress` lookups on host DLLs resolved behind `api-ms-win-crt-runtime-*`, `api-ms-win-core-psm-appnotify-*`, and `ext-ms-win-rtcore-ntuser-window-*` hit the HLE overrides. - `cargo test -p victory-hle --lib modules::kernel:: -- --test-threads=1`: 7 passed, 0 failed. - `cargo test -p victory-hle --lib modules::lifecycle:: -- --test-threads=1`: 16 passed, 0 failed. - `cargo clippy -p victory-hle --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠cloph-dsp on GitHub · 2026-11-26 17:08 UTC · original

Independent local verification of PR #3310 — "HLE: match host DLLs behind lifecycle and CRT API sets".

No game data, assets or extracted shaders were used. Windows, Rust/Cargo 1.100.0 (MSVC), repository-pinned toolchain 1.98.1 noted; per-worktree CARGO_TARGET_DIR=D:\Victory-Contrib\target-3310, CARGO_BUILD_JOBS=2. Head verified: 0468c76.

Exact tests (single filtered invocation):
cargo test --locked -p victory-hle --lib -- --exact modules::kernel::tests::ucrtbase_termination_functions_resolve_to_hle modules::kernel::tests::crt_runtime_api_set_lookups_get_our_overrides modules::lifecycle::tests::appcore_notifications_resolve_to_hle modules::lifecycle::tests::user32_window_functions_resolve_to_hle modules::lifecycle::tests::appnotify_api_set_lookups_get_our_overrides modules::lifecycle::tests::ntuser_window_api_set_lookups_get_our_overrides
→ 6 passed, 0 failed, 152 filtered out, exit 0.

git diff --check origin/main HEAD → exit 0.

Negative control: all six test names are absent on the merge base 63bcca43 (git grep -c returned no matches), confirming the tests are added by this PR.

Caveat: these are synthetic API-set lookup tests using real Windows LoadLibraryW/GetProcAddress; no title process or in-game UI was exercised. AI-assisted (Hy4 flash). GPU/driver: N/A (CPU-only HLE).

**@⁠cloph-dsp** on GitHub · 2026-11-26 17:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/3310#issuecomment-7198554121) Independent local verification of PR #3310 — "HLE: match host DLLs behind lifecycle and CRT API sets". No game data, assets or extracted shaders were used. Windows, Rust/Cargo 1.100.0 (MSVC), repository-pinned toolchain 1.98.1 noted; per-worktree `CARGO_TARGET_DIR=D:\Victory-Contrib\target-3310`, `CARGO_BUILD_JOBS=2`. Head verified: `0468c76`. Exact tests (single filtered invocation): `cargo test --locked -p victory-hle --lib -- --exact modules::kernel::tests::ucrtbase_termination_functions_resolve_to_hle modules::kernel::tests::crt_runtime_api_set_lookups_get_our_overrides modules::lifecycle::tests::appcore_notifications_resolve_to_hle modules::lifecycle::tests::user32_window_functions_resolve_to_hle modules::lifecycle::tests::appnotify_api_set_lookups_get_our_overrides modules::lifecycle::tests::ntuser_window_api_set_lookups_get_our_overrides` → 6 passed, 0 failed, 152 filtered out, exit 0. `git diff --check origin/main HEAD` → exit 0. Negative control: all six test names are absent on the merge base `63bcca43` (`git grep -c` returned no matches), confirming the tests are added by this PR. Caveat: these are synthetic API-set lookup tests using real Windows `LoadLibraryW`/`GetProcAddress`; no title process or in-game UI was exercised. AI-assisted (Hy4 flash). GPU/driver: N/A (CPU-only HLE).
This pull request can be merged automatically.
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/3310/head:github-bot/gh-3310'
git switch 'github-bot/gh-3310'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3310'
git switch 'github-bot/gh-3310'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3310'
git switch 'github-bot/gh-3310'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3310'
git switch 'main'
git merge --squash 'github-bot/gh-3310'
git switch 'main'
git merge --ff-only 'github-bot/gh-3310'
git switch 'main'
git merge 'github-bot/gh-3310'
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/Marvisak--VIctory!3310
No description provided.