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.

361 lines
12 KiB

  1. /*++
  2. Copyright (c) 1993 Microsoft Corporation
  3. Module Name:
  4. kdmacros.h
  5. Abstract:
  6. This file is a common header file for tcpext.dll
  7. Author:
  8. John Ballard (jballard)
  9. Environment:
  10. User Mode
  11. --*/
  12. #define ITEMSIZE 25
  13. typedef struct
  14. {
  15. ULONG Value;
  16. PCHAR pszDescription;
  17. } ENUM_INFO, *PENUM_INFO, FLAG_INFO, *PFLAG_INFO;
  18. #define EnumString( Value ) { Value, #Value }
  19. extern ENUM_INFO EnumStructureType[];
  20. //#define EOL ( (Item++ & 1) ? "\n":"" )
  21. typedef enum
  22. {
  23. VERBOSITY_ONE_LINER = 0,
  24. VERBOSITY_NORMAL,
  25. VERBOSITY_FULL
  26. } VERBOSITY;
  27. #define PrintStart Item = 0;
  28. extern int _Indent;
  29. extern char IndentBuf[ 80 ];
  30. #define IndentChange( cch ) { IndentBuf[_Indent]=' '; _Indent += ( cch ); IndentBuf[_Indent]='\0';}
  31. #define Indent( cch ) IndentChange( cch )
  32. #define Outdent( cch ) IndentChange( -( cch ) )
  33. #define PrintStartStruct() { PrintStart; dprintf( "%s{\n", IndentBuf ); Indent( 2 ); }
  34. #define PrintStartNamedStruct( _name ) { PrintStart; dprintf( "%s%s {\n", IndentBuf, _name ); Indent( 2 ); }
  35. static PCHAR pchEol = "\n";
  36. static PCHAR pchBlank = "";
  37. static PCHAR * ppchCurrentEol = &pchEol;
  38. static PCHAR * ppchTempEol = &pchEol;
  39. #define PrintJoin() { ppchCurrentEol = &pchBlank; }
  40. #define EOL (( ppchTempEol = ppchCurrentEol ), ( ppchCurrentEol = &pchEol ), ( *ppchTempEol ))
  41. VOID
  42. dprintSymbolPtr
  43. (
  44. PVOID Pointer,
  45. PCHAR EndOfLine
  46. );
  47. VOID
  48. dprint_nchar
  49. (
  50. PCHAR pch,
  51. int cch
  52. );
  53. VOID
  54. dprint_hardware_address
  55. (
  56. PUCHAR Address
  57. );
  58. BOOL
  59. dprint_enum_name
  60. (
  61. ULONG Value,
  62. PENUM_INFO pEnumInfo
  63. );
  64. BOOL
  65. dprint_flag_names
  66. (
  67. ULONG Value,
  68. PFLAG_INFO pFlagInfo
  69. );
  70. BOOL
  71. dprint_masked_value
  72. (
  73. ULONG Value,
  74. ULONG Mask
  75. );
  76. VOID
  77. dprint_addr_list(
  78. ULONG FirstAddress,
  79. ULONG OffsetToNextPtr
  80. );
  81. VOID
  82. dprint_IP_address
  83. (
  84. IPAddr Address
  85. );
  86. ULONG
  87. GetUlongValue (
  88. PCHAR String
  89. );
  90. /*
  91. #define PrintEnd \
  92. dprintf( "%s", EOL ); \
  93. Item = 0;
  94. */
  95. #define PrintEnd \
  96. Item = 0;
  97. #define PrintNL() dprintf("\n");
  98. #define PrintEndStruct() { Outdent( 2 ); PrintEnd; dprintf( "%s}\n", IndentBuf ); }
  99. #define PrintFlushLeft() PrintEnd
  100. #define PRINTBOOL(var) ( (var) ? "True" : "False")
  101. #define PrintFieldName(_fieldName) \
  102. if ( strlen(_fieldName) > 35 ) { \
  103. dprintf("%s%-.25s..%s = ",IndentBuf,_fieldName, &(_fieldName[strlen(_fieldName)-8])); \
  104. }else { \
  105. dprintf("%s%-35.35s = ",IndentBuf,_fieldName ); \
  106. }
  107. #define PrintFieldNameAt(_fieldName) \
  108. if ( strlen(_fieldName) > 35 ) { \
  109. dprintf("%s%-.25s..%s @ ",IndentBuf,_fieldName, &(_fieldName[strlen(_fieldName)-8])); \
  110. }else { \
  111. dprintf("%s%-35.35s @ ",IndentBuf,_fieldName ); \
  112. }
  113. #define PrintListTcpFieldName(_fieldName) \
  114. if ( strlen(_fieldName) > 40 ) { \
  115. dprintf("%s%-.30s...%s q_next = ",IndentBuf,_fieldName, &(_fieldName[strlen(_fieldName)-7])); \
  116. }else { \
  117. dprintf("%s%-40.40s q_next = ",IndentBuf,_fieldName ); \
  118. }
  119. #define PrintListFieldName(_fieldName) \
  120. if ( strlen(_fieldName) > 40 ) { \
  121. dprintf("%s%-.30s...%s FLink = ",IndentBuf,_fieldName, &(_fieldName[strlen(_fieldName)-7])); \
  122. }else { \
  123. dprintf("%s%-40.40s FLink = ",IndentBuf,_fieldName ); \
  124. }
  125. #define PrintIndent() dprintf( "%s", IndentBuf );
  126. /* #define PrintFieldName(_fieldName) \
  127. dprintf(" %-25.25s = ",_fieldName );*/
  128. #define PrintRawBool( _bValue ) \
  129. dprintf("%-10s%s", (_obj._bValue) ? "True" : "False", EOL)
  130. #define PrintBool(_field) \
  131. PrintFieldName(#_field) \
  132. dprintf("%-10s%s", (_obj._field) ? "True" : "False", EOL)
  133. #define PrintULong(_field) \
  134. PrintFieldName(#_field) \
  135. dprintf("%-10lu%s", _obj._field, EOL)
  136. #define PrintXULong(_field) \
  137. PrintFieldName(#_field) \
  138. dprintf("0x%08lx%s", _obj._field, EOL)
  139. #define PrintUShort(_field) \
  140. PrintFieldName(#_field) \
  141. dprintf("%-10hu%s", _obj._field, EOL)
  142. #define PrintHTONUShort(_field) \
  143. PrintFieldName(#_field) \
  144. dprintf("%-10hu%s", htons(_obj._field), EOL)
  145. #define PrintXUShort(_field) \
  146. PrintFieldName(#_field) \
  147. dprintf("0x%04hx%s", _obj._field, EOL)
  148. #define PrintNChar( _field, count ) \
  149. PrintFieldName(#_field) \
  150. dprint_nchar( ( PCHAR )_obj._field, count ); \
  151. dprintf("%s", EOL)
  152. #define PrintUChar(_field) \
  153. PrintFieldName(#_field) \
  154. dprintf("%-10lu%s", (ULONG) _obj._field, EOL)
  155. #define PrintXUChar(_field) \
  156. PrintFieldName(#_field) \
  157. dprintf("0x%-8lx%s", (ULONG) _obj._field, EOL)
  158. #define PrintPtr(_field) \
  159. PrintFieldName(#_field) \
  160. dprintf("%-10lx%s", _obj._field, EOL)
  161. #define PrintSymbolPtr( _field ) \
  162. PrintFieldName(#_field) \
  163. dprintSymbolPtr( (( PVOID )_obj._field), EOL );
  164. #define AddressOf( _field ) ((( ULONG )_objAddr) + FIELD_OFFSET( _objType, _field ))
  165. #define PrintAddr(_field) \
  166. PrintFieldNameAt(#_field) \
  167. dprintf("%-10lx%s", AddressOf( _field ), EOL)
  168. #define PrintL(_field) \
  169. PrintFieldName(#_field##".Next") \
  170. dprintf("%-10lx%s", _obj._field.Next, EOL )
  171. #define PrintLL(_field) \
  172. PrintEnd; \
  173. PrintListFieldName(#_field ); \
  174. dprintf("%-10lx", _obj._field.Flink ); \
  175. dprintf("Blink = %-10lx", _obj._field.Blink ); \
  176. dprintf("%s\n", ( _obj._field.Flink == _obj._field.Blink ) ? " (Empty)" : "" );
  177. #define PrintLLTcp(_field) \
  178. PrintEnd; \
  179. PrintListTcpFieldName(#_field ); \
  180. dprintf("%-10lx", _obj._field.q_next ); \
  181. dprintf("q_prev = %-10lx", _obj._field.q_prev ); \
  182. dprintf("%s\n", ( _obj._field.q_next == _obj._field.q_prev ) ? " (Empty)" : "" );
  183. #define PrintIrpQ(_field) \
  184. PrintEnd; \
  185. PrintFieldName(#_field##".Head"); \
  186. dprintf("%-10lx", _obj._field.Head ); \
  187. PrintFieldName(#_field##".Tail"); \
  188. dprintf("%-10lx\n", _obj._field.Tail );
  189. #define PrintFlags( _field, _pFlagStruct ) \
  190. PrintEnd; \
  191. PrintFieldName(#_field); \
  192. dprintf("0x%08lx (", (ULONG) _obj._field ); \
  193. dprint_flag_names( (ULONG) _obj._field, _pFlagStruct ); \
  194. dprintf( ")\n" );
  195. #define PrintFlagsMask( _field, _pFlagStruct, _Mask ) \
  196. PrintEnd; \
  197. PrintFieldName(" & " ## #_Mask ); \
  198. dprintf("0x"); \
  199. dprint_masked_value((ULONG) _obj._field, _Mask ); \
  200. dprintf("("); \
  201. dprint_flag_names( (ULONG) _obj._field, _pFlagStruct ); \
  202. dprintf( ")\n" );
  203. #define PrintEnum( _field, _pEnumStruct ) \
  204. PrintEnd; \
  205. PrintFieldName(#_field); \
  206. dprintf("%lu (", (ULONG) _obj._field ); \
  207. dprint_enum_name( (ULONG) _obj._field, _pEnumStruct ); \
  208. dprintf( ")\n" );
  209. #define PrintXEnum( _field, _pEnumStruct ) \
  210. PrintEnd; \
  211. PrintFieldName(#_field); \
  212. dprintf("0x%08lx (", (ULONG) _obj._field ); \
  213. dprint_enum_name( (ULONG) _obj._field, _pEnumStruct ); \
  214. dprintf( ")\n" );
  215. #define PrintXEnumMask( _field, _pEnumStruct, _Mask ) \
  216. PrintEnd; \
  217. PrintFieldName(" & " ## #_Mask ); \
  218. dprintf("0x"); \
  219. dprint_masked_value((ULONG) _obj._field, _Mask ); \
  220. dprintf("("); \
  221. dprint_enum_name((ULONG) _obj._field & _Mask, _pEnumStruct ); \
  222. dprintf( ")\n" );
  223. #define PrintHardwareAddress( _field ) \
  224. PrintFieldName(#_field); \
  225. dprint_hardware_address( _obj._field.Address ); \
  226. dprintf( "%s", EOL );
  227. #define PrintIPAddress( _field ) \
  228. PrintFieldName(#_field); \
  229. dprint_IP_address( _obj._field ); \
  230. dprintf( "%s", EOL );
  231. #define PrintGUID( _field ) \
  232. PrintFieldName(#_field); \
  233. dprintf("{%lx.%lx.%lx.%lx}", \
  234. *(PULONG)(&_obj._field), \
  235. *((PUCHAR)(&_obj._field)+4), \
  236. *((PUCHAR)(&_obj._field)+8), \
  237. *((PUCHAR)(&_obj._field)+12)); \
  238. dprintf( "%s", EOL );
  239. #define PrintLock(_field) \
  240. PrintFieldName(#_field) \
  241. dprintf("( 0x%08lx ) %-10s%s", (_obj._field), (_obj._field) ? "Locked" : "UnLocked", EOL)
  242. #define PrintTDIAddress( _field ) \
  243. PrintFieldName( #_field ); \
  244. dprintf( "{ NetworkAddress = %X, NodeAddress = ", _obj._field.NetworkAddress );\
  245. dprint_hardware_address( _obj._field.NodeAddress );\
  246. dprintf( ", Socket = %d }%s", _obj._field.Socket, EOL );
  247. #define PrintCTETimer( _field ) \
  248. dprintf( "%s", #_field ); \
  249. PrintStartStruct(); \
  250. DumpCTETimer ( ((ULONG)_objAddr) +FIELD_OFFSET( _objType, _field ), VERBOSITY_NORMAL );\
  251. PrintEndStruct();
  252. #define PrintCTEEvent( _field ) \
  253. dprintf( "%s", #_field ); \
  254. PrintStartStruct(); \
  255. DumpCTEEvent ( ((ULONG)_objAddr) +FIELD_OFFSET( _objType, _field ), VERBOSITY_NORMAL );\
  256. PrintEndStruct();
  257. #define PrintKEvent( _field ) \
  258. dprintf( "%s", #_field ); \
  259. PrintStartStruct(); \
  260. DumpKEvent ( ((ULONG)_objAddr) +FIELD_OFFSET( _objType, _field ), VERBOSITY_NORMAL );\
  261. PrintEndStruct();
  262. #define PrintWorkQueueItem( _field ) \
  263. dprintf( "%s", #_field ); \
  264. PrintStartStruct(); \
  265. DumpWorkQueueItem ( ((ULONG)_objAddr) +FIELD_OFFSET( _objType, _field ), VERBOSITY_NORMAL );\
  266. PrintEndStruct();
  267. extern BOOLEAN ChkTarget;
  268. extern INT Item;
  269. #define CHECK_SIGNATURE( _field, _signature ) \
  270. if ( _obj._field != _signature ) \
  271. { \
  272. dprintf( "Object at %08X doesn't have signature %s at %08X\n", \
  273. _objAddr, \
  274. #_signature, \
  275. (( ULONG )_objAddr) + FIELD_OFFSET( _objType, _field ));\
  276. }