mirror of https://github.com/x64dbg/zydis
Moved `internal` sub-struct from info to context
Also, fixed examples and tools.
This commit is contained in:
parent
71a551ef1a
commit
ebf71d632f
|
@ -175,9 +175,6 @@ static ZydisStatus ZydisFormatterFormatOperandImm(ZydisInstructionFormatter* for
|
||||||
|
|
||||||
void disassembleBuffer(uint8_t* data, size_t length, ZydisBool installHooks)
|
void disassembleBuffer(uint8_t* data, size_t length, ZydisBool installHooks)
|
||||||
{
|
{
|
||||||
ZydisInstructionDecoder decoder;
|
|
||||||
ZydisDecoderInitInstructionDecoder(&decoder, ZYDIS_DISASSEMBLER_MODE_64BIT);
|
|
||||||
|
|
||||||
ZydisInstructionFormatter formatter;
|
ZydisInstructionFormatter formatter;
|
||||||
ZydisFormatterInitInstructionFormatterEx(&formatter, ZYDIS_FORMATTER_STYLE_INTEL,
|
ZydisFormatterInitInstructionFormatterEx(&formatter, ZYDIS_FORMATTER_STYLE_INTEL,
|
||||||
ZYDIS_FMTFLAG_FORCE_SEGMENTS | ZYDIS_FMTFLAG_FORCE_OPERANDSIZE,
|
ZYDIS_FMTFLAG_FORCE_SEGMENTS | ZYDIS_FMTFLAG_FORCE_OPERANDSIZE,
|
||||||
|
@ -198,7 +195,7 @@ void disassembleBuffer(uint8_t* data, size_t length, ZydisBool installHooks)
|
||||||
ZydisInstructionInfo info;
|
ZydisInstructionInfo info;
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
while (ZYDIS_SUCCESS(
|
while (ZYDIS_SUCCESS(
|
||||||
ZydisDecoderDecodeInstruction(&decoder, data, length, instructionPointer, &info)))
|
ZydisDecode(ZYDIS_DISASSEMBLER_MODE_64BIT, data, length, instructionPointer, &info)))
|
||||||
{
|
{
|
||||||
data += info.length;
|
data += info.length;
|
||||||
length -= info.length;
|
length -= info.length;
|
||||||
|
|
|
@ -74,7 +74,8 @@ enum ZydisDecodeGranularities
|
||||||
* @return A zydis status code.
|
* @return A zydis status code.
|
||||||
*/
|
*/
|
||||||
ZYDIS_EXPORT ZydisStatus ZydisDecode(ZydisOperatingMode operatingMode,
|
ZYDIS_EXPORT ZydisStatus ZydisDecode(ZydisOperatingMode operatingMode,
|
||||||
const void* buffer, size_t bufferLen, uint64_t instructionPointer, ZydisInstructionInfo* info);
|
const void* buffer, size_t bufferLen, uint64_t instructionPointer,
|
||||||
|
ZydisInstructionInfo* info);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Decodes the instruction in the given input @c buffer.
|
* @brief Decodes the instruction in the given input @c buffer.
|
||||||
|
|
|
@ -396,7 +396,7 @@ typedef struct ZydisOperandInfo_
|
||||||
/* ---------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Defines the @c ZydisDisassemblerMode datatype.
|
* @brief Defines the @c ZydisOperatingMode datatype.
|
||||||
*/
|
*/
|
||||||
typedef uint8_t ZydisOperatingMode;
|
typedef uint8_t ZydisOperatingMode;
|
||||||
|
|
||||||
|
@ -783,7 +783,7 @@ enum ZydisAVXRoundingModes
|
||||||
typedef struct ZydisInstructionInfo_
|
typedef struct ZydisInstructionInfo_
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @brief The disassembler-mode used to decode this instruction.
|
* @brief The operating mode used to decode this instruction.
|
||||||
*/
|
*/
|
||||||
ZydisOperatingMode mode;
|
ZydisOperatingMode mode;
|
||||||
/**
|
/**
|
||||||
|
@ -1101,21 +1101,6 @@ typedef struct ZydisInstructionInfo_
|
||||||
uint8_t index;
|
uint8_t index;
|
||||||
uint8_t base;
|
uint8_t base;
|
||||||
} sib;
|
} sib;
|
||||||
/**
|
|
||||||
* @brief Internal data.
|
|
||||||
*/
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
const void* definition;
|
|
||||||
uint8_t W;
|
|
||||||
uint8_t R;
|
|
||||||
uint8_t X;
|
|
||||||
uint8_t B;
|
|
||||||
uint8_t L;
|
|
||||||
uint8_t L2;
|
|
||||||
uint8_t R2;
|
|
||||||
uint8_t V2;
|
|
||||||
} internal; // TODO: Move into decoder struct
|
|
||||||
} details;
|
} details;
|
||||||
/**
|
/**
|
||||||
* @brief This field is intended for custom data and may be freely set by the user.
|
* @brief This field is intended for custom data and may be freely set by the user.
|
||||||
|
|
476
src/Decoder.c
476
src/Decoder.c
File diff suppressed because it is too large
Load Diff
|
@ -40,12 +40,13 @@
|
||||||
#include <Zydis/Zydis.h>
|
#include <Zydis/Zydis.h>
|
||||||
|
|
||||||
typedef struct ZydisFuzzControlBlock_ {
|
typedef struct ZydisFuzzControlBlock_ {
|
||||||
ZydisDisassemblerMode disasMode;
|
ZydisOperatingMode operatingMode;
|
||||||
ZydisFormatterStyle formatterStyle;
|
ZydisFormatterStyle formatterStyle;
|
||||||
ZydisFormatterFlags formatterFlags;
|
ZydisFormatterFlags formatterFlags;
|
||||||
ZydisFormatterAddressFormat formatterAddrFormat;
|
ZydisFormatterAddressFormat formatterAddrFormat;
|
||||||
ZydisFormatterDisplacementFormat formatterDispFormat;
|
ZydisFormatterDisplacementFormat formatterDispFormat;
|
||||||
ZydisFormatterImmediateFormat formatterImmFormat;
|
ZydisFormatterImmediateFormat formatterImmFormat;
|
||||||
|
ZydisDecodeGranularity granularity;
|
||||||
} ZydisFuzzControlBlock;
|
} ZydisFuzzControlBlock;
|
||||||
|
|
||||||
/* ============================================================================================== */
|
/* ============================================================================================== */
|
||||||
|
@ -79,11 +80,12 @@ int main()
|
||||||
ZydisInstructionInfo info;
|
ZydisInstructionInfo info;
|
||||||
ZydisStatus status;
|
ZydisStatus status;
|
||||||
size_t readOffs = 0;
|
size_t readOffs = 0;
|
||||||
while ((status = ZydisDecode(
|
while ((status = ZydisDecodeEx(
|
||||||
controlBlock.disasMode,
|
controlBlock.operatingMode,
|
||||||
readBuf + readOffs,
|
readBuf + readOffs,
|
||||||
numBytesRead - readOffs,
|
numBytesRead - readOffs,
|
||||||
readOffs,
|
readOffs,
|
||||||
|
controlBlock.granularity,
|
||||||
&info
|
&info
|
||||||
)) != ZYDIS_STATUS_NO_MORE_DATA)
|
)) != ZYDIS_STATUS_NO_MORE_DATA)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue