SetUnhandledExceptionFilter(MyUnFilter);
LONG WINAPI MyUnFilter(PEXCEPTION_POINTERS lpExceptionInfo)
{
static int s_SigCount = 0;
DWORD dwExceptCode = lpExceptionInfo->ExceptionRecord->ExceptionCode;
LONG lResult = EXCEPTION_CONTINUE_SEARCH;
if (dwExceptCode == EXCEPTION_ACCESS_VIOLATION)
{
g_runLog.Write("Access violation caught by MyUnFilter, addr=0x%08x", lpExceptionInfo->ExceptionRecord->ExceptionAddress);
++s_SigCount;
// test case to keep this from going on forever (since we're not
// fixing the AV)
if (s_SigCount < 2)
lResult = EXCEPTION_CONTINUE_EXECUTION;
else
lResult = EXCEPTION_EXECUTE_HANDLER;
}
else
{
lResult = EXCEPTION_CONTINUE_SEARCH;
}
return lResult;
}