Reading a PVOID in c#, how many bits should I read?
I'm reading from a USB packet that has a URB type. The URB header defined at http://msdn.microsoft.com/en-us/library/windows/hardware/ff540409(v=vs.85).aspx as
struct _URB_HEADER {
USHORT Length;
USHORT Function;
USBD_STATUS Status;
PVOID UsbdDeviceHandle;
ULONG UsbdFlags;
};
How many bits sho开发者_运维技巧uld I be reading for the PVOID?
Since that's a pointer type, then it depends on your platform. 32 bits for x86; 64 bits for x64.
I'm not well-versed with those libraries but should you be using those fields though? The link you shared says "Reserved. Do not use".
Edit: Disregard the last statement. I just realized that the structure is just the header. Of course you need to know that field's size in order to get to the body. :)
Thanks for the comments - reading through them, it looks like using
byte [] ptr_bytes = rdr.ReadBytes(System.IntPtr.Size);
will provide the size of the pointer correctly depending on the operating system.
精彩评论