victory-hle: reject non-null reserved in OEM RegQueryValueExW (#3123) #3407

Open
cloph-dsp wants to merge 1 commit from upstream-pr/3407 into main
cloph-dsp commented 2026-11-26 22:48:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-26T22:48:41Z.


Depends on: #1633

Fixes the closed-unmerged #3123 item: the emulated RegQueryValueExW on the OEM device-type key accepted a non-null lpReserved, which Windows rejects with ERROR_INVALID_PARAMETER.

Change (1 file, victory-hle/src/modules/xsystem.rs): after the non-OEM host-forward branch, return INVALID_PARAMETER (87) when reserved is non-null. Added modules::xsystem::device_type::tests::oem_queries_require_null_reserved, which checks non-null reserved is rejected for both ConsoleMode and an unknown value name with output sentinels unchanged.

Validation (Windows, Rust 1.100.0/MSVC, cargo test --locked, CARGO_BUILD_JOBS=2, per-worktree CARGO_TARGET_DIR): exact test passes, git diff --check clean, negative control: test absent on origin/main.

AI-assisted (Hy4 flash). GPU/driver: N/A (CPU-only synthetic test). No game data used.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5518192129 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3407). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-26T22:48:41Z. --- Depends on: #1633 Fixes the closed-unmerged #3123 item: the emulated `RegQueryValueExW` on the OEM device-type key accepted a non-null `lpReserved`, which Windows rejects with `ERROR_INVALID_PARAMETER`. Change (1 file, victory-hle/src/modules/xsystem.rs): after the non-OEM host-forward branch, return `INVALID_PARAMETER` (87) when `reserved` is non-null. Added `modules::xsystem::device_type::tests::oem_queries_require_null_reserved`, which checks non-null reserved is rejected for both `ConsoleMode` and an unknown value name with output sentinels unchanged. Validation (Windows, Rust 1.100.0/MSVC, `cargo test --locked`, `CARGO_BUILD_JOBS=2`, per-worktree `CARGO_TARGET_DIR`): exact test passes, `git diff --check` clean, negative control: test absent on `origin/main`. AI-assisted (Hy4 flash). GPU/driver: N/A (CPU-only synthetic test). No game data used.
Jackster commented 2026-11-26 23:02:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Jackster on 2026-11-26T23:02:13Z.


Windows 11, 63bcca4 + this PR:

  • cargo test -p victory-hle: lib 153 passed / 0 failed (unpatched 63bcca4 here: 152), plus the integration suite (1 passed).
  • cargo clippy -p victory-hle --all-targets -- -D warnings: clean.

The added test oem_queries_require_null_reserved passes; it is the only change and the rest of the module's tests are unchanged. Synthetic only. AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7205198346 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3407#issuecomment-7205198346). Originally posted by [Jackster](https://github.com/Jackster) on 2026-11-26T23:02:13Z. --- Windows 11, `63bcca4` + this PR: - `cargo test -p victory-hle`: lib 153 passed / 0 failed (unpatched `63bcca4` here: 152), plus the integration suite (1 passed). - `cargo clippy -p victory-hle --all-targets -- -D warnings`: clean. The added test `oem_queries_require_null_reserved` passes; it is the only change and the rest of the module's tests are unchanged. Synthetic only. AI-assisted.
AurumCarlos commented 2026-11-26 23:03:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by AurumCarlos on 2026-11-26T23:03:21Z.

Review: COMMENTED


This brings back the change from #3123, which was closed after the maintainer triage marked it "proposed close: a guard for a case that does not occur" (the emulated OEM key only serves the title's own calls, which pass NULL). fuzeofficlal closed it on that basis.

Unless there's new evidence, such as a title passing a non-null lpReserved there or a call path that triage missed, this is likely to be closed for the same reason. If you have that evidence, please quote it in the description and answer the triage note directly.

<!-- greyfinch-sync:Marvisak/VIctory:review:6081328080 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3407#pullrequestreview-6081328080). Originally posted by [AurumCarlos](https://github.com/AurumCarlos) on 2026-11-26T23:03:21Z. **Review:** COMMENTED --- This brings back the change from #3123, which was closed after the maintainer triage marked it "proposed close: a guard for a case that does not occur" (the emulated OEM key only serves the title's own calls, which pass `NULL`). fuzeofficlal closed it on that basis. Unless there's new evidence, such as a title passing a non-null `lpReserved` there or a call path that triage missed, this is likely to be closed for the same reason. If you have that evidence, please quote it in the description and answer the triage note directly.
fuzeofficlal commented 2026-11-26 23:13:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T23:13:31Z.

Review: APPROVED


LGTM! Verified locally with rustfmt --edition 2024 --check, cargo clippy --locked -p victory-hle --all-targets -- -D warnings, cargo xtask policy, and cargo test --locked -p victory-hle --lib modules::xsystem:: (5/5 passed).

device_type::RegQueryValueExW (crates/victory-hle/src/modules/xsystem.rs:234-236) cleanly returns ERROR_INVALID_PARAMETER (87) for any non-null lpReserved on the synthetic OEM handle before inspecting lpValueName or touching lpType/lpData/lpcbData, while continuing to forward lpReserved to advapi32.dll for host handles.

(Minor non-blocking note: in oem_queries_require_null_reserved, size starts at 4, which matches the DWORD byte count, so a different sentinel like 0 or u32::MAX would also catch unintended writes to lpcbData.)

<!-- greyfinch-sync:Marvisak/VIctory:review:6081384302 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3407#pullrequestreview-6081384302). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T23:13:31Z. **Review:** APPROVED --- LGTM! Verified locally with `rustfmt --edition 2024 --check`, `cargo clippy --locked -p victory-hle --all-targets -- -D warnings`, `cargo xtask policy`, and `cargo test --locked -p victory-hle --lib modules::xsystem::` (5/5 passed). `device_type::RegQueryValueExW` (`crates/victory-hle/src/modules/xsystem.rs:234-236`) cleanly returns `ERROR_INVALID_PARAMETER` (`87`) for any non-null `lpReserved` on the synthetic OEM handle before inspecting `lpValueName` or touching `lpType`/`lpData`/`lpcbData`, while continuing to forward `lpReserved` to `advapi32.dll` for host handles. *(Minor non-blocking note: in `oem_queries_require_null_reserved`, `size` starts at `4`, which matches the `DWORD` byte count, so a different sentinel like `0` or `u32::MAX` would also catch unintended writes to `lpcbData`.)*
Dukestar69 commented 2026-11-27 01:28:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-27T01:28:08Z.

Review: APPROVED


LGTM — verified on Windows:

  • Rejecting non-null lpReserved with ERROR_INVALID_PARAMETER before checking the value name matches Win32 RegQueryValueExW semantics cleanly
  • cargo test -p victory-hle --lib xsystem passed (5/5, including oem_queries_require_null_reserved)
  • cargo clippy -p victory-hle --all-targets -- -D warnings passed with 0 warnings
  • cargo xtask policy passed (191 files ok)

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6082277301 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3407#pullrequestreview-6082277301). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-27T01:28:08Z. **Review:** APPROVED --- LGTM — verified on Windows: - Rejecting non-null `lpReserved` with `ERROR_INVALID_PARAMETER` before checking the value name matches Win32 `RegQueryValueExW` semantics cleanly - `cargo test -p victory-hle --lib xsystem` passed (5/5, including `oem_queries_require_null_reserved`) - `cargo clippy -p victory-hle --all-targets -- -D warnings` passed with 0 warnings - `cargo xtask policy` passed (`191 files ok`) Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3407:upstream-pr/3407'
git switch 'upstream-pr/3407'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3407'
git switch 'upstream-pr/3407'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3407'
git switch 'upstream-pr/3407'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3407'
git switch 'main'
git merge --squash 'upstream-pr/3407'
git switch 'main'
git merge --ff-only 'upstream-pr/3407'
git switch 'main'
git merge 'upstream-pr/3407'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!3407
No description provided.