MCPcopy Create free account
hub / github.com/FEX-Emu/FEX / BTCpuSimulate

Function BTCpuSimulate

Source/Windows/WOW64/Module.cpp:753–768  ·  view source on GitHub ↗

.seh_pushframe doesn't restore the frame pointer, so if when unwinding from RtlCaptureContext an operation is used that sets SP from FP, the unwound SP value will be incorrect. Wrap RtlCaptureContext so the correct FP is immediately restored from the stack to prevent this.

Source from the content-addressed store, hash-verified

751// that sets SP from FP, the unwound SP value will be incorrect. Wrap RtlCaptureContext so the correct FP is immediately
752// restored from the stack to prevent this.
753__attribute__((naked)) void BTCpuSimulate() {
754 asm(".seh_proc BTCpuSimulate;"
755 "sub sp, sp, #0x390;"
756 ".seh_stackalloc 0x390;"
757 "stp x29, x30, [sp, #-0x10]!;"
758 ".seh_save_fplr_x 16;"
759 ".seh_endprologue;"
760 "add x0, sp, #0x10;"
761 "bl RtlCaptureContext;"
762 "add x0, sp, #0x10;"
763 "bl BTCpuSimulateImpl;"
764 "ldp x29, x30, [sp], 0x10;"
765 "add sp, sp, #0x390;"
766 "ret;"
767 ".seh_endproc;");
768}
769
770extern "C" void BTCpuSimulateImpl(CONTEXT* entry_context) {
771 auto TLS = GetTLS();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected