diff --git a/include/Zydis/InstructionInfo.h b/include/Zydis/InstructionInfo.h index 036e078..10fba65 100644 --- a/include/Zydis/InstructionInfo.h +++ b/include/Zydis/InstructionInfo.h @@ -522,6 +522,10 @@ enum ZydisOpcodeMaps */ typedef uint64_t ZydisInstructionAttributes; +// TODO: Update values + +// TODO: Add IsAtomic + /** * @brief The instruction has the ModRM byte. */ @@ -553,8 +557,7 @@ typedef uint64_t ZydisInstructionAttributes; /** * @brief The instruction is privileged. * - * Priviliged instructions are any instructions that require a current ring - * level below 3 or even SMM. + * Priviliged instructions are any instructions that require a current ring level below 3. */ #define ZYDIS_ATTRIB_IS_PRIVILEGED 0x0000000000000080 /** @@ -606,14 +609,6 @@ typedef uint64_t ZydisInstructionAttributes; * @brief The instruction accepts segment prefixes (0x2E, 0x36, 0x3E, 0x26, 0x64, 0x65). */ #define ZYDIS_ATTRIB_ACCEPTS_SEGMENT 0x0000000000020000 -/** - * @brief The instruction accepts the operand-size prefix (0x66). - */ -#define ZYDIS_ATTRIB_ACCEPTS_OPERANDSIZE 0x0000000000040000 // TODO: Remove -/** - * @brief The instruction accepts the address-size prefix (0x67). - */ -#define ZYDIS_ATTRIB_ACCEPTS_ADDRESSSIZE 0x0000000000080000 // TODO: Remove /** * @brief The instruction has the lock prefix (0xF0). */ diff --git a/src/Decoder.c b/src/Decoder.c index b4a67b3..7d714b9 100644 --- a/src/Decoder.c +++ b/src/Decoder.c @@ -933,8 +933,14 @@ static void ZydisSetOperandSizeAndElementInfo(ZydisDecoderContext* context, { case ZYDIS_OPERAND_TYPE_REGISTER: { - operand->size = (context->decoder->machineMode == 64) ? - ZydisRegisterGetWidth64(operand->reg) : ZydisRegisterGetWidth(operand->reg); + if (definition->size[context->eoszIndex]) + { + operand->size = definition->size[context->eoszIndex] * 8; + } else + { + operand->size = (context->decoder->machineMode == 64) ? + ZydisRegisterGetWidth64(operand->reg) : ZydisRegisterGetWidth(operand->reg); + } operand->elementType = ZYDIS_ELEMENT_TYPE_INT; operand->elementSize = operand->size; break; @@ -2055,6 +2061,10 @@ static void ZydisSetPrefixRelatedAttributes(ZydisDecoderContext* context, } } else { + if (def->acceptsSegment) + { + info->attributes |= ZYDIS_ATTRIB_ACCEPTS_SEGMENT; + } if (context->lastSegmentPrefix && def->acceptsSegment) { switch (context->lastSegmentPrefix) diff --git a/src/Formatter.c b/src/Formatter.c index 946ce96..4523867 100644 --- a/src/Formatter.c +++ b/src/Formatter.c @@ -500,11 +500,11 @@ static ZydisStatus ZydisFormatterPrintOperandSizeIntel(ZydisInstructionFormatter uint32_t typecast = 0; if (formatter->flags & ZYDIS_FMTFLAG_FORCE_OPERANDSIZE) { - if (info->operands[operand->id].type == ZYDIS_OPERAND_TYPE_MEMORY) + if ((operand->type == ZYDIS_OPERAND_TYPE_MEMORY) && (!operand->mem.isAddressGenOnly)) { typecast = info->operands[operand->id].size; } - } else if (info->operands[operand->id].type == ZYDIS_OPERAND_TYPE_MEMORY) + } else if ((operand->type == ZYDIS_OPERAND_TYPE_MEMORY) && (!operand->mem.isAddressGenOnly)) { switch (operand->id) {