upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/shims/registry.cpp
diff options
context:
space:
mode:
authormariuslozo-boop <254631011+mariuslozo-boop@users.noreply.github.com>2026-11-23 01:48:51 +0100
committermariuslozo-boop <254631011+mariuslozo-boop@users.noreply.github.com>2026-11-23 01:48:51 +0100
commitf87d05fdd3a96b5f42e712d376cfc0b9b4e398d5 (patch)
tree6ec9160e28831d6d4a7170e9b06249cc0658827d /runtime/shims/registry.cpp
parent03b09a086592a197db64d91655c6e65c30764d96 (diff)
runtime: console DirectStorage (DStorageGetFactory) with file-to-memory reads
Serve the Xbox DirectStorage API (IDStorageFactoryX2, IDStorageQueueX2, IDStorageFileX, IDStorageStatusArrayX) under dstorage_xs.dll, xcrdapi.dll and dstorage.dll. Declarations are our own (shims/dstorage_xs_abi.h), written from the public GDK reference; layouts are pinned with static_asserts. - OpenFile goes through the registry's kernel32!CreateFileW, so GAME: paths use the console path mapping and the write overlay. GetHandle returns a ReOpenFile handle with its own file position. - One worker thread per queue runs submitted entries in order: file and memory requests, status arrays, ID3D12Fence::Signal, EnqueueSetEvent (on a duplicate of the title's handle taken at enqueue). - Auto-submit at half the capacity (or disabled through DSTORAGE_QUEUE_OPTIONS), enqueue into a full queue waits, CancelRequestsWithTag (a cancelled request is a success and not a failure), error record and error event, Close and the last Release drain the queue, IDStorageFileX::Close waits for the file's submitted reads. - Request checks: reserved bits, source type, BCPack/swizzle ranges, sizes, 1 GiB limit, null and foreign objects and closed files (also for zero-size requests), end of file, inaccessible memory. - zlib, BCPack, swizzle and physical pages return E_NOTIMPL (later PRs). - Interface ids of the X interfaces are not public: a creating call accepts and logs a new id per object kind, but refuses system COM ids (IMarshal, IAgileObject, ...) and the PC DirectStorage ids; QueryInterface accepts only IUnknown, the PC IDStorageStatusArray id (same shape) and the ids creating calls accepted for that kind. Bad arguments are logged once per method. - registry.cpp classifies xcrdapi.dll!DStorageGetFactory as HRESULT; the cl.exe fallback in build_runtime.ps1 builds the new shim too. ctest dstorage: 258 checks over synthetic files in %TEMP%, no GPU, no game data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/shims/registry.cpp')
-rw-r--r--runtime/shims/registry.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/runtime/shims/registry.cpp b/runtime/shims/registry.cpp
index 37ff540c5..047645401 100644
--- a/runtime/shims/registry.cpp
+++ b/runtime/shims/registry.cpp
@@ -80,7 +80,10 @@ std::vector<Lookup> g_lookups;
80// xaudio2_9.dll XAudio2Create: HRESULT (learn.microsoft.com/windows/win32/api/xaudio2/ 80// xaudio2_9.dll XAudio2Create: HRESULT (learn.microsoft.com/windows/win32/api/xaudio2/
81// xaudio2_9redist.dll nf-xaudio2-xaudio2create). xaudio2_9.dll is the console name (docs/d3d12_vulkan.md §7). 81// xaudio2_9redist.dll nf-xaudio2-xaudio2create). xaudio2_9.dll is the console name (docs/d3d12_vulkan.md §7).
82// dstorage.dll DStorageGetFactory: HRESULT (learn.microsoft.com/windows/win32/api/dstorage/ 82// dstorage.dll DStorageGetFactory: HRESULT (learn.microsoft.com/windows/win32/api/dstorage/
83// dstorage_xs.dll nf-dstorage-dstoragegetfactory). dstorage_xs.dll is the console name. 83// dstorage_xs.dll nf-dstorage-dstoragegetfactory, and the GDK's gaming/gdk/docs/reference/system/dstorage/
84// xcrdapi.dll functions/dstoragegetfactory). dstorage_xs.dll is the console name; xcrdapi.dll is a
85// console module the title may import it from (docs/directstorage.md). dstorage.cpp serves
86// it; the class is kept for a build without that shim.
84const char* const kNotHResult[] = { 87const char* const kNotHResult[] = {
85 "XAsyncCancel", "XAsyncComplete", 88 "XAsyncCancel", "XAsyncComplete",
86 "XTaskQueueCloseHandle", "XTaskQueueDispatch", "XTaskQueueGetCurrentProcessTaskQueue", 89 "XTaskQueueCloseHandle", "XTaskQueueDispatch", "XTaskQueueGetCurrentProcessTaskQueue",
@@ -111,7 +114,7 @@ ReturnClass classify(const std::string& dll, const std::string& name) {
111 if (name == "XAudio2Create") return ReturnClass::HResult; 114 if (name == "XAudio2Create") return ReturnClass::HResult;
112 } else if (dll == "gameinput.dll") { 115 } else if (dll == "gameinput.dll") {
113 if (name == "GameInputCreate") return ReturnClass::HResult; 116 if (name == "GameInputCreate") return ReturnClass::HResult;
114 } else if (dll == "dstorage.dll" || dll == "dstorage_xs.dll") { 117 } else if (dll == "dstorage.dll" || dll == "dstorage_xs.dll" || dll == "xcrdapi.dll") {
115 if (name == "DStorageGetFactory") return ReturnClass::HResult; 118 if (name == "DStorageGetFactory") return ReturnClass::HResult;
116 } else if (dll == "xgameruntime.dll") { 119 } else if (dll == "xgameruntime.dll") {
117 if (name == "XGameRuntimeInitialize" || name == "XGameEventWrite") return ReturnClass::HResult; 120 if (name == "XGameRuntimeInitialize" || name == "XGameEventWrite") return ReturnClass::HResult;