diff --git a/Core/Extensions/InteropExtensions.cs b/Core/Extensions/InteropExtensions.cs
index d6698c5c..c9f85516 100644
--- a/Core/Extensions/InteropExtensions.cs
+++ b/Core/Extensions/InteropExtensions.cs
@@ -214,6 +214,25 @@ namespace Vanara.Extensions
}
}
+ /// Marshals an unmanaged linked list of structures to an of that structure.
+ /// Type of native structure used by the unmanaged linked list.
+ /// The pointing to the native array.
+ /// The expression to be used to fetch the offset from the current pointer to the next item in the list.
+ ///
+ /// The number of allocated bytes behind . This value is used to determine when to stop enumerating.
+ ///
+ /// An exposing the elements of the linked list.
+ public static IEnumerable LinkedListToIEnum(this IntPtr ptr, Func nextOffset, SizeT allocatedBytes)
+ {
+ var pEnd = ptr.Offset(allocatedBytes);
+ for (var pCurrent = ptr; pCurrent.ToInt64() < pEnd.ToInt64();)
+ {
+ var ret = pCurrent.ToStructure();
+ yield return ret;
+ pCurrent = pCurrent.Offset(nextOffset(ret));
+ }
+ }
+
///
/// Marshals data from a managed list of objects to an unmanaged block of memory allocated by the method.
///