windows SetUnhandledExceptionFilter

EXCEPTION_RECORD: "https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-exception_record"

SetUnhandledExceptionFilter:

bool g_showCrashDialog = false;

LONG WINAPI OurCrashHandler(EXCEPTION_POINTERS * /*ExceptionInfo*/)
{
    std::cout << "Gotcha!" << std::endl;

    return g_showCrashDialog ? EXCEPTION_CONTINUE_SEARCH : EXCEPTION_EXECUTE_HANDLER;
}


int main()
{
    ::SetUnhandledExceptionFilter(OurCrashHandler);

    std::cout << "Normal null pointer crash" << std::endl;

    char *p = 0;
    *p = 5;
}
posted @ 2022-05-02 21:35  mtgold  阅读(56)  评论(0编辑  收藏  举报