From 07fe0d63a793724c355ea313daf177fb4cb63cb6 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Tue, 27 Sep 2011 22:33:10 +0000 Subject: [PATCH] Always decode unknown instructions as "db" (single-byte) --- src/arch/i386.h | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/arch/i386.h b/src/arch/i386.h index 5b84be1..85049f7 100644 --- a/src/arch/i386.h +++ b/src/arch/i386.h @@ -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;