C++

Architectures

Engine

class Engine

This class interfaces the assembler/disassembler support.

Public Types

using instructions_it = iterator_range<Instruction::Iterator>

Disassembly instruction iterator.

Public Functions

Engine() = delete
Engine(std::unique_ptr<details::Engine> impl)
Engine(const Engine&) = delete
Engine &operator=(const Engine&) = delete
Engine(Engine&&) noexcept
Engine &operator=(Engine&&) noexcept
instructions_it disassemble(const uint8_t *buffer, size_t size, uint64_t addr)

Disassemble the provided buffer with the address specified in the second parameter.

inline instructions_it disassemble(const std::vector<uint8_t> &bytes, uint64_t addr)

Disassemble the given vector of bytes with the address specified in the second parameter.

~Engine()

Instruction

class Instruction

This class represents an assembly instruction.

Subclassed by LIEF::assembly::aarch64::Instruction, LIEF::assembly::arm::Instruction, LIEF::assembly::ebpf::Instruction, LIEF::assembly::mips::Instruction, LIEF::assembly::powerpc::Instruction, LIEF::assembly::riscv::Instruction, LIEF::assembly::x86::Instruction

Public Functions

uint64_t address() const

Address of the instruction.

size_t size() const

Size of the instruction in bytes.

const std::vector<uint8_t> &raw() const

Raw bytes of the current instruction.

std::string mnemonic() const

Instruction mnemonic (e.g. br)

std::string to_string() const

Representation of the current instruction in a pretty assembly way.

bool is_call() const

True if the instruction is a call.

bool is_terminator() const

True if the instruction marks the end of a basic block.

bool is_branch() const

True if the instruction is a branch.

bool is_syscall() const

True if the instruction is a syscall.

template<class T>
inline const T *as() const

This function can be used to down cast an Instruction instance:

std::unique_ptr<assembly::Instruction> inst = get_inst();
if (const auto* arm = inst->as<assembly::arm::Instruction>()) {
  const arm::OPCODE op = arm->opcode();
}
virtual ~Instruction()

Friends

inline friend std::ostream &operator<<(std::ostream &os, const Instruction &inst)
class Iterator : public LIEF::iterator_facade_base<Iterator, std::forward_iterator_tag, std::unique_ptr<Instruction>, std::ptrdiff_t, Instruction*, std::unique_ptr<Instruction>>

Lazy-forward iterator that outputs Instruction

Public Types

using implementation = details::InstructionIt

Public Functions

Iterator()
Iterator(std::unique_ptr<details::InstructionIt> impl)
Iterator(const Iterator&)
Iterator &operator=(const Iterator&)
Iterator(Iterator&&) noexcept
Iterator &operator=(Iterator&&) noexcept
~Iterator()
Iterator &operator++()
std::unique_ptr<Instruction> operator*() const

Disassemble and output an Instruction at the current iterator’s position.

Friends

friend bool operator==(const Iterator &LHS, const Iterator &RHS)
inline friend bool operator!=(const Iterator &LHS, const Iterator &RHS)