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.

187 lines
4.9 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. errorlog.c
  5. Abstract:
  6. WinDbg Extension Api
  7. Author:
  8. Wesley Witt (wesw) 15-Aug-1993
  9. Environment:
  10. User Mode.
  11. Revision History:
  12. --*/
  13. #include "precomp.h"
  14. #pragma hdrstop
  15. DECLARE_API( errlog )
  16. /*++
  17. Routine Description:
  18. This routine dumps the contents of the error log list. It uses a nasty
  19. hack to get started (i.e. a duplicate structure definition) because the
  20. error log list entries are not defined in a public header.
  21. Arguments:
  22. args - not used
  23. Return Value:
  24. None
  25. --*/
  26. {
  27. ULONG64 listAddress;
  28. ULONG result;
  29. ULONG i;
  30. ULONG64 next;
  31. ULONG64 entryAddress;
  32. ULONG64 HeadFlink;
  33. ULONG ErrLogOff, DataOff;
  34. listAddress = GetNtDebuggerData( IopErrorLogListHead );
  35. if (!listAddress) {
  36. dprintf("Can't find error log list head\n");
  37. goto exit;
  38. }
  39. if (GetFieldValue(listAddress,
  40. "nt!_LIST_ENTRY",
  41. "Flink",
  42. HeadFlink)) {
  43. dprintf("%08p: Could not read error log list head\n", listAddress);
  44. goto exit;
  45. }
  46. //
  47. // walk the list.
  48. //
  49. next = HeadFlink;
  50. if (next == 0) {
  51. dprintf("ErrorLog is empty\n");
  52. goto exit;
  53. }
  54. if (next == listAddress) {
  55. dprintf("errorlog is empty\n");
  56. } else {
  57. dprintf("PacketAdr DeviceObj DriverObj Function ErrorCode UniqueVal FinalStat\n");
  58. }
  59. GetFieldOffset("nt!ERROR_LOG_ENTRY", "ListEntry", &ErrLogOff);
  60. GetFieldOffset("nt!IO_ERROR_LOG_PACKET", "DumpData", &DataOff);
  61. while(next != listAddress) {
  62. ULONG64 DeviceObject, DriverObject;
  63. ULONG DumpDataSize;
  64. if (next != 0) {
  65. entryAddress = next - ErrLogOff;
  66. } else {
  67. break;
  68. }
  69. //
  70. // Read the internal error log packet structure.
  71. //
  72. if (GetFieldValue(entryAddress,
  73. "nt!ERROR_LOG_ENTRY",
  74. "DeviceObject",
  75. DeviceObject)) {
  76. dprintf("%08p: Cannot read entry\n", entryAddress);
  77. goto exit;
  78. }
  79. GetFieldValue(entryAddress,"ERROR_LOG_ENTRY","DriverObject", DriverObject);
  80. GetFieldValue(entryAddress,"ERROR_LOG_ENTRY","ListEntry.Flink", next);
  81. //
  82. // now calculate the address and read the io_error_log_packet
  83. //
  84. entryAddress = entryAddress + GetTypeSize("ERROR_LOG_ENTRY");
  85. if (GetFieldValue(entryAddress,
  86. "nt!IO_ERROR_LOG_PACKET",
  87. "DumpDataSize",
  88. DumpDataSize)) {
  89. dprintf("%08p: Cannot read packet\n", entryAddress);
  90. goto exit;
  91. }
  92. //
  93. // read again to get the dumpdata if necessary. This just rereads
  94. // the entire packet into a new buffer and hopes the cache is enabled
  95. // behind the DbgKdReadxx routine for performance.
  96. //
  97. InitTypeRead(entryAddress, nt!IO_ERROR_LOG_PACKET);
  98. dprintf("%08p %08p %08p %2x %08lx %08lx %08lx\n",
  99. entryAddress,
  100. DeviceObject,
  101. DriverObject,
  102. (UCHAR) ReadField(MajorFunctionCode),
  103. (ULONG) ReadField(ErrorCode),
  104. (ULONG) ReadField(UniqueErrorValue),
  105. (ULONG) ReadField(FinalStatus));
  106. dprintf("\t\t ");
  107. DumpDriver(DriverObject, 0, 0);
  108. if (DumpDataSize) {
  109. PULONG dumpData = NULL;
  110. dumpData = LocalAlloc(LPTR, DumpDataSize);
  111. if (dumpData == NULL) {
  112. dprintf("Cannot allocate memory for dumpData (%u)\n", DumpDataSize);
  113. goto exit;
  114. }
  115. if ((!ReadMemory(entryAddress + DataOff,
  116. dumpData,
  117. DumpDataSize,
  118. &result)) || (result != DumpDataSize)) {
  119. LocalFree(dumpData);
  120. dprintf("%08p: Cannot read packet and dump data\n", entryAddress);
  121. goto exit;
  122. }
  123. dprintf("\n\t\t DumpData: ");
  124. for (i = 0; (i * sizeof(ULONG)) < DumpDataSize; i++) {
  125. dprintf("%08lx ", dumpData[i]);
  126. if ((i & 0x03) == 0x03) {
  127. dprintf("\n\t\t ");
  128. }
  129. if (CheckControlC()) {
  130. break;
  131. }
  132. }
  133. LocalFree(dumpData);
  134. }
  135. dprintf("\n");
  136. if (CheckControlC()) {
  137. goto exit;
  138. }
  139. }
  140. exit:
  141. return S_OK;
  142. }