Implemented decoder-modes to support ISA-extensions that conflict with existing instructions

- Added decoder-modes
 - `ZYDIS_DECODER_MODE_MINIMAL`
 - `ZYDIS_DECODER_MODE_AMD_BRANCHES`
 - `ZYDIS_DECODER_MODE_MPX`
 - `ZYDIS_DECODER_MODE_CET`
 - `ZYDIS_DECODER_MODE_LZCNT`
 - `ZYDIS_DECODER_MODE_TZCNT`
- Removed `ZydisDecoderInitEx` and the possibility to pass a decoder-granularity (use `ZYDIS_DECODER_MODE_MINIMAL` instead)
This commit is contained in:
flobernd 2017-11-01 23:39:10 +01:00
parent 5ed561a0fc
commit 57f7ff8bcd
10 changed files with 5818 additions and 5691 deletions

View File

@ -39,10 +39,11 @@
#include <stdlib.h>
#include <Zydis/Zydis.h>
typedef struct ZydisFuzzControlBlock_ {
typedef struct ZydisFuzzControlBlock_
{
ZydisMachineMode machineMode;
ZydisAddressWidth addressWidth;
ZydisDecodeGranularity granularity;
ZydisBool decoderMode[ZYDIS_DECODER_MODE_MAX_VALUE + 1];
ZydisFormatterStyle formatterStyle;
ZydisFormatterFlags formatterFlags;
ZydisFormatterAddressFormat formatterAddrFormat;
@ -70,12 +71,21 @@ int main()
}
ZydisDecoder decoder;
if (!ZYDIS_SUCCESS(ZydisDecoderInitEx(&decoder, controlBlock.machineMode,
controlBlock.addressWidth, controlBlock.granularity)))
if (!ZYDIS_SUCCESS(
ZydisDecoderInit(&decoder, controlBlock.machineMode, controlBlock.addressWidth)))
{
fputs("Failed to initialize decoder\n", stderr);
return EXIT_FAILURE;
}
for (ZydisDecoderMode mode = 1; mode <= ZYDIS_DECODER_MODE_MAX_VALUE; ++mode)
{
if (!ZYDIS_SUCCESS(
ZydisDecoderEnableMode(&decoder, mode, controlBlock.decoderMode[mode] ? 1 : 0)))
{
fputs("Failed to adjust decoder-mode\n", stderr);
return EXIT_FAILURE;
}
}
ZydisFormatter formatter;
if (!ZYDIS_SUCCESS(ZydisFormatterInitEx(&formatter, controlBlock.formatterStyle,

View File

@ -152,16 +152,21 @@ void adjustProcessAndThreadPriority()
/* Internal functions */
/* ============================================================================================== */
uint64_t processBuffer(const char* buffer, size_t length, ZydisDecodeGranularity granularity,
ZydisBool format)
uint64_t processBuffer(const char* buffer, size_t length, ZydisBool minimalMode, ZydisBool format)
{
ZydisDecoder decoder;
if (!ZYDIS_SUCCESS(ZydisDecoderInitEx(&decoder,
ZYDIS_MACHINE_MODE_LONG_64, ZYDIS_ADDRESS_WIDTH_64, granularity)))
if (!ZYDIS_SUCCESS(
ZydisDecoderInit(&decoder, ZYDIS_MACHINE_MODE_LONG_64, ZYDIS_ADDRESS_WIDTH_64)))
{
fputs("Failed to initialize decoder\n", stderr);
exit(EXIT_FAILURE);
}
if (!ZYDIS_SUCCESS(
ZydisDecoderEnableMode(&decoder, ZYDIS_DECODER_MODE_MINIMAL, minimalMode)))
{
fputs("Failed to adjust decoder-mode\n", stderr);
exit(EXIT_FAILURE);
}
ZydisFormatter formatter;
if (format)
@ -202,21 +207,20 @@ uint64_t processBuffer(const char* buffer, size_t length, ZydisDecodeGranularity
return count;
}
void testPerformance(const char* buffer, size_t length, ZydisDecodeGranularity granularity,
ZydisBool format)
void testPerformance(const char* buffer, size_t length, ZydisBool minimalMode, ZydisBool format)
{
// Cache warmup
processBuffer(buffer, length, granularity, format);
processBuffer(buffer, length, minimalMode, format);
// Testing
uint64_t count = 0;
StartCounter();
for (uint8_t j = 0; j < 100; ++j)
{
count += processBuffer(buffer, length, granularity, format);
count += processBuffer(buffer, length, minimalMode, format);
}
printf("Granularity %d, Formatting %d, Instructions: %6.2fM, Time: %8.2f msec\n",
granularity, format, (double)count / 1000000, GetCounter());
printf("Minimal-Mode %d, Formatting %d, Instructions: %6.2fM, Time: %8.2f msec\n",
minimalMode, format, (double)count / 1000000, GetCounter());
}
void generateTestData(FILE* file, uint8_t encoding)
@ -401,9 +405,9 @@ int main(int argc, char** argv)
}
printf("Testing %s ...\n", tests[i].encoding);
testPerformance(buffer, length, ZYDIS_DECODE_GRANULARITY_MINIMAL, ZYDIS_FALSE);
testPerformance(buffer, length, ZYDIS_DECODE_GRANULARITY_FULL , ZYDIS_FALSE);
testPerformance(buffer, length, ZYDIS_DECODE_GRANULARITY_FULL , ZYDIS_TRUE );
testPerformance(buffer, length, ZYDIS_TRUE , ZYDIS_FALSE);
testPerformance(buffer, length, ZYDIS_FALSE, ZYDIS_FALSE);
testPerformance(buffer, length, ZYDIS_FALSE, ZYDIS_TRUE );
puts("");
NextFile1:

View File

@ -45,22 +45,23 @@ extern "C" {
/* Enums and types */
/* ============================================================================================== */
/**
* @brief Defines the @c ZydisDecodeGranularity datatype.
*/
typedef uint8_t ZydisDecodeGranularity;
/* ---------------------------------------------------------------------------------------------- */
/* Decoder mode */
/* ---------------------------------------------------------------------------------------------- */
/**
* @brief Decoder modes defining how granular the instruction should be decoded.
* @brief Defines the @c ZydisDecoderMode datatype.
*/
enum ZydisDecodeGranularities
typedef uint8_t ZydisDecoderMode;
/**
* @brief Values that represent decoder-modes.
*/
enum ZydisDecoderModes
{
ZYDIS_DECODER_MODE_INVALID,
/**
* @brief Defaults to `ZYDIS_DECODE_GRANULARITY_FULL`.
*/
ZYDIS_DECODE_GRANULARITY_DEFAULT,
/**
* @brief Minimal instruction decoding without semantic analysis.
* @brief Enables minimal instruction decoding without semantic analysis.
*
* This mode provides access to the mnemonic, the instruction-length, the effective
* operand-size, the effective address-width, some attributes (e.g. `ZYDIS_ATTRIB_IS_RELATIVE`)
@ -69,17 +70,58 @@ enum ZydisDecodeGranularities
* Operands, most attributes and other specific information (like AVX info) are not
* accessible in this mode.
*/
ZYDIS_DECODE_GRANULARITY_MINIMAL,
ZYDIS_DECODER_MODE_MINIMAL,
/**
* @brief Full physical and semantic instruction-decoding.
* @brief Enables the AMD-branch mode.
*
* Intel ignores the operand-size override-prefix (`0x66`) for all branches with 32-bit
* immediates and forces the operand-size of the instruction to 64-bit in 64-bit mode.
* In AMD-branch mode `0x66` is not ignored and changes the operand-size and the size of the
* immediate to 16-bit.
*/
ZYDIS_DECODE_GRANULARITY_FULL,
ZYDIS_DECODER_MODE_AMD_BRANCHES,
/**
* @brief Enables the MPX mode.
*
* The MPX isa-extension reuses (overrides) some of the widenop instruction opcodes.
*
* This mode is enabled by default.
*/
ZYDIS_DECODER_MODE_MPX,
/**
* @brief Enables the CET mode.
*
* The CET isa-extension reuses (overrides) some of the widenop instruction opcodes.
*
* This mode is enabled by default.
*/
ZYDIS_DECODER_MODE_CET,
/**
* @brief Enables the LZCNT mode.
*
* The LZCNT isa-extension reuses (overrides) some of the widenop instruction opcodes.
*
* This mode is enabled by default.
*/
ZYDIS_DECODER_MODE_LZCNT,
/**
* @brief Enables the TZCNT mode.
*
* The TZCNT isa-extension reuses (overrides) some of the widenop instruction opcodes.
*
* This mode is enabled by default.
*/
ZYDIS_DECODER_MODE_TZCNT,
/**
* @brief Maximum value of this enum.
*/
ZYDIS_DECODE_GRANULARITY_MAX_VALUE = ZYDIS_DECODE_GRANULARITY_FULL,
ZYDIS_DECODER_MODE_MAX_VALUE = ZYDIS_DECODER_MODE_TZCNT
};
/* ---------------------------------------------------------------------------------------------- */
/* Decoder struct */
/* ---------------------------------------------------------------------------------------------- */
/**
* @brief Defines the @c ZydisDecoder struct.
*/
@ -87,7 +129,7 @@ typedef struct ZydisDecoder_
{
ZydisMachineMode machineMode;
ZydisAddressWidth addressWidth;
ZydisDecodeGranularity granularity;
ZydisBool decoderMode[ZYDIS_DECODER_MODE_MAX_VALUE + 1];
} ZydisDecoder;
/* ---------------------------------------------------------------------------------------------- */
@ -109,17 +151,16 @@ ZYDIS_EXPORT ZydisStatus ZydisDecoderInit(ZydisDecoder* decoder, ZydisMachineMod
ZydisAddressWidth addressWidth);
/**
* @brief Initializes the given @c ZydisDecoder instance.
* @brief Enables or disables the specified decoder-mode.
*
* @param decoder A pointer to the @c ZydisDecoder instance.
* @param machineMode The machine mode.
* @param addressWidth The address width.
* @param granularity The decode granularity.
* @param decoder A pointer to the @c ZydisDecoder instance.
* @param mode The decoder mode.
* @param enabled `ZYDIS_TRUE` to enable, or `ZYDIS_FALSE` to disable the specified decoder-mode.
*
* @return A zydis status code.
*/
ZYDIS_EXPORT ZydisStatus ZydisDecoderInitEx(ZydisDecoder* decoder, ZydisMachineMode machineMode,
ZydisAddressWidth addressWidth, ZydisDecodeGranularity granularity);
ZYDIS_EXPORT ZydisStatus ZydisDecoderEnableMode(ZydisDecoder* decoder, ZydisDecoderMode mode,
ZydisBool enabled);
/**
* @brief Decodes the instruction in the given input @c buffer.

View File

@ -2107,7 +2107,8 @@ static void ZydisSetAttributes(ZydisDecoderContext* context, ZydisDecodedInstruc
break;
}
}
if (instruction->attributes & ZYDIS_ATTRIB_ACCEPTS_BOUND)
if (context->decoder->decoderMode[ZYDIS_DECODER_MODE_MPX] &&
instruction->attributes & ZYDIS_ATTRIB_ACCEPTS_BOUND)
{
instruction->attributes |= ZYDIS_ATTRIB_HAS_BOUND;
break;
@ -4298,12 +4299,20 @@ static ZydisStatus ZydisDecodeInstruction(ZydisDecoderContext* context,
case ZYDIS_NODETYPE_FILTER_MVEX_E:
status = ZydisNodeHandlerMvexE(instruction, &index);
break;
case ZYDIS_NODETYPE_FILTER_FEATURE_MPX:
case ZYDIS_NODETYPE_FILTER_FEATURE_CET:
case ZYDIS_NODETYPE_FILTER_FEATURE_LZCNT:
case ZYDIS_NODETYPE_FILTER_FEATURE_TZCNT:
// TODO: Make configurable by option
index = 1;
case ZYDIS_NODETYPE_FILTER_MODE_AMD:
index = context->decoder->decoderMode[ZYDIS_DECODER_MODE_AMD_BRANCHES] ? 1 : 0;
break;
case ZYDIS_NODETYPE_FILTER_MODE_MPX:
index = context->decoder->decoderMode[ZYDIS_DECODER_MODE_MPX] ? 1 : 0;
break;
case ZYDIS_NODETYPE_FILTER_MODE_CET:
index = context->decoder->decoderMode[ZYDIS_DECODER_MODE_CET] ? 1 : 0;
break;
case ZYDIS_NODETYPE_FILTER_MODE_LZCNT:
index = context->decoder->decoderMode[ZYDIS_DECODER_MODE_LZCNT] ? 1 : 0;
break;
case ZYDIS_NODETYPE_FILTER_MODE_TZCNT:
index = context->decoder->decoderMode[ZYDIS_DECODER_MODE_TZCNT] ? 1 : 0;
break;
default:
if (nodeType & ZYDIS_NODETYPE_DEFINITION_MASK)
@ -4344,7 +4353,7 @@ static ZydisStatus ZydisDecodeInstruction(ZydisDecoderContext* context,
instruction->meta.isaExt = definition->isaExt;
instruction->meta.exceptionClass = definition->exceptionClass;
if (context->decoder->granularity == ZYDIS_DECODE_GRANULARITY_FULL)
if (!context->decoder->decoderMode[ZYDIS_DECODER_MODE_MINIMAL])
{
ZydisSetAttributes(context, instruction, definition);
switch (instruction->encoding)
@ -4387,16 +4396,18 @@ static ZydisStatus ZydisDecodeInstruction(ZydisDecoderContext* context,
ZydisStatus ZydisDecoderInit(ZydisDecoder* decoder, ZydisMachineMode machineMode,
ZydisAddressWidth addressWidth)
{
return ZydisDecoderInitEx(decoder, machineMode, addressWidth, ZYDIS_DECODE_GRANULARITY_DEFAULT);
}
static const ZydisBool decoderModes[ZYDIS_DECODER_MODE_MAX_VALUE + 1] =
{
ZYDIS_FALSE, // ZYDIS_DECODER_MODE_INVALID
ZYDIS_FALSE, // ZYDIS_DECODER_MODE_MINIMAL
ZYDIS_FALSE, // ZYDIS_DECODER_MODE_AMD_BRANCHES
ZYDIS_TRUE , // ZYDIS_DECODER_MODE_MPX
ZYDIS_TRUE , // ZYDIS_DECODER_MODE_CET
ZYDIS_TRUE , // ZYDIS_DECODER_MODE_LZCNT
ZYDIS_TRUE // ZYDIS_DECODER_MODE_TZCNT
};
ZydisStatus ZydisDecoderInitEx(ZydisDecoder* decoder, ZydisMachineMode machineMode,
ZydisAddressWidth addressWidth, ZydisDecodeGranularity granularity)
{
if (!decoder || ((machineMode != 16) && (machineMode != 32) && (machineMode != 64)) ||
((granularity != ZYDIS_DECODE_GRANULARITY_DEFAULT) &&
(granularity != ZYDIS_DECODE_GRANULARITY_MINIMAL) &&
(granularity != ZYDIS_DECODE_GRANULARITY_FULL)))
if (!decoder || ((machineMode != 16) && (machineMode != 32) && (machineMode != 64)))
{
return ZYDIS_STATUS_INVALID_PARAMETER;
}
@ -4413,14 +4424,22 @@ ZydisStatus ZydisDecoderInitEx(ZydisDecoder* decoder, ZydisMachineMode machineMo
return ZYDIS_STATUS_INVALID_PARAMETER;
}
}
if (granularity == ZYDIS_DECODE_GRANULARITY_DEFAULT)
{
granularity = ZYDIS_DECODE_GRANULARITY_FULL;
}
decoder->machineMode = machineMode;
decoder->addressWidth = addressWidth;
decoder->granularity = granularity;
memcpy(&decoder->decoderMode, &decoderModes, sizeof(decoderModes));
return ZYDIS_STATUS_SUCCESS;
}
ZydisStatus ZydisDecoderEnableMode(ZydisDecoder* decoder, ZydisDecoderMode mode, ZydisBool enabled)
{
if (!decoder || !mode || (mode > ZYDIS_DECODER_MODE_MAX_VALUE))
{
return ZYDIS_STATUS_INVALID_PARAMETER;
}
decoder->decoderMode[mode] = enabled;
return ZYDIS_STATUS_SUCCESS;
}

View File

@ -333,18 +333,21 @@ const ZydisDecoderTreeNode* ZydisDecoderTreeGetChildNode(const ZydisDecoderTreeN
case ZYDIS_NODETYPE_FILTER_MVEX_E:
ZYDIS_ASSERT(index < 2);
return &filtersMVEXE[parent->value][index];
case ZYDIS_NODETYPE_FILTER_FEATURE_MPX:
case ZYDIS_NODETYPE_FILTER_MODE_AMD:
ZYDIS_ASSERT(index < 2);
return &filtersFeatureMPX[parent->value][index];
case ZYDIS_NODETYPE_FILTER_FEATURE_CET:
return &filtersModeAMD[parent->value][index];
case ZYDIS_NODETYPE_FILTER_MODE_MPX:
ZYDIS_ASSERT(index < 2);
return &filtersFeatureCET[parent->value][index];
case ZYDIS_NODETYPE_FILTER_FEATURE_LZCNT:
return &filtersModeMPX[parent->value][index];
case ZYDIS_NODETYPE_FILTER_MODE_CET:
ZYDIS_ASSERT(index < 2);
return &filtersFeatureLZCNT[parent->value][index];
case ZYDIS_NODETYPE_FILTER_FEATURE_TZCNT:
return &filtersModeCET[parent->value][index];
case ZYDIS_NODETYPE_FILTER_MODE_LZCNT:
ZYDIS_ASSERT(index < 2);
return &filtersFeatureTZCNT[parent->value][index];
return &filtersModeLZCNT[parent->value][index];
case ZYDIS_NODETYPE_FILTER_MODE_TZCNT:
ZYDIS_ASSERT(index < 2);
return &filtersModeTZCNT[parent->value][index];
default:
ZYDIS_UNREACHABLE;
}

View File

@ -138,21 +138,25 @@ enum ZydisDecoderTreeNodeTypes
*/
ZYDIS_NODETYPE_FILTER_MVEX_E = 0x12,
/**
* @brief Reference to a MPX-feature filter.
* @brief Reference to a AMD-mode filter.
*/
ZYDIS_NODETYPE_FILTER_FEATURE_MPX = 0x13,
ZYDIS_NODETYPE_FILTER_MODE_AMD = 0x13,
/**
* @brief Reference to a CET-feature filter.
* @brief Reference to a MPX-mode filter.
*/
ZYDIS_NODETYPE_FILTER_FEATURE_CET = 0x14,
ZYDIS_NODETYPE_FILTER_MODE_MPX = 0x14,
/**
* @brief Reference to a LZCNT-feature filter.
* @brief Reference to a CET-mode filter.
*/
ZYDIS_NODETYPE_FILTER_FEATURE_LZCNT = 0x15,
ZYDIS_NODETYPE_FILTER_MODE_CET = 0x15,
/**
* @brief Reference to a TZCNT-feature filter.
* @brief Reference to a LZCNT-mode filter.
*/
ZYDIS_NODETYPE_FILTER_FEATURE_TZCNT = 0x16
ZYDIS_NODETYPE_FILTER_MODE_LZCNT = 0x16,
/**
* @brief Reference to a TZCNT-mode filter.
*/
ZYDIS_NODETYPE_FILTER_MODE_TZCNT = 0x17
};
/* ---------------------------------------------------------------------------------------------- */

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -1098,6 +1098,10 @@ const ZydisOperandDefinition operandDefinitions[] =
{ ZYDIS_SEMANTIC_OPTYPE_IMPLICIT_REG, ZYDIS_OPERAND_VISIBILITY_HIDDEN, ZYDIS_OPERAND_ACTION_READWRITE, { 0, 0, 0 }, ZYDIS_IELEMENT_TYPE_INVALID, { .reg = { ZYDIS_IMPLREG_TYPE_GPR_SSZ, { .id = 0x4 } } } },
{ ZYDIS_SEMANTIC_OPTYPE_IMPLICIT_MEM, ZYDIS_OPERAND_VISIBILITY_HIDDEN, ZYDIS_OPERAND_ACTION_WRITE, { 2, 4, 8 }, ZYDIS_IELEMENT_TYPE_INT, { .mem = { 0, ZYDIS_IMPLMEM_BASE_ASP } } },
{ ZYDIS_SEMANTIC_OPTYPE_REL, ZYDIS_OPERAND_VISIBILITY_EXPLICIT, ZYDIS_OPERAND_ACTION_READ, { 2, 4, 4 }, ZYDIS_IELEMENT_TYPE_INT, { .encoding = ZYDIS_OPERAND_ENCODING_JIMM16_32_32 } },
{ ZYDIS_SEMANTIC_OPTYPE_IMPLICIT_REG, ZYDIS_OPERAND_VISIBILITY_HIDDEN, ZYDIS_OPERAND_ACTION_READWRITE, { 0, 0, 0 }, ZYDIS_IELEMENT_TYPE_INVALID, { .reg = { ZYDIS_IMPLREG_TYPE_STATIC, { .reg = ZYDIS_REGISTER_RIP } } } },
{ ZYDIS_SEMANTIC_OPTYPE_IMPLICIT_REG, ZYDIS_OPERAND_VISIBILITY_HIDDEN, ZYDIS_OPERAND_ACTION_READWRITE, { 0, 0, 0 }, ZYDIS_IELEMENT_TYPE_INVALID, { .reg = { ZYDIS_IMPLREG_TYPE_GPR_SSZ, { .id = 0x4 } } } },
{ ZYDIS_SEMANTIC_OPTYPE_IMPLICIT_MEM, ZYDIS_OPERAND_VISIBILITY_HIDDEN, ZYDIS_OPERAND_ACTION_WRITE, { 2, 4, 8 }, ZYDIS_IELEMENT_TYPE_INT, { .mem = { 0, ZYDIS_IMPLMEM_BASE_ASP } } },
{ ZYDIS_SEMANTIC_OPTYPE_REL, ZYDIS_OPERAND_VISIBILITY_EXPLICIT, ZYDIS_OPERAND_ACTION_READ, { 2, 4, 4 }, ZYDIS_IELEMENT_TYPE_INT, { .encoding = ZYDIS_OPERAND_ENCODING_JIMM16_32_32 } },
{ ZYDIS_SEMANTIC_OPTYPE_IMPLICIT_REG, ZYDIS_OPERAND_VISIBILITY_HIDDEN, ZYDIS_OPERAND_ACTION_READWRITE, { 0, 0, 0 }, ZYDIS_IELEMENT_TYPE_INVALID, { .reg = { ZYDIS_IMPLREG_TYPE_STATIC, { .reg = ZYDIS_REGISTER_EIP } } } },
{ ZYDIS_SEMANTIC_OPTYPE_IMPLICIT_REG, ZYDIS_OPERAND_VISIBILITY_HIDDEN, ZYDIS_OPERAND_ACTION_READWRITE, { 0, 0, 0 }, ZYDIS_IELEMENT_TYPE_INVALID, { .reg = { ZYDIS_IMPLREG_TYPE_GPR_SSZ, { .id = 0x4 } } } },
{ ZYDIS_SEMANTIC_OPTYPE_IMPLICIT_MEM, ZYDIS_OPERAND_VISIBILITY_HIDDEN, ZYDIS_OPERAND_ACTION_WRITE, { 2, 4, 8 }, ZYDIS_IELEMENT_TYPE_INT, { .mem = { 0, ZYDIS_IMPLMEM_BASE_ASP } } },
@ -3067,15 +3071,15 @@ const ZydisOperandDefinition operandDefinitions[] =
{ ZYDIS_SEMANTIC_OPTYPE_MEM, ZYDIS_OPERAND_VISIBILITY_EXPLICIT, ZYDIS_OPERAND_ACTION_READ, { 16, 16, 16 }, ZYDIS_IELEMENT_TYPE_INT32, { .encoding = ZYDIS_OPERAND_ENCODING_MODRM_RM } },
{ ZYDIS_SEMANTIC_OPTYPE_IMPLICIT_REG, ZYDIS_OPERAND_VISIBILITY_HIDDEN, ZYDIS_OPERAND_ACTION_WRITE, { 0, 0, 0 }, ZYDIS_IELEMENT_TYPE_INVALID, { .reg = { ZYDIS_IMPLREG_TYPE_FLAGS_SSZ, { .id = 0x3F } } } },
{ ZYDIS_SEMANTIC_OPTYPE_REL, ZYDIS_OPERAND_VISIBILITY_EXPLICIT, ZYDIS_OPERAND_ACTION_READ, { 1, 1, 1 }, ZYDIS_IELEMENT_TYPE_INT8, { .encoding = ZYDIS_OPERAND_ENCODING_JIMM8 } },
{ ZYDIS_SEMANTIC_OPTYPE_IMPLICIT_REG, ZYDIS_OPERAND_VISIBILITY_HIDDEN, ZYDIS_OPERAND_ACTION_READWRITE, { 0, 0, 0 }, ZYDIS_IELEMENT_TYPE_INVALID, { .reg = { ZYDIS_IMPLREG_TYPE_STATIC, { .reg = ZYDIS_REGISTER_RIP } } } },
{ ZYDIS_SEMANTIC_OPTYPE_IMPLICIT_REG, ZYDIS_OPERAND_VISIBILITY_HIDDEN, ZYDIS_OPERAND_ACTION_READ, { 0, 0, 0 }, ZYDIS_IELEMENT_TYPE_INVALID, { .reg = { ZYDIS_IMPLREG_TYPE_FLAGS_SSZ, { .id = 0x3F } } } },
{ ZYDIS_SEMANTIC_OPTYPE_REL, ZYDIS_OPERAND_VISIBILITY_EXPLICIT, ZYDIS_OPERAND_ACTION_READ, { 1, 1, 1 }, ZYDIS_IELEMENT_TYPE_INT8, { .encoding = ZYDIS_OPERAND_ENCODING_JIMM8 } },
{ ZYDIS_SEMANTIC_OPTYPE_IMPLICIT_REG, ZYDIS_OPERAND_VISIBILITY_HIDDEN, ZYDIS_OPERAND_ACTION_READWRITE, { 0, 0, 0 }, ZYDIS_IELEMENT_TYPE_INVALID, { .reg = { ZYDIS_IMPLREG_TYPE_STATIC, { .reg = ZYDIS_REGISTER_EIP } } } },
{ ZYDIS_SEMANTIC_OPTYPE_IMPLICIT_REG, ZYDIS_OPERAND_VISIBILITY_HIDDEN, ZYDIS_OPERAND_ACTION_READ, { 0, 0, 0 }, ZYDIS_IELEMENT_TYPE_INVALID, { .reg = { ZYDIS_IMPLREG_TYPE_FLAGS_SSZ, { .id = 0x3F } } } },
{ ZYDIS_SEMANTIC_OPTYPE_REL, ZYDIS_OPERAND_VISIBILITY_EXPLICIT, ZYDIS_OPERAND_ACTION_READ, { 4, 4, 4 }, ZYDIS_IELEMENT_TYPE_INT32, { .encoding = ZYDIS_OPERAND_ENCODING_JIMM32 } },
{ ZYDIS_SEMANTIC_OPTYPE_IMPLICIT_REG, ZYDIS_OPERAND_VISIBILITY_HIDDEN, ZYDIS_OPERAND_ACTION_READWRITE, { 0, 0, 0 }, ZYDIS_IELEMENT_TYPE_INVALID, { .reg = { ZYDIS_IMPLREG_TYPE_STATIC, { .reg = ZYDIS_REGISTER_RIP } } } },
{ ZYDIS_SEMANTIC_OPTYPE_IMPLICIT_REG, ZYDIS_OPERAND_VISIBILITY_HIDDEN, ZYDIS_OPERAND_ACTION_READ, { 0, 0, 0 }, ZYDIS_IELEMENT_TYPE_INVALID, { .reg = { ZYDIS_IMPLREG_TYPE_FLAGS_SSZ, { .id = 0x3F } } } },
{ ZYDIS_SEMANTIC_OPTYPE_REL, ZYDIS_OPERAND_VISIBILITY_EXPLICIT, ZYDIS_OPERAND_ACTION_READ, { 2, 4, 4 }, ZYDIS_IELEMENT_TYPE_INT, { .encoding = ZYDIS_OPERAND_ENCODING_JIMM16_32_32 } },
{ ZYDIS_SEMANTIC_OPTYPE_IMPLICIT_REG, ZYDIS_OPERAND_VISIBILITY_HIDDEN, ZYDIS_OPERAND_ACTION_READWRITE, { 0, 0, 0 }, ZYDIS_IELEMENT_TYPE_INVALID, { .reg = { ZYDIS_IMPLREG_TYPE_STATIC, { .reg = ZYDIS_REGISTER_RIP } } } },
{ ZYDIS_SEMANTIC_OPTYPE_IMPLICIT_REG, ZYDIS_OPERAND_VISIBILITY_HIDDEN, ZYDIS_OPERAND_ACTION_READ, { 0, 0, 0 }, ZYDIS_IELEMENT_TYPE_INVALID, { .reg = { ZYDIS_IMPLREG_TYPE_FLAGS_SSZ, { .id = 0x3F } } } },
{ ZYDIS_SEMANTIC_OPTYPE_REL, ZYDIS_OPERAND_VISIBILITY_EXPLICIT, ZYDIS_OPERAND_ACTION_READ, { 2, 4, 4 }, ZYDIS_IELEMENT_TYPE_INT, { .encoding = ZYDIS_OPERAND_ENCODING_JIMM16_32_32 } },
{ ZYDIS_SEMANTIC_OPTYPE_IMPLICIT_REG, ZYDIS_OPERAND_VISIBILITY_HIDDEN, ZYDIS_OPERAND_ACTION_READWRITE, { 0, 0, 0 }, ZYDIS_IELEMENT_TYPE_INVALID, { .reg = { ZYDIS_IMPLREG_TYPE_STATIC, { .reg = ZYDIS_REGISTER_EIP } } } },
{ ZYDIS_SEMANTIC_OPTYPE_IMPLICIT_REG, ZYDIS_OPERAND_VISIBILITY_HIDDEN, ZYDIS_OPERAND_ACTION_READ, { 0, 0, 0 }, ZYDIS_IELEMENT_TYPE_INVALID, { .reg = { ZYDIS_IMPLREG_TYPE_FLAGS_SSZ, { .id = 0x3F } } } },
{ ZYDIS_SEMANTIC_OPTYPE_REL, ZYDIS_OPERAND_VISIBILITY_EXPLICIT, ZYDIS_OPERAND_ACTION_READ, { 1, 1, 1 }, ZYDIS_IELEMENT_TYPE_INT8, { .encoding = ZYDIS_OPERAND_ENCODING_JIMM8 } },
@ -5662,6 +5666,8 @@ const ZydisOperandDefinition operandDefinitions[] =
{ ZYDIS_SEMANTIC_OPTYPE_IMPLICIT_REG, ZYDIS_OPERAND_VISIBILITY_HIDDEN, ZYDIS_OPERAND_ACTION_READWRITE, { 0, 0, 0 }, ZYDIS_IELEMENT_TYPE_INVALID, { .reg = { ZYDIS_IMPLREG_TYPE_FLAGS_SSZ, { .id = 0x3F } } } },
{ ZYDIS_SEMANTIC_OPTYPE_IMPLICIT_REG, ZYDIS_OPERAND_VISIBILITY_IMPLICIT, ZYDIS_OPERAND_ACTION_READ, { 0, 0, 0 }, ZYDIS_IELEMENT_TYPE_INVALID, { .reg = { ZYDIS_IMPLREG_TYPE_GPR_OSZ, { .id = 0x0 } } } },
{ ZYDIS_SEMANTIC_OPTYPE_IMPLICIT_REG, ZYDIS_OPERAND_VISIBILITY_IMPLICIT, ZYDIS_OPERAND_ACTION_READ, { 0, 0, 0 }, ZYDIS_IELEMENT_TYPE_INVALID, { .reg = { ZYDIS_IMPLREG_TYPE_STATIC, { .reg = ZYDIS_REGISTER_ECX } } } },
{ ZYDIS_SEMANTIC_OPTYPE_REL, ZYDIS_OPERAND_VISIBILITY_EXPLICIT, ZYDIS_OPERAND_ACTION_READ, { 1, 1, 1 }, ZYDIS_IELEMENT_TYPE_INT8, { .encoding = ZYDIS_OPERAND_ENCODING_JIMM8 } },
{ ZYDIS_SEMANTIC_OPTYPE_IMPLICIT_REG, ZYDIS_OPERAND_VISIBILITY_HIDDEN, ZYDIS_OPERAND_ACTION_READWRITE, { 0, 0, 0 }, ZYDIS_IELEMENT_TYPE_INVALID, { .reg = { ZYDIS_IMPLREG_TYPE_STATIC, { .reg = ZYDIS_REGISTER_RIP } } } },
{ ZYDIS_SEMANTIC_OPTYPE_GPR16_32_64, ZYDIS_OPERAND_VISIBILITY_EXPLICIT, ZYDIS_OPERAND_ACTION_READ, { 0, 0, 0 }, ZYDIS_IELEMENT_TYPE_INVALID, { .encoding = ZYDIS_OPERAND_ENCODING_MODRM_RM } },
{ ZYDIS_SEMANTIC_OPTYPE_IMPLICIT_REG, ZYDIS_OPERAND_VISIBILITY_HIDDEN, ZYDIS_OPERAND_ACTION_WRITE, { 0, 0, 0 }, ZYDIS_IELEMENT_TYPE_INVALID, { .reg = { ZYDIS_IMPLREG_TYPE_IP_SSZ, { .id = 0x3F } } } },
{ ZYDIS_SEMANTIC_OPTYPE_MEM, ZYDIS_OPERAND_VISIBILITY_EXPLICIT, ZYDIS_OPERAND_ACTION_READ, { 2, 4, 8 }, ZYDIS_IELEMENT_TYPE_INT, { .encoding = ZYDIS_OPERAND_ENCODING_MODRM_RM } },

View File

@ -590,7 +590,7 @@ int main(int argc, char** argv)
{
fputs("Usage: ZydisInfo -[16|32|64] [hexbytes]\n", stderr);
return ZYDIS_STATUS_INVALID_PARAMETER;
}
}
uint8_t data[ZYDIS_MAX_INSTRUCTION_LENGTH];
uint8_t length = 0;