From c382a4610cc0ea7f8b8134b847d29bca7dc25398 Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Sun, 24 Apr 2016 00:33:26 -0400 Subject: Create API for adding known indirect branch targets --- lowlevelil.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'lowlevelil.cpp') diff --git a/lowlevelil.cpp b/lowlevelil.cpp index a006a581..a3d591a0 100644 --- a/lowlevelil.cpp +++ b/lowlevelil.cpp @@ -54,6 +54,25 @@ void LowLevelILFunction::SetCurrentAddress(uint64_t addr) } +void LowLevelILFunction::ClearIndirectBranches() +{ + BNLowLevelILClearIndirectBranches(m_object); +} + + +void LowLevelILFunction::SetIndirectBranches(const vector& branches) +{ + BNArchitectureAndAddress* branchList = new BNArchitectureAndAddress[branches.size()]; + for (size_t i = 0; i < branches.size(); i++) + { + branchList[i].arch = branches[i].arch->GetObject(); + branchList[i].address = branches[i].address; + } + BNLowLevelILSetIndirectBranches(m_object, branchList, branches.size()); + delete[] branchList; +} + + ExprId LowLevelILFunction::AddExpr(BNLowLevelILOperation operation, size_t size, uint32_t flags, ExprId a, ExprId b, ExprId c, ExprId d) { @@ -463,6 +482,40 @@ void LowLevelILFunction::MarkLabel(BNLowLevelILLabel& label) } +vector LowLevelILFunction::GetOperandList(ExprId i, size_t listOperand) +{ + size_t count; + uint64_t* operands = BNLowLevelILGetOperandList(m_object, i, listOperand, &count); + vector result; + for (size_t i = 0; i < count; i++) + result.push_back(operands[i]); + BNLowLevelILFreeOperandList(operands); + return result; +} + + +ExprId LowLevelILFunction::AddLabelList(const vector& labels) +{ + BNLowLevelILLabel** labelList = new BNLowLevelILLabel*[labels.size()]; + for (size_t i = 0; i < labels.size(); i++) + labelList[i] = labels[i]; + ExprId result = (ExprId)BNLowLevelILAddLabelList(m_object, labelList, labels.size()); + delete[] labelList; + return result; +} + + +ExprId LowLevelILFunction::AddOperandList(const vector operands) +{ + uint64_t* operandList = new uint64_t[operands.size()]; + for (size_t i = 0; i < operands.size(); i++) + operandList[i] = operands[i]; + ExprId result = (ExprId)BNLowLevelILAddOperandList(m_object, operandList, operands.size()); + delete[] operandList; + return result; +} + + ExprId LowLevelILFunction::Operand(uint32_t n, ExprId expr) { BNLowLevelILSetExprSourceOperand(m_object, expr, n); -- cgit v1.3.1