Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

emulx86.h

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1992 Microsoft Corporation 00004 00005 Module Name: 00006 00007 emulx86.h 00008 00009 Abstract: 00010 00011 This is the private include file for the x86 emulated opcode component. 00012 Much of this file is a duplicate of .../ntos/vdm/i386/vdm.inc 00013 with some parts from i386.h 00014 00015 Author: 00016 00017 Charles Spirakis (intel) 1 Feb 1996 00018 00019 Revision History: 00020 00021 --*/ 00022 // 00023 // Prefix Flags 00024 // 00025 // Copied from .../ntos/vdm/i386/vdm.inc 00026 // The bottom byte originally corresponded to the number of prefixes seen 00027 // which is effectively the length of the instruction... 00028 // 00029 #if REALLY 00030 #define PREFIX_ES 0x00000100 00031 #define PREFIX_CS 0x00000200 00032 #define PREFIX_SS 0x00000400 00033 #define PREFIX_DS 0x00000800 00034 #define PREFIX_FS 0x00001000 00035 #define PREFIX_GS 0x00002000 00036 #define PREFIX_OPER32 0x00004000 00037 #define PREFIX_ADDR32 0x00008000 00038 #define PREFIX_LOCK 0x00010000 00039 #define PREFIX_REPNE 0x00020000 00040 #define PREFIX_REP 0x00040000 00041 #define PREFIX_SEG_ALL 0x00003f00 00042 00043 00044 // 00045 // Reginfo structure 00046 // 00047 // Similar to .../ntos/vdm/i386/vdm.inc 00048 // 00049 00050 typedef struct _REGINFO { 00051 ULONG RiSegSs; 00052 ULONG RiEsp; 00053 ULONG RiEFlags; 00054 ULONG RiSegCs; 00055 ULONG RiEip; 00056 PKIA32_FRAME RiTrapFrame; 00057 ULONG RiCsLimit; 00058 ULONG RiCsBase; 00059 ULONG RiSsLimit; 00060 ULONG RiSsBase; 00061 ULONG RiPrefixFlags; 00062 // ULONG RiOperand; // Not needed when convered to C code 00063 // 00064 // These are newly added fields 00065 // 00066 ULONG RiInstLength; 00067 PUCHAR RiLinearAddr; 00068 UCHAR RiOpcode; 00069 KXDESCRIPTOR RiCsDescriptor; 00070 KXDESCRIPTOR RiSsDescriptor; 00071 } REGINFO, *PREGINFO; 00072 00073 #define BOP_OPCODE 0xc4c4 00074 00075 #define DPMISTACK_EXCEPTION_OFFSET 0x1000 00076 00077 // 00078 // And the offset if we include the windows "undocumented feature" 00079 // 00080 #define DPMISTACK_OFFSET (DPMISTACK_EXCEPTION_OFFSET - 0x20) 00081 00082 #ifdef NEEDED 00083 00084 // 00085 // Common STYPE's that are checked 00086 // 00087 00088 #define STYPE_DATA 0x12 00089 #define STYPE_CODE 0x18 00090 #define STYPE_EXECWRITE_MASK 0x1a 00091 00092 // Because the descriptors are stored in registers and are stored 00093 // in an unscrambled format, Need to define shifts and masks 00094 // to make it easy to get to them 00095 00096 // base is 32 bits 00097 #define UNSCRAM_BASE_OFFSET 0 00098 #define UNSCRAM_BASE_MASK 0x0ffffffff 00099 #define UNSCRAM_GET_BASE(x) ((PUCHAR) ((x) & UNSCRAM_BASE_MASK)) 00100 00101 // limit is 20 bits 00102 #define UNSCRAM_LIMIT_OFFSET 32 00103 #define UNSCRAM_LIMIT_MASK 0x0fffff 00104 #define UNSCRAM_GET_LIMIT(x) (((x) >> UNSCRAM_LIMIT_OFFSET) & UNSCRAM_LIMIT_MASK) 00105 00106 // type (in the NT world) includes ths S bit, so 00107 // is really 5 bits 00108 #define UNSCRAM_STYPE_OFFSET 52 00109 #define UNSCRAM_STYPE_MASK 0x1f 00110 #define UNSCRAM_GET_STYPE(x) (((x) >> UNSCRAM_STYPE_OFFSET) & UNSCRAM_STYPE_MASK) 00111 00112 // dpl is 2 bits 00113 #define UNSCRAM_DPL_OFFSET 57 00114 #define UNSCRAM_DPL_MASK 0x3 00115 #define UNSCRAM_GET_DPL(x) (((x) >> UNSCRAM_DPL_OFFSET) & UNSCRAM_DPL_MASK) 00116 00117 // The Present bit is 1 bit 00118 #define UNSCRAM_PRESENT_OFFSET 59 00119 #define UNSCRAM_PRESENT_MASK 0x1 00120 #define UNSCRAM_GET_PRESENT(x) (((x) >> UNSCRAM_PRESENT_OFFSET) & UNSCRAM_PRESENT_MASK) 00121 00122 // The Big bit is 1 bit 00123 #define UNSCRAM_BIG_OFFSET 62 00124 #define UNSCRAM_BIG_MASK 0x1 00125 #define UNSCRAM_GET_BIG(x) (((x) >> UNSCRAM_BIG_OFFSET) & UNSCRAM_BIG_MASK) 00126 00127 // The Granularity is 1 bit 00128 #define UNSCRAM_GRAN_OFFSET 63 00129 #define UNSCRAM_GRAN_MASK 0x1 00130 #define UNSCRAM_GET_GRAN(x) (((x) >> UNSCRAM_GRAN_OFFSET) & UNSCRAM_GRAN_MASK) 00131 00132 // All of the flags fit into 12 bits 00133 #define UNSCRAM_FLAGS_OFFSET 52 00134 #define UNSCRAM_FLAGS_MASK 0xfff 00135 #define UNSCRAM_GET_FLAGS(x) (((x) >> UNSCRAM_FLAGS_OFFSET) & UNSCRAM_FLAGS_MASK) 00136 00137 #define UNSCRAM_EXPAND_IS_DOWN(x) ((((x) >> UNSCRAM_STYPE_OFFSET) & 0x1c) == 0x14) 00138 #define UNSCRAM_GRAN_IS_LARGE(x) ((x) & (UNSCRAM_GRAN_MASK << UNSCRAM_GRAN_OFFSET)) 00139 #define UNSCRAM_IS_PRESENT(x) ((x) & (UNSCRAM_PRESENT_MASK << UNSCRAM_PRESENT_OFFSET)) 00140 #define UNSCRAM_ACCESS_BIG(x) ((x) & (UNSCRAM_BIG_MASK << UNSCRAM_BIG_OFFSET)) 00141 00142 #endif // NEEDED 00143 00144 // From i386.h 00145 // 00146 // If kernel mode, then 00147 // let caller specify Carry, Parity, AuxCarry, Zero, Sign, Trap, 00148 // Direction, Overflow, Interrupt, AlignCheck. 00149 // 00150 // If user mode, then 00151 // let caller specify Carry, Parity, AuxCarry, Zero, Sign, Trap, 00152 // Direction, Overflow, AlignCheck. 00153 // force Interrupts on. 00154 // 00155 // Since there isn't any 386 code running in kernal mode, don't need 00156 // the full sanitize with mode, and change name to make sure we 00157 // don't accidentally use the original one (let the compiler catch the error) 00158 // 00159 00160 #define SANITIZE_FLAGS_IA32(eFlags) (\ 00161 ((((eFlags) & EFLAGS_V86_MASK) && KeIA32VdmIoplAllowed) ? \ 00162 (((eFlags) & KeIA32EFlagsAndMaskV86) | KeIA32EFlagsOrMaskV86) : \ 00163 ((EFLAGS_INTERRUPT_MASK) | ((eFlags) & EFLAGS_USER_SANITIZE))) 00164 00165 extern ULONG KeIA32EFlagsAndMaskV86; 00166 extern ULONG KeIA32EFlagsOrMaskV86; 00167 extern BOOLEAN KeIA32VdmIoplAllowed; 00168 extern ULONG KeIA32VirtualIntExtensions; 00169 00170 #define UNSCRAM_LIMIT_OFFSET 32 00171 #endif

Generated on Sat May 15 19:39:49 2004 for test by doxygen 1.3.7