1 | /* $Id: DisasmInternal.h 41796 2012-06-17 01:40:36Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox disassembler - Internal header.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2012 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef ___DisasmInternal_h___
|
---|
19 | #define ___DisasmInternal_h___
|
---|
20 |
|
---|
21 | #include <VBox/types.h>
|
---|
22 | #include <VBox/dis.h>
|
---|
23 |
|
---|
24 |
|
---|
25 | /** @defgroup grp_dis_int Internals.
|
---|
26 | * @ingroup grp_dis
|
---|
27 | * @{
|
---|
28 | */
|
---|
29 |
|
---|
30 | /** @name Index into g_apfnCalcSize and g_apfnFullDisasm.
|
---|
31 | * @{ */
|
---|
32 | #define IDX_ParseNop 0
|
---|
33 | #define IDX_ParseModRM 1
|
---|
34 | #define IDX_UseModRM 2
|
---|
35 | #define IDX_ParseImmByte 3
|
---|
36 | #define IDX_ParseImmBRel 4
|
---|
37 | #define IDX_ParseImmUshort 5
|
---|
38 | #define IDX_ParseImmV 6
|
---|
39 | #define IDX_ParseImmVRel 7
|
---|
40 | #define IDX_ParseImmAddr 8
|
---|
41 | #define IDX_ParseFixedReg 9
|
---|
42 | #define IDX_ParseImmUlong 10
|
---|
43 | #define IDX_ParseImmQword 11
|
---|
44 | #define IDX_ParseTwoByteEsc 12
|
---|
45 | #define IDX_ParseImmGrpl 13
|
---|
46 | #define IDX_ParseShiftGrp2 14
|
---|
47 | #define IDX_ParseGrp3 15
|
---|
48 | #define IDX_ParseGrp4 16
|
---|
49 | #define IDX_ParseGrp5 17
|
---|
50 | #define IDX_Parse3DNow 18
|
---|
51 | #define IDX_ParseGrp6 19
|
---|
52 | #define IDX_ParseGrp7 20
|
---|
53 | #define IDX_ParseGrp8 21
|
---|
54 | #define IDX_ParseGrp9 22
|
---|
55 | #define IDX_ParseGrp10 23
|
---|
56 | #define IDX_ParseGrp12 24
|
---|
57 | #define IDX_ParseGrp13 25
|
---|
58 | #define IDX_ParseGrp14 26
|
---|
59 | #define IDX_ParseGrp15 27
|
---|
60 | #define IDX_ParseGrp16 28
|
---|
61 | #define IDX_ParseModFence 29
|
---|
62 | #define IDX_ParseYv 30
|
---|
63 | #define IDX_ParseYb 31
|
---|
64 | #define IDX_ParseXv 32
|
---|
65 | #define IDX_ParseXb 33
|
---|
66 | #define IDX_ParseEscFP 34
|
---|
67 | #define IDX_ParseNopPause 35
|
---|
68 | #define IDX_ParseImmByteSX 36
|
---|
69 | #define IDX_ParseImmZ 37
|
---|
70 | #define IDX_ParseThreeByteEsc4 38
|
---|
71 | #define IDX_ParseThreeByteEsc5 39
|
---|
72 | #define IDX_ParseImmAddrF 40
|
---|
73 | #define IDX_ParseInvOpModRM 41
|
---|
74 | #define IDX_ParseMax (IDX_ParseInvOpModRM+1)
|
---|
75 | /** @} */
|
---|
76 |
|
---|
77 |
|
---|
78 | /** @name Opcode maps.
|
---|
79 | * @{ */
|
---|
80 | extern const DISOPCODE g_InvalidOpcode[1];
|
---|
81 |
|
---|
82 | extern const DISOPCODE g_aOneByteMapX86[256];
|
---|
83 | extern const DISOPCODE g_aOneByteMapX64[256];
|
---|
84 | extern const DISOPCODE g_aTwoByteMapX86[256];
|
---|
85 |
|
---|
86 | /** Two byte opcode map with prefix 0x66 */
|
---|
87 | extern const DISOPCODE g_aTwoByteMapX86_PF66[256];
|
---|
88 |
|
---|
89 | /** Two byte opcode map with prefix 0xF2 */
|
---|
90 | extern const DISOPCODE g_aTwoByteMapX86_PFF2[256];
|
---|
91 |
|
---|
92 | /** Two byte opcode map with prefix 0xF3 */
|
---|
93 | extern const DISOPCODE g_aTwoByteMapX86_PFF3[256];
|
---|
94 |
|
---|
95 | /** Three byte opcode map (0xF 0x38) */
|
---|
96 | extern PCDISOPCODE const g_apThreeByteMapX86_0F38[16];
|
---|
97 |
|
---|
98 | /** Three byte opcode map with prefix 0x66 (0xF 0x38) */
|
---|
99 | extern PCDISOPCODE const g_apThreeByteMapX86_660F38[16];
|
---|
100 |
|
---|
101 | /** Three byte opcode map with prefix 0xF2 (0xF 0x38) */
|
---|
102 | extern PCDISOPCODE const g_apThreeByteMapX86_F20F38[16];
|
---|
103 |
|
---|
104 | /** Three byte opcode map with prefix 0x66 (0xF 0x3A) */
|
---|
105 | extern PCDISOPCODE const g_apThreeByteMapX86_660F3A[16];
|
---|
106 | /** @} */
|
---|
107 |
|
---|
108 | /** @name Opcode extensions (Group tables)
|
---|
109 | * @{ */
|
---|
110 | extern const DISOPCODE g_aMapX86_Group1[8*4];
|
---|
111 | extern const DISOPCODE g_aMapX86_Group2[8*6];
|
---|
112 | extern const DISOPCODE g_aMapX86_Group3[8*2];
|
---|
113 | extern const DISOPCODE g_aMapX86_Group4[8];
|
---|
114 | extern const DISOPCODE g_aMapX86_Group5[8];
|
---|
115 | extern const DISOPCODE g_aMapX86_Group6[8];
|
---|
116 | extern const DISOPCODE g_aMapX86_Group7_mem[8];
|
---|
117 | extern const DISOPCODE g_aMapX86_Group7_mod11_rm000[8];
|
---|
118 | extern const DISOPCODE g_aMapX86_Group7_mod11_rm001[8];
|
---|
119 | extern const DISOPCODE g_aMapX86_Group8[8];
|
---|
120 | extern const DISOPCODE g_aMapX86_Group9[8];
|
---|
121 | extern const DISOPCODE g_aMapX86_Group10[8];
|
---|
122 | extern const DISOPCODE g_aMapX86_Group11[8*2];
|
---|
123 | extern const DISOPCODE g_aMapX86_Group12[8*2];
|
---|
124 | extern const DISOPCODE g_aMapX86_Group13[8*2];
|
---|
125 | extern const DISOPCODE g_aMapX86_Group14[8*2];
|
---|
126 | extern const DISOPCODE g_aMapX86_Group15_mem[8];
|
---|
127 | extern const DISOPCODE g_aMapX86_Group15_mod11_rm000[8];
|
---|
128 | extern const DISOPCODE g_aMapX86_Group16[8];
|
---|
129 | extern const DISOPCODE g_aMapX86_NopPause[2];
|
---|
130 | /** @} */
|
---|
131 |
|
---|
132 | /** 3DNow! map (0x0F 0x0F prefix) */
|
---|
133 | extern const DISOPCODE g_aTwoByteMapX86_3DNow[256];
|
---|
134 |
|
---|
135 | /** Floating point opcodes starting with escape byte 0xDF
|
---|
136 | * @{ */
|
---|
137 | extern const DISOPCODE g_aMapX86_EscF0_Low[8];
|
---|
138 | extern const DISOPCODE g_aMapX86_EscF0_High[16*4];
|
---|
139 | extern const DISOPCODE g_aMapX86_EscF1_Low[8];
|
---|
140 | extern const DISOPCODE g_aMapX86_EscF1_High[16*4];
|
---|
141 | extern const DISOPCODE g_aMapX86_EscF2_Low[8];
|
---|
142 | extern const DISOPCODE g_aMapX86_EscF2_High[16*4];
|
---|
143 | extern const DISOPCODE g_aMapX86_EscF3_Low[8];
|
---|
144 | extern const DISOPCODE g_aMapX86_EscF3_High[16*4];
|
---|
145 | extern const DISOPCODE g_aMapX86_EscF4_Low[8];
|
---|
146 | extern const DISOPCODE g_aMapX86_EscF4_High[16*4];
|
---|
147 | extern const DISOPCODE g_aMapX86_EscF5_Low[8];
|
---|
148 | extern const DISOPCODE g_aMapX86_EscF5_High[16*4];
|
---|
149 | extern const DISOPCODE g_aMapX86_EscF6_Low[8];
|
---|
150 | extern const DISOPCODE g_aMapX86_EscF6_High[16*4];
|
---|
151 | extern const DISOPCODE g_aMapX86_EscF7_Low[8];
|
---|
152 | extern const DISOPCODE g_aMapX86_EscF7_High[16*4];
|
---|
153 |
|
---|
154 | extern const PCDISOPCODE g_apMapX86_FP_Low[8];
|
---|
155 | extern const PCDISOPCODE g_apMapX86_FP_High[8];
|
---|
156 | /** @} */
|
---|
157 |
|
---|
158 | /** @def OP
|
---|
159 | * Wrapper which initializes an OPCODE.
|
---|
160 | * We must use this so that we can exclude unused fields in order
|
---|
161 | * to save precious bytes in the GC version.
|
---|
162 | *
|
---|
163 | * @internal
|
---|
164 | */
|
---|
165 | #ifndef DIS_CORE_ONLY
|
---|
166 | # define OP(pszOpcode, idxParse1, idxParse2, idxParse3, opcode, param1, param2, param3, optype) \
|
---|
167 | { pszOpcode, idxParse1, idxParse2, idxParse3, 0, opcode, param1, param2, param3, optype }
|
---|
168 | #else
|
---|
169 | # define OP(pszOpcode, idxParse1, idxParse2, idxParse3, opcode, param1, param2, param3, optype) \
|
---|
170 | { idxParse1, idxParse2, idxParse3, 0, opcode, param1, param2, param3, optype }
|
---|
171 | #endif
|
---|
172 |
|
---|
173 |
|
---|
174 | size_t disFormatBytes(PCDISSTATE pDis, char *pszDst, size_t cchDst, uint32_t fFlags);
|
---|
175 |
|
---|
176 | /** @} */
|
---|
177 | #endif
|
---|
178 |
|
---|