Control flow that leaves a function without returning from it, and the three
places the toolkit got it wrong.
Non-local jumps. A recompiled function is a real C function, so restoring the
guest esp is only half of a longjmp: the abandoned frames stay on the native
stack and control returns into them once the resume point finishes. Each guest
jmp_buf is now paired with a native one taken at the setjmp call site, the only
place a native setjmp is valid, so the frames actually unwind. The CRT's pair is
detected by the "VC20" cookie MSVC stamps into every jmp_buf.
Frameless callees inherited a dead frame: ebp is read through g_seh_ebp, but
only tail jumps and the SEH helpers ever wrote it, so one reached by an ordinary
call got whatever the last tail jump left behind. Published wherever g_ebp is.
The fs: segment prefix was dropped, putting the TIB at guest address 0 - where a
null pointer also lands. A null check written as "cmp byte [ecx], 0" read the
exception chain head's 0xFF and passed; a null store overwrote that head instead
of faulting. Segment overrides are recorded and based at XBOX_FS_BASE, leaving
page zero free for RECOMP_TRAP_NULL to trap.
Kernel exports implemented but never dispatched: RtlUnwind, XeLoadSection,
XeUnloadSection, NtSuspendThread. Each returned success without acting, which is
worse than a stub. NtSuspendThread was the costly one - a worker that parked
itself never stopped, spinning 289M kernel calls; now 9,789.
MCPX APU never started: the frame thread idles on pause_requested, which init
sets and only the test tone ever cleared, so a title enabling the APU through
SECTL/FECTL got an APU that stayed asleep.
cvtps2pi / cvttps2pi implemented; 36 sat inside one title's WMV decoder as
no-op comments.
New xbox_video library: Media Foundation FMV decode onto a D3D8 texture, plus a
window on the guest framebuffer. Orientation comes from IMF2DBuffer's pitch
sign rather than the RGB32 convention, which had the video upside down.
Diagnostics, since a recompiled title offers no debugger: tools/stackwalk.py
guest backtraces, RECOMP_WATCHDOG_SECS, RECOMP_TRACE_ARGS/DEREF, RECOMP_PEEK
and PEEK_CHAIN, RECOMP_WATCH_VA, RECOMP_PB_SCAN/PB_EXEC, RECOMP_FB_WINDOW.
Fixed: duplicate trace symbols broke the link for any title defining its own
recomp_trace_*; they now live once in the kernel.
Verified: 4639 + 211 conformance vectors 0 mismatches, 146 tests, Halo builds.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PZDe6qTWAvohfDtYXbpRyM