开发者

Reading a PVOID in c#, how many bits should I read?

开发者 https://www.devze.com 2023-04-10 23:16 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号