C++

Note

You can also find the Doxygen documentation here

Iterators

template<class T, typename U = typename decay_t<T>::value_type, class ITERATOR_T = typename decay_t<T>::iterator>
class ref_iterator

Iterator which returns reference on container’s values.

Public Types

using iterator_category = std::bidirectional_iterator_tag
using value_type = decay_t<U>
using difference_type = ptrdiff_t
using pointer = typename std::remove_pointer<U>::type*
using reference = typename std::remove_pointer<U>::type&
using container_type = T
using DT_VAL = U
using DT = decay_t<T>
using ref_t = typename ref_iterator::reference
using pointer_t = typename ref_iterator::pointer

Public Functions

inline ref_iterator(T container)
inline ref_iterator(const ref_iterator &copy)
inline ref_iterator &operator=(ref_iterator other)
inline void swap(ref_iterator &other) noexcept
inline ref_iterator &operator++()
inline ref_iterator operator++(int)
inline ref_iterator &operator--()
inline ref_iterator operator--(int)
inline ref_iterator &operator+=(const typename ref_iterator::difference_type &movement)
inline ref_iterator &operator-=(const typename ref_iterator::difference_type &movement)
inline std::enable_if<!std::is_const<ref_t>::value, remove_const_t<ref_t>>::type operator[](size_t n)
inline add_const_t<ref_t> operator[](size_t n) const
inline ref_iterator operator+(typename ref_iterator::difference_type n) const
inline ref_iterator operator-(typename ref_iterator::difference_type n) const
inline ref_iterator::difference_type operator-(const ref_iterator &rhs) const
inline bool operator<(const ref_iterator &rhs) const
inline bool operator>(const ref_iterator &rhs) const
inline bool operator>=(const ref_iterator &rhs) const
inline bool operator<=(const ref_iterator &rhs) const
inline ref_iterator begin() const
inline ref_iterator cbegin() const
inline ref_iterator end() const
inline ref_iterator cend() const
inline bool operator==(const ref_iterator &other) const
inline bool operator!=(const ref_iterator &other) const
inline size_t size() const
inline bool empty() const
inline std::enable_if<!std::is_const<ref_t>::value, remove_const_t<ref_t>>::type operator*()
template<typename V = DT_VAL>
inline std::enable_if<std::is_pointer<V>::value, add_const_t<ref_t>>::type operator*() const
template<typename V = DT_VAL>
inline std::enable_if<!std::is_pointer<V>::value, add_const_t<ref_t>>::type operator*() const
inline std::enable_if<!std::is_const<pointer_t>::value, pointer_t>::type operator->()
inline add_const_t<pointer_t> operator->() const
template<class T, typename U = typename decay_t<T>::value_type, class CT = typename std::add_const<T>::type>
using LIEF::const_ref_iterator = ref_iterator<CT, U, typename decay_t<CT>::const_iterator>

Iterator which return const ref on container’s values.

template<class T, typename U = typename decay_t<T>::value_type, class ITERATOR_T = typename decay_t<T>::iterator>
class filter_iterator

Iterator which return a ref on container’s values given predicates.

Public Types

using iterator_category = std::forward_iterator_tag
using value_type = decay_t<U>
using difference_type = ptrdiff_t
using pointer = typename std::remove_pointer<U>::type*
using reference = typename std::remove_pointer<U>::type&
using container_type = T
using DT_VAL = U
using DT = decay_t<T>
using ref_t = typename filter_iterator::reference
using pointer_t = typename filter_iterator::pointer
using filter_t = std::function<bool(const typename DT::value_type&)>

Public Functions

inline filter_iterator(T container, filter_t filter)
inline filter_iterator(T container, const std::vector<filter_t> &filters)
inline filter_iterator(T container)
inline filter_iterator(const filter_iterator &copy)
inline filter_iterator &operator=(filter_iterator other)
inline void swap(filter_iterator &other) noexcept
inline filter_iterator &def(filter_t func)
inline filter_iterator &operator++()
inline filter_iterator operator++(int)
inline filter_iterator begin() const
inline filter_iterator cbegin() const
inline filter_iterator end() const
inline filter_iterator cend() const
inline std::enable_if<!std::is_const<ref_t>::value, remove_const_t<ref_t>>::type operator*()
template<typename V = DT_VAL>
inline std::enable_if<std::is_pointer<V>::value, add_const_t<ref_t>>::type operator*() const
template<typename V = DT_VAL>
inline std::enable_if<!std::is_pointer<V>::value, add_const_t<ref_t>>::type operator*() const
inline std::enable_if<!std::is_const<ref_t>::value, remove_const_t<ref_t>>::type operator[](size_t n)
inline add_const_t<ref_t> operator[](size_t n) const
inline std::enable_if<!std::is_const<pointer_t>::value, pointer_t>::type operator->()
inline add_const_t<pointer_t> operator->() const
inline size_t size() const
inline bool empty() const
inline bool operator==(const filter_iterator &other) const
inline bool operator!=(const filter_iterator &other) const
template<class T, typename U = typename decay_t<T>::value_type, class CT = typename std::add_const<T>::type>
using LIEF::const_filter_iterator = filter_iterator<CT, U, typename decay_t<CT>::const_iterator>

Iterator which return a const ref on container’s values given predicates.

template<typename IteratorT>
class iterator_range

Public Types

using IteratorTy = IteratorT

Public Functions

inline iterator_range(IteratorT &&it_begin, IteratorT &&it_end)
inline IteratorT begin() const
inline IteratorT end() const
inline bool empty() const
inline IteratorT::value_type at(typename IteratorT::difference_type pos) const
inline IteratorT::value_type operator[](typename IteratorT::difference_type pos) const
inline std::ptrdiff_t size() const

BinaryStream

class BinaryStream

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

Subclassed by LIEF::FileStream, LIEF::MemoryStream, LIEF::SpanStream, LIEF::VectorStream

Public Types

enum class STREAM_TYPE

Values:

enumerator UNKNOWN = 0
enumerator VECTOR
enumerator MEMORY
enumerator SPAN
enumerator FILE
enumerator ELF_DATA_HANDLER

Public Functions

inline BinaryStream(STREAM_TYPE type)
virtual ~BinaryStream() = default
virtual uint64_t size() const = 0
inline 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
inline virtual ok_error_t peek_data(std::vector<uint8_t> &container, uint64_t offset, uint64_t size, uint64_t virtual_address = 0)
inline virtual ok_error_t read_data(std::vector<uint8_t> &container, uint64_t size)
template<class T>
inline ok_error_t read_objects(std::vector<T> &container, uint64_t count)
template<class T>
inline ok_error_t peek_objects(std::vector<T> &container, uint64_t count)
template<class T>
inline ok_error_t peek_objects_at(uint64_t offset, std::vector<T> &container, uint64_t count)
inline void setpos(size_t pos) const
inline void increment_pos(size_t value) const
inline void decrement_pos(size_t value) const
inline size_t pos() const
inline 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
inline bool can_read(int64_t offset, int64_t size) const
size_t align(size_t align_on) const
inline void set_endian_swap(bool swap)
inline bool should_swap() const
inline virtual const uint8_t *p() const
inline virtual uint8_t *start()
inline virtual uint8_t *p()
inline virtual uint8_t *end()
inline virtual const uint8_t *start() const
inline virtual const uint8_t *end() const

Public Static Functions

template<class T>
static inline bool is_all_zero(const T &buffer)

Friends

friend class ASN1Reader
class FileStream : public LIEF::BinaryStream

Stream interface over a std::ifstream

Public Functions

inline FileStream(std::ifstream fs, uint64_t size)
FileStream() = delete
FileStream(const FileStream&) = delete
FileStream &operator=(const FileStream&) = delete
FileStream(FileStream &&other) noexcept = default
FileStream &operator=(FileStream &&other) noexcept = default
inline virtual uint64_t size() const override
std::vector<uint8_t> content() const
~FileStream() override = default
inline virtual ok_error_t peek_in(void *dst, uint64_t offset, uint64_t size, uint64_t = 0) const override
inline virtual result<const void*> read_at(uint64_t, uint64_t, uint64_t) const override

Public Static Functions

static result<FileStream> from_file(const std::string &file)
static inline bool classof(const BinaryStream &stream)
class SpanStream : public LIEF::BinaryStream

Public Functions

inline SpanStream(span<const uint8_t> data)
inline SpanStream(span<uint8_t> data)
inline SpanStream(const uint8_t *p, size_t size)
inline SpanStream(const std::vector<uint8_t> &data)
inline std::unique_ptr<SpanStream> clone() const
SpanStream() = delete
SpanStream(const SpanStream &other) = default
SpanStream &operator=(const SpanStream &other) = default
SpanStream(SpanStream &&other) noexcept = default
SpanStream &operator=(SpanStream &&other) noexcept = default
inline virtual uint64_t size() const override
inline virtual const uint8_t *p() const override
inline virtual const uint8_t *start() const override
inline virtual const uint8_t *end() const override
inline std::vector<uint8_t> content() const
inline result<SpanStream> slice(size_t offset, size_t size) const
inline result<SpanStream> slice(size_t offset) const
std::unique_ptr<VectorStream> to_vector() const
~SpanStream() override = default
inline virtual uint8_t *p()
inline virtual uint8_t *end()
inline virtual uint8_t *start()

Public Static Functions

static inline result<SpanStream> from_vector(const std::vector<uint8_t> &data)
template<size_t N>
static inline result<SpanStream> from_array(const std::array<uint8_t, N> &data)
static inline bool classof(const BinaryStream &stream)
class VectorStream : public LIEF::BinaryStream

Public Functions

inline VectorStream(std::vector<uint8_t> data)
VectorStream() = delete
VectorStream(const VectorStream&) = delete
VectorStream &operator=(const VectorStream&) = delete
VectorStream(VectorStream &&other) noexcept = default
VectorStream &operator=(VectorStream &&other) noexcept = default
inline virtual uint64_t size() const override
inline const std::vector<uint8_t> &content() const
inline std::vector<uint8_t> &&move_content()
inline virtual const uint8_t *p() const override
inline virtual const uint8_t *start() const override
inline virtual const uint8_t *end() const override
std::unique_ptr<SpanStream> slice(uint32_t offset, size_t size) const
std::unique_ptr<SpanStream> slice(uint32_t offset) const
inline virtual uint8_t *p()
inline virtual uint8_t *end()
inline virtual uint8_t *start()

Public Static Functions

static result<VectorStream> from_file(const std::string &file)
static inline bool classof(const BinaryStream &stream)
class MemoryStream : public LIEF::BinaryStream

Public Functions

MemoryStream() = delete
MemoryStream(uintptr_t base_address)
inline MemoryStream(uintptr_t base_address, uint64_t size)
MemoryStream(const MemoryStream&) = delete
MemoryStream &operator=(const MemoryStream&) = delete
MemoryStream(MemoryStream&&) noexcept = default
MemoryStream &operator=(MemoryStream&&) noexcept = default
inline uintptr_t base_address() const
inline virtual const uint8_t *p() const override
inline virtual const uint8_t *start() const override
inline virtual const uint8_t *end() const override
inline void binary(Binary &bin)
inline Binary *binary()
inline virtual uint64_t size() const override
~MemoryStream() override = default
inline virtual uint8_t *p()
inline virtual uint8_t *end()
inline virtual uint8_t *start()

Public Static Functions

static inline bool classof(const BinaryStream &stream)