Show / Hide Table of Contents

# Class MemoryHelper

A simple class that provides read/write access to arbitrary memory.

##### Inheritance

System.Object
MemoryHelper

##### Inherited Members

System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()

###### Namespace: Dalamud.Memory

###### Assembly: Dalamud.dll

##### Syntax

    public static class MemoryHelper

### Methods

| Improve this Doc View Source

#### Allocate(Int32)

Allocates fixed size of memory inside the target memory source via Windows API calls. Returns the address of newly allocated memory.

##### Declaration

    public static IntPtr Allocate(int length)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Int32 | length | Amount of bytes to be allocated.

##### Returns

Type | Description
--- | ---
System.IntPtr | Address to the newly allocated memory.

| Improve this Doc View Source

#### Allocate(Int32, out IntPtr)

Allocates fixed size of memory inside the target memory source via Windows API calls. Returns the address of newly allocated memory.

##### Declaration

    public static void Allocate(int length, out IntPtr memoryAddress)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Int32 | length | Amount of bytes to be allocated.
System.IntPtr | memoryAddress | Address to the newly allocated memory.

| Improve this Doc View Source

#### ChangePermission(IntPtr, Int32, MemoryProtection)

Changes the page permissions for a specified combination of address and length via Windows API calls.

##### Declaration

    public static MemoryProtection ChangePermission(IntPtr memoryAddress, int length, MemoryProtection newPermissions)

##### 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.
MemoryProtection | newPermissions | The new permissions to set.

##### Returns

Type | Description
--- | ---
MemoryProtection | The old page permissions.

| Improve this Doc View Source

#### ChangePermission(IntPtr, Int32, MemoryProtection, out MemoryProtection)

Changes the page permissions for a specified combination of address and length via Windows API calls.

##### Declaration

    public static void ChangePermission(IntPtr 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.
MemoryProtection | newPermissions | The new permissions to set.
MemoryProtection | oldPermissions | The old page permissions.

| Improve this Doc View Source

#### ChangePermission<T>(IntPtr, ref T, MemoryProtection, Boolean)

Changes the page permissions for a specified combination of address and element from which to deduce size via Windows API calls.

##### Declaration

    public static MemoryProtection ChangePermission<T>(IntPtr memoryAddress, ref T baseElement, MemoryProtection newPermissions, bool marshal)

##### 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.
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.

##### Returns

Type | Description
--- | ---
MemoryProtection | The old page permissions.

##### Type Parameters

Name | Description
--- | ---
T | An individual struct type of a class with an explicit StructLayout.LayoutKind attribute.

| Improve this Doc View Source

#### Free(IntPtr)

Frees memory previously allocated with Allocate via Windows API calls.

##### Declaration

    public static bool Free(IntPtr memoryAddress)

##### Parameters

Type | Name | Description
--- | --- | ---
System.IntPtr | memoryAddress | The address of the memory to free.

##### Returns

Type | Description
--- | ---
System.Boolean | True if the operation is successful.

| Improve this Doc View Source

#### GameAllocateAnimation(UInt64, UInt64)

Allocate memory in the game's animation memory space.

##### Declaration

    public static IntPtr GameAllocateAnimation(ulong size, ulong alignment = 0UL)

##### Parameters

Type | Name | Description
--- | --- | ---
System.UInt64 | size | Amount of bytes to allocate.
System.UInt64 | alignment | The alignment of the allocation.

##### Returns

Type | Description
--- | ---
System.IntPtr | Pointer to the allocated region.

| Improve this Doc View Source

#### GameAllocateApricot(UInt64, UInt64)

Allocate memory in the game's apricot memory space.

##### Declaration

    public static IntPtr GameAllocateApricot(ulong size, ulong alignment = 0UL)

##### Parameters

Type | Name | Description
--- | --- | ---
System.UInt64 | size | Amount of bytes to allocate.
System.UInt64 | alignment | The alignment of the allocation.

##### Returns

Type | Description
--- | ---
System.IntPtr | Pointer to the allocated region.

| Improve this Doc View Source

#### GameAllocateDefault(UInt64, UInt64)

Allocate memory in the game's default memory space.

##### Declaration

    public static IntPtr GameAllocateDefault(ulong size, ulong alignment = 0UL)

##### Parameters

Type | Name | Description
--- | --- | ---
System.UInt64 | size | Amount of bytes to allocate.
System.UInt64 | alignment | The alignment of the allocation.

##### Returns

Type | Description
--- | ---
System.IntPtr | Pointer to the allocated region.

| Improve this Doc View Source

#### GameAllocateSound(UInt64, UInt64)

Allocate memory in the game's sound memory space.

##### Declaration

    public static IntPtr GameAllocateSound(ulong size, ulong alignment = 0UL)

##### Parameters

Type | Name | Description
--- | --- | ---
System.UInt64 | size | Amount of bytes to allocate.
System.UInt64 | alignment | The alignment of the allocation.

##### Returns

Type | Description
--- | ---
System.IntPtr | Pointer to the allocated region.

| Improve this Doc View Source

#### GameAllocateUi(UInt64, UInt64)

Allocate memory in the game's UI memory space.

##### Declaration

    public static IntPtr GameAllocateUi(ulong size, ulong alignment = 0UL)

##### Parameters

Type | Name | Description
--- | --- | ---
System.UInt64 | size | Amount of bytes to allocate.
System.UInt64 | alignment | The alignment of the allocation.

##### Returns

Type | Description
--- | ---
System.IntPtr | Pointer to the allocated region.

| Improve this Doc View Source

#### GameFree(ref IntPtr, UInt64)

Free memory in the game's memory space.

##### Declaration

    public static void GameFree(ref IntPtr 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.

##### Remarks

The memory you are freeing must be allocated with game allocators.

| Improve this Doc View Source

#### NullTerminate(Byte[])

Null-terminate a byte array.

##### Declaration

    public static byte[] NullTerminate(this byte[] bytes)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Byte[] | bytes | The byte array to terminate.

##### Returns

Type | Description
--- | ---
System.Byte[] | The terminated byte array.

| Improve this Doc View Source

#### Read<T>(IntPtr)

Reads a generic type from a specified memory address.

##### Declaration

    public static T Read<T>(IntPtr memoryAddress)
        where T : struct

##### Parameters

Type | Name | Description
--- | --- | ---
System.IntPtr | memoryAddress | The memory address to read from.

##### Returns

Type | Description
--- | ---
T | The read in struct.

##### Type Parameters

Name | Description
--- | ---
T | An individual struct type of a class with an explicit StructLayout.LayoutKind attribute.

| Improve this Doc View Source

#### Read<T>(IntPtr, out T)

Reads a generic type from a specified memory address.

##### Declaration

    public static void Read<T>(IntPtr memoryAddress, out T value)
        where T : struct

##### 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.

| Improve this Doc View Source

#### Read<T>(IntPtr, out T, Boolean)

Reads a generic type from a specified memory address.

##### Declaration

    public static void Read<T>(IntPtr 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.

| Improve this Doc View Source

#### Read<T>(IntPtr, Boolean)

Reads a generic type from a specified memory address.

##### Declaration

    public static T Read<T>(IntPtr memoryAddress, bool marshal)

##### Parameters

Type | Name | Description
--- | --- | ---
System.IntPtr | memoryAddress | The memory address to read from.
System.Boolean | marshal | Set this to true to enable struct marshalling.

##### Returns

Type | Description
--- | ---
T | The read in struct.

##### Type Parameters

Name | Description
--- | ---
T | An individual struct type of a class with an explicit StructLayout.LayoutKind attribute.

| Improve this Doc View Source

#### Read<T>(IntPtr, Int32)

Reads a generic type array from a specified memory address.

##### Declaration

    public static T[] Read<T>(IntPtr memoryAddress, int arrayLength)
        where T : struct

##### Parameters

Type | Name | Description
--- | --- | ---
System.IntPtr | memoryAddress | The memory address to read from.
System.Int32 | arrayLength | The amount of array items to read.

##### Returns

Type | Description
--- | ---
T[] | The read in struct array.

##### Type Parameters

Name | Description
--- | ---
T | An individual struct type of a class with an explicit StructLayout.LayoutKind attribute.

| Improve this Doc View Source

#### Read<T>(IntPtr, Int32, out T[])

Reads a generic type array from a specified memory address.

##### Declaration

    public static void Read<T>(IntPtr memoryAddress, int arrayLength, out T[] value)
        where T : struct

##### 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.

| Improve this Doc View Source

#### Read<T>(IntPtr, Int32, Boolean)

Reads a generic type array from a specified memory address.

##### Declaration

    public static T[] Read<T>(IntPtr memoryAddress, int arrayLength, bool marshal)

##### 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.

##### Returns

Type | Description
--- | ---
T[] | The read in struct array.

##### Type Parameters

Name | Description
--- | ---
T | An individual struct type of a class with an explicit StructLayout.LayoutKind attribute.

| Improve this Doc View Source

#### Read<T>(IntPtr, Int32, Boolean, out T[])

Reads a generic type array from a specified memory address.

##### Declaration

    public static void Read<T>(IntPtr 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.

| Improve this Doc View Source

#### ReadProcessMemory(IntPtr, ref Byte[])

Reads raw data from a specified memory address via Windows API calls. This is noticably slower than Unsafe or Marshal.

##### Declaration

    public static void ReadProcessMemory(IntPtr memoryAddress, ref byte[] value)

##### Parameters

Type | Name | Description
--- | --- | ---
System.IntPtr | memoryAddress | The memory address to read from.
System.Byte[] | value | The read in bytes.

| Improve this Doc View Source

#### ReadProcessMemory(IntPtr, Int32)

Reads raw data from a specified memory address via Windows API calls. This is noticably slower than Unsafe or Marshal.

##### Declaration

    public static byte[] ReadProcessMemory(IntPtr memoryAddress, int length)

##### 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.

##### Returns

Type | Description
--- | ---
System.Byte[] | The read in bytes.

| Improve this Doc View Source

#### ReadProcessMemory(IntPtr, Int32, out Byte[])

Reads raw data from a specified memory address via Windows API calls. This is noticably slower than Unsafe or Marshal.

##### Declaration

    public static void ReadProcessMemory(IntPtr 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.

| Improve this Doc View Source

#### ReadRaw(IntPtr, Int32)

Reads a byte array from a specified memory address.

##### Declaration

    public static byte[] ReadRaw(IntPtr memoryAddress, int length)

##### 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.

##### Returns

Type | Description
--- | ---
System.Byte[] | The read in byte array.

| Improve this Doc View Source

#### ReadRaw(IntPtr, Int32, out Byte[])

Reads raw data from a specified memory address.

##### Declaration

    public static void ReadRaw(IntPtr 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.

| Improve this Doc View Source

#### ReadRawNullTerminated(IntPtr)

Reads a null-terminated byte array from a specified memory address.

##### Declaration

    public static byte[] ReadRawNullTerminated(IntPtr memoryAddress)

##### Parameters

Type | Name | Description
--- | --- | ---
System.IntPtr | memoryAddress | The memory address to read from.

##### Returns

Type | Description
--- | ---
System.Byte[] | The read in byte array.

| Improve this Doc View Source

#### ReadSeString(Utf8String*)

Read an SeString from a specified Utf8String structure.

##### Declaration

    public static SeString ReadSeString(Utf8String*utf8String)

##### Parameters

Type | Name | Description
--- | --- | ---
Utf8String* | utf8String | The memory address to read from.

##### Returns

Type | Description
--- | ---
SeString | The read in string.

| Improve this Doc View Source

#### ReadSeString(Utf8String*, out SeString)

Read an SeString from a specified Utf8String structure.

##### Declaration

    public static void ReadSeString(Utf8String*utf8String, out SeString value)

##### Parameters

Type | Name | Description
--- | --- | ---
Utf8String* | utf8String | The memory address to read from.
SeString | value | The read in string.

| Improve this Doc View Source

#### ReadSeString(IntPtr, Int32)

Read an SeString from a specified memory address.

##### Declaration

    public static SeString ReadSeString(IntPtr memoryAddress, int maxLength)

##### Parameters

Type | Name | Description
--- | --- | ---
System.IntPtr | memoryAddress | The memory address to read from.
System.Int32 | maxLength | The maximum length of the string.

##### Returns

Type | Description
--- | ---
SeString | The read in string.

| Improve this Doc View Source

#### ReadSeString(IntPtr, Int32, out SeString)

Read an SeString from a specified memory address.

##### Declaration

    public static void ReadSeString(IntPtr 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.
SeString | value | The read in SeString.

| Improve this Doc View Source

#### ReadSeStringNullTerminated(IntPtr)

Read a null-terminated SeString from a specified memory address.

##### Declaration

    public static SeString ReadSeStringNullTerminated(IntPtr memoryAddress)

##### Parameters

Type | Name | Description
--- | --- | ---
System.IntPtr | memoryAddress | The memory address to read from.

##### Returns

Type | Description
--- | ---
SeString | The read in string.

| Improve this Doc View Source

#### ReadSeStringNullTerminated(IntPtr, out SeString)

Read a null-terminated SeString from a specified memory address.

##### Declaration

    public static void ReadSeStringNullTerminated(IntPtr memoryAddress, out SeString value)

##### Parameters

Type | Name | Description
--- | --- | ---
System.IntPtr | memoryAddress | The memory address to read from.
SeString | value | The read in SeString.

| Improve this Doc View Source

#### ReadString(IntPtr, Int32)

Read a UTF-8 encoded string from a specified memory address.

##### Declaration

    public static string ReadString(IntPtr memoryAddress, int maxLength)

##### Parameters

Type | Name | Description
--- | --- | ---
System.IntPtr | memoryAddress | The memory address to read from.
System.Int32 | maxLength | The maximum length of the string.

##### Returns

Type | Description
--- | ---
System.String | The read in string.

##### Remarks

Attention! If this is an SeString, use the SeStringManager to decode or the applicable helper method.

| Improve this Doc View Source

#### ReadString(IntPtr, out String, Int32)

Read a UTF-8 encoded string from a specified memory address.

##### Declaration

    public static void ReadString(IntPtr 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.

##### Remarks

Attention! If this is an SeString, use the SeStringManager to decode or the applicable helper method.

| Improve this Doc View Source

#### ReadString(IntPtr, Encoding, Int32)

Read a string with the given encoding from a specified memory address.

##### Declaration

    public static string ReadString(IntPtr memoryAddress, Encoding encoding, int maxLength)

##### 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.

##### Returns

Type | Description
--- | ---
System.String | The read in string.

##### Remarks

Attention! If this is an SeString, use the SeStringManager to decode or the applicable helper method.

| Improve this Doc View Source

#### ReadString(IntPtr, Encoding, Int32, out String)

Read a string with the given encoding from a specified memory address.

##### Declaration

    public static void ReadString(IntPtr 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.

##### Remarks

Attention! If this is an SeString, use the SeStringManager to decode or the applicable helper method.

| Improve this Doc View Source

#### ReadStringNullTerminated(IntPtr)

Read a UTF-8 encoded string from a specified memory address.

##### Declaration

    public static string ReadStringNullTerminated(IntPtr memoryAddress)

##### Parameters

Type | Name | Description
--- | --- | ---
System.IntPtr | memoryAddress | The memory address to read from.

##### Returns

Type | Description
--- | ---
System.String | The read in string.

##### Remarks

Attention! If this is an SeString, use the SeStringManager to decode or the applicable helper method.

| Improve this Doc View Source

#### ReadStringNullTerminated(IntPtr, out String)

Read a UTF-8 encoded string from a specified memory address.

##### Declaration

    public static void ReadStringNullTerminated(IntPtr memoryAddress, out string value)

##### Parameters

Type | Name | Description
--- | --- | ---
System.IntPtr | memoryAddress | The memory address to read from.
System.String | value | The read in string.

##### Remarks

Attention! If this is an SeString, use the SeStringManager to decode or the applicable helper method.

| Improve this Doc View Source

#### ReadStringNullTerminated(IntPtr, Encoding)

Read a string with the given encoding from a specified memory address.

##### Declaration

    public static string ReadStringNullTerminated(IntPtr memoryAddress, Encoding encoding)

##### 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.

##### Returns

Type | Description
--- | ---
System.String | The read in string.

##### Remarks

Attention! If this is an SeString, use the SeStringManager to decode or the applicable helper method.

| Improve this Doc View Source

#### ReadStringNullTerminated(IntPtr, Encoding, out String)

Read a string with the given encoding from a specified memory address.

##### Declaration

    public static void ReadStringNullTerminated(IntPtr 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.

##### Remarks

Attention! If this is an SeString, use the SeStringManager to decode or the applicable helper method.

| Improve this Doc View Source

#### SizeOf<T>()

Returns the size of a specific primitive or struct type.

##### Declaration

    public static int SizeOf<T>()

##### Returns

Type | Description
--- | ---
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.

| Improve this Doc View Source

#### SizeOf<T>(Boolean)

Returns the size of a specific primitive or struct type.

##### Declaration

    public static int SizeOf<T>(bool marshal)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Boolean | marshal | If set to true; will return the size of an element after marshalling.

##### Returns

Type | Description
--- | ---
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.

| Improve this Doc View Source

#### SizeOf<T>(Int32)

Returns the size of a specific primitive or struct type.

##### Declaration

    public static int SizeOf<T>(int elementCount)
        where T : struct

##### Parameters

Type | Name | Description
--- | --- | ---
System.Int32 | elementCount | The number of array elements present.

##### Returns

Type | Description
--- | ---
System.Int32 | The size of the primitive or struct array.

##### Type Parameters

Name | Description
--- | ---
T | An individual struct type of a class with an explicit StructLayout.LayoutKind attribute.

| Improve this Doc View Source

#### SizeOf<T>(Int32, Boolean)

Returns the size of a specific primitive or struct type.

##### Declaration

    public static int SizeOf<T>(int elementCount, bool marshal)

##### 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.

##### Returns

Type | Description
--- | ---
System.Int32 | The size of the primitive or struct array.

##### Type Parameters

Name | Description
--- | ---
T | An individual struct type of a class with an explicit StructLayout.LayoutKind attribute.

| Improve this Doc View Source

#### Write<T>(IntPtr, T)

Writes a generic type to a specified memory address.

##### Declaration

    public static void Write<T>(IntPtr memoryAddress, T item)
        where T : struct

##### 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.

| Improve this Doc View Source

#### Write<T>(IntPtr, T, Boolean)

Writes a generic type to a specified memory address.

##### Declaration

    public static void Write<T>(IntPtr 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.

| Improve this Doc View Source

#### Write<T>(IntPtr, T[])

Writes a generic type array to a specified memory address.

##### Declaration

    public static void Write<T>(IntPtr memoryAddress, T[] items)
        where T : struct

##### 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.

| Improve this Doc View Source

#### Write<T>(IntPtr, T[], Boolean)

Writes a generic type array to a specified memory address.

##### Declaration

    public static void Write<T>(IntPtr 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.

| Improve this Doc View Source

#### WriteProcessMemory(IntPtr, Byte[])

Writes raw data to a specified memory address via Windows API calls. This is noticably slower than Unsafe or Marshal.

##### Declaration

    public static void WriteProcessMemory(IntPtr 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.

| Improve this Doc View Source

#### WriteRaw(IntPtr, Byte[])

Writes raw data to a specified memory address.

##### Declaration

    public static void WriteRaw(IntPtr 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.

| Improve this Doc View Source

#### WriteSeString(IntPtr, SeString)

Write an SeString to a specified memory address.

##### Declaration

    public static void WriteSeString(IntPtr memoryAddress, SeString value)

##### Parameters

Type | Name | Description
--- | --- | ---
System.IntPtr | memoryAddress | The memory address to write to.
SeString | value | The SeString to write.

| Improve this Doc View Source

#### WriteString(IntPtr, String)

Write a UTF-8 encoded string to a specified memory address.

##### Declaration

    public static void WriteString(IntPtr memoryAddress, string value)

##### Parameters

Type | Name | Description
--- | --- | ---
System.IntPtr | memoryAddress | The memory address to write to.
System.String | value | The string to write.

##### Remarks

Attention! If this is an SeString, use the SeStringManager to encode or the applicable helper method.

| Improve this Doc View Source

#### WriteString(IntPtr, String, Encoding)

Write a string with the given encoding to a specified memory address.

##### Declaration

    public static void WriteString(IntPtr 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.

##### Remarks

Attention! If this is an SeString, use the SeStringManager to encode or the applicable helper method.