From aed5feb7ca0bf5d543c85448f71119623a92014c Mon Sep 17 00:00:00 2001 From: nmlgc Date: Thu, 31 Aug 2017 21:26:28 +0200 Subject: [PATCH] exception: Only report selected exceptions. Unfortunately, we tend to get way more than we want, particularly with wininet. Using AddVectoredExceptionHandler(0) to register our handler as the last one to be called doesn't seem to work either. --- thcrap/src/exception.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/thcrap/src/exception.cpp b/thcrap/src/exception.cpp index 6eb09e71..43279e6e 100644 --- a/thcrap/src/exception.cpp +++ b/thcrap/src/exception.cpp @@ -44,8 +44,20 @@ void log_print_rva_and_module(HMODULE mod, void *addr) LONG WINAPI exception_filter(LPEXCEPTION_POINTERS lpEI) { LPEXCEPTION_RECORD lpER = lpEI->ExceptionRecord; - HMODULE crash_mod = GetModuleContaining(lpER->ExceptionAddress); + // These should be all that matter. Unfortunately, we tend + // to get way more than we want, particularly with wininet. + switch(lpER->ExceptionCode) { + case STATUS_ACCESS_VIOLATION: + case STATUS_ILLEGAL_INSTRUCTION: + case STATUS_INTEGER_DIVIDE_BY_ZERO: + case 0xE06D7363: /* MSVCRT exceptions, doesn't seem to have a name */ + break; + default: + return EXCEPTION_CONTINUE_SEARCH; + } + + HMODULE crash_mod = GetModuleContaining(lpER->ExceptionAddress); log_printf( "\n" "===\n" @@ -72,7 +84,7 @@ LONG WINAPI exception_filter(LPEXCEPTION_POINTERS lpEI) while( GetModuleContaining(trace[skip]) != crash_mod && skip < captured - ) { + ) { skip++; } } @@ -94,5 +106,5 @@ LONG WINAPI exception_filter(LPEXCEPTION_POINTERS lpEI) void exception_init(void) { - AddVectoredExceptionHandler(1, exception_filter); + AddVectoredExceptionHandler(0, exception_filter); }