HLE xsystem: reject non-null lpReserved in emulated RegQueryValueExW #3121

Closed
fuzeofficlal wants to merge 1 commit from upstream-pr/3123 into main
fuzeofficlal commented 2026-11-26 09:07:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T09:07:38Z.


Summary

  • In crates/victory-hle/src/modules/xsystem.rs (device_type::RegQueryValueExW), validate reserved.is_null() at the start of the emulated oem() key path and return ERROR_INVALID_PARAMETER (87) before inspecting value names or writing output buffers (kind, size, data), matching Win32 RegQueryValueExW behavior.
  • Host-forwarded keys remain untouched and pass reserved through to advapi32.dll.
  • Added unit test device_type::tests::oem_queries_require_null_reserved verifying non-null reserved is rejected for both "ConsoleMode" and unknown value names without mutating output sentinels, while null reserved succeeds.

Verification

  • cargo test -p victory-hle --locked -- modules::xsystem::: 5 passed, 0 failed.
  • cargo clippy -p victory-hle --all-targets --locked -- -D warnings: clean.
  • cargo clippy -p victory-hle --all-targets --all-features --locked -- -D warnings: clean.
  • rustfmt --check --edition 2024 --config skip_children=true crates/victory-hle/src/modules/xsystem.rs: clean.
  • cargo test -p xtask --locked policy::tests::repository_passes_policy: 1 passed, 0 failed.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6623229633 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3123). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T09:07:38Z. --- ## Summary - In `crates/victory-hle/src/modules/xsystem.rs` (`device_type::RegQueryValueExW`), validate `reserved.is_null()` at the start of the emulated `oem()` key path and return `ERROR_INVALID_PARAMETER` (`87`) before inspecting value names or writing output buffers (`kind`, `size`, `data`), matching Win32 `RegQueryValueExW` behavior. - Host-forwarded keys remain untouched and pass `reserved` through to `advapi32.dll`. - Added unit test `device_type::tests::oem_queries_require_null_reserved` verifying non-null `reserved` is rejected for both `"ConsoleMode"` and unknown value names without mutating output sentinels, while null `reserved` succeeds. ## Verification - `cargo test -p victory-hle --locked -- modules::xsystem::`: 5 passed, 0 failed. - `cargo clippy -p victory-hle --all-targets --locked -- -D warnings`: clean. - `cargo clippy -p victory-hle --all-targets --all-features --locked -- -D warnings`: clean. - `rustfmt --check --edition 2024 --config skip_children=true crates/victory-hle/src/modules/xsystem.rs`: clean. - `cargo test -p xtask --locked policy::tests::repository_passes_policy`: 1 passed, 0 failed.
Marvisak commented 2026-11-26 10:05:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T09:17:59Z.


Automated triage for the maintainers.

Proposed close: a guard for a case that does not occur. This adds a non-null reserved check to the emulated path of device_type::RegQueryValueExW (crates/victory-hle/src/modules/xsystem.rs) and returns ERROR_INVALID_PARAMETER before the value name is read. As the module comment says, the only caller that reaches the emulated OEM key is the title reading ConsoleMode, and it passes NULL there. Every other key already goes to advapi32.dll with reserved passed through. The check order the test asserts (reserved before the value name, outputs untouched) also comes with no reference. Evidence that a title passes a non-null lpReserved here, together with the host's actual return value and check order, would change this.

CI: check passing.

This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the triage: proposed close label.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7187744112 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3123#issuecomment-7187744112). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T09:17:59Z. --- <!-- victory-triage v1 head=06bd75795d1dd62f36d7d9f5000019e4dbce4a31 verdict=proposed-close at=2026-11-26T09:18:00Z --> Automated triage for the maintainers. **Proposed close: a guard for a case that does not occur.** This adds a non-null `reserved` check to the emulated path of `device_type::RegQueryValueExW` (`crates/victory-hle/src/modules/xsystem.rs`) and returns `ERROR_INVALID_PARAMETER` before the value name is read. As the module comment says, the only caller that reaches the emulated `OEM` key is the title reading `ConsoleMode`, and it passes `NULL` there. Every other key already goes to `advapi32.dll` with `reserved` passed through. The check order the test asserts (reserved before the value name, outputs untouched) also comes with no reference. Evidence that a title passes a non-null `lpReserved` here, together with the host's actual return value and check order, would change this. CI: `check` passing. This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the `triage: proposed close` label. --- _Generated by [Claude Code](https://claude.ai/code)_
cloph-dsp commented 2026-11-26 10:05:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-26T09:27:46Z.


Independent local verification of head 06bd757 on Windows 11, Rust 1.100.0/MSVC:

  • cargo test --locked -p victory-hle --lib modules::xsystem:: — 5 passed, 0 failed (including oem_queries_require_null_reserved and other_keys_reach_the_host).
  • git diff --check origin/main HEAD — clean.

Synthetic registry queries only; no game assets or DRM material used. AI-assisted (Hy4 flash).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7188022729 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3123#issuecomment-7188022729). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-26T09:27:46Z. --- Independent local verification of head `06bd757` on Windows 11, Rust 1.100.0/MSVC: - `cargo test --locked -p victory-hle --lib modules::xsystem::` — 5 passed, 0 failed (including `oem_queries_require_null_reserved` and `other_keys_reach_the_host`). - `git diff --check origin/main HEAD` — clean. Synthetic registry queries only; no game assets or DRM material used. AI-assisted (Hy4 flash).
fuzeofficlal commented 2026-11-26 16:27:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T16:27:25Z.


Closing per triage feedback — the emulated OEM key path only serves valid NULL lpReserved callers, so this extra guard is unnecessary.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7197669467 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3123#issuecomment-7197669467). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T16:27:25Z. --- Closing per triage feedback — the emulated `OEM` key path only serves valid `NULL` `lpReserved` callers, so this extra guard is unnecessary.

Pull request closed

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!3121
No description provided.