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.

238 lines
8.7 KiB

  1. /*++
  2. Copyright (c) 1999-2000 Microsoft Corporation
  3. Module Name:
  4. kd.c
  5. Abstract:
  6. Contains debugger extension defaults and setup.
  7. Author:
  8. Scott Holden (sholden) 24-Apr-1999
  9. Revision History:
  10. --*/
  11. #include "tcpipxp.h"
  12. //
  13. // Globals.
  14. //
  15. EXT_API_VERSION ApiVersion = { 3, 5, EXT_API_VERSION_NUMBER, 0 };
  16. WINDBG_EXTENSION_APIS ExtensionApis;
  17. USHORT SavedMajorVersion;
  18. USHORT SavedMinorVersion;
  19. BOOL ChkTarget;
  20. VERB g_Verbosity = 0;
  21. //
  22. // Print help.
  23. //
  24. #define TAB "\t"
  25. DECLARE_API(help)
  26. {
  27. dprintf("TCP/IP debugger extension commands:" ENDL ENDL);
  28. dprintf(TAB "tcpv - Global setting of verbosity of searches." ENDL);
  29. dprintf(TAB " 0 - One liner" ENDL);
  30. dprintf(TAB " 1 - Medium" ENDL);
  31. dprintf(TAB " 2 - Full structure dump." ENDL);
  32. dprintf(TAB " some dumps have global verbosity override, indicated as [v] below." ENDL);
  33. dprintf(ENDL);
  34. dprintf("Simple structure dumping" ENDL);
  35. dprintf(TAB "ipaddr <ulong> - Dumps ipaddr in <a.b.c.d> format." ENDL);
  36. dprintf(TAB "macaddr <ptr> - Dumps 802.3 address in x-x-x-x-x-x" ENDL);
  37. dprintf(TAB "ao <ptr> [v] - Dumps an AddrObj" ENDL);
  38. dprintf(TAB "tcb <ptr> [v] - Dumps a TCB" ENDL);
  39. dprintf(TAB "twtcb <ptr> [v] - Dumps a TWTCB" ENDL);
  40. dprintf(TAB "tcpctxt <ptr> [v] - Dumps a TCP_CONTEXT" ENDL);
  41. dprintf(TAB "tcpfo <ptr> [v] - Dumps a FILE_OBJECT" ENDL);
  42. dprintf(TAB "tc <ptr> [v] - Dumps a TCPConn" ENDL);
  43. dprintf(TAB "trr <ptr> [v] - Dumps a TCPRcvReq" ENDL);
  44. dprintf(TAB "tsr <ptr> [v] - Dumps a TCPRSendReq" ENDL);
  45. dprintf(TAB "scc <ptr> [v] - Dumps a SendCmpltContext" ENDL);
  46. dprintf(TAB "trh <ptr> [v] - Dumps a TCPRAHdr" ENDL);
  47. dprintf(TAB "dsr <ptr> [v] - Dumps a DGSendReq" ENDL);
  48. dprintf(TAB "drr <ptr> [v] - Dumps a DGRcvReq" ENDL);
  49. dprintf(TAB "udph <ptr> [v] - Dumps an UDPHeader" ENDL);
  50. dprintf(TAB "tcph <ptr> [v] - Dumps an TCPHeader" ENDL);
  51. dprintf(TAB "iph <ptr> [v] - Dumps an IPHeader" ENDL);
  52. dprintf(TAB "icmph <ptr> [v] - Dumps an ICMPHeader" ENDL);
  53. dprintf(TAB "arph <ptr> [v] - Dumps an ARPHeader" ENDL);
  54. dprintf(TAB "ipi <ptr> [v] - Dumps an IPInfo" ENDL);
  55. dprintf(TAB "rce <ptr> [v] - Dumps a RouteCacheEntry" ENDL);
  56. dprintf(TAB "nte <ptr> [v] - Dumps a NetTableEntry" ENDL);
  57. dprintf(TAB "ate <ptr> [v] - Dumps an ARPTableEntry" ENDL);
  58. dprintf(TAB "aia <ptr> [v] - Dumps an ARPIPAddr" ENDL);
  59. dprintf(TAB "rte <ptr> [v] - Dumps a RouteTableEntry" ENDL);
  60. dprintf(TAB "ioi <ptr> [v] - Dumps an IPOptInfo" ENDL);
  61. dprintf(TAB "cb <ptr> [v] - Dumps a TCPConnBlock" ENDL);
  62. dprintf(TAB "pc <ptr> [v] - Dumps a PacketContext" ENDL);
  63. dprintf(TAB "ai <ptr> [v] - Dumps an ARPInterface" ENDL);
  64. dprintf(TAB "interface <ptr> [v] - Dumps an Interface" ENDL);
  65. dprintf(TAB "lip <ptr> [v] - Dumps a LLIPBindInfo" ENDL);
  66. dprintf(TAB "link <ptr> [v] - Dumps a LinkEntry" ENDL);
  67. dprintf(ENDL);
  68. dprintf("Dump and search lists and tables" ENDL);
  69. dprintf(TAB "mdlc <ptr> [v] - Dumps the given MDL chain" ENDL);
  70. dprintf(TAB "arptable <ptr> - Dumps the given ARPTable" ENDL);
  71. dprintf(TAB "conntable - Dumps the ConnTable" ENDL);
  72. dprintf(TAB "ailist - Dumps the ARPInterface list" ENDL);
  73. dprintf(TAB "iflist - Dumps the Interface list" ENDL);
  74. dprintf(TAB "rtetable - Dumps the RouteTable" ENDL);
  75. dprintf(TAB "rtes - Dumps the RouteTable in route print format" ENDL);
  76. dprintf(TAB "srchtcbtable - Searches TCB table and dumps found TCBs." ENDL);
  77. dprintf(TAB " port <n> - Searches <n> against source and dest port on TCB" ENDL);
  78. dprintf(TAB " ipaddr <a.b.c.d> - Searches <a.b.c.d> against source and dest ipaddr on TCB" ENDL);
  79. dprintf(TAB " all - Dumps all TCBs in the TCB table" ENDL);
  80. dprintf(TAB "srchtwtcbtable - Searches TimeWait TCB table and dumps found TWTCBs." ENDL);
  81. dprintf(TAB " port <n> - Searches <n> against source and dest port on TCB" ENDL);
  82. dprintf(TAB " ipaddr <a.b.c.d> - Searches <a.b.c.d> against source and dest ipaddr on TCB" ENDL);
  83. dprintf(TAB " all - Dumps all TCBs in the TCB table" ENDL);
  84. dprintf(TAB "srchtwtcbq - Searches TimeWait TCB Queue and dumps found TWTCBs." ENDL);
  85. dprintf(TAB " port <n> - Searches <n> against source and dest port on TCB" ENDL);
  86. dprintf(TAB " ipaddr <a.b.c.d> - Searches <a.b.c.d> against source and dest ipaddr on TCB" ENDL);
  87. dprintf(TAB " all - Dumps all TCBs in the TCB table" ENDL);
  88. dprintf(TAB "srchaotable - Searches AO tables and dumps found AOs" ENDL);
  89. dprintf(TAB " port <n> - Searches <n> against source and dest port on TCB" ENDL);
  90. dprintf(TAB " ipaddr <a.b.c.d> - Searches <a.b.c.d> against source and dest ipaddr on TCB" ENDL);
  91. dprintf(TAB " prot <udp|tcp|raw> - Searches AO table for specific protocol" ENDL);
  92. dprintf(TAB " stats - Only dumps stats for AOs in the table" ENDL);
  93. dprintf(TAB " all - Dumps all AOs in the AO table" ENDL);
  94. dprintf(TAB "srchntelist - Dumps NTE list and dumps found NTEs" ENDL);
  95. dprintf(TAB " ipaddr <a.b.c.d> - Searches <a.b.c.d> against NTEs" ENDL);
  96. dprintf(TAB " context <context> - Dumps all NTEs with context" ENDL);
  97. dprintf(TAB " all - Dumps all NTEs in the NTE list" ENDL);
  98. dprintf(TAB "srchlink <ptr> - Dumps a LinkEntry list starting at <ptr>" ENDL);
  99. dprintf(TAB " ipaddr <a.b.c.d> - Searches <a.b.c.d> against LinkEntry's NextHop addr" ENDL);
  100. dprintf(TAB " all - Dumps all LinkEntry's in given list" ENDL);
  101. dprintf(ENDL);
  102. dprintf("Dump global variables and paramters" ENDL);
  103. dprintf(TAB "gtcp - All TCP globals" ENDL);
  104. dprintf(TAB "gip - All IP globals" ENDL);
  105. dprintf("" ENDL);
  106. dprintf( "Compiled on " __DATE__ " at " __TIME__ "" ENDL );
  107. return;
  108. }
  109. //
  110. // Initialization.
  111. //
  112. DllInit(
  113. HANDLE hModule,
  114. DWORD dwReason,
  115. DWORD dwReserved
  116. )
  117. {
  118. switch (dwReason) {
  119. case DLL_THREAD_ATTACH:
  120. break;
  121. case DLL_THREAD_DETACH:
  122. break;
  123. case DLL_PROCESS_DETACH:
  124. break;
  125. case DLL_PROCESS_ATTACH:
  126. DisableThreadLibraryCalls(hModule);
  127. InitTcpipx();
  128. break;
  129. }
  130. return TRUE;
  131. }
  132. //
  133. // WinDbgExtensionDllInit - Called by debugger to init function pointers.
  134. //
  135. VOID
  136. WinDbgExtensionDllInit(
  137. PWINDBG_EXTENSION_APIS lpExtensionApis,
  138. USHORT MajorVersion,
  139. USHORT MinorVersion
  140. )
  141. {
  142. ExtensionApis = *lpExtensionApis;
  143. SavedMajorVersion = MajorVersion;
  144. SavedMinorVersion = MinorVersion;
  145. ChkTarget = SavedMajorVersion == 0x0c ? TRUE : FALSE;
  146. return;
  147. }
  148. DECLARE_API(version)
  149. {
  150. #if DBG
  151. PCHAR DebuggerType = "Checked";
  152. #else
  153. PCHAR DebuggerType = "Free";
  154. #endif
  155. dprintf( "%s Extension dll for Build %d debugging %s kernel for Build %d" ENDL,
  156. DebuggerType,
  157. VER_PRODUCTBUILD,
  158. SavedMajorVersion == 0x0c ? "Checked" : "Free",
  159. SavedMinorVersion
  160. );
  161. }
  162. VOID
  163. CheckVersion(
  164. VOID
  165. )
  166. {
  167. return;
  168. }
  169. LPEXT_API_VERSION
  170. ExtensionApiVersion(
  171. VOID
  172. )
  173. {
  174. return &ApiVersion;
  175. }
  176. //
  177. // Set verbosity level for debugger extensions.
  178. //
  179. DECLARE_API(tcpv)
  180. {
  181. VERB v;
  182. if (*args)
  183. {
  184. v = atoi(args);
  185. if (v >= VERB_MIN && v <= VERB_MAX)
  186. {
  187. g_Verbosity = v;
  188. }
  189. else
  190. {
  191. dprintf("Bad verbosity value. Must be = [0 | 1 | 2]" ENDL);
  192. }
  193. }
  194. dprintf("Current verbosity = %s" ENDL,
  195. g_Verbosity == VERB_MIN ? "VERB_MIN" :
  196. g_Verbosity == VERB_MED ? "VERB_MED" :
  197. g_Verbosity == VERB_MAX ? "VERB_MAX" : "??????");
  198. return;
  199. }