Byte[] 转Intptr:
byte[] buf;
unsafe
{
GCHandle gch = GCHandle.Alloc(buf, GCHandleType.Pinned);
IntPtr addr = gch.AddrOfPinnedObject();
gch.Free();
}
UIntptr转Intptr :
UIntptr buf;
unsafe
{
IntPtr addr;
addr = (IntPtr)buf.ToPointer();
}
Intptr转UIntptr :
IntPtr addr;
UIntptr buf = (UIntPtr)addr.ToPointer()