.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.
| 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 | |
| 770 | extern "C" void BTCpuSimulateImpl(CONTEXT* entry_context) { |
| 771 | auto TLS = GetTLS(); |
nothing calls this directly
no outgoing calls
no test coverage detected