|
Assuming in your code "Packet" is a struct, that (IntPtr) would convert your struct to an IntPtr. Seems simple enough. That sounds like a lot of movement, as far as I understand it.
My code creates a buffer, pins it in the memory so there would be no movement induced by the GC, and move the bytes in my struct directly to my pinned buffer, without any intermediate "helper".
EDIT : I just saw that you`re actually passing Packet.pBuffer, which shouldn`t be a struct lol. In that case marshalling is totally pointless.
|