Leaked source code of windows server 2003
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.

189 lines
6.4 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_AMD64
  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(_IA64_)
  56. #define PROGRAM_COUNTER(_context) ((_context)->StIIP)
  57. #define STACK_POINTER(_context) ((_context)->IntSp)
  58. #define CURRENT_IMAGE_TYPE() IMAGE_FILE_MACHINE_IA64
  59. #define PaeEnabled() (FALSE)
  60. #else
  61. #error ("unknown processor type")
  62. #endif
  63. //
  64. // min3(_a,_b,_c)
  65. //
  66. // Same as min() but takes 3 parameters.
  67. //
  68. #define min3(_a,_b,_c) ( min ( min ((_a), (_b)), min ((_a), (_c))) )
  69. #define CRASHDUMP_ERROR DPFLTR_ERROR_LEVEL
  70. #define CRASHDUMP_WARNING DPFLTR_WARNING_LEVEL
  71. #define CRASHDUMP_TRACE DPFLTR_TRACE_LEVEL
  72. #define CRASHDUMP_INFO DPFLTR_INFO_LEVEL
  73. #define CRASHDUMP_VERBOSE (DPFLTR_INFO_LEVEL + 100)
  74. ULONG
  75. IopGetDumpControlBlockCheck (
  76. IN PDUMP_CONTROL_BLOCK Dcb
  77. );
  78. //
  79. // The remainder of this file verifies that the DUMP_HEADER32, DUMP_HEADER64,
  80. // MEMORY_DUMP32 and MEMORY_DUMP64 structures have been defined correctly.
  81. // If you die on one of the asserts, it means you changed on of the crashdump
  82. // structures without knowing how it affected the rest of the system.
  83. //
  84. //
  85. // Define dump header longword offset constants. Note: these constants are
  86. // should no longer be used in accessing the fields. Use the MEMORY_DUMP32
  87. // and MEMORY_DUMP64 structures instead.
  88. //
  89. #define DHP_PHYSICAL_MEMORY_BLOCK (25)
  90. #define DHP_CONTEXT_RECORD (200)
  91. #define DHP_EXCEPTION_RECORD (500)
  92. #define DHP_DUMP_TYPE (994)
  93. #define DHP_REQUIRED_DUMP_SPACE (1000)
  94. #define DHP_CRASH_DUMP_TIMESTAMP (1008)
  95. #define DHP_SUMMARY_DUMP_RECORD (1024)
  96. //
  97. // Validate the MEMORY_DUMP32 structure.
  98. //
  99. C_ASSERT ( FIELD_OFFSET (DUMP_HEADER32, PhysicalMemoryBlock) == DHP_PHYSICAL_MEMORY_BLOCK * 4);
  100. C_ASSERT ( FIELD_OFFSET (DUMP_HEADER32, ContextRecord) == DHP_CONTEXT_RECORD * 4);
  101. C_ASSERT ( FIELD_OFFSET (DUMP_HEADER32, Exception) == DHP_EXCEPTION_RECORD * 4);
  102. C_ASSERT ( FIELD_OFFSET (DUMP_HEADER32, DumpType) == DHP_DUMP_TYPE * 4 );
  103. C_ASSERT ( FIELD_OFFSET (DUMP_HEADER32, RequiredDumpSpace) == DHP_REQUIRED_DUMP_SPACE * 4);
  104. C_ASSERT ( FIELD_OFFSET (DUMP_HEADER32, SystemTime) == DHP_CRASH_DUMP_TIMESTAMP * 4);
  105. C_ASSERT ( sizeof (DUMP_HEADER32) == 4096 );
  106. C_ASSERT ( FIELD_OFFSET (MEMORY_DUMP32, Summary) == 4096);
  107. //
  108. // Verify that the PHYSICAL_MEMORY_RUN and PHYSICAL_MEMORY_DESCRIPTOR
  109. // structs match up.
  110. //
  111. #if !defined (_WIN64)
  112. C_ASSERT ( sizeof (PHYSICAL_MEMORY_RUN) == sizeof (PHYSICAL_MEMORY_RUN32) &&
  113. FIELD_OFFSET (PHYSICAL_MEMORY_RUN, BasePage) ==
  114. FIELD_OFFSET (PHYSICAL_MEMORY_RUN32, BasePage) &&
  115. FIELD_OFFSET (PHYSICAL_MEMORY_RUN, PageCount) ==
  116. FIELD_OFFSET (PHYSICAL_MEMORY_RUN32, PageCount) );
  117. C_ASSERT ( sizeof (PHYSICAL_MEMORY_DESCRIPTOR) == sizeof (PHYSICAL_MEMORY_DESCRIPTOR) &&
  118. FIELD_OFFSET (PHYSICAL_MEMORY_DESCRIPTOR, NumberOfRuns) ==
  119. FIELD_OFFSET (PHYSICAL_MEMORY_DESCRIPTOR32, NumberOfRuns) &&
  120. FIELD_OFFSET (PHYSICAL_MEMORY_DESCRIPTOR, NumberOfPages) ==
  121. FIELD_OFFSET (PHYSICAL_MEMORY_DESCRIPTOR32, NumberOfPages) &&
  122. FIELD_OFFSET (PHYSICAL_MEMORY_DESCRIPTOR, Run) ==
  123. FIELD_OFFSET (PHYSICAL_MEMORY_DESCRIPTOR32, Run) );
  124. #else // IA64
  125. C_ASSERT ( sizeof (PHYSICAL_MEMORY_RUN) == sizeof (PHYSICAL_MEMORY_RUN64) &&
  126. FIELD_OFFSET (PHYSICAL_MEMORY_RUN, BasePage) ==
  127. FIELD_OFFSET (PHYSICAL_MEMORY_RUN64, BasePage) &&
  128. FIELD_OFFSET (PHYSICAL_MEMORY_RUN, PageCount) ==
  129. FIELD_OFFSET (PHYSICAL_MEMORY_RUN64, PageCount) );
  130. C_ASSERT ( sizeof (PHYSICAL_MEMORY_DESCRIPTOR) == sizeof (PHYSICAL_MEMORY_DESCRIPTOR) &&
  131. FIELD_OFFSET (PHYSICAL_MEMORY_DESCRIPTOR, NumberOfRuns) ==
  132. FIELD_OFFSET (PHYSICAL_MEMORY_DESCRIPTOR64, NumberOfRuns) &&
  133. FIELD_OFFSET (PHYSICAL_MEMORY_DESCRIPTOR, NumberOfPages) ==
  134. FIELD_OFFSET (PHYSICAL_MEMORY_DESCRIPTOR64, NumberOfPages) &&
  135. FIELD_OFFSET (PHYSICAL_MEMORY_DESCRIPTOR, Run) ==
  136. FIELD_OFFSET (PHYSICAL_MEMORY_DESCRIPTOR64, Run) );
  137. #endif
  138. //
  139. // Verify we have enough room for the CONTEXT record.
  140. //
  141. C_ASSERT (sizeof (CONTEXT) <= sizeof ((PDUMP_HEADER)NULL)->ContextRecord);
  142. #if defined(_AMD64_)
  143. C_ASSERT (sizeof (DUMP_HEADER) == (2 * PAGE_SIZE));
  144. #else
  145. C_ASSERT (sizeof (DUMP_HEADER) == PAGE_SIZE);
  146. #endif