HLE: registry lookups through kernelbase.dll reach the device-type overrides #2141
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2141
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2141"
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?
@BastienRodz on GitHub · 2026-11-25 05:54 UTC · original
BastienRodz:hle/kernelbase-registry→main· +88 −1 · 1 files · 1 commits · openWhat's wrong
xsystem::device_typeserves the console'sOEM\ConsoleModeregistry value, but its module only listsadvapi32.dllandapi-ms-win-core-registry-*.GetProcAddresson a host module resolves our overrides by the module's file name (kernel::host_override), and on Windows both the registry API set andkernelbase.dllitself arekernelbase.dll. SoGetProcAddress(LoadLibraryW("api-ms-win-core-registry-l1-1-0.dll"), "RegOpenKeyExW")returns the host's function, and the title reads the host registry instead of the emulated key. Imports straight fromkernelbase.dllgo to the host too.kernel::module()andfiles::module()already listkernelbase.dllnext to their API sets for this reason.What the fix does
Adds
kernelbase.dlltodevice_type::module().dlls. Nothing else changes: other keys still reach the host through the existing fallthrough.Tests
New
modules::xsystem::device_type::tests::kernelbase_registry_lookups_get_our_overrides:HleResolver::classify("kernelbase.dll", …)givesHleforRegOpenKeyExW,RegQueryValueExWandRegCloseKey;GetProcAddressonGetModuleHandleW("kernelbase.dll")and onLoadLibraryW("api-ms-win-core-registry-l1-1-0.dll")returns our functions, and readingConsoleModethrough them gives the chosen model.On
main(940d32f) it fails at the first check (left: Some(Host),right: Some(Hle)); with the classify check removed, theGetProcAddresscheck fails as well (host address instead of ours). With the fix the test and the rest ofmodules::xsystem::,modules::kernel::andregistry::pass (Wine 10, x86_64-pc-windows-msvc).windows-latest run on the fork: https://github.com/BastienRodz/VIctory/actions/runs/45556724719
Not tested
No title run. Per AgneyaK's check of the title's import table, Grand Theft Auto VI 1.0.2.1 binds
RegOpenKeyW/RegQueryValueExW/RegCloseKeyfromadvapi32.dll(already served) and its only run-time registry lookup isadvapi32.dll!RegGetValueWfor a GDK setting, so this change does not affect that title. It only makes thekernelbase.dll/ API-set path agree with theadvapi32.dllone.Fixes #2140
AI-assisted (Gemini 4 Neon found and wrote it, Claude Code reviewed and verified it). No game data used.
🤖 Generated with Claude Code
@AgneyaK on GitHub · 2026-11-25 06:13 UTC · original
For scope: Grand Theft Auto VI 1.0.2.1 doesn't take this path, so the PR changes nothing for it. It's still right in principle for other titles. From the title's own import table and code (image
b99f876b…):ADVAPI32.dll→RegOpenKeyW,RegQueryValueExW,RegCloseKey, and nothing fromkernelbase.dllor the registry API sets. TheConsoleModeread goes through those, whichdevice_typealready serves (device type readat debug level).RegGetValueW. At+0x55e27b4it callsLoadLibraryExA("advapi32.dll", 0, 0x800)and thenGetProcAddress(…, "RegGetValueW"). The only caller (+0x55e286c) readsHKLM\Software\Microsoft\GamingServices→ForceUseLocalServices(RRF_RT_REG_DWORD). That's GDK library code, not the console model. It's onadvapi32.dll, notkernelbase.dll, andRegGetValueWisn't one ofdevice_type's exports, so it reaches the host with or without this PR. On a PC that value is normally absent, so the check reads false.So nothing in this title reaches the emulated key through
kernelbase.dllorGetProcAddress. The PR is a correct guard for titles that do; it just won't show up in a Grand Theft Auto VI run.AI use: Claude Code (Claude Opus 5.5) read the title's import table and disassembled the image locally; no game data beyond addresses, import names and two registry names the title's library code uses.
@BastienRodz on GitHub · 2026-11-25 06:15 UTC · original
Thanks for checking the import table, that answers the open question in "Not tested". I've updated the description: the title binds
RegOpenKeyW/RegQueryValueExW/RegCloseKeyfromadvapi32.dll, whichdevice_typealready serves, so this PR doesn't change anything for it. What it does is makekernelbase.dlland the registry API set behave likeadvapi32.dllfor lookups by name, the same waykernelandfilesalready handle it. Whether that's worth carrying is the maintainer's call.@kotekompotek on GitHub · 2026-11-25 07:31 UTC · original
Verified locally on Windows (MSVC, pinned 1.98.1): the new test
kernelbase_registry_lookups_get_our_overridespasses, and it covers both lookup paths from the issue — directkernelbase.dllimports viaHleResolver::classify, andGetProcAddresson bothkernelbase.dlland theapi-ms-win-core-registry-l1-1-0.dllhandle (whose file name resolves to kernelbase.dll inhost_override).Checked for export collisions:
kernelandfilesmodules also servekernelbase.dllbut export noReg*names, soregistry::lookup's first match is unambiguous.@Marvisak on GitHub · 2026-11-25 10:52 UTC · original
Automated triage for the maintainers.
Merge candidate. This adds
kernelbase.dlltoxsystem::device_type::module().dlls. With it,GetProcAddresson kernelbase or the registry API set (whichkernel::host_overrideresolves by the module's file name,kernelbase.dll) reaches ourReg*overrides.kernelandfilesalready list kernelbase for the same reason, and no other module exportsReg*names, soregistry::lookupis unambiguous. The test covers bothclassifyandGetProcAddress. CI passes.Note that AgneyaK's import-table check shows Grand Theft Auto VI 1.0.2.1 does not take this path. The change only makes the kernelbase path behave like the
advapi32.dllone.Generated by Claude Code
@fuzeofficlal on GitHub · 2026-11-26 01:41 UTC · original
Code review and Windows 11 verification at head
92d75e4d6db5merged cleanly ontomain(63bcca43c6a0):crates/victory-hle/src/modules/xsystem.rs:270-285, 435-515):"kernelbase.dll"todevice_type::module().dllsshares the exact same 4 registry exports (RegOpenKeyW,RegOpenKeyExW,RegQueryValueExW,RegCloseKey) asadvapi32.dllandapi-ms-win-core-registry-*, while non-overridden keys continue forwarding throughhost!("advapi32.dll", ...)without re-entering HLEkernelbase.dll.registry::tests::export_names_are_unique_per_dll_patternpasses with zero export collisions acrosskernelbase.dllHLE modules.cargo xtask policy:191 files ok;cargo clippy --locked -p victory-hle --tests -- -D warnings: 0 warningscargo test --locked -p victory-hle -- --test-threads=1: 155/155 passed (includingkernelbase_registry_lookups_get_our_overrides).LGTM.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.