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

Manages the emulation and dispatching of Linux system calls. More...

#include <lnx_syscall_manager.hpp>

Public Member Functions

 LinuxSyscallManager (std::weak_ptr< Arion > arion)
 
void process_syscall (std::shared_ptr< Arion > arion)
 
void set_syscall_func (uint64_t sysno, std::shared_ptr< SYSCALL_FUNC > func)
 
void set_syscall_func (std::string name, std::shared_ptr< SYSCALL_FUNC > func)
 
std::shared_ptr< SYSCALL_FUNCget_syscall_func (uint64_t sysno)
 
std::shared_ptr< SYSCALL_FUNCget_syscall_func (std::string name)
 

Static Public Member Functions

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

Private Member Functions

void add_syscall_entry (std::string name, std::shared_ptr< SYSCALL_FUNC > func)
 
template<typename... SignatureArgs>
std::shared_ptr< SYSCALL_FUNCmake_sys_func (std::function< uint64_t(std::shared_ptr< Arion > arion, std::vector< SYS_PARAM > params, bool &cancel)> func, SignatureArgs &&...signature)
 
void init_syscall_funcs ()
 
void print_syscall (std::shared_ptr< Arion > arion, std::string sys_name, std::vector< std::shared_ptr< arion_type::KernelType > > signature, std::vector< SYS_PARAM > func_params, uint64_t syscall_ret)
 

Private Attributes

std::weak_ptr< Arionarion
 Weak pointer to the main Arion instance.
 
std::map< uint64_t, std::shared_ptr< SYSCALL_FUNC > > syscall_funcs
 Map linking the numeric syscall number (sysno) to its emulation function and signature.
 

Detailed Description

Manages the emulation and dispatching of Linux system calls.

Constructor & Destructor Documentation

◆ LinuxSyscallManager()

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

Builder for LinuxSyscallManager instances.

Parameters
[in]arionWeak pointer to the main Arion instance.

Member Function Documentation

◆ add_syscall_entry()

void arion::LinuxSyscallManager::add_syscall_entry ( std::string  name,
std::shared_ptr< SYSCALL_FUNC func 
)
private

Adds an entry to the internal syscall_funcs map, looking up the numeric syscall number by its name.

Parameters
[in]nameThe string name of the syscall (e.g., "sys_read").
[in]funcShared pointer to the syscall function and signature structure.

◆ get_syscall_func() [1/2]

std::shared_ptr< SYSCALL_FUNC > arion::LinuxSyscallManager::get_syscall_func ( std::string  name)

Retrieves the syscall emulation function structure based on its string name.

Parameters
[in]nameThe string name of the syscall.
Returns
Shared pointer to the found SYSCALL_FUNC, or nullptr if not found.

◆ get_syscall_func() [2/2]

std::shared_ptr< SYSCALL_FUNC > arion::LinuxSyscallManager::get_syscall_func ( uint64_t  sysno)

Retrieves the syscall emulation function structure based on its numeric syscall number.

Parameters
[in]sysnoThe numeric syscall number.
Returns
Shared pointer to the found SYSCALL_FUNC, or nullptr if not found.

◆ init_syscall_funcs()

void arion::LinuxSyscallManager::init_syscall_funcs ( )
private

Populates the syscall_funcs map by initializing all known syscall emulation functions.

◆ initialize()

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

Static method to create and initialize a new LinuxSyscallManager instance.

Parameters
[in]arionWeak pointer to the main Arion instance.
Returns
A unique pointer to the initialized manager.

◆ make_sys_func()

template<typename... SignatureArgs>
std::shared_ptr< SYSCALL_FUNC > arion::LinuxSyscallManager::make_sys_func ( std::function< uint64_t(std::shared_ptr< Arion > arion, std::vector< SYS_PARAM > params, bool &cancel)>  func,
SignatureArgs &&...  signature 
)
inlineprivate

Template helper function to easily create a shared pointer to a SYSCALL_FUNC instance, converting a variadic list of KernelType arguments into the signature vector.

Template Parameters
SignatureArgsTypes of the kernel types making up the signature.
Parameters
[in]funcThe system call emulation function.
[in]signatureThe KernelType objects defining the return type and parameter types.
Returns
A shared pointer to the new SYSCALL_FUNC structure.

◆ print_syscall()

void arion::LinuxSyscallManager::print_syscall ( std::shared_ptr< Arion arion,
std::string  sys_name,
std::vector< std::shared_ptr< arion_type::KernelType > >  signature,
std::vector< SYS_PARAM func_params,
uint64_t  syscall_ret 
)
private

Logs the executed syscall, formatting parameters and return value based on the syscall's signature.

Parameters
[in]arionShared pointer to the Arion instance.
[in]sys_nameThe string name of the syscall.
[in]signatureThe type signature of the syscall.
[in]func_paramsThe actual raw parameter values passed to the syscall.
[in]syscall_retThe raw return value of the syscall.

◆ process_syscall()

void arion::LinuxSyscallManager::process_syscall ( std::shared_ptr< Arion arion)

Main entry point for syscall handling: reads registers, looks up the function, executes the handler, and writes the return value. Also handles logic for syscall hooks and canceling/deferring execution based on the cancel boolean.

Parameters
[in]arionShared pointer to the Arion instance.

◆ set_syscall_func() [1/2]

void arion::LinuxSyscallManager::set_syscall_func ( std::string  name,
std::shared_ptr< SYSCALL_FUNC func 
)

Sets a custom syscall emulation function by its string name.

Parameters
[in]nameThe string name of the syscall.
[in]funcShared pointer to the new syscall function structure.

◆ set_syscall_func() [2/2]

void arion::LinuxSyscallManager::set_syscall_func ( uint64_t  sysno,
std::shared_ptr< SYSCALL_FUNC func 
)

Sets a custom syscall emulation function by its numeric syscall number.

Parameters
[in]sysnoThe numeric syscall number.
[in]funcShared pointer to the new syscall function structure.

Member Data Documentation

◆ arion

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

Weak pointer to the main Arion instance.

◆ syscall_funcs

std::map<uint64_t, std::shared_ptr<SYSCALL_FUNC> > arion::LinuxSyscallManager::syscall_funcs
private

Map linking the numeric syscall number (sysno) to its emulation function and signature.


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