X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=os_win32.cpp;h=587503c41553fa7cd013cf5ad28862fa34f938a7;hb=46c4a32730c5b52c119376042a84a6773d8d789f;hp=a35e2a3c0229aec6c7a6646c8893790be5c5f997;hpb=f32476d63b395c2d844247bd4d7fae4173df4065;p=apitrace diff --git a/os_win32.cpp b/os_win32.cpp index a35e2a3..587503c 100644 --- a/os_win32.cpp +++ b/os_win32.cpp @@ -137,21 +137,12 @@ Abort(void) static LPTOP_LEVEL_EXCEPTION_FILTER prevExceptionFilter = NULL; - -static void (*handler)(int) = NULL; +static void (*gCallback)(void) = NULL; static LONG WINAPI UnhandledExceptionFilter(PEXCEPTION_POINTERS pExceptionInfo) { - if (handler) { - int exceptionCode = 0; - if (pExceptionInfo) { - PEXCEPTION_RECORD pExceptionRecord = pExceptionInfo->ExceptionRecord; - if (pExceptionRecord) { - exceptionCode = pExceptionRecord->ExceptionCode; - } - } - - handler(exceptionCode); + if (gCallback) { + gCallback(); } if (prevExceptionFilter) { @@ -162,18 +153,23 @@ static LONG WINAPI UnhandledExceptionFilter(PEXCEPTION_POINTERS pExceptionInfo) } void -CatchInterrupts(void (*func)(int)) +SetExceptionCallback(void (*callback)(void)) { - assert(!handler); - assert(!prevExceptionFilter); + assert(!gCallback); - handler = func; + if (!gCallback) { + gCallback = callback; - if (handler && !prevExceptionFilter) { - prevExceptionFilter = - SetUnhandledExceptionFilter(UnhandledExceptionFilter); + assert(!prevExceptionFilter); + prevExceptionFilter = SetUnhandledExceptionFilter(UnhandledExceptionFilter); } } +void +ResetExceptionCallback(void) +{ + gCallback = NULL; +} + } /* namespace OS */