32 #ifndef ZYDIS_ENCODER_H
33 #define ZYDIS_ENCODER_H
35 #include <Zycore/Types.h>
57 #define ZYDIS_ENCODER_MAX_OPERANDS 5
65 #define ZYDIS_ENCODABLE_PREFIXES (ZYDIS_ATTRIB_HAS_LOCK | \
66 ZYDIS_ATTRIB_HAS_REP | \
67 ZYDIS_ATTRIB_HAS_REPE | \
68 ZYDIS_ATTRIB_HAS_REPNE | \
69 ZYDIS_ATTRIB_HAS_BND | \
70 ZYDIS_ATTRIB_HAS_XACQUIRE | \
71 ZYDIS_ATTRIB_HAS_XRELEASE | \
72 ZYDIS_ATTRIB_HAS_BRANCH_NOT_TAKEN | \
73 ZYDIS_ATTRIB_HAS_BRANCH_TAKEN | \
74 ZYDIS_ATTRIB_HAS_NOTRACK | \
75 ZYDIS_ATTRIB_HAS_SEGMENT_CS | \
76 ZYDIS_ATTRIB_HAS_SEGMENT_SS | \
77 ZYDIS_ATTRIB_HAS_SEGMENT_DS | \
78 ZYDIS_ATTRIB_HAS_SEGMENT_ES | \
79 ZYDIS_ATTRIB_HAS_SEGMENT_FS | \
80 ZYDIS_ATTRIB_HAS_SEGMENT_GS)
412 void *buffer, ZyanUSize *length);
430 void *buffer, ZyanUSize *length, ZyanU64 runtime_address);
Defines the basic ZydisDecodedInstruction and ZydisDecodedOperand structs.
enum ZydisConversionMode_ ZydisConversionMode
Defines the ZydisConversionMode enum.
enum ZydisRoundingMode_ ZydisRoundingMode
Defines the ZydisRoundingMode enum.
enum ZydisSwizzleMode_ ZydisSwizzleMode
Defines the ZydisSwizzleMode enum.
enum ZydisBroadcastMode_ ZydisBroadcastMode
Defines the ZydisBroadcastMode enum.
enum ZydisBranchType_ ZydisBranchType
Defines the ZydisBranchType enum.
#define ZYDIS_EXPORT
Symbol is exported in shared library builds.
Definition: Defines.h:67
#define ZYDIS_ENCODER_MAX_OPERANDS
Maximum number of encodable (explicit and implicit) operands.
Definition: Encoder.h:57
enum ZydisAddressSizeHint_ ZydisAddressSizeHint
Defines possible values for address size hints.
enum ZydisBranchWidth_ ZydisBranchWidth
Defines encodable physical/effective sizes of relative immediate operands.
ZydisAddressSizeHint_
Defines possible values for address size hints.
Definition: Encoder.h:141
@ ZYDIS_ADDRESS_SIZE_HINT_REQUIRED_BITS
The minimum number of bits required to represent all values of this enum.
Definition: Encoder.h:154
@ ZYDIS_ADDRESS_SIZE_HINT_NONE
Definition: Encoder.h:142
@ ZYDIS_ADDRESS_SIZE_HINT_16
Definition: Encoder.h:143
@ ZYDIS_ADDRESS_SIZE_HINT_MAX_VALUE
Maximum value of this enum.
Definition: Encoder.h:150
@ ZYDIS_ADDRESS_SIZE_HINT_32
Definition: Encoder.h:144
@ ZYDIS_ADDRESS_SIZE_HINT_64
Definition: Encoder.h:145
struct ZydisEncoderOperand_ ZydisEncoderOperand
Describes explicit or implicit instruction operand.
ZYAN_STATIC_ASSERT(ZYAN_BITS_TO_REPRESENT(ZYDIS_ENCODER_MAX_OPERANDS)==3)
ZydisOperandSizeHint_
Defines possible values for operand size hints.
Definition: Encoder.h:163
@ ZYDIS_OPERAND_SIZE_HINT_16
Definition: Encoder.h:166
@ ZYDIS_OPERAND_SIZE_HINT_32
Definition: Encoder.h:167
@ ZYDIS_OPERAND_SIZE_HINT_REQUIRED_BITS
The minimum number of bits required to represent all values of this enum.
Definition: Encoder.h:177
@ ZYDIS_OPERAND_SIZE_HINT_NONE
Definition: Encoder.h:164
@ ZYDIS_OPERAND_SIZE_HINT_8
Definition: Encoder.h:165
@ ZYDIS_OPERAND_SIZE_HINT_MAX_VALUE
Maximum value of this enum.
Definition: Encoder.h:173
@ ZYDIS_OPERAND_SIZE_HINT_64
Definition: Encoder.h:168
enum ZydisEncodableEncoding_ ZydisEncodableEncoding
Defines possible physical instruction encodings as bit flags, so multiple acceptable encodings can be...
enum ZydisOperandSizeHint_ ZydisOperandSizeHint
Defines possible values for operand size hints.
ZydisBranchWidth_
Defines encodable physical/effective sizes of relative immediate operands.
Definition: Encoder.h:119
@ ZYDIS_BRANCH_WIDTH_NONE
Definition: Encoder.h:120
@ ZYDIS_BRANCH_WIDTH_MAX_VALUE
Maximum value of this enum.
Definition: Encoder.h:129
@ ZYDIS_BRANCH_WIDTH_8
Definition: Encoder.h:121
@ ZYDIS_BRANCH_WIDTH_32
Definition: Encoder.h:123
@ ZYDIS_BRANCH_WIDTH_REQUIRED_BITS
The minimum number of bits required to represent all values of this enum.
Definition: Encoder.h:133
@ ZYDIS_BRANCH_WIDTH_16
Definition: Encoder.h:122
@ ZYDIS_BRANCH_WIDTH_64
Definition: Encoder.h:124
ZydisEncodableEncoding_
Defines possible physical instruction encodings as bit flags, so multiple acceptable encodings can be...
Definition: Encoder.h:93
@ ZYDIS_ENCODABLE_ENCODING_REQUIRED_BITS
The minimum number of bits required to represent all values of this enum.
Definition: Encoder.h:110
@ ZYDIS_ENCODABLE_ENCODING_MAX_VALUE
Maximum value of this enum.
Definition: Encoder.h:105
@ ZYDIS_ENCODABLE_ENCODING_DEFAULT
Definition: Encoder.h:94
@ ZYDIS_ENCODABLE_ENCODING_VEX
Definition: Encoder.h:98
@ ZYDIS_ENCODABLE_ENCODING_MVEX
Definition: Encoder.h:100
@ ZYDIS_ENCODABLE_ENCODING_EVEX
Definition: Encoder.h:99
@ ZYDIS_ENCODABLE_ENCODING_XOP
Definition: Encoder.h:97
@ ZYDIS_ENCODABLE_ENCODING_LEGACY
Definition: Encoder.h:95
@ ZYDIS_ENCODABLE_ENCODING_3DNOW
Definition: Encoder.h:96
struct ZydisEncoderRequest_ ZydisEncoderRequest
Main structure consumed by the encoder.
enum ZydisMnemonic_ ZydisMnemonic
Defines the ZydisMnemonic enum.
enum ZydisRegister_ ZydisRegister
Defines the ZydisRegister enum.
Mnemonic constant definitions and helper functions.
Utility functions and constants for registers.
enum ZydisOperandType_ ZydisOperandType
Defines the ZydisOperandType enum.
enum ZydisMachineMode_ ZydisMachineMode
Defines the ZydisMachineMode enum.
Status code definitions and check macros.
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 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 ZydisEncoderNopFill(void *buffer, ZyanUSize length)
Fills provided buffer with NOP instructions using longest possible multi-byte instructions.
ZyanU64 ZydisInstructionAttributes
Defines the ZydisInstructionAttributes data-type.
Definition: SharedTypes.h:501
Information about a decoded instruction.
Definition: DecoderTypes.h:1238
Defines the ZydisDecodedOperand struct.
Definition: DecoderTypes.h:200
Extended info for memory-operands.
Definition: Encoder.h:210
ZyanU16 size
Size of this operand in bytes.
Definition: Encoder.h:234
ZyanI64 displacement
The displacement value.
Definition: Encoder.h:230
ZydisRegister base
The base register.
Definition: Encoder.h:214
ZyanU8 scale
The scale factor.
Definition: Encoder.h:222
ZydisRegister index
The index register.
Definition: Encoder.h:218
Extended info for pointer-operands.
Definition: Encoder.h:240
ZyanU32 offset
The offset value.
Definition: Encoder.h:248
ZyanU16 segment
The segment value.
Definition: Encoder.h:244
Extended info for register-operands.
Definition: Encoder.h:194
ZyanBool is4
Is this 4th operand (VEX/XOP).
Definition: Encoder.h:204
ZydisRegister value
The register value.
Definition: Encoder.h:198
Describes explicit or implicit instruction operand.
Definition: Encoder.h:185
struct ZydisEncoderOperand_::ZydisEncoderOperandPtr_ ptr
struct ZydisEncoderOperand_::ZydisEncoderOperandReg_ reg
union ZydisEncoderOperand_::ZydisEncoderOperandImm_ imm
struct ZydisEncoderOperand_::ZydisEncoderOperandMem_ mem
ZydisOperandType type
The type of the operand.
Definition: Encoder.h:189
Extended info for EVEX instructions.
Definition: Encoder.h:337
ZydisRoundingMode rounding
The rounding-mode.
Definition: Encoder.h:346
ZyanBool zeroing_mask
Signals, if the zeroing-mask functionality should be enabled for the instruction.
Definition: Encoder.h:356
ZyanBool sae
Signals, if the SAE (suppress-all-exceptions) functionality should be enabled for the instruction.
Definition: Encoder.h:351
ZydisBroadcastMode broadcast
The broadcast-mode.
Definition: Encoder.h:342
Extended info for MVEX instructions.
Definition: Encoder.h:362
ZydisRoundingMode rounding
The rounding-mode.
Definition: Encoder.h:374
ZydisConversionMode conversion
The data-conversion mode.
Definition: Encoder.h:370
ZyanBool eviction_hint
Signals, if the instruction has a memory-eviction-hint (KNC only).
Definition: Encoder.h:387
ZyanBool sae
Signals, if the SAE (suppress-all-exceptions) functionality is enabled for the instruction.
Definition: Encoder.h:383
ZydisSwizzleMode swizzle
The AVX register-swizzle mode.
Definition: Encoder.h:378
ZydisBroadcastMode broadcast
The broadcast-mode.
Definition: Encoder.h:366
Main structure consumed by the encoder.
Definition: Encoder.h:270
ZydisBranchType branch_type
Branch type (required for branching instructions only).
Definition: Encoder.h:296
ZydisMnemonic mnemonic
The instruction-mnemonic.
Definition: Encoder.h:285
ZydisOperandSizeHint operand_size_hint
Optional operand size hint used to resolve ambiguities for some instructions.
Definition: Encoder.h:324
ZydisInstructionAttributes prefixes
A combination of requested encodable prefixes (ZYDIS_ATTRIB_HAS_* flags) for desired instruction.
Definition: Encoder.h:290
ZydisEncodableEncoding allowed_encodings
This optional field can be used to restrict allowed physical encodings for desired instruction.
Definition: Encoder.h:281
ZydisMachineMode machine_mode
The machine mode used to encode this instruction.
Definition: Encoder.h:274
struct ZydisEncoderRequest_::ZydisEncoderRequestEvexFeatures_ evex
struct ZydisEncoderRequest_::ZydisEncoderRequestMvexFeatures_ mvex
ZydisEncoderOperand operands[ZYDIS_ENCODER_MAX_OPERANDS]
Detailed info for all explicit and implicit instruction operands.
Definition: Encoder.h:332
ZyanU8 operand_count
The number of instruction-operands.
Definition: Encoder.h:328
ZydisBranchWidth branch_width
Specifies physical size for relative immediate operands.
Definition: Encoder.h:303
ZydisAddressSizeHint address_size_hint
Optional address size hint used to resolve ambiguities for some instructions.
Definition: Encoder.h:317
Extended info for immediate-operands.
Definition: Encoder.h:254
ZyanU64 u
The unsigned immediate value.
Definition: Encoder.h:258
ZyanI64 s
The signed immediate value.
Definition: Encoder.h:262