Minor refactorings

- Adjusted datatype of some enums
- Renamed some things
  - `ZydisDecodedInstruction.flags` -> `ZydisDecodedInstruction.accessedFlags`
  - `ZydisDecodedInstruction.meta.roundingMode` -> `ZydisDecodedInstruction.meta.rounding.mode`
  - `ZydisDecodedInstruction.meta.swizzleMode` -> `ZydisDecodedInstruction.meta.swizzle.mode`
  - `ZydisDecodedInstruction.meta.conversionMode` -> `ZydisDecodedInstruction.meta.conversion.mode`
  - `ZydisGetCPUFlagsByAction` -> `ZydisGetAccessedFlagsByAction`
This commit is contained in:
flobernd 2017-09-10 21:43:52 +02:00
parent 5d6c58ad1c
commit 01b8267d47
14 changed files with 91 additions and 73 deletions

View File

@ -480,7 +480,7 @@ enum ZydisCPUFlagActions
/** /**
* @brief Defines the @c ZydisExceptionClass datatype. * @brief Defines the @c ZydisExceptionClass datatype.
*/ */
typedef uint16_t ZydisExceptionClass; typedef uint8_t ZydisExceptionClass;
/** /**
* @brief Values that represent exception-classes. * @brief Values that represent exception-classes.
@ -583,7 +583,7 @@ enum ZydisMaskModes
/** /**
* @brief Defines the @c ZydisBroadcastMode datatype. * @brief Defines the @c ZydisBroadcastMode datatype.
*/ */
typedef uint16_t ZydisBroadcastMode; typedef uint8_t ZydisBroadcastMode;
/** /**
* @brief Values that represent AVX broadcast-modes. * @brief Values that represent AVX broadcast-modes.
@ -645,7 +645,7 @@ enum ZydisRoundingModes
/** /**
* @brief Defines the @c ZydisSwizzleMode datatype. * @brief Defines the @c ZydisSwizzleMode datatype.
*/ */
typedef uint16_t ZydisSwizzleMode; typedef uint8_t ZydisSwizzleMode;
/** /**
* @brief Values that represent swizzle-modes. * @brief Values that represent swizzle-modes.
@ -670,7 +670,7 @@ enum ZydisSwizzleModes
/** /**
* @brief Defines the @c ZydisConversionMode datatype. * @brief Defines the @c ZydisConversionMode datatype.
*/ */
typedef uint16_t ZydisConversionMode; typedef uint8_t ZydisConversionMode;
/** /**
* @brief Values that represent conversion-modes. * @brief Values that represent conversion-modes.
@ -766,11 +766,11 @@ typedef struct ZydisDecodedInstruction_
/** /**
* @brief The CPU-flag action. * @brief The CPU-flag action.
* *
* You can call `ZydisGetCPUFlagsByAction` to get a mask with all flags matching a specific * You can call `ZydisGetAccessedFlagsByAction` to get a mask with all flags matching a
* action. * specific action.
*/ */
ZydisCPUFlagAction action; ZydisCPUFlagAction action;
} flags[ZYDIS_CPUFLAG_ENUM_COUNT]; } accessedFlags[ZYDIS_CPUFLAG_ENUM_COUNT];
/** /**
* @brief Extended info for AVX instructions. * @brief Extended info for AVX instructions.
*/ */
@ -799,7 +799,7 @@ typedef struct ZydisDecodedInstruction_
ZydisBool isControlMask; ZydisBool isControlMask;
} mask; } mask;
/** /**
* @brief Contains info about the AVX broadcast-factor. * @brief Contains info about the AVX broadcast.
*/ */
struct struct
{ {
@ -815,18 +815,36 @@ typedef struct ZydisDecodedInstruction_
*/ */
ZydisBroadcastMode mode; ZydisBroadcastMode mode;
} broadcast; } broadcast;
/**
* @brief Contains info about the AVX rounding.
*/
struct
{
/** /**
* @brief The AVX rounding-mode. * @brief The AVX rounding-mode.
*/ */
ZydisRoundingMode roundingMode; ZydisRoundingMode mode;
} rounding;
/**
* @brief Contains info about the AVX register-swizzle (MVEX only).
*/
struct
{
/** /**
* @brief The AVX register-swizzle mode (MVEX only). * @brief The AVX register-swizzle mode (MVEX only).
*/ */
ZydisSwizzleMode swizzleMode; ZydisSwizzleMode mode;
} swizzle;
/**
* @brief Contains info about the AVX data-conversion (MVEX only).
*/
struct
{
/** /**
* @brief The AVX data-conversion mode (MVEX only). * @brief The AVX data-conversion mode (MVEX only).
*/ */
ZydisConversionMode conversionMode; ZydisConversionMode mode;
} conversion;
/** /**
* @brief Signals, if the sae functionality is enabled for the instruction. * @brief Signals, if the sae functionality is enabled for the instruction.
*/ */

View File

@ -1,3 +1,5 @@
typedef uint8_t ZydisISAExt;
enum ZydisISAExts enum ZydisISAExts
{ {
ZYDIS_ISA_EXT_INVALID, ZYDIS_ISA_EXT_INVALID,

View File

@ -1,3 +1,5 @@
typedef uint8_t ZydisISASet;
enum ZydisISASets enum ZydisISASets
{ {
ZYDIS_ISA_SET_INVALID, ZYDIS_ISA_SET_INVALID,

View File

@ -1,4 +1,6 @@
enum ZydisCategories typedef uint8_t ZydisInstructionCategory;
enum ZydisInstructionCategories
{ {
ZYDIS_CATEGORY_INVALID, ZYDIS_CATEGORY_INVALID,
ZYDIS_CATEGORY_AES, ZYDIS_CATEGORY_AES,

View File

@ -1,3 +1,5 @@
typedef uint16_t ZydisMnemonic;
enum ZydisMnemonics enum ZydisMnemonics
{ {
ZYDIS_MNEMONIC_INVALID, ZYDIS_MNEMONIC_INVALID,

View File

@ -46,22 +46,16 @@ extern "C" {
/** /**
* @brief Defines the @c ZydisInstructionCategory datatype. * @brief Defines the @c ZydisInstructionCategory datatype.
*/ */
typedef uint16_t ZydisInstructionCategory; #include <Zydis/Generated/EnumInstructionCategory.h>
#include <Zydis/Generated/EnumCategory.h>
/** /**
* @brief Defines the @c ZydisISASet datatype. * @brief Defines the @c ZydisISASet datatype.
*/ */
typedef uint16_t ZydisISASet;
#include <Zydis/Generated/EnumISASet.h> #include <Zydis/Generated/EnumISASet.h>
/** /**
* @brief Defines the @c ZydisISAExt datatype. * @brief Defines the @c ZydisISAExt datatype.
*/ */
typedef uint16_t ZydisISAExt;
#include <Zydis/Generated/EnumISAExt.h> #include <Zydis/Generated/EnumISAExt.h>
/* ============================================================================================== */ /* ============================================================================================== */

View File

@ -46,8 +46,6 @@ extern "C" {
/** /**
* @brief Defines the @c ZydisMnemonic datatype. * @brief Defines the @c ZydisMnemonic datatype.
*/ */
typedef uint16_t ZydisMnemonic;
#include <Zydis/Generated/EnumMnemonic.h> #include <Zydis/Generated/EnumMnemonic.h>
/* ============================================================================================== */ /* ============================================================================================== */

View File

@ -62,7 +62,7 @@ ZYDIS_EXPORT ZydisStatus ZydisUtilsCalcAbsoluteTargetAddress(
/* ============================================================================================== */ /* ============================================================================================== */
/** /**
* @brief Returns a mask of CPU-flags matching the given `action`. * @brief Returns a mask of accessed CPU-flags matching the given `action`.
* *
* @param instruction A pointer to the @c ZydisDecodedInstruction struct. * @param instruction A pointer to the @c ZydisDecodedInstruction struct.
* @param action The CPU-flag action. * @param action The CPU-flag action.
@ -70,7 +70,7 @@ ZYDIS_EXPORT ZydisStatus ZydisUtilsCalcAbsoluteTargetAddress(
* *
* @return A zydis status code * @return A zydis status code
*/ */
ZYDIS_EXPORT ZydisStatus ZydisGetCPUFlagsByAction(const ZydisDecodedInstruction* instruction, ZYDIS_EXPORT ZydisStatus ZydisGetAccessedFlagsByAction(const ZydisDecodedInstruction* instruction,
ZydisCPUFlagAction action, ZydisCPUFlagMask* flags); ZydisCPUFlagAction action, ZydisCPUFlagMask* flags);
/* ============================================================================================== */ /* ============================================================================================== */

View File

@ -1153,7 +1153,7 @@ static void ZydisSetOperandSizeAndElementInfo(ZydisDecoderContext* context,
ZYDIS_ASSERT(definition->elementType == ZYDIS_IELEMENT_TYPE_VARIABLE); ZYDIS_ASSERT(definition->elementType == ZYDIS_IELEMENT_TYPE_VARIABLE);
ZYDIS_ASSERT(instruction->avx.vectorLength == 512); ZYDIS_ASSERT(instruction->avx.vectorLength == 512);
switch (instruction->avx.conversionMode) switch (instruction->avx.conversion.mode)
{ {
case ZYDIS_CONVERSION_MODE_INVALID: case ZYDIS_CONVERSION_MODE_INVALID:
operand->size = 512; operand->size = 512;
@ -2205,7 +2205,7 @@ static void ZydisSetAccessedFlags(ZydisDecodedInstruction* instruction,
ZYDIS_ASSERT(ZYDIS_ARRAY_SIZE(instruction->flags) == ZYDIS_ARRAY_SIZE(flags->action)); ZYDIS_ASSERT(ZYDIS_ARRAY_SIZE(instruction->flags) == ZYDIS_ARRAY_SIZE(flags->action));
memcpy(&instruction->flags, &flags->action, ZYDIS_ARRAY_SIZE(flags->action)); memcpy(&instruction->accessedFlags, &flags->action, ZYDIS_ARRAY_SIZE(flags->action));
} }
/** /**
@ -2681,7 +2681,7 @@ static void ZydisSetAVXInformation(ZydisDecoderContext* context,
// Noting to do here // Noting to do here
break; break;
case ZYDIS_EVEX_FUNC_RC: case ZYDIS_EVEX_FUNC_RC:
instruction->avx.roundingMode = ZYDIS_ROUNDING_MODE_RN + context->cache.LL; instruction->avx.rounding.mode = ZYDIS_ROUNDING_MODE_RN + context->cache.LL;
// Intentional fallthrough // Intentional fallthrough
case ZYDIS_EVEX_FUNC_SAE: case ZYDIS_EVEX_FUNC_SAE:
instruction->avx.hasSAE = ZYDIS_TRUE; instruction->avx.hasSAE = ZYDIS_TRUE;
@ -2838,7 +2838,7 @@ static void ZydisSetAVXInformation(ZydisDecoderContext* context,
// Nothing to do here // Nothing to do here
break; break;
case ZYDIS_MVEX_FUNC_RC: case ZYDIS_MVEX_FUNC_RC:
instruction->avx.roundingMode = ZYDIS_ROUNDING_MODE_RN + instruction->raw.mvex.SSS; instruction->avx.rounding.mode = ZYDIS_ROUNDING_MODE_RN + instruction->raw.mvex.SSS;
break; break;
case ZYDIS_MVEX_FUNC_SAE: case ZYDIS_MVEX_FUNC_SAE:
if (instruction->raw.mvex.SSS >= 4) if (instruction->raw.mvex.SSS >= 4)
@ -2848,7 +2848,7 @@ static void ZydisSetAVXInformation(ZydisDecoderContext* context,
break; break;
case ZYDIS_MVEX_FUNC_SWIZZLE_32: case ZYDIS_MVEX_FUNC_SWIZZLE_32:
case ZYDIS_MVEX_FUNC_SWIZZLE_64: case ZYDIS_MVEX_FUNC_SWIZZLE_64:
instruction->avx.swizzleMode = ZYDIS_SWIZZLE_MODE_DCBA + instruction->raw.mvex.SSS; instruction->avx.swizzle.mode = ZYDIS_SWIZZLE_MODE_DCBA + instruction->raw.mvex.SSS;
break; break;
case ZYDIS_MVEX_FUNC_SF_32: case ZYDIS_MVEX_FUNC_SF_32:
case ZYDIS_MVEX_FUNC_SF_32_BCST: case ZYDIS_MVEX_FUNC_SF_32_BCST:
@ -2864,19 +2864,19 @@ static void ZydisSetAVXInformation(ZydisDecoderContext* context,
instruction->avx.broadcast.mode = ZYDIS_BROADCAST_MODE_4_TO_16; instruction->avx.broadcast.mode = ZYDIS_BROADCAST_MODE_4_TO_16;
break; break;
case 3: case 3:
instruction->avx.conversionMode = ZYDIS_CONVERSION_MODE_FLOAT16; instruction->avx.conversion.mode = ZYDIS_CONVERSION_MODE_FLOAT16;
break; break;
case 4: case 4:
instruction->avx.conversionMode = ZYDIS_CONVERSION_MODE_UINT8; instruction->avx.conversion.mode = ZYDIS_CONVERSION_MODE_UINT8;
break; break;
case 5: case 5:
instruction->avx.conversionMode = ZYDIS_CONVERSION_MODE_SINT8; instruction->avx.conversion.mode = ZYDIS_CONVERSION_MODE_SINT8;
break; break;
case 6: case 6:
instruction->avx.conversionMode = ZYDIS_CONVERSION_MODE_UINT16; instruction->avx.conversion.mode = ZYDIS_CONVERSION_MODE_UINT16;
break; break;
case 7: case 7:
instruction->avx.conversionMode = ZYDIS_CONVERSION_MODE_SINT16; instruction->avx.conversion.mode = ZYDIS_CONVERSION_MODE_SINT16;
break; break;
default: default:
ZYDIS_UNREACHABLE; ZYDIS_UNREACHABLE;
@ -2896,16 +2896,16 @@ static void ZydisSetAVXInformation(ZydisDecoderContext* context,
instruction->avx.broadcast.mode = ZYDIS_BROADCAST_MODE_4_TO_16; instruction->avx.broadcast.mode = ZYDIS_BROADCAST_MODE_4_TO_16;
break; break;
case 4: case 4:
instruction->avx.conversionMode = ZYDIS_CONVERSION_MODE_UINT8; instruction->avx.conversion.mode = ZYDIS_CONVERSION_MODE_UINT8;
break; break;
case 5: case 5:
instruction->avx.conversionMode = ZYDIS_CONVERSION_MODE_SINT8; instruction->avx.conversion.mode = ZYDIS_CONVERSION_MODE_SINT8;
break; break;
case 6: case 6:
instruction->avx.conversionMode = ZYDIS_CONVERSION_MODE_UINT16; instruction->avx.conversion.mode = ZYDIS_CONVERSION_MODE_UINT16;
break; break;
case 7: case 7:
instruction->avx.conversionMode = ZYDIS_CONVERSION_MODE_SINT16; instruction->avx.conversion.mode = ZYDIS_CONVERSION_MODE_SINT16;
break; break;
default: default:
ZYDIS_UNREACHABLE; ZYDIS_UNREACHABLE;
@ -2934,19 +2934,19 @@ static void ZydisSetAVXInformation(ZydisDecoderContext* context,
case 0: case 0:
break; break;
case 3: case 3:
instruction->avx.conversionMode = ZYDIS_CONVERSION_MODE_FLOAT16; instruction->avx.conversion.mode = ZYDIS_CONVERSION_MODE_FLOAT16;
break; break;
case 4: case 4:
instruction->avx.conversionMode = ZYDIS_CONVERSION_MODE_UINT8; instruction->avx.conversion.mode = ZYDIS_CONVERSION_MODE_UINT8;
break; break;
case 5: case 5:
instruction->avx.conversionMode = ZYDIS_CONVERSION_MODE_SINT8; instruction->avx.conversion.mode = ZYDIS_CONVERSION_MODE_SINT8;
break; break;
case 6: case 6:
instruction->avx.conversionMode = ZYDIS_CONVERSION_MODE_UINT16; instruction->avx.conversion.mode = ZYDIS_CONVERSION_MODE_UINT16;
break; break;
case 7: case 7:
instruction->avx.conversionMode = ZYDIS_CONVERSION_MODE_SINT16; instruction->avx.conversion.mode = ZYDIS_CONVERSION_MODE_SINT16;
break; break;
default: default:
ZYDIS_UNREACHABLE; ZYDIS_UNREACHABLE;
@ -2962,16 +2962,16 @@ static void ZydisSetAVXInformation(ZydisDecoderContext* context,
case 0: case 0:
break; break;
case 4: case 4:
instruction->avx.conversionMode = ZYDIS_CONVERSION_MODE_UINT8; instruction->avx.conversion.mode = ZYDIS_CONVERSION_MODE_UINT8;
break; break;
case 5: case 5:
instruction->avx.conversionMode = ZYDIS_CONVERSION_MODE_SINT8; instruction->avx.conversion.mode = ZYDIS_CONVERSION_MODE_SINT8;
break; break;
case 6: case 6:
instruction->avx.conversionMode = ZYDIS_CONVERSION_MODE_UINT16; instruction->avx.conversion.mode = ZYDIS_CONVERSION_MODE_UINT16;
break; break;
case 7: case 7:
instruction->avx.conversionMode = ZYDIS_CONVERSION_MODE_SINT16; instruction->avx.conversion.mode = ZYDIS_CONVERSION_MODE_SINT16;
break; break;
default: default:
ZYDIS_UNREACHABLE; ZYDIS_UNREACHABLE;

View File

@ -728,7 +728,7 @@ static ZydisStatus ZydisFormatterPrintDecoratorIntel(const ZydisFormatter* forma
case ZYDIS_DECORATOR_TYPE_ROUNDING_CONTROL: case ZYDIS_DECORATOR_TYPE_ROUNDING_CONTROL:
if (instruction->avx.hasSAE) if (instruction->avx.hasSAE)
{ {
switch (instruction->avx.roundingMode) switch (instruction->avx.rounding.mode)
{ {
case ZYDIS_ROUNDING_MODE_INVALID: case ZYDIS_ROUNDING_MODE_INVALID:
break; break;
@ -753,7 +753,7 @@ static ZydisStatus ZydisFormatterPrintDecoratorIntel(const ZydisFormatter* forma
} }
} else } else
{ {
switch (instruction->avx.roundingMode) switch (instruction->avx.rounding.mode)
{ {
case ZYDIS_ROUNDING_MODE_INVALID: case ZYDIS_ROUNDING_MODE_INVALID:
break; break;
@ -779,14 +779,14 @@ static ZydisStatus ZydisFormatterPrintDecoratorIntel(const ZydisFormatter* forma
} }
break; break;
case ZYDIS_DECORATOR_TYPE_SAE: case ZYDIS_DECORATOR_TYPE_SAE:
if (instruction->avx.hasSAE && !instruction->avx.roundingMode) if (instruction->avx.hasSAE && !instruction->avx.rounding.mode)
{ {
ZYDIS_CHECK(ZydisStringBufferAppend(buffer, bufEnd - *buffer, ZYDIS_CHECK(ZydisStringBufferAppend(buffer, bufEnd - *buffer,
ZYDIS_STRBUF_APPEND_MODE_DEFAULT, " {sae}")); ZYDIS_STRBUF_APPEND_MODE_DEFAULT, " {sae}"));
} }
break; break;
case ZYDIS_DECORATOR_TYPE_SWIZZLE: case ZYDIS_DECORATOR_TYPE_SWIZZLE:
switch (instruction->avx.swizzleMode) switch (instruction->avx.swizzle.mode)
{ {
case ZYDIS_SWIZZLE_MODE_INVALID: case ZYDIS_SWIZZLE_MODE_INVALID:
case ZYDIS_SWIZZLE_MODE_DCBA: case ZYDIS_SWIZZLE_MODE_DCBA:
@ -825,7 +825,7 @@ static ZydisStatus ZydisFormatterPrintDecoratorIntel(const ZydisFormatter* forma
} }
break; break;
case ZYDIS_DECORATOR_TYPE_CONVERSION: case ZYDIS_DECORATOR_TYPE_CONVERSION:
switch (instruction->avx.conversionMode) switch (instruction->avx.conversion.mode)
{ {
case ZYDIS_CONVERSION_MODE_INVALID: case ZYDIS_CONVERSION_MODE_INVALID:
break; break;

View File

@ -1,4 +1,4 @@
static const char* zydisCategoryStrings[] = static const char* zydisInstructionCategoryStrings[] =
{ {
"INVALID", "INVALID",
"AES", "AES",

View File

@ -30,7 +30,7 @@
/* Enum strings */ /* Enum strings */
/* ============================================================================================== */ /* ============================================================================================== */
#include <Generated/EnumCategoryStrings.inc> #include <Generated/EnumInstructionCategoryStrings.inc>
#include <Generated/EnumISASetStrings.inc> #include <Generated/EnumISASetStrings.inc>
#include <Generated/EnumISAExtStrings.inc> #include <Generated/EnumISAExtStrings.inc>
@ -40,11 +40,11 @@
const char* ZydisCategoryGetString(ZydisInstructionCategory category) const char* ZydisCategoryGetString(ZydisInstructionCategory category)
{ {
if (category > ZYDIS_ARRAY_SIZE(zydisCategoryStrings) - 1) if (category > ZYDIS_ARRAY_SIZE(zydisInstructionCategoryStrings) - 1)
{ {
return NULL; return NULL;
} }
return zydisCategoryStrings[category]; return zydisInstructionCategoryStrings[category];
} }
const char* ZydisISASetGetString(ZydisISASet isaSet) const char* ZydisISASetGetString(ZydisISASet isaSet)

View File

@ -97,7 +97,7 @@ ZydisStatus ZydisUtilsCalcAbsoluteTargetAddress(const ZydisDecodedInstruction* i
/* Exported functions */ /* Exported functions */
/* ---------------------------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------------------------- */
ZydisStatus ZydisGetCPUFlagsByAction(const ZydisDecodedInstruction* instruction, ZydisStatus ZydisGetAccessedFlagsByAction(const ZydisDecodedInstruction* instruction,
ZydisCPUFlagAction action, ZydisCPUFlagMask* flags) ZydisCPUFlagAction action, ZydisCPUFlagMask* flags)
{ {
if (!instruction) if (!instruction)
@ -105,9 +105,9 @@ ZydisStatus ZydisGetCPUFlagsByAction(const ZydisDecodedInstruction* instruction,
return ZYDIS_STATUS_INVALID_PARAMETER; return ZYDIS_STATUS_INVALID_PARAMETER;
} }
*flags = 0; *flags = 0;
for (uint8_t i = 0; i < ZYDIS_ARRAY_SIZE(instruction->flags); ++i) for (uint8_t i = 0; i < ZYDIS_ARRAY_SIZE(instruction->accessedFlags); ++i)
{ {
if (instruction->flags[i].action == action) if (instruction->accessedFlags[i].action == action)
{ {
*flags |= (1 << i); *flags |= (1 << i);
} }

View File

@ -251,30 +251,30 @@ void printFlags(ZydisDecodedInstruction* instruction)
fputs("=======================================\n", stdout); fputs("=======================================\n", stdout);
printf(" ACTIONS: "); printf(" ACTIONS: ");
uint8_t c = 0; uint8_t c = 0;
for (ZydisCPUFlag i = 0; i < ZYDIS_ARRAY_SIZE(instruction->flags); ++i) for (ZydisCPUFlag i = 0; i < ZYDIS_ARRAY_SIZE(instruction->accessedFlags); ++i)
{ {
if (instruction->flags[i].action != ZYDIS_CPUFLAG_ACTION_NONE) if (instruction->accessedFlags[i].action != ZYDIS_CPUFLAG_ACTION_NONE)
{ {
if (c && (c % 8 == 0)) if (c && (c % 8 == 0))
{ {
printf("\n "); printf("\n ");
} }
++c; ++c;
printf("[%-4s: %s] ", flagNames[i], flagActions[instruction->flags[i].action]); printf("[%-4s: %s] ", flagNames[i], flagActions[instruction->accessedFlags[i].action]);
} }
} }
puts(c ? "" : "none"); puts(c ? "" : "none");
ZydisCPUFlagMask flags, temp; ZydisCPUFlagMask flags, temp;
ZydisGetCPUFlagsByAction(instruction, ZYDIS_CPUFLAG_ACTION_TESTED, &flags); ZydisGetAccessedFlagsByAction(instruction, ZYDIS_CPUFLAG_ACTION_TESTED, &flags);
printf(" READ: 0x%08" PRIX32 "\n", flags); printf(" READ: 0x%08" PRIX32 "\n", flags);
ZydisGetCPUFlagsByAction(instruction, ZYDIS_CPUFLAG_ACTION_MODIFIED, &flags); ZydisGetAccessedFlagsByAction(instruction, ZYDIS_CPUFLAG_ACTION_MODIFIED, &flags);
ZydisGetCPUFlagsByAction(instruction, ZYDIS_CPUFLAG_ACTION_SET_0, &temp); ZydisGetAccessedFlagsByAction(instruction, ZYDIS_CPUFLAG_ACTION_SET_0, &temp);
flags |= temp; flags |= temp;
ZydisGetCPUFlagsByAction(instruction, ZYDIS_CPUFLAG_ACTION_SET_1, &temp); ZydisGetAccessedFlagsByAction(instruction, ZYDIS_CPUFLAG_ACTION_SET_1, &temp);
flags |= temp; flags |= temp;
printf(" WRITTEN: 0x%08" PRIX32 "\n", flags); printf(" WRITTEN: 0x%08" PRIX32 "\n", flags);
ZydisGetCPUFlagsByAction(instruction, ZYDIS_CPUFLAG_ACTION_UNDEFINED, &flags); ZydisGetAccessedFlagsByAction(instruction, ZYDIS_CPUFLAG_ACTION_UNDEFINED, &flags);
printf(" UNDEFINED: 0x%08" PRIX32 "\n", flags); printf(" UNDEFINED: 0x%08" PRIX32 "\n", flags);
} }
@ -346,19 +346,19 @@ void printAVXInfo(ZydisDecodedInstruction* instruction)
switch (instruction->encoding) switch (instruction->encoding)
{ {
case ZYDIS_INSTRUCTION_ENCODING_EVEX: case ZYDIS_INSTRUCTION_ENCODING_EVEX:
printf("\n ROUNDING: %s", roundingModeStrings[instruction->avx.roundingMode]); printf("\n ROUNDING: %s", roundingModeStrings[instruction->avx.rounding.mode]);
printf("\n SAE: %s", instruction->avx.hasSAE ? "Y" : "N"); printf("\n SAE: %s", instruction->avx.hasSAE ? "Y" : "N");
printf("\n MASK: %s [%5s]%s", ZydisRegisterGetString(instruction->avx.mask.reg), printf("\n MASK: %s [%5s]%s", ZydisRegisterGetString(instruction->avx.mask.reg),
maskModeStrings[instruction->avx.mask.mode], maskModeStrings[instruction->avx.mask.mode],
instruction->avx.mask.isControlMask ? " (control-mask)" : ""); instruction->avx.mask.isControlMask ? " (control-mask)" : "");
break; break;
case ZYDIS_INSTRUCTION_ENCODING_MVEX: case ZYDIS_INSTRUCTION_ENCODING_MVEX:
printf("\n ROUNDING: %s", roundingModeStrings[instruction->avx.roundingMode]); printf("\n ROUNDING: %s", roundingModeStrings[instruction->avx.rounding.mode]);
printf("\n SAE: %s", instruction->avx.hasSAE ? "Y" : "N"); printf("\n SAE: %s", instruction->avx.hasSAE ? "Y" : "N");
printf("\n MASK: %s [MERGE]", ZydisRegisterGetString(instruction->avx.mask.reg)); printf("\n MASK: %s [MERGE]", ZydisRegisterGetString(instruction->avx.mask.reg));
printf("\n EH: %s", instruction->avx.hasEvictionHint ? "Y" : "N"); printf("\n EH: %s", instruction->avx.hasEvictionHint ? "Y" : "N");
printf("\n SWIZZLE: %s", swizzleModeStrings[instruction->avx.swizzleMode]); printf("\n SWIZZLE: %s", swizzleModeStrings[instruction->avx.swizzle.mode]);
printf("\n CONVERT: %s", conversionModeStrings[instruction->avx.conversionMode]); printf("\n CONVERT: %s", conversionModeStrings[instruction->avx.conversion.mode]);
break; break;
default: default:
break; break;