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.

254 lines
9.7 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. //
  4. // File: _dbgext.h
  5. //
  6. // Description:
  7. // Defines macros for defining structures to dump in your CDB extension
  8. //
  9. // Usage:
  10. // Create a head file that includes this file and defines your field
  11. // descriptors using only the following macros:
  12. //
  13. // BIT MASKS:
  14. // BEGIN_BIT_MASK_DESCRIPTOR(BitMaskName) -
  15. // start bit mask descriptor
  16. // BIT_MASK_VALUE(Value) -
  17. // Give a defined value for a bit mask. Uses #Value
  18. // to describe the value. If your bitmask values are
  19. // defined using #defines... then only the numerical
  20. // values will appear in the dump... use BIT_MASK_VALUE2
  21. // instead.
  22. // BIT_MASK_VALUE2(Value, Description) -
  23. // Give a value and description for a bit mask.
  24. // END_BIT_MASK_DESCRIPTOR
  25. // Mark the end of a bit mask descriptor
  26. //
  27. // ENUMS:
  28. // BEGIN_ENUM_DESCRIPTOR(BitMaskName) -
  29. // start enum descriptor
  30. // ENUM_VALUE(Value) -
  31. // Give a defined value for a enum. Uses #Value
  32. // to describe the value.
  33. // ENUM_VALUE2(Value, Description) -
  34. // Give a value and description for a enum.
  35. // END__DESCRIPTOR -
  36. // Mark the end of a enum descriptor
  37. //
  38. // STRUCTURES & CLASSES:
  39. // BEGIN_FIELD_DESCRIPTOR(FieldDescriptorName) -
  40. // start field decscritor
  41. // FIELD3(FieldType, StructureName, FieldName) -
  42. // define non-enum public field
  43. // FIELD4(FieldType, StructureName, FieldName, AuxInfo) -
  44. // define enum public field
  45. // For FIELD4, you should pass one of the following to
  46. // to define the aux info:
  47. // GET_ENUM_DESCRIPTOR(x)
  48. // GET_BITMASK_DESCRIPTOR(x)
  49. // Where x is one of the values used to define a bit mask
  50. // or enum.
  51. //
  52. // END_FIELD_DESCRIPTOR -
  53. // Define end of field descriptors for class/struct
  54. //
  55. // GLOBALS: - Used to tell ptdbgext what class/structures to dump
  56. // BEGIN_STRUCT_DESCRIPTOR -
  57. // Marks the begining of the global stuct descriptor
  58. // STRUCT(TypeName,FieldDescriptor) -
  59. // Defines a struct to dump. TypeName is the name of the
  60. // type, and FieldDescriptor is a name given in a
  61. // BEGIN_FIELD_DESCRIPTOR.
  62. //
  63. // NOTE: You must define bit masks & enums before classes and structures.
  64. // You must also define the global STRUCT_DESCRIPTOR last.
  65. //
  66. // **this include file with redefine the key words "protected" and "private"***
  67. //
  68. // Author: mikeswa
  69. //
  70. // Copyright (C) 1998 Microsoft Corporation
  71. //
  72. //-----------------------------------------------------------------------------
  73. #ifndef ___DBGEXT_H__FIRST_PASS_
  74. #define ___DBGEXT_H__FIRST_PASS_
  75. #ifndef PTDBGEXT_USE_FRIEND_CLASSES
  76. //Needed to allow access to private members of classes
  77. #define private public
  78. #define protected public
  79. #endif //PTDBGEXT_USE_FRIEND_CLASSES
  80. #define DEFINE_VALUE(VAL) \
  81. {VAL, #VAL},
  82. #define DEFINE_VALUE2(VAL, DESCRIPTION) \
  83. {VAL, DESCRIPTION},
  84. //---[ ENUM MACROS ]-----------------------------------------------------------
  85. //
  86. //
  87. // Description: Enum macro definitions.... used to define enum values for
  88. // the dump command.
  89. //
  90. //
  91. //-----------------------------------------------------------------------------
  92. #define GET_ENUM_DESCRIPTOR(ENUM_NAME) EnumValueDescrsOf_##ENUM_NAME
  93. #define BEGIN_ENUM_DESCRIPTOR(ENUM_NAME) \
  94. ENUM_VALUE_DESCRIPTOR GET_ENUM_DESCRIPTOR(ENUM_NAME)[] = {
  95. #define END_ENUM_DESCRIPTOR \
  96. 0 \
  97. };
  98. #define ENUM_VALUE(VAL) DEFINE_VALUE(VAL)
  99. #define ENUM_VALUE2(VAL, DESCRIPTION) DEFINE_VALUE2(VAL, DESCRIPTION)
  100. //Bit masks
  101. //---[ BIT MASK MACROS ]-------------------------------------------------------
  102. //
  103. //
  104. // Description: Bit mask macro definitions... used to define bit mask values
  105. // for the dump command.
  106. //
  107. //
  108. //-----------------------------------------------------------------------------
  109. #define GET_BIT_MASK_DESCRIPTOR(BITMAP_NAME) BitmapValueDescrsOf_##BITMAP_NAME
  110. #define BEGIN_BIT_MASK_DESCRIPTOR(BITMAP_NAME) \
  111. BIT_MASK_DESCRIPTOR GET_BIT_MASK_DESCRIPTOR(BITMAP_NAME)[] = {
  112. #define END_BIT_MASK_DESCRIPTOR \
  113. 0 \
  114. };
  115. #define BIT_MASK_VALUE(VAL) DEFINE_VALUE(VAL)
  116. #define BIT_MASK_VALUE2(VAL, DESCRIPTION) DEFINE_VALUE2(VAL, DESCRIPTION)
  117. //---[ FIELD MACROS ]----------------------------------------------------------
  118. //
  119. //
  120. // Description: Field descriptor macros.... used to define fields from structures
  121. // and classes to dump.
  122. //
  123. //
  124. //-----------------------------------------------------------------------------
  125. //Field descriptor... used to define structures and classes
  126. #define BEGIN_FIELD_DESCRIPTOR(x) \
  127. FIELD_DESCRIPTOR x[] = {
  128. #define END_FIELD_DESCRIPTOR \
  129. NULL_FIELD \
  130. };
  131. #define FIELD3(FieldType,StructureName, FieldName) \
  132. {FieldType, #FieldName , FIELD_OFFSET(StructureName,FieldName) ,NULL},
  133. #define FIELD4(FieldType, StructureName, FieldName, AuxInfo) \
  134. {FieldType, #FieldName , FIELD_OFFSET(StructureName,FieldName) ,(VOID *) AuxInfo},
  135. #ifdef PTDBGEXT_USE_FRIEND_CLASSES
  136. #define FIELD3_PRIV(FieldType,StructureName, FieldName) \
  137. {FieldType, #FieldName , 0 ,NULL},
  138. #define FIELD4_PRIV(FieldType, StructureName, FieldName, AuxInfo) \
  139. {FieldType, #FieldName , 0,(VOID *) AuxInfo},
  140. #else //PTDBGEXT_USE_FRIEND_CLASSES not defined
  141. #define FIELD3_PRIV(FieldType,StructureName, FieldName) \
  142. {FieldType, #FieldName , FIELD_OFFSET(StructureName,FieldName) ,NULL},
  143. #define FIELD4_PRIV(FieldType, StructureName, FieldName, AuxInfo) \
  144. {FieldType, #FieldName , FIELD_OFFSET(StructureName,FieldName) ,(VOID *) AuxInfo},
  145. #endif //PTDBGEXT_USE_FRIEND_CLASSES
  146. //Struct descriptor
  147. #define BEGIN_STRUCT_DESCRIPTOR \
  148. STRUCT_DESCRIPTOR Structs[] = {
  149. #define END_STRUCT_DESCRIPTOR \
  150. 0 \
  151. };
  152. #define STRUCT(StructTypeName,FieldDescriptors) \
  153. { #StructTypeName,sizeof(StructTypeName),FieldDescriptors},
  154. #define EMBEDDED_STRUCT(StructTypeName, FieldDescriptors, EmbeddedStructName) \
  155. STRUCT_DESCRIPTOR EmbeddedStructName[] = \
  156. { STRUCT(StructTypeName, FieldDescriptors) 0 };
  157. #else //___DBGEXT_H__FIRST_PASS_ already defined...at least 2nd pass
  158. #ifdef PTDBGEXT_USE_FRIEND_CLASSES //if not set, do not do the multipass stuff
  159. #ifndef ___DBGEXT_H__
  160. #define ___DBGEXT_H__
  161. //
  162. // As an alternative to using #defining private and protected to public, you
  163. // may wish to use the friend class method of accessing the structure offsets.
  164. // (If, for example, the organization of your classes are changed as a result
  165. // of those #defining private and prctected).
  166. //
  167. // To do so, #define PTDBGEXT_USE_FRIEND_CLASSES and use the following
  168. // additional macros:
  169. //
  170. // FIELD3_PRIV(FieldType, StructureName, FieldName) -
  171. // define non-enum private field
  172. // FIELD4_PRIV(FieldType, StructureName, FieldName, AuxInfo) -
  173. // define enum private field
  174. //
  175. // If you use FIELD?_PRIV, then you are accessing private members of a
  176. // class. In this case, you need to create a void (void) initialization
  177. // function and assign it to g_pExtensionInitRoutine. It should be a
  178. // member function of class that is a friend of all the classes you are
  179. // interested in debugging. Suppose your field descriptors are defined
  180. // in mydump.h, you would need to create an initialization function as
  181. // follows:
  182. //
  183. // #include <mydump.h> //initial definition
  184. // ...
  185. // void CMyDebugExt::Init(void) {
  186. // #include <mydump.h>
  187. // }
  188. //undefine previously defined macros
  189. #undef BEGIN_FIELD_DESCRIPTOR
  190. #undef END_FIELD_DESCRIPTOR
  191. #undef FIELD3
  192. #undef FIELD4
  193. #undef FIELD3_PRIV
  194. #undef FIELD4_PRIV
  195. #undef GET_ENUM_DESCRIPTOR
  196. #undef BEGIN_ENUM_DESCRIPTOR
  197. #undef END_ENUM_DESCRIPTOR
  198. #undef GET_BIT_MASK_DESCRIPTOR
  199. #undef BEGIN_BIT_MASK_DESCRIPTOR
  200. #undef END_BIT_MASK_DESCRIPTOR
  201. #undef BEGIN_STRUCT_DESCRIPTOR
  202. #undef STRUCT
  203. #undef END_STRUCT_DESCRIPTOR
  204. #undef DEFINE_VALUE
  205. #undef DEFINE_VALUE2
  206. #undef EMBEDDED_STRUCT
  207. #define GET_ENUM_DESCRIPTOR(ENUM_NAME)
  208. #define BEGIN_ENUM_DESCRIPTOR(ENUM_NAME)
  209. #define END_ENUM_DESCRIPTOR
  210. #define GET_BIT_MASK_DESCRIPTOR(BITMAP_NAME)
  211. #define BEGIN_BIT_MASK_DESCRIPTOR(BITMAP_NAME)
  212. #define END_BIT_MASK_DESCRIPTOR
  213. #define DEFINE_VALUE(VAL)
  214. #define DEFINE_VALUE2(VAL, DESCRIPTION)
  215. #define BEGIN_STRUCT_DESCRIPTOR
  216. #define STRUCT(x, y)
  217. #define END_STRUCT_DESCRIPTOR
  218. #define EMBEDDED_STRUCT(x, y, z)
  219. #define BEGIN_FIELD_DESCRIPTOR(x) \
  220. pfd = x;
  221. #define END_FIELD_DESCRIPTOR \
  222. pfd = NULL;
  223. #define FIELD3(FieldType,StructureName, FieldName) \
  224. pfd++;
  225. #define FIELD4(FieldType, StructureName, FieldName, AuxInfo) \
  226. pfd++;
  227. //Use Field?_PRIV when dealing with private memebers. Requires 2 passes
  228. #define FIELD3_PRIV(FieldType,StructureName, FieldName) \
  229. pfd->Offset = FIELD_OFFSET(StructureName, FieldName); \
  230. pfd++;
  231. #define FIELD4_PRIV(FieldType, StructureName, FieldName, AuxInfo) \
  232. pfd->Offset = FIELD_OFFSET(StructureName, FieldName); \
  233. pfd++;
  234. FIELD_DESCRIPTOR *pfd = NULL; //Variable declaration in INIT function
  235. #else //whoops
  236. #pragma message "WARNING: _dbgext.h included more than twice"
  237. #endif //___DBGEXT_H__
  238. #endif //PTDBGEXT_USE_FRIEND_CLASSES
  239. #endif //___DBGEXT_H__FIRST_PASS_