#include <arch_manager.hpp>
Public Member Functions | |
| virtual | ~ArchManager ()=default |
| std::shared_ptr< ARCH_ATTRIBUTES > | get_attrs () |
| bool | does_hook_intr () |
| std::string | get_name_by_syscall_no (uint64_t syscall_no) |
| bool | has_syscall_with_name (std::string name) |
| uint64_t | get_syscall_no_by_name (std::string name) |
| std::vector< REG > | get_context_regs () |
| std::unique_ptr< std::map< REG, RVAL > > | dump_regs () |
| void | load_regs (std::unique_ptr< std::map< REG, RVAL > > regs) |
| bool | has_idt_entry (uint64_t intno) |
| CPU_INTR | get_idt_entry (uint64_t intno) |
| std::unique_ptr< std::map< REG, RVAL > > | init_thread_regs (ADDR pc, ADDR sp) |
| virtual ks_engine * | curr_ks ()=0 |
| virtual csh * | curr_cs ()=0 |
| virtual void | setup ()=0 |
| virtual ADDR | dump_tls ()=0 |
| virtual void | load_tls (ADDR new_tls)=0 |
| virtual void | prerun_hook (ADDR &start) |
| template<typename T > | |
| T | read_reg (REG reg) |
| template<typename T > | |
| T | read_reg (std::string reg_name) |
| uint64_t | read_arch_reg (REG reg) |
| template<typename T > | |
| void | write_reg (REG reg, T val) |
| template<typename T > | |
| void | write_reg (std::string reg_name, T val) |
| void | write_arch_reg (REG reg, uint64_t val) |
Static Public Member Functions | |
| static std::unique_ptr< ArchManager > | initialize (std::weak_ptr< Arion > arion, CPU_ARCH arch, PLATFORM platform=PLATFORM::UNKNOWN_PLATFORM) |
| static int | get_signal_from_intr (CPU_INTR intr) |
Protected Member Functions | |
| ArchManager (std::shared_ptr< ARCH_ATTRIBUTES > attrs, std::map< std::string, REG > arch_regs, std::map< REG, uint8_t > arch_regs_sz, std::vector< REG > ctxt_regs, std::map< uint64_t, CPU_INTR > cpu_idt, bool hooks_intr) | |
Protected Attributes | |
| std::weak_ptr< Arion > | arion |
| The Arion instanced associated to this instance. | |
| uc_engine * | uc |
| The Unicorn engine associated with this instance. | |
| std::vector< ks_engine * > | ks |
| The Keystone engine associated with this instance. | |
| std::vector< csh * > | cs |
| The Capstone engine associated with this instance. | |
| std::shared_ptr< ARCH_ATTRIBUTES > | attrs |
| Multiple architecture specific attributes, grouped in a structure for genericity purpose. | |
| std::map< std::string, REG > | arch_regs |
| Unicorn registers by their name. | |
| std::map< REG, uint8_t > | arch_regs_sz |
| Unicorn registers sizes. | |
| std::vector< REG > | ctxt_regs |
| Unicorn registers making up the context to save and restore. | |
| std::map< uint64_t, CPU_INTR > | cpu_idt |
| Interrupt Descriptor Table for the CPU. | |
| bool | hooks_intr |
| True if the ArchManager subclass uses hook_intr to intercept syscalls. | |
Static Private Attributes | |
| static std::map< CPU_INTR, int > | signo_by_intr |
| A map identifying a signal number given a cpu interruption. | |
A class responsible for performing architecture specific operations. This class is abstract and its subclasses must implement a specific architecture.
|
inlineprotected |
Builder for ArchManager instances.
| [in] | attrs | Multiple architecture specific attributes, grouped in a structure for genericity purpose. |
| [in] | arch_regs | Unicorn registers by their name. |
| [in] | arch_regs_sz | Unicorn registers sizes. |
| [in] | ctxt_regs | Unicorn registers making up the context to save and restore. |
| [in] | Interrupt | Descriptor Table for the CPU. |
| [in] | hooks_intr | True if the ArchManager subclass uses hook_intr to detect syscalls. |
|
virtualdefault |
|
pure virtual |
Retrieves a Capstone engine associated with this instance, based on the current mode of the CPU.
Implemented in arion_arm::ArchManagerARM, arion_arm64::ArchManagerARM64, arion_x86_64::ArchManagerX8664, and arion_x86::ArchManagerX86.
|
pure virtual |
Retrieves a Keystone engine associated with this instance, based on the current mode of the CPU.
Implemented in arion_arm::ArchManagerARM, arion_arm64::ArchManagerARM64, arion_x86_64::ArchManagerX8664, and arion_x86::ArchManagerX86.
| bool arion::ArchManager::does_hook_intr | ( | ) |
Checks whether the ArchManager subclass uses hook_intr to intercept syscalls.
During emulation, dumps values of registers making up the context inside a map.
|
pure virtual |
Retrieves the current Thread Local Storage (TLS) address from the emulation context.
Implemented in arion_arm::ArchManagerARM, arion_arm64::ArchManagerARM64, arion_x86_64::ArchManagerX8664, and arion_x86::ArchManagerX86.
| std::shared_ptr< ARCH_ATTRIBUTES > arion::ArchManager::get_attrs | ( | ) |
Retrieves the list of architecture specific attributes.
| std::vector< REG > arion::ArchManager::get_context_regs | ( | ) |
Retrieves the list of registers making up the context to save and restore.
| CPU_INTR arion::ArchManager::get_idt_entry | ( | uint64_t | intno | ) |
| std::string arion::ArchManager::get_name_by_syscall_no | ( | uint64_t | syscall_no | ) |
Retrieves a syscall name by its number.
| [in] | syscall_no | The syscall number. |
|
static |
Retrieves a signal number from a CPU interrupt based on the Interrupt Descriptor Table for the architecture.
| [in] | intr | The CPU interrupt. |
| uint64_t arion::ArchManager::get_syscall_no_by_name | ( | std::string | name | ) |
Retrieves a syscall number by its name.
| [in] | name | The syscall name. |
| bool arion::ArchManager::has_idt_entry | ( | uint64_t | intno | ) |
Checks whether this CPU architecture has a given Interrupt Descriptor Table entry.
| [in] | intno | The interrupt number. |
| bool arion::ArchManager::has_syscall_with_name | ( | std::string | name | ) |
Checks whether this architecture has a syscall with a given name.
| [in] | name | The syscall name. |
Initializes a map of values associated to registers, with a PC and SP value. This method is used when instanciating a new thread, where only these two registers are initialized.
| [in] | pc | The Unicorn PC register. |
| [in] | sp | The Unicorn SP register. |
|
static |
Instanciates and initializes new ArchManager objects with some parameters.
| [in] | arion | The Arion instance associated with this instance. |
| [in] | arch | Arion CPU architecture. |
| [in] | platform | Arion platform on which the emulation occurs. |
During emulation, loads values of registers making up the context from a map.
| [in] | regs | A map identifying a value by its associated register. |
|
pure virtual |
Defines a Thread Local Storage (TLS) address to apply to the emulation.
| [in] | new_tls | The new TLS address. |
Implemented in arion_arm::ArchManagerARM, arion_arm64::ArchManagerARM64, arion_x86_64::ArchManagerX8664, and arion_x86::ArchManagerX86.
|
inlinevirtual |
Performs architecture specific operations each time emulation starts.
| [in,out] | start | The emulation start address. |
Reimplemented in arion_arm::ArchManagerARM.
| uint64_t arion::ArchManager::read_arch_reg | ( | REG | reg | ) |
Reads a general-purpose register value from the CPU context during emulation. The result is casted on a 64-bit integer for convenience.
| [in] | reg | The Unicorn register. |
|
inline |
Reads a register value from the CPU context during emulation.
| T | A RVAL type large enough to store the register value. |
| [in] | reg | The Unicorn register. |
|
inline |
Reads a register value from the CPU context during emulation.
| T | A RVAL type large enough to store the register value. |
| [in] | reg | The register name. |
|
pure virtual |
Prepares the ArchManager for emulation.
Implemented in arion_arm::ArchManagerARM, arion_arm64::ArchManagerARM64, arion_x86_64::ArchManagerX8664, and arion_x86::ArchManagerX86.
| void arion::ArchManager::write_arch_reg | ( | REG | reg, |
| uint64_t | val | ||
| ) |
Writes a general-purpose register value to the CPU context during emulation. The new value is casted on a 64-bit integer for convenience.
| [in] | reg | The Unicorn register. |
| [in] | val | The new register value. |
|
inline |
Writes a register value to the CPU context during emulation.
| T | A RVAL type large enough to store the register value. |
| [in] | reg | The Unicorn register. |
| [in] | val | The new register value. |
|
inline |
Writes a register value to the CPU context during emulation.
| T | A RVAL type large enough to store the register value. |
| [in] | reg | The register name. |
| [in] | val | The new register value. |
|
protected |
Unicorn registers by their name.
|
protected |
Unicorn registers sizes.
|
protected |
The Arion instanced associated to this instance.
|
protected |
Multiple architecture specific attributes, grouped in a structure for genericity purpose.
|
protected |
Interrupt Descriptor Table for the CPU.
|
protected |
The Capstone engine associated with this instance.
|
protected |
Unicorn registers making up the context to save and restore.
|
protected |
True if the ArchManager subclass uses hook_intr to intercept syscalls.
|
protected |
The Keystone engine associated with this instance.
|
staticprivate |
A map identifying a signal number given a cpu interruption.
|
protected |
The Unicorn engine associated with this instance.