swiftlys2/docs/api/ai/
API Reference Memory

IUnmanagedFunction`1

Interface
Namespace: SwiftlyS2.Shared.Memory · Assembly: SwiftlyS2.CS2.dll
public interface IUnmanagedFunction<TDelegate> where TDelegate : Delegate
View source

Properties

Address

The address of the unmanaged function.

nint Address { get; }
Property Value

Call

The delegate that directly call to the address. Might be hooked by other plugins or core.

TDelegate Call { get; }
Property Value
TDelegate

CallOriginal

The unhooked original function delegate. Call this if you don't want your invocation to be hooked.

TDelegate CallOriginal { get; }
Property Value
TDelegate

Methods

AddHook(Func<Func<TDelegate>, TDelegate>)

Hook a native function at the specified address with a managed callback. The callbackBuilder receives the pointer to the "next" function in the chain (previous callback if any, or the original function pointer if this is the first callback), and must return a delegate matching the native function signature with proper calling convention.

Guid AddHook(Func<Func<TDelegate>, TDelegate> callbackBuilder)
Parameters
  • callbackBuilderFunc<Func<TDelegate>, TDelegate>Builder that receives the next function pointer and returns the managed callback.
Returns
a guid for the hook.

RemoveHook(Guid)

Unhook a hook by its id.

void RemoveHook(Guid id)
Parameters
  • idGuidThe id of the hook to unhook.