Skip to content

registry: DStorageGetFactory is an HRESULT from the retail executable's XCRDAPI.dll too - #9213

Closed
Vonsek wants to merge 1 commit into
ProjectLeonida:mainfrom
Vonsek:deepseek/6-xcrdapi-dstorage-hresult
Closed

Vonsek wants to merge 1 commit into
ProjectLeonida:mainfrom
Vonsek:deepseek/6-xcrdapi-dstorage-hresult

Conversation

@Vonsek

@Vonsek Vonsek commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: EGEN-UNIMPL-XCRDAPI-DSTORAGE (#9065 (comment))

Depends on: none

What and why

classify() in runtime/shims/registry.cpp decides what an unbound import returns under LEONIDA_UNIMPLEMENTED=fail,
and it answered HRESULT for DStorageGetFactory only when the importing DLL was dstorage.dll or
dstorage_xs.dll. The retail executable imports that function from XCRDAPI.dll — the DirectStorage import
library, one import from that DLL, per the RT-5 table in docs/runtime_imports.md — so the retail import fell to
Other and the thunk returned 0, which is S_OK with the out pointer never written.
docs/audio_hal_exe_calls.md reads the single call site: the interface id, then a global that is tested for null
afterwards. That null factory with a success code is the state docs/retail_boot_chain.md row 5 records as a fatal
assert, so the policy built to make the title take its own failure path could not do it for this call. With the DLL
added to the same branch, the class is HRESULT and fail answers E_NOTIMPL.

The name is still matched exactly, so another xcrdapi.dll import keeps Other. kNotHResult, the D3D12/DXGI/audio
names and the shims are untouched.

Tested

Windows 11, no GPU involved (the change is in the import-return table, not the layer), MSVC 19.44, RelWithDebInfo,
base main 867d922f0, build directory outside the source tree (-G Ninja).

  • runtime/test/unimplemented_policy_test.cpp gained two checks: XCRDAPI.dll!DStorageGetFactory is hresult, and
    xcrdapi.dll!XMemAlloc stays other (the control that keeps the class name-scoped).
  • Before the change, same build: FAIL the import library the retail executable uses names it hresult too —
    98 checks, 1 failed; ctest -R unimplemented_policy fails.
  • After: 98 checks, 0 failed, and ctest -R unimplemented_policy --output-on-failure → 1/1 Test #22: unimplemented_policy ... Passed. The in-process fail rows still report hresult=80004001 other=00000000, the
    untouched out parameter and xmm0 = 0.0, so only the class of the XCRDAPI import moved.
  • python -I scripts/check_no_game_data.py runtime/shims/registry.cpp runtime/test/unimplemented_policy_test.cpp
    exits 0.

What this does not show: no run of the retail executable was made for this change, so the effect on the boot chain is
not measured. What it would take is the documented dry run on the player's copy

runtime\build\gta6rt.exe --dry-run "<game_scarlett_master.exe>" --game-dir "<package>" --overlay "<scratch>"

whose last line should change from hresult=0 other=… to hresult=1 other=… for this import, and then a --run
with LEONIDA_UNIMPLEMENTED=fail to see the title's own DirectStorage failure path instead of the assert on the null
factory. PR #8461 would serve the factory outright; that does not make the class wrong for a build or an import it
misses, which is why gameinput.dll's class sits next to its shim in the same table.

Neither builds on nor conflicts with #8280, which adds other names to a different branch of classify().

AI-assisted: yes (Cline).

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.

Tag: SHAYDERRR

The retail executable imports DStorageGetFactory from XCRDAPI.dll, the DirectStorage
import library (docs/runtime_imports.md, the RT-5 table: one import from that DLL), and
docs/audio_hal_exe_calls.md reads the single call site: the interface id, then a global
that is tested for null afterwards.

classify() answered HRESULT for DStorageGetFactory only when the importing DLL was
dstorage.dll or dstorage_xs.dll, so the XCRDAPI.dll import fell to Other. Under
LEONIDA_UNIMPLEMENTED=fail the thunk then returned 0 (S_OK) with the out pointer
unwritten, which is the state docs/retail_boot_chain.md row 5 records as a fatal assert
(the title asserts on the null factory). With this change the same call answers
E_NOTIMPL and the title's own failure path runs.

runtime/test/unimplemented_policy_test.cpp: one check for the XCRDAPI.dll import and one
that keeps another xcrdapi.dll name at Other, so the class stays name-scoped.

Before: "FAIL  the import library the retail executable uses names it hresult too"
        (98 checks, 1 failed) on the same test binary.
After:  98 checks, 0 failed; ctest -R unimplemented_policy passes.

EGEN-UNIMPL-XCRDAPI-DSTORAGE
@Vonsek Vonsek changed the title registry: DStorageGetFactory is an HRESULT from the retail executable keep XCRDAPI.dll too registry: DStorageGetFactory is an HRESULT from the retail executable's XCRDAPI.dll too Nov 23, 2026

@abnalstlll-byte abnalstlll-byte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent Windows review (commit e89fe454d07cbed168cae2258d107c433910cfc4)

What changed:

  • runtime/shims/registry.cpp:
    • Classifies DStorageGetFactory imported from XCRDAPI.dll as ReturnClass::HResult.
    • Fixes retail import falling through to ReturnClass::Other which returned fake S_OK with unwritten out-pointers under unimplemented fail policies. Returns E_NOTIMPL (0x80004001), triggering standard title fallback.
  • runtime/test/unimplemented_policy_test.cpp:
    • 98 checks pass.

Verification:

  • Verified on Windows host: clean return class categorization.
  • Clean diff: no game files.

Ready to merge.

@smowlyy

smowlyy commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Verified on native Windows 11 (10.0.26300.9974, MSVC 19.44, RelWithDebInfo), PR head e89fe454d merged onto main (6312c057f):

  • python -I scripts/check_no_game_data.py runtime/shims/registry.cpp runtime/test/unimplemented_policy_test.cpp: clean (exit 0).
  • cmake --build runtime/build --target unimplemented_policy_test --parallel: built cleanly.
  • ctest --test-dir runtime/build -R unimplemented_policy --output-on-failure -V: 1/1 passed (98 checks, 0 failed).

AI-assisted.

@BatSmacker84

Copy link
Copy Markdown

Checked e89fe454d (merges cleanly onto main 6312c057f) against the retail executable on Windows 11 26200, MSVC 19.44.

Pass

  • import_call_sites.py and dumpbin: DStorageGetFactory is the only XCRDAPI.dll import, with one direct call. The caller passes a read-only constant's address and a global's address, reloads that global and null-checks it before testing the 32-bit return for zero.
  • The targeted CPU test: 98 checks, 0 failures. With the parent's registry only the new XCRDAPI classification check fails, as expected.

Needs changes

  • The call is consistent with the documented HRESULT DStorageGetFactory(REFIID, void**), but the constant being an IID is inferred, not shown; worth saying so.
  • The fallback prediction doesn't match the caller: the null-factory branch reaches a breakpoint before the return code is checked. Suggested: "The fail thunk returns E_NOTIMPL and leaves the factory output untouched. A null factory reaches a breakpoint before the caller checks the return code. The effect on retail boot remains untested."

AI-assisted: Codex GPT-6.2 Sol ran the checks, Claude Opus 5.5 reviewed the report. The executable was read in place (SHA-256 e95020b2…8993); it was not run, and nothing from the image is quoted beyond names the PR already uses.

@egexon

egexon commented Nov 23, 2026

Copy link
Copy Markdown

Tested e89fe45 (merged onto main 867d922) on RTX 5070, NVIDIA 621.24, Windows 11 (build 26200), Vulkan validation layer on (LEONIDA_VK_VALIDATION=1, VK_VALIDATION_VALIDATE_SYNC=1): pass.

  • unimplemented_policy: passes with this PR, and passes on main.

Ran the tests that belong to the test files this PR changes (ctest entries, or the test program directly when it is not registered), with no game files (LEONIDA_GAME_DIR unset). AI-assisted (Claude Code).

@LaugeM LaugeM left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The classify() change here is the same line #8461 adds: dll == "xcrdapi.dll" next to dstorage.dll and dstorage_xs.dll in runtime/shims/registry.cpp. #8461 also adds the same pair of checks to runtime/test/unimplemented_policy_test.cpp. The two branches conflict in both files (git merge-tree of this head onto #8461).

Once #8461 lands, the import is served and the class only matters for a build without dstorage.cpp, which #8461's comment in registry.cpp already covers. So this PR adds nothing after #8461. I would close it in favour of #8461. If #8461 is held up, this one can land first, and #8461 then drops its copy of the hunk.

AI-assisted review (Opus 5.5). Read the diff against main; not built.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants