Zydis v4.1.1
Loading...
Searching...
No Matches
Encoder.h File Reference

Functions for encoding instructions. More...

#include <Zycore/Types.h>
#include <Zydis/MetaInfo.h>
#include <Zydis/Register.h>
#include <Zydis/DecoderTypes.h>
#include <Zydis/Mnemonic.h>
#include <Zydis/Status.h>

Go to the source code of this file.

Data Structures

struct  ZydisEncoderOperand_
 Describes explicit or implicit instruction operand. More...
 
struct  ZydisEncoderOperand_::ZydisEncoderOperandReg_
 Extended info for register-operands. More...
 
struct  ZydisEncoderOperand_::ZydisEncoderOperandMem_
 Extended info for memory-operands. More...
 
struct  ZydisEncoderOperand_::ZydisEncoderOperandPtr_
 Extended info for pointer-operands. More...
 
union  ZydisEncoderOperand_::ZydisEncoderOperandImm_
 Extended info for immediate-operands. More...
 
struct  ZydisEncoderRequest_
 Main structure consumed by the encoder. More...
 
struct  ZydisEncoderRequest_::ZydisEncoderRequestEvexFeatures_
 Extended info for EVEX instructions. More...
 
struct  ZydisEncoderRequest_::ZydisEncoderRequestMvexFeatures_
 Extended info for MVEX instructions. More...
 

Macros

#define ZYDIS_ENCODER_MAX_OPERANDS   5
 Maximum number of encodable (explicit and implicit) operands.
 
#define ZYDIS_ENCODABLE_PREFIXES
 Combination of all user-encodable prefixes.
 

Typedefs

typedef enum ZydisEncodableEncoding_ ZydisEncodableEncoding
 Defines possible physical instruction encodings as bit flags, so multiple acceptable encodings can be specified simultaneously.
 
typedef enum ZydisBranchWidth_ ZydisBranchWidth
 Defines encodable physical/effective sizes of relative immediate operands.
 
typedef enum ZydisAddressSizeHint_ ZydisAddressSizeHint
 Defines possible values for address size hints.
 
typedef enum ZydisOperandSizeHint_ ZydisOperandSizeHint
 Defines possible values for operand size hints.
 
typedef struct ZydisEncoderOperand_ ZydisEncoderOperand
 Describes explicit or implicit instruction operand.
 
typedef struct ZydisEncoderRequest_ ZydisEncoderRequest
 Main structure consumed by the encoder.
 

Enumerations

enum  ZydisEncodableEncoding_ {
  ZYDIS_ENCODABLE_ENCODING_DEFAULT = 0x00000000 , ZYDIS_ENCODABLE_ENCODING_LEGACY = 0x00000001 , ZYDIS_ENCODABLE_ENCODING_3DNOW = 0x00000002 , ZYDIS_ENCODABLE_ENCODING_XOP = 0x00000004 ,
  ZYDIS_ENCODABLE_ENCODING_VEX = 0x00000008 , ZYDIS_ENCODABLE_ENCODING_EVEX = 0x00000010 , ZYDIS_ENCODABLE_ENCODING_MVEX = 0x00000020 , ZYDIS_ENCODABLE_ENCODING_MAX_VALUE ,
  ZYDIS_ENCODABLE_ENCODING_REQUIRED_BITS =
}
 Defines possible physical instruction encodings as bit flags, so multiple acceptable encodings can be specified simultaneously. More...
 
enum  ZydisBranchWidth_ {
  ZYDIS_BRANCH_WIDTH_NONE , ZYDIS_BRANCH_WIDTH_8 , ZYDIS_BRANCH_WIDTH_16 , ZYDIS_BRANCH_WIDTH_32 ,
  ZYDIS_BRANCH_WIDTH_64 , ZYDIS_BRANCH_WIDTH_MAX_VALUE = ZYDIS_BRANCH_WIDTH_64 , ZYDIS_BRANCH_WIDTH_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_BRANCH_WIDTH_MAX_VALUE)
}
 Defines encodable physical/effective sizes of relative immediate operands. More...
 
enum  ZydisAddressSizeHint_ {
  ZYDIS_ADDRESS_SIZE_HINT_NONE , ZYDIS_ADDRESS_SIZE_HINT_16 , ZYDIS_ADDRESS_SIZE_HINT_32 , ZYDIS_ADDRESS_SIZE_HINT_64 ,
  ZYDIS_ADDRESS_SIZE_HINT_MAX_VALUE = ZYDIS_ADDRESS_SIZE_HINT_64 , ZYDIS_ADDRESS_SIZE_HINT_REQUIRED_BITS =
}
 Defines possible values for address size hints. More...
 
enum  ZydisOperandSizeHint_ {
  ZYDIS_OPERAND_SIZE_HINT_NONE , ZYDIS_OPERAND_SIZE_HINT_8 , ZYDIS_OPERAND_SIZE_HINT_16 , ZYDIS_OPERAND_SIZE_HINT_32 ,
  ZYDIS_OPERAND_SIZE_HINT_64 , ZYDIS_OPERAND_SIZE_HINT_MAX_VALUE = ZYDIS_OPERAND_SIZE_HINT_64 , ZYDIS_OPERAND_SIZE_HINT_REQUIRED_BITS =
}
 Defines possible values for operand size hints. More...
 

Functions

 ZYAN_STATIC_ASSERT (ZYAN_BITS_TO_REPRESENT(ZYDIS_ENCODER_MAX_OPERANDS)==3)
 
ZYDIS_EXPORT ZyanStatus ZydisEncoderEncodeInstruction (const ZydisEncoderRequest *request, void *buffer, ZyanUSize *length)
 Encodes instruction with semantics specified in encoder request structure.
 
ZYDIS_EXPORT ZyanStatus ZydisEncoderEncodeInstructionAbsolute (ZydisEncoderRequest *request, void *buffer, ZyanUSize *length, ZyanU64 runtime_address)
 Encodes instruction with semantics specified in encoder request structure.
 
ZYDIS_EXPORT ZyanStatus ZydisEncoderDecodedInstructionToEncoderRequest (const ZydisDecodedInstruction *instruction, const ZydisDecodedOperand *operands, ZyanU8 operand_count, ZydisEncoderRequest *request)
 Converts decoded instruction to encoder request that can be passed to ZydisEncoderEncodeInstruction.
 
ZYDIS_EXPORT ZyanStatus ZydisEncoderNopFill (void *buffer, ZyanUSize length)
 Fills provided buffer with NOP instructions using longest possible multi-byte instructions.
 

Detailed Description

Functions for encoding instructions.

Macro Definition Documentation

◆ ZYDIS_ENCODABLE_PREFIXES

#define ZYDIS_ENCODABLE_PREFIXES
Value:
#define ZYDIS_ATTRIB_HAS_BRANCH_TAKEN
The instruction has the branch-taken hint (0x3E).
Definition SharedTypes.h:666
#define ZYDIS_ATTRIB_HAS_BND
The instruction has the BND prefix (0xF2).
Definition SharedTypes.h:650
#define ZYDIS_ATTRIB_HAS_XRELEASE
The instruction has the XRELEASE prefix (0xF3).
Definition SharedTypes.h:658
#define ZYDIS_ATTRIB_HAS_BRANCH_NOT_TAKEN
The instruction has the branch-not-taken hint (0x2E).
Definition SharedTypes.h:662
#define ZYDIS_ATTRIB_HAS_SEGMENT_FS
The instruction has the FS segment modifier (0x64).
Definition SharedTypes.h:690
#define ZYDIS_ATTRIB_HAS_SEGMENT_CS
The instruction has the CS segment modifier (0x2E).
Definition SharedTypes.h:674
#define ZYDIS_ATTRIB_HAS_REP
The instruction has the REP prefix (0xF3).
Definition SharedTypes.h:630
#define ZYDIS_ATTRIB_HAS_SEGMENT_DS
The instruction has the DS segment modifier (0x3E).
Definition SharedTypes.h:682
#define ZYDIS_ATTRIB_HAS_SEGMENT_SS
The instruction has the SS segment modifier (0x36).
Definition SharedTypes.h:678
#define ZYDIS_ATTRIB_HAS_NOTRACK
The instruction has the CET no-track prefix (0x3E).
Definition SharedTypes.h:670
#define ZYDIS_ATTRIB_HAS_SEGMENT_GS
The instruction has the GS segment modifier (0x65).
Definition SharedTypes.h:694
#define ZYDIS_ATTRIB_HAS_XACQUIRE
The instruction has the XACQUIRE prefix (0xF2).
Definition SharedTypes.h:654
#define ZYDIS_ATTRIB_HAS_SEGMENT_ES
The instruction has the ES segment modifier (0x26).
Definition SharedTypes.h:686
#define ZYDIS_ATTRIB_HAS_LOCK
The instruction has the LOCK prefix (0xF0).
Definition SharedTypes.h:626
#define ZYDIS_ATTRIB_HAS_REPE
The instruction has the REPE/REPZ prefix (0xF3).
Definition SharedTypes.h:634
#define ZYDIS_ATTRIB_HAS_REPNE
The instruction has the REPNE/REPNZ prefix (0xF2).
Definition SharedTypes.h:642

Combination of all user-encodable prefixes.

◆ ZYDIS_ENCODER_MAX_OPERANDS

#define ZYDIS_ENCODER_MAX_OPERANDS   5

Maximum number of encodable (explicit and implicit) operands.

Typedef Documentation

◆ ZydisAddressSizeHint

Defines possible values for address size hints.

See ZydisEncoderRequest for more information about address size hints.

◆ ZydisBranchWidth

Defines encodable physical/effective sizes of relative immediate operands.

See ZydisEncoderRequest.branch_width for more details.

◆ ZydisEncodableEncoding

Defines possible physical instruction encodings as bit flags, so multiple acceptable encodings can be specified simultaneously.

◆ ZydisEncoderOperand

Describes explicit or implicit instruction operand.

◆ ZydisEncoderRequest

Main structure consumed by the encoder.

It represents full semantics of an instruction.

◆ ZydisOperandSizeHint

Defines possible values for operand size hints.

See ZydisEncoderRequest for more information about operand size hints.

Enumeration Type Documentation

◆ ZydisAddressSizeHint_

Defines possible values for address size hints.

See ZydisEncoderRequest for more information about address size hints.

Enumerator
ZYDIS_ADDRESS_SIZE_HINT_NONE 
ZYDIS_ADDRESS_SIZE_HINT_16 
ZYDIS_ADDRESS_SIZE_HINT_32 
ZYDIS_ADDRESS_SIZE_HINT_64 
ZYDIS_ADDRESS_SIZE_HINT_MAX_VALUE 

Maximum value of this enum.

ZYDIS_ADDRESS_SIZE_HINT_REQUIRED_BITS 

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

◆ ZydisBranchWidth_

Defines encodable physical/effective sizes of relative immediate operands.

See ZydisEncoderRequest.branch_width for more details.

Enumerator
ZYDIS_BRANCH_WIDTH_NONE 
ZYDIS_BRANCH_WIDTH_8 
ZYDIS_BRANCH_WIDTH_16 
ZYDIS_BRANCH_WIDTH_32 
ZYDIS_BRANCH_WIDTH_64 
ZYDIS_BRANCH_WIDTH_MAX_VALUE 

Maximum value of this enum.

ZYDIS_BRANCH_WIDTH_REQUIRED_BITS 

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

◆ ZydisEncodableEncoding_

Defines possible physical instruction encodings as bit flags, so multiple acceptable encodings can be specified simultaneously.

Enumerator
ZYDIS_ENCODABLE_ENCODING_DEFAULT 
ZYDIS_ENCODABLE_ENCODING_LEGACY 
ZYDIS_ENCODABLE_ENCODING_3DNOW 
ZYDIS_ENCODABLE_ENCODING_XOP 
ZYDIS_ENCODABLE_ENCODING_VEX 
ZYDIS_ENCODABLE_ENCODING_EVEX 
ZYDIS_ENCODABLE_ENCODING_MVEX 
ZYDIS_ENCODABLE_ENCODING_MAX_VALUE 

Maximum value of this enum.

ZYDIS_ENCODABLE_ENCODING_REQUIRED_BITS 

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

◆ ZydisOperandSizeHint_

Defines possible values for operand size hints.

See ZydisEncoderRequest for more information about operand size hints.

Enumerator
ZYDIS_OPERAND_SIZE_HINT_NONE 
ZYDIS_OPERAND_SIZE_HINT_8 
ZYDIS_OPERAND_SIZE_HINT_16 
ZYDIS_OPERAND_SIZE_HINT_32 
ZYDIS_OPERAND_SIZE_HINT_64 
ZYDIS_OPERAND_SIZE_HINT_MAX_VALUE 

Maximum value of this enum.

ZYDIS_OPERAND_SIZE_HINT_REQUIRED_BITS 

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

Function Documentation

◆ ZYAN_STATIC_ASSERT()

ZYAN_STATIC_ASSERT ( ZYAN_BITS_TO_REPRESENT(ZYDIS_ENCODER_MAX_OPERANDS) = =3)