summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Potchik <brian@vector35.com>2021-08-04 11:09:16 -0400
committerBrian Potchik <brian@vector35.com>2021-08-04 11:09:16 -0400
commit98c2b6f32e3181a3a3462c6bd41306ff674a515b (patch)
tree189c5e7badf84a92b44e31fb2ad3fa18a01ed601
parent754fb4d12a85cdf8c791725002c9a1e78894d8c0 (diff)
Add query mode to flow graph reports.
-rw-r--r--binaryninjaapi.h7
-rw-r--r--binaryninjacore.h6
-rw-r--r--flowgraph.cpp15
-rw-r--r--interaction.cpp6
-rw-r--r--python/interaction.py12
5 files changed, 45 insertions, 1 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 9f7acf0f..0f49039f 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -3621,6 +3621,8 @@ __attribute__ ((format (printf, 1, 2)))
static void FreeObjectCallback(void* ctxt);
protected:
+ bool m_queryMode = false;
+
FlowGraph(BNFlowGraph* graph);
void FinishPrepareForLayout();
@@ -3665,6 +3667,8 @@ __attribute__ ((format (printf, 1, 2)))
void Show(const std::string& title);
+ virtual bool HasUpdates() const;
+
virtual Ref<FlowGraph> Update();
void SetOption(BNFlowGraphOption option, bool value = true);
@@ -3675,6 +3679,7 @@ __attribute__ ((format (printf, 1, 2)))
{
public:
CoreFlowGraph(BNFlowGraph* graph);
+ virtual bool HasUpdates() const override;
virtual Ref<FlowGraph> Update() override;
};
@@ -5355,6 +5360,8 @@ __attribute__ ((format (printf, 1, 2)))
void AddHTMLReport(Ref<BinaryView> view, const std::string& title, const std::string& contents,
const std::string& plainText = "");
void AddGraphReport(Ref<BinaryView> view, const std::string& title, Ref<FlowGraph> graph);
+
+ void UpdateFlowGraph(size_t i, Ref<FlowGraph> graph);
};
class InteractionHandler
diff --git a/binaryninjacore.h b/binaryninjacore.h
index eef37ab6..df8d6d12 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -27,7 +27,7 @@
// Current ABI version for linking to the core. This is incremented any time
// there are changes to the API that affect linking, including new functions,
// new types, or modifications to existing functions or types.
-#define BN_CURRENT_CORE_ABI_VERSION 12
+#define BN_CURRENT_CORE_ABI_VERSION 13
// Minimum ABI version that is supported for loading of plugins. Plugins that
// are linked to an ABI version less than this will not be able to load and
@@ -4052,6 +4052,9 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI void BNFinishPrepareForLayout(BNFlowGraph* graph);
+ BINARYNINJACOREAPI bool BNFlowGraphUpdateQueryMode(BNFlowGraph* graph);
+ BINARYNINJACOREAPI bool BNFlowGraphHasUpdates(BNFlowGraph* graph);
+
BINARYNINJACOREAPI BNFlowGraph* BNUpdateFlowGraph(BNFlowGraph* graph);
BINARYNINJACOREAPI void BNSetFlowGraphOption(BNFlowGraph* graph, BNFlowGraphOption option, bool value);
@@ -5069,6 +5072,7 @@ __attribute__ ((format (printf, 1, 2)))
const char* title, const char* contents, const char* plaintext);
BINARYNINJACOREAPI void BNAddGraphReportToCollection(BNReportCollection* reports, BNBinaryView* view,
const char* title, BNFlowGraph* graph);
+ BINARYNINJACOREAPI void BNUpdateReportFlowGraph(BNReportCollection* reports, size_t i, BNFlowGraph* graph);
BINARYNINJACOREAPI bool BNIsGNU3MangledString(const char* mangledName);
BINARYNINJACOREAPI bool BNDemangleGNU3(BNArchitecture* arch, const char* mangledName, BNType** outType,
diff --git a/flowgraph.cpp b/flowgraph.cpp
index 48109f46..e2ebdae4 100644
--- a/flowgraph.cpp
+++ b/flowgraph.cpp
@@ -386,6 +386,12 @@ void FlowGraph::Show(const string& title)
}
+bool FlowGraph::HasUpdates() const
+{
+ return false;
+}
+
+
Ref<FlowGraph> FlowGraph::Update()
{
return nullptr;
@@ -406,6 +412,15 @@ bool FlowGraph::IsOptionSet(BNFlowGraphOption option)
CoreFlowGraph::CoreFlowGraph(BNFlowGraph* graph): FlowGraph(graph)
{
+ m_queryMode = BNFlowGraphUpdateQueryMode(GetObject());
+}
+
+
+bool CoreFlowGraph::HasUpdates() const
+{
+ if (m_queryMode)
+ return BNFlowGraphHasUpdates(GetObject());
+ return false;
}
diff --git a/interaction.cpp b/interaction.cpp
index 7a7fa6bb..05420f17 100644
--- a/interaction.cpp
+++ b/interaction.cpp
@@ -755,3 +755,9 @@ void ReportCollection::AddGraphReport(Ref<BinaryView> view, const string& title,
{
BNAddGraphReportToCollection(m_object, view ? view->GetObject() : nullptr, title.c_str(), graph->GetObject());
}
+
+
+void ReportCollection::UpdateFlowGraph(size_t i, Ref<FlowGraph> graph)
+{
+ BNUpdateReportFlowGraph(m_object, i, graph->GetObject());
+}
diff --git a/python/interaction.py b/python/interaction.py
index 13cf93c6..7cc4442b 100644
--- a/python/interaction.py
+++ b/python/interaction.py
@@ -984,6 +984,18 @@ class ReportCollection(object):
else:
raise TypeError("expected report object")
+ def update(self, i, report):
+ # if isinstance(report, PlainTextReport):
+ # core.BNUpdatePlainTextReportToCollection(self.handle, i, report.contents)
+ # elif isinstance(report, MarkdownReport):
+ # core.BNUpdateMarkdownReportToCollection(self.handle, i, report.contents, report.plaintext)
+ # elif isinstance(report, HTMLReport):
+ # core.BNUpdateHTMLReportToCollection(self.handle, i, report.contents, report.plaintext)
+ if isinstance(report, FlowGraphReport):
+ core.BNUpdateReportFlowGraph(self.handle, i, report.graph.handle)
+ else:
+ raise TypeError("expected report object")
+
def markdown_to_html(contents):
"""