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.

298 lines
7.3 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. tranfile.c
  5. Abstract:
  6. Implements the tranfile command.
  7. Author:
  8. Keith Moore (keithmo) 15-Apr-1996
  9. Environment:
  10. User Mode.
  11. Revision History:
  12. --*/
  13. #include "afdkdp.h"
  14. #pragma hdrstop
  15. BOOL
  16. DumpTransmitInfoCallback(
  17. ULONG64 ActualAddress,
  18. ULONG64 Context
  19. );
  20. //
  21. // Public functions.
  22. //
  23. DECLARE_API( tran )
  24. /*++
  25. Routine Description:
  26. Dumps the AFD_TRANSMIT_FILE_INFO_INTERNAL structure at the specified
  27. address.
  28. Arguments:
  29. None.
  30. Return Value:
  31. None.
  32. --*/
  33. {
  34. ULONG result;
  35. CHAR expr[MAX_ADDRESS_EXPRESSION];
  36. INT i;
  37. PCHAR argp;
  38. ULONG64 address;
  39. gClient = pClient;
  40. if (!CheckKmGlobals ()) {
  41. return E_INVALIDARG;
  42. }
  43. argp = ProcessOptions ((PCHAR)args);
  44. if (argp==NULL)
  45. return E_INVALIDARG;
  46. if (Options&AFDKD_BRIEF_DISPLAY) {
  47. if (SavedMinorVersion>=2219) {
  48. dprintf (AFDKD_BRIEF_TPACKETS_DISPLAY_HEADER);
  49. }
  50. else {
  51. dprintf (AFDKD_BRIEF_TRANFILE_DISPLAY_HEADER);
  52. }
  53. }
  54. if ((argp[0]==0) || (Options & AFDKD_ENDPOINT_SCAN)) {
  55. EnumEndpoints(
  56. DumpTransmitInfoCallback,
  57. 0
  58. );
  59. dprintf ("\nTotal transmits: %ld", EntityCount);
  60. }
  61. else {
  62. //
  63. // Snag the address from the command line.
  64. //
  65. while (sscanf( argp, "%s%n", expr, &i )==1) {
  66. if( CheckControlC() ) {
  67. break;
  68. }
  69. argp += i;
  70. address = GetExpression (expr);
  71. if (SavedMinorVersion>=2219) {
  72. result = (ULONG)InitTypeRead (address, AFD!_IRP);
  73. if (result!=0) {
  74. dprintf(
  75. "\ntran: Could not read IRP @ %p, err:%d\n",
  76. address, result
  77. );
  78. break;
  79. }
  80. if (Options & AFDKD_BRIEF_DISPLAY) {
  81. DumpAfdTPacketsInfoBrief(
  82. address
  83. );
  84. }
  85. else {
  86. DumpAfdTPacketsInfo(
  87. address
  88. );
  89. }
  90. if (Options & AFDKD_FIELD_DISPLAY) {
  91. ProcessFieldOutput (address, "AFD!_IRP");
  92. }
  93. }
  94. else {
  95. result = (ULONG)InitTypeRead (address, AFD!AFD_TRANSMIT_FILE_INFO_INTERNAL);
  96. if (result!=0) {
  97. dprintf(
  98. "\ntran: Could not read transmit info @ %p, err:%d\n",
  99. address, result
  100. );
  101. break;
  102. }
  103. if (Options & AFDKD_BRIEF_DISPLAY) {
  104. DumpAfdTransmitInfoBrief(
  105. address
  106. );
  107. }
  108. else {
  109. DumpAfdTransmitInfo(
  110. address
  111. );
  112. }
  113. if (Options & AFDKD_FIELD_DISPLAY) {
  114. ProcessFieldOutput (address, "AFD!AFD_TRANSMIT_FILE_INFO_INTERNAL");
  115. }
  116. }
  117. }
  118. }
  119. if (Options&AFDKD_BRIEF_DISPLAY) {
  120. if (SavedMinorVersion>=2219) {
  121. dprintf (AFDKD_BRIEF_TPACKETS_DISPLAY_TRAILER);
  122. }
  123. else {
  124. dprintf (AFDKD_BRIEF_TRANFILE_DISPLAY_TRAILER);
  125. }
  126. }
  127. else {
  128. dprintf ("\n");
  129. }
  130. return S_OK;
  131. } // tranfile
  132. BOOL
  133. DumpTransmitInfoCallback(
  134. ULONG64 ActualAddress,
  135. ULONG64 Context
  136. )
  137. /*++
  138. Routine Description:
  139. EnumEndpoints() callback for dumping transmit info structures.
  140. Arguments:
  141. Endpoint - The current AFD_ENDPOINT.
  142. ActualAddress - The actual address where the structure resides on the
  143. debugee.
  144. Context - The context value passed into EnumEndpoints().
  145. Return Value:
  146. BOOL - TRUE if enumeration should continue, FALSE if it should be
  147. terminated.
  148. --*/
  149. {
  150. ULONG result;
  151. ULONG64 address;
  152. USHORT type;
  153. UCHAR state;
  154. type = (USHORT)ReadField (Type);
  155. state = (UCHAR)ReadField (State);
  156. if (SavedMinorVersion>=2219) {
  157. if (type!=AfdBlockTypeEndpoint &&
  158. (state==AfdEndpointStateConnected ||
  159. state==AfdEndpointStateTransmitClosing)) {
  160. address = ReadField (Irp);
  161. }
  162. else {
  163. address = 0;
  164. }
  165. }
  166. else {
  167. address = ReadField (TransmitInfo);
  168. }
  169. if (address!=0) {
  170. if (SavedMinorVersion>=2219) {
  171. result = (ULONG)InitTypeRead (address, AFD!_IRP);
  172. if (result!=0) {
  173. dprintf(
  174. "\nDumpTransmitInfoCallback: Could not read irp @ %p, err: %ld\n",
  175. address, result
  176. );
  177. return TRUE;
  178. }
  179. if (!(Options & AFDKD_CONDITIONAL) ||
  180. CheckConditional (address, "AFD!_IRP") ) {
  181. if (Options & AFDKD_NO_DISPLAY)
  182. dprintf ("+");
  183. else {
  184. if (Options & AFDKD_BRIEF_DISPLAY) {
  185. DumpAfdTPacketsInfoBrief(
  186. address
  187. );
  188. }
  189. else {
  190. DumpAfdTPacketsInfo(
  191. address
  192. );
  193. }
  194. if (Options & AFDKD_FIELD_DISPLAY) {
  195. ProcessFieldOutput (address, "AFD!_IRP");
  196. }
  197. }
  198. EntityCount += 1;
  199. }
  200. else
  201. dprintf (",");
  202. }
  203. else {
  204. result = (ULONG)InitTypeRead (address, AFD!AFD_TRANSMIT_FILE_INFO_INTERNAL);
  205. if (result!=0) {
  206. dprintf(
  207. "\nDumpTransmitInfoCallback: Could not read transmit file info @ %p, err: %ld\n",
  208. address, result
  209. );
  210. return TRUE;
  211. }
  212. if (!(Options & AFDKD_CONDITIONAL) ||
  213. CheckConditional (address, "AFD!AFD_TRANSMIT_FILE_INFO_INTERNAL") ) {
  214. if (Options & AFDKD_NO_DISPLAY)
  215. dprintf ("+");
  216. else {
  217. if (Options & AFDKD_BRIEF_DISPLAY) {
  218. DumpAfdTransmitInfoBrief(
  219. address
  220. );
  221. }
  222. else {
  223. DumpAfdTransmitInfo(
  224. address
  225. );
  226. }
  227. if (Options & AFDKD_FIELD_DISPLAY) {
  228. ProcessFieldOutput (address, "AFD!AFD_TRANSMIT_FILE_INFO_INTERNAL");
  229. }
  230. }
  231. EntityCount += 1;
  232. }
  233. else
  234. dprintf (",");
  235. }
  236. }
  237. else {
  238. dprintf (".");
  239. }
  240. return TRUE;
  241. } // DumpTransmitInfoCallback