Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- include/dbghelp.h | 388 +----------------------------- include/minidumpapiset.h | 412 ++++++++++++++++++++++++++++++++ programs/winedbg/tgt_minidump.c | 2 +- 3 files changed, 415 insertions(+), 387 deletions(-) create mode 100644 include/minidumpapiset.h
diff --git a/include/dbghelp.h b/include/dbghelp.h index 07fa429809a..b34ebd2edab 100644 --- a/include/dbghelp.h +++ b/include/dbghelp.h @@ -21,6 +21,8 @@ #ifndef __WINE_DBGHELP_H #define __WINE_DBGHELP_H
+#include <minidumpapiset.h> + #ifdef __cplusplus extern "C" { #endif /* defined(__cplusplus) */ @@ -481,392 +483,6 @@ typedef struct _DBGHELP_MODLOAD_DATA DWORD flags; } MODLOAD_DATA, *PMODLOAD_DATA;
-/************************* - * MiniDUMP * - *************************/ - -#include <pshpack4.h> -/* DebugHelp */ - -#define MINIDUMP_SIGNATURE 0x504D444D /* 'MDMP' */ -#define MINIDUMP_VERSION (42899) - -typedef DWORD RVA; -typedef ULONG64 RVA64; - -typedef enum _MINIDUMP_TYPE -{ - MiniDumpNormal = 0x0000, - MiniDumpWithDataSegs = 0x0001, - MiniDumpWithFullMemory = 0x0002, - MiniDumpWithHandleData = 0x0004, - MiniDumpFilterMemory = 0x0008, - MiniDumpScanMemory = 0x0010, - MiniDumpWithUnloadedModules = 0x0020, - MiniDumpWithIndirectlyReferencedMemory = 0x0040, - MiniDumpFilterModulePaths = 0x0080, - MiniDumpWithProcessThreadData = 0x0100, - MiniDumpWithPrivateReadWriteMemory = 0x0200, - MiniDumpWithoutOptionalData = 0x0400, - MiniDumpWithFullMemoryInfo = 0x0800, - MiniDumpWithThreadInfo = 0x1000, - MiniDumpWithCodeSegs = 0x2000 -} MINIDUMP_TYPE; - -typedef enum _MINIDUMP_CALLBACK_TYPE -{ - ModuleCallback, - ThreadCallback, - ThreadExCallback, - IncludeThreadCallback, - IncludeModuleCallback, - MemoryCallback, -} MINIDUMP_CALLBACK_TYPE; - -typedef struct _MINIDUMP_THREAD_CALLBACK -{ - ULONG ThreadId; - HANDLE ThreadHandle; -#if defined(__aarch64__) - ULONG Pad; -#endif - CONTEXT Context; - ULONG SizeOfContext; - ULONG64 StackBase; - ULONG64 StackEnd; -} MINIDUMP_THREAD_CALLBACK, *PMINIDUMP_THREAD_CALLBACK; - -typedef struct _MINIDUMP_THREAD_EX_CALLBACK -{ - ULONG ThreadId; - HANDLE ThreadHandle; -#if defined(__aarch64__) - ULONG Pad; -#endif - CONTEXT Context; - ULONG SizeOfContext; - ULONG64 StackBase; - ULONG64 StackEnd; - ULONG64 BackingStoreBase; - ULONG64 BackingStoreEnd; -} MINIDUMP_THREAD_EX_CALLBACK, *PMINIDUMP_THREAD_EX_CALLBACK; - -typedef struct _MINIDUMP_INCLUDE_THREAD_CALLBACK -{ - ULONG ThreadId; -} MINIDUMP_INCLUDE_THREAD_CALLBACK, *PMINIDUMP_INCLUDE_THREAD_CALLBACK; - -typedef enum _THREAD_WRITE_FLAGS -{ - ThreadWriteThread = 0x0001, - ThreadWriteStack = 0x0002, - ThreadWriteContext = 0x0004, - ThreadWriteBackingStore = 0x0008, - ThreadWriteInstructionWindow = 0x0010, - ThreadWriteThreadData = 0x0020, - ThreadWriteThreadInfo = 0x0040 -} THREAD_WRITE_FLAGS; - -typedef struct _MINIDUMP_MODULE_CALLBACK -{ - PWCHAR FullPath; - ULONG64 BaseOfImage; - ULONG SizeOfImage; - ULONG CheckSum; - ULONG TimeDateStamp; - VS_FIXEDFILEINFO VersionInfo; - PVOID CvRecord; - ULONG SizeOfCvRecord; - PVOID MiscRecord; - ULONG SizeOfMiscRecord; -} MINIDUMP_MODULE_CALLBACK, *PMINIDUMP_MODULE_CALLBACK; - -typedef struct _MINIDUMP_INCLUDE_MODULE_CALLBACK -{ - ULONG64 BaseOfImage; -} MINIDUMP_INCLUDE_MODULE_CALLBACK, *PMINIDUMP_INCLUDE_MODULE_CALLBACK; - -typedef enum _MODULE_WRITE_FLAGS -{ - ModuleWriteModule = 0x0001, - ModuleWriteDataSeg = 0x0002, - ModuleWriteMiscRecord = 0x0004, - ModuleWriteCvRecord = 0x0008, - ModuleReferencedByMemory = 0x0010, - ModuleWriteTlsData = 0x0020, - ModuleWriteCodeSegs = 0x0040, -} MODULE_WRITE_FLAGS; - -typedef struct _MINIDUMP_CALLBACK_INPUT -{ - ULONG ProcessId; - HANDLE ProcessHandle; - ULONG CallbackType; - union - { - MINIDUMP_THREAD_CALLBACK Thread; - MINIDUMP_THREAD_EX_CALLBACK ThreadEx; - MINIDUMP_MODULE_CALLBACK Module; - MINIDUMP_INCLUDE_THREAD_CALLBACK IncludeThread; - MINIDUMP_INCLUDE_MODULE_CALLBACK IncludeModule; - } DUMMYUNIONNAME; -} MINIDUMP_CALLBACK_INPUT, *PMINIDUMP_CALLBACK_INPUT; - -typedef struct _MINIDUMP_CALLBACK_OUTPUT -{ - union - { - ULONG ModuleWriteFlags; - ULONG ThreadWriteFlags; - struct - { - ULONG64 MemoryBase; - ULONG MemorySize; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME; -} MINIDUMP_CALLBACK_OUTPUT, *PMINIDUMP_CALLBACK_OUTPUT; - -typedef BOOL (WINAPI* MINIDUMP_CALLBACK_ROUTINE)(PVOID, const PMINIDUMP_CALLBACK_INPUT, PMINIDUMP_CALLBACK_OUTPUT); - -typedef struct _MINIDUMP_CALLBACK_INFORMATION -{ - MINIDUMP_CALLBACK_ROUTINE CallbackRoutine; - void* CallbackParam; -} MINIDUMP_CALLBACK_INFORMATION, *PMINIDUMP_CALLBACK_INFORMATION; - -typedef struct _MINIDUMP_LOCATION_DESCRIPTOR -{ - ULONG DataSize; - RVA Rva; -} MINIDUMP_LOCATION_DESCRIPTOR; - -typedef struct _MINIDUMP_LOCATION_DESCRIPTOR64 -{ - ULONG64 DataSize; - RVA64 Rva; -} MINIDUMP_LOCATION_DESCRIPTOR64; - -typedef struct _MINIDUMP_DIRECTORY -{ - ULONG StreamType; - MINIDUMP_LOCATION_DESCRIPTOR Location; -} MINIDUMP_DIRECTORY, *PMINIDUMP_DIRECTORY; - -typedef struct _MINIDUMP_EXCEPTION -{ - ULONG ExceptionCode; - ULONG ExceptionFlags; - ULONG64 ExceptionRecord; - ULONG64 ExceptionAddress; - ULONG NumberParameters; - ULONG __unusedAlignment; - ULONG64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; -} MINIDUMP_EXCEPTION, *PMINIDUMP_EXCEPTION; - -typedef struct _MINIDUMP_EXCEPTION_INFORMATION -{ - DWORD ThreadId; - PEXCEPTION_POINTERS ExceptionPointers; - BOOL ClientPointers; -} MINIDUMP_EXCEPTION_INFORMATION, *PMINIDUMP_EXCEPTION_INFORMATION; - -typedef struct MINIDUMP_EXCEPTION_STREAM -{ - ULONG ThreadId; - ULONG __alignment; - MINIDUMP_EXCEPTION ExceptionRecord; - MINIDUMP_LOCATION_DESCRIPTOR ThreadContext; -} MINIDUMP_EXCEPTION_STREAM, *PMINIDUMP_EXCEPTION_STREAM; - -typedef struct _MINIDUMP_HEADER -{ - DWORD Signature; - DWORD Version; - DWORD NumberOfStreams; - RVA StreamDirectoryRva; - DWORD CheckSum; - union - { - DWORD Reserved; - DWORD TimeDateStamp; - } DUMMYUNIONNAME; - ULONG64 Flags; -} MINIDUMP_HEADER, *PMINIDUMP_HEADER; - -typedef struct _MINIDUMP_MEMORY_DESCRIPTOR -{ - ULONG64 StartOfMemoryRange; - MINIDUMP_LOCATION_DESCRIPTOR Memory; -} MINIDUMP_MEMORY_DESCRIPTOR, *PMINIDUMP_MEMORY_DESCRIPTOR; - -typedef struct _MINIDUMP_MEMORY_LIST -{ - ULONG NumberOfMemoryRanges; - MINIDUMP_MEMORY_DESCRIPTOR MemoryRanges[1]; /* FIXME: 0-sized array not supported */ -} MINIDUMP_MEMORY_LIST, *PMINIDUMP_MEMORY_LIST; - -typedef struct _MINIDUMP_MEMORY_DESCRIPTOR64 -{ - ULONG64 StartOfMemoryRange; - ULONG64 DataSize; -} MINIDUMP_MEMORY_DESCRIPTOR64, *PMINIDUMP_MEMORY_DESCRIPTOR64; - -typedef struct _MINIDUMP_MEMORY64_LIST -{ - ULONG64 NumberOfMemoryRanges; - RVA64 BaseRva; - MINIDUMP_MEMORY_DESCRIPTOR64 MemoryRanges[1]; /* FIXME: 0-sized array not supported */ -} MINIDUMP_MEMORY64_LIST, *PMINIDUMP_MEMORY64_LIST; - -#define MINIDUMP_MISC1_PROCESS_ID 0x00000001 -#define MINIDUMP_MISC1_PROCESS_TIMES 0x00000002 - -typedef struct _MINIDUMP_MISC_INFO -{ - ULONG SizeOfInfo; - ULONG Flags1; - ULONG ProcessId; - ULONG ProcessCreateTime; - ULONG ProcessUserTime; - ULONG ProcessKernelTime; -} MINIDUMP_MISC_INFO, *PMINIDUMP_MISC_INFO; - -typedef struct _MINIDUMP_MODULE -{ - ULONG64 BaseOfImage; - ULONG SizeOfImage; - ULONG CheckSum; - ULONG TimeDateStamp; - RVA ModuleNameRva; - VS_FIXEDFILEINFO VersionInfo; - MINIDUMP_LOCATION_DESCRIPTOR CvRecord; - MINIDUMP_LOCATION_DESCRIPTOR MiscRecord; - ULONG64 Reserved0; - ULONG64 Reserved1; -} MINIDUMP_MODULE, *PMINIDUMP_MODULE; - -typedef struct _MINIDUMP_MODULE_LIST -{ - ULONG NumberOfModules; - MINIDUMP_MODULE Modules[1]; /* FIXME: 0-sized array not supported */ -} MINIDUMP_MODULE_LIST, *PMINIDUMP_MODULE_LIST; - -typedef struct _MINIDUMP_STRING -{ - ULONG Length; - WCHAR Buffer[1]; /* FIXME: O-sized array not supported */ -} MINIDUMP_STRING, *PMINIDUMP_STRING; - -typedef struct _MINIDUMP_SYSTEM_INFO -{ - USHORT ProcessorArchitecture; - USHORT ProcessorLevel; - USHORT ProcessorRevision; - union - { - USHORT Reserved0; - struct - { - UCHAR NumberOfProcessors; - UCHAR ProductType; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME; - - ULONG MajorVersion; - ULONG MinorVersion; - ULONG BuildNumber; - ULONG PlatformId; - - RVA CSDVersionRva; - union - { - ULONG Reserved1; - struct - { - USHORT SuiteMask; - USHORT Reserved2; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME1; - union _CPU_INFORMATION - { - struct - { - ULONG VendorId[3]; - ULONG VersionInformation; - ULONG FeatureInformation; - ULONG AMDExtendedCpuFeatures; - } X86CpuInfo; - struct - { - ULONG64 ProcessorFeatures[2]; - } OtherCpuInfo; - } Cpu; - -} MINIDUMP_SYSTEM_INFO, *PMINIDUMP_SYSTEM_INFO; - -typedef struct _MINIDUMP_THREAD -{ - ULONG ThreadId; - ULONG SuspendCount; - ULONG PriorityClass; - ULONG Priority; - ULONG64 Teb; - MINIDUMP_MEMORY_DESCRIPTOR Stack; - MINIDUMP_LOCATION_DESCRIPTOR ThreadContext; -} MINIDUMP_THREAD, *PMINIDUMP_THREAD; - -typedef struct _MINIDUMP_THREAD_LIST -{ - ULONG NumberOfThreads; - MINIDUMP_THREAD Threads[1]; /* FIXME: no support of 0 sized array */ -} MINIDUMP_THREAD_LIST, *PMINIDUMP_THREAD_LIST; - -typedef struct _MINIDUMP_USER_STREAM -{ - ULONG Type; - ULONG BufferSize; - void* Buffer; -} MINIDUMP_USER_STREAM, *PMINIDUMP_USER_STREAM; - -typedef struct _MINIDUMP_USER_STREAM_INFORMATION -{ - ULONG UserStreamCount; - PMINIDUMP_USER_STREAM UserStreamArray; -} MINIDUMP_USER_STREAM_INFORMATION, *PMINIDUMP_USER_STREAM_INFORMATION; - -typedef enum _MINIDUMP_STREAM_TYPE -{ - UnusedStream = 0, - ReservedStream0 = 1, - ReservedStream1 = 2, - ThreadListStream = 3, - ModuleListStream = 4, - MemoryListStream = 5, - ExceptionStream = 6, - SystemInfoStream = 7, - ThreadExListStream = 8, - Memory64ListStream = 9, - CommentStreamA = 10, - CommentStreamW = 11, - HandleDataStream = 12, - FunctionTableStream = 13, - UnloadedModuleListStream = 14, - MiscInfoStream = 15, - MemoryInfoListStream = 16, - ThreadInfoListStream = 17, - - LastReservedStream = 0xffff -} MINIDUMP_STREAM_TYPE; - -BOOL WINAPI MiniDumpWriteDump(HANDLE, DWORD, HANDLE, MINIDUMP_TYPE, - const PMINIDUMP_EXCEPTION_INFORMATION, - const PMINIDUMP_USER_STREAM_INFORMATION, - const PMINIDUMP_CALLBACK_INFORMATION); -BOOL WINAPI MiniDumpReadDumpStream(PVOID, ULONG, PMINIDUMP_DIRECTORY*, PVOID*, - ULONG*); - -#include <poppack.h> - /************************* * MODULE handling * *************************/ diff --git a/include/minidumpapiset.h b/include/minidumpapiset.h new file mode 100644 index 00000000000..5efe948bad7 --- /dev/null +++ b/include/minidumpapiset.h @@ -0,0 +1,412 @@ +/* + * Copyright 2022 Nikolay Sivov for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef __WINE_MINIDUMP_H +#define __WINE_MINIDUMP_H + +#include <pshpack4.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#define MINIDUMP_SIGNATURE 0x504D444D /* 'MDMP' */ +#define MINIDUMP_VERSION (42899) + +typedef DWORD RVA; +typedef ULONG64 RVA64; + +typedef enum _MINIDUMP_TYPE +{ + MiniDumpNormal = 0x00000000, + MiniDumpWithDataSegs = 0x00000001, + MiniDumpWithFullMemory = 0x00000002, + MiniDumpWithHandleData = 0x00000004, + MiniDumpFilterMemory = 0x00000008, + MiniDumpScanMemory = 0x00000010, + MiniDumpWithUnloadedModules = 0x00000020, + MiniDumpWithIndirectlyReferencedMemory = 0x00000040, + MiniDumpFilterModulePaths = 0x00000080, + MiniDumpWithProcessThreadData = 0x00000100, + MiniDumpWithPrivateReadWriteMemory = 0x00000200, + MiniDumpWithoutOptionalData = 0x00000400, + MiniDumpWithFullMemoryInfo = 0x00000800, + MiniDumpWithThreadInfo = 0x00001000, + MiniDumpWithCodeSegs = 0x00002000, + MiniDumpValidTypeFlags = 0x01ffffff, +} MINIDUMP_TYPE; + +typedef enum _MINIDUMP_CALLBACK_TYPE +{ + ModuleCallback, + ThreadCallback, + ThreadExCallback, + IncludeThreadCallback, + IncludeModuleCallback, + MemoryCallback, +} MINIDUMP_CALLBACK_TYPE; + +typedef struct _MINIDUMP_THREAD_CALLBACK +{ + ULONG ThreadId; + HANDLE ThreadHandle; +#if defined(__aarch64__) + ULONG Pad; +#endif + CONTEXT Context; + ULONG SizeOfContext; + ULONG64 StackBase; + ULONG64 StackEnd; +} MINIDUMP_THREAD_CALLBACK, *PMINIDUMP_THREAD_CALLBACK; + +typedef struct _MINIDUMP_THREAD_EX_CALLBACK +{ + ULONG ThreadId; + HANDLE ThreadHandle; +#if defined(__aarch64__) + ULONG Pad; +#endif + CONTEXT Context; + ULONG SizeOfContext; + ULONG64 StackBase; + ULONG64 StackEnd; + ULONG64 BackingStoreBase; + ULONG64 BackingStoreEnd; +} MINIDUMP_THREAD_EX_CALLBACK, *PMINIDUMP_THREAD_EX_CALLBACK; + +typedef struct _MINIDUMP_INCLUDE_THREAD_CALLBACK +{ + ULONG ThreadId; +} MINIDUMP_INCLUDE_THREAD_CALLBACK, *PMINIDUMP_INCLUDE_THREAD_CALLBACK; + +typedef enum _THREAD_WRITE_FLAGS +{ + ThreadWriteThread = 0x0001, + ThreadWriteStack = 0x0002, + ThreadWriteContext = 0x0004, + ThreadWriteBackingStore = 0x0008, + ThreadWriteInstructionWindow = 0x0010, + ThreadWriteThreadData = 0x0020, + ThreadWriteThreadInfo = 0x0040 +} THREAD_WRITE_FLAGS; + +typedef struct _MINIDUMP_MODULE_CALLBACK +{ + PWCHAR FullPath; + ULONG64 BaseOfImage; + ULONG SizeOfImage; + ULONG CheckSum; + ULONG TimeDateStamp; + VS_FIXEDFILEINFO VersionInfo; + PVOID CvRecord; + ULONG SizeOfCvRecord; + PVOID MiscRecord; + ULONG SizeOfMiscRecord; +} MINIDUMP_MODULE_CALLBACK, *PMINIDUMP_MODULE_CALLBACK; + +typedef struct _MINIDUMP_INCLUDE_MODULE_CALLBACK +{ + ULONG64 BaseOfImage; +} MINIDUMP_INCLUDE_MODULE_CALLBACK, *PMINIDUMP_INCLUDE_MODULE_CALLBACK; + +typedef enum _MODULE_WRITE_FLAGS +{ + ModuleWriteModule = 0x0001, + ModuleWriteDataSeg = 0x0002, + ModuleWriteMiscRecord = 0x0004, + ModuleWriteCvRecord = 0x0008, + ModuleReferencedByMemory = 0x0010, + ModuleWriteTlsData = 0x0020, + ModuleWriteCodeSegs = 0x0040, +} MODULE_WRITE_FLAGS; + +typedef struct _MINIDUMP_CALLBACK_INPUT +{ + ULONG ProcessId; + HANDLE ProcessHandle; + ULONG CallbackType; + union + { + MINIDUMP_THREAD_CALLBACK Thread; + MINIDUMP_THREAD_EX_CALLBACK ThreadEx; + MINIDUMP_MODULE_CALLBACK Module; + MINIDUMP_INCLUDE_THREAD_CALLBACK IncludeThread; + MINIDUMP_INCLUDE_MODULE_CALLBACK IncludeModule; + } DUMMYUNIONNAME; +} MINIDUMP_CALLBACK_INPUT, *PMINIDUMP_CALLBACK_INPUT; + +typedef struct _MINIDUMP_CALLBACK_OUTPUT +{ + union + { + ULONG ModuleWriteFlags; + ULONG ThreadWriteFlags; + struct + { + ULONG64 MemoryBase; + ULONG MemorySize; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; +} MINIDUMP_CALLBACK_OUTPUT, *PMINIDUMP_CALLBACK_OUTPUT; + +typedef BOOL (WINAPI* MINIDUMP_CALLBACK_ROUTINE)(PVOID, const PMINIDUMP_CALLBACK_INPUT, PMINIDUMP_CALLBACK_OUTPUT); + +typedef struct _MINIDUMP_CALLBACK_INFORMATION +{ + MINIDUMP_CALLBACK_ROUTINE CallbackRoutine; + void *CallbackParam; +} MINIDUMP_CALLBACK_INFORMATION, *PMINIDUMP_CALLBACK_INFORMATION; + +typedef struct _MINIDUMP_LOCATION_DESCRIPTOR +{ + ULONG32 DataSize; + RVA Rva; +} MINIDUMP_LOCATION_DESCRIPTOR; + +typedef struct _MINIDUMP_LOCATION_DESCRIPTOR64 +{ + ULONG64 DataSize; + RVA64 Rva; +} MINIDUMP_LOCATION_DESCRIPTOR64; + +typedef struct _MINIDUMP_DIRECTORY +{ + ULONG32 StreamType; + MINIDUMP_LOCATION_DESCRIPTOR Location; +} MINIDUMP_DIRECTORY, *PMINIDUMP_DIRECTORY; + +typedef struct _MINIDUMP_EXCEPTION +{ + ULONG32 ExceptionCode; + ULONG32 ExceptionFlags; + ULONG64 ExceptionRecord; + ULONG64 ExceptionAddress; + ULONG32 NumberParameters; + ULONG32 __unusedAlignment; + ULONG64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; +} MINIDUMP_EXCEPTION, *PMINIDUMP_EXCEPTION; + +typedef struct _MINIDUMP_EXCEPTION_INFORMATION +{ + DWORD ThreadId; + PEXCEPTION_POINTERS ExceptionPointers; + BOOL ClientPointers; +} MINIDUMP_EXCEPTION_INFORMATION, *PMINIDUMP_EXCEPTION_INFORMATION; + +typedef struct MINIDUMP_EXCEPTION_STREAM +{ + ULONG32 ThreadId; + ULONG32 __alignment; + MINIDUMP_EXCEPTION ExceptionRecord; + MINIDUMP_LOCATION_DESCRIPTOR ThreadContext; +} MINIDUMP_EXCEPTION_STREAM, *PMINIDUMP_EXCEPTION_STREAM; + +typedef struct _MINIDUMP_HEADER +{ + ULONG32 Signature; + ULONG32 Version; + ULONG32 NumberOfStreams; + RVA StreamDirectoryRva; + ULONG32 CheckSum; + union + { + ULONG32 Reserved; + ULONG32 TimeDateStamp; + } DUMMYUNIONNAME; + ULONG64 Flags; +} MINIDUMP_HEADER, *PMINIDUMP_HEADER; + +typedef struct _MINIDUMP_MEMORY_DESCRIPTOR +{ + ULONG64 StartOfMemoryRange; + MINIDUMP_LOCATION_DESCRIPTOR Memory; +} MINIDUMP_MEMORY_DESCRIPTOR, *PMINIDUMP_MEMORY_DESCRIPTOR; + +typedef struct _MINIDUMP_MEMORY_LIST +{ + ULONG32 NumberOfMemoryRanges; + MINIDUMP_MEMORY_DESCRIPTOR MemoryRanges[1]; /* FIXME: 0-sized array not supported */ +} MINIDUMP_MEMORY_LIST, *PMINIDUMP_MEMORY_LIST; + +typedef struct _MINIDUMP_MEMORY_DESCRIPTOR64 +{ + ULONG64 StartOfMemoryRange; + ULONG64 DataSize; +} MINIDUMP_MEMORY_DESCRIPTOR64, *PMINIDUMP_MEMORY_DESCRIPTOR64; + +typedef struct _MINIDUMP_MEMORY64_LIST +{ + ULONG64 NumberOfMemoryRanges; + RVA64 BaseRva; + MINIDUMP_MEMORY_DESCRIPTOR64 MemoryRanges[1]; /* FIXME: 0-sized array not supported */ +} MINIDUMP_MEMORY64_LIST, *PMINIDUMP_MEMORY64_LIST; + +#define MINIDUMP_MISC1_PROCESS_ID 0x00000001 +#define MINIDUMP_MISC1_PROCESS_TIMES 0x00000002 + +typedef struct _MINIDUMP_MISC_INFO +{ + ULONG32 SizeOfInfo; + ULONG32 Flags1; + ULONG32 ProcessId; + ULONG32 ProcessCreateTime; + ULONG32 ProcessUserTime; + ULONG32 ProcessKernelTime; +} MINIDUMP_MISC_INFO, *PMINIDUMP_MISC_INFO; + +typedef struct _MINIDUMP_MODULE +{ + ULONG64 BaseOfImage; + ULONG32 SizeOfImage; + ULONG32 CheckSum; + ULONG32 TimeDateStamp; + RVA ModuleNameRva; + VS_FIXEDFILEINFO VersionInfo; + MINIDUMP_LOCATION_DESCRIPTOR CvRecord; + MINIDUMP_LOCATION_DESCRIPTOR MiscRecord; + ULONG64 Reserved0; + ULONG64 Reserved1; +} MINIDUMP_MODULE, *PMINIDUMP_MODULE; + +typedef struct _MINIDUMP_MODULE_LIST +{ + ULONG32 NumberOfModules; + MINIDUMP_MODULE Modules[1]; /* FIXME: 0-sized array not supported */ +} MINIDUMP_MODULE_LIST, *PMINIDUMP_MODULE_LIST; + +typedef struct _MINIDUMP_STRING +{ + ULONG32 Length; + WCHAR Buffer[1]; /* FIXME: O-sized array not supported */ +} MINIDUMP_STRING, *PMINIDUMP_STRING; + +typedef union _CPU_INFORMATION +{ + struct + { + ULONG32 VendorId[3]; + ULONG32 VersionInformation; + ULONG32 FeatureInformation; + ULONG32 AMDExtendedCpuFeatures; + } X86CpuInfo; + struct + { + ULONG64 ProcessorFeatures[2]; + } OtherCpuInfo; +} CPU_INFORMATION, *PCPU_INFORMATION; + +typedef struct _MINIDUMP_SYSTEM_INFO +{ + USHORT ProcessorArchitecture; + USHORT ProcessorLevel; + USHORT ProcessorRevision; + union + { + USHORT Reserved0; + struct + { + UCHAR NumberOfProcessors; + UCHAR ProductType; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; + + ULONG32 MajorVersion; + ULONG32 MinorVersion; + ULONG32 BuildNumber; + ULONG32 PlatformId; + + RVA CSDVersionRva; + union + { + ULONG32 Reserved1; + struct + { + USHORT SuiteMask; + USHORT Reserved2; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME1; + CPU_INFORMATION Cpu; +} MINIDUMP_SYSTEM_INFO, *PMINIDUMP_SYSTEM_INFO; + +typedef struct _MINIDUMP_THREAD +{ + ULONG32 ThreadId; + ULONG32 SuspendCount; + ULONG32 PriorityClass; + ULONG32 Priority; + ULONG64 Teb; + MINIDUMP_MEMORY_DESCRIPTOR Stack; + MINIDUMP_LOCATION_DESCRIPTOR ThreadContext; +} MINIDUMP_THREAD, *PMINIDUMP_THREAD; + +typedef struct _MINIDUMP_THREAD_LIST +{ + ULONG32 NumberOfThreads; + MINIDUMP_THREAD Threads[1]; /* FIXME: no support of 0 sized array */ +} MINIDUMP_THREAD_LIST, *PMINIDUMP_THREAD_LIST; + +typedef struct _MINIDUMP_USER_STREAM +{ + ULONG32 Type; + ULONG BufferSize; + void *Buffer; +} MINIDUMP_USER_STREAM, *PMINIDUMP_USER_STREAM; + +typedef struct _MINIDUMP_USER_STREAM_INFORMATION +{ + ULONG UserStreamCount; + PMINIDUMP_USER_STREAM UserStreamArray; +} MINIDUMP_USER_STREAM_INFORMATION, *PMINIDUMP_USER_STREAM_INFORMATION; + +typedef enum _MINIDUMP_STREAM_TYPE +{ + UnusedStream = 0, + ReservedStream0 = 1, + ReservedStream1 = 2, + ThreadListStream = 3, + ModuleListStream = 4, + MemoryListStream = 5, + ExceptionStream = 6, + SystemInfoStream = 7, + ThreadExListStream = 8, + Memory64ListStream = 9, + CommentStreamA = 10, + CommentStreamW = 11, + HandleDataStream = 12, + FunctionTableStream = 13, + UnloadedModuleListStream = 14, + MiscInfoStream = 15, + MemoryInfoListStream = 16, + ThreadInfoListStream = 17, + + LastReservedStream = 0xffff +} MINIDUMP_STREAM_TYPE; + +BOOL WINAPI MiniDumpWriteDump(HANDLE process, DWORD pid, HANDLE hfile, MINIDUMP_TYPE dumptype, + PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, + PMINIDUMP_CALLBACK_INFORMATION CallbackParam); +BOOL WINAPI MiniDumpReadDumpStream(PVOID base, ULONG index, PMINIDUMP_DIRECTORY *dir, void **streamptr, + ULONG *stream_size); + +#ifdef __cplusplus +} +#endif + +#include <poppack.h> + +#endif /* __WINE_MINIDUMP_H */ diff --git a/programs/winedbg/tgt_minidump.c b/programs/winedbg/tgt_minidump.c index 5fa615bcd45..af39d4af922 100644 --- a/programs/winedbg/tgt_minidump.c +++ b/programs/winedbg/tgt_minidump.c @@ -379,7 +379,7 @@ static enum dbg_start minidump_do_reload(struct tgt_process_minidump_data* data) break; default: str = "???"; break; } - dbg_printf(" on Windows %s (%lu)\n", str, msi->BuildNumber); + dbg_printf(" on Windows %s (%u)\n", str, msi->BuildNumber); /* FIXME CSD: msi->CSDVersionRva */
if (sizeof(MINIDUMP_SYSTEM_INFO) + 4 > dir->Location.DataSize &&
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- tools/winedump/minidump.c | 39 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 26 deletions(-)
diff --git a/tools/winedump/minidump.c b/tools/winedump/minidump.c index b834ec887e4..efc91bfdbfd 100644 --- a/tools/winedump/minidump.c +++ b/tools/winedump/minidump.c @@ -40,21 +40,6 @@ static void dump_mdmp_string(DWORD rva) printf("<<?>>"); }
-static const MINIDUMP_DIRECTORY* get_mdmp_dir(const MINIDUMP_HEADER* hdr, unsigned int str_idx) -{ - const MINIDUMP_DIRECTORY* dir; - unsigned int i; - - for (i = 0; i < hdr->NumberOfStreams; i++) - { - dir = PRD(hdr->StreamDirectoryRva + i * sizeof(MINIDUMP_DIRECTORY), - sizeof(MINIDUMP_DIRECTORY)); - if (!dir) continue; - if (dir->StreamType == str_idx) return dir; - } - return NULL; -} - enum FileSig get_kind_mdmp(void) { const DWORD* pdw; @@ -69,9 +54,9 @@ enum FileSig get_kind_mdmp(void) void mdmp_dump(void) { const MINIDUMP_HEADER* hdr = PRD(0, sizeof(MINIDUMP_HEADER)); - UINT idx, ndir = 0; const MINIDUMP_DIRECTORY* dir; const void* stream; + unsigned int idx;
if (!hdr) { @@ -79,27 +64,29 @@ void mdmp_dump(void) return; }
- printf("Signature: %u (%.4s)\n", (UINT)hdr->Signature, (const char*)&hdr->Signature); - printf("Version: %x\n", (UINT)hdr->Version); - printf("NumberOfStreams: %u\n", (UINT)hdr->NumberOfStreams); + printf("Signature: %#x (%.4s)\n", hdr->Signature, (const char*)&hdr->Signature); + printf("Version: %#x\n", hdr->Version); + printf("NumberOfStreams: %u\n", hdr->NumberOfStreams); printf("StreamDirectoryRva: %u\n", (UINT)hdr->StreamDirectoryRva); - printf("CheckSum: %u\n", (UINT)hdr->CheckSum); + printf("CheckSum: %u\n", hdr->CheckSum); printf("TimeDateStamp: %s\n", get_time_str(hdr->TimeDateStamp)); printf("Flags: %x%08x\n", (UINT)(hdr->Flags >> 32), (UINT)hdr->Flags);
- for (idx = 0; idx <= LastReservedStream; idx++) + for (idx = 0; idx < hdr->NumberOfStreams; ++idx) { - if (!(dir = get_mdmp_dir(hdr, idx))) continue; + dir = PRD(hdr->StreamDirectoryRva + idx * sizeof(MINIDUMP_DIRECTORY), sizeof(*dir)); + if (!dir) break;
stream = PRD(dir->Location.Rva, dir->Location.DataSize); - printf("Directory [%u]: ", ndir++); + + printf("Stream [%u]: ", idx); switch (dir->StreamType) { case ThreadListStream: { - const MINIDUMP_THREAD_LIST* mtl = (const MINIDUMP_THREAD_LIST*)stream; - const MINIDUMP_THREAD* mt = mtl->Threads; - unsigned int i; + const MINIDUMP_THREAD_LIST *mtl = stream; + const MINIDUMP_THREAD *mt = mtl->Threads; + unsigned int i;
printf("Threads: %u\n", (UINT)mtl->NumberOfThreads); for (i = 0; i < mtl->NumberOfThreads; i++, mt++)
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- tools/winedump/minidump.c | 122 ++++++++++++++++++++------------------ 1 file changed, 65 insertions(+), 57 deletions(-)
diff --git a/tools/winedump/minidump.c b/tools/winedump/minidump.c index efc91bfdbfd..9474381fd02 100644 --- a/tools/winedump/minidump.c +++ b/tools/winedump/minidump.c @@ -51,6 +51,30 @@ enum FileSig get_kind_mdmp(void) return SIG_UNKNOWN; }
+static inline void print_longlong(const char *title, ULONG64 value) +{ + printf("%s: 0x", title); + if (sizeof(value) > sizeof(unsigned long) && value >> 32) + printf("%lx%08lx\n", (unsigned long)(value >> 32), (unsigned long)value); + else + printf("%lx\n", (unsigned long)value); +} + +static inline void print_longlong_range(const char *title, ULONG64 start, ULONG64 length) +{ + ULONG64 value = start; + printf("%s: 0x", title); + if (sizeof(value) > sizeof(unsigned long) && value >> 32) + printf("%lx%08lx-", (unsigned long)(value >> 32), (unsigned long)value); + else + printf("%lx-", (unsigned long)value); + value = start + length; + if (sizeof(value) > sizeof(unsigned long) && value >> 32) + printf("0x%lx%08lx\n", (unsigned long)(value >> 32), (unsigned long)value); + else + printf("0x%lx\n", (unsigned long)value); +} + void mdmp_dump(void) { const MINIDUMP_HEADER* hdr = PRD(0, sizeof(MINIDUMP_HEADER)); @@ -70,7 +94,7 @@ void mdmp_dump(void) printf("StreamDirectoryRva: %u\n", (UINT)hdr->StreamDirectoryRva); printf("CheckSum: %u\n", hdr->CheckSum); printf("TimeDateStamp: %s\n", get_time_str(hdr->TimeDateStamp)); - printf("Flags: %x%08x\n", (UINT)(hdr->Flags >> 32), (UINT)hdr->Flags); + print_longlong("Flags", hdr->Flags);
for (idx = 0; idx < hdr->NumberOfStreams; ++idx) { @@ -91,17 +115,13 @@ void mdmp_dump(void) printf("Threads: %u\n", (UINT)mtl->NumberOfThreads); for (i = 0; i < mtl->NumberOfThreads; i++, mt++) { - printf(" Thread: #%d\n", i); - printf(" ThreadId: %u\n", (UINT)mt->ThreadId); - printf(" SuspendCount: %u\n", (UINT)mt->SuspendCount); - printf(" PriorityClass: %u\n", (UINT)mt->PriorityClass); - printf(" Priority: %u\n", (UINT)mt->Priority); - printf(" Teb: 0x%x%08x\n", (UINT)(mt->Teb >> 32), (UINT)mt->Teb); - printf(" Stack: 0x%x%08x-0x%x%08x\n", - (UINT)(mt->Stack.StartOfMemoryRange >> 32), - (UINT)mt->Stack.StartOfMemoryRange, - (UINT)((mt->Stack.StartOfMemoryRange + mt->Stack.Memory.DataSize) >> 32), - (UINT)(mt->Stack.StartOfMemoryRange + mt->Stack.Memory.DataSize)); + printf("Thread: #%d\n", i); + printf(" ThreadId: %u\n", mt->ThreadId); + printf(" SuspendCount: %u\n", mt->SuspendCount); + printf(" PriorityClass: %u\n", mt->PriorityClass); + printf(" Priority: %u\n", mt->Priority); + print_longlong(" Teb", mt->Teb); + print_longlong_range(" Stack", mt->Stack.StartOfMemoryRange, mt->Stack.Memory.DataSize); dump_mdmp_data(&mt->Stack.Memory, " "); printf(" ThreadContext:\n"); dump_mdmp_data(&mt->ThreadContext, " "); @@ -111,7 +131,7 @@ void mdmp_dump(void) case ModuleListStream: case 0xFFF0: { - const MINIDUMP_MODULE_LIST* mml = (const MINIDUMP_MODULE_LIST*)stream; + const MINIDUMP_MODULE_LIST *mml = stream; const MINIDUMP_MODULE* mm = mml->Modules; unsigned int i; const char* p1; @@ -119,14 +139,13 @@ void mdmp_dump(void)
printf("Modules (%s): %u\n", dir->StreamType == ModuleListStream ? "PE" : "ELF", - (UINT)mml->NumberOfModules); + mml->NumberOfModules); for (i = 0; i < mml->NumberOfModules; i++, mm++) { printf(" Module #%d:\n", i); - printf(" BaseOfImage: 0x%x%08x\n", - (UINT)(mm->BaseOfImage >> 32), (UINT) mm->BaseOfImage); - printf(" SizeOfImage: %u\n", (UINT)mm->SizeOfImage); - printf(" CheckSum: %u\n", (UINT)mm->CheckSum); + print_longlong(" BaseOfImage", mm->BaseOfImage); + printf(" SizeOfImage: %u\n", mm->SizeOfImage); + printf(" CheckSum: %#x\n", mm->CheckSum); printf(" TimeDateStamp: %s\n", get_time_str(mm->TimeDateStamp)); printf(" ModuleName: "); dump_mdmp_string(mm->ModuleNameRva); @@ -203,26 +222,22 @@ void mdmp_dump(void) break; case MemoryListStream: { - const MINIDUMP_MEMORY_LIST* mml = (const MINIDUMP_MEMORY_LIST*)stream; + const MINIDUMP_MEMORY_LIST *mml = stream; const MINIDUMP_MEMORY_DESCRIPTOR* mmd = mml->MemoryRanges; unsigned int i;
- printf("Memory Ranges: %u\n", (UINT)mml->NumberOfMemoryRanges); + printf("Memory Ranges: %u\n", mml->NumberOfMemoryRanges); for (i = 0; i < mml->NumberOfMemoryRanges; i++, mmd++) { printf(" Memory Range #%d:\n", i); - printf(" Range: 0x%x%08x-0x%x%08x\n", - (UINT)(mmd->StartOfMemoryRange >> 32), - (UINT)mmd->StartOfMemoryRange, - (UINT)((mmd->StartOfMemoryRange + mmd->Memory.DataSize) >> 32), - (UINT)(mmd->StartOfMemoryRange + mmd->Memory.DataSize)); + print_longlong_range(" Range", mmd->StartOfMemoryRange, mmd->Memory.DataSize); dump_mdmp_data(&mmd->Memory, " "); } } break; case SystemInfoStream: { - const MINIDUMP_SYSTEM_INFO* msi = (const MINIDUMP_SYSTEM_INFO*)stream; + const MINIDUMP_SYSTEM_INFO *msi = stream; const char* str; char tmp[128];
@@ -353,19 +368,19 @@ void mdmp_dump(void) break; default: str = "???"; break; } - printf(" Version: Windows %s (%u)\n", str, (UINT)msi->BuildNumber); - printf(" PlatformId: %u\n", (UINT)msi->PlatformId); + printf(" Version: Windows %s (%u)\n", str, msi->BuildNumber); + printf(" PlatformId: %u\n", msi->PlatformId); printf(" CSD: "); dump_mdmp_string(msi->CSDVersionRva); printf("\n"); - printf(" Reserved1: %u\n", (UINT)msi->Reserved1); + printf(" Reserved1: %u\n", msi->Reserved1); if (msi->ProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL) { printf(" x86.VendorId: %.12s\n", (const char*)msi->Cpu.X86CpuInfo.VendorId); - printf(" x86.VersionInformation: %x\n", (UINT)msi->Cpu.X86CpuInfo.VersionInformation); - printf(" x86.FeatureInformation: %x\n", (UINT)msi->Cpu.X86CpuInfo.FeatureInformation); - printf(" x86.AMDExtendedCpuFeatures: %x\n", (UINT)msi->Cpu.X86CpuInfo.AMDExtendedCpuFeatures); + printf(" x86.VersionInformation: %x\n", msi->Cpu.X86CpuInfo.VersionInformation); + printf(" x86.FeatureInformation: %x\n", msi->Cpu.X86CpuInfo.FeatureInformation); + printf(" x86.AMDExtendedCpuFeatures: %x\n", msi->Cpu.X86CpuInfo.AMDExtendedCpuFeatures); } if (sizeof(MINIDUMP_SYSTEM_INFO) + 4 > dir->Location.DataSize && msi->CSDVersionRva >= dir->Location.Rva + 4) @@ -386,45 +401,38 @@ void mdmp_dump(void) break; case MiscInfoStream: { - const MINIDUMP_MISC_INFO* mmi = (const MINIDUMP_MISC_INFO*)stream; + const MINIDUMP_MISC_INFO *mmi = stream;
printf("Misc Information\n"); - printf(" Size: %u\n", (UINT)mmi->SizeOfInfo); - printf(" Flags: %s%s\n", - mmi->Flags1 & MINIDUMP_MISC1_PROCESS_ID ? "ProcessId " : "", - mmi->Flags1 & MINIDUMP_MISC1_PROCESS_TIMES ? "ProcessTimes " : ""); + printf(" Size: %u\n", mmi->SizeOfInfo); + printf(" Flags: %#x\n", mmi->Flags1); if (mmi->Flags1 & MINIDUMP_MISC1_PROCESS_ID) - printf(" ProcessId: %u\n", (UINT)mmi->ProcessId); + printf(" ProcessId: %u\n", mmi->ProcessId); if (mmi->Flags1 & MINIDUMP_MISC1_PROCESS_TIMES) { - printf(" ProcessCreateTime: %u\n", (UINT)mmi->ProcessCreateTime); - printf(" ProcessUserTime: %u\n", (UINT)mmi->ProcessUserTime); - printf(" ProcessKernelTime: %u\n", (UINT)mmi->ProcessKernelTime); + printf(" ProcessCreateTime: %s\n", get_time_str(mmi->ProcessCreateTime)); + printf(" ProcessUserTime: %u\n", mmi->ProcessUserTime); + printf(" ProcessKernelTime: %u\n", mmi->ProcessKernelTime); } } break; case ExceptionStream: { - const MINIDUMP_EXCEPTION_STREAM* mes = (const MINIDUMP_EXCEPTION_STREAM*)stream; + const MINIDUMP_EXCEPTION_STREAM *mes = stream; unsigned int i;
printf("Exception:\n"); - printf(" ThreadId: %08x\n", (UINT)mes->ThreadId); + printf(" ThreadId: %#x\n", mes->ThreadId); printf(" ExceptionRecord:\n"); - printf(" ExceptionCode: %u\n", (UINT)mes->ExceptionRecord.ExceptionCode); - printf(" ExceptionFlags: %u\n", (UINT)mes->ExceptionRecord.ExceptionFlags); - printf(" ExceptionRecord: 0x%x%08x\n", - (UINT)(mes->ExceptionRecord.ExceptionRecord >> 32), - (UINT)mes->ExceptionRecord.ExceptionRecord); - printf(" ExceptionAddress: 0x%x%08x\n", - (UINT)(mes->ExceptionRecord.ExceptionAddress >> 32), - (UINT)(mes->ExceptionRecord.ExceptionAddress)); - printf(" ExceptionNumberParameters: %u\n", (UINT)mes->ExceptionRecord.NumberParameters); + printf(" ExceptionCode: %#x\n", mes->ExceptionRecord.ExceptionCode); + printf(" ExceptionFlags: %#x\n", mes->ExceptionRecord.ExceptionFlags); + print_longlong(" ExceptionRecord", mes->ExceptionRecord.ExceptionRecord); + print_longlong(" ExceptionAddress", mes->ExceptionRecord.ExceptionAddress); + printf(" ExceptionNumberParameters: %u\n", mes->ExceptionRecord.NumberParameters); for (i = 0; i < mes->ExceptionRecord.NumberParameters; i++) { - printf(" [%d]: 0x%x%08x\n", i, - (UINT)(mes->ExceptionRecord.ExceptionInformation[i] >> 32), - (UINT)mes->ExceptionRecord.ExceptionInformation[i]); + printf(" [%d]", i); + print_longlong(" ", mes->ExceptionRecord.ExceptionInformation[i]); } printf(" ThreadContext:\n"); dump_mdmp_data(&mes->ThreadContext, " "); @@ -432,9 +440,9 @@ void mdmp_dump(void) break;
default: - printf("NIY %d\n", (UINT)dir->StreamType); + printf("NIY %d\n", dir->StreamType); printf(" RVA: %u\n", (UINT)dir->Location.Rva); - printf(" Size: %u\n", (UINT)dir->Location.DataSize); + printf(" Size: %u\n", dir->Location.DataSize); dump_mdmp_data(&dir->Location, " "); break; }
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- include/minidumpapiset.h | 39 ++++++++++++++++++++++++++++++ tools/winedump/minidump.c | 50 ++++++++++++++++++++++++++++++++++----- 2 files changed, 83 insertions(+), 6 deletions(-)
diff --git a/include/minidumpapiset.h b/include/minidumpapiset.h index 5efe948bad7..997a04cc865 100644 --- a/include/minidumpapiset.h +++ b/include/minidumpapiset.h @@ -373,6 +373,38 @@ typedef struct _MINIDUMP_USER_STREAM_INFORMATION PMINIDUMP_USER_STREAM UserStreamArray; } MINIDUMP_USER_STREAM_INFORMATION, *PMINIDUMP_USER_STREAM_INFORMATION;
+typedef struct _MINIDUMP_HANDLE_DATA_STREAM +{ + ULONG32 SizeOfHeader; + ULONG32 SizeOfDescriptor; + ULONG32 NumberOfDescriptors; + ULONG32 Reserved; +} MINIDUMP_HANDLE_DATA_STREAM, *PMINIDUMP_HANDLE_DATA_STREAM; + +typedef struct _MINIDUMP_HANDLE_DESCRIPTOR +{ + ULONG64 Handle; + RVA TypeNameRva; + RVA ObjectNameRva; + ULONG32 Attributes; + ULONG32 GrantedAccess; + ULONG32 HandleCount; + ULONG32 PointerCount; +} MINIDUMP_HANDLE_DESCRIPTOR, *PMINIDUMP_HANDLE_DESCRIPTOR; + +typedef struct _MINIDUMP_HANDLE_DESCRIPTOR_2 +{ + ULONG64 Handle; + RVA TypeNameRva; + RVA ObjectNameRva; + ULONG32 Attributes; + ULONG32 GrantedAccess; + ULONG32 HandleCount; + ULONG32 PointerCount; + RVA ObjectInfoRva; + ULONG32 Reserved0; +} MINIDUMP_HANDLE_DESCRIPTOR_2, *PMINIDUMP_HANDLE_DESCRIPTOR_2; + typedef enum _MINIDUMP_STREAM_TYPE { UnusedStream = 0, @@ -393,6 +425,13 @@ typedef enum _MINIDUMP_STREAM_TYPE MiscInfoStream = 15, MemoryInfoListStream = 16, ThreadInfoListStream = 17, + HandleOperationListStream = 18, + TokenStream = 19, + JavaScriptDataStream = 20, + SystemMemoryInfoStream = 21, + ProcessVmCountersStream = 22, + IptTraceStream = 23, + ThreadNamesStream = 24,
LastReservedStream = 0xffff } MINIDUMP_STREAM_TYPE; diff --git a/tools/winedump/minidump.c b/tools/winedump/minidump.c index 9474381fd02..f8bd03ca0c5 100644 --- a/tools/winedump/minidump.c +++ b/tools/winedump/minidump.c @@ -34,7 +34,9 @@ static void dump_mdmp_data(const MINIDUMP_LOCATION_DESCRIPTOR* md, const char* p static void dump_mdmp_string(DWORD rva) { const MINIDUMP_STRING* ms = PRD(rva, sizeof(MINIDUMP_STRING)); - if (ms) + if (!rva) + printf("<<rva=0>>"); + else if (ms) dump_unicode_str( ms->Buffer, ms->Length / sizeof(WCHAR) ); else printf("<<?>>"); @@ -80,7 +82,7 @@ void mdmp_dump(void) const MINIDUMP_HEADER* hdr = PRD(0, sizeof(MINIDUMP_HEADER)); const MINIDUMP_DIRECTORY* dir; const void* stream; - unsigned int idx; + unsigned int i, idx;
if (!hdr) { @@ -110,7 +112,6 @@ void mdmp_dump(void) { const MINIDUMP_THREAD_LIST *mtl = stream; const MINIDUMP_THREAD *mt = mtl->Threads; - unsigned int i;
printf("Threads: %u\n", (UINT)mtl->NumberOfThreads); for (i = 0; i < mtl->NumberOfThreads; i++, mt++) @@ -133,7 +134,6 @@ void mdmp_dump(void) { const MINIDUMP_MODULE_LIST *mml = stream; const MINIDUMP_MODULE* mm = mml->Modules; - unsigned int i; const char* p1; const char* p2;
@@ -224,7 +224,6 @@ void mdmp_dump(void) { const MINIDUMP_MEMORY_LIST *mml = stream; const MINIDUMP_MEMORY_DESCRIPTOR* mmd = mml->MemoryRanges; - unsigned int i;
printf("Memory Ranges: %u\n", mml->NumberOfMemoryRanges); for (i = 0; i < mml->NumberOfMemoryRanges; i++, mmd++) @@ -419,7 +418,6 @@ void mdmp_dump(void) case ExceptionStream: { const MINIDUMP_EXCEPTION_STREAM *mes = stream; - unsigned int i;
printf("Exception:\n"); printf(" ThreadId: %#x\n", mes->ThreadId); @@ -438,6 +436,46 @@ void mdmp_dump(void) dump_mdmp_data(&mes->ThreadContext, " "); } break; + case HandleDataStream: + { + const MINIDUMP_HANDLE_DATA_STREAM *mhd = stream; + const BYTE *desc; + + printf("Handle data:\n"); + printf(" SizeOfHeader: %u\n", mhd->SizeOfHeader); + printf(" SizeOfDescriptor: %u\n", mhd->SizeOfDescriptor); + printf(" NumberOfDescriptors: %u\n", mhd->NumberOfDescriptors); + + desc = (BYTE *)mhd + sizeof(*mhd); + for (i = 0; i < mhd->NumberOfDescriptors; ++i) + { + const MINIDUMP_HANDLE_DESCRIPTOR_2 *hd = (void *)desc; + + printf(" Handle [%u]:\n", i); + print_longlong(" Handle", hd->Handle); + printf(" TypeName: "); + dump_mdmp_string(hd->TypeNameRva); + printf("\n"); + printf(" ObjectName: "); + dump_mdmp_string(hd->ObjectNameRva); + printf("\n"); + printf(" Attributes: %#x\n", hd->Attributes); + printf(" GrantedAccess: %#x\n", hd->GrantedAccess); + printf(" HandleCount: %u\n", hd->HandleCount); + printf(" PointerCount: %#x\n", hd->PointerCount); + + if (mhd->SizeOfDescriptor >= sizeof(MINIDUMP_HANDLE_DESCRIPTOR_2)) + { + printf(" ObjectInfo: "); + dump_mdmp_string(hd->ObjectInfoRva); + printf("\n"); + printf(" Reserved0: %#x\n", hd->Reserved0); + } + + desc += mhd->SizeOfDescriptor; + } + } + break;
default: printf("NIY %d\n", dir->StreamType);
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- include/minidumpapiset.h | 21 +++++++++++++++++++++ tools/winedump/minidump.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+)
diff --git a/include/minidumpapiset.h b/include/minidumpapiset.h index 997a04cc865..6811892e189 100644 --- a/include/minidumpapiset.h +++ b/include/minidumpapiset.h @@ -405,6 +405,27 @@ typedef struct _MINIDUMP_HANDLE_DESCRIPTOR_2 ULONG32 Reserved0; } MINIDUMP_HANDLE_DESCRIPTOR_2, *PMINIDUMP_HANDLE_DESCRIPTOR_2;
+typedef struct _MINIDUMP_THREAD_INFO +{ + ULONG32 ThreadId; + ULONG32 DumpFlags; + ULONG32 DumpError; + ULONG32 ExitStatus; + ULONG64 CreateTime; + ULONG64 ExitTime; + ULONG64 KernelTime; + ULONG64 UserTime; + ULONG64 StartAddress; + ULONG64 Affinity; +} MINIDUMP_THREAD_INFO, *PMINIDUMP_THREAD_INFO; + +typedef struct _MINIDUMP_THREAD_INFO_LIST +{ + ULONG SizeOfHeader; + ULONG SizeOfEntry; + ULONG NumberOfEntries; +} MINIDUMP_THREAD_INFO_LIST, *PMINIDUMP_THREAD_INFO_LIST; + typedef enum _MINIDUMP_STREAM_TYPE { UnusedStream = 0, diff --git a/tools/winedump/minidump.c b/tools/winedump/minidump.c index f8bd03ca0c5..734c754e6be 100644 --- a/tools/winedump/minidump.c +++ b/tools/winedump/minidump.c @@ -476,6 +476,37 @@ void mdmp_dump(void) } } break; + case ThreadInfoListStream: + { + const MINIDUMP_THREAD_INFO_LIST *til = stream; + const BYTE *desc; + + printf("Thread Info List:\n"); + printf(" SizeOfHeader: %u\n", (UINT)til->SizeOfHeader); + printf(" SizeOfEntry: %u\n", (UINT)til->SizeOfEntry); + printf(" NumberOfEntries: %u\n", (UINT)til->NumberOfEntries); + + desc = (BYTE *)til + sizeof(*til); + for (i = 0; i < til->NumberOfEntries; ++i) + { + const MINIDUMP_THREAD_INFO *ti = (void *)desc; + + printf(" Thread [%u]:\n", i); + printf(" ThreadId: %u\n", ti->ThreadId); + printf(" DumpFlags: %#x\n", ti->DumpFlags); + printf(" DumpError: %u\n", ti->DumpError); + printf(" ExitStatus: %u\n", ti->ExitStatus); + print_longlong(" CreateTime", ti->CreateTime); + print_longlong(" ExitTime", ti->ExitTime); + print_longlong(" KernelTime", ti->KernelTime); + print_longlong(" UserTime", ti->UserTime); + print_longlong(" StartAddress", ti->StartAddress); + print_longlong(" Affinity", ti->Affinity); + + desc += til->SizeOfEntry; + } + } + break;
default: printf("NIY %d\n", dir->StreamType);