8#ifndef KUNAI_UTILS_KUNAISTREAM_HPP
9#define KUNAI_UTILS_KUNAISTREAM_HPP
12#include "Kunai/Exceptions/stream_exception.hpp"
22 std::ifstream& input_file;
25 std::size_t file_size;
36 KunaiStream(std::ifstream& input_file) : input_file(input_file)
38 if (!input_file.is_open())
65 input_file.read(
reinterpret_cast<char*
>(&buffer), read_size);
75 return input_file.tellg();
81 void seekg(std::streamoff off, std::ios_base::seekdir dir)
85 input_file.seekg(off, dir);
Class to manage an input file stream given for the analysis.
Definition kunaistream.hpp:20
void seekg(std::streamoff off, std::ios_base::seekdir dir)
Move the pointer from the input file.
Definition kunaistream.hpp:81
std::size_t get_size() const
Obtain the size of the file.
Definition kunaistream.hpp:49
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>
KunaiStream(std::ifstream &input_file)
Constructor from KunaiStream class.
Definition kunaistream.hpp:36
std::streampos tellg() const
Obtain the current pointer of the file.
Definition kunaistream.hpp:73
std::string read_ansii_string(std::int64_t offset)
Read a string as an array of char finished in a 0 byte.
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.
Definition kunaistream.hpp:60
std::int64_t read_sleb128()
Read a number in sleb128 format.
std::uint64_t read_uleb128()
Read a number in uleb128 format.
~KunaiStream()=default
Destructor from KunaiStream, nothing done here for the moment.
const std::int32_t MAX_ANSII_STR_SIZE
maximum size for ansii strings
Definition kunaistream.hpp:32
Exception raised in stream error.
Definition stream_exception.hpp:15
utilities
Definition analysis.hpp:23