Zydis  master
Encoder

Functions allowing encoding of instruction bytes from a machine interpretable struct. More...

Functions

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

Detailed Description

Functions allowing encoding of instruction bytes from a machine interpretable struct.

Function Documentation

◆ ZydisEncoderDecodedInstructionToEncoderRequest()

ZYDIS_EXPORT ZyanStatus ZydisEncoderDecodedInstructionToEncoderRequest ( const ZydisDecodedInstruction instruction,
const ZydisDecodedOperand operands,
ZyanU8  operand_count_visible,
ZydisEncoderRequest request 
)

Converts decoded instruction to encoder request that can be passed to ZydisEncoderEncodeInstruction.

Parameters
instructionA pointer to the ZydisDecodedInstruction struct.
operandsA pointer to the decoded operands.
operand_count_visibleThe number of visible instruction operands.
requestA pointer to the ZydisEncoderRequest struct, that receives information necessary for encoder to re-encode the instruction.

This function performs simple structure conversion and does minimal sanity checks on the input. There's no guarantee that produced request will be accepted by ZydisEncoderEncodeInstruction if malformed ZydisDecodedInstruction or malformed ZydisDecodedOperands is passed to this function.

Returns
A zyan status code.

◆ ZydisEncoderEncodeInstruction()

ZYDIS_EXPORT ZyanStatus ZydisEncoderEncodeInstruction ( const ZydisEncoderRequest request,
void *  buffer,
ZyanUSize *  length 
)

Encodes instruction with semantics specified in encoder request structure.

Parameters
requestA pointer to the ZydisEncoderRequest struct.
bufferA pointer to the output buffer receiving encoded instruction.
lengthA pointer to the variable containing length of the output buffer. Upon successful return this variable receives length of the encoded instruction.
Returns
A zyan status code.

◆ ZydisEncoderEncodeInstructionAbsolute()

ZYDIS_EXPORT ZyanStatus ZydisEncoderEncodeInstructionAbsolute ( ZydisEncoderRequest request,
void *  buffer,
ZyanUSize *  length,
ZyanU64  runtime_address 
)

Encodes instruction with semantics specified in encoder request structure.

This function expects absolute addresses inside encoder request instead of EIP/RIP-relative values. Function predicts final instruction length prior to encoding and writes back calculated relative operands to provided encoder request.

Parameters
requestA pointer to the ZydisEncoderRequest struct.
bufferA pointer to the output buffer receiving encoded instruction.
lengthA pointer to the variable containing length of the output buffer. Upon successful return this variable receives length of the encoded instruction.
runtime_addressThe runtime address of the instruction.
Returns
A zyan status code.

◆ ZydisEncoderNopFill()

ZYDIS_EXPORT ZyanStatus ZydisEncoderNopFill ( void *  buffer,
ZyanUSize  length 
)

Fills provided buffer with NOP instructions using longest possible multi-byte instructions.

Parameters
bufferA pointer to the output buffer receiving encoded instructions.
lengthSize of the output buffer.
Returns
A zyan status code.