swiftlys2/docs/api/ai/
API Reference Memory

IMemoryService

Interface
Namespace: SwiftlyS2.Shared.Memory · Assembly: SwiftlyS2.CS2.dll
public interface IMemoryService
View source

Methods

Alloc(ulong)

Allocate a block of memory.

nint Alloc(ulong size)
Parameters
  • sizeulongThe size of the memory block to allocate.
Returns
The address of the allocated memory block.

Free(nint)

Free a block of memory.

void Free(nint pointer)
Parameters
  • pointernintThe address of the memory block to free.

GetAddressBySignature(string, string)

Get the address of a ida-style signature.

nint? GetAddressBySignature(string library, string signature)
Parameters
  • librarystringThe library of that signature belongs to.
  • signaturestringThe signature of the function.
Returns
The address of the function. Return null if not found.

GetInterfaceByName(string)

Get the address of an valve or swiftly native interface by its name.

nint? GetInterfaceByName(string name)
Parameters
  • namestringThe name of the interface.
Returns
The address of the interface. Return null if not found.

GetObjectPtrVtableName(nint)

Get the vtable name of an object pointer.

string? GetObjectPtrVtableName(nint address)
Parameters
  • addressnintThe address of the object pointer.
Returns
The vtable name. Return null if not found.

GetUnmanagedFunctionByAddress<TDelegate>(nint)

Get an unmanaged function by its address.

IUnmanagedFunction<TDelegate> GetUnmanagedFunctionByAddress<TDelegate>(nint address) where TDelegate : Delegate
Parameters
  • addressnintThe address of the unmanaged function.
Returns
IUnmanagedFunction<TDelegate>
The unmanaged function.

GetUnmanagedFunctionByVTable<TDelegate>(nint, int)

Get an unmanaged function by its vtable address and index.

IUnmanagedFunction<TDelegate> GetUnmanagedFunctionByVTable<TDelegate>(nint pVTable, int index) where TDelegate : Delegate
Parameters
  • pVTablenintThe address of the vtable.
  • indexintThe index of the function in the vtable.
Returns
IUnmanagedFunction<TDelegate>
The unmanaged function.

GetUnmanagedMemoryByAddress(nint)

Get an unmanaged memory block by its address.

IUnmanagedMemory GetUnmanagedMemoryByAddress(nint address)
Parameters
  • addressnintThe address from which to create the Unmanaged Memory wrapper.

GetVTableAddress(string, string)

Get the address of a vtable by its name.

nint? GetVTableAddress(string library, string vtableName)
Parameters
  • librarystringThe library of that vtable belongs to.
  • vtableNamestringThe name of the vtable.
Returns
The address of the vtable. Return null if not found.

ObjectPtrHasBaseClass(nint, string)

Check if an object pointer has a base class.

bool ObjectPtrHasBaseClass(nint address, string baseClassName)
Parameters
  • addressnintThe address of the object pointer.
  • baseClassNamestringThe name of the base class.
Returns
True if the object pointer has the base class, false otherwise.

ObjectPtrHasVtable(nint)

Check if an object pointer has a vtable.

bool ObjectPtrHasVtable(nint address)
Parameters
  • addressnintThe address of the object pointer.
Returns
True if the object pointer has a vtable, false otherwise.

Resize(nint, ulong)

Resize a block of memory.

nint Resize(nint pointer, ulong newSize)
Parameters
  • pointernintThe address of the memory block to resize.
  • newSizeulongThe new size of the memory block.
Returns
The address of the resized memory block.

ResolveXrefAddress(nint)

Resolve the address of a xref signature.

nint ResolveXrefAddress(nint xrefAddress)
Parameters
  • xrefAddressnintThe address of the xref.
Returns
The resolved address.

ToSchemaClass<T>(nint)

Convert a raw address to a schema class.

T ToSchemaClass<T>(nint address) where T : class, ISchemaClass<T>
Parameters
  • addressnintThe address of the schema class.
Returns
T
The schema class.

ToServerSideClient(nint)

Convert a raw address to a server-side client.

IServerSideClient ToServerSideClient(nint address)
Parameters
  • addressnintThe address of the server-side client.
Returns
The server-side client.