docs(directstorage): measured factory IID and SetStagingBufferSize slot (DSTORAGE-FACTORY-MEASURED) #1023

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

@⁠robot00f on GitHub · 2026-11-24 17:01 UTC · original
robot00f:docs/agent4 → main · +79 −18 · 1 files · 1 commits · open

docs/directstorage.md now records, as measured, what the executable asks the factory for and which slot it then calls. Claim: ubiquitarianism/leonida#14, item DSTORAGE-FACTORY-MEASURED.

What

  • The serving module is measured: the executable's only DStorageGetFactory import comes from XCRDAPI.dll, one import with one call site (RVA 0x1D8E4F0, thunk 0x5F3FF80, IAT slot RVA 0x6793FB8), consistent with docs/runtime_imports.md (RT-5) and docs/audio_hal_exe_calls.md. dstorage.dll and dstorage_xs.dll are imported by nobody.
  • The interface id is read: RCX is the address of the 16 bytes at RVA 0x62FC7D8 / VA 0x1462FC7D8, 11 9D 95 62 5F D4 84 48 A0 A3 F7 86 2E A2 43 AE — {62959D11-D45F-4884-A0A3-F7862EA243AE} read Data1 LE, Data2/Data3 LE, Data4 as stored. RDX is the out pointer at VA 0x1478F5E78; the result is tested for null and then for a non-zero HRESULT before reloading the factory pointer.
  • The call is call [rax+0x40] with edx = 0x02000000, followed by test eax, eax / jns. 0x40 / 8 = 8, where PC dstorage.h puts SetDebugFlags at 6 and SetStagingBufferSize at 7, so SetStagingBufferSize at slot 8 confirms one console-only method (SetCpuAffinity) sits alongside the shared SetDebugFlags at slots 6 and 7 before it (matching runtime/shims/dstorage_xs_abi.h), and the 32 MiB value plus HRESULT sign check distinguish SetStagingBufferSize from void SetDebugFlags(UINT32). Which of SetCpuAffinity and SetDebugFlags is 6 and which is 7 stays a guess.
  • The page's confidence rows are corrected (module xcrdapi.dll measured; factory order medium instead of low), the id is added to the factory-id policy, and the shim consequence is written down: accept the id as the factory's declared id (beside kStatusArrayIds) rather than only learning it at boot, and keep SetStagingBufferSize on slot 8.
  • The 32 MiB argument matches the largest size the shim accepts, and the call is once, on first use, before any queue or file — the state the E_DSTORAGE_STAGING_BUFFER_LOCKED rule expects.

Why

The page listed the module as "low" on a name in a library list and the factory order as low "(SetCpuAffinity slot is a guess)". Both are now measured from the file, so a shim that misroutes the staging call or refuses the real factory id can be caught before a boot. Nothing is executed; no game bytes are committed.

Tested

  • python -I scripts/check_no_game_data.py docs/directstorage.md — exit 0
  • python -I tests/test_docs_*.py and python -I tests/test_i18n_index.py — OK
  • python -m compileall -q make_game.py tools tests — exit 0
  • python -I tools/import_call_sites.py game_scarlett_master.exe --import XCRDAPI.dll!DStorageGetFactory --json — one thunk, one call, at the RVAs quoted
  • Capstone disassembly around the call site, the thunk and the GUID, and the import descriptor walked for the DLL name

Docs only, no runtime or test change. GPUs tested: n/a.

AI-assisted: yes (Antigravity)

**@⁠robot00f** on GitHub · 2026-11-24 17:01 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1023) `robot00f:docs/agent4` → `main` · +79 −18 · 1 files · 1 commits · open `docs/directstorage.md` now records, as measured, what the executable asks the factory for and which slot it then calls. Claim: ubiquitarianism/leonida#14, item `DSTORAGE-FACTORY-MEASURED`. ## What - The serving module is measured: the executable's only `DStorageGetFactory` import comes from `XCRDAPI.dll`, one import with one call site (RVA `0x1D8E4F0`, thunk `0x5F3FF80`, IAT slot RVA `0x6793FB8`), consistent with [`docs/runtime_imports.md`](docs/runtime_imports.md) (RT-5) and [`docs/audio_hal_exe_calls.md`](docs/audio_hal_exe_calls.md). `dstorage.dll` and `dstorage_xs.dll` are imported by nobody. - The interface id is read: RCX is the address of the 16 bytes at RVA `0x62FC7D8` / VA `0x1462FC7D8`, `11 9D 95 62 5F D4 84 48 A0 A3 F7 86 2E A2 43 AE` — `{62959D11-D45F-4884-A0A3-F7862EA243AE}` read Data1 LE, Data2/Data3 LE, Data4 as stored. RDX is the out pointer at VA `0x1478F5E78`; the result is tested for null and then for a non-zero HRESULT before reloading the factory pointer. - The call is `call [rax+0x40]` with `edx = 0x02000000`, followed by `test eax, eax` / `jns`. `0x40 / 8 = 8`, where PC `dstorage.h` puts `SetDebugFlags` at 6 and `SetStagingBufferSize` at 7, so `SetStagingBufferSize` at slot 8 confirms one console-only method (`SetCpuAffinity`) sits alongside the shared `SetDebugFlags` at slots 6 and 7 before it (matching `runtime/shims/dstorage_xs_abi.h`), and the 32 MiB value plus `HRESULT` sign check distinguish `SetStagingBufferSize` from `void SetDebugFlags(UINT32)`. Which of `SetCpuAffinity` and `SetDebugFlags` is 6 and which is 7 stays a guess. - The page's confidence rows are corrected (module `xcrdapi.dll` measured; factory order medium instead of low), the id is added to the factory-id policy, and the shim consequence is written down: accept the id as the factory's declared id (beside `kStatusArrayIds`) rather than only learning it at boot, and keep `SetStagingBufferSize` on slot 8. - The 32 MiB argument matches the largest size the shim accepts, and the call is once, on first use, before any queue or file — the state the `E_DSTORAGE_STAGING_BUFFER_LOCKED` rule expects. ## Why The page listed the module as "low" on a name in a library list and the factory order as low "(`SetCpuAffinity` slot is a guess)". Both are now measured from the file, so a shim that misroutes the staging call or refuses the real factory id can be caught before a boot. Nothing is executed; no game bytes are committed. ## Tested - `python -I scripts/check_no_game_data.py docs/directstorage.md` — exit 0 - `python -I tests/test_docs_*.py` and `python -I tests/test_i18n_index.py` — OK - `python -m compileall -q make_game.py tools tests` — exit 0 - `python -I tools/import_call_sites.py game_scarlett_master.exe --import XCRDAPI.dll!DStorageGetFactory --json` — one thunk, one call, at the RVAs quoted - Capstone disassembly around the call site, the thunk and the GUID, and the import descriptor walked for the DLL name Docs only, no runtime or test change. GPUs tested: n/a. AI-assisted: yes (Antigravity)
Records the one DStorageGetFactory call site (RT-5): the import comes from XCRDAPI.dll, RCX is the id address {62959D11-D45F-4884-A0A3-F7862EA243AE} at 0x1462FC7D8, RDX is the out pointer at 0x1478F5E78, and the object's slot 8 (call [rax+0x40]) takes 0x02000000 and checks the HRESULT sign.

PC dstorage.h puts SetDebugFlags at slot 6 and SetStagingBufferSize at slot 7, so SetStagingBufferSize at slot 8 confirms one console-only method (SetCpuAffinity) sits alongside the shared SetDebugFlags at slots 6 and 7 while their relative order stays a guess; the module is now measured instead of a name from a library list.

Claimed in ubiquitarianism/leonida#14 (item DSTORAGE-FACTORY-MEASURED).

AI-assisted: yes (Antigravity)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:34:00 +00:00
Author
Owner

@⁠PierreEbele on GitHub · 2026-11-25 07:02 UTC · original

Reviewed 16ce4126:
Docs-only PR verified against the repository: GUID byte conversion, RVA/VA pairs, 32 MiB limit, RT-5 cross-references, check_no_game_data.py docs/directstorage.md, tools/import_call_sites.py --help, and all 13 tests/test_docs_*.py / test_i18n_index.py checks pass. Three issues to fix before merge:

  1. Wrong address annotation: lea rdx, [rip+0x5B6798F] ; VA 0x14D894E78 — RVA 0xD894E78 (227 MB) is past the end of the 184,995,840-byte image (docs/runtime_imports.md RT-5), and the excerpt's own displacements (0x5B6798F and 0x5B6797C on the mov rcx after the call) both resolve to 0x1478F5E78. Please fix it and re-verify the excerpt with Capstone.
  2. Slot-8 reasoning contradicts runtime/shims/dstorage_xs_abi.h:9,352-354: SetDebugFlags(UINT32) is shared with PC dstorage.h (not console-only), so PC puts SetStagingBufferSize at slot 7 (not 6) and slot 8 confirms one console-only method (SetCpuAffinity) plus SetDebugFlags at slots 6–7 (not two console-only methods). SetDebugFlags also takes one UINT32 argument; it is the HRESULT return check (test eax, eax) and 0x02000000 (32 MiB) value that identify SetStagingBufferSize.
  3. Please rebase on origin/main to resolve the merge conflict in docs/directstorage.md (SetStagingBufferSize bullet).
    AI-assisted review.

Recommendation: Fix first

**@⁠PierreEbele** on GitHub · 2026-11-25 07:02 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1023#issuecomment-7155420616) Reviewed 16ce4126: Docs-only PR verified against the repository: GUID byte conversion, RVA/VA pairs, 32 MiB limit, RT-5 cross-references, `check_no_game_data.py docs/directstorage.md`, `tools/import_call_sites.py --help`, and all 13 `tests/test_docs_*.py` / `test_i18n_index.py` checks pass. Three issues to fix before merge: 1. Wrong address annotation: `lea rdx, [rip+0x5B6798F] ; VA 0x14D894E78` — RVA `0xD894E78` (227 MB) is past the end of the 184,995,840-byte image (`docs/runtime_imports.md` RT-5), and the excerpt's own displacements (`0x5B6798F` and `0x5B6797C` on the `mov rcx` after the call) both resolve to `0x1478F5E78`. Please fix it and re-verify the excerpt with Capstone. 2. Slot-8 reasoning contradicts `runtime/shims/dstorage_xs_abi.h:9,352-354`: `SetDebugFlags(UINT32)` is shared with PC `dstorage.h` (not console-only), so PC puts `SetStagingBufferSize` at slot 7 (not 6) and slot 8 confirms one console-only method (`SetCpuAffinity`) plus `SetDebugFlags` at slots 6–7 (not two console-only methods). `SetDebugFlags` also takes one `UINT32` argument; it is the `HRESULT` return check (`test eax, eax`) and `0x02000000` (32 MiB) value that identify `SetStagingBufferSize`. 3. Please rebase on `origin/main` to resolve the merge conflict in `docs/directstorage.md` (`SetStagingBufferSize` bullet). AI-assisted review. **Recommendation:** Fix first
Author
Owner

@⁠robot00f on GitHub · 2026-11-25 15:49 UTC · original

Thanks @⁠PierreEbele — all three points are addressed:

  1. Address annotation & Capstone re-verification: Fixed lea rdx, [rip+0x5B6798F] from VA 0x14D894E78 to VA 0x1478F5E78 (0x141D8E4E2 + 7 + 0x5B6798F) and re-verified the entire 0x141D8E4DB–0x141D8E51C call-site excerpt with Capstone, including mov [rip+0x5B67990], rax (VA 0x1478F5E80) before call 0x145F3FF80 and both mov rcx reloads from VA 0x1478F5E78.
  2. Slot-8 reasoning (dstorage_xs_abi.h): Updated docs/directstorage.md (plus the commit message and PR description) so SetDebugFlags(UINT32) is noted as shared with PC dstorage.h (PC slot 6, SetStagingBufferSize at PC slot 7), meaning SetStagingBufferSize at console slot 8 confirms one console-only method (SetCpuAffinity) sits alongside SetDebugFlags at slots 6–7, and 0x02000000 (32 MiB) plus the HRESULT sign check (test eax, eax / jns) distinguish SetStagingBufferSize from void SetDebugFlags(UINT32).
  3. Rebase: Rebased cleanly onto origin/main (preserving the host-transform scratch sentence on the SetStagingBufferSize bullet) and re-ran check_no_game_data.py along with all tests/test_docs_*.py and tests/test_i18n_index.py checks.

AI-assisted: yes (Antigravity)

**@⁠robot00f** on GitHub · 2026-11-25 15:49 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1023#issuecomment-7167341781) Thanks @⁠PierreEbele — all three points are addressed: 1. **Address annotation & Capstone re-verification:** Fixed `lea rdx, [rip+0x5B6798F]` from `VA 0x14D894E78` to `VA 0x1478F5E78` (`0x141D8E4E2 + 7 + 0x5B6798F`) and re-verified the entire `0x141D8E4DB`–`0x141D8E51C` call-site excerpt with Capstone, including `mov [rip+0x5B67990], rax` (`VA 0x1478F5E80`) before `call 0x145F3FF80` and both `mov rcx` reloads from `VA 0x1478F5E78`. 2. **Slot-8 reasoning (`dstorage_xs_abi.h`):** Updated `docs/directstorage.md` (plus the commit message and PR description) so `SetDebugFlags(UINT32)` is noted as shared with PC `dstorage.h` (PC slot 6, `SetStagingBufferSize` at PC slot 7), meaning `SetStagingBufferSize` at console slot 8 confirms one console-only method (`SetCpuAffinity`) sits alongside `SetDebugFlags` at slots 6–7, and `0x02000000` (32 MiB) plus the `HRESULT` sign check (`test eax, eax` / `jns`) distinguish `SetStagingBufferSize` from `void SetDebugFlags(UINT32)`. 3. **Rebase:** Rebased cleanly onto `origin/main` (preserving the host-transform scratch sentence on the `SetStagingBufferSize` bullet) and re-ran `check_no_game_data.py` along with all `tests/test_docs_*.py` and `tests/test_i18n_index.py` checks. AI-assisted: yes (Antigravity)
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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