Moved `internal` sub-struct from info to context

Also, fixed examples and tools.
This commit is contained in:
Joel Höner 2017-04-11 03:18:08 +02:00
parent 71a551ef1a
commit ebf71d632f
5 changed files with 262 additions and 251 deletions

View File

@ -175,9 +175,6 @@ static ZydisStatus ZydisFormatterFormatOperandImm(ZydisInstructionFormatter* for
void disassembleBuffer(uint8_t* data, size_t length, ZydisBool installHooks)
{
ZydisInstructionDecoder decoder;
ZydisDecoderInitInstructionDecoder(&decoder, ZYDIS_DISASSEMBLER_MODE_64BIT);
ZydisInstructionFormatter formatter;
ZydisFormatterInitInstructionFormatterEx(&formatter, ZYDIS_FORMATTER_STYLE_INTEL,
ZYDIS_FMTFLAG_FORCE_SEGMENTS | ZYDIS_FMTFLAG_FORCE_OPERANDSIZE,
@ -198,7 +195,7 @@ void disassembleBuffer(uint8_t* data, size_t length, ZydisBool installHooks)
ZydisInstructionInfo info;
char buffer[256];
while (ZYDIS_SUCCESS(
ZydisDecoderDecodeInstruction(&decoder, data, length, instructionPointer, &info)))
ZydisDecode(ZYDIS_DISASSEMBLER_MODE_64BIT, data, length, instructionPointer, &info)))
{
data += info.length;
length -= info.length;

View File

@ -74,7 +74,8 @@ enum ZydisDecodeGranularities
* @return A zydis status code.
*/
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.

View File

@ -396,7 +396,7 @@ typedef struct ZydisOperandInfo_
/* ---------------------------------------------------------------------------------------------- */
/**
* @brief Defines the @c ZydisDisassemblerMode datatype.
* @brief Defines the @c ZydisOperatingMode datatype.
*/
typedef uint8_t ZydisOperatingMode;
@ -783,7 +783,7 @@ enum ZydisAVXRoundingModes
typedef struct ZydisInstructionInfo_
{
/**
* @brief The disassembler-mode used to decode this instruction.
* @brief The operating mode used to decode this instruction.
*/
ZydisOperatingMode mode;
/**
@ -1101,21 +1101,6 @@ typedef struct ZydisInstructionInfo_
uint8_t index;
uint8_t base;
} 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;
/**
* @brief This field is intended for custom data and may be freely set by the user.

File diff suppressed because it is too large Load Diff

View File

@ -40,12 +40,13 @@
#include <Zydis/Zydis.h>
typedef struct ZydisFuzzControlBlock_ {
ZydisDisassemblerMode disasMode;
ZydisOperatingMode operatingMode;
ZydisFormatterStyle formatterStyle;
ZydisFormatterFlags formatterFlags;
ZydisFormatterAddressFormat formatterAddrFormat;
ZydisFormatterDisplacementFormat formatterDispFormat;
ZydisFormatterImmediateFormat formatterImmFormat;
ZydisDecodeGranularity granularity;
} ZydisFuzzControlBlock;
/* ============================================================================================== */
@ -79,11 +80,12 @@ int main()
ZydisInstructionInfo info;
ZydisStatus status;
size_t readOffs = 0;
while ((status = ZydisDecode(
controlBlock.disasMode,
while ((status = ZydisDecodeEx(
controlBlock.operatingMode,
readBuf + readOffs,
numBytesRead - readOffs,
numBytesRead - readOffs,
readOffs,
controlBlock.granularity,
&info
)) != ZYDIS_STATUS_NO_MORE_DATA)
{