From d29963d39adbb136ad2a4ec99a8e82f822629890 Mon Sep 17 00:00:00 2001 From: dahall Date: Sat, 5 Feb 2022 15:14:55 -0700 Subject: [PATCH] Added PinnedObject implicit operator to unsafe void*. --- Core/InteropServices/PinnedObject.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Core/InteropServices/PinnedObject.cs b/Core/InteropServices/PinnedObject.cs index 5e088d54..18b2ae14 100644 --- a/Core/InteropServices/PinnedObject.cs +++ b/Core/InteropServices/PinnedObject.cs @@ -41,6 +41,11 @@ namespace Vanara.InteropServices /// The result of the conversion. public static implicit operator IntPtr(PinnedObject ap) => !ap.IsInvalid ? ap.pinnedArray.AddrOfPinnedObject().Offset(ap.mOffset) : IntPtr.Zero; + /// Get an unsafe pointer to the pinned memory of the object with any preset offset. + /// The instance. + /// The result of the conversion. + public static unsafe implicit operator void*(PinnedObject ap) => !ap.IsInvalid ? (void*)ap.pinnedArray.AddrOfPinnedObject().Offset(ap.mOffset) : null; + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. public void Dispose() {