Flowgraph

Detailed Description

Classes

struct  BinaryNinja::FlowGraphEdge
 
class  BinaryNinja::FlowGraphNode
 
class  BinaryNinja::FlowGraphLayoutRequest
 
class  BinaryNinja::FlowGraph
 FlowGraph implements a directed flow graph to be shown in the UI. More...
 
class  BinaryNinja::CoreFlowGraph
 

Class Documentation

◆ BinaryNinja::FlowGraphEdge

struct BinaryNinja::FlowGraphEdge
Class Members
BNBranchType type
Ref< FlowGraphNode > target
vector< BNPoint > points
bool backEdge
BNEdgeStyle style

◆ BinaryNinja::FlowGraphNode

class BinaryNinja::FlowGraphNode

Public Member Functions

 FlowGraphNode (FlowGraph *graph)
 
 FlowGraphNode (BNFlowGraphNode *node)
 
Ref< FlowGraphGetGraph () const
 Get the FlowGraph associated with this node. More...
 
Ref< BasicBlockGetBasicBlock () const
 Get the Basic Block associated with this node. More...
 
void SetBasicBlock (BasicBlock *block)
 Set the Basic Block associated with this node. More...
 
int GetX () const
 Flow graph block X position. More...
 
int GetY () const
 Flow graph block Y position. More...
 
int GetWidth () const
 Flow graph block width. More...
 
int GetHeight () const
 Flow graph block height. More...
 
const std::vector< DisassemblyTextLine > & GetLines ()
 Get the list of DisassemblyTextLines for this graph node. More...
 
void SetLines (const std::vector< DisassemblyTextLine > &lines)
 Set the list of DisassemblyTextLines for this graph node. More...
 
const std::vector< FlowGraphEdge > & GetOutgoingEdges ()
 Get the list of outgoing edges for this flow graph node. More...
 
const std::vector< FlowGraphEdge > & GetIncomingEdges ()
 Get the list of incoming edges for this flow graph node. More...
 
void AddOutgoingEdge (BNBranchType type, FlowGraphNode *target, BNEdgeStyle edgeStyle=BNEdgeStyle())
 Connects two flow graph nodes with an edge. More...
 
BNHighlightColor GetHighlight () const
 Get the highlight color for the node. More...
 
void SetHighlight (const BNHighlightColor &color)
 Set the highlight color for the node. More...
 
bool IsValidForGraph (FlowGraph *graph) const
 
- Public Member Functions inherited from BinaryNinja::CoreRefCountObject< BNFlowGraphNode, BNNewFlowGraphNodeReference, BNFreeFlowGraphNode >
 CoreRefCountObject ()
 
virtual ~CoreRefCountObject ()
 
BNFlowGraphNodeGetObject () const
 
void AddRef ()
 
void Release ()
 
void AddRefForRegistration ()
 
void ReleaseForRegistration ()
 
void AddRefForCallback ()
 
void ReleaseForCallback ()
 

Additional Inherited Members

- Static Public Member Functions inherited from BinaryNinja::CoreRefCountObject< BNFlowGraphNode, BNNewFlowGraphNodeReference, BNFreeFlowGraphNode >
static BNFlowGraphNodeGetObject (CoreRefCountObject *obj)
 
static BNFlowGraphNodeGetObject (const CoreRefCountObject *obj)
 
- Public Attributes inherited from BinaryNinja::CoreRefCountObject< BNFlowGraphNode, BNNewFlowGraphNodeReference, BNFreeFlowGraphNode >
std::atomic< int > m_refs
 
bool m_registeredRef
 
BNFlowGraphNodem_object
 

Constructor & Destructor Documentation

◆ FlowGraphNode() [1/2]

FlowGraphNode::FlowGraphNode ( FlowGraph graph)

◆ FlowGraphNode() [2/2]

FlowGraphNode::FlowGraphNode ( BNFlowGraphNode node)

Member Function Documentation

◆ GetGraph()

Ref< FlowGraph > FlowGraphNode::GetGraph ( ) const

Get the FlowGraph associated with this node.

Returns
The FlowGraph associated with this node

◆ GetBasicBlock()

Ref< BasicBlock > FlowGraphNode::GetBasicBlock ( ) const

Get the Basic Block associated with this node.

Returns
The BasicBlock associated with this node

◆ SetBasicBlock()

void FlowGraphNode::SetBasicBlock ( BasicBlock block)

Set the Basic Block associated with this node.

Parameters
blockThe BasicBlock associated with this node

◆ GetX()

int FlowGraphNode::GetX ( ) const

Flow graph block X position.

Returns
Flow graph block X position

◆ GetY()

int FlowGraphNode::GetY ( ) const

Flow graph block Y position.

Returns
Flow graph block Y position

◆ GetWidth()

int FlowGraphNode::GetWidth ( ) const

Flow graph block width.

Returns
Flow graph block width

◆ GetHeight()

int FlowGraphNode::GetHeight ( ) const

Flow graph block height.

Returns
Flow graph block height

◆ GetLines()

const vector< DisassemblyTextLine > & FlowGraphNode::GetLines ( )

Get the list of DisassemblyTextLines for this graph node.

Returns
The list of DisassemblyTextLines for this graph node.

◆ SetLines()

void FlowGraphNode::SetLines ( const std::vector< DisassemblyTextLine > &  lines)

Set the list of DisassemblyTextLines for this graph node.

Parameters
linesThe list of DisassemblyTextLines for this graph node.

◆ GetOutgoingEdges()

const vector< FlowGraphEdge > & FlowGraphNode::GetOutgoingEdges ( )

Get the list of outgoing edges for this flow graph node.

Returns
The list of outgoing edges for this flow graph node

◆ GetIncomingEdges()

const vector< FlowGraphEdge > & FlowGraphNode::GetIncomingEdges ( )

Get the list of incoming edges for this flow graph node.

Returns
The list of incoming edges for this flow graph node

◆ AddOutgoingEdge()

void FlowGraphNode::AddOutgoingEdge ( BNBranchType  type,
FlowGraphNode target,
BNEdgeStyle  edgeStyle = BNEdgeStyle() 
)

Connects two flow graph nodes with an edge.

Parameters
typeType of edge to add
targetTarget node object
edgeStyle

Custom style for this edge.

Styling for graph edge Branch Type must be set to UserDefinedBranch

◆ GetHighlight()

BNHighlightColor FlowGraphNode::GetHighlight ( ) const

Get the highlight color for the node.

Returns
The highlight color for the node

◆ SetHighlight()

void FlowGraphNode::SetHighlight ( const BNHighlightColor color)

Set the highlight color for the node.

Parameters
colorThe highlight color for the node

◆ IsValidForGraph()

bool FlowGraphNode::IsValidForGraph ( FlowGraph graph) const

◆ BinaryNinja::FlowGraphLayoutRequest

class BinaryNinja::FlowGraphLayoutRequest

Public Member Functions

 FlowGraphLayoutRequest (FlowGraph *graph, const std::function< void()> &completeFunc)
 
virtual ~FlowGraphLayoutRequest ()
 
BNFlowGraphLayoutRequestGetObject () const
 
Ref< FlowGraphGetGraph () const
 
bool IsComplete () const
 
void Abort ()
 
- Public Member Functions inherited from BinaryNinja::RefCountObject
 RefCountObject ()
 
virtual ~RefCountObject ()
 
RefCountObjectGetObject ()
 
void AddRef ()
 
void Release ()
 

Additional Inherited Members

- Static Public Member Functions inherited from BinaryNinja::RefCountObject
static RefCountObjectGetObject (RefCountObject *obj)
 
- Public Attributes inherited from BinaryNinja::RefCountObject
std::atomic< int > m_refs
 

Constructor & Destructor Documentation

◆ FlowGraphLayoutRequest()

FlowGraphLayoutRequest::FlowGraphLayoutRequest ( FlowGraph graph,
const std::function< void()> &  completeFunc 
)

◆ ~FlowGraphLayoutRequest()

FlowGraphLayoutRequest::~FlowGraphLayoutRequest ( )
virtual

Member Function Documentation

◆ GetObject()

BNFlowGraphLayoutRequest * BinaryNinja::FlowGraphLayoutRequest::GetObject ( ) const
inline

◆ GetGraph()

Ref< FlowGraph > FlowGraphLayoutRequest::GetGraph ( ) const

◆ IsComplete()

bool FlowGraphLayoutRequest::IsComplete ( ) const

◆ Abort()

void FlowGraphLayoutRequest::Abort ( )

◆ BinaryNinja::FlowGraph

class BinaryNinja::FlowGraph

FlowGraph implements a directed flow graph to be shown in the UI.

This class allows plugins to create custom flow graphs and render them in the UI using the flow graph report API.

Public Member Functions

 FlowGraph ()
 
Ref< FunctionGetFunction () const
 Get the Function associated with this FlowGraph. More...
 
Ref< BinaryViewGetView () const
 Get the BinaryView associated with this FlowGraph. More...
 
void SetFunction (Function *func)
 Set the Function associated with this FlowGraph. More...
 
void SetView (BinaryView *view)
 Set the BinaryView associated with this FlowGraph. More...
 
int GetHorizontalNodeMargin () const
 
int GetVerticalNodeMargin () const
 
void SetNodeMargins (int horiz, int vert)
 
Ref< FlowGraphLayoutRequestStartLayout (const std::function< void()> &func)
 Starts rendering a graph for display. More...
 
bool IsLayoutComplete ()
 Check whether layout is complete. More...
 
std::vector< Ref< FlowGraphNode > > GetNodes ()
 Get the list of nodes in the graph. More...
 
Ref< FlowGraphNodeGetNode (size_t i)
 Retrieve node by index. More...
 
bool HasNodes () const
 Whether the FlowGraph has any nodes added. More...
 
size_t AddNode (FlowGraphNode *node)
 Add a node to this flowgraph. More...
 
int GetWidth () const
 Flow graph width. More...
 
int GetHeight () const
 Flow graph height. More...
 
std::vector< Ref< FlowGraphNode > > GetNodesInRegion (int left, int top, int right, int bottom)
 
bool IsILGraph () const
 Whether this graph is representing IL. More...
 
bool IsLowLevelILGraph () const
 Whether this graph is representing Low Level IL. More...
 
bool IsMediumLevelILGraph () const
 Whether this graph is representing Medium Level IL. More...
 
bool IsHighLevelILGraph () const
 Whether this graph is representing High Level IL. More...
 
Ref< LowLevelILFunctionGetLowLevelILFunction () const
 Get the associated Low Level IL Function. More...
 
Ref< MediumLevelILFunctionGetMediumLevelILFunction () const
 Get the associated Medium Level IL Function. More...
 
Ref< HighLevelILFunctionGetHighLevelILFunction () const
 Get the associated High Level IL Function. More...
 
void SetLowLevelILFunction (LowLevelILFunction *func)
 Set the associated Low Level IL Function. More...
 
void SetMediumLevelILFunction (MediumLevelILFunction *func)
 Set the associated Medium Level IL Function. More...
 
void SetHighLevelILFunction (HighLevelILFunction *func)
 Set the associated High Level IL Function. More...
 
void Show (const std::string &title)
 Display a flowgraph with a given title. More...
 
virtual bool HasUpdates () const
 
virtual Ref< FlowGraphUpdate ()
 
void SetOption (BNFlowGraphOption option, bool value=true)
 
bool IsOptionSet (BNFlowGraphOption option)
 
- Public Member Functions inherited from BinaryNinja::CoreRefCountObject< BNFlowGraph, BNNewFlowGraphReference, BNFreeFlowGraph >
 CoreRefCountObject ()
 
virtual ~CoreRefCountObject ()
 
BNFlowGraphGetObject () const
 
void AddRef ()
 
void Release ()
 
void AddRefForRegistration ()
 
void ReleaseForRegistration ()
 
void AddRefForCallback ()
 
void ReleaseForCallback ()
 

Protected Member Functions

 FlowGraph (BNFlowGraph *graph)
 
void FinishPrepareForLayout ()
 
virtual void PrepareForLayout ()
 
virtual void PopulateNodes ()
 
virtual void CompleteLayout ()
 

Protected Attributes

bool m_queryMode = false
 

Additional Inherited Members

- Static Public Member Functions inherited from BinaryNinja::CoreRefCountObject< BNFlowGraph, BNNewFlowGraphReference, BNFreeFlowGraph >
static BNFlowGraphGetObject (CoreRefCountObject *obj)
 
static BNFlowGraphGetObject (const CoreRefCountObject *obj)
 
- Public Attributes inherited from BinaryNinja::CoreRefCountObject< BNFlowGraph, BNNewFlowGraphReference, BNFreeFlowGraph >
std::atomic< int > m_refs
 
bool m_registeredRef
 
BNFlowGraphm_object
 

Constructor & Destructor Documentation

◆ FlowGraph() [1/2]

FlowGraph::FlowGraph ( BNFlowGraph graph)
protected

◆ FlowGraph() [2/2]

FlowGraph::FlowGraph ( )

Member Function Documentation

◆ FinishPrepareForLayout()

void FlowGraph::FinishPrepareForLayout ( )
protected

◆ PrepareForLayout()

void FlowGraph::PrepareForLayout ( )
protectedvirtual

◆ PopulateNodes()

void FlowGraph::PopulateNodes ( )
protectedvirtual

◆ CompleteLayout()

void FlowGraph::CompleteLayout ( )
protectedvirtual

◆ GetFunction()

Ref< Function > FlowGraph::GetFunction ( ) const

Get the Function associated with this FlowGraph.

Returns
The Function associated with this FlowGraph

◆ GetView()

Ref< BinaryView > FlowGraph::GetView ( ) const

Get the BinaryView associated with this FlowGraph.

Returns
The BinaryView associated with this FlowGraph

◆ SetFunction()

void FlowGraph::SetFunction ( Function func)

Set the Function associated with this FlowGraph.

Parameters
funcThe Function associated with this FlowGraph

◆ SetView()

void FlowGraph::SetView ( BinaryView view)

Set the BinaryView associated with this FlowGraph.

Parameters
viewThe BinaryView associated with this FlowGraph

◆ GetHorizontalNodeMargin()

int FlowGraph::GetHorizontalNodeMargin ( ) const

◆ GetVerticalNodeMargin()

int FlowGraph::GetVerticalNodeMargin ( ) const

◆ SetNodeMargins()

void FlowGraph::SetNodeMargins ( int  horiz,
int  vert 
)

◆ StartLayout()

Ref< FlowGraphLayoutRequest > FlowGraph::StartLayout ( const std::function< void()> &  func)

Starts rendering a graph for display.

Once a layout is complete, each node will contain coordinates and extents that can be used to render a graph with minimum additional computation. This function does not wait for the graph to be ready to display, but a callback can be provided to signal when the graph is ready.

Parameters
funcCallback to execute once layout is complete.
Returns

◆ IsLayoutComplete()

bool FlowGraph::IsLayoutComplete ( )

Check whether layout is complete.

Returns
Whether layout is complete

◆ GetNodes()

vector< Ref< FlowGraphNode > > FlowGraph::GetNodes ( )

Get the list of nodes in the graph.

Returns
List of nodes in the graph

◆ GetNode()

Ref< FlowGraphNode > FlowGraph::GetNode ( size_t  i)

Retrieve node by index.

Parameters
iIndex of the node to retrieve
Returns
The flow graph node at that index

◆ HasNodes()

bool FlowGraph::HasNodes ( ) const

Whether the FlowGraph has any nodes added.

Returns
Whether the FlowGraph has any nodes added

◆ AddNode()

size_t FlowGraph::AddNode ( FlowGraphNode node)

Add a node to this flowgraph.

Parameters
nodeNode to be added.
Returns
Index of the node

◆ GetWidth()

int FlowGraph::GetWidth ( ) const

Flow graph width.

Returns
Flow graph width

◆ GetHeight()

int FlowGraph::GetHeight ( ) const

Flow graph height.

Returns
Flow graph height

◆ GetNodesInRegion()

vector< Ref< FlowGraphNode > > FlowGraph::GetNodesInRegion ( int  left,
int  top,
int  right,
int  bottom 
)

◆ IsILGraph()

bool FlowGraph::IsILGraph ( ) const

Whether this graph is representing IL.

Returns
Whether this graph is representing IL.

◆ IsLowLevelILGraph()

bool FlowGraph::IsLowLevelILGraph ( ) const

Whether this graph is representing Low Level IL.

Returns
Whether this graph is representing Low Level IL.

◆ IsMediumLevelILGraph()

bool FlowGraph::IsMediumLevelILGraph ( ) const

Whether this graph is representing Medium Level IL.

Returns
Whether this graph is representing Medium Level IL.

◆ IsHighLevelILGraph()

bool FlowGraph::IsHighLevelILGraph ( ) const

Whether this graph is representing High Level IL.

Returns
Whether this graph is representing High Level IL.

◆ GetLowLevelILFunction()

Ref< LowLevelILFunction > FlowGraph::GetLowLevelILFunction ( ) const

Get the associated Low Level IL Function.

Returns
The associated Low Level IL Function

◆ GetMediumLevelILFunction()

Ref< MediumLevelILFunction > FlowGraph::GetMediumLevelILFunction ( ) const

Get the associated Medium Level IL Function.

Returns
The associated Medium Level IL Function

◆ GetHighLevelILFunction()

Ref< HighLevelILFunction > FlowGraph::GetHighLevelILFunction ( ) const

Get the associated High Level IL Function.

Returns
The associated High Level IL Function

◆ SetLowLevelILFunction()

void FlowGraph::SetLowLevelILFunction ( LowLevelILFunction func)

Set the associated Low Level IL Function.

Parameters
funcThe associated function

◆ SetMediumLevelILFunction()

void FlowGraph::SetMediumLevelILFunction ( MediumLevelILFunction func)

Set the associated Medium Level IL Function.

Parameters
funcThe associated function

◆ SetHighLevelILFunction()

void FlowGraph::SetHighLevelILFunction ( HighLevelILFunction func)

Set the associated High Level IL Function.

Parameters
funcThe associated function

◆ Show()

void FlowGraph::Show ( const std::string &  title)

Display a flowgraph with a given title.

Parameters
titleTitle for the flowgraph

◆ HasUpdates()

bool FlowGraph::HasUpdates ( ) const
virtual

Reimplemented in BinaryNinja::CoreFlowGraph.

◆ Update()

Ref< FlowGraph > FlowGraph::Update ( )
virtual

Reimplemented in BinaryNinja::CoreFlowGraph.

◆ SetOption()

void FlowGraph::SetOption ( BNFlowGraphOption  option,
bool  value = true 
)

◆ IsOptionSet()

bool FlowGraph::IsOptionSet ( BNFlowGraphOption  option)

Member Data Documentation

◆ m_queryMode

bool BinaryNinja::FlowGraph::m_queryMode = false
protected

◆ BinaryNinja::CoreFlowGraph

class BinaryNinja::CoreFlowGraph

Public Member Functions

 CoreFlowGraph (BNFlowGraph *graph)
 
virtual bool HasUpdates () const override
 
virtual Ref< FlowGraphUpdate () override
 
- Public Member Functions inherited from BinaryNinja::FlowGraph
 FlowGraph ()
 
Ref< FunctionGetFunction () const
 Get the Function associated with this FlowGraph. More...
 
Ref< BinaryViewGetView () const
 Get the BinaryView associated with this FlowGraph. More...
 
void SetFunction (Function *func)
 Set the Function associated with this FlowGraph. More...
 
void SetView (BinaryView *view)
 Set the BinaryView associated with this FlowGraph. More...
 
int GetHorizontalNodeMargin () const
 
int GetVerticalNodeMargin () const
 
void SetNodeMargins (int horiz, int vert)
 
Ref< FlowGraphLayoutRequestStartLayout (const std::function< void()> &func)
 Starts rendering a graph for display. More...
 
bool IsLayoutComplete ()
 Check whether layout is complete. More...
 
std::vector< Ref< FlowGraphNode > > GetNodes ()
 Get the list of nodes in the graph. More...
 
Ref< FlowGraphNodeGetNode (size_t i)
 Retrieve node by index. More...
 
bool HasNodes () const
 Whether the FlowGraph has any nodes added. More...
 
size_t AddNode (FlowGraphNode *node)
 Add a node to this flowgraph. More...
 
int GetWidth () const
 Flow graph width. More...
 
int GetHeight () const
 Flow graph height. More...
 
std::vector< Ref< FlowGraphNode > > GetNodesInRegion (int left, int top, int right, int bottom)
 
bool IsILGraph () const
 Whether this graph is representing IL. More...
 
bool IsLowLevelILGraph () const
 Whether this graph is representing Low Level IL. More...
 
bool IsMediumLevelILGraph () const
 Whether this graph is representing Medium Level IL. More...
 
bool IsHighLevelILGraph () const
 Whether this graph is representing High Level IL. More...
 
Ref< LowLevelILFunctionGetLowLevelILFunction () const
 Get the associated Low Level IL Function. More...
 
Ref< MediumLevelILFunctionGetMediumLevelILFunction () const
 Get the associated Medium Level IL Function. More...
 
Ref< HighLevelILFunctionGetHighLevelILFunction () const
 Get the associated High Level IL Function. More...
 
void SetLowLevelILFunction (LowLevelILFunction *func)
 Set the associated Low Level IL Function. More...
 
void SetMediumLevelILFunction (MediumLevelILFunction *func)
 Set the associated Medium Level IL Function. More...
 
void SetHighLevelILFunction (HighLevelILFunction *func)
 Set the associated High Level IL Function. More...
 
void Show (const std::string &title)
 Display a flowgraph with a given title. More...
 
virtual bool HasUpdates () const
 
virtual Ref< FlowGraphUpdate ()
 
void SetOption (BNFlowGraphOption option, bool value=true)
 
bool IsOptionSet (BNFlowGraphOption option)
 
- Public Member Functions inherited from BinaryNinja::CoreRefCountObject< BNFlowGraph, BNNewFlowGraphReference, BNFreeFlowGraph >
 CoreRefCountObject ()
 
virtual ~CoreRefCountObject ()
 
BNFlowGraphGetObject () const
 
void AddRef ()
 
void Release ()
 
void AddRefForRegistration ()
 
void ReleaseForRegistration ()
 
void AddRefForCallback ()
 
void ReleaseForCallback ()
 

Additional Inherited Members

- Static Public Member Functions inherited from BinaryNinja::CoreRefCountObject< BNFlowGraph, BNNewFlowGraphReference, BNFreeFlowGraph >
static BNFlowGraphGetObject (CoreRefCountObject *obj)
 
static BNFlowGraphGetObject (const CoreRefCountObject *obj)
 
- Public Attributes inherited from BinaryNinja::CoreRefCountObject< BNFlowGraph, BNNewFlowGraphReference, BNFreeFlowGraph >
std::atomic< int > m_refs
 
bool m_registeredRef
 
BNFlowGraphm_object
 
- Protected Member Functions inherited from BinaryNinja::FlowGraph
 FlowGraph (BNFlowGraph *graph)
 
void FinishPrepareForLayout ()
 
virtual void PrepareForLayout ()
 
virtual void PopulateNodes ()
 
virtual void CompleteLayout ()
 
- Protected Attributes inherited from BinaryNinja::FlowGraph
bool m_queryMode = false
 

Constructor & Destructor Documentation

◆ CoreFlowGraph()

CoreFlowGraph::CoreFlowGraph ( BNFlowGraph graph)

Member Function Documentation

◆ HasUpdates()

bool CoreFlowGraph::HasUpdates ( ) const
overridevirtual

Reimplemented from BinaryNinja::FlowGraph.

◆ Update()

Ref< FlowGraph > CoreFlowGraph::Update ( )
overridevirtual

Reimplemented from BinaryNinja::FlowGraph.