LIEF: Library to Instrument Executable Formats Version 0.15.0
|
Abstract binary that exposes an uniform API for the different executable file formats. More...
#include <Binary.hpp>
Public Types | |
enum class | VA_TYPES { AUTO = 0 , RVA = 1 , VA = 2 } |
Type of a virtual address. More... | |
enum | FORMATS { UNKNOWN = 0 , ELF , PE , MACHO , OAT } |
using | functions_t = std::vector<Function> |
using | sections_t = std::vector<Section*> |
Internal container. | |
using | it_sections = ref_iterator<sections_t> |
Iterator that outputs LIEF::Section&. | |
using | it_const_sections = const_ref_iterator<sections_t> |
Iterator that outputs const LIEF::Section&. | |
using | symbols_t = std::vector<Symbol*> |
Internal container. | |
using | it_symbols = ref_iterator<symbols_t> |
Iterator that outputs LIEF::Symbol&. | |
using | it_const_symbols = const_ref_iterator<symbols_t> |
Iterator that outputs const LIEF::Symbol&. | |
using | relocations_t = std::vector<Relocation*> |
Internal container. | |
using | it_relocations = ref_iterator<relocations_t> |
Iterator that outputs LIEF::Relocation&. | |
using | it_const_relocations = const_ref_iterator<relocations_t> |
Iterator that outputs const LIEF::Relocation&. | |
Public Types inherited from LIEF::Object | |
template<class T > | |
using | output_t = add_pointer_t<decay_t<T>> |
template<class T > | |
using | output_const_t = add_pointer_t<add_const_t<decay_t<T>>> |
Public Member Functions | |
Binary (FORMATS fmt) | |
Binary & | operator= (const Binary &) |
Binary (const Binary &) | |
FORMATS | format () const |
Executable format (ELF, PE, Mach-O) of the underlying binary. | |
Header | header () const |
Return the abstract header of the binary. | |
it_symbols | symbols () |
Return an iterator over the abstracted symbols in which the elements can be modified. | |
it_const_symbols | symbols () const |
Return an iterator over the abstracted symbols in which the elements can't be modified. | |
bool | has_symbol (const std::string &name) const |
Check if a Symbol with the given name exists. | |
const Symbol * | get_symbol (const std::string &name) const |
Return the Symbol with the given name If the symbol does not exist, return a nullptr. | |
Symbol * | get_symbol (const std::string &name) |
it_sections | sections () |
Return an iterator over the binary's sections (LIEF::Section) | |
it_const_sections | sections () const |
virtual void | remove_section (const std::string &name, bool clear=false)=0 |
Remove all the sections in the underlying binary. | |
it_relocations | relocations () |
Return an iterator over the binary relocation (LIEF::Relocation) | |
it_const_relocations | relocations () const |
virtual uint64_t | entrypoint () const =0 |
Binary's entrypoint (if any) | |
uint64_t | original_size () const |
Binary's original size. | |
functions_t | exported_functions () const |
Return the functions exported by the binary. | |
std::vector< std::string > | imported_libraries () const |
Return libraries which are imported by the binary. | |
functions_t | imported_functions () const |
Return functions imported by the binary. | |
virtual result< uint64_t > | get_function_address (const std::string &func_name) const |
Return the address of the given function name. | |
void | accept (Visitor &visitor) const override |
Method so that a visitor can visit us. | |
std::vector< uint64_t > | xref (uint64_t address) const |
virtual void | patch_address (uint64_t address, const std::vector< uint8_t > &patch_value, VA_TYPES addr_type=VA_TYPES::AUTO)=0 |
Patch the content at virtual address address with patch_value . | |
virtual void | patch_address (uint64_t address, uint64_t patch_value, size_t size=sizeof(uint64_t), VA_TYPES addr_type=VA_TYPES::AUTO)=0 |
Patch the address with the given value. | |
virtual span< const uint8_t > | get_content_from_virtual_address (uint64_t virtual_address, uint64_t size, VA_TYPES addr_type=VA_TYPES::AUTO) const =0 |
Return the content located at the given virtual address. | |
void | original_size (uint64_t size) |
Change binary's original size. | |
virtual bool | is_pie () const =0 |
Check if the binary is position independent. | |
virtual bool | has_nx () const =0 |
Check if the binary uses NX protection. | |
virtual uint64_t | imagebase () const =0 |
Default image base address if the ASLR is not enabled. | |
virtual functions_t | ctor_functions () const =0 |
Constructor functions that are called prior any other functions. | |
virtual result< uint64_t > | offset_to_virtual_address (uint64_t offset, uint64_t slide=0) const =0 |
Convert the given offset into a virtual address. | |
virtual std::ostream & | print (std::ostream &os) const |
virtual void | write (const std::string &name)=0 |
Build & transform the Binary object representation into a real executable. | |
virtual void | write (std::ostream &os)=0 |
Public Member Functions inherited from LIEF::Object | |
Object (const Object &other) | |
Object & | operator= (const Object &other) |
template<class T > | |
output_t< T > | as () |
template<class T > | |
output_const_t< T > | as () const |
virtual bool | operator== (const Object &other) const |
virtual bool | operator!= (const Object &other) const |
Abstract binary that exposes an uniform API for the different executable file formats.
|
strong |
|
overridevirtual |
Method so that a visitor
can visit us.
Implements LIEF::Object.
Reimplemented in LIEF::ELF::Binary, LIEF::MachO::Binary, LIEF::OAT::Binary, and LIEF::PE::Binary.
|
pure virtual |
Constructor functions that are called prior any other functions.
Implemented in LIEF::ELF::Binary, LIEF::MachO::Binary, and LIEF::PE::Binary.
|
pure virtual |
Binary's entrypoint (if any)
Implemented in LIEF::ELF::Binary, LIEF::MachO::Binary, and LIEF::PE::Binary.
|
pure virtual |
Return the content located at the given virtual address.
Implemented in LIEF::ELF::Binary, LIEF::MachO::Binary, and LIEF::PE::Binary.
|
virtual |
Return the address of the given function name.
Reimplemented in LIEF::ELF::Binary.
|
pure virtual |
Check if the binary uses NX
protection.
Implemented in LIEF::ELF::Binary, LIEF::MachO::Binary, and LIEF::PE::Binary.
|
pure virtual |
Default image base address if the ASLR is not enabled.
Implemented in LIEF::ELF::Binary, LIEF::MachO::Binary, and LIEF::PE::Binary.
|
pure virtual |
Check if the binary is position independent.
Implemented in LIEF::ELF::Binary, LIEF::MachO::Binary, and LIEF::PE::Binary.
|
pure virtual |
Convert the given offset into a virtual address.
[in] | offset | The offset to convert. |
[in] | slide | If not 0, it will replace the default base address (if any) |
Implemented in LIEF::ELF::Binary, LIEF::MachO::Binary, and LIEF::PE::Binary.
|
inline |
Change binary's original size.
|
pure virtual |
Patch the content at virtual address address
with patch_value
.
[in] | address | Address to patch |
[in] | patch_value | Patch to apply |
[in] | addr_type | Specify if the address should be used as an absolute virtual address or a RVA |
Implemented in LIEF::ELF::Binary, LIEF::MachO::Binary, and LIEF::PE::Binary.
|
pure virtual |
Patch the address with the given value.
[in] | address | Address to patch |
[in] | patch_value | Patch to apply |
[in] | size | Size of the value in bytes (1, 2, ... 8) |
[in] | addr_type | Specify if the address should be used as an absolute virtual address or an RVA |
Implemented in LIEF::ELF::Binary, LIEF::MachO::Binary, and LIEF::PE::Binary.
|
pure virtual |
Remove all the sections in the underlying binary.
Implemented in LIEF::ELF::Binary, LIEF::MachO::Binary, and LIEF::PE::Binary.
|
pure virtual |
Build & transform the Binary object representation into a real executable.
Implemented in LIEF::ELF::Binary, LIEF::MachO::Binary, and LIEF::PE::Binary.
|
pure virtual |
Implemented in LIEF::ELF::Binary, LIEF::MachO::Binary, and LIEF::PE::Binary.