LIEF: Library to Instrument Executable Formats Version 0.15.1
Loading...
Searching...
No Matches
LIEF::BinaryStream Class Referenceabstract

Class that is used to a read stream of data from different sources. More...

#include <BinaryStream.hpp>

Inheritance diagram for LIEF::BinaryStream:

Public Types

enum class  STREAM_TYPE {
  UNKNOWN = 0 , VECTOR , MEMORY , SPAN ,
  FILE , ELF_DATA_HANDLER
}
 

Public Member Functions

 BinaryStream (STREAM_TYPE type)
 
virtual ~BinaryStream ()=default
 
virtual uint64_t size () const =0
 
STREAM_TYPE type () const
 
result< uint64_t > read_uleb128 () const
 
result< uint64_t > read_sleb128 () const
 
result< int64_t > read_dwarf_encoded (uint8_t encoding) const
 
result< std::string > read_string (size_t maxsize=~static_cast< size_t >(0)) const
 
result< std::string > peek_string (size_t maxsize=~static_cast< size_t >(0)) const
 
result< std::string > peek_string_at (size_t offset, size_t maxsize=~static_cast< size_t >(0)) const
 
result< std::u16string > read_u16string () const
 
result< std::u16string > peek_u16string () const
 
result< std::string > read_mutf8 (size_t maxsize=~static_cast< size_t >(0)) const
 
result< std::u16string > read_u16string (size_t length) const
 
result< std::u16string > peek_u16string (size_t length) const
 
result< std::u16string > peek_u16string_at (size_t offset, size_t length) const
 
virtual ok_error_t peek_data (std::vector< uint8_t > &container, uint64_t offset, uint64_t size)
 
virtual ok_error_t read_data (std::vector< uint8_t > &container, uint64_t size)
 
void setpos (size_t pos) const
 
void increment_pos (size_t value) const
 
void decrement_pos (size_t value) const
 
size_t pos () const
 
 operator bool () const
 
template<class T >
const T * read_array (size_t size) const
 
template<class T >
result< T > peek () const
 
template<class T >
result< T > peek (size_t offset) const
 
template<class T >
const T * peek_array (size_t size) const
 
template<class T >
const T * peek_array (size_t offset, size_t size) const
 
template<class T >
result< T > read () const
 
template<typename T >
bool can_read () const
 
template<typename T >
bool can_read (size_t offset) const
 
size_t align (size_t align_on) const
 
template<class T >
std::enable_if< std::is_integral< T >::value, result< T > >::type peek_conv () const
 
template<class T >
std::enable_if<!std::is_integral< T >::value, result< T > >::type peek_conv () const
 
template<class T >
result< T > peek_conv (size_t offset) const
 
template<class T >
result< T > read_conv () const
 
template<typename T >
std::unique_ptr< T[]> read_conv_array (size_t size) const
 
template<typename T >
std::unique_ptr< T[]> peek_conv_array (size_t offset, size_t size) const
 
void set_endian_swap (bool swap)
 
bool should_swap () const
 
virtual const uint8_t * p () const
 
virtual uint8_t * start ()
 
virtual uint8_t * p ()
 
virtual uint8_t * end ()
 
virtual const uint8_t * start () const
 
virtual const uint8_t * end () const
 

Static Public Member Functions

template<typename T >
static T swap_endian (T u)
 
template<class T >
static bool is_all_zero (const T &buffer)
 

Detailed Description

Class that is used to a read stream of data from different sources.

Member Enumeration Documentation

◆ STREAM_TYPE

Enumerator
UNKNOWN 
VECTOR 
MEMORY 
SPAN 
FILE 
ELF_DATA_HANDLER 

Constructor & Destructor Documentation

◆ BinaryStream()

LIEF::BinaryStream::BinaryStream ( STREAM_TYPE type)
inline

◆ ~BinaryStream()

virtual LIEF::BinaryStream::~BinaryStream ( )
virtualdefault

Member Function Documentation

◆ align()

size_t LIEF::BinaryStream::align ( size_t align_on) const

◆ can_read() [1/2]

template<typename T >
bool LIEF::BinaryStream::can_read ( ) const

References size().

◆ can_read() [2/2]

template<typename T >
bool LIEF::BinaryStream::can_read ( size_t offset) const

References size().

◆ decrement_pos()

void LIEF::BinaryStream::decrement_pos ( size_t value) const
inline

◆ end() [1/2]

virtual uint8_t * LIEF::BinaryStream::end ( )
inlinevirtual

Reimplemented in LIEF::MemoryStream, LIEF::SpanStream, and LIEF::VectorStream.

References end().

Referenced by end().

◆ end() [2/2]

virtual const uint8_t * LIEF::BinaryStream::end ( ) const
inlinevirtual

◆ increment_pos()

void LIEF::BinaryStream::increment_pos ( size_t value) const
inline

Referenced by read(), read_array(), read_conv(), and read_data().

◆ is_all_zero()

template<class T >
static bool LIEF::BinaryStream::is_all_zero ( const T & buffer)
inlinestatic

◆ operator bool()

LIEF::BinaryStream::operator bool ( ) const
inline

References size().

◆ p() [1/2]

virtual uint8_t * LIEF::BinaryStream::p ( )
inlinevirtual

Reimplemented in LIEF::MemoryStream, LIEF::SpanStream, and LIEF::VectorStream.

References p().

◆ p() [2/2]

virtual const uint8_t * LIEF::BinaryStream::p ( ) const
inlinevirtual

Reimplemented in LIEF::MemoryStream, LIEF::SpanStream, and LIEF::VectorStream.

Referenced by p().

◆ peek() [1/2]

template<class T >
result< T > LIEF::BinaryStream::peek ( ) const

References make_error_code(), pos(), read_error, and setpos().

Referenced by peek(), and read().

◆ peek() [2/2]

template<class T >
result< T > LIEF::BinaryStream::peek ( size_t offset) const

References peek(), pos(), and setpos().

◆ peek_array() [1/2]

template<class T >
const T * LIEF::BinaryStream::peek_array ( size_t offset,
size_t size ) const

References peek_array(), pos(), and setpos().

◆ peek_array() [2/2]

template<class T >
const T * LIEF::BinaryStream::peek_array ( size_t size) const

References pos(), and size().

Referenced by peek_array(), peek_conv_array(), and read_array().

◆ peek_conv() [1/3]

template<class T >
std::enable_if<!std::is_integral< T >::value, result< T > >::type LIEF::BinaryStream::peek_conv ( ) const

References make_error_code(), pos(), read_error, and swap_endian().

Referenced by peek_conv(), and read_conv().

◆ peek_conv() [2/3]

template<class T >
std::enable_if<!std::is_integral< T >::value, result< T > >::type LIEF::BinaryStream::peek_conv ( ) const

◆ peek_conv() [3/3]

template<class T >
result< T > LIEF::BinaryStream::peek_conv ( size_t offset) const

References peek_conv(), pos(), and setpos().

◆ peek_conv_array()

template<typename T >
std::unique_ptr< T[]> LIEF::BinaryStream::peek_conv_array ( size_t offset,
size_t size ) const

◆ peek_data()

virtual ok_error_t LIEF::BinaryStream::peek_data ( std::vector< uint8_t > & container,
uint64_t offset,
uint64_t size )
inlinevirtual

References make_error_code(), LIEF::ok(), read_error, and size().

Referenced by read_data().

◆ peek_string()

result< std::string > LIEF::BinaryStream::peek_string ( size_t maxsize = ~static_cast< size_t >(0)) const

◆ peek_string_at()

result< std::string > LIEF::BinaryStream::peek_string_at ( size_t offset,
size_t maxsize = ~static_cast< size_t >(0) ) const

◆ peek_u16string() [1/2]

result< std::u16string > LIEF::BinaryStream::peek_u16string ( ) const

◆ peek_u16string() [2/2]

result< std::u16string > LIEF::BinaryStream::peek_u16string ( size_t length) const

◆ peek_u16string_at()

result< std::u16string > LIEF::BinaryStream::peek_u16string_at ( size_t offset,
size_t length ) const

◆ pos()

◆ read()

template<class T >
result< T > LIEF::BinaryStream::read ( ) const

References increment_pos(), and peek().

◆ read_array()

template<class T >
const T * LIEF::BinaryStream::read_array ( size_t size) const

References increment_pos(), peek_array(), and size().

Referenced by read_conv_array().

◆ read_conv()

template<class T >
result< T > LIEF::BinaryStream::read_conv ( ) const

References increment_pos(), and peek_conv().

◆ read_conv_array()

template<typename T >
std::unique_ptr< T[]> LIEF::BinaryStream::read_conv_array ( size_t size) const

◆ read_data()

virtual ok_error_t LIEF::BinaryStream::read_data ( std::vector< uint8_t > & container,
uint64_t size )
inlinevirtual

◆ read_dwarf_encoded()

result< int64_t > LIEF::BinaryStream::read_dwarf_encoded ( uint8_t encoding) const

◆ read_mutf8()

result< std::string > LIEF::BinaryStream::read_mutf8 ( size_t maxsize = ~static_cast< size_t >(0)) const

◆ read_sleb128()

result< uint64_t > LIEF::BinaryStream::read_sleb128 ( ) const

◆ read_string()

result< std::string > LIEF::BinaryStream::read_string ( size_t maxsize = ~static_cast< size_t >(0)) const

◆ read_u16string() [1/2]

result< std::u16string > LIEF::BinaryStream::read_u16string ( ) const

◆ read_u16string() [2/2]

result< std::u16string > LIEF::BinaryStream::read_u16string ( size_t length) const

◆ read_uleb128()

result< uint64_t > LIEF::BinaryStream::read_uleb128 ( ) const

◆ set_endian_swap()

void LIEF::BinaryStream::set_endian_swap ( bool swap)
inline

◆ setpos()

void LIEF::BinaryStream::setpos ( size_t pos) const
inline

◆ should_swap()

bool LIEF::BinaryStream::should_swap ( ) const
inline

◆ size()

virtual uint64_t LIEF::BinaryStream::size ( ) const
pure virtual

◆ start() [1/2]

virtual uint8_t * LIEF::BinaryStream::start ( )
inlinevirtual

Reimplemented in LIEF::MemoryStream, LIEF::SpanStream, and LIEF::VectorStream.

References start().

Referenced by start().

◆ start() [2/2]

virtual const uint8_t * LIEF::BinaryStream::start ( ) const
inlinevirtual

◆ swap_endian()

template<typename T >
static T LIEF::BinaryStream::swap_endian ( T u)
static

Referenced by peek_conv().

◆ type()


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