HLE: reach the ConsoleMode overrides through kernelbase.dll #2285

Closed
github-bot wants to merge 1 commit from gh-pr/2285/head into gh-pr/2285/base
Owner

@⁠Calvix2k on GitHub · 2026-11-25 09:48 UTC · original
Calvix2k:codex/hle-consolemode-kernelbase-2140 → main · +36 −1 · 1 files · 1 commits · closed without merging

Fixes #2140.

Problem

The emulated HKLM\…\OEM\ConsoleMode value is served by device_type's registry functions, listed only for advapi32.dll and api-ms-win-core-registry-*. On Windows the registry API set loads as kernelbase.dll, and the host policy lets kernelbase.dll through, so a title that imports the registry calls from that DLL (or reaches them through GetProcAddress on it) got the host's functions: the read went to the host registry, which has no ConsoleMode, and the title saw a PC instead of the chosen console.

Change

device_type::module lists kernelbase.dll next to the API set, as kernel and files already do.

Verification

New the_console_mode_lookups_are_reached_through_kernelbase: an HleResolver with HostPolicy::none() classifies RegOpenKeyExW, RegQueryValueExW and RegCloseKey as Hle from kernelbase.dll, advapi32.dll and api-ms-win-core-registry-l1-1-0.dll.

  • With the change: passes.
  • Without the kernelbase.dll entry (checked by removing it locally): fails on kernelbase.dll!RegOpenKeyExW (None vs Some(Hle)), so the test catches exactly this.

cargo test -p victory-hle: 144 lib tests pass; clippy -D warnings clean; cargo xtask policy 1 file ok. No game data.

**@⁠Calvix2k** on GitHub · 2026-11-25 09:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/2285) `Calvix2k:codex/hle-consolemode-kernelbase-2140` → `main` · +36 −1 · 1 files · 1 commits · closed without merging Fixes #2140. ## Problem The emulated `HKLM\…\OEM\ConsoleMode` value is served by `device_type`'s registry functions, listed only for `advapi32.dll` and `api-ms-win-core-registry-*`. On Windows the registry API set loads as `kernelbase.dll`, and the host policy lets `kernelbase.dll` through, so a title that imports the registry calls from that DLL (or reaches them through `GetProcAddress` on it) got the host's functions: the read went to the host registry, which has no `ConsoleMode`, and the title saw a PC instead of the chosen console. ## Change `device_type::module` lists `kernelbase.dll` next to the API set, as `kernel` and `files` already do. ## Verification New `the_console_mode_lookups_are_reached_through_kernelbase`: an `HleResolver` with `HostPolicy::none()` classifies `RegOpenKeyExW`, `RegQueryValueExW` and `RegCloseKey` as `Hle` from `kernelbase.dll`, `advapi32.dll` and `api-ms-win-core-registry-l1-1-0.dll`. - With the change: passes. - Without the `kernelbase.dll` entry (checked by removing it locally): fails on `kernelbase.dll!RegOpenKeyExW` (`None` vs `Some(Hle)`), so the test catches exactly this. `cargo test -p victory-hle`: 144 lib tests pass; clippy `-D warnings` clean; `cargo xtask policy` 1 file ok. No game data.
The emulated `ConsoleMode` value is served by `device_type`'s registry
functions, which were listed only for `advapi32.dll` and the registry API
set. On Windows the API set and `GetModuleHandleW("kernelbase.dll")` both
give `kernelbase.dll`, and the host policy lets that DLL through, so a
title importing (or GetProcAddress-ing) the registry calls by that name
got the host's own functions: the read went to the host registry, found no
value, and the title saw a PC instead of the chosen console.

List `kernelbase.dll` with the other modules that point it out next to
their API sets (kernel, files).

Test: an `HleResolver` with no host pass-through classifies
`RegOpenKeyExW`, `RegQueryValueExW` and `RegCloseKey` as HLE from
`kernelbase.dll`, `advapi32.dll` and the API set name; without the list
entry the test fails on the first `kernelbase.dll` lookup.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:00:55 +00:00
github-bot closed this pull request 2026-11-26 05:00:55 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 13:33 UTC · original

Automated triage for the maintainers.

Proposed close: duplicate of #2141. This PR adds kernelbase.dll to device_type::module().dlls in crates/victory-hle/src/modules/xsystem.rs so the ConsoleMode registry overrides are reached through that DLL. The change is correct, but #2141 (opened earlier, also "Fixes #2140", merges cleanly, CI passing) makes the identical one-line change, and its test goes further: besides HleResolver::classify, it checks that GetProcAddress on kernelbase.dll and on the registry API set returns our functions and reads the chosen ConsoleMode through them. CI (check) passes here too. If something in this PR is not covered by #2141, a review comment there would be the best place for it.

This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the label.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 13:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/2285#issuecomment-7163953884) <!-- victory-triage v1 head=5ff13a057ce62e65c0f540f3f5f0c7b994bca797 verdict=proposed-close at=2026-11-25T13:54:00Z --> Automated triage for the maintainers. **Proposed close: duplicate of #2141.** This PR adds `kernelbase.dll` to `device_type::module().dlls` in `crates/victory-hle/src/modules/xsystem.rs` so the ConsoleMode registry overrides are reached through that DLL. The change is correct, but #2141 (opened earlier, also "Fixes #2140", merges cleanly, CI passing) makes the identical one-line change, and its test goes further: besides `HleResolver::classify`, it checks that `GetProcAddress` on `kernelbase.dll` and on the registry API set returns our functions and reads the chosen ConsoleMode through them. CI (`check`) passes here too. If something in this PR is not covered by #2141, a review comment there would be the best place for it. This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the label. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-25 16:09 UTC · original

Closing as a duplicate of the earlier #2141, as the triage proposes: the identical one-line change, with a test that goes further (GetProcAddress through the API set too). No objection to #2141 going in.

**@⁠Calvix2k** on GitHub · 2026-11-25 16:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/2285#issuecomment-7167640123) Closing as a duplicate of the earlier #2141, as the triage proposes: the identical one-line change, with a test that goes further (GetProcAddress through the API set too). No objection to #2141 going in.
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-25 16:28 UTC · original

Closing as a duplicate of the earlier #2141, as the triage proposes: the identical one-line change, with a test that goes further (GetProcAddress through the API set too). No objection to #2141 going in.

**@⁠Calvix2k** on GitHub · 2026-11-25 16:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/2285#issuecomment-7168049526) Closing as a duplicate of the earlier #2141, as the triage proposes: the identical one-line change, with a test that goes further (`GetProcAddress` through the API set too). No objection to #2141 going in.

Pull request closed

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!2285
No description provided.