From 54d3836256de55c6e4143de9e921c7b80c99be2c Mon Sep 17 00:00:00 2001 From: flobernd Date: Sat, 15 Jul 2017 03:39:48 +0200 Subject: [PATCH] Minor improvements to the instruction-formatter --- include/Zydis/Formatter.h | 3 +-- src/Formatter.c | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/include/Zydis/Formatter.h b/include/Zydis/Formatter.h index 82dad9c..a59d481 100644 --- a/include/Zydis/Formatter.h +++ b/include/Zydis/Formatter.h @@ -402,7 +402,6 @@ typedef ZydisStatus (*ZydisFormatterFormatAddressFunc)(const ZydisFormatter* for * @param instruction A pointer to the @c ZydisDecodedInstruction struct. * @param operand A pointer to the @c ZydisDecodedOperand struct. * @param type The decorator type. - * @param mask The embedded-mask register (`ZYDIS_DECORATOR_TYPE_MASK` only). * * @return Returning a status code other than @c ZYDIS_STATUS_SUCCESS will immediately cause the * formatting process to fail. @@ -417,7 +416,7 @@ typedef ZydisStatus (*ZydisFormatterFormatAddressFunc)(const ZydisFormatter* for */ typedef ZydisStatus (*ZydisFormatterFormatDecoratorFunc)(const ZydisFormatter* formatter, char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction, - ZydisDecodedOperand* operand, ZydisDecoratorType type, ZydisRegister mask); + ZydisDecodedOperand* operand, ZydisDecoratorType type); /** * @brief Defines the @c ZydisFormatter struct. diff --git a/src/Formatter.c b/src/Formatter.c index e950fc7..196b934 100644 --- a/src/Formatter.c +++ b/src/Formatter.c @@ -637,7 +637,7 @@ static ZydisStatus ZydisFormatterPrintSegmentIntel(const ZydisFormatter* formatt static ZydisStatus ZydisFormatterPrintDecoratorIntel(const ZydisFormatter* formatter, char** buffer, size_t bufferLen, ZydisDecodedInstruction* instruction, - ZydisDecodedOperand* operand, ZydisDecoratorType type, ZydisRegister mask) + ZydisDecodedOperand* operand, ZydisDecoratorType type) { if (!formatter || !buffer || !*buffer || (bufferLen <= 0) || !instruction || !operand) { @@ -649,9 +649,9 @@ static ZydisStatus ZydisFormatterPrintDecoratorIntel(const ZydisFormatter* forma { case ZYDIS_DECORATOR_TYPE_MASK: { - if (mask != ZYDIS_REGISTER_K0) + if (instruction->avx.mask.reg != ZYDIS_REGISTER_K0) { - const char* reg = ZydisRegisterGetString(mask); + const char* reg = ZydisRegisterGetString(instruction->avx.mask.reg); if (!reg) { return ZYDIS_STATUS_INVALID_PARAMETER; @@ -921,21 +921,21 @@ static ZydisStatus ZydisFormatterFormatInstrIntel(const ZydisFormatter* formatte { ZYDIS_CHECK(formatter->funcPrintDecorator(formatter, buffer, bufEnd - *buffer, instruction, &instruction->operands[i], - ZYDIS_DECORATOR_TYPE_MASK, instruction->operands[i + 1].reg)); + ZYDIS_DECORATOR_TYPE_MASK)); } if (instruction->operands[i].type == ZYDIS_OPERAND_TYPE_MEMORY) { ZYDIS_CHECK(formatter->funcPrintDecorator(formatter, buffer, bufEnd - *buffer, instruction, &instruction->operands[i], - ZYDIS_DECORATOR_TYPE_BROADCAST, ZYDIS_REGISTER_NONE)); + ZYDIS_DECORATOR_TYPE_BROADCAST)); if (instruction->encoding == ZYDIS_INSTRUCTION_ENCODING_MVEX) { ZYDIS_CHECK(formatter->funcPrintDecorator(formatter, buffer, bufEnd - *buffer, instruction, &instruction->operands[i], - ZYDIS_DECORATOR_TYPE_CONVERSION, ZYDIS_REGISTER_NONE)); + ZYDIS_DECORATOR_TYPE_CONVERSION)); ZYDIS_CHECK(formatter->funcPrintDecorator(formatter, buffer, bufEnd - *buffer, instruction, &instruction->operands[i], - ZYDIS_DECORATOR_TYPE_EVICTION_HINT, ZYDIS_REGISTER_NONE)); + ZYDIS_DECORATOR_TYPE_EVICTION_HINT)); } } else { @@ -946,18 +946,18 @@ static ZydisStatus ZydisFormatterFormatInstrIntel(const ZydisFormatter* formatte { ZYDIS_CHECK(formatter->funcPrintDecorator(formatter, buffer, bufEnd - *buffer, instruction, &instruction->operands[i], - ZYDIS_DECORATOR_TYPE_SWIZZLE, ZYDIS_REGISTER_NONE)); + ZYDIS_DECORATOR_TYPE_SWIZZLE)); } if (instruction->avx.roundingMode) { ZYDIS_CHECK(formatter->funcPrintDecorator(formatter, buffer, bufEnd - *buffer, instruction, &instruction->operands[i], - ZYDIS_DECORATOR_TYPE_ROUNDING_CONTROL, ZYDIS_REGISTER_NONE)); + ZYDIS_DECORATOR_TYPE_ROUNDING_CONTROL)); } else { ZYDIS_CHECK(formatter->funcPrintDecorator(formatter, buffer, bufEnd - *buffer, instruction, &instruction->operands[i], - ZYDIS_DECORATOR_TYPE_SAE, ZYDIS_REGISTER_NONE)); + ZYDIS_DECORATOR_TYPE_SAE)); } } }