summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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");