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.

211 lines
3.5 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. Lists.c
  5. Abstract:
  6. WinDbg Extension Api
  7. Author:
  8. Gary Kimura [GaryKi] 25-Mar-96
  9. Environment:
  10. User Mode.
  11. Revision History:
  12. --*/
  13. #include "precomp.h"
  14. #pragma hdrstop
  15. #define ReadAtAddress(A,V,S,R) \
  16. (ReadMemory( (A), &(V), (S), &R ) && (R >= (S)))
  17. #define BIG_READ (sizeof(ULONG) * 4)
  18. #define SMALL_READ (sizeof(ULONG) * 2)
  19. VOID
  20. DumpListByLinks (
  21. IN ULONG64 StartAddress,
  22. IN ULONG MaxCount,
  23. IN ULONG Bias,
  24. IN LOGICAL UseFlink
  25. )
  26. /*++
  27. Routine Description:
  28. Dump a list by its blinks.
  29. Arguments:
  30. arg - [Address] [count] [bias]
  31. Return Value:
  32. None
  33. --*/
  34. {
  35. ULONG64 Address;
  36. ULONG Buffer[4];
  37. ULONG ReadSize;
  38. ULONG BytesRead;
  39. ULONG Count;
  40. //
  41. // set our starting address and then while the count is greater than zero
  42. // and the starting address is not equal to the current dumping address
  43. // we'll read in 4 ulongs, dump them, and then go through the flink&blink
  44. // using the specified bias.
  45. //
  46. if (!IsPtr64()) {
  47. StartAddress = (ULONG64) (LONG64) (LONG) StartAddress;
  48. }
  49. Address = StartAddress;
  50. ReadSize = BIG_READ;
  51. for (Count = 0; Count < MaxCount; ) {
  52. if (ReadAtAddress( Address, Buffer, ReadSize, BytesRead ) == 0) {
  53. ReadSize = SMALL_READ;
  54. if (ReadAtAddress( Address, Buffer, ReadSize, BytesRead ) == 0) {
  55. dprintf("Can't Read Memory at %08lx\n", Address);
  56. break;
  57. }
  58. }
  59. if (ReadSize == BIG_READ) {
  60. dprintf("%08p %08lx %08lx %08lx %08lx\n", Address, Buffer[0], Buffer[1], Buffer[2], Buffer[3]);
  61. }
  62. else {
  63. dprintf("%08p %08lx %08lx\n", Address, Buffer[0], Buffer[1]);
  64. }
  65. Count += 1;
  66. //
  67. // the bias tells us which bits to knock out of the pointer
  68. //
  69. if (UseFlink == TRUE) {
  70. GetFieldValue(Address, "LIST_ENTRY", "Flink", Address);
  71. Address &= ~((ULONG64)Bias);
  72. }
  73. else {
  74. GetFieldValue(Address, "LIST_ENTRY", "Blink", Address);
  75. Address &= ~((ULONG64)Bias);
  76. }
  77. if (Address == StartAddress) {
  78. break;
  79. }
  80. if (((Count & 0xf) == 0) && CheckControlC() ) {
  81. break;
  82. }
  83. }
  84. if (Count != 0) {
  85. dprintf("0x%x entries dumped\n", Count);
  86. }
  87. return;
  88. }
  89. DECLARE_API( dflink )
  90. /*++
  91. Routine Description:
  92. Dump a list by its flinks.
  93. Arguments:
  94. arg - [Address] [count] [bias]
  95. Return Value:
  96. None
  97. --*/
  98. {
  99. ULONG64 StartAddress;
  100. ULONG Count;
  101. ULONG Bias;
  102. StartAddress = 0;
  103. Count = 0x20;
  104. Bias = 0;
  105. //
  106. // read in the parameters
  107. //
  108. if (GetExpressionEx(args,&StartAddress, &args)) {
  109. if (!sscanf(args, "%lx %lx", &Count, &Bias)) {
  110. Bias = 0;
  111. }
  112. }
  113. DumpListByLinks (StartAddress, Count, Bias, TRUE);
  114. return S_OK;
  115. }
  116. DECLARE_API( dblink )
  117. /*++
  118. Routine Description:
  119. Dump a list by its blinks.
  120. Arguments:
  121. arg - [Address] [count] [bias]
  122. Return Value:
  123. None
  124. --*/
  125. {
  126. ULONG64 StartAddress;
  127. ULONG Count;
  128. ULONG Bias;
  129. StartAddress = 0;
  130. Count = 0x20;
  131. Bias = 0;
  132. //
  133. // read in the parameters
  134. //
  135. if (GetExpressionEx(args,&StartAddress, &args)) {
  136. if (!sscanf(args, "%lx %lx", &Count, &Bias)) {
  137. Bias = 0;
  138. }
  139. }
  140. DumpListByLinks (StartAddress, Count, Bias, FALSE);
  141. return S_OK;
  142. }