From 4ce428215cbf8e34b00d781742476235c84b457c Mon Sep 17 00:00:00 2001 From: dahall Date: Sat, 22 Jan 2022 15:30:42 -0700 Subject: [PATCH] Added SafeAllocatedMemoryHandleBase.GetBytes() and pulled SafeMemoryHandle.Locked from IMemoryMethods instance --- Core/InteropServices/SafeMemoryHandle.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Core/InteropServices/SafeMemoryHandle.cs b/Core/InteropServices/SafeMemoryHandle.cs index ca7112e8..3f7ea458 100644 --- a/Core/InteropServices/SafeMemoryHandle.cs +++ b/Core/InteropServices/SafeMemoryHandle.cs @@ -325,6 +325,10 @@ namespace Vanara.InteropServices return h; } + /// Gets a copy of bytes from the allocated memory block. + /// A byte array with the copied bytes. + public byte[] GetBytes() => GetBytes(0, Size); + /// Gets a copy of bytes from the allocated memory block. /// The start index. /// The number of bytes to retrieve. @@ -451,6 +455,10 @@ namespace Vanara.InteropServices /// When overridden in a derived class, gets a value indicating whether the handle value is invalid. public override bool IsInvalid => handle == IntPtr.Zero; + /// Gets a value indicating whether this memory supports locking. + /// if lockable; otherwise, . + public override bool Lockable => mm.Lockable; + /// Gets or sets the size in bytes of the allocated memory block. /// The size in bytes of the allocated memory block. public override SizeT Size