Storage: a path buffer too small fails with E_FAIL, as on Xbox #371

Merged
marquezinii merged 1 commit from upstream-pr/371 into main 2026-11-24 08:06:20 +00:00
marquezinii commented 2026-11-24 02:43:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by marquezinii on 2026-11-24T02:43:00Z.


XPersistentLocalStorageGetPath with a buffer smaller than the path returned HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) through put_string. The GDK reference says that is the PC result, and that Xbox devices get E_FAIL: "If the function fails because pathSize is less than the length of the PLS path, the return value is set to E_FAIL for Xbox devices and to HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) for PC devices."

Slot 0x20 is the one Grand Theft Auto VI calls, so this answers as the console would.

Tested: the existing storage test now also asks with a 3-byte buffer for X:\; it got 0x8007007A before the change and gets E_FAIL now. cargo test -p victory-hle passes.

https://learn.microsoft.com/gaming/gdk/docs/reference/system/xpersistentlocalstorage/functions/xpersistentlocalstoragegetpath

<!-- greyfinch-sync:Marvisak/VIctory:issue:6573421563 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/371). Originally posted by [marquezinii](https://github.com/marquezinii) on 2026-11-24T02:43:00Z. --- `XPersistentLocalStorageGetPath` with a buffer smaller than the path returned `HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)` through `put_string`. The GDK reference says that is the PC result, and that Xbox devices get `E_FAIL`: "If the function fails because *pathSize* is less than the length of the PLS path, the return value is set to **E_FAIL** for Xbox devices and to **HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)** for PC devices." Slot 0x20 is the one Grand Theft Auto VI calls, so this answers as the console would. Tested: the existing storage test now also asks with a 3-byte buffer for `X:\`; it got 0x8007007A before the change and gets `E_FAIL` now. `cargo test -p victory-hle` passes. https://learn.microsoft.com/gaming/gdk/docs/reference/system/xpersistentlocalstorage/functions/xpersistentlocalstoragegetpath
mercuryVM commented 2026-11-24 06:52:39 +00:00 (Migrated from github.com)

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

Review: APPROVED


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

  • size <= path.len() is the right bound, since the path needs len + 1 bytes with its NUL. That matches put_string's own check, so an exact fit still succeeds. The doc quote supports E_FAIL for Xbox.
  • Interaction to be aware of: #446 makes put_string write the required size through used on a short buffer. This early E_FAIL return bypasses that, so for this one getter used stays untouched on failure. That seems fine, since titles size this buffer through XPersistentLocalStorageGetPathSize (path_size), but it is a small inconsistency if both land.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6034775330 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/371#pullrequestreview-6034775330). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T06:40:41Z. **Review:** APPROVED --- Tested 376b3cf on Windows 11, RTX 5070, MSVC: `cargo test --workspace --no-fail-fast` passes (264 passed, 0 failed). - `size <= path.len()` is the right bound, since the path needs `len + 1` bytes with its NUL. That matches `put_string`'s own check, so an exact fit still succeeds. The doc quote supports `E_FAIL` for Xbox. - Interaction to be aware of: #446 makes `put_string` write the required size through `used` on a short buffer. This early `E_FAIL` return bypasses that, so for this one getter `used` stays untouched on failure. That seems fine, since titles size this buffer through `XPersistentLocalStorageGetPathSize` (`path_size`), but it is a small inconsistency if both land. AI-assisted (Claude Code).
jeremygold02 commented 2026-11-24 06:55:37 +00:00 (Migrated from github.com)

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


Thanks @marquezinii for this platform-compatibility fix. I tested head 376b3cf1785380cc397fdf89027f46e3472a6b55 with:

cargo test --locked -p victory-hle --lib serves_a_drive_over_the_title_folder_and_its_quota -- --test-threads=1

Result: 1 passed, 0 failed (85 filtered out). The storage-object test now covers a too-small path buffer returning E_FAIL, alongside the drive-root path and quota behavior. This is a unit test of the HLE object; I did not exercise a title call.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7121728059 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/371#issuecomment-7121728059). Originally posted by [jeremygold02](https://github.com/jeremygold02) on 2026-11-24T04:07:27Z. --- Thanks @marquezinii for this platform-compatibility fix. I tested head `376b3cf1785380cc397fdf89027f46e3472a6b55` with: ``` cargo test --locked -p victory-hle --lib serves_a_drive_over_the_title_folder_and_its_quota -- --test-threads=1 ``` Result: 1 passed, 0 failed (85 filtered out). The storage-object test now covers a too-small path buffer returning `E_FAIL`, alongside the drive-root path and quota behavior. This is a unit test of the HLE object; I did not exercise a title call.
upstream-sync closed this pull request 2026-11-24 09:05:25 +00:00
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!371
No description provided.