--- /dev/null
+#include "stdafx.h"\r
+#include "BaseDialog.h"\r
+\r
+\r
+INT_PTR CDialog::DoModal(HINSTANCE hInstance, int resID, HWND hWndParent)\r
+{\r
+ hResource = hInstance;\r
+ return DialogBoxParam(hInstance, MAKEINTRESOURCE(resID), hWndParent, &CDialog::stDlgFunc, (LPARAM)this);\r
+}\r
+\r
+void CDialog::InitDialog(HWND hwndDlg, UINT iconID)\r
+{\r
+ HWND hwndOwner; \r
+ RECT rc, rcDlg, rcOwner;\r
+\r
+ hwndOwner = ::GetParent(hwndDlg);\r
+ if (hwndOwner == NULL)\r
+ hwndOwner = ::GetDesktopWindow();\r
+\r
+ GetWindowRect(hwndOwner, &rcOwner); \r
+ GetWindowRect(hwndDlg, &rcDlg); \r
+ CopyRect(&rc, &rcOwner); \r
+\r
+ OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top); \r
+ OffsetRect(&rc, -rc.left, -rc.top); \r
+ OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom); \r
+\r
+ SetWindowPos(hwndDlg, HWND_TOP, rcOwner.left + (rc.right / 2), rcOwner.top + (rc.bottom / 2), 0, 0, SWP_NOSIZE); \r
+ HICON hIcon = (HICON)::LoadImage(hResource, MAKEINTRESOURCE(iconID), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE|LR_SHARED);\r
+ ::SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);\r
+ ::SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);\r
+}\r
+\r
+INT_PTR CALLBACK CDialog::stDlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)\r
+{\r
+ CDialog* pWnd;\r
+ if (uMsg == WM_INITDIALOG)\r
+ {\r
+ // get the pointer to the window from lpCreateParams\r
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);\r
+ pWnd = (CDialog*)lParam;\r
+ pWnd->m_hwnd = hwndDlg;\r
+ }\r
+ // get the pointer to the window\r
+ pWnd = GetObjectFromWindow(hwndDlg);\r
+\r
+ // if we have the pointer, go to the message handler of the window\r
+ // else, use DefWindowProc\r
+ if (pWnd)\r
+ {\r
+ LRESULT lRes = pWnd->DlgFunc(hwndDlg, uMsg, wParam, lParam);\r
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, lRes);\r
+ return lRes;\r
+ }\r
+ else\r
+ return DefWindowProc(hwndDlg, uMsg, wParam, lParam);\r
+}\r
--- /dev/null
+#pragma once\r
+#include <string>\r
+\r
+\r
+/**\r
+ * A base window class.\r
+ * Provides separate window message handlers for every window object based on\r
+ * this class.\r
+ */\r
+class CDialog\r
+{\r
+public:\r
+ INT_PTR DoModal(HINSTANCE hInstance, int resID, HWND hWndParent);\r
+\r
+ virtual LRESULT CALLBACK DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) = 0;\r
+\r
+ operator HWND() {return m_hwnd;}\r
+protected:\r
+ HINSTANCE hResource;\r
+ HWND m_hwnd;\r
+\r
+ void InitDialog(HWND hwndDlg, UINT iconID);\r
+\r
+ // the real message handler\r
+ static INT_PTR CALLBACK stDlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);\r
+\r
+ // returns a pointer the dialog (stored as the WindowLong)\r
+ inline static CDialog * GetObjectFromWindow(HWND hWnd)\r
+ {\r
+ return (CDialog *)GetWindowLongPtr(hWnd, GWLP_USERDATA);\r
+ }\r
+};\r
+\r
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Module: CrashHandler.cpp\r
+//\r
+// Desc: See CrashHandler.h\r
+//\r
+// Copyright (c) 2003 Michael Carruth\r
+//\r
+///////////////////////////////////////////////////////////////////////////////\r
+\r
+#include "stdafx.h"\r
+#include "CrashHandler.h"\r
+#include "zlibcpp.h"\r
+#include "excprpt.h"\r
+#include "maindlg.h"\r
+#include "mailmsg.h"\r
+#include "WriteRegistry.h"\r
+#include "resource.h"\r
+\r
+#include <windows.h>\r
+#include <shlwapi.h>\r
+#include <commctrl.h>\r
+#pragma comment(lib, "shlwapi")\r
+#pragma comment(lib, "comctl32")\r
+\r
+#include <algorithm>\r
+\r
+BOOL g_bNoCrashHandler;// don't use the crash handler but let the system handle it\r
+\r
+// maps crash objects to processes\r
+map<DWORD, CCrashHandler*> _crashStateMap;\r
+\r
+// unhandled exception callback set with SetUnhandledExceptionFilter()\r
+LONG WINAPI CustomUnhandledExceptionFilter(PEXCEPTION_POINTERS pExInfo)\r
+{\r
+ OutputDebugString("Exception\n");\r
+ if (EXCEPTION_BREAKPOINT == pExInfo->ExceptionRecord->ExceptionCode)\r
+ {\r
+ // Breakpoint. Don't treat this as a normal crash.\r
+ return EXCEPTION_CONTINUE_SEARCH;\r
+ }\r
+\r
+ if (g_bNoCrashHandler)\r
+ {\r
+ return EXCEPTION_CONTINUE_SEARCH;\r
+ }\r
+\r
+ BOOL result = false;\r
+ if (_crashStateMap.find(GetCurrentProcessId()) != _crashStateMap.end())\r
+ result = _crashStateMap[GetCurrentProcessId()]->GenerateErrorReport(pExInfo, NULL);\r
+\r
+ // If we're in a debugger, return EXCEPTION_CONTINUE_SEARCH to cause the debugger to stop;\r
+ // or if GenerateErrorReport returned FALSE (i.e. drop into debugger).\r
+ return (!result || IsDebuggerPresent()) ? EXCEPTION_CONTINUE_SEARCH : EXCEPTION_EXECUTE_HANDLER;\r
+}\r
+\r
+CCrashHandler * CCrashHandler::GetInstance()\r
+{\r
+ CCrashHandler *instance = NULL;\r
+ if (_crashStateMap.find(GetCurrentProcessId()) != _crashStateMap.end())\r
+ instance = _crashStateMap[GetCurrentProcessId()];\r
+ if (instance == NULL) {\r
+ // will register\r
+ instance = new CCrashHandler();\r
+ }\r
+ return instance;\r
+}\r
+\r
+CCrashHandler::CCrashHandler():\r
+ m_oldFilter(NULL),\r
+ m_lpfnCallback(NULL),\r
+ m_pid(GetCurrentProcessId()),\r
+ m_ipc_event(NULL),\r
+ m_rpt(NULL),\r
+ m_installed(false),\r
+ m_hModule(NULL),\r
+ m_bUseUI(TRUE),\r
+ m_wantDebug(false)\r
+{\r
+ // wtl initialization stuff...\r
+ HRESULT hRes = ::CoInitialize(NULL);\r
+ if (hRes != S_OK)\r
+ m_pid = 0;\r
+ else\r
+ _crashStateMap[m_pid] = this;\r
+}\r
+\r
+void CCrashHandler::Install(LPGETLOGFILE lpfn, LPCTSTR lpcszTo, LPCTSTR lpcszSubject, BOOL bUseUI)\r
+{\r
+ if (m_pid == 0)\r
+ return;\r
+#ifdef _DEBUG\r
+ OutputDebugString("::Install\n");\r
+#endif\r
+ if (m_installed) {\r
+ Uninstall();\r
+ }\r
+ // save user supplied callback\r
+ m_lpfnCallback = lpfn;\r
+ // save optional email info\r
+ m_sTo = lpcszTo;\r
+ m_sSubject = lpcszSubject;\r
+ m_bUseUI = bUseUI;\r
+\r
+ // This is needed for CRT to not show dialog for invalid param\r
+ // failures and instead let the code handle it.\r
+ _CrtSetReportMode(_CRT_ASSERT, 0);\r
+ // add this filter in the exception callback chain\r
+ m_oldFilter = SetUnhandledExceptionFilter(CustomUnhandledExceptionFilter);\r
+/*m_oldErrorMode=*/ SetErrorMode( SEM_FAILCRITICALERRORS );\r
+\r
+ m_installed = true;\r
+}\r
+\r
+void CCrashHandler::Uninstall()\r
+{\r
+#ifdef _DEBUG\r
+ OutputDebugString("Uninstall\n");\r
+#endif\r
+ // reset exception callback (to previous filter, which can be NULL)\r
+ SetUnhandledExceptionFilter(m_oldFilter);\r
+ m_installed = false;\r
+}\r
+\r
+void CCrashHandler::EnableUI()\r
+{\r
+ m_bUseUI = TRUE;\r
+}\r
+\r
+void CCrashHandler::DisableUI()\r
+{\r
+ m_bUseUI = FALSE;\r
+}\r
+\r
+void CCrashHandler::DisableHandler()\r
+{\r
+ g_bNoCrashHandler = TRUE;\r
+}\r
+\r
+void CCrashHandler::EnableHandler()\r
+{\r
+ g_bNoCrashHandler = FALSE;\r
+}\r
+\r
+CCrashHandler::~CCrashHandler()\r
+{\r
+\r
+ Uninstall();\r
+\r
+ _crashStateMap.erase(m_pid);\r
+\r
+ ::CoUninitialize();\r
+\r
+}\r
+\r
+void CCrashHandler::AddFile(LPCTSTR lpFile, LPCTSTR lpDesc)\r
+{\r
+ // make sure we don't already have the file\r
+ RemoveFile(lpFile);\r
+ // make sure the file exists\r
+ HANDLE hFile = ::CreateFile(\r
+ lpFile,\r
+ GENERIC_READ,\r
+ FILE_SHARE_READ | FILE_SHARE_WRITE,\r
+ NULL,\r
+ OPEN_EXISTING,\r
+ FILE_ATTRIBUTE_NORMAL,\r
+ 0);\r
+ if (hFile != INVALID_HANDLE_VALUE)\r
+ {\r
+ // add file to report\r
+ m_files.push_back(TStrStrPair(lpFile, lpDesc));\r
+ ::CloseHandle(hFile);\r
+ }\r
+}\r
+\r
+void CCrashHandler::RemoveFile(LPCTSTR lpFile)\r
+{\r
+ TStrStrVector::iterator iter;\r
+ for (iter = m_files.begin(); iter != m_files.end(); ++iter) {\r
+ if ((*iter).first == lpFile) {\r
+ iter = m_files.erase(iter);\r
+ break;\r
+ }\r
+ }\r
+}\r
+\r
+void CCrashHandler::AddRegistryHive(LPCTSTR lpRegistryHive, LPCTSTR lpDesc)\r
+{\r
+ // make sure we don't already have the RegistryHive\r
+ RemoveRegistryHive(lpRegistryHive);\r
+ // Unfortunately, we have no easy way of verifying the existence of\r
+ // the registry hive.\r
+ // add RegistryHive to report\r
+ m_registryHives.push_back(TStrStrPair(lpRegistryHive, lpDesc));\r
+}\r
+\r
+void CCrashHandler::RemoveRegistryHive(LPCTSTR lpRegistryHive)\r
+{\r
+ TStrStrVector::iterator iter;\r
+ for (iter = m_registryHives.begin(); iter != m_registryHives.end(); ++iter) {\r
+ if ((*iter).first == lpRegistryHive) {\r
+ iter = m_registryHives.erase(iter);\r
+ }\r
+ }\r
+}\r
+\r
+void CCrashHandler::AddEventLog(LPCTSTR lpEventLog, LPCTSTR lpDesc)\r
+{\r
+ // make sure we don't already have the EventLog\r
+ RemoveEventLog(lpEventLog);\r
+ // Unfortunately, we have no easy way of verifying the existence of\r
+ // the event log..\r
+ // add EventLog to report\r
+ m_eventLogs.push_back(TStrStrPair(lpEventLog, lpDesc));\r
+}\r
+\r
+void CCrashHandler::RemoveEventLog(LPCTSTR lpEventLog)\r
+{\r
+ TStrStrVector::iterator iter;\r
+ for (iter = m_eventLogs.begin(); iter != m_eventLogs.end(); ++iter) {\r
+ if ((*iter).first == lpEventLog) {\r
+ iter = m_eventLogs.erase(iter);\r
+ }\r
+ }\r
+}\r
+\r
+DWORD WINAPI CCrashHandler::DialogThreadExecute(LPVOID pParam)\r
+{\r
+ // New thread. This will display the dialog and handle the result.\r
+ CCrashHandler * self = reinterpret_cast<CCrashHandler *>(pParam);\r
+ CMainDlg mainDlg;\r
+ string sTempFileName = CUtility::getTempFileName();\r
+ CZLib zlib;\r
+\r
+ // delete existing copy, if any\r
+ DeleteFile(sTempFileName.c_str());\r
+\r
+ // zip the report\r
+ if (!zlib.Open(sTempFileName))\r
+ return TRUE;\r
+ \r
+ // add report files to zip\r
+ TStrStrVector::iterator cur = self->m_files.begin();\r
+ for (cur = self->m_files.begin(); cur != self->m_files.end(); cur++)\r
+ if (PathFileExists((*cur).first.c_str()))\r
+ zlib.AddFile((*cur).first);\r
+\r
+ zlib.Close();\r
+\r
+ mainDlg.m_pUDFiles = &self->m_files;\r
+ mainDlg.m_sendButton = !self->m_sTo.empty();\r
+\r
+ INITCOMMONCONTROLSEX used = {\r
+ sizeof(INITCOMMONCONTROLSEX),\r
+ ICC_LISTVIEW_CLASSES | ICC_WIN95_CLASSES | ICC_BAR_CLASSES | ICC_USEREX_CLASSES\r
+ };\r
+ InitCommonControlsEx(&used);\r
+\r
+ INT_PTR status = mainDlg.DoModal(GetModuleHandle("CrashRpt.dll"), IDD_MAINDLG, GetDesktopWindow());\r
+ if (IDOK == status || IDC_SAVE == status)\r
+ {\r
+ if (IDC_SAVE == status || self->m_sTo.empty() || \r
+ !self->MailReport(*self->m_rpt, sTempFileName.c_str(), mainDlg.m_sEmail.c_str(), mainDlg.m_sDescription.c_str()))\r
+ {\r
+ // write user data to file if to be supplied\r
+ if (!self->m_userDataFile.empty()) {\r
+ HANDLE hFile = ::CreateFile(\r
+ self->m_userDataFile.c_str(),\r
+ GENERIC_READ | GENERIC_WRITE,\r
+ FILE_SHARE_READ | FILE_SHARE_WRITE,\r
+ NULL,\r
+ CREATE_ALWAYS,\r
+ FILE_ATTRIBUTE_NORMAL,\r
+ 0);\r
+ if (hFile != INVALID_HANDLE_VALUE)\r
+ {\r
+ static const char e_mail[] = "E-mail:";\r
+ static const char newline[] = "\r\n";\r
+ static const char description[] = "\r\n\r\nDescription:";\r
+ DWORD writtenBytes;\r
+ ::WriteFile(hFile, e_mail, sizeof(e_mail) - 1, &writtenBytes, NULL);\r
+ ::WriteFile(hFile, mainDlg.m_sEmail.c_str(), mainDlg.m_sEmail.size(), &writtenBytes, NULL);\r
+ ::WriteFile(hFile, description, sizeof(description) - 1, &writtenBytes, NULL);\r
+ ::WriteFile(hFile, mainDlg.m_sDescription.c_str(), mainDlg.m_sDescription.size(), &writtenBytes, NULL);\r
+ ::WriteFile(hFile, newline, sizeof(newline) - 1, &writtenBytes, NULL);\r
+ ::CloseHandle(hFile);\r
+ // redo zip file to add user data\r
+ // delete existing copy, if any\r
+ DeleteFile(sTempFileName.c_str());\r
+\r
+ // zip the report\r
+ if (!zlib.Open(sTempFileName))\r
+ return TRUE;\r
+ \r
+ // add report files to zip\r
+ TStrStrVector::iterator cur = self->m_files.begin();\r
+ for (cur = self->m_files.begin(); cur != self->m_files.end(); cur++)\r
+ if (PathFileExists((*cur).first.c_str()))\r
+ zlib.AddFile((*cur).first);\r
+\r
+ zlib.Close();\r
+ }\r
+ }\r
+ self->SaveReport(*self->m_rpt, sTempFileName.c_str());\r
+ }\r
+ }\r
+\r
+ DeleteFile(sTempFileName.c_str());\r
+\r
+ self->m_wantDebug = IDC_DEBUG == status;\r
+ // signal main thread to resume\r
+ ::SetEvent(self->m_ipc_event);\r
+ // set flag for debugger break\r
+\r
+ // exit thread\r
+ ::ExitThread(0);\r
+ // keep compiler happy.\r
+ return TRUE;\r
+}\r
+\r
+BOOL CCrashHandler::GenerateErrorReport(PEXCEPTION_POINTERS pExInfo, BSTR message)\r
+{\r
+ CExceptionReport rpt(pExInfo, message);\r
+ unsigned int i;\r
+ // save state of file list prior to generating report\r
+ TStrStrVector save_m_files = m_files;\r
+ char temp[_MAX_PATH];\r
+\r
+ GetTempPath(sizeof temp, temp);\r
+\r
+\r
+ // let client add application specific files to report\r
+ if (m_lpfnCallback && !m_lpfnCallback(this))\r
+ return TRUE;\r
+\r
+ m_rpt = &rpt;\r
+\r
+ // if no e-mail address, add file to contain user data\r
+ m_userDataFile = "";\r
+ if (m_sTo.empty()) {\r
+ m_userDataFile = temp + string("\\") + CUtility::getAppName() + "_UserInfo.txt";\r
+ HANDLE hFile = ::CreateFile(\r
+ m_userDataFile.c_str(),\r
+ GENERIC_READ | GENERIC_WRITE,\r
+ FILE_SHARE_READ | FILE_SHARE_WRITE,\r
+ NULL,\r
+ CREATE_ALWAYS,\r
+ FILE_ATTRIBUTE_NORMAL,\r
+ 0);\r
+ if (hFile != INVALID_HANDLE_VALUE)\r
+ {\r
+ static const char description[] = "Your e-mail and description will go here.";\r
+ DWORD writtenBytes;\r
+ ::WriteFile(hFile, description, sizeof(description)-1, &writtenBytes, NULL);\r
+ ::CloseHandle(hFile);\r
+ m_files.push_back(TStrStrPair(m_userDataFile, LoadResourceString(IDS_USER_DATA)));\r
+ } else {\r
+ return m_wantDebug;\r
+ }\r
+ }\r
+\r
+\r
+\r
+ // add crash files to report\r
+ string crashFile = rpt.getCrashFile();\r
+ string crashLog = rpt.getCrashLog();\r
+ m_files.push_back(TStrStrPair(crashFile, LoadResourceString(IDS_CRASH_DUMP)));\r
+ m_files.push_back(TStrStrPair(crashLog, LoadResourceString(IDS_CRASH_LOG)));\r
+\r
+ // Export registry hives and add to report\r
+ std::vector<string> extraFiles;\r
+ string file;\r
+ string number;\r
+ TStrStrVector::iterator iter;\r
+ int n = 0;\r
+\r
+ for (iter = m_registryHives.begin(); iter != m_registryHives.end(); iter++) {\r
+ ++n;\r
+ TCHAR buf[MAX_PATH] = {0};\r
+ _tprintf_s(buf, "%d", n);\r
+ number = buf;\r
+ file = temp + string("\\") + CUtility::getAppName() + "_registry" + number + ".reg";\r
+ ::DeleteFile(file.c_str());\r
+\r
+ // we want to export in a readable format. Unfortunately, RegSaveKey saves in a binary\r
+ // form, so let's use our own function.\r
+ if (WriteRegistryTreeToFile((*iter).first.c_str(), file.c_str())) {\r
+ extraFiles.push_back(file);\r
+ m_files.push_back(TStrStrPair(file, (*iter).second));\r
+ } else {\r
+ OutputDebugString("Could not write registry hive\n");\r
+ }\r
+ }\r
+ //\r
+ // Add the specified event log(s). Note that this will not work on Win9x/WinME.\r
+ //\r
+ for (iter = m_eventLogs.begin(); iter != m_eventLogs.end(); iter++) {\r
+ HANDLE h;\r
+ h = OpenEventLog( NULL, // use local computer\r
+ (*iter).first.c_str()); // source name\r
+ if (h != NULL) {\r
+\r
+ file = temp + string("\\") + CUtility::getAppName() + "_" + (*iter).first + ".evt";\r
+\r
+ DeleteFile(file.c_str());\r
+\r
+ if (BackupEventLog(h, file.c_str())) {\r
+ m_files.push_back(TStrStrPair(file, (*iter).second));\r
+ extraFiles.push_back(file);\r
+ } else {\r
+ OutputDebugString("could not backup log\n");\r
+ }\r
+ CloseEventLog(h);\r
+ } else {\r
+ OutputDebugString("could not open log\n");\r
+ }\r
+ }\r
+ \r
+\r
+ // add symbol files to report\r
+ for (i = 0; i < (UINT)rpt.getNumSymbolFiles(); i++)\r
+ m_files.push_back(TStrStrPair(rpt.getSymbolFile(i).c_str(), \r
+ string("Symbol File")));\r
+ \r
+ //remove the crash handler, just in case the dialog crashes...\r
+ Uninstall();\r
+ if (m_bUseUI)\r
+ {\r
+ // Start a new thread to display the dialog, and then wait\r
+ // until it completes\r
+ m_ipc_event = ::CreateEvent(NULL, FALSE, FALSE, "ACrashHandlerEvent");\r
+ if (m_ipc_event == NULL)\r
+ return m_wantDebug;\r
+ DWORD threadId;\r
+ if (::CreateThread(NULL, 0, DialogThreadExecute,\r
+ reinterpret_cast<LPVOID>(this), 0, &threadId) == NULL)\r
+ return m_wantDebug;\r
+ ::WaitForSingleObject(m_ipc_event, INFINITE);\r
+ CloseHandle(m_ipc_event);\r
+ }\r
+ else\r
+ {\r
+ string sTempFileName = CUtility::getTempFileName();\r
+ CZLib zlib;\r
+\r
+ sTempFileName += _T(".zip");\r
+ // delete existing copy, if any\r
+ DeleteFile(sTempFileName.c_str());\r
+\r
+ // zip the report\r
+ if (!zlib.Open(sTempFileName))\r
+ return TRUE;\r
+\r
+ // add report files to zip\r
+ TStrStrVector::iterator cur = m_files.begin();\r
+ for (cur = m_files.begin(); cur != m_files.end(); cur++)\r
+ if (PathFileExists((*cur).first.c_str()))\r
+ zlib.AddFile((*cur).first);\r
+ zlib.Close();\r
+ fprintf(stderr, "a zipped crash report has been saved to\n");\r
+ _ftprintf(stderr, sTempFileName.c_str());\r
+ fprintf(stderr, "\n");\r
+ if (!m_sTo.empty())\r
+ {\r
+ fprintf(stderr, "please send the report to ");\r
+ _ftprintf(stderr, m_sTo.c_str());\r
+ fprintf(stderr, "\n");\r
+ }\r
+ }\r
+ // clean up - delete files we created\r
+ ::DeleteFile(crashFile.c_str());\r
+ ::DeleteFile(crashLog.c_str());\r
+ if (!m_userDataFile.empty()) {\r
+ ::DeleteFile(m_userDataFile.c_str());\r
+ }\r
+\r
+ std::vector<string>::iterator file_iter;\r
+ for (file_iter = extraFiles.begin(); file_iter != extraFiles.end(); file_iter++) {\r
+ ::DeleteFile(file_iter->c_str());\r
+ }\r
+\r
+ // restore state of file list\r
+ m_files = save_m_files;\r
+\r
+ m_rpt = NULL;\r
+\r
+ return !m_wantDebug;\r
+}\r
+\r
+BOOL CCrashHandler::SaveReport(CExceptionReport&, LPCTSTR lpcszFile)\r
+{\r
+ // let user more zipped report\r
+ return (CopyFile(lpcszFile, CUtility::getSaveFileName().c_str(), TRUE));\r
+}\r
+\r
+BOOL CCrashHandler::MailReport(CExceptionReport&, LPCTSTR lpcszFile,\r
+ LPCTSTR lpcszEmail, LPCTSTR lpcszDesc)\r
+{\r
+ CMailMsg msg;\r
+ msg\r
+ .SetTo(m_sTo)\r
+ .SetFrom(lpcszEmail)\r
+ .SetSubject(m_sSubject.empty()?_T("Incident Report"):m_sSubject)\r
+ .SetMessage(lpcszDesc)\r
+ .AddAttachment(lpcszFile, CUtility::getAppName() + _T(".zip"));\r
+\r
+ return (msg.Send());\r
+}\r
+\r
+string CCrashHandler::LoadResourceString(UINT id)\r
+{\r
+ static int address;\r
+ char buffer[512];\r
+ if (m_hModule == NULL) {\r
+ m_hModule = GetModuleHandle("CrashRpt.dll");\r
+ }\r
+ buffer[0] = '\0';\r
+ if (m_hModule) {\r
+ LoadString(m_hModule, id, buffer, sizeof buffer);\r
+ }\r
+ return buffer;\r
+}\r
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Module: CrashHandler.h\r
+//\r
+// Desc: CCrashHandler is the main class used by crashrpt to manage all\r
+// of the details associated with handling the exception, generating\r
+// the report, gathering client input, and sending the report.\r
+//\r
+// Copyright (c) 2003 Michael Carruth\r
+//\r
+///////////////////////////////////////////////////////////////////////////////\r
+\r
+#pragma once\r
+\r
+#include "crashrpt.h" // defines LPGETLOGFILE callback\r
+#include "excprpt.h" // bulk of crash report generation\r
+\r
+#ifndef TStrStrVector\r
+#include <vector>\r
+\r
+typedef std::pair<string,string> TStrStrPair;\r
+typedef std::vector<TStrStrPair> TStrStrVector;\r
+#endif // !defined TStrStrVector\r
+\r
+\r
+extern BOOL g_bNoCrashHandler;// don't use the crash handler but let the system handle it\r
+\r
+////////////////////////////// Class Definitions /////////////////////////////\r
+\r
+// ===========================================================================\r
+// CCrashHandler\r
+// \r
+// See the module comment at top of file.\r
+//\r
+class CCrashHandler \r
+{\r
+public:\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // GetInstance (static)\r
+ // Returns the instance for the current process. Creates one if necessary.\r
+ //\r
+ // Parameters\r
+ // none\r
+ //\r
+ // Return Values\r
+ // none\r
+ //\r
+ // Remarks\r
+ // none\r
+ //\r
+ static CCrashHandler * GetInstance();\r
+\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // Install\r
+ // Installs the crash handler..\r
+ //\r
+ // Parameters\r
+ // lpfn Client crash callback\r
+ // lpcszTo Email address to send crash report\r
+ // lpczSubject Subject line to be used with email\r
+ //\r
+ // Return Values\r
+ // none\r
+ //\r
+ // Remarks\r
+ // Passing NULL for lpTo will disable the email feature and cause the crash \r
+ // report to be saved to disk.\r
+ //\r
+ void Install(\r
+ LPGETLOGFILE lpfn = NULL, // Client crash callback\r
+ LPCTSTR lpcszTo = NULL, // EMail:To\r
+ LPCTSTR lpcszSubject = NULL, // EMail:Subject\r
+ BOOL bUseUI = TRUE\r
+ );\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // Unnstall\r
+ // Removes the crash handler..\r
+ //\r
+ // Parameters\r
+ // none\r
+ //\r
+ // Return Values\r
+ // none\r
+ //\r
+ // Remarks\r
+ // none\r
+ //\r
+ void Uninstall();\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // EnableUI\r
+ // Enables the UI part\r
+ //\r
+ // Parameters\r
+ // none\r
+ //\r
+ // Return Values\r
+ // none\r
+ //\r
+ // Remarks\r
+ // none\r
+ //\r
+ void EnableUI();\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // DisableUI\r
+ // Disables the UI part\r
+ //\r
+ // Parameters\r
+ // none\r
+ //\r
+ // Return Values\r
+ // none\r
+ //\r
+ // Remarks\r
+ // none\r
+ //\r
+ void DisableUI();\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // DisableUI\r
+ // Disables the exception handler\r
+ //\r
+ // Parameters\r
+ // none\r
+ //\r
+ // Return Values\r
+ // none\r
+ //\r
+ // Remarks\r
+ // none\r
+ //\r
+ void DisableHandler();\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // DisableUI\r
+ // Enables the custom exception handler\r
+ //\r
+ // Parameters\r
+ // none\r
+ //\r
+ // Return Values\r
+ // none\r
+ //\r
+ // Remarks\r
+ // none\r
+ //\r
+ void EnableHandler();\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // ~CCrashHandler\r
+ // Uninitializes the crashrpt library.\r
+ //\r
+ // Parameters\r
+ // none\r
+ //\r
+ // Return Values\r
+ // none\r
+ //\r
+ // Remarks\r
+ // none\r
+ //\r
+ virtual \r
+ ~CCrashHandler();\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // AddFile\r
+ // Adds a file to the crash report.\r
+ //\r
+ // Parameters\r
+ // lpFile Fully qualified file name\r
+ // lpDesc File description\r
+ //\r
+ // Return Values\r
+ // none\r
+ //\r
+ // Remarks\r
+ // Call this function to include application specific file(s) in the crash\r
+ // report. For example, application logs, initialization files, etc.\r
+ //\r
+ void \r
+ AddFile(\r
+ LPCTSTR lpFile, // File nae\r
+ LPCTSTR lpDesc // File description\r
+ );\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // RemoveFile\r
+ // Removes a file from the crash report.\r
+ //\r
+ // Parameters\r
+ // lpFile Fully qualified file name\r
+ //\r
+ // Return Values\r
+ // none\r
+ //\r
+ // Remarks\r
+ // lpFile must exactly match that passed to AddFile.\r
+ //\r
+ void \r
+ RemoveFile(\r
+ LPCTSTR lpFile // File nae\r
+ );\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // AddRegistryHive\r
+ // Adds a registry hive to the crash report.\r
+ //\r
+ // Parameters\r
+ // lpKey Fully registry eky\r
+ // lpDesc Description\r
+ //\r
+ // Return Values\r
+ // none\r
+ //\r
+ // Remarks\r
+ // Call this function to include application specific registry hive(s) in the crash\r
+ // report.\r
+ //\r
+ void \r
+ AddRegistryHive(\r
+ LPCTSTR lpKey, // Registry key\r
+ LPCTSTR lpDesc // description\r
+ );\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // RemoveRegistryHive\r
+ // Removes a registry hive from the crash report.\r
+ //\r
+ // Parameters\r
+ // lpKey Full registry key\r
+ //\r
+ // Return Values\r
+ // none\r
+ //\r
+ // Remarks\r
+ // lpKey must exactly match that passed to AddRegistryHive.\r
+ //\r
+ void \r
+ RemoveRegistryHive(\r
+ LPCTSTR lpKey // Registry key\r
+ );\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // AddEventLog\r
+ // Adds an event log to the crash report.\r
+ //\r
+ // Parameters\r
+ // lpKey Event log name ("Application", "System", "Security")\r
+ // lpDesc Description\r
+ //\r
+ // Return Values\r
+ // none\r
+ //\r
+ // Remarks\r
+ // Call this function to include application specific registry hive(s) in the crash\r
+ // report.\r
+ //\r
+ void \r
+ AddEventLog(\r
+ LPCTSTR lpKey, // Event log name\r
+ LPCTSTR lpDesc // description\r
+ );\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // RemoveEventLog\r
+ // Removes an event log from the crash report.\r
+ //\r
+ // Parameters\r
+ // lpKey Event log name\r
+ //\r
+ // Return Values\r
+ // none\r
+ //\r
+ // Remarks\r
+ // lpKey must exactly match that passed to AddEventLog.\r
+ //\r
+ void \r
+ RemoveEventLog(\r
+ LPCTSTR lpKey // Registry key\r
+ );\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // GenerateErrorReport\r
+ // Produces a crash report.\r
+ //\r
+ // Parameters\r
+ // pExInfo Pointer to an EXCEPTION_POINTERS structure\r
+ //\r
+ // Return Values\r
+ // BOOL TRUE if exception to be executed; FALSE\r
+ // if to search for another handler. This\r
+ // should be used to allow breaking into\r
+ // the debugger, where appropriate.\r
+ //\r
+ // Remarks\r
+ // Call this function to manually generate a crash report.\r
+ //\r
+ BOOL \r
+ GenerateErrorReport(\r
+ PEXCEPTION_POINTERS pExInfo, // Exception pointers (see MSDN)\r
+ BSTR message = NULL\r
+ );\r
+\r
+\r
+protected:\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // CCrashHandler\r
+ // Initializes the library and optionally set the client crash callback and\r
+ // sets up the email details.\r
+ //\r
+ // Parameters\r
+ // none\r
+ //\r
+ // Return Values\r
+ // none\r
+ //\r
+ // Remarks\r
+ // Passing NULL for lpTo will disable the email feature and cause the crash \r
+ // report to be saved to disk.\r
+ //\r
+ CCrashHandler(\r
+ );\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // SaveReport\r
+ // Presents the user with a file save dialog and saves the crash report\r
+ // file to disk. This function is called if an Email:To was not provided\r
+ // in the constructor.\r
+ //\r
+ // Parameters\r
+ // rpt The report details\r
+ // lpcszFile The zipped crash report\r
+ //\r
+ // Return Values\r
+ // True is successful.\r
+ //\r
+ // Remarks\r
+ // none\r
+ //\r
+ BOOL \r
+ SaveReport(\r
+ CExceptionReport &rpt, \r
+ LPCTSTR lpcszFile\r
+ );\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // MailReport\r
+ // Mails the zipped crash report to the address specified.\r
+ //\r
+ // Parameters\r
+ // rpt The report details\r
+ // lpcszFile The zipped crash report\r
+ // lpcszEmail The Email:To\r
+ // lpcszDesc \r
+ //\r
+ // Return Values\r
+ // TRUE is successful.\r
+ //\r
+ // Remarks\r
+ // MAPI is used to send the report.\r
+ //\r
+ BOOL \r
+ MailReport(\r
+ CExceptionReport &rpt, \r
+ LPCTSTR lpcszFile, \r
+ LPCTSTR lpcszEmail, \r
+ LPCTSTR lpcszSubject\r
+ );\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // DialogThreadExecute\r
+ // Displays the dialog and handles the user's reply. Executed as a separate\r
+ // thread.\r
+ //\r
+ // Parameters\r
+ // pParam Standard CreateThreadParameter; set to pointer to CCrashHandler\r
+ //\r
+ // Return Values\r
+ // none\r
+ //\r
+ // Remarks\r
+ // Started from GenerateErrorReport via CreateThread. This ensures the caller\r
+ // is stopped (and will not confuse state by dispatching messages).\r
+ //\r
+ static DWORD WINAPI CCrashHandler::DialogThreadExecute(LPVOID pParam);\r
+\r
+ string LoadResourceString(UINT id);\r
+ LPTOP_LEVEL_EXCEPTION_FILTER m_oldFilter; // previous exception filter\r
+ LPGETLOGFILE m_lpfnCallback; // client crash callback\r
+ int m_pid; // process id\r
+ TStrStrVector m_files; // custom files to add\r
+ TStrStrVector m_registryHives; // custom registry hives to save\r
+ TStrStrVector m_eventLogs; // custom event logs to save\r
+ string m_sTo; // Email:To\r
+ string m_sSubject; // Email:Subject\r
+ HANDLE m_ipc_event; // Event for dialog thread synchronization\r
+ CExceptionReport *m_rpt; // Exception report for dialog\r
+ bool m_installed; // True if already installed\r
+ HMODULE m_hModule; // Module handle for loading resource strings\r
+ string m_userDataFile; // file to save user input when m_sTo is empty\r
+ bool m_wantDebug; // user pushed Debug button\r
+ BOOL m_bUseUI; // use an UI or print to the error output\r
+};\r
+\r
--- /dev/null
+#pragma once\r
+\r
+// Client crash callback\r
+typedef BOOL (CALLBACK *LPGETLOGFILE) (LPVOID lpvState);\r
+// Stack trace callback\r
+typedef void (*TraceCallbackFunction)(DWORD_PTR address, const char *ImageName,\r
+ const char *FunctionName, DWORD functionDisp,\r
+ const char *Filename, DWORD LineNumber, DWORD lineDisp,\r
+ void *data);\r
+\r
+typedef LPVOID (*InstallEx)(LPGETLOGFILE pfn, LPCSTR lpcszTo, LPCSTR lpcszSubject, BOOL bUseUI);\r
+typedef void (*UninstallEx)(LPVOID lpState);\r
+typedef void (*EnableUI)(void);\r
+typedef void (*DisableUI)(void);\r
+typedef void (*EnableHandler)(void);\r
+typedef void (*DisableHandler)(void);\r
+typedef void (*AddFileEx)(LPVOID lpState, LPCSTR lpFile, LPCSTR lpDesc);\r
+typedef void (*AddRegistryEx)(LPVOID lpState, LPCSTR lpRegistry, LPCSTR lpDesc);\r
+typedef void (*AddEventLogEx)(LPVOID lpState, LPCSTR lpEventLog, LPCSTR lpDesc);\r
+\r
+/**\r
+ * \ingroup CrashRpt\r
+ * This class wraps the most important functions the CrashRpt-library\r
+ * offers. To learn more about the CrashRpt-library go to\r
+ * http://www.codeproject.com/debug/crash_report.asp \n\r
+ * To compile the library you need the WTL. You can get the WTL\r
+ * directly from Microsoft: \r
+ * http://www.microsoft.com/downloads/details.aspx?FamilyID=128e26ee-2112-4cf7-b28e-7727d9a1f288&DisplayLang=en \n\r
+ * \n\r
+ * Many changes were made to the library so if you read the\r
+ * article on CodeProject also read the change log in the source\r
+ * folder.\n\r
+ * The most important changes are:\r
+ * - stack trace is included in the report, with symbols/linenumbers if available\r
+ * - "save" button so the user can save the report instead of directly send it\r
+ * - can be used by multiple applications\r
+ * - zlib linked statically, so no need to ship the zlib.dll separately\r
+ * \n\r
+ * To use the library just include the header file "CrashReport.h"\r
+ * \code\r
+ * #include "CrashReport.h"\r
+ * \endcode\r
+ * Then you can either declare an instance of the class CCrashReport\r
+ * somewhere globally in your application like this:\r
+ * \code\r
+ * CCrashReport g_crasher("report@mycompany.com", "Crash report for MyApplication");\r
+ * \endcode\r
+ * that way you can't add registry keys or additional files to the report, but\r
+ * it's the fastest and easiest way to use the library.\r
+ * Another way is to declare a global variable and initialize it in e.g. InitInstance()\r
+ * \code\r
+ * CCrashReport g_crasher;\r
+ * //then somewhere in InitInstance.\r
+ * g_crasher.AddFile("mylogfile.log", "this is a log file");\r
+ * g_crasher.AddRegistry("HKCU\\Software\\MyCompany\\MyProgram");\r
+ * \endcode\r
+ *\r
+ *\r
+ * \remark the dll is dynamically linked at runtime. So the main application\r
+ * will still work even if the dll is not shipped. \r
+ *\r
+ */\r
+class CCrashReport\r
+{\r
+public:\r
+ /**\r
+ * Construct the CrashReport-Object. This loads the dll\r
+ * and initializes it.\r
+ * \param lpTo the mail address the crash report should be sent to\r
+ * \param lpSubject the mail subject\r
+ */\r
+ CCrashReport(LPCSTR lpTo = NULL, LPCSTR lpSubject = NULL, BOOL bUseUI = TRUE)\r
+ {\r
+ InstallEx pfnInstallEx;\r
+ TCHAR szFileName[_MAX_PATH];\r
+ GetModuleFileName(NULL, szFileName, _MAX_FNAME);\r
+\r
+ // C:\Programme\TortoiseSVN\bin\TortoiseProc.exe -> C:\Programme\TortoiseSVN\bin\CrashRpt.dll\r
+ CString strFilename = szFileName;\r
+ strFilename = strFilename.Left(strFilename.ReverseFind(_T('\\')) + 1);\r
+ strFilename += _T("CrashRpt.dll");\r
+\r
+ m_hDll = LoadLibrary(strFilename);\r
+ if (m_hDll)\r
+ {\r
+ pfnInstallEx = (InstallEx)GetProcAddress(m_hDll, "InstallEx");\r
+ if ( pfnInstallEx )\r
+ {\r
+ m_lpvState = pfnInstallEx(NULL, lpTo, lpSubject, bUseUI);\r
+ }\r
+ }\r
+ }\r
+ ~CCrashReport()\r
+ {\r
+ UninstallEx pfnUninstallEx;\r
+ if ((m_hDll)&&(m_lpvState))\r
+ {\r
+ pfnUninstallEx = (UninstallEx)GetProcAddress(m_hDll, "UninstallEx");\r
+ pfnUninstallEx(m_lpvState);\r
+ }\r
+ FreeLibrary(m_hDll);\r
+ }\r
+ /**\r
+ * Adds a file which will be included in the crash report. Use this\r
+ * if your application generates log-files or the like.\r
+ * \param lpFile the full path to the file\r
+ * \param lpDesc a description of the file, used in the crash report dialog\r
+ */\r
+ void AddFile(LPCSTR lpFile, LPCSTR lpDesc)\r
+ {\r
+ AddFileEx pfnAddFileEx;\r
+ if ((m_hDll)&&(m_lpvState))\r
+ {\r
+ pfnAddFileEx = (AddFileEx)GetProcAddress(m_hDll, "AddFileEx");\r
+ (pfnAddFileEx)(m_lpvState, lpFile, lpDesc);\r
+ }\r
+ }\r
+ /**\r
+ * Adds a whole registry tree to the crash report. \r
+ * \param lpFile the full registry path, e.g. "HKLM\\Software\\MyApplication"\r
+ * \param lpDesc a description of the generated registry file, used in the crash report dialog\r
+ */\r
+ void AddRegistry(LPCSTR lpFile, LPCSTR lpDesc)\r
+ {\r
+ AddRegistryEx pfnAddRegistryEx;\r
+ if ((m_hDll)&&(m_lpvState))\r
+ {\r
+ pfnAddRegistryEx = (AddRegistryEx)GetProcAddress(m_hDll, "AddRegistryHiveEx");\r
+ (pfnAddRegistryEx)(m_lpvState, lpFile, lpDesc);\r
+ }\r
+ }\r
+ /**\r
+ * Adds a system Event Log to the crash report.\r
+ * \param lpFile \r
+ * \param lpDesc \r
+ */\r
+ void AddEventLog(LPCSTR lpFile, LPCSTR lpDesc)\r
+ {\r
+ AddEventLogEx pfnAddEventLogEx;\r
+ if ((m_hDll)&&(m_lpvState))\r
+ {\r
+ pfnAddEventLogEx = (AddEventLogEx)GetProcAddress(m_hDll, "AddEventLogEx");\r
+ (pfnAddEventLogEx)(m_lpvState, lpFile, lpDesc);\r
+ }\r
+ }\r
+\r
+\r
+ void Enable(BOOL bEnable)\r
+ {\r
+ EnableHandler pfnEnableHandler;\r
+ DisableHandler pfnDisableHandler;\r
+ if ((m_hDll)&&(m_lpvState))\r
+ {\r
+ if (bEnable)\r
+ {\r
+ pfnEnableHandler = (EnableHandler)GetProcAddress(m_hDll, "EnableHandlerEx");\r
+ (pfnEnableHandler)();\r
+ }\r
+ else\r
+ {\r
+ OutputDebugString(_T("Calling DisableHandlerEx\n"));\r
+\r
+ pfnDisableHandler = (DisableHandler)GetProcAddress(m_hDll, "DisableHandlerEx");\r
+ (pfnDisableHandler)();\r
+ }\r
+ }\r
+ }\r
+\r
+private:\r
+ HMODULE m_hDll;\r
+ LPVOID m_lpvState;\r
+};
\ No newline at end of file
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Module: CrashRpt.cpp\r
+//\r
+// Desc: See CrashRpt.h\r
+//\r
+// Copyright (c) 2003 Michael Carruth\r
+//\r
+///////////////////////////////////////////////////////////////////////////////\r
+\r
+#include "stdafx.h"\r
+#include "CrashRpt.h"\r
+#include "CrashHandler.h"\r
+\r
+#include "StackTrace.h"\r
+\r
+#ifdef _DEBUG\r
+#define CRASH_ASSERT(pObj) \\r
+ if (!pObj || sizeof(*pObj) != sizeof(CCrashHandler)) \\r
+ DebugBreak() \r
+#else\r
+#define CRASH_ASSERT(pObj)\r
+#endif // _DEBUG\r
+\r
+// New interfaces\r
+CRASHRPTAPI LPVOID GetInstance()\r
+{\r
+ CCrashHandler *pImpl = CCrashHandler::GetInstance();\r
+ CRASH_ASSERT(pImpl);\r
+ return pImpl;\r
+}\r
+\r
+CRASHRPTAPI LPVOID InstallEx(LPGETLOGFILE pfn, LPCTSTR lpcszTo, LPCTSTR lpcszSubject, BOOL bUseUI)\r
+{\r
+#ifdef _DEBUG\r
+ OutputDebugString("InstallEx\n");\r
+#endif\r
+ CCrashHandler *pImpl = CCrashHandler::GetInstance();\r
+ CRASH_ASSERT(pImpl);\r
+ pImpl->Install(pfn, lpcszTo, lpcszSubject, bUseUI);\r
+\r
+ return pImpl;\r
+}\r
+\r
+CRASHRPTAPI void UninstallEx(LPVOID lpState)\r
+{\r
+ CCrashHandler *pImpl = (CCrashHandler*)lpState;\r
+ CRASH_ASSERT(pImpl);\r
+\r
+ delete pImpl;\r
+}\r
+\r
+CRASHRPTAPI void EnableUIEx(LPVOID lpState)\r
+{\r
+ CCrashHandler *pImpl = (CCrashHandler*)lpState;\r
+ CRASH_ASSERT(pImpl);\r
+ pImpl->EnableUI();\r
+}\r
+\r
+CRASHRPTAPI void DisableUIEx(LPVOID lpState)\r
+{\r
+ CCrashHandler *pImpl = (CCrashHandler*)lpState;\r
+ CRASH_ASSERT(pImpl);\r
+ pImpl->DisableUI();\r
+}\r
+\r
+CRASHRPTAPI void EnableHandlerEx(LPVOID lpState)\r
+{\r
+ CCrashHandler *pImpl = (CCrashHandler*)lpState;\r
+ CRASH_ASSERT(pImpl);\r
+ pImpl->EnableHandler();\r
+}\r
+\r
+CRASHRPTAPI void DisableHandlerEx(LPVOID lpState)\r
+{\r
+ CCrashHandler *pImpl = (CCrashHandler*)lpState;\r
+ CRASH_ASSERT(pImpl);\r
+ pImpl->DisableHandler();\r
+}\r
+\r
+CRASHRPTAPI void AddFileEx(LPVOID lpState, LPCTSTR lpFile, LPCTSTR lpDesc)\r
+{\r
+ CCrashHandler *pImpl = (CCrashHandler*)lpState;\r
+ CRASH_ASSERT(pImpl);\r
+\r
+ pImpl->AddFile(lpFile, lpDesc);\r
+}\r
+\r
+CRASHRPTAPI void RemoveFileEx(LPVOID lpState, LPCTSTR lpFile)\r
+{\r
+ CCrashHandler *pImpl = (CCrashHandler*)lpState;\r
+ CRASH_ASSERT(pImpl);\r
+\r
+ pImpl->RemoveFile(lpFile);\r
+}\r
+\r
+CRASHRPTAPI void AddRegistryHiveEx(LPVOID lpState, LPCTSTR lpHive, LPCTSTR lpDesc)\r
+{\r
+ CCrashHandler *pImpl = (CCrashHandler*)lpState;\r
+ CRASH_ASSERT(pImpl);\r
+\r
+ pImpl->AddRegistryHive(lpHive, lpDesc);\r
+}\r
+\r
+CRASHRPTAPI void RemoveRegistryHiveEx(LPVOID lpState, LPCTSTR lpFile)\r
+{\r
+ CCrashHandler *pImpl = (CCrashHandler*)lpState;\r
+ CRASH_ASSERT(pImpl);\r
+\r
+ pImpl->RemoveRegistryHive(lpFile);\r
+}\r
+\r
+\r
+CRASHRPTAPI void AddEventLogEx(LPVOID lpState, LPCTSTR lpHive, LPCTSTR lpDesc)\r
+{\r
+ CCrashHandler *pImpl = (CCrashHandler*)lpState;\r
+ CRASH_ASSERT(pImpl);\r
+\r
+ pImpl->AddEventLog(lpHive, lpDesc);\r
+}\r
+\r
+CRASHRPTAPI void RemoveEventLogEx(LPVOID lpState, LPCTSTR lpFile)\r
+{\r
+ CCrashHandler *pImpl = (CCrashHandler*)lpState;\r
+ CRASH_ASSERT(pImpl);\r
+\r
+ pImpl->RemoveEventLog(lpFile);\r
+}\r
+\r
+CRASHRPTAPI void GenerateErrorReportEx(LPVOID lpState, PEXCEPTION_POINTERS pExInfo, BSTR message)\r
+{\r
+ CCrashHandler *pImpl = (CCrashHandler*)lpState;\r
+ CRASH_ASSERT(pImpl);\r
+\r
+ if (!pImpl->GenerateErrorReport(pExInfo, message)) {\r
+ DebugBreak();\r
+ }\r
+}\r
+\r
+CRASHRPTAPI void StackTrace ( int numSkip, int depth, TraceCallbackFunction pFunction, CONTEXT *pContext, void *data)\r
+{\r
+ DoStackTrace(numSkip, depth > 0 ? depth : 9999, pFunction, pContext, data);\r
+}\r
+\r
+// DLL Entry Points usable from Visual Basic\r
+// explicit export is required to export undecorated names.\r
+extern "C" LPVOID __stdcall InstallExVB(LPGETLOGFILE pfn, LPCTSTR lpcszTo, LPCTSTR lpcszSubject, BOOL bUseUI)\r
+{\r
+ return InstallEx(pfn, lpcszTo, lpcszSubject, bUseUI);\r
+}\r
+\r
+extern "C" void __stdcall UninstallExVB(LPVOID lpState)\r
+{\r
+ UninstallEx(lpState);\r
+}\r
+\r
+extern "C" void __stdcall EnableUIVB(void)\r
+{\r
+ EnableUI();\r
+}\r
+\r
+extern "C" void __stdcall DisableUIVB()\r
+{\r
+ DisableUI();\r
+}\r
+\r
+extern "C" void __stdcall AddFileExVB(LPVOID lpState, LPCTSTR lpFile, LPCTSTR lpDesc)\r
+{\r
+ AddFileEx(lpState, lpFile, lpDesc);\r
+}\r
+\r
+extern "C" void __stdcall RemoveFileExVB(LPVOID lpState, LPCTSTR lpFile)\r
+{\r
+ RemoveFileEx(lpState, lpFile);\r
+}\r
+\r
+extern "C" void __stdcall AddRegistryHiveExVB(LPVOID lpState, LPCTSTR lpRegistryHive, LPCTSTR lpDesc)\r
+{\r
+ AddRegistryHiveEx(lpState, lpRegistryHive, lpDesc);\r
+}\r
+\r
+extern "C" void __stdcall RemoveRegistryHiveExVB(LPVOID lpState, LPCTSTR lpRegistryHive)\r
+{\r
+ RemoveRegistryHiveEx(lpState, lpRegistryHive);\r
+}\r
+\r
+extern "C" void __stdcall GenerateErrorReportExVB(LPVOID lpState, PEXCEPTION_POINTERS pExInfo, BSTR message)\r
+{\r
+ GenerateErrorReportEx(lpState, pExInfo, message);\r
+}\r
+\r
+extern "C" void __stdcall StackTraceVB(int numSkip, int depth, TraceCallbackFunction pFunction, CONTEXT *pContext, void *data)\r
+{\r
+ StackTrace(numSkip, depth, pFunction, pContext, data);\r
+}\r
+\r
+// Compatibility interfaces\r
+CRASHRPTAPI void Install(LPGETLOGFILE pfn, LPCTSTR lpcszTo, LPCTSTR lpcszSubject, BOOL bUseUI)\r
+{\r
+ (void) InstallEx(pfn, lpcszTo, lpcszSubject, bUseUI);\r
+}\r
+\r
+CRASHRPTAPI void Uninstall()\r
+{\r
+ UninstallEx(CCrashHandler::GetInstance());\r
+}\r
+\r
+CRASHRPTAPI void EnableUI()\r
+{\r
+ EnableUIEx(CCrashHandler::GetInstance());\r
+}\r
+\r
+CRASHRPTAPI void DisableUI()\r
+{\r
+ DisableUIEx(CCrashHandler::GetInstance());\r
+}\r
+\r
+CRASHRPTAPI void AddFile(LPCTSTR lpFile, LPCTSTR lpDesc)\r
+{\r
+ AddFileEx(CCrashHandler::GetInstance(), lpFile, lpDesc);\r
+}\r
+\r
+CRASHRPTAPI void RemoveFile(LPCTSTR lpFile)\r
+{\r
+ RemoveFileEx(CCrashHandler::GetInstance(), lpFile);\r
+}\r
+\r
+CRASHRPTAPI void AddRegistryHive(LPCTSTR lpRegistryHive, LPCTSTR lpDesc)\r
+{\r
+ AddRegistryHiveEx(CCrashHandler::GetInstance(), lpRegistryHive, lpDesc);\r
+}\r
+\r
+CRASHRPTAPI void RemoveRegistryHive(LPCTSTR lpRegistryHive)\r
+{\r
+ RemoveRegistryHiveEx(CCrashHandler::GetInstance(), lpRegistryHive);\r
+}\r
+CRASHRPTAPI void AddEventLog(LPCTSTR lpEventLog, LPCTSTR lpDesc)\r
+{\r
+ AddEventLogEx(CCrashHandler::GetInstance(), lpEventLog, lpDesc);\r
+}\r
+\r
+CRASHRPTAPI void RemoveEventLog(LPCTSTR lpEventLog)\r
+{\r
+ RemoveEventLogEx(CCrashHandler::GetInstance(), lpEventLog);\r
+}\r
+\r
+CRASHRPTAPI void GenerateErrorReport(BSTR message)\r
+{\r
+ GenerateErrorReportEx(CCrashHandler::GetInstance(), NULL, message);\r
+}\r
+\r
+extern "C" void __stdcall InstallVB(LPGETLOGFILE pfn, LPCTSTR lpTo, LPCTSTR lpSubject, BOOL bUseUI)\r
+{\r
+ Install(pfn, lpTo, lpSubject, bUseUI);\r
+}\r
+\r
+extern "C" void __stdcall UninstallVB()\r
+{\r
+ Uninstall();\r
+}\r
+\r
+extern "C" void __stdcall AddFileVB(LPCTSTR lpFile, LPCTSTR lpDesc)\r
+{\r
+ AddFile(lpFile, lpDesc);\r
+}\r
+\r
+extern "C" void __stdcall RemoveFileVB(LPCTSTR lpFile)\r
+{\r
+ RemoveFile(lpFile);\r
+}\r
+\r
+extern "C" void __stdcall AddRegistryHiveVB(LPCTSTR lpRegistryHive, LPCTSTR lpDesc)\r
+{\r
+ AddRegistryHive(lpRegistryHive, lpDesc);\r
+}\r
+\r
+extern "C" void __stdcall RemoveRegistryHiveVB(LPCTSTR lpRegistryHive)\r
+{\r
+ RemoveRegistryHive(lpRegistryHive);\r
+}\r
+\r
+extern "C" void __stdcall AddEventLogVB(LPCTSTR lpEventLog, LPCTSTR lpDesc)\r
+{\r
+ AddEventLog(lpEventLog, lpDesc);\r
+}\r
+\r
+extern "C" void __stdcall RemoveEventLogVB(LPCTSTR lpEventLog)\r
+{\r
+ RemoveEventLog(lpEventLog);\r
+}\r
+\r
+extern "C" void __stdcall GenerateErrorReportVB(BSTR message)\r
+{\r
+ GenerateErrorReport(message);\r
+}\r
+\r
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Module: CrashRpt.h\r
+//\r
+// Desc: Defines the interface for the CrashRpt.DLL.\r
+//\r
+// Copyright (c) 2003 Michael Carruth\r
+//\r
+///////////////////////////////////////////////////////////////////////////////\r
+\r
+#ifndef _CRASHRPT_H_\r
+#define _CRASHRPT_H_\r
+\r
+#if _MSC_VER >= 1000\r
+#pragma once\r
+#endif // _MSC_VER >= 1000\r
+\r
+#include <windows.h>\r
+#include <wtypes.h> // BSTR\r
+\r
+// CrashRpt.h\r
+#ifdef CRASHRPTAPI\r
+\r
+// CRASHRPTAPI should be defined in all of the DLL's source files as\r
+// #define CRASHRPTAPI extern "C" __declspec(dllexport)\r
+\r
+#else\r
+\r
+// This header file is included by an EXE - export\r
+#define CRASHRPTAPI extern "C" __declspec(dllimport)\r
+\r
+#endif\r
+\r
+// Client crash callback\r
+typedef BOOL (CALLBACK *LPGETLOGFILE) (LPVOID lpvState);\r
+// Stack trace callback\r
+typedef void (*TraceCallbackFunction)(DWORD_PTR address, const char *ImageName,\r
+ const char *FunctionName, DWORD_PTR functionDisp,\r
+ const char *Filename, DWORD LineNumber, DWORD lineDisp,\r
+ void *data);\r
+\r
+\r
+//-----------------------------------------------------------------------------\r
+// GetInstance\r
+// Returns the instance (state information) for the current process. Will create\r
+// one if required; does not install.\r
+//\r
+// Parameters\r
+// none\r
+//\r
+// Return Values\r
+// If the function succeeds, the return value is a pointer to the underlying\r
+// crash object created. This state information is required as the first\r
+// parameter to all other crash report functions.\r
+//\r
+// Remarks\r
+// none\r
+//\r
+CRASHRPTAPI \r
+LPVOID \r
+GetInstance();\r
+\r
+//-----------------------------------------------------------------------------\r
+// Install, InstallEx\r
+// Initializes the library and optionally set the client crash callback and\r
+// sets up the email details.\r
+//\r
+// Parameters\r
+// pfn Client crash callback\r
+// lpTo Email address to send crash report\r
+// lpSubject Subject line to be used with email\r
+//\r
+// Return Values\r
+// InstallEx:\r
+// If the function succeeds, the return value is a pointer to the underlying\r
+// crash object created. This state information is required as the first\r
+// parameter to all other crash report functions.\r
+// Install:\r
+// void\r
+//\r
+// Remarks\r
+// Passing NULL for lpTo will disable the email feature and cause the crash \r
+// report to be saved to disk.\r
+//\r
+CRASHRPTAPI\r
+void\r
+Install(\r
+ IN LPGETLOGFILE pfn OPTIONAL, // client crash callback\r
+ IN LPCSTR lpTo OPTIONAL, // Email:to\r
+ IN LPCSTR lpSubject OPTIONAL, // Email:subject\r
+ IN BOOL bUseUI OPTIONAL // UI or console\r
+ );\r
+CRASHRPTAPI \r
+LPVOID \r
+InstallEx(\r
+ IN LPGETLOGFILE pfn OPTIONAL, // client crash callback\r
+ IN LPCSTR lpTo OPTIONAL, // Email:to\r
+ IN LPCSTR lpSubject OPTIONAL, // Email:subject\r
+ IN BOOL bUseUI OPTIONAL // UI or console\r
+ );\r
+\r
+//-----------------------------------------------------------------------------\r
+// Uninstall, UninstallEx\r
+// Uninstalls the unhandled exception filter set up in Install().\r
+//\r
+// Parameters\r
+// lpState State information returned from Install()\r
+//\r
+// Return Values\r
+// void\r
+//\r
+// Remarks\r
+// This call is optional. The crash report library will automatically \r
+// deinitialize when the library is unloaded. Call this function to\r
+// unhook the exception filter manually.\r
+//\r
+CRASHRPTAPI void Uninstall();\r
+CRASHRPTAPI \r
+void \r
+UninstallEx(\r
+ IN LPVOID lpState // State from Install()\r
+ );\r
+\r
+CRASHRPTAPI void EnableUI();\r
+CRASHRPTAPI void DisableUI();\r
+//-----------------------------------------------------------------------------\r
+// AddFile, AddFileEx\r
+// Adds a file to the crash report.\r
+//\r
+// Parameters\r
+// lpState State information returned from Install()\r
+// lpFile Fully qualified file name\r
+// lpDesc Description of file, used by details dialog\r
+//\r
+// Return Values\r
+// void\r
+//\r
+// Remarks\r
+// This function can be called anytime after Install() to add one or more\r
+// files to the generated crash report. If lpFile and lpDesc exactly match\r
+// a previously added pair, it is not added again.\r
+//\r
+CRASHRPTAPI\r
+void\r
+AddFile(\r
+ IN LPCSTR lpFile, // File name\r
+ IN LPCSTR lpDesc // File desc\r
+ );\r
+CRASHRPTAPI \r
+void \r
+AddFileEx(\r
+ IN LPVOID lpState, // State from Install()\r
+ IN LPCSTR lpFile, // File name\r
+ IN LPCSTR lpDesc // File desc\r
+ );\r
+\r
+//-----------------------------------------------------------------------------\r
+// RemoveFile\r
+// Removes a file from the crash report.\r
+//\r
+// Parameters\r
+// lpState State information returned from Install()\r
+// lpFile Fully qualified file name\r
+//\r
+// Return Values\r
+// void\r
+//\r
+// Remarks\r
+// The filename must exactly match that provided to AddFile.\r
+//\r
+CRASHRPTAPI\r
+void\r
+RemoveFile(\r
+ IN LPCSTR lpFile // File name\r
+ );\r
+CRASHRPTAPI \r
+void \r
+RemoveFileEx(\r
+ IN LPVOID lpState, // State from Install()\r
+ IN LPCSTR lpFile // File name\r
+ );\r
+\r
+//-----------------------------------------------------------------------------\r
+// AddRegistryHive\r
+// Adds a RegistryHive to the crash report.\r
+//\r
+// Parameters\r
+// lpState State information returned from Install()\r
+// lpRegistryHive Fully qualified RegistryHive name\r
+// lpDesc Description of RegistryHive, used by details dialog\r
+//\r
+// Return Values\r
+// void\r
+//\r
+// Remarks\r
+// This function can be called anytime after Install() to add one or more\r
+// RegistryHives to the generated crash report. If lpRegistryHive and lpDesc exactly match\r
+// a previously added pair, it is not added again.\r
+//\r
+CRASHRPTAPI\r
+void\r
+AddRegistryHive(\r
+ IN LPCSTR lpRegistryHive, // RegistryHive name\r
+ IN LPCSTR lpDesc // RegistryHive desc\r
+ );\r
+CRASHRPTAPI \r
+void \r
+AddRegistryHiveEx(\r
+ IN LPVOID lpState, // State from Install()\r
+ IN LPCSTR lpRegistryHive, // RegistryHive name\r
+ IN LPCSTR lpDesc // RegistryHive desc\r
+ );\r
+\r
+//-----------------------------------------------------------------------------\r
+// RemoveRegistryHive\r
+// Removes a RegistryHive from the crash report.\r
+//\r
+// Parameters\r
+// lpState State information returned from Install()\r
+// lpRegistryHive Fully qualified RegistryHive name\r
+//\r
+// Return Values\r
+// void\r
+//\r
+// Remarks\r
+// The RegistryHive name must exactly match that provided to AddRegistryHive.\r
+//\r
+CRASHRPTAPI\r
+void \r
+RemoveRegistryHive(\r
+ IN LPCSTR lpRegistryHive // RegistryHive name\r
+ );\r
+CRASHRPTAPI \r
+void \r
+RemoveRegistryHiveEx(\r
+ IN LPVOID lpState, // State from Install()\r
+ IN LPCSTR lpRegistryHive // RegistryHive name\r
+ );\r
+\r
+//-----------------------------------------------------------------------------\r
+// AddEventLog\r
+// Adds an event log to the crash report.\r
+//\r
+// Parameters\r
+// lpState State information returned from Install()\r
+// lpEventLog Event log name ("Application", "Security", "System" or any other known to your system)\r
+// lpDesc Description of event log, used by details dialog\r
+//\r
+// Return Values\r
+// void\r
+//\r
+// Remarks\r
+// This function can be called anytime after Install() to add one or more\r
+// event logs to the generated crash report. If lpEventLog and lpDesc exactly match\r
+// a previously added pair, it is not added again.\r
+//\r
+CRASHRPTAPI\r
+void\r
+AddEventLog(\r
+ IN LPCSTR lpEventLog, // Event Log name\r
+ IN LPCSTR lpDesc // Event Log desc\r
+ );\r
+CRASHRPTAPI \r
+void \r
+AddEventLogEx(\r
+ IN LPVOID lpState, // State from Install()\r
+ IN LPCSTR lpEventLog, // Event Log name\r
+ IN LPCSTR lpDesc // Event Log desc\r
+ );\r
+\r
+//-----------------------------------------------------------------------------\r
+// RemoveEventLog\r
+// Removes a EventLog from the crash report.\r
+//\r
+// Parameters\r
+// lpState State information returned from Install()\r
+// lpEventLog Fully qualified EventLog name\r
+//\r
+// Return Values\r
+// void\r
+//\r
+// Remarks\r
+// The EventLog name must exactly match that provided to AddEventLog.\r
+//\r
+CRASHRPTAPI\r
+void \r
+RemoveEventLog(\r
+ IN LPCSTR lpEventLog // EventLog name\r
+ );\r
+CRASHRPTAPI \r
+void \r
+RemoveEventLogEx(\r
+ IN LPVOID lpState, // State from Install()\r
+ IN LPCSTR lpEventLog // EventLog name\r
+ );\r
+\r
+//-----------------------------------------------------------------------------\r
+// GenerateErrorReport, GenerateErrorReportEx\r
+// Generates the crash report.\r
+//\r
+// Parameters\r
+// lpState State information returned from Install()\r
+// pExInfo Optional; pointer to an EXCEPTION_POINTERS structure\r
+// message Optional; message to include in report\r
+//\r
+// Return Values\r
+// void\r
+//\r
+// Remarks\r
+// Call this function to manually generate a crash report.\r
+// Note that only GenerateErrorReportEx can be supplied exception information.\r
+// If you are using the basic interfaces and wish to supply exception information,\r
+// use the call GenerateErrorReportEx, supplying GetInstance() for the state\r
+// information.\r
+//\r
+CRASHRPTAPI\r
+void\r
+GenerateErrorReport(\r
+ IN BSTR message OPTIONAL\r
+ );\r
+CRASHRPTAPI \r
+void \r
+GenerateErrorReportEx(\r
+ IN LPVOID lpState,\r
+ IN PEXCEPTION_POINTERS pExInfo OPTIONAL,\r
+ IN BSTR message OPTIONAL\r
+ );\r
+\r
+//-----------------------------------------------------------------------------\r
+// StackTrace\r
+// Creates a stack trace.\r
+//\r
+// Parameters\r
+// numSkip Number of initial stack frames to skip\r
+// depth Number of stack frames to process\r
+// pFunction Optional; function to call for each frame\r
+// pContext Optional; stack context to trace\r
+//\r
+// Return Values\r
+// void\r
+//\r
+// Remarks\r
+// Call this function to manually generate a stack trace. If\r
+// pFunction is not supplied, stack trace frames are output using\r
+// OutputDebugString. Note that this function does not require the\r
+// 'lpState'; it can be called even if the crash handler is not\r
+// installed.\r
+//\r
+CRASHRPTAPI\r
+void\r
+StackTrace(\r
+ IN int numSkip,\r
+ IN int depth OPTIONAL,\r
+ IN TraceCallbackFunction pFunction OPTIONAL,\r
+ IN CONTEXT * pContext OPTIONAL,\r
+ IN LPVOID data OPTIONAL\r
+ );\r
+\r
+\r
+//-----------------------------------------------------------------------------\r
+// The following functions are identical to the above save that they are callable from Visual Basic\r
+extern "C"\r
+LPVOID\r
+__stdcall\r
+InstallExVB(\r
+ IN LPGETLOGFILE pfn OPTIONAL, // client crash callback\r
+ IN LPCSTR lpTo OPTIONAL, // Email:to\r
+ IN LPCSTR lpSubject OPTIONAL, // Email:subject\r
+ IN BOOL bUseUI OPTIONAL // UI or console\r
+ );\r
+\r
+\r
+extern "C"\r
+void\r
+__stdcall\r
+UninstallExVB(\r
+ IN LPVOID lpState // State from InstallVB()\r
+ );\r
+\r
+\r
+extern "C"\r
+void\r
+__stdcall\r
+EnableUIVB();\r
+\r
+extern "C"\r
+void\r
+__stdcall\r
+DisableUIVB();\r
+\r
+extern "C"\r
+void\r
+__stdcall\r
+AddFileExVB(\r
+ IN LPVOID lpState, // State from InstallVB()\r
+ IN LPCSTR lpFile, // File name\r
+ IN LPCSTR lpDesc // File desc\r
+ );\r
+\r
+extern "C"\r
+void\r
+__stdcall\r
+RemoveFileExVB(\r
+ IN LPVOID lpState, // State from InstallVB()\r
+ IN LPCSTR lpFile // File name\r
+ );\r
+\r
+extern "C"\r
+void\r
+__stdcall\r
+AddRegistryHiveExVB(\r
+ IN LPVOID lpState, // State from InstallVB()\r
+ IN LPCSTR lpRegistryHive, // RegistryHive name\r
+ IN LPCSTR lpDesc // RegistryHive desc\r
+ );\r
+\r
+extern "C"\r
+void\r
+__stdcall\r
+RemoveRegistryHiveExVB(\r
+ IN LPVOID lpState, // State from InstallVB()\r
+ IN LPCSTR lpRegistryHive // RegistryHive name\r
+ );\r
+\r
+extern "C"\r
+void\r
+__stdcall\r
+GenerateErrorReportExVB(\r
+ IN LPVOID lpState,\r
+ IN PEXCEPTION_POINTERS pExInfo OPTIONAL,\r
+ IN BSTR message OPTIONAL\r
+ );\r
+\r
+extern "C"\r
+void\r
+__stdcall\r
+StackTraceVB(\r
+ IN int numSkip,\r
+ IN int depth OPTIONAL,\r
+ IN TraceCallbackFunction pFunction OPTIONAL,\r
+ IN CONTEXT * pContext OPTIONAL,\r
+ IN LPVOID data OPTIONAL\r
+ );\r
+\r
+extern "C" void __stdcall InstallVB(IN LPGETLOGFILE pfn OPTIONAL, IN LPCSTR lpTo OPTIONAL, IN LPCSTR lpSubject OPTIONAL, IN BOOL bUseUI OPTIONAL);\r
+extern "C" void __stdcall UninstallVB();\r
+extern "C" void __stdcall AddFileVB(LPCSTR file, LPCSTR desc);\r
+extern "C" void __stdcall RemoveFileVB(LPCSTR file);\r
+extern "C" void __stdcall AddRegistryHiveVB(LPCSTR RegistryHive, LPCSTR desc);\r
+extern "C" void __stdcall RemoveRegistryHiveVB(LPCSTR RegistryHive);\r
+extern "C" void __stdcall GenerateErrorReportVB(BSTR message);\r
+\r
+#endif\r
--- /dev/null
+// Microsoft Visual C++ generated resource script.\r
+//\r
+#include "resource.h"\r
+\r
+#define APSTUDIO_READONLY_SYMBOLS\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Generated from the TEXTINCLUDE 2 resource.\r
+//\r
+#define APSTUDIO_HIDDEN_SYMBOLS\r
+#include "windows.h"\r
+#undef APSTUDIO_HIDDEN_SYMBOLS\r
+#ifndef APSTUDIO_INVOKED\r
+\r
+#endif\r
+/////////////////////////////////////////////////////////////////////////////\r
+#undef APSTUDIO_READONLY_SYMBOLS\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+// Neutral resources\r
+\r
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)\r
+#ifdef _WIN32\r
+LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL\r
+#pragma code_page(1252)\r
+#endif //_WIN32\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Icon\r
+//\r
+\r
+// Icon with lowest ID value placed first to ensure application icon\r
+// remains consistent on all systems.\r
+IDR_MAINFRAME ICON "res\\CrashRpt.ico"\r
+#endif // Neutral resources\r
+/////////////////////////////////////////////////////////////////////////////\r
+\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+// German (Germany) resources\r
+\r
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)\r
+#ifdef _WIN32\r
+LANGUAGE LANG_GERMAN, SUBLANG_GERMAN\r
+#pragma code_page(1252)\r
+#endif //_WIN32\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Dialog\r
+//\r
+\r
+IDD_MAINDLG DIALOGEX 0, 0, 270, 219\r
+STYLE DS_SETFONT | WS_POPUP | WS_CAPTION | WS_SYSMENU\r
+FONT 8, "MS Sans Serif", 0, 0, 0x0\r
+BEGIN\r
+ EDITTEXT IDC_EMAIL,20,94,230,14,ES_AUTOHSCROLL\r
+ EDITTEXT IDC_DESCRIPTION,20,127,230,58,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL\r
+ PUSHBUTTON "&Senden",IDOK,152,200,50,14,NOT WS_VISIBLE\r
+ PUSHBUTTON "&Beenden",IDCANCEL,205,200,50,14\r
+ LTEXT "Das Programm hat einen schweren Fehler verursacht. Ihre nicht gespeicherten Daten sind wahrscheinlich verloren.",IDC_STATIC,20,4,230,20\r
+ LTEXT "Wir haben einen Fehlerreport erstellt welchen Sie uns zuschicken können. Wir werden diesen Report vertraulich und anonym behandeln.",IDC_STATIC,20,28,230,20\r
+ LTEXT "Um uns zu helfen diesen Fehler zu beheben und die Software zu verbessern geben Sie bitte Ihre Email-Adresse ein und beschreiben Sie kurz was Sie gerade taten als dieser Fehler auftrat.",IDC_STATIC,20,52,230,29\r
+ LTEXT "Ihre EMail-Addresse (optional):",IDC_STATIC,20,82,230,8\r
+ LTEXT "Beschreiben Sie was Sie taten als der Fehler auftrat (optional):",IDC_STATIC,20,116,230,8\r
+ CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,0,194,272,1\r
+ PUSHBUTTON "S&peichern",IDC_SAVE,99,200,50,14\r
+END\r
+\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// DESIGNINFO\r
+//\r
+\r
+#ifdef APSTUDIO_INVOKED\r
+GUIDELINES DESIGNINFO \r
+BEGIN\r
+ IDD_MAINDLG, DIALOG\r
+ BEGIN\r
+ VERTGUIDE, 15\r
+ VERTGUIDE, 20\r
+ VERTGUIDE, 250\r
+ VERTGUIDE, 255\r
+ BOTTOMMARGIN, 213\r
+ HORZGUIDE, 4\r
+ HORZGUIDE, 195\r
+ HORZGUIDE, 200\r
+ END\r
+END\r
+#endif // APSTUDIO_INVOKED\r
+\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// String Table\r
+//\r
+\r
+STRINGTABLE \r
+BEGIN\r
+ IDR_MAINFRAME "CrashRpt"\r
+END\r
+\r
+STRINGTABLE \r
+BEGIN\r
+ IDS_HEADER "{\\bnsi\\bnsicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fswiss\\fcharset0 Microsoft Sans Serif;}}\n{\\*\\generator Msftedit 5.41.15.1503;}\\viewkind4\\uc1\\pard\\b\\f0\\fs17 %s hat ein Problem festgestellt und wird beendet. Wir entschuldigen uns für Unannehmlichkeiten.\\b0}\n "\r
+ IDS_INVALID_EMAIL "Please enter a valid email address"\r
+ IDS_ZIP_FILTER "Zip Dateien (*.zip)"\r
+ IDS_HTTP_HEADER_CONTENT_TYPE \r
+ "Content-Type: Multipart/form-data; boundary=%s"\r
+ IDS_HTTP_HEADER_BOUNDARY "-----------------7d31389b0426"\r
+END\r
+\r
+STRINGTABLE \r
+BEGIN\r
+ IDS_ABOUTBOX "Über..."\r
+END\r
+\r
+STRINGTABLE \r
+BEGIN\r
+ IDS_FORM_DATA "module=%s&exception=%s&address=%s"\r
+END\r
+\r
+STRINGTABLE \r
+BEGIN\r
+ IDS_CONTENT_TYPE "Content-Type: Multipart/form-data; boundary=""crash-report-boundary"""\r
+END\r
+\r
+STRINGTABLE \r
+BEGIN\r
+ IDS_NAME "Name"\r
+ IDS_DESC "Beschreibung"\r
+ IDS_TYPE "Typ"\r
+ IDS_SIZE "Grösse"\r
+ IDS_CRASH_DUMP "Crash Dump"\r
+ IDS_CRASH_LOG "Crash Log"\r
+ IDS_SYMBOL_FILE "Symbol Datei"\r
+END\r
+\r
+STRINGTABLE \r
+BEGIN\r
+ IDS_USER_DATA "Ihre E-Mail und Beschreibung"\r
+END\r
+\r
+#endif // German (Germany) resources\r
+/////////////////////////////////////////////////////////////////////////////\r
+\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+// English (U.S.) resources\r
+\r
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r
+#ifdef _WIN32\r
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US\r
+#pragma code_page(1252)\r
+#endif //_WIN32\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Dialog\r
+//\r
+\r
+IDD_MAINDLG DIALOGEX 0, 0, 270, 217\r
+STYLE DS_SETFONT | WS_POPUP | WS_CAPTION | WS_SYSMENU\r
+FONT 8, "MS Sans Serif", 0, 0, 0x0\r
+BEGIN\r
+ EDITTEXT IDC_EMAIL,20,95,230,14,ES_AUTOHSCROLL\r
+ EDITTEXT IDC_DESCRIPTION,20,129,230,57,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL\r
+ PUSHBUTTON "&Send",IDOK,152,198,50,14,NOT WS_VISIBLE\r
+ PUSHBUTTON "E&xit",IDCANCEL,205,198,50,14\r
+ LTEXT "If you were in the middle of something, the information you were working on might be lost.",IDC_STATIC,20,6,230,20\r
+ LTEXT "We have created an error report that you can send to us. We will treat this report as confidential and anonymous.",IDC_STATIC,20,30,230,20\r
+ LTEXT "To help us diagnose the cause of this error and improve this software, please enter your email address, describe what you were doing when this error occurred, and send this report to us.",IDC_STATIC,20,54,230,29\r
+ LTEXT "Your EMail Address (optional):",IDC_STATIC,20,84,230,8\r
+ LTEXT "Describe what you were doing when the error occurred (optional):",IDC_STATIC,20,118,230,8\r
+ CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,0,192,272,1\r
+ PUSHBUTTON "Sa&ve",IDC_SAVE,99,198,50,14\r
+END\r
+\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// DESIGNINFO\r
+//\r
+\r
+#ifdef APSTUDIO_INVOKED\r
+GUIDELINES DESIGNINFO \r
+BEGIN\r
+ IDD_MAINDLG, DIALOG\r
+ BEGIN\r
+ VERTGUIDE, 15\r
+ VERTGUIDE, 20\r
+ VERTGUIDE, 250\r
+ VERTGUIDE, 255\r
+ BOTTOMMARGIN, 211\r
+ HORZGUIDE, 6\r
+ HORZGUIDE, 193\r
+ HORZGUIDE, 198\r
+ END\r
+END\r
+#endif // APSTUDIO_INVOKED\r
+\r
+\r
+#ifdef APSTUDIO_INVOKED\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// TEXTINCLUDE\r
+//\r
+\r
+1 TEXTINCLUDE \r
+BEGIN\r
+ "resource.h\0"\r
+END\r
+\r
+2 TEXTINCLUDE \r
+BEGIN\r
+ "#define APSTUDIO_HIDDEN_SYMBOLS\r\n"\r
+ "#include ""windows.h""\r\n"\r
+ "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"\r
+ "#ifndef APSTUDIO_INVOKED\r\n"\r
+ "\r\n"\r
+ "#endif\0"\r
+END\r
+\r
+#endif // APSTUDIO_INVOKED\r
+\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Version\r
+//\r
+\r
+VS_VERSION_INFO VERSIONINFO\r
+ FILEVERSION 3,1,2,3\r
+ PRODUCTVERSION 3,1,2,3\r
+ FILEFLAGSMASK 0x37L\r
+#ifdef _DEBUG\r
+ FILEFLAGS 0x21L\r
+#else\r
+ FILEFLAGS 0x20L\r
+#endif\r
+ FILEOS 0x4L\r
+ FILETYPE 0x2L\r
+ FILESUBTYPE 0x0L\r
+BEGIN\r
+ BLOCK "StringFileInfo"\r
+ BEGIN\r
+ BLOCK "040904b0"\r
+ BEGIN\r
+ VALUE "FileDescription", "Crash Report Module"\r
+ VALUE "FileVersion", "3.1.2.3"\r
+ VALUE "InternalName", "CrashRpt"\r
+ VALUE "LegalCopyright", "Copyright 2003-2007"\r
+ VALUE "OriginalFilename", "CrashRpt.exe"\r
+ VALUE "ProductName", "Crash Report Module"\r
+ VALUE "ProductVersion", "3.1.2.3"\r
+ VALUE "SpecialBuild", "0"\r
+ END\r
+ END\r
+ BLOCK "VarFileInfo"\r
+ BEGIN\r
+ VALUE "Translation", 0x409, 1200\r
+ END\r
+END\r
+\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// String Table\r
+//\r
+\r
+STRINGTABLE \r
+BEGIN\r
+ IDR_MAINFRAME "CrashRpt"\r
+END\r
+\r
+STRINGTABLE \r
+BEGIN\r
+ IDS_HEADER "{\\bnsi\\bnsicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fswiss\\fcharset0 Microsoft Sans Serif;}}\n{\\*\\generator Msftedit 5.41.15.1503;}\\viewkind4\\uc1\\pard\\b\\f0\\fs17 %s has encountered a problem and needs to close. We are sorry for the inconvenience.\\b0}\n "\r
+ IDS_INVALID_EMAIL "Please enter a valid email address"\r
+ IDS_ZIP_FILTER "Zip Files (*.zip)"\r
+ IDS_HTTP_HEADER_CONTENT_TYPE \r
+ "Content-Type: Multipart/form-data; boundary=%s"\r
+ IDS_HTTP_HEADER_BOUNDARY "-----------------7d31389b0426"\r
+END\r
+\r
+STRINGTABLE \r
+BEGIN\r
+ IDS_ABOUTBOX "About..."\r
+END\r
+\r
+STRINGTABLE \r
+BEGIN\r
+ IDS_CONTENT_TYPE "Content-Type: Multipart/form-data; boundary=""crash-report-boundary"""\r
+END\r
+\r
+STRINGTABLE \r
+BEGIN\r
+ IDS_NAME "Name"\r
+ IDS_DESC "Description"\r
+ IDS_TYPE "Type"\r
+ IDS_SIZE "Size"\r
+ IDS_CRASH_DUMP "Crash Dump"\r
+ IDS_CRASH_LOG "Crash Log"\r
+ IDS_SYMBOL_FILE "Symbol File"\r
+END\r
+\r
+STRINGTABLE \r
+BEGIN\r
+ IDS_USER_DATA "Your e-mail and description"\r
+END\r
+\r
+STRINGTABLE \r
+BEGIN\r
+ IDS_FORM_DATA "module=%s&exception=%s&address=%s"\r
+END\r
+\r
+#endif // English (U.S.) resources\r
+/////////////////////////////////////////////////////////////////////////////\r
+\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+// German (Switzerland) resources\r
+\r
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DES)\r
+#ifdef _WIN32\r
+LANGUAGE LANG_GERMAN, SUBLANG_GERMAN_SWISS\r
+#pragma code_page(1252)\r
+#endif //_WIN32\r
+\r
+#ifdef APSTUDIO_INVOKED\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// TEXTINCLUDE\r
+//\r
+\r
+3 TEXTINCLUDE \r
+BEGIN\r
+ "\r\0"\r
+END\r
+\r
+#endif // APSTUDIO_INVOKED\r
+\r
+#endif // German (Switzerland) resources\r
+/////////////////////////////////////////////////////////////////////////////\r
+\r
+\r
+\r
+#ifndef APSTUDIO_INVOKED\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Generated from the TEXTINCLUDE 3 resource.\r
+//\r
+\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+#endif // not APSTUDIO_INVOKED\r
+\r
--- /dev/null
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+ ProjectType="Visual C++"\r
+ Version="9.00"\r
+ Name="CrashRpt"\r
+ ProjectGUID="{13BC1836-2726-45C4-9249-5BA2BBBF8328}"\r
+ RootNamespace="CrashRpt"\r
+ TargetFrameworkVersion="131072"\r
+ >\r
+ <Platforms>\r
+ <Platform\r
+ Name="Win32"\r
+ />\r
+ <Platform\r
+ Name="x64"\r
+ />\r
+ </Platforms>\r
+ <ToolFiles>\r
+ </ToolFiles>\r
+ <Configurations>\r
+ <Configuration\r
+ Name="Release|Win32"\r
+ OutputDirectory="..\..\bin\Release\bin"\r
+ IntermediateDirectory="..\..\obj\CrashRpt\Release"\r
+ ConfigurationType="2"\r
+ UseOfMFC="0"\r
+ UseOfATL="0"\r
+ ATLMinimizesCRunTimeLibraryUsage="false"\r
+ CharacterSet="2"\r
+ ManagedExtensions="0"\r
+ WholeProgramOptimization="1"\r
+ >\r
+ <Tool\r
+ Name="VCPreBuildEventTool"\r
+ />\r
+ <Tool\r
+ Name="VCCustomBuildTool"\r
+ />\r
+ <Tool\r
+ Name="VCXMLDataGeneratorTool"\r
+ />\r
+ <Tool\r
+ Name="VCWebServiceProxyGeneratorTool"\r
+ />\r
+ <Tool\r
+ Name="VCMIDLTool"\r
+ PreprocessorDefinitions="NDEBUG"\r
+ MkTypLibCompatible="true"\r
+ SuppressStartupBanner="true"\r
+ TargetEnvironment="1"\r
+ TypeLibraryName=".\Release/CrashRpt.tlb"\r
+ />\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="1"\r
+ InlineFunctionExpansion="1"\r
+ FavorSizeOrSpeed="2"\r
+ AdditionalIncludeDirectories=".\zlib;..\crashrpt"\r
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE"\r
+ StringPooling="false"\r
+ ExceptionHandling="1"\r
+ BasicRuntimeChecks="0"\r
+ SmallerTypeCheck="false"\r
+ RuntimeLibrary="2"\r
+ BufferSecurityCheck="false"\r
+ EnableFunctionLevelLinking="false"\r
+ ForceConformanceInForLoopScope="true"\r
+ UsePrecompiledHeader="2"\r
+ PrecompiledHeaderThrough="stdafx.h"\r
+ PrecompiledHeaderFile="..\..\obj\CrashRpt\Release/Crasher.pch"\r
+ AssemblerListingLocation="..\..\obj\CrashRpt\Release/"\r
+ ObjectFile="..\..\obj\CrashRpt\Release/"\r
+ ProgramDataBaseFileName="..\..\obj\CrashRpt\Release/"\r
+ WarningLevel="3"\r
+ SuppressStartupBanner="true"\r
+ DebugInformationFormat="3"\r
+ CompileAs="0"\r
+ />\r
+ <Tool\r
+ Name="VCManagedResourceCompilerTool"\r
+ />\r
+ <Tool\r
+ Name="VCResourceCompilerTool"\r
+ PreprocessorDefinitions="NDEBUG"\r
+ Culture="1033"\r
+ AdditionalIncludeDirectories=""\r
+ />\r
+ <Tool\r
+ Name="VCPreLinkEventTool"\r
+ />\r
+ <Tool\r
+ Name="VCLinkerTool"\r
+ AdditionalOptions="/MACHINE:I386"\r
+ AdditionalDependencies="dbghelp.lib"\r
+ OutputFile="$(OutDir)/$(ProjectName).dll"\r
+ LinkIncremental="1"\r
+ SuppressStartupBanner="true"\r
+ AdditionalLibraryDirectories=""\r
+ GenerateDebugInformation="true"\r
+ ProgramDatabaseFile=""\r
+ OptimizeReferences="2"\r
+ OptimizeForWindows98="0"\r
+ BaseAddress="0x2000000"\r
+ RandomizedBaseAddress="1"\r
+ DataExecutionPrevention="0"\r
+ ImportLibrary="$(OutDir)/$(TargetName).lib"\r
+ />\r
+ <Tool\r
+ Name="VCALinkTool"\r
+ />\r
+ <Tool\r
+ Name="VCManifestTool"\r
+ />\r
+ <Tool\r
+ Name="VCXDCMakeTool"\r
+ />\r
+ <Tool\r
+ Name="VCBscMakeTool"\r
+ />\r
+ <Tool\r
+ Name="VCFxCopTool"\r
+ />\r
+ <Tool\r
+ Name="VCAppVerifierTool"\r
+ />\r
+ <Tool\r
+ Name="VCPostBuildEventTool"\r
+ />\r
+ </Configuration>\r
+ <Configuration\r
+ Name="Release|x64"\r
+ OutputDirectory="..\..\bin\Release64\bin"\r
+ IntermediateDirectory="..\..\obj\CrashRpt\Release64"\r
+ ConfigurationType="2"\r
+ UseOfMFC="0"\r
+ UseOfATL="0"\r
+ ATLMinimizesCRunTimeLibraryUsage="false"\r
+ CharacterSet="2"\r
+ ManagedExtensions="0"\r
+ WholeProgramOptimization="1"\r
+ >\r
+ <Tool\r
+ Name="VCPreBuildEventTool"\r
+ />\r
+ <Tool\r
+ Name="VCCustomBuildTool"\r
+ />\r
+ <Tool\r
+ Name="VCXMLDataGeneratorTool"\r
+ />\r
+ <Tool\r
+ Name="VCWebServiceProxyGeneratorTool"\r
+ />\r
+ <Tool\r
+ Name="VCMIDLTool"\r
+ PreprocessorDefinitions="NDEBUG"\r
+ MkTypLibCompatible="true"\r
+ SuppressStartupBanner="true"\r
+ TargetEnvironment="3"\r
+ TypeLibraryName=".\Release/CrashRpt.tlb"\r
+ />\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="1"\r
+ InlineFunctionExpansion="1"\r
+ FavorSizeOrSpeed="2"\r
+ AdditionalIncludeDirectories=".\zlib;..\crashrpt"\r
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE"\r
+ StringPooling="false"\r
+ ExceptionHandling="1"\r
+ BasicRuntimeChecks="0"\r
+ SmallerTypeCheck="false"\r
+ RuntimeLibrary="2"\r
+ BufferSecurityCheck="false"\r
+ EnableFunctionLevelLinking="false"\r
+ ForceConformanceInForLoopScope="true"\r
+ UsePrecompiledHeader="2"\r
+ PrecompiledHeaderThrough="stdafx.h"\r
+ PrecompiledHeaderFile="..\..\obj\CrashRpt\Release64/Crasher.pch"\r
+ AssemblerListingLocation="..\..\obj\CrashRpt\Release64/"\r
+ ObjectFile="..\..\obj\CrashRpt\Release64/"\r
+ ProgramDataBaseFileName="..\..\obj\CrashRpt\Release64/"\r
+ WarningLevel="3"\r
+ SuppressStartupBanner="true"\r
+ DebugInformationFormat="3"\r
+ CompileAs="0"\r
+ />\r
+ <Tool\r
+ Name="VCManagedResourceCompilerTool"\r
+ />\r
+ <Tool\r
+ Name="VCResourceCompilerTool"\r
+ PreprocessorDefinitions="NDEBUG"\r
+ Culture="1033"\r
+ AdditionalIncludeDirectories=""\r
+ />\r
+ <Tool\r
+ Name="VCPreLinkEventTool"\r
+ />\r
+ <Tool\r
+ Name="VCLinkerTool"\r
+ AdditionalOptions="/MACHINE:X64"\r
+ AdditionalDependencies="dbghelp.lib"\r
+ OutputFile="$(OutDir)/$(ProjectName).dll"\r
+ LinkIncremental="1"\r
+ SuppressStartupBanner="true"\r
+ AdditionalLibraryDirectories=""\r
+ GenerateDebugInformation="true"\r
+ ProgramDatabaseFile=""\r
+ OptimizeReferences="2"\r
+ OptimizeForWindows98="1"\r
+ BaseAddress="0x2000000"\r
+ RandomizedBaseAddress="1"\r
+ DataExecutionPrevention="0"\r
+ ImportLibrary="$(OutDir)/$(TargetName).lib"\r
+ />\r
+ <Tool\r
+ Name="VCALinkTool"\r
+ />\r
+ <Tool\r
+ Name="VCManifestTool"\r
+ />\r
+ <Tool\r
+ Name="VCXDCMakeTool"\r
+ />\r
+ <Tool\r
+ Name="VCBscMakeTool"\r
+ />\r
+ <Tool\r
+ Name="VCFxCopTool"\r
+ />\r
+ <Tool\r
+ Name="VCAppVerifierTool"\r
+ />\r
+ <Tool\r
+ Name="VCPostBuildEventTool"\r
+ />\r
+ </Configuration>\r
+ </Configurations>\r
+ <References>\r
+ </References>\r
+ <Files>\r
+ <Filter\r
+ Name="Source Files"\r
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
+ >\r
+ <File\r
+ RelativePath=".\BaseDialog.cpp"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\CrashHandler.cpp"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\CrashRpt.cpp"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\CrashRpt.rc"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\excprpt.cpp"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\MailMsg.cpp"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\MainDlg.cpp"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\StackTrace.cpp"\r
+ >\r
+ <FileConfiguration\r
+ Name="Release|Win32"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="2"\r
+ />\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|x64"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="2"\r
+ />\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath=".\StdAfx.cpp"\r
+ >\r
+ <FileConfiguration\r
+ Name="Release|Win32"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="1"\r
+ />\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|x64"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="1"\r
+ />\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath=".\Utility.cpp"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\WriteRegistry.cpp"\r
+ >\r
+ </File>\r
+ </Filter>\r
+ <Filter\r
+ Name="Header Files"\r
+ Filter="h;hpp;hxx;hm;inl"\r
+ >\r
+ <File\r
+ RelativePath=".\BaseDialog.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\CrashHandler.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="CrashReport.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\CrashRpt.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\excprpt.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\MailMsg.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\maindlg.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\resource.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\StackTrace.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\StdAfx.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\SymbolEngine.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\Utility.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\WriteRegistry.h"\r
+ >\r
+ </File>\r
+ </Filter>\r
+ <Filter\r
+ Name="Resource Files"\r
+ Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"\r
+ >\r
+ <File\r
+ RelativePath=".\res\CrashRpt.ico"\r
+ >\r
+ </File>\r
+ </Filter>\r
+ <Filter\r
+ Name="zlib"\r
+ >\r
+ <File\r
+ RelativePath="zlib\adler32.c"\r
+ >\r
+ <FileConfiguration\r
+ Name="Release|Win32"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|x64"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\compress.c"\r
+ >\r
+ <FileConfiguration\r
+ Name="Release|Win32"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|x64"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\crc32.c"\r
+ >\r
+ <FileConfiguration\r
+ Name="Release|Win32"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|x64"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\deflate.c"\r
+ >\r
+ <FileConfiguration\r
+ Name="Release|Win32"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|x64"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\deflate.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\gzio.c"\r
+ >\r
+ <FileConfiguration\r
+ Name="Release|Win32"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|x64"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\infblock.c"\r
+ >\r
+ <FileConfiguration\r
+ Name="Release|Win32"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|x64"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\infblock.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\infcodes.c"\r
+ >\r
+ <FileConfiguration\r
+ Name="Release|Win32"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|x64"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\infcodes.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\inffast.c"\r
+ >\r
+ <FileConfiguration\r
+ Name="Release|Win32"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|x64"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\inffast.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\inffixed.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\inflate.c"\r
+ >\r
+ <FileConfiguration\r
+ Name="Release|Win32"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|x64"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\inftrees.c"\r
+ >\r
+ <FileConfiguration\r
+ Name="Release|Win32"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|x64"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\inftrees.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\infutil.c"\r
+ >\r
+ <FileConfiguration\r
+ Name="Release|Win32"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|x64"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\infutil.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\maketree.c"\r
+ >\r
+ <FileConfiguration\r
+ Name="Release|Win32"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|x64"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\readme.txt"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\trees.c"\r
+ >\r
+ <FileConfiguration\r
+ Name="Release|Win32"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|x64"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\trees.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\uncompr.c"\r
+ >\r
+ <FileConfiguration\r
+ Name="Release|Win32"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|x64"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\unzip.c"\r
+ >\r
+ <FileConfiguration\r
+ Name="Release|Win32"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|x64"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\unzip.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\zconf.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\zip.c"\r
+ >\r
+ <FileConfiguration\r
+ Name="Release|Win32"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|x64"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\zip.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\zlib.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\zlibcpp.cpp"\r
+ >\r
+ <FileConfiguration\r
+ Name="Release|Win32"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ AdditionalIncludeDirectories=""\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|x64"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ AdditionalIncludeDirectories=""\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\zlibcpp.h"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\zutil.c"\r
+ >\r
+ <FileConfiguration\r
+ Name="Release|Win32"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ <FileConfiguration\r
+ Name="Release|x64"\r
+ >\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ UsePrecompiledHeader="0"\r
+ />\r
+ </FileConfiguration>\r
+ </File>\r
+ <File\r
+ RelativePath="zlib\zutil.h"\r
+ >\r
+ </File>\r
+ </Filter>\r
+ <File\r
+ RelativePath=".\chglog.txt"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\license.txt"\r
+ >\r
+ </File>\r
+ </Files>\r
+ <Globals>\r
+ <Global\r
+ Name="DevPartner_IsInstrumented"\r
+ Value="0"\r
+ />\r
+ </Globals>\r
+</VisualStudioProject>\r
--- /dev/null
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioUserFile\r
+ ProjectType="Visual C++"\r
+ Version="9.00"\r
+ ShowAllFiles="false"\r
+ >\r
+ <Configurations>\r
+ <Configuration\r
+ Name="Release|Win32"\r
+ >\r
+ <DebugSettings\r
+ Command=""\r
+ WorkingDirectory=""\r
+ CommandArguments=""\r
+ Attach="false"\r
+ DebuggerType="3"\r
+ Remote="1"\r
+ RemoteMachine="B20596-01"\r
+ RemoteCommand=""\r
+ HttpUrl=""\r
+ PDBPath=""\r
+ SQLDebugging=""\r
+ Environment=""\r
+ EnvironmentMerge="true"\r
+ DebuggerFlavor=""\r
+ MPIRunCommand=""\r
+ MPIRunArguments=""\r
+ MPIRunWorkingDirectory=""\r
+ ApplicationCommand=""\r
+ ApplicationArguments=""\r
+ ShimCommand=""\r
+ MPIAcceptMode=""\r
+ MPIAcceptFilter=""\r
+ />\r
+ </Configuration>\r
+ </Configurations>\r
+</VisualStudioUserFile>\r
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Module: CrashRptDL.h\r
+//\r
+// Desc: Defines the interface for the CrashRpt.DLL, using a dynamically\r
+// loaded instance of the library. Can be used when CrashRpt.dll may\r
+// not be present on the system.\r
+//\r
+// Note that all functions except GetInstanceDL() and\r
+// ReleaseInstanceDL() return an integer, which is non-zero ('true')\r
+// when the real DLL function was located and called. This does not\r
+// mean the actual DLL function succeeded, however.\r
+//\r
+// Please don't get confused by the macro usage; all functions do end\r
+// in DL, even though the name supplied to CRASHRPT_DECLARE does not.\r
+//\r
+// Copyright (c) 2003 Michael Carruth\r
+// Copyright (c) 2003 Grant McDorman\r
+// This software is provided 'as-is', without any express or implied\r
+// warranty. In no event will the authors be held liable for any damages\r
+// arising from the use of this software.\r
+//\r
+// Permission is granted to anyone to use this software for any purpose,\r
+// including commercial applications, and to alter it and redistribute it\r
+// freely, subject to the following restrictions:\r
+//\r
+// 1. The origin of this software must not be misrepresented; you must not\r
+// claim that you wrote the original software. If you use this software\r
+// in a product, an acknowledgment in the product documentation would be\r
+// appreciated but is not required.\r
+// 2. Altered source versions must be plainly marked as such, and must not be\r
+// misrepresented as being the original software.\r
+// 3. This notice may not be removed or altered from any source distribution.\r
+//\r
+///////////////////////////////////////////////////////////////////////////////\r
+\r
+#ifndef _CRASHRPT_H_\r
+#define _CRASHRPT_H_\r
+\r
+#if _MSC_VER >= 1000\r
+#pragma once\r
+#endif // _MSC_VER >= 1000\r
+\r
+#include <windows.h>\r
+#include <wtypes.h> // BSTR\r
+\r
+// Client crash callback\r
+typedef BOOL (CALLBACK *LPGETLOGFILE) (LPVOID lpvState);\r
+// Stack trace callback\r
+typedef void (*TraceCallbackFunction)(DWORD address, const char *ImageName,\r
+ const char *FunctionName, DWORD functionDisp,\r
+ const char *Filename, DWORD LineNumber, DWORD lineDisp,\r
+ void *data);\r
+\r
+// macro to create the inline forwarding function\r
+#define CRASHRPT_DECLARE(function, declare1, declare2, arguments) \\r
+ __inline int function##DL declare1 \\r
+ { \\r
+ typedef void (*function##_t) declare2; \\r
+ function##_t p##function; \\r
+ p##function = (function##_t) GetProcAddress(hModule, #function); \\r
+ if (p##function != NULL) { \\r
+ p##function arguments; \\r
+ return 1; \\r
+ } \\r
+ return 0; \\r
+ }\r
+\r
+\r
+\r
+//-----------------------------------------------------------------------------\r
+// GetInstanceDL\r
+// Returns the instance (module handle) for the CrashRpt DLL.\r
+//\r
+// Parameters\r
+// none\r
+//\r
+// Return Values\r
+// If the function succeeds, the return value is a module handle for the CrashRpt\r
+// shared library (CrashRpt.dll). This handle is required for all the other functions.\r
+//\r
+// Remarks\r
+// none\r
+//\r
+__inline \r
+HMODULE\r
+GetInstanceDL()\r
+{\r
+ return LoadLibrary("CrashRpt");\r
+}\r
+\r
+//-----------------------------------------------------------------------------\r
+// InstallDL\r
+// Initializes the library and optionally set the client crash callback and\r
+// sets up the email details.\r
+//\r
+// Parameters\r
+// hModule State information returned from GetInstanceDL() (must not be NULL)\r
+// pfn Client crash callback\r
+// lpTo Email address to send crash report\r
+// lpSubject Subject line to be used with email\r
+//\r
+// Return Values\r
+// non-zero if successful\r
+//\r
+// Remarks\r
+// Passing NULL for lpTo will disable the email feature and cause the crash \r
+// report to be saved to disk.\r
+//\r
+CRASHRPT_DECLARE(Install, (IN HMODULE hModule, IN LPGETLOGFILE pfn, IN LPCTSTR lpTo OPTIONAL, IN LPCTSTR lpSubject OPTIONAL), \\r
+ (LPGETLOGFILE pfn, LPCTSTR lpTo, LPCTSTR lpSubject), \\r
+ (pfn, lpTo, lpSubject))\r
+\r
+//-----------------------------------------------------------------------------\r
+// UninstallDL\r
+// Uninstalls the unhandled exception filter set up in InstallDL().\r
+//\r
+// Parameters\r
+// hModule Module handle returned from GetInstanceDL()\r
+//\r
+// Return Values\r
+// non-zero if successful\r
+//\r
+// Remarks\r
+// This call is optional. The crash report library will automatically \r
+// deinitialize when the library is unloaded. Call this function to\r
+// unhook the exception filter manually.\r
+//\r
+CRASHRPT_DECLARE(Uninstall, (IN HMODULE hModule), \\r
+ (), \\r
+ ())\r
+//-----------------------------------------------------------------------------\r
+// ReleaseInstanceDL\r
+// Releases the library.\r
+//\r
+// Parameters\r
+// hModule Module handle returned from GetInstanceDL()\r
+//\r
+// Return Values\r
+// void\r
+//\r
+// Remarks\r
+// This will call UninstallDL before releasing the library.\r
+//\r
+__inline \r
+void\r
+ReleaseInstanceDL(IN HMODULE hModule)\r
+{\r
+ UninstallDL(hModule);\r
+ FreeLibrary(hModule);\r
+}\r
+\r
+//-----------------------------------------------------------------------------\r
+// AddFileDL\r
+// Adds a file to the crash report.\r
+//\r
+// Parameters\r
+// hModule Module handle returned from GetInstanceDL()\r
+// lpFile Fully qualified file name\r
+// lpDesc Description of file, used by details dialog\r
+//\r
+// Return Values\r
+// non-zero if successful\r
+//\r
+// Remarks\r
+// This function can be called anytime after Install() to add one or more\r
+// files to the generated crash report. If lpFile exactly matches\r
+// a previously added file, it is not added again.\r
+//\r
+CRASHRPT_DECLARE(AddFile, (IN HMODULE hModule, IN LPCTSTR lpFile, IN LPCTSTR lpDesc), \\r
+ (LPCTSTR lpFile, LPCTSTR lpDesc), \\r
+ (lpFile, lpDesc))\r
+\r
+//-----------------------------------------------------------------------------\r
+// RemoveFileDL\r
+// Removes a file from the crash report.\r
+//\r
+// Parameters\r
+// hModule Module handle returned from GetInstanceDL()\r
+// lpFile Fully qualified file name\r
+//\r
+// Return Values\r
+// non-zero if successful\r
+//\r
+// Remarks\r
+// The filename must exactly match that provided to AddFile.\r
+//\r
+CRASHRPT_DECLARE(RemoveFile, (IN HMODULE hModule, IN LPCTSTR lpFile), \\r
+ (LPCTSTR lpFile), \\r
+ (lpFile))\r
+\r
+//-----------------------------------------------------------------------------\r
+// AddRegistryHiveDL\r
+// Adds a RegistryHive to the crash report.\r
+//\r
+// Parameters\r
+// hModule Module handle returned from GetInstanceDL()\r
+// lpRegistryHive Fully qualified RegistryHive name\r
+// lpDesc Description of RegistryHive, used by details dialog\r
+//\r
+// Return Values\r
+// non-zero if successful\r
+//\r
+// Remarks\r
+// This function can be called anytime after Install() to add one or more\r
+// RegistryHives to the generated crash report. If lpRegistryHive exactly matches\r
+// a previously added file, it is not added again.\r
+//\r
+CRASHRPT_DECLARE(AddRegistryHive, (IN HMODULE hModule, IN LPCTSTR lpRegistryHive, IN LPCTSTR lpDesc), \\r
+ (LPCTSTR lpRegistryHive, LPCTSTR lpDesc), \\r
+ (lpRegistryHive, lpDesc))\r
+\r
+//-----------------------------------------------------------------------------\r
+// RemoveRegistryHiveDL\r
+// Removes a RegistryHive from the crash report.\r
+//\r
+// Parameters\r
+// hModule Module handle returned from GetInstanceDL()\r
+// lpRegistryHive Fully qualified RegistryHive name\r
+//\r
+// Return Values\r
+// non-zero if successful\r
+//\r
+// Remarks\r
+// The RegistryHive name must exactly match that provided to AddRegistryHive.\r
+//\r
+CRASHRPT_DECLARE(RemoveRegistryHive, (IN HMODULE hModule, IN LPCTSTR lpRegistryHive), \\r
+ (LPCTSTR lpRegistryHive), \\r
+ (lpRegistryHive))\r
+\r
+//-----------------------------------------------------------------------------\r
+// AddEventLogDL\r
+// Adds an event log to the crash report.\r
+//\r
+// Parameters\r
+// hModule Module handle returned from GetInstanceDL()\r
+// lpEventLog Event log name ("Application", "Security", "System" or any other known to your system)\r
+// lpDesc Description of event log, used by details dialog\r
+//\r
+// Return Values\r
+// non-zero if successful\r
+//\r
+// Remarks\r
+// This function can be called anytime after Install() to add one or more\r
+// event logs to the generated crash report. If lpEventLog exactly matches\r
+// a previously added file, it is not added again.\r
+//\r
+CRASHRPT_DECLARE(AddEventLog, (IN HMODULE hModule, IN LPCTSTR lpEventLog, IN LPCTSTR lpDesc), \\r
+ (LPCTSTR lpEventLog, LPCTSTR lpDesc), \\r
+ (lpEventLog, lpDesc))\r
+\r
+//-----------------------------------------------------------------------------\r
+// RemoveEventLogDL\r
+// Removes a EventLog from the crash report.\r
+//\r
+// Parameters\r
+// hModule Module handle returned from GetInstanceDL()\r
+// lpEventLog Fully qualified EventLog name\r
+//\r
+// Return Values\r
+// non-zero if successful\r
+//\r
+// Remarks\r
+// The EventLog name must exactly match that provided to AddEventLog.\r
+//\r
+CRASHRPT_DECLARE(RemoveEventLog, (IN HMODULE hModule, IN LPCTSTR lpEventLog), \\r
+ (LPCTSTR lpEventLog), \\r
+ (lpEventLog))\r
+\r
+//-----------------------------------------------------------------------------\r
+// GenerateErrorReportDL\r
+// Generates the crash report.\r
+//\r
+// Parameters\r
+// hModule Module handle returned from GetInstanceDL()\r
+// pExInfo Optional; exception information\r
+// message Optional; message to include in report\r
+//\r
+// Return Values\r
+// non-zero if successful\r
+//\r
+// Remarks\r
+// Call this function to manually generate a crash report.\r
+//\r
+__inline\r
+int\r
+GenerateErrorReportDL(\r
+ IN HMODULE hModule,\r
+ IN PEXCEPTION_POINTERS pExInfo OPTIONAL,\r
+ IN BSTR message OPTIONAL\r
+ )\r
+{\r
+ // we can't use GenerateErrorReport(), because that is lacking the PEXCEPTION_POINTERS parameter\r
+ LPVOID instance;\r
+ typedef LPVOID (*GetInstance_t) ();\r
+ GetInstance_t pGetInstance;\r
+ pGetInstance = (GetInstance_t) GetProcAddress(hModule, "GetInstance");\r
+ if (pGetInstance != NULL) {\r
+ typedef void (*GenerateErrorReportEx_t)(LPVOID lpState, PEXCEPTION_POINTERS pExInfo, BSTR message);\r
+ GenerateErrorReportEx_t pGenerateErrorReportEx;\r
+\r
+ instance = pGetInstance();\r
+ pGenerateErrorReportEx = (GenerateErrorReportEx_t) GetProcAddress(hModule, "GenerateErrorReportEx");\r
+ if (pGenerateErrorReportEx != NULL) {\r
+ pGenerateErrorReportEx(instance, pExInfo, message);\r
+ return 1;\r
+ }\r
+ }\r
+ return 0;\r
+}\r
+\r
+\r
+//-----------------------------------------------------------------------------\r
+// StackTraceDL\r
+// Creates a stack trace.\r
+//\r
+// Parameters\r
+// hModule Module handle returned from GetInstanceDL()\r
+// numSkip Number of initial stack frames to skip\r
+// depth Number of stack frames to process\r
+// pFunction Optional; function to call for each frame\r
+// pContext Optional; stack context to trace\r
+//\r
+// Return Values\r
+// void\r
+//\r
+// Remarks\r
+// Call this function to manually generate a stack trace. If\r
+// pFunction is not supplied, stack trace frames are output using\r
+// OutputDebugString. Can be called without installing (InstallDL)\r
+// CrashRpt.\r
+//\r
+CRASHRPT_DECLARE(StackTrace, (IN HMODULE hModule, IN int numSkip, IN int depth, IN TraceCallbackFunction pFunction OPTIONAL, IN CONTEXT * pContext OPTIONAL, IN LPVOID data OPTIONAL), \\r
+ (int numSkip, int depth, TraceCallbackFunction pFunction, CONTEXT * pContext, LPVOID data), \\r
+ (numSkip, depth, pFunction, pContext, data))\r
+\r
+#undef CRASHRPT_DECLARE\r
+\r
+#endif\r
--- /dev/null
+<?xml version="1.0"?>\r
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\r
+ <xsl:output method = "html" encoding="iso-8859-1" />\r
+ <xsl:template match="/Exception"> \r
+ <html>\r
+ <title></title>\r
+ <body>\r
+ \r
+ <xsl:if test = "ExceptionRecord/@ExceptionAddress[1]">\r
+ <H2>Exception</H2>\r
+ <TABLE BORDER="1">\r
+ <TR>\r
+ <TH>Exceptino Description</TH> <TH>Code</TH> <TH>Address</TH> <TH>Module</TH>\r
+ <xsl:if test="ExceptionRecord/@Filename[1]">\r
+ <TH>Filename</TH> <TH>Function</TH> <TH>Line</TH>\r
+ </xsl:if>\r
+ </TR>\r
+ <TR>\r
+ <TD>\r
+ <xsl:value-of select = "ExceptionRecord/@ExceptionDescription[1]" />\r
+ </TD>\r
+ <TD>\r
+ <xsl:value-of select = "ExceptionRecord/@ExceptionCode[1]" />\r
+ </TD>\r
+ <TD>\r
+ <xsl:value-of select = "ExceptionRecord/@ExceptionAddress[1]" />\r
+ </TD>\r
+ <TD>\r
+ <xsl:value-of select = "ExceptionRecord/@ModuleName[1]" />\r
+ </TD>\r
+ <xsl:if test="ExceptionRecord/@Filename[1]">\r
+ <td>\r
+ <xsl:value-of select = "ExceptionRecord/@Filename[1]" />\r
+ </td>\r
+ </xsl:if>\r
+ \r
+ <xsl:if test="ExceptionRecord/@FunctionName[1]">\r
+ <td>\r
+ <xsl:value-of select = "ExceptionRecord/@FunctionName[1]" />\r
+ <xsl:if test="ExceptionRecord/@FunctionDisplacement[1]">\r
+ + <xsl:value-of select = "ExceptionRecord/@FunctionDisplacement[1]" />\r
+ </xsl:if>\r
+ </td>\r
+ <xsl:if test="ExceptionRecord/@LineNumber[1]">\r
+ <td>\r
+ <xsl:value-of select = "ExceptionRecord/@LineNumber[1]" />\r
+ <xsl:if test="ExceptionRecord/@LineDisplacement[1]">\r
+ + <xsl:value-of select = "ExceptionRecord/@LineDisplacement[1]" />\r
+ </xsl:if>\r
+ </td>\r
+ </xsl:if>\r
+ </xsl:if>\r
+ </TR>\r
+ </TABLE>\r
+ </xsl:if>\r
+\r
+ <xsl:if test="ApplicationDescription">\r
+ <H2>Application Description</H2>\r
+ <pre><xsl:value-of select = "ApplicationDescription" /> </pre>\r
+ </xsl:if>\r
+\r
+ <xsl:if test="CallStack">\r
+ <h2>Call Stack</h2>\r
+ <table border="1">\r
+ <tr> <th>#</th> <th> Return Address </th> <th>Module</th> <th>File</th> <th> Function </th> <th> Line </th> </tr>\r
+ <xsl:for-each select="CallStack/Frame">\r
+ <xsl:sort data-type="number" select="@FrameNumber[1]"/>\r
+ <tr>\r
+ <td>\r
+ <xsl:value-of select = "@FrameNumber[1]" />\r
+ </td>\r
+ <td>\r
+ <xsl:value-of select = "@ReturnAddress[1]" />\r
+ </td>\r
+ <xsl:if test="@ModuleName[1]">\r
+ <td>\r
+ <xsl:value-of select = "@ModuleName[1]" />\r
+ </td>\r
+ </xsl:if>\r
+ <xsl:if test="not(@ModuleName[1])">\r
+ <td>\r
+ -\r
+ </td>\r
+ </xsl:if>\r
+ <xsl:if test="@Filename[1]">\r
+ <td>\r
+ <xsl:value-of select = "@Filename[1]" />\r
+ </td>\r
+ </xsl:if>\r
+ <xsl:if test="not(@Filename[1])">\r
+ <td>\r
+ -\r
+ </td>\r
+ </xsl:if>\r
+ \r
+ <xsl:if test="@FunctionName[1]">\r
+ <td>\r
+ <xsl:value-of select = "@FunctionName[1]" />\r
+ <xsl:if test="@FunctionDisplacement[1]">\r
+ + <xsl:value-of select = "@FunctionDisplacement[1]" />\r
+ </xsl:if>\r
+ </td>\r
+ <xsl:if test="@LineNumber[1]">\r
+ <td>\r
+ <xsl:value-of select = "@LineNumber[1]" />\r
+ <xsl:if test="@LineDisplacement[1]">\r
+ + <xsl:value-of select = "@LineDisplacement[1]" />\r
+ </xsl:if>\r
+ </td>\r
+ </xsl:if>\r
+ </xsl:if>\r
+ </tr>\r
+ </xsl:for-each>\r
+ </table>\r
+ </xsl:if>\r
+\r
+\r
+ <xsl:if test="Modules/Module">\r
+ <h2>Loaded Modules</h2>\r
+ <table border="1">\r
+ <tr> <th>Full Path</th> <th> Product Version </th> <th> File Version </th> <th>Timestamp</th> <th>Base Addr</th> <th>Size</th> </tr>\r
+ <xsl:for-each select="Modules/Module">\r
+ <xsl:sort data-type="text" select="@FullPath[1]"/>\r
+ <tr>\r
+ <td>\r
+ <xsl:value-of select = "@FullPath[1]" />\r
+ </td>\r
+ <td>\r
+ <xsl:value-of select = "@ProductVersion[1]" />\r
+ </td>\r
+ <td>\r
+ <xsl:if test="@ProductVersion[1] != @FileVersion[1]">\r
+ <xsl:value-of select = "@FileVersion[1]" />\r
+ </xsl:if>\r
+ </td>\r
+ <td>\r
+ <xsl:value-of select = "@TimeStamp[1]" />\r
+ </td>\r
+ <td>\r
+ <xsl:value-of select = "@BaseAddress[1]" />\r
+ </td>\r
+ <td>\r
+ <xsl:value-of select = "@Size[1]" />\r
+ </td>\r
+ </tr>\r
+ </xsl:for-each>\r
+ </table>\r
+ </xsl:if>\r
+\r
+ </body>\r
+ </html>\r
+ </xsl:template>\r
+</xsl:stylesheet>\r
+\r
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Module: MailMsg.cpp\r
+//\r
+// Desc: See MailMsg.h\r
+//\r
+// Copyright (c) 2003 Michael Carruth\r
+//\r
+///////////////////////////////////////////////////////////////////////////////\r
+\r
+#include "stdafx.h"\r
+#include "MailMsg.h"\r
+\r
+CMailMsg::CMailMsg()\r
+{\r
+ m_lpCmcLogon = NULL;\r
+ m_lpCmcSend = NULL;\r
+ m_lpCmcLogoff = NULL;\r
+ m_lpMapiLogon = NULL;\r
+ m_lpMapiSendMail = NULL;\r
+ m_lpMapiLogoff = NULL;\r
+ m_lpMapiResolveName = NULL;\r
+ m_lpMapiFreeBuffer = NULL;\r
+ m_bReady = FALSE;\r
+}\r
+\r
+CMailMsg::~CMailMsg()\r
+{\r
+ if (m_bReady)\r
+ Uninitialize();\r
+}\r
+\r
+CMailMsg& CMailMsg::SetFrom(string sAddress, string sName)\r
+{\r
+ if (m_bReady || Initialize())\r
+ {\r
+ // only one sender allowed\r
+ if (m_from.size())\r
+ m_from.empty();\r
+\r
+ m_from.push_back(TStrStrPair(sAddress,sName));\r
+ }\r
+\r
+ return *this;\r
+}\r
+\r
+CMailMsg& CMailMsg::SetTo(string sAddress, string sName)\r
+{\r
+ if (m_bReady || Initialize())\r
+ {\r
+ // only one recipient allowed\r
+ if (m_to.size())\r
+ m_to.empty();\r
+\r
+ m_to.push_back(TStrStrPair(sAddress,sName));\r
+ }\r
+\r
+ return *this;\r
+}\r
+\r
+CMailMsg& CMailMsg::SetCc(string sAddress, string sName)\r
+{\r
+ if (m_bReady || Initialize())\r
+ {\r
+ m_cc.push_back(TStrStrPair(sAddress,sName));\r
+ }\r
+\r
+ return *this;\r
+}\r
+\r
+CMailMsg& CMailMsg::SetBc(string sAddress, string sName)\r
+{\r
+ if (m_bReady || Initialize())\r
+ {\r
+ m_bcc.push_back(TStrStrPair(sAddress, sName));\r
+ }\r
+\r
+ return *this;\r
+}\r
+\r
+CMailMsg& CMailMsg::AddAttachment(string sAttachment, string sTitle)\r
+{\r
+ if (m_bReady || Initialize())\r
+ {\r
+ m_attachments.push_back(TStrStrPair(sAttachment, sTitle));\r
+ }\r
+\r
+ return *this;\r
+}\r
+\r
+BOOL CMailMsg::Send()\r
+{\r
+ // try mapi\r
+ int status = MAPISend();\r
+ if (status != 0)\r
+ return status == 1;\r
+ // try cmc\r
+// if (CMCSend())\r
+// return TRUE;\r
+\r
+ return FALSE;\r
+}\r
+\r
+/*\r
++------------------------------------------------------------------------------\r
+|\r
+| Function: cResolveName()\r
+|\r
+| Parameters: [IN] lpszName = Name of e-mail recipient to resolve.\r
+| [OUT] ppRecips = Pointer to a pointer to an lpMapiRecipDesc\r
+|\r
+| Purpose: Resolves an e-mail address and returns a pointer to a \r
+| MapiRecipDesc structure filled with the recipient information\r
+| contained in the address book.\r
+|\r
+| Note: ppRecips is allocated off the heap using MAPIAllocateBuffer.\r
+| Any user of this method must be sure to release ppRecips when \r
+| done with it using either MAPIFreeBuffer or cFreeBuffer.\r
++-------------------------------------------------------------------------------\r
+*/\r
+int CMailMsg::cResolveName( LHANDLE m_lhSession, const char * lpszName, lpMapiRecipDesc *ppRecip )\r
+{ \r
+ HRESULT hRes = E_FAIL;\r
+ FLAGS flFlags = 0L;\r
+ ULONG ulReserved = 0L;\r
+ lpMapiRecipDesc pRecips = NULL;\r
+ \r
+ // Always check to make sure there is an active session\r
+ if ( m_lhSession ) \r
+ {\r
+ hRes = m_lpMapiResolveName (\r
+ m_lhSession, // Session handle\r
+ 0L, // Parent window.\r
+ const_cast<LPSTR>(lpszName), // Name of recipient. Passed in by argv.\r
+ flFlags, // Flags set to 0 for MAPIResolveName.\r
+ ulReserved,\r
+ &pRecips\r
+ ); \r
+\r
+ if ( hRes == SUCCESS_SUCCESS )\r
+ { \r
+ // Copy the recipient descriptor returned from MAPIResolveName to \r
+ // the out parameter for this function,\r
+ *ppRecip = pRecips;\r
+ } \r
+ }\r
+ return hRes;\r
+}\r
+\r
+\r
+\r
+int CMailMsg::MAPISend()\r
+{\r
+\r
+ TStrStrVector::iterator p;\r
+ int nIndex = 0;\r
+ size_t nRecipients = 0;\r
+ MapiRecipDesc* pRecipients = NULL;\r
+ MapiRecipDesc* pOriginator = NULL;\r
+ MapiRecipDesc* pFirstRecipient = NULL;\r
+ size_t nAttachments = 0;\r
+ MapiFileDesc* pAttachments = NULL;\r
+ ULONG status = 0;\r
+ MapiMessage message;\r
+ std::vector<MapiRecipDesc*> buffersToFree;\r
+ MapiRecipDesc* pRecip;\r
+ MapiRecipDesc grecip;\r
+\r
+ if (m_bReady || Initialize())\r
+ {\r
+ LHANDLE hMapiSession;\r
+ status = m_lpMapiLogon(NULL, NULL, NULL, MAPI_NEW_SESSION | MAPI_LOGON_UI, 0, &hMapiSession);\r
+ if (SUCCESS_SUCCESS != status) {\r
+ return FALSE;\r
+ }\r
+\r
+ nRecipients = m_to.size() + m_cc.size() + m_bcc.size() + m_from.size();\r
+ if (nRecipients)\r
+ {\r
+ pRecipients = new MapiRecipDesc[nRecipients];\r
+ memset(pRecipients, 0, nRecipients * sizeof MapiRecipDesc);\r
+ }\r
+\r
+ nAttachments = m_attachments.size();\r
+ if (nAttachments)\r
+ pAttachments = new MapiFileDesc[nAttachments];\r
+\r
+ if (pRecipients)\r
+ {\r
+ pFirstRecipient = pRecipients;\r
+ if (m_from.size())\r
+ {\r
+ // set from\r
+ if (cResolveName(hMapiSession, m_from.begin()->first.c_str(), &pOriginator) == SUCCESS_SUCCESS) {\r
+ buffersToFree.push_back(pOriginator);\r
+ }\r
+ }\r
+ if (m_to.size())\r
+ {\r
+ if (cResolveName(hMapiSession, m_to.begin()->first.c_str(), &pRecip) == SUCCESS_SUCCESS) {\r
+ if (pFirstRecipient == NULL)\r
+ pFirstRecipient = &pRecipients[nIndex];\r
+ pRecip->ulRecipClass = MAPI_TO;\r
+ memcpy(&pRecipients[nIndex], pRecip, sizeof pRecipients[nIndex]);\r
+ buffersToFree.push_back(pRecip);\r
+ nIndex++;\r
+ }\r
+ else\r
+ {\r
+ if (pFirstRecipient == NULL)\r
+ pFirstRecipient = &pRecipients[nIndex];\r
+ grecip.ulRecipClass = MAPI_TO;\r
+ grecip.lpEntryID = 0;\r
+ grecip.lpszName = 0;\r
+ grecip.ulEIDSize = 0;\r
+ grecip.ulReserved = 0;\r
+ grecip.lpszAddress = (LPTSTR)(LPCTSTR)m_to.begin()->first.c_str();\r
+ memcpy(&pRecipients[nIndex], &grecip, sizeof pRecipients[nIndex]);\r
+ nIndex++;\r
+ }\r
+ } \r
+ if (m_cc.size())\r
+ {\r
+ // set cc's\r
+ for (p = m_cc.begin(); p != m_cc.end(); p++, nIndex++)\r
+ {\r
+ if ( cResolveName(hMapiSession, p->first.c_str(), &pRecip) == SUCCESS_SUCCESS) {\r
+ if (pFirstRecipient == NULL)\r
+ pFirstRecipient = &pRecipients[nIndex];\r
+ pRecip->ulRecipClass = MAPI_CC;\r
+ memcpy(&pRecipients[nIndex], pRecip, sizeof pRecipients[nIndex]);\r
+ buffersToFree.push_back(pRecip);\r
+ nIndex++;\r
+ }\r
+ }\r
+ }\r
+ \r
+ if (m_bcc.size())\r
+ {\r
+ // set bcc\r
+ for (p = m_bcc.begin(); p != m_bcc.end(); p++, nIndex++)\r
+ {\r
+ if ( cResolveName(hMapiSession, p->first.c_str(), &pRecip) == SUCCESS_SUCCESS) {\r
+ if (pFirstRecipient == NULL)\r
+ pFirstRecipient = &pRecipients[nIndex];\r
+ pRecip->ulRecipClass = MAPI_BCC;\r
+ memcpy(&pRecipients[nIndex], pRecip, sizeof pRecipients[nIndex]);\r
+ buffersToFree.push_back(pRecip);\r
+ nIndex++;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ if (pAttachments)\r
+ {\r
+ // add attachments\r
+ for (p = m_attachments.begin(), nIndex = 0;\r
+ p != m_attachments.end(); p++, nIndex++)\r
+ {\r
+ pAttachments[nIndex].ulReserved = 0;\r
+ pAttachments[nIndex].flFlags = 0;\r
+ pAttachments[nIndex].nPosition = 0;\r
+ pAttachments[nIndex].lpszPathName = (LPTSTR)p->first.c_str();\r
+ pAttachments[nIndex].lpszFileName = (LPTSTR)p->second.c_str();\r
+ pAttachments[nIndex].lpFileType = NULL;\r
+ }\r
+ }\r
+ memset(&message, 0, sizeof message);\r
+ message.ulReserved = 0;\r
+ if (!m_sSubject.empty())\r
+ message.lpszSubject = (LPTSTR)m_sSubject.c_str();\r
+ else\r
+ message.lpszSubject = "No Subject";\r
+ if (!m_sMessage.empty())\r
+ message.lpszNoteText = (LPTSTR)m_sMessage.c_str();\r
+ else\r
+ message.lpszNoteText = "No Message Body";\r
+ message.lpszMessageType = NULL;\r
+ message.lpszDateReceived = NULL;\r
+ message.lpszConversationID = NULL;\r
+ message.flFlags = 0;\r
+ message.lpOriginator = pOriginator;\r
+ message.nRecipCount = nIndex;\r
+ message.lpRecips = pFirstRecipient;\r
+ message.nFileCount = nAttachments;\r
+ message.lpFiles = pAttachments;\r
+\r
+ status = m_lpMapiSendMail(hMapiSession, 0, &message, MAPI_DIALOG, 0);\r
+ \r
+ m_lpMapiLogoff(hMapiSession, NULL, 0, 0);\r
+ std::vector<MapiRecipDesc*>::iterator iter;\r
+ for (iter = buffersToFree.begin(); iter != buffersToFree.end(); iter++) {\r
+ m_lpMapiFreeBuffer(*iter);\r
+ }\r
+if (SUCCESS_SUCCESS != status) {\r
+ string txt;\r
+ TCHAR buf[MAX_PATH];\r
+ _tprintf_s(buf, "Message did not get sent due to error code %d.\r\n", status);\r
+ txt = buf;\r
+ switch (status)\r
+ { \r
+ case MAPI_E_AMBIGUOUS_RECIPIENT:\r
+ txt += "A recipient matched more than one of the recipient descriptor structures and MAPI_DIALOG was not set. No message was sent.\r\n" ;\r
+ break;\r
+ case MAPI_E_ATTACHMENT_NOT_FOUND:\r
+ txt += "The specified attachment was not found. No message was sent.\r\n" ;\r
+ break;\r
+ case MAPI_E_ATTACHMENT_OPEN_FAILURE:\r
+ txt += "The specified attachment could not be opened. No message was sent.\r\n" ;\r
+ break;\r
+ case MAPI_E_BAD_RECIPTYPE:\r
+ txt += "The type of a recipient was not MAPI_TO, MAPI_CC, or MAPI_BCC. No message was sent.\r\n" ;\r
+ break;\r
+ case MAPI_E_FAILURE:\r
+ txt += "One or more unspecified errors occurred. No message was sent.\r\n" ;\r
+ break;\r
+ case MAPI_E_INSUFFICIENT_MEMORY:\r
+ txt += "There was insufficient memory to proceed. No message was sent.\r\n" ;\r
+ break;\r
+ case MAPI_E_INVALID_RECIPS:\r
+ txt += "One or more recipients were invalid or did not resolve to any address.\r\n" ;\r
+ break;\r
+ case MAPI_E_LOGIN_FAILURE:\r
+ txt += "There was no default logon, and the user failed to log on successfully when the logon dialog box was displayed. No message was sent.\r\n" ;\r
+ break;\r
+ case MAPI_E_TEXT_TOO_LARGE:\r
+ txt += "The text in the message was too large. No message was sent.\r\n" ;\r
+ break;\r
+ case MAPI_E_TOO_MANY_FILES:\r
+ txt += "There were too many file attachments. No message was sent.\r\n" ;\r
+ break;\r
+ case MAPI_E_TOO_MANY_RECIPIENTS:\r
+ txt += "There were too many recipients. No message was sent.\r\n" ;\r
+ break;\r
+ case MAPI_E_UNKNOWN_RECIPIENT:\r
+ txt += "A recipient did not appear in the address list. No message was sent.\r\n" ;\r
+ break;\r
+ case MAPI_E_USER_ABORT:\r
+ txt += "The user canceled one of the dialog boxes. No message was sent.\r\n" ;\r
+ break;\r
+ default:\r
+ txt += "Unknown error code.\r\n" ;\r
+ break;\r
+ }\r
+ ::MessageBox(0, txt.c_str(), "Error", MB_OK);\r
+}\r
+\r
+ if (pRecipients)\r
+ delete [] pRecipients;\r
+\r
+ if (nAttachments)\r
+ delete [] pAttachments;\r
+ }\r
+\r
+ if (SUCCESS_SUCCESS == status)\r
+ return 1;\r
+ if (MAPI_E_USER_ABORT == status)\r
+ return -1;\r
+ // other failure\r
+ return 0;\r
+}\r
+\r
+BOOL CMailMsg::CMCSend()\r
+{\r
+ TStrStrVector::iterator p;\r
+ int nIndex = 0;\r
+ CMC_recipient* pRecipients;\r
+ CMC_attachment* pAttachments;\r
+ CMC_session_id session;\r
+ CMC_return_code status = 0;\r
+ CMC_message message;\r
+ CMC_boolean bAvailable = FALSE;\r
+ CMC_time t_now = {0};\r
+\r
+ if (m_bReady || Initialize())\r
+ {\r
+ pRecipients = new CMC_recipient[m_to.size() + m_cc.size() + m_bcc.size() + m_from.size()];\r
+ pAttachments = new CMC_attachment[m_attachments.size()];\r
+\r
+ // set cc's\r
+ for (p = m_cc.begin(); p != m_cc.end(); p++, nIndex++)\r
+ {\r
+ pRecipients[nIndex].name = (LPTSTR)(LPCTSTR)p->second.c_str();\r
+ pRecipients[nIndex].name_type = CMC_TYPE_INDIVIDUAL;\r
+ pRecipients[nIndex].address = (LPTSTR)(LPCTSTR)p->first.c_str();\r
+ pRecipients[nIndex].role = CMC_ROLE_CC;\r
+ pRecipients[nIndex].recip_flags = 0;\r
+ pRecipients[nIndex].recip_extensions = NULL;\r
+ }\r
+ \r
+ // set bcc\r
+ for (p = m_bcc.begin(); p != m_bcc.end(); p++, nIndex++)\r
+ {\r
+ pRecipients[nIndex].name = (LPTSTR)(LPCTSTR)p->second.c_str();\r
+ pRecipients[nIndex].name_type = CMC_TYPE_INDIVIDUAL;\r
+ pRecipients[nIndex].address = (LPTSTR)(LPCTSTR)p->first.c_str();\r
+ pRecipients[nIndex].role = CMC_ROLE_BCC;\r
+ pRecipients[nIndex].recip_flags = 0;\r
+ pRecipients[nIndex].recip_extensions = NULL;\r
+ }\r
+ \r
+ // set to\r
+ pRecipients[nIndex].name = (LPTSTR)(LPCTSTR)m_to.begin()->second.c_str();\r
+ pRecipients[nIndex].name_type = CMC_TYPE_INDIVIDUAL;\r
+ pRecipients[nIndex].address = (LPTSTR)(LPCTSTR)m_to.begin()->first.c_str();\r
+ pRecipients[nIndex].role = CMC_ROLE_TO;\r
+ pRecipients[nIndex].recip_flags = 0;\r
+ pRecipients[nIndex].recip_extensions = NULL;\r
+ \r
+ // set from\r
+ pRecipients[nIndex+1].name = (LPTSTR)(LPCTSTR)m_from.begin()->second.c_str();\r
+ pRecipients[nIndex+1].name_type = CMC_TYPE_INDIVIDUAL;\r
+ pRecipients[nIndex+1].address = (LPTSTR)(LPCTSTR)m_from.begin()->first.c_str();\r
+ pRecipients[nIndex+1].role = CMC_ROLE_ORIGINATOR;\r
+ pRecipients[nIndex+1].recip_flags = CMC_RECIP_LAST_ELEMENT;\r
+ pRecipients[nIndex+1].recip_extensions = NULL;\r
+ \r
+ // add attachments\r
+ for (p = m_attachments.begin(), nIndex = 0;\r
+ p != m_attachments.end(); p++, nIndex++)\r
+ {\r
+ pAttachments[nIndex].attach_title = (LPTSTR)(LPCTSTR)p->second.c_str();\r
+ pAttachments[nIndex].attach_type = NULL;\r
+ pAttachments[nIndex].attach_filename = (LPTSTR)(LPCTSTR)p->first.c_str();\r
+ pAttachments[nIndex].attach_flags = 0;\r
+ pAttachments[nIndex].attach_extensions = NULL;\r
+ }\r
+ pAttachments[nIndex-1].attach_flags = CMC_ATT_LAST_ELEMENT;\r
+\r
+ message.message_reference = NULL;\r
+ message.message_type = NULL;\r
+ if (m_sSubject.empty())\r
+ message.subject = "No Subject";\r
+ else\r
+ message.subject = (LPTSTR)(LPCTSTR)m_sSubject.c_str();\r
+ message.time_sent = t_now;\r
+ if (m_sMessage.empty())\r
+ message.text_note = "No Body";\r
+ else\r
+ message.text_note = (LPTSTR)(LPCTSTR)m_sMessage.c_str();\r
+ message.recipients = pRecipients;\r
+ message.attachments = pAttachments;\r
+ message.message_flags = 0;\r
+ message.message_extensions = NULL;\r
+\r
+ status = m_lpCmcQueryConfiguration(\r
+ 0, \r
+ CMC_CONFIG_UI_AVAIL, \r
+ (void*)&bAvailable, \r
+ NULL\r
+ );\r
+\r
+ if (CMC_SUCCESS == status && bAvailable)\r
+ {\r
+ status = m_lpCmcLogon(\r
+ NULL,\r
+ NULL,\r
+ NULL,\r
+ NULL,\r
+ 0,\r
+ CMC_VERSION,\r
+ CMC_LOGON_UI_ALLOWED |\r
+ CMC_ERROR_UI_ALLOWED,\r
+ &session,\r
+ NULL\r
+ );\r
+\r
+ if (CMC_SUCCESS == status)\r
+ {\r
+ status = m_lpCmcSend(session, &message, 0, 0, NULL);\r
+\r
+ m_lpCmcLogoff(session, NULL, CMC_LOGON_UI_ALLOWED, NULL);\r
+ }\r
+ }\r
+\r
+ delete [] pRecipients;\r
+ delete [] pAttachments;\r
+ }\r
+\r
+ return ((CMC_SUCCESS == status) && bAvailable);\r
+}\r
+\r
+BOOL CMailMsg::Initialize()\r
+{\r
+ m_hMapi = ::LoadLibrary(_T("mapi32.dll"));\r
+ \r
+ if (!m_hMapi)\r
+ return FALSE;\r
+\r
+ m_lpCmcQueryConfiguration = (LPCMCQUERY)::GetProcAddress(m_hMapi, _T("cmc_query_configuration"));\r
+ m_lpCmcLogon = (LPCMCLOGON)::GetProcAddress(m_hMapi, _T("cmc_logon"));\r
+ m_lpCmcSend = (LPCMCSEND)::GetProcAddress(m_hMapi, _T("cmc_send"));\r
+ m_lpCmcLogoff = (LPCMCLOGOFF)::GetProcAddress(m_hMapi, _T("cmc_logoff"));\r
+ m_lpMapiLogon = (LPMAPILOGON)::GetProcAddress(m_hMapi, _T("MAPILogon"));\r
+ m_lpMapiSendMail = (LPMAPISENDMAIL)::GetProcAddress(m_hMapi, _T("MAPISendMail"));\r
+ m_lpMapiLogoff = (LPMAPILOGOFF)::GetProcAddress(m_hMapi, _T("MAPILogoff"));\r
+ m_lpMapiResolveName = (LPMAPIRESOLVENAME) GetProcAddress(m_hMapi, _T("MAPIResolveName"));\r
+ m_lpMapiFreeBuffer = (LPMAPIFREEBUFFER) GetProcAddress(m_hMapi, _T("MAPIFreeBuffer"));\r
+\r
+ m_bReady = (m_lpCmcLogon && m_lpCmcSend && m_lpCmcLogoff) ||\r
+ (m_lpMapiLogon && m_lpMapiSendMail && m_lpMapiLogoff);\r
+\r
+ return m_bReady;\r
+}\r
+\r
+void CMailMsg::Uninitialize()\r
+{\r
+ ::FreeLibrary(m_hMapi);\r
+}
\ No newline at end of file
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Module: MailMsg.h\r
+//\r
+// Desc: This class encapsulates the MAPI and CMC mail functions.\r
+//\r
+// Copyright (c) 2003 Michael Carruth\r
+//\r
+///////////////////////////////////////////////////////////////////////////////\r
+\r
+#pragma once\r
+\r
+#include <xcmc.h> // CMC function defs\r
+#include <mapi.h> // MAPI function defs\r
+\r
+#ifndef TStrStrVector\r
+// STL generates various warnings.\r
+// 4100: unreferenced formal parameter\r
+// 4663: C++ language change: to explicitly specialize class template...\r
+// 4018: signed/unsigned mismatch\r
+// 4245: conversion from <a> to <b>: signed/unsigned mismatch\r
+#pragma warning(push, 3)\r
+#pragma warning(disable: 4100)\r
+#pragma warning(disable: 4663)\r
+#pragma warning(disable: 4018)\r
+#pragma warning(disable: 4245)\r
+#include <vector>\r
+#pragma warning(pop)\r
+\r
+typedef std::pair<string,string> TStrStrPair;\r
+typedef std::vector<TStrStrPair> TStrStrVector;\r
+#endif // !defined TStrStrVector\r
+\r
+//\r
+// Define CMC entry points\r
+//\r
+typedef CMC_return_code (FAR PASCAL *LPCMCLOGON) \\r
+ (CMC_string, CMC_string, CMC_string, CMC_object_identifier, \\r
+ CMC_ui_id, CMC_uint16, CMC_flags, CMC_session_id FAR*, \\r
+ CMC_extension FAR*);\r
+\r
+typedef CMC_return_code (FAR PASCAL *LPCMCSEND) \\r
+ (CMC_session_id, CMC_message FAR*, CMC_flags, \\r
+ CMC_ui_id, CMC_extension FAR*);\r
+\r
+typedef CMC_return_code (FAR PASCAL *LPCMCLOGOFF) \\r
+ (CMC_session_id, CMC_ui_id, CMC_flags, CMC_extension FAR*);\r
+\r
+typedef CMC_return_code (FAR PASCAL *LPCMCQUERY) \\r
+ (CMC_session_id, CMC_enum, CMC_buffer, CMC_extension FAR*);\r
+\r
+\r
+////////////////////////////// Class Definitions /////////////////////////////\r
+\r
+// ===========================================================================\r
+// CMailMsg\r
+// \r
+// See the module comment at top of file.\r
+//\r
+class CMailMsg \r
+{\r
+public:\r
+ CMailMsg();\r
+ virtual ~CMailMsg();\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // SetTo\r
+ // Sets the Email:To address\r
+ //\r
+ // Parameters\r
+ // sAddress Address\r
+ // sName Optional name\r
+ //\r
+ // Return Values\r
+ // CMailMsg reference\r
+ //\r
+ // Remarks\r
+ // Only one To address can be set. If called more than once\r
+ // the last address will be used.\r
+ //\r
+ CMailMsg& \r
+ SetTo(\r
+ string sAddress, \r
+ string sName = _T("")\r
+ );\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // SetCc\r
+ // Sets the Email:Cc address\r
+ //\r
+ // Parameters\r
+ // sAddress Address\r
+ // sName Optional name\r
+ //\r
+ // Return Values\r
+ // CMailMsg reference\r
+ //\r
+ // Remarks\r
+ // Multiple Cc addresses can be set.\r
+ //\r
+ CMailMsg& \r
+ SetCc(\r
+ string sAddress, \r
+ string sName = _T("")\r
+ );\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // SetBc\r
+ // Sets the Email:Bcc address\r
+ //\r
+ // Parameters\r
+ // sAddress Address\r
+ // sName Optional name\r
+ //\r
+ // Return Values\r
+ // CMailMsg reference\r
+ //\r
+ // Remarks\r
+ // Multiple Bcc addresses can be set.\r
+ //\r
+ CMailMsg& \r
+ SetBc(\r
+ string sAddress, \r
+ string sName = _T("")\r
+ );\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // SetFrom\r
+ // Sets the Email:From address\r
+ //\r
+ // Parameters\r
+ // sAddress Address\r
+ // sName Optional name\r
+ //\r
+ // Return Values\r
+ // CMailMsg reference\r
+ //\r
+ // Remarks\r
+ // Only one From address can be set. If called more than once\r
+ // the last address will be used.\r
+ //\r
+ CMailMsg& \r
+ SetFrom(\r
+ string sAddress, \r
+ string sName = _T("")\r
+ );\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // SetSubect\r
+ // Sets the Email:Subject\r
+ //\r
+ // Parameters\r
+ // sSubject Subject\r
+ //\r
+ // Return Values\r
+ // CMailMsg reference\r
+ //\r
+ // Remarks\r
+ // none\r
+ //\r
+ CMailMsg& \r
+ SetSubject(\r
+ string sSubject\r
+ ) {m_sSubject = sSubject; return *this;};\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // SetMessage\r
+ // Sets the Email message body\r
+ //\r
+ // Parameters\r
+ // sMessage Message body\r
+ //\r
+ // Return Values\r
+ // CMailMsg reference\r
+ //\r
+ // Remarks\r
+ // none\r
+ //\r
+ CMailMsg& \r
+ SetMessage(\r
+ string sMessage\r
+ ) {m_sMessage = sMessage; return *this;};\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // AddAttachment\r
+ // Attaches a file to the email\r
+ //\r
+ // Parameters\r
+ // sAttachment Fully qualified file name\r
+ // sTitle File display name\r
+ //\r
+ // Return Values\r
+ // CMailMsg reference\r
+ //\r
+ // Remarks\r
+ // none\r
+ //\r
+ CMailMsg& \r
+ AddAttachment(\r
+ string sAttachment, \r
+ string sTitle = _T("")\r
+ );\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // Send\r
+ // Send the email.\r
+ //\r
+ // Parameters\r
+ // none\r
+ //\r
+ // Return Values\r
+ // TRUE if successful\r
+ //\r
+ // Remarks\r
+ // First simple MAPI is used if unsuccessful CMC is used.\r
+ //\r
+ BOOL Send();\r
+\r
+protected:\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // CMCSend\r
+ // Send email using CMC functions.\r
+ //\r
+ // Parameters\r
+ // none\r
+ //\r
+ // Return Values\r
+ // TRUE if successful\r
+ //\r
+ // Remarks\r
+ // none\r
+ //\r
+ BOOL CMCSend();\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // MAPISend\r
+ // Send email using MAPI functions.\r
+ //\r
+ // Parameters\r
+ // none\r
+ //\r
+ // Return Values\r
+ // -1: cancelled; 0: other failure; 1: success\r
+ //\r
+ // Remarks\r
+ // none\r
+ //\r
+ int MAPISend();\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // Initialize\r
+ // Initialize MAPI32.dll\r
+ //\r
+ // Parameters\r
+ // none\r
+ //\r
+ // Return Values\r
+ // TRUE if successful\r
+ //\r
+ // Remarks\r
+ // none\r
+ //\r
+ BOOL Initialize();\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // Uninitialize\r
+ // Uninitialize MAPI32.dll\r
+ //\r
+ // Parameters\r
+ // none\r
+ //\r
+ // Return Values\r
+ // void\r
+ //\r
+ // Remarks\r
+ // none\r
+ //\r
+ void Uninitialize();\r
+\r
+ /*\r
+ +------------------------------------------------------------------------------\r
+ |\r
+ | Function: cResolveName()\r
+ |\r
+ | Parameters: [IN] lpszName = Name of e-mail recipient to resolve.\r
+ | [OUT] ppRecips = Pointer to a pointer to an lpMapiRecipDesc\r
+ |\r
+ | Purpose: Resolves an e-mail address and returns a pointer to a \r
+ | MapiRecipDesc structure filled with the recipient information\r
+ | contained in the address book.\r
+ |\r
+ | Note: ppRecips is allocated off the heap using MAPIAllocateBuffer.\r
+ | Any user of this method must be sure to release ppRecips when \r
+ | done with it using either MAPIFreeBuffer or cFreeBuffer.\r
+ +-------------------------------------------------------------------------------\r
+ */\r
+ int cResolveName( LHANDLE m_lhSession, const char * lpszName, lpMapiRecipDesc *ppRecip );\r
+\r
+ TStrStrVector m_from; // From <address,name>\r
+ TStrStrVector m_to; // To <address,name>\r
+ TStrStrVector m_cc; // Cc <address,name>\r
+ TStrStrVector m_bcc; // Bcc <address,name>\r
+ TStrStrVector m_attachments; // Attachment <file,title>\r
+ string m_sSubject; // EMail subject\r
+ string m_sMessage; // EMail message\r
+\r
+ HMODULE m_hMapi; // Handle to MAPI32.DLL\r
+ LPCMCQUERY m_lpCmcQueryConfiguration; // Cmc func pointer\r
+ LPCMCLOGON m_lpCmcLogon; // Cmc func pointer\r
+ LPCMCSEND m_lpCmcSend; // Cmc func pointer\r
+ LPCMCLOGOFF m_lpCmcLogoff; // Cmc func pointer\r
+ LPMAPILOGON m_lpMapiLogon; // Mapi func pointer\r
+ LPMAPISENDMAIL m_lpMapiSendMail; // Mapi func pointer\r
+ LPMAPILOGOFF m_lpMapiLogoff; // Mapi func pointer\r
+ LPMAPIRESOLVENAME m_lpMapiResolveName; // Mapi func pointer\r
+ LPMAPIFREEBUFFER m_lpMapiFreeBuffer; // Mapi func pointer\r
+ \r
+ BOOL m_bReady; // MAPI is loaded\r
+};\r
--- /dev/null
+#include "StdAfx.h"\r
+\r
+#include "MainDlg.h"\r
+#include "resource.h"\r
+\r
+CMainDlg::CMainDlg(void)\r
+{\r
+}\r
+\r
+CMainDlg::~CMainDlg(void)\r
+{\r
+}\r
+\r
+LRESULT CMainDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)\r
+{\r
+ switch (uMsg)\r
+ {\r
+ case WM_INITDIALOG:\r
+ {\r
+ InitDialog(hwndDlg, IDR_MAINFRAME);\r
+ //\r
+ // Set title using app name\r
+ //\r
+ ::SetWindowText(*this, CUtility::getAppName().c_str());\r
+ // Hide 'Send' button if required. Position 'Send' and 'Save'.\r
+ //\r
+ HWND okButton = ::GetDlgItem(*this, IDOK);\r
+ HWND saveButton = ::GetDlgItem(*this, IDC_SAVE);\r
+ if (m_sendButton) \r
+ {\r
+ // Line up Save, Send [OK] and Exit [Cancel] all in a row\r
+ HWND cancelButton = ::GetDlgItem(*this, IDCANCEL);\r
+ WINDOWPLACEMENT okPlace;\r
+ WINDOWPLACEMENT savePlace;\r
+ WINDOWPLACEMENT cancelPlace;\r
+\r
+ ::GetWindowPlacement(okButton, &okPlace);\r
+ ::GetWindowPlacement(saveButton, &savePlace);\r
+ ::GetWindowPlacement(cancelButton, &cancelPlace);\r
+\r
+ savePlace.rcNormalPosition.left =\r
+ okPlace.rcNormalPosition.left -\r
+ (savePlace.rcNormalPosition.right - savePlace.rcNormalPosition.left) +\r
+ (okPlace.rcNormalPosition.right - cancelPlace.rcNormalPosition.left);\r
+ ::SetWindowPlacement(saveButton, &savePlace);\r
+\r
+ DWORD style = ::GetWindowLong(okButton, GWL_STYLE);\r
+ ::SetWindowLong(okButton, GWL_STYLE, style | WS_VISIBLE);\r
+ } \r
+ else \r
+ {\r
+ WINDOWPLACEMENT okPlace;\r
+\r
+ // Put Save on top of the invisible Send [OK]\r
+ ::GetWindowPlacement(okButton, &okPlace);\r
+\r
+ ::SetWindowPlacement(saveButton, &okPlace);\r
+\r
+ DWORD style = ::GetWindowLong(okButton, GWL_STYLE);\r
+ ::SetWindowLong(okButton, GWL_STYLE, style & ~ WS_VISIBLE);\r
+ }\r
+ }\r
+ return TRUE;\r
+ case WM_COMMAND:\r
+ return DoCommand(LOWORD(wParam));\r
+ default:\r
+ return FALSE;\r
+ }\r
+ return TRUE;\r
+}\r
+\r
+LRESULT CMainDlg::DoCommand(int id)\r
+{\r
+ switch (id)\r
+ {\r
+ case IDOK: // send\r
+ {\r
+ HWND hWndEmail = ::GetDlgItem(*this, IDC_EMAIL);\r
+ HWND hWndDesc = ::GetDlgItem(*this, IDC_DESCRIPTION);\r
+ int nEmailLen = ::GetWindowTextLength(hWndEmail) + 1;\r
+ int nDescLen = ::GetWindowTextLength(hWndDesc) + 1;\r
+\r
+ TCHAR * lpStr = new TCHAR[nEmailLen+1];\r
+ ::GetWindowText(hWndEmail, lpStr, nEmailLen);\r
+ m_sEmail = lpStr;\r
+ delete [] lpStr;\r
+\r
+ lpStr = new TCHAR[nDescLen+1];\r
+ ::GetWindowText(hWndDesc, lpStr, nDescLen);\r
+ m_sDescription = lpStr;\r
+ delete [] lpStr;\r
+ }\r
+ EndDialog(*this, IDOK);\r
+ return 0;\r
+ break;\r
+ case IDC_SAVE:\r
+ EndDialog(*this, IDC_SAVE);\r
+ return 0;\r
+ break;\r
+ case IDCANCEL:\r
+ EndDialog(*this, IDCANCEL);\r
+ PostQuitMessage(IDCANCEL);\r
+ return 0;\r
+ break;\r
+ }\r
+ return 1;\r
+}\r
--- /dev/null
+/*----------------------------------------------------------------------\r
+ John Robbins - Microsoft Systems Journal Bugslayer Column - Feb 99\r
+----------------------------------------------------------------------*/\r
+#include <stdafx.h>\r
+\r
+#include "StackTrace.h"\r
+#include "SymbolEngine.h"\r
+\r
+// 4710: inline function not inlined\r
+#pragma warning(disable: 4710)\r
+#pragma warning(disable: 4786)\r
+#pragma warning(push, 3)\r
+#include <map>\r
+#pragma warning(pop)\r
+\r
+/*//////////////////////////////////////////////////////////////////////\r
+ File Scope Globals\r
+//////////////////////////////////////////////////////////////////////*/\r
+\r
+// The symbol engine. Indexed by process-id so there is no collision between processes.\r
+#pragma warning(push, 3)\r
+typedef std::map<DWORD, CSymbolEngine> TSymbolEngineMap;\r
+static TSymbolEngineMap g_cSymMap;\r
+#pragma warning(pop)\r
+\r
+static CSymbolEngine & GetSymbolEngine()\r
+{\r
+ DWORD CurrProcessId = GetCurrentProcessId();\r
+ TSymbolEngineMap::iterator iter;\r
+ iter = g_cSymMap.lower_bound(CurrProcessId);\r
+ if (iter == g_cSymMap.end() || iter->first != CurrProcessId) {\r
+ CSymbolEngine cSym;\r
+ HANDLE hProcess = GetCurrentProcess ( ) ;\r
+ DWORD dwOpts = SymGetOptions ( ) ;\r
+\r
+ // Turn on load lines.\r
+ SymSetOptions ( dwOpts |\r
+ SYMOPT_LOAD_LINES ) ;\r
+ iter = g_cSymMap.insert(iter, std::make_pair(CurrProcessId, CSymbolEngine()));\r
+ if ( FALSE == iter->second.SymInitialize ( hProcess ,\r
+ NULL ,\r
+ TRUE ) )\r
+ {\r
+ OutputDebugString ( "DiagAssert : Unable to initialize the "\r
+ "symbol engine!!!\n" ) ;\r
+\r
+#ifdef _DEBUG\r
+ DebugBreak ( ) ;\r
+#endif\r
+ }\r
+ }\r
+ return iter->second;\r
+}\r
+\r
+static DWORD_PTR __stdcall GetModBase ( HANDLE hProcess , DWORD_PTR dwAddr )\r
+{\r
+ // Check in the symbol engine first.\r
+ IMAGEHLP_MODULE stIHM ;\r
+ CSymbolEngine & cSym = GetSymbolEngine();\r
+ // This is what the MFC stack trace routines forgot to do so their\r
+ // code will not get the info out of the symbol engine.\r
+ stIHM.SizeOfStruct = sizeof ( IMAGEHLP_MODULE ) ;\r
+\r
+ if ( cSym.SymGetModuleInfo ( dwAddr , &stIHM ) )\r
+ {\r
+ return ( stIHM.BaseOfImage ) ;\r
+ }\r
+ else\r
+ {\r
+ // Let's go fishing.\r
+ MEMORY_BASIC_INFORMATION stMBI ;\r
+\r
+ if ( 0 != VirtualQueryEx ( hProcess ,\r
+ (LPCVOID)dwAddr ,\r
+ &stMBI ,\r
+ sizeof ( stMBI ) ) )\r
+ {\r
+ // Try and load it.\r
+ DWORD dwNameLen = 0 ;\r
+ TCHAR szFile[ MAX_PATH ] ;\r
+ szFile[0] = '\0';\r
+ dwNameLen = GetModuleFileName ( (HINSTANCE)\r
+ stMBI.AllocationBase ,\r
+ szFile ,\r
+ MAX_PATH );\r
+ HANDLE hFile = NULL ;\r
+\r
+ if ( 0 != dwNameLen )\r
+ {\r
+ hFile = CreateFile ( szFile ,\r
+ GENERIC_READ ,\r
+ FILE_SHARE_READ ,\r
+ NULL ,\r
+ OPEN_EXISTING ,\r
+ 0 ,\r
+ 0 ) ;\r
+ }\r
+#ifdef NOTDEF_DEBUG\r
+ DWORD dwRet =\r
+#endif\r
+ cSym.SymLoadModule ( hFile ,\r
+ ( dwNameLen ? szFile : NULL ) ,\r
+ NULL ,\r
+ (DWORD)stMBI.AllocationBase ,\r
+ 0 );\r
+ ::CloseHandle(hFile);\r
+ \r
+#ifdef NOTDEF_DEBUG\r
+ if ( 0 == dwRet )\r
+ {\r
+ ATLTRACE ( "SymLoadModule failed : 0x%08X\n" ,\r
+ GetLastError ( ) ) ;\r
+ }\r
+#endif // _DEBUG\r
+ return ( (DWORD)stMBI.AllocationBase ) ;\r
+ }\r
+ }\r
+ return ( 0 ) ;\r
+}\r
+\r
+static void PrintAddress (DWORD_PTR address, const char *ImageName,\r
+ const char *FunctionName, DWORD_PTR functionDisp,\r
+ const char *Filename, DWORD LineNumber, DWORD lineDisp,\r
+ void * /* data, unused */ )\r
+{\r
+ static char buffer [ MAX_PATH*2 + 512 ];\r
+ LPTSTR pCurrPos = buffer ;\r
+ // Always stick the address in first.\r
+ pCurrPos += _snprintf ( pCurrPos , sizeof buffer - (pCurrPos - buffer), addressFormat , address ) ;\r
+\r
+ if (ImageName != NULL) {\r
+ LPCTSTR szName = strchr ( ImageName , ( '\\' ) ) ;\r
+ if ( NULL != szName ) {\r
+ szName++ ;\r
+ } else {\r
+ szName = const_cast<char *>(ImageName) ;\r
+ }\r
+ pCurrPos += _snprintf ( pCurrPos , sizeof buffer - (pCurrPos - buffer), ( "%s: " ) , szName ) ;\r
+ } else {\r
+ pCurrPos += _snprintf ( pCurrPos , sizeof buffer - (pCurrPos - buffer), ( "<unknown module>: " ) );\r
+ }\r
+ if (FunctionName != NULL) {\r
+ if ( 0 == functionDisp ) {\r
+ pCurrPos += _snprintf ( pCurrPos , sizeof buffer - (pCurrPos - buffer), ( "%s" ) , FunctionName);\r
+ } else {\r
+ pCurrPos += _snprintf ( pCurrPos , sizeof buffer - (pCurrPos - buffer), \r
+ ( "%s + %d bytes" ) ,\r
+ FunctionName ,\r
+ functionDisp ) ;\r
+ }\r
+ if (Filename != NULL) {\r
+ // Put this on the next line and indented a bit.\r
+ pCurrPos += _snprintf( pCurrPos, sizeof buffer - (pCurrPos - buffer), "-\n");\r
+ OutputDebugString(buffer);\r
+ pCurrPos = buffer;\r
+ pCurrPos += _snprintf ( pCurrPos , sizeof buffer - (pCurrPos - buffer), \r
+ ( "\t\t%s, Line %d" ) ,\r
+ Filename ,\r
+ LineNumber ) ;\r
+ if ( 0 != lineDisp )\r
+ {\r
+ pCurrPos += _snprintf ( pCurrPos , sizeof buffer - (pCurrPos - buffer), \r
+ ( " + %d bytes" ) ,\r
+ lineDisp ) ;\r
+ }\r
+ }\r
+ } else {\r
+ pCurrPos += _snprintf ( pCurrPos , sizeof buffer - (pCurrPos - buffer), ( "<unknown symbol>" ) ) ;\r
+ }\r
+ // Tack on a CRLF.\r
+ pCurrPos += _snprintf ( pCurrPos , sizeof buffer - (pCurrPos - buffer), ( "\n" ) ) ;\r
+ OutputDebugString ( buffer );\r
+}\r
+\r
+\r
+void AddressToSymbol(DWORD_PTR dwAddr, TraceCallbackFunction pFunction, LPVOID data)\r
+{\r
+ char szTemp [ MAX_PATH + sizeof ( IMAGEHLP_SYMBOL ) ] ;\r
+\r
+ PIMAGEHLP_SYMBOL pIHS = (PIMAGEHLP_SYMBOL)&szTemp ;\r
+\r
+ IMAGEHLP_MODULE stIHM ;\r
+ IMAGEHLP_LINE stIHL ;\r
+\r
+ bool haveModule = false;\r
+ bool haveFunction = false;\r
+ bool haveLine = false;\r
+\r
+ CSymbolEngine & cSym = GetSymbolEngine();\r
+\r
+ SecureZeroMemory ( pIHS , MAX_PATH + sizeof ( IMAGEHLP_SYMBOL ) ) ;\r
+ SecureZeroMemory ( &stIHM , sizeof ( IMAGEHLP_MODULE ) ) ;\r
+ SecureZeroMemory ( &stIHL , sizeof ( IMAGEHLP_LINE ) ) ;\r
+\r
+ pIHS->SizeOfStruct = sizeof ( IMAGEHLP_SYMBOL ) ;\r
+ pIHS->Address = dwAddr ;\r
+ pIHS->MaxNameLength = MAX_PATH ;\r
+\r
+ stIHM.SizeOfStruct = sizeof ( IMAGEHLP_MODULE ) ;\r
+\r
+\r
+ // Get the module name.\r
+ haveModule = (0 != cSym.SymGetModuleInfo ( dwAddr , &stIHM ));\r
+\r
+ // Get the function.\r
+ DWORD_PTR dwFuncDisp=0 ;\r
+ DWORD dwLineDisp=0;\r
+ if ( 0 != cSym.SymGetSymFromAddr ( dwAddr , &dwFuncDisp , pIHS ) )\r
+ {\r
+ haveFunction = true;\r
+\r
+\r
+ // If I got a symbol, give the source and line a whirl.\r
+\r
+\r
+ stIHL.SizeOfStruct = sizeof ( IMAGEHLP_LINE ) ;\r
+\r
+ haveLine = 0 != cSym.SymGetLineFromAddr ( dwAddr ,\r
+ &dwLineDisp ,\r
+ &stIHL );\r
+ }\r
+ if (pFunction != NULL) {\r
+\r
+ pFunction(dwAddr, haveModule ? stIHM.ImageName : NULL,\r
+ haveFunction ? pIHS->Name : NULL, dwFuncDisp,\r
+ haveLine ? stIHL.FileName : NULL, haveLine ? stIHL.LineNumber : 0, dwLineDisp,\r
+ data);\r
+ }\r
+}\r
+\r
+void DoStackTrace ( int numSkip, int depth, TraceCallbackFunction pFunction, CONTEXT *pContext, LPVOID data )\r
+{\r
+ HANDLE hProcess = GetCurrentProcess ( ) ;\r
+\r
+ if (pFunction == NULL) {\r
+ pFunction = PrintAddress;\r
+ }\r
+\r
+ // The symbol engine is initialized so do the stack walk.\r
+\r
+ // The thread information - if not supplied.\r
+ CONTEXT stCtx ;\r
+ if (pContext == NULL) {\r
+\r
+ stCtx.ContextFlags = CONTEXT_FULL ;\r
+\r
+ if ( GetThreadContext ( GetCurrentThread ( ) , &stCtx ) )\r
+ {\r
+ pContext = &stCtx;\r
+ }\r
+ }\r
+ if (pContext != NULL) {\r
+ STACKFRAME stFrame ;\r
+ DWORD dwMachine ;\r
+\r
+ SecureZeroMemory ( &stFrame , sizeof ( STACKFRAME ) ) ;\r
+\r
+ stFrame.AddrPC.Mode = AddrModeFlat ;\r
+\r
+#if defined (_M_IX86)\r
+ dwMachine = IMAGE_FILE_MACHINE_I386 ;\r
+ stFrame.AddrPC.Offset = pContext->Eip ;\r
+ stFrame.AddrStack.Offset = pContext->Esp ;\r
+ stFrame.AddrStack.Mode = AddrModeFlat ;\r
+ stFrame.AddrFrame.Offset = pContext->Ebp ;\r
+ stFrame.AddrFrame.Mode = AddrModeFlat ;\r
+\r
+#elif defined (_M_AMD64)\r
+ dwMachine = IMAGE_FILE_MACHINE_AMD64 ;\r
+ stFrame.AddrPC.Offset = pContext->Rip ;\r
+ stFrame.AddrStack.Offset = pContext->Rsp ;\r
+ stFrame.AddrStack.Mode = AddrModeFlat ;\r
+ stFrame.AddrFrame.Offset = pContext->Rbp ;\r
+ stFrame.AddrFrame.Mode = AddrModeFlat ;\r
+\r
+#elif defined (_M_ALPHA)\r
+ dwMachine = IMAGE_FILE_MACHINE_ALPHA ;\r
+ stFrame.AddrPC.Offset = (unsigned long)pContext->Fir ;\r
+#else\r
+#error ( "Unknown machine!" )\r
+#endif\r
+\r
+ // Loop for the first <depth> stack elements.\r
+ for ( int i = 0 ; i < depth ; i++ )\r
+ {\r
+ if ( FALSE == StackWalk ( dwMachine ,\r
+ hProcess ,\r
+ //hProcess ,\r
+ GetCurrentThread(),\r
+ &stFrame ,\r
+ pContext ,\r
+ NULL ,\r
+ SymFunctionTableAccess ,\r
+ GetModBase ,\r
+ NULL ) )\r
+ {\r
+ break ;\r
+ }\r
+ if ( i >= numSkip )\r
+ {\r
+ // Also check that the address is not zero. Sometimes\r
+ // StackWalk returns TRUE with a frame of zero.\r
+ if ( 0 != stFrame.AddrPC.Offset )\r
+ {\r
+ AddressToSymbol ( stFrame.AddrPC.Offset, pFunction, data ) ;\r
+ }\r
+ }\r
+ }\r
+\r
+ }\r
+}\r
--- /dev/null
+#ifndef STACKTRACE_H\r
+#define STACKTRACE_H\r
+\r
+typedef void (*TraceCallbackFunction)(DWORD_PTR address, const char *ImageName,\r
+ const char *FunctionName, DWORD_PTR functionDisp,\r
+ const char *Filename, DWORD LineNumber, DWORD lineDisp, void *data);\r
+\r
+extern void DoStackTrace ( int numSkip, int depth=9999, TraceCallbackFunction pFunction=NULL, CONTEXT *pContext=NULL, void *data=NULL );\r
+extern void AddressToSymbol(DWORD_PTR dwAddr, TraceCallbackFunction pFunction, void *data);\r
+\r
+#endif\r
--- /dev/null
+// stdafx.cpp : source file that includes just the standard includes\r
+// CrashRpt.pch will be the pre-compiled header\r
+// stdafx.obj will contain the pre-compiled type information\r
+\r
+#include "stdafx.h"\r
+\r
+\r
+//////////////////////////////////////////////////////////////////////\r
+// how shall addresses be formatted?\r
+//////////////////////////////////////////////////////////////////////\r
+\r
+const LPCTSTR addressFormat = sizeof (void*) <= 4\r
+ ? _T("0x%08x")\r
+ : _T("0x%016x");\r
+\r
+const LPCTSTR sizeFormat = _T("0x%08x");\r
+const LPCTSTR offsetFormat = _T("0x%x");\r
+\r
--- /dev/null
+#pragma once\r
+\r
+// Change these values to use different versions\r
+#define WINVER 0x0400\r
+#define _WIN32_WINNT 0x0400\r
+#define _WIN32_IE 0x0400\r
+#include <Windows.h>\r
+#include <tchar.h>\r
+#include <oleauto.h>\r
+\r
+#include <vector>\r
+#include <map>\r
+#include <string>\r
+\r
+using namespace std;\r
+\r
+#define CRASHRPTAPI extern "C" __declspec(dllexport)\r
+//////////////////////////////////////////////////////////////////////\r
+// how shall addresses be formatted?\r
+//////////////////////////////////////////////////////////////////////\r
+\r
+extern const LPCTSTR addressFormat;\r
+extern const LPCTSTR offsetFormat;\r
+extern const LPCTSTR sizeFormat;\r
+\r
--- /dev/null
+/*----------------------------------------------------------------------\r
+"Debugging Applications" (Microsoft Press)\r
+Copyright (c) 1997-2000 John Robbins -- All rights reserved.\r
+------------------------------------------------------------------------\r
+This class is a paper-thin layer around the DBGHELP.DLL symbol engine.\r
+\r
+This class wraps only those functions that take the unique\r
+HANDLE value. Other DBGHELP.DLL symbol engine functions are global in\r
+scope, so I didn\92t wrap them with this class.\r
+\r
+------------------------------------------------------------------------\r
+Compilation Defines:\r
+\r
+DO_NOT_WORK_AROUND_SRCLINE_BUG - If defined, the class will NOT work\r
+ around the SymGetLineFromAddr bug where\r
+ PDB file lookups fail after the first\r
+ lookup.\r
+USE_BUGSLAYERUTIL - If defined, the class will have another\r
+ initialization method, BSUSymInitialize, which will\r
+ use BSUSymInitialize from BUGSLAYERUTIL.DLL to\r
+ initialize the symbol engine and allow the invade\r
+ process flag to work for all Win32 operating systems.\r
+ If you use this define, you must use\r
+ BUGSLAYERUTIL.H to include this file.\r
+----------------------------------------------------------------------*/\r
+\r
+#ifndef _SYMBOLENGINE_H\r
+#define _SYMBOLENGINE_H\r
+\r
+// You could include either IMAGEHLP.DLL or DBGHELP.DLL.\r
+#include "imagehlp.h"\r
+#include <tchar.h>\r
+\r
+// Include these in case the user forgets to link against them.\r
+#pragma comment (lib,"dbghelp.lib")\r
+#pragma comment (lib,"version.lib")\r
+\r
+// The great Bugslayer idea of creating wrapper classes on structures\r
+// that have size fields came from fellow MSJ columnist, Paul DiLascia.\r
+// Thanks, Paul!\r
+\r
+// I didn\92t wrap IMAGEHLP_SYMBOL because that is a variable-size\r
+// structure.\r
+\r
+// The IMAGEHLP_MODULE wrapper class\r
+struct CImageHlp_Module : public IMAGEHLP_MODULE\r
+{\r
+ CImageHlp_Module ( )\r
+ {\r
+ memset ( this , NULL , sizeof ( IMAGEHLP_MODULE ) ) ;\r
+ SizeOfStruct = sizeof ( IMAGEHLP_MODULE ) ;\r
+ }\r
+} ;\r
+\r
+// The IMAGEHLP_LINE wrapper class\r
+struct CImageHlp_Line : public IMAGEHLP_LINE\r
+{\r
+ CImageHlp_Line ( )\r
+ {\r
+ memset ( this , NULL , sizeof ( IMAGEHLP_LINE ) ) ;\r
+ SizeOfStruct = sizeof ( IMAGEHLP_LINE ) ;\r
+ }\r
+} ;\r
+\r
+// The symbol engine class\r
+class CSymbolEngine\r
+{\r
+/*----------------------------------------------------------------------\r
+ Public Construction and Destruction\r
+----------------------------------------------------------------------*/\r
+public :\r
+ // To use this class, call the SymInitialize member function to\r
+ // initialize the symbol engine and then use the other member\r
+ // functions in place of their corresponding DBGHELP.DLL functions.\r
+ CSymbolEngine ( void )\r
+ {\r
+ }\r
+\r
+ virtual ~CSymbolEngine ( void )\r
+ {\r
+ }\r
+\r
+/*----------------------------------------------------------------------\r
+ Public Helper Information Functions\r
+----------------------------------------------------------------------*/\r
+public :\r
+\r
+ // Returns the file version of DBGHELP.DLL being used.\r
+ // To convert the return values into a readable format:\r
+ // wsprintf ( szVer ,\r
+ // ( "%d.%02d.%d.%d" ) ,\r
+ // HIWORD ( dwMS ) ,\r
+ // LOWORD ( dwMS ) ,\r
+ // HIWORD ( dwLS ) ,\r
+ // LOWORD ( dwLS ) ) ;\r
+ // szVer will contain a string like: 5.00.1878.1\r
+ BOOL GetImageHlpVersion ( DWORD & dwMS , DWORD & dwLS )\r
+ {\r
+ return( GetInMemoryFileVersion ( ( "DBGHELP.DLL" ) ,\r
+ dwMS ,\r
+ dwLS ) ) ;\r
+ }\r
+\r
+ BOOL GetDbgHelpVersion ( DWORD & dwMS , DWORD & dwLS )\r
+ {\r
+ return( GetInMemoryFileVersion ( ( "DBGHELP.DLL" ) ,\r
+ dwMS ,\r
+ dwLS ) ) ;\r
+ }\r
+\r
+ // Returns the file version of the PDB reading DLLs\r
+ BOOL GetPDBReaderVersion ( DWORD & dwMS , DWORD & dwLS )\r
+ {\r
+ // First try MSDBI.DLL.\r
+ if ( TRUE == GetInMemoryFileVersion ( ( "MSDBI.DLL" ) ,\r
+ dwMS ,\r
+ dwLS ) )\r
+ {\r
+ return ( TRUE ) ;\r
+ }\r
+ else if ( TRUE == GetInMemoryFileVersion ( ( "MSPDB60.DLL" ),\r
+ dwMS ,\r
+ dwLS ))\r
+ {\r
+ return ( TRUE ) ;\r
+ }\r
+ // Just fall down to MSPDB50.DLL.\r
+ return ( GetInMemoryFileVersion ( ( "MSPDB50.DLL" ) ,\r
+ dwMS ,\r
+ dwLS ) ) ;\r
+ }\r
+\r
+ // The worker function used by the previous two functions\r
+ BOOL GetInMemoryFileVersion ( LPCTSTR szFile ,\r
+ DWORD & dwMS ,\r
+ DWORD & dwLS )\r
+ {\r
+ HMODULE hInstIH = GetModuleHandle ( szFile ) ;\r
+\r
+ // Get the full filename of the loaded version.\r
+ TCHAR szImageHlp[ MAX_PATH ] ;\r
+ GetModuleFileName ( hInstIH , szImageHlp , MAX_PATH ) ;\r
+\r
+ dwMS = 0 ;\r
+ dwLS = 0 ;\r
+\r
+ // Get the version information size.\r
+ DWORD dwVerInfoHandle ;\r
+ DWORD dwVerSize ;\r
+\r
+ dwVerSize = GetFileVersionInfoSize ( szImageHlp ,\r
+ &dwVerInfoHandle ) ;\r
+ if ( 0 == dwVerSize )\r
+ {\r
+ return ( FALSE ) ;\r
+ }\r
+\r
+ // Got the version size, now get the version information.\r
+ LPVOID lpData = (LPVOID)new TCHAR [ dwVerSize ] ;\r
+ if ( FALSE == GetFileVersionInfo ( szImageHlp ,\r
+ dwVerInfoHandle ,\r
+ dwVerSize ,\r
+ lpData ) )\r
+ {\r
+ delete [] lpData ;\r
+ return ( FALSE ) ;\r
+ }\r
+\r
+ VS_FIXEDFILEINFO * lpVerInfo ;\r
+ UINT uiLen ;\r
+ BOOL bRet = VerQueryValue ( lpData ,\r
+ ( "\\" ) ,\r
+ (LPVOID*)&lpVerInfo ,\r
+ &uiLen ) ;\r
+ if ( TRUE == bRet )\r
+ {\r
+ dwMS = lpVerInfo->dwFileVersionMS ;\r
+ dwLS = lpVerInfo->dwFileVersionLS ;\r
+ }\r
+\r
+ delete [] lpData ;\r
+\r
+ return ( bRet ) ;\r
+ }\r
+\r
+/*----------------------------------------------------------------------\r
+ Public Initialization and Cleanup\r
+----------------------------------------------------------------------*/\r
+public :\r
+\r
+ BOOL SymInitialize ( IN HANDLE hProcess ,\r
+ IN LPSTR UserSearchPath ,\r
+ IN BOOL fInvadeProcess )\r
+ {\r
+ m_hProcess = hProcess ;\r
+ return ( ::SymInitialize ( hProcess ,\r
+ UserSearchPath ,\r
+ fInvadeProcess ) ) ;\r
+ }\r
+\r
+#ifdef USE_BUGSLAYERUTIL\r
+ BOOL BSUSymInitialize ( DWORD dwPID ,\r
+ HANDLE hProcess ,\r
+ PSTR UserSearchPath ,\r
+ BOOL fInvadeProcess )\r
+ {\r
+ m_hProcess = hProcess ;\r
+ return ( ::BSUSymInitialize ( dwPID ,\r
+ hProcess ,\r
+ UserSearchPath ,\r
+ fInvadeProcess ) ) ;\r
+ }\r
+#endif // USE_BUGSLAYERUTIL\r
+ BOOL SymCleanup ( void )\r
+ {\r
+ return ( ::SymCleanup ( m_hProcess ) ) ;\r
+ }\r
+\r
+/*----------------------------------------------------------------------\r
+ Public Module Manipulation\r
+----------------------------------------------------------------------*/\r
+public :\r
+\r
+ BOOL SymEnumerateModules ( IN PSYM_ENUMMODULES_CALLBACK\r
+ EnumModulesCallback,\r
+ IN PVOID UserContext )\r
+ {\r
+ return ( ::SymEnumerateModules ( m_hProcess ,\r
+ EnumModulesCallback ,\r
+ UserContext ) ) ;\r
+ }\r
+\r
+ BOOL SymLoadModule ( IN HANDLE hFile ,\r
+ IN PSTR ImageName ,\r
+ IN PSTR ModuleName ,\r
+ IN DWORD_PTR BaseOfDll ,\r
+ IN DWORD SizeOfDll )\r
+ {\r
+ return ( ::SymLoadModule ( m_hProcess ,\r
+ hFile ,\r
+ ImageName ,\r
+ ModuleName ,\r
+ BaseOfDll ,\r
+ SizeOfDll ) != NULL) ;\r
+ }\r
+\r
+ BOOL EnumerateLoadedModules ( IN PENUMLOADED_MODULES_CALLBACK\r
+ EnumLoadedModulesCallback,\r
+ IN PVOID UserContext )\r
+ {\r
+ return ( ::EnumerateLoadedModules ( m_hProcess ,\r
+ EnumLoadedModulesCallback ,\r
+ UserContext ));\r
+ }\r
+\r
+ BOOL SymUnloadModule ( IN DWORD_PTR BaseOfDll )\r
+ {\r
+ return ( ::SymUnloadModule ( m_hProcess , BaseOfDll ) ) ;\r
+ }\r
+\r
+ BOOL SymGetModuleInfo ( IN DWORD_PTR dwAddr ,\r
+ OUT PIMAGEHLP_MODULE ModuleInfo )\r
+ {\r
+ return ( ::SymGetModuleInfo ( m_hProcess ,\r
+ dwAddr ,\r
+ ModuleInfo ) ) ;\r
+ }\r
+\r
+ DWORD SymGetModuleBase ( IN DWORD_PTR dwAddr )\r
+ {\r
+ return ( ::SymGetModuleBase ( m_hProcess , dwAddr ) != NULL ) ;\r
+ }\r
+\r
+/*----------------------------------------------------------------------\r
+ Public Symbol Manipulation\r
+----------------------------------------------------------------------*/\r
+public :\r
+\r
+ BOOL SymEnumerateSymbols (IN DWORD_PTR BaseOfDll,\r
+ IN PSYM_ENUMSYMBOLS_CALLBACK\r
+ EnumSymbolsCallback,\r
+ IN PVOID UserContext )\r
+ {\r
+ return ( ::SymEnumerateSymbols ( m_hProcess ,\r
+ BaseOfDll ,\r
+ EnumSymbolsCallback ,\r
+ UserContext ) ) ;\r
+ }\r
+\r
+ BOOL SymGetSymFromAddr ( IN DWORD_PTR dwAddr ,\r
+ OUT PDWORD_PTR pdwDisplacement ,\r
+ OUT PIMAGEHLP_SYMBOL Symbol )\r
+ {\r
+ return ( ::SymGetSymFromAddr ( m_hProcess ,\r
+ dwAddr ,\r
+ pdwDisplacement ,\r
+ Symbol ) ) ;\r
+ }\r
+\r
+ BOOL SymGetSymFromName ( IN LPSTR Name ,\r
+ OUT PIMAGEHLP_SYMBOL Symbol )\r
+ {\r
+ return ( ::SymGetSymFromName ( m_hProcess ,\r
+ Name ,\r
+ Symbol ) ) ;\r
+ }\r
+\r
+ BOOL SymGetSymNext ( IN OUT PIMAGEHLP_SYMBOL Symbol )\r
+ {\r
+ return ( ::SymGetSymNext ( m_hProcess , Symbol ) ) ;\r
+ }\r
+\r
+ BOOL SymGetSymPrev ( IN OUT PIMAGEHLP_SYMBOL Symbol )\r
+ {\r
+ return ( ::SymGetSymPrev ( m_hProcess , Symbol ) ) ;\r
+ }\r
+\r
+/*----------------------------------------------------------------------\r
+ Public Source Line Manipulation\r
+----------------------------------------------------------------------*/\r
+public :\r
+\r
+ BOOL SymGetLineFromAddr ( IN DWORD_PTR dwAddr ,\r
+ OUT PDWORD pdwDisplacement ,\r
+ OUT PIMAGEHLP_LINE Line )\r
+ {\r
+\r
+#ifdef DO_NOT_WORK_AROUND_SRCLINE_BUG\r
+ // Just pass along the values returned by the main function.\r
+ return ( ::SymGetLineFromAddr ( m_hProcess ,\r
+ dwAddr ,\r
+ pdwDisplacement ,\r
+ Line ) ) ;\r
+\r
+#else\r
+ // The problem is that the symbol engine finds only those source\r
+ // line addresses (after the first lookup) that fall exactly on\r
+ // a zero displacement. I\92ll walk backward 100 bytes to\r
+ // find the line and return the proper displacement.\r
+ DWORD dwTempDis = 0 ;\r
+ while ( FALSE == ::SymGetLineFromAddr ( m_hProcess ,\r
+ dwAddr - dwTempDis ,\r
+ pdwDisplacement ,\r
+ Line ) )\r
+ {\r
+ dwTempDis += 1 ;\r
+ if ( 100 == dwTempDis )\r
+ {\r
+ return ( FALSE ) ;\r
+ }\r
+ }\r
+ // I found it and the source line information is correct, so\r
+ // change the displacement if I had to search backward to find\r
+ // the source line.\r
+ if ( 0 != dwTempDis )\r
+ {\r
+ *pdwDisplacement = dwTempDis ;\r
+ }\r
+ return ( TRUE ) ;\r
+#endif // DO_NOT_WORK_AROUND_SRCLINE_BUG\r
+ }\r
+\r
+ BOOL SymGetLineFromName ( IN LPSTR ModuleName ,\r
+ IN LPSTR FileName ,\r
+ IN DWORD dwLineNumber ,\r
+ OUT PLONG plDisplacement ,\r
+ IN OUT PIMAGEHLP_LINE Line )\r
+ {\r
+ return ( ::SymGetLineFromName ( m_hProcess ,\r
+ ModuleName ,\r
+ FileName ,\r
+ dwLineNumber ,\r
+ plDisplacement ,\r
+ Line ) ) ;\r
+ }\r
+\r
+ BOOL SymGetLineNext ( IN OUT PIMAGEHLP_LINE Line )\r
+ {\r
+ return ( ::SymGetLineNext ( m_hProcess , Line ) ) ;\r
+ }\r
+\r
+ BOOL SymGetLinePrev ( IN OUT PIMAGEHLP_LINE Line )\r
+ {\r
+ return ( ::SymGetLinePrev ( m_hProcess , Line ) ) ;\r
+ }\r
+\r
+ BOOL SymMatchFileName ( IN LPSTR FileName ,\r
+ IN LPSTR Match ,\r
+ OUT LPSTR * FileNameStop ,\r
+ OUT LPSTR * MatchStop )\r
+ {\r
+ return ( ::SymMatchFileName ( FileName ,\r
+ Match ,\r
+ FileNameStop ,\r
+ MatchStop ) ) ;\r
+ }\r
+\r
+/*----------------------------------------------------------------------\r
+ Public Miscellaneous Members\r
+----------------------------------------------------------------------*/\r
+public :\r
+\r
+ LPVOID SymFunctionTableAccess ( DWORD_PTR AddrBase )\r
+ {\r
+ return ( ::SymFunctionTableAccess ( m_hProcess , AddrBase ) ) ;\r
+ }\r
+\r
+ BOOL SymGetSearchPath ( OUT LPSTR SearchPath ,\r
+ IN DWORD SearchPathLength )\r
+ {\r
+ return ( ::SymGetSearchPath ( m_hProcess ,\r
+ SearchPath ,\r
+ SearchPathLength ) ) ;\r
+ }\r
+\r
+ BOOL SymSetSearchPath ( IN LPSTR SearchPath )\r
+ {\r
+ return ( ::SymSetSearchPath ( m_hProcess , SearchPath ) ) ;\r
+ }\r
+\r
+/* BOOL SymRegisterCallback ( IN PSYMBOL_REGISTERED_CALLBACK\r
+ CallbackFunction,\r
+ IN DWORD_PTR UserContext )\r
+ {\r
+ return ( ::SymRegisterCallback ( m_hProcess ,\r
+ CallbackFunction ,\r
+ UserContext ) ) ;\r
+ }\r
+*/\r
+\r
+/*----------------------------------------------------------------------\r
+ Protected Data Members\r
+----------------------------------------------------------------------*/\r
+protected :\r
+ // The unique value that will be used for this instance of the\r
+ // symbol engine. This value doesn\92t have to be an actual\r
+ // process value, just a unique value.\r
+ HANDLE m_hProcess ;\r
+\r
+} ;\r
+\r
+#endif // _SYMBOLENGINE_H\r
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Module: Utility.cpp\r
+//\r
+// Desc: See Utility.h\r
+//\r
+// Copyright (c) 2007 TortoiseSVN\r
+// Copyright (c) 2003 Michael Carruth\r
+//\r
+///////////////////////////////////////////////////////////////////////////////\r
+\r
+#include "stdafx.h"\r
+#include "Utility.h"\r
+#include "resource.h"\r
+\r
+namespace CUtility {\r
+\r
+BSTR CUtility::AllocSysString(string s)\r
+{\r
+#if defined(_UNICODE) || defined(OLE2ANSI)\r
+ BSTR bstr = ::SysAllocStringLen(s.c_str(), s.size());\r
+#else\r
+ int nLen = MultiByteToWideChar(CP_ACP, 0, s.c_str(),\r
+ s.size(), NULL, NULL);\r
+ BSTR bstr = ::SysAllocStringLen(NULL, nLen);\r
+ if(bstr != NULL)\r
+ MultiByteToWideChar(CP_ACP, 0, s.c_str(), s.size(), bstr, nLen);\r
+#endif\r
+ return bstr;\r
+}\r
+\r
+FILETIME CUtility::getLastWriteFileTime(string sFile)\r
+{\r
+ FILETIME ftLocal = {0};\r
+ HANDLE hFind;\r
+ WIN32_FIND_DATA ff32;\r
+ hFind = FindFirstFile(sFile.c_str(), &ff32);\r
+ if (INVALID_HANDLE_VALUE != hFind)\r
+ {\r
+ FileTimeToLocalFileTime(&(ff32.ftLastWriteTime), &ftLocal);\r
+ FindClose(hFind); \r
+ }\r
+ return ftLocal;\r
+}\r
+\r
+FILETIME CUtility::getLastWriteFileTime(WCHAR * wszFile)\r
+{\r
+ FILETIME ftLocal = {0};\r
+ HANDLE hFind;\r
+ WIN32_FIND_DATAW ff32;\r
+ hFind = FindFirstFileW(wszFile, &ff32);\r
+ if (INVALID_HANDLE_VALUE != hFind)\r
+ {\r
+ FileTimeToLocalFileTime(&(ff32.ftLastWriteTime), &ftLocal);\r
+ FindClose(hFind); \r
+ }\r
+ return ftLocal;\r
+}\r
+\r
+string CUtility::getAppName()\r
+{\r
+ TCHAR szFileName[_MAX_PATH];\r
+ GetModuleFileName(NULL, szFileName, _MAX_FNAME);\r
+\r
+ string sAppName; // Extract from last '\' to '.'\r
+\r
+ *_tcsrchr(szFileName, '.') = '\0';\r
+ sAppName = (_tcsrchr(szFileName, '\\')+1);\r
+\r
+ return sAppName;\r
+}\r
+\r
+\r
+string CUtility::getTempFileName()\r
+{\r
+ static int counter = 0;\r
+ TCHAR szTempDir[MAX_PATH - 14] = _T("");\r
+ TCHAR szTempFile[MAX_PATH] = _T("");\r
+\r
+ if (GetTempPath(MAX_PATH - 14, szTempDir))\r
+ GetTempFileName(szTempDir, getAppName().c_str(), ++counter, szTempFile);\r
+\r
+ return szTempFile;\r
+}\r
+\r
+\r
+string CUtility::getSaveFileName()\r
+{\r
+ string sFilter = _T("Zip Files (*.zip)");\r
+\r
+ OPENFILENAME ofn = {0}; // common dialog box structure\r
+ TCHAR szFile[MAX_PATH] = {0}; // buffer for file name\r
+ // Initialize OPENFILENAME\r
+ ofn.lStructSize = sizeof(OPENFILENAME);\r
+ ofn.hwndOwner = NULL;\r
+ ofn.lpstrFile = szFile;\r
+ ofn.nMaxFile = sizeof(szFile)/sizeof(TCHAR);\r
+ ofn.Flags = OFN_OVERWRITEPROMPT;\r
+\r
+ ofn.lpstrFilter = sFilter.c_str();\r
+ ofn.nFilterIndex = 1;\r
+ // Display the Open dialog box. \r
+ bool bTargetSelected = !!GetSaveFileName(&ofn);\r
+\r
+ DeleteFile(ofn.lpstrFile); // Just in-case it already exist\r
+ return ofn.lpstrFile;\r
+}\r
+\r
+};\r
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Module: Utility.h\r
+//\r
+// Desc: Misc static helper methods\r
+//\r
+// Copyright (c) 2003 Michael Carruth\r
+//\r
+///////////////////////////////////////////////////////////////////////////////\r
+\r
+#pragma once\r
+\r
+#include "stdafx.h"\r
+\r
+\r
+////////////////////////////// Class Definitions /////////////////////////////\r
+\r
+// ===========================================================================\r
+// CUtility\r
+// \r
+// See the module comment at top of file.\r
+//\r
+namespace CUtility \r
+{\r
+\r
+ BSTR AllocSysString(string s);\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // getLastWriteFileTime\r
+ // Returns the time the file was last modified in a FILETIME structure.\r
+ //\r
+ // Parameters\r
+ // sFile Fully qualified file name\r
+ //\r
+ // Return Values\r
+ // FILETIME structure\r
+ //\r
+ // Remarks\r
+ //\r
+ FILETIME \r
+ getLastWriteFileTime(\r
+ string sFile\r
+ );\r
+ FILETIME\r
+ getLastWriteFileTime(\r
+ WCHAR * wszFile\r
+ );\r
+ //-----------------------------------------------------------------------------\r
+ // getAppName\r
+ // Returns the application module's file name\r
+ //\r
+ // Parameters\r
+ // none\r
+ //\r
+ // Return Values\r
+ // File name of the executable\r
+ //\r
+ // Remarks\r
+ // none\r
+ //\r
+ string \r
+ getAppName();\r
+\r
+ //-----------------------------------------------------------------------------\r
+ // getSaveFileName\r
+ // Presents the user with a save as dialog and returns the name selected.\r
+ //\r
+ // Parameters\r
+ // none\r
+ //\r
+ // Return Values\r
+ // Name of the file to save to, or "" if the user cancels.\r
+ //\r
+ // Remarks\r
+ // none\r
+ //\r
+ string \r
+ getSaveFileName();\r
+ \r
+ //-----------------------------------------------------------------------------\r
+ // getTempFileName\r
+ // Returns a generated temporary file name\r
+ //\r
+ // Parameters\r
+ // none\r
+ //\r
+ // Return Values\r
+ // Temporary file name\r
+ //\r
+ // Remarks\r
+ //\r
+ string \r
+ getTempFileName();\r
+};\r
+\r
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Module: WriteRegistry.cpp\r
+//\r
+// Desc: Functions to write a registry hive to a file.\r
+//\r
+// Copyright (c) 2003 Grant McDorman\r
+// This file is licensed using a BSD-type license:\r
+// This software is provided 'as-is', without any express or implied\r
+// warranty. In no event will the authors be held liable for any damages\r
+// arising from the use of this software.\r
+//\r
+// Permission is granted to anyone to use this software for any purpose,\r
+// including commercial applications, and to alter it and redistribute it\r
+// freely, subject to the following restrictions:\r
+//\r
+// 1. The origin of this software must not be misrepresented; you must not\r
+// claim that you wrote the original software. If you use this software\r
+// in a product, an acknowledgment in the product documentation would be\r
+// appreciated but is not required.\r
+// 2. Altered source versions must be plainly marked as such, and must not be\r
+// misrepresented as being the original software.\r
+// 3. This notice may not be removed or altered from any source distribution.\r
+//\r
+///////////////////////////////////////////////////////////////////////////////\r
+#include <StdAfx.h>\r
+\r
+#include <windows.h> // CreateFile, WriteFile, CloseHandle, DeleteFile, Reg* functions\r
+#include <stdio.h> // _snprintf\r
+\r
+#include "WriteRegistry.h"\r
+\r
+static bool WriteRegValue(HANDLE hFile, const char *key_path, const char *name, int name_len, DWORD type, const unsigned char *data, DWORD data_len);\r
+static bool WriteValuesAndSubkeys(const char *key_path, HKEY parent_key, const char *subkey, HANDLE hFile);\r
+static void WriteFileString(HANDLE hFile, const char *string);\r
+\r
+bool WriteRegistryTreeToFile(const char *key, const char *filename)\r
+{\r
+ const char *cp = strchr(key, '\\');\r
+ if (cp == NULL) {\r
+ return false;\r
+ }\r
+ ptrdiff_t len = cp - key;\r
+ HKEY hKey = 0;\r
+\r
+#define IS_PATH(id, short_id) if (strncmp(key, #id, len) == 0 || strncmp(key, #short_id, len) == 0) hKey = id\r
+ IS_PATH(HKEY_CLASSES_ROOT, HKCR);\r
+ else IS_PATH(HKEY_CURRENT_USER, HKCU);\r
+ else IS_PATH(HKEY_LOCAL_MACHINE, HKLM);\r
+ else IS_PATH(HKEY_CURRENT_CONFIG, HKCC);\r
+ else IS_PATH(HKEY_USERS, HKU);\r
+ else IS_PATH(HKEY_PERFORMANCE_DATA, HKPD);\r
+ else IS_PATH(HKEY_DYN_DATA, HKDD);\r
+ else {\r
+ return false;\r
+ }\r
+ return WriteRegistryTreeToFile(hKey, cp + 1, filename);\r
+}\r
+\r
+bool WriteRegistryTreeToFile(HKEY section, const char *subkey, const char *filename)\r
+{\r
+ bool status = false;\r
+ HANDLE hFile = ::CreateFile(\r
+ filename,\r
+ GENERIC_READ | GENERIC_WRITE,\r
+ FILE_SHARE_READ | FILE_SHARE_WRITE,\r
+ NULL,\r
+ CREATE_ALWAYS,\r
+ FILE_ATTRIBUTE_NORMAL,\r
+ 0);\r
+ if (INVALID_HANDLE_VALUE != hFile) {\r
+ char * key_path = "UNKNOWN";\r
+#define SET_PATH(id) if (id == section) key_path = #id\r
+ SET_PATH(HKEY_CLASSES_ROOT);\r
+ else SET_PATH(HKEY_CURRENT_USER);\r
+ else SET_PATH(HKEY_LOCAL_MACHINE);\r
+ else SET_PATH(HKEY_CURRENT_CONFIG);\r
+ else SET_PATH(HKEY_USERS);\r
+ else SET_PATH(HKEY_PERFORMANCE_DATA);\r
+ else SET_PATH(HKEY_DYN_DATA);\r
+ WriteFileString(hFile, "REGEDIT4\r\n");\r
+#undef SET_PATH\r
+ try {\r
+ status = WriteValuesAndSubkeys(key_path, section, subkey, hFile);\r
+ } catch (...) {\r
+ status = false;\r
+ }\r
+ CloseHandle(hFile);\r
+ if (!status) {\r
+ DeleteFile(filename);\r
+ }\r
+ }\r
+ return status;\r
+}\r
+\r
+static bool WriteValuesAndSubkeys(const char *key_path, HKEY parent_key, const char *subkey, HANDLE hFile)\r
+{\r
+ HKEY key;\r
+\r
+ if (RegOpenKeyEx(parent_key, subkey, 0, KEY_READ, &key) != ERROR_SUCCESS) {\r
+ OutputDebugString("RegOpenKeyEx failed, key:\n");\r
+ OutputDebugString(subkey);\r
+ return false;\r
+ }\r
+ DWORD num_subkeys;\r
+ DWORD max_subkey_len;\r
+ DWORD num_values;\r
+ DWORD max_name_len;\r
+ DWORD max_value_len;\r
+ DWORD max_id_len;\r
+\r
+ if (RegQueryInfoKey(key,\r
+ NULL, // class\r
+ NULL, // num_class\r
+ NULL, // reserved\r
+ &num_subkeys, &max_subkey_len,\r
+ NULL, // MaxClassLen\r
+ &num_values, &max_name_len, &max_value_len, NULL, NULL) != ERROR_SUCCESS) {\r
+ OutputDebugString("RegQueryInfoKey failed, key:\n");\r
+ OutputDebugString(subkey);\r
+ return false;\r
+ }\r
+\r
+ max_id_len = (max_name_len > max_subkey_len) ? max_name_len : max_subkey_len;\r
+ char *this_path = reinterpret_cast<char *>(alloca(strlen(key_path) + strlen(subkey) + 2));\r
+ // strcpy/strcat safe because of above alloca\r
+ strcpy(this_path, key_path);\r
+ strcat(this_path, "\\");\r
+ strcat(this_path, subkey);\r
+\r
+ WriteFileString(hFile, "\r\n[");\r
+ WriteFileString(hFile, this_path);\r
+ WriteFileString(hFile, "]\r\n");\r
+\r
+ // enumerate values\r
+ char *name = reinterpret_cast<char *>(alloca(max_id_len*2 + 2));\r
+ unsigned char *data = reinterpret_cast<unsigned char *>(alloca(max_value_len*2 + 2));\r
+ DWORD index;\r
+ bool status = true;\r
+\r
+ for (index = 0; index < num_values && status; index++) {\r
+ DWORD name_len = max_id_len + 1;\r
+ DWORD value_len = max_value_len + 1;\r
+ DWORD type;\r
+ if (RegEnumValue(key, index, name, &name_len, NULL, &type, data, &value_len) == ERROR_SUCCESS) {\r
+ status = WriteRegValue(hFile, this_path, name, name_len, type, data, value_len);\r
+ }\r
+ }\r
+\r
+ // enumerate subkeys\r
+ for (index = 0; index < num_subkeys && status; index++) {\r
+ DWORD name_len = max_id_len + 1;\r
+ if (RegEnumKeyEx(key, index, name, &name_len, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) {\r
+ status = WriteValuesAndSubkeys(this_path, key, name, hFile);\r
+ }\r
+ }\r
+\r
+ RegCloseKey(key);\r
+\r
+ return status;\r
+}\r
+\r
+static bool WriteRegValue(HANDLE hFile, const char * /*key_path*/, const char *name, int /* name_len */, DWORD type, const unsigned char *data, DWORD data_len)\r
+{\r
+ WriteFileString(hFile, "\"");\r
+ WriteFileString(hFile, name);\r
+\r
+ char string_type[64];\r
+\r
+ switch(type) {\r
+ case REG_DWORD: // A 32-bit number.\r
+ strncpy(string_type, "\"=dword:", sizeof string_type);\r
+ break;\r
+\r
+ case REG_SZ: // A null terminated string.\r
+ strncpy(string_type, "\"=\"", sizeof string_type);\r
+ break;\r
+\r
+ case REG_BINARY: // Binary data in any form.\r
+ strncpy(string_type, "\"=hex:", sizeof string_type);\r
+ break;\r
+\r
+ case REG_EXPAND_SZ: // A null-terminated string that contains unexpanded references to environment variables (for example, "%PATH%"). It will be a Unicode or ANSI string depending on whether you use the Unicode or ANSI functions. To expand the environment variable references, use the ExpandEnvironmentStrings function.\r
+ case REG_LINK: // A Unicode symbolic link. Used internally; applications should not use this type.\r
+ case REG_MULTI_SZ: // An array of null-terminated strings, terminated by two null characters. \r
+ case REG_NONE: // No defined value type.\r
+ case REG_DWORD_BIG_ENDIAN: // A 64-bit number in big-endian format.\r
+ case REG_RESOURCE_LIST: // A device-driver resource list.\r
+ default:\r
+ _snprintf(string_type, sizeof string_type, "\"=hex(%x):", type);\r
+ break;\r
+ }\r
+\r
+ WriteFileString(hFile, string_type);\r
+\r
+ if (type == REG_SZ || type == REG_EXPAND_SZ) {\r
+ // escape special characters; length includes trailing NUL\r
+ int i;\r
+ // don't crash'n'burn if data_len is 0\r
+ for (i = 0; i < static_cast<int>(data_len) - 1; i++) {\r
+ if (data[i] == '\\' || data[i] == '"') {\r
+ WriteFileString(hFile, "\\");\r
+ }\r
+ if (isprint(data[i])) {\r
+ DWORD written;\r
+ if (!WriteFile(hFile, &data[i], 1, &written, NULL) || written != 1) {\r
+ return false;\r
+ }\r
+ } else {\r
+ _snprintf(string_type, sizeof string_type, "\\%02x", data[i]);\r
+ WriteFileString(hFile, string_type);\r
+ }\r
+ }\r
+ WriteFileString(hFile, "\"");\r
+ } else if (type == REG_DWORD) {\r
+ // write as hex, MSB first\r
+ int i;\r
+ for (i = static_cast<int>(data_len) - 1; i >= 0; i--) {\r
+ _snprintf(string_type, sizeof string_type, "%02x", data[i]);\r
+ WriteFileString(hFile, string_type);\r
+ }\r
+ } else {\r
+ // write as comma-separated hex values\r
+ DWORD i;\r
+ for (i = 0; i < data_len; i++) {\r
+ _snprintf(string_type, sizeof string_type, "%s%02x", i > 0 ? "," : "", data[i]);\r
+ WriteFileString(hFile, string_type);\r
+ if (i > 0 && i % 16 == 0) {\r
+ WriteFileString(hFile, "\r\n");\r
+ }\r
+ }\r
+ }\r
+ WriteFileString(hFile, "\r\n");\r
+\r
+ return true;\r
+}\r
+\r
+ \r
+ \r
+static void WriteFileString(HANDLE hFile, const char *string)\r
+{\r
+ DWORD written;\r
+ if (!WriteFile(hFile, string, strlen(string), &written, NULL) || written != strlen(string)) {\r
+ OutputDebugString("WriteFile failed\n");\r
+ throw false;\r
+ }\r
+}\r
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Module: WriteRegistry.h\r
+//\r
+// Desc: Defines the interface for the WriteRegistry functions.\r
+//\r
+// Copyright (c) 2003 Grant McDorman\r
+// This file is licensed using a BSD-type license:\r
+// This software is provided 'as-is', without any express or implied\r
+// warranty. In no event will the authors be held liable for any damages\r
+// arising from the use of this software.\r
+//\r
+// Permission is granted to anyone to use this software for any purpose,\r
+// including commercial applications, and to alter it and redistribute it\r
+// freely, subject to the following restrictions:\r
+//\r
+// 1. The origin of this software must not be misrepresented; you must not\r
+// claim that you wrote the original software. If you use this software\r
+// in a product, an acknowledgment in the product documentation would be\r
+// appreciated but is not required.\r
+// 2. Altered source versions must be plainly marked as such, and must not be\r
+// misrepresented as being the original software.\r
+// 3. This notice may not be removed or altered from any source distribution.\r
+//\r
+///////////////////////////////////////////////////////////////////////////////\r
+\r
+#ifndef _WRITEREGISTRY_H_\r
+#define _WRITEREGISTRY_H_\r
+\r
+#if _MSC_VER >= 1000\r
+#pragma once\r
+#endif // _MSC_VER >= 1000\r
+\r
+\r
+//-----------------------------------------------------------------------------\r
+// WriteRegistryTreeToFile\r
+// Writes a registry tree to a file. Registry tree is fully specified by\r
+// the string.\r
+//\r
+// Parameters\r
+// key registry key name; must start with on of:\r
+// HKEY_CLASSES_ROOT or HKCR\r
+// HKEY_CURRENT_USER or HKCU\r
+// HKEY_LOCAL_MACHINE or HKLM\r
+// HKEY_CURRENT_CONFIG or HKCC\r
+// HKEY_USERS or HKU\r
+// HKEY_PERFORMANCE_DATA or HKPD\r
+// HKEY_DYN_DATA or HKDD\r
+// filename file to write to\r
+//\r
+// Return Values\r
+// Returns true if successful.\r
+//\r
+// Remarks\r
+// Translates call into WriteRegistryTreeToFile(section, subkey, filename).\r
+//\r
+bool WriteRegistryTreeToFile(const char *key, const char *filename);\r
+\r
+\r
+//-----------------------------------------------------------------------------\r
+// WriteRegistryTreeToFile\r
+// Writes a registry tree to a file. Registry tree is relative to given key,\r
+// which must be one of the root keys.\r
+//\r
+// Parameters\r
+// section registry section; must be one of\r
+// HKEY_CLASSES_ROOT\r
+// HKEY_CURRENT_USER\r
+// HKEY_LOCAL_MACHINE\r
+// HKEY_CURRENT_CONFIG\r
+// HKEY_USERS\r
+// HKEY_PERFORMANCE_DATA\r
+// HKEY_DYN_DATA\r
+// subkey subkey relative to section\r
+// filename file to write to\r
+//\r
+// Return Values\r
+// Returns true if successful.\r
+//\r
+// Remarks\r
+// none\r
+//\r
+bool WriteRegistryTreeToFile(HKEY section, const char *subkey, const char *filename);\r
+ \r
+\r
+#endif\r
--- /dev/null
+01/28/2007 Stefan Kueng\r
+ Major Changes:\r
+ * Remove dependency on WTL/ATL, use only Win32 API and the std lib.\r
+\r
+05/23/2003 Stefan Kueng\r
+ Major Changes:\r
+ * the zlib part now is linked statically, so no additional zlib.dll\r
+ needs to be shipped.\r
+ * added german language\r
+ Minor Changes:\r
+ * \r
+ Bugs Fixed:\r
+ * the symbol information wasn't shown sometimes (Stacktrace).\r
+ \r
+04/08/2003 Grant McDorman\r
+ Version ID: 3.0.2.3\r
+ Major Changes:\r
+ * A new header file, CrashRptDL.h, is available. It declares all the\r
+ functions with a 'DL' suffix, plus GetInstanceDL() and ReleaseInstanceDL().\r
+ All of these versions are inline functions for run-time binding to\r
+ CrashRpt; by using these, your application can run without CrashRpt\r
+ available. See the header file for more details.\r
+ * A 'Debug' button is available. It is normally invisible, but will\r
+ become visible by setting \r
+ HKEY_CURRENT_USER\Software\Carruth\CrashRpt\EnableDebug\r
+ to a DWORD value of 1. Pressing this button will discard the\r
+ crash report and drop into the debugger. (On an explicit\r
+ GenerateErrorReport call, DebugBreak() is called).\r
+ * When running under a debugger, the handler will always drop into\r
+ the debugger after handling a crash (even if the crash is saved, mailed,\r
+ or the Exit button pressed). Note that this is NOT the case\r
+ for explicit calls to GenerateErrorReport.\r
+ * The dialog now includes a 'Save' button to allow the user to\r
+ explicitly save the crash report\r
+ * The 'Send' button is hidden if the handler is installed without\r
+ an e-mail address\r
+ * APIs introduced with previous release renamed with Ex suffix\r
+ * New API: GetInstance, returns CrashRpt instance for current\r
+ process\r
+ * APIs from January 12th release reintroduced; minor changes to\r
+ Install() call, however\r
+ * Initialize can be called multiple times; it will return\r
+ the same instance each time\r
+ * An API to get the instance for the current process was added\r
+ * APIs callable from Visual Basic added (suffix VB)\r
+ * API to add event logs to saved report (where the system supports event logs)\r
+ * API to add registry hives, in REGEDIT4 save format, to saved report\r
+ * API allowing removal of files added to report\r
+ * User-supplied e-mail and comments saved (as separate file) in\r
+ crash report if Initialize called without e-mail address\r
+ * Crash report XML includes stack walkback and, if possible,\r
+ file, function, and line number information for all addresses\r
+ * Dialog is in a separate thread, so crashing application freezes\r
+ * Application can include a message when calling GenerateErrorReport\r
+ * New API to generate stack trace (independant of crashes and crash\r
+ handling)\r
+ * User e-mail field now initialized with name of signed-on user\r
+ (no domain, unfortunately)\r
+ Minor Changes:\r
+ * Working files deleted after report mailed, saved, or cancelled\r
+ * XSL style sheet provided that will transform crash report XML to\r
+ HTML\r
+ * Minor internal design changes\r
+ * Package now includes Zlib 1.1.4 and dbghelp.dll 6.1.17.2.\r
+ Bugs Fixed: