summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRusty Wagner <rusty@vector35.com>2016-09-09 03:29:14 -0400
committerRusty Wagner <rusty@vector35.com>2016-09-09 03:29:14 -0400
commit6be6ee30e5973fa4d5f29cebdeafdf05c3f4251e (patch)
treeacffac0a6d81c7037d532d65096a2d04fb45a47e
parentf5e59b13b726a0d154dbe9351010ed3bd4b2b9e6 (diff)
Minor changes to API for creation of IL functions
-rw-r--r--binaryninjaapi.h4
-rw-r--r--binaryninjacore.h4
-rw-r--r--lowlevelil.cpp8
-rw-r--r--python/__init__.py15
4 files changed, 15 insertions, 16 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index a86f1067..9c7ff4f1 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -1788,7 +1788,7 @@ namespace BinaryNinja
BNNewLowLevelILFunctionReference, BNFreeLowLevelILFunction>
{
public:
- LowLevelILFunction(Architecture* arch);
+ LowLevelILFunction(Architecture* arch, Function* func = nullptr);
LowLevelILFunction(BNLowLevelILFunction* func);
uint64_t GetCurrentAddress() const;
@@ -1883,7 +1883,7 @@ namespace BinaryNinja
void AddLabelForAddress(Architecture* arch, ExprId addr);
BNLowLevelILLabel* GetLabelForAddress(Architecture* arch, ExprId addr);
- void Finalize(Function* func = nullptr);
+ void Finalize();
bool GetExprText(Architecture* arch, ExprId expr, std::vector<InstructionTextToken>& tokens);
bool GetInstructionText(Function* func, Architecture* arch, size_t i,
diff --git a/binaryninjacore.h b/binaryninjacore.h
index 960390fa..f917c2fa 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -1665,7 +1665,7 @@ extern "C"
BINARYNINJACOREAPI BNSymbol* BNImportedFunctionFromImportAddressSymbol(BNSymbol* sym, uint64_t addr);
// Low-level IL
- BINARYNINJACOREAPI BNLowLevelILFunction* BNCreateLowLevelILFunction(BNArchitecture* arch);
+ BINARYNINJACOREAPI BNLowLevelILFunction* BNCreateLowLevelILFunction(BNArchitecture* arch, BNFunction* func);
BINARYNINJACOREAPI BNLowLevelILFunction* BNNewLowLevelILFunctionReference(BNLowLevelILFunction* func);
BINARYNINJACOREAPI void BNFreeLowLevelILFunction(BNLowLevelILFunction* func);
BINARYNINJACOREAPI uint64_t BNLowLevelILGetCurrentAddress(BNLowLevelILFunction* func);
@@ -1681,7 +1681,7 @@ extern "C"
BINARYNINJACOREAPI size_t BNLowLevelILIf(BNLowLevelILFunction* func, uint64_t op, BNLowLevelILLabel* t, BNLowLevelILLabel* f);
BINARYNINJACOREAPI void BNLowLevelILInitLabel(BNLowLevelILLabel* label);
BINARYNINJACOREAPI void BNLowLevelILMarkLabel(BNLowLevelILFunction* func, BNLowLevelILLabel* label);
- BINARYNINJACOREAPI void BNFinalizeLowLevelILFunction(BNLowLevelILFunction* func, BNFunction* sourceFunc);
+ BINARYNINJACOREAPI void BNFinalizeLowLevelILFunction(BNLowLevelILFunction* func);
BINARYNINJACOREAPI size_t BNLowLevelILAddLabelList(BNLowLevelILFunction* func, BNLowLevelILLabel** labels, size_t count);
BINARYNINJACOREAPI size_t BNLowLevelILAddOperandList(BNLowLevelILFunction* func, uint64_t* operands, size_t count);
diff --git a/lowlevelil.cpp b/lowlevelil.cpp
index 550accc2..a312bbd6 100644
--- a/lowlevelil.cpp
+++ b/lowlevelil.cpp
@@ -30,9 +30,9 @@ LowLevelILLabel::LowLevelILLabel()
}
-LowLevelILFunction::LowLevelILFunction(Architecture* arch)
+LowLevelILFunction::LowLevelILFunction(Architecture* arch, Function* func)
{
- m_object = BNCreateLowLevelILFunction(arch->GetObject());
+ m_object = BNCreateLowLevelILFunction(arch->GetObject(), func ? func->GetObject() : nullptr);
}
@@ -559,9 +559,9 @@ BNLowLevelILLabel* LowLevelILFunction::GetLabelForAddress(Architecture* arch, Ex
}
-void LowLevelILFunction::Finalize(Function* func)
+void LowLevelILFunction::Finalize()
{
- BNFinalizeLowLevelILFunction(m_object, func ? func->GetObject() : nullptr);
+ BNFinalizeLowLevelILFunction(m_object);
}
diff --git a/python/__init__.py b/python/__init__.py
index e36670cc..7978fd2c 100644
--- a/python/__init__.py
+++ b/python/__init__.py
@@ -7201,7 +7201,10 @@ class LowLevelILFunction(object):
if handle is not None:
self.handle = core.handle_of_type(handle, core.BNLowLevelILFunction)
else:
- self.handle = core.BNCreateLowLevelILFunction(arch.handle)
+ func_handle = None
+ if self.source_function is not None:
+ func_handle = self.source_function.handle
+ self.handle = core.BNCreateLowLevelILFunction(arch.handle, func_handle)
def __del__(self):
core.BNFreeLowLevelILFunction(self.handle)
@@ -8164,17 +8167,13 @@ class LowLevelILFunction(object):
core.BNLowLevelILSetExprSourceOperand(self.handle, expr.index, n)
return expr
- def finalize(self, func = None):
+ def finalize(self):
"""
- ``finalize`` ends the provided LowLevelILLabel.
+ ``finalize`` ends the function and computes the list of basic blocks.
- :param LowLevelILFunction func: optional function to end
:rtype: None
"""
- if func is None:
- core.BNFinalizeLowLevelILFunction(self.handle, None)
- else:
- core.BNFinalizeLowLevelILFunction(self.handle, func.handle)
+ core.BNFinalizeLowLevelILFunction(self.handle)
def add_label_for_address(self, arch, addr):
"""