Skip to content

Commit

Permalink
Script_CrashReport: Create crash log also for unhandled exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
georgeto committed Jun 13, 2021
1 parent 5eedfce commit 709c8b6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
16 changes: 16 additions & 0 deletions source/Scripts/Script_CrashReport/Script_CrashReport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@

namespace
{
LONG WINAPI GenomeUnhandledExceptionFilter(EXCEPTION_POINTERS *ExceptionInfo)
{
return bCErrorAdmin::GetInstance().CallExceptionError(static_cast<bSException_Pointers *>(ExceptionInfo));
}

LPTOP_LEVEL_EXCEPTION_FILTER WINAPI NopSetUnhandledExceptionFilter(LPTOP_LEVEL_EXCEPTION_FILTER)
{
return NULL;
}

class bCErrorAdmin_Helper : public bCErrorAdmin
{
public:
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion source/SharedBase/ge_erroradmin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit 709c8b6

Please sign in to comment.