SetUnhandledExceptionFilter

#include <windows.h>

LONG WINAPI MyUnhandledExceptionFilter(PEXCEPTION_POINTERS pExceptionPointers);

int main() {
    SetUnhandledExceptionFilter(MyUnhandledExceptionFilter);

    // Your program logic goes here

    return 0;
}

LONG WINAPI MyUnhandledExceptionFilter(PEXCEPTION_POINTERS pExceptionPointers) {
    // Your exception handling logic goes here

    // Return EXCEPTION_CONTINUE_SEARCH to allow default handling
    // Return EXCEPTION_EXECUTE_HANDLER to suppress default handling

    return EXCEPTION_CONTINUE_SEARCH;
}