Zydis  v2.0.1
DecoderData.h
Go to the documentation of this file.
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 <Zydis/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 bitfields
42 #ifdef ZYDIS_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 
57 
62 {
164 };
165 
166 /* ---------------------------------------------------------------------------------------------- */
167 
172 
173 /* ---------------------------------------------------------------------------------------------- */
174 
178 typedef struct ZydisDecoderTreeNode_
179 {
183 
184 /* ---------------------------------------------------------------------------------------------- */
185 
186 #pragma pack(pop)
187 
188 #ifdef ZYDIS_MSVC
189 # pragma warning(pop)
190 #endif
191 
192 /* ---------------------------------------------------------------------------------------------- */
193 /* Physical instruction encoding info */
194 /* ---------------------------------------------------------------------------------------------- */
195 
200 
204 #define ZYDIS_INSTR_ENC_FLAG_HAS_MODRM 0x01
205 
209 #define ZYDIS_INSTR_ENC_FLAG_HAS_DISP 0x02
210 
214 #define ZYDIS_INSTR_ENC_FLAG_HAS_IMM0 0x04
215 
219 #define ZYDIS_INSTR_ENC_FLAG_HAS_IMM1 0x08
220 
227 #define ZYDIS_INSTR_ENC_FLAG_FORCE_REG_FORM 0x10
228 
233 {
241  struct
242  {
247  } disp;
251  struct
252  {
256  ZydisU8 size[3];
265  } imm[2];
267 
268 /* ---------------------------------------------------------------------------------------------- */
269 
270 /* ============================================================================================== */
271 /* Functions */
272 /* ============================================================================================== */
273 
274 /* ---------------------------------------------------------------------------------------------- */
275 /* Decoder tree */
276 /* ---------------------------------------------------------------------------------------------- */
277 
284 
294  const ZydisDecoderTreeNode* parent, ZydisU16 index);
295 
303 ZYDIS_NO_EXPORT void ZydisGetInstructionEncodingInfo(const ZydisDecoderTreeNode* node,
304  const ZydisInstructionEncodingInfo** info);
305 
306 /* ---------------------------------------------------------------------------------------------- */
307 
308 /* ============================================================================================== */
309 
310 #ifdef __cplusplus
311 }
312 #endif
313 
314 #endif /* ZYDIS_INTERNAL_DECODERDATA_H */
uint8_t ZydisU8
Definition: CommonTypes.h:45
ZydisU8 ZydisBool
@briefs Defines the ZydisBool datatype.
Definition: CommonTypes.h:133
uint16_t ZydisU16
Definition: CommonTypes.h:46
ZydisU16 ZydisDecoderTreeNodeValue
Defines the ZydisDecoderTreeNodeValue datatype.
Definition: DecoderData.h:171
struct ZydisDecoderTreeNode_ ZydisDecoderTreeNode
Defines the ZydisDecoderTreeNode struct.
ZYDIS_NO_EXPORT const ZydisDecoderTreeNode * ZydisDecoderTreeGetChildNode(const ZydisDecoderTreeNode *parent, ZydisU16 index)
Returns the child node of parent specified by index.
ZYDIS_NO_EXPORT const ZydisDecoderTreeNode * ZydisDecoderTreeGetRootNode(void)
Returns the root node of the instruction tree.
ZydisU8 ZydisInstructionEncodingFlags
Defines the ZydisInstructionEncodingFlags datatype.
Definition: DecoderData.h:199
ZYDIS_NO_EXPORT void ZydisGetInstructionEncodingInfo(const ZydisDecoderTreeNode *node, const ZydisInstructionEncodingInfo **info)
Returns information about optional instruction parts (like modrm, displacement or immediates) for the...
ZydisDecoderTreeNodeTypes
Values that represent zydis decoder tree node types.
Definition: DecoderData.h:62
@ ZYDIS_NODETYPE_FILTER_MODRM_MOD_COMPACT
Reference to a compacted ModRM.mod filter.
Definition: DecoderData.h:99
@ ZYDIS_NODETYPE_DEFINITION_MASK
Reference to an instruction-definition.
Definition: DecoderData.h:67
@ ZYDIS_NODETYPE_FILTER_MVEX_E
Reference to an MVEX.E filter.
Definition: DecoderData.h:139
@ ZYDIS_NODETYPE_FILTER_EMVEX
Reference to an EVEX/MVEX-map filter.
Definition: DecoderData.h:79
@ ZYDIS_NODETYPE_FILTER_MODRM_MOD
Reference to a ModRM.mod filter.
Definition: DecoderData.h:95
@ ZYDIS_NODETYPE_FILTER_MODRM_REG
Reference to a ModRM.reg filter.
Definition: DecoderData.h:103
@ ZYDIS_NODETYPE_FILTER_MODE_MPX
Reference to a MPX-mode filter.
Definition: DecoderData.h:151
@ ZYDIS_NODETYPE_FILTER_MODE_TZCNT
Reference to a TZCNT-mode filter.
Definition: DecoderData.h:163
@ ZYDIS_NODETYPE_FILTER_MODE_COMPACT
Reference to an compacted instruction-mode filter.
Definition: DecoderData.h:91
@ ZYDIS_NODETYPE_FILTER_REX_B
Reference to an REX/VEX/EVEX.B filter.
Definition: DecoderData.h:131
@ ZYDIS_NODETYPE_FILTER_OPCODE
Reference to an opcode filter.
Definition: DecoderData.h:83
@ ZYDIS_NODETYPE_FILTER_MODRM_RM
Reference to a ModRM.rm filter.
Definition: DecoderData.h:107
@ ZYDIS_NODETYPE_FILTER_VECTOR_LENGTH
Reference to a vector-length filter.
Definition: DecoderData.h:123
@ ZYDIS_NODETYPE_FILTER_MODE_KNC
Reference to a KNC-mode filter.
Definition: DecoderData.h:147
@ ZYDIS_NODETYPE_FILTER_ADDRESS_SIZE
Reference to an address-size filter.
Definition: DecoderData.h:119
@ ZYDIS_NODETYPE_FILTER_REX_W
Reference to an REX/VEX/EVEX.W filter.
Definition: DecoderData.h:127
@ ZYDIS_NODETYPE_FILTER_MODE
Reference to an instruction-mode filter.
Definition: DecoderData.h:87
@ ZYDIS_NODETYPE_FILTER_MODE_LZCNT
Reference to a LZCNT-mode filter.
Definition: DecoderData.h:159
@ ZYDIS_NODETYPE_FILTER_MODE_AMD
Reference to a AMD-mode filter.
Definition: DecoderData.h:143
@ ZYDIS_NODETYPE_INVALID
Definition: DecoderData.h:63
@ ZYDIS_NODETYPE_FILTER_EVEX_B
Reference to an EVEX.b filter.
Definition: DecoderData.h:135
@ ZYDIS_NODETYPE_FILTER_MANDATORY_PREFIX
Reference to a mandatory-prefix filter.
Definition: DecoderData.h:111
@ ZYDIS_NODETYPE_FILTER_OPERAND_SIZE
Reference to an operand-size filter.
Definition: DecoderData.h:115
@ ZYDIS_NODETYPE_FILTER_XOP
Reference to an XOP-map filter.
Definition: DecoderData.h:71
@ ZYDIS_NODETYPE_FILTER_MODE_CET
Reference to a CET-mode filter.
Definition: DecoderData.h:155
@ ZYDIS_NODETYPE_FILTER_VEX
Reference to an VEX-map filter.
Definition: DecoderData.h:75
ZydisU8 ZydisDecoderTreeNodeType
Defines the ZydisDecoderTreeNodeType datatype.
Definition: DecoderData.h:56
struct ZydisInstructionEncodingInfo_ ZydisInstructionEncodingInfo
Defines the ZydisInstructionEncodingInfo struct.
Defines the basic ZydisDecodedInstruction and ZydisDecodedOperand structs.
General helper and platform detection macros.
Defines the ZydisDecoderTreeNode struct.
Definition: DecoderData.h:179
ZydisDecoderTreeNodeValue value
Definition: DecoderData.h:181
ZydisDecoderTreeNodeType type
Definition: DecoderData.h:180
Defines the ZydisInstructionEncodingInfo struct.
Definition: DecoderData.h:233
struct ZydisInstructionEncodingInfo_::@27 imm[2]
Immediate info.
ZydisInstructionEncodingFlags flags
Contains flags with information about the physical instruction-encoding.
Definition: DecoderData.h:237
ZydisU8 size[3]
The size of the displacement value.
Definition: DecoderData.h:246
ZydisBool isRelative
Signals, if the value is a relative offset.
Definition: DecoderData.h:264
struct ZydisInstructionEncodingInfo_::@26 disp
Displacement info.
ZydisBool isSigned
Signals, if the value is signed.
Definition: DecoderData.h:260