crashrpt | ||
A crash reporting system for Windows applications |
The CrashSender.exe is by default assumed to be located in the same folder as CrashRpt.dll. Optionally, you can specify a different path using the CR_INSTALL_INFO::pszCrashSenderPath structure member.
If your want to just collect and save crash report files to disc, but not to send the report, you can specify CR_INST_DONT_SEND_REPORT flag for CR_INSTALL_INFO::dwFlags member. This forces CrashSender.exe to exit after crash report data collection is finished.
By default, CrashRpt stores error report files in uncompressed state. If you want to additionally compress error reports and store them as ZIP archives, specify the CR_INST_STORE_ZIP_ARCHIVES flag for CR_INSTALL_INFO::dwFlags member.
Sending Error Report Dialog
Certain delivery method can be disabled by specifying special constant CR_NEGATIVE_PRIORITY as method's priority.
In the Sending Error Report dialog, there is a status log area below the progress bar control. It contains the details of report delivery process. The log may be useful when troubleshooting error report delivery issues.
A user can copy some selected lines or the whole log to the clipboard. To do this, he should select several lines of the log, right-click the selection and choose an item from the context menu.
On application start up, CrashRpt checks if it is time to remind user about recent error reports ready for delivery, shows notification balloon and offers user to deliver them (see the figure below). CrashRpt shows notification balloon if at least one week elapsed since the last notification.
Notification Balloon
Sending Recent Error Reports
CrashRpt supports HTTP file uploads as described in RFC-1867. This mechanism allows to upload large files by using binary content transfer encoding. The "multipart/form-data" encoding type is utilized for this purpose.
The equivalent HTML form for file uploads is presented below (some form fields may be omitted, see the next section for the complete list of fields that may appear):
<html> <form action="http://someserver.net/crashrpt.php" method="POST" enctype="multipart/form-data"> Application name:<input type="text" name="appname"> Application version:<input type="text" name="appversion"> Email from:<input type="text" name="emailfrom"> Email subject:<input type="text" name="emailsubject"> Crash GUID:<input type="text" name="crashguid"> MD5:<input type="text" name="md5"> Attach ZIP file:<input type="file" name="crashrpt"> <input type="submit" name="Submit"> </form> </html>
The server-side script may receive the following POST parameters. In PHP, these parameters are part of $_POST global array.
Parameter Name | Example value | Remarks |
---|---|---|
md5 | "af89e902b42cd301092bb34530984e59" | This parameter contains the MD5 hash of error report data. This can be used to check error report integrity. |
appname | "MyApp" | Application name (as passed to CR_INSTALL_INFO::pszAppName structure member). This parameter is available in error report sent by CrashRpt v.1.2.2 or later. |
appversion | "1.0.0" | Application version (as passed to CR_INSTALL_INFO::pszAppVersion structure member). This parameter is available in error report sent by CrashRpt v.1.2.2 or later. |
crashguid | "37b4d6da-1211-4e62-adc6-174acb53ddf5" | Crash GUID (globally unique identifier). This parameter is available in error report sent by CrashRpt v.1.2.2 or later. |
emailsubject | "MyApp 1.0.0 Error Report" | E-mail subject (as passed to CR_INSTALL_INFO::pszEmailSubject structure member). This parameter is available in error report sent by CrashRpt v.1.2.2 or later. |
emailfrom | "user@example.com" | E-mail of the user who sent this report. This parameter is available in error report sent by CrashRpt v.1.2.2 or later. |
description | "I just started the app and then it crashed. Help!" | User-provided problem description. This parameter is available in error report sent by CrashRpt v.1.2.2 or later.
|
The server side script may receive the following file attachments. In PHP, these parameters are part of $_FILES global array.
Attachment Name | Remarks |
---|---|
crashrpt | This file attachment contains the error report file data. This parameter is available in error report sent by CrashRpt v.1.2.2 or later. |
If the script succeeds in saving the error report, it should return the "200 Success" as server responce header. If the script encounters an error, it should return a 4xx error code, for example "450 Invalid parameter". Note that some error codes are reserved by HTTP specification. If the script uses custom error codes, they shouldn't intersect with standard predefined HTTP codes.
<?php // Specify the directory where to save error reports $file_root = "/home/username/crash_reports/"; // This is to avoid PHP warning date_default_timezone_set('UTC'); // Writes error code and text message and then exits function done($return_status, $message) { // Write HTTP responce code header("HTTP/1.0 ".$return_status." ".$message); // Write HTTP responce body (for backwards compatibility) echo $return_status." ".$message; exit(0); } // Checks that text fild doesn't contain inacceptable symbols function checkOK($field) { if (stristr($field, "\\r") || stristr($field, "\\n")) { done(450, "Invalid input parameter."); } } $md5_hash = ""; // MD5 hash for error report ZIP $file_name = ""; // Destination file name $crash_guid = ""; // Crash GUID // Check that MD5 hash exists if(!isset($_POST['md5'])) { done(450, "MD5 hash is missing."); } // Get MD5 hash $md5_hash = $_POST['md5']; checkOK($md5_hash); if(strlen($md5_hash)!=32) { done(450, "MD5 hash value has wrong length."); } // Get CrashGUID if(!array_key_exists("crashguid", $_POST)) { done(450, "Crash GUID missing."); } $crash_guid = $_POST["crashguid"]; checkOK($crash_guid); if(strlen($crash_guid)!=36) { done(450, "Crash GUID has wrong length."); } // Get file attachment if(array_key_exists("crashrpt", $_FILES)) { // Check upload error code $error_code = $_FILES["crashrpt"]["error"]; if($error_code!=0) { done(450, "File upload failed with code $error_code."); } // Get temporary name uploaded file is stored currently $tmp_file_name = $_FILES["crashrpt"]["tmp_name"]; checkOK($tmp_file_name); // Check that uploaded file data have correct MD5 hash $my_md5_hash = strtolower(md5_file($tmp_file_name)); $their_md5_hash = strtolower($md5_hash); if($my_md5_hash!=$their_md5_hash) { done(451, "MD5 hash is invalid (yours is ".$their_md5_hash.", but mine is ".$my_md5_hash.")"); } // Use crash GUID as file name $file_name = $file_root.$crash_guid.".zip"; // Move uploaded file to an appropriate directory if(!move_uploaded_file($tmp_file_name, $file_name)) { done(452, "Couldn't save data to local storage"); } } else { done(452, "File attachment missing"); } // OK. done(200, "Success."); ?>
Many SMTP servers may block direct access to them from dynamic IPs to avoid spam (for example Google Mail does so). This delivery method may also fail if firewall blocks outgoing connections on port 25. Because of this reason, this delivery method is recommended to use if you install your application to a single machine with installed SMTP server (for example, server applications may fit this requirements).
To specify the address of the SMTP server, use CR_INSTALL_INFO::pszSmtpProxy structure member. This parameter defines the network address (IP or domain) and, optionally, port formatted as "address[:port]" of SMTP server.
To specify the recipient of E-mail messages, you use the CR_INSTALL_INFO::pszEmailTo structure member. You can specify the subject of E-mail message using the CR_INSTALL_INFO::pszEmailSubject structure member.
If CR_INSTALL_INFO::pszSmtpProxy is not provided, CrashRpt tries to determine the SMTP server's address from the recipient E-mail address's MX domain record and relays the email message to that server.
If SMTP server requires authentication, you can specify the login and password through CR_INSTALL_INFO::pszSmtpLogin and CR_INSTALL_INFO::pszSmtpPassword members, respectively.
By default CrashRpt generates an E-mail message's text automatically, but if you want to override the E-mail text, you can use the CR_INSTALL_INFO::pszEmailText structure member.
To specify the recipient of E-mail messages, you use the CR_INSTALL_INFO::pszEmailTo structure member. You can specify the subject of E-mail message using the CR_INSTALL_INFO::pszEmailSubject structure member.
By default CrashRpt generates an E-mail message's text automatically, but if you want to override the E-mail text, you can use the CR_INSTALL_INFO::pszEmailText structure member.
In case you plan to deliver error reports over E-mail (SMTP or Simple MAPI), than error reports should be as small as possible. This is because of limitations of email attachment size. If the error report is larger than the limit (which may be different for different mail servers), it is possible that the error report will be rejected.
Further reading: Miscellaneous API Features.