plugify 1.2.8
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | List of all members
plugify::JitCallback Class Reference

Class to create callback objects, that can be passed to functions as callback function pointers. In other words, a pointer to the callback object can be "called", directly. A generic callback handler invoked by this object then allows iterating dynamically over the arguments once called back. More...

#include <callback.hpp>

Public Types

using CallbackHandler = void(*)(const Method *method, MemAddr data, uint64_t *params, size_t count, void *ret)
 CallbackHandler is a function pointer type for generic callback invocation. The params argument can be accessed safely and conveniently using ParametersSpan, and the ret argument (return value storage) can be managed using ReturnSlot. These helper classes provide type-safe and ergonomic access to arguments and return values.
 
using HiddenParam = bool(*)(ValueType)
 HiddenParam is a predicate function pointer to determine if a ValueType should be passed as a hidden parameter. Use for return structs on x86 and arm arch.
 

Public Member Functions

 JitCallback ()
 Constructor.
 
 JitCallback (const JitCallback &other)=delete
 Copy constructor.
 
 JitCallback (JitCallback &&other) noexcept
 Move constructor.
 
 ~JitCallback ()
 Destructor.
 
MemAddr GetJitFunc (const Signature &signature, const Method *method, CallbackHandler callback, MemAddr data, bool hidden)
 Generates a JIT-compiled callback function based on the provided raw signature.
 
MemAddr GetJitFunc (const Method &method, CallbackHandler callback, MemAddr data=nullptr, HiddenParam hidden=&ValueUtils::IsHiddenParam)
 Generates a callback function matching the specified method signature.
 
MemAddr GetFunction () const noexcept
 Get a dynamically created function.
 
MemAddr GetUserData () const noexcept
 Get the user data associated with the object.
 
std::string_view GetError () noexcept
 Get the error message, if any.
 
JitCallbackoperator= (const JitCallback &other)=delete
 Copy assignment operator for JitCallback.
 
JitCallbackoperator= (JitCallback &&other) noexcept
 Move assignment operator for JitCall.
 

Public Attributes

PLUGIFY_ACCESS : struct Impl
 

Detailed Description

Class to create callback objects, that can be passed to functions as callback function pointers. In other words, a pointer to the callback object can be "called", directly. A generic callback handler invoked by this object then allows iterating dynamically over the arguments once called back.

Definition at line 24 of file callback.hpp.

Member Typedef Documentation

◆ CallbackHandler

using plugify::JitCallback::CallbackHandler = void (*)( const Method* method, MemAddr data, uint64_t* params, size_t count, void* ret )

CallbackHandler is a function pointer type for generic callback invocation. The params argument can be accessed safely and conveniently using ParametersSpan, and the ret argument (return value storage) can be managed using ReturnSlot. These helper classes provide type-safe and ergonomic access to arguments and return values.

Definition at line 55 of file callback.hpp.

◆ HiddenParam

using plugify::JitCallback::HiddenParam = bool (*)(ValueType)

HiddenParam is a predicate function pointer to determine if a ValueType should be passed as a hidden parameter. Use for return structs on x86 and arm arch.

Definition at line 67 of file callback.hpp.

Constructor & Destructor Documentation

◆ JitCallback() [1/2]

plugify::JitCallback::JitCallback ( const JitCallback other)
delete

Copy constructor.

Parameters
otherAnother instance of JitCallback.

◆ JitCallback() [2/2]

plugify::JitCallback::JitCallback ( JitCallback &&  other)
noexcept

Move constructor.

Parameters
otherAnother instance of JitCallback.

Member Function Documentation

◆ GetError()

std::string_view plugify::JitCallback::GetError ( )
noexcept

Get the error message, if any.

Returns
Error message.

◆ GetFunction()

MemAddr plugify::JitCallback::GetFunction ( ) const
noexcept

Get a dynamically created function.

Returns
Pointer to the already generated function.
Note
The returned pointer can be nullptr if function is not generate.

◆ GetJitFunc() [1/2]

MemAddr plugify::JitCallback::GetJitFunc ( const Method method,
CallbackHandler  callback,
MemAddr  data = nullptr,
HiddenParam  hidden = &ValueUtils::IsHiddenParam 
)

Generates a callback function matching the specified method signature.

Parameters
methodThe method descriptor defining the function signature.
callbackPointer to the generic callback handler to invoke.
dataOptional user data passed to the callback handler.
hiddenPredicate to determine if the return value should be passed as a hidden argument.
Returns
Pointer to the generated function, or nullptr if generation fails.

This function creates a JIT-compiled callback based on the provided method, allowing dynamic invocation with runtime argument handling. The callback handler receives arguments and user data as specified. If the hidden predicate returns true, the return value is passed as an additional hidden parameter.

◆ GetJitFunc() [2/2]

MemAddr plugify::JitCallback::GetJitFunc ( const Signature signature,
const Method method,
CallbackHandler  callback,
MemAddr  data,
bool  hidden 
)

Generates a JIT-compiled callback function based on the provided raw signature.

Parameters
signatureThe function signature to use for the generated callback.
methodOptional pointer to a method descriptor for additional context. May be nullptr if not needed.
callbackPointer to the callback handler to invoke.
dataUser data to be passed to the callback handler.
hiddenIf true, the return value will be passed as a hidden argument.
Returns
Pointer to the generated function, or nullptr if generation fails.

The method pointer can be nullptr and is provided for context in addition to user data, as it is common to access both in callback scenarios.

◆ GetUserData()

MemAddr plugify::JitCallback::GetUserData ( ) const
noexcept

Get the user data associated with the object.

This function returns a pointer to the user data associated with the object.

Returns
A void pointer to the user data.
Note
The returned pointer can be nullptr if no user data is set.

◆ operator=() [1/2]

JitCallback & plugify::JitCallback::operator= ( const JitCallback other)
delete

Copy assignment operator for JitCallback.

Parameters
otherThe other JitCallback instance to copy from.
Returns
A reference to this instance after copying.

◆ operator=() [2/2]

JitCallback & plugify::JitCallback::operator= ( JitCallback &&  other)
noexcept

Move assignment operator for JitCall.

Parameters
otherThe other JitCallback instance to move from.
Returns
A reference to this instance after moving.
Note
This operator is marked noexcept to indicate it does not throw exceptions.

Member Data Documentation

◆ __pad0__

PLUGIFY_ACCESS plugify::JitCallback::__pad0__

Definition at line 148 of file callback.hpp.


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