Fixed check for invalid gather registers in non 64-bit mode

This commit is contained in:
flobernd 2018-03-13 13:24:20 +01:00
parent 16e6d0f02b
commit 16c60185a6
No known key found for this signature in database
GPG Key ID: 9C3AE0ED4A969F10
1 changed files with 9 additions and 5 deletions

View File

@ -4279,16 +4279,20 @@ static ZydisStatus ZydisCheckErrorConditions(ZydisDecoderContext* context,
ZYDIS_UNREACHABLE; ZYDIS_UNREACHABLE;
} }
// Check gather/scatter registers // Check gather registers
if (isGather) if (isGather)
{ {
ZYDIS_ASSERT(hasVSIB); ZYDIS_ASSERT(hasVSIB);
ZYDIS_ASSERT(instruction->raw.modrm.mod != 3); ZYDIS_ASSERT(instruction->raw.modrm.mod != 3);
ZYDIS_ASSERT(instruction->raw.modrm.rm == 4); ZYDIS_ASSERT(instruction->raw.modrm.rm == 4);
const ZydisU8 dest = instruction->raw.modrm.reg | (context->cache.R << 3) |
(context->cache.R2 << 4); ZydisU8 dest = instruction->raw.modrm.reg;
const ZydisU8 index = instruction->raw.sib.index | (context->cache.X << 3) | ZydisU8 index = instruction->raw.sib.index;
(context->cache.V2 << 4); if (context->decoder->machineMode == ZYDIS_MACHINE_MODE_LONG_64)
{
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 = 0xFF;
switch (instruction->encoding) switch (instruction->encoding)