runtime: add an opt-in console profile for the OEM ConsoleMode read #2642
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2650"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-26T00:26:38Z.
Change
Slice 4 of 4 from #2591: the opt-in profile.
X2W_DEVICE_TYPE(withX2W_RUNTIME_PROXY=1) answers the title's reads ofHKLM\Software\Microsoft\Windows NT\CurrentVersion\OEM\ConsoleMode:671Unset, every call goes to the real registry as before.
console_mode.hholds the value table and recognises the key and value.registry_console_mode.inlholds hooks forRegOpenKeyExW,RegOpenKeyW,RegQueryValueExW,RegGetValueWandRegCloseKey. They answer only a ConsoleMode read under the OEM key while theswitch names a known console. Every other call is passed through. Opening the key and reading the
value are logged a few times either way.
runtime_gpa_patch.h:visit_imports_withtakes a classifier, so the proxy can rewrite theregistry imports of the EXE and package helpers.
visit_importskeeps its old behaviour.runtime_proxy.cpppatches those imports and returns the hooks fromGetProcAddressby name.The switch changes only what the registry reads answer. On the Series S profile, the path a title
then takes meets desktop refusals that the other profiles do not reach. Those are separate slices:
device slot 76 and view dimensions.
R9G9B9E5_SHAREDEXPwith unordered access is already covered onmain. This slice claims nothing about what runs after the profile is chosen.Refs #2591. Independent of the other three slices. Comparing a combined start-up build needs all four.
Verification
Build: this branch, one commit
bac83cb2onmainat02368737. From the worktree in PowerShell:. .\tools\dev.ps1,cmake --preset release,cmake --build --preset release(Python envout/pe-envfromrequirements-dev.txt).Environment: NVIDIA GeForce RTX 5090, driver 32.0.16.1088, Windows 10.0.26200.9974. The fixture
creates no device and replaces the registry functions with fakes, so no machine state is read or
changed.
ctest --preset release --no-tests=error -R '^startup_(console_mode(_control)?|runtime_gpa_patch(_name_only_control)?|runtime_proxy_scope.*)$' -V: 5/5 passed (startup_console_modeand its control, which prints 5FAIL:lines;startup_runtime_gpa_patchand itsname_onlycontrol;startup_runtime_proxy_scope).ctest --preset release -j 6 --no-tests=error -R '^startup_' -E '_hardware$|^startup_audio_': 640 tests, 633 passed, 6 skipped (capability, exit 77), 1 failed:startup_storage_worker_starttimed out at 60 s under-j 6; rerun alone (ctest --preset release --no-tests=error -R '^startup_storage_worker_start$') it passed in 13.9 s, as on the slice-1 build (14.0 s). This change does not touch it.python -B tests/docs_links_check.py: pass (19 Markdown files, 509 links).python -B tests/bidi_controls_check.py: pass.git diff --check origin/main...HEAD: clean.Evidence
startup_console_mode(from #2591, unchanged) reaches the hooks throughGetProcAddress, the way atitle does, against fake registry functions that report the value missing:
6and7: answer 0x60 and 0x64 without calling the fake.1: answers missing.--controlleavesX2W_DEVICE_TYPEunset for the answered cases, so those rows printFAIL:. Thetest is registered with
PASS_REGULAR_EXPRESSION "FAIL: ". The existingstartup_runtime_gpa_patchand its
name_onlycontrol pass unchanged, which shows the classifier refactor keeps the proxy's ownimport walk the same.
Hypothesis: what the
ConsoleModevalues mean on the console comes from public notes, not from ameasurement here. With a local console executable (not included), each value changed which start-up
path the title took (#2591).
Checklist
This change was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T00:32:30Z.
Review: COMMENTED
Review of head
bac83cb2against main (comment only).Code read:
console_mode.h,registry_console_mode.inl, theruntime_gpa_patch.hclassifier change, theruntime_proxy.cppwiring, andtests/startup_console_mode_check.cpp.visit_imports_withrefactor keepsvisit_importsunchanged: it passes the old classifier through. The existingstartup_runtime_gpa_patchtests cover that.GetProcAddresslike a title would, and uses fake registry functions. It has a negative control (--control,PASS_REGULAR_EXPRESSION "FAIL: "). So the "source-built regression test plus negative control" requirement is met.oem_keysholds 16 handles. When it is full, a further OEM key is not tracked and its reads go to the real registry. That is a safe fallback, but a log line when it happens would help.Commands run locally on the exact head:
python3 -B tests/docs_links_check.py,python3 -B tests/bidi_controls_check.py,git diff --check origin/main...HEAD: all clean.<windows.h>, so it does not build on Linux. I could not run it or a mutation of it here, and I did not run Win2025. The test results in the PR body are the author's.Merge: the PR says that, with a local console executable, each value changed which start-up path the title took (#2591). This is a start-up claim from running the game, and I cannot check it. I am not merging this. The merge stays with MasterDomino or @R0Y00, who can verify on the game.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T00:43:01Z.
Review: CHANGES_REQUESTED
The registry hooks currently match function name alone on both routes.
patch_registry_importsignores the imported DLL argument, andhooked_get_proc_addresspasses only the export name and address intoregistry_hook_for. Becauseremember_registrysaves the first address globally, a package DLL exporting the same name can change which implementation later calls reach, even withX2W_DEVICE_TYPEunset. Please restrict both routes to the supported Windows registry providers, preserving the existing provider identity checks on the other proxy hooks. Add a source-built decoy DLL or synthetic IAT provider with the same export name and distinct result to verify the decoy is untouched, including with the switch unset.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T01:36:10Z.
Review: APPROVED
Re-reviewed the bound-address plus system-module checks for IAT and GetProcAddress at
0ac58f7b. Windows Release passed six targeted CTests, including the real loaded runtime-proxy host. The decoy kept its sentinel with the switch unset and with X2W_DEVICE_TYPE=7. The genuine advapi32 lookup reached the system registry, and both the registry name-only mutant and the original provider-scope mutant were detected. This resolves my provider-identity finding. The startup behavior remains an opt-in experiment.Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-26T01:07:37Z.
@R0Y00 thanks, addressed in
0ac58f7b(new commit on top ofbac83cb2, no rebase).Both routes are now limited to the Windows registry providers (
src/startup_stubs/registry_console_mode.inl)patch_registry_imports): an import is classified only if its DLL name isadvapi32.dll,kernelbase.dll,kernel32.dllorapi-ms-win-core-registry-*(any case). On top of that, the bound slot address must lie in the system-directory copy of advapi32/kernelbase/kernel32 (GetModuleHandleExW(FROM_ADDRESS), then compared withGetModuleHandleW(<system dir>\<name>)). That way a package DLL that has the same name, or sits behind a provider-named import, does not match.registry_hook_for(module, name, real)now takes the HMODULE. It returns a hook only when that module is one of those system modules, sohooked_get_proc_addressreturns the original export for any other module.remember_registryrefuses any address outside those modules, so a decoy can never become the remembered implementation, whetherX2W_DEVICE_TYPEis set or not.GetProcAddressfrom any module, andQueryApiImpl/InitializeApiImpl*only fromxgameruntime.dll.startup_runtime_gpa_patch(_name_only_control)passes as before.Decoy coverage
startup_console_mode_decoy.dll(tests/startup_console_mode_decoy.cpp/.def). It exportsRegOpenKeyExWandRegQueryValueExWreturning0x5EC0, which no registry returns, plus a call counter.startup_console_mode --decoy <dll>runs the decoy checks before the fake registry is registered, so a name-only match would keep the decoy first. The checks run with the switch unset and again withX2W_DEVICE_TYPE=7:0x5EC0and counts.advapi32.dllentry bound to the decoy, are left untouched; a call through the decoy's slot reaches the decoy. Only theadvapi32.dllentries bound to the fixture's registry are rewritten (2 of 5).ERROR_FILE_NOT_FOUND, decoy counter unchanged).startup_console_mode_provider_control(--control provider) matches registry imports by name alone and must printFAIL:. The decoy checks fail in both passes. The existingstartup_console_mode_controlis unchanged.startup_runtime_proxy_scope(real loader, proxy carrier) uses its existing decoy DLL, which now also exportsRegQueryValueExW. With the switch unset and set: the host'sGetProcAddress(decoy, "RegQueryValueExW")stays the decoy's export and returns its own result, whileGetProcAddress(advapi32, ...)is hooked and returns advapi32's own answer, with no decoy call.startup_console_modefailed (35 checks, all decoy checks in both passes) andstartup_runtime_proxy_scopefailed (4 mismatches: decoy lookup hooked and hook reaching the decoy, in both passes). After restoring the source both pass.tedin7's note: when all 16
oem_keysslots are in use, one line... 16 OEM key handles already open, another is not trackedis logged once. It is covered instartup_console_mode.docs/startup-runtime.md(Console profile) now describes the provider rule and the new control.Commands and results (commit
0ac58f7b; NVIDIA GeForce RTX 5090, driver 32.0.16.1088, Windows 10.0.26200.9974, D3D12 debug layer off; none of the tests below use the GPU)6/6 passed:
startup_runtime_gpa_patch,startup_runtime_gpa_patch_name_only_control,startup_console_mode,startup_console_mode_control,startup_console_mode_provider_control(both controls printFAIL:as required),startup_runtime_proxy_scope.640/641 passed, plus 6 not run (skip/disabled):
startup_view_heap_warp,startup_gameinput_script_syntax,startup_sharedexp_target_warp,startup_small_texture_4k_addrlib,startup_logical_view_warp,startup_run_sh.startup_inflatetimed out under-j 6. Run alone (ctest --preset release --no-tests=error -R '^startup_inflate$'), it passes in 9.6 s. It does not touch the registry code.This change was AI-assisted.