Skip to content

d3d12_xs: serve D3D12ConfigureVirtualMemoryX, the retail executable's first d3d12_xs call (D3D-661) - #7017

Closed
Spaghetih wants to merge 1 commit into
ProjectLeonida:mainfrom
Spaghetih:d3d661-configure-virtual-memory
Closed

Spaghetih wants to merge 1 commit into
ProjectLeonida:mainfrom
Spaghetih:d3d661-configure-virtual-memory

Conversation

@Spaghetih

Copy link
Copy Markdown
Contributor

D3D-661 (claimed in #6603: #6603 (comment)). It is the first unimplemented import the retail executable reaches under gta6rt --run (reported by @undeadhuman37, @mrp1no and @kapitche).

What the title does with it

A static look at the 1.0.2.1 game_scarlett_master.exe on my own copy. Only argument shapes and checks are given here; no code or bytes from the image:

  • The import has one jump thunk and one call site, in a startup function.
  • One argument: a pointer to a 32-byte block on the caller's stack, as @mrp1no found.
  • The caller zeroes the block and sets only the second 32-bit word, a value derived from the size of the XMemVirtualAlloc reservation it makes right after.
  • The result is checked only for success (>= 0; a failure hits an int 3).
  • The block is input only: its address is used once, to pass it, and nothing reads it after the call. This answers @Jess-Doit's hypothesis in Coordinating who works on what (39) (moved to #6910) #6750 (Coordinating who works on what (39) (moved to #6910) #6750 (comment)): the later 0xC0000005 read of 0xFFFFFFFFFFFFFFFF does not come from this block being left unwritten.

Change

  • runtime/shims/d3d12_xs.cpp: D3D12ConfigureVirtualMemoryX(const void* config) logs the block as 8 x 32-bit words (or null) and returns S_OK through d3d12_trace::result. The PC/Vulkan device has no GPU virtual-address layout to configure. Only the first argument is read.
  • runtime/test/root_sig_test.cpp: the registry exposes the entry, it returns S_OK for a 32-byte block and for null, and it leaves the block unchanged.
  • docs/d3d12_xs_surface.md: row 4 goes from absent to present.

This doesn't change the run's outcome by itself: the default unimplemented thunk returns 0 too, which the title accepts. The next stop is XMemVirtualAlloc with nonzero attributes and the console protection bits, which belongs to #4531 and the xmem items. What this PR changes: the import is now served and logged instead of going through the unimplemented thunk.

Tested

Windows 11 (26200), RTX 4070 Ti, driver 621.24, MSVC 14.44, scripts/build_runtime.ps1 on main 1cc6e3c1:

  • the full runtime build passes (598 targets);
  • root_sig_test: OK, 0 failures, including the 4 new checks;
  • gta6rt --dry-run game_scarlett_master.exe (own 1.0.2.1 copy): d3d12_xs.dll!D3D12ConfigureVirtualMemoryX now binds as shim; the executable's unimplemented imports go from 30 to 29, with none left in d3d12_xs.dll.

I did not run --run with this build.

AI-assisted (Claude Code).

… first d3d12_xs call (D3D-661)

The 1.0.2.1 executable calls it once, with a pointer to a 32-byte input block, and checks only for success. The PC device has no GPU virtual-address layout to configure, so the shim logs the block and returns S_OK.

AI-assisted (Claude Code).
@mrp1no

mrp1no commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 855e41f0 on Windows 11, MSVC RelWithDebInfo, merged onto main bd3f061ad, against my own copy of the retail executable (outcomes only):

AI-assisted (Claude Code).

@Zunraz

Zunraz commented Nov 23, 2026

Copy link
Copy Markdown

Independent Windows x64 check of 855e41f0701d42d70072b918619766e587326579, integrated onto main e6190e7b5 with #6991's trace opener and the RT-488 cache change. clang-cl 21.1.8 + xwin SDK 10.0.26100, static CRT, binaries executed natively on Windows build 26300. CPU only.

No GPU/rendering claim. The debugger stopped before DNS, socket creation or network transmission. No game files, raw traces, title offsets or register contents included. AI-assisted (Codex).

@gkissel

gkissel commented Nov 23, 2026

Copy link
Copy Markdown

Tested 855e41f0 under Wine 11.21 (Linux, clang-cl + xwin cross build, RelWithDebInfo), LEONIDA_D3D12=vulkan, GTX 1650 Mobile 4 GB, retail 1.0.2.1 executable (own copy). Merged locally on top of #4313 (28ea6b97), because on Wine main faults earlier, in host_module_name (see my comment on #4313). The conflicts were the ones described in #4313's thread: on_host_thread_event keeps forget_ended_thread_id() / release_existing_blocks_of_this_thread() in front of #4313's kTlsSlotCount loops; CMake/README keep both sides. Outcomes only:

  • gta6rt --run, 3 runs: the call is served and logs its 32-byte block (only the second word nonzero, as described). The trace has no unimplemented_call event any more.
  • The stop is unchanged, 3/3: the title's own int3 at the same place as with the default thunk (exit 3). That matches the note in the description (the default thunk also returns 0), and the Windows reports above that the next check is XMemVirtualAlloc's.

So on Wine this PR behaves as on Windows. Nothing new to fix here from my side.

AI-assisted (Claude Code); runs done on my machine.

@Spaghetih

Copy link
Copy Markdown
Contributor Author

Closing as a duplicate of #6792 (undeadhuman37), merged at 15:58, which serves the same import the same way. My search before opening this one missed it. One fact from my static look that #6792 doesn't state, in case it helps whoever reads the boot chain: the 32-byte block is input only. Its address is used once, to pass it, and nothing reads it after the call, so later faults don't come from it being left unwritten. AI-assisted (Claude Code).

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.

4 participants