contur2
Loading...
Searching...
No Matches
contur::SyscallTable Class Reference

Dispatch table mapping SyscallId to handler functions. More...

#include <syscall_table.h>

Public Types

using HandlerFn = std::function<Result<RegisterValue>(std::span<const RegisterValue>, ProcessImage &)>
 Function signature used for syscall handlers.

Public Member Functions

 SyscallTable ()
 ~SyscallTable ()
 SyscallTable (const SyscallTable &)=delete
SyscallTableoperator= (const SyscallTable &)=delete
 SyscallTable (SyscallTable &&) noexcept
SyscallTableoperator= (SyscallTable &&) noexcept
Result< void > registerHandler (SyscallId id, HandlerFn handler)
 Registers/replaces a function handler for syscall id.
Result< void > registerHandler (SyscallId id, ISyscallHandler &handler)
 Registers/replaces an interface-based handler for syscall id.
Result< void > unregisterHandler (SyscallId id)
 Unregisters a handler for syscall id.
Result< RegisterValuedispatch (SyscallId id, std::span< const RegisterValue > args, ProcessImage &caller) const
 Dispatches syscall to registered handler.
bool hasHandler (SyscallId id) const noexcept
 Returns true when id has a registered handler.
std::size_t handlerCount () const noexcept
 Number of registered handlers.

Private Attributes

std::unique_ptr< Impl > impl_

Detailed Description

Dispatch table mapping SyscallId to handler functions.

Definition at line 21 of file syscall_table.h.

Member Typedef Documentation

◆ HandlerFn

using contur::SyscallTable::HandlerFn = std::function<Result<RegisterValue>(std::span<const RegisterValue>, ProcessImage &)>

Function signature used for syscall handlers.

Definition at line 25 of file syscall_table.h.

Constructor & Destructor Documentation

◆ SyscallTable() [1/3]

contur::SyscallTable::SyscallTable ( )

◆ ~SyscallTable()

contur::SyscallTable::~SyscallTable ( )

◆ SyscallTable() [2/3]

contur::SyscallTable::SyscallTable ( const SyscallTable & )
delete

◆ SyscallTable() [3/3]

contur::SyscallTable::SyscallTable ( SyscallTable && )
noexcept

Member Function Documentation

◆ dispatch()

Result< RegisterValue > contur::SyscallTable::dispatch ( SyscallId id,
std::span< const RegisterValue > args,
ProcessImage & caller ) const
nodiscard

Dispatches syscall to registered handler.

Returns
Handler result or NotFound when no handler is registered.

◆ handlerCount()

std::size_t contur::SyscallTable::handlerCount ( ) const
nodiscardnoexcept

Number of registered handlers.

◆ hasHandler()

bool contur::SyscallTable::hasHandler ( SyscallId id) const
nodiscardnoexcept

Returns true when id has a registered handler.

◆ operator=() [1/2]

SyscallTable & contur::SyscallTable::operator= ( const SyscallTable & )
delete

◆ operator=() [2/2]

SyscallTable & contur::SyscallTable::operator= ( SyscallTable && )
noexcept

◆ registerHandler() [1/2]

Result< void > contur::SyscallTable::registerHandler ( SyscallId id,
HandlerFn handler )
nodiscard

Registers/replaces a function handler for syscall id.

Returns
Ok on success, InvalidArgument for empty function.

◆ registerHandler() [2/2]

Result< void > contur::SyscallTable::registerHandler ( SyscallId id,
ISyscallHandler & handler )
nodiscard

Registers/replaces an interface-based handler for syscall id.

The table stores a lightweight wrapper that forwards to handler.

◆ unregisterHandler()

Result< void > contur::SyscallTable::unregisterHandler ( SyscallId id)
nodiscard

Unregisters a handler for syscall id.

Returns
Ok on success or NotFound.

Member Data Documentation

◆ impl_

std::unique_ptr<Impl> contur::SyscallTable::impl_
private

Definition at line 61 of file syscall_table.h.


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