Last active
March 28, 2016 16:48
-
-
Save mrexodia/5d8b0459139abaa03000 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
Small program to check if Vectored Exception Handlers are called before Unhandled Exception Filters.