Always decode unknown instructions as "db" (single-byte)

This commit is contained in:
Pierre Pronchery 2011-09-27 22:33:10 +00:00
parent a0bdbe2ee7
commit 07fe0d63a7

View File

@ -66,7 +66,15 @@ static int _i386_decode(ArchPlugin * plugin, ArchInstructionCall * call)
== NULL)
{
u16 = u8;
if(helper->read(helper->arch, &u8, sizeof(u8)) != sizeof(u8))
if(helper->peek(helper->arch, &u8, sizeof(u8)) == sizeof(u8))
{
opcode = (u16 << 8) | u8;
ai = helper->get_instruction_by_opcode(helper->arch, 16,
opcode);
if(ai != NULL)
helper->read(helper->arch, &u8, sizeof(u8));
}
if(ai == NULL)
{
call->name = "db";
call->operands[0].definition = AO_IMMEDIATE(0, 8, 0);
@ -76,18 +84,6 @@ static int _i386_decode(ArchPlugin * plugin, ArchInstructionCall * call)
call->operands_cnt = 1;
return 0;
}
opcode = (u16 << 8) | u8;
if((ai = helper->get_instruction_by_opcode(helper->arch, 16,
opcode)) == NULL)
{
call->name = "dw";
call->operands[0].definition = AO_IMMEDIATE(0, 16, 0);
call->operands[0].value.immediate.name = NULL;
call->operands[0].value.immediate.value = u16;
call->operands[0].value.immediate.negative = 0;
call->operands_cnt = 1;
return 0;
}
}
if((ai = _decode_opcode(plugin, ai)) == NULL)
return -1;