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.

487 lines
16 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. nbfcom.h
  5. Abstract:
  6. This file is a common header file for nbfext.dll
  7. Author:
  8. Chaitanya Kodeboyina (Chaitk)
  9. Environment:
  10. User Mode
  11. --*/
  12. #ifndef __NBFCOM_H
  13. #define __NBFCOM_H
  14. #define ITEMSIZE 25
  15. typedef struct
  16. {
  17. ULONG Value;
  18. PCHAR pszDescription;
  19. } ENUM_INFO, *PENUM_INFO, FLAG_INFO, *PFLAG_INFO;
  20. #define EnumString( Value ) { Value, #Value }
  21. extern ENUM_INFO EnumStructureType[];
  22. //#define EOL ( (Item++ & 1) ? "\n":"" )
  23. typedef enum
  24. {
  25. VERBOSITY_ONE_LINER = 0,
  26. VERBOSITY_NORMAL,
  27. VERBOSITY_FULL
  28. } VERBOSITY;
  29. #define PrintStart Item = 0;
  30. extern int _Indent;
  31. extern char IndentBuf[ 80 ];
  32. #define IndentChange( cch ) { IndentBuf[_Indent]=' '; _Indent += ( cch ); IndentBuf[_Indent]='\0';}
  33. #define Indent( cch ) IndentChange( cch )
  34. #define Outdent( cch ) IndentChange( -( cch ) )
  35. #define PrintStartStruct() { PrintStart; dprintf( "%s{\n", IndentBuf ); Indent( 2 ); }
  36. #define PrintStartNamedStruct( _name ) { PrintStart; dprintf( "%s%s {\n", IndentBuf, _name ); Indent( 2 ); }
  37. static PCHAR pchEol = "\n";
  38. static PCHAR pchBlank = "";
  39. static PCHAR * ppchCurrentEol = &pchEol;
  40. static PCHAR * ppchTempEol = &pchEol;
  41. #define PrintJoin() { ppchCurrentEol = &pchBlank; }
  42. #define EOL (( ppchTempEol = ppchCurrentEol ), ( ppchCurrentEol = &pchEol ), ( *ppchTempEol ))
  43. VOID
  44. dprintSymbolPtr
  45. (
  46. PVOID Pointer,
  47. PCHAR EndOfLine
  48. );
  49. VOID
  50. dprint_nchar
  51. (
  52. PCHAR pch,
  53. int cch
  54. );
  55. VOID
  56. dprint_hardware_address
  57. (
  58. PUCHAR Address
  59. );
  60. BOOL
  61. dprint_enum_name
  62. (
  63. ULONG Value,
  64. PENUM_INFO pEnumInfo
  65. );
  66. BOOL
  67. dprint_flag_names
  68. (
  69. ULONG Value,
  70. PFLAG_INFO pFlagInfo
  71. );
  72. BOOL
  73. dprint_masked_value
  74. (
  75. ULONG Value,
  76. ULONG Mask
  77. );
  78. VOID
  79. dprint_addr_list(
  80. ULONG FirstAddress,
  81. ULONG OffsetToNextPtr
  82. );
  83. ULONG
  84. GetUlongValue (
  85. PCHAR String
  86. );
  87. /*
  88. #define PrintEnd \
  89. dprintf( "%s", EOL ); \
  90. Item = 0;
  91. */
  92. #define PrintEnd \
  93. Item = 0;
  94. #define PrintEndStruct() { Outdent( 2 ); PrintEnd; dprintf( "%s}\n", IndentBuf ); }
  95. #define PrintFlushLeft() PrintEnd
  96. #define PRINTBOOL(var) ( (var) ? "True" : "False")
  97. #define PrintFieldName(_fieldName) \
  98. if ( strlen(_fieldName) > 35 ) { \
  99. dprintf("%s%-.25s..%s = ",IndentBuf,_fieldName, &(_fieldName[strlen(_fieldName)-8])); \
  100. }else { \
  101. dprintf("%s%-35.35s = ",IndentBuf,_fieldName ); \
  102. }
  103. #define PrintFieldNameAt(_fieldName) \
  104. if ( strlen(_fieldName) > 35 ) { \
  105. dprintf("%s%-.25s..%s @ ",IndentBuf,_fieldName, &(_fieldName[strlen(_fieldName)-8])); \
  106. }else { \
  107. dprintf("%s%-35.35s @ ",IndentBuf,_fieldName ); \
  108. }
  109. #define PrintListTcpFieldName(_fieldName) \
  110. if ( strlen(_fieldName) > 40 ) { \
  111. dprintf("%s%-.30s...%s q_next = ",IndentBuf,_fieldName, &(_fieldName[strlen(_fieldName)-7])); \
  112. }else { \
  113. dprintf("%s%-40.40s q_next = ",IndentBuf,_fieldName ); \
  114. }
  115. #define PrintListFieldName(_fieldName) \
  116. if ( strlen(_fieldName) > 40 ) { \
  117. dprintf("%s%-.30s...%s FLink = ",IndentBuf,_fieldName, &(_fieldName[strlen(_fieldName)-7])); \
  118. }else { \
  119. dprintf("%s%-40.40s FLink = ",IndentBuf,_fieldName ); \
  120. }
  121. #define PrintIndent() dprintf( "%s", IndentBuf );
  122. /* #define PrintFieldName(_fieldName) \
  123. dprintf(" %-25.25s = ",_fieldName );*/
  124. #define PrintRawBool( _bValue ) \
  125. dprintf("%-10s%s", (_obj._bValue) ? "True" : "False", EOL)
  126. #define PrintBool(_field) \
  127. PrintFieldName(#_field) \
  128. dprintf("%-10s%s", (_obj._field) ? "True" : "False", EOL)
  129. #define PrintULong(_field) \
  130. PrintFieldName(#_field) \
  131. dprintf("%-10lu%s", _obj._field, EOL)
  132. #define PrintXULong(_field) \
  133. PrintFieldName(#_field) \
  134. dprintf("0x%08lx%s", _obj._field, EOL)
  135. #define PrintUShort(_field) \
  136. PrintFieldName(#_field) \
  137. dprintf("%-10hu%s", _obj._field, EOL)
  138. #define PrintHTONUShort(_field) \
  139. PrintFieldName(#_field) \
  140. dprintf("%-10hu%s", htons(_obj._field), EOL)
  141. #define PrintXUShort(_field) \
  142. PrintFieldName(#_field) \
  143. dprintf("0x%04hx%s", _obj._field, EOL)
  144. #define PrintNChar( _field, count ) \
  145. PrintFieldName(#_field) \
  146. dprint_nchar( ( PCHAR )_obj._field, count ); \
  147. dprintf("%s", EOL)
  148. #define PrintUChar(_field) \
  149. PrintFieldName(#_field) \
  150. dprintf("%-10lu%s", (ULONG) _obj._field, EOL)
  151. #define PrintXUChar(_field) \
  152. PrintFieldName(#_field) \
  153. dprintf("0x%-8lx%s", (ULONG) _obj._field, EOL)
  154. #define PrintPtr(_field) \
  155. PrintFieldName(#_field) \
  156. dprintf("%-10lx%s", _obj._field, EOL)
  157. #define PrintSymbolPtr( _field ) \
  158. PrintFieldName(#_field) \
  159. dprintSymbolPtr( (( PVOID )_obj._field), EOL );
  160. #define AddressOf( _field ) ((( ULONG )_objAddr) + FIELD_OFFSET( _objType, _field ))
  161. #define PrintAddr(_field) \
  162. PrintFieldNameAt(#_field) \
  163. dprintf("%-10lx%s", AddressOf( _field ), EOL)
  164. #define PrintL(_field) \
  165. PrintFieldName(#_field##".Next") \
  166. dprintf("%-10lx%s", _obj._field.Next, EOL )
  167. #define PrintLL(_field) \
  168. PrintEnd; \
  169. PrintListFieldName(#_field ); \
  170. dprintf("%-10lx", _obj._field.Flink ); \
  171. dprintf("Blink = %-10lx", _obj._field.Blink ); \
  172. dprintf("%s\n", ( _obj._field.Flink == _obj._field.Blink ) ? " (Empty)" : "" );
  173. #define PrintLLTcp(_field) \
  174. PrintEnd; \
  175. PrintListTcpFieldName(#_field ); \
  176. dprintf("%-10lx", _obj._field.q_next ); \
  177. dprintf("q_prev = %-10lx", _obj._field.q_prev ); \
  178. dprintf("%s\n", ( _obj._field.q_next == _obj._field.q_prev ) ? " (Empty)" : "" );
  179. #define PrintIrpQ(_field) \
  180. PrintEnd; \
  181. PrintFieldName(#_field##".Head"); \
  182. dprintf("%-10lx", _obj._field.Head ); \
  183. PrintFieldName(#_field##".Tail"); \
  184. dprintf("%-10lx\n", _obj._field.Tail );
  185. #define PrintFlags( _field, _pFlagStruct ) \
  186. PrintEnd; \
  187. PrintFieldName(#_field); \
  188. dprintf("0x%08lx (", (ULONG) _obj._field ); \
  189. dprint_flag_names( (ULONG) _obj._field, _pFlagStruct ); \
  190. dprintf( ")\n" );
  191. #define PrintFlagsMask( _field, _pFlagStruct, _Mask ) \
  192. PrintEnd; \
  193. PrintFieldName(" & " ## #_Mask ); \
  194. dprintf("0x"); \
  195. dprint_masked_value((ULONG) _obj._field, _Mask ); \
  196. dprintf("("); \
  197. dprint_flag_names( (ULONG) _obj._field, _pFlagStruct ); \
  198. dprintf( ")\n" );
  199. #define PrintEnum( _field, _pEnumStruct ) \
  200. PrintEnd; \
  201. PrintFieldName(#_field); \
  202. dprintf("%lu (", (ULONG) _obj._field ); \
  203. dprint_enum_name( (ULONG) _obj._field, _pEnumStruct ); \
  204. dprintf( ")\n" );
  205. #define PrintXEnum( _field, _pEnumStruct ) \
  206. PrintEnd; \
  207. PrintFieldName(#_field); \
  208. dprintf("0x%08lx (", (ULONG) _obj._field ); \
  209. dprint_enum_name( (ULONG) _obj._field, _pEnumStruct ); \
  210. dprintf( ")\n" );
  211. #define PrintXEnumMask( _field, _pEnumStruct, _Mask ) \
  212. PrintEnd; \
  213. PrintFieldName(" & " ## #_Mask ); \
  214. dprintf("0x"); \
  215. dprint_masked_value((ULONG) _obj._field, _Mask ); \
  216. dprintf("("); \
  217. dprint_enum_name((ULONG) _obj._field & _Mask, _pEnumStruct ); \
  218. dprintf( ")\n" );
  219. #define PrintHardwareAddress( _field ) \
  220. PrintFieldName(#_field); \
  221. dprint_hardware_address( _obj._field.Address ); \
  222. dprintf( "%s", EOL );
  223. #define PrintIpxLocalTarget( _field ) \
  224. PrintStartNamedStruct( #_field ); \
  225. PrintFieldName( "NicId" ); \
  226. dprintf("%-10u%s", _obj._field.NicId, EOL); \
  227. PrintFieldName( "MacAddress" ); \
  228. dprint_hardware_address( _obj._field.MacAddress ); \
  229. dprintf( "%s", EOL ); \
  230. PrintEndStruct();
  231. #define PrintIPAddress( _field ) \
  232. PrintFieldName(#_field); \
  233. dprint_IP_address( _obj._field ); \
  234. dprintf( "%s", EOL );
  235. #define PrintLock(_field) \
  236. PrintFieldName(#_field) \
  237. dprintf("( 0x%08lx ) %-10s%s", (_obj._field), (_obj._field) ? "Locked" : "UnLocked", EOL)
  238. #define PrintTDIAddress( _field ) \
  239. PrintFieldName( #_field ); \
  240. dprintf( "{ NetworkAddress = %X, NodeAddress = ", _obj._field.NetworkAddress );\
  241. dprint_hardware_address( _obj._field.NodeAddress );\
  242. dprintf( ", Socket = %d }%s", _obj._field.Socket, EOL );
  243. #define PrintCTETimer( _field ) \
  244. dprintf( "%s", #_field ); \
  245. PrintStartStruct(); \
  246. DumpCTETimer ( ((ULONG)_objAddr) +FIELD_OFFSET( _objType, _field ), VERBOSITY_NORMAL );\
  247. PrintEndStruct();
  248. #define PrintCTEEvent( _field ) \
  249. dprintf( "%s", #_field ); \
  250. PrintStartStruct(); \
  251. DumpCTEEvent ( ((ULONG)_objAddr) +FIELD_OFFSET( _objType, _field ), VERBOSITY_NORMAL );\
  252. PrintEndStruct();
  253. #define PrintKEvent( _field ) \
  254. dprintf( "%s", #_field ); \
  255. PrintStartStruct(); \
  256. DumpKEvent ( ((ULONG)_objAddr) +FIELD_OFFSET( _objType, _field ), VERBOSITY_NORMAL );\
  257. PrintEndStruct();
  258. #define PrintWorkQueueItem( _field ) \
  259. dprintf( "%s", #_field ); \
  260. PrintStartStruct(); \
  261. DumpWorkQueueItem ( ((ULONG)_objAddr) +FIELD_OFFSET( _objType, _field ), VERBOSITY_NORMAL );\
  262. PrintEndStruct();
  263. extern BOOLEAN ChkTarget;
  264. extern INT Item;
  265. #define CHECK_SIGNATURE( _field, _signature ) \
  266. if ( _obj._field != _signature ) \
  267. { \
  268. dprintf( "Object at %08X doesn't have signature %s at %08X\n", \
  269. _objAddr, \
  270. #_signature, \
  271. (( ULONG )_objAddr) + FIELD_OFFSET( _objType, _field ));\
  272. }
  273. //
  274. // Constants
  275. //
  276. #define MAX_SYMBOL_LEN 80
  277. #define MAX_FIELD 256
  278. enum PRINT_DETAIL {
  279. NULL_INFO, // 0
  280. SUMM_INFO, // 1
  281. NORM_SHAL, // 2
  282. FULL_SHAL, // 3
  283. NORM_DEEP, // 4
  284. FULL_DEEP // 5
  285. };
  286. #define MIN_DETAIL NULL_INFO
  287. #define MAX_DETAIL FULL_DEEP
  288. enum FIELD_IMPORTANCE
  289. {
  290. LOW, // 0
  291. NOR, // 1
  292. HIG // 2
  293. };
  294. //
  295. // Structures
  296. //
  297. typedef VOID (*funcPrintField) (PVOID fieldPtr, ULONG fieldProxy, ULONG printDetail);
  298. typedef struct _FieldAccessInfo
  299. {
  300. CHAR Name[MAX_SYMBOL_LEN];
  301. ULONG Offset;
  302. ULONG Size;
  303. funcPrintField PrintField;
  304. ULONG Importance;
  305. } FieldAccessInfo;
  306. typedef struct _StructAccessInfo
  307. {
  308. CHAR Name[MAX_SYMBOL_LEN];
  309. FieldAccessInfo fieldInfo[MAX_FIELD];
  310. } StructAccessInfo;
  311. //
  312. // Common Prototypes
  313. //
  314. ULONG GetLocation(PCHAR String);
  315. VOID PrintClosestSymbol(PVOID Pointer, ULONG PtrProxy, ULONG printDetail);
  316. VOID PrintFields(PVOID pStructure, ULONG structProxy, CHAR *fieldPrefix,
  317. ULONG printDetail, StructAccessInfo *pStructInfo);
  318. VOID PrintListFromListEntryAndOffset(PVOID ListEntryPointer,
  319. ULONG ListEntryProxy, ULONG ListEntryOffset);
  320. //
  321. // Global Prototypes
  322. //
  323. // Device Context Helpers
  324. VOID FieldInDeviceContext(ULONG structAddr, CHAR *fieldName, ULONG printDetail);
  325. // Address Helpers
  326. VOID FieldInAddress(ULONG structAddr, CHAR *fieldName, ULONG printDetail);
  327. VOID PrintAddressList(PVOID ListEntryPtr, ULONG ListEntryProxy, ULONG printDetail);
  328. // Address File Helpers
  329. VOID FieldInAddressFile(ULONG structAddr, CHAR *fieldName, ULONG printDetail);
  330. VOID PrintAddressFileList(PVOID ListEntryPtr, ULONG ListEntryProxy, ULONG printDetail);
  331. // Connection Helpers
  332. VOID FieldInConnection(ULONG structAddr, CHAR *fieldName, ULONG printDetail);
  333. VOID PrintConnectionListOnLink(PVOID ListEntryPtr, ULONG ListEntryProxy, ULONG printDetail);
  334. VOID PrintConnectionListOnAddress(PVOID ListEntryPtr, ULONG ListEntryProxy, ULONG printDetail);
  335. VOID PrintConnectionListOnAddrFile(PVOID ListEntryPtr, ULONG ListEntryProxy, ULONG printDetail);
  336. // DLC Link Helpers
  337. VOID FieldInDlcLink(ULONG structAddr, CHAR *fieldName, ULONG printDetail);
  338. UINT PrintDlcLink(PTP_LINK DlcLinkPointer, ULONG DlcLinkProxy, ULONG printDetail);
  339. VOID PrintDlcLinkList(PVOID ListEntryPointer, ULONG ListEntryProxy, ULONG printDetail);
  340. VOID PrintDlcLinkFromPtr(PVOID DlcLinkPtrPointer, ULONG DlcLinkPtrProxy, ULONG printDetail);
  341. // Request Helpers
  342. VOID FieldInRequest(ULONG structAddr, CHAR *fieldName, ULONG printDetail);
  343. VOID PrintRequestList(PVOID ListEntryPtr, ULONG ListEntryProxy, ULONG printDetail);
  344. // Packet Helpers
  345. VOID FieldInPacket(ULONG structAddr, CHAR *fieldName, ULONG printDetail);
  346. VOID PrintPacketList(PVOID ListEntryPtr, ULONG ListEntryProxy, ULONG printDetail);
  347. // Packet Header Helpers
  348. VOID FieldInNbfPktHdr(ULONG structAddr, CHAR *fieldName, ULONG printDetail);
  349. // Device Helpers
  350. VOID PrintDeviceObject(PVOID fieldPtr, ULONG fieldProxy, ULONG printDetail);
  351. // Packet Log Helpers
  352. VOID PrintPktLogQue(PVOID pPktLog, ULONG proxyPtr, ULONG printDetail);
  353. VOID PrintPktIndQue(PVOID pPktLog, ULONG proxyPtr, ULONG printDetail);
  354. // Miscellaneous Helpers
  355. VOID PrintStringofLenN(PVOID Pointer, ULONG PtrProxy, ULONG printDetail);
  356. VOID PrintNbfPacketPoolList(PVOID Pointer, ULONG PtrProxy, ULONG printDetail);
  357. VOID PrintNbfPacketPoolListFromPtr(PVOID PacketPoolPtrPointer, ULONG PacketPoolPtrProxy, ULONG printDetail);
  358. VOID PrintNbfNetbiosAddress(PVOID AddressPointer, ULONG AddressProxy, ULONG printDetail);
  359. VOID PrintNbfNetbiosAddressFromPtr(PVOID AddressPtrPointer, ULONG AddressPtrProxy, ULONG printDetail);
  360. VOID PrintListFromListEntry(PVOID ListEntryPointer, ULONG ListEntryProxy, ULONG printDetail);
  361. VOID PrintIRPListFromListEntry(PVOID IRPListEntryPointer, ULONG IRPListEntryProxy, ULONG debugDetail);
  362. #endif // __NBFCOM_H