diff --git a/Core/InteropServices/SafeCoTaskMemHandle.cs b/Core/InteropServices/SafeCoTaskMemHandle.cs index 35e6035b..b735dd72 100644 --- a/Core/InteropServices/SafeCoTaskMemHandle.cs +++ b/Core/InteropServices/SafeCoTaskMemHandle.cs @@ -82,7 +82,7 @@ namespace Vanara.InteropServices /// Native type /// The value. /// object to an native (unmanaged) memory block the size of T. - public static SafeCoTaskMemHandle CreateFromStructure(T value = default) => new SafeCoTaskMemHandle(InteropExtensions.StructureToPtr(value, new CoTaskMemoryMethods().AllocMem, out int s), s); + public static SafeCoTaskMemHandle CreateFromStructure(in T value = default) => new SafeCoTaskMemHandle(InteropExtensions.StructureToPtr(value, new CoTaskMemoryMethods().AllocMem, out int s), s); /// /// Allocates from unmanaged memory to represent a structure with a variable length array at the end and marshal these structure elements. It is the diff --git a/Core/InteropServices/SafeHGlobalHandle.cs b/Core/InteropServices/SafeHGlobalHandle.cs index c04e44d6..d7abaf5b 100644 --- a/Core/InteropServices/SafeHGlobalHandle.cs +++ b/Core/InteropServices/SafeHGlobalHandle.cs @@ -81,7 +81,7 @@ namespace Vanara.InteropServices /// Native type /// The value. /// object to an native (unmanaged) memory block the size of T. - public static SafeHGlobalHandle CreateFromStructure(T value = default) => new SafeHGlobalHandle(InteropExtensions.StructureToPtr(value, new HGlobalMemoryMethods().AllocMem, out int s), s); + public static SafeHGlobalHandle CreateFromStructure(in T value = default) => new SafeHGlobalHandle(InteropExtensions.StructureToPtr(value, new HGlobalMemoryMethods().AllocMem, out int s), s); /// /// Allocates from unmanaged memory to represent a structure with a variable length array at the end and marshal these structure elements. It is the diff --git a/PInvoke/Kernel32/HeapApi.cs b/PInvoke/Kernel32/HeapApi.cs index 67deb58f..6de41efa 100644 --- a/PInvoke/Kernel32/HeapApi.cs +++ b/PInvoke/Kernel32/HeapApi.cs @@ -1527,7 +1527,7 @@ namespace Vanara.PInvoke /// Native type /// The value. /// object to an native (unmanaged) memory block the size of T. - public static SafeHeapBlock CreateFromStructure(T value = default) => new SafeHeapBlock(InteropExtensions.StructureToPtr(value, new CoTaskMemoryMethods().AllocMem, out int s), s); + public static SafeHeapBlock CreateFromStructure(in T value = default) => new SafeHeapBlock(InteropExtensions.StructureToPtr(value, new CoTaskMemoryMethods().AllocMem, out int s), s); /// Converts an to a where it owns the reference. /// The . diff --git a/PInvoke/Kernel32/InteropServices/SafeLocalHandle.cs b/PInvoke/Kernel32/InteropServices/SafeLocalHandle.cs index 2be9b44c..1a7c31cf 100644 --- a/PInvoke/Kernel32/InteropServices/SafeLocalHandle.cs +++ b/PInvoke/Kernel32/InteropServices/SafeLocalHandle.cs @@ -113,7 +113,7 @@ namespace Vanara.InteropServices /// Native type /// The value. /// object to an native (unmanaged) memory block the size of T. - public static SafeLocalHandle CreateFromStructure(T value = default) => new SafeLocalHandle(InteropExtensions.StructureToPtr(value, new LocalMemoryMethods().AllocMem, out var s), s); + public static SafeLocalHandle CreateFromStructure(in T value = default) => new SafeLocalHandle(InteropExtensions.StructureToPtr(value, new LocalMemoryMethods().AllocMem, out var s), s); /// Converts an to a where it owns the reference. /// The .