Minor bugfixes and improvement of the encoder-table

- Fixed scale-factor of memory operands, if SIB byte is used
- Fixed operand-encoding missing for some operands
- Added operand-size and address-size filters to the encoder-table
This commit is contained in:
flobernd 2017-07-09 18:06:43 +02:00
parent 5c07598a2d
commit 8fa80f0b86
5 changed files with 6939 additions and 6937 deletions

View File

@ -223,7 +223,7 @@ int main()
// vcmppd xmm1, xmm2, xmm3, 0x17
0xC5, 0xE9, 0xC2, 0xCB, 0x17,
// vcmpps k2 {k7}, zmm2, zmmword ptr ds:[rax + rbx*4 + 0x100] {1to16}, 0x0F
// vcmpps k2 {k7}, zmm2, dword ptr ds:[rax + rbx*4 + 0x100] {1to16}, 0x0F
0x62, 0xF1, 0x6C, 0x5F, 0xC2, 0x54, 0x98, 0x40, 0x0F
};
@ -234,7 +234,6 @@ int main()
puts("");
disassembleBuffer(&decoder, &data[0], sizeof(data), ZYDIS_TRUE);
getchar();
return 0;
}

View File

@ -303,7 +303,7 @@ enum ZydisOperandActions
/**
* @brief The operand is written and conditionally read by the instruction (must write).
*/
ZYDIS_OPERAND_ACTION_CONDREAD_WRITE,
ZYDIS_OPERAND_ACTION_CONDREAD_WRITE
};
/* ---------------------------------------------------------------------------------------------- */

View File

@ -1415,7 +1415,7 @@ static ZydisStatus ZydisDecodeOperandMemory(ZydisDecoderContext* context,
ZydisCalcRegisterId(context, instruction,
vidxRegisterClass ? ZYDIS_REG_ENCODING_VIDX : ZYDIS_REG_ENCODING_INDEX,
vidxRegisterClass ? vidxRegisterClass : ZYDIS_REGCLASS_GPR32));
operand->mem.scale = (1 << instruction->raw.sib.scale) & ~1;
operand->mem.scale = (1 << instruction->raw.sib.scale);
if (operand->mem.index == ZYDIS_REGISTER_ESP)
{
operand->mem.index = ZYDIS_REGISTER_NONE;
@ -1472,7 +1472,7 @@ static ZydisStatus ZydisDecodeOperandMemory(ZydisDecoderContext* context,
ZydisCalcRegisterId(context, instruction,
vidxRegisterClass ? ZYDIS_REG_ENCODING_VIDX : ZYDIS_REG_ENCODING_INDEX,
vidxRegisterClass ? vidxRegisterClass : ZYDIS_REGCLASS_GPR64));
operand->mem.scale = (1 << instruction->raw.sib.scale) & ~1;
operand->mem.scale = (1 << instruction->raw.sib.scale);;
if (operand->mem.index == ZYDIS_REGISTER_RSP)
{
operand->mem.index = ZYDIS_REGISTER_NONE;
@ -1731,6 +1731,8 @@ static ZydisStatus ZydisDecodeOperands(ZydisDecoderContext* context,
goto FinalizeOperand;
}
instruction->operands[i].encoding = operand->op.encoding;
// Register operands
ZydisRegisterClass registerClass = ZYDIS_REGCLASS_INVALID;
switch (operand->type)
@ -1797,7 +1799,6 @@ static ZydisStatus ZydisDecodeOperands(ZydisDecoderContext* context,
}
if (registerClass)
{
instruction->operands[i].encoding = operand->op.encoding;
switch (operand->op.encoding)
{
case ZYDIS_OPERAND_ENCODING_MODRM_REG:

View File

@ -61,6 +61,8 @@ typedef struct ZydisEncodableInstruction_
uint8_t opcode ZYDIS_BITFIELD( 8);
ZydisOpcodeMap opcodeMap ZYDIS_BITFIELD( 3);
uint8_t mode ZYDIS_BITFIELD( 3);
uint8_t operandSize ZYDIS_BITFIELD( 3);
uint8_t addressSize ZYDIS_BITFIELD( 3);
uint8_t modrmMod ZYDIS_BITFIELD( 4);
ZydisBool forceModrmReg ZYDIS_BITFIELD( 1);
uint8_t modrmReg ZYDIS_BITFIELD( 8);

File diff suppressed because it is too large Load Diff