Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

473 lines
8.7 KiB

  1. /*++
  2. Copyright(c) 1999-2002 Microsoft Corporation
  3. Module Name:
  4. mdump.h
  5. Abstract:
  6. Private header for minidump user-mode crashdump support.
  7. Author:
  8. Matthew D Hendel (math) 20-Aug-1999
  9. --*/
  10. #pragma once
  11. #include "platform.h"
  12. #define IsFlagSet(_var, _flag) ( ((_var) & (_flag)) != 0 )
  13. #define IsFlagClear(_var, _flag) ( !IsFlagSet(_var, _flag) )
  14. //
  15. // StartOfStack gives the lowest address of the stack. SizeOfStack gives
  16. // the size of the stack. Used together, they will give the memory region
  17. // used by the stack.
  18. //
  19. #define StartOfStack(_thread) ((_thread)->StackEnd)
  20. #define SizeOfStack(_thread) ((ULONG)((_thread)->StackBase - (_thread)->StackEnd)))
  21. // Types of memory regions.
  22. typedef enum
  23. {
  24. MEMBLOCK_OTHER,
  25. MEMBLOCK_MERGED,
  26. MEMBLOCK_STACK,
  27. MEMBLOCK_STORE,
  28. MEMBLOCK_DATA_SEG,
  29. MEMBLOCK_UNWIND_INFO,
  30. MEMBLOCK_INSTR_WINDOW,
  31. MEMBLOCK_PEB,
  32. MEMBLOCK_TEB,
  33. MEMBLOCK_INDIRECT,
  34. MEMBLOCK_PRIVATE_RW,
  35. } MEMBLOCK_TYPE;
  36. //
  37. // A VA_RANGE is a range of addresses that represents Size bytes beginning
  38. // at Start.
  39. //
  40. typedef struct _VA_RANGE {
  41. ULONG64 Start;
  42. ULONG Size;
  43. MEMBLOCK_TYPE Type;
  44. LIST_ENTRY NextLink;
  45. } VA_RANGE, *PVA_RANGE;
  46. //
  47. // INTERNAL_MODULE is the structure minidump uses internally to manage modules.
  48. // A linked list of INTERNAL_MODULE structures are built up when
  49. // GenGetProcessInfo is called.
  50. //
  51. //
  52. typedef struct _INTERNAL_MODULE {
  53. //
  54. // File handle to the image.
  55. //
  56. HANDLE FileHandle;
  57. //
  58. // Base address, size, CheckSum, and TimeDateStamp for the image.
  59. //
  60. ULONG64 BaseOfImage;
  61. ULONG SizeOfImage;
  62. ULONG CheckSum;
  63. ULONG TimeDateStamp;
  64. //
  65. // Version information for the image.
  66. //
  67. VS_FIXEDFILEINFO VersionInfo;
  68. //
  69. // Buffer and size containing NB10 record for given module.
  70. //
  71. PVOID CvRecord;
  72. ULONG SizeOfCvRecord;
  73. //
  74. // Buffer and size of MISC debug record. We only get this with
  75. // images that have been split.
  76. //
  77. PVOID MiscRecord;
  78. ULONG SizeOfMiscRecord;
  79. //
  80. // Full path to the image.
  81. //
  82. WCHAR FullPath [ MAX_PATH + 1];
  83. // Portion of full path to write in the module list. This
  84. // allows paths to be filtered out for privacy reasons.
  85. PWSTR SavePath;
  86. //
  87. // What sections of the module does the client want written.
  88. //
  89. ULONG WriteFlags;
  90. //
  91. // Next image pointer.
  92. //
  93. LIST_ENTRY ModulesLink;
  94. } INTERNAL_MODULE, *PINTERNAL_MODULE;
  95. //
  96. // INTERNAL_UNLOADED_MODULE is the structure minidump uses
  97. // internally to manage unloaded modules.
  98. // A linked list of INTERNAL_UNLOADED_MODULE structures are built up when
  99. // GenGetProcessInfo is called.
  100. //
  101. //
  102. typedef struct _INTERNAL_UNLOADED_MODULE {
  103. ULONG64 BaseOfImage;
  104. ULONG SizeOfImage;
  105. ULONG CheckSum;
  106. ULONG TimeDateStamp;
  107. //
  108. // As much of the path to the image as can be recovered.
  109. //
  110. WCHAR Path[MAX_PATH + 1];
  111. //
  112. // Next image pointer.
  113. //
  114. LIST_ENTRY ModulesLink;
  115. } INTERNAL_UNLOADED_MODULE, *PINTERNAL_UNLOADED_MODULE;
  116. //
  117. // INTERNAL_THREAD is the structure the minidump uses internally to
  118. // manage threads. A list of INTERNAL_THREAD structures is built when
  119. // GenGetProcessInfo is called.
  120. //
  121. typedef struct _INTERNAL_THREAD {
  122. //
  123. // The Win32 thread id of the thread an an open handle for the
  124. // thread.
  125. //
  126. ULONG ThreadId;
  127. HANDLE ThreadHandle;
  128. //
  129. // Suspend count, priority, priority class for the thread.
  130. //
  131. ULONG SuspendCount;
  132. ULONG PriorityClass;
  133. ULONG Priority;
  134. //
  135. // Thread TEB, Context and Size of Context.
  136. //
  137. ULONG64 Teb;
  138. ULONG SizeOfTeb;
  139. CONTEXT Context;
  140. ULONG SizeOfContext;
  141. //
  142. // Stack variables. Remember, the stack grows down, so StackBase is
  143. // the highest stack address and StackEnd is the lowest.
  144. //
  145. ULONG64 StackBase;
  146. ULONG64 StackEnd;
  147. //
  148. // Backing store variables.
  149. //
  150. ULONG64 BackingStoreBase;
  151. ULONG BackingStoreSize;
  152. //
  153. // What sections of the module we should actually write to the file.
  154. //
  155. ULONG WriteFlags;
  156. //
  157. // Link to next thread.
  158. //
  159. LIST_ENTRY ThreadsLink;
  160. } INTERNAL_THREAD, *PINTERNAL_THREAD;
  161. //
  162. // INTERNAL_FUNCTION_TABLE is the structure minidump uses
  163. // internally to manage function tables.
  164. // A linked list of INTERNAL_FUNCTION_TABLE structures is built up when
  165. // GenGetProcessInfo is called.
  166. //
  167. typedef struct _INTERNAL_FUNCTION_TABLE {
  168. ULONG64 MinimumAddress;
  169. ULONG64 MaximumAddress;
  170. ULONG64 BaseAddress;
  171. ULONG EntryCount;
  172. DYNAMIC_FUNCTION_TABLE RawTable;
  173. PVOID RawEntries;
  174. LIST_ENTRY TableLink;
  175. } INTERNAL_FUNCTION_TABLE, *PINTERNAL_FUNCTION_TABLE;
  176. typedef struct _INTERNAL_PROCESS {
  177. //
  178. // The process id for the process.
  179. //
  180. ULONG ProcessId;
  181. //
  182. // Process data.
  183. //
  184. ULONG64 Peb;
  185. ULONG SizeOfPeb;
  186. //
  187. // Process run time information.
  188. //
  189. BOOL TimesValid;
  190. ULONG CreateTime;
  191. ULONG UserTime;
  192. ULONG KernelTime;
  193. //
  194. // An open handle to the process with read permissions.
  195. //
  196. HANDLE ProcessHandle;
  197. //
  198. // Number of threads for the process.
  199. //
  200. ULONG NumberOfThreads;
  201. ULONG NumberOfThreadsToWrite;
  202. ULONG MaxStackOrStoreSize;
  203. //
  204. // Number of modules for the process.
  205. //
  206. ULONG NumberOfModules;
  207. ULONG NumberOfModulesToWrite;
  208. //
  209. // Number of unloaded modules for the process.
  210. //
  211. ULONG NumberOfUnloadedModules;
  212. //
  213. // Number of function tables for the process.
  214. //
  215. ULONG NumberOfFunctionTables;
  216. //
  217. // Thread, module and function table lists for the process.
  218. //
  219. LIST_ENTRY ThreadList;
  220. LIST_ENTRY ModuleList;
  221. LIST_ENTRY UnloadedModuleList;
  222. LIST_ENTRY FunctionTableList;
  223. //
  224. // List of memory blocks to include for the process.
  225. //
  226. LIST_ENTRY MemoryBlocks;
  227. ULONG NumberOfMemoryBlocks;
  228. ULONG SizeOfMemoryBlocks;
  229. } INTERNAL_PROCESS, *PINTERNAL_PROCESS;
  230. //
  231. // The visible streams are: (1) machine info, (2) exception, (3) thread list,
  232. // (4) module list (5) memory list (6) misc info.
  233. // We also add two extra for post-processing tools that want to add data later.
  234. //
  235. #define NUMBER_OF_STREAMS (8)
  236. //
  237. // MINIDUMP_STREAM_INFO is the structure used by the minidump to manage
  238. // it's internal data streams.
  239. //
  240. typedef struct _MINIDUMP_STREAM_INFO {
  241. //
  242. // How many streams we have.
  243. //
  244. ULONG NumberOfStreams;
  245. //
  246. // Reserved space for header.
  247. //
  248. ULONG RvaOfHeader;
  249. ULONG SizeOfHeader;
  250. //
  251. // Reserved space for directory.
  252. //
  253. ULONG RvaOfDirectory;
  254. ULONG SizeOfDirectory;
  255. //
  256. // Reserved space for system info.
  257. //
  258. ULONG RvaOfSystemInfo;
  259. ULONG SizeOfSystemInfo;
  260. ULONG VersionStringLength;
  261. //
  262. // Reserved space for misc info.
  263. //
  264. ULONG RvaOfMiscInfo;
  265. //
  266. // Reserved space for exception list.
  267. //
  268. ULONG RvaOfException;
  269. ULONG SizeOfException;
  270. //
  271. // Reserved space for thread list.
  272. //
  273. ULONG RvaOfThreadList;
  274. ULONG SizeOfThreadList;
  275. ULONG RvaForCurThread;
  276. ULONG ThreadStructSize;
  277. //
  278. // Reserved space for module list.
  279. //
  280. ULONG RvaOfModuleList;
  281. ULONG SizeOfModuleList;
  282. ULONG RvaForCurModule;
  283. //
  284. // Reserved space for unloaded module list.
  285. //
  286. ULONG RvaOfUnloadedModuleList;
  287. ULONG SizeOfUnloadedModuleList;
  288. ULONG RvaForCurUnloadedModule;
  289. //
  290. // Reserved space for function table list.
  291. //
  292. ULONG RvaOfFunctionTableList;
  293. ULONG SizeOfFunctionTableList;
  294. //
  295. // Reserved space for memory descriptors.
  296. //
  297. ULONG RvaOfMemoryDescriptors;
  298. ULONG SizeOfMemoryDescriptors;
  299. ULONG RvaForCurMemoryDescriptor;
  300. //
  301. // Reserved space for actual memory data.
  302. //
  303. ULONG RvaOfMemoryData;
  304. ULONG SizeOfMemoryData;
  305. ULONG RvaForCurMemoryData;
  306. //
  307. // Reserved space for strings.
  308. //
  309. ULONG RvaOfStringPool;
  310. ULONG SizeOfStringPool;
  311. ULONG RvaForCurString;
  312. //
  313. // Reserved space for other data like contexts, debug info records,
  314. // etc.
  315. //
  316. ULONG RvaOfOther;
  317. ULONG SizeOfOther;
  318. ULONG RvaForCurOther;
  319. //
  320. // Reserved space for user streams.
  321. //
  322. ULONG RvaOfUserStreams;
  323. ULONG SizeOfUserStreams;
  324. //
  325. // Reserved space for handle data.
  326. //
  327. ULONG RvaOfHandleData;
  328. ULONG SizeOfHandleData;
  329. } MINIDUMP_STREAM_INFO, *PMINIDUMP_STREAM_INFO;
  330. typedef struct _EXCEPTION_INFO {
  331. DWORD ThreadId;
  332. EXCEPTION_POINTERS ExceptionPointers;
  333. BOOL FreeExceptionPointers;
  334. } EXCEPTION_INFO, *PEXCEPTION_INFO;