22 #ifndef __CRASH_RPT_H__
23 #define __CRASH_RPT_H__
29 #if !(defined CRASHRPT_ENABLE_RELEASE_ASSERTS)
30 # define CRASHRPT_ENABLE_RELEASE_ASSERTS 1
42 # undef CRASHRPT_ENABLE_RELEASE_ASSERTS // this is to make doxygen document CRASHRPT_ENABLE_RELEASE_ASSERTS macro
43 #elif CRASHRPT_ENABLE_RELEASE_ASSERTS == 1
47 # define assert(expr) ((void) (!(expr) && (crash_rpt::SkipDoctorDump_ReportAssertionViolation<__COUNTER__>(__FUNCTION__ ": "#expr " is false" ), true)))
49 #endif // CRASHRPT_ENABLE_RELEASE_ASSERTS
56 template<
unsigned uniqueAssertId>
57 __forceinline
static void SkipDoctorDump_ReportAssertionViolation(LPCSTR dumpGroup)
59 static LONG
volatile isAlreadyReported = FALSE;
60 if (TRUE == InterlockedCompareExchange(&isAlreadyReported, TRUE, FALSE))
112 LPCSTR applicationGUID,
120 InitCrashRpt(applicationGUID, NULL, appName, company, TRUE);
126 LPCSTR applicationGUID,
130 BOOL ownProcess = TRUE
138 InitCrashRpt(applicationGUID, prefix, appName, company, ownProcess);
144 LPCWSTR crashrptPath,
145 LPCSTR applicationGUID,
149 BOOL ownProcess = TRUE
154 if (!LoadDll(crashrptPath))
157 InitCrashRpt(applicationGUID, prefix, appName, company, ownProcess);
165 BOOL ownProcess = TRUE
173 InitCrashRpt(applicationInfo, handlerSettings, ownProcess);
179 LPCWSTR crashrptPath,
182 BOOL ownProcess = TRUE
187 if (!LoadDll(crashrptPath))
190 InitCrashRpt(applicationInfo, handlerSettings, ownProcess);
197 LPCWSTR crashrptPath = NULL
200 LoadDll(crashrptPath);
208 if (!m_IsReadyToExit)
213 while (!m_IsReadyToExit())
216 #if _WIN32_WINNT >= 0x0501
217 if (m_bSkipAssertsAdded)
218 RemoveVectoredExceptionHandler(SkipAsserts);
235 BOOL ownProcess = TRUE
243 m_bWorking = m_InitCrashRpt(applicationInfo, handlerSettings, ownProcess) != FALSE;
251 __declspec(deprecated)
255 BOOL ownProcess = TRUE
260 return InitCrashRpt(applicationInfo, handlerSettings, ownProcess);
268 LPCSTR applicationGUID,
272 BOOL ownProcess = TRUE
277 if (!m_GetVersionFromApp)
281 memset(&appInfo, 0,
sizeof(appInfo));
287 if (!m_GetVersionFromApp(&appInfo))
291 memset(&handlerSettings, 0,
sizeof(handlerSettings));
293 handlerSettings.OpenProblemInBrowser = TRUE;
295 return InitCrashRpt(&appInfo, &handlerSettings, ownProcess);
307 if (!m_SetCustomInfo)
309 m_SetCustomInfo(text);
321 if (!m_AddUserInfoToReport)
323 m_AddUserInfoToReport(key, value);
334 if (!m_RemoveUserInfoFromReport)
336 m_RemoveUserInfoFromReport(key);
346 LPCWSTR reportFileName
349 if (!m_AddFileToReport)
351 m_AddFileToReport(path, reportFileName);
362 if (!m_RemoveFileFromReport)
364 m_RemoveFileFromReport(path);
375 if (!m_GetVersionFromApp)
377 return m_GetVersionFromApp(appInfo) != FALSE;
387 if (!m_GetVersionFromFile)
389 return m_GetVersionFromFile(path, appInfo) != FALSE;
411 EXCEPTION_POINTERS* exceptionPointers
416 return EXCEPTION_CONTINUE_SEARCH;
419 return EXCEPTION_CONTINUE_EXECUTION;
420 return m_SendReport(exceptionPointers);
438 LPCSTR dumpGroup = NULL
450 bool LoadDll(LPCWSTR crashrptPath = NULL) throw()
454 m_bSkipAssertsAdded =
false;
455 m_InitCrashRpt = NULL;
457 m_IsReadyToExit = NULL;
458 m_SetCustomInfo = NULL;
459 m_AddUserInfoToReport = NULL;
460 m_RemoveUserInfoFromReport = NULL;
461 m_AddFileToReport = NULL;
462 m_RemoveFileFromReport = NULL;
463 m_GetVersionFromApp = NULL;
464 m_GetVersionFromFile = NULL;
468 HMODULE hCrashrptDll = ::LoadLibraryW(crashrptPath ? crashrptPath : L
"crashrpt.dll");
469 if (hCrashrptDll != NULL)
471 m_InitCrashRpt = (pfnInitCrashRpt) GetProcAddress(hCrashrptDll,
"InitCrashRpt");
472 m_SendReport = (pfnSendReport) GetProcAddress(hCrashrptDll,
"SendReport");
473 m_IsReadyToExit = (pfnIsReadyToExit) GetProcAddress(hCrashrptDll,
"IsReadyToExit");
474 m_SetCustomInfo = (pfnSetCustomInfo) GetProcAddress(hCrashrptDll,
"SetCustomInfo");
475 m_AddUserInfoToReport = (pfnAddUserInfoToReport) GetProcAddress(hCrashrptDll,
"AddUserInfoToReport");
476 m_RemoveUserInfoFromReport = (pfnRemoveUserInfoFromReport) GetProcAddress(hCrashrptDll,
"RemoveUserInfoFromReport");
477 m_AddFileToReport = (pfnAddFileToReport) GetProcAddress(hCrashrptDll,
"AddFileToReport");
478 m_RemoveFileFromReport = (pfnRemoveFileFromReport) GetProcAddress(hCrashrptDll,
"RemoveFileFromReport");
479 m_GetVersionFromApp = (pfnGetVersionFromApp) GetProcAddress(hCrashrptDll,
"GetVersionFromApp");
480 m_GetVersionFromFile = (pfnGetVersionFromFile) GetProcAddress(hCrashrptDll,
"GetVersionFromFile");
482 m_bLoaded = m_InitCrashRpt
486 && m_AddUserInfoToReport
487 && m_RemoveUserInfoFromReport
489 && m_RemoveFileFromReport
490 && m_GetVersionFromApp
491 && m_GetVersionFromFile;
494 #if _WIN32_WINNT >= 0x0501
498 ::AddVectoredExceptionHandler(TRUE, SkipAsserts);
499 m_bSkipAssertsAdded =
true;
506 static LONG CALLBACK SkipAsserts(EXCEPTION_POINTERS* pExceptionInfo)
509 return EXCEPTION_CONTINUE_EXECUTION;
510 return EXCEPTION_CONTINUE_SEARCH;
515 bool m_bSkipAssertsAdded;
518 typedef LONG (*pfnSendReport)(EXCEPTION_POINTERS* exceptionPointers);
519 typedef BOOL (*pfnIsReadyToExit)();
520 typedef void (*pfnSetCustomInfo)(LPCWSTR text);
521 typedef void (*pfnAddUserInfoToReport)(LPCWSTR key, LPCWSTR value);
522 typedef void (*pfnRemoveUserInfoFromReport)(LPCWSTR key);
523 typedef void (*pfnAddFileToReport)(LPCWSTR path, LPCWSTR reportFileName );
524 typedef void (*pfnRemoveFileFromReport)(LPCWSTR path);
526 typedef BOOL (*pfnGetVersionFromFile)(LPCWSTR path,
ApplicationInfo* appInfo);
528 pfnInitCrashRpt m_InitCrashRpt;
529 pfnSendReport m_SendReport;
530 pfnIsReadyToExit m_IsReadyToExit;
531 pfnSetCustomInfo m_SetCustomInfo;
532 pfnAddUserInfoToReport m_AddUserInfoToReport;
533 pfnRemoveUserInfoFromReport m_RemoveUserInfoFromReport;
534 pfnAddFileToReport m_AddFileToReport;
535 pfnRemoveFileFromReport m_RemoveFileFromReport;
536 pfnGetVersionFromApp m_GetVersionFromApp;
537 pfnGetVersionFromFile m_GetVersionFromFile;
546 #endif // __CRASH_RPT_H__
static const DWORD ExceptionAssertionViolated
Definition: CrashRpt.h:431
BOOL OpenProblemInBrowser
To open Web-page belonging to the uploaded report after it was uploaded set this member to TRUE...
Definition: CrashRpt.h:87
bool AddFileToReport(LPCWSTR path, LPCWSTR reportFileName)
Definition: CrashRpt.h:344
void SkipDoctorDump_SendAssertionViolated(LPCSTR dumpGroup=NULL) const
Definition: CrashRpt.h:437
bool SetCustomInfo(LPCWSTR text)
Definition: CrashRpt.h:303
bool AddUserInfoToReport(LPCWSTR key, LPCWSTR value)
Definition: CrashRpt.h:316
LPCSTR ApplicationGUID
GUID assigned to this application in form 00000000-0000-0000-0000-000000000000.
Definition: CrashRpt.h:71
LPCWSTR PrivacyPolicyUrl
URL to privacy policy. If NULL default privacy policy is used.
Definition: CrashRpt.h:77
BOOL OverrideDefaultFullDumpType
To override default type of data gathered by the library set this member to TRUE and set required typ...
Definition: CrashRpt.h:91
CrashRpt(LPCWSTR crashrptPath, LPCSTR applicationGUID, LPCSTR prefix, LPCWSTR appName, LPCWSTR company, BOOL ownProcess=TRUE)
Definition: CrashRpt.h:143
bool GetVersionFromApp(ApplicationInfo *appInfo)
Definition: CrashRpt.h:371
CrashRpt(LPCSTR applicationGUID, LPCSTR prefix, LPCWSTR appName, LPCWSTR company, BOOL ownProcess=TRUE)
Definition: CrashRpt.h:125
bool RemoveUserInfoFromReport(LPCWSTR key)
Definition: CrashRpt.h:330
LPCWSTR Company
Company name that will be shown in message box.
Definition: CrashRpt.h:74
CrashRpt(LPCWSTR crashrptPath, ApplicationInfo *applicationInfo, HandlerSettings *handlerSettings, BOOL ownProcess=TRUE)
Definition: CrashRpt.h:178
~CrashRpt()
Definition: CrashRpt.h:206
LPCWSTR SendRptPath
Set this member to NULL to use default behavior when SendRpt is named sendrpt.exe and exist in same f...
Definition: CrashRpt.h:94
CrashRpt(LPCSTR applicationGUID, LPCWSTR appName, LPCWSTR company)
Definition: CrashRpt.h:111
bool InitCrashRpt(ApplicationInfo *applicationInfo, HandlerSettings *handlerSettings, BOOL ownProcess=TRUE)
Definition: CrashRpt.h:232
DWORD FullDumpType
The type of information to be generated when full dump is requested by Doctor Dump. This parameter can be one or more of the values from the MINIDUMP_TYPE enumeration.
Definition: CrashRpt.h:92
To enable crash processing you should create an instance of this class.
Definition: CrashRpt.h:103
bool InitCrashHandler(ApplicationInfo *applicationInfo, HandlerSettings *handlerSettings, BOOL ownProcess=TRUE)
Definition: CrashRpt.h:252
bool IsCrashHandlingEnabled() const
Definition: CrashRpt.h:224
CrashRpt(ApplicationInfo *applicationInfo, HandlerSettings *handlerSettings, BOOL ownProcess=TRUE)
Definition: CrashRpt.h:162
LPCSTR Prefix
Prefix that will be used with the dump name: YourPrefix_v1.v2.v3.v4_YYYYMMDD_HHMMSS.mini.dmp.
Definition: CrashRpt.h:72
DWORD SubmitterID
Doctor Dump user ID. Uploaded report will be marked as uploaded by this user. This is useful for Doct...
Definition: CrashRpt.h:89
bool RemoveFileFromReport(LPCWSTR path)
Definition: CrashRpt.h:358
bool GetVersionFromFile(LPCWSTR path, ApplicationInfo *appInfo)
Definition: CrashRpt.h:382
USHORT V[4]
Version of this application.
Definition: CrashRpt.h:75
CrashRpt(LPCWSTR crashrptPath=NULL)
Definition: CrashRpt.h:196
bool InitCrashRpt(LPCSTR applicationGUID, LPCSTR prefix, LPCWSTR appName, LPCWSTR company, BOOL ownProcess=TRUE)
Definition: CrashRpt.h:267
Contains crash handling behavior customization parameters.
Definition: CrashRpt.h:83
BOOL UseWER
To continue use Microsoft Windows Error Reporting (WER) set this member to TRUE. In that case after D...
Definition: CrashRpt.h:88
USHORT Hotfix
Version of hotfix for this application (reserved for future use, should be 0).
Definition: CrashRpt.h:76
LONG SendReport(EXCEPTION_POINTERS *exceptionPointers)
Definition: CrashRpt.h:410
BOOL SendAdditionalDataWithoutApproval
To automatically accepted the question "Do you want to send more information about the problem...
Definition: CrashRpt.h:90
BOOL LeaveDumpFilesInTempFolder
To leave error reports in temp folder you should set this member to TRUE. Your support or test lab te...
Definition: CrashRpt.h:86
DWORD ApplicationInfoSize
Size of this structure. Should be set to sizeof(ApplicationInfo).
Definition: CrashRpt.h:70
LPCWSTR LangFilePath
To customize localization set this member to the path to the language file (including file name)...
Definition: CrashRpt.h:93
Contains data that identifies your application.
Definition: CrashRpt.h:68
LPCWSTR DbgHelpPath
Definition: CrashRpt.h:95
DWORD HandlerSettingsSize
Size of this structure. Should be set to sizeof(HandlerSettings).
Definition: CrashRpt.h:85
LPCWSTR AppName
Application name that will be shown in message box.
Definition: CrashRpt.h:73