HLE: RegOpenKeyW/RegOpenKeyExW with a null or empty subkey fail on the emulated OEM key (fix on a fork) #765
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 Marvisak/VIctory. Originally posted by Peppacodes on 2026-11-24T09:55:10Z.
What's wrong
open()incrates/victory-hle/src/modules/xsystem.rs:185-187returnsERROR_FILE_NOT_FOUNDfor every open below our stand-in forHKLM\Software\Microsoft\Windows NT\CurrentVersion\OEM. That includes a null or empty subkey. BothRegOpenKeyWandRegOpenKeyExWgo through it.Microsoft's docs:
RegOpenKeyW,lpSubKey: if it is NULL or points to an empty string, the function returns the same handle that was passed in.RegOpenKeyExW: with a NULL or emptylpSubKeyon a key that isn't predefined,phkResultreceives a new handle to the key.The host does both. I checked on
HKLM\Software\Microsoft\Windows NT\CurrentVersion.The impact is low. As the code's comment says, the title opens the full path and queries
ConsoleMode. This only matters for code that opens the key again this way.Repro
After
RegOpenKeyW(HKLM, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\OEM", &k)succeeds:RegOpenKeyW(k, NULL, &k2)returns 2. Expected: 0, withk2 == k.RegOpenKeyExW(k, L"", 0, KEY_READ, &k3)returns 2. Expected: 0.Fix
8e9f9b3, rebased onmain(ffe310e), 0 commits behind it. One file, with its test.What changed:
RegCloseKeyalready accepts.phkResultthere getsERROR_INVALID_PARAMETER(87), which is what the host returns.Test
a_null_or_empty_path_opens_the_key_itself, inxsystem.rs'sdevice_typetests:main(left: 2,right: 0) and passes with the fix.Results on Windows 11 with Rust 1.98.1, using the CI's own commands:
cargo test --workspace --locked: 343 passed, 0 failed, 6 ignored.cargo clippy --workspace --all-targets --locked -- -D warnings, with and without--all-features: clean.rustfmt --edition 2024 --check xsystem.rs: clean.cargo xtask policy: 154 files ok.Not changed: the path must match
KEYexactly, apart from case. The host also accepts a trailing or doubled backslash.PR creation is limited to collaborators right now, so this is an issue with the branch. I can open a PR when it reopens.
No game files used. AI use: Claude Code (Claude Opus 5.5) found this in an audit of the HLE modules, wrote the fix and the test, and ran everything above.
Imported from Marvisak/VIctory. Originally posted by nopsled0x on 2026-11-24T14:09:24Z.
I checked
fix/oem-key-empty-subkey(8e9f9b3, on top offfe310e) on Windows 10, debug build:cargo test -p victory-hle --locked -- xsystem: 5 passed, 0 failed, includingdevice_type::tests::a_null_or_empty_path_opens_the_key_itself.cargo clippy -p victory-hle --all-targets --locked -- -D warnings: clean.phkResultthere getsERROR_INVALID_PARAMETER.is(sub, "")is never reached with a null pointer, becausesub.is_null()short-circuits first. I found no new panic path inside theextern "system"functions, andRegCloseKeyaccepts the pseudo handle without calling the host.phkResult, the code returnsERROR_FILE_NOT_FOUNDbefore looking at the output pointer. I believe the host checks the pointer first, but I did not verify that.Not verified:
cargo test --workspace,--features diagnostics,cargo xtask policy,rustfmt, workspace-wide clippy, whether these tests compile on non-Windows targets, or in-game behavior.AI-assisted verification (Claude); tests were run locally by me.
Imported from Marvisak/VIctory. Originally posted by MamaLeVrai on 2026-11-24T19:42:22Z.
@Peppacodes your fix for this issue is now in a pull request, #1603, together with the three others of yours (#762, #764, #765, #832): the branches are merged as they are, with your commits and your name unchanged, onto
mainffe310e. Clippy (both runs) andcargo test --workspacepass on the result. If you would rather open your own pull request for this one, say so and I will take it out of #1603. AI-assisted (Claude Code); no game data.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T03:51:12Z.
Automated triage for the maintainers.
Still confirmed on current
main(940d32f):openincrates/victory-hle/src/modules/xsystem.rsreturnsERROR_FILE_NOT_FOUNDfor every open whose root is the emulated OEM key, including a null or empty subkey. BothRegOpenKeyWandRegOpenKeyExWgo through it. The impact is low, as the report says, because the title opens the full path.No open pull request carries this change now. #1431 was closed without being merged, and the bundle #1603 is not open. Pull requests are open to everyone, so please open one from
fix/oem-key-empty-subkey(8e9f9b3), rebased on currentmain. It already has a regression test,a_null_or_empty_path_opens_the_key_itself. The point raised above, that a nullphkResultwith a non-empty subkey returnsERROR_FILE_NOT_FOUNDbefore the pointer is checked, can be settled in that pull request.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by Dathinel on 2026-11-25T07:26:45Z.
Following up on the request to compare with #1431: its author closed it without merging after the triage comment here. The Windows regression test passed. The outstanding evidence is a caller reopening an already-open OEM key with a null or empty subkey. An initial open of the full key path would exercise a different operation.
AI-assisted follow-up based on the public review history.