Sync DrDump crash handler with TortoiseSVN codebase
[TortoiseGit.git] / ext / CrashServer / CrashHandler / SendRpt / DumpWriter.h
blobd534b15b7580540d8d842663e4d788fd5b2bd1f3
1 // Copyright 2014 Idol Software, Inc.
2 //
3 // This file is part of Doctor Dump SDK.
4 //
5 // Doctor Dump SDK is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #pragma once
20 #include <wtypes.h>
21 #include <dbghelp.h>
22 #include <map>
23 #include "DoctorDump.h"
24 #include "../../CommonLibs/Log/log.h"
26 class DumpWriter
28 public:
29 DumpWriter(Log& log);
30 ~DumpWriter();
32 void Init(LPCWSTR dbgHelpPath);
34 bool WriteMiniDump(
35 HANDLE hProcess,
36 DWORD dwProcessId,
37 MINIDUMP_EXCEPTION_INFORMATION* pExceptInfo,
38 LPCTSTR pszFileName,
39 MINIDUMP_TYPE DumpType,
40 MINIDUMP_CALLBACK_INFORMATION* pCallback);
42 private:
43 typedef BOOL (WINAPI *fnMiniDumpWriteDump)(
44 HANDLE hProcess,
45 DWORD ProcessId,
46 HANDLE hFile,
47 MINIDUMP_TYPE DumpType,
48 CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
49 CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,
50 CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam);
52 Log& m_log;
53 CStringW m_dbgHelpPath;
54 HINSTANCE m_hDbgHelp;
55 fnMiniDumpWriteDump m_pfnMiniDumpWriteDump;
58 class DumpFilter
60 public:
61 DumpFilter(bool& cancel, DWORD saveOnlyThisThreadID = 0);
63 operator MINIDUMP_CALLBACK_INFORMATION*() { return &m_callback; }
65 private:
66 MINIDUMP_CALLBACK_INFORMATION m_callback;
67 bool& m_cancel;
68 DWORD m_saveOnlyThisThreadID;
70 BOOL MinidumpCallback(
71 const PMINIDUMP_CALLBACK_INPUT CallbackInput,
72 PMINIDUMP_CALLBACK_OUTPUT CallbackOutput);
74 static BOOL CALLBACK _MinidumpCallback(
75 PVOID CallbackParam,
76 const PMINIDUMP_CALLBACK_INPUT CallbackInput,
77 PMINIDUMP_CALLBACK_OUTPUT CallbackOutput);