22 #ifndef __CRASH_RPT_H__ 23 #define __CRASH_RPT_H__ 32 #if !(defined CRASHRPT_ENABLE_RELEASE_ASSERTS) 33 # define CRASHRPT_ENABLE_RELEASE_ASSERTS 1 45 # undef CRASHRPT_ENABLE_RELEASE_ASSERTS // this is to make doxygen document CRASHRPT_ENABLE_RELEASE_ASSERTS macro 46 #elif CRASHRPT_ENABLE_RELEASE_ASSERTS == 1 50 # define assert(expr) ((void) (!(expr) && (crash_rpt::SkipDoctorDump_ReportAssertionViolation<__COUNTER__>(__FUNCTION__ ": "#expr " is false" ), true))) 52 #endif // CRASHRPT_ENABLE_RELEASE_ASSERTS 60 template<
unsigned uniqueAssertId>
61 __forceinline
static void SkipDoctorDump_ReportAssertionViolation(LPCSTR dumpGroup)
63 static LONG
volatile isAlreadyReported = FALSE;
64 if (TRUE == InterlockedCompareExchange(&isAlreadyReported, TRUE, FALSE))
106 namespace custom_data_collection {
138 virtual bool AddFileToReport(
140 LPCWSTR reportFileName
145 virtual bool RemoveFileFromReport(
151 virtual bool AddUserInfoToReport(
158 virtual bool RemoveUserInfoFromReport(
182 namespace crt_error_handlers {
184 typedef void(__cdecl *_crt_signal_t)(int);
185 typedef _crt_signal_t(__cdecl *pfn_signal)(
int sig, _crt_signal_t func);
186 typedef void(__cdecl* terminate_function)();
187 typedef terminate_function(__cdecl *pfn_set_terminate)(terminate_function);
188 typedef void(__cdecl* _invalid_parameter_handler)(
wchar_t const*,
wchar_t const*,
wchar_t const*,
unsigned int, uintptr_t);
189 typedef _invalid_parameter_handler(__cdecl *pfn_set_invalid_parameter_handler)(_invalid_parameter_handler);
190 typedef void(__cdecl* _purecall_handler)(void);
191 typedef _purecall_handler(__cdecl *pfn_set_purecall_handler)(_purecall_handler);
256 LPCSTR applicationGUID,
264 InitCrashRpt(applicationGUID, NULL, appName, company, TRUE);
270 LPCSTR applicationGUID,
274 BOOL ownProcess = TRUE
282 InitCrashRpt(applicationGUID, prefix, appName, company, ownProcess);
288 LPCWSTR crashrptPath,
289 LPCSTR applicationGUID,
293 BOOL ownProcess = TRUE
298 if (!LoadDll(crashrptPath))
301 InitCrashRpt(applicationGUID, prefix, appName, company, ownProcess);
309 BOOL ownProcess = TRUE
317 InitCrashRpt(applicationInfo, handlerSettings, ownProcess);
323 LPCWSTR crashrptPath,
326 BOOL ownProcess = TRUE
331 if (!LoadDll(crashrptPath))
334 InitCrashRpt(applicationInfo, handlerSettings, ownProcess);
341 LPCWSTR crashrptPath = NULL
344 LoadDll(crashrptPath);
352 if (!m_IsReadyToExit)
357 while (!m_IsReadyToExit())
360 #if _WIN32_WINNT >= 0x0501 361 if (m_bSkipAssertsAdded)
362 RemoveVectoredExceptionHandler(SkipAsserts);
379 BOOL ownProcess = TRUE
388 memset(&crtErrorHandlersSettings, 0,
sizeof(crtErrorHandlersSettings));
389 crtErrorHandlersSettings.
SettingsSize =
sizeof(crtErrorHandlersSettings);
390 crtErrorHandlersSettings.
Signal = signal;
392 #if defined(_MSC_VER) 398 memset(&defHandlerSettings, 0,
sizeof(defHandlerSettings));
403 if (handlerSettings == NULL)
405 handlerSettings = &defHandlerSettings;
407 else if (handlerSettings->CrtErrorHandlersSettings == NULL)
412 m_bWorking = m_InitCrashRpt(applicationInfo, handlerSettings, ownProcess) != FALSE;
421 LPCSTR applicationGUID,
425 BOOL ownProcess = TRUE
430 if (!m_GetVersionFromApp)
434 memset(&appInfo, 0,
sizeof(appInfo));
440 if (!m_GetVersionFromApp(&appInfo))
443 return InitCrashRpt(&appInfo, NULL, ownProcess);
455 if (!m_SetCustomInfo)
457 m_SetCustomInfo(text);
469 if (!m_AddUserInfoToReport)
471 m_AddUserInfoToReport(key, value);
482 if (!m_RemoveUserInfoFromReport)
484 m_RemoveUserInfoFromReport(key);
497 LPCWSTR reportFileName
500 if (!m_AddFileToReport)
502 m_AddFileToReport(path, reportFileName);
513 if (!m_RemoveFileFromReport)
515 m_RemoveFileFromReport(path);
526 if (!m_GetVersionFromApp)
528 return m_GetVersionFromApp(appInfo) != FALSE;
538 if (!m_GetVersionFromFile)
540 return m_GetVersionFromFile(path, appInfo) != FALSE;
562 EXCEPTION_POINTERS* exceptionPointers
569 if (exceptionPointers->ExceptionRecord->ExceptionCode == ExceptionAssertionViolated)
570 return EXCEPTION_CONTINUE_EXECUTION;
571 return EXCEPTION_CONTINUE_SEARCH;
573 return m_SendReport(exceptionPointers);
584 static const DWORD ExceptionAssertionViolated = ((DWORD)0xCCE17000);
587 static const DWORD ExceptionCppTerminate = ((DWORD)0xCCE17001);
590 static const DWORD ExceptionPureCall = ((DWORD)0xCCE17002);
593 static const DWORD ExceptionInvalidParameter = ((DWORD)0xCCE17003);
600 LPCSTR dumpGroup = NULL
612 bool LoadDll(LPCWSTR crashrptPath = NULL)
throw()
616 m_bSkipAssertsAdded =
false;
617 m_InitCrashRpt = NULL;
619 m_IsReadyToExit = NULL;
620 m_SetCustomInfo = NULL;
621 m_AddUserInfoToReport = NULL;
622 m_RemoveUserInfoFromReport = NULL;
623 m_AddFileToReport = NULL;
624 m_RemoveFileFromReport = NULL;
625 m_GetVersionFromApp = NULL;
626 m_GetVersionFromFile = NULL;
630 HMODULE hCrashrptDll = ::LoadLibraryW(crashrptPath ? crashrptPath : L
"crashrpt.dll");
631 if (hCrashrptDll != NULL)
633 m_InitCrashRpt = (pfnInitCrashRpt) GetProcAddress(hCrashrptDll,
"InitCrashRpt");
634 m_SendReport = (pfnSendReport) GetProcAddress(hCrashrptDll,
"SendReport");
635 m_IsReadyToExit = (pfnIsReadyToExit) GetProcAddress(hCrashrptDll,
"IsReadyToExit");
636 m_SetCustomInfo = (pfnSetCustomInfo) GetProcAddress(hCrashrptDll,
"SetCustomInfo");
637 m_AddUserInfoToReport = (pfnAddUserInfoToReport) GetProcAddress(hCrashrptDll,
"AddUserInfoToReport");
638 m_RemoveUserInfoFromReport = (pfnRemoveUserInfoFromReport) GetProcAddress(hCrashrptDll,
"RemoveUserInfoFromReport");
639 m_AddFileToReport = (pfnAddFileToReport) GetProcAddress(hCrashrptDll,
"AddFileToReport");
640 m_RemoveFileFromReport = (pfnRemoveFileFromReport) GetProcAddress(hCrashrptDll,
"RemoveFileFromReport");
641 m_GetVersionFromApp = (pfnGetVersionFromApp) GetProcAddress(hCrashrptDll,
"GetVersionFromApp");
642 m_GetVersionFromFile = (pfnGetVersionFromFile) GetProcAddress(hCrashrptDll,
"GetVersionFromFile");
644 m_bLoaded = m_InitCrashRpt
648 && m_AddUserInfoToReport
649 && m_RemoveUserInfoFromReport
651 && m_RemoveFileFromReport
652 && m_GetVersionFromApp
653 && m_GetVersionFromFile;
656 #if _WIN32_WINNT >= 0x0501 660 ::AddVectoredExceptionHandler(TRUE, SkipAsserts);
661 m_bSkipAssertsAdded =
true;
668 static LONG CALLBACK SkipAsserts(EXCEPTION_POINTERS* pExceptionInfo)
670 if (pExceptionInfo->ExceptionRecord->ExceptionCode == ExceptionAssertionViolated)
671 return EXCEPTION_CONTINUE_EXECUTION;
672 return EXCEPTION_CONTINUE_SEARCH;
677 bool m_bSkipAssertsAdded;
680 typedef LONG (__cdecl *pfnSendReport)(EXCEPTION_POINTERS* exceptionPointers);
681 typedef BOOL (__cdecl *pfnIsReadyToExit)();
682 typedef void (__cdecl *pfnSetCustomInfo)(LPCWSTR text);
683 typedef void (__cdecl *pfnAddUserInfoToReport)(LPCWSTR key, LPCWSTR value);
684 typedef void (__cdecl *pfnRemoveUserInfoFromReport)(LPCWSTR key);
685 typedef void (__cdecl *pfnAddFileToReport)(LPCWSTR path, LPCWSTR reportFileName );
686 typedef void (__cdecl *pfnRemoveFileFromReport)(LPCWSTR path);
687 typedef BOOL (__cdecl *pfnGetVersionFromApp)(
ApplicationInfo* appInfo);
688 typedef BOOL (__cdecl *pfnGetVersionFromFile)(LPCWSTR path,
ApplicationInfo* appInfo);
690 pfnInitCrashRpt m_InitCrashRpt;
691 pfnSendReport m_SendReport;
692 pfnIsReadyToExit m_IsReadyToExit;
693 pfnSetCustomInfo m_SetCustomInfo;
694 pfnAddUserInfoToReport m_AddUserInfoToReport;
695 pfnRemoveUserInfoFromReport m_RemoveUserInfoFromReport;
696 pfnAddFileToReport m_AddFileToReport;
697 pfnRemoveFileFromReport m_RemoveFileFromReport;
698 pfnGetVersionFromApp m_GetVersionFromApp;
699 pfnGetVersionFromFile m_GetVersionFromFile;
704 #endif // __CRASH_RPT_H__ static const DWORD ExceptionAssertionViolated
Definition: CrashRpt.h:584
Cancel upload.
Definition: CrashRpt.h:113
Setters for CRT error handlers.
Definition: CrashRpt.h:194
BOOL OpenProblemInBrowser
To open Web-page belonging to the uploaded report after it was uploaded set this member to TRUE...
Definition: CrashRpt.h:225
int DumpID
Dump ID of this crash in DrDump service.
Definition: CrashRpt.h:127
CrashProcessingCallbackStage
Stages when crash processing callback called.
Definition: CrashRpt.h:81
bool AddFileToReport(LPCWSTR path, LPCWSTR reportFileName)
Definition: CrashRpt.h:495
Callback is called before report send.
Definition: CrashRpt.h:83
HANDLE Process
Handle to the crashed process.
Definition: CrashRpt.h:122
bool SetCustomInfo(LPCWSTR text)
Definition: CrashRpt.h:451
bool AddUserInfoToReport(LPCWSTR key, LPCWSTR value)
Definition: CrashRpt.h:464
LPCSTR ApplicationGUID
GUID assigned to this application in form 00000000-0000-0000-0000-000000000000.
Definition: CrashRpt.h:209
LPBYTE UserData
Pointer to user-defined data buffer.
Definition: CrashRpt.h:120
LPCWSTR PrivacyPolicyUrl
URL to privacy policy. If NULL default privacy policy is used.
Definition: CrashRpt.h:215
int DumpGroupID
DumpGroup ID of this crash in DrDump service.
Definition: CrashRpt.h:128
BOOL OverrideDefaultFullDumpType
To override default type of data gathered by the library set this member to TRUE and set required typ...
Definition: CrashRpt.h:229
CrashRpt(LPCWSTR crashrptPath, LPCSTR applicationGUID, LPCSTR prefix, LPCWSTR appName, LPCWSTR company, BOOL ownProcess=TRUE)
Definition: CrashRpt.h:287
bool GetVersionFromApp(ApplicationInfo *appInfo)
Definition: CrashRpt.h:522
CrashRpt(LPCSTR applicationGUID, LPCSTR prefix, LPCWSTR appName, LPCWSTR company, BOOL ownProcess=TRUE)
Definition: CrashRpt.h:269
LPBYTE UserData
Pointer to user-defined data buffer.
Definition: CrashRpt.h:175
Default result. Crash handler continues its default processing.
Definition: CrashRpt.h:90
bool RemoveUserInfoFromReport(LPCWSTR key)
Definition: CrashRpt.h:478
DWORD ExceptionInfoSize
Size of this structure. Should be set to sizeof(ExceptionInfo).
Definition: CrashRpt.h:74
int ProblemID
Problem ID of this crash in DrDump service.
Definition: CrashRpt.h:129
DWORD UserDataSize
Size of UserData buffer.
Definition: CrashRpt.h:176
Skip upload confirm dialog and proceed to upload stage.
Definition: CrashRpt.h:112
LPCSTR CollectionFunctionName
Name of collection function exported from CollectionLibraryPath. It should have crash_rpt::custom_dat...
Definition: CrashRpt.h:174
LPCWSTR Company
Company name that will be shown in message box.
Definition: CrashRpt.h:212
This is namespace crash_rpt.
Definition: CrashRpt.h:55
CrashRpt(LPCWSTR crashrptPath, ApplicationInfo *applicationInfo, HandlerSettings *handlerSettings, BOOL ownProcess=TRUE)
Definition: CrashRpt.h:322
Result(CALLBACK * PFNCUSTOMDATACOLLECTIONCALLBACK)(const ExceptionInfo &exceptionInfo, IDataBag *dataBag)
Client crash callback function prototype.
Definition: CrashRpt.h:164
This interface used to add custom data to crash report.
Definition: CrashRpt.h:133
PEXCEPTION_POINTERS ExceptionPointers
Exception pointers. ExceptionPointers->ExceptionRecord->ExceptionCode contains SEH code or ExceptionA...
Definition: CrashRpt.h:76
Callback is called after the report has been sent.
Definition: CrashRpt.h:84
crt_error_handlers::Settings * CrtErrorHandlersSettings
Contains setters for CRT error handlers. Set to NULL to use default handlers.
Definition: CrashRpt.h:239
pfn_set_invalid_parameter_handler SetInvalidParameterHandler
Address of _set_invalid_parameter_handler function.
Definition: CrashRpt.h:199
pfn_signal Signal
Address of signal function.
Definition: CrashRpt.h:197
custom_data_collection::Settings * CustomDataCollectionSettings
Contains data for optional custom data collection after the crash in context of sendrpt.exe process.
Definition: CrashRpt.h:237
~CrashRpt()
Definition: CrashRpt.h:350
LPVOID ExceptInfo
Pointer to MINIDUMP_EXCEPTION_INFORMATION structure.
Definition: CrashRpt.h:124
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:232
BOOL WasAssert
Is it assert? (see crash_rpt::CrashRpt::SkipDoctorDump_SendAssertionViolated).
Definition: CrashRpt.h:125
Result
Result of custom data collection.
Definition: CrashRpt.h:109
Proceed to upload confirm dialog stage.
Definition: CrashRpt.h:111
DWORD SettingsSize
Size of this structure. Should be set to sizeof(crash_rpt::crt_error_handlers::Settings).
Definition: CrashRpt.h:196
Explicitly force crash handler to return EXCEPTION_EXECUTE_HANDLER.
Definition: CrashRpt.h:94
CrashRpt(LPCSTR applicationGUID, LPCWSTR appName, LPCWSTR company)
Definition: CrashRpt.h:255
bool InitCrashRpt(ApplicationInfo *applicationInfo, HandlerSettings *handlerSettings, BOOL ownProcess=TRUE)
Definition: CrashRpt.h:376
DWORD ThreadId
Thread identifier of the crashed thread.
Definition: CrashRpt.h:77
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:230
To enable crash processing you should create an instance of this class.
Definition: CrashRpt.h:247
void SkipDoctorDump_SendAssertionViolated(LPCSTR dumpGroup=NULL) const
Definition: CrashRpt.h:599
DWORD ExceptionInfoSize
Size of this structure. Should be set to sizeof(ExceptionInfo).
Definition: CrashRpt.h:119
Explicitly force crash handler to return EXCEPTION_CONTINUE_EXECUTION.
Definition: CrashRpt.h:92
CrashRpt(ApplicationInfo *applicationInfo, HandlerSettings *handlerSettings, BOOL ownProcess=TRUE)
Definition: CrashRpt.h:306
LPCSTR Prefix
Prefix that will be used with the dump name: YourPrefix_v1.v2.v3.v4_YYYYMMDD_HHMMSS.mini.dmp.
Definition: CrashRpt.h:210
DWORD SubmitterID
Doctor Dump user ID. Uploaded report will be marked as uploaded by this user. This is useful for Doct...
Definition: CrashRpt.h:227
bool RemoveFileFromReport(LPCWSTR path)
Definition: CrashRpt.h:509
bool GetVersionFromFile(LPCWSTR path, ApplicationInfo *appInfo)
Definition: CrashRpt.h:533
USHORT V[4]
Version of this application.
Definition: CrashRpt.h:213
DWORD SettingsSize
Size of this structure. Should be set to sizeof(crash_rpt::custom_data_collection::Settings).
Definition: CrashRpt.h:172
CrashRpt(LPCWSTR crashrptPath=NULL)
Definition: CrashRpt.h:340
Contains data for optional custom data collection after the crash in context of sendrpt.exe process.
Definition: CrashRpt.h:170
bool IsCrashHandlingEnabled() const
Definition: CrashRpt.h:368
bool InitCrashRpt(LPCSTR applicationGUID, LPCSTR prefix, LPCWSTR appName, LPCWSTR company, BOOL ownProcess=TRUE)
Definition: CrashRpt.h:420
CrashProcessingCallbackResult(CALLBACK * PFNCRASHPROCESSINGCALLBACK)(CrashProcessingCallbackStage stage, ExceptionInfo *exceptionInfo, LPVOID userData)
Client crash callback function prototype.
Definition: CrashRpt.h:98
Contains crash handling behavior customization parameters.
Definition: CrashRpt.h:221
pfn_set_purecall_handler SetPureCallHandler
Address of _set_purecall_handler function.
Definition: CrashRpt.h:200
Explicitly force crash handler to return EXCEPTION_CONTINUE_SEARCH.
Definition: CrashRpt.h:93
BOOL FromSendReport
Indicates is exception processed using CrashRpt::SendReport() call.
Definition: CrashRpt.h:75
BOOL UseWER
To continue use Microsoft Windows Error Reporting (WER) set this member to TRUE. In that case after D...
Definition: CrashRpt.h:226
USHORT Hotfix
Version of hotfix for this application (reserved for future use, should be 0).
Definition: CrashRpt.h:214
DWORD UserDataSize
Size of userData buffer.
Definition: CrashRpt.h:121
LPCSTR DumpGroup
Used-defined dump group (see crash_rpt::CrashRpt::SkipDoctorDump_SendAssertionViolated).
Definition: CrashRpt.h:126
LONG SendReport(EXCEPTION_POINTERS *exceptionPointers)
Definition: CrashRpt.h:561
BOOL SendAdditionalDataWithoutApproval
To automatically accepted the question "Do you want to send more information about the problem...
Definition: CrashRpt.h:228
CrashProcessingCallbackResult
Result code for crash processing callback.
Definition: CrashRpt.h:88
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:224
DWORD ApplicationInfoSize
Size of this structure. Should be set to sizeof(ApplicationInfo).
Definition: CrashRpt.h:208
Crash handler doesn't send the report and returns its default result.
Definition: CrashRpt.h:91
Information about the exception.
Definition: CrashRpt.h:117
DWORD ProcessId
Process ID of the crashed process.
Definition: CrashRpt.h:123
LPCWSTR LangFilePath
To customize localization set this member to the path to the language file (including file name)...
Definition: CrashRpt.h:231
LPVOID CrashProcessingCallbackUserData
User defined parameter for CrashProcessingCallback. Optional.
Definition: CrashRpt.h:236
Information about exception being processed.
Definition: CrashRpt.h:72
pfn_set_terminate SetTerminate
Address of set_terminate function.
Definition: CrashRpt.h:198
Contains data that identifies your application.
Definition: CrashRpt.h:206
LPCWSTR DbgHelpPath
Definition: CrashRpt.h:233
DWORD HandlerSettingsSize
Size of this structure. Should be set to sizeof(HandlerSettings).
Definition: CrashRpt.h:223
LPCWSTR CollectionLibraryPath
Path to dll where collection function exported from.
Definition: CrashRpt.h:173
LPCWSTR AppName
Application name that will be shown in message box.
Definition: CrashRpt.h:211