summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--binaryninjaapi.h1
-rw-r--r--binaryninjacore.h1
-rw-r--r--flowgraphnode.cpp9
-rw-r--r--python/basicblock.py34
-rw-r--r--python/binaryview.py14
-rw-r--r--python/callingconvention.py16
-rw-r--r--python/flowgraph.py14
-rw-r--r--python/function.py27
-rw-r--r--python/lowlevelil.py14
-rw-r--r--python/mediumlevelil.py14
-rw-r--r--python/platform.py20
-rw-r--r--python/scriptingprovider.py5
12 files changed, 110 insertions, 59 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 17069869..18645092 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -2715,6 +2715,7 @@ namespace BinaryNinja
FlowGraphNode(FlowGraph* graph);
FlowGraphNode(BNFlowGraphNode* node);
+ Ref<FlowGraph> GetGraph() const;
Ref<BasicBlock> GetBasicBlock() const;
void SetBasicBlock(BasicBlock* block);
int GetX() const;
diff --git a/binaryninjacore.h b/binaryninjacore.h
index ecc30c01..9f735f76 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -2851,6 +2851,7 @@ extern "C"
BINARYNINJACOREAPI BNFlowGraphNode* BNCreateFlowGraphNode(BNFlowGraph* graph);
BINARYNINJACOREAPI BNFlowGraphNode* BNNewFlowGraphNodeReference(BNFlowGraphNode* node);
BINARYNINJACOREAPI void BNFreeFlowGraphNode(BNFlowGraphNode* node);
+ BINARYNINJACOREAPI BNFlowGraph* BNGetFlowGraphNodeOwner(BNFlowGraphNode* node);
BINARYNINJACOREAPI BNBasicBlock* BNGetFlowGraphBasicBlock(BNFlowGraphNode* node);
BINARYNINJACOREAPI void BNSetFlowGraphBasicBlock(BNFlowGraphNode* node, BNBasicBlock* block);
diff --git a/flowgraphnode.cpp b/flowgraphnode.cpp
index 9d4ed631..0101d716 100644
--- a/flowgraphnode.cpp
+++ b/flowgraphnode.cpp
@@ -40,6 +40,15 @@ FlowGraphNode::FlowGraphNode(BNFlowGraphNode* node)
}
+Ref<FlowGraph> FlowGraphNode::GetGraph() const
+{
+ BNFlowGraph* graph = BNGetFlowGraphNodeOwner(m_object);
+ if (!graph)
+ return nullptr;
+ return new CoreFlowGraph(graph);
+}
+
+
Ref<BasicBlock> FlowGraphNode::GetBasicBlock() const
{
BNBasicBlock* block = BNGetFlowGraphBasicBlock(m_object);
diff --git a/python/basicblock.py b/python/basicblock.py
index be8b26e7..4bf2f3b2 100644
--- a/python/basicblock.py
+++ b/python/basicblock.py
@@ -56,8 +56,8 @@ class BasicBlockEdge(object):
class BasicBlock(object):
- def __init__(self, view, handle):
- self.view = view
+ def __init__(self, handle, view = None):
+ self._view = view
self.handle = core.handle_of_type(handle, core.BNBasicBlock)
self._arch = None
self._func = None
@@ -75,9 +75,9 @@ class BasicBlock(object):
return True
return ctypes.addressof(self.handle.contents) != ctypes.addressof(value.handle.contents)
- def _create_instance(self, view, handle):
+ def _create_instance(self, handle, view):
"""Internal method used to instantiate child instances"""
- return BasicBlock(view, handle)
+ return BasicBlock(handle, view)
def __hash__(self):
return hash((self.start, self.end, self.arch.name))
@@ -90,10 +90,18 @@ class BasicBlock(object):
func = core.BNGetBasicBlockFunction(self.handle)
if func is None:
return None
- self._func =binaryninja.function.Function(self.view, func)
+ self._func =binaryninja.function.Function(self._view, func)
return self._func
@property
+ def view(self):
+ """Binary view that contains the basic block (read-ony)"""
+ if self._view is not None:
+ return self._view
+ self._view = self.function.view
+ return self._view
+
+ @property
def arch(self):
"""Basic block architecture (read-only)"""
# The arch for a BasicBlock isn't going to change so just cache
@@ -135,7 +143,7 @@ class BasicBlock(object):
for i in range(0, count.value):
branch_type = BranchType(edges[i].type)
if edges[i].target:
- target = self._create_instance(self.view, core.BNNewBasicBlockReference(edges[i].target))
+ target = self._create_instance(core.BNNewBasicBlockReference(edges[i].target), self.view)
else:
target = None
result.append(BasicBlockEdge(branch_type, self, target, edges[i].backEdge, edges[i].fallThrough))
@@ -151,7 +159,7 @@ class BasicBlock(object):
for i in range(0, count.value):
branch_type = BranchType(edges[i].type)
if edges[i].target:
- target = self._create_instance(self.view, core.BNNewBasicBlockReference(edges[i].target))
+ target = self._create_instance(core.BNNewBasicBlockReference(edges[i].target), self.view)
else:
target = None
result.append(BasicBlockEdge(branch_type, target, self, edges[i].backEdge, edges[i].fallThrough))
@@ -175,7 +183,7 @@ class BasicBlock(object):
blocks = core.BNGetBasicBlockDominators(self.handle, count)
result = []
for i in range(0, count.value):
- result.append(self._create_instance(self.view, core.BNNewBasicBlockReference(blocks[i])))
+ result.append(self._create_instance(core.BNNewBasicBlockReference(blocks[i]), self.view))
core.BNFreeBasicBlockList(blocks, count.value)
return result
@@ -186,7 +194,7 @@ class BasicBlock(object):
blocks = core.BNGetBasicBlockStrictDominators(self.handle, count)
result = []
for i in range(0, count.value):
- result.append(self._create_instance(self.view, core.BNNewBasicBlockReference(blocks[i])))
+ result.append(self._create_instance(core.BNNewBasicBlockReference(blocks[i]), self.view))
core.BNFreeBasicBlockList(blocks, count.value)
return result
@@ -196,7 +204,7 @@ class BasicBlock(object):
result = core.BNGetBasicBlockImmediateDominator(self.handle)
if not result:
return None
- return self._create_instance(self.view, result)
+ return self._create_instance(result, self.view)
@property
def dominator_tree_children(self):
@@ -205,7 +213,7 @@ class BasicBlock(object):
blocks = core.BNGetBasicBlockDominatorTreeChildren(self.handle, count)
result = []
for i in range(0, count.value):
- result.append(self._create_instance(self.view, core.BNNewBasicBlockReference(blocks[i])))
+ result.append(self._create_instance(core.BNNewBasicBlockReference(blocks[i]), self.view))
core.BNFreeBasicBlockList(blocks, count.value)
return result
@@ -216,7 +224,7 @@ class BasicBlock(object):
blocks = core.BNGetBasicBlockDominanceFrontier(self.handle, count)
result = []
for i in range(0, count.value):
- result.append(self._create_instance(self.view, core.BNNewBasicBlockReference(blocks[i])))
+ result.append(self._create_instance(core.BNNewBasicBlockReference(blocks[i]), self.view))
core.BNFreeBasicBlockList(blocks, count.value)
return result
@@ -278,7 +286,7 @@ class BasicBlock(object):
out_blocks = core.BNGetBasicBlockIteratedDominanceFrontier(block_set, len(blocks), count)
result = []
for i in range(0, count.value):
- result.append(BasicBlock(blocks[0].view, core.BNNewBasicBlockReference(out_blocks[i])))
+ result.append(BasicBlock(core.BNNewBasicBlockReference(out_blocks[i]), blocks[0].view))
core.BNFreeBasicBlockList(out_blocks, count.value)
return result
diff --git a/python/binaryview.py b/python/binaryview.py
index 951b3f09..e8debdd0 100644
--- a/python/binaryview.py
+++ b/python/binaryview.py
@@ -470,7 +470,7 @@ class BinaryViewType(with_metaclass(_BinaryViewTypeMetaclass, object)):
plat = core.BNGetPlatformForViewType(self.handle, ident, arch.handle)
if plat is None:
return None
- return binaryninja.platform.Platform(None, plat)
+ return binaryninja.platform.Platform(handle = plat)
class Segment(object):
@@ -2429,7 +2429,7 @@ class BinaryView(object):
blocks = core.BNGetBasicBlocksForAddress(self.handle, addr, count)
result = []
for i in range(0, count.value):
- result.append(basicblock.BasicBlock(self, core.BNNewBasicBlockReference(blocks[i])))
+ result.append(basicblock.BasicBlock(core.BNNewBasicBlockReference(blocks[i]), self))
core.BNFreeBasicBlockList(blocks, count.value)
return result
@@ -2445,7 +2445,7 @@ class BinaryView(object):
blocks = core.BNGetBasicBlocksStartingAtAddress(self.handle, addr, count)
result = []
for i in range(0, count.value):
- result.append(basicblock.BasicBlock(self, core.BNNewBasicBlockReference(blocks[i])))
+ result.append(basicblock.BasicBlock(core.BNNewBasicBlockReference(blocks[i]), self))
core.BNFreeBasicBlockList(blocks, count.value)
return result
@@ -2453,7 +2453,7 @@ class BinaryView(object):
block = core.BNGetRecentBasicBlockForAddress(self.handle, addr)
if block is None:
return None
- return basicblock.BasicBlock(self, block)
+ return basicblock.BasicBlock(block, self)
def get_code_refs(self, addr, length=None):
"""
@@ -3247,7 +3247,7 @@ class BinaryView(object):
if pos.function:
func = binaryninja.function.Function(self, pos.function)
if pos.block:
- block = basicblock.BasicBlock(self, pos.block)
+ block = basicblock.BasicBlock(pos.block, self)
return lineardisassembly.LinearDisassemblyPosition(func, block, pos.address)
def _get_linear_disassembly_lines(self, api, pos, settings):
@@ -3273,7 +3273,7 @@ class BinaryView(object):
if lines[i].function:
func = binaryninja.function.Function(self, core.BNNewFunctionReference(lines[i].function))
if lines[i].block:
- block = basicblock.BasicBlock(self, core.BNNewBasicBlockReference(lines[i].block))
+ block = basicblock.BasicBlock(core.BNNewBasicBlockReference(lines[i].block), self)
color = highlight.HighlightColor._from_core_struct(lines[i].contents.highlight)
addr = lines[i].contents.addr
tokens = binaryninja.function.InstructionTextToken.get_instruction_lines(lines[i].contents.tokens, lines[i].contents.count)
@@ -3285,7 +3285,7 @@ class BinaryView(object):
if pos_obj.function:
func = binaryninja.function.Function(self, pos_obj.function)
if pos_obj.block:
- block = basicblock.BasicBlock(self, pos_obj.block)
+ block = basicblock.BasicBlock(pos_obj.block, self)
pos.function = func
pos.block = block
pos.address = pos_obj.address
diff --git a/python/callingconvention.py b/python/callingconvention.py
index 2d638855..ee42caca 100644
--- a/python/callingconvention.py
+++ b/python/callingconvention.py
@@ -51,6 +51,7 @@ class CallingConvention(object):
def __init__(self, arch=None, name=None, handle=None, confidence=binaryninja.types.max_confidence):
if handle is None:
if arch is None or name is None:
+ self.handle = None
raise ValueError("Must specify either handle or architecture and name")
self.arch = arch
self._pending_reg_lists = {}
@@ -155,7 +156,8 @@ class CallingConvention(object):
self.confidence = confidence
def __del__(self):
- core.BNFreeCallingConvention(self.handle)
+ if self.handle is not None:
+ core.BNFreeCallingConvention(self.handle)
def __eq__(self, value):
if not isinstance(value, CallingConvention):
@@ -308,8 +310,7 @@ class CallingConvention(object):
def _get_incoming_reg_value(self, ctxt, reg, func, result):
try:
- func_obj = binaryninja.function.Function(binaryninja.binaryview.BinaryView(handle = core.BNGetFunctionData(func)),
- core.BNNewFunctionReference(func))
+ func_obj = binaryninja.function.Function(handle = core.BNNewFunctionReference(func))
reg_name = self.arch.get_reg_name(reg)
api_obj = self.perform_get_incoming_reg_value(reg_name, func_obj)._to_api_object()
except:
@@ -320,8 +321,7 @@ class CallingConvention(object):
def _get_incoming_flag_value(self, ctxt, reg, func, result):
try:
- func_obj = binaryninja.function.Function(binaryninja.binaryview.BinaryView(handle = core.BNGetFunctionData(func)),
- core.BNNewFunctionReference(func))
+ func_obj = binaryninja.function.Function(handle = core.BNNewFunctionReference(func))
reg_name = self.arch.get_reg_name(reg)
api_obj = self.perform_get_incoming_flag_value(reg_name, func_obj)._to_api_object()
except:
@@ -335,8 +335,7 @@ class CallingConvention(object):
if func is None:
func_obj = None
else:
- func_obj = binaryninja.function.Function(binaryninja.binaryview.BinaryView(handle = core.BNGetFunctionData(func)),
- core.BNNewFunctionReference(func))
+ func_obj = binaryninja.function.Function(handle = core.BNNewFunctionReference(func))
in_var_obj = binaryninja.function.Variable(func_obj, in_var[0].type, in_var[0].index, in_var[0].storage)
out_var = self.perform_get_incoming_var_for_parameter_var(in_var_obj, func_obj)
result[0].type = out_var.source_type
@@ -353,8 +352,7 @@ class CallingConvention(object):
if func is None:
func_obj = None
else:
- func_obj = binaryninja.function.Function(binaryninja.binaryview.BinaryView(handle = core.BNGetFunctionData(func)),
- core.BNNewFunctionReference(func))
+ func_obj = binaryninja.function.Function(handle = core.BNNewFunctionReference(func))
in_var_obj = binaryninja.function.Variable(func_obj, in_var[0].type, in_var[0].index, in_var[0].storage)
out_var = self.perform_get_parameter_var_for_incoming_var(in_var_obj, func_obj)
result[0].type = out_var.source_type
diff --git a/python/flowgraph.py b/python/flowgraph.py
index 90ab33db..d3c57a56 100644
--- a/python/flowgraph.py
+++ b/python/flowgraph.py
@@ -51,14 +51,20 @@ class FlowGraphEdge(object):
class FlowGraphNode(object):
- def __init__(self, graph, handle = None):
+ def __init__(self, graph = None, handle = None):
if handle is None:
+ if graph is None:
+ self.handle = None
+ raise ValueError("flow graph node must be associated with a graph")
handle = core.BNCreateFlowGraphNode(graph.handle)
self.handle = handle
self.graph = graph
+ if self.graph is None:
+ self.graph = FlowGraph(handle = core.BNGetFlowGraphNodeOwner(self.handle))
def __del__(self):
- core.BNFreeFlowGraphNode(self.handle)
+ if self.handle is not None:
+ core.BNFreeFlowGraphNode(self.handle)
def __eq__(self, value):
if not isinstance(value, FlowGraphNode):
@@ -91,7 +97,7 @@ class FlowGraphNode(object):
block = mediumlevelil.MediumLevelILBasicBlock(view, block,
mediumlevelil.MediumLevelILFunction(func.arch, core.BNGetBasicBlockMediumLevelILFunction(block), func))
else:
- block = basicblock.BasicBlock(view, block)
+ block = basicblock.BasicBlock(block, view)
return block
@property
@@ -389,7 +395,7 @@ class FlowGraph(object):
func = core.BNGetFunctionForFlowGraph(self.handle)
if func is None:
return None
- return function.Function(binaryview.BinaryView(handle = core.BNGetFunctionData(func)), func)
+ return function.Function(handle = func)
@function.setter
def function(self, func):
diff --git a/python/function.py b/python/function.py
index 9666f735..c8e339cd 100644
--- a/python/function.py
+++ b/python/function.py
@@ -357,17 +357,24 @@ class _FunctionAssociatedDataStore(associateddatastore._AssociatedDataStore):
class Function(object):
_associated_data = {}
- def __init__(self, view, handle):
- self._view = view
- self.handle = core.handle_of_type(handle, core.BNFunction)
+ def __init__(self, view = None, handle = None):
self._advanced_analysis_requests = 0
+ if handle is None:
+ self.handle = None
+ raise NotImplementedError("creation of standalone 'Function' objects is not implemented")
+ self.handle = core.handle_of_type(handle, core.BNFunction)
+ if view is None:
+ self._view = binaryninja.binaryview.BinaryView(handle = core.BNGetFunctionData(self.handle))
+ else:
+ self._view = view
self._arch = None
self._platform = None
def __del__(self):
- if self._advanced_analysis_requests > 0:
- core.BNReleaseAdvancedFunctionAnalysisDataMultiple(self.handle, self._advanced_analysis_requests)
- core.BNFreeFunction(self.handle)
+ if self.handle is not None:
+ if self._advanced_analysis_requests > 0:
+ core.BNReleaseAdvancedFunctionAnalysisDataMultiple(self.handle, self._advanced_analysis_requests)
+ core.BNFreeFunction(self.handle)
def __eq__(self, value):
if not isinstance(value, Function):
@@ -432,7 +439,7 @@ class Function(object):
plat = core.BNGetFunctionPlatform(self.handle)
if plat is None:
return None
- self._platform = binaryninja.platform.Platform(None, handle = plat)
+ self._platform = binaryninja.platform.Platform(handle = plat)
return self._platform
@property
@@ -486,7 +493,7 @@ class Function(object):
blocks = core.BNGetFunctionBasicBlockList(self.handle, count)
result = []
for i in range(0, count.value):
- result.append(binaryninja.basicblock.BasicBlock(self._view, core.BNNewBasicBlockReference(blocks[i])))
+ result.append(binaryninja.basicblock.BasicBlock(core.BNNewBasicBlockReference(blocks[i]), self._view))
core.BNFreeBasicBlockList(blocks, count.value)
return result
@@ -868,7 +875,7 @@ class Function(object):
blocks = core.BNGetFunctionBasicBlockList(self.handle, count)
try:
for i in range(0, count.value):
- yield binaryninja.basicblock.BasicBlock(self._view, core.BNNewBasicBlockReference(blocks[i]))
+ yield binaryninja.basicblock.BasicBlock(core.BNNewBasicBlockReference(blocks[i]), self._view)
finally:
core.BNFreeBasicBlockList(blocks, count.value)
@@ -1343,7 +1350,7 @@ class Function(object):
block = core.BNGetFunctionBasicBlockAtAddress(self.handle, arch.handle, addr)
if not block:
return None
- return binaryninja.basicblock.BasicBlock(self._view, handle = block)
+ return binaryninja.basicblock.BasicBlock(block, self._view)
def get_instr_highlight(self, addr, arch=None):
"""
diff --git a/python/lowlevelil.py b/python/lowlevelil.py
index c3f6963a..08c27383 100644
--- a/python/lowlevelil.py
+++ b/python/lowlevelil.py
@@ -727,19 +727,27 @@ class LowLevelILFunction(object):
LLFC_NO !overflow No overflow
======================= ========== ===============================
"""
- def __init__(self, arch, handle = None, source_func = None):
+ def __init__(self, arch = None, handle = None, source_func = None):
self.arch = arch
self.source_function = source_func
if handle is not None:
self.handle = core.handle_of_type(handle, core.BNLowLevelILFunction)
+ if self.source_function is None:
+ self.source_function = binaryninja.function.Function(handle = core.BNGetLowLevelILOwnerFunction(self.handle))
+ if self.arch is None:
+ self.arch = self.source_function.arch
else:
if self.source_function is None:
+ self.handle = None
raise ValueError("IL functions must be created with an associated function")
+ if self.arch is None:
+ self.arch = self.source_function.arch
func_handle = self.source_function.handle
self.handle = core.BNCreateLowLevelILFunction(arch.handle, func_handle)
def __del__(self):
- core.BNFreeLowLevelILFunction(self.handle)
+ if self.handle is not None:
+ core.BNFreeLowLevelILFunction(self.handle)
def __eq__(self, value):
if not isinstance(value, LowLevelILFunction):
@@ -2389,7 +2397,7 @@ class LowLevelILFunction(object):
class LowLevelILBasicBlock(basicblock.BasicBlock):
def __init__(self, view, handle, owner):
- super(LowLevelILBasicBlock, self).__init__(view, handle)
+ super(LowLevelILBasicBlock, self).__init__(handle, view)
self.il_function = owner
def __iter__(self):
diff --git a/python/mediumlevelil.py b/python/mediumlevelil.py
index a6867c60..a83cfff4 100644
--- a/python/mediumlevelil.py
+++ b/python/mediumlevelil.py
@@ -615,19 +615,27 @@ class MediumLevelILFunction(object):
objects can be added to the MediumLevelILFunction by calling ``append`` and passing the result of the various class
methods which return MediumLevelILExpr objects.
"""
- def __init__(self, arch, handle = None, source_func = None):
+ def __init__(self, arch = None, handle = None, source_func = None):
self.arch = arch
self.source_function = source_func
if handle is not None:
self.handle = core.handle_of_type(handle, core.BNMediumLevelILFunction)
+ if self.source_function is None:
+ self.source_function = binaryninja.function.Function(handle = core.BNGetMediumLevelILOwnerFunction(self.handle))
+ if self.arch is None:
+ self.arch = self.source_function.arch
else:
if self.source_function is None:
+ self.handle = None
raise ValueError("IL functions must be created with an associated function")
+ if self.arch is None:
+ self.arch = self.source_function.arch
func_handle = self.source_function.handle
self.handle = core.BNCreateMediumLevelILFunction(arch.handle, func_handle)
def __del__(self):
- core.BNFreeMediumLevelILFunction(self.handle)
+ if self.handle is not None:
+ core.BNFreeMediumLevelILFunction(self.handle)
def __eq__(self, value):
if not isinstance(value, MediumLevelILFunction):
@@ -966,7 +974,7 @@ class MediumLevelILFunction(object):
class MediumLevelILBasicBlock(basicblock.BasicBlock):
def __init__(self, view, handle, owner):
- super(MediumLevelILBasicBlock, self).__init__(view, handle)
+ super(MediumLevelILBasicBlock, self).__init__(handle, view)
self.il_function = owner
def __iter__(self):
diff --git a/python/platform.py b/python/platform.py
index 9ef4715c..0ac8858b 100644
--- a/python/platform.py
+++ b/python/platform.py
@@ -39,7 +39,7 @@ class _PlatformMetaClass(type):
platforms = core.BNGetPlatformList(count)
result = []
for i in range(0, count.value):
- result.append(Platform(None, core.BNNewPlatformReference(platforms[i])))
+ result.append(Platform(handle = core.BNNewPlatformReference(platforms[i])))
core.BNFreePlatformList(platforms, count.value)
return result
@@ -60,7 +60,7 @@ class _PlatformMetaClass(type):
platforms = core.BNGetPlatformList(count)
try:
for i in range(0, count.value):
- yield Platform(None, core.BNNewPlatformReference(platforms[i]))
+ yield Platform(handle = core.BNNewPlatformReference(platforms[i]))
finally:
core.BNFreePlatformList(platforms, count.value)
@@ -75,7 +75,7 @@ class _PlatformMetaClass(type):
platform = core.BNGetPlatformByName(str(value))
if platform is None:
raise KeyError("'%s' is not a valid platform" % str(value))
- return Platform(None, platform)
+ return Platform(handle = platform)
def get_list(cls, os = None, arch = None):
binaryninja._init_plugins()
@@ -88,7 +88,7 @@ class _PlatformMetaClass(type):
platforms = core.BNGetPlatformListByArchitecture(os, arch.handle)
result = []
for i in range(0, count.value):
- result.append(Platform(None, core.BNNewPlatformReference(platforms[i])))
+ result.append(Platform(handle = core.BNNewPlatformReference(platforms[i])))
core.BNFreePlatformList(platforms, count.value)
return result
@@ -100,8 +100,11 @@ class Platform(with_metaclass(_PlatformMetaClass, object)):
"""
name = None
- def __init__(self, arch, handle = None):
+ def __init__(self, arch = None, handle = None):
if handle is None:
+ if arch is None:
+ self.handle = None
+ raise ValueError("platform must have an associated architecture")
self.arch = arch
self.handle = core.BNCreatePlatform(arch.handle, self.__class__.name)
else:
@@ -110,7 +113,8 @@ class Platform(with_metaclass(_PlatformMetaClass, object)):
self.arch = binaryninja.architecture.CoreArchitecture._from_cache(core.BNGetPlatformArchitecture(self.handle))
def __del__(self):
- core.BNFreePlatform(self.handle)
+ if self.handle is not None:
+ core.BNFreePlatform(self.handle)
def __eq__(self, value):
if not isinstance(value, Platform):
@@ -316,7 +320,7 @@ class Platform(with_metaclass(_PlatformMetaClass, object)):
result = core.BNGetRelatedPlatform(self.handle, arch.handle)
if not result:
return None
- return Platform(None, handle = result)
+ return Platform(handle = result)
def add_related_platform(self, arch, platform):
core.BNAddRelatedPlatform(self.handle, arch.handle, platform.handle)
@@ -325,7 +329,7 @@ class Platform(with_metaclass(_PlatformMetaClass, object)):
new_addr = ctypes.c_ulonglong()
new_addr.value = addr
result = core.BNGetAssociatedPlatformByAddress(self.handle, new_addr)
- return Platform(None, handle = result), new_addr.value
+ return Platform(handle = result), new_addr.value
def get_type_by_name(self, name):
name = types.QualifiedName(name)._get_core_struct()
diff --git a/python/scriptingprovider.py b/python/scriptingprovider.py
index 690bd6cc..fcbca6dc 100644
--- a/python/scriptingprovider.py
+++ b/python/scriptingprovider.py
@@ -154,7 +154,7 @@ class ScriptingInstance(object):
def _set_current_function(self, ctxt, func):
try:
if func:
- func = binaryninja.function.Function(binaryninja.binaryview.BinaryView(handle = core.BNGetFunctionData(func)), core.BNNewFunctionReference(func))
+ func = binaryninja.function.Function(handle = core.BNNewFunctionReference(func))
else:
func = None
self.perform_set_current_function(func)
@@ -168,7 +168,8 @@ class ScriptingInstance(object):
if func is None:
block = None
else:
- block = binaryninja.basicblock.BasicBlock(binaryninja.binaryview.BinaryView(handle = core.BNGetFunctionData(func)), core.BNNewBasicBlockReference(block))
+ block = binaryninja.basicblock.BasicBlock(core.BNNewBasicBlockReference(block),
+ binaryninja.binaryview.BinaryView(handle = core.BNGetFunctionData(func)))
core.BNFreeFunction(func)
else:
block = None