summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Potchik <brian@vector35.com>2025-04-08 21:44:48 -0400
committerBrian Potchik <brian@vector35.com>2025-04-08 22:43:32 -0400
commit4403757cf9f0ad1cbca6f99d46b45f534edc66c0 (patch)
tree40043430d3fcaf401cd7d7b66c25160bd8dbb240
parente424223cfb0aaea137b98f233de6fa7384a3901c (diff)
Add API to post requests to the workflow machine.
-rw-r--r--binaryninjaapi.h2
-rw-r--r--workflow.cpp17
2 files changed, 19 insertions, 0 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 82e6ace1..5c292481 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -10083,6 +10083,8 @@ namespace BinaryNinja {
WorkflowMachine(Ref<BinaryView> view);
WorkflowMachine(Ref<Function> function);
+ bool PostJsonRequest(const std::string& request);
+
/*! Start the workflow WorkflowMachine
Starts the workflow machine for the given BinaryView or Function.
\return true if the command is accepted, false otherwise.
diff --git a/workflow.cpp b/workflow.cpp
index 8e3dc7df..8146e923 100644
--- a/workflow.cpp
+++ b/workflow.cpp
@@ -147,6 +147,23 @@ WorkflowMachine::WorkflowMachine(Ref<Function> function): m_function(function)
}
+bool WorkflowMachine::PostJsonRequest(const std::string& request)
+{
+ string jsonResult;
+ if (m_function)
+ jsonResult = BNPostWorkflowRequestForFunction(m_function->GetObject(), request.c_str());
+ else
+ jsonResult = BNPostWorkflowRequestForBinaryView(m_view->GetObject(), request.c_str());
+
+ 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::Run()
{
return PostRequest("run");