From d37aefee4edb15ca58534454c7d5dd87af696fef Mon Sep 17 00:00:00 2001 From: iximeow Date: Fri, 29 Nov 2019 17:21:28 -0800 Subject: hack to handle prefixed sequences that might appear to be escaped opcodes --- src/lib.rs | 8 ++++++-- test/test.rs | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index d507f3c..312be7c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1237,7 +1237,8 @@ const BITWISE_OPCODE_MAP: [Opcode; 8] = [ Opcode::SAR ]; fn read_opcode_660f_map>(_bytes_iter: &mut T, _length: &mut u8) -> Option { - panic!("660f opcode map unsupported".to_string()); + None +// panic!("660f opcode map unsupported".to_string()); } const OPCODE_F20F_MAP: [OpcodeRecord; 256] = [ @@ -2645,7 +2646,10 @@ pub fn read_instr>(mut bytes_iter: T, instruction: &mut Ins } else if b == 0x0f { if let Some(record) = match alternate_opcode_map { Some(OpcodeMap::Map66) => { - read_opcode_660f_map(&mut bytes_iter, &mut length) + // read_opcode_660f_map(&mut bytes_iter, &mut length) + prefixes.set_operand_size(); + length += 1; + Some(OPCODES[bytes_iter.next().unwrap() as usize]) }, Some(OpcodeMap::MapF2) => { read_opcode_f20f_map(&mut bytes_iter, &mut length) diff --git a/test/test.rs b/test/test.rs index b88e470..90a1599 100644 --- a/test/test.rs +++ b/test/test.rs @@ -89,6 +89,7 @@ fn test_arithmetic() { test_display(&[0x81, 0xec, 0x10, 0x03, 0x00, 0x00], "sub esp, 0x310"); test_display(&[0x0f, 0xaf, 0xc2], "imul eax, edx"); test_display(&[0x4b, 0x69, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65], "imul rax, [r11 + 0x6f], 0x656c706d"); + test_display(&[0x66, 0x0f, 0xaf, 0xd1], "imul dx, cx"); test_display(&[0x4b, 0x6b, 0x43, 0x6f, 0x6d], "imul al, [r11 + 0x6f], 0x6d"); test_display(&[0x4f, 0x4e, 0x00, 0xcc], "add spl, r9b"); } -- cgit v1.1