diff options
| author | Rusty Wagner <rusty@vector35.com> | 2017-05-04 19:28:27 -0400 |
|---|---|---|
| committer | Rusty Wagner <rusty@vector35.com> | 2017-05-04 19:28:27 -0400 |
| commit | 7cc163fa72b3ea342a9b061ae8988887edbf198f (patch) | |
| tree | 2803aaffa080a3e63b36d659bbeb8052b5a4cdf6 /lowlevelil.cpp | |
| parent | 26c8f70fd837baec98bcf2aac89ae658c5590013 (diff) | |
Initial support for concrete flags computation
Diffstat (limited to 'lowlevelil.cpp')
| -rw-r--r-- | lowlevelil.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lowlevelil.cpp b/lowlevelil.cpp index 0b2837f1..875f0083 100644 --- a/lowlevelil.cpp +++ b/lowlevelil.cpp @@ -534,6 +534,45 @@ ExprId LowLevelILFunction::AddOperandList(const vector<ExprId> operands) } +ExprId LowLevelILFunction::GetExprForRegisterOrConstant(const BNRegisterOrConstant& operand, size_t size) +{ + if (operand.constant) + return AddExpr(LLIL_CONST, size, 0, operand.value); + return AddExpr(LLIL_REG, size, 0, operand.reg); +} + + +ExprId LowLevelILFunction::GetNegExprForRegisterOrConstant(const BNRegisterOrConstant& operand, size_t size) +{ + if (operand.constant) + return AddExpr(LLIL_CONST, size, 0, -(int64_t)operand.value); + return AddExpr(LLIL_NEG, size, 0, AddExpr(LLIL_REG, size, 0, operand.reg)); +} + + +ExprId LowLevelILFunction::GetExprForRegisterOrConstantOperation(BNLowLevelILOperation op, size_t size, + BNRegisterOrConstant* operands, size_t operandCount) +{ + if (operandCount == 0) + return AddExpr(op, size, 0); + if (operandCount == 1) + return AddExpr(op, size, 0, GetExprForRegisterOrConstant(operands[0], size)); + if (operandCount == 2) + { + return AddExpr(op, size, 0, GetExprForRegisterOrConstant(operands[0], size), + GetExprForRegisterOrConstant(operands[1], size)); + } + if (operandCount == 3) + { + return AddExpr(op, size, 0, GetExprForRegisterOrConstant(operands[0], size), + GetExprForRegisterOrConstant(operands[1], size), GetExprForRegisterOrConstant(operands[2], size)); + } + return AddExpr(op, size, 0, GetExprForRegisterOrConstant(operands[0], size), + GetExprForRegisterOrConstant(operands[1], size), GetExprForRegisterOrConstant(operands[2], size), + GetExprForRegisterOrConstant(operands[3], size)); +} + + ExprId LowLevelILFunction::Operand(uint32_t n, ExprId expr) { BNLowLevelILSetExprSourceOperand(m_object, expr, n); |
