Search code examples
c#bytearraysintptr

C# how to get Byte[] from IntPtr


I have a .dll(not my own) that has a delegate. This delegate Callback function is:
"CallBackFN(ushort opCOde, IntPtr payload, uint size, uint localIP)"

How can i convert IntPtr to Byte[]? I think that payload is actually Byte[]. If it's not Byte[] and it's something else would i lose some data?


Solution

  • Have you looked into Marshal.Copy?

    http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.copy.aspx