Skip to content

Commit 709c8b6

Browse files
committed
Script_CrashReport: Create crash log also for unhandled exceptions
1 parent 5eedfce commit 709c8b6

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

source/Scripts/Script_CrashReport/Script_CrashReport.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77

88
namespace
99
{
10+
LONG WINAPI GenomeUnhandledExceptionFilter(EXCEPTION_POINTERS *ExceptionInfo)
11+
{
12+
return bCErrorAdmin::GetInstance().CallExceptionError(static_cast<bSException_Pointers *>(ExceptionInfo));
13+
}
14+
15+
LPTOP_LEVEL_EXCEPTION_FILTER WINAPI NopSetUnhandledExceptionFilter(LPTOP_LEVEL_EXCEPTION_FILTER)
16+
{
17+
return NULL;
18+
}
19+
1020
class bCErrorAdmin_Helper : public bCErrorAdmin
1121
{
1222
public:
@@ -128,6 +138,12 @@ namespace
128138

129139
void ApplyHooks()
130140
{
141+
// Show error dialog also if no frame-based exception is active
142+
SetUnhandledExceptionFilter(GenomeUnhandledExceptionFilter);
143+
// Prevent other modules that are loaded later to overwrite our exception handler
144+
static mCFunctionHook Hook_SetUnhandledExceptionFilter;
145+
Hook_SetUnhandledExceptionFilter.Hook(GetProcAddress("kernel32.dll", "SetUnhandledExceptionFilter"), &NopSetUnhandledExceptionFilter);
146+
131147
// Print modules and stack dump
132148
static mCFunctionHook Hook_bCErrorAdmin_PrintStackFrame;
133149
Hook_bCErrorAdmin_PrintStackFrame.Hook(PROC_SharedBase("?PrintStackFrame@bCErrorAdmin@@IAEXPAUbSException_Pointers@@@Z"), &bCErrorAdmin_PrintStackFrame);

source/SharedBase/ge_erroradmin.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ enum bEErrorType
1717
bEErrorType_ForceDWORD = GE_FORCE_DWORD
1818
};
1919

20-
typedef EXCEPTION_POINTERS bSException_Pointers;
20+
struct bSException_Pointers : public EXCEPTION_POINTERS
21+
{
22+
};
2123

2224
class GE_DLLIMPORT bCErrorAdmin
2325
{

0 commit comments

Comments
 (0)