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

Class to manage an input file stream given for the analysis. More...

#include <kunaistream.hpp>

Public Member Functions

 KunaiStream (std::ifstream &input_file)
 Constructor from KunaiStream class.
 
 ~KunaiStream ()=default
 Destructor from KunaiStream, nothing done here for the moment.
 
std::size_t get_size () const
 Obtain the size of the file.
 
template<typename T >
void read_data (T &buffer, std::int32_t read_size)
 Read data given a buffer of a T data type and with a size specified by the user.
 
std::streampos tellg () const
 Obtain the current pointer of the file.
 
void seekg (std::streamoff off, std::ios_base::seekdir dir)
 Move the pointer from the input file.
 
std::string read_ansii_string (std::int64_t offset)
 Read a string as an array of char finished in a 0 byte.
 
std::string read_dex_string (std::int64_t offset)
 Read a DEX string, the dex string contains the next format: <size in uleb128><string with size>
 
std::uint64_t read_uleb128 ()
 Read a number in uleb128 format.
 
std::int64_t read_sleb128 ()
 Read a number in sleb128 format.
 

Public Attributes

const std::int32_t MAX_ANSII_STR_SIZE = 256
 maximum size for ansii strings
 

Detailed Description

Class to manage an input file stream given for the analysis.

Constructor & Destructor Documentation

◆ KunaiStream()

KUNAI::stream::KunaiStream::KunaiStream ( std::ifstream &  input_file)
inline

Constructor from KunaiStream class.

Parameters
input_filefile for the analysis this must be an std::ifstream

Member Function Documentation

◆ get_size()

std::size_t KUNAI::stream::KunaiStream::get_size ( ) const
inline

Obtain the size of the file.

Returns
std::size_t with the calculated file size

◆ read_ansii_string()

std::string KUNAI::stream::KunaiStream::read_ansii_string ( std::int64_t  offset)

Read a string as an array of char finished in a 0 byte.

Parameters
offsetthe offset in the file where to read the string
Returns
string read

◆ read_data()

template<typename T >
void KUNAI::stream::KunaiStream::read_data ( T &  buffer,
std::int32_t  read_size 
)
inline

Read data given a buffer of a T data type and with a size specified by the user.

Template Parameters
Ttype of the buffer where to read the data
Parameters
bufferBuffer where to read the data from the file.
read_sizesize to read

◆ read_dex_string()

std::string KUNAI::stream::KunaiStream::read_dex_string ( std::int64_t  offset)

Read a DEX string, the dex string contains the next format: <size in uleb128><string with size>

Parameters
offsetthe offset in the file where to read the string
Returns
string read

◆ read_sleb128()

std::int64_t KUNAI::stream::KunaiStream::read_sleb128 ( )

Read a number in sleb128 format.

Returns
int64_t with the number

◆ read_uleb128()

std::uint64_t KUNAI::stream::KunaiStream::read_uleb128 ( )

Read a number in uleb128 format.

Returns
uint64_t with the number

◆ seekg()

void KUNAI::stream::KunaiStream::seekg ( std::streamoff  off,
std::ios_base::seekdir  dir 
)
inline

Move the pointer from the input file.

Parameters
offoffset where to move
dirdirectorion to move

◆ tellg()

std::streampos KUNAI::stream::KunaiStream::tellg ( ) const
inline

Obtain the current pointer of the file.

Returns
position of file

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