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.

235 lines
4.5 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. reqext.c
  5. Abstract:
  6. This file contains the generic routines
  7. for debugging NBF request structures.
  8. Author:
  9. Chaitanya Kodeboyina
  10. Environment:
  11. User Mode
  12. --*/
  13. #include "precomp.h"
  14. #pragma hdrstop
  15. #include "reqext.h"
  16. //
  17. // Exported Functions
  18. //
  19. DECLARE_API( reqs )
  20. /*++
  21. Routine Description:
  22. Print a list of requests given the
  23. head LIST_ENTRY.
  24. Arguments:
  25. args - Address of the list entry, &
  26. Detail of debug information
  27. Return Value:
  28. None
  29. --*/
  30. {
  31. ULONG proxyPtr;
  32. ULONG printDetail;
  33. // Get list-head address & debug print level
  34. printDetail = SUMM_INFO;
  35. if (*args)
  36. {
  37. sscanf(args, "%x %lu", &proxyPtr, &printDetail);
  38. }
  39. PrintRequestList(NULL, proxyPtr, printDetail);
  40. }
  41. DECLARE_API( req )
  42. /*++
  43. Routine Description:
  44. Print the NBF Request at a location
  45. Arguments:
  46. args -
  47. Pointer to the NBF Request
  48. Detail of debug information
  49. Return Value:
  50. None
  51. --*/
  52. {
  53. TP_REQUEST Request;
  54. ULONG printDetail;
  55. ULONG proxyPtr;
  56. // Get the detail of debug information needed
  57. printDetail = NORM_SHAL;
  58. if (*args)
  59. {
  60. sscanf(args, "%x %lu", &proxyPtr, &printDetail);
  61. }
  62. // Get the NBF Request
  63. if (ReadRequest(&Request, proxyPtr) != 0)
  64. return;
  65. // Print this Request
  66. PrintRequest(&Request, proxyPtr, printDetail);
  67. }
  68. //
  69. // Global Helper Functions
  70. //
  71. VOID
  72. PrintRequestList(PVOID ListEntryPointer, ULONG ListEntryProxy, ULONG printDetail)
  73. {
  74. TP_REQUEST Request;
  75. LIST_ENTRY RequestList;
  76. PLIST_ENTRY RequestListPtr;
  77. PLIST_ENTRY RequestListProxy;
  78. PLIST_ENTRY p, q;
  79. ULONG proxyPtr;
  80. ULONG numReqs;
  81. ULONG bytesRead;
  82. // Get list-head address & debug print level
  83. proxyPtr = ListEntryProxy;
  84. if (ListEntryPointer == NULL)
  85. {
  86. // Read the list entry of NBF requests
  87. if (!ReadMemory(proxyPtr, &RequestList, sizeof(LIST_ENTRY), &bytesRead))
  88. {
  89. dprintf("%s @ %08x: Could not read structure\n",
  90. "Request ListEntry", proxyPtr);
  91. return;
  92. }
  93. RequestListPtr = &RequestList;
  94. }
  95. else
  96. {
  97. RequestListPtr = ListEntryPointer;
  98. }
  99. // Traverse the doubly linked list
  100. dprintf("Requests:\n");
  101. RequestListProxy = (PLIST_ENTRY)proxyPtr;
  102. numReqs = 0;
  103. p = RequestListPtr->Flink;
  104. while (p != RequestListProxy)
  105. {
  106. // Another Request
  107. numReqs++;
  108. // Get Request Ptr
  109. proxyPtr = (ULONG) CONTAINING_RECORD (p, TP_REQUEST, Linkage);
  110. // Get NBF Request
  111. if (ReadRequest(&Request, proxyPtr) != 0)
  112. break;
  113. // Print the Request
  114. PrintRequest(&Request, proxyPtr, printDetail);
  115. // Go to the next one
  116. p = Request.Linkage.Flink;
  117. // Free the Request
  118. FreeRequest(&Request);
  119. }
  120. if (p == RequestListProxy)
  121. {
  122. dprintf("Number of Requests: %lu\n", numReqs);
  123. }
  124. }
  125. //
  126. // Local Helper Functions
  127. //
  128. UINT
  129. ReadRequest(PTP_REQUEST pReq, ULONG proxyPtr)
  130. {
  131. ULONG bytesRead;
  132. // Read the current NBF request
  133. if (!ReadMemory(proxyPtr, pReq, sizeof(TP_REQUEST), &bytesRead))
  134. {
  135. dprintf("%s @ %08x: Could not read structure\n",
  136. "Request", proxyPtr);
  137. return -1;
  138. }
  139. return 0;
  140. }
  141. UINT
  142. PrintRequest(PTP_REQUEST pReq, ULONG proxyPtr, ULONG printDetail)
  143. {
  144. // Is this a valid NBF request ?
  145. if (pReq->Type != NBF_REQUEST_SIGNATURE)
  146. {
  147. dprintf("%s @ %08x: Could not match signature\n",
  148. "Request", proxyPtr);
  149. return -1;
  150. }
  151. // What detail do we print at ?
  152. if (printDetail > MAX_DETAIL)
  153. printDetail = MAX_DETAIL;
  154. // Print Information at reqd detail
  155. FieldInRequest(proxyPtr, NULL, printDetail);
  156. return 0;
  157. }
  158. VOID
  159. FieldInRequest(ULONG structAddr, CHAR *fieldName, ULONG printDetail)
  160. {
  161. TP_REQUEST Request;
  162. if (ReadRequest(&Request, structAddr) == 0)
  163. {
  164. PrintFields(&Request, structAddr, fieldName, printDetail, &RequestInfo);
  165. }
  166. }
  167. UINT
  168. FreeRequest(PTP_REQUEST pReq)
  169. {
  170. return 0;
  171. }