#ifndef __APPLE__
// Check if the PC is the return address from the SEHProcessException in the common_signal_handler.
- // If that's the case, extract its local variable containing the native_context_t of the hardware
+ // If that's the case, extract its local variable containing the windows style context of the hardware
// exception and return that. This skips the hardware signal handler trampoline that the libunwind
// cannot cross on some systems.
if ((void*)curPc == g_SEHProcessExceptionReturnAddress)
{
- ULONG contextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT | CONTEXT_EXCEPTION_ACTIVE;
-
- #if defined(_AMD64_)
- contextFlags |= CONTEXT_XSTATE;
- #endif
- size_t nativeContext = *(size_t*)(CONTEXTGetFP(context) + g_common_signal_handler_context_locvar_offset);
- CONTEXTFromNativeContext((const native_context_t *)nativeContext, context, contextFlags);
+ CONTEXT* nativeContext = *(CONTEXT**)(CONTEXTGetFP(context) + g_common_signal_handler_context_locvar_offset);
+ memcpy_s(context, sizeof(CONTEXT), nativeContext, sizeof(CONTEXT));
return TRUE;
}
struct sigaction g_previous_activation;
#endif
-// Offset of the local variable containing native context in the common_signal_handler function.
+// Offset of the local variable containing pointer to windows style context in the common_signal_handler function.
// This offset is relative to the frame pointer.
int g_common_signal_handler_context_locvar_offset = 0;
#endif // !HAVE_MACH_EXCEPTIONS
native_context_t *ucontext;
ucontext = (native_context_t *)sigcontext;
- g_common_signal_handler_context_locvar_offset = (int)((char*)&ucontext - (char*)__builtin_frame_address(0));
+ g_common_signal_handler_context_locvar_offset = (int)((char*)&contextRecord - (char*)__builtin_frame_address(0));
AllocateExceptionRecords(&exceptionRecord, &contextRecord);