Repository navigation
Conversation
…ype reads A title does not import XSystemGetDeviceType: xgameruntime.lib links it in, and that copy opens HKLM\Software\Microsoft\Windows NT\CurrentVersion\OEM and reads the DWORD ConsoleMode; a missing key or value means PC. The package's XCurl.dll and libHttpClient.GDK.dll both carry it. No shim served those registry calls, so they reached the host, which has no such key, and the title was told it runs on a PC whatever the shim's export or LEONIDA_DEVICE_TYPE said. RegOpenKeyW, RegOpenKeyExW, RegQueryValueExW and RegCloseKey are now served under advapi32.dll and the two registry API sets those DLLs import them by. They answer that one key with the ConsoleMode of the device type the export reports and pass every other key, root and handle to the host. advapi32.dll stays a host module. xgameruntime_test runs the title's sequence against the registry functions the loader would bind. docs: the sequence in runtime_imports.md; an entry for xvalkyrie. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Contributor
|
Tested 42f3708 on Windows 11, MSVC (VS 2022 Build Tools) RelWithDebInfo, with RTX 5080 (driver 616.92) and AMD Radeon iGPU gfx1036 (driver 26.10.1) each selected in turn (
No negative control run. AI-assisted. |
|
Tested 42f3708 on Windows 11 (26300), RX 9070 (AMD 26.11.1), VS 2022 Build Tools, RelWithDebInfo with SDL3: pass Full AI-assisted |
This was referenced Nov 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claim (new RT item, no ID assigned yet)
AI-assisted (Claude Code). I ran everything under "Tested" on Windows.
Problem
runtime/shims/xgameruntime.cppexportsXSystemGetDeviceType(Series X, orLEONIDA_DEVICE_TYPE). A title never calls that export.xgameruntime.liblinks the function into the title, and that copy asks the registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\OEM;ConsoleModeand closes the key;XSystemDeviceType. If the key or the value is missing, its answer is PC.The package's own
XCurl.dllandlibHttpClient.GDK.dllboth carry that function (read statically; nothing was run). The first importsRegOpenKeyW,RegQueryValueExWandRegCloseKeyfromapi-ms-win-core-registry-l1-1-0.dlland-l2-1-0.dll, the second fromadvapi32.dll.No shim served those calls, so they went to the host, where that key does not exist. The title's function therefore answered PC, whatever the shim's export or
LEONIDA_DEVICE_TYPEsaid. The new test prints what the sequence returns against the host's registry before it runs: 1 (PC) on this machine.Other layers: sammwyy/xvalkyrie (GPL-3.0) describes the same read in
docs/research/gdk-titles.mdand reports a retail title that indexes a jump table with the result and crashes on the PC value. ivall/xcl (crates/xcl/src/hle/kernelx.rs, GPL-2.0-only) and omonkeyz/xbox-emulator (crates/compat/compat-common/src/gdk/hook.rs, GPL-3.0) answer the same key; those two share lineage, so together they are one reading, and xvalkyrie is a separate code base. Facts only, and the code is my own. I read xcl's source (GPL-2.0-only) while working on this, so please check the provenance.Change
xgameruntime.cppservesRegOpenKeyW,RegOpenKeyExW,RegQueryValueExWandRegCloseKeyunder the three DLL names above. For that one key (any case, separators around it tolerated) they answer a pseudo-key whose only value is the DWORDConsoleMode, set from the device type the export reports. Every other key, root and handle goes to the host's function unchanged.LEONIDA_DEVICE_TYPEnow reaches the title: 2..8 pick the matchingConsoleMode; 1 (PC) leaves the key to the host, which is how a PC answers (on a machine that really has that key, the title then reads the host's value); 0 answers a value the title does not know.registry.cpp:advapi32.dlljoins the host modules of which only a few functions are replaced, so a title'sLoadLibrary("advapi32.dll")still gets the host module and not a pseudo-handle. That list feedsowns_dllfor every caller; nothing registeredadvapi32.dllnames before, and the fullctestrun below shows nothing relied on the old answer.docs/runtime_imports.md: a section describing the read.docs/related_projects.md: an entry for xvalkyrie.Not done:
RegGetValueW, the ANSI forms, and the enumeration and subkey functions (RegEnumValueW, an open with the pseudo-key as its root) are not served, because neither DLL imports them for this read. Given the pseudo-key, the host's function answersERROR_INVALID_HANDLE. If the executable reads the key another way,--dry-runshows the import.Test
xgameruntime_testgainstest_console_mode_registry. It has a stand-in for the title's function (open, query with a 4-byte buffer, close, map the value) and runs it against the registry functions the loader would bind:LEONIDA_DEVICE_TYPE2..8; with 1 it reads 1 through the host (checked only when the host has no such key, which the test asks the host first);REG_DWORD, 4 bytes),ERROR_MORE_DATAfor a short buffer,ERROR_FILE_NOT_FOUNDfor any other value name, and closes;HKLMkey opened through the shim returns the sameCurrentBuildbytes as the host does directly; a key that merely ends inOEM, and the same path underHKEY_CURRENT_USER, are the host's;advapi32.dllis not a module the shims own.Tested
Windows 11 (build 26200), MSVC 19.44.35222, Visual Studio's CMake and
ctest3.31.6 with Ninja, RelWithDebInfo, built byscripts/build_runtime.ps1. Basef847748c(main).xgameruntime_testwith the new test onmain's shims: 1 of 95 checks failed (the twelve registry names do not resolve; the test stops there, after printing that the sequence answers 1 against the host's registry). With the change: OK, 110 checks.gta6rt --dry-runon my own copy of the two DLLs: the four registry imports of each are nowshim(XCurl.dllshim=28 host=112,libHttpClient.GDK.dllshim=30 host=168, 0 unimplemented).ctest --test-dir runtime/build -C RelWithDebInfowithLEONIDA_GAME_DIRset, on this head: 140 run, 134 passed, 6 skipped, 0 failed (gameinputis disabled, no SDL3 here). NVIDIA GeForce RTX 4090, driver 32.0.16.2114, for the Vulkan tests in that run; this change needs no GPU.python -Iontests/test_docs_links.py,test_docs_repo_paths.py,test_docs_list_items.py,test_docs_design_rows.py,test_i18n_index.py: OK.Overlap: several open PRs add runtime classes to
xgameruntime.cpp(#3363, #3408, #3476, #3505, #3550, #3657). This adds one block afterXSystemGetDeviceTypeand its own small shim table, apart from the class tables and the big export table. #3601 (mine) adds adocs/related_projects.mdentry in a different place.🤖 Generated with Claude Code