LIEF: Library to Instrument Executable Formats Version 0.13.0
Namespaces | Classes | Typedefs | Enumerations | Functions
LIEF Namespace Reference

LIEF namespace. More...

Namespaces

namespace  ART
 Namespace related to the LIEF's ART module.
 
namespace  ELF
 Namespace related to the LIEF's ELF module.
 
namespace  MachO
 Namespace related to the LIEF's Mach-O module.
 
namespace  PE
 Namespace related to the LIEF's PE module.
 

Classes

class  AbstractHash
 
class  bad_file
 
class  bad_format
 
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...
 
class  builder_error
 
class  conversion_error
 
class  corrupted
 
class  dict_iterator
 
struct  dict_iterator_pair
 
class  exception
 
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  integrity_error
 
class  MemoryStream
 
class  not_found
 
class  not_implemented
 
class  not_supported
 
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...
 
class  parser_error
 
class  pe_bad_section_name
 
class  pe_error
 
class  read_out_of_bound
 
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  type_error
 
class  vector_iostream
 
class  VectorStream
 
class  Visitor
 

Typedefs

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_pointer_t = typename std::add_pointer< T >::type
 
template<class T >
using remove_pointer_t = typename std::remove_pointer< T >::type
 
template<class T >
using add_ref_t = typename add_lvalue_reference< T >::type
 
template<typename T >
using result = boost::leaf::result< T >
 Wrapper that contains an Object (T) or an error. More...
 
template<typename T >
using error_result_t = typename result< T >::error_resul
 Abstraction over the implementation.
 
using error_t = boost::leaf::error_id
 Abstraction over the implementation.
 
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: More...
 
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  EXE_FORMATS { FORMAT_UNKNOWN = 0 , FORMAT_ELF = 1 , FORMAT_PE = 2 , FORMAT_MACHO = 3 }
 LIEF executable format. More...
 
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
}
 
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 (EXE_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 (Binary::VA_TYPES e)
 
const char * to_string (Function::FLAGS e)
 
std::string to_json_from_abstract (const Object &v)
 
error_t return_error (lief_errors)
 Create an error_t from a lief_errors.
 
template<class T >
std::error_code 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.
 
size_t hash (const Object &v)
 
size_t hash (const std::vector< uint8_t > &raw)
 
size_t hash (span< const uint8_t > raw)
 
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.
 
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=":")
 
bool is_printable (const std::string &str)
 Check if the given string in printable.
 
bool is_hex_number (const std::string &nb)
 Check if the given number is a hex-like string.
 

Detailed Description

LIEF namespace.

Typedef Documentation

◆ ok_error_t

using LIEF::ok_error_t = typedef result<ok_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();
}
ok_t ok()
Return success for function with return type ok_error_t.
Definition: errors.hpp:110
result< ok_t > ok_error_t
Opaque structure that is used by LIEF to avoid writing result<void> f(...). Instead,...
Definition: errors.hpp:126

◆ result

template<typename T >
using LIEF::result = typedef boost::leaf::result<T>

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

The LEAF 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";
}
std::error_code get_error(result< T > &err)
Get the error code associated with the result.
Definition: errors.hpp:96
boost::leaf::result< T > result
Wrapper that contains an Object (T) or an error.
Definition: errors.hpp:82

See https://boostorg.github.io/leaf/ for more details

Enumeration Type Documentation

◆ EXE_FORMATS

LIEF executable format.

Enumerator
FORMAT_PE 

ELF. See: LIEF::ELF.

FORMAT_MACHO 

PE. See: LIEF::PE.