From fb4e34d1783fa9c82e3523423280425c106aa1f5 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 8 Dec 2016 13:07:52 +0100 Subject: [PATCH] Fix crash reporter for 64 bit --- src/win32/i_main.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/win32/i_main.cpp b/src/win32/i_main.cpp index db92467bc..0931aff99 100644 --- a/src/win32/i_main.cpp +++ b/src/win32/i_main.cpp @@ -1184,6 +1184,11 @@ void CALLBACK ExitFatally (ULONG_PTR dummy) // //========================================================================== +namespace +{ + CONTEXT MainThreadContext; +} + LONG WINAPI CatchAllExceptions (LPEXCEPTION_POINTERS info) { #ifdef _DEBUG @@ -1208,11 +1213,7 @@ LONG WINAPI CatchAllExceptions (LPEXCEPTION_POINTERS info) // Otherwise, put the crashing thread to sleep and signal the main thread to clean up. if (GetCurrentThreadId() == MainThreadID) { -#ifndef _M_X64 - info->ContextRecord->Eip = (DWORD_PTR)ExitFatally; -#else - info->ContextRecord->Rip = (DWORD_PTR)ExitFatally; -#endif + *info->ContextRecord = MainThreadContext; } else { @@ -1304,6 +1305,15 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE nothing, LPSTR cmdline, int n if (MainThread != INVALID_HANDLE_VALUE) { SetUnhandledExceptionFilter (CatchAllExceptions); + + static bool setJumpResult = false; + RtlCaptureContext(&MainThreadContext); + if (setJumpResult) + { + ExitFatally(0); + return 0; + } + setJumpResult = true; } #endif