Loading...
Searching...
No Matches
Workflows

Detailed Description

Classes

class  BinaryNinja::AnalysisContext
 
class  BinaryNinja::Activity
 
class  BinaryNinja::Workflow
 A Binary Ninja Workflow is an abstraction of a computational binary analysis pipeline and it provides the extensibility mechanism needed for tailored binary analysis and decompilation. More...
 

Class Documentation

◆ BinaryNinja::AnalysisContext

class BinaryNinja::AnalysisContext

Public Member Functions

 AnalysisContext (BNAnalysisContext *analysisContext)
 
virtual ~AnalysisContext ()
 
Ref< BinaryViewGetBinaryView ()
 Get the BinaryView for the current AnalysisContext.
 
Ref< FunctionGetFunction ()
 Get the Function for the current AnalysisContext.
 
Ref< LowLevelILFunctionGetLowLevelILFunction ()
 Get the low level IL function for the current AnalysisContext.
 
Ref< MediumLevelILFunctionGetMediumLevelILFunction ()
 Get the medium level IL function for the current AnalysisContext.
 
Ref< HighLevelILFunctionGetHighLevelILFunction ()
 Get the high level IL function for the current AnalysisContext.
 
void SetBasicBlockList (std::vector< Ref< BasicBlock > > basicBlocks)
 Set a new BasicBlock list for the current analysis context.
 
void SetLiftedILFunction (Ref< LowLevelILFunction > liftedIL)
 Set new lifted IL for the current analysis context.
 
void SetLowLevelILFunction (Ref< LowLevelILFunction > lowLevelIL)
 Set the new Low Level IL for the current analysis context.
 
void SetMediumLevelILFunction (Ref< MediumLevelILFunction > mediumLevelIL)
 Set the new Medium Level IL for the current analysis context.
 
void SetHighLevelILFunction (Ref< HighLevelILFunction > highLevelIL)
 Set the new High Level IL for the current analysis context.
 
bool Inform (const std::string &request)
 
- Public Member Functions inherited from BinaryNinja::CoreRefCountObject< BNAnalysisContext, BNNewAnalysisContextReference, BNFreeAnalysisContext >
 CoreRefCountObject ()
 
virtual ~CoreRefCountObject ()
 
BNAnalysisContextGetObject () const
 
void AddRef ()
 
void Release ()
 
void AddRefForRegistration ()
 
void ReleaseForRegistration ()
 
void AddRefForCallback ()
 
void ReleaseForCallback ()
 

Additional Inherited Members

- Static Public Member Functions inherited from BinaryNinja::CoreRefCountObject< BNAnalysisContext, BNNewAnalysisContextReference, BNFreeAnalysisContext >
static BNAnalysisContextGetObject (CoreRefCountObject *obj)
 
static BNAnalysisContextGetObject (const CoreRefCountObject *obj)
 
- Public Attributes inherited from BinaryNinja::CoreRefCountObject< BNAnalysisContext, BNNewAnalysisContextReference, BNFreeAnalysisContext >
std::atomic< int > m_refs
 
bool m_registeredRef
 
BNAnalysisContextm_object
 

Constructor & Destructor Documentation

◆ AnalysisContext()

AnalysisContext::AnalysisContext ( BNAnalysisContext * analysisContext)

◆ ~AnalysisContext()

AnalysisContext::~AnalysisContext ( )
virtual

Member Function Documentation

◆ GetBinaryView()

Ref< BinaryView > AnalysisContext::GetBinaryView ( )

Get the BinaryView for the current AnalysisContext.

Returns
The binary view for the current context

◆ GetFunction()

Ref< Function > AnalysisContext::GetFunction ( )

Get the Function for the current AnalysisContext.

Returns
The function for the current context

◆ GetLowLevelILFunction()

Ref< LowLevelILFunction > AnalysisContext::GetLowLevelILFunction ( )

Get the low level IL function for the current AnalysisContext.

Returns
The LowLevelILFunction for the current context

◆ GetMediumLevelILFunction()

Ref< MediumLevelILFunction > AnalysisContext::GetMediumLevelILFunction ( )

Get the medium level IL function for the current AnalysisContext.

Returns
The MediumLevelILFunction for the current context

◆ GetHighLevelILFunction()

Ref< HighLevelILFunction > AnalysisContext::GetHighLevelILFunction ( )

Get the high level IL function for the current AnalysisContext.

Returns
The HighLevelILFunction for the current context

◆ SetBasicBlockList()

void AnalysisContext::SetBasicBlockList ( std::vector< Ref< BasicBlock > > basicBlocks)

Set a new BasicBlock list for the current analysis context.

Parameters
basicBlocksThe new list of BasicBlocks

◆ SetLiftedILFunction()

void AnalysisContext::SetLiftedILFunction ( Ref< LowLevelILFunction > liftedIL)

Set new lifted IL for the current analysis context.

Parameters
liftedILThe new lifted IL

◆ SetLowLevelILFunction()

void AnalysisContext::SetLowLevelILFunction ( Ref< LowLevelILFunction > lowLevelIL)

Set the new Low Level IL for the current analysis context.

Parameters
lowLevelILthe new Low Level IL

◆ SetMediumLevelILFunction()

void AnalysisContext::SetMediumLevelILFunction ( Ref< MediumLevelILFunction > mediumLevelIL)

Set the new Medium Level IL for the current analysis context.

Parameters
mediumLevelILthe new Medium Level IL

◆ SetHighLevelILFunction()

void AnalysisContext::SetHighLevelILFunction ( Ref< HighLevelILFunction > highLevelIL)

Set the new High Level IL for the current analysis context.

Parameters
highLevelILthe new High Level IL

◆ Inform()

bool AnalysisContext::Inform ( const std::string & request)

◆ BinaryNinja::Activity

class BinaryNinja::Activity

Public Member Functions

 Activity (const std::string &configuration, const std::function< void(Ref< AnalysisContext >)> &action)
 
 Activity (BNActivity *activity)
 
virtual ~Activity ()
 
std::string GetName () const
 Get the Activity name.
 
- Public Member Functions inherited from BinaryNinja::CoreRefCountObject< BNActivity, BNNewActivityReference, BNFreeActivity >
 CoreRefCountObject ()
 
virtual ~CoreRefCountObject ()
 
BNActivityGetObject () const
 
void AddRef ()
 
void Release ()
 
void AddRefForRegistration ()
 
void ReleaseForRegistration ()
 
void AddRefForCallback ()
 
void ReleaseForCallback ()
 

Static Protected Member Functions

static void Run (void *ctxt, BNAnalysisContext *analysisContext)
 

Protected Attributes

std::function< void(Ref< AnalysisContext > analysisContext)> m_action
 

Additional Inherited Members

- Static Public Member Functions inherited from BinaryNinja::CoreRefCountObject< BNActivity, BNNewActivityReference, BNFreeActivity >
static BNActivityGetObject (CoreRefCountObject *obj)
 
static BNActivityGetObject (const CoreRefCountObject *obj)
 
- Public Attributes inherited from BinaryNinja::CoreRefCountObject< BNActivity, BNNewActivityReference, BNFreeActivity >
std::atomic< int > m_refs
 
bool m_registeredRef
 
BNActivitym_object
 

Constructor & Destructor Documentation

◆ Activity() [1/2]

BinaryNinja::Activity::Activity ( const std::string & configuration,
const std::function< void(Ref< AnalysisContext >)> & action )
MyClass::MyActionMethod(Ref<AnalysisContext> ac);
...
// Create a clone of the default workflow named "core.function.myWorkflowName"
Ref<Workflow> wf = BinaryNinja::Workflow::Instance("core.function.defaultAnalysis")->Clone("core.function.myWorkflowName");
wf->RegisterActivity(new BinaryNinja::Activity("core.function.myWorkflowName.resolveMethodCalls", &MyClass::MyActionMethod));
Definition binaryninjaapi.h:239
static Ref< Workflow > Instance(const std::string &name="")
Get an instance of a workflow by name.
Definition workflow.cpp:245
Ref< Workflow > Clone(const std::string &name, const std::string &activity="")
Clone a workflow, copying all Activities and the execution strategy.
Definition workflow.cpp:257
Ref< Activity > RegisterActivity(const std::string &configuration, const std::function< void(Ref< AnalysisContext >)> &action, const std::vector< std::string > &subactivities={})
Register an Activity with this Workflow.
Definition binaryninjaapi.h:9936
A Binary Ninja Workflow is an abstraction of a computational binary analysis pipeline and it provides...
Definition binaryninjaapi.h:9993
Parameters
configurationa JSON representation of the activity configuration
actionWorkflow action, a function taking a Ref<AnalysisContext> as an argument.

◆ Activity() [2/2]

Activity::Activity ( BNActivity * activity)

◆ ~Activity()

Activity::~Activity ( )
virtual

Member Function Documentation

◆ Run()

void Activity::Run ( void * ctxt,
BNAnalysisContext * analysisContext )
staticprotected

◆ GetName()

string Activity::GetName ( ) const

Get the Activity name.

Returns
Activity name

Member Data Documentation

◆ m_action

std::function<void(Ref<AnalysisContext> analysisContext)> BinaryNinja::Activity::m_action
protected

◆ BinaryNinja::Workflow

class BinaryNinja::Workflow

A Binary Ninja Workflow is an abstraction of a computational binary analysis pipeline and it provides the extensibility mechanism needed for tailored binary analysis and decompilation.

More specifically, a Workflow is a repository of activities along with a unique strategy to execute them. Binary Ninja provides two Workflows named ``core.module.defaultAnalysis`` and ``core.function.defaultAnalysis`` which expose the core analysis.

A Workflow starts in the unregistered state from either creating a new empty Workflow, or cloning an existing Workflow. While unregistered it's possible to add and remove activities, as well as change the execution strategy. In order to use the Workflow on a binary it must be registered. Once registered the Workflow is immutable and available for use.

Public Member Functions

 Workflow (const std::string &name="")
 
 Workflow (BNWorkflow *workflow)
 
 Workflow (BNWorkflow *workflow, Ref< BinaryView > view)
 
 Workflow (BNWorkflow *workflow, Ref< Function > function)
 
virtual ~Workflow ()
 
Ref< WorkflowClone (const std::string &name, const std::string &activity="")
 Clone a workflow, copying all Activities and the execution strategy.
 
Ref< ActivityRegisterActivity (const std::string &configuration, const std::function< void(Ref< AnalysisContext >)> &action, const std::vector< std::string > &subactivities={})
 Register an Activity with this Workflow.
 
Ref< ActivityRegisterActivity (Ref< Activity > activity, const std::vector< std::string > &subactivities={})
 Register an Activity with this Workflow.
 
bool Contains (const std::string &activity)
 Determine if an Activity exists in this Workflow.
 
std::string GetConfiguration (const std::string &activity="")
 Retrieve the configuration as an adjacency list in JSON for the Workflow, or if specified just for the given ``activity``.
 
std::string GetName () const
 Get the workflow name.
 
bool IsRegistered () const
 Check whether the workflow is registered.
 
size_t Size () const
 Get the amount of registered activities for this Workflow.
 
Ref< ActivityGetActivity (const std::string &activity)
 Retrieve an activity by name.
 
std::vector< std::string > GetActivityRoots (const std::string &activity="")
 Retrieve the list of activity roots for the Workflow, or if specified just for the given `activity`.
 
std::vector< std::string > GetSubactivities (const std::string &activity="", bool immediate=true)
 Retrieve the list of all activities, or optionally a filtered list.
 
bool AssignSubactivities (const std::string &activity, const std::vector< std::string > &subactivities={})
 Assign the list of `activities` as the new set of children for the specified `activity`.
 
bool Clear ()
 Remove all activity nodes from this Workflow.
 
bool Insert (const std::string &activity, const std::string &newActivity)
 Insert an activity before the specified activity and at the same level.
 
bool Insert (const std::string &activity, const std::vector< std::string > &activities)
 Insert a list of activities before the specified activity and at the same level.
 
bool Remove (const std::string &activity)
 Remove an activity by name.
 
bool Replace (const std::string &activity, const std::string &newActivity)
 Replace the activity name.
 
Ref< FlowGraphGetGraph (const std::string &activity="", bool sequential=false)
 Generate a FlowGraph object for the current Workflow.
 
void ShowReport (const std::string &name)
 
std::vector< std::string > GetEligibilitySettings ()
 
WorkflowMachineGetWorkflowMachine () const
 
- Public Member Functions inherited from BinaryNinja::CoreRefCountObject< BNWorkflow, BNNewWorkflowReference, BNFreeWorkflow >
 CoreRefCountObject ()
 
virtual ~CoreRefCountObject ()
 
BNWorkflowGetObject () const
 
void AddRef ()
 
void Release ()
 
void AddRefForRegistration ()
 
void ReleaseForRegistration ()
 
void AddRefForCallback ()
 
void ReleaseForCallback ()
 

Static Public Member Functions

static std::vector< Ref< Workflow > > GetList ()
 Get a list of all workflows.
 
static Ref< WorkflowInstance (const std::string &name="")
 Get an instance of a workflow by name.
 
static bool RegisterWorkflow (Ref< Workflow > workflow, const std::string &description="")
 Register a workflow, making it immutable and available for use.
 
- Static Public Member Functions inherited from BinaryNinja::CoreRefCountObject< BNWorkflow, BNNewWorkflowReference, BNFreeWorkflow >
static BNWorkflowGetObject (CoreRefCountObject *obj)
 
static BNWorkflowGetObject (const CoreRefCountObject *obj)
 

Additional Inherited Members

- Public Attributes inherited from BinaryNinja::CoreRefCountObject< BNWorkflow, BNNewWorkflowReference, BNFreeWorkflow >
std::atomic< int > m_refs
 
bool m_registeredRef
 
BNWorkflowm_object
 

Constructor & Destructor Documentation

◆ Workflow() [1/4]

BinaryNinja::Workflow::Workflow ( const std::string & name = "")

◆ Workflow() [2/4]

Workflow::Workflow ( BNWorkflow * workflow)

◆ Workflow() [3/4]

Workflow::Workflow ( BNWorkflow * workflow,
Ref< BinaryView > view )

◆ Workflow() [4/4]

Workflow::Workflow ( BNWorkflow * workflow,
Ref< Function > function )

◆ ~Workflow()

virtual BinaryNinja::Workflow::~Workflow ( )
inlinevirtual

Member Function Documentation

◆ GetList()

vector< Ref< Workflow > > Workflow::GetList ( )
static

Get a list of all workflows.

Returns
A list of Workflows

◆ Instance()

Ref< Workflow > Workflow::Instance ( const std::string & name = "")
static

Get an instance of a workflow by name.

If it is already registered, this will return the registered Workflow. If not, it will create and return a new Workflow.

Parameters
nameWorkflow name
Returns
The registered workflow.

◆ RegisterWorkflow()

bool Workflow::RegisterWorkflow ( Ref< Workflow > workflow,
const std::string & description = "" )
static

Register a workflow, making it immutable and available for use.

Parameters
workflowThe workflow to register
descriptionA JSON description of the Workflow
Returns
true on success, false otherwise

◆ Clone()

Ref< Workflow > Workflow::Clone ( const std::string & name,
const std::string & activity = "" )

Clone a workflow, copying all Activities and the execution strategy.

Parameters
nameName for the new Workflow
activityIf specified, perform the clone with `activity` as the root
Returns
A new Workflow

◆ RegisterActivity() [1/2]

Ref< Activity > BinaryNinja::Workflow::RegisterActivity ( const std::string & configuration,
const std::function< void(Ref< AnalysisContext >)> & action,
const std::vector< std::string > & subactivities = {} )

Register an Activity with this Workflow.

Parameters
activityThe Activity to register
descriptionA JSON description of the Activity
Returns

Register an Activity with this Workflow

Parameters
configurationa JSON representation of the activity configuration
actionWorkflow action, a function taking a Ref<AnalysisContext> as an argument.
subactivitiesThe list of Activities to assign
Returns

◆ RegisterActivity() [2/2]

Ref< Activity > BinaryNinja::Workflow::RegisterActivity ( Ref< Activity > activity,
const std::vector< std::string > & subactivities = {} )

Register an Activity with this Workflow.

Parameters
activityThe Activity to register
subactivitiesThe list of Activities to assign
Returns

◆ Contains()

bool Workflow::Contains ( const std::string & activity)

Determine if an Activity exists in this Workflow.

Parameters
activityThe Activity name
Returns
Whether the Activity exists in this workflow

◆ GetConfiguration()

string Workflow::GetConfiguration ( const std::string & activity = "")

Retrieve the configuration as an adjacency list in JSON for the Workflow, or if specified just for the given ``activity``.

Parameters
activityIf specified, return the configuration for the ``activity``
Returns
An adjacency list representation of the configuration in JSON

◆ GetName()

string Workflow::GetName ( ) const

Get the workflow name.

Returns
The workflow name

◆ IsRegistered()

bool Workflow::IsRegistered ( ) const

Check whether the workflow is registered.

Returns
Whether the workflow is registered

◆ Size()

size_t Workflow::Size ( ) const

Get the amount of registered activities for this Workflow.

Returns
The amount of registered workflows

◆ GetActivity()

Ref< Activity > Workflow::GetActivity ( const std::string & activity)

Retrieve an activity by name.

Parameters
activityThe Activity name
Returns
The Activity object

◆ GetActivityRoots()

vector< string > Workflow::GetActivityRoots ( const std::string & activity = "")

Retrieve the list of activity roots for the Workflow, or if specified just for the given `activity`.

Parameters
activityIf specified, return the roots for `activity`
Returns
A list of root activity names.

◆ GetSubactivities()

vector< string > Workflow::GetSubactivities ( const std::string & activity = "",
bool immediate = true )

Retrieve the list of all activities, or optionally a filtered list.

Parameters
activityIf specified, return the direct children and optionally the descendants of the `activity` (includes `activity`)
immediatewhether to include only direct children of `activity` or all descendants
Returns
A list of Activity names

◆ AssignSubactivities()

bool Workflow::AssignSubactivities ( const std::string & activity,
const std::vector< std::string > & subactivities = {} )

Assign the list of `activities` as the new set of children for the specified `activity`.

Parameters
activityThe activity node to assign children
subactivitiesthe list of Activities to assign
Returns
true on success, false otherwise

◆ Clear()

bool Workflow::Clear ( )

Remove all activity nodes from this Workflow.

Returns
true on success, false otherwise

◆ Insert() [1/2]

bool BinaryNinja::Workflow::Insert ( const std::string & activity,
const std::string & newActivity )

Insert an activity before the specified activity and at the same level.

Parameters
activityName of the activity to insert the new one before
newActivityName of the new activity to be inserted
Returns
true on success, false otherwise

◆ Insert() [2/2]

bool BinaryNinja::Workflow::Insert ( const std::string & activity,
const std::vector< std::string > & activities )

Insert a list of activities before the specified activity and at the same level.

Parameters
activityName of the activity to insert the new one before
newActivityName of the new activities to be inserted
Returns
true on success, false otherwise

◆ Remove()

bool Workflow::Remove ( const std::string & activity)

Remove an activity by name.

Parameters
activityName of the activity to remove
Returns
true on success, false otherwise

◆ Replace()

bool Workflow::Replace ( const std::string & activity,
const std::string & newActivity )

Replace the activity name.

Parameters
activityName of the activity to replace
newActivityName of the new activity
Returns
true on success, false otherwise

◆ GetGraph()

Ref< FlowGraph > Workflow::GetGraph ( const std::string & activity = "",
bool sequential = false )

Generate a FlowGraph object for the current Workflow.

Parameters
activityif specified, generate the Flowgraph using ``activity`` as the root
sequentialwhether to generate a **Composite** or **Sequential** style graph
Returns
FlowGraph on success

◆ ShowReport()

void Workflow::ShowReport ( const std::string & name)

◆ GetEligibilitySettings()

vector< string > Workflow::GetEligibilitySettings ( )

◆ GetWorkflowMachine()

WorkflowMachine * BinaryNinja::Workflow::GetWorkflowMachine ( ) const
inline