Annotation of mstools/h/vdmdbg.h, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.