Skip to content

Instantly share code, notes, and snippets.

@blaquee
Forked from mrexodia/main.cpp
Created February 9, 2016 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blaquee/48bfc716c536da4a4192 to your computer and use it in GitHub Desktop.
Save blaquee/48bfc716c536da4a4192 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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment