From 9d781518d6e1ffa75613a65a13733b38a66758a4 Mon Sep 17 00:00:00 2001 From: goat <16760685+goaaats@users.noreply.github.com> Date: Tue, 7 Dec 2021 22:19:21 +0100 Subject: [PATCH] doc: SafeMemory.PtrToStructure --- Dalamud/SafeMemory.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Dalamud/SafeMemory.cs b/Dalamud/SafeMemory.cs index d4f79714e..fb61453f3 100644 --- a/Dalamud/SafeMemory.cs +++ b/Dalamud/SafeMemory.cs @@ -190,8 +190,20 @@ namespace Dalamud return WriteBytes(address, encoding.GetBytes(str + "\0")); } + /// + /// Marshals data from an unmanaged block of memory to a managed object. + /// + /// The type to create. + /// The address to read from. + /// The read object, or null, if it could not be read. public static T? PtrToStructure(IntPtr addr) where T : struct => (T?)PtrToStructure(addr, typeof(T)); + /// + /// Marshals data from an unmanaged block of memory to a managed object. + /// + /// The address to read from. + /// The type to create. + /// The read object, or null, if it could not be read. public static object? PtrToStructure(IntPtr addr, Type type) { var size = Marshal.SizeOf(type);