Manages the emulation and dispatching of Linux system calls.
More...
#include <lnx_syscall_manager.hpp>
|
| std::weak_ptr< Arion > | arion |
| | 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.
|
| |
Manages the emulation and dispatching of Linux system calls.
◆ LinuxSyscallManager()
| arion::LinuxSyscallManager::LinuxSyscallManager |
( |
std::weak_ptr< Arion > |
arion | ) |
|
◆ 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] | name | The string name of the syscall (e.g., "sys_read"). |
| [in] | func | Shared 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] | name | The 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] | sysno | The 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 method to create and initialize a new LinuxSyscallManager instance.
- Parameters
-
| [in] | arion | Weak 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
-
| SignatureArgs | Types of the kernel types making up the signature. |
- Parameters
-
| [in] | func | The system call emulation function. |
| [in] | signature | The 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] | arion | Shared pointer to the Arion instance. |
| [in] | sys_name | The string name of the syscall. |
| [in] | signature | The type signature of the syscall. |
| [in] | func_params | The actual raw parameter values passed to the syscall. |
| [in] | syscall_ret | The 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] | arion | Shared 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] | name | The string name of the syscall. |
| [in] | func | Shared 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] | sysno | The numeric syscall number. |
| [in] | func | Shared pointer to the new syscall function structure. |
◆ 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: