[PR #152] runtime: answer the console-type registry key (ConsoleMode) from LEONIDA_DEVICE_TYPE #204

Open
opened 2026-11-26 20:17:07 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/152
Author: @Andretuta
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: old-pr/9884


📝 Commits (1)

  • dab4112 runtime: answer the console-type registry key (ConsoleMode) from LEONIDA_DEVICE_TYPE

📊 Changes

5 files changed (+139 additions, -2 deletions)

View changed files

📝 runtime/CMakeLists.txt (+2 -0)
📝 runtime/README.md (+1 -1)
➕ runtime/shims/advapi32_registry.cpp (+85 -0)
📝 runtime/shims/registry.cpp (+1 -1)
📝 runtime/test/xgameruntime_test.cpp (+50 -0)

📄 Description

Carried over from old PR 9884 by AwkGrep256 in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9884, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
AwkGrep256: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

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: https://github.com/ItsNotRexed/Leonida/issues/6750#issuecomment-7105596665 (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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/152 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `old-pr/9884` --- ### 📝 Commits (1) - [`dab4112`](https://github.com/ubiquitarianism/leonida/commit/dab41122066cad1141f6b5b6dc3046354a752914) runtime: answer the console-type registry key (ConsoleMode) from LEONIDA_DEVICE_TYPE ### 📊 Changes **5 files changed** (+139 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `runtime/CMakeLists.txt` (+2 -0) 📝 `runtime/README.md` (+1 -1) ➕ `runtime/shims/advapi32_registry.cpp` (+85 -0) 📝 `runtime/shims/registry.cpp` (+1 -1) 📝 `runtime/test/xgameruntime_test.cpp` (+50 -0) </details> ### 📄 Description > Carried over from **old PR 9884** by `AwkGrep256` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9884`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `AwkGrep256`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): 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: https://github.com/ItsNotRexed/Leonida/issues/6750#issuecomment-7105596665 (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](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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
starred/leonida#204
No description provided.