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.

1071 lines
40 KiB

  1. An Explanation of VDMDBG.DLL
  2. BobDay - 10 Jun 93
  3. Section 1.0 - Overview
  4. Section 2.0 - The Simulated Environment
  5. Section 3.0 - The 32-bit Environment
  6. Section 4.0 - Communication Protocol via Exception
  7. Section 5.0 - The VDM Debugging APIs
  8. 1.0 Overview
  9. This document describes the mechanism used to support debugging DOS and
  10. WIN16 applications under Windows NT. The mechanism involves 2 parts
  11. in the simulated environment, one for v86 mode (or simulated real mode)
  12. and one for protected mode. It also involves 3 parts in the 32-bit NT
  13. environment, one for fielding information from the simulated enviroment
  14. and sending it to the debugger, one for code in the debugger, and one
  15. for code in a DLL used by the debugger.
  16. 16-bit simulated environment 32-bit environment
  17. NTIO.SYS DBG.LIB (in NTVDM.EXE)
  18. KRNL286.EXE NTSD (WinDbg or equivalent)
  19. VDMDBG.DLL
  20. 2.0 Simulated enviroment
  21. Once the simulated environment is up and running, if one of the normal
  22. debugging type events occurs it gets simulated to happen exactly the
  23. way it would on a normal PC. This means that if an INT 3 occurs, it
  24. pushes the flags, CS, IP, looks up the address in the IVT and then
  25. jumps to it. Same goes for INT 1's and INT D's (GP Faults). If the
  26. processor is in protected mode, these interrupts are normally trapped
  27. by the DOS extender (most of the time DOSX.EXE) and then reflected
  28. down into the real mode interrupts (except for GP Faults).
  29. In order to debug in the simulated enviroment, it is necessary to
  30. catch and process these events. The simplest way to do this is to
  31. install our own routines to watch these interrupts and that is
  32. what NTIO.SYS and KRNL286.EXE do. They are nothing but small
  33. stubs which insert themselves into the interrupt chains (NTIO.SYS
  34. inserts itself into the real mode interrupt chain, and KRNL286.EXE
  35. inserts itself into the protected mode interrupt chain). It is important
  36. to install oneself as early as possible so that other programs (such
  37. as DEBUG.COM) can install themselves ahead of these small stubs.
  38. In this way the events are only detected when they are not handled by some
  39. program in the simulated environment.
  40. Also, segment loading and unloading notifications are routed to
  41. these small stubs so that the debugger can be notified when selectors
  42. are associated with programs and their symbols.
  43. The small stubs will perform a BOP (a method of transitioning from
  44. the simulated environment back to the real 32-bit NT environment and
  45. notifying it that a debug event has occurred). After the BOP, they will
  46. either perform an IRET instruction to return control back to the simulated
  47. program generating the interrupt, or pass the interrupt down to the
  48. previous interrupt handler (continue down the chain). The decision
  49. whether to return from or pass the interrupt will be made on the basis
  50. of the ContinueDebugEvent continue status parameter. DBG_CONTINUE will
  51. IRET, DBG_EXCEPTION_NOT_HANDLE will pass it back down the chain.
  52. 3.0 32-bit environment
  53. Once the 32-bit environment has been notified that a debug event has
  54. occurred, it begins executing code in NTVDM (DBG.C) which parcels up the
  55. register context (based on the type of event which occurred) and
  56. communicates all the information to the debugger.
  57. Since the debugger is in another process's context, communication
  58. is done through exceptions. NTVDM will raise an exception with the
  59. status STATUS_VDM_EVENT. Exception information will be passed via the
  60. "lpArguments" parameter to the API RaiseException().
  61. The lpArguments parameter will cause an array of 4 DWORD values to
  62. be passed to the debugger. The values of the meanings of the array
  63. will be discussed in section 4.0
  64. The debugger should receive this exception and return from the call
  65. WaitForDebugEvent (debuggers should always have some thread waiting
  66. for debug events). By examining the events dwDebugEventCode member,
  67. the debugger can determine the type of the debug event. If this type
  68. is EXCEPTION_DEBUG_EVENT, then the
  69. u.Exception.ExceptionRecord.ExceptionCode
  70. member of the debug event structure will contain the exception type.
  71. If this value is STATUS_VDM_EVENT then the exception is coming from the
  72. 16-bit environment.
  73. When an exception of this type is detected, a debugger should load (if
  74. it hasn't done so already) the VDMDBG.DLL and determine the addresses
  75. of the key functions needed. The key functions are:
  76. VDMProcessException
  77. VDMGetThreadSelectorEntry
  78. VDMGetPointer
  79. VDMGetThreadContext
  80. VDMSetThreadContext
  81. VDMGetSelectorModule
  82. VDMGetModuleSelector
  83. VDMKillWOW
  84. VDMDetectWOW
  85. VDMBreakThread
  86. VDMModuleFirst
  87. VDMModuleNext
  88. VDMGlobalFirst
  89. VDMGlobalNext
  90. The prototypes and structures used by this DLL are prototyped in the header
  91. file VDMDBG.H. Section 5.0 explains each of these functions.
  92. Debuggers should not use these APIs to deal with the 16-bit environment:
  93. GetThreadSelectoryEntry
  94. GetThreadContext
  95. SetThreadContext
  96. The APIs ReadProcessMemory and WriteProcessMemory are still useful except
  97. that the debugger must convert the 16-bit addresses into 32-bit addresses
  98. (using VDMGetPointer).
  99. Each and every exception with the exception code of STATUS_VDM_EVENT
  100. should be passed to the function VDMProcessException. This function
  101. filters out the extraneous communication between the 16-bit environment
  102. and the VDMDBG.DLL. Most of this extraneous communication a debugger
  103. can ignore (deals with segment & module loading & unloading, this
  104. information will be provided via another interface). If the event is
  105. part of this communication process, VDMProcessException will return
  106. FALSE, if not, it will return TRUE.
  107. If the function VDMProcessException returns FALSE, the debugger can
  108. immediately call the API ContinueDebugEvent with a continue status of
  109. DBG_CONTINUE and return to waiting for additional debug events.
  110. If the function VDMProcessException returns TRUE, then the lpArguments
  111. parameter of the exception should be processed to determine the type of
  112. event (INT 1, INT 3, INT D, etc.). The debugger can then act accordingly.
  113. When it has completed operating with the thread, the debugger should
  114. call the API ContinueDebugEvent with a continue status of DBG_CONTINUE
  115. or DBG_EXCEPTION_NOT_HANDLED.
  116. For the processing of each of the debug events, the debugger should use
  117. the API VDMGetThreadSelectorEntry, VDMGetThreadContext, and
  118. VDMSetThreadContext instead of the likewise named functions listed above
  119. that are exported from KERNEL32.DLL. These functions operate on an x86
  120. CONTEXT structure, even when running on a non-x86 machine. The debugger
  121. should likewise present an x86 debugging view (x86 register dump, x86
  122. dis-assembly, breakpoints are INT 3's, etc.)
  123. 4.0 Communication Protocol via. Exceptions
  124. The method of communicating between the application and debugger
  125. will be exceptions. NTVDM will raise an exception and debugger should
  126. receive it. NTVDM can detect whether or not it is being debugged, and
  127. will conditionally raise the exception.
  128. If a debugger attaches itself to an existing NTVDM process, the
  129. 32-bit environment detects this and comminicates an acknowledgement
  130. of this attachment. This allows debuggers to perform initialization
  131. dealing with the 16-bit environment before beginning any new 16-bit tasks.
  132. For the simulated 16-bit environment, the exception code will always be
  133. STATUS_VDM_EVENT.
  134. On NT, each exception can only contain up to 4 DWORD values. Here is
  135. how they are used for this communication. The first 2 DWORDs contain
  136. 4 WORD fields. The last two DWORDs are just DWORDs.
  137. +---------+
  138. | W1 | W2 | = DW1
  139. +---------+
  140. | W3 | W4 | = DW2
  141. +---------+
  142. | DW3 |
  143. +---------+
  144. | DW4 |
  145. +---------+
  146. The header file VDMDBG.H contains macros for isolating the individual
  147. parts of the exception information.
  148. The W1 field is a WORD which specifies which type of event has occurred.
  149. This can be one of the following:
  150. W1 == 0 - Segment Load Notification (DBG_SEGLOAD)
  151. W1 == 1 - Segment Move Notification (DBG_SEGMOVE)
  152. W1 == 2 - Segment Free Notification (DBG_SEGFREE)
  153. W1 == 3 - Module Load Notification (DBG_MODLOAD)
  154. W1 == 4 - Module Free Notification (DBG_MODFREE)
  155. W1 == 5 - Int 01h break (DBG_SINGLESTEP)
  156. W1 == 6 - Int 03h break (DBG_BREAKPOINT)
  157. W1 == 7 - Int 0Dh break (GP Fault) (DBG_GPFAULT)
  158. W1 == 8 - Divide Overflow (DBG_DIVOVERFLOW)
  159. W1 == 9 - Invalid Opcode Fault (DBG_INSTRFAULT)
  160. W1 == 10 - Task starting (DBG_TASKSTART)
  161. W1 == 11 - Task stop (DBG_TASKSTOP)
  162. W1 == 12 - DLL starting (DBG_DLLSTART)
  163. W1 == 13 - DLL stop (DBG_DLLSTOP)
  164. They are described below.
  165. The debugger will probably need to be smart enough to know how to manage
  166. both protected mode selectors and segment numbers from simulated real mode.
  167. Segment/selector to symbol lookup should be mode sensitive and only use
  168. segments from the appropriate mode.
  169. 4.1 Segment Load Notification
  170. Under Win16, this event is used to indicate that a selector has just
  171. been created and that it maps to a module's segment.
  172. When a .EXE or .DLL is loaded, many of these events will be received.
  173. No module load notification event will occur (this is the way it is
  174. done under Windows 3.1 too).
  175. Under DOS, no segment load notifications will occur.
  176. W1 = DBG_SEGLOAD (0)
  177. W2 = Unused
  178. W3 = Unused
  179. W4 = Unused
  180. DW3 = Pointer to a SEGMENT_NOTE structure in NTVDM address space
  181. DW4 = Reserved
  182. SEGMENT_NOTE structure field definitions will be:
  183. Selector1 - Selector assigned to new segment
  184. Selector2 - Unused
  185. Segment - Segment within module
  186. Module - Null terminated module name
  187. FileName - Null terminated path to executable image
  188. Type - Code/data information from segment definition
  189. Length - Unused
  190. VDMProcessException will return FALSE for this event.
  191. 4.2 Segment Move Notification
  192. A segment has changed from one selector number to another. If the
  193. new selector number is 0, this should be considered the same as
  194. discarding (freeing) the segment.
  195. This event only happens under Win16. As such, these selectors should be
  196. tagged as protected mode only selectors.
  197. W1 = DBG_SEGMOVE (1)
  198. W2 = Unused
  199. W3 = Unused
  200. W4 = Unused
  201. DW3 = Pointer to a SEGMENT_NOTE structure in NTVDM address space
  202. DW4 = Reserved
  203. SEGMENT_NOTE structure field definitions will be:
  204. Selector1 - Old selector number
  205. Selector2 - New selector number (0 to discard segment)
  206. Segment - Unused
  207. Module - Unused
  208. FileName - Unused
  209. Type - Unused
  210. Length - Unused
  211. VDMProcessException will return FALSE for this event.
  212. 4.3 Segment Free Notification
  213. When a segment is being released, this event will be received.
  214. This event only happens under Win16.
  215. W1 = DBG_SEGFREE (2)
  216. W2 = Unused
  217. W3 = Unused
  218. W4 = Unused
  219. DW3 = Pointer to a SEGMENT_NOTE structure in NTVDM address space
  220. DW4 = Reserved
  221. SEGMENT_NOTE structure field definitions will be:
  222. Selector1 - Selector number
  223. Selector2 - Unused
  224. Segment - Unused
  225. Module - Unused
  226. FileName - Unused
  227. Type - Unused
  228. Length - Unused
  229. VDMProcessException will return FALSE for this event.
  230. 4.4 Module Load Notification
  231. This event is used to indicate that a module is going to take up a
  232. range of memory.
  233. This event is used only under DOS. As such, these segment numbers
  234. should be tagged as simulated real mode only selectors.
  235. W1 = DBG_MODLOAD (3)
  236. W2 = Unused
  237. W3 = Unused
  238. W4 = Unused
  239. DW3 = Pointer to a SEGMENT_NOTE structure in NTVDM address space
  240. DW4 = Reserved
  241. SEGMENT_NOTE structure field definitions will be:
  242. Selector1 - Unused
  243. Selector2 - Unused
  244. Segment - Starting segment
  245. Module - Null terminated module name
  246. FileName - Null terminated path to executable image
  247. Type - Unused
  248. Length - Length of module (in bytes)
  249. VDMProcessException will return FALSE for this event.
  250. 4.5 Module Free Notification
  251. Module freeing notifications happen under both DOS and Win16. For
  252. to determine which selectors to free for a Win16 application, all of the
  253. selectors must be scanned to determine if it was associated with this
  254. module. Again, this is the way it is done under Windows 3.1.
  255. W1 = DBG_MODFREE (4)
  256. W2 = Unused
  257. W3 = Unused
  258. W4 = Unused
  259. DW3 = Pointer to a SEGMENT_NOTE structure in NTVDM address space
  260. DW4 = Reserved
  261. SEGMENT_NOTE structure field definitions will be:
  262. Selector1 - Unused
  263. Selector2 - Unused
  264. Segment - Unused
  265. Module - Null terminated module name
  266. FileName - Null terminated path to executable image
  267. Type - Unused
  268. Length - Unused
  269. VDMProcessException will return FALSE for this event.
  270. 4.6 Int 01h break
  271. This event probably requires interaction with the debugger and its
  272. internal breakpoint, trace bit setting mechanisms.
  273. W1 = DBG_SINGLE_STEP (5)
  274. W2 = Unused
  275. W3 = Unused
  276. W4 = Unused
  277. DW3 = Unused
  278. DW4 = Reserved
  279. VDMProcessException will return TRUE for this event.
  280. 4.7 Int 03h break
  281. This event probably requires interaction with the debugger and its
  282. internal breakpoints.
  283. W1 = DBG_BREAKPOINT (6)
  284. W2 = Unused
  285. W3 = Unused
  286. W4 = Unused
  287. DW3 = Unused
  288. DW4 = Reserved
  289. VDMProcessException will return TRUE for this event.
  290. 4.8 Int 0Dh break (GP Fault)
  291. This event probably requires interaction with the debugger and its
  292. internal breakpoints.
  293. W1 = DBG_GPFAULT (7)
  294. W2 = Unused
  295. W3 = Unused
  296. W4 = Unused
  297. DW3 = Unused
  298. DW4 = Reserved
  299. It is also important to note that all GP Faults will not be sent via
  300. this interface. The Win16 subsystem intercepts some of the GP faults
  301. in its parameter validation code. Faults in the parameter validation
  302. code indicated that an invalid parameter is being passed to one of the
  303. 16-bit APIs. There is currently no way to intercept these faults, the
  304. APIs will just return errors in the same mechanism as under Windows 3.1.
  305. VDMProcessException will return TRUE for this event.
  306. 4.9 Divide Overflow break (Int 0)
  307. This event probably requires interaction with the debugger and its
  308. internal breakpoints.
  309. W1 = DBG_DIVOVERFLOW (8)
  310. W2 = Unused
  311. W3 = Unused
  312. W4 = Unused
  313. DW3 = Unused
  314. DW4 = Reserved
  315. VDMProcessException will return TRUE for this event.
  316. 4.A Invalid Opcode Fault (Int 6)
  317. W1 = DBG_INSTRFAULT (9)
  318. W2 = Unused
  319. W3 = Unused
  320. W4 = Unused
  321. DW3 = Unused
  322. DW4 = Reserved
  323. VDMProcessException will return TRUE for this event.
  324. 4.B Task starting
  325. After all of the image has been loaded for the application, but
  326. before executing the first instruction, this event will occur.
  327. W1 = DBG_TASKSTART (0Ah)
  328. W2 = Unused
  329. W3 = Unused
  330. W4 = Unused
  331. DW3 = Pointer to an IMAGE_NOTE structure in NTVDM address space
  332. DW4 = Reserved
  333. IMAGE_NOTE structure field definitions will be:
  334. Module - Null terminated module name
  335. FileName - Null terminated path to executable image
  336. VDMProcessException will return TRUE for this event.
  337. 4.C Task stopping
  338. After all of the image has been unloaded for the application
  339. this event will occur. None of the segments for the application
  340. will be valid. This is provided for the debugger to clean up any
  341. internal data it keeps on a per task basis.
  342. W1 = DBG_TASKSTOP (0Bh)
  343. W2 = Unused
  344. W3 = Unused
  345. W4 = Unused
  346. DW3 = Pointer to an IMAGE_NOTE structure in NTVDM address space
  347. DW4 = Reserved
  348. IMAGE_NOTE structure field definitions will be:
  349. Module - Null terminated module name
  350. FileName - Null terminated path to executable image
  351. VDMProcessException will return TRUE for this event.
  352. 4.D Dll starting
  353. After the image of the DLL has been loaded, but before the
  354. Dll's initialization code is executed, this event will occur.
  355. W1 = DBG_DLLSTART (0Ch)
  356. W2 = Unused
  357. W3 = Unused
  358. W4 = Unused
  359. DW3 = Pointer to an IMAGE_NOTE structure in NTVDM address space
  360. DW4 = Reserved
  361. IMAGE_NOTE structure field definitions will be:
  362. Module - Null terminated module name
  363. FileName - Null terminated path to executable image
  364. VDMProcessException will return TRUE for this event.
  365. 4.E Dll stopping
  366. After all of the image of the DLL has been unloaded for the Dll
  367. this event will occur. None of the segments for the Dll will be
  368. valid. This is provided for the debugger to clean up any internal
  369. data it keeps on a per Dll basis.
  370. W1 = DBG_DLLSTOP (0Ch)
  371. W2 = Unused
  372. W3 = Unused
  373. W4 = Unused
  374. DW3 = Pointer to an IMAGE_NOTE structure in NTVDM address space
  375. DW4 = Reserved
  376. IMAGE_NOTE structure field definitions will be:
  377. Module - Null terminated module name
  378. FileName - Null terminated path to executable image
  379. VDMProcessException will return TRUE for this event.
  380. 4.F Attach Acknowlegement
  381. Once the 16-bit environment has detected that a debugger is present
  382. it sends this event to allow the debugger to perform any initialization
  383. processing specific to the 16-bit environment.
  384. W1 = DBG_ATTACH (0Dh)
  385. W2 = Unused
  386. W3 = Unused
  387. W4 = Unused
  388. DW3 = Unused
  389. DW4 = Reserved
  390. VDMProcessException will return TRUE for this event.
  391. 5.0 The VDM debugging APIs
  392. These APIs are described below:
  393. VDMProcessException
  394. VDMGetThreadSelectorEntry
  395. VDMGetPointer
  396. VDMGetThreadContext
  397. VDMSetThreadContext
  398. VDMGetSelectorModule
  399. VDMGetModuleSelector
  400. VDMEnumProcessWOW
  401. VDMEnumTaskWOW
  402. The following APIs require WOWDEB.EXE to be loaded and running in the
  403. Win16 subsystem. WOWDEB.EXE is started automatically if the debugger
  404. is present at process creation time (CreateProcess with debug options
  405. set). If the debugger is attached to the Win16 subsystem process after
  406. the process has already been created (with the DebugActiveProcess API),
  407. then the debugger should spawn WOWDEB.EXE before starting the Win16 task
  408. to be debugged.
  409. VDMModuleFirst
  410. VDMModuleNext
  411. VDMGlobalFirst
  412. VDMGlobalNext
  413. This following APIs are obsolete. They return failure conditions.
  414. VDMKillWOW
  415. VDMDetectWOW
  416. VDMBreakThread
  417. 5.1 VDMProcessException
  418. BOOL VDMProcessException(
  419. LPDEBUG_EVENT lpDebugEvent
  420. );
  421. The VDMProcessExecption function performs the pre-processing needed to
  422. prepare the debug event for handling by the debugger.
  423. This function filters all VDM debugee/debugger communication for
  424. information which is only used by the VDM debugging DLL (VDMDBG.DLL).
  425. This function is only valid in the context of processing for debug
  426. events that are of type STATUS_VDM_EVENT.
  427. lpDebugEvent Points to a DEBUG_EVENT structure that was returned
  428. from WaitForDebugEvent.
  429. The return value is TRUE if the debug event should be processed by the
  430. debugger.
  431. The return value is FALSE if the debug event should be ignored. This
  432. This indicates that no processing should occur for this debug event.
  433. The event should be continued using ContinueDebugEvent with a continue
  434. status of DBG_CONTINUE.
  435. 5.2 VDMGetThreadSelectorEntry
  436. BOOL VDMGetThreadSelectorEntry(
  437. HANDLE hProcess,
  438. HANDLE hThread,
  439. WORD wSelector
  440. LPLDT_ENTRY lpSelectorEntry
  441. );
  442. This function is used to return a descriptor table entry for the
  443. specified VDM thread corresponding to the specified selector. This
  444. function is simimlar to the API GetThreadSelectorEntry except that
  445. it works on the simulated DOS/WIN16 environment, and it works on all
  446. systems, not just x86 systems.
  447. This API returns a simulated descriptor entry on non-x86 systems.
  448. Simulated descriptor entrys may (on some systems) have the base value
  449. adjusted to account for the fact that the simulated address space may
  450. not begin at linear (32-bit) address 0.
  451. It is also important to note that 16-bit applications may modify
  452. the contents of the LDT entries. For example, the Win16 subsystem
  453. may change the selector's base value to coalesce discontinous memory
  454. segments. Also, please see the description in VDMGetPointer.
  455. hProcess Supplies a handle to the DOS/WIN16 sub-system process.
  456. The handle must have been created with PROCESS_VM_READ
  457. access.
  458. hThread Supplies a handle to the thread that contains the
  459. specified selector. The handle must have been created
  460. with THREAD_QUERY_INFORMATION access.
  461. wSelector Supplies the selector value to look up. The selector
  462. value may be a global selector (GDT) or a local selector
  463. (LDT).
  464. lpSelectorEntry If the specifed selector is contained within the
  465. thread's descriptor tables, its descriptor table entry
  466. is copied into the data structure pointed to by this
  467. parameter. This data can be used to compute the linear
  468. base address that segment relative addresses refer to.
  469. The return value is TRUE if the operation was successful. In that case,
  470. the data structure pointed to by lpSelectorEntry receives a copy of the
  471. specified descriptor table entry.
  472. Refer to the WinHelp entry for the structure of an LDT_ENTRY.
  473. 5.3 VDMGetPointer
  474. ULONG VDMGetPointer(
  475. HANDLE hProcess,
  476. HANDLE hThread,
  477. WORD wSelector,
  478. DWORD dwOffset,
  479. BOOL fProtMode
  480. );
  481. This function is used to convert a 16-bit address into a flat 32-bit
  482. address.
  483. It is also very important to note that under the WIN16 environment,
  484. pointers derived from protected mode selectors may change. WIN16 does
  485. this by changing selector's base value to coalesce memory during
  486. compaction. For this reason, it is necessary that any addresses
  487. evaluated in the 16-bit environment should be reevaluated each time
  488. an access into 16-bit memory is needed. An example would be
  489. placing and removing 16-bit breakpoint instructions. If the debugger
  490. is told to place a breakpoint at a given address of SEL:OFFSET, then
  491. when the breakpoint is needs to be removed, the debugger must reevaluate
  492. the SEL:OFFSET address since it might have moved in terms of the linear
  493. 32-bit address.
  494. hProcess Supplies a handle to the DOS/WIN16 sub-system process.
  495. The handle must have been created with PROCESS_VM_READ
  496. access.
  497. hThread Supplies a handle to the thread that contains the
  498. specified selector. The handle must have been created
  499. with THREAD_QUERY_INFORMATION access.
  500. wSelector Supplies the selector value to determine the pointer for.
  501. dwOffset Supplies the offset value to determine the pointer for.
  502. fProtMode Indicates whether the 16-bit address specified is a
  503. real mode (v86 mode) address or a protected mode address.
  504. Protected mode addresses are translated through the
  505. descriptor tables.
  506. The return value is a 32-bit linear address pointing to the memory
  507. in the simulated DOS/WIN16 environment that represents the 16-bit address
  508. specified. The return value is NULL, if the address specified is invalid.
  509. On some systems, NULL may be returned for the address 0:0.
  510. To determine the address of the simulated 16-bit memory, VDMGetPointer
  511. may be called with the address 0:0 and an fProtMode of FALSE.
  512. 5.4 VDMGetThreadContext
  513. BOOL VDMGetThreadContext(
  514. LPDEBUG_EVENT lpDebugEvent,
  515. LPVDMCONTEXT lpVDMContext
  516. );
  517. The context of a specified simulated DOS or WIN16 thread can be
  518. retrieved using VDMGetThreadContext. The context returned will
  519. always be that of an x86 system.
  520. This API returns a simulated context for x86 and non-x86 systems.
  521. Under some systems, values within the context are meaningless. For
  522. example, the CONTEXT_DEBUG_REGISTERS portions on RISC systems have
  523. no effect.
  524. Release 1 of Windows NT has a 286 emulator on RISC systems. For this
  525. reason, only the 16-bit registers can be supported on RISC systems.
  526. lpDebugEvent Points to a DEBUG_EVENT structure that was returned
  527. from WaitForDebugEvent.
  528. lpVDMContext If the specified thread is a simulated DOS or WIN16
  529. thread, its context is copied into the data structure
  530. pointed to by this parameter.
  531. The return value is TRUE if the operation was successful. In that case,
  532. the data structure pointed to by <lpVDMContext> receives a copy of the
  533. simulated context.
  534. Refer to the WinHelp for the structure of a VDMCONTEXT (same as x86
  535. CONTEXT structure in NTI386.H).
  536. 5.5 VDMSetThreadContext
  537. BOOL VDMSetThreadContext(
  538. LPDEBUG_EVENT lpDebugEvent,
  539. LPVDMCONTEXT lpVDMContext
  540. );
  541. The VDMSetThreadContext function sets the simulated context in the
  542. specified DOS or WIN16 thread. The function allows selective context
  543. to be set based on the value of the ContextFlags member of the context
  544. structure. This API operates only when debugging a simulated DOS or
  545. WIN16 thread. The caller must have a thread handle which was created
  546. with THREAD_SET_CONTEXT access.
  547. The context set will always be that of an x86 system.
  548. lpDebugEvent Points to a DEBUG_EVENT structure that was returned
  549. from WaitForDebugEvent.
  550. lpVDMContext Supplies the address of a context structure that
  551. contains the context that is to be set in the specified
  552. thread. The value of the ContextFlags member of this
  553. structure specifies which portions of a thread's context
  554. are to be set. Some values in the context structure are
  555. not settable and are silently set to the correct values.
  556. This include CPU status register bits that specify
  557. processor mode, debug register global enabling bits, and
  558. other state that must be completely controlled by the
  559. system.
  560. The return value is TRUE if the context was set; otherwise it is FALSE if
  561. an error occurred.
  562. Refer to the WinHelp for the structure of a VDMCONTEXT (same as x86
  563. CONTEXT structure in NTI386.H).
  564. 5.6 VDMGetSelectorModule
  565. BOOL VDMGetSelectorModule(
  566. HANDLE hProcess,
  567. HANDLE hThread,
  568. WORD wSelector,
  569. PUINT lpSegmentNumber,
  570. LPSTR lpModuleName,
  571. UINT nSize,
  572. LPSTR lpModulePath,
  573. UINT nPathSize
  574. );
  575. The VDMGetSelectorModule function is intended to provide an interface
  576. such that debuggers can determine which module belongs to a code or
  577. data address. Given the selector for that address, the function will
  578. return the module name, and the segment number (0 based) of the segment
  579. that corresponds to that selector. If the selector is not a selector
  580. which directly corresponds to a module, the function will return FALSE.
  581. hProcess Supplies a handle to the process of the 16-bit environment
  582. hThread Supplies a handle to a thread in the 16-bit environment
  583. wSelector Supplies the selector value to look up.
  584. lpSegmentNumber Returns the segment number within the module.
  585. lpModuleName Buffer to receive the module name.
  586. nModuleSize Size of the buffer.
  587. lpModulePath Buffer to receive the module path name.
  588. nPathSize Size of the buffer.
  589. The return value is TRUE if the selector is mapped directly to a module.
  590. This means it must be either a code or data segment. Selectors allocated
  591. using the global memory management functions are not mapped directly to
  592. a module. The return value is FALSE if the function is not successful.
  593. The function returns the segment number in the address specified by
  594. the lpSegmentNumber parameter, and the module name in the address
  595. specified by the lpModuleName parameter.
  596. It is up to the debugger to determine from the module and segment number
  597. information the correct symbol, if a symbol lookup is needed.
  598. 5.7 VDMGetModuleSelector
  599. BOOL VDMGetModuleSelector(
  600. HANDLE hProcess,
  601. HANDLE hThread,
  602. UINT uSegmentNumber,
  603. LPSTR lpModuleName,
  604. LPWORD lpSelector
  605. );
  606. The VDMGetModuleSelector function is the reverse operation of the
  607. VDMGetSelectorModule function. A module name and segment number
  608. are converted into a selector number.
  609. hProcess Supplies a handle to the process of the 16-bit environment
  610. hThread Supplies a handle to a thread in the 16-bit environment
  611. uSegmentNumber Supplies the segment number to look up.
  612. lpModuleName Specifies the module name of the segment.
  613. lpSelector Returns the selector value.
  614. The return value is TRUE if the module and segment are found. Also,
  615. the lpSelector value is filled-in with the selector of that segment.
  616. Otherwise, the return value is FALSE.
  617. It is up to the debugger to convert symbol names and expressions into
  618. modules, segment numbers and offsets. Usings the modules and segment
  619. numbers, a selector value can be determined. In combination with the
  620. offset, the selector can be used to index into the simulated Win16
  621. environment for reading, writing, etc.
  622. 5.8 VDMEnumProcessWOW
  623. INT VDMEnumProcessWOW(
  624. PROCESSENUMPROC fp,
  625. LPARAM lparam
  626. );
  627. The VDMEnumProcessWOW function enumerates all of the processes in
  628. the system which are Win16 subsystem processes. In NT's first release,
  629. there is only one Win16 subsystem. For later releases, there may be
  630. more than one process to support address space seperation for Win16
  631. tasks.
  632. fp Supplies the address of a callback routine.
  633. lparam Supplies a parameter to the callback routine.
  634. The return value is the number of Win16 subsystem processes, or the
  635. number enumerated before enumeration was terminated.
  636. BOOL ProcessEnumProc(
  637. DWORD dwProcessId,
  638. DWORD dwAttributes,
  639. LPARAM lparam
  640. );
  641. The callback function will be called once for each Win16 subsystem process
  642. in the system.
  643. dwProcessId Provides the process id of a Win16 subsystem.
  644. dwAttributes Provides flags indicating information about the process.
  645. lparam Provides the parameter passed to VDMEnumProcessWOW
  646. The callback function should return a non-zero value to terminate
  647. enumeration.
  648. The dwAttributes field should be compared with the bit mask WOW_SYSTEM
  649. to determine if the process is the main Win16 subsystem process. The
  650. main Win16 subsystem process will be the process that the next Win16
  651. task that specifies no address space seperation requirements.
  652. Win16 subsystem processes which are created due to address space
  653. seperation will not have the WOW_SYSTEM bit enabled.
  654. 5.9 VDMEnumTaskWOW
  655. INT
  656. VDMEnumTaskWOW(
  657. DWORD dwProcessId,
  658. TASKENUMPROC fp,
  659. LPARAM lparam
  660. );
  661. The VDMEnumTaskWOW function enumerates all of the Win16 tasks currently
  662. running in the Win16 subsystem process id specified.
  663. dwProcessId Supplies the process id of the Win16 subsystem.
  664. fp Supplies the address of a callback routine.
  665. lparam Supplies a parameter to the callback routine.
  666. The return value is the number of Win16 tasks or the number of
  667. tasks enumerated before terminating.
  668. BOOL TaskEnumProc(
  669. DWORD dwThreadId,
  670. WORD hMod16,
  671. WORD hTask16,
  672. LPARAM lparam
  673. );
  674. The callback function will be called once for each Win16 task.
  675. dwThreadId Provides the thread id of the Win16 task
  676. hMod16 Provides the Win16 module handle for the task
  677. hTask16 Provides the Win16 task handle for the task
  678. lparam Provides the parameter passed to VDMEnumTaskWOW
  679. The callback function should return a non-zero value to terminate
  680. enumeration.
  681. 5.A VDMModuleFirst
  682. BOOL VDMModuleFirst(
  683. HANDLE hProcess,
  684. HANDLE hThread,
  685. LPMODULEENTRY lpModuleEntry,
  686. DEBUGEVENTPROC lpEventProc,
  687. LPVOID lpData
  688. );
  689. This function is used to start enumerating all of the modules currently
  690. loaded in the 16-bit Windows environment. It behaves in the same manner
  691. as the Windows 3.1 ToolHelp API ModuleFirst().
  692. hProcess Supplies a handle to the process of the 16-bit environment
  693. hThread Supplies a handle to a thread in the 16-bit environment
  694. lpModuleEntry Specifies the address of a MODULEENTRY structure which
  695. will be filled in with the first module in the module
  696. list.
  697. lpEventProc Specifies the address of a procedure which might be
  698. called in the event of a debug event occuring while
  699. the communication session with the 16-bit enviroment
  700. is occurring.
  701. lpData Specifies a parameter to pass to the debug event procudure
  702. The return value is TRUE if the operation was successful. In that case,
  703. the MODULEENTRY structure will be filled in with information for the
  704. first module in the module list.
  705. 5.B VDMModuleNext
  706. BOOL VDMModuleNext(
  707. HANDLE hProcess,
  708. HANDLE hThread,
  709. LPMODULEENTRY lpModuleEntry,
  710. DEBUGEVENTPROC lpEventProc,
  711. LPVOID lpData
  712. );
  713. This function is used to continue enumerating all of the modules currently
  714. loaded in the 16-bit Windows environment. It behaves in the same manner
  715. as the Windows 3.1 ToolHelp API ModuleNext().
  716. hProcess Supplies a handle to the process of the 16-bit environment
  717. hThread Supplies a handle to a thread in the 16-bit environment
  718. lpModuleEntry Specifies the address of a MODULEENTRY structure which
  719. will be used to determine the next module and which will
  720. be filled in with the next module in the module list.
  721. lpEventProc Specifies the address of a procedure which might be
  722. called in the event of a debug event occuring while
  723. the communication session with the 16-bit enviroment
  724. is occurring.
  725. lpData Specifies a parameter to pass to the debug event procudure
  726. The return value is TRUE if the operation was successful. In that case,
  727. the MODULEENTRY structure will be filled in with information for the
  728. next module in the module list.
  729. 5.C VDMGlobalFirst
  730. BOOL VDMGlobalFirst(
  731. HANDLE hProcess,
  732. HANDLE hThread,
  733. LPGLOBALENTRY lpGlobalEntry,
  734. WORD wFlags,
  735. DEBUGEVENTPROC lpEventProc,
  736. LPVOID lpData
  737. );
  738. This function is used to continue enumerating all of the global memory
  739. blocks currently allocated in the 16-bit Windows environment. It
  740. behaves in the same manner as the Windows 3.1 ToolHelp API GlobalFirst().
  741. hProcess Supplies a handle to the process of the 16-bit environment
  742. hThread Supplies a handle to a thread in the 16-bit environment
  743. lpModuleEntry Specifies the address of a GLOBALENTRY structure which
  744. will be filled in with information for the first global
  745. memory block matching the specified flags
  746. wFlags Specifies which types of global memory blocks to enumerate
  747. lpEventProc Specifies the address of a procedure which might be
  748. called in the event of a debug event occuring while
  749. the communication session with the 16-bit enviroment
  750. is occurring.
  751. lpData Specifies a parameter to pass to the debug event procudure
  752. The return value is TRUE if the operation was successful. In that case,
  753. the GLOBALENTRY structure will be filled in with information for the
  754. first global memory block that matches the specified flags.
  755. 5.D VDMGlobalNext
  756. BOOL VDMGlobalNext(
  757. HANDLE hProcess,
  758. HANDLE hThread,
  759. LPGLOBALENTRY lpGlobalEntry,
  760. WORD wFlags,
  761. DEBUGEVENTPROC lpEventProc,
  762. LPVOID lpData
  763. );
  764. This function is used to continue enumerating all of the global memory
  765. blocks currently allocated in the 16-bit Windows environment. It behaves
  766. in the same manner as the Windows 3.1 ToolHelp API GlobalNext().
  767. hProcess Supplies a handle to the process of the 16-bit environment
  768. hThread Supplies a handle to a thread in the 16-bit environment
  769. lpModuleEntry Specifies the address of a GLOBALENTRY structure which
  770. will be used to determine the next global memory block
  771. and which will be filled in with information for the
  772. next global memory block matching the specified flags
  773. wFlags Specifies which types of global memory blocks to enumerate
  774. lpEventProc Specifies the address of a procedure which might be
  775. called in the event of a debug event occuring while
  776. the communication session with the 16-bit enviroment
  777. is occurring.
  778. lpData Specifies a parameter to pass to the debug event procudure
  779. The return value is TRUE if the operation was successful. In that case,
  780. the GLOBALENTRY structure will be filled in with information for the
  781. next global memory block that matches the specified flags.
  782. 5.E VDMKillWOW
  783. BOOL VDMKillWOW(void);
  784. This function is obsolete and performs no operation. It returns FALSE.
  785. 5.F VDMDetectWOW
  786. BOOL VDMDetectWOW(void);
  787. This function is obsolete and performs no operation. It returns FALSE.
  788. 5.G VDMBreakThread
  789. BOOL VDMBreakThread(
  790. HANDLE hProcess
  791. HANDLE hThread
  792. );
  793. This function is obsolete and performs no operation. It returns FALSE.