home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 19.ddi / GENINC32.PAK / VDMDBG.H < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  11.9 KB  |  480 lines

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