Created
July 18, 2019 07:19
-
-
Save alpinskiy/85366616730b77216c68eb78796f2207 to your computer and use it in GitHub Desktop.
This file contains 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 <cstdio> | |
LONG WINAPI ExceptionHandlerProc(_EXCEPTION_POINTERS *exceptionInfo) { | |
printf("Exception code %d", exceptionInfo->ExceptionRecord->ExceptionCode); | |
return EXCEPTION_CONTINUE_SEARCH; | |
} | |
PVOID ExceptionHandler; | |
BOOLEAN WINAPI DllMain(IN HINSTANCE hDllHandle, IN DWORD nReason, | |
IN LPVOID Reserved) { | |
BOOLEAN bSuccess = TRUE; | |
switch (nReason) { | |
case DLL_PROCESS_ATTACH: | |
DisableThreadLibraryCalls(hDllHandle); | |
ExceptionHandler = AddVectoredExceptionHandler(1, ExceptionHandlerProc); | |
if (ExceptionHandler) printf("Registred exception handler"); | |
break; | |
case DLL_PROCESS_DETACH: | |
if (ExceptionHandler) { | |
RemoveVectoredExceptionHandler(ExceptionHandler); | |
if (ExceptionHandler) printf("Unregistred exception handler"); | |
} | |
break; | |
} | |
return TRUE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment