|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#define SHORT_PACKET_TERMINATE 0x01 |
| 4 | +#define AUTO_CLEAR_STALL 0x02 |
| 5 | +#define PIPE_TRANSFER_TIMEOUT 0x03 |
| 6 | + |
| 7 | +#define USB_DEVICE_DESCRIPTOR_TYPE 0x01 |
| 8 | +#define USB_STRING_DESCRIPTOR_TYPE 0x03 |
| 9 | + |
| 10 | +extern "C" |
| 11 | +{ |
| 12 | + |
| 13 | +typedef PVOID WINUSB_INTERFACE_HANDLE, * PWINUSB_INTERFACE_HANDLE; |
| 14 | + |
| 15 | +typedef struct _USB_DEVICE_DESCRIPTOR { |
| 16 | + UCHAR bLength; |
| 17 | + UCHAR bDescriptorType; |
| 18 | + USHORT bcdUSB; |
| 19 | + UCHAR bDeviceClass; |
| 20 | + UCHAR bDeviceSubClass; |
| 21 | + UCHAR bDeviceProtocol; |
| 22 | + UCHAR bMaxPacketSize0; |
| 23 | + USHORT idVendor; |
| 24 | + USHORT idProduct; |
| 25 | + USHORT bcdDevice; |
| 26 | + UCHAR iManufacturer; |
| 27 | + UCHAR iProduct; |
| 28 | + UCHAR iSerialNumber; |
| 29 | + UCHAR bNumConfigurations; |
| 30 | +} USB_DEVICE_DESCRIPTOR, * PUSB_DEVICE_DESCRIPTOR; |
| 31 | + |
| 32 | +#pragma pack(1) |
| 33 | + |
| 34 | +typedef struct _WINUSB_SETUP_PACKET { |
| 35 | + UCHAR RequestType; |
| 36 | + UCHAR Request; |
| 37 | + USHORT Value; |
| 38 | + USHORT Index; |
| 39 | + USHORT Length; |
| 40 | +} WINUSB_SETUP_PACKET, * PWINUSB_SETUP_PACKET; |
| 41 | + |
| 42 | +typedef struct _USB_STRING_DESCRIPTOR { |
| 43 | + UCHAR bLength; |
| 44 | + UCHAR bDescriptorType; |
| 45 | + WCHAR bString[1]; |
| 46 | +} USB_STRING_DESCRIPTOR, * PUSB_STRING_DESCRIPTOR; |
| 47 | + |
| 48 | +#pragma pack() |
| 49 | + |
| 50 | +BOOL __stdcall |
| 51 | +WinUsb_Initialize( |
| 52 | + _In_ HANDLE DeviceHandle, |
| 53 | + _Out_ PWINUSB_INTERFACE_HANDLE InterfaceHandle |
| 54 | +); |
| 55 | + |
| 56 | + |
| 57 | +BOOL __stdcall |
| 58 | +WinUsb_Free( |
| 59 | + _In_ WINUSB_INTERFACE_HANDLE InterfaceHandle |
| 60 | +); |
| 61 | + |
| 62 | +BOOL __stdcall |
| 63 | +WinUsb_GetDescriptor( |
| 64 | + _In_ WINUSB_INTERFACE_HANDLE InterfaceHandle, |
| 65 | + _In_ UCHAR DescriptorType, |
| 66 | + _In_ UCHAR Index, |
| 67 | + _In_ USHORT LanguageID, |
| 68 | + _Out_writes_bytes_to_opt_(BufferLength, *LengthTransferred) PUCHAR Buffer, |
| 69 | + _In_ ULONG BufferLength, |
| 70 | + _Out_ PULONG LengthTransferred |
| 71 | +); |
| 72 | + |
| 73 | +BOOL __stdcall |
| 74 | +WinUsb_GetAssociatedInterface( |
| 75 | + _In_ WINUSB_INTERFACE_HANDLE InterfaceHandle, |
| 76 | + _In_ UCHAR AssociatedInterfaceIndex, |
| 77 | + _Out_ PWINUSB_INTERFACE_HANDLE AssociatedInterfaceHandle |
| 78 | +); |
| 79 | + |
| 80 | +BOOL __stdcall |
| 81 | +WinUsb_SetPipePolicy( |
| 82 | + _In_ WINUSB_INTERFACE_HANDLE InterfaceHandle, |
| 83 | + _In_ UCHAR PipeID, |
| 84 | + _In_ ULONG PolicyType, |
| 85 | + _In_ ULONG ValueLength, |
| 86 | + _In_reads_bytes_(ValueLength) PVOID Value |
| 87 | +); |
| 88 | + |
| 89 | +BOOL __stdcall |
| 90 | +WinUsb_ControlTransfer( |
| 91 | + _In_ WINUSB_INTERFACE_HANDLE InterfaceHandle, |
| 92 | + _In_ WINUSB_SETUP_PACKET SetupPacket, |
| 93 | + _Out_writes_bytes_to_opt_(BufferLength, *LengthTransferred) PUCHAR Buffer, |
| 94 | + _In_ ULONG BufferLength, |
| 95 | + _Out_opt_ PULONG LengthTransferred, |
| 96 | + _In_opt_ LPOVERLAPPED Overlapped |
| 97 | +); |
| 98 | + |
| 99 | +BOOL __stdcall |
| 100 | +WinUsb_ReadPipe( |
| 101 | + _In_ WINUSB_INTERFACE_HANDLE InterfaceHandle, |
| 102 | + _In_ UCHAR PipeID, |
| 103 | + _Out_writes_bytes_to_opt_(BufferLength, *LengthTransferred) PUCHAR Buffer, |
| 104 | + _In_ ULONG BufferLength, |
| 105 | + _Out_opt_ PULONG LengthTransferred, |
| 106 | + _In_opt_ LPOVERLAPPED Overlapped |
| 107 | +); |
| 108 | + |
| 109 | +BOOL __stdcall |
| 110 | +WinUsb_WritePipe( |
| 111 | + _In_ WINUSB_INTERFACE_HANDLE InterfaceHandle, |
| 112 | + _In_ UCHAR PipeID, |
| 113 | + _In_reads_bytes_(BufferLength) PUCHAR Buffer, |
| 114 | + _In_ ULONG BufferLength, |
| 115 | + _Out_opt_ PULONG LengthTransferred, |
| 116 | + _In_opt_ LPOVERLAPPED Overlapped |
| 117 | +); |
| 118 | + |
| 119 | +}; // extern "C" |
0 commit comments