diff --git a/src/Decoder.c b/src/Decoder.c index 293ea1c..ea0fe36 100644 --- a/src/Decoder.c +++ b/src/Decoder.c @@ -4231,8 +4231,7 @@ static ZydisStatus ZydisCheckErrorConditions(ZydisDecoderContext* context, case ZYDIS_REG_CONSTRAINTS_MASK: break; case ZYDIS_REG_CONSTRAINTS_BND: - ZYDIS_ASSERT(!context->cache.X); - if (context->cache.B || instruction->raw.modrm.rm > 3) + if (context->cache.B || context->cache.X || instruction->raw.modrm.rm > 3) { return ZYDIS_STATUS_BAD_REGISTER; } @@ -4293,7 +4292,7 @@ static ZydisStatus ZydisCheckErrorConditions(ZydisDecoderContext* context, dest = dest | (context->cache.R << 3) | (context->cache.R2 << 4); index = index | (context->cache.X << 3) | (context->cache.V2 << 4); } - ZydisU8 mask = 0xFF; + ZydisU8 mask = 0xF0; switch (instruction->encoding) { @@ -4312,10 +4311,18 @@ static ZydisStatus ZydisCheckErrorConditions(ZydisDecoderContext* context, break; case ZYDIS_INSTRUCTION_ENCODING_EVEX: case ZYDIS_INSTRUCTION_ENCODING_MVEX: - ZYDIS_ASSERT((constrREG == ZYDIS_REG_CONSTRAINTS_NONE) && - (constrRM == ZYDIS_REG_CONSTRAINTS_VSIB) && - (constrNDSNDD == ZYDIS_REG_CONSTRAINTS_UNUSED)); - break; + ZYDIS_ASSERT(((constrREG == ZYDIS_REG_CONSTRAINTS_UNUSED) || + (constrREG == ZYDIS_REG_CONSTRAINTS_NONE)) && + (constrRM == ZYDIS_REG_CONSTRAINTS_VSIB) && + (constrNDSNDD == ZYDIS_REG_CONSTRAINTS_UNUSED)); + + // Some gather instructions (like `VGATHERPF0{D|Q}{PS|PD}`) doe not have a destination + // operand + if (constrREG == ZYDIS_REG_CONSTRAINTS_UNUSED) + { + dest = 0xF1; + } + break; default: ZYDIS_UNREACHABLE; } diff --git a/src/String.c b/src/String.c index 87cb6fd..d6a1c97 100644 --- a/src/String.c +++ b/src/String.c @@ -134,6 +134,11 @@ ZydisStatus ZydisStringAppendHexU32(ZydisString* string, ZydisU32 value, ZydisU8 ZydisMemorySet(buffer, '0', n); string->length += n; + if (suffix) + { + ZYDIS_CHECK(ZydisStringAppend(string, suffix)); + } + return ZYDIS_STATUS_SUCCESS; } @@ -244,6 +249,11 @@ ZydisStatus ZydisStringAppendHexU64(ZydisString* string, ZydisU64 value, ZydisU8 ZydisMemorySet(buffer, '0', n); string->length += n; + if (suffix) + { + ZYDIS_CHECK(ZydisStringAppend(string, suffix)); + } + return ZYDIS_STATUS_SUCCESS; }