tooling: keep the entry register when resolving xmem attribute callers #755
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/761"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by FZNull on 2026-11-23T01:22:22Z.
Problem
tools/xmem_attribute_scan.pyreports where the attribute word inRDXcomes from. WhenScan.walk()follows a register copy such asmov rdx, r8back to a function entry,Scan.block_start()returned an"argument"node without recording which register reached the entry, andScan.finish()resolved the direct callers with the defaultRDX. A pass-through that receives the word inR8therefore reported the caller'sRDXinstead of itsR8.Reproduction with the source-built fixture patched so
call_clobbersetsEDX = 0x05e50000andR8D = 0xa8004000andcomputed_wordrunsmov rdx, r8; jmp [__imp_XMemAlloc]:Expected
0xa8004000; observed0x5e50000.Change
Scan.walk()passes the tracked register toScan.block_start(), which records it on the"argument"node ("register": "R8").truncate()marks an"argument"node"truncated": truewhen a 32-bit copy led to the entry (it already masked constants).Scan.finish()resolves each caller with the recorded entry register instead of the defaultRDX, and applies the 32-bit truncation to the resolved caller word.tests/cpu/xmem_attributes.asmgains two exports:caller_copy(caller setsEDX=0x5e50000,R8D=0xa8004000; calleemov rdx, r8) andcaller_copy_low(caller setsR8=0x1a8004000; calleemov edx, r8d).tests/xmem_attribute_scan_check.pyrequires both to resolve0xa8004000fromR8, checks the truncation flag, and the summary counts 25 sites.docs/experiments.mdrecords the entry-register rule and the two new forms.Verification
Environment: Windows 11, Python 3.13.12 (
out/pe-env: pefile 2024.8.26, iced-x86 1.21.0), MSVC 19.50.35726, Windows SDK 10.0.26100.0, CMake 4.5.1 + Ninja.Results: configure exit 0; build
[1355/1355]exit 0;1/1 Test #122: xmem_attribute_scan ... Passedwithdecoding: 13 cases passed,fixture: 25 sites, summary and exit codes passed,delay-load fixture: 1 site and exit codes passed.ctest -R 'xmem'is 5/5.With the fix the reproduction resolves:
Negative controls, run with mutant copies of the scanner: resolving callers with the default
RDXfails the check with0x5e50000; dropping the 32-bit truncation fails it with0x1a8004000(memory type 13, null).No game files, dumps or distribution links are used; the fixture is source-built MASM.
Fixes #747