From 709c8b6c2fb5bc288e0f1f4faf9caedc115e44f9 Mon Sep 17 00:00:00 2001 From: Georgeto Date: Sun, 13 Jun 2021 16:37:57 +0200 Subject: [PATCH] Script_CrashReport: Create crash log also for unhandled exceptions --- .../Script_CrashReport/Script_CrashReport.cpp | 16 ++++++++++++++++ source/SharedBase/ge_erroradmin.h | 4 +++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/source/Scripts/Script_CrashReport/Script_CrashReport.cpp b/source/Scripts/Script_CrashReport/Script_CrashReport.cpp index db7ae32..6b12829 100644 --- a/source/Scripts/Script_CrashReport/Script_CrashReport.cpp +++ b/source/Scripts/Script_CrashReport/Script_CrashReport.cpp @@ -7,6 +7,16 @@ namespace { + LONG WINAPI GenomeUnhandledExceptionFilter(EXCEPTION_POINTERS *ExceptionInfo) + { + return bCErrorAdmin::GetInstance().CallExceptionError(static_cast(ExceptionInfo)); + } + + LPTOP_LEVEL_EXCEPTION_FILTER WINAPI NopSetUnhandledExceptionFilter(LPTOP_LEVEL_EXCEPTION_FILTER) + { + return NULL; + } + class bCErrorAdmin_Helper : public bCErrorAdmin { public: @@ -128,6 +138,12 @@ namespace void ApplyHooks() { + // Show error dialog also if no frame-based exception is active + SetUnhandledExceptionFilter(GenomeUnhandledExceptionFilter); + // Prevent other modules that are loaded later to overwrite our exception handler + static mCFunctionHook Hook_SetUnhandledExceptionFilter; + Hook_SetUnhandledExceptionFilter.Hook(GetProcAddress("kernel32.dll", "SetUnhandledExceptionFilter"), &NopSetUnhandledExceptionFilter); + // Print modules and stack dump static mCFunctionHook Hook_bCErrorAdmin_PrintStackFrame; Hook_bCErrorAdmin_PrintStackFrame.Hook(PROC_SharedBase("?PrintStackFrame@bCErrorAdmin@@IAEXPAUbSException_Pointers@@@Z"), &bCErrorAdmin_PrintStackFrame); diff --git a/source/SharedBase/ge_erroradmin.h b/source/SharedBase/ge_erroradmin.h index 35505d9..e6fd259 100644 --- a/source/SharedBase/ge_erroradmin.h +++ b/source/SharedBase/ge_erroradmin.h @@ -17,7 +17,9 @@ enum bEErrorType bEErrorType_ForceDWORD = GE_FORCE_DWORD }; -typedef EXCEPTION_POINTERS bSException_Pointers; +struct bSException_Pointers : public EXCEPTION_POINTERS +{ +}; class GE_DLLIMPORT bCErrorAdmin {