runtime/shims: implement console DirectStorage shims (XCRDAPI / dstorage_xs) #231

Closed
Andretuta wants to merge 1 commit from upstream-pr/231 into main
Andretuta commented 2026-11-24 02:49:27 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Andretuta on 2026-11-24T02:49:27Z.


Carried over from old PR 9964 by piyonchu in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9964, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
This branch conflicts with the current main and needs a rebase.
piyonchu: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Clean-room console DirectStorage shims for XCRDAPI.dll (DStorageGetFactory), plus dstorage_xs.dll and dstorage.dll aliases, backed by static PE/ABI verification of the Xbox Series COM call sites.

What changed

  • Added runtime/shims/dstorage.cpp serving DStorageGetFactory (xcrdapi.dll, dstorage_xs.dll, dstorage.dll) with COM implementations matching the console ABI:
    • IDStorageFactoryX (OpenFile, CreateStatusArray, CreateQueue at console vtable slot 10 and slot 3 alias, SetStagingBufferSize, SetDebugFlags, SetCpuAffinity, SetDisableBypassIO)
    • IDStorageFileX (Close, GetFileInformation, thread-safe 64-bit ranged ReadFile over rt::fs::open_read_only)
    • IDStorageStatusArrayX (IsComplete, GetHResult)
    • IDStorageQueueX (EnqueueRequest with console Destination-first layout, memory-source bit 22, low codec byte 0 raw / 1 zlib; EnqueueStatus; Submit at console vtable slot 6; Close at slot 8; CancelRequestsWithTag; EnqueueSignal)
    • Built-in zero-static-guard RFC 1950/1951 zlib inflator (inflate_zlib) failing closed (E_NOTIMPL / ERROR_INVALID_DATA) on unsupported codecs or truncated streams; zero _Init_thread_header TLS guards.
  • Added rt::fs::open_read_only in runtime/shims/file_system.h / runtime/shims/file_system.cpp so OpenFile inherits GAME: / G: / T: / overlay precedence, deletion markers, and .. traversal refusal without duplicating path resolution.
  • Added "xcrdapi.dll" DStorageGetFactory (ReturnClass::HResult) classification in runtime/shims/registry.cpp.
  • Added unit tests runtime/test/dstorage_test.cpp and wired dstorage_test / dstorage.cpp in runtime/CMakeLists.txt and scripts/build_runtime.ps1.

Verification

  • Built dstorage_test and file_system_test (cmake --build runtime/build --target dstorage_test file_system_test): 0 warnings in dstorage.cpp and dstorage_test.cpp.
  • ctest --test-dir runtime/build -R "^(dstorage|file_system)$" --output-on-failure: 2/2 passed (dstorage, file_system).
  • dumpbin /symbols on dstorage.cpp.obj and file_system.cpp.obj: 0 _Init_thread_header references.
  • python -m unittest tests/test_ctest_registration.py: 4/4 OK.
  • python scripts/check_no_game_data.py & git diff --check: clean.

Claim: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7116843209

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5465146616 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/231). Originally posted by [Andretuta](https://github.com/Andretuta) on 2026-11-24T02:49:27Z. --- > Carried over from **old PR 9964** by `piyonchu` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9964`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > This branch conflicts with the current `main` and needs a rebase. > `piyonchu`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): Clean-room console DirectStorage shims for `XCRDAPI.dll` (`DStorageGetFactory`), plus `dstorage_xs.dll` and `dstorage.dll` aliases, backed by static PE/ABI verification of the Xbox Series COM call sites. ### What changed - Added [`runtime/shims/dstorage.cpp`](runtime/shims/dstorage.cpp) serving `DStorageGetFactory` (`xcrdapi.dll`, `dstorage_xs.dll`, `dstorage.dll`) with COM implementations matching the console ABI: - `IDStorageFactoryX` (`OpenFile`, `CreateStatusArray`, `CreateQueue` at console vtable slot 10 and slot 3 alias, `SetStagingBufferSize`, `SetDebugFlags`, `SetCpuAffinity`, `SetDisableBypassIO`) - `IDStorageFileX` (`Close`, `GetFileInformation`, thread-safe 64-bit ranged `ReadFile` over `rt::fs::open_read_only`) - `IDStorageStatusArrayX` (`IsComplete`, `GetHResult`) - `IDStorageQueueX` (`EnqueueRequest` with console `Destination`-first layout, memory-source bit `22`, low codec byte `0` raw / `1` zlib; `EnqueueStatus`; `Submit` at console vtable slot 6; `Close` at slot 8; `CancelRequestsWithTag`; `EnqueueSignal`) - Built-in zero-static-guard RFC 1950/1951 zlib inflator (`inflate_zlib`) failing closed (`E_NOTIMPL` / `ERROR_INVALID_DATA`) on unsupported codecs or truncated streams; zero `_Init_thread_header` TLS guards. - Added `rt::fs::open_read_only` in [`runtime/shims/file_system.h`](runtime/shims/file_system.h) / [`runtime/shims/file_system.cpp`](runtime/shims/file_system.cpp) so `OpenFile` inherits `GAME:` / `G:` / `T:` / overlay precedence, deletion markers, and `..` traversal refusal without duplicating path resolution. - Added `"xcrdapi.dll"` `DStorageGetFactory` (`ReturnClass::HResult`) classification in [`runtime/shims/registry.cpp`](runtime/shims/registry.cpp). - Added unit tests [`runtime/test/dstorage_test.cpp`](runtime/test/dstorage_test.cpp) and wired `dstorage_test` / `dstorage.cpp` in [`runtime/CMakeLists.txt`](runtime/CMakeLists.txt) and [`scripts/build_runtime.ps1`](scripts/build_runtime.ps1). ### Verification - Built `dstorage_test` and `file_system_test` (`cmake --build runtime/build --target dstorage_test file_system_test`): 0 warnings in `dstorage.cpp` and `dstorage_test.cpp`. - `ctest --test-dir runtime/build -R "^(dstorage|file_system)$" --output-on-failure`: `2/2` passed (`dstorage`, `file_system`). - `dumpbin /symbols` on `dstorage.cpp.obj` and `file_system.cpp.obj`: `0` `_Init_thread_header` references. - `python -m unittest tests/test_ctest_registration.py`: `4/4` OK. - `python scripts/check_no_game_data.py` & `git diff --check`: clean. Claim: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7116843209
aslan2142 commented 2026-12-01 12:15:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T12:15:35Z.


Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review.

(AI-assisted triage.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7310877409 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/231#issuecomment-7310877409). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T12:15:35Z. --- Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review. *(AI-assisted triage.)*
aslan2142 commented 2026-12-01 17:20:33 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T17:20:33Z.


Closing this PR because it targets the deprecated legacy C++ Vulkan runtime (in favor of the new Rust Vulkan runtime in progress and the Rust DX12 runtime (d3d12/) available now), and the DirectStorage shim (runtime/shims/dstorage.cpp) has already been superseded on main. Thank you for the contribution! If you believe this PR was closed by mistake, please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7319145699 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/231#issuecomment-7319145699). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T17:20:33Z. --- Closing this PR because it targets the deprecated legacy C++ Vulkan runtime (in favor of the new Rust Vulkan runtime in progress and the Rust DX12 runtime (`d3d12/`) available now), and the DirectStorage shim (`runtime/shims/dstorage.cpp`) has already been superseded on `main`. Thank you for the contribution! If you believe this PR was closed by mistake, please feel free to reopen it.

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
ProjectLeonida/mandy!231
No description provided.