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

Namespaces

namespace  android
namespace  details
namespace  Linux
namespace  osx
namespace  windows

Classes

class  Host
 This class represents the current host. More...
class  Memory
 This class exposes API to access and manage memory. More...
class  Module
 This class represents an in-memory module which can be an executable or a library. More...
class  Process
 This structure represents the current process and provides functions to query process-level information. More...

Typedefs

using instructions_it = iterator_range<assembly::Instruction::Iterator>
using modules_t = iterator_range<Module::Iterator>

Enumerations

enum class  PLATFORMS : uint32_t {
  NONE = 0 , LINUX , WINDOWS , ANDROID_ ,
  OSX , IOS
}
enum class  ARCH : uint32_t { NONE , X86_64 , ARM64 , RISCV64 }

Functions

std::vector< uint8_t > assemble (uint64_t addr, const std::string &Asm, assembly::AssemblerConfig &config=assembly::AssemblerConfig::default_config())
 Assemble the provided assembly code at the specified (absolute) virtual address.
std::vector< uint8_t > assemble (uint64_t address, const llvm::MCInst &inst)
 Assemble the provided LLVM MCInst instruction at the specified (absolute) virtual address and return the generated assembly bytes.
std::vector< uint8_t > assemble (uint64_t address, const std::vector< llvm::MCInst > &insts)
 Assemble the provided sequence of LLVM MCInst instructions at the specified (absolute) virtual address and return the generated assembly bytes.
instructions_it disassemble (uintptr_t addr)
 Start disassembling instructions at the given absolute virtual address.
modules_t modules ()
 Return an iterator over the different modules loaded in the current process.
std::unique_ptr< Modulemodule_from_name (const std::string &name)
 Find the module with the given name.
std::unique_ptr< Modulemodule_from_path (const std::string &path)
 Find the module with the given path.
std::unique_ptr< Modulemodule_from_addr (uintptr_t addr)
 Find the module that encompasses the given virtual address (absolute).

Typedef Documentation

◆ instructions_it

◆ modules_t

Enumeration Type Documentation

◆ ARCH

enum class LIEF::runtime::ARCH : uint32_t
strong
Enumerator
NONE 
X86_64 
ARM64 
RISCV64 

◆ PLATFORMS

enum class LIEF::runtime::PLATFORMS : uint32_t
strong
Enumerator
NONE 
LINUX 
WINDOWS 
ANDROID_ 
OSX 
IOS 

Function Documentation

◆ assemble() [1/3]

std::vector< uint8_t > LIEF::runtime::assemble ( uint64_t addr,
const std::string & Asm,
assembly::AssemblerConfig & config = assembly::AssemblerConfig::default_config() )

Assemble the provided assembly code at the specified (absolute) virtual address.

The function returns the generated assembly bytes.

#include <LIEF/runtime.hpp>
auto code = LIEF::runtime::assemble(0x7f0011223344, R"(
xor rax, rbx;
mov rcx, rax;
)");
std::vector< uint8_t > assemble(uint64_t addr, const std::string &Asm, assembly::AssemblerConfig &config=assembly::AssemblerConfig::default_config())
Assemble the provided assembly code at the specified (absolute) virtual address.

If you need to configure the assembly engine or to define addresses for symbols, you can provide your own assembly::AssemblerConfig instance.

References LIEF::assembly::AssemblerConfig::default_config(), and LIEF_API.

◆ assemble() [2/3]

std::vector< uint8_t > LIEF::runtime::assemble ( uint64_t address,
const llvm::MCInst & inst )

Assemble the provided LLVM MCInst instruction at the specified (absolute) virtual address and return the generated assembly bytes.

References LIEF_API.

◆ assemble() [3/3]

std::vector< uint8_t > LIEF::runtime::assemble ( uint64_t address,
const std::vector< llvm::MCInst > & insts )

Assemble the provided sequence of LLVM MCInst instructions at the specified (absolute) virtual address and return the generated assembly bytes.

References LIEF_API.

◆ disassemble()

instructions_it LIEF::runtime::disassemble ( uintptr_t addr)

Start disassembling instructions at the given absolute virtual address.

for (const auto& inst : disassemble(0x7f0011223344)) {
std::cout << inst.to_string() << '\n';
}
instructions_it disassemble(uintptr_t addr)
Start disassembling instructions at the given absolute virtual address.

References LIEF_API.

◆ module_from_addr()

std::unique_ptr< Module > LIEF::runtime::module_from_addr ( uintptr_t addr)
inline

Find the module that encompasses the given virtual address (absolute).

References module_from_addr(), and modules().

Referenced by module_from_addr().

◆ module_from_name()

std::unique_ptr< Module > LIEF::runtime::module_from_name ( const std::string & name)
inline

Find the module with the given name.

References module_from_name(), and modules().

Referenced by module_from_name().

◆ module_from_path()

std::unique_ptr< Module > LIEF::runtime::module_from_path ( const std::string & path)
inline

Find the module with the given path.

References module_from_path(), and modules().

Referenced by module_from_path().

◆ modules()

modules_t LIEF::runtime::modules ( )

Return an iterator over the different modules loaded in the current process.

References LIEF_API, and modules().

Referenced by module_from_addr(), module_from_name(), module_from_path(), and modules().