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

Open
github-bot wants to merge 1 commit from github-bot/gh-231 into main AGit
Owner

@⁠Andretuta on GitHub · 2026-11-24 02:49 UTC · original
ubiquitarianism:old-pr/9964 → main · +1210 −3 · 7 files · 1 commits · draft

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

**@⁠Andretuta** on GitHub · 2026-11-24 02:49 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/231) `ubiquitarianism:old-pr/9964` → `main` · +1210 −3 · 7 files · 1 commits · draft > 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
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:49:41 +00:00
This pull request has changes conflicting with the target branch.
  • runtime/CMakeLists.txt
  • runtime/shims/dstorage.cpp
  • runtime/test/dstorage_test.cpp
  • scripts/build_runtime.ps1
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/231/head:github-bot/gh-231'
git switch 'github-bot/gh-231'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-231'
git switch 'github-bot/gh-231'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-231'
git switch 'github-bot/gh-231'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-231'
git switch 'main'
git merge --squash 'github-bot/gh-231'
git switch 'main'
git merge --ff-only 'github-bot/gh-231'
git switch 'main'
git merge 'github-bot/gh-231'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.