KUNAI Static Analyzer
Kunai is a library for doing static binary analysis of Dalvik.
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
KUNAI::DEX::BasicBlocks Class Reference

Class to keep all the Dalvik Basic Blocks from a method. More...

#include <analysis.hpp>

Public Types

enum  node_type_t { JOIN_NODE = 0 , BRANCH_NODE , REGULAR_NODE }
 Type of a node.
 
using connected_blocks_t = std::unordered_map< DVMBasicBlock *, std::set< DVMBasicBlock * > >
 blocks that are connected with others
 
using edges_t = std::vector< std::pair< DVMBasicBlock *, DVMBasicBlock * > >
 edges between nodes
 

Public Member Functions

 ~BasicBlocks ()
 Destructor of the BasicBlocks, we need to free the memory.
 
size_t get_number_of_basic_blocks () const
 Return the number of basic blocks in the graph.
 
const connected_blocks_tget_predecessors () const
 Get all predecessors from all the blocks.
 
connected_blocks_tget_predecessors ()
 Get all predecessors from all the blocks.
 
void add_predecessor (DVMBasicBlock *node, DVMBasicBlock *pred)
 Add a node to the list of predecessors of another.
 
const connected_blocks_tget_sucessors () const
 Get all sucessors from all the blocks.
 
connected_blocks_tget_sucessors ()
 Get all sucessors from all the blocks.
 
void add_sucessor (DVMBasicBlock *node, DVMBasicBlock *suc)
 Add a node to the list of sucessors of another.
 
void add_node (DVMBasicBlock *node)
 Add a node to the vector of nodes, we will transfer the ownership.
 
void add_edge (DVMBasicBlock *src, DVMBasicBlock *dst)
 Add an edge to the basic blocks.
 
const edges_tget_edges () const
 Get a constant reference to the edges of the graph.
 
edges_tget_edges ()
 Get a reference to the edges of the graph.
 
node_type_t get_node_type (DVMBasicBlock *node)
 Get the node type between JOIN_NODE, BRANCH_NODE or REGULAR_NODE.
 
void remove_node (DVMBasicBlock *node)
 Remove a node from the graph, this operation can be expensive on time.
 
DVMBasicBlockget_basic_block_by_idx (std::uint64_t idx)
 Get a basic block given an idx, the idx can be one address from the first to the last address of the block.
 
const std::vector< DVMBasicBlock * > & get_nodes () const
 Get a constant reference to the nodes of the graph.
 
std::vector< DVMBasicBlock * > & get_nodes ()
 Get a reference to the nodes of the graph.
 

Detailed Description

Class to keep all the Dalvik Basic Blocks from a method.

Member Function Documentation

◆ add_edge()

void KUNAI::DEX::BasicBlocks::add_edge ( DVMBasicBlock src,
DVMBasicBlock dst 
)
inline

Add an edge to the basic blocks.

Parameters
srcsource node
dstedge node

now add the sucessors and predecessors

◆ add_node()

void KUNAI::DEX::BasicBlocks::add_node ( DVMBasicBlock node)
inline

Add a node to the vector of nodes, we will transfer the ownership.

Parameters
nodenode to push into our vector

◆ add_predecessor()

void KUNAI::DEX::BasicBlocks::add_predecessor ( DVMBasicBlock node,
DVMBasicBlock pred 
)
inline

Add a node to the list of predecessors of another.

Parameters
nodenode to add predecessor
predpredecessor node

◆ add_sucessor()

void KUNAI::DEX::BasicBlocks::add_sucessor ( DVMBasicBlock node,
DVMBasicBlock suc 
)
inline

Add a node to the list of sucessors of another.

Parameters
nodenode to add sucessor
sucsucessor node

◆ get_basic_block_by_idx()

DVMBasicBlock * KUNAI::DEX::BasicBlocks::get_basic_block_by_idx ( std::uint64_t  idx)

Get a basic block given an idx, the idx can be one address from the first to the last address of the block.

Parameters
idxaddress of the block to retrieve
Returns
block that contains an instruction in that address

◆ get_edges() [1/2]

edges_t & KUNAI::DEX::BasicBlocks::get_edges ( )
inline

Get a reference to the edges of the graph.

Returns
reference to the edges

◆ get_edges() [2/2]

const edges_t & KUNAI::DEX::BasicBlocks::get_edges ( ) const
inline

Get a constant reference to the edges of the graph.

Returns
constant reference to the edges

◆ get_node_type()

node_type_t KUNAI::DEX::BasicBlocks::get_node_type ( DVMBasicBlock node)
inline

Get the node type between JOIN_NODE, BRANCH_NODE or REGULAR_NODE.

Parameters
nodenode to check
Returns
type of node

◆ get_nodes() [1/2]

std::vector< DVMBasicBlock * > & KUNAI::DEX::BasicBlocks::get_nodes ( )
inline

Get a reference to the nodes of the graph.

Returns
reference to basic blocks

◆ get_nodes() [2/2]

const std::vector< DVMBasicBlock * > & KUNAI::DEX::BasicBlocks::get_nodes ( ) const
inline

Get a constant reference to the nodes of the graph.

Returns
constant reference to basic blocks

◆ get_number_of_basic_blocks()

size_t KUNAI::DEX::BasicBlocks::get_number_of_basic_blocks ( ) const
inline

Return the number of basic blocks in the graph.

Returns
number of basic blocks

◆ get_predecessors() [1/2]

connected_blocks_t & KUNAI::DEX::BasicBlocks::get_predecessors ( )
inline

Get all predecessors from all the blocks.

Returns
reference to predecessors

◆ get_predecessors() [2/2]

const connected_blocks_t & KUNAI::DEX::BasicBlocks::get_predecessors ( ) const
inline

Get all predecessors from all the blocks.

Returns
constant reference to predecessors

◆ get_sucessors() [1/2]

connected_blocks_t & KUNAI::DEX::BasicBlocks::get_sucessors ( )
inline

Get all sucessors from all the blocks.

Returns
reference to sucessors

◆ get_sucessors() [2/2]

const connected_blocks_t & KUNAI::DEX::BasicBlocks::get_sucessors ( ) const
inline

Get all sucessors from all the blocks.

Returns
constant reference to sucessors

◆ remove_node()

void KUNAI::DEX::BasicBlocks::remove_node ( DVMBasicBlock node)

Remove a node from the graph, this operation can be expensive on time.

Parameters
nodenode to remove

The documentation for this class was generated from the following file: