Skip to content

Instantly share code, notes, and snippets.

@TheEpicFace007
Last active March 2, 2021 18:56
Show Gist options
  • Save TheEpicFace007/14816335fb67a2e421b2611c9daf997e to your computer and use it in GitHub Desktop.
Save TheEpicFace007/14816335fb67a2e421b2611c9daf997e to your computer and use it in GitHub Desktop.
ignore all exception
#include <Windows.h>
#include <iostream>
LONG WINAPI RedirectedSetUnhandledExceptionFilter(EXCEPTION_POINTERS *ExceptionInfo);;
int main()
{
SetUnhandledExceptionFilter(RedirectedSetUnhandledExceptionFilter);
}
LONG WINAPI RedirectedSetUnhandledExceptionFilter(EXCEPTION_POINTERS *ExceptionInfo)
{
auto result = MessageBoxA(NULL, "An exception has been caught. Do you wish to continue the execution of the program?", "Exception handling", MB_ICONQUESTION | MB_YESNO);
if (result == IDYES)
return EXCEPTION_CONTINUE_EXECUTION;
else
return EXCEPTION_EXECUTE_HANDLER;
}
#include <Windows.h>
#include <iostream>
LONG WINAPI RedirectedSetUnhandledExceptionFilter(EXCEPTION_POINTERS *ExceptionInfo);;
int main()
{
SetUnhandledExceptionFilter(RedirectedSetUnhandledExceptionFilter);
}
LONG WINAPI RedirectedSetUnhandledExceptionFilter(EXCEPTION_POINTERS * ExceptionInfo)
{
//When the CRT calls SetUnhandledExceptionFilter with NULL parameter
// our handler will not get removed.
std::cerr << "Caught an exception.\n";
std::cerr << "Ignoring the exception\n";
return EXCEPTION_CONTINUE_EXECUTION;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment