Repository navigation
Conversation
…onsole protection bits (RT-5) The retail executable's startup reserves three regions with XMemVirtualAlloc right after D3D12ConfigureVirtualMemoryX. Each must be non-null or the game breaks (0x80000003). Main's shim returned null for all three: - attributes 0x21, 0x3 and 0x183: refused (ERROR_NOT_SUPPORTED) "until their host mapping is known". The word is now taken and recorded once per value in the startup trace (note_attributes, the same "xmem_attributes" event XMemAlloc and XMemFree already write), so its bits can be read from real runs. None of them changes what a host reservation can give. - protect 0x801 and 0x22004: VirtualAlloc rejects the console bits above the Win32 ones (0x800, 0x2000, 0x20000). kHostProtectionMask keeps the base protection and the PAGE_GUARD/NOCACHE/WRITECOMBINE modifiers. A protection with no CPU protection left still fails, with ERROR_INVALID_PARAMETER. The 2 MiB page mode is still refused. That is ItsNotRexed#4531, and it is where the next reservation of the retail boot stops with this change. xmem_test: the attribute check now expects success. New checks cover the two console protections the executable passes (the region's protection from VirtualQuery), a kept PAGE_NOCACHE, and a console-only protection that is refused. With main's xmem.cpp the four new checks fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Closing as a duplicate, sorry for the noise. @Stalkerino's #6709 (opened 14:52) already serves the two 64 KiB startup reservations, with the exact (attribute, protection) pairs. The committed one with |
shayderrr
left a comment
There was a problem hiding this comment.
Summary
runtime/shims/xmem.cpp generalizes note_attributes() from a bool to an XmemApi enum, so a distinct xmem_attributes startup-trace event with "api":"XMemVirtualAlloc" is emitted per raw attribute word. XMemVirtualAlloc now accepts nonzero attribute words (0x21/0x3/0x183 observed in retail startup) that previously returned ERROR_NOT_SUPPORTED, and masks protect with the new kHostProtectionMask (0xFF | PAGE_GUARD | PAGE_NOCACHE | PAGE_WRITECOMBINE) to drop console graphics/cache bits, failing ERROR_INVALID_PARAMETER when no CPU protection remains. xmem_test.cpp covers accepted attributes, dropped bits and the no-CPU-protection case.
Why merge
Unblocks the first three RT-5 startup reservations; the 2 MiB mode stays explicitly refused as tracked in #4531.
Verdict: Approve
Summary
Why mergeUnblocks the first three RT-5 startup reservations; the 2 MiB mode stays explicitly refused as tracked in #4531. Verdict: Approve |
Claimed in the coordination issue: #6750 (comment) (the part of the RT-5 boot path past D3D-661 that nobody held)
What and why
On my own copy of the retail executable, right after
D3D12ConfigureVirtualMemoryX, startup reserves regions withxmem.dll!XMemVirtualAlloc. Each one must be non-null or the game breaks (0x80000003). The argument shapes:allocation_typeattributesprotectmain0x20402000(64 KiB pages, reserve)0x210x004attributes != 00x204020000x30x801attributes; the host also rejects0x8000x1830x22004attributes; the host also rejects0x2000,0x200000x20003000(2 MiB pages)0x1830x22004This PR makes 1 to 3 succeed:
xmem_attributeseventXMemAlloc/XMemFreealready write, now with"api":"XMemVirtualAlloc". So its layout can be read from real runs.kHostProtectionMaskkeeps the Win32 base protection andPAGE_GUARD/PAGE_NOCACHE/PAGE_WRITECOMBINE. The bits above them (0x800,0x2000,0x20000seen so far: graphics and cache attributes) are dropped, because the host has one kind of memory. A protection with no CPU protection left still fails, withERROR_INVALID_PARAMETER.XMemVirtualAlloc, so whichever lands second needs a small rebase. xmem: 4 MiB pages, and a title's VirtualAlloc with console page-size bits (what #6919 leaves) #4531 already conflicts withmain, and I'm glad to do the rebase on either side.Tested
Windows 11, MSVC RelWithDebInfo,
main1cc6e3c1:xmem_test: OK (111 checks). The attribute check now expects success. New checks cover:VirtualQuery;PAGE_NOCACHE;With
main'sxmem.cpp, the four new checks fail.Boot, own copy,
LEONIDA_UNIMPLEMENTED=log: the startup trace recordsxmem_attributesforXMemVirtualAllocwith0x21,0x3and0x183. The run now ends at reservation 4, the 2 MiB one.No game files: only argument shapes and counts from my own copy. AI-assisted (Claude Code).
🤖 Generated with Claude Code