Class MemoryHelper
A simple class that provides read/write access to arbitrary memory.
Assembly: Dalamud.dll
View Source
public static class MemoryHelper
Methods
Cast<T>(nint)
Casts the given memory address as the reference to the live object.
View Source
public static ref T Cast<T>(nint memoryAddress) where T : unmanaged
Returns
<T>
: The reference to the live object.
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address. |
Type Parameters
Name | Description |
---|---|
T | The unmanaged type. |
Cast<T>(nint, int)
Casts the given memory address as the span of the live object(s).
View Source
public static Span<T> Cast<T>(nint memoryAddress, int length) where T : unmanaged
Returns
System.Span<<T>>
: The span containing reference to the live object(s).
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address. |
System.Int32 | length | The number of items. |
Type Parameters
Name | Description |
---|---|
T | The unmanaged type. |
CastNullTerminated<T>(nint, int)
Casts the given memory address as the span of the live object(s), until it encounters a zero.
View Source
public static Span<T> CastNullTerminated<T>(nint memoryAddress, int maxLength = 2147483647) where T : unmanaged, IEquatable<T>
Returns
System.Span<<T>>
: The span containing reference to the live object(s).
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address. |
System.Int32 | maxLength | The maximum number of items. |
Type Parameters
Name | Description |
---|---|
T | The unmanaged type. |
Read<T>(nint)
Reads a generic type from a specified memory address.
View Source
public static T Read<T>(nint memoryAddress) where T : unmanaged
Returns
<T>
: The read in struct.
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to read from. |
Type Parameters
Name | Description |
---|---|
T | An individual struct type of a class with an explicit StructLayout.LayoutKind attribute. |
Read<T>(nint, bool)
Reads a generic type from a specified memory address.
View Source
public static T Read<T>(nint memoryAddress, bool marshal)
Returns
<T>
: The read in struct.
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to read from. |
System.Boolean | marshal | Set this to true to enable struct marshalling. |
Type Parameters
Name | Description |
---|---|
T | An individual struct type of a class with an explicit StructLayout.LayoutKind attribute. |
ReadRaw(nint, int)
Reads a byte array from a specified memory address.
View Source
public static byte[] ReadRaw(nint memoryAddress, int length)
Returns
System.Byte[]
: The read in byte array.
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to read from. |
System.Int32 | length | The amount of bytes to read starting from the memoryAddress. |
Read<T>(nint, int)
Reads a generic type array from a specified memory address.
View Source
public static T[] Read<T>(nint memoryAddress, int arrayLength) where T : unmanaged
Returns
<T>[]
: The read in struct array.
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to read from. |
System.Int32 | arrayLength | The amount of array items to read. |
Type Parameters
Name | Description |
---|---|
T | An individual struct type of a class with an explicit StructLayout.LayoutKind attribute. |
Read<T>(nint, int, bool)
Reads a generic type array from a specified memory address.
View Source
public static T[] Read<T>(nint memoryAddress, int arrayLength, bool marshal)
Returns
<T>[]
: The read in struct array.
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to read from. |
System.Int32 | arrayLength | The amount of array items to read. |
System.Boolean | marshal | Set this to true to enable struct marshalling. |
Type Parameters
Name | Description |
---|---|
T | An individual struct type of a class with an explicit StructLayout.LayoutKind attribute. |
ReadRawNullTerminated(nint)
Reads a null-terminated byte array from a specified memory address.
View Source
public static byte[] ReadRawNullTerminated(nint memoryAddress)
Returns
System.Byte[]
: The read in byte array.
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to read from. |
Read<T>(nint, out T)
Reads a generic type from a specified memory address.
View Source
public static void Read<T>(nint memoryAddress, out T value) where T : unmanaged
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to read from. |
<T> | value | Local variable to receive the read in struct. |
Type Parameters
Name | Description |
---|---|
T | An individual struct type of a class with an explicit StructLayout.LayoutKind attribute. |
Read<T>(nint, out T, bool)
Reads a generic type from a specified memory address.
View Source
public static void Read<T>(nint memoryAddress, out T value, bool marshal)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to read from. |
<T> | value | Local variable to receive the read in struct. |
System.Boolean | marshal | Set this to true to enable struct marshalling. |
Type Parameters
Name | Description |
---|---|
T | An individual struct type of a class with an explicit StructLayout.LayoutKind attribute. |
ReadRaw(nint, int, out byte[])
Reads raw data from a specified memory address.
View Source
public static void ReadRaw(nint memoryAddress, int length, out byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to read from. |
System.Int32 | length | The amount of bytes to read starting from the memoryAddress. |
System.Byte[] | value | Local variable to receive the read in bytes. |
Read<T>(nint, int, out T[])
Reads a generic type array from a specified memory address.
View Source
public static void Read<T>(nint memoryAddress, int arrayLength, out T[] value) where T : unmanaged
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to read from. |
System.Int32 | arrayLength | The amount of array items to read. |
<T>[] | value | The read in struct array. |
Type Parameters
Name | Description |
---|---|
T | An individual struct type of a class with an explicit StructLayout.LayoutKind attribute. |
Read<T>(nint, int, bool, out T[])
Reads a generic type array from a specified memory address.
View Source
public static void Read<T>(nint memoryAddress, int arrayLength, bool marshal, out T[] value)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to read from. |
System.Int32 | arrayLength | The amount of array items to read. |
System.Boolean | marshal | Set this to true to enable struct marshalling. |
<T>[] | value | The read in struct array. |
Type Parameters
Name | Description |
---|---|
T | An individual struct type of a class with an explicit StructLayout.LayoutKind attribute. |
EqualsZeroTerminatedString(ReadOnlySpan<char>, nint, Encoding?, int)
Compares if the given char span equals to the null-terminated string at <code class="paramref">memoryAddress</code>.
View Source
public static bool EqualsZeroTerminatedString(ReadOnlySpan<char> charSpan, nint memoryAddress, Encoding? encoding = null, int maxLength = 2147483647)
Returns
System.Boolean
: Whether they are equal.
Parameters
Type | Name | Description |
---|---|---|
System.ReadOnlySpan<System.Char> | charSpan | The character span. |
System.IntPtr | memoryAddress | The address of null-terminated string. |
System.Text.Encoding | encoding | The encoding of the null-terminated string. |
System.Int32 | maxLength | The maximum length of the null-terminated string. |
ReadStringNullTerminated(nint)
Read a UTF-8 encoded string from a specified memory address.
View Source
public static string ReadStringNullTerminated(nint memoryAddress)
Returns
System.String
: The read in string.
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to read from. |
ReadStringNullTerminated(nint, Encoding)
Read a string with the given encoding from a specified memory address.
View Source
public static string ReadStringNullTerminated(nint memoryAddress, Encoding encoding)
Returns
System.String
: The read in string.
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to read from. |
System.Text.Encoding | encoding | The encoding to use to decode the string. |
ReadString(nint, int)
Read a UTF-8 encoded string from a specified memory address.
View Source
public static string ReadString(nint memoryAddress, int maxLength)
Returns
System.String
: The read in string.
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to read from. |
System.Int32 | maxLength | The maximum number of bytes to read. |
Note that this is NOT the maximum length of the returned string. |
ReadString(nint, Encoding, int)
Read a string with the given encoding from a specified memory address.
View Source
public static string ReadString(nint memoryAddress, Encoding encoding, int maxLength)
Returns
System.String
: The read in string.
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to read from. |
System.Text.Encoding | encoding | The encoding to use to decode the string. |
System.Int32 | maxLength | The maximum number of bytes to read. |
Note that this is NOT the maximum length of the returned string. |
ReadSeStringNullTerminated(nint)
Read a null-terminated SeString from a specified memory address.
View Source
public static SeString ReadSeStringNullTerminated(nint memoryAddress)
Returns
Dalamud.Game.Text.SeStringHandling.SeString: The read in string.
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to read from. |
ReadSeString(nint, int)
Read an SeString from a specified memory address.
View Source
public static SeString ReadSeString(nint memoryAddress, int maxLength)
Returns
Dalamud.Game.Text.SeStringHandling.SeString: The read in string.
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to read from. |
System.Int32 | maxLength | The maximum length of the string. |
ReadSeString(Utf8String*)
Read an SeString from a specified Utf8String structure.
View Source
public static SeString ReadSeString(Utf8String* utf8String)
Returns
Dalamud.Game.Text.SeStringHandling.SeString: The read in string.
Parameters
Type | Name | Description |
---|---|---|
FFXIVClientStructs.FFXIV.Client.System.String.Utf8String* | utf8String | The memory address to read from. |
ReadSeStringAsString(out bool, nint, int, bool, string)
Reads an SeString from a specified memory address, and extracts the outermost string.
If the SeString is malformed, behavior is undefined.
View Source
public static string ReadSeStringAsString(out bool containsNonRepresentedPayload, nint memoryAddress, int maxLength = 2147483647, bool stopOnFirstNonRepresentedPayload = false, string nonRepresentedPayloadReplacement = "*")
Returns
System.String
: The read in string.
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | containsNonRepresentedPayload | Whether the SeString contained a non-represented payload. |
System.IntPtr | memoryAddress | The memory address to read from. |
System.Int32 | maxLength | The maximum length of the string. |
System.Boolean | stopOnFirstNonRepresentedPayload | Stop reading on encountering the first non-represented payload. |
What payloads are represented via this function may change. |
| System.String
| nonRepresentedPayloadReplacement | Replacement for non-represented payloads. |
ReadStringNullTerminated(nint, out string)
Read a UTF-8 encoded string from a specified memory address.
View Source
public static void ReadStringNullTerminated(nint memoryAddress, out string value)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to read from. |
System.String | value | The read in string. |
ReadStringNullTerminated(nint, Encoding, out string)
Read a string with the given encoding from a specified memory address.
View Source
public static void ReadStringNullTerminated(nint memoryAddress, Encoding encoding, out string value)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to read from. |
System.Text.Encoding | encoding | The encoding to use to decode the string. |
System.String | value | The read in string. |
ReadString(nint, out string, int)
Read a UTF-8 encoded string from a specified memory address.
View Source
public static void ReadString(nint memoryAddress, out string value, int maxLength)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to read from. |
System.String | value | The read in string. |
System.Int32 | maxLength | The maximum length of the string. |
ReadString(nint, Encoding, int, out string)
Read a string with the given encoding from a specified memory address.
View Source
public static void ReadString(nint memoryAddress, Encoding encoding, int maxLength, out string value)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to read from. |
System.Text.Encoding | encoding | The encoding to use to decode the string. |
System.Int32 | maxLength | The maximum length of the string. |
System.String | value | The read in string. |
ReadSeStringNullTerminated(nint, out SeString)
Read a null-terminated SeString from a specified memory address.
View Source
public static void ReadSeStringNullTerminated(nint memoryAddress, out SeString value)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to read from. |
Dalamud.Game.Text.SeStringHandling.SeString | value | The read in SeString. |
ReadSeString(nint, int, out SeString)
Read an SeString from a specified memory address.
View Source
public static void ReadSeString(nint memoryAddress, int maxLength, out SeString value)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to read from. |
System.Int32 | maxLength | The maximum length of the string. |
Dalamud.Game.Text.SeStringHandling.SeString | value | The read in SeString. |
ReadSeString(Utf8String*, out SeString)
Read an SeString from a specified Utf8String structure.
View Source
public static void ReadSeString(Utf8String* utf8String, out SeString value)
Parameters
Type | Name | Description |
---|---|---|
FFXIVClientStructs.FFXIV.Client.System.String.Utf8String* | utf8String | The memory address to read from. |
Dalamud.Game.Text.SeStringHandling.SeString | value | The read in string. |
Write<T>(nint, T)
Writes a generic type to a specified memory address.
View Source
public static void Write<T>(nint memoryAddress, T item) where T : unmanaged
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to read from. |
<T> | item | The item to write to the address. |
Type Parameters
Name | Description |
---|---|
T | An individual struct type of a class with an explicit StructLayout.LayoutKind attribute. |
Write<T>(nint, T, bool)
Writes a generic type to a specified memory address.
View Source
public static void Write<T>(nint memoryAddress, T item, bool marshal)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to read from. |
<T> | item | The item to write to the address. |
System.Boolean | marshal | Set this to true to enable struct marshalling. |
Type Parameters
Name | Description |
---|---|
T | An individual struct type of a class with an explicit StructLayout.LayoutKind attribute. |
WriteRaw(nint, byte[])
Writes raw data to a specified memory address.
View Source
public static void WriteRaw(nint memoryAddress, byte[] data)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to read from. |
System.Byte[] | data | The bytes to write to memoryAddress. |
Write<T>(nint, T[])
Writes a generic type array to a specified memory address.
View Source
public static void Write<T>(nint memoryAddress, T[] items) where T : unmanaged
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to write to. |
<T>[] | items | The array of items to write to the address. |
Type Parameters
Name | Description |
---|---|
T | An individual struct type of a class with an explicit StructLayout.LayoutKind attribute. |
Write<T>(nint, T[], bool)
Writes a generic type array to a specified memory address.
View Source
public static void Write<T>(nint memoryAddress, T[] items, bool marshal)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to write to. |
<T>[] | items | The array of items to write to the address. |
System.Boolean | marshal | Set this to true to enable struct marshalling. |
Type Parameters
Name | Description |
---|---|
T | An individual struct type of a class with an explicit StructLayout.LayoutKind attribute. |
WriteString(nint, string?)
Write a UTF-8 encoded string to a specified memory address.
View Source
public static void WriteString(nint memoryAddress, string? value)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to write to. |
System.String | value | The string to write. |
WriteString(nint, string?, Encoding)
Write a string with the given encoding to a specified memory address.
View Source
public static void WriteString(nint memoryAddress, string? value, Encoding encoding)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to write to. |
System.String | value | The string to write. |
System.Text.Encoding | encoding | The encoding to use. |
WriteSeString(nint, SeString?)
Write an SeString to a specified memory address.
View Source
public static void WriteSeString(nint memoryAddress, SeString? value)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to write to. |
Dalamud.Game.Text.SeStringHandling.SeString | value | The SeString to write. |
Allocate(int)
Allocates fixed size of memory inside the target memory source via Windows API calls. Returns the address of newly allocated memory.
View Source
public static nint Allocate(int length)
Returns
System.IntPtr
: Address to the newly allocated memory.
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | length | Amount of bytes to be allocated. |
Allocate(int, out nint)
Allocates fixed size of memory inside the target memory source via Windows API calls. Returns the address of newly allocated memory.
View Source
public static void Allocate(int length, out nint memoryAddress)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | length | Amount of bytes to be allocated. |
System.IntPtr | memoryAddress | Address to the newly allocated memory. |
Free(nint)
Frees memory previously allocated with Allocate via Windows API calls.
View Source
public static bool Free(nint memoryAddress)
Returns
System.Boolean
: True if the operation is successful.
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The address of the memory to free. |
ChangePermission(nint, int, MemoryProtection)
Changes the page permissions for a specified combination of address and length via Windows API calls.
View Source
public static MemoryProtection ChangePermission(nint memoryAddress, int length, MemoryProtection newPermissions)
Returns
Dalamud.Memory.MemoryProtection: The old page permissions.
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address for which to change page permissions for. |
System.Int32 | length | The region size for which to change permissions for. |
Dalamud.Memory.MemoryProtection | newPermissions | The new permissions to set. |
ChangePermission(nint, int, MemoryProtection, out MemoryProtection)
Changes the page permissions for a specified combination of address and length via Windows API calls.
View Source
public static void ChangePermission(nint memoryAddress, int length, MemoryProtection newPermissions, out MemoryProtection oldPermissions)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address for which to change page permissions for. |
System.Int32 | length | The region size for which to change permissions for. |
Dalamud.Memory.MemoryProtection | newPermissions | The new permissions to set. |
Dalamud.Memory.MemoryProtection | oldPermissions | The old page permissions. |
ChangePermission<T>(nint, ref T, MemoryProtection, bool)
Changes the page permissions for a specified combination of address and element from which to deduce size via Windows API calls.
View Source
public static MemoryProtection ChangePermission<T>(nint memoryAddress, ref T baseElement, MemoryProtection newPermissions, bool marshal)
Returns
Dalamud.Memory.MemoryProtection: The old page permissions.
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address for which to change page permissions for. |
<T> | baseElement | The struct element from which the region size to change permissions for will be calculated. |
Dalamud.Memory.MemoryProtection | newPermissions | The new permissions to set. |
System.Boolean | marshal | Set to true to calculate the size of the struct after marshalling instead of before. |
Type Parameters
Name | Description |
---|---|
T | An individual struct type of a class with an explicit StructLayout.LayoutKind attribute. |
ReadProcessMemory(nint, int)
Reads raw data from a specified memory address via Windows API calls. This is noticably slower than Unsafe or Marshal.
View Source
public static byte[] ReadProcessMemory(nint memoryAddress, int length)
Returns
System.Byte[]
: The read in bytes.
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to read from. |
System.Int32 | length | The amount of bytes to read starting from the memoryAddress. |
ReadProcessMemory(nint, int, out byte[])
Reads raw data from a specified memory address via Windows API calls. This is noticably slower than Unsafe or Marshal.
View Source
public static void ReadProcessMemory(nint memoryAddress, int length, out byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to read from. |
System.Int32 | length | The amount of bytes to read starting from the memoryAddress. |
System.Byte[] | value | The read in bytes. |
ReadProcessMemory(nint, ref byte[])
Reads raw data from a specified memory address via Windows API calls. This is noticably slower than Unsafe or Marshal.
View Source
public static void ReadProcessMemory(nint memoryAddress, ref byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to read from. |
System.Byte[] | value | The read in bytes. |
WriteProcessMemory(nint, byte[])
Writes raw data to a specified memory address via Windows API calls. This is noticably slower than Unsafe or Marshal.
View Source
public static void WriteProcessMemory(nint memoryAddress, byte[] data)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | memoryAddress | The memory address to write to. |
System.Byte[] | data | The bytes to write to memoryAddress. |
SizeOf<T>()
Returns the size of a specific primitive or struct type.
View Source
public static int SizeOf<T>()
Returns
System.Int32
: The size of the primitive or struct.##### Type Parameters
Name | Description |
---|---|
T | An individual struct type of a class with an explicit StructLayout.LayoutKind attribute. |
SizeOf<T>(bool)
Returns the size of a specific primitive or struct type.
View Source
public static int SizeOf<T>(bool marshal)
Returns
System.Int32
: The size of the primitive or struct.
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | marshal | If set to true; will return the size of an element after marshalling. |
Type Parameters
Name | Description |
---|---|
T | An individual struct type of a class with an explicit StructLayout.LayoutKind attribute. |
SizeOf<T>(int)
Returns the size of a specific primitive or struct type.
View Source
public static int SizeOf<T>(int elementCount) where T : unmanaged
Returns
System.Int32
: The size of the primitive or struct array.
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | elementCount | The number of array elements present. |
Type Parameters
Name | Description |
---|---|
T | An individual struct type of a class with an explicit StructLayout.LayoutKind attribute. |
SizeOf<T>(int, bool)
Returns the size of a specific primitive or struct type.
View Source
public static int SizeOf<T>(int elementCount, bool marshal)
Returns
System.Int32
: The size of the primitive or struct array.
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | elementCount | The number of array elements present. |
System.Boolean | marshal | If set to true; will return the size of an element after marshalling. |
Type Parameters
Name | Description |
---|---|
T | An individual struct type of a class with an explicit StructLayout.LayoutKind attribute. |
GameAllocateUi(ulong, ulong)
Allocate memory in the game's UI memory space.
View Source
public static nint GameAllocateUi(ulong size, ulong alignment = 0)
Returns
System.IntPtr
: Pointer to the allocated region.
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | size | Amount of bytes to allocate. |
System.UInt64 | alignment | The alignment of the allocation. |
GameAllocateDefault(ulong, ulong)
Allocate memory in the game's default memory space.
View Source
public static nint GameAllocateDefault(ulong size, ulong alignment = 0)
Returns
System.IntPtr
: Pointer to the allocated region.
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | size | Amount of bytes to allocate. |
System.UInt64 | alignment | The alignment of the allocation. |
GameAllocateAnimation(ulong, ulong)
Allocate memory in the game's animation memory space.
View Source
public static nint GameAllocateAnimation(ulong size, ulong alignment = 0)
Returns
System.IntPtr
: Pointer to the allocated region.
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | size | Amount of bytes to allocate. |
System.UInt64 | alignment | The alignment of the allocation. |
GameAllocateApricot(ulong, ulong)
Allocate memory in the game's apricot memory space.
View Source
public static nint GameAllocateApricot(ulong size, ulong alignment = 0)
Returns
System.IntPtr
: Pointer to the allocated region.
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | size | Amount of bytes to allocate. |
System.UInt64 | alignment | The alignment of the allocation. |
GameAllocateSound(ulong, ulong)
Allocate memory in the game's sound memory space.
View Source
public static nint GameAllocateSound(ulong size, ulong alignment = 0)
Returns
System.IntPtr
: Pointer to the allocated region.
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | size | Amount of bytes to allocate. |
System.UInt64 | alignment | The alignment of the allocation. |
GameFree(ref nint, ulong)
Free memory in the game's memory space.
View Source
public static void GameFree(ref nint ptr, ulong size)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | ptr | Position at which the memory to be freed is located. |
System.UInt64 | size | Amount of bytes to free. |
NullTerminate(byte[])
Null-terminate a byte array.
View Source
public static byte[] NullTerminate(this byte[] bytes)
Returns
System.Byte[]
: The terminated byte array.
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | bytes | The byte array to terminate. |