[PR #231] runtime/shims: implement console DirectStorage shims (XCRDAPI / dstorage_xs) #284

Open
opened 2026-11-26 20:17:23 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/231
Author: @Andretuta
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: old-pr/9964


📝 Commits (1)

  • 5b02252 runtime/shims: implement console DirectStorage shims (XCRDAPI / dstorage_xs)

📊 Changes

7 files changed (+1210 additions, -3 deletions)

View changed files

📝 runtime/CMakeLists.txt (+16 -0)
➕ runtime/shims/dstorage.cpp (+849 -0)
📝 runtime/shims/file_system.cpp (+17 -0)
📝 runtime/shims/file_system.h (+4 -0)
📝 runtime/shims/registry.cpp (+1 -1)
➕ runtime/test/dstorage_test.cpp (+321 -0)
📝 scripts/build_runtime.ps1 (+2 -2)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/231 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `old-pr/9964` --- ### 📝 Commits (1) - [`5b02252`](https://github.com/ubiquitarianism/leonida/commit/5b022527100f2f4c8c246f652fe819b396b921b2) runtime/shims: implement console DirectStorage shims (XCRDAPI / dstorage_xs) ### 📊 Changes **7 files changed** (+1210 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `runtime/CMakeLists.txt` (+16 -0) ➕ `runtime/shims/dstorage.cpp` (+849 -0) 📝 `runtime/shims/file_system.cpp` (+17 -0) 📝 `runtime/shims/file_system.h` (+4 -0) 📝 `runtime/shims/registry.cpp` (+1 -1) ➕ `runtime/test/dstorage_test.cpp` (+321 -0) 📝 `scripts/build_runtime.ps1` (+2 -2) </details> ### 📄 Description > 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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#284
No description provided.