This class purpose is to manage user-defined Arion hooks including hook creation, deletion, trigger handling...
More...
#include <hooks_manager.hpp>
|
| | HooksManager (std::weak_ptr< Arion > arion) |
| |
| | ~HooksManager () |
| |
| HOOK_ID | hook_intr (U32_HOOK_CALLBACK callback, ADDR start=0, ADDR end=ARION_MAX_U64, void *user_data=nullptr) |
| |
| HOOK_ID | hook_insn (NO_PARAM_HOOK_CALLBACK callback, uint64_t insn, ADDR start=0, ADDR end=ARION_MAX_U64, void *user_data=nullptr) |
| |
| HOOK_ID | hook_code (ADDR_SZ_HOOK_CALLBACK callback, ADDR start=0, ADDR end=ARION_MAX_U64, void *user_data=nullptr) |
| |
| HOOK_ID | hook_addr (ADDR_SZ_HOOK_CALLBACK callback, ADDR addr, void *user_data=nullptr) |
| |
| HOOK_ID | hook_block (ADDR_SZ_HOOK_CALLBACK callback, ADDR start=0, ADDR end=ARION_MAX_U64, void *user_data=nullptr) |
| |
| HOOK_ID | hook_mem_read_unmapped (MEM_HOOK_CALLBACK callback, ADDR start=0, ADDR end=ARION_MAX_U64, void *user_data=nullptr) |
| |
| HOOK_ID | hook_mem_write_unmapped (MEM_HOOK_CALLBACK callback, ADDR start=0, ADDR end=ARION_MAX_U64, void *user_data=nullptr) |
| |
| HOOK_ID | hook_mem_fetch_unmapped (MEM_HOOK_CALLBACK callback, ADDR start=0, ADDR end=ARION_MAX_U64, void *user_data=nullptr) |
| |
| HOOK_ID | hook_mem_read_prot (MEM_HOOK_CALLBACK callback, ADDR start=0, ADDR end=ARION_MAX_U64, void *user_data=nullptr) |
| |
| HOOK_ID | hook_mem_write_prot (MEM_HOOK_CALLBACK callback, ADDR start=0, ADDR end=ARION_MAX_U64, void *user_data=nullptr) |
| |
| HOOK_ID | hook_mem_fetch_prot (MEM_HOOK_CALLBACK callback, ADDR start=0, ADDR end=ARION_MAX_U64, void *user_data=nullptr) |
| |
| HOOK_ID | hook_mem_read (MEM_HOOK_CALLBACK callback, ADDR start=0, ADDR end=ARION_MAX_U64, void *user_data=nullptr) |
| |
| HOOK_ID | hook_mem_write (MEM_HOOK_CALLBACK callback, ADDR start=0, ADDR end=ARION_MAX_U64, void *user_data=nullptr) |
| |
| HOOK_ID | hook_mem_fetch (MEM_HOOK_CALLBACK callback, ADDR start=0, ADDR end=ARION_MAX_U64, void *user_data=nullptr) |
| |
| HOOK_ID | hook_mem_read_after (MEM_HOOK_CALLBACK callback, ADDR start=0, ADDR end=ARION_MAX_U64, void *user_data=nullptr) |
| |
| HOOK_ID | hook_insn_invalid (NO_PARAM_BOOL_HOOK_CALLBACK callback, ADDR start=0, ADDR end=ARION_MAX_U64, void *user_data=nullptr) |
| |
| HOOK_ID | hook_edge_generated (EDGE_HOOK_CALLBACK callback, ADDR start=0, ADDR end=ARION_MAX_U64, void *user_data=nullptr) |
| |
| HOOK_ID | hook_tcg_opcode (TCG_HOOK_CALLBACK callback, uint64_t aux1, uint64_t aux2, ADDR start=0, ADDR end=ARION_MAX_U64, void *user_data=nullptr) |
| |
| HOOK_ID | hook_tlb_fill (TLB_HOOK_CALLBACK callback, ADDR start=0, ADDR end=ARION_MAX_U64, void *user_data=nullptr) |
| |
| HOOK_ID | hook_fork (PROCESS_HOOK_CALLBACK callback, void *user_data=nullptr) |
| |
| HOOK_ID | hook_execve (PROCESS_HOOK_CALLBACK callback, void *user_data=nullptr) |
| |
| HOOK_ID | hook_syscall (SYSCALL_HOOK_CALLBACK callback, void *user_data=nullptr) |
| |
| void | unhook (HOOK_ID hook_id) |
| |
| void | clear_hooks () |
| |
| template<typename... HookParams> |
| void | trigger_arion_hook (ARION_HOOK_TYPE type, HookParams... params) |
| |
|
| std::weak_ptr< Arion > | arion |
| | The Arion instance associated with this instance.
|
| |
| uc_engine * | uc |
| | The Unicorn engine associated with this instance.
|
| |
| HOOK_ID | curr_id = 1 |
| | ID of the next hook to be created.
|
| |
| std::map< HOOK_ID, std::shared_ptr< ARION_HOOK > > | hooks |
| | A map identifying an Arion hook given its ID.
|
| |
| std::stack< HOOK_ID > | free_hook_ids |
| | A stack of hook IDs that got deleted and that can be reused.
|
| |
This class purpose is to manage user-defined Arion hooks including hook creation, deletion, trigger handling...
◆ HooksManager()
| arion::HooksManager::HooksManager |
( |
std::weak_ptr< Arion > |
arion | ) |
|
Builder for HooksManager instances.
- Parameters
-
| [in] | arion | The Arion instance associated with this instance. |
◆ ~HooksManager()
| arion::HooksManager::~HooksManager |
( |
| ) |
|
◆ clear_hooks()
| void arion::HooksManager::clear_hooks |
( |
| ) |
|
Deletes all Arion hooks, preventing them from being triggered.
◆ gen_next_id()
| HOOK_ID arion::HooksManager::gen_next_id |
( |
| ) |
|
|
private |
Generates a new hook ID.
- Returns
- The new ID.
◆ hook_addr()
Creates a new hook that gets triggered when execution reaches a specific address.
- Parameters
-
| [in] | callback | Callback being called when this hook gets triggered. |
| [in] | addr | Exact memory address where the hook should trigger. |
| [in] | user_data | Optional user-defined data passed to the hook. |
- Returns
- The new hook ID.
◆ hook_arion()
Creates a new hook which is not related to the Unicorn engine.
- Parameters
-
| [in] | type | Arion type for the hook. |
| [in] | callback | Arion callback which gets called when the Unicorn hook is triggered. |
| [in] | user_data | Optional user-defined data passed to the hook. |
- Returns
- The new hook ID.
◆ hook_block()
Creates a new hook that gets triggered at the start of a new basic block or translation block (TB).
- Parameters
-
| [in] | callback | Callback being called when this hook gets triggered. |
| [in] | start | Start memory address where the hook should trigger. |
| [in] | end | End memory address where the hook should trigger. |
| [in] | user_data | Optional user-defined data passed to the hook. |
- Returns
- The new hook ID.
◆ hook_code()
Creates a new hook that gets triggered when code execution reaches a specified address or range.
- Parameters
-
| [in] | callback | Callback being called when this hook gets triggered. |
| [in] | start | Start memory address where the hook should trigger. |
| [in] | end | End memory address where the hook should trigger. |
| [in] | user_data | Optional user-defined data passed to the hook. |
- Returns
- The new hook ID.
◆ hook_edge_generated()
Creates a new hook that gets triggered when a new control-flow edge (translation block to translation block) is generated.
- Parameters
-
| [in] | callback | Callback being called when this hook gets triggered. |
| [in] | start | Start memory address range monitored by this hook. |
| [in] | end | End memory address range monitored by this hook. |
| [in] | user_data | Optional user-defined data passed to the hook. |
- Returns
- The new hook ID.
◆ hook_execve()
Creates a new hook that gets triggered when a process executes a new program (via execve()).
- Parameters
-
| [in] | callback | Callback being called when this hook gets triggered. |
| [in] | user_data | Optional user-defined data passed to the hook. |
- Returns
- The new hook ID.
◆ hook_fork()
Creates a new hook that gets triggered when a process forks (via fork(), vfork(), or clone()).
- Parameters
-
| [in] | callback | Callback being called when this hook gets triggered. |
| [in] | user_data | Optional user-defined data passed to the hook. |
- Returns
- The new hook ID.
◆ hook_insn()
Creates a new hook that gets triggered before or after executing a specific instruction.
- Parameters
-
| [in] | callback | Callback being called when this hook gets triggered. |
| [in] | insn | Instruction identifier (architecture-specific). |
| [in] | start | Start memory address where the hook should trigger. |
| [in] | end | End memory address where the hook should trigger. |
| [in] | user_data | Optional user-defined data passed to the hook. |
- Returns
- The new hook ID.
◆ hook_insn_invalid()
Creates a new hook that gets triggered when an invalid or unimplemented instruction is encountered.
- Parameters
-
| [in] | callback | Callback being called when this hook gets triggered. |
| [in] | start | Start memory address range monitored by this hook. |
| [in] | end | End memory address range monitored by this hook. |
| [in] | user_data | Optional user-defined data passed to the hook. |
- Returns
- The new hook ID.
◆ hook_intr()
Creates a new hook that gets triggered when an interrupt occurs (e.g., software or hardware interrupt).
- Parameters
-
| [in] | callback | Callback being called when this hook gets triggered. |
| [in] | start | Start memory address where the hook should trigger. |
| [in] | end | End memory address where the hook should trigger. |
| [in] | user_data | Optional user-defined data passed to the hook. |
- Returns
- The new hook ID.
◆ hook_mem_fetch()
Creates a new hook that gets triggered when fetching instructions from valid mapped memory.
- Parameters
-
| [in] | callback | Callback being called when this hook gets triggered. |
| [in] | start | Start memory address range monitored by this hook. |
| [in] | end | End memory address range monitored by this hook. |
| [in] | user_data | Optional user-defined data passed to the hook. |
- Returns
- The new hook ID.
◆ hook_mem_fetch_prot()
Creates a new hook that gets triggered when fetching instructions from a protected region.
- Parameters
-
| [in] | callback | Callback being called when this hook gets triggered. |
| [in] | start | Start memory address range monitored by this hook. |
| [in] | end | End memory address range monitored by this hook. |
| [in] | user_data | Optional user-defined data passed to the hook. |
- Returns
- The new hook ID.
◆ hook_mem_fetch_unmapped()
Creates a new hook that gets triggered when fetching instructions from an unmapped region.
- Parameters
-
| [in] | callback | Callback being called when this hook gets triggered. |
| [in] | start | Start memory address range monitored by this hook. |
| [in] | end | End memory address range monitored by this hook. |
| [in] | user_data | Optional user-defined data passed to the hook. |
- Returns
- The new hook ID.
◆ hook_mem_read()
Creates a new hook that gets triggered on every valid memory read access.
- Parameters
-
| [in] | callback | Callback being called when this hook gets triggered. |
| [in] | start | Start memory address range monitored by this hook. |
| [in] | end | End memory address range monitored by this hook. |
| [in] | user_data | Optional user-defined data passed to the hook. |
- Returns
- The new hook ID.
◆ hook_mem_read_after()
Creates a new hook that gets triggered after a memory read operation completes.
- Parameters
-
| [in] | callback | Callback being called when this hook gets triggered. |
| [in] | start | Start memory address range monitored by this hook. |
| [in] | end | End memory address range monitored by this hook. |
| [in] | user_data | Optional user-defined data passed to the hook. |
- Returns
- The new hook ID.
◆ hook_mem_read_prot()
Creates a new hook that gets triggered on a memory read violating protection flags.
- Parameters
-
| [in] | callback | Callback being called when this hook gets triggered. |
| [in] | start | Start memory address range monitored by this hook. |
| [in] | end | End memory address range monitored by this hook. |
| [in] | user_data | Optional user-defined data passed to the hook. |
- Returns
- The new hook ID.
◆ hook_mem_read_unmapped()
Creates a new hook that gets triggered on a memory read from an unmapped region.
- Parameters
-
| [in] | callback | Callback being called when this hook gets triggered. |
| [in] | start | Start memory address range monitored by this hook. |
| [in] | end | End memory address range monitored by this hook. |
| [in] | user_data | Optional user-defined data passed to the hook. |
- Returns
- The new hook ID.
◆ hook_mem_write()
Creates a new hook that gets triggered on every valid memory write access.
- Parameters
-
| [in] | callback | Callback being called when this hook gets triggered. |
| [in] | start | Start memory address range monitored by this hook. |
| [in] | end | End memory address range monitored by this hook. |
| [in] | user_data | Optional user-defined data passed to the hook. |
- Returns
- The new hook ID.
◆ hook_mem_write_prot()
Creates a new hook that gets triggered on a memory write violating protection flags.
- Parameters
-
| [in] | callback | Callback being called when this hook gets triggered. |
| [in] | start | Start memory address range monitored by this hook. |
| [in] | end | End memory address range monitored by this hook. |
| [in] | user_data | Optional user-defined data passed to the hook. |
- Returns
- The new hook ID.
◆ hook_mem_write_unmapped()
Creates a new hook that gets triggered on a memory write to an unmapped region.
- Parameters
-
| [in] | callback | Callback being called when this hook gets triggered. |
| [in] | start | Start memory address range monitored by this hook. |
| [in] | end | End memory address range monitored by this hook. |
| [in] | user_data | Optional user-defined data passed to the hook. |
- Returns
- The new hook ID.
◆ hook_syscall()
Creates a new hook that gets triggered when a system call is invoked.
- Parameters
-
| [in] | callback | Callback being called when this hook gets triggered. |
| [in] | user_data | Optional user-defined data passed to the hook. |
- Returns
- The new hook ID.
◆ hook_tcg_opcode()
Creates a new hook that gets triggered for each TCG opcode during translation or emulation.
- Parameters
-
| [in] | callback | Callback being called when this hook gets triggered. |
| [in] | aux1 | Auxiliary value (architecture-specific argument 1). |
| [in] | aux2 | Auxiliary value (architecture-specific argument 2). |
| [in] | start | Start memory address where the hook should trigger. |
| [in] | end | End memory address where the hook should trigger. |
| [in] | user_data | Optional user-defined data passed to the hook. |
- Returns
- The new hook ID.
◆ hook_tlb_fill()
Creates a new hook that gets triggered when a TLB entry is filled or a translation lookup occurs.
- Parameters
-
| [in] | callback | Callback being called when this hook gets triggered. |
| [in] | start | Start memory address range monitored by this hook. |
| [in] | end | End memory address range monitored by this hook. |
| [in] | user_data | Optional user-defined data passed to the hook. |
- Returns
- The new hook ID.
◆ hook_uc()
template<typename... UcParams>
Creates a new hook related to the Unicorn engine, which means every hooks that are defined in Unicorn.
- Template Parameters
-
| UcParams | Additional parameters for genericity purpose. |
- Parameters
-
| [in] | type | Arion type for the hook. |
| [in] | callback | Arion callback which gets called when the Unicorn hook is triggered. |
| [in] | user_data | Optional user-defined data passed to the hook. |
| [in] | start | Start memory address where the hook should trigger. |
| [in] | end | End memory address where the hook should trigger. |
| [in] | uc_params | Additional parameters for the hook. |
- Returns
- The new hook ID.
◆ initialize()
| static std::unique_ptr< HooksManager > arion::HooksManager::initialize |
( |
std::weak_ptr< Arion > |
arion | ) |
|
|
static |
Instanciates and initializes new HooksManager objects with some parameters.
- Parameters
-
| [in] | arion | The Arion instance associated with this instance. |
- Returns
- A new HooksManager instance.
◆ trigger_arion_hook()
template<typename... HookParams>
| void arion::HooksManager::trigger_arion_hook |
( |
ARION_HOOK_TYPE |
type, |
|
|
HookParams... |
params |
|
) |
| |
|
inline |
Triggers all hooks with a given type, which are not related to the Unicorn engine.
- Template Parameters
-
| HookParams | Additional parameters for genericity purpose. |
- Parameters
-
| [in] | type | Arion type for the hooks to be triggered. |
| [in] | params | Additional parameters for the hooks. |
◆ unhook()
| void arion::HooksManager::unhook |
( |
HOOK_ID |
hook_id | ) |
|
Deletes an Arion hook, preventing it from being triggered.
- Parameters
-
| [in] | hook_id | ID of the hook which must get deleted. |
◆ arion
| std::weak_ptr<Arion> arion::HooksManager::arion |
|
private |
The Arion instance associated with this instance.
◆ curr_id
| HOOK_ID arion::HooksManager::curr_id = 1 |
|
private |
ID of the next hook to be created.
◆ free_hook_ids
| std::stack<HOOK_ID> arion::HooksManager::free_hook_ids |
|
private |
A stack of hook IDs that got deleted and that can be reused.
◆ hooks
A map identifying an Arion hook given its ID.
◆ uc
| uc_engine* arion::HooksManager::uc |
|
private |
The Unicorn engine associated with this instance.
The documentation for this class was generated from the following file: