Skip to content

runtime: answer the console-type registry key (ConsoleMode) from LEONIDA_DEVICE_TYPE - #9884

Open
AwkGrep256 wants to merge 1 commit into
ProjectLeonida:mainfrom
AwkGrep256:console-mode-registry
Open

AwkGrep256 wants to merge 1 commit into
ProjectLeonida:mainfrom
AwkGrep256:console-mode-registry

Conversation

@AwkGrep256

Copy link
Copy Markdown
Contributor

Resubmitted unchanged: this was #6990, closed at the repository's move to the organisation (the members-only switch, 22:25–22:49 UTC) with no review comment; reopening it is refused. Same branch and head (dab411220), which merges cleanly on main 7e39a81ea. The test reports from other contributors are on #6990.

Claimed in the coordination issue as part of: #6750 (comment) (FSR in the Series X render path; this is its first, standalone step and also matters for RT-5).

What and why

The retail executable does not ask XSystemGetDeviceType for its console type. It reads the registry: RegOpenKeyW(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows NT\CurrentVersion\OEM"), then the REG_DWORD ConsoleMode, and maps the value itself (a static look at my own copy, nothing executed; RegOpenKeyW, RegQueryValueExW and RegCloseKey are its only advapi32.dll imports, and that query is RegOpenKeyW's only caller):

ConsoleMode XSystemDeviceType
key or value missing 1 Pc
0x60 6 XboxScarlettLockhart (Series S)
0x64 7 XboxScarlettAnaconda (Series X)
0x68 8 XboxScarlettDevkit
0x58 / 0x50 / 0x40 5 / 4 / 3 (Xbox One X devkit, One X, One S)
0x10, 0x20, 0x21, 0x30, 0x31 2 XboxOne
anything else 0 Unknown

A PC has no such key, so under gta6rt the title saw Pc while XSystemGetDeviceType (and LEONIDA_DEVICE_TYPE) said Series X. One thing that hangs on it: the title picks its upscaler from it. Series S gets AMD's FFX upscaler (the amd_fidelityfx_loader_xbox.dll path), every other type the title's own.

The change

  • runtime/shims/advapi32_registry.cpp (new): RegOpenKeyW, RegQueryValueExW and RegCloseKey answer that one key from XSystemGetDeviceType, looked up in the shim table, so the two can't disagree: 0x64 by default, 0x60 with LEONIDA_DEVICE_TYPE=6, no key for 1 (Pc), as the title's mapping reads them back. The key and value names match case-insensitively. Every other key goes to the host's registry.
  • runtime/shims/registry.cpp: advapi32.dll joins the host DLLs (owns_dll) like kernel32 and user32, so its other names (and the package DLLs' advapi32 imports) still bind to the host's.
  • runtime/README.md: the LEONIDA_DEVICE_TYPE row says the registry follows it.

Tested

Windows cross-build (clang-cl + xwin), run under Wine 11 on CachyOS:

  • xgameruntime_test: OK, 153 checks. New: the three names are shims and advapi32.dll stays a host DLL; ConsoleMode is 0x64 by default and 0x60 with LEONIDA_DEVICE_TYPE=6; 1 gives no key; case-insensitive key; a size query gives 4; a 2-byte buffer gets ERROR_MORE_DATA and 4; another value is ERROR_FILE_NOT_FOUND; another key opens and closes in the host's registry.
  • ctest -R "loader|pe_loader|xmem|process_cmdline|winhttp_offline|run_tiny|xgameruntime": 30 of 31 pass. run_tiny_game_abort_exit_codes fails the same way on main 1cc6e3c1 under Wine (native abort exit codes), so it's unrelated.
  • Not run: the title's --run (it doesn't reach the query yet on Linux), native Windows.

Nothing from the executable is in the repository or here: only the import names, the public registry path the GDK uses, and the value mapping.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

…IDA_DEVICE_TYPE

The title reads its console type from HKLM\Software\Microsoft\Windows NT\
CurrentVersion\OEM, value ConsoleMode, not from XSystemGetDeviceType. A PC
has no such key, so the title saw Pc while the xgameruntime shim reported
Series X. advapi32.dll's RegOpenKeyW, RegQueryValueExW and RegCloseKey now
answer that one key from XSystemGetDeviceType (LEONIDA_DEVICE_TYPE, default
Series X: 0x64); advapi32.dll stays a host DLL, so every other key and
name reaches the host's registry. xgameruntime_test checks it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant