mirror of https://github.com/x64dbg/zydis
Refactorings
This commit is contained in:
parent
6ce34bd141
commit
87c9155207
33
README.md
33
README.md
|
@ -37,29 +37,26 @@ int main()
|
||||||
0x88, 0xFC, 0xDA, 0x02, 0x00
|
0x88, 0xFC, 0xDA, 0x02, 0x00
|
||||||
};
|
};
|
||||||
|
|
||||||
ZydisMemoryInput input;
|
ZydisDecoder decoder;
|
||||||
ZydisInputInitMemoryInput(&input, &data, sizeof(data));
|
ZydisDecoderInit(&decoder, ZYDIS_MACHINE_MODE_LONG_64, ZYDIS_ADDRESS_WIDTH_64);
|
||||||
|
|
||||||
ZydisInstructionDecoder decoder;
|
ZydisFormatter formatter;
|
||||||
ZydisDecoderInitInstructionDecoderEx(&decoder, ZYDIS_DISASSEMBLER_MODE_64BIT,
|
ZydisFormatterInitEx(&formatter, ZYDIS_FORMATTER_STYLE_INTEL,
|
||||||
(ZydisCustomInput*)&input, ZYDIS_DECODER_FLAG_SKIP_DATA);
|
ZYDIS_FMTFLAG_FORCE_SEGMENTS | ZYDIS_FMTFLAG_FORCE_OPERANDSIZE,
|
||||||
ZydisDecoderSetInstructionPointer(&decoder, 0x007FFFFFFF400000);
|
ZYDIS_FORMATTER_ADDR_ABSOLUTE, ZYDIS_FORMATTER_DISP_DEFAULT, ZYDIS_FORMATTER_IMM_DEFAULT);
|
||||||
|
|
||||||
ZydisInstructionFormatter formatter;
|
uint64_t instructionPointer = 0x007FFFFFFF400000;
|
||||||
ZydisFormatterInitInstructionFormatterEx(&formatter,
|
|
||||||
ZYDIS_FORMATTER_STYLE_INTEL, ZYDIS_FORMATTER_FLAG_ALWAYS_DISPLAY_MEMORY_SEGMENT);
|
|
||||||
|
|
||||||
ZydisInstructionInfo info;
|
ZydisDecodedInstruction instruction;
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
while (ZYDIS_SUCCESS(ZydisDecoderDecodeNextInstruction(&decoder, &info)))
|
while (ZYDIS_SUCCESS(
|
||||||
|
ZydisDecoderDecodeBuffer(decoder, data, length, instructionPointer, &instruction)))
|
||||||
{
|
{
|
||||||
printf("%016llX ", info.instrAddress);
|
data += instruction.length;
|
||||||
if (info.flags & ZYDIS_IFLAG_ERROR_MASK)
|
length -= instruction.length;
|
||||||
{
|
instructionPointer += instruction.length;
|
||||||
printf(" db %02x\n", info.data[0]);
|
printf("%016" PRIX64 " ", instruction.instrAddress);
|
||||||
continue;
|
ZydisFormatterFormatInstruction(&formatter, &instruction, &buffer[0], sizeof(buffer));
|
||||||
}
|
|
||||||
ZydisFormatterFormatInstruction(&formatter, &info, &buffer[0], sizeof(buffer));
|
|
||||||
printf(" %s\n", &buffer[0]);
|
printf(" %s\n", &buffer[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,9 +26,9 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file
|
* @file
|
||||||
* @brief Demonstrates the hooking functionality of the @c ZydisInstructionFormatter class.
|
* @brief Demonstrates the hooking functionality of the @c ZydisFormatter class.
|
||||||
*
|
*
|
||||||
* This example demonstrates the hooking functionality of the @c ZydisInstructionFormatter class by
|
* This example demonstrates the hooking functionality of the @c ZydisFormatter class by
|
||||||
* rewriting the mnemonics of (V)CMPPS and (V)CMPPD to their corresponding alias-forms (based on
|
* rewriting the mnemonics of (V)CMPPS and (V)CMPPD to their corresponding alias-forms (based on
|
||||||
* the condition encoded in the immediate operand).
|
* the condition encoded in the immediate operand).
|
||||||
*/
|
*/
|
||||||
|
@ -87,7 +87,7 @@ static const char* conditionCodeStrings[0x20] =
|
||||||
|
|
||||||
ZydisFormatterFormatFunc defaultPrintMnemonic;
|
ZydisFormatterFormatFunc defaultPrintMnemonic;
|
||||||
|
|
||||||
static ZydisStatus ZydisFormatterPrintMnemonic(const ZydisInstructionFormatter* formatter,
|
static ZydisStatus ZydisFormatterPrintMnemonic(const ZydisFormatter* formatter,
|
||||||
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction)
|
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction)
|
||||||
{
|
{
|
||||||
// We use the user-data field of the instruction-info to pass data to the
|
// We use the user-data field of the instruction-info to pass data to the
|
||||||
|
@ -152,7 +152,7 @@ static ZydisStatus ZydisFormatterPrintMnemonic(const ZydisInstructionFormatter*
|
||||||
|
|
||||||
ZydisFormatterFormatOperandFunc defaultFormatOperandImm;
|
ZydisFormatterFormatOperandFunc defaultFormatOperandImm;
|
||||||
|
|
||||||
static ZydisStatus ZydisFormatterFormatOperandImm(const ZydisInstructionFormatter* formatter,
|
static ZydisStatus ZydisFormatterFormatOperandImm(const ZydisFormatter* formatter,
|
||||||
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction,
|
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction,
|
||||||
ZydisDecodedOperand* operand)
|
ZydisDecodedOperand* operand)
|
||||||
{
|
{
|
||||||
|
@ -175,11 +175,10 @@ static ZydisStatus ZydisFormatterFormatOperandImm(const ZydisInstructionFormatte
|
||||||
/* Helper functions */
|
/* Helper functions */
|
||||||
/* ============================================================================================== */
|
/* ============================================================================================== */
|
||||||
|
|
||||||
void disassembleBuffer(ZydisInstructionDecoder* decoder, uint8_t* data, size_t length,
|
void disassembleBuffer(ZydisDecoder* decoder, uint8_t* data, size_t length, ZydisBool installHooks)
|
||||||
ZydisBool installHooks)
|
|
||||||
{
|
{
|
||||||
ZydisInstructionFormatter formatter;
|
ZydisFormatter formatter;
|
||||||
ZydisFormatterInitInstructionFormatterEx(&formatter, ZYDIS_FORMATTER_STYLE_INTEL,
|
ZydisFormatterInitEx(&formatter, ZYDIS_FORMATTER_STYLE_INTEL,
|
||||||
ZYDIS_FMTFLAG_FORCE_SEGMENTS | ZYDIS_FMTFLAG_FORCE_OPERANDSIZE,
|
ZYDIS_FMTFLAG_FORCE_SEGMENTS | ZYDIS_FMTFLAG_FORCE_OPERANDSIZE,
|
||||||
ZYDIS_FORMATTER_ADDR_ABSOLUTE, ZYDIS_FORMATTER_DISP_DEFAULT, ZYDIS_FORMATTER_IMM_DEFAULT);
|
ZYDIS_FORMATTER_ADDR_ABSOLUTE, ZYDIS_FORMATTER_DISP_DEFAULT, ZYDIS_FORMATTER_IMM_DEFAULT);
|
||||||
|
|
||||||
|
@ -215,6 +214,7 @@ void disassembleBuffer(ZydisInstructionDecoder* decoder, uint8_t* data, size_t l
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|
||||||
uint8_t data[] =
|
uint8_t data[] =
|
||||||
{
|
{
|
||||||
// cmpps xmm1, xmm4, 0x03
|
// cmpps xmm1, xmm4, 0x03
|
||||||
|
@ -227,10 +227,8 @@ int main()
|
||||||
0x62, 0xF1, 0x6C, 0x5F, 0xC2, 0x54, 0x98, 0x40, 0x0F
|
0x62, 0xF1, 0x6C, 0x5F, 0xC2, 0x54, 0x98, 0x40, 0x0F
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ZydisDecoder decoder;
|
||||||
ZydisInstructionDecoder decoder;
|
ZydisDecoderInit(&decoder, ZYDIS_MACHINE_MODE_LONG_64, ZYDIS_ADDRESS_WIDTH_64);
|
||||||
ZydisDecoderInitInstructionDecoder(
|
|
||||||
&decoder, ZYDIS_MACHINE_MODE_LONG_64, ZYDIS_ADDRESS_WIDTH_64);
|
|
||||||
|
|
||||||
disassembleBuffer(&decoder, &data[0], sizeof(data), ZYDIS_FALSE);
|
disassembleBuffer(&decoder, &data[0], sizeof(data), ZYDIS_FALSE);
|
||||||
puts("");
|
puts("");
|
||||||
|
|
|
@ -59,14 +59,14 @@ enum ZydisDecodeGranularities
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Defines the @c ZydisInstructionDecoder datatype.
|
* @brief Defines the @c ZydisDecoder datatype.
|
||||||
*/
|
*/
|
||||||
typedef struct ZydisInstructionDecoder_
|
typedef struct ZydisDecoder_
|
||||||
{
|
{
|
||||||
ZydisMachineMode machineMode;
|
ZydisMachineMode machineMode;
|
||||||
ZydisAddressWidth addressWidth;
|
ZydisAddressWidth addressWidth;
|
||||||
ZydisDecodeGranularity decodeGranularity;
|
ZydisDecodeGranularity decodeGranularity;
|
||||||
} ZydisInstructionDecoder;
|
} ZydisDecoder;
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
@ -75,35 +75,34 @@ typedef struct ZydisInstructionDecoder_
|
||||||
/* ============================================================================================== */
|
/* ============================================================================================== */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initializes the given @c ZydisInstructionDecoder instance.
|
* @brief Initializes the given @c ZydisDecoder instance.
|
||||||
*
|
*
|
||||||
* @param decoder A pointer to the @c ZydisInstructionDecoder instance.
|
* @param decoder A pointer to the @c ZydisDecoder instance.
|
||||||
* @param machineMode The machine mode.
|
* @param machineMode The machine mode.
|
||||||
* @param addressWidth The address width.
|
* @param addressWidth The address width.
|
||||||
*
|
*
|
||||||
* @return A zydis status code.
|
* @return A zydis status code.
|
||||||
*/
|
*/
|
||||||
ZYDIS_EXPORT ZydisStatus ZydisDecoderInitInstructionDecoder(ZydisInstructionDecoder* decoder,
|
ZYDIS_EXPORT ZydisStatus ZydisDecoderInit(ZydisDecoder* decoder, ZydisMachineMode machineMode,
|
||||||
ZydisMachineMode machineMode, ZydisAddressWidth addressWidth);
|
ZydisAddressWidth addressWidth);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initializes the given @c ZydisInstructionDecoder instance.
|
* @brief Initializes the given @c ZydisDecoder instance.
|
||||||
*
|
*
|
||||||
* @param decoder A pointer to the @c ZydisInstructionDecoder instance.
|
* @param decoder A pointer to the @c ZydisDecoder instance.
|
||||||
* @param machineMode The machine mode.
|
* @param machineMode The machine mode.
|
||||||
* @param addressWidth The address width.
|
* @param addressWidth The address width.
|
||||||
* @param decodeGranularity The decode granularity.
|
* @param decodeGranularity The decode granularity.
|
||||||
*
|
*
|
||||||
* @return A zydis status code.
|
* @return A zydis status code.
|
||||||
*/
|
*/
|
||||||
ZYDIS_EXPORT ZydisStatus ZydisDecoderInitInstructionDecoderEx(ZydisInstructionDecoder* decoder,
|
ZYDIS_EXPORT ZydisStatus ZydisDecoderInitEx(ZydisDecoder* decoder, ZydisMachineMode machineMode,
|
||||||
ZydisMachineMode machineMode, ZydisAddressWidth addressWidth,
|
ZydisAddressWidth addressWidth, ZydisDecodeGranularity decodeGranularity);
|
||||||
ZydisDecodeGranularity decodeGranularity);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Decodes the instruction in the given input @c buffer.
|
* @brief Decodes the instruction in the given input @c buffer.
|
||||||
*
|
*
|
||||||
* @param decoder A pointer to the @c ZydisInstructionDecoder instance.
|
* @param decoder A pointer to the @c ZydisDecoder instance.
|
||||||
* @param buffer A pointer to the input buffer.
|
* @param buffer A pointer to the input buffer.
|
||||||
* @param bufferLen The length of the input buffer.
|
* @param bufferLen The length of the input buffer.
|
||||||
* @param instructionPointer The instruction-pointer.
|
* @param instructionPointer The instruction-pointer.
|
||||||
|
@ -112,7 +111,7 @@ ZYDIS_EXPORT ZydisStatus ZydisDecoderInitInstructionDecoderEx(ZydisInstructionDe
|
||||||
*
|
*
|
||||||
* @return A zydis status code.
|
* @return A zydis status code.
|
||||||
*/
|
*/
|
||||||
ZYDIS_EXPORT ZydisStatus ZydisDecoderDecodeBuffer(const ZydisInstructionDecoder* decoder,
|
ZYDIS_EXPORT ZydisStatus ZydisDecoderDecodeBuffer(const ZydisDecoder* decoder,
|
||||||
const void* buffer, size_t bufferLen, uint64_t instructionPointer,
|
const void* buffer, size_t bufferLen, uint64_t instructionPointer,
|
||||||
ZydisDecodedInstruction* instruction);
|
ZydisDecodedInstruction* instruction);
|
||||||
|
|
||||||
|
|
|
@ -277,12 +277,12 @@ enum ZydisFormatterHookTypes
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
typedef struct ZydisInstructionFormatter_ ZydisInstructionFormatter;
|
typedef struct ZydisFormatter_ ZydisFormatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Defines the @c ZydisFormatterNotifyFunc function pointer.
|
* @brief Defines the @c ZydisFormatterNotifyFunc function pointer.
|
||||||
*
|
*
|
||||||
* @param formatter A pointer to the @c ZydisInstructionFormatter instance.
|
* @param formatter A pointer to the @c ZydisFormatter instance.
|
||||||
* @param instruction A pointer to the @c ZydisDecodedInstruction struct.
|
* @param instruction A pointer to the @c ZydisDecodedInstruction struct.
|
||||||
*
|
*
|
||||||
* @return Returning a status code other than @c ZYDIS_STATUS_SUCCESS will immediately cause the
|
* @return Returning a status code other than @c ZYDIS_STATUS_SUCCESS will immediately cause the
|
||||||
|
@ -291,13 +291,13 @@ typedef struct ZydisInstructionFormatter_ ZydisInstructionFormatter;
|
||||||
* This function type is used for the @c ZYDIS_FORMATTER_HOOK_PRE and
|
* This function type is used for the @c ZYDIS_FORMATTER_HOOK_PRE and
|
||||||
* @c ZYDIS_FORMATTER_HOOK_POST hook-types.
|
* @c ZYDIS_FORMATTER_HOOK_POST hook-types.
|
||||||
*/
|
*/
|
||||||
typedef ZydisStatus (*ZydisFormatterNotifyFunc)(const ZydisInstructionFormatter* formatter,
|
typedef ZydisStatus (*ZydisFormatterNotifyFunc)(const ZydisFormatter* formatter,
|
||||||
ZydisDecodedInstruction* instruction);
|
ZydisDecodedInstruction* instruction);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Defines the @c ZydisFormatterFormatFunc function pointer.
|
* @brief Defines the @c ZydisFormatterFormatFunc function pointer.
|
||||||
*
|
*
|
||||||
* @param formatter A pointer to the @c ZydisInstructionFormatter instance.
|
* @param formatter A pointer to the @c ZydisFormatter instance.
|
||||||
* @param buffer A pointer to the string-buffer.
|
* @param buffer A pointer to the string-buffer.
|
||||||
* @param bufferLen The length of the string-buffer.
|
* @param bufferLen The length of the string-buffer.
|
||||||
* @param instruction A pointer to the @c ZydisDecodedInstruction struct.
|
* @param instruction A pointer to the @c ZydisDecodedInstruction struct.
|
||||||
|
@ -311,13 +311,13 @@ typedef ZydisStatus (*ZydisFormatterNotifyFunc)(const ZydisInstructionFormatter*
|
||||||
* This function type is used for the @c ZYDIS_FORMATTER_HOOK_FORMAT_INSTRUCTION,
|
* This function type is used for the @c ZYDIS_FORMATTER_HOOK_FORMAT_INSTRUCTION,
|
||||||
* @c ZYDIS_FORMATTER_HOOK_PRINT_PREFIXES and @c ZYDIS_FORMATTER_HOOK_PRINT_MNEMONIC hook-types.
|
* @c ZYDIS_FORMATTER_HOOK_PRINT_PREFIXES and @c ZYDIS_FORMATTER_HOOK_PRINT_MNEMONIC hook-types.
|
||||||
*/
|
*/
|
||||||
typedef ZydisStatus (*ZydisFormatterFormatFunc)(const ZydisInstructionFormatter* formatter,
|
typedef ZydisStatus (*ZydisFormatterFormatFunc)(const ZydisFormatter* formatter,
|
||||||
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction);
|
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Defines the @c ZydisFormatterFormatOperandFunc function pointer.
|
* @brief Defines the @c ZydisFormatterFormatOperandFunc function pointer.
|
||||||
*
|
*
|
||||||
* @param formatter A pointer to the @c ZydisInstructionFormatter instance.
|
* @param formatter A pointer to the @c ZydisFormatter instance.
|
||||||
* @param buffer A pointer to the string-buffer.
|
* @param buffer A pointer to the string-buffer.
|
||||||
* @param bufferLen The length of the string-buffer.
|
* @param bufferLen The length of the string-buffer.
|
||||||
* @param instruction A pointer to the @c ZydisDecodedInstruction struct.
|
* @param instruction A pointer to the @c ZydisDecodedInstruction struct.
|
||||||
|
@ -347,14 +347,14 @@ typedef ZydisStatus (*ZydisFormatterFormatFunc)(const ZydisInstructionFormatter*
|
||||||
* @c ZYDIS_FORMATTER_HOOK_PRINT_DISPLACEMENT and @c ZYDIS_FORMATTER_HOOK_PRINT_IMMEDIATE
|
* @c ZYDIS_FORMATTER_HOOK_PRINT_DISPLACEMENT and @c ZYDIS_FORMATTER_HOOK_PRINT_IMMEDIATE
|
||||||
* hook-types.
|
* hook-types.
|
||||||
*/
|
*/
|
||||||
typedef ZydisStatus (*ZydisFormatterFormatOperandFunc)(const ZydisInstructionFormatter* formatter,
|
typedef ZydisStatus (*ZydisFormatterFormatOperandFunc)(const ZydisFormatter* formatter,
|
||||||
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction,
|
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction,
|
||||||
ZydisDecodedOperand* operand);
|
ZydisDecodedOperand* operand);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Defines the @c ZydisFormatterFormatAddressFunc function pointer.
|
* @brief Defines the @c ZydisFormatterFormatAddressFunc function pointer.
|
||||||
*
|
*
|
||||||
* @param formatter A pointer to the @c ZydisInstructionFormatter instance.
|
* @param formatter A pointer to the @c ZydisFormatter instance.
|
||||||
* @param buffer A pointer to the string-buffer.
|
* @param buffer A pointer to the string-buffer.
|
||||||
* @param bufferLen The length of the string-buffer.
|
* @param bufferLen The length of the string-buffer.
|
||||||
* @param instruction A pointer to the @c ZydisDecodedInstruction struct.
|
* @param instruction A pointer to the @c ZydisDecodedInstruction struct.
|
||||||
|
@ -369,14 +369,14 @@ typedef ZydisStatus (*ZydisFormatterFormatOperandFunc)(const ZydisInstructionFor
|
||||||
*
|
*
|
||||||
* This function type is used for the @c ZYDIS_FORMATTER_HOOK_PRINT_ADDRESS hook-type.
|
* This function type is used for the @c ZYDIS_FORMATTER_HOOK_PRINT_ADDRESS hook-type.
|
||||||
*/
|
*/
|
||||||
typedef ZydisStatus (*ZydisFormatterFormatAddressFunc)(const ZydisInstructionFormatter* formatter,
|
typedef ZydisStatus (*ZydisFormatterFormatAddressFunc)(const ZydisFormatter* formatter,
|
||||||
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction,
|
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction,
|
||||||
ZydisDecodedOperand* operand, uint64_t address);
|
ZydisDecodedOperand* operand, uint64_t address);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Defines the @c ZydisInstructionFormatter struct.
|
* @brief Defines the @c ZydisFormatter struct.
|
||||||
*/
|
*/
|
||||||
struct ZydisInstructionFormatter_
|
struct ZydisFormatter_
|
||||||
{
|
{
|
||||||
ZydisFormatterFlags flags;
|
ZydisFormatterFlags flags;
|
||||||
ZydisFormatterAddressFormat addressFormat;
|
ZydisFormatterAddressFormat addressFormat;
|
||||||
|
@ -409,20 +409,19 @@ struct ZydisInstructionFormatter_
|
||||||
/* ============================================================================================== */
|
/* ============================================================================================== */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initializes the given @c ZydisInstructionFormatter instance.
|
* @brief Initializes the given @c ZydisFormatter instance.
|
||||||
*
|
*
|
||||||
* @param formatter A pointer to the @c ZydisInstructionFormatter instance.
|
* @param formatter A pointer to the @c ZydisFormatter instance.
|
||||||
* @param style The formatter style.
|
* @param style The formatter style.
|
||||||
*
|
*
|
||||||
* @return A zydis status code.
|
* @return A zydis status code.
|
||||||
*/
|
*/
|
||||||
ZYDIS_EXPORT ZydisStatus ZydisFormatterInitInstructionFormatter(
|
ZYDIS_EXPORT ZydisStatus ZydisFormatterInit(ZydisFormatter* formatter, ZydisFormatterStyle style);
|
||||||
ZydisInstructionFormatter* formatter, ZydisFormatterStyle style);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initializes the given @c ZydisInstructionFormatter instance.
|
* @brief Initializes the given @c ZydisFormatter instance.
|
||||||
*
|
*
|
||||||
* @param formatter A pointer to the @c ZydisInstructionFormatter instance.
|
* @param formatter A pointer to the @c ZydisFormatter instance.
|
||||||
* @param style The formatter style.
|
* @param style The formatter style.
|
||||||
* @param addressFormat The address format.
|
* @param addressFormat The address format.
|
||||||
* @param displacementFormat The displacement format.
|
* @param displacementFormat The displacement format.
|
||||||
|
@ -430,34 +429,34 @@ ZYDIS_EXPORT ZydisStatus ZydisFormatterInitInstructionFormatter(
|
||||||
*
|
*
|
||||||
* @return A zydis status code.
|
* @return A zydis status code.
|
||||||
*/
|
*/
|
||||||
ZYDIS_EXPORT ZydisStatus ZydisFormatterInitInstructionFormatterEx(
|
ZYDIS_EXPORT ZydisStatus ZydisFormatterInitEx(ZydisFormatter* formatter, ZydisFormatterStyle style,
|
||||||
ZydisInstructionFormatter* formatter, ZydisFormatterStyle style, ZydisFormatterFlags flags,
|
ZydisFormatterFlags flags, ZydisFormatterAddressFormat addressFormat,
|
||||||
ZydisFormatterAddressFormat addressFormat, ZydisFormatterDisplacementFormat displacementFormat,
|
ZydisFormatterDisplacementFormat displacementFormat,
|
||||||
ZydisFormatterImmediateFormat immmediateFormat);
|
ZydisFormatterImmediateFormat immmediateFormat);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief TODO:
|
* @brief TODO:
|
||||||
*
|
*
|
||||||
* @param formatter A pointer to the @c ZydisInstructionFormatter instance.
|
* @param formatter A pointer to the @c ZydisFormatter instance.
|
||||||
* @param hook The formatter hook-type.
|
* @param hook The formatter hook-type.
|
||||||
* @param callback TODO: In Out
|
* @param callback TODO: In Out
|
||||||
*
|
*
|
||||||
* @return A zydis status code.
|
* @return A zydis status code.
|
||||||
*/
|
*/
|
||||||
ZYDIS_EXPORT ZydisStatus ZydisFormatterSetHook(ZydisInstructionFormatter* formatter,
|
ZYDIS_EXPORT ZydisStatus ZydisFormatterSetHook(ZydisFormatter* formatter,
|
||||||
ZydisFormatterHookType hook, const void** callback);
|
ZydisFormatterHookType hook, const void** callback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Formats the given instruction and writes it into the output buffer.
|
* @brief Formats the given instruction and writes it into the output buffer.
|
||||||
*
|
*
|
||||||
* @param formatter A pointer to the @c ZydisInstructionFormatter instance.
|
* @param formatter A pointer to the @c ZydisFormatter instance.
|
||||||
* @param instruction A pointer to the @c ZydisDecodedInstruction struct.
|
* @param instruction A pointer to the @c ZydisDecodedInstruction struct.
|
||||||
* @param buffer A pointer to the output buffer.
|
* @param buffer A pointer to the output buffer.
|
||||||
* @param bufferLen The length of the output buffer.
|
* @param bufferLen The length of the output buffer.
|
||||||
*
|
*
|
||||||
* @return A zydis status code.
|
* @return A zydis status code.
|
||||||
*/
|
*/
|
||||||
ZYDIS_EXPORT ZydisStatus ZydisFormatterFormatInstruction(const ZydisInstructionFormatter* formatter,
|
ZYDIS_EXPORT ZydisStatus ZydisFormatterFormatInstruction(const ZydisFormatter* formatter,
|
||||||
ZydisDecodedInstruction* instruction, char* buffer, size_t bufferLen);
|
ZydisDecodedInstruction* instruction, char* buffer, size_t bufferLen);
|
||||||
|
|
||||||
/* ============================================================================================== */
|
/* ============================================================================================== */
|
||||||
|
|
|
@ -45,7 +45,7 @@ typedef struct ZydisDecoderContext_
|
||||||
/**
|
/**
|
||||||
* @brief A pointer to the @c ZydisInstructionDecoder instance.
|
* @brief A pointer to the @c ZydisInstructionDecoder instance.
|
||||||
*/
|
*/
|
||||||
const ZydisInstructionDecoder* decoder;
|
const ZydisDecoder* decoder;
|
||||||
/**
|
/**
|
||||||
* @brief The input buffer.
|
* @brief The input buffer.
|
||||||
*/
|
*/
|
||||||
|
@ -4324,16 +4324,14 @@ static ZydisStatus ZydisDecodeInstruction(ZydisDecoderContext* context,
|
||||||
/* Exported functions */
|
/* Exported functions */
|
||||||
/* ============================================================================================== */
|
/* ============================================================================================== */
|
||||||
|
|
||||||
ZydisStatus ZydisDecoderInitInstructionDecoder(ZydisInstructionDecoder* decoder,
|
ZydisStatus ZydisDecoderInit(ZydisDecoder* decoder, ZydisMachineMode machineMode,
|
||||||
ZydisMachineMode machineMode, ZydisAddressWidth addressWidth)
|
ZydisAddressWidth addressWidth)
|
||||||
{
|
{
|
||||||
return ZydisDecoderInitInstructionDecoderEx(
|
return ZydisDecoderInitEx(decoder, machineMode, addressWidth, ZYDIS_DECODE_GRANULARITY_DEFAULT);
|
||||||
decoder, machineMode, addressWidth, ZYDIS_DECODE_GRANULARITY_DEFAULT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ZydisStatus ZydisDecoderInitInstructionDecoderEx(ZydisInstructionDecoder* decoder,
|
ZydisStatus ZydisDecoderInitEx(ZydisDecoder* decoder, ZydisMachineMode machineMode,
|
||||||
ZydisMachineMode machineMode, ZydisAddressWidth addressWidth,
|
ZydisAddressWidth addressWidth, ZydisDecodeGranularity decodeGranularity)
|
||||||
ZydisDecodeGranularity decodeGranularity)
|
|
||||||
{
|
{
|
||||||
if (!decoder || ((machineMode != 16) && (machineMode != 32) && (machineMode != 64)) ||
|
if (!decoder || ((machineMode != 16) && (machineMode != 32) && (machineMode != 64)) ||
|
||||||
((decodeGranularity != ZYDIS_DECODE_GRANULARITY_DEFAULT) &&
|
((decodeGranularity != ZYDIS_DECODE_GRANULARITY_DEFAULT) &&
|
||||||
|
@ -4364,7 +4362,7 @@ ZydisStatus ZydisDecoderInitInstructionDecoderEx(ZydisInstructionDecoder* decode
|
||||||
return ZYDIS_STATUS_SUCCESS;
|
return ZYDIS_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZydisStatus ZydisDecoderDecodeBuffer(const ZydisInstructionDecoder* decoder, const void* buffer,
|
ZydisStatus ZydisDecoderDecodeBuffer(const ZydisDecoder* decoder, const void* buffer,
|
||||||
size_t bufferLen, uint64_t instructionPointer, ZydisDecodedInstruction* instruction)
|
size_t bufferLen, uint64_t instructionPointer, ZydisDecodedInstruction* instruction)
|
||||||
{
|
{
|
||||||
if (!decoder)
|
if (!decoder)
|
||||||
|
|
|
@ -181,7 +181,7 @@ static ZydisStatus ZydisStringBufferAppendFormat(char** buffer, size_t bufferLen
|
||||||
/* Intel style */
|
/* Intel style */
|
||||||
/* ---------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static ZydisStatus ZydisFormatterPrintPrefixesIntel(const ZydisInstructionFormatter* formatter,
|
static ZydisStatus ZydisFormatterPrintPrefixesIntel(const ZydisFormatter* formatter,
|
||||||
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction)
|
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction)
|
||||||
{
|
{
|
||||||
if (!formatter || !buffer || !*buffer || (bufferLen <= 0) || !instruction)
|
if (!formatter || !buffer || !*buffer || (bufferLen <= 0) || !instruction)
|
||||||
|
@ -224,7 +224,7 @@ static ZydisStatus ZydisFormatterPrintPrefixesIntel(const ZydisInstructionFormat
|
||||||
return ZYDIS_STATUS_SUCCESS;
|
return ZYDIS_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ZydisStatus ZydisFormatterPrintMnemonicIntel(const ZydisInstructionFormatter* formatter,
|
static ZydisStatus ZydisFormatterPrintMnemonicIntel(const ZydisFormatter* formatter,
|
||||||
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction)
|
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction)
|
||||||
{
|
{
|
||||||
if (!formatter || !buffer || !*buffer || (bufferLen <= 0) || !instruction)
|
if (!formatter || !buffer || !*buffer || (bufferLen <= 0) || !instruction)
|
||||||
|
@ -242,7 +242,7 @@ static ZydisStatus ZydisFormatterPrintMnemonicIntel(const ZydisInstructionFormat
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static ZydisStatus ZydisFormatterFormatOperandRegIntel(const ZydisInstructionFormatter* formatter,
|
static ZydisStatus ZydisFormatterFormatOperandRegIntel(const ZydisFormatter* formatter,
|
||||||
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction,
|
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction,
|
||||||
ZydisDecodedOperand* operand)
|
ZydisDecodedOperand* operand)
|
||||||
{
|
{
|
||||||
|
@ -259,7 +259,7 @@ static ZydisStatus ZydisFormatterFormatOperandRegIntel(const ZydisInstructionFor
|
||||||
return ZydisStringBufferAppend(buffer, bufferLen, ZYDIS_APPENDMODE, reg);
|
return ZydisStringBufferAppend(buffer, bufferLen, ZYDIS_APPENDMODE, reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ZydisStatus ZydisFormatterFormatOperandMemIntel(const ZydisInstructionFormatter* formatter,
|
static ZydisStatus ZydisFormatterFormatOperandMemIntel(const ZydisFormatter* formatter,
|
||||||
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction,
|
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction,
|
||||||
ZydisDecodedOperand* operand)
|
ZydisDecodedOperand* operand)
|
||||||
{
|
{
|
||||||
|
@ -327,7 +327,7 @@ static ZydisStatus ZydisFormatterFormatOperandMemIntel(const ZydisInstructionFor
|
||||||
return ZydisStringBufferAppend(buffer, bufEnd - *buffer, ZYDIS_STRBUF_APPEND_MODE_DEFAULT, "]");
|
return ZydisStringBufferAppend(buffer, bufEnd - *buffer, ZYDIS_STRBUF_APPEND_MODE_DEFAULT, "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
static ZydisStatus ZydisFormatterFormatOperandPtrIntel(const ZydisInstructionFormatter* formatter,
|
static ZydisStatus ZydisFormatterFormatOperandPtrIntel(const ZydisFormatter* formatter,
|
||||||
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction,
|
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction,
|
||||||
ZydisDecodedOperand* operand)
|
ZydisDecodedOperand* operand)
|
||||||
{
|
{
|
||||||
|
@ -340,7 +340,7 @@ static ZydisStatus ZydisFormatterFormatOperandPtrIntel(const ZydisInstructionFor
|
||||||
"0x%04"PRIX16":0x%08"PRIX32, operand->ptr.segment, operand->ptr.offset);
|
"0x%04"PRIX16":0x%08"PRIX32, operand->ptr.segment, operand->ptr.offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ZydisStatus ZydisFormatterFormatOperandImmIntel(const ZydisInstructionFormatter* formatter,
|
static ZydisStatus ZydisFormatterFormatOperandImmIntel(const ZydisFormatter* formatter,
|
||||||
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction,
|
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction,
|
||||||
ZydisDecodedOperand* operand)
|
ZydisDecodedOperand* operand)
|
||||||
{
|
{
|
||||||
|
@ -386,7 +386,7 @@ static ZydisStatus ZydisFormatterFormatOperandImmIntel(const ZydisInstructionFor
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static ZydisStatus ZydisFormatterPrintAddressIntel(const ZydisInstructionFormatter* formatter,
|
static ZydisStatus ZydisFormatterPrintAddressIntel(const ZydisFormatter* formatter,
|
||||||
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction,
|
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction,
|
||||||
ZydisDecodedOperand* operand,
|
ZydisDecodedOperand* operand,
|
||||||
uint64_t address)
|
uint64_t address)
|
||||||
|
@ -410,7 +410,7 @@ static ZydisStatus ZydisFormatterPrintAddressIntel(const ZydisInstructionFormatt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static ZydisStatus ZydisFormatterPrintDisplacementIntel(const ZydisInstructionFormatter* formatter,
|
static ZydisStatus ZydisFormatterPrintDisplacementIntel(const ZydisFormatter* formatter,
|
||||||
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction,
|
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction,
|
||||||
ZydisDecodedOperand* operand)
|
ZydisDecodedOperand* operand)
|
||||||
{
|
{
|
||||||
|
@ -441,7 +441,7 @@ static ZydisStatus ZydisFormatterPrintDisplacementIntel(const ZydisInstructionFo
|
||||||
return ZYDIS_STATUS_SUCCESS;
|
return ZYDIS_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ZydisStatus ZydisFormatterPrintImmediateIntel(const ZydisInstructionFormatter* formatter,
|
static ZydisStatus ZydisFormatterPrintImmediateIntel(const ZydisFormatter* formatter,
|
||||||
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction,
|
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction,
|
||||||
ZydisDecodedOperand* operand)
|
ZydisDecodedOperand* operand)
|
||||||
{
|
{
|
||||||
|
@ -493,7 +493,7 @@ static ZydisStatus ZydisFormatterPrintImmediateIntel(const ZydisInstructionForma
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static ZydisStatus ZydisFormatterPrintOperandSizeIntel(const ZydisInstructionFormatter* formatter,
|
static ZydisStatus ZydisFormatterPrintOperandSizeIntel(const ZydisFormatter* formatter,
|
||||||
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction,
|
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction,
|
||||||
ZydisDecodedOperand* operand)
|
ZydisDecodedOperand* operand)
|
||||||
{
|
{
|
||||||
|
@ -586,7 +586,7 @@ static ZydisStatus ZydisFormatterPrintOperandSizeIntel(const ZydisInstructionFor
|
||||||
return ZYDIS_STATUS_SUCCESS;
|
return ZYDIS_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ZydisStatus ZydisFormatterPrintSegmentIntel(const ZydisInstructionFormatter* formatter,
|
static ZydisStatus ZydisFormatterPrintSegmentIntel(const ZydisFormatter* formatter,
|
||||||
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction,
|
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction,
|
||||||
ZydisDecodedOperand* operand)
|
ZydisDecodedOperand* operand)
|
||||||
{
|
{
|
||||||
|
@ -625,7 +625,7 @@ static ZydisStatus ZydisFormatterPrintSegmentIntel(const ZydisInstructionFormatt
|
||||||
return ZYDIS_STATUS_SUCCESS;
|
return ZYDIS_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ZydisStatus ZydisFormatterPrintDecoratorIntel(const ZydisInstructionFormatter* formatter,
|
static ZydisStatus ZydisFormatterPrintDecoratorIntel(const ZydisFormatter* formatter,
|
||||||
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction,
|
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction,
|
||||||
ZydisDecodedOperand* operand)
|
ZydisDecodedOperand* operand)
|
||||||
{
|
{
|
||||||
|
@ -828,7 +828,7 @@ static ZydisStatus ZydisFormatterPrintDecoratorIntel(const ZydisInstructionForma
|
||||||
return ZYDIS_STATUS_SUCCESS;
|
return ZYDIS_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ZydisStatus ZydisFormatterFormatInstrIntel(const ZydisInstructionFormatter* formatter,
|
static ZydisStatus ZydisFormatterFormatInstrIntel(const ZydisFormatter* formatter,
|
||||||
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction)
|
char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction)
|
||||||
{
|
{
|
||||||
if (!formatter || !buffer || !*buffer || (bufferLen <= 0) || !instruction)
|
if (!formatter || !buffer || !*buffer || (bufferLen <= 0) || !instruction)
|
||||||
|
@ -916,16 +916,16 @@ static ZydisStatus ZydisFormatterFormatInstrIntel(const ZydisInstructionFormatte
|
||||||
/* Exported functions */
|
/* Exported functions */
|
||||||
/* ---------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
ZydisStatus ZydisFormatterInitInstructionFormatter(
|
ZydisStatus ZydisFormatterInit(ZydisFormatter* formatter,
|
||||||
ZydisInstructionFormatter* formatter, ZydisFormatterStyle style)
|
ZydisFormatterStyle style)
|
||||||
{
|
{
|
||||||
return ZydisFormatterInitInstructionFormatterEx(formatter, style, 0,
|
return ZydisFormatterInitEx(formatter, style, 0, ZYDIS_FORMATTER_ADDR_DEFAULT,
|
||||||
ZYDIS_FORMATTER_ADDR_DEFAULT, ZYDIS_FORMATTER_DISP_DEFAULT, ZYDIS_FORMATTER_IMM_DEFAULT);
|
ZYDIS_FORMATTER_DISP_DEFAULT, ZYDIS_FORMATTER_IMM_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZydisStatus ZydisFormatterInitInstructionFormatterEx(
|
ZydisStatus ZydisFormatterInitEx(ZydisFormatter* formatter,
|
||||||
ZydisInstructionFormatter* formatter, ZydisFormatterStyle style, ZydisFormatterFlags flags,
|
ZydisFormatterStyle style, ZydisFormatterFlags flags, ZydisFormatterAddressFormat addressFormat,
|
||||||
ZydisFormatterAddressFormat addressFormat, ZydisFormatterDisplacementFormat displacementFormat,
|
ZydisFormatterDisplacementFormat displacementFormat,
|
||||||
ZydisFormatterImmediateFormat immmediateFormat)
|
ZydisFormatterImmediateFormat immmediateFormat)
|
||||||
{
|
{
|
||||||
if (!formatter ||
|
if (!formatter ||
|
||||||
|
@ -944,7 +944,7 @@ ZydisStatus ZydisFormatterInitInstructionFormatterEx(
|
||||||
return ZYDIS_STATUS_INVALID_PARAMETER;
|
return ZYDIS_STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(formatter, 0, sizeof(ZydisInstructionFormatter));
|
memset(formatter, 0, sizeof(ZydisFormatter));
|
||||||
formatter->flags = flags;
|
formatter->flags = flags;
|
||||||
formatter->addressFormat = addressFormat;
|
formatter->addressFormat = addressFormat;
|
||||||
formatter->displacementFormat = displacementFormat;
|
formatter->displacementFormat = displacementFormat;
|
||||||
|
@ -974,8 +974,8 @@ ZydisStatus ZydisFormatterInitInstructionFormatterEx(
|
||||||
return ZYDIS_STATUS_SUCCESS;
|
return ZYDIS_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZydisStatus ZydisFormatterSetHook(ZydisInstructionFormatter* formatter,
|
ZydisStatus ZydisFormatterSetHook(ZydisFormatter* formatter, ZydisFormatterHookType hook,
|
||||||
ZydisFormatterHookType hook, const void** callback)
|
const void** callback)
|
||||||
{
|
{
|
||||||
if (!formatter || !callback)
|
if (!formatter || !callback)
|
||||||
{
|
{
|
||||||
|
@ -1097,7 +1097,7 @@ ZydisStatus ZydisFormatterSetHook(ZydisInstructionFormatter* formatter,
|
||||||
return ZYDIS_STATUS_INVALID_PARAMETER;
|
return ZYDIS_STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZydisStatus ZydisFormatterFormatInstruction(const ZydisInstructionFormatter* formatter,
|
ZydisStatus ZydisFormatterFormatInstruction(const ZydisFormatter* formatter,
|
||||||
ZydisDecodedInstruction* instruction, char* buffer, size_t bufferLen)
|
ZydisDecodedInstruction* instruction, char* buffer, size_t bufferLen)
|
||||||
{
|
{
|
||||||
if (!formatter || !instruction || !buffer || (bufferLen == 0))
|
if (!formatter || !instruction || !buffer || (bufferLen == 0))
|
||||||
|
|
|
@ -51,17 +51,17 @@ int main(int argc, char** argv)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZydisInstructionDecoder decoder;
|
ZydisDecoder decoder;
|
||||||
if (!ZYDIS_SUCCESS(ZydisDecoderInitInstructionDecoder(
|
if (!ZYDIS_SUCCESS(
|
||||||
&decoder, ZYDIS_MACHINE_MODE_LONG_64, ZYDIS_ADDRESS_WIDTH_64)))
|
ZydisDecoderInit(&decoder, ZYDIS_MACHINE_MODE_LONG_64, ZYDIS_ADDRESS_WIDTH_64)))
|
||||||
{
|
{
|
||||||
fputs("Failed to initialize decoder\n", stderr);
|
fputs("Failed to initialize decoder\n", stderr);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZydisInstructionFormatter formatter;
|
ZydisFormatter formatter;
|
||||||
if (!ZYDIS_SUCCESS(ZydisFormatterInitInstructionFormatterEx(&formatter,
|
if (!ZYDIS_SUCCESS(ZydisFormatterInitEx(&formatter, ZYDIS_FORMATTER_STYLE_INTEL,
|
||||||
ZYDIS_FORMATTER_STYLE_INTEL, ZYDIS_FMTFLAG_FORCE_SEGMENTS | ZYDIS_FMTFLAG_FORCE_OPERANDSIZE,
|
ZYDIS_FMTFLAG_FORCE_SEGMENTS | ZYDIS_FMTFLAG_FORCE_OPERANDSIZE,
|
||||||
ZYDIS_FORMATTER_ADDR_ABSOLUTE, ZYDIS_FORMATTER_DISP_DEFAULT, ZYDIS_FORMATTER_IMM_DEFAULT)))
|
ZYDIS_FORMATTER_ADDR_ABSOLUTE, ZYDIS_FORMATTER_DISP_DEFAULT, ZYDIS_FORMATTER_IMM_DEFAULT)))
|
||||||
{
|
{
|
||||||
fputs("Failed to initialized instruction-formatter\n", stderr);
|
fputs("Failed to initialized instruction-formatter\n", stderr);
|
||||||
|
|
|
@ -63,17 +63,17 @@ int main()
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZydisInstructionDecoder decoder;
|
ZydisDecoder decoder;
|
||||||
if (!ZYDIS_SUCCESS(ZydisDecoderInitInstructionDecoderEx(
|
if (!ZYDIS_SUCCESS(ZydisDecoderInitEx(&decoder, controlBlock.machineMode,
|
||||||
&decoder, controlBlock.machineMode, controlBlock.addressWidth, controlBlock.granularity)))
|
controlBlock.addressWidth, controlBlock.granularity)))
|
||||||
{
|
{
|
||||||
fputs("Failed to initialize decoder\n", stderr);
|
fputs("Failed to initialize decoder\n", stderr);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZydisInstructionFormatter formatter;
|
ZydisFormatter formatter;
|
||||||
if (!ZYDIS_SUCCESS(ZydisFormatterInitInstructionFormatterEx(&formatter,
|
if (!ZYDIS_SUCCESS(ZydisFormatterInitEx(&formatter, controlBlock.formatterStyle,
|
||||||
controlBlock.formatterStyle, controlBlock.formatterFlags, controlBlock.formatterAddrFormat,
|
controlBlock.formatterFlags, controlBlock.formatterAddrFormat,
|
||||||
controlBlock.formatterDispFormat, controlBlock.formatterImmFormat)))
|
controlBlock.formatterDispFormat, controlBlock.formatterImmFormat)))
|
||||||
{
|
{
|
||||||
fputs("failed to initialize instruction-formatter\n", stderr);
|
fputs("failed to initialize instruction-formatter\n", stderr);
|
||||||
|
|
Loading…
Reference in New Issue