HLE: XSystemGetXboxLiveSandboxId refuses a buffer under 16 bytes #939

Open
LouisRiverstone wants to merge 2 commits from upstream-pr/939 into main
LouisRiverstone commented 2026-11-24 14:21:51 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by LouisRiverstone on 2026-11-24T14:21:51Z.


Fixes #862.

XSystemGetXboxLiveSandboxId documents XSystemXboxLiveSandboxIdMaxBytes (16) as the minimum buffer and returns HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) below it. We only checked the 7 bytes "RETAIL\0" needs, so a 7–15 byte buffer succeeded here and failed on console.

sandbox_id now returns E_NOT_SUFFICIENT_BUFFER when size < 16, before put_string. put_string is unchanged.

Verify: cargo test -p victory-hle xsystem. The new test a_sandbox_id_buffer_under_the_documented_minimum_is_refused checks that sizes 7 and 15 are refused and leave the buffer alone, and that size 16 gives S_OK with used = 7.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:6583916547 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/939). Originally posted by [LouisRiverstone](https://github.com/LouisRiverstone) on 2026-11-24T14:21:51Z. --- Fixes #862. `XSystemGetXboxLiveSandboxId` documents `XSystemXboxLiveSandboxIdMaxBytes` (16) as the minimum buffer and returns `HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)` below it. We only checked the 7 bytes `"RETAIL\0"` needs, so a 7–15 byte buffer succeeded here and failed on console. `sandbox_id` now returns `E_NOT_SUFFICIENT_BUFFER` when `size < 16`, before `put_string`. `put_string` is unchanged. **Verify:** `cargo test -p victory-hle xsystem`. The new test `a_sandbox_id_buffer_under_the_documented_minimum_is_refused` checks that sizes 7 and 15 are refused and leave the buffer alone, and that size 16 gives `S_OK` with `used = 7`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
DenRakEiw commented 2026-11-24 15:03:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T14:24:06Z.

Review: APPROVED


Tested head d4306f4 (fast-forward on main ffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC):

  • cargo test -p victory-hle: 95 passed, 0 failed (plus no_dll_planting: 1 passed)
  • cargo clippy -p victory-hle --all-targets: 0 warnings
  • cargo xtask policy: ok

Clean fix enforcing the 16-byte minimum buffer size for XSystemGetXboxLiveSandboxId. Approving.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6040965132 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/939#pullrequestreview-6040965132). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T14:24:06Z. **Review:** APPROVED --- Tested head `d4306f4` (fast-forward on `main` `ffe310e`) on Windows 11 x64 (Rust 1.98.1 MSVC): - `cargo test -p victory-hle`: **95 passed, 0 failed** (plus `no_dll_planting`: 1 passed) - `cargo clippy -p victory-hle --all-targets`: **0 warnings** - `cargo xtask policy`: ok Clean fix enforcing the 16-byte minimum buffer size for `XSystemGetXboxLiveSandboxId`. Approving. AI-assisted (Gemini 4 Neon).
dcastell1 commented 2026-11-24 15:04:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by dcastell1 on 2026-11-24T14:35:09Z.


Verified on native Windows (no Wine): NVIDIA GeForce RTX 5090 (driver 621.24), Windows 11 10.0.26300, Rust 1.98.1, MSVC 14.44.35207, debug build. main@ffe310e baseline on this box: 342 passed, 0 failed, 6 ignored.

cargo test --workspace
343 passed; 0 failed; 6 ignored   (exit 0)

One more than the baseline; XSystemGetXboxLiveSandboxId refusing a short buffer is covered and green.

Tree restored afterwards (full diff against a clean checkout); no game data, the tests are synthetic. AI-assisted (opencode): applied the patch to a built tree, ran cargo test --workspace, reverted it.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7134616529 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/939#issuecomment-7134616529). Originally posted by [dcastell1](https://github.com/dcastell1) on 2026-11-24T14:35:09Z. --- Verified on native Windows (no Wine): NVIDIA GeForce RTX 5090 (driver 621.24), Windows 11 10.0.26300, Rust 1.98.1, MSVC 14.44.35207, debug build. `main@ffe310e` baseline on this box: **342 passed, 0 failed, 6 ignored**. ``` cargo test --workspace 343 passed; 0 failed; 6 ignored (exit 0) ``` One more than the baseline; `XSystemGetXboxLiveSandboxId` refusing a short buffer is covered and green. Tree restored afterwards (full diff against a clean checkout); no game data, the tests are synthetic. AI-assisted (opencode): applied the patch to a built tree, ran `cargo test --workspace`, reverted it.
pushkarreddyy commented 2026-11-24 15:04:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-24T14:43:51Z.


Thanks @LouisRiverstone for the implementation and @dcastell1 for the testing!

Just a quick heads-up: Issue #862 was claimed earlier (claim on #862) and our matching PR is open at #972. It enforces SANDBOX_ID_MAX_BYTES = 16 with unit tests verifying sizes 0, 7, and 15 return E_NOT_SUFFICIENT_BUFFER.

Would really appreciate community testing and verification on PR #972 as well to help @Marvisak with review and integration!

<!-- greyfinch-sync:Marvisak/VIctory:comment:7134854197 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/939#issuecomment-7134854197). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-11-24T14:43:51Z. --- Thanks @LouisRiverstone for the implementation and @dcastell1 for the testing! Just a quick heads-up: Issue #862 was claimed earlier ([claim on #862](https://github.com/Marvisak/VIctory/issues/862#issuecomment-7133104992)) and our matching PR is open at #972. It enforces `SANDBOX_ID_MAX_BYTES = 16` with unit tests verifying sizes 0, 7, and 15 return `E_NOT_SUFFICIENT_BUFFER`. Would really appreciate community testing and verification on PR #972 as well to help @Marvisak with review and integration!
mercuryVM commented 2026-11-24 16:04:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T15:26:41Z.

Review: APPROVED


Tested d4306f4 on Windows 11, RTX 5070, MSVC: builds, cargo test --workspace --no-fail-fast 557 passed. One run had frame::tests::waits_end_on_ticks_and_count_frames fail under load (the known timing flake, untouched here); it passed 3 of 3 on its own. The new a_sandbox_id_buffer_under_the_documented_minimum_is_refused passes.

  • The check comes before put_string, so a 7-15 byte buffer is refused and neither the buffer nor used is touched. The test covers that, plus the 16-byte success case.
  • E_NOT_SUFFICIENT_BUFFER (0x8007007A) is HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), as documented.
  • Slot 0x20 is sandbox_id in the vtable, matching the existing identity_strings_fit_the_documented_sizes, which already passes 16.

Merged into our fork's main.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6042176072 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/939#pullrequestreview-6042176072). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T15:26:41Z. **Review:** APPROVED --- Tested d4306f4 on Windows 11, RTX 5070, MSVC: builds, `cargo test --workspace --no-fail-fast` 557 passed. One run had `frame::tests::waits_end_on_ticks_and_count_frames` fail under load (the known timing flake, untouched here); it passed 3 of 3 on its own. The new `a_sandbox_id_buffer_under_the_documented_minimum_is_refused` passes. - The check comes before `put_string`, so a 7-15 byte buffer is refused and neither the buffer nor `used` is touched. The test covers that, plus the 16-byte success case. - `E_NOT_SUFFICIENT_BUFFER` (0x8007007A) is `HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)`, as documented. - Slot 0x20 is `sandbox_id` in the vtable, matching the existing `identity_strings_fit_the_documented_sizes`, which already passes 16. Merged into our fork's main. AI-assisted (Claude Code).
Zipettte commented 2026-11-24 16:05:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T15:40:46Z.


Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at d4306f4: cargo test -p victory-hle passes, 96 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7136430269 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/939#issuecomment-7136430269). Originally posted by [Zipettte](https://github.com/Zipettte) on 2026-11-24T15:40:46Z. --- Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at d4306f4: `cargo test -p victory-hle` passes, 96 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
Marvisak commented 2026-11-25 02:06:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:25:30Z.


Automated triage for the maintainers.

Merge candidate.

sandbox_id in crates/victory-hle/src/modules/xsystem.rs now refuses any buffer under 16 bytes with E_NOT_SUFFICIENT_BUFFER before put_string runs. This matches issue #862. The new test checks sizes 7 and 15 (refused, with the buffer and used untouched) and size 16 (S_OK, used = 7).

Changed since the last review (new head 5a7687d): the doc comment on SANDBOX_ID_MAX_BYTES is now in plain terms and no longer names an identifier from the console SDK, which was the only thing asked for. Optional: the constant is a minimum, so a name like SANDBOX_ID_MIN_BUFFER would read better.

CI: check failing in emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index (victory-shader). This PR does not cause it: the PR touches only victory-hle, and that test-harness failure was fixed on main in 67e8ae1. The branch is based on an older main; a rebase or re-run should turn CI green.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149531542 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/939#issuecomment-7149531542). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:25:30Z. --- <!-- victory-triage v1 head=5a7687dc22c75c611df31cc90aaee5eff0530d3e verdict=merge-candidate at=2026-11-25T16:44:54Z --> Automated triage for the maintainers. **Merge candidate.** `sandbox_id` in `crates/victory-hle/src/modules/xsystem.rs` now refuses any buffer under 16 bytes with `E_NOT_SUFFICIENT_BUFFER` before `put_string` runs. This matches issue #862. The new test checks sizes 7 and 15 (refused, with the buffer and `used` untouched) and size 16 (`S_OK`, `used = 7`). Changed since the last review (new head `5a7687d`): the doc comment on `SANDBOX_ID_MAX_BYTES` is now in plain terms and no longer names an identifier from the console SDK, which was the only thing asked for. Optional: the constant is a minimum, so a name like `SANDBOX_ID_MIN_BUFFER` would read better. CI: `check` failing in `emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index` (victory-shader). This PR does not cause it: the PR touches only victory-hle, and that test-harness failure was fixed on main in `67e8ae1`. The branch is based on an older main; a rebase or re-run should turn CI green. --- _Generated by [Claude Code](https://claude.ai/code)_
fuzeofficlal commented 2026-11-26 02:07:01 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T01:20:51Z.


Code review and Windows 11 verification at head 5a7687dc22c7 merged cleanly onto main (63bcca43c6a0):

  • Code review (crates/victory-hle/src/modules/xsystem.rs:41, 68-73):
    • Enforces SANDBOX_ID_MAX_BYTES = 16 upfront, returning E_NOT_SUFFICIENT_BUFFER (0x8007_007A) without touching buffer or used when size < 16, and delegates size >= 16 cleanly to put_string(SANDBOX, size, buffer, used) (which also handles null buffer and writes "RETAIL\0" + used = 7).
  • Verified (Windows 11, Rust 1.98.1):
    • cargo xtask policy: 191 files ok; cargo clippy -p victory-hle --all-targets -- -D warnings: 0 warnings
    • victory-hle: 153/153 unit + 2/2 integration passed (including a_sandbox_id_buffer_under_the_documented_minimum_is_refused).

LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7179682550 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/939#issuecomment-7179682550). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T01:20:51Z. --- Code review and Windows 11 verification at head `5a7687dc22c7` merged cleanly onto `main` (`63bcca43c6a0`): - **Code review (`crates/victory-hle/src/modules/xsystem.rs:41, 68-73`)**: - Enforces `SANDBOX_ID_MAX_BYTES = 16` upfront, returning `E_NOT_SUFFICIENT_BUFFER` (`0x8007_007A`) without touching `buffer` or `used` when `size < 16`, and delegates `size >= 16` cleanly to `put_string(SANDBOX, size, buffer, used)` (which also handles null `buffer` and writes `"RETAIL\0"` + `used = 7`). - **Verified (Windows 11, Rust 1.98.1)**: - `cargo xtask policy`: `191 files ok`; `cargo clippy -p victory-hle --all-targets -- -D warnings`: 0 warnings - `victory-hle`: **153/153 unit + 2/2 integration passed** (including `a_sandbox_id_buffer_under_the_documented_minimum_is_refused`). LGTM.
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/939:upstream-pr/939'
git switch 'upstream-pr/939'

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