Skip to content

Instantly share code, notes, and snippets.

@Donpedro13
Created October 26, 2020 18:52
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 Donpedro13/621f975dbf9dd2c6edcda82df92b7bc6 to your computer and use it in GitHub Desktop.
Save Donpedro13/621f975dbf9dd2c6edcda82df92b7bc6 to your computer and use it in GitHub Desktop.
// 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