1 ///////////////////////////////////////////////////////////////////////////////
\r
3 // Module: CrashRpt.cpp
\r
5 // Desc: See CrashRpt.h
\r
7 // Copyright (c) 2003 Michael Carruth
\r
9 ///////////////////////////////////////////////////////////////////////////////
\r
12 #include "CrashRpt.h"
\r
13 #include "CrashHandler.h"
\r
15 #include "StackTrace.h"
\r
18 #define CRASH_ASSERT(pObj) \
\r
19 if (!pObj || sizeof(*pObj) != sizeof(CCrashHandler)) \
\r
22 #define CRASH_ASSERT(pObj)
\r
26 CRASHRPTAPI LPVOID GetInstance()
\r
28 CCrashHandler *pImpl = CCrashHandler::GetInstance();
\r
29 CRASH_ASSERT(pImpl);
\r
33 CRASHRPTAPI LPVOID InstallEx(LPGETLOGFILE pfn, LPCTSTR lpcszTo, LPCTSTR lpcszSubject, BOOL bUseUI)
\r
36 OutputDebugString("InstallEx\n");
\r
38 CCrashHandler *pImpl = CCrashHandler::GetInstance();
\r
39 CRASH_ASSERT(pImpl);
\r
40 pImpl->Install(pfn, lpcszTo, lpcszSubject, bUseUI);
\r
45 CRASHRPTAPI void UninstallEx(LPVOID lpState)
\r
47 CCrashHandler *pImpl = (CCrashHandler*)lpState;
\r
48 CRASH_ASSERT(pImpl);
\r
53 CRASHRPTAPI void EnableUIEx(LPVOID lpState)
\r
55 CCrashHandler *pImpl = (CCrashHandler*)lpState;
\r
56 CRASH_ASSERT(pImpl);
\r
60 CRASHRPTAPI void DisableUIEx(LPVOID lpState)
\r
62 CCrashHandler *pImpl = (CCrashHandler*)lpState;
\r
63 CRASH_ASSERT(pImpl);
\r
67 CRASHRPTAPI void EnableHandlerEx(LPVOID lpState)
\r
69 CCrashHandler *pImpl = (CCrashHandler*)lpState;
\r
70 CRASH_ASSERT(pImpl);
\r
71 pImpl->EnableHandler();
\r
74 CRASHRPTAPI void DisableHandlerEx(LPVOID lpState)
\r
76 CCrashHandler *pImpl = (CCrashHandler*)lpState;
\r
77 CRASH_ASSERT(pImpl);
\r
78 pImpl->DisableHandler();
\r
81 CRASHRPTAPI void AddFileEx(LPVOID lpState, LPCTSTR lpFile, LPCTSTR lpDesc)
\r
83 CCrashHandler *pImpl = (CCrashHandler*)lpState;
\r
84 CRASH_ASSERT(pImpl);
\r
86 pImpl->AddFile(lpFile, lpDesc);
\r
89 CRASHRPTAPI void RemoveFileEx(LPVOID lpState, LPCTSTR lpFile)
\r
91 CCrashHandler *pImpl = (CCrashHandler*)lpState;
\r
92 CRASH_ASSERT(pImpl);
\r
94 pImpl->RemoveFile(lpFile);
\r
97 CRASHRPTAPI void AddRegistryHiveEx(LPVOID lpState, LPCTSTR lpHive, LPCTSTR lpDesc)
\r
99 CCrashHandler *pImpl = (CCrashHandler*)lpState;
\r
100 CRASH_ASSERT(pImpl);
\r
102 pImpl->AddRegistryHive(lpHive, lpDesc);
\r
105 CRASHRPTAPI void RemoveRegistryHiveEx(LPVOID lpState, LPCTSTR lpFile)
\r
107 CCrashHandler *pImpl = (CCrashHandler*)lpState;
\r
108 CRASH_ASSERT(pImpl);
\r
110 pImpl->RemoveRegistryHive(lpFile);
\r
114 CRASHRPTAPI void AddEventLogEx(LPVOID lpState, LPCTSTR lpHive, LPCTSTR lpDesc)
\r
116 CCrashHandler *pImpl = (CCrashHandler*)lpState;
\r
117 CRASH_ASSERT(pImpl);
\r
119 pImpl->AddEventLog(lpHive, lpDesc);
\r
122 CRASHRPTAPI void RemoveEventLogEx(LPVOID lpState, LPCTSTR lpFile)
\r
124 CCrashHandler *pImpl = (CCrashHandler*)lpState;
\r
125 CRASH_ASSERT(pImpl);
\r
127 pImpl->RemoveEventLog(lpFile);
\r
130 CRASHRPTAPI void GenerateErrorReportEx(LPVOID lpState, PEXCEPTION_POINTERS pExInfo, BSTR message)
\r
132 CCrashHandler *pImpl = (CCrashHandler*)lpState;
\r
133 CRASH_ASSERT(pImpl);
\r
135 if (!pImpl->GenerateErrorReport(pExInfo, message)) {
\r
140 CRASHRPTAPI void StackTrace ( int numSkip, int depth, TraceCallbackFunction pFunction, CONTEXT *pContext, void *data)
\r
142 DoStackTrace(numSkip, depth > 0 ? depth : 9999, pFunction, pContext, data);
\r
145 // DLL Entry Points usable from Visual Basic
\r
146 // explicit export is required to export undecorated names.
\r
147 extern "C" LPVOID __stdcall InstallExVB(LPGETLOGFILE pfn, LPCTSTR lpcszTo, LPCTSTR lpcszSubject, BOOL bUseUI)
\r
149 return InstallEx(pfn, lpcszTo, lpcszSubject, bUseUI);
\r
152 extern "C" void __stdcall UninstallExVB(LPVOID lpState)
\r
154 UninstallEx(lpState);
\r
157 extern "C" void __stdcall EnableUIVB(void)
\r
162 extern "C" void __stdcall DisableUIVB()
\r
167 extern "C" void __stdcall AddFileExVB(LPVOID lpState, LPCTSTR lpFile, LPCTSTR lpDesc)
\r
169 AddFileEx(lpState, lpFile, lpDesc);
\r
172 extern "C" void __stdcall RemoveFileExVB(LPVOID lpState, LPCTSTR lpFile)
\r
174 RemoveFileEx(lpState, lpFile);
\r
177 extern "C" void __stdcall AddRegistryHiveExVB(LPVOID lpState, LPCTSTR lpRegistryHive, LPCTSTR lpDesc)
\r
179 AddRegistryHiveEx(lpState, lpRegistryHive, lpDesc);
\r
182 extern "C" void __stdcall RemoveRegistryHiveExVB(LPVOID lpState, LPCTSTR lpRegistryHive)
\r
184 RemoveRegistryHiveEx(lpState, lpRegistryHive);
\r
187 extern "C" void __stdcall GenerateErrorReportExVB(LPVOID lpState, PEXCEPTION_POINTERS pExInfo, BSTR message)
\r
189 GenerateErrorReportEx(lpState, pExInfo, message);
\r
192 extern "C" void __stdcall StackTraceVB(int numSkip, int depth, TraceCallbackFunction pFunction, CONTEXT *pContext, void *data)
\r
194 StackTrace(numSkip, depth, pFunction, pContext, data);
\r
197 // Compatibility interfaces
\r
198 CRASHRPTAPI void Install(LPGETLOGFILE pfn, LPCTSTR lpcszTo, LPCTSTR lpcszSubject, BOOL bUseUI)
\r
200 (void) InstallEx(pfn, lpcszTo, lpcszSubject, bUseUI);
\r
203 CRASHRPTAPI void Uninstall()
\r
205 UninstallEx(CCrashHandler::GetInstance());
\r
208 CRASHRPTAPI void EnableUI()
\r
210 EnableUIEx(CCrashHandler::GetInstance());
\r
213 CRASHRPTAPI void DisableUI()
\r
215 DisableUIEx(CCrashHandler::GetInstance());
\r
218 CRASHRPTAPI void AddFile(LPCTSTR lpFile, LPCTSTR lpDesc)
\r
220 AddFileEx(CCrashHandler::GetInstance(), lpFile, lpDesc);
\r
223 CRASHRPTAPI void RemoveFile(LPCTSTR lpFile)
\r
225 RemoveFileEx(CCrashHandler::GetInstance(), lpFile);
\r
228 CRASHRPTAPI void AddRegistryHive(LPCTSTR lpRegistryHive, LPCTSTR lpDesc)
\r
230 AddRegistryHiveEx(CCrashHandler::GetInstance(), lpRegistryHive, lpDesc);
\r
233 CRASHRPTAPI void RemoveRegistryHive(LPCTSTR lpRegistryHive)
\r
235 RemoveRegistryHiveEx(CCrashHandler::GetInstance(), lpRegistryHive);
\r
237 CRASHRPTAPI void AddEventLog(LPCTSTR lpEventLog, LPCTSTR lpDesc)
\r
239 AddEventLogEx(CCrashHandler::GetInstance(), lpEventLog, lpDesc);
\r
242 CRASHRPTAPI void RemoveEventLog(LPCTSTR lpEventLog)
\r
244 RemoveEventLogEx(CCrashHandler::GetInstance(), lpEventLog);
\r
247 CRASHRPTAPI void GenerateErrorReport(BSTR message)
\r
249 GenerateErrorReportEx(CCrashHandler::GetInstance(), NULL, message);
\r
252 extern "C" void __stdcall InstallVB(LPGETLOGFILE pfn, LPCTSTR lpTo, LPCTSTR lpSubject, BOOL bUseUI)
\r
254 Install(pfn, lpTo, lpSubject, bUseUI);
\r
257 extern "C" void __stdcall UninstallVB()
\r
262 extern "C" void __stdcall AddFileVB(LPCTSTR lpFile, LPCTSTR lpDesc)
\r
264 AddFile(lpFile, lpDesc);
\r
267 extern "C" void __stdcall RemoveFileVB(LPCTSTR lpFile)
\r
269 RemoveFile(lpFile);
\r
272 extern "C" void __stdcall AddRegistryHiveVB(LPCTSTR lpRegistryHive, LPCTSTR lpDesc)
\r
274 AddRegistryHive(lpRegistryHive, lpDesc);
\r
277 extern "C" void __stdcall RemoveRegistryHiveVB(LPCTSTR lpRegistryHive)
\r
279 RemoveRegistryHive(lpRegistryHive);
\r
282 extern "C" void __stdcall AddEventLogVB(LPCTSTR lpEventLog, LPCTSTR lpDesc)
\r
284 AddEventLog(lpEventLog, lpDesc);
\r
287 extern "C" void __stdcall RemoveEventLogVB(LPCTSTR lpEventLog)
\r
289 RemoveEventLog(lpEventLog);
\r
292 extern "C" void __stdcall GenerateErrorReportVB(BSTR message)
\r
294 GenerateErrorReport(message);
\r