1 ///////////////////////////////////////////////////////////////////////////////
\r
3 // Module: CrashRpt.h
\r
5 // Desc: Defines the interface for the CrashRpt.DLL.
\r
7 // Copyright (c) 2003 Michael Carruth
\r
9 ///////////////////////////////////////////////////////////////////////////////
\r
11 #ifndef _CRASHRPT_H_
\r
12 #define _CRASHRPT_H_
\r
14 #if _MSC_VER >= 1000
\r
16 #endif // _MSC_VER >= 1000
\r
18 #include <windows.h>
\r
19 #include <wtypes.h> // BSTR
\r
24 // CRASHRPTAPI should be defined in all of the DLL's source files as
\r
25 // #define CRASHRPTAPI extern "C" __declspec(dllexport)
\r
29 // This header file is included by an EXE - export
\r
30 #define CRASHRPTAPI extern "C" __declspec(dllimport)
\r
34 // Client crash callback
\r
35 typedef BOOL (CALLBACK *LPGETLOGFILE) (LPVOID lpvState);
\r
36 // Stack trace callback
\r
37 typedef void (*TraceCallbackFunction)(DWORD_PTR address, const char *ImageName,
\r
38 const char *FunctionName, DWORD_PTR functionDisp,
\r
39 const char *Filename, DWORD LineNumber, DWORD lineDisp,
\r
43 //-----------------------------------------------------------------------------
\r
45 // Returns the instance (state information) for the current process. Will create
\r
46 // one if required; does not install.
\r
52 // If the function succeeds, the return value is a pointer to the underlying
\r
53 // crash object created. This state information is required as the first
\r
54 // parameter to all other crash report functions.
\r
63 //-----------------------------------------------------------------------------
\r
64 // Install, InstallEx
\r
65 // Initializes the library and optionally set the client crash callback and
\r
66 // sets up the email details.
\r
69 // pfn Client crash callback
\r
70 // lpTo Email address to send crash report
\r
71 // lpSubject Subject line to be used with email
\r
75 // If the function succeeds, the return value is a pointer to the underlying
\r
76 // crash object created. This state information is required as the first
\r
77 // parameter to all other crash report functions.
\r
82 // Passing NULL for lpTo will disable the email feature and cause the crash
\r
83 // report to be saved to disk.
\r
88 IN LPGETLOGFILE pfn OPTIONAL, // client crash callback
\r
89 IN LPCSTR lpTo OPTIONAL, // Email:to
\r
90 IN LPCSTR lpSubject OPTIONAL, // Email:subject
\r
91 IN BOOL bUseUI OPTIONAL // UI or console
\r
96 IN LPGETLOGFILE pfn OPTIONAL, // client crash callback
\r
97 IN LPCSTR lpTo OPTIONAL, // Email:to
\r
98 IN LPCSTR lpSubject OPTIONAL, // Email:subject
\r
99 IN BOOL bUseUI OPTIONAL // UI or console
\r
102 //-----------------------------------------------------------------------------
\r
103 // Uninstall, UninstallEx
\r
104 // Uninstalls the unhandled exception filter set up in Install().
\r
107 // lpState State information returned from Install()
\r
113 // This call is optional. The crash report library will automatically
\r
114 // deinitialize when the library is unloaded. Call this function to
\r
115 // unhook the exception filter manually.
\r
117 CRASHRPTAPI void Uninstall();
\r
121 IN LPVOID lpState // State from Install()
\r
124 CRASHRPTAPI void EnableUI();
\r
125 CRASHRPTAPI void DisableUI();
\r
126 //-----------------------------------------------------------------------------
\r
127 // AddFile, AddFileEx
\r
128 // Adds a file to the crash report.
\r
131 // lpState State information returned from Install()
\r
132 // lpFile Fully qualified file name
\r
133 // lpDesc Description of file, used by details dialog
\r
139 // This function can be called anytime after Install() to add one or more
\r
140 // files to the generated crash report. If lpFile and lpDesc exactly match
\r
141 // a previously added pair, it is not added again.
\r
146 IN LPCSTR lpFile, // File name
\r
147 IN LPCSTR lpDesc // File desc
\r
152 IN LPVOID lpState, // State from Install()
\r
153 IN LPCSTR lpFile, // File name
\r
154 IN LPCSTR lpDesc // File desc
\r
157 //-----------------------------------------------------------------------------
\r
159 // Removes a file from the crash report.
\r
162 // lpState State information returned from Install()
\r
163 // lpFile Fully qualified file name
\r
169 // The filename must exactly match that provided to AddFile.
\r
174 IN LPCSTR lpFile // File name
\r
179 IN LPVOID lpState, // State from Install()
\r
180 IN LPCSTR lpFile // File name
\r
183 //-----------------------------------------------------------------------------
\r
185 // Adds a RegistryHive to the crash report.
\r
188 // lpState State information returned from Install()
\r
189 // lpRegistryHive Fully qualified RegistryHive name
\r
190 // lpDesc Description of RegistryHive, used by details dialog
\r
196 // This function can be called anytime after Install() to add one or more
\r
197 // RegistryHives to the generated crash report. If lpRegistryHive and lpDesc exactly match
\r
198 // a previously added pair, it is not added again.
\r
203 IN LPCSTR lpRegistryHive, // RegistryHive name
\r
204 IN LPCSTR lpDesc // RegistryHive desc
\r
209 IN LPVOID lpState, // State from Install()
\r
210 IN LPCSTR lpRegistryHive, // RegistryHive name
\r
211 IN LPCSTR lpDesc // RegistryHive desc
\r
214 //-----------------------------------------------------------------------------
\r
215 // RemoveRegistryHive
\r
216 // Removes a RegistryHive from the crash report.
\r
219 // lpState State information returned from Install()
\r
220 // lpRegistryHive Fully qualified RegistryHive name
\r
226 // The RegistryHive name must exactly match that provided to AddRegistryHive.
\r
230 RemoveRegistryHive(
\r
231 IN LPCSTR lpRegistryHive // RegistryHive name
\r
235 RemoveRegistryHiveEx(
\r
236 IN LPVOID lpState, // State from Install()
\r
237 IN LPCSTR lpRegistryHive // RegistryHive name
\r
240 //-----------------------------------------------------------------------------
\r
242 // Adds an event log to the crash report.
\r
245 // lpState State information returned from Install()
\r
246 // lpEventLog Event log name ("Application", "Security", "System" or any other known to your system)
\r
247 // lpDesc Description of event log, used by details dialog
\r
253 // This function can be called anytime after Install() to add one or more
\r
254 // event logs to the generated crash report. If lpEventLog and lpDesc exactly match
\r
255 // a previously added pair, it is not added again.
\r
260 IN LPCSTR lpEventLog, // Event Log name
\r
261 IN LPCSTR lpDesc // Event Log desc
\r
266 IN LPVOID lpState, // State from Install()
\r
267 IN LPCSTR lpEventLog, // Event Log name
\r
268 IN LPCSTR lpDesc // Event Log desc
\r
271 //-----------------------------------------------------------------------------
\r
273 // Removes a EventLog from the crash report.
\r
276 // lpState State information returned from Install()
\r
277 // lpEventLog Fully qualified EventLog name
\r
283 // The EventLog name must exactly match that provided to AddEventLog.
\r
288 IN LPCSTR lpEventLog // EventLog name
\r
293 IN LPVOID lpState, // State from Install()
\r
294 IN LPCSTR lpEventLog // EventLog name
\r
297 //-----------------------------------------------------------------------------
\r
298 // GenerateErrorReport, GenerateErrorReportEx
\r
299 // Generates the crash report.
\r
302 // lpState State information returned from Install()
\r
303 // pExInfo Optional; pointer to an EXCEPTION_POINTERS structure
\r
304 // message Optional; message to include in report
\r
310 // Call this function to manually generate a crash report.
\r
311 // Note that only GenerateErrorReportEx can be supplied exception information.
\r
312 // If you are using the basic interfaces and wish to supply exception information,
\r
313 // use the call GenerateErrorReportEx, supplying GetInstance() for the state
\r
318 GenerateErrorReport(
\r
319 IN BSTR message OPTIONAL
\r
323 GenerateErrorReportEx(
\r
325 IN PEXCEPTION_POINTERS pExInfo OPTIONAL,
\r
326 IN BSTR message OPTIONAL
\r
329 //-----------------------------------------------------------------------------
\r
331 // Creates a stack trace.
\r
334 // numSkip Number of initial stack frames to skip
\r
335 // depth Number of stack frames to process
\r
336 // pFunction Optional; function to call for each frame
\r
337 // pContext Optional; stack context to trace
\r
343 // Call this function to manually generate a stack trace. If
\r
344 // pFunction is not supplied, stack trace frames are output using
\r
345 // OutputDebugString. Note that this function does not require the
\r
346 // 'lpState'; it can be called even if the crash handler is not
\r
353 IN int depth OPTIONAL,
\r
354 IN TraceCallbackFunction pFunction OPTIONAL,
\r
355 IN CONTEXT * pContext OPTIONAL,
\r
356 IN LPVOID data OPTIONAL
\r
360 //-----------------------------------------------------------------------------
\r
361 // The following functions are identical to the above save that they are callable from Visual Basic
\r
366 IN LPGETLOGFILE pfn OPTIONAL, // client crash callback
\r
367 IN LPCSTR lpTo OPTIONAL, // Email:to
\r
368 IN LPCSTR lpSubject OPTIONAL, // Email:subject
\r
369 IN BOOL bUseUI OPTIONAL // UI or console
\r
377 IN LPVOID lpState // State from InstallVB()
\r
395 IN LPVOID lpState, // State from InstallVB()
\r
396 IN LPCSTR lpFile, // File name
\r
397 IN LPCSTR lpDesc // File desc
\r
404 IN LPVOID lpState, // State from InstallVB()
\r
405 IN LPCSTR lpFile // File name
\r
411 AddRegistryHiveExVB(
\r
412 IN LPVOID lpState, // State from InstallVB()
\r
413 IN LPCSTR lpRegistryHive, // RegistryHive name
\r
414 IN LPCSTR lpDesc // RegistryHive desc
\r
420 RemoveRegistryHiveExVB(
\r
421 IN LPVOID lpState, // State from InstallVB()
\r
422 IN LPCSTR lpRegistryHive // RegistryHive name
\r
428 GenerateErrorReportExVB(
\r
430 IN PEXCEPTION_POINTERS pExInfo OPTIONAL,
\r
431 IN BSTR message OPTIONAL
\r
439 IN int depth OPTIONAL,
\r
440 IN TraceCallbackFunction pFunction OPTIONAL,
\r
441 IN CONTEXT * pContext OPTIONAL,
\r
442 IN LPVOID data OPTIONAL
\r
445 extern "C" void __stdcall InstallVB(IN LPGETLOGFILE pfn OPTIONAL, IN LPCSTR lpTo OPTIONAL, IN LPCSTR lpSubject OPTIONAL, IN BOOL bUseUI OPTIONAL);
\r
446 extern "C" void __stdcall UninstallVB();
\r
447 extern "C" void __stdcall AddFileVB(LPCSTR file, LPCSTR desc);
\r
448 extern "C" void __stdcall RemoveFileVB(LPCSTR file);
\r
449 extern "C" void __stdcall AddRegistryHiveVB(LPCSTR RegistryHive, LPCSTR desc);
\r
450 extern "C" void __stdcall RemoveRegistryHiveVB(LPCSTR RegistryHive);
\r
451 extern "C" void __stdcall GenerateErrorReportVB(BSTR message);
\r