Raise and catch SEH exceptions inside a mapped image #65
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/65"
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 Leyukaka on 2026-11-21T14:54:16Z.
Change
Item 4 of #46: a separate fixture that raises and catches an exception inside an image mapped by
tools/pe_map.cpp.tests/cpu/seh_route.asm:guarded_load(address, mode, trace)names its own language-specific handler throughPROC FRAME:on_fault. The built image has oneRUNTIME_FUNCTION, withUNWIND_INFOflags EHANDLER|UHANDLER. The handler resumes only an access violation raised by the load instruction itself: it checksExceptionAddress, then setsCONTEXT.Ripto a recovery label andCONTEXT.Raxto a fixed value. It declines everything else and every unwind call.tests/cpu/native_seh_check.py(cpu_native_seh): runs the same four cases against the Windows-loaded original and the mapped copy, each target in its own child process. If an unwind is broken, only the child crashes, and the test reports it as a failed check.ud2is declined and unwinds through the mapped frame to the ctypes caller, which reports0xc000001d. The trace shows that the function ran up toud2.docs/experiments.mdnow describes this case, and SEH is removed from its list of open items.Verification
At
5995954onec05dab(Windows 11 build 26300, VS Build Tools 17.14, Python 3.14.10):The full suite gives 73 tests and 0 failures; only
bvh_wave64_hardwareandbvh_wave64_warpare skipped.As one-off manual checks (not in CI), I disabled
.pdataregistration inpe_map. The mapped child then crashes with0xc0000005and the test fails. I also madeon_faultdecline everything, which fails both the native and the mapped targets.Evidence and follow-up
The fixture is original and built from this repository; there is no game data. CI runs Python 3.12, and I only ran 3.14 locally. ctypes reports an unhandled SEH code through
OSError.winerror, and the test masks it to 32 bits. TLS callbacks and entry-point calls remain open inpe_map.Refs #46
AI-assisted.