diff options
| author | Konstantin Komarov <gerayee@gmail.com> | 2021-07-03 12:04:25 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-03 11:04:25 +0200 |
| commit | fcb324e04e11feb7f6f5aa51ec60f67f24b040e3 (patch) | |
| tree | a5144ec3c21ecc5906618ecd529f9d13b9f37e9d /miasm | |
| parent | 069440e8b4517a0ff93b94b4f89598e1695a429a (diff) | |
| download | focaccia-miasm-fcb324e04e11feb7f6f5aa51ec60f67f24b040e3.tar.gz focaccia-miasm-fcb324e04e11feb7f6f5aa51ec60f67f24b040e3.zip | |
x86_64 Fix multiple REX prefix instruction disasm (#1376)
Fix multiple rex prefixes
Diffstat (limited to 'miasm')
| -rw-r--r-- | miasm/arch/x86/arch.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/miasm/arch/x86/arch.py b/miasm/arch/x86/arch.py index e0580bc0..d17577fc 100644 --- a/miasm/arch/x86/arch.py +++ b/miasm/arch/x86/arch.py @@ -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 |