Skip to content

kernelx: GetConsoleType follows the device type, and ConsoleMode answers through RegGetValue - #3671

Open
Prime1997 wants to merge 2 commits into
xcl-dev:mainfrom
Prime1997:contrib/up-console-type-follow
Open

Prime1997 wants to merge 2 commits into
xcl-dev:mainfrom
Prime1997:contrib/up-console-type-follow

Conversation

@Prime1997

Copy link
Copy Markdown
Collaborator

Requested by Prime

With XCL_DEVICE_TYPE=lockhart (Series S), the registry and XSystemGetDeviceType told the title it ran on a Series S, but GetConsoleType returned console_type_raw from xcl.toml, which is written as 6 by default whatever device_type says. In the kernel's order (Xbox One 1 ... One X devkit 4, Lockhart 5, Anaconda 6) 6 is a Series X, so the title was told both. In a Series S test run on an RTX 3060 Ti the title still made many 3840x2160 render targets. Also, the GDK thunk behind XSystemGetDeviceType reads HKLM\...\OEM ConsoleMode, and XCL answered it only through RegOpenKeyW, RegOpenKeyExW and RegQueryValueExW; a thunk that used RegGetValueW or the ANSI functions reached the PC registry and was told "PC". Now the written default (6, or 0) follows device_type: 5 on a Series S, 6 on a Series X. Any other configured value is kept. RegGetValueW/A, RegOpenKeyExA, RegOpenKeyA and RegQueryValueExA give the same ConsoleMode answer as the W functions. The value 5 is inferred from the kernel's order, not documented.

Related: #3564 documents XCL_DEVICE_TYPE in the README; this change makes GetConsoleType agree with it.

What is in it

  • crates/xcl/src/hle/kernelx.rs: GetConsoleType follows device_type for the written default (decided once and logged); RegGetValueW/A, RegOpenKeyExA, RegOpenKeyA and RegQueryValueExA answer the OEM key's ConsoleMode with Windows' rules for flags, buffer size, RRF_ZEROONFAILURE and unknown values; every other key goes to the real registry. Unit tests for both.
  • crates/xcl/src/config.rs: the console_type_raw doc comment says how the value is chosen now.
  • crates/xcl/src/resolver.rs: a test that the new functions resolve to kernelx through advapi32, advapi32legacy and the api-ms-win-core-registry API sets.

Two commits: the GetConsoleType change, then the registry functions on top of it.

Tested

  • RTX 3060 Ti 8 GB, Windows 11, release build: the change has been in our test builds since 30 Nov (no measured before/after on its own).
  • This branch (on main 1c8b551): cargo check -p xcl --lib --tests --target x86_64-pc-windows-gnu passes. The test suite was not run on this exact branch.

Regression run

  • Not run yet: testers welcome.

Not tested

  • The suite and scripts/smoke.ps1 on this branch; AMD.
  • A title whose thunk actually uses RegGetValueW or the ANSI functions: we have only seen the W functions used.
  • That 5 is the Series S value on a real console.

Switches

  • XCL_CONSOLE_TYPE_FOLLOW (default on): =0 makes GetConsoleType return xcl.toml's console_type_raw as before, and the new registry hooks forward everything to the PC registry.
  • XCL_CONSOLE_TYPE_RAW=<n> (default unset; decimal or 0x hex): GetConsoleType returns <n> over everything.

AI use

  • Claude Code wrote the change and this description.

🤖 Generated with Claude Code

Prime1997 and others added 2 commits December 2, 2026 05:25
GetConsoleType returned xcl.toml's console_type_raw, written as 6 by
default, whatever device_type said. In the kernel's order (Xbox One 1 ...
One X devkit 4, Lockhart 5, Anaconda 6) 6 is a Series X, so under
XCL_DEVICE_TYPE=lockhart the title was told a Series S by the registry
and XSystemGetDeviceType and a Series X by GetConsoleType. A lockhart
test run still made many 3840x2160 render targets.

The written default (6, or 0) now follows device_type: 5 on a Series S,
6 on a Series X. Any other configured value was set on purpose and is
kept. XCL_CONSOLE_TYPE_RAW=<n> forces a value over everything.
XCL_CONSOLE_TYPE_FOLLOW=0 returns xcl.toml's value as before. The value
is decided once and logged ("kernelx: GetConsoleType -> 5 (...)"), as is
the switch. 5 is inferred from the kernel's order, not documented.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The GDK thunk behind XSystemGetDeviceType reads HKLM\...\OEM ConsoleMode.
XCL answered it only through RegOpenKeyW, RegOpenKeyExW, RegQueryValueExW
and RegCloseKey, the functions seen so far. A thunk that uses RegGetValueW
or the A functions reached the PC registry, found no OEM key and was told
"PC", whatever XCL_DEVICE_TYPE said.

RegGetValueW/A, RegOpenKeyExA, RegOpenKeyA and RegQueryValueExA now give
the same answer. RegGetValue follows Windows' rules: RRF_RT_* must allow a
REG_DWORD (else ERROR_UNSUPPORTED_TYPE), data without a size is
ERROR_INVALID_PARAMETER, a small buffer gets ERROR_MORE_DATA and the size,
RRF_ZEROONFAILURE zeroes the buffer on failure, and a subkey of the OEM
handle or another value name is ERROR_FILE_NOT_FOUND. Every other key and
value goes to the real registry. RegCloseKey already accepts the OEM
handle. The functions are routed through advapi32, advapi32legacy and the
api-ms-win-core-registry API sets.

XCL_CONSOLE_TYPE_FOLLOW=0 (logged once with the GetConsoleType change)
makes the new hooks forward everything, as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Prime1997 Prime1997 self-assigned this Dec 2, 2026
@github-actions github-actions Bot added the area:hle kernelx, XGameRuntime, XAudio2, VFS, PE loader, TLS, EH label Dec 2, 2026
@Foniass

Foniass commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Review (head 57f41be, diff read, not a merge-check; checks red):

  • PR description check is red. It refuses the PR because Regression run has no xcl-smoke block, neither one from this head nor one from main. This PR changes the runtime, so it needs both. Tested also lists only a cargo check with the x86_64-pc-windows-gnu target. The suite never ran on a GPU on this branch.
  • Two logical changes and two new switches in one PR. Commit 1 is the actual fix: GetConsoleType now follows device_type. Commit 2 adds RegGetValueW/A, RegOpenKeyA, RegOpenKeyExA and RegQueryValueExA hooks (kernelx.rs ~3136-3193), but the description says no title was seen calling them. Those hooks now handle every title's ANSI and RegGetValue registry calls. Both env switches are extra knobs on top. Per CONTRIBUTING, the GetConsoleType fix should be its own PR. The registry hooks should come in a separate PR once a title needs them, and the switches each in their own PR.
  • XCL_CONSOLE_TYPE_FOLLOW controls two unrelated things. console_type_follow() (kernelx.rs ~2889) chooses where GetConsoleType gets its value. It also turns the new registry hooks on or off. As a result, getting xcl.toml's raw value back also switches the new ConsoleMode paths back to the PC registry. Separately, XCL_CONSOLE_TYPE_RAW (~2925) duplicates console_type_raw in xcl.toml, which already sets this value.
  • An explicit console_type_raw = 0 is overwritten. console_type_for (kernelx.rs ~2913) treats 0 the same as the written default and returns 5 or 6 instead. Config::default() (config.rs ~167) has written 6 since the first commit, and no version wrote 0. So a 0 can only be one the user set on purpose. Overwriting it contradicts the config doc ("any other value is returned as set") and the test message "a value set on purpose is kept". Either drop the 0 case or explain where a written 0 comes from.
  • Claims in the description are not measured. The 3840x2160 render-target observation is offered as the motivation, but there is no before/after measurement for this change. The value 5 for Series S is inferred, not checked. Any Series S run now gets 5 instead of 6, so if that guess is wrong, the title sees a console type it does not know.

Fine (by reading):

  • The default answer is unchanged for the default config (anaconda, 6). Only Series S changes, from 6 to 5.
  • ConsoleMode already followed device_type on main.
  • The hook signatures match the Win32 prototypes.
  • RegGetValue handling looks right:
    • A size query with null pvData returns 0 and *pcbData = 4.
    • A too-small buffer gives ERROR_MORE_DATA with the needed size.
    • Data without a size, or no RRF_RT_* bits, gives ERROR_INVALID_PARAMETER.
    • RRF_ZEROONFAILURE zeroes the caller's original size.
  • Only HKLM\...\OEM, or its handle with no subkey, is answered. Every other key is forwarded with the caller's own pointers.
  • The resolver test covers the API-set names.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

@Foniass

Foniass commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

merge-check
base: 1c8b551
head: 57f41be
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2911 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read by one reviewer at this same head; the review is at #3671 (comment) and its findings stand. Most serious: two changes plus two env switches, and an explicit console_type_raw = 0 is overwritten.
performance: 60 s smoke of a retail title, main 1c8b551 vs this merge (57f41be): 1652 -> 1681 frames shown (101 %; last presents per 2 s: 60 60 61), peak commit 18228 -> 17358 MB, 0 device removals, 0 crashes.
verdict: not yet: two changes plus two env switches, and an explicit console_type_raw = 0 is overwritten (see the review); the merge passes the whole suite on current main and the smoke run is clean
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

AI-written and posted by Foniass without a human check of each point.

@Prime1997 Prime1997 added the test-only A maintainer reviewed the diff: tests only, no smoke run needed for this revision (CONTRIBUTING.md) label Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:hle kernelx, XGameRuntime, XAudio2, VFS, PE loader, TLS, EH test-only A maintainer reviewed the diff: tests only, no smoke run needed for this revision (CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants