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.

236 lines
4.8 KiB

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