CRASHRPTAPI(int) crUninstall() { crSetErrorMsg(_T("Success.")); CCrashHandler *pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); if(pCrashHandler==NULL || !pCrashHandler->IsInitialized()) { crSetErrorMsg(_T("Crash handler wasn't preiviously installed for this process.")); return 1; } // Uninstall main thread's C++ exception handlers int nUnset = pCrashHandler->UnSetThreadExceptionHandlers(); if(nUnset!=0) return 2; int nDestroy = pCrashHandler->Destroy(); if(nDestroy!=0) return 3; delete pCrashHandler; return 0; }
CRASHRPTAPI(int) crUninstall() { crSetErrorMsg(_T("Success.")); // Get crash handler singleton CCrashHandler *pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); // Check if found if(pCrashHandler==NULL || !pCrashHandler->IsInitialized()) { crSetErrorMsg(_T("Crash handler wasn't preiviously installed for this process.")); return 1; } // Uninstall main thread's C++ exception handlers int nUnset = pCrashHandler->UnSetThreadExceptionHandlers(); if(nUnset!=0) return 2; // Destroy the crash handler. int nDestroy = pCrashHandler->Destroy(); if(nDestroy!=0) return 3; // Free the crash handler object. delete pCrashHandler; // Clear last error message list. g_cs.Lock(); g_sErrorMsg.clear(); g_cs.Unlock(); return 0; }
CRASHRPTAPI(int) crInstallW(CR_INSTALL_INFOW* pInfo) { int nStatus = -1; crSetErrorMsg(_T("Success.")); strconv_t strconv; CCrashHandler *pCrashHandler = NULL; // Validate input parameters. if(pInfo==NULL || pInfo->cb!=sizeof(CR_INSTALL_INFOW)) { crSetErrorMsg(_T("pInfo is NULL or pInfo->cb member is not valid.")); nStatus = 1; goto cleanup; } // Check if crInstall() already was called for current process. pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); if(pCrashHandler!=NULL && pCrashHandler->IsInitialized()) { crSetErrorMsg(_T("Can't install crash handler to the same process twice.")); nStatus = 2; goto cleanup; } if(pCrashHandler==NULL) { pCrashHandler = new CCrashHandler(); if(pCrashHandler==NULL) { crSetErrorMsg(_T("Error allocating memory for crash handler.")); nStatus = 3; goto cleanup; } } LPCTSTR ptszAppName = strconv.w2t((LPWSTR)pInfo->pszAppName); LPCTSTR ptszAppVersion = strconv.w2t((LPWSTR)pInfo->pszAppVersion); LPCTSTR ptszCrashSenderPath = strconv.w2t((LPWSTR)pInfo->pszCrashSenderPath); LPCTSTR ptszEmailTo = strconv.w2t((LPWSTR)pInfo->pszEmailTo); LPCTSTR ptszEmailSubject = strconv.w2t((LPWSTR)pInfo->pszEmailSubject); LPCTSTR ptszUrl = strconv.w2t((LPWSTR)pInfo->pszUrl); LPCTSTR ptszPrivacyPolicyURL = strconv.w2t((LPWSTR)pInfo->pszPrivacyPolicyURL); LPCTSTR ptszDebugHelpDLL_file = strconv.w2t((LPWSTR)pInfo->pszDebugHelpDLL); MINIDUMP_TYPE miniDumpType = pInfo->uMiniDumpType; LPCTSTR ptszErrorReportSaveDir = strconv.w2t((LPWSTR)pInfo->pszErrorReportSaveDir); LPCTSTR ptszRestartCmdLine = strconv.w2t((LPWSTR)pInfo->pszRestartCmdLine); LPCTSTR ptszLangFilePath = strconv.w2t((LPWSTR)pInfo->pszLangFilePath); LPCTSTR ptszEmailText = strconv.w2t((LPWSTR)pInfo->pszEmailText); LPCTSTR ptszSmtpProxy = strconv.w2t((LPWSTR)pInfo->pszSmtpProxy); int nInitResult = pCrashHandler->Init( ptszAppName, ptszAppVersion, ptszCrashSenderPath, pInfo->pfnCrashCallback, ptszEmailTo, ptszEmailSubject, ptszUrl, &pInfo->uPriorities, pInfo->dwFlags, ptszPrivacyPolicyURL, ptszDebugHelpDLL_file, miniDumpType, ptszErrorReportSaveDir, ptszRestartCmdLine, ptszLangFilePath, ptszEmailText, ptszSmtpProxy ); if(nInitResult!=0) { nStatus = 4; goto cleanup; } // OK. nStatus = 0; cleanup: if(nStatus!=0) // If failed { if(pCrashHandler!=NULL && !pCrashHandler->IsInitialized()) { // Release crash handler object CCrashHandler::ReleaseCurrentProcessCrashHandler(); } } return nStatus; }