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.

359 lines
7.3 KiB

  1. /*++
  2. Copyright (c) 1993 Microsoft Corporation
  3. Module Name:
  4. isnext.c
  5. Abstract:
  6. This file contains the generic routines and initialization code
  7. for the kernel debugger extensions dll.
  8. Author:
  9. Munil Shah
  10. Environment:
  11. User Mode
  12. --*/
  13. #include "precomp.h"
  14. #pragma hdrstop
  15. //
  16. // globals
  17. //
  18. #include "isnspx.h"
  19. ENUM_INFO EnumStructureType[] =
  20. {
  21. EnumString( IPX_DEVICE_SIGNATURE ),
  22. EnumString( IPX_ADAPTER_SIGNATURE ),
  23. EnumString( IPX_BINDING_SIGNATURE ),
  24. EnumString( IPX_ADDRESS_SIGNATURE ),
  25. EnumString( IPX_ADDRESSFILE_SIGNATURE ),
  26. { 0x4453, "SPX_DEVICE_SIGNATURE" },
  27. { 0x4441, "SPX_ADDRESS_SIGNATURE" },
  28. { 0x4641, "SPX_ADDRESSFILE_SIGNATURE" },
  29. { 0x4643, "SPX_CONNFILE_SIGNATURE" },
  30. { 0, NULL }
  31. };
  32. EXT_API_VERSION ApiVersion = { 3, 5, EXT_API_VERSION_NUMBER, 0 };
  33. WINDBG_EXTENSION_APIS ExtensionApis;
  34. USHORT SavedMajorVersion;
  35. USHORT SavedMinorVersion;
  36. BOOLEAN ChkTarget;
  37. INT Item;
  38. HANDLE _hInstance;
  39. HANDLE _hAdditionalReference;
  40. HANDLE _hProcessHeap;
  41. int _Indent = 0;
  42. char IndentBuf[ 80 ]={"\0 "};
  43. DllInit(
  44. HANDLE hModule,
  45. DWORD dwReason,
  46. DWORD dwReserved
  47. )
  48. {
  49. switch (dwReason) {
  50. case DLL_THREAD_ATTACH:
  51. break;
  52. case DLL_THREAD_DETACH:
  53. break;
  54. case DLL_PROCESS_DETACH:
  55. break;
  56. case DLL_PROCESS_ATTACH:
  57. _hInstance = hModule;
  58. _hAdditionalReference = NULL;
  59. break;
  60. }
  61. return TRUE;
  62. }
  63. VOID
  64. WinDbgExtensionDllInit(
  65. PWINDBG_EXTENSION_APIS lpExtensionApis,
  66. USHORT MajorVersion,
  67. USHORT MinorVersion
  68. )
  69. {
  70. ExtensionApis = *lpExtensionApis;
  71. SavedMajorVersion = MajorVersion;
  72. SavedMinorVersion = MinorVersion;
  73. ChkTarget = SavedMajorVersion == 0x0c ? TRUE : FALSE;
  74. return;
  75. }
  76. DECLARE_API( version )
  77. {
  78. #if DBG
  79. PCHAR DebuggerType = "Checked";
  80. #else
  81. PCHAR DebuggerType = "Free";
  82. #endif
  83. dprintf( "%s Extension dll for Build %d debugging %s kernel for Build %d\n",
  84. DebuggerType,
  85. VER_PRODUCTBUILD,
  86. SavedMajorVersion == 0x0c ? "Checked" : "Free",
  87. SavedMinorVersion
  88. );
  89. }
  90. VOID
  91. CheckVersion(
  92. VOID
  93. )
  94. {
  95. return;
  96. #if DBG
  97. if ((SavedMajorVersion != 0x0c) || (SavedMinorVersion != VER_PRODUCTBUILD)) {
  98. dprintf("\r\n*** Extension DLL(%d Checked) does not match target system(%d %s)\r\n\r\n",
  99. VER_PRODUCTBUILD, SavedMinorVersion, (SavedMajorVersion==0x0f) ? "Free" : "Checked" );
  100. }
  101. #else
  102. if ((SavedMajorVersion != 0x0f) || (SavedMinorVersion != VER_PRODUCTBUILD)) {
  103. dprintf("\r\n*** Extension DLL(%d Free) does not match target system(%d %s)\r\n\r\n",
  104. VER_PRODUCTBUILD, SavedMinorVersion, (SavedMajorVersion==0x0f) ? "Free" : "Checked" );
  105. }
  106. #endif
  107. }
  108. LPEXT_API_VERSION
  109. ExtensionApiVersion(
  110. VOID
  111. )
  112. {
  113. return &ApiVersion;
  114. }
  115. //
  116. // Exported functions
  117. //
  118. DECLARE_API( help )
  119. /*++
  120. Routine Description:
  121. Command help for ISN debugger extensions.
  122. Arguments:
  123. None
  124. Return Value:
  125. None
  126. --*/
  127. {
  128. dprintf("NB debugger extension commands:\n\n");
  129. dprintf("\tnbaddr <ptr> - Dump an NB ADDRESS object\n");
  130. dprintf("\tnbaddrfile <ptr> - Dump an NB ADDRESS_FILE object\n");
  131. dprintf("\tnbconn <ptr> - Dump key fields of an NB CONNECTION object\n");
  132. dprintf("\tnbconnfull <ptr> - Dump all fields of an NB CONNECTION object\n");
  133. dprintf("\tnbdev [ptr] - Dump key fields of an NB DEVICE object\n");
  134. dprintf("\tnbdevfull [ptr] - Dump all fields of an NB DEVICE object\n");
  135. dprintf("\tnbspacketlist [ptr] [-l Max] - Dump SEND_PACKET list upto Max count\n");
  136. dprintf("\tnbcache\n");
  137. dprintf("\n");
  138. dprintf("SPX debugger extension commands:\n\n");
  139. dprintf("\tspxdev [ptr] [-l var] - Dump all fields of an IPX DEVICE object\n" );
  140. dprintf("\tspxaddr <ptr>\n" );
  141. dprintf("\tspxaddrfile <ptr>\n" );
  142. dprintf("\tspxconnfile <ptr>\n" );
  143. dprintf("\n");
  144. dprintf("IPX debugger extension commands:\n\n");
  145. dprintf("\tipxdev [ptr] [-l var] - Dump all fields of an IPX DEVICE object\n" );
  146. dprintf("\tipxaddr <ptr>\n" );
  147. dprintf("\tipxaddrfile <ptr>\n" );
  148. dprintf("\tipxbinding <ptr>\n" );
  149. dprintf("\tipxadapter <ptr>\n" );
  150. dprintf("\tipxrequest <ptr> - Turn an IRP into an IPX_ADDRESS_FILE\n" );
  151. dprintf("\n");
  152. dprintf("\tnext - Advance to next element in currently focused list.\n\n" );
  153. dprintf("\tprev - Advance to previous element in currently focused list.\n\n" );
  154. dprintf( "Compiled on " __DATE__ " at " __TIME__ "\n" );
  155. return;
  156. }
  157. VOID
  158. dprintSymbolPtr
  159. (
  160. PVOID Pointer,
  161. PCHAR EndOfLine
  162. )
  163. {
  164. UCHAR SymbolName[ 80 ];
  165. ULONG Displacement;
  166. dprintf("%-10lx", ( ULONG )Pointer );
  167. GetSymbol( Pointer, SymbolName, &Displacement );
  168. if ( Displacement == 0 )
  169. {
  170. dprintf( "(%s)%s", SymbolName, EndOfLine );
  171. }
  172. else
  173. {
  174. dprintf( "(%s + 0x%X)%s", SymbolName, Displacement, EndOfLine );
  175. }
  176. }
  177. VOID
  178. dprint_nchar
  179. (
  180. PCHAR pch,
  181. int cch
  182. )
  183. {
  184. CHAR ch;
  185. int index;
  186. for ( index = 0; index < cch; index ++ )
  187. {
  188. ch = pch[ index ];
  189. dprintf( "%c", ( ch >= 32 ) ? ch : '.' );
  190. }
  191. }
  192. VOID
  193. dprint_hardware_address
  194. (
  195. PUCHAR Address
  196. )
  197. {
  198. dprintf( "%02x-%02x-%02x-%02x-%02x-%02x",
  199. Address[ 0 ],
  200. Address[ 1 ],
  201. Address[ 2 ],
  202. Address[ 3 ],
  203. Address[ 4 ],
  204. Address[ 5 ] );
  205. }
  206. VOID
  207. dprint_network_address
  208. (
  209. PUCHAR Address
  210. )
  211. {
  212. dprintf( "%02x-%02x-%02x-%02x",
  213. Address[ 0 ],
  214. Address[ 1 ],
  215. Address[ 2 ],
  216. Address[ 3 ]);
  217. }
  218. BOOL
  219. dprint_enum_name
  220. (
  221. ULONG Value,
  222. PENUM_INFO pEnumInfo
  223. )
  224. {
  225. while ( pEnumInfo->pszDescription != NULL )
  226. {
  227. if ( pEnumInfo->Value == Value )
  228. {
  229. dprintf( "%.40s", pEnumInfo->pszDescription );
  230. return( TRUE );
  231. }
  232. pEnumInfo ++;
  233. }
  234. dprintf( "Unknown enumeration value." );
  235. return( FALSE );
  236. }
  237. BOOL
  238. dprint_flag_names
  239. (
  240. ULONG Value,
  241. PFLAG_INFO pFlagInfo
  242. )
  243. {
  244. BOOL bFoundOne = FALSE;
  245. while ( pFlagInfo->pszDescription != NULL )
  246. {
  247. if ( pFlagInfo->Value & Value )
  248. {
  249. if ( bFoundOne )
  250. {
  251. dprintf( " | " );
  252. }
  253. bFoundOne = TRUE;
  254. dprintf( "%.15s", pFlagInfo->pszDescription );
  255. }
  256. pFlagInfo ++;
  257. }
  258. return( bFoundOne );
  259. }
  260. BOOL
  261. dprint_masked_value
  262. (
  263. ULONG Value,
  264. ULONG Mask
  265. )
  266. {
  267. CHAR Buf[ 9 ];
  268. ULONG nibble;
  269. int index;
  270. for ( index = 0; index < 8; index ++ )
  271. {
  272. nibble = ( Mask & 0xF0000000 );
  273. /*
  274. dprintf( "#%d: nibble == %08X\n"
  275. " Mask == %08X\n"
  276. " Value == %08X\n", index, nibble, Mask, Value );
  277. */
  278. if ( nibble )
  279. {
  280. Buf[ index ] = "0123456789abcdef"[ (( nibble & Value ) >> 28) & 0xF ];
  281. }
  282. else
  283. {
  284. Buf[ index ] = ' ';
  285. }
  286. Mask <<= 4;
  287. Value <<= 4;
  288. }
  289. Buf[ 8 ] = '\0';
  290. dprintf( "%s", Buf );
  291. return( TRUE );
  292. }