Zydis
v2.0.0
|
Functions for formatting human-readable instructions. More...
#include <Zydis/DecoderTypes.h>
#include <Zydis/Defines.h>
#include <Zydis/Status.h>
#include <Zydis/String.h>
Go to the source code of this file.
Data Structures | |
struct | ZydisFormatter_ |
Defines the ZydisFormatter struct. More... | |
Typedefs | |
typedef ZydisU8 | ZydisFormatterStyle |
Defines the ZydisFormatterStyle datatype. More... | |
typedef ZydisU8 | ZydisFormatterProperty |
Defines the ZydisFormatterProperty datatype. More... | |
typedef ZydisU8 | ZydisFormatterHookType |
Defines the ZydisFormatterHookType datatype. More... | |
typedef ZydisU8 | ZydisDecoratorType |
Defines the ZydisDecoratorType datatype. More... | |
typedef struct ZydisFormatter_ | ZydisFormatter |
typedef ZydisStatus(* | ZydisFormatterFunc) (const ZydisFormatter *formatter, ZydisString *string, const ZydisDecodedInstruction *instruction, void *userData) |
Defines the ZydisFormatterFunc function pointer. More... | |
typedef ZydisStatus(* | ZydisFormatterOperandFunc) (const ZydisFormatter *formatter, ZydisString *string, const ZydisDecodedInstruction *instruction, const ZydisDecodedOperand *operand, void *userData) |
Defines the ZydisFormatterOperandFunc function pointer. More... | |
typedef ZydisStatus(* | ZydisFormatterRegisterFunc) (const ZydisFormatter *formatter, ZydisString *string, const ZydisDecodedInstruction *instruction, const ZydisDecodedOperand *operand, ZydisRegister reg, void *userData) |
Defines the ZydisFormatterRegisterFunc function pointer. More... | |
typedef ZydisStatus(* | ZydisFormatterAddressFunc) (const ZydisFormatter *formatter, ZydisString *string, const ZydisDecodedInstruction *instruction, const ZydisDecodedOperand *operand, ZydisU64 address, void *userData) |
Defines the ZydisFormatterAddressFunc function pointer. More... | |
typedef ZydisStatus(* | ZydisFormatterDecoratorFunc) (const ZydisFormatter *formatter, ZydisString *string, const ZydisDecodedInstruction *instruction, const ZydisDecodedOperand *operand, ZydisDecoratorType decorator, void *userData) |
Defines the ZydisFormatterDecoratorFunc function pointer. More... | |
Functions | |
ZYDIS_EXPORT ZydisStatus | ZydisFormatterInit (ZydisFormatter *formatter, ZydisFormatterStyle style) |
Initializes the given ZydisFormatter instance. More... | |
ZYDIS_EXPORT ZydisStatus | ZydisFormatterSetProperty (ZydisFormatter *formatter, ZydisFormatterProperty property, ZydisUPointer value) |
Sets the value of the specified formatter attribute . More... | |
ZYDIS_EXPORT ZydisStatus | ZydisFormatterSetHook (ZydisFormatter *formatter, ZydisFormatterHookType hook, const void **callback) |
Replaces a formatter function with a custom callback and/or retrieves the currently used function. More... | |
ZYDIS_EXPORT ZydisStatus | ZydisFormatterFormatInstruction (const ZydisFormatter *formatter, const ZydisDecodedInstruction *instruction, char *buffer, ZydisUSize bufferLen) |
Formats the given instruction and writes it into the output buffer. More... | |
ZYDIS_EXPORT ZydisStatus | ZydisFormatterFormatInstructionEx (const ZydisFormatter *formatter, const ZydisDecodedInstruction *instruction, char *buffer, ZydisUSize bufferLen, void *userData) |
Formats the given instruction and writes it into the output buffer. More... | |
ZYDIS_EXPORT ZydisStatus | ZydisFormatterFormatOperand (const ZydisFormatter *formatter, const ZydisDecodedInstruction *instruction, ZydisU8 index, char *buffer, ZydisUSize bufferLen) |
Formats the given operand and writes it into the output buffer. More... | |
ZYDIS_EXPORT ZydisStatus | ZydisFormatterFormatOperandEx (const ZydisFormatter *formatter, const ZydisDecodedInstruction *instruction, ZydisU8 index, char *buffer, ZydisUSize bufferLen, void *userData) |
Formats the given operand and writes it into the output buffer. More... | |
Functions for formatting human-readable instructions.
typedef ZydisU8 ZydisDecoratorType |
Defines the ZydisDecoratorType
datatype.
typedef struct ZydisFormatter_ ZydisFormatter |
typedef ZydisStatus(* ZydisFormatterAddressFunc) (const ZydisFormatter *formatter, ZydisString *string, const ZydisDecodedInstruction *instruction, const ZydisDecodedOperand *operand, ZydisU64 address, void *userData) |
Defines the ZydisFormatterAddressFunc
function pointer.
formatter | A pointer to the ZydisFormatter instance. |
string | A pointer to the string. |
instruction | A pointer to the ZydisDecodedInstruction struct. |
operand | A pointer to the ZydisDecodedOperand struct. |
address | The address. |
userData | A pointer to user-defined data. |
ZYDIS_STATUS_SUCCESS
will immediately cause the formatting process to fail.This function type is used for:
ZYDIS_FORMATTER_HOOK_PRINT_ADDRESS
typedef ZydisStatus(* ZydisFormatterDecoratorFunc) (const ZydisFormatter *formatter, ZydisString *string, const ZydisDecodedInstruction *instruction, const ZydisDecodedOperand *operand, ZydisDecoratorType decorator, void *userData) |
Defines the ZydisFormatterDecoratorFunc
function pointer.
formatter | A pointer to the ZydisFormatter instance. |
string | A pointer to the string. |
instruction | A pointer to the ZydisDecodedInstruction struct. |
operand | A pointer to the ZydisDecodedOperand struct. |
decorator | The decorator type. |
userData | A pointer to user-defined data. |
ZYDIS_STATUS_SUCCESS
will immediately cause the formatting process to fail.This function type is used for:
ZYDIS_FORMATTER_HOOK_PRINT_DECORATOR
typedef ZydisStatus(* ZydisFormatterFunc) (const ZydisFormatter *formatter, ZydisString *string, const ZydisDecodedInstruction *instruction, void *userData) |
Defines the ZydisFormatterFunc
function pointer.
formatter | A pointer to the ZydisFormatter instance. |
string | A pointer to the string. |
instruction | A pointer to the ZydisDecodedInstruction struct. |
userData | A pointer to user-defined data. |
Returning a status code other than ZYDIS_STATUS_SUCCESS
will immediately cause the formatting process to fail.
This function type is used for:
ZYDIS_FORMATTER_HOOK_PRE_INSTRUCTION
ZYDIS_FORMATTER_HOOK_POST_INSTRUCTION
ZYDIS_FORMATTER_HOOK_FORMAT_INSTRUCTION
ZYDIS_FORMATTER_HOOK_PRINT_MNEMONIC
ZYDIS_FORMATTER_HOOK_PRINT_PREFIXES
typedef ZydisU8 ZydisFormatterHookType |
Defines the ZydisFormatterHookType
datatype.
typedef ZydisStatus(* ZydisFormatterOperandFunc) (const ZydisFormatter *formatter, ZydisString *string, const ZydisDecodedInstruction *instruction, const ZydisDecodedOperand *operand, void *userData) |
Defines the ZydisFormatterOperandFunc
function pointer.
formatter | A pointer to the ZydisFormatter instance. |
string | A pointer to the string. |
instruction | A pointer to the ZydisDecodedInstruction struct. |
operand | A pointer to the ZydisDecodedOperand struct. |
userData | A pointer to user-defined data. |
Returning a status code other than ZYDIS_STATUS_SUCCESS
will immediately cause the formatting process to fail (see exceptions below).
Returning ZYDIS_STATUS_SKIP_OPERAND
is valid for ZYDIS_FORMATTER_HOOK_PRE_OPERAND
, ZYDIS_FORMATTER_HOOK_POST_OPERAND
and all of the ZYDIS_FORMATTER_HOOK_FORMAT_OPERAND_XXX
callbacks. This will cause the formatter to omit the current operand.
DEPRECATED: Returning ZYDIS_STATUS_SUCCESS
without writing to the string is valid for ZYDIS_FORMATTER_HOOK_PRE_OPERAND
, ZYDIS_FORMATTER_HOOK_POST_OPERAND
and all of the ZYDIS_FORMATTER_HOOK_FORMAT_OPERAND_XXX
. This will cause the formatter to omit the current operand.
This function type is used for:
ZYDIS_FORMATTER_HOOK_PRE_OPERAND
ZYDIS_FORMATTER_HOOK_POST_OPERAND
ZYDIS_FORMATTER_HOOK_FORMAT_OPERAND_REG
ZYDIS_FORMATTER_HOOK_FORMAT_OPERAND_MEM
ZYDIS_FORMATTER_HOOK_FORMAT_OPERAND_PTR
ZYDIS_FORMATTER_HOOK_FORMAT_OPERAND_IMM
ZYDIS_FORMATTER_HOOK_PRINT_DISP
ZYDIS_FORMATTER_HOOK_PRINT_IMM
ZYDIS_FORMATTER_HOOK_PRINT_MEMSIZE
typedef ZydisU8 ZydisFormatterProperty |
Defines the ZydisFormatterProperty
datatype.
typedef ZydisStatus(* ZydisFormatterRegisterFunc) (const ZydisFormatter *formatter, ZydisString *string, const ZydisDecodedInstruction *instruction, const ZydisDecodedOperand *operand, ZydisRegister reg, void *userData) |
Defines the ZydisFormatterRegisterFunc
function pointer.
formatter | A pointer to the ZydisFormatter instance. |
string | A pointer to the string. |
instruction | A pointer to the ZydisDecodedInstruction struct. |
operand | A pointer to the ZydisDecodedOperand struct. |
reg | The register. |
userData | A pointer to user-defined data. |
ZYDIS_STATUS_SUCCESS
will immediately cause the formatting process to fail.This function type is used for:
ZYDIS_FORMATTER_HOOK_PRINT_REGISTER
. typedef ZydisU8 ZydisFormatterStyle |
Defines the ZydisFormatterStyle
datatype.
enum ZydisAddressFormat |
Values that represent address-formats.
enum ZydisDecoratorTypes |
Values that represent decorator-types.
Values that represent displacement-formats.
Values that represent formatter hook-types.
Values that represent formatter-properties.
enum ZydisFormatterStyles |
enum ZydisImmediateFormat |
Values that represent formatter immediate-formats.
ZYDIS_EXPORT ZydisStatus ZydisFormatterFormatInstruction | ( | const ZydisFormatter * | formatter, |
const ZydisDecodedInstruction * | instruction, | ||
char * | buffer, | ||
ZydisUSize | bufferLen | ||
) |
Formats the given instruction and writes it into the output buffer.
formatter | A pointer to the ZydisFormatter instance. |
instruction | A pointer to the ZydisDecodedInstruction struct. |
buffer | A pointer to the output buffer. |
bufferLen | The length of the output buffer. |
ZYDIS_EXPORT ZydisStatus ZydisFormatterFormatInstructionEx | ( | const ZydisFormatter * | formatter, |
const ZydisDecodedInstruction * | instruction, | ||
char * | buffer, | ||
ZydisUSize | bufferLen, | ||
void * | userData | ||
) |
Formats the given instruction and writes it into the output buffer.
formatter | A pointer to the ZydisFormatter instance. |
instruction | A pointer to the ZydisDecodedInstruction struct. |
buffer | A pointer to the output buffer. |
bufferLen | The length of the output buffer. |
userData | A pointer to user-defined data which can be used in custom formatter callbacks. |
ZYDIS_EXPORT ZydisStatus ZydisFormatterFormatOperand | ( | const ZydisFormatter * | formatter, |
const ZydisDecodedInstruction * | instruction, | ||
ZydisU8 | index, | ||
char * | buffer, | ||
ZydisUSize | bufferLen | ||
) |
Formats the given operand and writes it into the output buffer.
formatter | A pointer to the ZydisFormatter instance. |
instruction | A pointer to the ZydisDecodedInstruction struct. |
index | The index of the operand to format. |
buffer | A pointer to the output buffer. |
bufferLen | The length of the output buffer. |
Use ZydisFormatterFormatInstruction
or ZydisFormatterFormatInstructionEx
to format a complete instruction.
ZYDIS_EXPORT ZydisStatus ZydisFormatterFormatOperandEx | ( | const ZydisFormatter * | formatter, |
const ZydisDecodedInstruction * | instruction, | ||
ZydisU8 | index, | ||
char * | buffer, | ||
ZydisUSize | bufferLen, | ||
void * | userData | ||
) |
Formats the given operand and writes it into the output buffer.
formatter | A pointer to the ZydisFormatter instance. |
instruction | A pointer to the ZydisDecodedInstruction struct. |
index | The index of the operand to format. |
buffer | A pointer to the output buffer. |
bufferLen | The length of the output buffer. |
userData | A pointer to user-defined data which can be used in custom formatter callbacks. |
Use ZydisFormatterFormatInstruction
or ZydisFormatterFormatInstructionEx
to format a complete instruction.
ZYDIS_EXPORT ZydisStatus ZydisFormatterInit | ( | ZydisFormatter * | formatter, |
ZydisFormatterStyle | style | ||
) |
Initializes the given ZydisFormatter
instance.
formatter | A pointer to the ZydisFormatter instance. |
style | The formatter style. |
ZYDIS_EXPORT ZydisStatus ZydisFormatterSetHook | ( | ZydisFormatter * | formatter, |
ZydisFormatterHookType | hook, | ||
const void ** | callback | ||
) |
Replaces a formatter function with a custom callback and/or retrieves the currently used function.
formatter | A pointer to the ZydisFormatter instance. |
hook | The formatter hook-type. |
callback | A pointer to a variable that contains the pointer of the callback function and receives the pointer of the currently used function. |
Call this function with callback
pointing to a NULL
value to retrieve the currently used function without replacing it.
ZYDIS_EXPORT ZydisStatus ZydisFormatterSetProperty | ( | ZydisFormatter * | formatter, |
ZydisFormatterProperty | property, | ||
ZydisUPointer | value | ||
) |
Sets the value of the specified formatter attribute
.
formatter | A pointer to the ZydisFormatter instance. |
property | The id of the formatter-property. |
value | The new value. |