Zydis  master
DecoderData.h File Reference
#include <Zycore/Defines.h>
#include <Zycore/Types.h>
#include <Zydis/Defines.h>
Include dependency graph for DecoderData.h:

Go to the source code of this file.

Data Structures

struct  ZydisInstructionEncodingInfo_
 Defines the ZydisInstructionEncodingInfo struct. More...
 

Macros

#define ZYDIS_OPCODE_TABLE_PRIMARY   0x00
 
#define ZYDIS_OPCODE_TABLE_0F   0x01
 
#define ZYDIS_OPCODE_TABLE_0F38   0x02
 
#define ZYDIS_OPCODE_TABLE_0F3A   0x03
 
#define ZYDIS_OPCODE_TABLE_VEX   0x04
 
#define ZYDIS_OPCODE_TABLE_EVEX   0x14
 
#define ZYDIS_OPCODE_TABLE_MVEX   0x34
 
#define ZYDIS_OPCODE_TABLE_XOP   0x44
 
#define ZYDIS_OPCODE_TABLE_3DNOW   0x47
 
#define ZYDIS_INSTR_ENC_FLAG_HAS_MODRM   0x01
 The instruction has an optional modrm byte. More...
 
#define ZYDIS_INSTR_ENC_FLAG_HAS_DISP   0x02
 The instruction has an optional displacement value. More...
 
#define ZYDIS_INSTR_ENC_FLAG_HAS_IMM0   0x04
 The instruction has an optional immediate value. More...
 
#define ZYDIS_INSTR_ENC_FLAG_HAS_IMM1   0x08
 The instruction has a second optional immediate value. More...
 
#define ZYDIS_INSTR_ENC_FLAG_FORCE_REG_FORM   0x10
 The instruction ignores the value of modrm.mod and always assumes modrm.mod == 3 ("reg, reg" - form). More...
 
#define ZYDIS_DT_GET_TYPE(node)    ((ZydisDecoderTreeNodeType)((*(node)) & 0xFF))
 Gets the type of the given decoder tree node. More...
 
#define ZYDIS_DT_GET_ARG0(node)    ((ZyanU8)(((*(node)) >> 8) & 0xFF))
 Gets the first argument of the given decoder tree node. More...
 
#define ZYDIS_DT_GET_VALUE(node, index)    ((ZyanU16)(*((node) + 1 + (index))))
 Gets the value at index index of the given decoder tree node. More...
 

Typedefs

typedef ZyanU16 ZydisDecoderTreeNode
 Defines the ZydisDecoderTreeNode data-type. More...
 
typedef enum ZydisDecoderTreeNodeType_ ZydisDecoderTreeNodeType
 Values that represent Zydis decoder tree node types. More...
 
typedef ZyanU8 ZydisInstructionEncodingFlags
 Defines the ZydisInstructionEncodingFlags data-type. More...
 
typedef struct ZydisInstructionEncodingInfo_ ZydisInstructionEncodingInfo
 Defines the ZydisInstructionEncodingInfo struct. More...
 

Enumerations

enum  ZydisDecoderTreeNodeType_ {
  ZYDIS_NODETYPE_INVALID = 0 , ZYDIS_NODETYPE_DEFINITION , ZYDIS_NODETYPE_SWITCH_TABLE , ZYDIS_NODETYPE_SWITCH_TABLE_XOP ,
  ZYDIS_NODETYPE_SWITCH_TABLE_VEX , ZYDIS_NODETYPE_SWITCH_TABLE_EMVEX , ZYDIS_NODETYPE_SWITCH_TABLE_REX2 , ZYDIS_NODETYPE_OPCODE_TABLE ,
  ZYDIS_NODETYPE_MODE , ZYDIS_NODETYPE_MODE_COMPACT , ZYDIS_NODETYPE_MODRM_MOD , ZYDIS_NODETYPE_MODRM_MOD_COMPACT ,
  ZYDIS_NODETYPE_MODRM_REG , ZYDIS_NODETYPE_MODRM_RM , ZYDIS_NODETYPE_PREFIX_GROUP1 , ZYDIS_NODETYPE_MANDATORY_PREFIX ,
  ZYDIS_NODETYPE_OPERAND_SIZE , ZYDIS_NODETYPE_ADDRESS_SIZE , ZYDIS_NODETYPE_VECTOR_LENGTH , ZYDIS_NODETYPE_REX_W ,
  ZYDIS_NODETYPE_REX_B , ZYDIS_NODETYPE_EVEX_B , ZYDIS_NODETYPE_MVEX_E , ZYDIS_NODETYPE_MODE_AMD ,
  ZYDIS_NODETYPE_MODE_KNC , ZYDIS_NODETYPE_MODE_MPX , ZYDIS_NODETYPE_MODE_CET , ZYDIS_NODETYPE_MODE_LZCNT ,
  ZYDIS_NODETYPE_MODE_TZCNT , ZYDIS_NODETYPE_MODE_WBNOINVD , ZYDIS_NODETYPE_MODE_CLDEMOTE , ZYDIS_NODETYPE_MODE_IPREFETCH ,
  ZYDIS_NODETYPE_MODE_UD0_COMPAT , ZYDIS_NODETYPE_EVEX_ND , ZYDIS_NODETYPE_EVEX_NF , ZYDIS_NODETYPE_EVEX_SCC ,
  ZYDIS_NODETYPE_REX_2 , ZYDIS_NODETYPE_EVEX_U , ZYDIS_NODETYPE_MAX_VALUE = ZYDIS_NODETYPE_EVEX_U , ZYDIS_NODETYPE_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_NODETYPE_MAX_VALUE)
}
 Values that represent Zydis decoder tree node types. More...
 

Functions

ZYDIS_NO_EXPORT const ZydisDecoderTreeNodeZydisGetOpcodeTableRootNode (ZyanU8 opcode_table_id)
 Returns the root node of the opcode table with the given opcode_table_id. More...
 
ZYDIS_NO_EXPORT void ZydisGetInstructionEncodingInfo (const ZydisDecoderTreeNode *node, const ZydisInstructionEncodingInfo **info)
 Returns information about optional instruction parts (like modrm, displacement or immediates) for the instruction that is linked to the given node. More...
 

Macro Definition Documentation

◆ ZYDIS_DT_GET_ARG0

#define ZYDIS_DT_GET_ARG0 (   node)     ((ZyanU8)(((*(node)) >> 8) & 0xFF))

Gets the first argument of the given decoder tree node.

Parameters
nodeThe decoder tree node.

Encoding: [15..8] = ARG0, [7..0] = TYPE.

◆ ZYDIS_DT_GET_TYPE

#define ZYDIS_DT_GET_TYPE (   node)     ((ZydisDecoderTreeNodeType)((*(node)) & 0xFF))

Gets the type of the given decoder tree node.

Parameters
nodeThe decoder tree node.

Encoding: [15..8] = ARG0, [7..0] = TYPE.

◆ ZYDIS_DT_GET_VALUE

#define ZYDIS_DT_GET_VALUE (   node,
  index 
)     ((ZyanU16)(*((node) + 1 + (index))))

Gets the value at index index of the given decoder tree node.

Parameters
nodeThe decoder tree node.
indexThe index of the value to retrieve.

◆ ZYDIS_INSTR_ENC_FLAG_FORCE_REG_FORM

#define ZYDIS_INSTR_ENC_FLAG_FORCE_REG_FORM   0x10

The instruction ignores the value of modrm.mod and always assumes modrm.mod == 3 ("reg, reg" - form).

Instructions with this flag can't have a SIB byte or a displacement value.

◆ ZYDIS_INSTR_ENC_FLAG_HAS_DISP

#define ZYDIS_INSTR_ENC_FLAG_HAS_DISP   0x02

The instruction has an optional displacement value.

◆ ZYDIS_INSTR_ENC_FLAG_HAS_IMM0

#define ZYDIS_INSTR_ENC_FLAG_HAS_IMM0   0x04

The instruction has an optional immediate value.

◆ ZYDIS_INSTR_ENC_FLAG_HAS_IMM1

#define ZYDIS_INSTR_ENC_FLAG_HAS_IMM1   0x08

The instruction has a second optional immediate value.

◆ ZYDIS_INSTR_ENC_FLAG_HAS_MODRM

#define ZYDIS_INSTR_ENC_FLAG_HAS_MODRM   0x01

The instruction has an optional modrm byte.

◆ ZYDIS_OPCODE_TABLE_0F

#define ZYDIS_OPCODE_TABLE_0F   0x01

◆ ZYDIS_OPCODE_TABLE_0F38

#define ZYDIS_OPCODE_TABLE_0F38   0x02

◆ ZYDIS_OPCODE_TABLE_0F3A

#define ZYDIS_OPCODE_TABLE_0F3A   0x03

◆ ZYDIS_OPCODE_TABLE_3DNOW

#define ZYDIS_OPCODE_TABLE_3DNOW   0x47

◆ ZYDIS_OPCODE_TABLE_EVEX

#define ZYDIS_OPCODE_TABLE_EVEX   0x14

◆ ZYDIS_OPCODE_TABLE_MVEX

#define ZYDIS_OPCODE_TABLE_MVEX   0x34

◆ ZYDIS_OPCODE_TABLE_PRIMARY

#define ZYDIS_OPCODE_TABLE_PRIMARY   0x00

◆ ZYDIS_OPCODE_TABLE_VEX

#define ZYDIS_OPCODE_TABLE_VEX   0x04

◆ ZYDIS_OPCODE_TABLE_XOP

#define ZYDIS_OPCODE_TABLE_XOP   0x44

Typedef Documentation

◆ ZydisDecoderTreeNode

typedef ZyanU16 ZydisDecoderTreeNode

Defines the ZydisDecoderTreeNode data-type.

◆ ZydisDecoderTreeNodeType

Values that represent Zydis decoder tree node types.

◆ ZydisInstructionEncodingFlags

Defines the ZydisInstructionEncodingFlags data-type.

◆ ZydisInstructionEncodingInfo

Defines the ZydisInstructionEncodingInfo struct.

Enumeration Type Documentation

◆ ZydisDecoderTreeNodeType_

Values that represent Zydis decoder tree node types.

Enumerator
ZYDIS_NODETYPE_INVALID 
ZYDIS_NODETYPE_DEFINITION 

Reference to an instruction-definition.

ZYDIS_NODETYPE_SWITCH_TABLE 

A decoder tree node that instructs the decoder to switch to a different opcode table.

The arg0 value of the node header is the id of the opcode table to switch to.

ZYDIS_NODETYPE_SWITCH_TABLE_XOP 

Reference to an XOP-map selector.

ZYDIS_NODETYPE_SWITCH_TABLE_VEX 

Reference to an VEX-map selector.

ZYDIS_NODETYPE_SWITCH_TABLE_EMVEX 

Reference to an EVEX/MVEX-map selector.

ZYDIS_NODETYPE_SWITCH_TABLE_REX2 

Reference to a REX2-map selector.

ZYDIS_NODETYPE_OPCODE_TABLE 

Reference to an opcode selector.

ZYDIS_NODETYPE_MODE 

Reference to an instruction-mode selector.

ZYDIS_NODETYPE_MODE_COMPACT 

Reference to an compacted instruction-mode selector.

ZYDIS_NODETYPE_MODRM_MOD 

Reference to a ModRM.mod selector.

ZYDIS_NODETYPE_MODRM_MOD_COMPACT 

Reference to a compacted ModRM.mod selector.

ZYDIS_NODETYPE_MODRM_REG 

Reference to a ModRM.reg selector.

ZYDIS_NODETYPE_MODRM_RM 

Reference to a ModRM.rm selector.

ZYDIS_NODETYPE_PREFIX_GROUP1 

Reference to a PrefixGroup1 selector.

ZYDIS_NODETYPE_MANDATORY_PREFIX 

Reference to a mandatory-prefix selector.

ZYDIS_NODETYPE_OPERAND_SIZE 

Reference to an operand-size selector.

ZYDIS_NODETYPE_ADDRESS_SIZE 

Reference to an address-size selector.

ZYDIS_NODETYPE_VECTOR_LENGTH 

Reference to a vector-length selector.

ZYDIS_NODETYPE_REX_W 

Reference to an REX/VEX/EVEX.W selector.

ZYDIS_NODETYPE_REX_B 

Reference to an REX/VEX/EVEX.B selector.

ZYDIS_NODETYPE_EVEX_B 

Reference to an EVEX.b selector.

ZYDIS_NODETYPE_MVEX_E 

Reference to an MVEX.E selector.

ZYDIS_NODETYPE_MODE_AMD 

Reference to a AMD-mode selector.

ZYDIS_NODETYPE_MODE_KNC 

Reference to a KNC-mode selector.

ZYDIS_NODETYPE_MODE_MPX 

Reference to a MPX-mode selector.

ZYDIS_NODETYPE_MODE_CET 

Reference to a CET-mode selector.

ZYDIS_NODETYPE_MODE_LZCNT 

Reference to a LZCNT-mode selector.

ZYDIS_NODETYPE_MODE_TZCNT 

Reference to a TZCNT-mode selector.

ZYDIS_NODETYPE_MODE_WBNOINVD 

Reference to a WBNOINVD-mode selector.

ZYDIS_NODETYPE_MODE_CLDEMOTE 

Reference to a CLDEMOTE-mode selector.

ZYDIS_NODETYPE_MODE_IPREFETCH 

Reference to a IPREFETCH-mode selector.

ZYDIS_NODETYPE_MODE_UD0_COMPAT 

Reference to a UD0_COMPAT-mode selector.

ZYDIS_NODETYPE_EVEX_ND 

Reference to an EVEX.nd selector.

ZYDIS_NODETYPE_EVEX_NF 

Reference to an EVEX.nf selector.

ZYDIS_NODETYPE_EVEX_SCC 

Reference to an EVEX.scc selector.

ZYDIS_NODETYPE_REX_2 

Reference to a REX2-prefix selector.

ZYDIS_NODETYPE_EVEX_U 

Reference to a EVEX.U selector.

ZYDIS_NODETYPE_MAX_VALUE 

Maximum value of this enum.

ZYDIS_NODETYPE_REQUIRED_BITS 

The minimum number of bits required to represent all values of this enum.

Function Documentation

◆ ZydisGetInstructionEncodingInfo()

ZYDIS_NO_EXPORT void ZydisGetInstructionEncodingInfo ( const ZydisDecoderTreeNode node,
const ZydisInstructionEncodingInfo **  info 
)

Returns information about optional instruction parts (like modrm, displacement or immediates) for the instruction that is linked to the given node.

Parameters
nodeThe instruction definition node.
infoA pointer to the ZydisInstructionParts struct.

◆ ZydisGetOpcodeTableRootNode()

ZYDIS_NO_EXPORT const ZydisDecoderTreeNode* ZydisGetOpcodeTableRootNode ( ZyanU8  opcode_table_id)

Returns the root node of the opcode table with the given opcode_table_id.

Parameters
opcode_table_idThe id of the opcode table to retrieve.
Returns
The root node of the opcode table with the given opcode_table_id.