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

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

@⁠Andretuta on GitHub · 2026-11-24 02:29 UTC · original
ubiquitarianism:old-pr/9884 → main · +139 −2 · 5 files · 1 commits · draft

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

**@⁠Andretuta** on GitHub · 2026-11-24 02:29 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/152) `ubiquitarianism:old-pr/9884` → `main` · +139 −2 · 5 files · 1 commits · draft > 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)
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 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:46:35 +00:00
Author
Owner

@⁠CLHelper on GitHub · 2026-11-24 16:08 UTC · original

Tested (retail boot, native Windows): native Windows 11, MSVC 19.44, RTX 4060 Laptop (NVIDIA 576.80), own 1.0.2.1 copy. I applied this pull request's three pieces (advapi32_registry.cpp from dab411220, its CMake line and advapi32.dll in owns_dll) by hand on @⁠DadaCap's boot-prototype fa497b930, since this branch conflicts with main.

  • The title's RegOpenKeyW, RegQueryValueExW and RegCloseKey imports bind to these shims (gta6rt's import listing); without them they bind to the host.
  • With the default (LEONIDA_DEVICE_TYPE unset, so 0x64, Series X) the boot takes the same path as without the shims: no early int3, the same twelve XMem allocations (sizes and page counts), the window up and PresentX running (2,937 against 3,374 without), and both runs end at the same later stop, which is unrelated to this change.
  • Not measured: 0x60 (LEONIDA_DEVICE_TYPE=6) and the upscaler choice the description mentions.

This also answers the warning in #14 against setting ConsoleMode: it was measured with a raw 6, which this table maps to Unknown (#14).

AI-assisted.

**@⁠CLHelper** on GitHub · 2026-11-24 16:08 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/152#issuecomment-7137172926) Tested (retail boot, native Windows): native Windows 11, MSVC 19.44, RTX 4060 Laptop (NVIDIA 576.80), own 1.0.2.1 copy. I applied this pull request's three pieces (`advapi32_registry.cpp` from `dab411220`, its CMake line and `advapi32.dll` in `owns_dll`) by hand on @⁠DadaCap's `boot-prototype` `fa497b930`, since this branch conflicts with `main`. - The title's `RegOpenKeyW`, `RegQueryValueExW` and `RegCloseKey` imports bind to these shims (gta6rt's import listing); without them they bind to the host. - With the default (`LEONIDA_DEVICE_TYPE` unset, so `0x64`, Series X) the boot takes the same path as without the shims: no early `int3`, the same twelve XMem allocations (sizes and page counts), the window up and `PresentX` running (2,937 against 3,374 without), and both runs end at the same later stop, which is unrelated to this change. - Not measured: `0x60` (`LEONIDA_DEVICE_TYPE=6`) and the upscaler choice the description mentions. This also answers the warning in #14 against setting `ConsoleMode`: it was measured with a raw `6`, which this table maps to Unknown (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14). AI-assisted.
This pull request has changes conflicting with the target branch.
  • runtime/CMakeLists.txt
  • runtime/README.md
  • runtime/shims/registry.cpp
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/152/head:github-bot/gh-152'
git switch 'github-bot/gh-152'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-152'
git switch 'github-bot/gh-152'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-152'
git switch 'github-bot/gh-152'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-152'
git switch 'main'
git merge --squash 'github-bot/gh-152'
git switch 'main'
git merge --ff-only 'github-bot/gh-152'
git switch 'main'
git merge 'github-bot/gh-152'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.