From 74ef4ac22eeb377653b822ddcd72636c91225f93 Mon Sep 17 00:00:00 2001 From: flobernd Date: Sat, 27 Jan 2018 21:57:16 +0100 Subject: [PATCH] Fixed detection of bad gather registers in non 64-bit mode --- src/Decoder.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Decoder.c b/src/Decoder.c index 6dfc8f4..7fc5a3a 100644 --- a/src/Decoder.c +++ b/src/Decoder.c @@ -4325,7 +4325,14 @@ static ZydisStatus ZydisCheckErrorConditions(ZydisDecoderContext* context, ZYDIS_ASSERT((constrREG == ZYDIS_REG_CONSTRAINTS_NONE) && (constrRM == ZYDIS_REG_CONSTRAINTS_VSIB) && (constrNDSNDD == ZYDIS_REG_CONSTRAINTS_NONE)); - mask = context->cache.v_vvvv; + if (context->decoder->machineMode == ZYDIS_MACHINE_MODE_LONG_64) + { + mask = context->cache.v_vvvv; + } else + { + // Ignore the high-register bits in 16- and 32-bit mode + mask = context->cache.v_vvvv & 0x07; + } break; case ZYDIS_INSTRUCTION_ENCODING_EVEX: case ZYDIS_INSTRUCTION_ENCODING_MVEX: