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)