Design note · interop shim
Proxying d3d12_xs.dll to Windows D3D12
The plan is sound engineering and it is exactly how d3d12on7, DXVK and VKD3D work: put
something in the loader's path that answers to the console's names and translates them to the host API.
This note specifies that shim for a Visual Studio build — and is precise about the one problem the
export table cannot solve.
- proxy DLL d3d12_xs.dll
- 3 exported functions
- 1 pure linker forward
- 1 wrapper object needed
- interfaces ID3D12DeviceX and friends
Names are cheap. Pointers are the project — and the assets decide the outcome.
A .def file can make d3d12_xs.dll export every console name and forward the compatible ones
to d3d12.dll in an afternoon. What it cannot do is hand the title a device object
with the console vtable. That requires implementing the Xbox interfaces — and once that is
done, the shaders and assets are still console-cooked. The shim is the right pattern applied to the wrong
target.
The goal, stated precisely
The title's import table names d3d12_xs.dll. On a PC that file does not exist, so the loader
gives up before WinMain. The shim's job is narrow: exist, answer to those names, and route work
to the real Windows runtime.
d3d12_xs.dllWhat a proxy DLL actually is
Two mechanisms make this work, and neither is exotic: the loader's search order, and the export table.
The loader does the hard part for you
When a PE is loaded, Windows resolves each import by searching the application directory before the
system directory. d3d12_xs.dll is not a Known DLL, so a file with that name sitting beside
the executable is what gets loaded — no patching, no injection, no registry.
That is also the whole security lesson of DLL search order in reverse: whoever controls the application directory controls which library the process gets. Here that is deliberate.
Then you match the exports exactly
x64 Windows has one calling convention, and exports are undecorated. A .def file therefore
guarantees the exact names, in the exact spelling the title linked against.
Where a console function has a PC twin with the same name, you do not even need code: the export table can forward directly to the other DLL. The linker emits a jump thunk for you.
Visual Studio project settings that matter
| Setting | Value and why |
|---|---|
| Configuration type | Dynamic Library (.dll) |
| Platform | x64 only — the console binary is AMD64, so a Win32 build is meaningless |
| C++ standard | C++17 or later |
| Runtime library | Multi-threaded Static (/MT), so the shim does not need the VC redist |
| Precompiled headers | off — one translation unit, nothing to gain |
| Module definition file | d3d12_xs.def, so exports are undecorated and exact |
| Target name | d3d12_xs.dll — it must match the import name the title links against |
| Output location | beside the executable, never in System32 |
| Post-build step | copy the DLL next to the test executable and assert the name |
The three exports, and what each needs
The title imports exactly three functions — which is why this looks like a small job. Two of them are, in fact, small.
| Console export | Purpose | PC counterpart | Strategy | Why |
|---|---|---|---|---|
D3D12XboxCreateDevice | create the console device | D3D12CreateDevice | wrap | The call itself maps, but the object it must return does not. This is the whole project in one line. |
D3D12SerializeVersionedRootSignature | flatten a root signature | identical export in d3d12.dll | forward | A pure linker forward. No code at all — the export table can point straight at the real DLL. |
D3D12ConfigureVirtualMemoryX | configure console virtual memory | none | stub | Console memory model. Nothing on a PC does this, so the shim must decide whether lying is safer than failing. |
D3D12SerializeVersionedRootSignature exists on both sides
with the same name and the same layout, so the .def file forwards it and the shim contains no code for it at
all. This is the "linker" half of what the plan calls a linker/proxy.
Names are cheap. Pointers are the project.
This is the part that decides whether the plan works, and it is entirely about object layout rather than symbol resolution.
What the title expects back
D3D12XboxCreateDevice returns a pointer to a console device: a COM object
whose vtable begins with the common D3D12 methods and then continues into Xbox extensions — frame
interval control, game configuration, console capability queries, XBOX heap semantics.
The title was compiled against those declarations. Every method call is a fixed vtable offset baked into the binary. It has no way to ask "are you a PC device?" and adapt.
What Windows can give you
D3D12CreateDevice returns a PC ID3D12Device, whose vtable is the common prefix
and then stops. The shared prefix means ordinary calls would land correctly; the tail means every Xbox
call jumps past the end of the table.
So handing back the raw PC pointer buys you exactly the calls that did not need a shim, and undefined behaviour for the ones that did.
What sits behind the device pointer
Once the wrapper exists, its methods fall into three classes. Only the first is mechanical.
| Area | Console surface | What a shim can do | Status |
|---|---|---|---|
| Object creation | CreateCommittedResource, CreateDescriptorHeap, CreatePipelineState | Mechanical forward; the flags and enums need translation tables | partial |
| Resource flags | XBOX heap flags, reserved and tiled resources | Console tiling has no PC equivalent; must be translated or flattened | blocking |
| Frame control | SetFrameIntervalX, SetGameConfigX, present behaviour | Console compositor assumptions; the shim can accept the calls but not honour the semantics | partial |
| Memory | XMem-backed heaps, GPU-visible CPU writes | Requires a second shim (xmem.dll) plus a staging strategy the title never had | blocking |
| Ray tracing | XboxBvhBuilder streams, XDXR acceleration structures | A different BVH format and a different builder API | blocking |
| Shaders | console DXBC, ACO-cooked pipeline state | Needs conversion to PC DXIL before any pipeline can be created | blocking |
The pattern in the last column is why the earlier conversion study ranked this direction where it did: translation of calls is tractable, translation of semantics is not.
Skeleton
Illustrative structure, not a working shim. The parts that compile are the parts that always compile; the part that does not is the Xbox prototype, which must come from the GDK headers.
; One export is a pure linker forward - no code, no thunk written by hand. LIBRARY d3d12_xs EXPORTS D3D12XboxCreateDevice ; implemented here D3D12SerializeVersionedRootSignature = d3d12.D3D12SerializeVersionedRootSignature D3D12ConfigureVirtualMemoryX ; implemented (stub) here
// The loader half. Note the search flag: it is the difference between // "routes to System32" and "recurses into itself until the stack dies". static HMODULE g_realD3D12 = nullptr; static bool LoadRealD3D12() { if (g_realD3D12) return true; g_realD3D12 = LoadLibraryExW(L"d3d12.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32); return g_realD3D12 != nullptr; } // Creative half: the prototype below MUST match the GXDK declaration exactly. // A wrong argument count is not a compile error here - it is a crash later. extern "C" HRESULT WINAPI D3D12XboxCreateDevice( IUnknown* pAdapter, const void* pXboxParams, REFIID riid, void** ppDevice) { if (!LoadRealD3D12() || !ppDevice) return E_FAIL; auto create = (PFN_D3D12CreateDevice)GetProcAddress(g_realD3D12, "D3D12CreateDevice"); ID3D12Device* real = nullptr; HRESULT hr = create(pAdapter, D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&real)); if (FAILED(hr)) return hr; // Returning 'real' is the trap from section 04: the vtable ends too early. return E_NOTIMPL; // a DeviceX wrapper goes here }
// Illustrative shape. Compiling this needs ID3D12DeviceX, i.e. the GDK headers, // or a hand-reconstructed vtable. That dependency is the real gate. class DeviceX final : public ID3D12DeviceX { public: explicit DeviceX(ID3D12Device* real) : m_real(real) {} // base methods: forward, translating enums and flags on the way HRESULT CreateCommittedResource(const D3D12_HEAP_PROPERTIES* heap, D3D12_HEAP_FLAGS flags, const D3D12_RESOURCE_DESC* desc, D3D12_RESOURCE_STATES state, const D3D12_CLEAR_VALUE* clear, REFIID riid, void** out) override { return m_real->CreateCommittedResource(heap, Translate(flags), desc, state, clear, riid, out); } // xbox tail: exactly three honest options - map, stub, refuse HRESULT SetFrameIntervalX(UINT, void*) override { return S_OK; } // ignore HRESULT GetXboxDeviceCaps(void*) override { return E_NOTIMPL; } // refuse private: ID3D12Device* m_real; long m_refs = 1; // + AddRef/Release, and every other interface };
The memory model does not translate
Console
One unified pool. The GPU sees what the CPU wrote without a copy. XMemAlloc hands out
physical pages with explicit mappings, and the title's budgets and residency decisions are built on
those numbers.
This is why the import table carries xmem.dll alongside d3d12_xs.dll: the
allocator is part of the graphics contract, not a separate concern.
PC
A separate VRAM pool with its own budgets. CPU writes need staging buffers or mapped upload heaps; readbacks go the other way. A title written to write-once-read-on-GPU will still work — it will just do it through a copy it never budgeted for.
So the shim needs a second DLL (xmem.dll) and a translation table, and the result is slower
and subtly different from what the engine's assertions expect.
Shaders and assets — the part no shim reaches
- Pipeline state can arrive pre-cooked. Console components ship cooked compute pipeline state for the console driver — the pattern is visible in this package's FidelityFX upscaler, which logs a fallback when its cooked part will not load. That fallback is the exception, not the rule; titles generally do not carry a PC-usable path.
- Console shader containers are not PC shader containers. They must be converted to PC DXIL before any pipeline can be created. The console OS does this conversion for itself; a shim running on Windows would have to bring its own converter.
- Assets are stored for console tiling. Textures and buffers are laid out for the console's swizzle modes. Reading them on a PC produces correctly sized, wrongly ordered data.
- Streaming assumes hardware decompression. The IO path expects a decompression block and a console queue model that a PC does not present.
Every one of those is upstream of the first draw call. A perfect d3d12_xs shim can get the
process to create a device and still never render a frame, because the frame needs shaders and textures that
the PC cannot consume as shipped.
Where it stops, in order
Verdict
Right pattern, wrong target — build it to learn, not to ship
As an interop exercise the proxy DLL is textbook and worth building: you get loader mechanics, a real .def forward, COM wrapper objects and a hard lesson in ABI. As a way to run this title, it reaches the third step of six and stops where every console-to-PC shim stops — at shaders and stored assets.
That is the same conclusion the conversion study reached from the import table alone, now demonstrated at the level of the one DLL that looked most promising.
What is legitimate here
Writing an original proxy DLL against a documented public API, and testing it against a binary you hold, is ordinary compatibility engineering. Nothing in this design needs a Microsoft binary, a leaked header or a key.
What is not: shipping or copying Microsoft's runtime, extracting and redistributing GDK headers, or distributing the game or anything derived from it. A shim is your code; the title is not.
If the goal is to learn this properly
The same skills apply to a target you can actually finish: take an open-source renderer or a GDK sample and build a translation layer between two real APIs — D3D12 to Vulkan, say, which is exactly what VKD3D does in the open.
You will implement the same wrapper objects, hit the same enum-translation problems and the same difference between a call that maps and a call whose meaning does not — with a result that runs.
Scope of this note
- Design analysis only. No shim was compiled, no proxy was placed in any loader path, and no binary was modified.
- The three exports and their roles come from the audited import table of
game_scarlett_master.exe; the console behaviour behind them is described from public documentation and the binary's own evidence. - The
D3D12XboxCreateDeviceprototype shown is illustrative. The real declaration lives in partner-gated GDK headers, and matching it exactly is a prerequisite the shim cannot work around. - Effort figures in the ladder are order-of-magnitude judgements, not measurements.