tooling: report unreadable images in xmem_attribute_scan without a traceback #657
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/663"
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 louisdibiasi on 2026-11-22T18:29:43Z.
Change
tools/xmem_attribute_scan.pyreads the image with pefile and rejects non-x64 images, butmain()did not catch the resulting errors. A non-PE file, an empty file, a missing file and an x86 image each ended in a traceback with exit status 1. Status 1 is also what--fail-on-nulland--fail-on-unresolvedreturn when a gate trips, so an unreadable input looked like a gate result. This reportsOSError,ValueErrorandPEFormatErroras<image>: <message>and exits with status 2, leaving 1 for the gates.Independent problem, no linked issue.
Verification
Commit under test:
74da052on719552e, Windows 11, Python 3.12.10, pefile 2024.8.26.python -B tools/xmem_attribute_scan.py <image> --fail-on-null, base vs this branch:pefile.PEFormatError: 'DOS Header magic not found.'traceback, exit 1<path>: 'DOS Header magic not found.', exit 2PEFormatError: 'The file is empty', exit 1FileNotFoundError, exit 1C:\Windows\SysWOW64\kernel32.dll(x86,--fail-on-unresolved)ValueError: Expected an x64 image, exit 1...kernel32.dll: Expected an x64 image, exit 2New
check_unreadable_image_is_not_a_gate_resultintests/xmem_attribute_scan_check.pyruns the first three inputs with both gate flags and requires exit 2, the file name in stderr and no traceback; it runs in the no-argument CI invocation. The x86 row is a manual check; I have no portable x86 fixture.python -B tests/xmem_attribute_scan_check.pyfails (traceback from the non-PE case).decoding: 13 cases passed, exit 0.python -B tests/xmem_attribute_scan_check.py cpu_xmem_attributes.dll cpu_xmem_delay.dllstill reportsfixture: 23 sites, summary and exit codes passedanddelay-load fixture: 1 site and exit codes passed, so the gate statuses (0, 1, 1) are unchanged.Evidence and follow-up
Synthetic bytes only. I chose status 2 rather than the usual 1 for tool errors so it does not collide with the documented gates; happy to change it.
Checklist
AI-assisted: I used Claude to find the bug and draft the change. I ran the reproductions and tests above myself.