Loading...
Searching...
No Matches
Basic Blocks

Documentation for interacting with basic blocks . More...

Detailed Description

Documentation for interacting with basic blocks .

Classes

struct  BinaryNinja::BasicBlockEdge
 
class  BinaryNinja::BasicBlock
 

Class Documentation

◆ BinaryNinja::BasicBlockEdge

struct BinaryNinja::BasicBlockEdge
Class Members
BNBranchType type
Ref< BasicBlock > target
bool backEdge The source or destination of the edge, depending on context.
bool fallThrough

◆ BinaryNinja::BasicBlock

class BinaryNinja::BasicBlock

Public Member Functions

 BasicBlock (BNBasicBlock *block)
 
Ref< FunctionGetFunction () const
 Basic block function.
 
Ref< ArchitectureGetArchitecture () const
 Basic block architecture.
 
uint64_t GetStart () const
 Starting address of the basic block.
 
uint64_t GetEnd () const
 Ending address of the basic block.
 
uint64_t GetLength () const
 Length of the basic block.
 
size_t GetIndex () const
 Basic block index in list of blocks for the function.
 
std::vector< BasicBlockEdgeGetOutgoingEdges () const
 List of basic block outgoing edges.
 
std::vector< BasicBlockEdgeGetIncomingEdges () const
 List of basic block incoming edges.
 
bool HasUndeterminedOutgoingEdges () const
 Whether basic block has undetermined outgoing edges.
 
bool CanExit () const
 Whether basic block can return or is tagged as 'No Return'.
 
void SetCanExit (bool value)
 Sets whether basic block can return or is tagged as 'No Return'.
 
std::set< Ref< BasicBlock > > GetDominators (bool post=false) const
 List of dominators for this basic block.
 
std::set< Ref< BasicBlock > > GetStrictDominators (bool post=false) const
 List of dominators for this basic block.
 
Ref< BasicBlockGetImmediateDominator (bool post=false) const
 Get the immediate dominator of this basic block.
 
std::set< Ref< BasicBlock > > GetDominatorTreeChildren (bool post=false) const
 List of child blocks in the dominator tree for this basic block.
 
std::set< Ref< BasicBlock > > GetDominanceFrontier (bool post=false) const
 Get the dominance frontier for this basic block.
 
void MarkRecentUse ()
 
std::vector< std::vector< InstructionTextToken > > GetAnnotations ()
 List of automatic annotations for the start of this block.
 
std::vector< DisassemblyTextLineGetDisassemblyText (DisassemblySettings *settings)
 property which returns a list of DisassemblyTextLine objects for the current basic block.
 
BNHighlightColor GetBasicBlockHighlight ()
 Get the current highlight color for the Basic Block.
 
void SetAutoBasicBlockHighlight (BNHighlightColor color)
 Set the analysis basic block highlight color.
 
void SetAutoBasicBlockHighlight (BNHighlightStandardColor color, uint8_t alpha=255)
 Set the analysis basic block highlight color.
 
void SetAutoBasicBlockHighlight (BNHighlightStandardColor color, BNHighlightStandardColor mixColor, uint8_t mix, uint8_t alpha=255)
 Set the analysis basic block highlight color.
 
void SetAutoBasicBlockHighlight (uint8_t r, uint8_t g, uint8_t b, uint8_t alpha=255)
 Set the analysis basic block highlight color.
 
void SetUserBasicBlockHighlight (BNHighlightColor color)
 Set the basic block highlight color.
 
void SetUserBasicBlockHighlight (BNHighlightStandardColor color, uint8_t alpha=255)
 Set the basic block highlight color.
 
void SetUserBasicBlockHighlight (BNHighlightStandardColor color, BNHighlightStandardColor mixColor, uint8_t mix, uint8_t alpha=255)
 Set the basic block highlight color.
 
void SetUserBasicBlockHighlight (uint8_t r, uint8_t g, uint8_t b, uint8_t alpha=255)
 Set the basic block highlight color.
 
bool IsILBlock () const
 Whether the basic block contains IL.
 
bool IsLowLevelILBlock () const
 Whether the basic block contains Medium Level IL.
 
bool IsMediumLevelILBlock () const
 Whether the basic block contains High Level IL.
 
Ref< LowLevelILFunctionGetLowLevelILFunction () const
 Get the Low Level IL Function for this basic block.
 
Ref< MediumLevelILFunctionGetMediumLevelILFunction () const
 Get the Medium Level IL Function for this basic block.
 
Ref< HighLevelILFunctionGetHighLevelILFunction () const
 Get the High Level IL Function for this basic block.
 
bool GetInstructionContainingAddress (uint64_t addr, uint64_t *start)
 
Ref< BasicBlockGetSourceBlock () const
 Gets the corresponding assembly-level basic block for this basic block (which is itself, if called on an assembly-level basic block).
 
- Public Member Functions inherited from BinaryNinja::CoreRefCountObject< BNBasicBlock, BNNewBasicBlockReference, BNFreeBasicBlock >
 CoreRefCountObject ()
 
virtual ~CoreRefCountObject ()
 
BNBasicBlockGetObject () const
 
void AddRef ()
 
void Release ()
 
void AddRefForRegistration ()
 
void ReleaseForRegistration ()
 
void AddRefForCallback ()
 
void ReleaseForCallback ()
 

Static Public Member Functions

static std::set< Ref< BasicBlock > > GetIteratedDominanceFrontier (const std::set< Ref< BasicBlock > > &blocks)
 
static bool IsBackEdge (BasicBlock *source, BasicBlock *target)
 
- Static Public Member Functions inherited from BinaryNinja::CoreRefCountObject< BNBasicBlock, BNNewBasicBlockReference, BNFreeBasicBlock >
static BNBasicBlockGetObject (CoreRefCountObject *obj)
 
static BNBasicBlockGetObject (const CoreRefCountObject *obj)
 

Additional Inherited Members

- Public Attributes inherited from BinaryNinja::CoreRefCountObject< BNBasicBlock, BNNewBasicBlockReference, BNFreeBasicBlock >
std::atomic< int > m_refs
 
bool m_registeredRef
 
BNBasicBlockm_object
 

Constructor & Destructor Documentation

◆ BasicBlock()

BasicBlock::BasicBlock ( BNBasicBlock * block)

Member Function Documentation

◆ GetFunction()

Ref< Function > BasicBlock::GetFunction ( ) const

Basic block function.

Returns
The Function for this basic block

◆ GetArchitecture()

Ref< Architecture > BasicBlock::GetArchitecture ( ) const

Basic block architecture.

Returns
The Architecture for this Basic Block

◆ GetStart()

uint64_t BasicBlock::GetStart ( ) const

Starting address of the basic block.

Returns
Start address of the basic block

◆ GetEnd()

uint64_t BasicBlock::GetEnd ( ) const

Ending address of the basic block.

Returns
Ending address of the basic block

◆ GetLength()

uint64_t BasicBlock::GetLength ( ) const

Length of the basic block.

Returns
Length of the basic block

◆ GetIndex()

size_t BasicBlock::GetIndex ( ) const

Basic block index in list of blocks for the function.

Returns
Basic block index in list of blocks for the function

◆ GetOutgoingEdges()

vector< BasicBlockEdge > BasicBlock::GetOutgoingEdges ( ) const

List of basic block outgoing edges.

Returns
List of basic block outgoing edges

◆ GetIncomingEdges()

vector< BasicBlockEdge > BasicBlock::GetIncomingEdges ( ) const

List of basic block incoming edges.

Returns
List of basic block incoming edges

◆ HasUndeterminedOutgoingEdges()

bool BasicBlock::HasUndeterminedOutgoingEdges ( ) const

Whether basic block has undetermined outgoing edges.

Returns
Whether basic block has undetermined outgoing edges

◆ CanExit()

bool BasicBlock::CanExit ( ) const

Whether basic block can return or is tagged as 'No Return'.

Returns
Whether basic block can return or is tagged as 'No Return'

◆ SetCanExit()

void BasicBlock::SetCanExit ( bool value)

Sets whether basic block can return or is tagged as 'No Return'.

Parameters
valueSets whether basic block can return or is tagged as 'No Return'

◆ GetDominators()

set< Ref< BasicBlock > > BasicBlock::GetDominators ( bool post = false) const

List of dominators for this basic block.

Parameters
postWhether to get post dominators (default: false)
Returns
Set of BasicBlock dominators

◆ GetStrictDominators()

set< Ref< BasicBlock > > BasicBlock::GetStrictDominators ( bool post = false) const

List of dominators for this basic block.

Parameters
postWhether to get post dominators (default: false)
Returns
Set of BasicBlock dominators

◆ GetImmediateDominator()

Ref< BasicBlock > BasicBlock::GetImmediateDominator ( bool post = false) const

Get the immediate dominator of this basic block.

Parameters
postWhether to get the immediate post dominator
Returns
Immediate dominator basic block

◆ GetDominatorTreeChildren()

set< Ref< BasicBlock > > BasicBlock::GetDominatorTreeChildren ( bool post = false) const

List of child blocks in the dominator tree for this basic block.

Parameters
postWhether to get the post dominator tree children
Returns
Set of Tree children

◆ GetDominanceFrontier()

set< Ref< BasicBlock > > BasicBlock::GetDominanceFrontier ( bool post = false) const

Get the dominance frontier for this basic block.

Parameters
postWhether to get the post dominance frontier
Returns
Post dominance frontier for this basic block

◆ GetIteratedDominanceFrontier()

set< Ref< BasicBlock > > BasicBlock::GetIteratedDominanceFrontier ( const std::set< Ref< BasicBlock > > & blocks)
static

◆ MarkRecentUse()

void BasicBlock::MarkRecentUse ( )

◆ GetAnnotations()

vector< vector< InstructionTextToken > > BasicBlock::GetAnnotations ( )

List of automatic annotations for the start of this block.

Returns
List of automatic annotations for the start of this block

◆ GetDisassemblyText()

vector< DisassemblyTextLine > BasicBlock::GetDisassemblyText ( DisassemblySettings * settings)

property which returns a list of DisassemblyTextLine objects for the current basic block.

Parameters
settingsDisassembly settings to use when fetching the text
Returns
Disassembly text

◆ GetBasicBlockHighlight()

BNHighlightColor BasicBlock::GetBasicBlockHighlight ( )

Get the current highlight color for the Basic Block.

Returns
The current highlight color for the Basic Block

◆ SetAutoBasicBlockHighlight() [1/4]

void BasicBlock::SetAutoBasicBlockHighlight ( BNHighlightColor color)

Set the analysis basic block highlight color.

Parameters
colorHighlight Color

◆ SetAutoBasicBlockHighlight() [2/4]

void BasicBlock::SetAutoBasicBlockHighlight ( BNHighlightStandardColor color,
uint8_t alpha = 255 )

Set the analysis basic block highlight color.

Parameters
colorHighlight Color
alphaTransparency for the color

◆ SetAutoBasicBlockHighlight() [3/4]

void BasicBlock::SetAutoBasicBlockHighlight ( BNHighlightStandardColor color,
BNHighlightStandardColor mixColor,
uint8_t mix,
uint8_t alpha = 255 )

Set the analysis basic block highlight color.

Parameters
colorHighlight Color
mixColorHighlight Color to mix with `color`
mixMix point
alphaTransparency of the colors

◆ SetAutoBasicBlockHighlight() [4/4]

void BasicBlock::SetAutoBasicBlockHighlight ( uint8_t r,
uint8_t g,
uint8_t b,
uint8_t alpha = 255 )

Set the analysis basic block highlight color.

Parameters
rRed value, 0-255
gGreen value, 0-255
bBlue value, 0-255
alphaTransparency of the color

◆ SetUserBasicBlockHighlight() [1/4]

void BasicBlock::SetUserBasicBlockHighlight ( BNHighlightColor color)

Set the basic block highlight color.

Parameters
colorHighlight color

◆ SetUserBasicBlockHighlight() [2/4]

void BasicBlock::SetUserBasicBlockHighlight ( BNHighlightStandardColor color,
uint8_t alpha = 255 )

Set the basic block highlight color.

Parameters
colorHighlight color
alphaTransparency of the color

◆ SetUserBasicBlockHighlight() [3/4]

void BasicBlock::SetUserBasicBlockHighlight ( BNHighlightStandardColor color,
BNHighlightStandardColor mixColor,
uint8_t mix,
uint8_t alpha = 255 )

Set the basic block highlight color.

Parameters
colorHighlight Color
mixColorHighlight Color to mix with `color`
mixMix point
alphaTransparency of the colors

◆ SetUserBasicBlockHighlight() [4/4]

void BasicBlock::SetUserBasicBlockHighlight ( uint8_t r,
uint8_t g,
uint8_t b,
uint8_t alpha = 255 )

Set the basic block highlight color.

Parameters
rRed value, 0-255
gGreen value, 0-255
bBlue value, 0-255
alphaTransparency of the color

◆ IsBackEdge()

bool BasicBlock::IsBackEdge ( BasicBlock * source,
BasicBlock * target )
static

◆ IsILBlock()

bool BasicBlock::IsILBlock ( ) const

Whether the basic block contains IL.

Returns
Whether the basic block contains IL

◆ IsLowLevelILBlock()

bool BasicBlock::IsLowLevelILBlock ( ) const

Whether the basic block contains Medium Level IL.

Returns
Whether the basic block contains Medium Level IL

◆ IsMediumLevelILBlock()

bool BasicBlock::IsMediumLevelILBlock ( ) const

Whether the basic block contains High Level IL.

Returns
Whether the basic block contains High Level IL

◆ GetLowLevelILFunction()

Ref< LowLevelILFunction > BasicBlock::GetLowLevelILFunction ( ) const

Get the Low Level IL Function for this basic block.

Returns
Get the Low Level IL Function for this basic block

◆ GetMediumLevelILFunction()

Ref< MediumLevelILFunction > BasicBlock::GetMediumLevelILFunction ( ) const

Get the Medium Level IL Function for this basic block.

Returns
Get the Medium Level IL Function for this basic block

◆ GetHighLevelILFunction()

Ref< HighLevelILFunction > BasicBlock::GetHighLevelILFunction ( ) const

Get the High Level IL Function for this basic block.

Returns
Get the High Level IL Function for this basic block

◆ GetInstructionContainingAddress()

bool BasicBlock::GetInstructionContainingAddress ( uint64_t addr,
uint64_t * start )

◆ GetSourceBlock()

Ref< BasicBlock > BasicBlock::GetSourceBlock ( ) const

Gets the corresponding assembly-level basic block for this basic block (which is itself, if called on an assembly-level basic block).

Returns
Basic Block