2 * Copyright 2022 Nikolay Sivov for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #ifndef __WINE_MINIDUMP_H
20 #define __WINE_MINIDUMP_H
28 #define MINIDUMP_SIGNATURE 0x504D444D /* 'MDMP' */
29 #define MINIDUMP_VERSION (42899)
32 typedef ULONG64 RVA64
;
34 typedef enum _MINIDUMP_TYPE
36 MiniDumpNormal
= 0x00000000,
37 MiniDumpWithDataSegs
= 0x00000001,
38 MiniDumpWithFullMemory
= 0x00000002,
39 MiniDumpWithHandleData
= 0x00000004,
40 MiniDumpFilterMemory
= 0x00000008,
41 MiniDumpScanMemory
= 0x00000010,
42 MiniDumpWithUnloadedModules
= 0x00000020,
43 MiniDumpWithIndirectlyReferencedMemory
= 0x00000040,
44 MiniDumpFilterModulePaths
= 0x00000080,
45 MiniDumpWithProcessThreadData
= 0x00000100,
46 MiniDumpWithPrivateReadWriteMemory
= 0x00000200,
47 MiniDumpWithoutOptionalData
= 0x00000400,
48 MiniDumpWithFullMemoryInfo
= 0x00000800,
49 MiniDumpWithThreadInfo
= 0x00001000,
50 MiniDumpWithCodeSegs
= 0x00002000,
51 MiniDumpValidTypeFlags
= 0x01ffffff,
54 typedef enum _MINIDUMP_CALLBACK_TYPE
59 IncludeThreadCallback
,
60 IncludeModuleCallback
,
62 } MINIDUMP_CALLBACK_TYPE
;
64 typedef struct _MINIDUMP_THREAD_CALLBACK
68 #if defined(__aarch64__)
75 } MINIDUMP_THREAD_CALLBACK
, *PMINIDUMP_THREAD_CALLBACK
;
77 typedef struct _MINIDUMP_THREAD_EX_CALLBACK
81 #if defined(__aarch64__)
88 ULONG64 BackingStoreBase
;
89 ULONG64 BackingStoreEnd
;
90 } MINIDUMP_THREAD_EX_CALLBACK
, *PMINIDUMP_THREAD_EX_CALLBACK
;
92 typedef struct _MINIDUMP_INCLUDE_THREAD_CALLBACK
95 } MINIDUMP_INCLUDE_THREAD_CALLBACK
, *PMINIDUMP_INCLUDE_THREAD_CALLBACK
;
97 typedef enum _THREAD_WRITE_FLAGS
99 ThreadWriteThread
= 0x0001,
100 ThreadWriteStack
= 0x0002,
101 ThreadWriteContext
= 0x0004,
102 ThreadWriteBackingStore
= 0x0008,
103 ThreadWriteInstructionWindow
= 0x0010,
104 ThreadWriteThreadData
= 0x0020,
105 ThreadWriteThreadInfo
= 0x0040
106 } THREAD_WRITE_FLAGS
;
108 typedef struct _MINIDUMP_MODULE_CALLBACK
115 VS_FIXEDFILEINFO VersionInfo
;
117 ULONG SizeOfCvRecord
;
119 ULONG SizeOfMiscRecord
;
120 } MINIDUMP_MODULE_CALLBACK
, *PMINIDUMP_MODULE_CALLBACK
;
122 typedef struct _MINIDUMP_INCLUDE_MODULE_CALLBACK
125 } MINIDUMP_INCLUDE_MODULE_CALLBACK
, *PMINIDUMP_INCLUDE_MODULE_CALLBACK
;
127 typedef enum _MODULE_WRITE_FLAGS
129 ModuleWriteModule
= 0x0001,
130 ModuleWriteDataSeg
= 0x0002,
131 ModuleWriteMiscRecord
= 0x0004,
132 ModuleWriteCvRecord
= 0x0008,
133 ModuleReferencedByMemory
= 0x0010,
134 ModuleWriteTlsData
= 0x0020,
135 ModuleWriteCodeSegs
= 0x0040,
136 } MODULE_WRITE_FLAGS
;
138 typedef struct _MINIDUMP_CALLBACK_INPUT
141 HANDLE ProcessHandle
;
145 MINIDUMP_THREAD_CALLBACK Thread
;
146 MINIDUMP_THREAD_EX_CALLBACK ThreadEx
;
147 MINIDUMP_MODULE_CALLBACK Module
;
148 MINIDUMP_INCLUDE_THREAD_CALLBACK IncludeThread
;
149 MINIDUMP_INCLUDE_MODULE_CALLBACK IncludeModule
;
151 } MINIDUMP_CALLBACK_INPUT
, *PMINIDUMP_CALLBACK_INPUT
;
153 typedef struct _MINIDUMP_CALLBACK_OUTPUT
157 ULONG ModuleWriteFlags
;
158 ULONG ThreadWriteFlags
;
165 } MINIDUMP_CALLBACK_OUTPUT
, *PMINIDUMP_CALLBACK_OUTPUT
;
167 typedef BOOL (WINAPI
* MINIDUMP_CALLBACK_ROUTINE
)(PVOID
, const PMINIDUMP_CALLBACK_INPUT
, PMINIDUMP_CALLBACK_OUTPUT
);
169 typedef struct _MINIDUMP_CALLBACK_INFORMATION
171 MINIDUMP_CALLBACK_ROUTINE CallbackRoutine
;
173 } MINIDUMP_CALLBACK_INFORMATION
, *PMINIDUMP_CALLBACK_INFORMATION
;
175 typedef struct _MINIDUMP_LOCATION_DESCRIPTOR
179 } MINIDUMP_LOCATION_DESCRIPTOR
;
181 typedef struct _MINIDUMP_LOCATION_DESCRIPTOR64
185 } MINIDUMP_LOCATION_DESCRIPTOR64
;
187 typedef struct _MINIDUMP_DIRECTORY
190 MINIDUMP_LOCATION_DESCRIPTOR Location
;
191 } MINIDUMP_DIRECTORY
, *PMINIDUMP_DIRECTORY
;
193 typedef struct _MINIDUMP_EXCEPTION
195 ULONG32 ExceptionCode
;
196 ULONG32 ExceptionFlags
;
197 ULONG64 ExceptionRecord
;
198 ULONG64 ExceptionAddress
;
199 ULONG32 NumberParameters
;
200 ULONG32 __unusedAlignment
;
201 ULONG64 ExceptionInformation
[EXCEPTION_MAXIMUM_PARAMETERS
];
202 } MINIDUMP_EXCEPTION
, *PMINIDUMP_EXCEPTION
;
204 typedef struct _MINIDUMP_EXCEPTION_INFORMATION
207 PEXCEPTION_POINTERS ExceptionPointers
;
209 } MINIDUMP_EXCEPTION_INFORMATION
, *PMINIDUMP_EXCEPTION_INFORMATION
;
211 typedef struct MINIDUMP_EXCEPTION_STREAM
215 MINIDUMP_EXCEPTION ExceptionRecord
;
216 MINIDUMP_LOCATION_DESCRIPTOR ThreadContext
;
217 } MINIDUMP_EXCEPTION_STREAM
, *PMINIDUMP_EXCEPTION_STREAM
;
219 typedef struct _MINIDUMP_HEADER
223 ULONG32 NumberOfStreams
;
224 RVA StreamDirectoryRva
;
229 ULONG32 TimeDateStamp
;
232 } MINIDUMP_HEADER
, *PMINIDUMP_HEADER
;
234 typedef struct _MINIDUMP_MEMORY_DESCRIPTOR
236 ULONG64 StartOfMemoryRange
;
237 MINIDUMP_LOCATION_DESCRIPTOR Memory
;
238 } MINIDUMP_MEMORY_DESCRIPTOR
, *PMINIDUMP_MEMORY_DESCRIPTOR
;
240 typedef struct _MINIDUMP_MEMORY_LIST
242 ULONG32 NumberOfMemoryRanges
;
243 MINIDUMP_MEMORY_DESCRIPTOR MemoryRanges
[1]; /* FIXME: 0-sized array not supported */
244 } MINIDUMP_MEMORY_LIST
, *PMINIDUMP_MEMORY_LIST
;
246 typedef struct _MINIDUMP_MEMORY_DESCRIPTOR64
248 ULONG64 StartOfMemoryRange
;
250 } MINIDUMP_MEMORY_DESCRIPTOR64
, *PMINIDUMP_MEMORY_DESCRIPTOR64
;
252 typedef struct _MINIDUMP_MEMORY64_LIST
254 ULONG64 NumberOfMemoryRanges
;
256 MINIDUMP_MEMORY_DESCRIPTOR64 MemoryRanges
[1]; /* FIXME: 0-sized array not supported */
257 } MINIDUMP_MEMORY64_LIST
, *PMINIDUMP_MEMORY64_LIST
;
259 #define MINIDUMP_MISC1_PROCESS_ID 0x00000001
260 #define MINIDUMP_MISC1_PROCESS_TIMES 0x00000002
262 typedef struct _MINIDUMP_MISC_INFO
267 ULONG32 ProcessCreateTime
;
268 ULONG32 ProcessUserTime
;
269 ULONG32 ProcessKernelTime
;
270 } MINIDUMP_MISC_INFO
, *PMINIDUMP_MISC_INFO
;
272 typedef struct _MINIDUMP_MODULE
277 ULONG32 TimeDateStamp
;
279 VS_FIXEDFILEINFO VersionInfo
;
280 MINIDUMP_LOCATION_DESCRIPTOR CvRecord
;
281 MINIDUMP_LOCATION_DESCRIPTOR MiscRecord
;
284 } MINIDUMP_MODULE
, *PMINIDUMP_MODULE
;
286 typedef struct _MINIDUMP_MODULE_LIST
288 ULONG32 NumberOfModules
;
289 MINIDUMP_MODULE Modules
[1]; /* FIXME: 0-sized array not supported */
290 } MINIDUMP_MODULE_LIST
, *PMINIDUMP_MODULE_LIST
;
292 typedef struct _MINIDUMP_STRING
295 WCHAR Buffer
[1]; /* FIXME: O-sized array not supported */
296 } MINIDUMP_STRING
, *PMINIDUMP_STRING
;
298 typedef union _CPU_INFORMATION
303 ULONG32 VersionInformation
;
304 ULONG32 FeatureInformation
;
305 ULONG32 AMDExtendedCpuFeatures
;
309 ULONG64 ProcessorFeatures
[2];
311 } CPU_INFORMATION
, *PCPU_INFORMATION
;
313 typedef struct _MINIDUMP_SYSTEM_INFO
315 USHORT ProcessorArchitecture
;
316 USHORT ProcessorLevel
;
317 USHORT ProcessorRevision
;
323 UCHAR NumberOfProcessors
;
328 ULONG32 MajorVersion
;
329 ULONG32 MinorVersion
;
344 } MINIDUMP_SYSTEM_INFO
, *PMINIDUMP_SYSTEM_INFO
;
346 typedef struct _MINIDUMP_THREAD
349 ULONG32 SuspendCount
;
350 ULONG32 PriorityClass
;
353 MINIDUMP_MEMORY_DESCRIPTOR Stack
;
354 MINIDUMP_LOCATION_DESCRIPTOR ThreadContext
;
355 } MINIDUMP_THREAD
, *PMINIDUMP_THREAD
;
357 typedef struct _MINIDUMP_THREAD_LIST
359 ULONG32 NumberOfThreads
;
360 MINIDUMP_THREAD Threads
[1]; /* FIXME: no support of 0 sized array */
361 } MINIDUMP_THREAD_LIST
, *PMINIDUMP_THREAD_LIST
;
363 typedef struct _MINIDUMP_USER_STREAM
368 } MINIDUMP_USER_STREAM
, *PMINIDUMP_USER_STREAM
;
370 typedef struct _MINIDUMP_USER_STREAM_INFORMATION
372 ULONG UserStreamCount
;
373 PMINIDUMP_USER_STREAM UserStreamArray
;
374 } MINIDUMP_USER_STREAM_INFORMATION
, *PMINIDUMP_USER_STREAM_INFORMATION
;
376 typedef struct _MINIDUMP_HANDLE_DATA_STREAM
378 ULONG32 SizeOfHeader
;
379 ULONG32 SizeOfDescriptor
;
380 ULONG32 NumberOfDescriptors
;
382 } MINIDUMP_HANDLE_DATA_STREAM
, *PMINIDUMP_HANDLE_DATA_STREAM
;
384 typedef struct _MINIDUMP_HANDLE_DESCRIPTOR
390 ULONG32 GrantedAccess
;
392 ULONG32 PointerCount
;
393 } MINIDUMP_HANDLE_DESCRIPTOR
, *PMINIDUMP_HANDLE_DESCRIPTOR
;
395 typedef struct _MINIDUMP_HANDLE_DESCRIPTOR_2
401 ULONG32 GrantedAccess
;
403 ULONG32 PointerCount
;
406 } MINIDUMP_HANDLE_DESCRIPTOR_2
, *PMINIDUMP_HANDLE_DESCRIPTOR_2
;
408 typedef struct _MINIDUMP_THREAD_INFO
418 ULONG64 StartAddress
;
420 } MINIDUMP_THREAD_INFO
, *PMINIDUMP_THREAD_INFO
;
422 typedef struct _MINIDUMP_THREAD_INFO_LIST
426 ULONG NumberOfEntries
;
427 } MINIDUMP_THREAD_INFO_LIST
, *PMINIDUMP_THREAD_INFO_LIST
;
429 typedef struct _MINIDUMP_UNLOADED_MODULE
434 ULONG32 TimeDateStamp
;
436 } MINIDUMP_UNLOADED_MODULE
, *PMINIDUMP_UNLOADED_MODULE
;
438 typedef struct _MINIDUMP_UNLOADED_MODULE_LIST
440 ULONG32 SizeOfHeader
;
442 ULONG32 NumberOfEntries
;
443 } MINIDUMP_UNLOADED_MODULE_LIST
, *PMINIDUMP_UNLOADED_MODULE_LIST
;
445 typedef enum _MINIDUMP_STREAM_TYPE
450 ThreadListStream
= 3,
451 ModuleListStream
= 4,
452 MemoryListStream
= 5,
454 SystemInfoStream
= 7,
455 ThreadExListStream
= 8,
456 Memory64ListStream
= 9,
459 HandleDataStream
= 12,
460 FunctionTableStream
= 13,
461 UnloadedModuleListStream
= 14,
463 MemoryInfoListStream
= 16,
464 ThreadInfoListStream
= 17,
465 HandleOperationListStream
= 18,
467 JavaScriptDataStream
= 20,
468 SystemMemoryInfoStream
= 21,
469 ProcessVmCountersStream
= 22,
471 ThreadNamesStream
= 24,
473 LastReservedStream
= 0xffff
474 } MINIDUMP_STREAM_TYPE
;
476 BOOL WINAPI
MiniDumpWriteDump(HANDLE process
, DWORD pid
, HANDLE hfile
, MINIDUMP_TYPE dumptype
,
477 PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam
, PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam
,
478 PMINIDUMP_CALLBACK_INFORMATION CallbackParam
);
479 BOOL WINAPI
MiniDumpReadDumpStream(PVOID base
, ULONG index
, PMINIDUMP_DIRECTORY
*dir
, void **streamptr
,
488 #endif /* __WINE_MINIDUMP_H */