Skip to content

Instantly share code, notes, and snippets.

@Donpedro13
Created October 26, 2020 18:51
Show Gist options
  • Select an option

  • Save Donpedro13/2ceeaa1c3cf75d6799d84c10bec8496f to your computer and use it in GitHub Desktop.

Select an option

Save Donpedro13/2ceeaa1c3cf75d6799d84c10bec8496f to your computer and use it in GitHub Desktop.
// Compile with MSVC, *Release* configuration
#include <iostream>
#include <new>
#include <windows.h>
LONG WINAPI MyUEF (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 ()
{
SetUnhandledExceptionFilter (MyUEF);
delete reinterpret_cast<void*> (3);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment