Class MarshalUtils
Marshaling helper functions.
public static class MarshalUtils
- Inheritance
-
MarshalUtils
Methods
- ArrayToPtr<T>(T[], UnmanagedType, ref IntPtr, ref int)
Marshals an array to unmanaged memory and updates a pointer to this memory and a size field. If the unmanaged memory pointer is not zero, it is freed first. The memory should be cleaned up by setting the array to null. Manually changing the pointer or the size field may lead to memory leaks or crashes. This function uses the COM allocator.
- ArrayToPtr<T>(T[], UnmanagedType, ref IntPtr, ref uint)
Calls the other overload.
- PtrToArray<T>(UnmanagedType, IntPtr, int)
Reads an array from unmanaged memory given a pointer and the array size.
- PtrToArray<T>(UnmanagedType, IntPtr, uint)
Calls the other overload.
- PtrToStructure<T>(IntPtr)
A generic version of PtrToStructure(IntPtr, Type).