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) 94 ZYDIS_ENCODABLE_ENCODING_DEFAULT = 0x00000000,
95 ZYDIS_ENCODABLE_ENCODING_LEGACY = 0x00000001,
96 ZYDIS_ENCODABLE_ENCODING_3DNOW = 0x00000002,
97 ZYDIS_ENCODABLE_ENCODING_XOP = 0x00000004,
98 ZYDIS_ENCODABLE_ENCODING_VEX = 0x00000008,
99 ZYDIS_ENCODABLE_ENCODING_EVEX = 0x00000010,
100 ZYDIS_ENCODABLE_ENCODING_MVEX = 0x00000020,
106 (ZYDIS_ENCODABLE_ENCODING_MVEX - 1)),
120 ZYDIS_BRANCH_WIDTH_NONE,
121 ZYDIS_BRANCH_WIDTH_8,
122 ZYDIS_BRANCH_WIDTH_16,
123 ZYDIS_BRANCH_WIDTH_32,
124 ZYDIS_BRANCH_WIDTH_64,
142 ZYDIS_ADDRESS_SIZE_HINT_NONE,
143 ZYDIS_ADDRESS_SIZE_HINT_16,
144 ZYDIS_ADDRESS_SIZE_HINT_32,
145 ZYDIS_ADDRESS_SIZE_HINT_64,
164 ZYDIS_OPERAND_SIZE_HINT_NONE,
165 ZYDIS_OPERAND_SIZE_HINT_8,
166 ZYDIS_OPERAND_SIZE_HINT_16,
167 ZYDIS_OPERAND_SIZE_HINT_32,
168 ZYDIS_OPERAND_SIZE_HINT_64,
401 void *buffer, ZyanUSize *length);
419 void *buffer, ZyanUSize *length, ZyanU64 runtime_address);
ZydisRoundingMode rounding
The rounding-mode.
Definition: Encoder.h:363
enum ZydisMachineMode_ ZydisMachineMode
Defines the ZydisMachineMode enum.
Extended info for register-operands.
Definition: Encoder.h:193
The minimum number of bits required to represent all values of this enum.
Definition: Encoder.h:110
enum ZydisRoundingMode_ ZydisRoundingMode
Defines the ZydisRoundingMode enum.
Information about a decoded instruction.
Definition: DecoderTypes.h:1237
ZydisEncodableEncoding_
Defines possible physical instruction encodings as bit flags, so multiple acceptable encodings can be...
Definition: Encoder.h:92
enum ZydisOperandSizeHint_ ZydisOperandSizeHint
Defines possible values for operand size hints.
ZydisAddressSizeHint_
Defines possible values for address size hints.
Definition: Encoder.h:140
ZyanU16 size
Size of this operand in bytes.
Definition: Encoder.h:230
ZyanU64 u
The unsigned immediate value.
Definition: Encoder.h:254
ZydisEncoderOperand operands[ZYDIS_ENCODER_MAX_OPERANDS]
Detailed info for all explicit and implicit instruction operands.
Definition: Encoder.h:321
Describes explicit or implicit instruction operand.
Definition: Encoder.h:184
enum ZydisBranchType_ ZydisBranchType
Defines the ZydisBranchType enum.
ZyanBool sae
Signals, if the SAE (suppress-all-exceptions) functionality is enabled for the instruction.
Definition: Encoder.h:372
ZydisRegister index
The index register.
Definition: Encoder.h:218
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.
ZyanI64 s
The signed immediate value.
Definition: Encoder.h:258
ZydisOperandSizeHint operand_size_hint
Optional operand size hint used to resolve ambiguities for some instructions.
Definition: Encoder.h:313
Extended info for immediate-operands.
Definition: Encoder.h:249
ZyanBool sae
Signals, if the SAE (suppress-all-exceptions) functionality should be enabled for the instruction...
Definition: Encoder.h:340
Utility functions and constants for registers.
ZydisBranchType branch_type
Branch type (required for branching instructions only).
Definition: Encoder.h:292
ZyanU16 segment
The segment value.
Definition: Encoder.h:240
enum ZydisBroadcastMode_ ZydisBroadcastMode
Defines the ZydisBroadcastMode enum.
ZyanBool zeroing_mask
Signals, if the zeroing-mask functionality should be enabled for the instruction. ...
Definition: Encoder.h:345
The minimum number of bits required to represent all values of this enum.
Definition: Encoder.h:133
Extended info for EVEX instructions.
Definition: Encoder.h:325
ZYDIS_EXPORT ZyanStatus ZydisEncoderNopFill(void *buffer, ZyanUSize length)
Fills provided buffer with NOP instructions using longest possible multi-byte instructions.
ZydisOperandSizeHint_
Defines possible values for operand size hints.
Definition: Encoder.h:162
#define ZYDIS_EXPORT
Symbol is exported in shared library builds.
Definition: Defines.h:67
ZydisRoundingMode rounding
The rounding-mode.
Definition: Encoder.h:335
struct ZydisEncoderRequest_ ZydisEncoderRequest
Main structure consumed by the encoder.
#define ZYDIS_ENCODER_MAX_OPERANDS
Maximum number of encodable (explicit and implicit) operands.
Definition: Encoder.h:57
Extended info for pointer-operands.
Definition: Encoder.h:235
ZyanU8 scale
The scale factor.
Definition: Encoder.h:222
ZydisRegister base
The base register.
Definition: Encoder.h:214
ZydisBroadcastMode broadcast
The broadcast-mode.
Definition: Encoder.h:331
enum ZydisEncodableEncoding_ ZydisEncodableEncoding
Defines possible physical instruction encodings as bit flags, so multiple acceptable encodings can be...
ZydisAddressSizeHint address_size_hint
Optional address size hint used to resolve ambiguities for some instructions.
Definition: Encoder.h:306
ZydisEncodableEncoding allowed_encodings
This optional field can be used to restrict allowed physical encodings for desired instruction...
Definition: Encoder.h:277
enum ZydisAddressSizeHint_ ZydisAddressSizeHint
Defines possible values for address size hints.
ZyanU32 offset
The offset value.
Definition: Encoder.h:244
ZyanU8 operand_count
The number of instruction-operands.
Definition: Encoder.h:317
Maximum value of this enum.
Definition: Encoder.h:173
ZydisInstructionAttributes prefixes
A combination of requested encodable prefixes (ZYDIS_ATTRIB_HAS_* flags) for desired instruction...
Definition: Encoder.h:286
ZydisMachineMode machine_mode
The machine mode used to encode this instruction.
Definition: Encoder.h:270
struct ZydisEncoderOperand_ ZydisEncoderOperand
Describes explicit or implicit instruction operand.
ZydisRegister value
The register value.
Definition: Encoder.h:198
ZydisBroadcastMode broadcast
The broadcast-mode.
Definition: Encoder.h:355
ZydisSwizzleMode swizzle
The AVX register-swizzle mode.
Definition: Encoder.h:367
Maximum value of this enum.
Definition: Encoder.h:150
ZydisConversionMode conversion
The data-conversion mode.
Definition: Encoder.h:359
Extended info for MVEX instructions.
Definition: Encoder.h:350
The minimum number of bits required to represent all values of this enum.
Definition: Encoder.h:154
ZydisMnemonic mnemonic
The instruction-mnemonic.
Definition: Encoder.h:281
Maximum value of this enum.
Definition: Encoder.h:105
enum ZydisConversionMode_ ZydisConversionMode
Defines the ZydisConversionMode enum.
ZydisBranchWidth_
Defines encodable physical/effective sizes of relative immediate operands.
Definition: Encoder.h:118
ZYDIS_EXPORT ZyanStatus ZydisEncoderEncodeInstructionAbsolute(ZydisEncoderRequest *request, void *buffer, ZyanUSize *length, ZyanU64 runtime_address)
Encodes instruction with semantics specified in encoder request structure.
ZydisBranchWidth branch_width
Specifies physical size for relative immediate operands.
Definition: Encoder.h:299
ZyanBool eviction_hint
Signals, if the instruction has a memory-eviction-hint (KNC only).
Definition: Encoder.h:376
ZydisOperandType type
The type of the operand.
Definition: Encoder.h:189
enum ZydisSwizzleMode_ ZydisSwizzleMode
Defines the ZydisSwizzleMode enum.
ZyanBool is4
Is this 4th operand (VEX/XOP).
Definition: Encoder.h:204
Defines the basic ZydisDecodedInstruction and ZydisDecodedOperand structs.
enum ZydisBranchWidth_ ZydisBranchWidth
Defines encodable physical/effective sizes of relative immediate operands.
The minimum number of bits required to represent all values of this enum.
Definition: Encoder.h:177
ZYDIS_EXPORT ZyanStatus ZydisEncoderEncodeInstruction(const ZydisEncoderRequest *request, void *buffer, ZyanUSize *length)
Encodes instruction with semantics specified in encoder request structure.
Defines the ZydisDecodedOperand struct.
Definition: DecoderTypes.h:199
ZyanI64 displacement
The displacement value.
Definition: Encoder.h:226
Mnemonic constant definitions and helper functions.
Status code definitions and check macros.
ZyanU64 ZydisInstructionAttributes
Defines the ZydisInstructionAttributes data-type.
Definition: SharedTypes.h:497
Main structure consumed by the encoder.
Definition: Encoder.h:265
enum ZydisOperandType_ ZydisOperandType
Defines the ZydisOperandType enum.
Extended info for memory-operands.
Definition: Encoder.h:209
Maximum value of this enum.
Definition: Encoder.h:129