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.

226 lines
5.5 KiB

  1. /*++
  2. Copyright (c) 1999-2001 Microsoft Corporation
  3. Module Name:
  4. opaqueid.c
  5. Abstract:
  6. Dumps the Opaque ID table.
  7. Author:
  8. Keith Moore (keithmo) 10-Sep-1999
  9. Environment:
  10. User Mode.
  11. Revision History:
  12. --*/
  13. #include "precomp.h"
  14. //
  15. // Private prototypes.
  16. //
  17. //
  18. // Public functions.
  19. //
  20. DECLARE_API( opaqueid )
  21. /*++
  22. Routine Description:
  23. Dumps the Opaque ID table.
  24. Arguments:
  25. None.
  26. Return Value:
  27. None.
  28. --*/
  29. {
  30. ULONG_PTR address;
  31. UL_ALIGNED_OPAQUE_ID_TABLE OpaqueIdTables[MAXIMUM_PROCESSORS];
  32. PUL_OPAQUE_ID_TABLE_ENTRY *firstLevelTable = NULL;
  33. ULONG firstLevelTableInUse;
  34. ULONG result;
  35. LONG iSubTable, i, j, k;
  36. LONG BaseIdCyclic;
  37. LONG SecondaryIdCyclic;
  38. CHAR signature[sizeof("1234")];
  39. UL_OPAQUE_ID_TABLE_ENTRY secondLevelTable[SECOND_LEVEL_TABLE_SIZE];
  40. UL_OPAQUE_ID_INTERNAL internal;
  41. LONG NumberOfProcessors;
  42. SNAPSHOT_EXTENSION_DATA();
  43. //
  44. // CODEWORK: Add a read-variable function to encapsulate all of
  45. // this repetitive goo
  46. //
  47. //
  48. // Read the size of the first-level lookup table.
  49. //
  50. address = GetExpression( "&http!g_UlOpaqueIdTable" );
  51. if (address == 0)
  52. {
  53. dprintf( "opaqueid: cannot find http!g_UlOpaqueIdTable\n" );
  54. goto cleanup;
  55. }
  56. if (!ReadMemory(
  57. address,
  58. &OpaqueIdTables[0],
  59. sizeof(OpaqueIdTables),
  60. &result
  61. ))
  62. {
  63. dprintf(
  64. "opaqueid: cannot read g_UlOpaqueIdTable[0..%u] @ %p\n",
  65. MAXIMUM_PROCESSORS-1, address
  66. );
  67. goto cleanup;
  68. }
  69. address = GetExpression( "&http!g_UlNumberOfProcessors" );
  70. if (address == 0)
  71. {
  72. dprintf( "opaqueid: cannot find http!g_UlNumberOfProcessors\n" );
  73. goto cleanup;
  74. }
  75. if (!ReadMemory(
  76. address,
  77. &NumberOfProcessors,
  78. sizeof(NumberOfProcessors),
  79. &result
  80. ))
  81. {
  82. dprintf(
  83. "opaqueid: cannot read g_UlNumberOfProcessors @ %p\n",
  84. address
  85. );
  86. goto cleanup;
  87. }
  88. dprintf( "(%u subtables)\n\n", NumberOfProcessors);
  89. for (iSubTable = 0; iSubTable < NumberOfProcessors; iSubTable++)
  90. {
  91. //
  92. // Allocate and read the first level table.
  93. //
  94. firstLevelTableInUse = OpaqueIdTables[iSubTable].OpaqueIdTable.FirstLevelTableInUse;
  95. firstLevelTable = (PUL_OPAQUE_ID_TABLE_ENTRY*)
  96. ALLOC( firstLevelTableInUse * sizeof(*firstLevelTable) );
  97. if (firstLevelTable == NULL)
  98. {
  99. dprintf("opaqueid: cannot allocate FirstLevelTable[%u]"
  100. " (%u entries)\n",
  101. iSubTable, firstLevelTableInUse);
  102. goto cleanup;
  103. }
  104. if (!ReadMemory(
  105. (ULONG_PTR) OpaqueIdTables[iSubTable].OpaqueIdTable.FirstLevelTable,
  106. firstLevelTable,
  107. firstLevelTableInUse * sizeof(*firstLevelTable),
  108. &result
  109. ))
  110. {
  111. dprintf(
  112. "opaqueid: cannot read "
  113. "OpaqueIdTables[%u].FirstLevelTable @ %p\n",
  114. iSubTable,
  115. OpaqueIdTables[iSubTable].OpaqueIdTable.FirstLevelTable
  116. );
  117. goto cleanup;
  118. }
  119. dprintf( "opaqueid: OpaqueIdTables[%u].FirstLevelTable @ %p\n",
  120. iSubTable,
  121. OpaqueIdTables[iSubTable].OpaqueIdTable.FirstLevelTable);
  122. #ifdef OPAQUE_ID_INSTRUMENTATION
  123. dprintf( "\tNumberOfAllocations=%I64d, NumberOfFrees=%I64d, "
  124. "NumberOfTotalGets=%I64d, NumberOfSuccessfulGets=%I64d, "
  125. "Reallocs=%d.\n",
  126. OpaqueIdTables[iSubTable].OpaqueIdTable.NumberOfAllocations,
  127. OpaqueIdTables[iSubTable].OpaqueIdTable.NumberOfFrees,
  128. OpaqueIdTables[iSubTable].OpaqueIdTable.NumberOfTotalGets,
  129. OpaqueIdTables[iSubTable].OpaqueIdTable.NumberOfSuccessfulGets,
  130. firstLevelTableInUse);
  131. #endif // OPAQUE_ID_INSTRUMENTATION
  132. for (i = 0 ; i < (LONG)firstLevelTableInUse ; i++)
  133. {
  134. dprintf( " SecondLevelTable[%u] @ %p\n",
  135. i, firstLevelTable[i] );
  136. if (!ReadMemory(
  137. (ULONG_PTR) firstLevelTable[i],
  138. secondLevelTable,
  139. sizeof(secondLevelTable),
  140. &result
  141. ))
  142. {
  143. dprintf( " cannot read SecondLevelTable[%u] @ %p\n",
  144. i, firstLevelTable[i] );
  145. continue;
  146. }
  147. for (j = SECOND_LEVEL_TABLE_SIZE ; --j>= 0 ; )
  148. {
  149. if (secondLevelTable[j].OpaqueIdType != UlOpaqueIdTypeInvalid)
  150. {
  151. dprintf(
  152. " pContext - %p, "
  153. " EntryOpaqueIdCyclic - %x, "
  154. " Lock %x, "
  155. " OpaqueIdCyclic - %x, "
  156. " OpaqueIdType - %d.\n",
  157. secondLevelTable[j].pContext,
  158. secondLevelTable[j].EntryOpaqueIdCyclic,
  159. secondLevelTable[j].Lock,
  160. secondLevelTable[j].OpaqueIdCyclic,
  161. secondLevelTable[j].OpaqueIdType
  162. );
  163. }
  164. }
  165. }
  166. FREE( firstLevelTable );
  167. firstLevelTable = NULL;
  168. }
  169. cleanup:
  170. if (firstLevelTable != NULL)
  171. {
  172. FREE( firstLevelTable );
  173. }
  174. } // opaqueid