]> git.cworth.org Git - apitrace/blobdiff - os_win32.cpp
Some initial thoughts on the on-demand loading api.
[apitrace] / os_win32.cpp
index a35e2a3c0229aec6c7a6646c8893790be5c5f997..587503c41553fa7cd013cf5ad28862fa34f938a7 100644 (file)
@@ -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 */