Created
October 26, 2020 18:52
-
-
Save Donpedro13/621f975dbf9dd2c6edcda82df92b7bc6 to your computer and use it in GitHub Desktop.
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
// Compile with MSVC, *Release* configuration | |
#include <iostream> | |
#include <new> | |
#include <windows.h> | |
LONG WINAPI MyVEH (PEXCEPTION_POINTERS pExp) | |
{ | |
if (pExp->ExceptionRecord->ExceptionCode == STATUS_HEAP_CORRUPTION) { | |
std::cout << "Heap corruption detected!" << std::endl; | |
Sleep (5000); | |
TerminateProcess (GetCurrentProcess (), pExp->ExceptionRecord->ExceptionCode); | |
} | |
return EXCEPTION_CONTINUE_SEARCH; | |
} | |
int main () | |
{ | |
AddVectoredExceptionHandler (1, MyVEH); | |
delete reinterpret_cast<void*> (3); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment