Backported some bugfixes from `future` branch

- Fixed incorrect assert condition (5eb4aab322f021025afbff3c282d900853555db8)
- Fixed gather register check for `VGATHERPF0{D|Q}{PS|PD}` instruction (c020b84cb4027eaced55b4bd61219d8a00f0c332)
- Fixed check for invalid BOUND registers (7de458fa242e9e38233e09262fdc10217c9a0293)
- Fixed printing of hex-suffix for `0` values (e85ef9244d9fe24bc639fb5cb2826f5819bc01f8)
This commit is contained in:
flobernd 2018-05-22 16:16:09 +02:00
parent a343d90628
commit 7f836e7e61
No known key found for this signature in database
GPG Key ID: 9C3AE0ED4A969F10
2 changed files with 24 additions and 7 deletions

View File

@ -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;
}

View File

@ -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;
}