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

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

📋 Pull Request Information

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

Base: main ← Head: docs/agent4


📝 Commits (1)

  • 6be0617 docs(directstorage): measured factory IID and SetStagingBufferSize slot

📊 Changes

1 file changed (+79 additions, -18 deletions)

View changed files

📝 docs/directstorage.md (+79 -18)

📄 Description

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)


🔄 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/1023 **Author:** [@robot00f](https://github.com/robot00f) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `docs/agent4` --- ### 📝 Commits (1) - [`6be0617`](https://github.com/ubiquitarianism/leonida/commit/6be061761d3532d102b457f6772ed277b7dfa931) docs(directstorage): measured factory IID and SetStagingBufferSize slot ### 📊 Changes **1 file changed** (+79 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `docs/directstorage.md` (+79 -18) </details> ### 📄 Description `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) --- <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#1062
No description provided.