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.

471 lines
11 KiB

  1. /*++ BUILD Version: 0001 // Increment this if a change has global effects
  2. Copyright (c) 1985-1993, Microsoft Corporation
  3. Module Name:
  4. vdmdbg.h
  5. Abstract:
  6. Prodecure declarations, constant definitions, type definition and macros
  7. for the VDMDBG.DLL VDM Debugger interface.
  8. --*/
  9. #ifndef _VDMDBG_
  10. #define _VDMDBG_
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. #pragma pack(4)
  15. #define STATUS_VDM_EVENT STATUS_SEGMENT_NOTIFICATION
  16. #ifndef DBG_SEGLOAD
  17. #define DBG_SEGLOAD 0
  18. #define DBG_SEGMOVE 1
  19. #define DBG_SEGFREE 2
  20. #define DBG_MODLOAD 3
  21. #define DBG_MODFREE 4
  22. #define DBG_SINGLESTEP 5
  23. #define DBG_BREAK 6
  24. #define DBG_GPFAULT 7
  25. #define DBG_DIVOVERFLOW 8
  26. #define DBG_INSTRFAULT 9
  27. #define DBG_TASKSTART 10
  28. #define DBG_TASKSTOP 11
  29. #define DBG_DLLSTART 12
  30. #define DBG_DLLSTOP 13
  31. #define DBG_ATTACH 14
  32. #endif
  33. //
  34. // The following flags control the contents of the CONTEXT structure.
  35. //
  36. #define VDMCONTEXT_i386 0x00010000 // this assumes that i386 and
  37. #define VDMCONTEXT_i486 0x00010000 // i486 have identical context records
  38. #define VDMCONTEXT_CONTROL (VDMCONTEXT_i386 | 0x00000001L) // SS:SP, CS:IP, FLAGS, BP
  39. #define VDMCONTEXT_INTEGER (VDMCONTEXT_i386 | 0x00000002L) // AX, BX, CX, DX, SI, DI
  40. #define VDMCONTEXT_SEGMENTS (VDMCONTEXT_i386 | 0x00000004L) // DS, ES, FS, GS
  41. #define VDMCONTEXT_FLOATING_POINT (VDMCONTEXT_i386 | 0x00000008L) // 387 state
  42. #define VDMCONTEXT_DEBUG_REGISTERS (VDMCONTEXT_i386 | 0x00000010L) // DB 0-3,6,7
  43. #define VDMCONTEXT_FULL (VDMCONTEXT_CONTROL | VDMCONTEXT_INTEGER |\
  44. VDMCONTEXT_SEGMENTS)
  45. #ifdef _X86_
  46. // On x86 machines, just copy the definition of the CONTEXT and LDT_ENTRY
  47. // structures.
  48. typedef struct _CONTEXT VDMCONTEXT;
  49. typedef struct _LDT_ENTRY VDMLDT_ENTRY;
  50. #else // _X86_
  51. //
  52. // Define the size of the 80387 save area, which is in the context frame.
  53. //
  54. #define SIZE_OF_80387_REGISTERS 80
  55. typedef struct _FLOATING_SAVE_AREA {
  56. ULONG ControlWord;
  57. ULONG StatusWord;
  58. ULONG TagWord;
  59. ULONG ErrorOffset;
  60. ULONG ErrorSelector;
  61. ULONG DataOffset;
  62. ULONG DataSelector;
  63. UCHAR RegisterArea[SIZE_OF_80387_REGISTERS];
  64. ULONG Cr0NpxState;
  65. } FLOATING_SAVE_AREA;
  66. //
  67. // Simulated context structure for the 16-bit environment
  68. //
  69. typedef struct _VDMCONTEXT {
  70. //
  71. // The flags values within this flag control the contents of
  72. // a CONTEXT record.
  73. //
  74. // If the context record is used as an input parameter, then
  75. // for each portion of the context record controlled by a flag
  76. // whose value is set, it is assumed that that portion of the
  77. // context record contains valid context. If the context record
  78. // is being used to modify a threads context, then only that
  79. // portion of the threads context will be modified.
  80. //
  81. // If the context record is used as an IN OUT parameter to capture
  82. // the context of a thread, then only those portions of the thread's
  83. // context corresponding to set flags will be returned.
  84. //
  85. // The context record is never used as an OUT only parameter.
  86. //
  87. // CONTEXT_FULL on some systems (MIPS namely) does not contain the
  88. // CONTEXT_SEGMENTS definition. VDMDBG assumes that CONTEXT_INTEGER also
  89. // includes CONTEXT_SEGMENTS to account for this.
  90. //
  91. ULONG ContextFlags;
  92. //
  93. // This section is specified/returned if CONTEXT_DEBUG_REGISTERS is
  94. // set in ContextFlags. Note that CONTEXT_DEBUG_REGISTERS is NOT
  95. // included in CONTEXT_FULL.
  96. //
  97. ULONG Dr0;
  98. ULONG Dr1;
  99. ULONG Dr2;
  100. ULONG Dr3;
  101. ULONG Dr6;
  102. ULONG Dr7;
  103. //
  104. // This section is specified/returned if the
  105. // ContextFlags word contians the flag CONTEXT_FLOATING_POINT.
  106. //
  107. FLOATING_SAVE_AREA FloatSave;
  108. //
  109. // This section is specified/returned if the
  110. // ContextFlags word contians the flag CONTEXT_SEGMENTS.
  111. //
  112. ULONG SegGs;
  113. ULONG SegFs;
  114. ULONG SegEs;
  115. ULONG SegDs;
  116. //
  117. // This section is specified/returned if the
  118. // ContextFlags word contians the flag CONTEXT_INTEGER.
  119. //
  120. ULONG Edi;
  121. ULONG Esi;
  122. ULONG Ebx;
  123. ULONG Edx;
  124. ULONG Ecx;
  125. ULONG Eax;
  126. //
  127. // This section is specified/returned if the
  128. // ContextFlags word contians the flag CONTEXT_CONTROL.
  129. //
  130. ULONG Ebp;
  131. ULONG Eip;
  132. ULONG SegCs; // MUST BE SANITIZED
  133. ULONG EFlags; // MUST BE SANITIZED
  134. ULONG Esp;
  135. ULONG SegSs;
  136. } VDMCONTEXT;
  137. //
  138. // LDT descriptor entry
  139. //
  140. typedef struct _VDMLDT_ENTRY {
  141. USHORT LimitLow;
  142. USHORT BaseLow;
  143. union {
  144. struct {
  145. UCHAR BaseMid;
  146. UCHAR Flags1; // Declare as bytes to avoid alignment
  147. UCHAR Flags2; // Problems.
  148. UCHAR BaseHi;
  149. } Bytes;
  150. struct {
  151. ULONG BaseMid : 8;
  152. ULONG Type : 5;
  153. ULONG Dpl : 2;
  154. ULONG Pres : 1;
  155. ULONG LimitHi : 4;
  156. ULONG Sys : 1;
  157. ULONG Reserved_0 : 1;
  158. ULONG Default_Big : 1;
  159. ULONG Granularity : 1;
  160. ULONG BaseHi : 8;
  161. } Bits;
  162. } HighWord;
  163. } VDMLDT_ENTRY;
  164. #endif // _X86_
  165. typedef VDMCONTEXT *LPVDMCONTEXT;
  166. typedef VDMLDT_ENTRY *LPVDMLDT_ENTRY;
  167. #define VDMCONTEXT_TO_PROGRAM_COUNTER(Context) (PVOID)((Context)->Eip)
  168. #define VDMCONTEXT_LENGTH (sizeof(VDMCONTEXT))
  169. #define VDMCONTEXT_ALIGN (sizeof(ULONG))
  170. #define VDMCONTEXT_ROUND (VDMCONTEXT_ALIGN - 1)
  171. #define V86FLAGS_CARRY 0x00001
  172. #define V86FLAGS_PARITY 0x00004
  173. #define V86FLAGS_AUXCARRY 0x00010
  174. #define V86FLAGS_ZERO 0x00040
  175. #define V86FLAGS_SIGN 0x00080
  176. #define V86FLAGS_TRACE 0x00100
  177. #define V86FLAGS_INTERRUPT 0x00200
  178. #define V86FLAGS_DIRECTION 0x00400
  179. #define V86FLAGS_OVERFLOW 0x00800
  180. #define V86FLAGS_IOPL 0x03000
  181. #define V86FLAGS_IOPL_BITS 0x12
  182. #define V86FLAGS_RESUME 0x10000
  183. #define V86FLAGS_V86 0x20000 // Used to detect RealMode v. ProtMode
  184. #define V86FLAGS_ALIGNMENT 0x40000
  185. #define MAX_MODULE_NAME 8 + 1
  186. #define MAX_PATH16 255
  187. typedef struct _SEGMENT_NOTE {
  188. WORD Selector1; // Selector of operation
  189. WORD Selector2; // Dest. Sel. for moving segments
  190. WORD Segment; // Segment within Module
  191. CHAR Module[MAX_MODULE_NAME+1]; // Module name
  192. CHAR FileName[MAX_PATH16+1]; // PathName to executable image
  193. WORD Type; // Code / Data, etc.
  194. DWORD Length; // Length of image
  195. } SEGMENT_NOTE;
  196. typedef struct _IMAGE_NOTE {
  197. CHAR Module[MAX_MODULE_NAME+1]; // Module
  198. CHAR FileName[MAX_PATH16+1]; // Path to executable image
  199. WORD hModule; // 16-bit hModule
  200. WORD hTask; // 16-bit hTask
  201. } IMAGE_NOTE;
  202. typedef struct {
  203. DWORD dwSize;
  204. char szModule[MAX_MODULE_NAME+1];
  205. HANDLE hModule;
  206. WORD wcUsage;
  207. char szExePath[MAX_PATH16+1];
  208. WORD wNext;
  209. } MODULEENTRY, *LPMODULEENTRY;
  210. /* GlobalFirst()/GlobalNext() flags */
  211. #define GLOBAL_ALL 0
  212. #define GLOBAL_LRU 1
  213. #define GLOBAL_FREE 2
  214. /* GLOBALENTRY.wType entries */
  215. #define GT_UNKNOWN 0
  216. #define GT_DGROUP 1
  217. #define GT_DATA 2
  218. #define GT_CODE 3
  219. #define GT_TASK 4
  220. #define GT_RESOURCE 5
  221. #define GT_MODULE 6
  222. #define GT_FREE 7
  223. #define GT_INTERNAL 8
  224. #define GT_SENTINEL 9
  225. #define GT_BURGERMASTER 10
  226. /* If GLOBALENTRY.wType==GT_RESOURCE, the following is GLOBALENTRY.wData: */
  227. #define GD_USERDEFINED 0
  228. #define GD_CURSORCOMPONENT 1
  229. #define GD_BITMAP 2
  230. #define GD_ICONCOMPONENT 3
  231. #define GD_MENU 4
  232. #define GD_DIALOG 5
  233. #define GD_STRING 6
  234. #define GD_FONTDIR 7
  235. #define GD_FONT 8
  236. #define GD_ACCELERATORS 9
  237. #define GD_RCDATA 10
  238. #define GD_ERRTABLE 11
  239. #define GD_CURSOR 12
  240. #define GD_ICON 14
  241. #define GD_NAMETABLE 15
  242. #define GD_MAX_RESOURCE 15
  243. typedef struct {
  244. DWORD dwSize;
  245. DWORD dwAddress;
  246. DWORD dwBlockSize;
  247. HANDLE hBlock;
  248. WORD wcLock;
  249. WORD wcPageLock;
  250. WORD wFlags;
  251. BOOL wHeapPresent;
  252. HANDLE hOwner;
  253. WORD wType;
  254. WORD wData;
  255. DWORD dwNext;
  256. DWORD dwNextAlt;
  257. } GLOBALENTRY, *LPGLOBALENTRY;
  258. typedef DWORD (CALLBACK* DEBUGEVENTPROC)( LPDEBUG_EVENT, LPVOID );
  259. // Macros to access VDM_EVENT parameters
  260. #define W1(x) ((USHORT)(x.ExceptionInformation[0]))
  261. #define W2(x) ((USHORT)(x.ExceptionInformation[0] >> 16))
  262. #define W3(x) ((USHORT)(x.ExceptionInformation[1]))
  263. #define W4(x) ((USHORT)(x.ExceptionInformation[1] >> 16))
  264. #define DW3(x) (x.ExceptionInformation[2])
  265. #define DW4(x) (x.ExceptionInformation[3])
  266. #pragma pack()
  267. BOOL
  268. WINAPI
  269. VDMProcessException(
  270. LPDEBUG_EVENT lpDebugEvent
  271. );
  272. BOOL
  273. WINAPI
  274. VDMGetThreadSelectorEntry(
  275. HANDLE hProcess,
  276. HANDLE hThread,
  277. WORD wSelector,
  278. LPVDMLDT_ENTRY lpSelectorEntry
  279. );
  280. ULONG
  281. WINAPI
  282. VDMGetPointer(
  283. HANDLE hProcess,
  284. HANDLE hThread,
  285. WORD wSelector,
  286. DWORD dwOffset,
  287. BOOL fProtMode
  288. );
  289. BOOL
  290. WINAPI
  291. VDMGetThreadContext(
  292. LPDEBUG_EVENT lpDebugEvent,
  293. LPVDMCONTEXT lpVDMContext
  294. );
  295. BOOL
  296. WINAPI
  297. VDMSetThreadContext(
  298. LPDEBUG_EVENT lpDebugEvent,
  299. LPVDMCONTEXT lpVDMContext
  300. );
  301. BOOL
  302. WINAPI
  303. VDMGetSelectorModule(
  304. HANDLE hProcess,
  305. HANDLE hThread,
  306. WORD wSelector,
  307. PUINT lpSegmentNumber,
  308. LPSTR lpModuleName,
  309. UINT nNameSize,
  310. LPSTR lpModulePath,
  311. UINT nPathSize
  312. );
  313. BOOL
  314. WINAPI
  315. VDMGetModuleSelector(
  316. HANDLE hProcess,
  317. HANDLE hThread,
  318. UINT wSegmentNumber,
  319. LPSTR lpModuleName,
  320. LPWORD lpSelector
  321. );
  322. BOOL
  323. WINAPI
  324. VDMModuleFirst(
  325. HANDLE hProcess,
  326. HANDLE hThread,
  327. LPMODULEENTRY lpModuleEntry,
  328. DEBUGEVENTPROC lpEventProc,
  329. LPVOID lpData
  330. );
  331. BOOL
  332. WINAPI
  333. VDMModuleNext(
  334. HANDLE hProcess,
  335. HANDLE hThread,
  336. LPMODULEENTRY lpModuleEntry,
  337. DEBUGEVENTPROC lpEventProc,
  338. LPVOID lpData
  339. );
  340. BOOL
  341. WINAPI
  342. VDMGlobalFirst(
  343. HANDLE hProcess,
  344. HANDLE hThread,
  345. LPGLOBALENTRY lpGlobalEntry,
  346. WORD wFlags,
  347. DEBUGEVENTPROC lpEventProc,
  348. LPVOID lpData
  349. );
  350. BOOL
  351. WINAPI
  352. VDMGlobalNext(
  353. HANDLE hProcess,
  354. HANDLE hThread,
  355. LPGLOBALENTRY lpGlobalEntry,
  356. WORD wFlags,
  357. DEBUGEVENTPROC lpEventProc,
  358. LPVOID lpData
  359. );
  360. typedef BOOL (WINAPI *PROCESSENUMPROC)( DWORD dwProcessId, DWORD dwAttributes, LPARAM lpUserDefined );
  361. typedef BOOL (WINAPI *TASKENUMPROC)( DWORD dwThreadId, WORD hMod16, WORD hTask16, LPARAM lpUserDefined );
  362. #define WOW_SYSTEM (DWORD)0x0001
  363. INT
  364. WINAPI
  365. VDMEnumProcessWOW(
  366. PROCESSENUMPROC fp,
  367. LPARAM lparam
  368. );
  369. INT
  370. WINAPI
  371. VDMEnumTaskWOW(
  372. DWORD dwProcessId,
  373. TASKENUMPROC fp,
  374. LPARAM lparam
  375. );
  376. BOOL
  377. WINAPI
  378. VDMKillWOW(
  379. VOID
  380. );
  381. BOOL
  382. WINAPI
  383. VDMDetectWOW(
  384. VOID
  385. );
  386. BOOL
  387. WINAPI
  388. VDMBreakThread(
  389. HANDLE hProcess,
  390. HANDLE hThread
  391. );
  392. #ifdef __cplusplus
  393. }
  394. #endif
  395. #endif // _VDMDBG_