Repository navigation
xmem: record XMemVirtualAlloc's attribute word and drop the PAGE_GRAPHICS_* protection bits (retail exe GPU pools) - #6908
Conversation
…HICS_* protection bits (retail exe GPU pools)
|
Tested Result: both startup reservations now succeed.
On In 3 of 5 runs, the game now gets past both checks and stops at a later one. The other 2 hit the intermittent early TLS crash that #4313 fixes; that's unrelated to this PR. The next stop: an Tested and written by Claude (Claude Code). |
shayderrr
left a comment
There was a problem hiding this comment.
Summary
In runtime/shims/xmem.cpp, note_attributes now takes an API name so XMemAlloc/XMemFree trace text is unchanged while XMemVirtualAlloc records its attribute word and size (kNoSize sentinel). The ERROR_NOT_SUPPORTED refusal for nonzero attributes is removed. New kPageGraphicsMask (0x0007F800) and host_protect() strip the console PAGE_GRAPHICS_* bits, falling back to PAGE_NOACCESS, and are applied in both XMemVirtualAlloc and TitleVirtualAlloc. runtime/test/xmem_test.cpp covers attributes 0x21/0x3/0x183 and the trace event.
Why merge
On the retail engine exe all five startup XMemVirtualAlloc calls passed graphics protection bits and hit an int3 when NULL was returned. Dropping those host-rejected bits lets gta6rt --run get the GPU pools allocated and boot through TLS/XGameRuntime init — essential for static recompilation of the retail executable.
Verdict: Approve
SummaryIn Why mergeOn the retail engine exe all five startup Verdict: Approve |
…emVirtualAlloc takes 2 MiB pages and placeholders Serve the seven xmem.dll imports the shim table lacked, with argument shapes measured at a title's call sites: - XMemAllocDefault / XMemFreeDefault share XMemAlloc's heap. - XMemAllocatePhysicalPages / XMemFreePhysicalPages / XMemMapPhysicalPages / XMemMapPhysicalPagesScatter: 64 KiB pages of pagefile-backed sections, one MapViewOfFile3 view per page in a placeholder window, so pages keep their contents across remaps and can alias. Page numbers are non-zero multiples of 16 below 2^25; 0 unmaps. - XMemIsToolsMemAvailable returns FALSE. XMemVirtualAlloc no longer refuses 2 MiB pages (aligned through VirtualAlloc2), makes reserve-only 64 KiB regions placeholder windows, and passes MEM_RESERVE_PLACEHOLDER and MEM_REPLACE_PLACEHOLDER through. The attribute word and PAGE_GRAPHICS_* handling from ItsNotRexed#6908 is kept as is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…emVirtualAlloc takes 2 MiB pages and placeholders Serve the seven xmem.dll imports the shim table lacked, with argument shapes measured at a title's call sites: - XMemAllocDefault / XMemFreeDefault share XMemAlloc's heap. - XMemAllocatePhysicalPages / XMemFreePhysicalPages / XMemMapPhysicalPages / XMemMapPhysicalPagesScatter: 64 KiB pages of pagefile-backed sections, one MapViewOfFile3 view per page in a placeholder window, so pages keep their contents across remaps and can alias. Page numbers are non-zero multiples of 16 below 2^25; 0 unmaps. - XMemIsToolsMemAvailable returns FALSE. XMemVirtualAlloc no longer refuses 2 MiB pages (aligned through VirtualAlloc2), makes reserve-only 64 KiB regions placeholder windows, and passes MEM_RESERVE_PLACEHOLDER and MEM_REPLACE_PLACEHOLDER through. The attribute word and PAGE_GRAPHICS_* handling from ItsNotRexed#6908 is kept as is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sNotRexed#6792) XMemVirtualAlloc now takes the attribute word and drops the PAGE_GRAPHICS_* bits (ItsNotRexed#6908). It still refuses the 2 MiB page mode (0x20003000), which 4 of the 14 fatal sites pass; the other 10 reach VirtualAlloc. The 6 calls refused for 0x4000/0x40000 are not fatal sites. D3D12ConfigureVirtualMemoryX has a shim returning S_OK (ItsNotRexed#6792), so it moves from "No binding" to the shims table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claims #6603 (comment)
XMemVirtualAllocrefused every nonzero attribute word, and the host refuses the console'sPAGE_GRAPHICS_*protection bits (ERROR_INVALID_PARAMETER), so the retail engine exe's GPU memory pools got NULL.note_attributesnow takes the API name;XMemAllocandXMemFreeevent text is unchanged.XMemVirtualAllocrecords its attribute word and size, and theERROR_NOT_SUPPORTEDrefusal for nonzero attributes is gone. The word is recorded, not applied, as forXMemAlloc.kPageGraphicsMask(0x0007F800) andhost_protect()drop the graphics bits (falling back toPAGE_NOACCESSif nothing is left). Applied inXMemVirtualAllocand in the titleVirtualAllocshim.ERROR_NOT_SUPPORTEDhere; that is xmem: 4 MiB pages, and a title's VirtualAlloc with console page-size bits (what #6919 leaves) #4531's job.Measured on the retail engine exe (1.0.2.1) under
gta6rt --run: fiveXMemVirtualAlloccalls at startup. Attributes 0x21 and 0x3 are reserve-only, 64 KiB pages, 24 GiB, with protectPAGE_READWRITE/ 0x801. Attributes 0x183, 0x283 and 0x181 are committed, 2 MiB pages, with protect 0x22004 (PAGE_READWRITE|PAGE_GRAPHICS_READWRITE|PAGE_GRAPHICS_COHERENT). Each is followed by an int3 when NULL is returned. With this change plus #4531 (2 MiB pages) all five succeed and the boot proceeds to TLS/XGameRuntime init.Overlap: this generalises #6709's allowlist (same lines; whichever lands first, the other rebases) and complements #4531.
Tests (
runtime/test/xmem_test.cpp): the "nonzero attributes are rejected" check is replaced by attributes 0x21 (64 KiB pages, 8 GiB, reserve-only), 0x3 with protect 0x801 (PAGE_NOACCESS), 0x183 with protect 0x22004 (PAGE_READWRITE, writable); a titleVirtualAllocwith protect 0x2004 commits PAGE_READWRITE; the trace test gets oneXMemVirtualAllocevent with attributes and size.ctest -R xmem: passed.AI-assisted.