1 | /* $Id: DisasmInternal.h 53032 2014-10-10 16:18:37Z 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 | enum IDX_Parse
|
---|
33 | {
|
---|
34 | IDX_ParseNop = 0,
|
---|
35 | IDX_ParseModRM,
|
---|
36 | IDX_UseModRM,
|
---|
37 | IDX_ParseImmByte,
|
---|
38 | IDX_ParseImmBRel,
|
---|
39 | IDX_ParseImmUshort,
|
---|
40 | IDX_ParseImmV,
|
---|
41 | IDX_ParseImmVRel,
|
---|
42 | IDX_ParseImmAddr,
|
---|
43 | IDX_ParseFixedReg,
|
---|
44 | IDX_ParseImmUlong,
|
---|
45 | IDX_ParseImmQword,
|
---|
46 | IDX_ParseTwoByteEsc,
|
---|
47 | IDX_ParseImmGrpl,
|
---|
48 | IDX_ParseShiftGrp2,
|
---|
49 | IDX_ParseGrp3,
|
---|
50 | IDX_ParseGrp4,
|
---|
51 | IDX_ParseGrp5,
|
---|
52 | IDX_Parse3DNow,
|
---|
53 | IDX_ParseGrp6,
|
---|
54 | IDX_ParseGrp7,
|
---|
55 | IDX_ParseGrp8,
|
---|
56 | IDX_ParseGrp9,
|
---|
57 | IDX_ParseGrp10,
|
---|
58 | IDX_ParseGrp12,
|
---|
59 | IDX_ParseGrp13,
|
---|
60 | IDX_ParseGrp14,
|
---|
61 | IDX_ParseGrp15,
|
---|
62 | IDX_ParseGrp16,
|
---|
63 | IDX_ParseModFence,
|
---|
64 | IDX_ParseYv,
|
---|
65 | IDX_ParseYb,
|
---|
66 | IDX_ParseXv,
|
---|
67 | IDX_ParseXb,
|
---|
68 | IDX_ParseEscFP,
|
---|
69 | IDX_ParseNopPause,
|
---|
70 | IDX_ParseImmByteSX,
|
---|
71 | IDX_ParseImmZ,
|
---|
72 | IDX_ParseThreeByteEsc4,
|
---|
73 | IDX_ParseThreeByteEsc5,
|
---|
74 | IDX_ParseImmAddrF,
|
---|
75 | IDX_ParseInvOpModRM,
|
---|
76 | IDX_ParseMax
|
---|
77 | };
|
---|
78 | /** @} */
|
---|
79 |
|
---|
80 |
|
---|
81 | /** @name Opcode maps.
|
---|
82 | * @{ */
|
---|
83 | extern const DISOPCODE g_InvalidOpcode[1];
|
---|
84 |
|
---|
85 | extern const DISOPCODE g_aOneByteMapX86[256];
|
---|
86 | extern const DISOPCODE g_aOneByteMapX64[256];
|
---|
87 | extern const DISOPCODE g_aTwoByteMapX86[256];
|
---|
88 |
|
---|
89 | /** Two byte opcode map with prefix 0x66 */
|
---|
90 | extern const DISOPCODE g_aTwoByteMapX86_PF66[256];
|
---|
91 |
|
---|
92 | /** Two byte opcode map with prefix 0xF2 */
|
---|
93 | extern const DISOPCODE g_aTwoByteMapX86_PFF2[256];
|
---|
94 |
|
---|
95 | /** Two byte opcode map with prefix 0xF3 */
|
---|
96 | extern const DISOPCODE g_aTwoByteMapX86_PFF3[256];
|
---|
97 |
|
---|
98 | /** Three byte opcode map (0xF 0x38) */
|
---|
99 | extern PCDISOPCODE const g_apThreeByteMapX86_0F38[16];
|
---|
100 |
|
---|
101 | /** Three byte opcode map with prefix 0x66 (0xF 0x38) */
|
---|
102 | extern PCDISOPCODE const g_apThreeByteMapX86_660F38[16];
|
---|
103 |
|
---|
104 | /** Three byte opcode map with prefix 0xF2 (0xF 0x38) */
|
---|
105 | extern PCDISOPCODE const g_apThreeByteMapX86_F20F38[16];
|
---|
106 |
|
---|
107 | /** Three byte opcode map with prefix 0xF3 (0xF 0x38) */
|
---|
108 | extern PCDISOPCODE const g_apThreeByteMapX86_F30F38[16];
|
---|
109 |
|
---|
110 | /** Three byte opcode map with prefix 0x66 (0xF 0x3A) */
|
---|
111 | extern PCDISOPCODE const g_apThreeByteMapX86_660F3A[16];
|
---|
112 |
|
---|
113 | /** Three byte opcode map with prefixes 0x66 0xF2 (0xF 0x38) */
|
---|
114 | extern PCDISOPCODE const g_apThreeByteMapX86_66F20F38[16];
|
---|
115 | /** @} */
|
---|
116 |
|
---|
117 | /** @name Opcode extensions (Group tables)
|
---|
118 | * @{ */
|
---|
119 | extern const DISOPCODE g_aMapX86_Group1[8*4];
|
---|
120 | extern const DISOPCODE g_aMapX86_Group2[8*6];
|
---|
121 | extern const DISOPCODE g_aMapX86_Group3[8*2];
|
---|
122 | extern const DISOPCODE g_aMapX86_Group4[8];
|
---|
123 | extern const DISOPCODE g_aMapX86_Group5[8];
|
---|
124 | extern const DISOPCODE g_aMapX86_Group6[8];
|
---|
125 | extern const DISOPCODE g_aMapX86_Group7_mem[8];
|
---|
126 | extern const DISOPCODE g_aMapX86_Group7_mod11_rm000[8];
|
---|
127 | extern const DISOPCODE g_aMapX86_Group7_mod11_rm001[8];
|
---|
128 | extern const DISOPCODE g_aMapX86_Group8[8];
|
---|
129 | extern const DISOPCODE g_aMapX86_Group9[8];
|
---|
130 | extern const DISOPCODE g_aMapX86_Group10[8];
|
---|
131 | extern const DISOPCODE g_aMapX86_Group11[8*2];
|
---|
132 | extern const DISOPCODE g_aMapX86_Group12[8*2];
|
---|
133 | extern const DISOPCODE g_aMapX86_Group13[8*2];
|
---|
134 | extern const DISOPCODE g_aMapX86_Group14[8*2];
|
---|
135 | extern const DISOPCODE g_aMapX86_Group15_mem[8];
|
---|
136 | extern const DISOPCODE g_aMapX86_Group15_mod11_rm000[8];
|
---|
137 | extern const DISOPCODE g_aMapX86_Group16[8];
|
---|
138 | extern const DISOPCODE g_aMapX86_NopPause[2];
|
---|
139 | /** @} */
|
---|
140 |
|
---|
141 | /** 3DNow! map (0x0F 0x0F prefix) */
|
---|
142 | extern const DISOPCODE g_aTwoByteMapX86_3DNow[256];
|
---|
143 |
|
---|
144 | /** Floating point opcodes starting with escape byte 0xDF
|
---|
145 | * @{ */
|
---|
146 | extern const DISOPCODE g_aMapX86_EscF0_Low[8];
|
---|
147 | extern const DISOPCODE g_aMapX86_EscF0_High[16*4];
|
---|
148 | extern const DISOPCODE g_aMapX86_EscF1_Low[8];
|
---|
149 | extern const DISOPCODE g_aMapX86_EscF1_High[16*4];
|
---|
150 | extern const DISOPCODE g_aMapX86_EscF2_Low[8];
|
---|
151 | extern const DISOPCODE g_aMapX86_EscF2_High[16*4];
|
---|
152 | extern const DISOPCODE g_aMapX86_EscF3_Low[8];
|
---|
153 | extern const DISOPCODE g_aMapX86_EscF3_High[16*4];
|
---|
154 | extern const DISOPCODE g_aMapX86_EscF4_Low[8];
|
---|
155 | extern const DISOPCODE g_aMapX86_EscF4_High[16*4];
|
---|
156 | extern const DISOPCODE g_aMapX86_EscF5_Low[8];
|
---|
157 | extern const DISOPCODE g_aMapX86_EscF5_High[16*4];
|
---|
158 | extern const DISOPCODE g_aMapX86_EscF6_Low[8];
|
---|
159 | extern const DISOPCODE g_aMapX86_EscF6_High[16*4];
|
---|
160 | extern const DISOPCODE g_aMapX86_EscF7_Low[8];
|
---|
161 | extern const DISOPCODE g_aMapX86_EscF7_High[16*4];
|
---|
162 |
|
---|
163 | extern const PCDISOPCODE g_apMapX86_FP_Low[8];
|
---|
164 | extern const PCDISOPCODE g_apMapX86_FP_High[8];
|
---|
165 | /** @} */
|
---|
166 |
|
---|
167 | /** @def OP
|
---|
168 | * Wrapper which initializes an OPCODE.
|
---|
169 | * We must use this so that we can exclude unused fields in order
|
---|
170 | * to save precious bytes in the GC version.
|
---|
171 | *
|
---|
172 | * @internal
|
---|
173 | */
|
---|
174 | #ifndef DIS_CORE_ONLY
|
---|
175 | # define OP(pszOpcode, idxParse1, idxParse2, idxParse3, opcode, param1, param2, param3, optype) \
|
---|
176 | { pszOpcode, idxParse1, idxParse2, idxParse3, 0, opcode, param1, param2, param3, optype }
|
---|
177 | #else
|
---|
178 | # define OP(pszOpcode, idxParse1, idxParse2, idxParse3, opcode, param1, param2, param3, optype) \
|
---|
179 | { idxParse1, idxParse2, idxParse3, 0, opcode, param1, param2, param3, optype }
|
---|
180 | #endif
|
---|
181 |
|
---|
182 |
|
---|
183 | size_t disFormatBytes(PCDISSTATE pDis, char *pszDst, size_t cchDst, uint32_t fFlags);
|
---|
184 |
|
---|
185 | /** @} */
|
---|
186 | #endif
|
---|
187 |
|
---|