LIEF: Library to Instrument Executable Formats Version 0.15.1
Loading...
Searching...
No Matches
LIEF Namespace Reference

LIEF namespace. More...

Namespaces

namespace  Android
 
namespace  ART
 Namespace related to the LIEF's ART module.
 
namespace  Convert
 
namespace  details
 
namespace  DEX
 
namespace  dwarf
 Namespace for the DWARF debug format.
 
namespace  ELF
 Namespace related to the LIEF's ELF module.
 
namespace  LEB128
 
namespace  logging
 
namespace  MachO
 Namespace related to the LIEF's Mach-O module.
 
namespace  OAT
 
namespace  objc
 
namespace  pdb
 
namespace  PE
 Namespace related to the LIEF's PE module.
 
namespace  VDEX
 

Classes

class  AbstractHash
 
class  ASN1Reader
 
class  Binary
 Abstract binary that exposes an uniform API for the different executable file formats. More...
 
class  BinaryStream
 Class that is used to a read stream of data from different sources. More...
 
struct  debug_location_t
 This structure holds a debug location (source filename & line) More...
 
class  DebugInfo
 
class  FileStream
 Stream interface over a std::ifstream. More...
 
class  filter_iterator
 Iterator which return a ref on container's values given predicates. More...
 
class  Function
 Class that represents a function in the binary. More...
 
class  Hash
 
class  Header
 
class  iterator_range
 
class  MemoryStream
 
class  Object
 
struct  ok_t
 Opaque structure used by ok_error_t. More...
 
class  Parser
 Main interface to parse an executable regardless of its format. More...
 
struct  range_t
 
class  ref_iterator
 Iterator which returns reference on container's values. More...
 
class  Relocation
 Class which represents an abstracted Relocation. More...
 
class  ScopedStream
 
class  Section
 Class which represents an abstracted section. More...
 
class  SpanStream
 
class  Symbol
 This class represents a symbol in an executable format. More...
 
class  vector_iostream
 
class  VectorStream
 
class  Visitor
 

Typedefs

template<typename T >
using result = tl::expected<T, lief_errors>
 Wrapper that contains an Object (T) or an error.
 
using ok_error_t = result<ok_t>
 Opaque structure that is used by LIEF to avoid writing result<void> f(...). Instead, it makes the output explicit such as:
 
template<class T >
using decay_t = typename std::decay<T>::type
 
template<class T >
using add_const_t = typename std::add_const<T>::type
 
template<class T >
using remove_const_t = typename std::remove_const<T>::type
 
template<class T >
using add_lvalue_reference_t = typename std::add_lvalue_reference<T>::type
 
template<class T , typename U = typename decay_t<T>::value_type, class CT = typename std::add_const<T>::type>
using 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 CT = typename std::add_const<T>::type>
using 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 ElementType , std::size_t Extent = tcb::dynamic_extent>
using span = tcb::span<ElementType, Extent>
 

Enumerations

enum  OBJECT_TYPES { TYPE_NONE = 0 , TYPE_EXECUTABLE = 1 , TYPE_LIBRARY = 2 , TYPE_OBJECT = 3 }
 
enum  ARCHITECTURES {
  ARCH_NONE = 0 , ARCH_ARM = 1 , ARCH_ARM64 = 2 , ARCH_MIPS = 3 ,
  ARCH_X86 = 4 , ARCH_PPC = 5 , ARCH_SPARC = 6 , ARCH_SYSZ = 7 ,
  ARCH_XCORE = 8 , ARCH_INTEL = 9 , ARCH_RISCV = 10 , ARCH_LOONGARCH = 11
}
 
enum  MODES {
  MODE_NONE = 0 , MODE_16 = 1 , MODE_32 = 2 , MODE_64 = 3 ,
  MODE_ARM = 4 , MODE_THUMB = 5 , MODE_MCLASS = 6 , MODE_MICRO = 7 ,
  MODE_MIPS3 = 8 , MODE_MIPS32R6 = 9 , MODE_MIPSGP64 = 10 , MODE_V7 = 11 ,
  MODE_V8 = 12 , MODE_V9 = 13 , MODE_MIPS32 = 14 , MODE_MIPS64 = 15
}
 
enum  ENDIANNESS { ENDIAN_NONE = 0 , ENDIAN_BIG = 1 , ENDIAN_LITTLE = 2 }
 
enum class  PLATFORMS {
  UNKNOWN = 0 , LINUX , ANDROID_PLAT , WINDOWS ,
  IOS , OSX
}
 

Functions

const char * to_string (Binary::VA_TYPES e)
 
const char * to_string (Binary::FORMATS e)
 
const char * to_string (ARCHITECTURES e)
 
const char * to_string (OBJECT_TYPES e)
 
const char * to_string (MODES e)
 
const char * to_string (ENDIANNESS e)
 
const char * to_string (Function::FLAGS e)
 
std::string to_json_from_abstract (const Object &v)
 
template<class T >
lief_errors get_error (result< T > &err)
 Get the error code associated with the result.
 
template<class T >
lief_errors as_lief_err (result< T > &err)
 Return the lief_errors when the provided result<T> is an error.
 
ok_t ok ()
 Return success for function with return type ok_error_t.
 
bool is_ok (const ok_error_t &val)
 
bool is_err (const ok_error_t &val)
 
Hash::value_type hash (const Object &v)
 
Hash::value_type hash (const std::vector< uint8_t > &raw)
 
Hash::value_type hash (span< const uint8_t > raw)
 
template<class T >
iterator_range< T > make_range (T x, T y)
 
std::string to_json (const Object &v)
 
constexpr PLATFORMS current_platform ()
 
uint64_t align (uint64_t value, uint64_t align_on)
 
template<typename T >
constexpr T round (T x)
 
template<>
uint64_t round< uint64_t > (uint64_t x)
 
constexpr size_t operator""_KB (unsigned long long kbs)
 
constexpr size_t operator""_MB (unsigned long long mbs)
 
constexpr size_t operator""_GB (unsigned long long gbs)
 
std::string u16tou8 (const std::u16string &string, bool remove_null_char=false)
 Convert a UTF-16 string to a UTF-8 one.
 
result< std::u16string > u8tou16 (const std::string &string)
 Convert a UTF-8 string to a UTF-16 one.
 
std::string hex_str (uint8_t c)
 
std::string hex_dump (const std::vector< uint8_t > &data, const std::string &sep=":")
 
std::string hex_dump (span< const uint8_t > data, const std::string &sep=":")
 
bool is_hex_number (const std::string &nb)
 Check if the given number is a hex-like string.
 
bool is_extended ()
 Whether this version of LIEF includes extended features.
 

Detailed Description

LIEF namespace.

Typedef Documentation

◆ add_const_t

template<class T >
using LIEF::add_const_t = typename std::add_const<T>::type

◆ add_lvalue_reference_t

template<class T >
using LIEF::add_lvalue_reference_t = typename std::add_lvalue_reference<T>::type

◆ const_filter_iterator

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.

◆ const_ref_iterator

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.

◆ decay_t

template<class T >
using LIEF::decay_t = typename std::decay<T>::type

◆ ok_error_t

Opaque structure that is used by LIEF to avoid writing result<void> f(...). Instead, it makes the output explicit such as:

ok_error_t process() {
if (fail) {
return make_error_code(...);
}
return ok();
}
tl::unexpected< lief_errors > make_error_code(lief_errors e)
Create an standard error code from lief_errors.
Definition errors.hpp:51
result< ok_t > ok_error_t
Opaque structure that is used by LIEF to avoid writing result<void> f(...). Instead,...
Definition errors.hpp:108
ok_t ok()
Return success for function with return type ok_error_t.
Definition errors.hpp:92

◆ remove_const_t

template<class T >
using LIEF::remove_const_t = typename std::remove_const<T>::type

◆ result

template<typename T >
using LIEF::result = tl::expected<T, lief_errors>

Wrapper that contains an Object (T) or an error.

The tl/expected implementation exposes the method value() to access the underlying object (if no error)

Typical usage is:

result<int> intval = my_function();
if (intval) {
int val = intval.value();
} else { // There is an error
std::cout << get_error(intval).message() << "\n";
}
lief_errors get_error(result< T > &err)
Get the error code associated with the result.
Definition errors.hpp:78
tl::expected< T, lief_errors > result
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:74

See https://tl.tartanllama.xyz/en/latest/api/expected.html for more details

◆ span

template<typename ElementType , std::size_t Extent = tcb::dynamic_extent>
using LIEF::span = tcb::span<ElementType, Extent>

Enumeration Type Documentation

◆ ARCHITECTURES

Enumerator
ARCH_NONE 
ARCH_ARM 
ARCH_ARM64 
ARCH_MIPS 
ARCH_X86 
ARCH_PPC 
ARCH_SPARC 
ARCH_SYSZ 
ARCH_XCORE 
ARCH_INTEL 
ARCH_RISCV 
ARCH_LOONGARCH 

◆ ENDIANNESS

Enumerator
ENDIAN_NONE 
ENDIAN_BIG 
ENDIAN_LITTLE 

◆ MODES

Enumerator
MODE_NONE 
MODE_16 
MODE_32 
MODE_64 
MODE_ARM 
MODE_THUMB 
MODE_MCLASS 
MODE_MICRO 
MODE_MIPS3 
MODE_MIPS32R6 
MODE_MIPSGP64 
MODE_V7 
MODE_V8 
MODE_V9 
MODE_MIPS32 
MODE_MIPS64 

◆ OBJECT_TYPES

Enumerator
TYPE_NONE 
TYPE_EXECUTABLE 
TYPE_LIBRARY 
TYPE_OBJECT 

◆ PLATFORMS

enum class LIEF::PLATFORMS
strong
Enumerator
UNKNOWN 
LINUX 
ANDROID_PLAT 
WINDOWS 
IOS 
OSX 

Function Documentation

◆ align()

uint64_t LIEF::align ( uint64_t value,
uint64_t align_on )
inline

◆ as_lief_err()

template<class T >
lief_errors LIEF::as_lief_err ( result< T > & err)

Return the lief_errors when the provided result<T> is an error.

◆ current_platform()

PLATFORMS LIEF::current_platform ( )
constexpr

References ANDROID_PLAT, IOS, LINUX, OSX, UNKNOWN, and WINDOWS.

◆ get_error()

template<class T >
lief_errors LIEF::get_error ( result< T > & err)

Get the error code associated with the result.

◆ hash() [1/3]

◆ hash() [2/3]

Hash::value_type LIEF::hash ( const std::vector< uint8_t > & raw)

◆ hash() [3/3]

Hash::value_type LIEF::hash ( span< const uint8_t > raw)

◆ hex_dump() [1/2]

std::string LIEF::hex_dump ( const std::vector< uint8_t > & data,
const std::string & sep = ":" )

◆ hex_dump() [2/2]

std::string LIEF::hex_dump ( span< const uint8_t > data,
const std::string & sep = ":" )

◆ hex_str()

std::string LIEF::hex_str ( uint8_t c)

◆ is_err()

bool LIEF::is_err ( const ok_error_t & val)
inline

References is_ok().

◆ is_extended()

bool LIEF::is_extended ( )

Whether this version of LIEF includes extended features.

◆ is_hex_number()

bool LIEF::is_hex_number ( const std::string & nb)

Check if the given number is a hex-like string.

◆ is_ok()

bool LIEF::is_ok ( const ok_error_t & val)
inline

Referenced by is_err().

◆ make_range()

template<class T >
iterator_range< T > LIEF::make_range ( T x,
T y )

◆ ok()

ok_t LIEF::ok ( )
inline

Return success for function with return type ok_error_t.

Referenced by LIEF::BinaryStream::peek_data(), and LIEF::BinaryStream::read_data().

◆ operator""_GB()

size_t LIEF::operator""_GB ( unsigned long long gbs)
constexpr

◆ operator""_KB()

size_t LIEF::operator""_KB ( unsigned long long kbs)
constexpr

◆ operator""_MB()

size_t LIEF::operator""_MB ( unsigned long long mbs)
constexpr

◆ round()

template<typename T >
T LIEF::round ( T x)
inlineconstexpr

References round< uint64_t >().

◆ round< uint64_t >()

template<>
uint64_t LIEF::round< uint64_t > ( uint64_t x)
inline

Referenced by round().

◆ to_json()

std::string LIEF::to_json ( const Object & v)

◆ to_json_from_abstract()

std::string LIEF::to_json_from_abstract ( const Object & v)

◆ to_string() [1/7]

const char * LIEF::to_string ( ARCHITECTURES e)

◆ to_string() [2/7]

const char * LIEF::to_string ( Binary::FORMATS e)

◆ to_string() [3/7]

const char * LIEF::to_string ( Binary::VA_TYPES e)

◆ to_string() [4/7]

const char * LIEF::to_string ( ENDIANNESS e)

◆ to_string() [5/7]

const char * LIEF::to_string ( Function::FLAGS e)

◆ to_string() [6/7]

const char * LIEF::to_string ( MODES e)

◆ to_string() [7/7]

const char * LIEF::to_string ( OBJECT_TYPES e)

◆ u16tou8()

std::string LIEF::u16tou8 ( const std::u16string & string,
bool remove_null_char = false )

Convert a UTF-16 string to a UTF-8 one.

◆ u8tou16()

result< std::u16string > LIEF::u8tou16 ( const std::string & string)

Convert a UTF-8 string to a UTF-16 one.