Skip to content

Instantly share code, notes, and snippets.

@mrexodia
Last active March 28, 2016 16:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mrexodia/5d8b0459139abaa03000 to your computer and use it in GitHub Desktop.
Save mrexodia/5d8b0459139abaa03000 to your computer and use it in GitHub Desktop.
ExceptionHandlerTest
#include <windows.h>
#include <stdio.h>
static LPTOP_LEVEL_EXCEPTION_FILTER OldFilter;
static char callOrder[10] = "";
int main()
{
OldFilter = SetUnhandledExceptionFilter([](PEXCEPTION_POINTERS ExceptionInfo) -> LONG
{
strcat_s(callOrder, "UEF ");
return EXCEPTION_CONTINUE_SEARCH;
});
AddVectoredExceptionHandler(0, [](PEXCEPTION_POINTERS ExceptionInfo) -> LONG
{
strcat_s(callOrder, "VEH ");
if (OldFilter)
return OldFilter(ExceptionInfo);
return EXCEPTION_CONTINUE_SEARCH;
});
__debugbreak(); //crash the program
puts(callOrder); //"VEH UEF " <- no matter the order of registration
}
@mrexodia
Copy link
Author

mrexodia commented Feb 9, 2016

Small program to check if Vectored Exception Handlers are called before Unhandled Exception Filters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment