mirror of
https://github.com/cea-sec/miasm
synced 2026-08-17 10:26:03 -04:00
x86_64 Fix multiple REX prefix instruction disasm (#1376)
Fix multiple rex prefixes
This commit is contained in:
parent
069440e8b4
commit
fcb324e04e
2 changed files with 14 additions and 3 deletions
|
|
@ -751,14 +751,18 @@ class mn_x86(cls_mn):
|
|||
break
|
||||
pre_dis_info['prefix'] += c
|
||||
offset += 1
|
||||
if mode == 64 and c in b'@ABCDEFGHIJKLMNO':
|
||||
x = ord(c)
|
||||
rex_prefixes = b'@ABCDEFGHIJKLMNO'
|
||||
if mode == 64 and c in rex_prefixes:
|
||||
while c in rex_prefixes:
|
||||
# multiple REX prefixes case - use last REX prefix
|
||||
x = ord(c)
|
||||
offset += 1
|
||||
c = v.getbytes(offset)
|
||||
pre_dis_info['rex_p'] = 1
|
||||
pre_dis_info['rex_w'] = (x >> 3) & 1
|
||||
pre_dis_info['rex_r'] = (x >> 2) & 1
|
||||
pre_dis_info['rex_x'] = (x >> 1) & 1
|
||||
pre_dis_info['rex_b'] = (x >> 0) & 1
|
||||
offset += 1
|
||||
elif pre_dis_info.get('g1', None) == 12 and c in [b'\xa6', b'\xa7', b'\xae', b'\xaf']:
|
||||
pre_dis_info['g1'] = 4
|
||||
return pre_dis_info, v, mode, offset, offset - offset_o
|
||||
|
|
|
|||
|
|
@ -3125,6 +3125,8 @@ reg_tests = [
|
|||
"f30f1efa"),
|
||||
(m32, "00000000 ENDBR32",
|
||||
"f30f1efb"),
|
||||
(m64, "00000000 MOV QWORD PTR ES:[RAX], RDX",
|
||||
"26488910"),
|
||||
]
|
||||
|
||||
|
||||
|
|
@ -3201,3 +3203,8 @@ cProfile.run('profile_dis(o)')
|
|||
instr_bytes = b'\x65\xc7\x00\x09\x00\x00\x00'
|
||||
inst = mn_x86.dis(instr_bytes, 32, 0)
|
||||
assert(inst.b == instr_bytes)
|
||||
|
||||
# Test multiple REX prefixes
|
||||
for i in range(1, 4):
|
||||
mn = mn_x86.dis(b'\x26' + b'\x48' * i + b'\x89\x10', 64)
|
||||
assert (str(mn).strip() == 'MOV QWORD PTR ES:[RAX], RDX')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue