Skip to content

Commit 4403757

Browse files
committed
Add API to post requests to the workflow machine.
1 parent e424223 commit 4403757

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

binaryninjaapi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10083,6 +10083,8 @@ namespace BinaryNinja {
1008310083
WorkflowMachine(Ref<BinaryView> view);
1008410084
WorkflowMachine(Ref<Function> function);
1008510085

10086+
bool PostJsonRequest(const std::string& request);
10087+
1008610088
/*! Start the workflow WorkflowMachine
1008710089
Starts the workflow machine for the given BinaryView or Function.
1008810090
\return true if the command is accepted, false otherwise.

workflow.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,23 @@ WorkflowMachine::WorkflowMachine(Ref<Function> function): m_function(function)
147147
}
148148

149149

150+
bool WorkflowMachine::PostJsonRequest(const std::string& request)
151+
{
152+
string jsonResult;
153+
if (m_function)
154+
jsonResult = BNPostWorkflowRequestForFunction(m_function->GetObject(), request.c_str());
155+
else
156+
jsonResult = BNPostWorkflowRequestForBinaryView(m_view->GetObject(), request.c_str());
157+
158+
rapidjson::Document response(rapidjson::kObjectType);
159+
response.Parse(jsonResult.c_str());
160+
if (response.HasMember("commandStatus") && response["commandStatus"].HasMember("accepted"))
161+
return response["commandStatus"]["accepted"].GetBool();
162+
163+
return false;
164+
}
165+
166+
150167
bool WorkflowMachine::Run()
151168
{
152169
return PostRequest("run");

0 commit comments

Comments
 (0)