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.

196 lines
6.5 KiB

  1. #include "ntiodump.h"
  2. //
  3. // Define the type for a dump control block. This structure is used to
  4. // describe all of the data, drivers, and memory necessary to dump all of
  5. // physical memory to the disk after a bugcheck.
  6. //
  7. typedef struct _MINIPORT_NODE {
  8. LIST_ENTRY ListEntry;
  9. PKLDR_DATA_TABLE_ENTRY DriverEntry;
  10. ULONG DriverChecksum;
  11. } MINIPORT_NODE, *PMINIPORT_NODE;
  12. #define IO_TYPE_DCB 0xff
  13. #define DCB_DUMP_ENABLED 0x01
  14. #define DCB_SUMMARY_ENABLED 0x02
  15. #define DCB_DUMP_HEADER_ENABLED 0x10
  16. #define DCB_SUMMARY_DUMP_ENABLED 0x20
  17. #define DCB_TRIAGE_DUMP_ENABLED 0x40
  18. #define DCB_TRIAGE_DUMP_ACT_UPON_ENABLED 0x80
  19. typedef struct _DUMP_CONTROL_BLOCK {
  20. UCHAR Type;
  21. CHAR Flags;
  22. USHORT Size;
  23. CCHAR NumberProcessors;
  24. CHAR Reserved;
  25. USHORT ProcessorArchitecture;
  26. PDUMP_STACK_CONTEXT DumpStack;
  27. ULONG MemoryDescriptorLength;
  28. PLARGE_INTEGER FileDescriptorArray;
  29. ULONG FileDescriptorSize;
  30. PULONG HeaderPage;
  31. PFN_NUMBER HeaderPfn;
  32. ULONG MajorVersion;
  33. ULONG MinorVersion;
  34. ULONG BuildNumber;
  35. CHAR VersionUser[32];
  36. ULONG HeaderSize; // Size of dump header includes summary dump.
  37. LARGE_INTEGER DumpFileSize; // Size of dump file.
  38. ULONG TriageDumpFlags; // Flags for triage dump.
  39. PUCHAR TriageDumpBuffer; // Buffer for triage dump.
  40. ULONG TriageDumpBufferSize; // Size of triage dump buffer.
  41. } DUMP_CONTROL_BLOCK, *PDUMP_CONTROL_BLOCK;
  42. //
  43. // Processor specific macros.
  44. //
  45. #if defined(_AMD64_)
  46. #define PROGRAM_COUNTER(_context) ((ULONG_PTR)(_context)->Rip)
  47. #define STACK_POINTER(_context) ((ULONG_PTR)(_context)->Rsp)
  48. #define CURRENT_IMAGE_TYPE() IMAGE_FILE_MACHINE_I386
  49. #define PaeEnabled() TRUE
  50. #elif defined(_X86_)
  51. #define PROGRAM_COUNTER(_context) ((_context)->Eip)
  52. #define STACK_POINTER(_context) ((_context)->Esp)
  53. #define CURRENT_IMAGE_TYPE() IMAGE_FILE_MACHINE_I386
  54. #define PaeEnabled() X86PaeEnabled()
  55. #elif defined(_ALPHA_)
  56. #define PROGRAM_COUNTER(_context) ((_context)->Fir)
  57. #define STACK_POINTER(_context) ((_context)->IntSp)
  58. #define CURRENT_IMAGE_TYPE() IMAGE_FILE_MACHINE_ALPHA
  59. #define PaeEnabled() (FALSE)
  60. #elif defined(_IA64_)
  61. #define PROGRAM_COUNTER(_context) ((_context)->StIIP)
  62. #define STACK_POINTER(_context) ((_context)->IntSp)
  63. #define CURRENT_IMAGE_TYPE() IMAGE_FILE_MACHINE_IA64
  64. #define PaeEnabled() (FALSE)
  65. #else
  66. #error ("unknown processor type")
  67. #endif
  68. //
  69. // min3(_a,_b,_c)
  70. //
  71. // Same as min() but takes 3 parameters.
  72. //
  73. #define min3(_a,_b,_c) ( min ( min ((_a), (_b)), min ((_a), (_c))) )
  74. #define CRASHDUMP_ERROR DPFLTR_ERROR_LEVEL
  75. #define CRASHDUMP_WARNING DPFLTR_WARNING_LEVEL
  76. #define CRASHDUMP_TRACE DPFLTR_TRACE_LEVEL
  77. #define CRASHDUMP_INFO DPFLTR_INFO_LEVEL
  78. #define CRASHDUMP_VERBOSE (DPFLTR_INFO_LEVEL + 100)
  79. ULONG
  80. IopGetDumpControlBlockCheck (
  81. IN PDUMP_CONTROL_BLOCK Dcb
  82. );
  83. //
  84. // The remainder of this file verifies that the DUMP_HEADER32, DUMP_HEADER64,
  85. // MEMORY_DUMP32 and MEMORY_DUMP64 structures have been defined correctly.
  86. // If you die on one of the asserts, it means you changed on of the crashdump
  87. // structures without knowing how it affected the rest of the system.
  88. //
  89. //
  90. // Define dump header longword offset constants. Note: these constants are
  91. // should no longer be used in accessing the fields. Use the MEMORY_DUMP32
  92. // and MEMORY_DUMP64 structures instead.
  93. //
  94. #define DHP_PHYSICAL_MEMORY_BLOCK (25)
  95. #define DHP_CONTEXT_RECORD (200)
  96. #define DHP_EXCEPTION_RECORD (500)
  97. #define DHP_DUMP_TYPE (994)
  98. #define DHP_REQUIRED_DUMP_SPACE (1000)
  99. #define DHP_CRASH_DUMP_TIMESTAMP (1008)
  100. #define DHP_SUMMARY_DUMP_RECORD (1024)
  101. //
  102. // Validate the MEMORY_DUMP32 structure.
  103. //
  104. C_ASSERT ( FIELD_OFFSET (DUMP_HEADER32, PhysicalMemoryBlock) == DHP_PHYSICAL_MEMORY_BLOCK * 4);
  105. C_ASSERT ( FIELD_OFFSET (DUMP_HEADER32, ContextRecord) == DHP_CONTEXT_RECORD * 4);
  106. C_ASSERT ( FIELD_OFFSET (DUMP_HEADER32, Exception) == DHP_EXCEPTION_RECORD * 4);
  107. C_ASSERT ( FIELD_OFFSET (DUMP_HEADER32, DumpType) == DHP_DUMP_TYPE * 4 );
  108. C_ASSERT ( FIELD_OFFSET (DUMP_HEADER32, RequiredDumpSpace) == DHP_REQUIRED_DUMP_SPACE * 4);
  109. C_ASSERT ( FIELD_OFFSET (DUMP_HEADER32, SystemTime) == DHP_CRASH_DUMP_TIMESTAMP * 4);
  110. C_ASSERT ( sizeof (DUMP_HEADER32) == 4096 );
  111. C_ASSERT ( FIELD_OFFSET (MEMORY_DUMP32, Summary) == 4096);
  112. //
  113. // Verify that the PHYSICAL_MEMORY_RUN and PHYSICAL_MEMORY_DESCRIPTOR
  114. // structs match up.
  115. //
  116. #if !defined (_WIN64)
  117. C_ASSERT ( sizeof (PHYSICAL_MEMORY_RUN) == sizeof (PHYSICAL_MEMORY_RUN32) &&
  118. FIELD_OFFSET (PHYSICAL_MEMORY_RUN, BasePage) ==
  119. FIELD_OFFSET (PHYSICAL_MEMORY_RUN32, BasePage) &&
  120. FIELD_OFFSET (PHYSICAL_MEMORY_RUN, PageCount) ==
  121. FIELD_OFFSET (PHYSICAL_MEMORY_RUN32, PageCount) );
  122. C_ASSERT ( sizeof (PHYSICAL_MEMORY_DESCRIPTOR) == sizeof (PHYSICAL_MEMORY_DESCRIPTOR) &&
  123. FIELD_OFFSET (PHYSICAL_MEMORY_DESCRIPTOR, NumberOfRuns) ==
  124. FIELD_OFFSET (PHYSICAL_MEMORY_DESCRIPTOR32, NumberOfRuns) &&
  125. FIELD_OFFSET (PHYSICAL_MEMORY_DESCRIPTOR, NumberOfPages) ==
  126. FIELD_OFFSET (PHYSICAL_MEMORY_DESCRIPTOR32, NumberOfPages) &&
  127. FIELD_OFFSET (PHYSICAL_MEMORY_DESCRIPTOR, Run) ==
  128. FIELD_OFFSET (PHYSICAL_MEMORY_DESCRIPTOR32, Run) );
  129. #else // IA64
  130. C_ASSERT ( sizeof (PHYSICAL_MEMORY_RUN) == sizeof (PHYSICAL_MEMORY_RUN64) &&
  131. FIELD_OFFSET (PHYSICAL_MEMORY_RUN, BasePage) ==
  132. FIELD_OFFSET (PHYSICAL_MEMORY_RUN64, BasePage) &&
  133. FIELD_OFFSET (PHYSICAL_MEMORY_RUN, PageCount) ==
  134. FIELD_OFFSET (PHYSICAL_MEMORY_RUN64, PageCount) );
  135. C_ASSERT ( sizeof (PHYSICAL_MEMORY_DESCRIPTOR) == sizeof (PHYSICAL_MEMORY_DESCRIPTOR) &&
  136. FIELD_OFFSET (PHYSICAL_MEMORY_DESCRIPTOR, NumberOfRuns) ==
  137. FIELD_OFFSET (PHYSICAL_MEMORY_DESCRIPTOR64, NumberOfRuns) &&
  138. FIELD_OFFSET (PHYSICAL_MEMORY_DESCRIPTOR, NumberOfPages) ==
  139. FIELD_OFFSET (PHYSICAL_MEMORY_DESCRIPTOR64, NumberOfPages) &&
  140. FIELD_OFFSET (PHYSICAL_MEMORY_DESCRIPTOR, Run) ==
  141. FIELD_OFFSET (PHYSICAL_MEMORY_DESCRIPTOR64, Run) );
  142. #endif
  143. //
  144. // Verify we have enough room for the CONTEXT record.
  145. //
  146. C_ASSERT (sizeof (CONTEXT) <= sizeof ((PDUMP_HEADER)NULL)->ContextRecord);
  147. #if defined(_AMD64_)
  148. C_ASSERT (sizeof (DUMP_HEADER) == (2 * PAGE_SIZE));
  149. #else
  150. C_ASSERT (sizeof (DUMP_HEADER) == PAGE_SIZE);
  151. #endif