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

Closed
Andretuta wants to merge 1 commit from upstream-pr/152 into main
Andretuta commented 2026-11-24 02:29:49 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Andretuta on 2026-11-24T02:29:49Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5464955469 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/152). Originally posted by [Andretuta](https://github.com/Andretuta) on 2026-11-24T02:29:49Z. --- > 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)
CLHelper commented 2026-11-24 16:08:05 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by CLHelper on 2026-11-24T16:08:05Z.


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://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7137168441).

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7137172926 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/152#issuecomment-7137172926). Originally posted by [CLHelper](https://github.com/CLHelper) on 2026-11-24T16:08:05Z. --- 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://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7137168441). AI-assisted.
MoonEyes commented 2026-11-30 19:27:12 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T19:27:12Z.


This is not merge-ready: it remains a draft and mergeStateStatus is DIRTY; all current checks are cancelled. Please rebase/resolve the conflict with main and obtain green current-base Windows/runtime and CI checks before requesting review. The reported retail boot used a manually applied patch on a different branch, so it is supporting evidence, not validation of this PR head.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7289417111 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/152#issuecomment-7289417111). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-30T19:27:12Z. --- This is not merge-ready: it remains a draft and `mergeStateStatus` is `DIRTY`; all current checks are cancelled. Please rebase/resolve the conflict with `main` and obtain green current-base Windows/runtime and CI checks before requesting review. The reported retail boot used a manually applied patch on a different branch, so it is supporting evidence, not validation of this PR head.
aslan2142 commented 2026-12-01 12:11:46 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T12:11:46Z.


Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review.

(AI-assisted triage.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7310787591 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/152#issuecomment-7310787591). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T12:11:46Z. --- Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review. *(AI-assisted triage.)*
aslan2142 commented 2026-12-01 16:26:13 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:26:13Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7317602630 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/152#issuecomment-7317602630). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:26:13Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
ProjectLeonida/mandy!152
No description provided.