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

Base class for the Instructions of the Dalvik Bytecode. More...

#include <dalvik_instructions.hpp>

Inheritance diagram for KUNAI::DEX::Instruction:
Inheritance graph
[legend]

Public Member Functions

 Instruction (std::vector< uint8_t > &bytecode, std::size_t index, dexinsttype_t instruction_type)
 Constructor of the Instruction, here is applied the parsing of the opcodes.
 
 Instruction (std::vector< uint8_t > &bytecode, std::size_t index, dexinsttype_t instruction_type, std::uint32_t length)
 
virtual ~Instruction ()=default
 Destructor of the instruction.
 
virtual TYPES::Kind get_kind () const
 Get the kind of instruction, use a DalvikOpcodes function.
 
virtual dexinsttype_t get_instruction_type () const
 Get the instruction type from the enum.
 
virtual std::uint32_t get_instruction_length () const
 Get the length of the instruction.
 
virtual std::uint32_t get_instruction_opcode () const
 Get the opcode of the instruction.
 
virtual void set_address (std::uint64_t address)
 Set the address of the instruction.
 
virtual std::uint64_t get_address () const
 Get the address of the instruction.
 
virtual std::string print_instruction ()
 Return a string with the representation of the instruction.
 
virtual void print_instruction (std::ostream &os)
 Print the instruction on a given stream.
 
virtual const std::span< std::uint8_t > & get_opcodes ()
 Return the op codes in raw from the instruction.
 
virtual bool is_terminator ()
 Check if the instruction is a terminator (branch, ret, multibranch)
 
virtual bool has_side_effects () const
 Instruction has or can have some side effect.
 
virtual bool may_throw () const
 May throw an exception.
 

Protected Attributes

std::span< std::uint8_t > op_codes
 Opcodes of the instruction.
 
std::uint32_t length
 Length of the instruction.
 
std::uint32_t op
 op code from the instruction
 
std::uint64_t address
 address of the instruction
 

Detailed Description

Base class for the Instructions of the Dalvik Bytecode.

Constructor & Destructor Documentation

◆ Instruction() [1/2]

KUNAI::DEX::Instruction::Instruction ( std::vector< uint8_t > &  bytecode,
std::size_t  index,
dexinsttype_t  instruction_type 
)
inline

Constructor of the Instruction, here is applied the parsing of the opcodes.

Parameters
bytecode
index
instruction_type

◆ Instruction() [2/2]

KUNAI::DEX::Instruction::Instruction ( std::vector< uint8_t > &  bytecode,
std::size_t  index,
dexinsttype_t  instruction_type,
std::uint32_t  length 
)
inline

op_codes we can read here for all the classes that derives from Instruction, we have that is the bytecode from the index to index+length

Member Function Documentation

◆ get_address()

virtual std::uint64_t KUNAI::DEX::Instruction::get_address ( ) const
inlinevirtual

Get the address of the instruction.

Returns
address of the instruction

◆ get_instruction_length()

virtual std::uint32_t KUNAI::DEX::Instruction::get_instruction_length ( ) const
inlinevirtual

Get the length of the instruction.

Returns
current length of the instruction

◆ get_instruction_opcode()

virtual std::uint32_t KUNAI::DEX::Instruction::get_instruction_opcode ( ) const
inlinevirtual

Get the opcode of the instruction.

Returns
opcode of the instruction

◆ get_instruction_type()

virtual dexinsttype_t KUNAI::DEX::Instruction::get_instruction_type ( ) const
inlinevirtual

Get the instruction type from the enum.

Returns
dex instruction type

◆ get_kind()

virtual TYPES::Kind KUNAI::DEX::Instruction::get_kind ( ) const
inlinevirtual

Get the kind of instruction, use a DalvikOpcodes function.

Returns
TYPES::Kind of the instruction

◆ get_opcodes()

virtual const std::span< std::uint8_t > & KUNAI::DEX::Instruction::get_opcodes ( )
inlinevirtual

Return the op codes in raw from the instruction.

Returns
constant reference with op codes in raw

◆ has_side_effects()

virtual bool KUNAI::DEX::Instruction::has_side_effects ( ) const
virtual

Instruction has or can have some side effect.

Returns
boolean indicating if a side effect exists

◆ is_terminator()

virtual bool KUNAI::DEX::Instruction::is_terminator ( )
inlinevirtual

Check if the instruction is a terminator (branch, ret, multibranch)

Returns
true if instruction is a terminator instruction

◆ may_throw()

virtual bool KUNAI::DEX::Instruction::may_throw ( ) const
virtual

May throw an exception.

Returns
boolean indicating if instruction can throw an exception

◆ print_instruction() [1/2]

virtual std::string KUNAI::DEX::Instruction::print_instruction ( )
inlinevirtual

◆ print_instruction() [2/2]

virtual void KUNAI::DEX::Instruction::print_instruction ( std::ostream &  os)
inlinevirtual

◆ set_address()

virtual void KUNAI::DEX::Instruction::set_address ( std::uint64_t  address)
inlinevirtual

Set the address of the instruction.

Parameters
addressnew address of the instruction

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