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.

378 lines
8.9 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. crash.h
  5. Abstract:
  6. This module implements support for handling crash dump files.
  7. *** Use this file when linking against crashxxx.lib
  8. Author:
  9. Lou Perazzoli (Loup) 10-Nov-1993
  10. Wesley Witt (wesw) 1-Dec-1993 (additional work)
  11. Environment:
  12. NT 3.5
  13. Revision History:
  14. --*/
  15. #ifndef _CRASHLIB_
  16. #define _CRASHLIB_
  17. #if _MSC_VER > 1000
  18. #pragma once
  19. #endif
  20. #ifdef __cplusplus
  21. #if _MSC_VER >= 1200
  22. #pragma warning(push)
  23. #endif
  24. #pragma warning(disable:4200)
  25. extern "C" {
  26. #endif
  27. #if 0
  28. typedef struct _MEMORY_BASIC_INFORMATION32 {
  29. DWORD BaseAddress;
  30. DWORD AllocationBase;
  31. DWORD AllocationProtect;
  32. DWORD RegionSize;
  33. DWORD State;
  34. DWORD Protect;
  35. DWORD Type;
  36. } MEMORY_BASIC_INFORMATION32, *PMEMORY_BASIC_INFORMATION32;
  37. typedef struct _MEMORY_BASIC_INFORMATION64 {
  38. DWORDLONG BaseAddress;
  39. DWORDLONG AllocationBase;
  40. DWORD AllocationProtect;
  41. DWORD __alignment1;
  42. DWORDLONG RegionSize;
  43. DWORD State;
  44. DWORD Protect;
  45. DWORD Type;
  46. DWORD __alignment2;
  47. } MEMORY_BASIC_INFORMATION64, *PMEMORY_BASIC_INFORMATION64;
  48. #endif
  49. #define USERMODE_CRASHDUMP_SIGNATURE 'RESU'
  50. #define USERMODE_CRASHDUMP_VALID_DUMP32 'PMUD'
  51. #define USERMODE_CRASHDUMP_VALID_DUMP64 '46UD'
  52. typedef struct _USERMODE_CRASHDUMP_HEADER {
  53. DWORD Signature;
  54. DWORD ValidDump;
  55. DWORD MajorVersion;
  56. DWORD MinorVersion;
  57. DWORD MachineImageType;
  58. DWORD ThreadCount;
  59. DWORD ModuleCount;
  60. DWORD MemoryRegionCount;
  61. DWORD_PTR ThreadOffset;
  62. DWORD_PTR ModuleOffset;
  63. DWORD_PTR DataOffset;
  64. DWORD_PTR MemoryRegionOffset;
  65. DWORD_PTR DebugEventOffset;
  66. DWORD_PTR ThreadStateOffset;
  67. DWORD_PTR VersionInfoOffset;
  68. DWORD_PTR Spare1;
  69. } USERMODE_CRASHDUMP_HEADER, *PUSERMODE_CRASHDUMP_HEADER;
  70. typedef struct _USERMODE_CRASHDUMP_HEADER32 {
  71. DWORD Signature;
  72. DWORD ValidDump;
  73. DWORD MajorVersion;
  74. DWORD MinorVersion;
  75. DWORD MachineImageType;
  76. DWORD ThreadCount;
  77. DWORD ModuleCount;
  78. DWORD MemoryRegionCount;
  79. DWORD ThreadOffset;
  80. DWORD ModuleOffset;
  81. DWORD DataOffset;
  82. DWORD MemoryRegionOffset;
  83. DWORD DebugEventOffset;
  84. DWORD ThreadStateOffset;
  85. DWORD VersionInfoOffset;
  86. DWORD Spare1;
  87. } USERMODE_CRASHDUMP_HEADER32, *PUSERMODE_CRASHDUMP_HEADER32;
  88. typedef struct _USERMODE_CRASHDUMP_HEADER64 {
  89. DWORD Signature;
  90. DWORD ValidDump;
  91. DWORD MajorVersion;
  92. DWORD MinorVersion;
  93. DWORD MachineImageType;
  94. DWORD ThreadCount;
  95. DWORD ModuleCount;
  96. DWORD MemoryRegionCount;
  97. DWORDLONG ThreadOffset;
  98. DWORDLONG ModuleOffset;
  99. DWORDLONG DataOffset;
  100. DWORDLONG MemoryRegionOffset;
  101. DWORDLONG DebugEventOffset;
  102. DWORDLONG ThreadStateOffset;
  103. DWORDLONG VersionInfoOffset;
  104. DWORDLONG Spare1;
  105. } USERMODE_CRASHDUMP_HEADER64, *PUSERMODE_CRASHDUMP_HEADER64;
  106. typedef struct _CRASH_MODULE {
  107. DWORD_PTR BaseOfImage;
  108. DWORD SizeOfImage;
  109. DWORD ImageNameLength;
  110. CHAR ImageName[0];
  111. } CRASH_MODULE, *PCRASH_MODULE;
  112. typedef struct _CRASH_MODULE32 {
  113. DWORD BaseOfImage;
  114. DWORD SizeOfImage;
  115. DWORD ImageNameLength;
  116. CHAR ImageName[0];
  117. } CRASH_MODULE32, *PCRASH_MODULE32;
  118. typedef struct _CRASH_MODULE64 {
  119. DWORDLONG BaseOfImage;
  120. DWORD SizeOfImage;
  121. DWORD ImageNameLength;
  122. CHAR ImageName[0];
  123. } CRASH_MODULE64, *PCRASH_MODULE64;
  124. typedef struct _CRASH_THREAD {
  125. DWORD ThreadId;
  126. DWORD SuspendCount;
  127. DWORD PriorityClass;
  128. DWORD Priority;
  129. DWORD_PTR Teb;
  130. DWORD_PTR Spare0;
  131. DWORD_PTR Spare1;
  132. DWORD_PTR Spare2;
  133. DWORD_PTR Spare3;
  134. DWORD_PTR Spare4;
  135. DWORD_PTR Spare5;
  136. DWORD_PTR Spare6;
  137. } CRASH_THREAD, *PCRASH_THREAD;
  138. typedef struct _CRASH_THREAD32 {
  139. DWORD ThreadId;
  140. DWORD SuspendCount;
  141. DWORD PriorityClass;
  142. DWORD Priority;
  143. DWORD Teb;
  144. DWORD Spare0;
  145. DWORD Spare1;
  146. DWORD Spare2;
  147. DWORD Spare3;
  148. DWORD Spare4;
  149. DWORD Spare5;
  150. DWORD Spare6;
  151. } CRASH_THREAD32, *PCRASH_THREAD32;
  152. typedef struct _CRASH_THREAD64 {
  153. DWORD ThreadId;
  154. DWORD SuspendCount;
  155. DWORD PriorityClass;
  156. DWORD Priority;
  157. DWORDLONG Teb;
  158. DWORDLONG Spare0;
  159. DWORDLONG Spare1;
  160. DWORDLONG Spare2;
  161. DWORDLONG Spare3;
  162. DWORDLONG Spare4;
  163. DWORDLONG Spare5;
  164. DWORDLONG Spare6;
  165. } CRASH_THREAD64, *PCRASH_THREAD64;
  166. typedef struct _CRASHDUMP_VERSION_INFO {
  167. BOOL IgnoreGuardPages; // Whether we should ignore GuardPages or not
  168. DWORD PointerSize; // 32, 64 bit pointers
  169. } CRASHDUMP_VERSION_INFO, *PCRASHDUMP_VERSION_INFO;
  170. //
  171. // usermode crash dump data types
  172. //
  173. #define DMP_EXCEPTION 1 // obsolete
  174. #define DMP_MEMORY_BASIC_INFORMATION 2
  175. #define DMP_THREAD_CONTEXT 3
  176. #define DMP_MODULE 4
  177. #define DMP_MEMORY_DATA 5
  178. #define DMP_DEBUG_EVENT 6
  179. #define DMP_THREAD_STATE 7
  180. #define DMP_DUMP_FILE_HANDLE 8
  181. //
  182. // If a user mode API fails, GetLastError may return one of these error values
  183. //
  184. #define ERROR_DMP_INITIALIZENOTCALLED _HRESULT_TYPEDEF_(0xEFFF0001)
  185. #define ERROR_DMP_NOTUSERMODE _HRESULT_TYPEDEF_(0xEFFF0002)
  186. #define ERROR_DMP_HDR_THREADCOUNT _HRESULT_TYPEDEF_(0xEFFF0003)
  187. #define ERROR_DMP_HDR_MODULECOUNT _HRESULT_TYPEDEF_(0xEFFF0004)
  188. #define ERROR_DMP_HDR_MEMORYREGIONCOUNT _HRESULT_TYPEDEF_(0xEFFF0005)
  189. #define ERROR_DMP_HDR_THREADOFFSET _HRESULT_TYPEDEF_(0xEFFF0006)
  190. #define ERROR_DMP_HDR_MODULEOFFSET _HRESULT_TYPEDEF_(0xEFFF0007)
  191. #define ERROR_DMP_HDR_DATAOFFSET _HRESULT_TYPEDEF_(0xEFFF0008)
  192. #define ERROR_DMP_HDR_MEMORYREGIONOFFSET _HRESULT_TYPEDEF_(0xEFFF0009)
  193. #define ERROR_DMP_HDR_DEBUGEVENTOFFSET _HRESULT_TYPEDEF_(0xEFFF000A)
  194. #define ERROR_DMP_HDR_THREADSTATEOFFSET _HRESULT_TYPEDEF_(0xEFFF000B)
  195. #define ERROR_DMP_HDR_VERSIONINFOOFFSET _HRESULT_TYPEDEF_(0xEFFF000C)
  196. #define ERROR_DMP_HDR_SPARE1 _HRESULT_TYPEDEF_(0xEFFF000D)
  197. #define ERROR_DMP_OLD_VERSION _HRESULT_TYPEDEF_(0xEFFF000E)
  198. //
  199. // usermode crashdump error values
  200. //
  201. #define ERROR_DMP_DEBUG_EVENT _HRESULT_TYPEDEF_(0xEFFF000F)
  202. #define ERROR_DMP_MEMORY_MAP _HRESULT_TYPEDEF_(0xEFFF0010)
  203. #define ERROR_DMP_THREAD_CONTEXT _HRESULT_TYPEDEF_(0xEFFF0011)
  204. #define ERROR_DMP_THREAD_STATE _HRESULT_TYPEDEF_(0xEFFF0012)
  205. #define ERROR_DMP_MODULE_TABLE _HRESULT_TYPEDEF_(0xEFFF0013)
  206. //
  207. // usermode crashdump callback function
  208. //
  209. typedef BOOL (WINAPI *PDMP_CREATE_DUMP_CALLBACK)(
  210. DWORD DataType,
  211. PVOID* DumpData,
  212. LPDWORD DumpDataLength,
  213. PVOID UserData
  214. );
  215. BOOL
  216. WINAPI
  217. DmpCreateUserDump(
  218. IN LPSTR CrashDumpName,
  219. IN PDMP_CREATE_DUMP_CALLBACK DmpCallback,
  220. IN PVOID lpv
  221. );
  222. BOOL
  223. WINAPI
  224. DmpCreateUserDumpW(
  225. IN LPWSTR CrashDumpName,
  226. IN PDMP_CREATE_DUMP_CALLBACK DmpCallback,
  227. IN PVOID lpv
  228. );
  229. BOOL
  230. WINAPI
  231. DmpInitialize (
  232. IN LPSTR FileName,
  233. OUT PCONTEXT *Context,
  234. OUT PEXCEPTION_RECORD *Exception,
  235. OUT PVOID *DmpHeader
  236. );
  237. VOID
  238. WINAPI
  239. DmpUnInitialize (
  240. VOID
  241. );
  242. DWORD
  243. WINAPI
  244. DmpReadMemory (
  245. IN ULONG64 BaseAddress,
  246. IN PVOID Buffer,
  247. IN ULONG Size
  248. );
  249. DWORD
  250. WINAPI
  251. DmpWriteMemory (
  252. IN ULONG64 BaseAddress,
  253. IN PVOID Buffer,
  254. IN ULONG Size
  255. );
  256. DWORD
  257. WINAPI
  258. DmpReadPhysicalMemory (
  259. IN ULONG64 BaseAddress,
  260. IN PVOID Buffer,
  261. IN ULONG Size
  262. );
  263. DWORD
  264. WINAPI
  265. DmpWritePhysicalMemory (
  266. IN ULONG64 BaseAddress,
  267. IN PVOID Buffer,
  268. IN ULONG Size
  269. );
  270. DWORD
  271. WINAPI
  272. DmpReadFileByteOffset (
  273. IN ULONG FileByteOffset,
  274. IN PVOID Buffer,
  275. IN ULONG Size
  276. );
  277. BOOL
  278. WINAPI
  279. DmpReadControlSpace(
  280. IN USHORT Processor,
  281. IN ULONG64 TargetBaseAddress,
  282. OUT PVOID UserInterfaceBuffer,
  283. OUT ULONG TransferCount,
  284. OUT PULONG ActualBytesRead
  285. );
  286. BOOL
  287. WINAPI
  288. DmpGetContext(
  289. IN ULONG Processor,
  290. OUT PVOID Context
  291. );
  292. INT
  293. WINAPI
  294. DmpGetCurrentProcessor(
  295. VOID
  296. );
  297. BOOL
  298. WINAPI
  299. DmpGetThread(
  300. IN ULONG ThreadIndex,
  301. OUT PCRASH_THREAD Thread
  302. );
  303. BOOL
  304. WINAPI
  305. DmpDetectVersionParameters(
  306. CRASHDUMP_VERSION_INFO* VersionInfo
  307. );
  308. BOOL
  309. WINAPI
  310. DmpSetVersionParameters(
  311. PCRASHDUMP_VERSION_INFO VersionInfo
  312. );
  313. BOOL
  314. WINAPI
  315. DmpValidateDumpFile(
  316. BOOL ThoroughCheck
  317. );
  318. #ifdef __cplusplus
  319. }
  320. #if _MSC_VER >= 1200
  321. #pragma warning(pop)
  322. #else
  323. #pragma warning(default:4200)
  324. #endif
  325. #endif
  326. #endif