From baa8f5412c7652c3542ba313d414b4a334493ba4 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Sat, 8 Sep 2018 20:08:26 +0200 Subject: [PATCH] Decode prefixes on i386-based architectures --- src/arch/i386.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/arch/i386.h b/src/arch/i386.h index 4d763c5..e96b16c 100644 --- a/src/arch/i386.h +++ b/src/arch/i386.h @@ -91,6 +91,7 @@ static int _decode_register(AsmArchPlugin * plugin, static int _i386_decode(AsmArchPlugin * plugin, AsmArchInstructionCall * call) { AsmArchPluginHelper * helper = plugin->helper; + AsmArchPrefix const * ap = NULL; AsmArchInstruction const * ai = NULL; unsigned int opcode; uint8_t u8; @@ -101,6 +102,13 @@ static int _i386_decode(AsmArchPlugin * plugin, AsmArchInstructionCall * call) if(helper->read(helper->arch, &u8, sizeof(u8)) != sizeof(u8)) return -1; opcode = u8; + if((ap = helper->get_prefix_by_opcode(helper->arch, 8, opcode)) + != NULL) + { + if(helper->read(helper->arch, &u8, sizeof(u8)) != sizeof(u8)) + return -1; + opcode = u8; + } if((ai = helper->get_instruction_by_opcode(helper->arch, 8, opcode)) == NULL) { @@ -116,6 +124,8 @@ static int _i386_decode(AsmArchPlugin * plugin, AsmArchInstructionCall * call) } } } + /* FIXME ignore prefixes when opcodes are not recognized */ + call->prefix = (ap != NULL) ? ap->name : NULL; if(ai == NULL) { /* no opcode was recognized */