Zydis
v2.0.0-alpha2
|
Functions for formatting human-readable instructions. More...
Go to the source code of this file.
Data Structures | |
struct | ZydisFormatter_ |
Defines the ZydisFormatter struct. More... | |
Macros | |
#define | ZYDIS_FMTFLAG_UPPERCASE 0x00000001 |
Formats the instruction in uppercase instead of lowercase. More... | |
#define | ZYDIS_FMTFLAG_FORCE_SEGMENTS 0x00000002 |
Forces the formatter to always print the segment register of memory-operands, instead of ommiting implicit DS/SS segments. More... | |
#define | ZYDIS_FMTFLAG_FORCE_OPERANDSIZE 0x00000004 |
Forces the formatter to always print the size of memory-operands. More... | |
Typedefs | |
typedef uint8_t | ZydisFormatterStyle |
Defines the ZydisFormatterStyle datatype. More... | |
typedef uint32_t | ZydisFormatterFlags |
Defines the ZydisFormatFlags datatype. More... | |
typedef uint8_t | ZydisFormatterAddressFormat |
Defines the ZydisFormatterAddressFormat datatype. More... | |
typedef uint8_t | ZydisFormatterDisplacementFormat |
Defines the ZydisFormatterDisplacementFormat datatype. More... | |
typedef uint8_t | ZydisFormatterImmediateFormat |
Defines the ZydisFormatterImmediateFormat datatype. More... | |
typedef uint8_t | ZydisFormatterHookType |
Defines the ZydisFormatterHookType datatype. More... | |
typedef uint8_t | ZydisDecoratorType |
Defines the ZydisDecoratorType datatype. More... | |
typedef struct ZydisFormatter_ | ZydisFormatter |
typedef ZydisStatus(* | ZydisFormatterNotifyFunc) (const ZydisFormatter *formatter, const ZydisDecodedInstruction *instruction, void *userData) |
Defines the ZydisFormatterNotifyFunc function pointer. More... | |
typedef ZydisStatus(* | ZydisFormatterFormatFunc) (const ZydisFormatter *formatter, char **buffer, size_t bufferLen, const ZydisDecodedInstruction *instruction, void *userData) |
Defines the ZydisFormatterFormatFunc function pointer. More... | |
typedef ZydisStatus(* | ZydisFormatterFormatOperandFunc) (const ZydisFormatter *formatter, char **buffer, size_t bufferLen, const ZydisDecodedInstruction *instruction, const ZydisDecodedOperand *operand, void *userData) |
Defines the ZydisFormatterFormatOperandFunc function pointer. More... | |
typedef ZydisStatus(* | ZydisFormatterFormatAddressFunc) (const ZydisFormatter *formatter, char **buffer, size_t bufferLen, const ZydisDecodedInstruction *instruction, const ZydisDecodedOperand *operand, uint64_t address, void *userData) |
Defines the ZydisFormatterFormatAddressFunc function pointer. More... | |
typedef ZydisStatus(* | ZydisFormatterFormatDecoratorFunc) (const ZydisFormatter *formatter, char **buffer, size_t bufferLen, const ZydisDecodedInstruction *instruction, const ZydisDecodedOperand *operand, ZydisDecoratorType type, void *userData) |
Defines the ZydisFormatterFormatDecoratorFunc function pointer. More... | |
Functions | |
ZYDIS_EXPORT ZydisStatus | ZydisFormatterInit (ZydisFormatter *formatter, ZydisFormatterStyle style) |
Initializes the given ZydisFormatter instance. More... | |
ZYDIS_EXPORT ZydisStatus | ZydisFormatterInitEx (ZydisFormatter *formatter, ZydisFormatterStyle style, ZydisFormatterFlags flags, ZydisFormatterAddressFormat addressFormat, ZydisFormatterDisplacementFormat displacementFormat, ZydisFormatterImmediateFormat immmediateFormat) |
Initializes the given ZydisFormatter instance. 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, ZydisDecodedInstruction *instruction, char *buffer, size_t bufferLen) |
Formats the given instruction and writes it into the output buffer. More... | |
ZYDIS_EXPORT ZydisStatus | ZydisFormatterFormatInstructionEx (const ZydisFormatter *formatter, ZydisDecodedInstruction *instruction, char *buffer, size_t bufferLen, void *userData) |
Formats the given instruction and writes it into the output buffer. More... | |
Functions for formatting human-readable instructions.
#define ZYDIS_FMTFLAG_FORCE_OPERANDSIZE 0x00000004 |
Forces the formatter to always print the size of memory-operands.
#define ZYDIS_FMTFLAG_FORCE_SEGMENTS 0x00000002 |
Forces the formatter to always print the segment register of memory-operands, instead of ommiting implicit DS/SS segments.
#define ZYDIS_FMTFLAG_UPPERCASE 0x00000001 |
Formats the instruction in uppercase instead of lowercase.
typedef uint8_t ZydisDecoratorType |
Defines the ZydisDecoratorType
datatype.
typedef struct ZydisFormatter_ ZydisFormatter |
typedef uint8_t ZydisFormatterAddressFormat |
Defines the ZydisFormatterAddressFormat
datatype.
typedef uint8_t ZydisFormatterDisplacementFormat |
Defines the ZydisFormatterDisplacementFormat
datatype.
typedef uint32_t ZydisFormatterFlags |
Defines the ZydisFormatFlags
datatype.
typedef ZydisStatus(* ZydisFormatterFormatAddressFunc) (const ZydisFormatter *formatter, char **buffer, size_t bufferLen, const ZydisDecodedInstruction *instruction, const ZydisDecodedOperand *operand, uint64_t address, void *userData) |
Defines the ZydisFormatterFormatAddressFunc
function pointer.
formatter | A pointer to the ZydisFormatter instance. |
buffer | A pointer to the string-buffer. |
bufferLen | The length of the string-buffer. |
instruction | A pointer to the ZydisDecodedInstruction struct. |
operand | A pointer to the ZydisDecodedOperand struct. |
userData | A pointer to user-defined data. |
ZYDIS_STATUS_SUCCESS
will immediately cause the formatting process to fail.After appending text to the buffer
you MUST increase the buffer-pointer by the size of the number of chars written. Not increasing the buffer-pointer will cause unexpected behavior.
This function type is used for the ZYDIS_FORMATTER_HOOK_PRINT_ADDRESS
hook-type.
typedef ZydisStatus(* ZydisFormatterFormatDecoratorFunc) (const ZydisFormatter *formatter, char **buffer, size_t bufferLen, const ZydisDecodedInstruction *instruction, const ZydisDecodedOperand *operand, ZydisDecoratorType type, void *userData) |
Defines the ZydisFormatterFormatDecoratorFunc
function pointer.
formatter | A pointer to the ZydisFormatter instance. |
buffer | A pointer to the string-buffer. |
bufferLen | The length of the string-buffer. |
instruction | A pointer to the ZydisDecodedInstruction struct. |
operand | A pointer to the ZydisDecodedOperand struct. |
type | The decorator type. |
userData | A pointer to user-defined data. |
ZYDIS_STATUS_SUCCESS
will immediately cause the formatting process to fail.After appending text to the buffer
you MUST increase the buffer-pointer by the size of the number of chars written.
Returning ZYDIS_STATUS_SUCCESS
without increasing the buffer-pointer is valid and will cause the formatter to omit the current decorator.
This function type is used for the ZYDIS_FORMATTER_HOOK_PRINT_DECORATOR
hook-type.
typedef ZydisStatus(* ZydisFormatterFormatFunc) (const ZydisFormatter *formatter, char **buffer, size_t bufferLen, const ZydisDecodedInstruction *instruction, void *userData) |
Defines the ZydisFormatterFormatFunc
function pointer.
formatter | A pointer to the ZydisFormatter instance. |
buffer | A pointer to the string-buffer. |
bufferLen | The length of the string-buffer. |
instruction | A pointer to the ZydisDecodedInstruction struct. |
userData | A pointer to user-defined data. |
ZYDIS_STATUS_SUCCESS
will immediately cause the formatting process to fail.After appending text to the buffer
you MUST increase the buffer-pointer by the size of the number of chars written. Not increasing the buffer-pointer will cause unexpected behavior.
This function type is used for the ZYDIS_FORMATTER_HOOK_FORMAT_INSTRUCTION
, ZYDIS_FORMATTER_HOOK_PRINT_PREFIXES
and ZYDIS_FORMATTER_HOOK_PRINT_MNEMONIC
hook-types.
typedef ZydisStatus(* ZydisFormatterFormatOperandFunc) (const ZydisFormatter *formatter, char **buffer, size_t bufferLen, const ZydisDecodedInstruction *instruction, const ZydisDecodedOperand *operand, void *userData) |
Defines the ZydisFormatterFormatOperandFunc
function pointer.
formatter | A pointer to the ZydisFormatter instance. |
buffer | A pointer to the string-buffer. |
bufferLen | The length of the string-buffer. |
instruction | A pointer to the ZydisDecodedInstruction struct. |
operand | A pointer to the ZydisDecodedOperand struct. |
userData | A pointer to user-defined data. |
ZYDIS_STATUS_SUCCESS
will immediately cause the formatting process to fail.After appending text to the buffer
you MUST increase the buffer-pointer by the size of the number of chars written.
Returning ZYDIS_STATUS_SUCCESS
in one of the ZYDIS_FORMATTER_HOOK_FORMAT_OPERAND_X
hooks without increasing the buffer-pointer is valid and will cause the formatter to omit the current operand.
Returning ZYDIS_STATUS_SUCCESS
in ZYDIS_FORMATTER_HOOK_PRINT_OPERANDSIZE
, ZYDIS_FORMATTER_HOOK_PRINT_SEGMENT
or ZYDIS_FORMATTER_HOOK_PRINT_DECORATOR
without increasing the buffer-pointer is valid and signals that the corresponding element should not be printed for the current operand.
Not increasing the buffer-pointer for any other hook-type will cause unexpected behavior.
This function type is used for the 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_OPERANDSIZE
, ZYDIS_FORMATTER_HOOK_PRINT_SEGMENT
, ZYDIS_FORMATTER_HOOK_PRINT_DECORATOR
, ZYDIS_FORMATTER_HOOK_PRINT_DISPLACEMENT
and ZYDIS_FORMATTER_HOOK_PRINT_IMMEDIATE
hook-types.
typedef uint8_t ZydisFormatterHookType |
Defines the ZydisFormatterHookType
datatype.
typedef uint8_t ZydisFormatterImmediateFormat |
Defines the ZydisFormatterImmediateFormat
datatype.
typedef ZydisStatus(* ZydisFormatterNotifyFunc) (const ZydisFormatter *formatter, const ZydisDecodedInstruction *instruction, void *userData) |
Defines the ZydisFormatterNotifyFunc
function pointer.
formatter | A pointer to the ZydisFormatter instance. |
instruction | A pointer to the ZydisDecodedInstruction struct. |
userData | A pointer to user-defined data. |
ZYDIS_STATUS_SUCCESS
will immediately cause the formatting process to fail.This function type is used for the ZYDIS_FORMATTER_HOOK_PRE
and ZYDIS_FORMATTER_HOOK_POST
hook-types.
typedef uint8_t ZydisFormatterStyle |
Defines the ZydisFormatterStyle
datatype.
enum ZydisDecoratorTypes |
Values that represent decorator-types.
Values that represent address-formats.
Values that represent displacement-formats.
Values that represent formatter hook-types.
Values that represent formatter immediate-formats.
enum ZydisFormatterStyles |
ZYDIS_EXPORT ZydisStatus ZydisFormatterFormatInstruction | ( | const ZydisFormatter * | formatter, |
ZydisDecodedInstruction * | instruction, | ||
char * | buffer, | ||
size_t | 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, |
ZydisDecodedInstruction * | instruction, | ||
char * | buffer, | ||
size_t | 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 ZydisFormatterInit | ( | ZydisFormatter * | formatter, |
ZydisFormatterStyle | style | ||
) |
Initializes the given ZydisFormatter
instance.
formatter | A pointer to the ZydisFormatter instance. |
style | The formatter style. |
ZYDIS_EXPORT ZydisStatus ZydisFormatterInitEx | ( | ZydisFormatter * | formatter, |
ZydisFormatterStyle | style, | ||
ZydisFormatterFlags | flags, | ||
ZydisFormatterAddressFormat | addressFormat, | ||
ZydisFormatterDisplacementFormat | displacementFormat, | ||
ZydisFormatterImmediateFormat | immmediateFormat | ||
) |
Initializes the given ZydisFormatter
instance.
formatter | A pointer to the ZydisFormatter instance. |
style | The formatter style. |
addressFormat | The address format. |
displacementFormat | The displacement format. |
immmediateFormat | The immediate format. |
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.