HLE: validate XPackage chunk selectors #412

Open
enzoduarte1 wants to merge 1 commit from upstream-pr/412 into main
enzoduarte1 commented 2026-11-24 03:01:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by enzoduarte1 on 2026-11-24T03:01:38Z.


What

IXPackageImpl accepted any selector array and returned success for nonsense the console rejects. This adds the public XPackageChunkSelector ABI (u32 type tag plus the language/tag/chunk-id/feature union) and one validate_selectors helper used by all six selector-taking methods:

  • XPackageCreateInstallationMonitor
  • XPackageFindChunkAvailability
  • XPackageChangeChunkInstallOrder
  • XPackageInstallChunksAsync
  • XPackageEstimateDownloadSize
  • XPackageUninstallChunks

Zero selectors still mean the whole installation. A nonzero count with a null array, an unknown selector type, or a null/empty string attribute now returns E_INVALIDARG. A foreign package id still returns NO_PACKAGE before selector validation. The “own package is completely installed” model is unchanged for well-formed selectors.

The layout and enum values come from the public GDK XPackage.h / XPackageChunkSelector documentation; no title data is involved.

Tested

  • Windows 11, Rust 1.98.1, x86_64-pc-windows-gnu (this machine has no MSVC linker).
  • cargo test -p victory-hle --lib xpackage::tests: 3 passed, including new direct validation and vtable-level tests for every changed method.
  • cargo test -p victory-hle: 88 unit tests + 1 integration test passed.
  • cargo test --workspace --exclude victory-loader -- --test-threads=1: all suites passed.
  • cargo clippy -p victory-hle --all-targets -- -A clippy::field_reassign_with_default -D warnings: clean. The allowed lint is the pre-existing warning fixed in PR #355.
  • rustfmt --edition 2024 --check crates/victory-hle/src/modules/xpackage.rs and git diff --check: clean.
  • cargo xtask policy: 151 files ok. No game files or data taken from them were added.
  • Not tested: cargo test -p victory-loader --test load_probe. Its fixture passes MSVC's /DELAYLOAD flag, which MinGW rejects here; the same failure occurs on unmodified main. A parallel run of the whole suite hit the known WARP flake from #181; rerunning serially and rerunning victory-shader alone both passed.

Checklist

  • cargo fmt, cargo clippy --workspace --all-targets and cargo test --workspace pass — see the toolchain limitations above; the changed crate is clean.
  • cargo xtask policy passes. The change adds no game files or data taken from them (docs/asset-policy.md).
  • If an AI tool wrote part of this change, the description says so: an AI tool assisted with the code and tests; I reviewed and ran them.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6573642765 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/412). Originally posted by [enzoduarte1](https://github.com/enzoduarte1) on 2026-11-24T03:01:38Z. --- ## What `IXPackageImpl` accepted any selector array and returned success for nonsense the console rejects. This adds the public `XPackageChunkSelector` ABI (`u32` type tag plus the language/tag/chunk-id/feature union) and one `validate_selectors` helper used by all six selector-taking methods: - `XPackageCreateInstallationMonitor` - `XPackageFindChunkAvailability` - `XPackageChangeChunkInstallOrder` - `XPackageInstallChunksAsync` - `XPackageEstimateDownloadSize` - `XPackageUninstallChunks` Zero selectors still mean the whole installation. A nonzero count with a null array, an unknown selector type, or a null/empty string attribute now returns `E_INVALIDARG`. A foreign package id still returns `NO_PACKAGE` before selector validation. The “own package is completely installed” model is unchanged for well-formed selectors. The layout and enum values come from the public GDK `XPackage.h` / `XPackageChunkSelector` documentation; no title data is involved. ## Tested - Windows 11, Rust 1.98.1, `x86_64-pc-windows-gnu` (this machine has no MSVC linker). - `cargo test -p victory-hle --lib xpackage::tests`: 3 passed, including new direct validation and vtable-level tests for every changed method. - `cargo test -p victory-hle`: 88 unit tests + 1 integration test passed. - `cargo test --workspace --exclude victory-loader -- --test-threads=1`: all suites passed. - `cargo clippy -p victory-hle --all-targets -- -A clippy::field_reassign_with_default -D warnings`: clean. The allowed lint is the pre-existing warning fixed in PR #355. - `rustfmt --edition 2024 --check crates/victory-hle/src/modules/xpackage.rs` and `git diff --check`: clean. - `cargo xtask policy`: 151 files ok. No game files or data taken from them were added. - Not tested: `cargo test -p victory-loader --test load_probe`. Its fixture passes MSVC's `/DELAYLOAD` flag, which MinGW rejects here; the same failure occurs on unmodified `main`. A parallel run of the whole suite hit the known WARP flake from #181; rerunning serially and rerunning `victory-shader` alone both passed. ## Checklist - [ ] `cargo fmt`, `cargo clippy --workspace --all-targets` and `cargo test --workspace` pass — see the toolchain limitations above; the changed crate is clean. - [x] `cargo xtask policy` passes. The change adds no game files or data taken from them (`docs/asset-policy.md`). - [x] If an AI tool wrote part of this change, the description says so: an AI tool assisted with the code and tests; I reviewed and ran them.
mercuryVM commented 2026-11-24 06:52:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T06:19:05Z.

Review: APPROVED


Tested d2c7d4a on Windows 11, RTX 5070, MSVC: cargo test --workspace --no-fail-fast passes (266 passed, 0 failed).

  • ChunkSelector matches the public layout: a u32 tag, padded to 8, then an 8-byte union. Reading the tag as u32 instead of a Rust enum is the right way to reject unknown values safely. The count overflow guard before from_raw_parts is good.
  • The foreign-package check still runs before selector validation, as the description says.
  • One behaviour change not in the description: XPackageInstallChunksAsync with a foreign id used to complete the async block with NO_PACKAGE (finished_with(.., Err(NO_PACKAGE))). It now returns NO_PACKAGE from the call without completing the block. That matches the XAsync rule that a failed begin call does not complete, so I think it is correct. Still, a title that waits on the block after ignoring the begin HRESULT would now wait forever. Worth a line in the description.
  • "The console rejects empty attributes" is not something I can check here. It is plausible, and it only affects malformed calls.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6034584619 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/412#pullrequestreview-6034584619). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T06:19:05Z. **Review:** APPROVED --- Tested d2c7d4a on Windows 11, RTX 5070, MSVC: `cargo test --workspace --no-fail-fast` passes (266 passed, 0 failed). - `ChunkSelector` matches the public layout: a `u32` tag, padded to 8, then an 8-byte union. Reading the tag as `u32` instead of a Rust enum is the right way to reject unknown values safely. The `count` overflow guard before `from_raw_parts` is good. - The foreign-package check still runs before selector validation, as the description says. - One behaviour change not in the description: `XPackageInstallChunksAsync` with a foreign id used to *complete the async block* with `NO_PACKAGE` (`finished_with(.., Err(NO_PACKAGE))`). It now returns `NO_PACKAGE` from the call without completing the block. That matches the XAsync rule that a failed begin call does not complete, so I think it is correct. Still, a title that waits on the block after ignoring the begin HRESULT would now wait forever. Worth a line in the description. - "The console rejects empty attributes" is not something I can check here. It is plausible, and it only affects malformed calls. AI-assisted (Claude Code).
jeremygold02 commented 2026-11-24 06:55:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-24T04:36:05Z.


Thanks @enzoduarte1 for validating chunk selectors across the XPackage API. I tested head d2c7d4a329abb59d669867c5b5020776eb7963a9 with:

cargo test --locked -p victory-hle --lib xpackage::tests:: -- --test-threads=1

Result: 3 passed, 0 failed (85 filtered out). The tests cover selector validation, malformed selectors being refused through the API, and the unchanged complete-installation behavior for valid requests. This validates the synthetic HLE object cases, not a title package installation.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7122168305 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/412#issuecomment-7122168305). Originally posted by [jeremygold02](https://github.com/jeremygold02) on 2026-11-24T04:36:05Z. --- Thanks @enzoduarte1 for validating chunk selectors across the XPackage API. I tested head `d2c7d4a329abb59d669867c5b5020776eb7963a9` with: ``` cargo test --locked -p victory-hle --lib xpackage::tests:: -- --test-threads=1 ``` Result: 3 passed, 0 failed (85 filtered out). The tests cover selector validation, malformed selectors being refused through the API, and the unchanged complete-installation behavior for valid requests. This validates the synthetic HLE object cases, not a title package installation.
Marvisak commented 2026-11-25 01:08:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:32:03Z.


Automated triage for the maintainers.

Needs rebase. This PR does not merge cleanly into current main (4118f33b). Conflicting files: crates/victory-hle/src/modules/xpackage.rs.

The content will be reviewed once the branch is rebased onto main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148605781 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/412#issuecomment-7148605781). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:32:03Z. --- <!-- victory-triage v1 head=d2c7d4a329abb59d669867c5b5020776eb7963a9 verdict=needs-rebase at=2026-11-25T00:24:46Z --> Automated triage for the maintainers. **Needs rebase.** This PR does not merge cleanly into current `main` (4118f33b). Conflicting files: `crates/victory-hle/src/modules/xpackage.rs`. The content will be reviewed once the branch is rebased onto `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
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/412:upstream-pr/412'
git switch 'upstream-pr/412'

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/412'
git switch 'upstream-pr/412'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/412'
git switch 'upstream-pr/412'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/412'
git switch 'main'
git merge --squash 'upstream-pr/412'
git switch 'main'
git merge --ff-only 'upstream-pr/412'
git switch 'main'
git merge 'upstream-pr/412'
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!412
No description provided.