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.

297 lines
6.1 KiB

  1. #define MYASSERT(_cond) \
  2. ((_cond) ? 0 : MyDbgPrintf("ASSERTION FAILED\n"))
  3. typedef int bool;
  4. //
  5. // Debugger Extension Primitives
  6. //
  7. bool
  8. dbgextReadMemory(
  9. UINT_PTR uOffset,
  10. void * pvBuffer,
  11. UINT cb,
  12. char *pszDescription
  13. );
  14. bool
  15. dbgextReadUINT_PTR(
  16. UINT_PTR uOffset,
  17. UINT_PTR *pu,
  18. char *pszDescription
  19. );
  20. bool
  21. dbgextWriteMemory(
  22. UINT_PTR uOffset,
  23. void * pvBuffer,
  24. UINT cb,
  25. char *pszDescription
  26. );
  27. bool
  28. dbgextWriteUINT_PTR(
  29. UINT_PTR uOffset,
  30. UINT_PTR u,
  31. char *pszDescription
  32. );
  33. UINT_PTR
  34. dbgextGetExpression(
  35. const char *pcszExpression
  36. );
  37. #if 0 // Not sure what this one is about...
  38. void
  39. dbgextGetSymbol(
  40. void *offset,
  41. UCHAR *pchBuffer,
  42. UINT *pDisplacement
  43. );
  44. #endif // 0
  45. typedef
  46. void
  47. (__cdecl *MYPWINDBG_OUTPUT_ROUTINE)(
  48. const char * lpFormat,
  49. ...
  50. );
  51. extern MYPWINDBG_OUTPUT_ROUTINE g_pfnDbgPrintf;
  52. #define MyDbgPrintf g_pfnDbgPrintf
  53. //
  54. // User Commands Parsing Support and Structures
  55. //
  56. typedef struct
  57. {
  58. //TOKEN tokCmd;
  59. UINT uParam;
  60. UINT uFlags;
  61. } COMMAND;
  62. //!aac if@0x099900.*sig*
  63. //!aac if[0].*sig*
  64. struct _TYPE_INFO;
  65. typedef
  66. UINT_PTR
  67. (*PFN_DUMP)(
  68. struct _TYPE_INFO *pType,
  69. UINT uFlags
  70. );
  71. #define fDUMP_ONE_LINE_SUMMARY (0x1)
  72. typedef struct
  73. {
  74. char *szName;
  75. UINT Mask;
  76. UINT Value;
  77. } BITFIELD_INFO;
  78. typedef struct _TYPE_INFO
  79. {
  80. const char * szName;
  81. const char * szShortName;
  82. UINT uTypeID;
  83. UINT uFlags; // One or more fTYPEINFO_ flags.
  84. UINT cbSize;
  85. struct _STRUCT_FIELD_INFO *rgFields;
  86. UINT uNextOffset;
  87. // If this type is a list element, this is the offset
  88. // in bytes to the next pointer.
  89. // Only valid if uFlags contains fTYPEINFO_ISLIST
  90. BITFIELD_INFO *rgBitFieldInfo;
  91. //
  92. // If this type is a bitfield, this this points
  93. // to an array of BITFIELD_INFO structs, giving
  94. // the set of valid bitfield constants that can
  95. // be held in this bitfield.
  96. //
  97. // Note -- only one of rgFields and rgBitField info
  98. // should be non-null (both can be null).
  99. //
  100. UINT_PTR uCachedAddress; // Set to the address of this type that
  101. // was most recently referenced.
  102. PFN_DUMP pfnDump;
  103. } TYPE_INFO;
  104. #define fTYPEINFO_ISLIST (0x1<<0)
  105. #define fTYPEINFO_ISBITFIELD (0x1<<1)
  106. #define TYPEISLIST(_pType) ((_pType)->uFlags & fTYPEINFO_ISLIST)
  107. #define TYPEISBITFIELD(_pType) ((_pType)->uFlags & fTYPEINFO_ISBITFIELD)
  108. //
  109. // STRUCT_FIELD_INFO contains information about a particular field of a struct.
  110. //
  111. typedef struct _STRUCT_FIELD_INFO
  112. {
  113. const char *szFieldName;
  114. UINT uFieldOffset; // Offset in bytes from start of containing structure.
  115. UINT uFieldSize;
  116. UINT uFlags; // one or more fFI_* flags define below
  117. TYPE_INFO *pBaseType;
  118. } STRUCT_FIELD_INFO;
  119. #define fFI_PTR (0x1<<0) // Field is a pointer
  120. #define fFI_LIST (0x1<<1) // Field is a pointer to 1st element of a list
  121. #define fFI_ARRAY (0x1<<2) // Field is an array (pointer to array if
  122. // fFI_PTR is set).
  123. #define fFI_OPAQUE (0x1<<3) // Treat object as opaque, of size uObjectSize.
  124. // If set then fLIST must not be set.
  125. #define FIELD_IS_EMBEDDED_TYPE(_pFI) \
  126. ( !((_pFI)->uFlags & (fFI_PTR|fFI_OPAQUE|fFI_ARRAY)) \
  127. && ((_pFI)->pBaseType))
  128. //
  129. // true iff the field is itself a valid type
  130. //
  131. #define FIELD_IS_PTR_TO_TYPE(_pFI) \
  132. ( ((_pFI)->uFlags & fFI_PTR) \
  133. && !((_pFI)->uFlags & (fFI_OPAQUE|fFI_ARRAY)) \
  134. && ((_pFI)->pBaseType))
  135. //
  136. // true iff the field is pointer to a valid type
  137. //
  138. #define FIELD_SIZE(type, field) sizeof(((type *)0)->field)
  139. //
  140. // Information about a global variable.
  141. //
  142. typedef struct
  143. {
  144. const char *szName; // of variable.
  145. const char *szShortName;
  146. TYPE_INFO *pBaseType; // could be null (unspecified).
  147. UINT uFlags;
  148. UINT cbSize;
  149. UINT_PTR uAddr; // Address in debuggee's address space.
  150. } GLOBALVAR_INFO;
  151. typedef
  152. UINT_PTR
  153. (*PFN_RESOLVE_ADDRESS)(
  154. TYPE_INFO *pType
  155. );
  156. typedef struct
  157. {
  158. TYPE_INFO **pTypes;
  159. GLOBALVAR_INFO *pGlobals;
  160. PFN_RESOLVE_ADDRESS pfnResolveAddress;
  161. } NAMESPACE;
  162. void
  163. DumpObjects(TYPE_INFO *pType, UINT_PTR uAddr, UINT cObjects, UINT uFlags);
  164. #define fMATCH_SUBSTRING (0x1<<0)
  165. #define fMATCH_PREFIX (0x1<<1)
  166. #define fMATCH_SUFFIX (0x1<<2)
  167. void
  168. DumpStructure(
  169. TYPE_INFO *pType,
  170. UINT_PTR uAddr,
  171. char *szFieldSpec,
  172. UINT uFlags
  173. );
  174. bool
  175. DumpMemory(
  176. UINT_PTR uAddr,
  177. UINT cb,
  178. UINT uFlags,
  179. const char *pszDescription
  180. );
  181. typedef bool (*PFNMATCHINGFUNCTION) (
  182. const char *szPattern,
  183. const char *szString
  184. );
  185. bool
  186. MatchPrefix(const char *szPattern, const char *szString);
  187. bool
  188. MatchSuffix(const char *szPattern, const char *szString);
  189. bool
  190. MatchSubstring(const char *szPattern, const char *szString);
  191. bool
  192. MatchExactly(const char *szPattern, const char *szString);
  193. bool
  194. MatchAlways(const char *szPattern, const char *szString);
  195. typedef ULONG (*PFNNODEFUNC)(
  196. UINT_PTR uNodeAddr,
  197. UINT uIndex,
  198. void *pvContext
  199. );
  200. //
  201. // PFNNODEFUNC is the prototype of the func passed into WalkList
  202. //
  203. UINT
  204. WalkList(
  205. UINT_PTR uStartAddress,
  206. UINT uNextOffset,
  207. UINT uStartIndex,
  208. UINT uEndIndex,
  209. void *pvContext,
  210. PFNNODEFUNC pFunc,
  211. char *pszDescription
  212. );
  213. //
  214. // Visit each node in the list in turn,
  215. // reading just the next pointers. It calls pFunc for each list node
  216. // between uStartIndex and uEndIndex. It terminates under the first of
  217. // the following conditions:
  218. // * Null pointer
  219. // * ReadMemoryError
  220. // * Read past uEndIndex
  221. // * pFunc returns FALSE
  222. //
  223. ULONG
  224. NodeFunc_DumpAddress (
  225. UINT_PTR uNodeAddr,
  226. UINT uIndex,
  227. void *pvContext
  228. );
  229. //
  230. // This is a sample node function -- simply dumps the specfied address.
  231. //