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.

452 lines
12 KiB

  1. /*++
  2. Copyright (c) 1992-2001 Microsoft Corporation
  3. Module Name:
  4. extfns.h
  5. Abstract:
  6. This header file must be included after "windows.h", "dbgeng.h", and "wdbgexts.h".
  7. This file contains headers for various known extension functions defined in different
  8. extension dlls. To use these functions, the appropropriate extension dll must be loaded
  9. in the debugger. IDebugSymbols->GetExtension (declared in dbgeng.h) methood could be used
  10. to retrive these functions.
  11. Please see the Debugger documentation for specific information about
  12. how to write your own debugger extension DLL.
  13. Environment:
  14. Win32 only.
  15. Revision History:
  16. --*/
  17. #ifndef _EXTFNS_H
  18. #define _EXTFNS_H
  19. #ifndef _KDEXTSFN_H
  20. #define _KDEXTSFN_H
  21. /*
  22. * Extension functions defined in kdexts.dll
  23. */
  24. //
  25. // device.c
  26. //
  27. typedef struct _DEBUG_DEVICE_OBJECT_INFO {
  28. ULONG SizeOfStruct; // must be == sizeof(DEBUG_DEVICE_OBJECT_INFO)
  29. ULONG64 DevObjAddress;
  30. ULONG ReferenceCount;
  31. BOOL QBusy;
  32. ULONG64 DriverObject;
  33. ULONG64 CurrentIrp;
  34. ULONG64 DevExtension;
  35. ULONG64 DevObjExtension;
  36. } DEBUG_DEVICE_OBJECT_INFO, *PDEBUG_DEVICE_OBJECT_INFO;
  37. // GetDevObjInfo
  38. typedef HRESULT
  39. (WINAPI *PGET_DEVICE_OBJECT_INFO)(
  40. IN PDEBUG_CLIENT Client,
  41. IN ULONG64 DeviceObject,
  42. OUT PDEBUG_DEVICE_OBJECT_INFO pDevObjInfo);
  43. //
  44. // driver.c
  45. //
  46. typedef struct _DEBUG_DRIVER_OBJECT_INFO {
  47. ULONG SizeOfStruct; // must be == sizef(DEBUG_DRIVER_OBJECT_INFO)
  48. ULONG DriverSize;
  49. ULONG64 DriverObjAddress;
  50. ULONG64 DriverStart;
  51. ULONG64 DriverExtension;
  52. ULONG64 DeviceObject;
  53. UNICODE_STRING64 DriverName;
  54. } DEBUG_DRIVER_OBJECT_INFO, *PDEBUG_DRIVER_OBJECT_INFO;
  55. // GetDrvObjInfo
  56. typedef HRESULT
  57. (WINAPI *PGET_DRIVER_OBJECT_INFO)(
  58. IN PDEBUG_CLIENT Client,
  59. IN ULONG64 DriverObject,
  60. OUT PDEBUG_DRIVER_OBJECT_INFO pDrvObjInfo);
  61. //
  62. // irp.c
  63. //
  64. typedef struct _DEBUG_IRP_STACK_INFO {
  65. UCHAR Major;
  66. UCHAR Minor;
  67. ULONG64 DeviceObject;
  68. ULONG64 FileObject;
  69. ULONG64 CompletionRoutine;
  70. ULONG64 StackAddress;
  71. } DEBUG_IRP_STACK_INFO, *PDEBUG_IRP_STACK_INFO;
  72. typedef struct _DEBUG_IRP_INFO {
  73. ULONG SizeOfStruct; // Must be == sizeof(DEBUG_IRP_INFO)
  74. ULONG64 IrpAddress;
  75. ULONG StackCount;
  76. ULONG CurrentLocation;
  77. ULONG64 MdlAddress;
  78. ULONG64 Thread;
  79. ULONG64 CancelRoutine;
  80. DEBUG_IRP_STACK_INFO CurrentStack;
  81. } DEBUG_IRP_INFO, *PDEBUG_IRP_INFO;
  82. // GetIrpInfo
  83. typedef HRESULT
  84. (WINAPI * PGET_IRP_INFO)(
  85. IN PDEBUG_CLIENT Client,
  86. IN ULONG64 Irp,
  87. OUT PDEBUG_IRP_INFO IrpInfo
  88. );
  89. //
  90. // pool.c
  91. //
  92. typedef struct _DEBUG_POOL_DATA {
  93. ULONG SizeofStruct;
  94. ULONG64 PoolBlock;
  95. ULONG64 Pool;
  96. ULONG PreviousSize;
  97. ULONG Size;
  98. ULONG PoolTag;
  99. ULONG64 ProcessBilled;
  100. union {
  101. struct {
  102. ULONG Free:1;
  103. ULONG LargePool:1;
  104. ULONG SpecialPool:1;
  105. ULONG Pageable:1;
  106. ULONG Protected:1;
  107. ULONG Allocated:1;
  108. ULONG Reserved:26;
  109. };
  110. ULONG AsUlong;
  111. };
  112. ULONG64 Reserved2[4];
  113. CHAR PoolTagDescription[64];
  114. } DEBUG_POOL_DATA, *PDEBUG_POOL_DATA;
  115. // GetPoolData
  116. typedef HRESULT
  117. (WINAPI *PGET_POOL_DATA)(
  118. PDEBUG_CLIENT Client,
  119. ULONG64 Pool,
  120. PDEBUG_POOL_DATA PoolData
  121. );
  122. typedef enum _DEBUG_POOL_REGION {
  123. DbgPoolRegionUnknown,
  124. DbgPoolRegionSpecial,
  125. DbgPoolRegionPaged,
  126. DbgPoolRegionNonPaged,
  127. DbgPoolRegionCode,
  128. DbgPoolRegionNonPagedExpansion,
  129. DbgPoolRegionMax,
  130. } DEBUG_POOL_REGION;
  131. // GetPoolRegion
  132. typedef HRESULT
  133. (WINAPI *PGET_POOL_REGION)(
  134. PDEBUG_CLIENT Client,
  135. ULONG64 Pool,
  136. DEBUG_POOL_REGION *PoolRegion
  137. );
  138. #endif // _KDEXTSFN_H
  139. #ifndef _KEXTFN_H
  140. #define _KEXTFN_H
  141. /*
  142. * Extension functions defined in kdext.dll
  143. */
  144. /*********************************************************************************
  145. BugCheck definitions
  146. **********************************************************************************/
  147. typedef enum _DEBUG_FAILURE_TYPE {
  148. DEBUG_FLR_UNKNOWN,
  149. DEBUG_FLR_BUGCHECK,
  150. } DEBUG_FAILURE_TYPE;
  151. /*
  152. Each bugchek parameter has its own type, bugcheck analyzer knows how
  153. to handle each of these types, for examle it could do a !driver on
  154. a DEBUG_FLR_DRIVER_OBJECT or it coould do a .cxr and k on a DEBUG_FLR_CONTEXT.
  155. */
  156. typedef enum _DEBUG_FLR_PARAM_TYPE {
  157. DEBUG_FLR_READ_ADDRESS = 0,
  158. DEBUG_FLR_WRITE_ADDRESS,
  159. DEBUG_FLR_DRIVER_OBJECT,
  160. DEBUG_FLR_DEVICE_OBJECT,
  161. DEBUG_FLR_INVALID_PFN,
  162. DEBUG_FLR_WORKER_ROUTINE,
  163. DEBUG_FLR_WORK_ITEM,
  164. DEBUG_FLR_INVALID_DPC_FOUND,
  165. DEBUG_FLR_IRP_ADDRESS = 0x100,
  166. DEBUG_FLR_IRP_MAJOR_FN,
  167. DEBUG_FLR_IRP_MINOR_FN,
  168. DEBUG_FLR_IRP_CANCEL_ROUTINE,
  169. DEBUG_FLR_IOSB_ADDRESS,
  170. DEBUG_FLR_INVALID_USEREVENT,
  171. DEBUG_FLR_IOCONTROL_CODE,
  172. DEBUG_FLR_MM_INTERNAL_CODE,
  173. // Previous mode 0 == KernelMode , 1 == UserMode
  174. DEBUG_FLR_PREVIOUS_MODE,
  175. // Irql
  176. DEBUG_FLR_CURRENT_IRQL = 0x200,
  177. DEBUG_FLR_PREVIOUS_IRQL,
  178. DEBUG_FLR_REQUESTED_IRQL,
  179. // Exceptions
  180. DEBUG_FLR_TRAP_EXCEPTION = 0x300,
  181. DEBUG_FLR_EXCEPTION_CODE,
  182. DEBUG_FLR_EXCEPTION_PARAMETER1,
  183. DEBUG_FLR_EXCEPTION_PARAMETER2,
  184. DEBUG_FLR_EXCEPTION_PARAMETER3,
  185. DEBUG_FLR_EXCEPTION_PARAMETER4,
  186. DEBUG_FLR_EXCEPTION_RECORD,
  187. // Pool
  188. DEBUG_FLR_POOL_ADDRESS = 0x400,
  189. DEBUG_FLR_SPECIAL_POOL_CORRUPTION_TYPE,
  190. // FIlesystem
  191. DEBUG_FLR_FILE_ID = 0x500,
  192. DEBUG_FLR_FILE_LINE,
  193. DEBUG_FLR_DRIVER_VERIFIER_IOMANAGER_VIOLATION_TYPE = 0x1000,
  194. // Culprit module
  195. DEBUG_FLR_IP = 0x80000000, // Instruction where failure occurred
  196. DEBUG_FLR_FAULTING_MODULE,
  197. DEBUG_FLR_FAULTING_MODULE_OFFSET,
  198. DEBUG_FLR_POSSIBLE_FAULTING_MODULE,
  199. DEBUG_FLR_POSSIBLE_FAULTING_MODULE_OFFSET,
  200. // Routine to followup on for triaging, if not
  201. // present, consider DEBUG_FLR_IP as followup address
  202. DEBUG_FLR_FOLLOWUP_IP,
  203. // To get faulting stack
  204. DEBUG_FLR_THREAD = 0xc0000000,
  205. DEBUG_FLR_CONTEXT,
  206. DEBUG_FLR_TRAP,
  207. DEBUG_FLR_TSS,
  208. } DEBUG_FLR_PARAM_TYPE;
  209. typedef struct _DEBUG_FLR_PARAM_VALUES {
  210. DEBUG_FLR_PARAM_TYPE ParamType;
  211. ULONG64 Value;
  212. } DEBUG_FLR_PARAM_VALUES, *PDEBUG_FLR_PARAM_VALUES;
  213. typedef struct _DEBUG_FAILURE_ANALYSIS {
  214. ULONG SizeOfHeader; // must be sizeof(DEBUG_FAILURE_ANALYSIS)
  215. ULONG Size; // Actual size of struct
  216. DEBUG_FAILURE_TYPE FailureType;// Is this bugcheck / AV or something else
  217. ULONG BugCode;
  218. ULONG64 Reserved[4];
  219. ULONG SymNameOffset; // Offset of KeySymName from start of struct
  220. ULONG StackOffset; // Offset of KeyStack from start of struct
  221. ULONG DriverNameOffset;// Offset of KeyDriverName from start of struct
  222. ULONG ParamCount;
  223. DEBUG_FLR_PARAM_VALUES Params[1];
  224. // Varying fields in struct, corresponding Offset values in struct are used to
  225. // access these.
  226. // If corresponding offset is 0, the field is not present
  227. CHAR KeySymName[1]; // Most commonly this would be the symbol at
  228. // faulting address of format <mod>!<routine>
  229. // Null terminated dword aligned string.
  230. CHAR KeyStack[1]; // Stack relevant to this particular crash, it isn't always
  231. // the current stack.
  232. // The individual frames are separated by newline.
  233. // Whole stack is null terminated dword aligned string.
  234. WCHAR KeyDriverName[1];// If present this will have the name most driver
  235. // most likely to be the cause of the crash.
  236. } DEBUG_FAILURE_ANALYSIS, *PDEBUG_FAILURE_ANALYSIS;
  237. typedef HRESULT
  238. (WINAPI *PGET_DEBUG_FAILURE_ANALYZER)(
  239. IN PDEBUG_CLIENT Client,
  240. OUT PDEBUG_FAILURE_ANALYSIS* pAnalysis
  241. );
  242. /*********************************************************************************
  243. PoolTag definitions
  244. **********************************************************************************/
  245. typedef struct _DEBUG_POOLTAG_DESCRIPTION {
  246. ULONG SizeOfStruct; // must be == sizeof(DEBUG_POOLTAG_DESCRIPTION)
  247. ULONG PoolTag;
  248. CHAR Description[MAX_PATH];
  249. CHAR Binary[32];
  250. CHAR Owner[32];
  251. } DEBUG_POOLTAG_DESCRIPTION, *PDEBUG_POOLTAG_DESCRIPTION;
  252. // GetPoolTagDescription
  253. typedef HRESULT
  254. (WINAPI *PGET_POOL_TAG_DESCRIPTION)(
  255. ULONG PoolTag,
  256. PDEBUG_POOLTAG_DESCRIPTION pDescription
  257. );
  258. #endif // _KEXTFN_H
  259. #ifndef _EXTAPIS_H
  260. #define _EXTAPIS_H
  261. /*
  262. * Extension functions defined in ext.dll
  263. */
  264. /***********************************************************************************
  265. Target info
  266. ***********************************************************************************/
  267. typedef enum _TARGET_MODE {
  268. NoTarget = DEBUG_CLASS_UNINITIALIZED,
  269. KernelModeTarget = DEBUG_CLASS_KERNEL,
  270. UserModeTarget = DEBUG_CLASS_USER_WINDOWS,
  271. NumModes,
  272. } TARGET_MODE;
  273. typedef enum _OS_TYPE {
  274. WIN_95,
  275. WIN_98,
  276. WIN_ME,
  277. WIN_NT4,
  278. WIN_NT5,
  279. WIN_NT5_1,
  280. NUM_WIN,
  281. } OS_TYPE;
  282. //
  283. // Info about OS installed
  284. //
  285. typedef struct _OS_INFO {
  286. OS_TYPE Type; // OS type such as NT4, NT5 etc.
  287. union {
  288. struct {
  289. ULONG Major;
  290. ULONG Minor;
  291. } Version; // 64 bit OS version number
  292. ULONG64 Ver64;
  293. };
  294. NT_PRODUCT_TYPE ProductType; // NT, LanMan or Server
  295. SUITE_TYPE Suite; // OS flavour - per, SmallBuisness etc.
  296. struct {
  297. ULONG Checked:1; // If its a checked build
  298. ULONG Pae:1; // True for Pae systems
  299. ULONG MultiProc:1; // True for multiproc enabled OS
  300. ULONG Reserved:29;
  301. } s;
  302. ULONG SrvPackNumber; // Service pack number of OS
  303. TCHAR Language[30]; // OS language
  304. TCHAR OsString[64]; // Build string
  305. TCHAR ServicePackString[64];
  306. // Service pack string
  307. } OS_INFO, *POS_INFO;
  308. typedef struct _CPU_INFO {
  309. ULONG Type; // Processor type as in IMAGE_FILE_MACHINE types
  310. ULONG NumCPUs; // Actual number of Processors
  311. ULONG CurrentProc; // Current processor
  312. DEBUG_PROCESSOR_IDENTIFICATION_ALL ProcInfo[32];
  313. } CPU_INFO, *PCPU_INFO;
  314. typedef enum _DATA_SOURCE {
  315. Debugger,
  316. Stress,
  317. } DATA_SOURCE;
  318. #define MAX_STACK_IN_BYTES 4096
  319. typedef struct _TARGET_DEBUG_INFO {
  320. ULONG SizeOfStruct;
  321. ULONG64 Id; // ID unique to this debug info
  322. DATA_SOURCE Source; // Source where this came from
  323. ULONG64 EntryDate; // Date created
  324. ULONG64 SysUpTime; // System Up time
  325. ULONG64 AppUpTime; // Application up time
  326. ULONG64 CrashTime; // Time system / app crashed
  327. TARGET_MODE Mode; // Kernel / User mode
  328. OS_INFO OsInfo; // OS details
  329. CPU_INFO Cpu; // Processor details
  330. TCHAR DumpFile[MAX_PATH]; // Dump file name if its a dump
  331. PVOID FailureData; // Failure data collected by debugger
  332. CHAR StackTr[MAX_STACK_IN_BYTES];
  333. // Contains stacks, with frames separated by newline
  334. } TARGET_DEBUG_INFO, *PTARGET_DEBUG_INFO;
  335. // GetTargetInfo
  336. typedef HRESULT
  337. (WINAPI* EXT_TARGET_INFO)(
  338. PDEBUG_CLIENT Client,
  339. PTARGET_DEBUG_INFO pTargetInfo
  340. );
  341. typedef struct _DEBUG_DECODE_ERROR {
  342. ULONG SizeOfStruct; // Must be == sizeof(DEBUG_DECODE_ERROR)
  343. ULONG Code; // Error code to be decoded
  344. BOOL TreatAsStatus; // True if code is to be treated as Status
  345. CHAR Source[64]; // Source from where we got decoded message
  346. CHAR Message[MAX_PATH]; // Message string for error code
  347. } DEBUG_DECODE_ERROR, *PDEBUG_DECODE_ERROR;
  348. /*
  349. Decodes and prints the given error code - DecodeError
  350. */
  351. typedef VOID
  352. (WINAPI *EXT_DECODE_ERROR)(
  353. PDEBUG_DECODE_ERROR pDecodeError
  354. );
  355. //
  356. // ext.dll: GetTriageFollowupFromSymbol
  357. //
  358. // This returns owner info from a given symbol name
  359. //
  360. typedef struct _DEBUG_TRIAGE_FOLLOWUP_INFO {
  361. ULONG SizeOfStruct; // Must be == sizeof (DEBUG_TRIAGE_FOLLOWUP_INFO)
  362. STRING OwnerName; // Followup owner name returned in this
  363. // Caller should initialize the name buffer
  364. } DEBUG_TRIAGE_FOLLOWUP_INFO, *PDEBUG_TRIAGE_FOLLOWUP_INFO;
  365. typedef BOOL
  366. (WINAPI *EXT_TRIAGE_FOLLOWP)(
  367. IN PSTR SymbolName,
  368. OUT PDEBUG_TRIAGE_FOLLOWUP_INFO OwnerInfo
  369. );
  370. #endif // _EXTAPIS_H
  371. #endif // _EXTFNS_H