__try/__except - jak złapać EXCEPTION_ACCESS_VIOLATION

http://msdn.microsoft.com/en-us/library/swezty51(VS.80).aspx



int filter(unsigned int code, struct _EXCEPTION_POINTERS *ep)
{
if (code == EXCEPTION_ACCESS_VIOLATION)
{
return EXCEPTION_EXECUTE_HANDLER;
}
else
{
return EXCEPTION_CONTINUE_SEARCH;
};
}

void test()
{
__try
{
*((char *)(NULL)) = 2;
}
__except(filter(GetExceptionCode(), GetExceptionInformation()))
{
cout << "wicked :)";
}
}

0 komentarze:

Prześlij komentarz

 
Tomasz Kulig