Skip to content

Instantly share code, notes, and snippets.

@apankrat
Created November 7, 2018 14:12
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save apankrat/ce6d15e5a6aac681257257ad5809ca9b to your computer and use it in GitHub Desktop.
/*
* This will execute and exit cleanly despite of
* dereferencing a zero pointer in line 12 ...
*/
#include <windows.h>
#include <stdio.h>
void __stdcall OnTimer(HWND, UINT, UINT_PTR, DWORD)
{
printf("Tick\n");
*(int*)0 = 0; /* trip 'access denied' */
printf("Tock\n");
}
int wmain(int argc, wchar_t ** argv)
{
MSG msg = { 0 };
SetTimer(NULL, 0x1234, 1000, OnTimer);
GetMessage(&msg, NULL, 0, 0);
DispatchMessage(&msg);
printf("Done\n");
return 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment