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