Zydis  v3.0.0
DecoderData.h
1 /***************************************************************************************************
2 
3  Zyan Disassembler Library (Zydis)
4 
5  Original Author : Florian Bernd
6 
7  * Permission is hereby granted, free of charge, to any person obtaining a copy
8  * of this software and associated documentation files (the "Software"), to deal
9  * in the Software without restriction, including without limitation the rights
10  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11  * copies of the Software, and to permit persons to whom the Software is
12  * furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in all
15  * copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23  * SOFTWARE.
24 
25 ***************************************************************************************************/
26 
27 #ifndef ZYDIS_INTERNAL_DECODERDATA_H
28 #define ZYDIS_INTERNAL_DECODERDATA_H
29 
30 #include <Zycore/Defines.h>
31 #include <Zydis/DecoderTypes.h>
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 /* ============================================================================================== */
38 /* Enums and types */
39 /* ============================================================================================== */
40 
41 // MSVC does not like types other than (un-)signed int for bit-fields
42 #ifdef ZYAN_MSVC
43 # pragma warning(push)
44 # pragma warning(disable:4214)
45 #endif
46 
47 #pragma pack(push, 1)
48 
49 /* ---------------------------------------------------------------------------------------------- */
50 /* Decoder tree */
51 /* ---------------------------------------------------------------------------------------------- */
52 
56 typedef ZyanU8 ZydisDecoderTreeNodeType;
57 
61 enum ZydisDecoderTreeNodeTypes
62 {
63  ZYDIS_NODETYPE_INVALID = 0x00,
67  ZYDIS_NODETYPE_DEFINITION_MASK = 0x80,
71  ZYDIS_NODETYPE_FILTER_XOP = 0x01,
75  ZYDIS_NODETYPE_FILTER_VEX = 0x02,
79  ZYDIS_NODETYPE_FILTER_EMVEX = 0x03,
83  ZYDIS_NODETYPE_FILTER_OPCODE = 0x04,
87  ZYDIS_NODETYPE_FILTER_MODE = 0x05,
91  ZYDIS_NODETYPE_FILTER_MODE_COMPACT = 0x06,
95  ZYDIS_NODETYPE_FILTER_MODRM_MOD = 0x07,
99  ZYDIS_NODETYPE_FILTER_MODRM_MOD_COMPACT = 0x08,
103  ZYDIS_NODETYPE_FILTER_MODRM_REG = 0x09,
107  ZYDIS_NODETYPE_FILTER_MODRM_RM = 0x0A,
111  ZYDIS_NODETYPE_FILTER_PREFIX_GROUP1 = 0x0B,
115  ZYDIS_NODETYPE_FILTER_MANDATORY_PREFIX = 0x0C,
119  ZYDIS_NODETYPE_FILTER_OPERAND_SIZE = 0x0D,
123  ZYDIS_NODETYPE_FILTER_ADDRESS_SIZE = 0x0E,
127  ZYDIS_NODETYPE_FILTER_VECTOR_LENGTH = 0x0F,
131  ZYDIS_NODETYPE_FILTER_REX_W = 0x10,
135  ZYDIS_NODETYPE_FILTER_REX_B = 0x11,
139  ZYDIS_NODETYPE_FILTER_EVEX_B = 0x12,
143  ZYDIS_NODETYPE_FILTER_MVEX_E = 0x13,
147  ZYDIS_NODETYPE_FILTER_MODE_AMD = 0x14,
151  ZYDIS_NODETYPE_FILTER_MODE_KNC = 0x15,
155  ZYDIS_NODETYPE_FILTER_MODE_MPX = 0x16,
159  ZYDIS_NODETYPE_FILTER_MODE_CET = 0x17,
163  ZYDIS_NODETYPE_FILTER_MODE_LZCNT = 0x18,
167  ZYDIS_NODETYPE_FILTER_MODE_TZCNT = 0x19,
171  ZYDIS_NODETYPE_FILTER_MODE_WBNOINVD = 0x1A,
175  ZYDIS_NODETYPE_FILTER_MODE_CLDEMOTE = 0x1B
176 };
177 
178 /* ---------------------------------------------------------------------------------------------- */
179 
183 typedef ZyanU16 ZydisDecoderTreeNodeValue;
184 
185 /* ---------------------------------------------------------------------------------------------- */
186 
190 typedef struct ZydisDecoderTreeNode_
191 {
192  ZydisDecoderTreeNodeType type;
193  ZydisDecoderTreeNodeValue value;
195 
196 /* ---------------------------------------------------------------------------------------------- */
197 
198 #pragma pack(pop)
199 
200 #ifdef ZYAN_MSVC
201 # pragma warning(pop)
202 #endif
203 
204 /* ---------------------------------------------------------------------------------------------- */
205 /* Physical instruction encoding info */
206 /* ---------------------------------------------------------------------------------------------- */
207 
211 typedef ZyanU8 ZydisInstructionEncodingFlags;
212 
216 #define ZYDIS_INSTR_ENC_FLAG_HAS_MODRM 0x01
217 
221 #define ZYDIS_INSTR_ENC_FLAG_HAS_DISP 0x02
222 
226 #define ZYDIS_INSTR_ENC_FLAG_HAS_IMM0 0x04
227 
231 #define ZYDIS_INSTR_ENC_FLAG_HAS_IMM1 0x08
232 
239 #define ZYDIS_INSTR_ENC_FLAG_FORCE_REG_FORM 0x10
240 
245 {
249  ZydisInstructionEncodingFlags flags;
253  struct
254  {
258  ZyanU8 size[3];
259  } disp;
263  struct
264  {
268  ZyanU8 size[3];
272  ZyanBool is_signed;
276  ZyanBool is_relative;
277  } imm[2];
279 
280 /* ---------------------------------------------------------------------------------------------- */
281 
282 /* ============================================================================================== */
283 /* Functions */
284 /* ============================================================================================== */
285 
286 /* ---------------------------------------------------------------------------------------------- */
287 /* Decoder tree */
288 /* ---------------------------------------------------------------------------------------------- */
289 
295 ZYDIS_NO_EXPORT const ZydisDecoderTreeNode* ZydisDecoderTreeGetRootNode(void);
296 
305 ZYDIS_NO_EXPORT const ZydisDecoderTreeNode* ZydisDecoderTreeGetChildNode(
306  const ZydisDecoderTreeNode* parent, ZyanU16 index);
307 
315 ZYDIS_NO_EXPORT void ZydisGetInstructionEncodingInfo(const ZydisDecoderTreeNode* node,
316  const ZydisInstructionEncodingInfo** info);
317 
318 /* ---------------------------------------------------------------------------------------------- */
319 
320 /* ============================================================================================== */
321 
322 #ifdef __cplusplus
323 }
324 #endif
325 
326 #endif /* ZYDIS_INTERNAL_DECODERDATA_H */
ZyanBool is_relative
Signals, if the value is a relative offset.
Definition: DecoderData.h:276
struct ZydisInstructionEncodingInfo_::@1 disp
Displacement info.
ZydisInstructionEncodingFlags flags
Contains flags with information about the physical instruction-encoding.
Definition: DecoderData.h:249
Defines the ZydisDecoderTreeNode struct.
Definition: DecoderData.h:190
Defines the basic ZydisDecodedInstruction and ZydisDecodedOperand structs.
struct ZydisInstructionEncodingInfo_::@2 imm[2]
Immediate info.
ZyanU8 size[3]
The size of the displacement value.
Definition: DecoderData.h:258
ZyanBool is_signed
Signals, if the value is signed.
Definition: DecoderData.h:272
Defines the ZydisInstructionEncodingInfo struct.
Definition: DecoderData.h:244