-
-
Save blaquee/48bfc716c536da4a4192 to your computer and use it in GitHub Desktop.
ExceptionHandlerTest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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