crGenerateErrorReport( CR_EXCEPTION_INFO* pExceptionInfo) { crSetErrorMsg(_T("Unspecified error.")); if(pExceptionInfo==NULL || pExceptionInfo->cb!=sizeof(CR_EXCEPTION_INFO)) { crSetErrorMsg(_T("Exception info is NULL or invalid.")); return 1; } CCrashHandler *pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); if(pCrashHandler==NULL) { // Handler is not installed for current process crSetErrorMsg(_T("Crash handler wasn't previously installed for current process.")); ATLASSERT(pCrashHandler!=NULL); return 2; } return pCrashHandler->GenerateErrorReport(pExceptionInfo); }
crExceptionFilter(unsigned int code, struct _EXCEPTION_POINTERS* ep) { crSetErrorMsg(_T("Unspecified error.")); CCrashHandler *pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); if(pCrashHandler==NULL) { crSetErrorMsg(_T("Crash handler wasn't previously installed for current process.")); return EXCEPTION_CONTINUE_SEARCH; } CR_EXCEPTION_INFO ei; memset(&ei, 0, sizeof(CR_EXCEPTION_INFO)); ei.cb = sizeof(CR_EXCEPTION_INFO); ei.exctype = CR_SEH_EXCEPTION; ei.pexcptrs = ep; ei.code = code; int res = pCrashHandler->GenerateErrorReport(&ei); if(res!=0) { // If goes here than GenerateErrorReport() failed return EXCEPTION_CONTINUE_SEARCH; } crSetErrorMsg(_T("Success.")); return EXCEPTION_EXECUTE_HANDLER; }
void __cdecl cpp_invalid_parameter_handler( const wchar_t* expression, const wchar_t* function, const wchar_t* file, unsigned int line, uintptr_t pReserved) { pReserved; // Invalid parameter exception CCrashHandler* pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); ATLASSERT(pCrashHandler!=NULL); if(pCrashHandler!=NULL) { // Fill in the exception info CR_EXCEPTION_INFO ei; memset(&ei, 0, sizeof(CR_EXCEPTION_INFO)); ei.cb = sizeof(CR_EXCEPTION_INFO); ei.exctype = CR_CPP_INVALID_PARAMETER; ei.expression = expression; ei.function = function; ei.file = file; ei.line = line; pCrashHandler->GenerateErrorReport(&ei); } exit(1); // Terminate program }
CRASHRPTAPI void GenerateErrorReportEx(LPVOID lpState, PEXCEPTION_POINTERS pExInfo, BSTR message) { CCrashHandler *pImpl = (CCrashHandler*)lpState; CRASH_ASSERT(pImpl); if (!pImpl->GenerateErrorReport(pExInfo, message)) { DebugBreak(); } }
// Structured exception handler LONG WINAPI CCrashHandler::SehHandler(PEXCEPTION_POINTERS pExceptionPtrs) { CCrashHandler* pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); ATLASSERT(pCrashHandler!=NULL); if(pCrashHandler!=NULL) { CR_EXCEPTION_INFO ei; memset(&ei, 0, sizeof(CR_EXCEPTION_INFO)); ei.cb = sizeof(CR_EXCEPTION_INFO); ei.exctype = CR_SEH_EXCEPTION; ei.pexcptrs = pExceptionPtrs; pCrashHandler->GenerateErrorReport(&ei); } // Terminate program exit(1); }
void __cdecl cpp_unexp_handler() { // Unexpected error (unexpected() function was called) CCrashHandler* pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); ATLASSERT(pCrashHandler!=NULL); if(pCrashHandler!=NULL) { // Fill in the exception info CR_EXCEPTION_INFO ei; memset(&ei, 0, sizeof(CR_EXCEPTION_INFO)); ei.cb = sizeof(CR_EXCEPTION_INFO); ei.exctype = CR_CPP_UNEXPECTED_CALL; pCrashHandler->GenerateErrorReport(&ei); } // Terminate program exit(1); }
// CRT sigint signal handler void CCrashHandler::SigintHandler(int) { // Interruption (SIGINT) CCrashHandler* pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); ATLASSERT(pCrashHandler!=NULL); if(pCrashHandler!=NULL) { // Fill in the exception info CR_EXCEPTION_INFO ei; memset(&ei, 0, sizeof(CR_EXCEPTION_INFO)); ei.cb = sizeof(CR_EXCEPTION_INFO); ei.exctype = CR_CPP_SIGINT; pCrashHandler->GenerateErrorReport(&ei); } // Terminate program exit(1); }
void __cdecl cpp_purecall_handler() { // Pure virtual function call CCrashHandler* pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); ATLASSERT(pCrashHandler!=NULL); if(pCrashHandler!=NULL) { // Fill in the exception info CR_EXCEPTION_INFO ei; memset(&ei, 0, sizeof(CR_EXCEPTION_INFO)); ei.cb = sizeof(CR_EXCEPTION_INFO); ei.exctype = CR_CPP_PURE_CALL; pCrashHandler->GenerateErrorReport(&ei); } // Terminate program exit(1); }
void __cdecl cpp_terminate_handler() { // Abnormal program termination (terminate() function was called) CCrashHandler* pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); ATLASSERT(pCrashHandler!=NULL); if(pCrashHandler!=NULL) { // Fill in the exception info CR_EXCEPTION_INFO ei; memset(&ei, 0, sizeof(CR_EXCEPTION_INFO)); ei.cb = sizeof(CR_EXCEPTION_INFO); ei.exctype = CR_CPP_TERMINATE_CALL; pCrashHandler->GenerateErrorReport(&ei); } // Terminate program exit(1); }
// CRT SIGABRT signal handler void CCrashHandler::SigabrtHandler(int) { // Caught SIGABRT C++ signal CCrashHandler* pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); ATLASSERT(pCrashHandler!=NULL); if(pCrashHandler!=NULL) { // Fill in the exception info CR_EXCEPTION_INFO ei; memset(&ei, 0, sizeof(CR_EXCEPTION_INFO)); ei.cb = sizeof(CR_EXCEPTION_INFO); ei.exctype = CR_CPP_SIGABRT; pCrashHandler->GenerateErrorReport(&ei); } // Terminate program ExitProcess(1); }
void cpp_sigterm_handler(int) { // Termination request (SIGTERM) CCrashHandler* pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); ATLASSERT(pCrashHandler!=NULL); if(pCrashHandler!=NULL) { // Fill in the exception info CR_EXCEPTION_INFO ei; memset(&ei, 0, sizeof(CR_EXCEPTION_INFO)); ei.cb = sizeof(CR_EXCEPTION_INFO); ei.exctype = CR_CPP_SIGTERM; pCrashHandler->GenerateErrorReport(&ei); } // Terminate program exit(1); }
int __cdecl cpp_new_handler(size_t) { // 'new' operator memory allocation exception CCrashHandler* pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); ATLASSERT(pCrashHandler!=NULL); if(pCrashHandler!=NULL) { // Fill in the exception info CR_EXCEPTION_INFO ei; memset(&ei, 0, sizeof(CR_EXCEPTION_INFO)); ei.cb = sizeof(CR_EXCEPTION_INFO); ei.exctype = CR_CPP_NEW_OPERATOR_ERROR; ei.pexcptrs = NULL; pCrashHandler->GenerateErrorReport(&ei); } exit(1); // Terminate program }
void cpp_sigsegv_handler(int) { // Invalid storage access (SIGSEGV) CCrashHandler* pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); ATLASSERT(pCrashHandler!=NULL); if(pCrashHandler!=NULL) { // Fill in exception info CR_EXCEPTION_INFO ei; memset(&ei, 0, sizeof(CR_EXCEPTION_INFO)); ei.cb = sizeof(CR_EXCEPTION_INFO); ei.exctype = CR_CPP_SIGSEGV; ei.pexcptrs = (PEXCEPTION_POINTERS)_pxcptinfoptrs; pCrashHandler->GenerateErrorReport(&ei); } // Terminate program exit(1); }
LONG WINAPI Win32UnhandledExceptionFilter(PEXCEPTION_POINTERS pExceptionPtrs) { CCrashHandler* pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); ATLASSERT(pCrashHandler!=NULL); if(pCrashHandler!=NULL) { CR_EXCEPTION_INFO ei; memset(&ei, 0, sizeof(CR_EXCEPTION_INFO)); ei.cb = sizeof(CR_EXCEPTION_INFO); ei.exctype = CR_WIN32_STRUCTURED_EXCEPTION; ei.pexcptrs = pExceptionPtrs; pCrashHandler->GenerateErrorReport(&ei); } // Terminate program exit(1); #if _MSC_VER<1300 // This is to make MSVC6.0 compiler happy return EXCEPTION_EXECUTE_HANDLER; #endif }
void cpp_sigfpe_handler(int /*code*/, int subcode) { // Floating point exception (SIGFPE) CCrashHandler* pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); ATLASSERT(pCrashHandler!=NULL); if(pCrashHandler!=NULL) { // Fill in the exception info CR_EXCEPTION_INFO ei; memset(&ei, 0, sizeof(CR_EXCEPTION_INFO)); ei.cb = sizeof(CR_EXCEPTION_INFO); ei.exctype = CR_CPP_SIGFPE; ei.pexcptrs = (PEXCEPTION_POINTERS)_pxcptinfoptrs; ei.fpe_subcode = subcode; pCrashHandler->GenerateErrorReport(&ei); } // Terminate program exit(1); }
void __cdecl cpp_security_handler(int code, void *x) { // Security error (buffer overrun). code; x; CCrashHandler* pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); ATLASSERT(pCrashHandler!=NULL); if(pCrashHandler!=NULL) { // Fill in the exception info CR_EXCEPTION_INFO ei; memset(&ei, 0, sizeof(CR_EXCEPTION_INFO)); ei.cb = sizeof(CR_EXCEPTION_INFO); ei.exctype = CR_CPP_SECURITY_ERROR; pCrashHandler->GenerateErrorReport(&ei); } exit(1); // Terminate program }
crExceptionFilter(unsigned int code, struct _EXCEPTION_POINTERS* ep) { crSetErrorMsg(_T("Unspecified error.")); CCrashHandler *pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); if(pCrashHandler==NULL) { crSetErrorMsg(_T("Crash handler wasn't previously installed for current process.")); return EXCEPTION_CONTINUE_SEARCH; } #ifdef CRASHRPT_EX // AS: Unless the user will indeed check for the user choice this makes no real // sense here. // We assume that the execute_handler does what it should -> close the app. pCrashHandler ->AllowContinue(0); #endif CR_EXCEPTION_INFO ei; memset(&ei, 0, sizeof(CR_EXCEPTION_INFO)); ei.cb = sizeof(CR_EXCEPTION_INFO); ei.exctype = CR_SEH_EXCEPTION; ei.pexcptrs = ep; ei.code = code; int res = pCrashHandler->GenerateErrorReport(&ei); if(res!=0) { // If goes here than GenerateErrorReport() failed return EXCEPTION_CONTINUE_SEARCH; } crSetErrorMsg(_T("Success.")); return EXCEPTION_EXECUTE_HANDLER; }