summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--binaryninjaapi.h20
-rw-r--r--python/binaryview.py5
-rw-r--r--workflow.cpp48
3 files changed, 68 insertions, 5 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 4336febb..6b1d268e 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -5224,9 +5224,9 @@ namespace BinaryNinja {
*/
void UpdateAnalysis();
- /*! Abort the currently running analysis
+ /*! Abort analysis and suspend the workflow machine
- This method should be considered non-recoverable and generally only used when shutdown is imminent after stopping.
+ Stops analysis and transitions the workflow machine to the Suspend state. This operation is recoverable, and the workflow machine can be re-enabled via the WorkflowMachine Enable API.
*/
void AbortAnalysis();
@@ -10058,6 +10058,22 @@ namespace BinaryNinja {
WorkflowMachine(Ref<BinaryView> view);
WorkflowMachine(Ref<Function> function);
+ /*! Enable the workflow machine
+
+ Re-enables the workflow machine if it is in the Suspend state.
+ \return true if the command is accepted, false otherwise.
+ */
+ bool Enable();
+
+ /*! Disable the workflow machine
+
+ Disables analysis and suspends the workflow machine, equivalent to AbortAnalysis.
+ This operation is recoverable and the workflow machine can be re-enabled via the Enable API.
+ \return true if the command is accepted, false otherwise.
+ */
+ bool Disable();
+
+
std::optional<bool> QueryOverride(const std::string& activity);
bool SetOverride(const std::string& activity, bool enable);
bool ClearOverride(const std::string& activity);
diff --git a/python/binaryview.py b/python/binaryview.py
index 81a0e5e7..753f589d 100644
--- a/python/binaryview.py
+++ b/python/binaryview.py
@@ -4931,9 +4931,8 @@ class BinaryView:
def abort_analysis(self) -> None:
"""
- ``abort_analysis`` will abort the currently running analysis.
-
- .. warning:: This method should be considered non-recoverable and generally only used when shutdown is imminent after stopping.
+ ``abort_analysis`` aborts analysis and suspends the workflow machine. This operation is recoverable, and the workflow machine
+ can be re-enabled via the ``enable`` API on WorkflowMachine.
:rtype: None
"""
diff --git a/workflow.cpp b/workflow.cpp
index 3e43707e..63066baa 100644
--- a/workflow.cpp
+++ b/workflow.cpp
@@ -122,6 +122,54 @@ WorkflowMachine::WorkflowMachine(Ref<Function> function): m_function(function)
}
+bool WorkflowMachine::Enable()
+{
+ rapidjson::Document request(rapidjson::kObjectType);
+ rapidjson::Document::AllocatorType& allocator = request.GetAllocator();
+ request.AddMember("command", "enable", allocator);
+ rapidjson::StringBuffer buffer;
+ rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
+ request.Accept(writer);
+
+ string jsonResult;
+ if (m_function)
+ jsonResult = BNPostWorkflowRequestForFunction(m_function->GetObject(), buffer.GetString());
+ else
+ jsonResult = BNPostWorkflowRequestForBinaryView(m_view->GetObject(), buffer.GetString());
+
+ rapidjson::Document response(rapidjson::kObjectType);
+ response.Parse(jsonResult.c_str());
+ if (response.HasMember("commandStatus") && response["commandStatus"].HasMember("accepted"))
+ return response["commandStatus"]["accepted"].GetBool();
+
+ return false;
+}
+
+
+bool WorkflowMachine::Disable()
+{
+ rapidjson::Document request(rapidjson::kObjectType);
+ rapidjson::Document::AllocatorType& allocator = request.GetAllocator();
+ request.AddMember("command", "disable", allocator);
+ rapidjson::StringBuffer buffer;
+ rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
+ request.Accept(writer);
+
+ string jsonResult;
+ if (m_function)
+ jsonResult = BNPostWorkflowRequestForFunction(m_function->GetObject(), buffer.GetString());
+ else
+ jsonResult = BNPostWorkflowRequestForBinaryView(m_view->GetObject(), buffer.GetString());
+
+ rapidjson::Document response(rapidjson::kObjectType);
+ response.Parse(jsonResult.c_str());
+ if (response.HasMember("commandStatus") && response["commandStatus"].HasMember("accepted"))
+ return response["commandStatus"]["accepted"].GetBool();
+
+ return false;
+}
+
+
std::optional<bool> WorkflowMachine::QueryOverride(const string& activity)
{
rapidjson::Document request(rapidjson::kObjectType);