Arion 1.0.2-alpha
A high-performance C++ framework for emulating executable binaries.
 
Loading...
Searching...
No Matches
arion::SignalManager Class Reference

This class manages signal handling within an Arion emulation session. More...

#include <signal_manager.hpp>

Public Member Functions

 SignalManager (std::weak_ptr< Arion > arion)
 
void print_signal (std::shared_ptr< Arion > arion, std::string sig_name)
 
void handle_signal (pid_t source_pid, int signo)
 
void wait_for_sig (pid_t target_tid, pid_t source_pid, ADDR wait_status_addr)
 
bool has_sighandler (int signo)
 
std::shared_ptr< struct arion_lnx_type::ksigactionget_sighandler (int signo)
 
void set_sighandler (int signo, std::shared_ptr< struct arion_lnx_type::ksigaction > sighandler)
 
bool sigreturn ()
 

Static Public Member Functions

static std::unique_ptr< SignalManagerinitialize (std::weak_ptr< Arion > arion)
 

Private Member Functions

bool handle_sighandler (pid_t source_pid, int signo)
 
void handle_sigchld (pid_t source_pid)
 

Static Private Member Functions

static void intr_hook (std::shared_ptr< Arion > arion, uint32_t intno, void *user_data)
 
static bool invalid_memory_hook (std::shared_ptr< Arion > arion, uc_mem_type access, uint64_t addr, int size, int64_t val, void *user_data)
 
static bool invalid_insn_hook (std::shared_ptr< Arion > arion, void *user_data)
 

Private Attributes

std::weak_ptr< Arionarion
 The Arion instance associated with this instance.
 
std::map< int, std::shared_ptr< struct arion_lnx_type::ksigaction > > sighandlers
 A map identifying a ksigaction structure given its associated signal number.
 
std::map< pid_t, pid_t > sigwait_list
 A map identifying a process (ID) given the process (ID) it is waiting for.
 
std::unique_ptr< std::map< REG, RVAL > > ucontext_regs
 A map identifying a saved register value to be restored, given the Unicorn register it is associated to.
 

Static Private Attributes

static std::map< int, std::string > signals
 A map identifying a signal description string given its signal number.
 

Detailed Description

This class manages signal handling within an Arion emulation session.

Constructor & Destructor Documentation

◆ SignalManager()

arion::SignalManager::SignalManager ( std::weak_ptr< Arion arion)

Builder for SignalManager instances.

Parameters
[in]arionThe Arion instance associated with this instance.

Member Function Documentation

◆ get_sighandler()

std::shared_ptr< struct arion_lnx_type::ksigaction > arion::SignalManager::get_sighandler ( int  signo)

Retrieves a sighandler from a given signal.

Parameters
[in]signoThe signal number.
Returns
The sighandler.

◆ handle_sigchld()

void arion::SignalManager::handle_sigchld ( pid_t  source_pid)
private

Handles the specific case of SIGCHLD signals where a process waiting for another can be resumed.

Parameters
[in]source_pidThe Process ID that generated the SIGCHLD signal.

◆ handle_sighandler()

bool arion::SignalManager::handle_sighandler ( pid_t  source_pid,
int  signo 
)
private

If a sighandler is associated with a given signal for a given process, triggers its execution.

Parameters
[in]source_pidThe Process ID that generated the signal.
[in]signoThe signal number.
Returns
True if a sighandler was found and executed for the given parameters.

◆ handle_signal()

void arion::SignalManager::handle_signal ( pid_t  source_pid,
int  signo 
)

Processes a signal after it has been triggered by a given process.

Parameters
[in]source_pidThe process that triggered the signal.
[in]signoThe signal number.

◆ has_sighandler()

bool arion::SignalManager::has_sighandler ( int  signo)

Checks whether a given signal has a sighandler being attached.

Parameters
[in]signoThe signal number.
Returns
True if the given signal has a sighandler being attached.

◆ initialize()

static std::unique_ptr< SignalManager > arion::SignalManager::initialize ( std::weak_ptr< Arion arion)
static

Instanciates and initializes new SignalManager objects with some parameters.

Parameters
[in]arionThe Arion instance associated with this instance.
Returns
A new SignalManager instance.

◆ intr_hook()

static void arion::SignalManager::intr_hook ( std::shared_ptr< Arion arion,
uint32_t  intno,
void *  user_data 
)
staticprivate

A hook callback which is triggered when an interrupt occurs.

Parameters
[in]arionThe Arion instance that triggered the hook.
[in]intnoThe interrupt number.
[in]user_dataOptional user-defined data passed to the hook.

◆ invalid_insn_hook()

static bool arion::SignalManager::invalid_insn_hook ( std::shared_ptr< Arion arion,
void *  user_data 
)
staticprivate

A hook callback which is triggered when an invalid instruction gets fetched.

Parameters
[in]arionThe Arion instance that triggered the hook.
[in]user_dataOptional user-defined data passed to the hook.
Returns
True if the hook handled the access and default behavior should be suppressed.

◆ invalid_memory_hook()

static bool arion::SignalManager::invalid_memory_hook ( std::shared_ptr< Arion arion,
uc_mem_type  access,
uint64_t  addr,
int  size,
int64_t  val,
void *  user_data 
)
staticprivate

A hook callback which is triggered when a memory access violation occurs.

Parameters
[in]arionThe Arion instance that triggered the hook.
[in]accessType of memory access (e.g., UC_MEM_READ, UC_MEM_WRITE, UC_MEM_FETCH).
[in]addrMemory address being accessed.
[in]sizeSize of the memory access.
[in]valValue attempted to be written.
[in]user_dataOptional user-defined data passed to the hook.
Returns
True if the hook handled the access and default behavior should be suppressed.

◆ print_signal()

void arion::SignalManager::print_signal ( std::shared_ptr< Arion arion,
std::string  sig_name 
)

Logs a signal given its name.

Parameters
[in]arionThe Arion instance which triggered the signal.
[in]sig_nameName of the signal.

◆ set_sighandler()

void arion::SignalManager::set_sighandler ( int  signo,
std::shared_ptr< struct arion_lnx_type::ksigaction sighandler 
)

Associates a sighandler to a given signal.

Parameters
[in]signoThe signal number.
[in]sighandlerThe sighandler.

◆ sigreturn()

bool arion::SignalManager::sigreturn ( )

Returns from a sighandler by restoring context.

Returns
True if a context could be restored.

◆ wait_for_sig()

void arion::SignalManager::wait_for_sig ( pid_t  target_tid,
pid_t  source_pid,
ADDR  wait_status_addr 
)

Sets a thread in a paused state, waiting for a given process to trigger a signal before resuming its execution.

Parameters
[in]target_tidThe thread waiting for a given process.
[in]source_pidThe process which must trigger a signal to resume the thread execution.
[in]wait_status_addrThe address where to store the exit status of the signaled process.

Member Data Documentation

◆ arion

std::weak_ptr<Arion> arion::SignalManager::arion
private

The Arion instance associated with this instance.

◆ sighandlers

std::map<int, std::shared_ptr<struct arion_lnx_type::ksigaction> > arion::SignalManager::sighandlers
private

A map identifying a ksigaction structure given its associated signal number.

◆ signals

std::map<int, std::string> arion::SignalManager::signals
staticprivate

A map identifying a signal description string given its signal number.

◆ sigwait_list

std::map<pid_t, pid_t> arion::SignalManager::sigwait_list
private

A map identifying a process (ID) given the process (ID) it is waiting for.

◆ ucontext_regs

std::unique_ptr<std::map<REG, RVAL> > arion::SignalManager::ucontext_regs
private

A map identifying a saved register value to be restored, given the Unicorn register it is associated to.


The documentation for this class was generated from the following file: