From 34bd2341f9fb8d5e8bc57639cb0ec547c3b8596b Mon Sep 17 00:00:00 2001 From: yrp Date: Fri, 22 Nov 2024 22:03:13 -0800 Subject: Fix shrx, shlx, sarx, rorx --- arch/x86/il.cpp | 16 ++++++++-------- arch/x86/test_lifting.py | 8 +++++++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/arch/x86/il.cpp b/arch/x86/il.cpp index e6d704a6..3dd9f87a 100644 --- a/arch/x86/il.cpp +++ b/arch/x86/il.cpp @@ -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; @@ -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; @@ -3128,8 +3128,8 @@ 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; @@ -3137,8 +3137,8 @@ bool GetLowLevelILForInstruction(Architecture* arch, const uint64_t addr, LowLev 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; diff --git a/arch/x86/test_lifting.py b/arch/x86/test_lifting.py index ee2e1e34..6576b877 100755 --- a/arch/x86/test_lifting.py +++ b/arch/x86/test_lifting.py @@ -103,8 +103,14 @@ tests_movd = [ ), ] +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 -- cgit v1.3.1