Zydis  master
Formatter

Functions allowing formatting of previously decoded instructions to human readable text. More...

Functions

ZYDIS_EXPORT ZyanStatus ZydisFormatterInit (ZydisFormatter *formatter, ZydisFormatterStyle style)
 Initializes the given ZydisFormatter instance. More...
 
ZYDIS_EXPORT ZyanStatus ZydisFormatterSetProperty (ZydisFormatter *formatter, ZydisFormatterProperty property, ZyanUPointer value)
 Changes the value of the specified formatter property. More...
 
ZYDIS_EXPORT ZyanStatus ZydisFormatterSetHook (ZydisFormatter *formatter, ZydisFormatterFunction type, const void **callback)
 Replaces a formatter function with a custom callback and/or retrieves the currently used function. More...
 
ZYDIS_EXPORT ZyanStatus ZydisFormatterFormatInstruction (const ZydisFormatter *formatter, const ZydisDecodedInstruction *instruction, const ZydisDecodedOperand *operands, ZyanU8 operand_count, char *buffer, ZyanUSize length, ZyanU64 runtime_address, void *user_data)
 Formats the given instruction and writes it into the output buffer. More...
 
ZYDIS_EXPORT ZyanStatus ZydisFormatterFormatOperand (const ZydisFormatter *formatter, const ZydisDecodedInstruction *instruction, const ZydisDecodedOperand *operand, char *buffer, ZyanUSize length, ZyanU64 runtime_address, void *user_data)
 Formats the given operand and writes it into the output buffer. More...
 
ZYDIS_EXPORT ZyanStatus ZydisFormatterTokenizeInstruction (const ZydisFormatter *formatter, const ZydisDecodedInstruction *instruction, const ZydisDecodedOperand *operands, ZyanU8 operand_count, void *buffer, ZyanUSize length, ZyanU64 runtime_address, ZydisFormatterTokenConst **token, void *user_data)
 Tokenizes the given instruction and writes it into the output buffer. More...
 
ZYDIS_EXPORT ZyanStatus ZydisFormatterTokenizeOperand (const ZydisFormatter *formatter, const ZydisDecodedInstruction *instruction, const ZydisDecodedOperand *operand, void *buffer, ZyanUSize length, ZyanU64 runtime_address, ZydisFormatterTokenConst **token, void *user_data)
 Tokenizes the given operand and writes it into the output buffer. More...
 

Detailed Description

Functions allowing formatting of previously decoded instructions to human readable text.

Function Documentation

◆ ZydisFormatterFormatInstruction()

ZYDIS_EXPORT ZyanStatus ZydisFormatterFormatInstruction ( const ZydisFormatter formatter,
const ZydisDecodedInstruction instruction,
const ZydisDecodedOperand operands,
ZyanU8  operand_count,
char *  buffer,
ZyanUSize  length,
ZyanU64  runtime_address,
void *  user_data 
)

Formats the given instruction and writes it into the output buffer.

Parameters
formatterA pointer to the ZydisFormatter instance.
instructionA pointer to the ZydisDecodedInstruction struct.
operandsA pointer to the decoded operands array.
operand_countThe length of the operands array. Must be equal to or greater than the value of instruction->operand_count_visible.
bufferA pointer to the output buffer.
lengthThe length of the output buffer (in characters).
runtime_addressThe runtime address of the instruction or ZYDIS_RUNTIME_ADDRESS_NONE to print relative addresses.
user_dataA pointer to user-defined data which can be used in custom formatter callbacks. Can be ZYAN_NULL.
Returns
A zyan status code.

◆ ZydisFormatterFormatOperand()

ZYDIS_EXPORT ZyanStatus ZydisFormatterFormatOperand ( const ZydisFormatter formatter,
const ZydisDecodedInstruction instruction,
const ZydisDecodedOperand operand,
char *  buffer,
ZyanUSize  length,
ZyanU64  runtime_address,
void *  user_data 
)

Formats the given operand and writes it into the output buffer.

Parameters
formatterA pointer to the ZydisFormatter instance.
instructionA pointer to the ZydisDecodedInstruction struct.
operandA pointer to the ZydisDecodedOperand struct of the operand to format.
bufferA pointer to the output buffer.
lengthThe length of the output buffer (in characters).
runtime_addressThe runtime address of the instruction or ZYDIS_RUNTIME_ADDRESS_NONE to print relative addresses.
user_dataA pointer to user-defined data which can be used in custom formatter callbacks. Can be ZYAN_NULL.
Returns
A zyan status code.

Use ZydisFormatterFormatInstruction or ZydisFormatterFormatInstructionEx to format a complete instruction.

◆ ZydisFormatterInit()

ZYDIS_EXPORT ZyanStatus ZydisFormatterInit ( ZydisFormatter formatter,
ZydisFormatterStyle  style 
)

Initializes the given ZydisFormatter instance.

Parameters
formatterA pointer to the ZydisFormatter instance.
styleThe base formatter style (either AT&T or Intel style).
Returns
A zyan status code.

◆ ZydisFormatterSetHook()

ZYDIS_EXPORT ZyanStatus ZydisFormatterSetHook ( ZydisFormatter formatter,
ZydisFormatterFunction  type,
const void **  callback 
)

Replaces a formatter function with a custom callback and/or retrieves the currently used function.

Parameters
formatterA pointer to the ZydisFormatter instance.
typeThe formatter function-type.
callbackA pointer to a variable that contains the pointer of the callback function and receives the pointer of the currently used function.
Returns
A zyan status code.

Call this function with callback pointing to a ZYAN_NULL value to retrieve the currently used function without replacing it.

This function returns ZYAN_STATUS_INVALID_OPERATION if a function can't be replaced for the current formatter-style.

◆ ZydisFormatterSetProperty()

ZYDIS_EXPORT ZyanStatus ZydisFormatterSetProperty ( ZydisFormatter formatter,
ZydisFormatterProperty  property,
ZyanUPointer  value 
)

Changes the value of the specified formatter property.

Parameters
formatterA pointer to the ZydisFormatter instance.
propertyThe id of the formatter-property.
valueThe new value.
Returns
A zyan status code.

This function returns ZYAN_STATUS_INVALID_OPERATION if a property can't be changed for the current formatter-style.

◆ ZydisFormatterTokenizeInstruction()

ZYDIS_EXPORT ZyanStatus ZydisFormatterTokenizeInstruction ( const ZydisFormatter formatter,
const ZydisDecodedInstruction instruction,
const ZydisDecodedOperand operands,
ZyanU8  operand_count,
void *  buffer,
ZyanUSize  length,
ZyanU64  runtime_address,
ZydisFormatterTokenConst **  token,
void *  user_data 
)

Tokenizes the given instruction and writes it into the output buffer.

Parameters
formatterA pointer to the ZydisFormatter instance.
instructionA pointer to the ZydisDecodedInstruction struct.
operandsA pointer to the decoded operands array.
operand_countThe length of the operands array. Must be equal to or greater than the value of instruction->operand_count_visible.
bufferA pointer to the output buffer.
lengthThe length of the output buffer (in bytes).
runtime_addressThe runtime address of the instruction or ZYDIS_RUNTIME_ADDRESS_NONE to print relative addresses.
tokenReceives a pointer to the first token in the output buffer.
user_dataA pointer to user-defined data which can be used in custom formatter callbacks. Can be ZYAN_NULL.
Returns
A zyan status code.

◆ ZydisFormatterTokenizeOperand()

ZYDIS_EXPORT ZyanStatus ZydisFormatterTokenizeOperand ( const ZydisFormatter formatter,
const ZydisDecodedInstruction instruction,
const ZydisDecodedOperand operand,
void *  buffer,
ZyanUSize  length,
ZyanU64  runtime_address,
ZydisFormatterTokenConst **  token,
void *  user_data 
)

Tokenizes the given operand and writes it into the output buffer.

Parameters
formatterA pointer to the ZydisFormatter instance.
instructionA pointer to the ZydisDecodedInstruction struct.
operandA pointer to the ZydisDecodedOperand struct of the operand to format.
bufferA pointer to the output buffer.
lengthThe length of the output buffer (in bytes).
runtime_addressThe runtime address of the instruction or ZYDIS_RUNTIME_ADDRESS_NONE to print relative addresses.
tokenReceives a pointer to the first token in the output buffer.
user_dataA pointer to user-defined data which can be used in custom formatter callbacks. Can be ZYAN_NULL.
Returns
A zyan status code.

Use ZydisFormatterTokenizeInstruction to tokenize a complete instruction.