summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--binaryninjaapi.h2
-rw-r--r--binaryninjacore.h2
-rw-r--r--flowgraphnode.cpp6
-rw-r--r--python/flowgraph.py5
4 files changed, 15 insertions, 0 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 6a4b1bc1..1b0232fc 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -2742,6 +2742,8 @@ namespace BinaryNinja
BNHighlightColor GetHighlight() const;
void SetHighlight(const BNHighlightColor& color);
+
+ bool IsValidForGraph(FlowGraph* graph) const;
};
class FlowGraphLayoutRequest: public RefCountObject
diff --git a/binaryninjacore.h b/binaryninjacore.h
index 8e355ab1..89b61202 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -2948,6 +2948,8 @@ extern "C"
BINARYNINJACOREAPI void BNSetFlowGraphOption(BNFlowGraph* graph, BNFlowGraphOption option, bool value);
BINARYNINJACOREAPI bool BNIsFlowGraphOptionSet(BNFlowGraph* graph, BNFlowGraphOption option);
+ BINARYNINJACOREAPI bool BNIsNodeValidForFlowGraph(BNFlowGraph* graph, BNFlowGraphNode* node);
+
// Symbols
BINARYNINJACOREAPI BNSymbol* BNCreateSymbol(BNSymbolType type, const char* shortName, const char* fullName,
const char* rawName, uint64_t addr, BNSymbolBinding binding, const BNNameSpace* nameSpace, uint64_t ordinal);
diff --git a/flowgraphnode.cpp b/flowgraphnode.cpp
index 37128cd8..4a1729ff 100644
--- a/flowgraphnode.cpp
+++ b/flowgraphnode.cpp
@@ -208,3 +208,9 @@ void FlowGraphNode::SetHighlight(const BNHighlightColor& color)
{
BNSetFlowGraphNodeHighlight(m_object, color);
}
+
+
+bool FlowGraphNode::IsValidForGraph(FlowGraph* graph) const
+{
+ return BNIsNodeValidForFlowGraph(graph->GetObject(), m_object);
+}
diff --git a/python/flowgraph.py b/python/flowgraph.py
index 3054ff35..58add8b0 100644
--- a/python/flowgraph.py
+++ b/python/flowgraph.py
@@ -268,8 +268,13 @@ class FlowGraphNode(object):
:param BranchType edge_type: Type of edge to add
:param FlowGraphNode target: Target node object
"""
+ if not target.is_valid_for_graph(self.graph):
+ raise ValueError("Target of edge has not been added to the owning graph")
core.BNAddFlowGraphNodeOutgoingEdge(self.handle, edge_type, target.handle)
+ def is_valid_for_graph(self, graph):
+ return core.BNIsNodeValidForFlowGraph(graph.handle, self.handle)
+
class FlowGraphLayoutRequest(object):
def __init__(self, graph, callback = None):