Search code examples
c#usb

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 should I be reading for the PVOID?


Solution

  • 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.