Binary Ninja API C++: Basic Blocks
Documentation for interacting with basic blocks. More...
Documentation for interacting with basic blocks.
◆ 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::PendingBasicBlockEdge
struct BinaryNinja::PendingBasicBlockEdge
◆ BinaryNinja::BasicBlock
class BinaryNinja::BasicBlock
Public Member Functions | |
| BasicBlock (BNBasicBlock *block) | |
| Ref< Function > | GetFunction () const |
| Basic block function. | |
| Ref< Architecture > | GetArchitecture () const |
| Basic block architecture. | |
| uint64_t | GetStart () const |
| Starting address of the basic block. | |
| void | SetEnd (uint64_t end) |
| Set the end of a 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< BasicBlockEdge > | GetOutgoingEdges () const |
| List of basic block outgoing edges. | |
| std::vector< BasicBlockEdge > | GetIncomingEdges () const |
| List of basic block incoming edges. | |
| bool | HasUndeterminedOutgoingEdges () const |
| Whether basic block has undetermined outgoing edges. | |
| bool | HasInvalidInstructions () const |
| Whether the basic block has invalid instructions. | |
| void | SetHasInvalidInstructions (bool value) |
| Set whether the basic block has invalid instructions. | |
| void | AddPendingOutgoingEdge (BNBranchType type, uint64_t addr, Ref< Architecture > arch=nullptr, bool fallThrough=false) |
| Add a pending outgoing edge to this basic block. | |
| std::vector< PendingBasicBlockEdge > | GetPendingOutgoingEdges () const |
| Get a list of pending outgoing edges for this basic block. | |
| void | ClearPendingOutgoingEdges () |
| Clear the pending outgoing edges for this basic block. | |
| void | SetUndeterminedOutgoingEdges (bool value) |
| Set whether basic block has undetermined outgoing edges. | |
| const uint8_t * | GetInstructionData (uint64_t addr, size_t *len) const |
| Get the instruction data for a specific address in this basic block. | |
| void | AddInstructionData (const void *data, size_t len) |
| Add instruction data to the basic block. | |
| void | SetFallThroughToFunction (bool value) |
| Set whether the basic blocks falls through to a function. | |
| bool | IsFallThroughToFunction () const |
| Determine whether the basic block falls through to a function. | |
| 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< BasicBlock > | GetImmediateDominator (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< DisassemblyTextLine > | GetDisassemblyText (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 Low Level IL. | |
| bool | IsMediumLevelILBlock () const |
| Whether the basic block contains Medium Level IL. | |
| bool | IsHighLevelILBlock () const |
| Whether the basic block contains High Level IL. | |
| Ref< LowLevelILFunction > | GetLowLevelILFunction () const |
| Get the Low Level IL Function for this basic block. | |
| Ref< MediumLevelILFunction > | GetMediumLevelILFunction () const |
| Get the Medium Level IL Function for this basic block. | |
| Ref< HighLevelILFunction > | GetHighLevelILFunction () const |
| Get the High Level IL Function for this basic block. | |
| bool | GetInstructionContainingAddress (uint64_t addr, uint64_t *start) |
| Ref< 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). | |
| Public Member Functions inherited from BinaryNinja::CoreRefCountObject< BNBasicBlock, BNNewBasicBlockReference, BNFreeBasicBlock > | |
| CoreRefCountObject () | |
| virtual | ~CoreRefCountObject () |
| BNBasicBlock * | GetObject () 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) |
◆ BasicBlock()
◆ GetFunction()
Basic block function.
- Returns
- The Function for this basic block
◆ GetArchitecture()
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
◆ SetEnd()
| void BasicBlock::SetEnd | ( | uint64_t | end | ) |
Set the end of a basic block.
- Parameters
-
end Ending 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
◆ HasInvalidInstructions()
| bool BasicBlock::HasInvalidInstructions | ( | ) | const |
Whether the basic block has invalid instructions.
- Returns
- true if the basic block has invalid instructions, false otherwise
◆ SetHasInvalidInstructions()
| void BasicBlock::SetHasInvalidInstructions | ( | bool | value | ) |
Set whether the basic block has invalid instructions.
- Parameters
-
value true if the basic block has invalid instructions, false otherwise
◆ AddPendingOutgoingEdge()
| void BasicBlock::AddPendingOutgoingEdge | ( | BNBranchType | type, |
| uint64_t | addr, | ||
| Ref< Architecture > | arch = nullptr, | ||
| bool | fallThrough = false ) |
Add a pending outgoing edge to this basic block.
- Parameters
-
type Type of the branch addr Address of the target basic block arch Optional architecture for the target basic block, default is nullptr fallThrough Whether this is a fall-through edge, default false
◆ GetPendingOutgoingEdges()
| vector< PendingBasicBlockEdge > BasicBlock::GetPendingOutgoingEdges | ( | ) | const |
Get a list of pending outgoing edges for this basic block.
- Returns
- List of pending outgoing edges
◆ ClearPendingOutgoingEdges()
| void BasicBlock::ClearPendingOutgoingEdges | ( | ) |
Clear the pending outgoing edges for this basic block.
◆ SetUndeterminedOutgoingEdges()
| void BasicBlock::SetUndeterminedOutgoingEdges | ( | bool | value | ) |
Set whether basic block has undetermined outgoing edges.
- Parameters
-
value Whether basic block has undetermined outgoing edges
◆ GetInstructionData()
| const uint8_t * BasicBlock::GetInstructionData | ( | uint64_t | addr, |
| size_t * | len ) const |
Get the instruction data for a specific address in this basic block.
- Parameters
-
addr Address of the instruction len Pointer to a size_t variable to store the length of the instruction data
- Returns
- Pointer to the instruction data
◆ AddInstructionData()
| void BasicBlock::AddInstructionData | ( | const void * | data, |
| size_t | len ) |
Add instruction data to the basic block.
- Parameters
-
data Pointer to the instruction data len Length of the instruction data
◆ SetFallThroughToFunction()
| void BasicBlock::SetFallThroughToFunction | ( | bool | value | ) |
Set whether the basic blocks falls through to a function.
- Parameters
-
value Whether the basic block falls through to a function
◆ IsFallThroughToFunction()
| bool BasicBlock::IsFallThroughToFunction | ( | ) | const |
Determine whether the basic block falls through to a function.
- Returns
- Whether basic block falls through to a function
◆ 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
-
value Sets 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
-
post Whether 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
-
post Whether 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
-
post Whether 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
-
post Whether 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
-
post Whether to get the post dominance frontier
- Returns
- Post dominance frontier for this basic block
◆ GetIteratedDominanceFrontier()
|
static |
◆ MarkRecentUse()
| void BasicBlock::MarkRecentUse | ( | ) |
◆ GetAnnotations()
List of automatic annotations for the start of this block.
- Returns
- List of automatic annotations for the start of this block
◆ GetDisassemblyText()
property which returns a list of DisassemblyTextLine objects for the current basic block.
- Parameters
-
settings Disassembly settings to use when fetching the text
- Returns
- Disassembly text
◆ GetBasicBlockHighlight()
Get the current highlight color for the Basic Block.
- Returns
- The current highlight color for the Basic Block
◆ SetAutoBasicBlockHighlight() [1/4]
Set the analysis basic block highlight color.
- Parameters
◆ SetAutoBasicBlockHighlight() [2/4]
Set the analysis basic block highlight color.
- Parameters
-
color Highlight Color alpha Transparency for the color
◆ SetAutoBasicBlockHighlight() [3/4]
Set the analysis basic block highlight color.
- Parameters
-
color Highlight Color mixColor Highlight Color to mix with `color` mix Mix point alpha Transparency 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
-
r Red value, 0-255 g Green value, 0-255 b Blue value, 0-255 alpha Transparency of the color
◆ SetUserBasicBlockHighlight() [1/4]
Set the basic block highlight color.
- Parameters
◆ SetUserBasicBlockHighlight() [2/4]
Set the basic block highlight color.
- Parameters
-
color Highlight color alpha Transparency of the color
◆ SetUserBasicBlockHighlight() [3/4]
Set the basic block highlight color.
- Parameters
-
color Highlight Color mixColor Highlight Color to mix with `color` mix Mix point alpha Transparency 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
-
r Red value, 0-255 g Green value, 0-255 b Blue value, 0-255 alpha Transparency of the color
◆ IsBackEdge()
|
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 Low Level IL.
- Returns
- Whether the basic block contains Low Level IL
◆ IsMediumLevelILBlock()
| bool BasicBlock::IsMediumLevelILBlock | ( | ) | const |
Whether the basic block contains Medium Level IL.
- Returns
- Whether the basic block contains Medium Level IL
◆ IsHighLevelILBlock()
| bool BasicBlock::IsHighLevelILBlock | ( | ) | const |
Whether the basic block contains High Level IL.
- Returns
- Whether the basic block contains High Level IL
◆ GetLowLevelILFunction()
Get the Low Level IL Function for this basic block.
- Returns
- Get the Low Level IL Function for this basic block
◆ GetMediumLevelILFunction()
Get the Medium Level IL Function for this basic block.
- Returns
- Get the Medium Level IL Function for this basic block
◆ GetHighLevelILFunction()
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