Skip to content

Commit

Permalink
Fix shrx, shlx, sarx, rorx
Browse files Browse the repository at this point in the history
  • Loading branch information
yrp604 authored and emesare committed Nov 25, 2024
1 parent fce3b5b commit 34bd234
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
16 changes: 8 additions & 8 deletions arch/x86/il.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2939,8 +2939,8 @@ bool GetLowLevelILForInstruction(Architecture* arch, const uint64_t addr, LowLev
il.AddInstruction(
WriteILOperand(il, xedd, addr, 0, 0,
il.RotateRight(opOneLen,
ReadILOperand(il, xedd, addr, 0, 0),
ReadILOperand(il, xedd, addr, 1, 1)
ReadILOperand(il, xedd, addr, 1, 1),
ReadILOperand(il, xedd, addr, 2, 2)
)));
break;

Expand All @@ -2957,8 +2957,8 @@ bool GetLowLevelILForInstruction(Architecture* arch, const uint64_t addr, LowLev
il.AddInstruction(
WriteILOperand(il, xedd, addr, 0, 0,
il.ArithShiftRight(opOneLen,
ReadILOperand(il, xedd, addr, 0, 0),
ReadILOperand(il, xedd, addr, 1, 1)
ReadILOperand(il, xedd, addr, 1, 1),
ReadILOperand(il, xedd, addr, 2, 2)
)));
break;

Expand Down Expand Up @@ -3128,17 +3128,17 @@ bool GetLowLevelILForInstruction(Architecture* arch, const uint64_t addr, LowLev
il.AddInstruction(
WriteILOperand(il, xedd, addr, 0, 0,
il.ShiftLeft(opOneLen,
ReadILOperand(il, xedd, addr, 0, 0),
ReadILOperand(il, xedd, addr, 1, 1)
ReadILOperand(il, xedd, addr, 1, 1),
ReadILOperand(il, xedd, addr, 2, 2)
)));
break;

case XED_ICLASS_SHRX:
il.AddInstruction(
WriteILOperand(il, xedd, addr, 0, 0,
il.LogicalShiftRight(opOneLen,
ReadILOperand(il, xedd, addr, 0, 0),
ReadILOperand(il, xedd, addr, 1, 1)
ReadILOperand(il, xedd, addr, 1, 1),
ReadILOperand(il, xedd, addr, 2, 2)
)));
break;

Expand Down
8 changes: 7 additions & 1 deletion arch/x86/test_lifting.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,14 @@
),
]

test_shiftx = [
(b'\xc4\xe2\x4b\xf7\xc0', 'LLIL_SET_REG.d(eax,LLIL_LSR.d(LLIL_REG.d(eax),LLIL_REG.d(esi)))'), # shrx eax, eax, esi
(b'\xc4\xe2\x49\xf7\xc0', 'LLIL_SET_REG.d(eax,LLIL_LSL.d(LLIL_REG.d(eax),LLIL_REG.d(esi)))'), # shlx eax, eax, esi
(b'\xc4\xe2\x4a\xf7\xc0', 'LLIL_SET_REG.d(eax,LLIL_ASR.d(LLIL_REG.d(eax),LLIL_REG.d(esi)))'), # sarx eax, eax, esi
(b'\xc4\xe3\x7b\xf0\xc0\x05', 'LLIL_SET_REG.d(eax,LLIL_ROR.d(LLIL_REG.d(eax),LLIL_CONST.d(0x5)))'), # rorx eax, eax, 5
]

test_cases = tests_interrupts + tests_basics + tests_movd
test_cases = tests_interrupts + tests_basics + tests_movd + test_shiftx

import re
import sys
Expand Down

0 comments on commit 34bd234

Please sign in to comment.