HLE: a null or empty subkey opens the emulated OEM key itself (#765) #2392
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!2392
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2392"
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?
@KainanP on GitHub · 2026-11-25 12:39 UTC · original
KainanP:fix/oem-key-empty-subkey-765→main· +68 −3 · 1 files · 2 commits · openFixes #765.
This carries Peppacodes' fix from the issue (branch
fix/oem-key-empty-subkey,8e9f9b3), cherry-picked unchanged onto currentmainwith their name kept on the commit, plus one commit of mine that settles the open point from the thread (a nullphkResultwith a non-empty subkey). The earlier PRs for this (#1431 and the bundle #1603) were closed without being merged, and no open PR covers it.Problem.
openincrates/victory-hle/src/modules/xsystem.rsreturnedERROR_FILE_NOT_FOUNDfor any open whose root is our emulated OEM key, including a null or empty subkey. Microsoft documents that case as opening the key itself: forRegOpenKeyW, "If this parameter is NULL or a pointer to an empty string, the function returns the same handle that was passed in"; forRegOpenKeyExW,phkResult"receives a new handle to the opened key" (the same handle for a predefined key).Change
c76edcc(Peppacodes): a null or empty subkey under the OEM key gives back the OEM key; any other subkey is still not found (the key has none).7955705(mine): the nullphkResultcheck now comes before the path check, so a non-empty subkey with nowhere to put the key returnsERROR_INVALID_PARAMETER, notERROR_FILE_NOT_FOUND. Microsoft's pages do not name the error for a nullphkResult, so the test asks the host'sadvapi32the same calls on a host key and holds ours to the host's answers. On Windows 11 (build 26200) the host returnsERROR_INVALID_PARAMETER(87) for a nullphkResultwhether the subkey is missing, empty or null.Tests (both in
device_type::tests, Windows only, like the module)a_null_or_empty_path_opens_the_key_itself(Peppacodes):RegOpenKeyWandRegOpenKeyExWwith a null and an empty subkey, on our key and on a host key for comparison.nowhere_to_put_the_key_is_an_invalid_parameter(new): a nullphkResultwith a missing, an empty and a null subkey, on our key and the host's, then a missing subkey with a realphkResultis stillERROR_FILE_NOT_FOUND.With
openas onmain, both fail:left: 2, right: 0andleft: 2, right: 87. With only Peppacodes' commit, the new test fails on the missing subkey (2, not 87). With both commits, both pass.Checked on Windows 11 x64,
main940d32f+ these two commits:cargo test -p victory-hle --locked: 145 passed, 0 failed (plus the 3 integration tests)cargo clippy --workspace --all-targets --locked -- -D warningsand the--all-featuresvariant: cleancargo xtask policy: asset policy, 182 files okrustfmt --edition 2024 --checkon the changed file: cleanNot covered: in-game behavior (the title opens the full path, as the issue says, so this does not change what it reads); a caller reopening an already-open OEM key with a null or empty subkey is exercised only by the unit test. #2285 (open) touches the same module's DLL list, not
open; the two do not overlap.No game data used. AI use: Claude Code (Claude Opus 5.5).
🤖 Generated with Claude Code
@cloph-dsp on GitHub · 2026-11-25 13:00 UTC · original
Independent local verification (Windows, Rust 1.100.0/MSVC, head
7955705, no game data):cargo test --locked -p victory-hle --lib modules::xsystem::device_type::tests-> 4 tests passed on this PR (a_null_or_empty_path_opens_the_key_itself,nowhere_to_put_the_key_is_an_invalid_parameter,other_keys_reach_the_host,titles_read_the_chosen_model), exit 0; the same command on main940d32fruns 2 tests (titles_read_the_chosen_model,other_keys_reach_the_host), confirming this PR adds the two null/empty-path and invalid-parameter cases. Only a pre-existingfetch_updatedeprecation warning. I did not exercise a real title registry path. AI-assisted (Hy4 flash). GPU/driver: N/A (CPU-only unit tests). No game data used.@Marvisak on GitHub · 2026-11-25 15:00 UTC · original
Automated triage for the maintainers.
Merge candidate.
device_type::open(crates/victory-hle/src/modules/xsystem.rs) now opens the emulated OEM key itself for a null or empty subkey, as Microsoft documents forRegOpenKeyW/RegOpenKeyExW. It also returnsERROR_INVALID_PARAMETERfor a nullphkResultbefore looking at the path. Other subkeys still giveERROR_FILE_NOT_FOUND. I checked thatRegCloseKeyin the same module already treats the OEM pseudo-key as ours, so closing the returned handle is safe. The tests hold our answers to the hostadvapi32's for the same calls on a real key, which is the evidence for the error code the documentation does not name. It carries the issue author's commit with their name kept.As the description says, the title opens the full path, so this is API correctness rather than a visible fix.
CI:
checkpassing.Generated by Claude Code
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.