diff options
| author | Rusty Wagner <rusty@vector35.com> | 2017-05-05 17:57:06 -0400 |
|---|---|---|
| committer | Rusty Wagner <rusty@vector35.com> | 2017-05-05 17:57:06 -0400 |
| commit | 7bc394fc4490920bac688234f5c4c23901ab84c7 (patch) | |
| tree | 8ec639282eedc2bfebdb71e3fae1360963a70b01 /lowlevelil.cpp | |
| parent | 7cc163fa72b3ea342a9b061ae8988887edbf198f (diff) | |
Adding carry flag operand to IL instructions that need it
Diffstat (limited to 'lowlevelil.cpp')
| -rw-r--r-- | lowlevelil.cpp | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/lowlevelil.cpp b/lowlevelil.cpp index 875f0083..ffb447ab 100644 --- a/lowlevelil.cpp +++ b/lowlevelil.cpp @@ -170,9 +170,9 @@ ExprId LowLevelILFunction::Add(size_t size, ExprId a, ExprId b, uint32_t flags) } -ExprId LowLevelILFunction::AddCarry(size_t size, ExprId a, ExprId b, uint32_t flags) +ExprId LowLevelILFunction::AddCarry(size_t size, ExprId a, ExprId b, ExprId carry, uint32_t flags) { - return AddExpr(LLIL_ADC, size, flags, a, b); + return AddExpr(LLIL_ADC, size, flags, a, b, carry); } @@ -182,9 +182,9 @@ ExprId LowLevelILFunction::Sub(size_t size, ExprId a, ExprId b, uint32_t flags) } -ExprId LowLevelILFunction::SubBorrow(size_t size, ExprId a, ExprId b, uint32_t flags) +ExprId LowLevelILFunction::SubBorrow(size_t size, ExprId a, ExprId b, ExprId carry, uint32_t flags) { - return AddExpr(LLIL_SBB, size, flags, a, b); + return AddExpr(LLIL_SBB, size, flags, a, b, carry); } @@ -230,9 +230,9 @@ ExprId LowLevelILFunction::RotateLeft(size_t size, ExprId a, ExprId b, uint32_t } -ExprId LowLevelILFunction::RotateLeftCarry(size_t size, ExprId a, ExprId b, uint32_t flags) +ExprId LowLevelILFunction::RotateLeftCarry(size_t size, ExprId a, ExprId b, ExprId carry, uint32_t flags) { - return AddExpr(LLIL_RLC, size, flags, a, b); + return AddExpr(LLIL_RLC, size, flags, a, b, carry); } @@ -242,9 +242,9 @@ ExprId LowLevelILFunction::RotateRight(size_t size, ExprId a, ExprId b, uint32_t } -ExprId LowLevelILFunction::RotateRightCarry(size_t size, ExprId a, ExprId b, uint32_t flags) +ExprId LowLevelILFunction::RotateRightCarry(size_t size, ExprId a, ExprId b, ExprId carry, uint32_t flags) { - return AddExpr(LLIL_RRC, size, flags, a, b); + return AddExpr(LLIL_RRC, size, flags, a, b, carry); } @@ -550,6 +550,14 @@ ExprId LowLevelILFunction::GetNegExprForRegisterOrConstant(const BNRegisterOrCon } +ExprId LowLevelILFunction::GetExprForFlagOrConstant(const BNRegisterOrConstant& operand) +{ + if (operand.constant) + return AddExpr(LLIL_CONST, 0, 0, operand.value); + return AddExpr(LLIL_FLAG, 0, 0, operand.reg); +} + + ExprId LowLevelILFunction::GetExprForRegisterOrConstantOperation(BNLowLevelILOperation op, size_t size, BNRegisterOrConstant* operands, size_t operandCount) { @@ -564,6 +572,11 @@ ExprId LowLevelILFunction::GetExprForRegisterOrConstantOperation(BNLowLevelILOpe } if (operandCount == 3) { + if ((op == LLIL_ADC) || (op == LLIL_SBB) || (op == LLIL_RLC) || (op == LLIL_RRC)) + { + return AddExpr(op, size, 0, GetExprForRegisterOrConstant(operands[0], size), + GetExprForRegisterOrConstant(operands[1], size), GetExprForFlagOrConstant(operands[2])); + } return AddExpr(op, size, 0, GetExprForRegisterOrConstant(operands[0], size), GetExprForRegisterOrConstant(operands[1], size), GetExprForRegisterOrConstant(operands[2], size)); } |
