libusbK 
3.0
Library Documentation
© 2011-2021 Travis Lee Robinson. All rights reserved.
libusbk.h
Go to the documentation of this file.
1 
8 #ifndef _LIBUSBK_H__
9 #define _LIBUSBK_H__
10 
11 #include "lusbk_shared.h"
12 
14 // L I B U S B K PUBLIC STRUCTS, DEFINES, AND ENUMS //////////////////
16 
17 #ifndef _LIBUSBK_LIBK_TYPES
18 
23 #define _in
24 #define _inopt
25 #define _out
26 #define _outopt
27 #define _ref
28 #define _refopt
29 
31 typedef INT_PTR (FAR WINAPI* KPROC)();
32 
34 #if defined(DYNAMIC_DLL)
35 #define KUSB_EXP
36 #else
37 #define KUSB_EXP
38 #endif
39 
41 #if !defined(KUSB_API)
42 #define KUSB_API WINAPI
43 #endif
44 
45 #if _MSC_VER >= 1200
46 #pragma warning(push)
47 #endif
48 #pragma warning(disable:4200)
49 #pragma warning(disable:4201)
50 #pragma warning(disable:4214) // named type definition in parentheses
51 
54 
56 
60 typedef union _KUSB_SETUP_PACKET
61 {
62  UCHAR Bytes[8];
63  USHORT Words[4];
64  struct
65  {
67  struct
68  {
69  UCHAR Recipient: 2;
70  UCHAR Reserved: 3;
71  UCHAR Type: 2;
72  UCHAR Dir: 1;
73  } BmRequest;
74 
76  UCHAR Request;
77 
79  USHORT Value;
80 
82  USHORT Index;
83 
85  USHORT Length;
86  };
87  struct
88  {
89  struct
90  {
91  UCHAR b0: 1;
92  UCHAR b1: 1;
93  UCHAR b2: 1;
94  UCHAR b3: 1;
95  UCHAR b4: 1;
96  UCHAR b5: 1;
97  UCHAR b6: 1;
98  UCHAR b7: 1;
99  } BmRequestBits;
100 
101  struct
102  {
103  UCHAR b0: 1;
104  UCHAR b1: 1;
105  UCHAR b2: 1;
106  UCHAR b3: 1;
107  UCHAR b4: 1;
108  UCHAR b5: 1;
109  UCHAR b6: 1;
110  UCHAR b7: 1;
111  } RequestBits;
112 
113  UCHAR ValueLo;
114  UCHAR ValueHi;
115  UCHAR IndexLo;
116  UCHAR IndexHi;
117  UCHAR LengthLo;
118  UCHAR LengthHi;
119  };
121 // setup packet is eight bytes -- defined by spec
122 USBK_C_ASSERT(KUSB_SETUP_PACKET,sizeof(KUSB_SETUP_PACKET) == 8);
123 
125 typedef void* KLIB_HANDLE;
126 
128 typedef KLIB_HANDLE KUSB_HANDLE;
129 
131 typedef KLIB_HANDLE KLST_HANDLE;
132 
134 typedef KLIB_HANDLE KHOT_HANDLE;
135 
137 typedef KLIB_HANDLE KOVL_HANDLE;
138 
139 
141 typedef KLIB_HANDLE KOVL_POOL_HANDLE;
142 
144 typedef KLIB_HANDLE KSTM_HANDLE;
145 
147 typedef KLIB_HANDLE KISOCH_HANDLE;
148 
150 typedef enum _KLIB_HANDLE_TYPE
151 {
154 
157 
160 
163 
166 
169 
172 
175 
178 
182 
184 typedef INT KUSB_API KLIB_HANDLE_CLEANUP_CB (_in KLIB_HANDLE Handle, _in KLIB_HANDLE_TYPE HandleType, _in KLIB_USER_CONTEXT UserContext);
185 
187 typedef struct _KLIB_VERSION
188 {
190  INT Major;
191 
193  INT Minor;
194 
196  INT Micro;
197 
199  INT Nano;
200 } KLIB_VERSION;
203 
205 #endif
206 
207 #ifndef _LIBUSBK_ISOK_TYPES
208 
213 typedef BOOL KUSB_API KISO_ENUM_PACKETS_CB (_in UINT PacketIndex, _in PKISO_PACKET IsoPacket, _in PVOID UserState);
215 
217 typedef BOOL KUSB_API KISOCH_ENUM_PACKETS_CB(_in UINT PacketIndex, _ref PUINT Offset, _ref PUINT Length, _ref PUINT Status, _in PVOID UserState);
218 
220 #endif
221 
222 #ifndef _LIBUSBK_LSTK_TYPES
223 
228 #define KLST_STRING_MAX_LEN 256
230 
232 
238 typedef enum _KLST_SYNC_FLAG
239 {
242 
245 
248 
251 
254 
258 
260 typedef struct _KLST_DEV_COMMON_INFO
261 {
263  INT Vid;
264 
266  INT Pid;
267 
269  INT MI;
270 
271  // An ID that uniquely identifies a USB device.
272  CHAR InstanceID[KLST_STRING_MAX_LEN];
273 
277 
279 
284 typedef struct _KLST_DEVINFO
285 {
288 
290  INT DriverID;
291 
293  CHAR DeviceInterfaceGUID[KLST_STRING_MAX_LEN];
294 
296 
309  CHAR DeviceID[KLST_STRING_MAX_LEN];
310 
312  CHAR ClassGUID[KLST_STRING_MAX_LEN];
313 
316 
318  CHAR DeviceDesc[KLST_STRING_MAX_LEN];
319 
321  CHAR Service[KLST_STRING_MAX_LEN];
322 
324  CHAR SymbolicLink[KLST_STRING_MAX_LEN];
325 
327  CHAR DevicePath[KLST_STRING_MAX_LEN];
328 
331 
333  BOOL Connected;
334 
337 
338  INT BusNumber;
339 
340  INT DeviceAddress;
341 
343  CHAR SerialNumber[KLST_STRING_MAX_LEN];
344 
345 } KLST_DEVINFO;
348 
350 typedef enum _KLST_FLAG
351 {
354 
357 
360 
361 } KLST_FLAG;
362 
364 
371 typedef struct _KLST_PATTERN_MATCH
372 {
374  CHAR DeviceID[KLST_STRING_MAX_LEN];
375 
377  CHAR DeviceInterfaceGUID[KLST_STRING_MAX_LEN];
378 
380  CHAR ClassGUID[KLST_STRING_MAX_LEN];
381 
383  UCHAR z_F_i_x_e_d[1024 - KLST_STRING_MAX_LEN * 3];
384 
386 USBK_C_ASSERT(KLST_PATTERN_MATCH,sizeof(KLST_PATTERN_MATCH) == 1024);
387 
390 
392 
407  _in KLST_HANDLE DeviceList,
408  _in KLST_DEVINFO_HANDLE DeviceInfo,
409  _in PVOID Context);
410 
413 #endif
414 
415 #ifndef __USB_H__
416 
417 #include <pshpack1.h>
418 
423 #define USBD_ISO_START_FRAME_RANGE 1024
425 
426 
428 typedef enum _BMREQUEST_DIR
429 {
430  BMREQUEST_DIR_HOST_TO_DEVICE = 0,
431  BMREQUEST_DIR_DEVICE_TO_HOST = 1,
432 } BMREQUEST_DIR;
433 
435 typedef enum _BMREQUEST_TYPE
436 {
439 
442 
446 
448 typedef enum _BMREQUEST_RECIPIENT
449 {
452 
455 
458 
462 
464 #define MAXIMUM_USB_STRING_LENGTH 255
465 
467 typedef enum _USB_GETSTATUS
468 {
471 
474 } USB_GETSTATUS;
475 
477 typedef enum _USB_DESCRIPTOR_TYPE
478 {
481 
484 
487 
490 
493 
496 
499 
502 
505 
508 
511 
515 
517 #define USB_DESCRIPTOR_MAKE_TYPE_AND_INDEX(d, i) \
518  ((USHORT)((USHORT)d<<8 | i))
519 
521 #define USB_ENDPOINT_TYPE_MASK 0x03
522 
524 #define USB_ENDPOINT_TYPE_CONTROL 0x00
525 
527 #define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01
528 
530 #define USB_ENDPOINT_TYPE_BULK 0x02
531 
533 #define USB_ENDPOINT_TYPE_INTERRUPT 0x03
534 
536 #define USB_CONFIG_POWERED_MASK 0xc0
537 
539 typedef enum _USB_CONFIG_BM_ATTRIBUTE_ENUM
540 {
543 
546 
550 
552 #define USB_ENDPOINT_DIRECTION_MASK 0x80
553 
555 #define USB_ENDPOINT_ADDRESS_MASK 0x0F
556 
558 
561 #define USB_ENDPOINT_DIRECTION_OUT(addr) (!((addr) & USB_ENDPOINT_DIRECTION_MASK))
562 
564 
567 #define USB_ENDPOINT_DIRECTION_IN(addr) ((addr) & USB_ENDPOINT_DIRECTION_MASK)
568 
570 /*
571 * see Chapter 9 of the USB 2.0 specification for
572 * more information.
573 *
574 * These are the correct values based on the USB 2.0 specification.
575 */
576 typedef enum _USB_REQUEST_ENUM
577 {
580 
583 
586 
589 
592 
595 
598 
601 
604 
607 
611 
613 
617 typedef enum _USB_DEVICE_CLASS_ENUM
618 {
621 
624 
627 
630 
633 
636 
639 
642 
646 
648 
652 typedef struct _USB_DEVICE_DESCRIPTOR
653 {
655  UCHAR bLength;
656 
659 
661 
664  USHORT bcdUSB;
665 
668 
671 
674 
677 
679  USHORT idVendor;
680 
682  USHORT idProduct;
683 
685  USHORT bcdDevice;
686 
689 
691  UCHAR iProduct;
692 
695 
698 
702 
704 
708 typedef struct _USB_ENDPOINT_DESCRIPTOR
709 {
711  UCHAR bLength;
712 
715 
717 
723 
725 
732 
735 
737  UCHAR bInterval;
738 
742 
743 #if _MSC_VER >= 1200
744 #pragma warning(push)
745 #endif
746 #pragma warning (disable:4201)
747 #pragma warning(disable:4214) // named type definition in parentheses
748 
750 /*
751 *
752 * This descriptor is documented in the USB 3.0 specification.
753 * All multiple-byte fields are represented in host-endian format.
754 *
755 */
756 typedef struct _USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR
757 {
759  UCHAR bLength;
760 
763 
765  UCHAR bMaxBurst;
766 
767  union
768  {
769  UCHAR AsUchar;
770  struct
771  {
772 
774  UCHAR MaxStreams : 5;
775 
776  UCHAR Reserved1 : 3;
777  } Bulk;
778  struct
779  {
780 
782  UCHAR Mult : 2;
783 
784  UCHAR Reserved2 : 5;
785 
786  UCHAR SspCompanion : 1;
787  } Isochronous;
788  } bmAttributes;
789 
792 } USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR, *PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR;
793 
798 /*
800  * This is a variable length descriptor. The length of the \b CapabilityData is determined using the \b bLength member.
801  *
802  */
803 typedef struct _BOS_DEV_CAPABILITY_DESCRIPTOR
804 {
806  UCHAR bLength;
807 
810 
813 
815  UCHAR CapabilityData[0];
816 }BOS_DEV_CAPABILITY_DESCRIPTOR, *PBOS_DEV_CAPABILITY_DESCRIPTOR;
817 
819 typedef enum _BOS_CAPABILITY_TYPE
820 {
823 
826 
829 
832 
835 
838 
841 
844 
847 
850 
853 
856 
859 
862 
865 
869 
871 /*
872  * The BOS descriptor returns a set of device - level capability descriptors for the USB device.
873  *
874  * This descriptor is followed by and array of /ref BOS_DEV_CAPABILITY_DESCRIPTOR descriptors.
875  * The number of elements in this array is specified by /b bNumDeviceCaps.
876  */
877 typedef struct _BOS_DESCRIPTOR
878 {
880  UCHAR bLength;
881 
884 
886  USHORT wTotalLength;
887 
890 
891  UCHAR DevCapabilityDescriptors[0];
892 
893 }BOS_DESCRIPTOR, *PBOS_DESCRIPTOR;
894 
896 typedef struct _BOS_USB_2_0_EXTENSION_DESCRIPTOR
897 {
899  UCHAR bLength;
900 
903 
906 
909 
910 }BOS_USB_2_0_EXTENSION_DESCRIPTOR, *PBOS_USB_2_0_EXTENSION_DESCRIPTOR;
911 
913 typedef struct _BOS_SS_USB_DEVICE_CAPABILITY_DESCRIPTOR
914 {
916  UCHAR bLength;
917 
920 
923 
926 
929 
932 
935 
938 
939 }BOS_SS_USB_DEVICE_CAPABILITY_DESCRIPTOR, *PBOS_SS_USB_DEVICE_CAPABILITY_DESCRIPTOR;
940 
942 typedef struct _BOS_CONTAINER_ID_DESCRIPTOR
943 {
945  UCHAR bLength;
946 
949 
952 
953  // Reserved.
954  UCHAR bReserved;
955 
957  UCHAR ContainerID[16];
958 
959 }BOS_CONTAINER_ID_DESCRIPTOR, *PBOS_CONTAINER_ID_DESCRIPTOR;
960 
962 typedef struct _BOS_PLATFORM_DESCRIPTOR
963 {
965  UCHAR bLength;
966 
969 
970  // Capability type. See \ref BOS_CAPABILITY_TYPE
971  UCHAR bDevCapabilityType;
972 
974  UCHAR bReserved;
975 
977  /*
978  * For Windows OS 2.0 descriptor support, this is "D8DD60DF-4589-4CC7-9CD2-659D9E648A9F" (dashes not included in actual data)
979  */
980  UCHAR PlatformCapabilityUUID[16];
981 
983  UCHAR CapabilityData[0];
984 }BOS_PLATFORM_DESCRIPTOR, * PBOS_PLATFORM_DESCRIPTOR;
985 
987 typedef struct _BOS_WINDOWS_PLATFORM_VERSION
988 {
990 /*
991  * The Windows version indicates the minimum version of Windows that the descriptor set can be applied to.The DWORD value
992  * corresponds to the published NTDDI version constants in SDKDDKVER.H
993  *
994  */
996 
999 
1001  /*
1002  * Vendor defined code to use to retrieve this version of the MS OS 2.0 descriptor and also to set alternate enumeration
1003  * behavior on the device.
1004  */
1006 
1008  /*
1009  * A non-zero value to send to the device to indicate that the device may return non-default USB descriptors for
1010  * enumeration. If the device does not support alternate enumeration, this value shall be 0.
1011  */
1013 
1014 }BOS_WINDOWS_PLATFORM_VERSION, *PBOS_WINDOWS_PLATFORM_VERSION;
1021 typedef struct _USB_MSOSV1_STRING_DESCRIPTOR
1023 {
1025  UCHAR bLength;
1026 
1029 
1031  UCHAR qwSignature[14];
1032 
1035 
1037  UCHAR bPad;
1038 }USB_MSOSV1_STRING_DESCRIPTOR, *PUSB_MSOSV1_STRING_DESCRIPTOR;
1039 
1041 /*
1042  * When requesting Microsoft OS feature descriptors, these values are used in the \b wIndex of the control packet
1043  * to indicate the feature descriptor that is being requested.
1044  */
1045 typedef enum _MSOS_FEATURE_TYPE
1046 {
1049 
1052 
1056 
1057 // !The extended compat ID OS descriptor has two components:
1058 /*
1059 *
1060 * - A fixed-length header section, which contains information about the entire descriptor including the version number,
1061 * the number of function sections, and the descriptor’s total length.
1062 * - One or more fixed-length function sections, which follow the header section. Each function section contains the
1063 * data for the device, or a single interface, function, or single-function group of interfaces. It is not necessary
1064 * to define IDs for every function or interface, but each of them must still have an associated function section.
1065 *
1066 */
1067 typedef struct _MSOSV1_EXTENDED_COMPAT_ID_DESCRIPTOR
1068 {
1070  UINT dwLength;
1071 
1073  USHORT bcdVersion;
1074 
1076  USHORT wIndex;
1077 
1079  UCHAR bCount;
1080 
1082  UCHAR Rsvd[7];
1083 
1084 }MSOSV1_EXTENDED_COMPAT_ID_DESCRIPTOR, *PMSOSV1_EXTENDED_COMPAT_ID_DESCRIPTOR;
1085 
1087 typedef struct _MSOSV1_FUNCTION_DESCRIPTOR
1088 {
1090  /*
1091  * This field specifies the interface or function that is associated with the IDs in this section. To use this
1092  * function section to associate a single-function group of interfaces with a single pair of IDs, set
1093  * bFirstInterfaceNumber to the first interface in the group. Then use an IAD in that interface’s interface
1094  * descriptor to specify which additional interfaces should be included in the group. The interfaces in the
1095  * group must be consecutively numbered. For details, see “Support for USB Interface Association Descriptor
1096  * in Windows.” */ UCHAR bFirstInterfaceNumber; //! Reserved UCHAR Rsvd1[1]; //! The function’s compatible ID /* * This field contains the value of the compatible ID to be associated with this function. Any unused bytes * should be filled with NULLs. If the function does not have a compatible ID, fill the entire field with * NULLs. */ UCHAR CompatibleID[8]; //! The function’s subcompatible ID /* * This field contains the value of the subcompatible ID to be associated with this function. Any * remaining bytes should be filled with NULLs. If the function does not have a subcompatible ID, fill the * entire field with NULLs. */ UCHAR SubCompatibleID[8]; //! Reserved UCHAR Rsvd2[6]; }MSOSV1_FUNCTION_DESCRIPTOR, *PMSOSV1_FUNCTION_DESCRIPTOR; // !The extended properties OS descriptor is a Microsoft OS feature descriptor that can be used to store vendor-specific property data. /* * The extended properties OS descriptor has two components: * - A fixed-length header section, which contains information about the entire descriptor, including the * version number and total size. * - One or more variable-length custom properties sections, which follow the header section. Each section * contains the data for a single custom property. Although the length of custom properties sections can * vary, the format is fixed and vendors must not deviate from it. */ typedef struct _MSOSV1_EXTENDED_PROP_DESCRIPTOR { //! The length, in bytes, of the complete extended prop descriptor UINT dwLength; //! The descriptor’s version number, in binary coded decimal (BCD) format USHORT bcdVersion; //! The index for extended properties OS descriptors USHORT wIndex; //! The number of custom property sections that follow this header section USHORT wCount; //! Placeholder for \b wCount number of custom properties. See \ref MSOSV1_CUSTOM_PROP_DESCRIPTOR and \ref MSOS_CUSTOM_PROP_ELEMENT UCHAR CustomProperties[0]; }MSOSV1_EXTENDED_PROP_DESCRIPTOR, * PMSOSV1_EXTENDED_PROP_DESCRIPTOR; //! A custom property section contains the information for a single property /* * An interface that has an associated extended properties OS feature descriptor can have one or more * custom property sections following the header section. * * This section is followed by a variable length property name and data field: * - wPropertyNameLength in bytes (USHORT) * The length of bPropertyName, in bytes, including the trailing NULL character. wPropertyNameLength * is an unsigned 2-byte value, to support the use of long property names. * - bPropertyName[wPropertyNameLength] * The property name, as a NULL-terminated Unicode string. * - wPropertyDataLength in bytes (USHORT) * The size of the bPropertyData field, in bytes. * - bPropertyData[wPropertyDataLength] * The property data. * */ typedef struct _MSOSV1_CUSTOM_PROP_DESCRIPTOR { //! The size of this custom properties section UINT dwSize; //! The type of data associated with the section /* * - 0 RESERVED * - 1 A NULL-terminated Unicode String (REG_SZ) * - 2 A NULL-terminated Unicode String that includes environment variables (REG_EXPAND_SZ) * - 3 Free-form binary (REG_BINARY) * - 4 A little-endian 32-bit integer (REG_DWORD_LITTLE_ENDIAN) * - 5 A big-endian 32-bit integer (REG_DWORD_BIG_ENDIAN) * - 6 A NULL-terminated Unicode string that contains a symbolic link (REG_LINK) * - 7 Multiple NULL-terminated Unicode strings (REG_MULTI_SZ) * - 8 and higher RESERVED */ UINT dwPropertyDataType; //! Placeholder for variable length property name and data field. see \ref MSOS_CUSTOM_PROP_ELEMENT UCHAR CustomProperty[0]; }MSOSV1_CUSTOM_PROP_DESCRIPTOR, * PMSOSV1_CUSTOM_PROP_DESCRIPTOR; //! Helper structure for parsing a /ref MSOSV1_CUSTOM_PROP_DESCRIPTOR or a \ref MSOSV2_FEATURE_REG_PROPERTY_DESCRIPTOR typedef struct _MSOS_CUSTOM_PROP_ELEMENT { USHORT wPropertyNameLength; PWCHAR pPropertyName; USHORT wPropertyDataLength; PUCHAR pPropertyData; }MSOS_CUSTOM_PROP_ELEMENT,*PMSOS_CUSTOM_PROP_ELEMENT; /*! @} */ /*! \addtogroup msosv2_desc * @{ */ //! Microsoft OS 2.0 descriptor wDescriptorType values typedef enum _MSOSV2_DESCRIPTOR_TYPE { //! The MS OS 2.0 descriptor set header. MSOSV2_DESCRIPTOR_TYPE_SET_HEADER_DESCRIPTOR = 0x00, //! Microsoft OS 2.0 configuration subset header. MSOSV2_DESCRIPTOR_TYPE_SUBSET_HEADER_CONFIGURATION = 0x01, //! Microsoft OS 2.0 function subset header. MSOSV2_DESCRIPTOR_TYPE_SUBSET_HEADER_FUNCTION = 0x02, //! Microsoft OS 2.0 compatible ID descriptor. MSOSV2_DESCRIPTOR_TYPE_FEATURE_COMPATIBLE_ID = 0x03, //! Microsoft OS 2.0 registry property descriptor. MSOSV2_DESCRIPTOR_TYPE_FEATURE_REG_PROPERTY = 0x04, //! Microsoft OS 2.0 minimum USB resume time descriptor. MSOSV2_DESCRIPTOR_TYPE_FEATURE_MIN_RESUME_TIME = 0x05, //! Microsoft OS 2.0 model ID descriptor. MSOSV2_DESCRIPTOR_TYPE_FEATURE_MODEL_ID = 0x06, //! Microsoft OS 2.0 CCGP device descriptor. MSOSV2_DESCRIPTOR_TYPE_FEATURE_CCGP_DEVICE = 0x07, //! Microsoft OS 2.0 vendor revision descriptor. MSOSV2_DESCRIPTOR_TYPE_FEATURE_VENDOR_REVISION = 0x08, }MSOSV2_DESCRIPTOR_TYPE; //! All MS OS V2.0 descriptors start with these two fields. typedef struct _MSOSV2_COMMON_DESCRIPTOR { //! The length, in bytes, of this descriptor. USHORT wLength; //! See \ref MSOSV2_DESCRIPTOR_TYPE USHORT wDescriptorType; }MSOSV2_COMMON_DESCRIPTOR, * PMSOSV2_COMMON_DESCRIPTOR; //! Microsoft OS 2.0 descriptor set header typedef struct _MSOSV2_SET_HEADER_DESCRIPTOR { //! The length, in bytes, of this header. Shall be set to 10. USHORT wLength; //! \ref MSOSV2_DESCRIPTOR_TYPE_SET_HEADER_DESCRIPTOR USHORT wDescriptorType; //! Windows version. UINT dwWindowsVersion; //! The size of entire MS OS 2.0 descriptor set. The value shall match the value in the descriptor set information structure. See \ref BOS_WINDOWS_PLATFORM_VERSION::wMSOSDescriptorSetTotalLength USHORT wTotalLength; }MSOSV2_SET_HEADER_DESCRIPTOR,*PMSOSV2_SET_HEADER_DESCRIPTOR; //! Microsoft OS 2.0 configuration subset header typedef struct _MSOSV2_SUBSET_HEADER_CONFIGURATION_DESCRIPTOR { //! The length, in bytes, of this subset header. Shall be set to 8. USHORT wLength; //! \ref MSOSV2_DESCRIPTOR_TYPE_SUBSET_HEADER_CONFIGURATION USHORT wDescriptorType; //! The configuration value for the USB configuration to which this subset applies. UCHAR bConfigurationValue; //! Reserved UCHAR bReserved; //! The size of entire configuration subset including this header. USHORT wTotalLength; }MSOSV2_SUBSET_HEADER_CONFIGURATION_DESCRIPTOR, * PMSOSV2_SUBSET_HEADER_CONFIGURATION_DESCRIPTOR; //! Microsoft OS 2.0 function subset header typedef struct _MSOSV2_SUBSET_HEADER_FUNCTION_DESCRIPTOR { //! The length, in bytes, of this subset header. Shall be set to 8. USHORT wLength; //! \ref MSOSV2_DESCRIPTOR_TYPE_SUBSET_HEADER_FUNCTION USHORT wDescriptorType; //! The interface number for the first interface of the function to which this subset applies. UCHAR bFirstInterface; //! Reserved UCHAR bReserved; //! The size of entire function subset including this header. USHORT wSubsetLength; }MSOSV2_SUBSET_HEADER_FUNCTION_DESCRIPTOR, * PMSOSV2_SUBSET_HEADER_FUNCTION_DESCRIPTOR; //! Microsoft OS 2.0 compatible ID descriptor /* * The Microsoft OS 2.0 compatible ID descriptor is used to define a compatible device ID. Its usage is * identical to the Microsoft OS extended configuration descriptor defined in MS OS descriptors specification * version 1.0. * * The compatible ID can be applied to the entire device or a specific function within a composite device. */ typedef struct _MSOSV2_FEATURE_COMPATBLE_ID_DESCRIPTOR { //! The length, bytes, of the compatible ID descriptor including value descriptors. Shall be set to 20. USHORT wLength; //! \ref MSOSV2_DESCRIPTOR_TYPE_FEATURE_COMPATIBLE_ID USHORT wDescriptorType; //! Compatible ID String /* * This field contains the value of the compatible ID to be associated with this function. Any unused bytes * should be filled with NULLs. If the function does not have a compatible ID, fill the entire field with * NULLs. */ UCHAR CompatibleID[8]; //! Sub-compatible ID String /* * This field contains the value of the subcompatible ID to be associated with this function. Any * remaining bytes should be filled with NULLs. If the function does not have a subcompatible ID, fill the * entire field with NULLs. */ UCHAR SubCompatibleID[8]; }MSOSV2_FEATURE_COMPATBLE_ID_DESCRIPTOR, * PMSOSV2_FEATURE_COMPATBLE_ID_DESCRIPTOR; //! Microsoft OS 2.0 registry property descriptor /* * The Microsoft OS 2.0 registry property descriptor is used to add per-device or per-function registry values * that is read by the Windows USB driver stack or the device’s function driver. Usage is similar to Microsoft * OS extended property descriptor defined MS OS descriptors specification version 1.0. * * Windows retrieves MS OS 2.0 registry property descriptor values during device enumeration as part of the * overall descriptor set. However, only the values that are retrieved during the first device enumeration are * written to the registry and used subsequently. The behavior is to maintain registry values that might be * changed by the user. * * The registry property descriptor can be applied to the entire device or a specific function within a * composite device. */ typedef struct _MSOSV2_FEATURE_REG_PROPERTY_DESCRIPTOR { //! The length, in bytes, of this descriptor. USHORT wLength; //! \ref MSOSV2_DESCRIPTOR_TYPE_FEATURE_REG_PROPERTY USHORT wDescriptorType; //! The type of data associated with the section /* * - 0 RESERVED * - 1 A NULL-terminated Unicode String (REG_SZ) * - 2 A NULL-terminated Unicode String that includes environment variables (REG_EXPAND_SZ) * - 3 Free-form binary (REG_BINARY) * - 4 A little-endian 32-bit integer (REG_DWORD_LITTLE_ENDIAN) * - 5 A big-endian 32-bit integer (REG_DWORD_BIG_ENDIAN) * - 6 A NULL-terminated Unicode string that contains a symbolic link (REG_LINK) * - 7 Multiple NULL-terminated Unicode strings (REG_MULTI_SZ) * - 8 and higher RESERVED */ USHORT wPropertyDataType; //! Placeholder for variable length property name and data field. see \ref MSOS_CUSTOM_PROP_ELEMENT UCHAR CustomProperty[0]; }MSOSV2_FEATURE_REG_PROPERTY_DESCRIPTOR, * PMSOSV2_FEATURE_REG_PROPERTY_DESCRIPTOR; //! Microsoft OS 2.0 minimum USB resume time descriptor /* * The Microsoft OS 2.0 minimum USB resume time descriptor is used to indicate to the Windows USB driver * stack the minimum time needed to recover after resuming from suspend, and how long the device requires * resume signaling to be asserted. This descriptor is used for a device operating at high, full, or * low-speed. It is not used for a device operating at SuperSpeed or higher. * * This descriptor allows devices to recover faster than the default 10 millisecond specified in the USB * 2.0 specification. It can also allow the host to assert resume signaling for less than the 20 * milliseconds required in the USB 2.0 specification, in cases where the timing of resume signaling is * controlled by software. * * The USB resume time descriptor is applied to the entire device. */ typedef struct _MSOSV2_FEATURE_MIN_RESUME_TIME_DESCRIPTOR { //! The length, in bytes, of this descriptor. Shall be set to 6. USHORT wLength; //! \ref MSOSV2_DESCRIPTOR_TYPE_FEATURE_MIN_RESUME_TIME USHORT wDescriptorType; //! The number of milliseconds the device requires to recover from port resume. (Valid values are 0 to 10) UCHAR bResumeRecoveryTime; //! The number of milliseconds the device requires resume signaling to be asserted. (Valid values 1 to 20) UCHAR bResumeSignalingTime; }MSOSV2_FEATURE_MIN_RESUME_TIME_DESCRIPTOR, * PMSOSV2_FEATURE_MIN_RESUME_TIME_DESCRIPTOR; //! Microsoft OS 2.0 model ID descriptor /* * The Microsoft OS 2.0 model ID descriptor is used to uniquely identify the physical device. * * The model ID descriptor is applied to the entire device. */ typedef struct _MSOSV2_FEATURE_MODEL_ID_DESCRIPTOR { //! The length, in bytes, of this descriptor. Shall be set to 20. USHORT wLength; //! \ref MSOSV2_DESCRIPTOR_TYPE_FEATURE_MODEL_ID USHORT wDescriptorType; //! This is a 128-bit number that uniquely identifies a physical device. UCHAR ModelID[16]; }MSOSV2_FEATURE_MODEL_ID_DESCRIPTOR, * PMSOSV2_FEATURE_MODEL_ID_DESCRIPTOR; //! Microsoft OS 2.0 CCGP device descriptor /* * The Microsoft OS 2.0 CCGP device descriptor is used to indicate that the device should be treated as a * composite device by Windows regardless of the number of interfaces, configuration, or class, subclass, * and protocol codes, the device reports. * * The CCGP device descriptor must be applied to the entire device. */ typedef struct _MSOSV2_FEATURE_CCGP_DESCRIPTOR { //! The length, in bytes, of this descriptor. Shall be set to 4. USHORT wLength; //! \ref MSOSV2_DESCRIPTOR_TYPE_FEATURE_CCGP_DEVICE USHORT wDescriptorType; }MSOSV2_FEATURE_CCGP_DESCRIPTOR, * PMSOSV2_FEATURE_CCGP_DESCRIPTOR; //! Microsoft OS 2.0 vendor revision descriptor /* * The Microsoft OS 2.0 vendor revision descriptor is used to indicate the revision of registry property * and other MSOS descriptors. If this value changes between enumerations the registry property * descriptors will be updated in registry during that enumeration. You must always change this value * if you are adding/ modifying any registry property or other MSOS descriptors. * * The vendor revision descriptor must be applied at the device scope for a non-composite device or for * MSOS descriptors that apply to the device scope of a composite device. Additionally, for a composite * device, the vendor revision descriptor must be provided in every function subset and may be updated * independently per-function. */ typedef struct _MSOSV2_FEATURE_VENDOR_REVISION_DESCRIPTOR { //! The length, in bytes, of this descriptor. Shall be set to 6. USHORT wLength; //! \ref MSOSV2_DESCRIPTOR_TYPE_FEATURE_VENDOR_REVISION USHORT wDescriptorType; //! Revision number associated with the descriptor set. /* * Modify it every time you add / modify a registry property or other MSOS descriptor.Shell set to * greater than or equal to 1. */ USHORT VendorRevision; }MSOSV2_FEATURE_VENDOR_REVISION_DESCRIPTOR, * PMSOSV2_FEATURE_VENDOR_REVISION_DESCRIPTOR; /*! @} */ #if _MSC_VER >= 1200 #pragma warning(pop) #endif //! A structure representing the standard USB configuration descriptor. /* * * This descriptor is documented in section 9.6.3 of the USB 2.0 specification. * All multiple-byte fields are represented in host-endian format. * */ typedef struct _USB_CONFIGURATION_DESCRIPTOR { //! Size of this descriptor (in bytes) UCHAR bLength; //! Descriptor type UCHAR bDescriptorType; //! Total length of data returned for this configuration USHORT wTotalLength; //! Number of interfaces supported by this configuration UCHAR bNumInterfaces; //! Identifier value for this configuration UCHAR bConfigurationValue; //! Index of string descriptor describing this configuration UCHAR iConfiguration; //! Configuration characteristics UCHAR bmAttributes; //! Maximum power consumption of the USB device from this bus in this configuration when the device is fully operation. /*! * Expressed in units of 2 mA. */ UCHAR MaxPower; } USB_CONFIGURATION_DESCRIPTOR; //! pointer to a \c USB_CONFIGURATION_DESCRIPTOR typedef USB_CONFIGURATION_DESCRIPTOR* PUSB_CONFIGURATION_DESCRIPTOR; //! A structure representing the standard USB interface descriptor. /*! * This descriptor is documented in section 9.6.5 of the USB 2.0 specification. * All multiple-byte fields are represented in host-endian format. */ typedef struct _USB_INTERFACE_DESCRIPTOR { //! Size of this descriptor (in bytes) UCHAR bLength; //! Descriptor type UCHAR bDescriptorType; //! Number of this interface UCHAR bInterfaceNumber; //! Value used to select this alternate setting for this interface UCHAR bAlternateSetting; //! Number of endpoints used by this interface (excluding the control endpoint) UCHAR bNumEndpoints; //! USB-IF class code for this interface UCHAR bInterfaceClass; //! USB-IF subclass code for this interface UCHAR bInterfaceSubClass; //! USB-IF protocol code for this interface UCHAR bInterfaceProtocol; //! Index of string descriptor describing this interface UCHAR iInterface; } USB_INTERFACE_DESCRIPTOR; //! pointer to a \c USB_INTERFACE_DESCRIPTOR typedef USB_INTERFACE_DESCRIPTOR* PUSB_INTERFACE_DESCRIPTOR; //! A structure representing the standard USB string descriptor. /*! * This descriptor is documented in section 9.6.5 of the USB 2.0 specification. * All multiple-byte fields are represented in host-endian format. */ typedef struct _USB_STRING_DESCRIPTOR { //! Size of this descriptor (in bytes) UCHAR bLength; //! Descriptor type UCHAR bDescriptorType; //! Content of the string WCHAR bString[1]; } USB_STRING_DESCRIPTOR; //! pointer to a \c USB_STRING_DESCRIPTOR typedef USB_STRING_DESCRIPTOR* PUSB_STRING_DESCRIPTOR; //! A structure representing the common USB descriptor. typedef struct _USB_COMMON_DESCRIPTOR { //! Size of this descriptor (in bytes) UCHAR bLength; //! Descriptor type UCHAR bDescriptorType; } USB_COMMON_DESCRIPTOR; //! pointer to a \c USB_COMMON_DESCRIPTOR typedef USB_COMMON_DESCRIPTOR* PUSB_COMMON_DESCRIPTOR; #if _MSC_VER >= 1200 #pragma warning(push) #endif #pragma warning (disable:4201) #pragma warning(disable:4214) // named type definition in parentheses //! Allows hardware manufacturers to define groupings of interfaces. /*! * * The ECN specifies a USB descriptor, called the Interface Association * Descriptor (IAD). * * The Universal Serial Bus Specification, revision 2.0, does not support * grouping more than one interface of a composite device within a single * function. However, the USB Device Working Group (DWG) created USB device * classes that allow for functions with multiple interfaces, and the USB * Implementor's Forum issued an Engineering Change Notification (ECN) that * defines a mechanism for grouping interfaces. * */ typedef struct _USB_INTERFACE_ASSOCIATION_DESCRIPTOR { //! Size of this descriptor (in bytes) UCHAR bLength; //! Descriptor type UCHAR bDescriptorType; //! First interface number of the set of interfaces that follow this descriptor UCHAR bFirstInterface; //! The Number of interfaces follow this descriptor that are considered "associated" UCHAR bInterfaceCount; //! \c bInterfaceClass used for this associated interfaces UCHAR bFunctionClass; //! \c bInterfaceSubClass used for the associated interfaces UCHAR bFunctionSubClass; //! \c bInterfaceProtocol used for the associated interfaces UCHAR bFunctionProtocol; //! Index of string descriptor describing the associated interfaces UCHAR iFunction; } USB_INTERFACE_ASSOCIATION_DESCRIPTOR; //! pointer to a \c USB_INTERFACE_ASSOCIATION_DESCRIPTOR typedef USB_INTERFACE_ASSOCIATION_DESCRIPTOR* PUSB_INTERFACE_ASSOCIATION_DESCRIPTOR; #if _MSC_VER >= 1200 #pragma warning(pop) #endif /*! @} */ #include <poppack.h> #endif // __USB_H__ #ifndef _LIBUSBK_LIBK_TYPES /*! \addtogroup libk * @{ */ //! Usb handle specific properties that can be retrieved with \ref UsbK_GetProperty. typedef enum _KUSB_PROPERTY { //! Get the internal device file handle used for operations such as GetOverlappedResult or DeviceIoControl. KUSB_PROPERTY_DEVICE_FILE_HANDLE, KUSB_PROPERTY_COUNT } KUSB_PROPERTY; //! Supported driver id enumeration. typedef enum _KUSB_DRVID { //! libusbK.sys driver ID KUSB_DRVID_LIBUSBK, //! libusb0.sys driver ID KUSB_DRVID_LIBUSB0, //! WinUSB.sys driver ID KUSB_DRVID_WINUSB, //! libusb0.sys filter driver ID KUSB_DRVID_LIBUSB0_FILTER, //! Supported driver count KUSB_DRVID_COUNT } KUSB_DRVID; //! Supported function id enumeration. typedef enum _KUSB_FNID { //! \ref UsbK_Init dynamic driver function id. KUSB_FNID_Init, //! \ref UsbK_Free dynamic driver function id. KUSB_FNID_Free, //! \ref UsbK_ClaimInterface dynamic driver function id. KUSB_FNID_ClaimInterface, //! \ref UsbK_ReleaseInterface dynamic driver function id. KUSB_FNID_ReleaseInterface, //! \ref UsbK_SetAltInterface dynamic driver function id. KUSB_FNID_SetAltInterface, //! \ref UsbK_GetAltInterface dynamic driver function id. KUSB_FNID_GetAltInterface, //! \ref UsbK_GetDescriptor dynamic driver function id. KUSB_FNID_GetDescriptor, //! \ref UsbK_ControlTransfer dynamic driver function id. KUSB_FNID_ControlTransfer, //! \ref UsbK_SetPowerPolicy dynamic driver function id. KUSB_FNID_SetPowerPolicy, //! \ref UsbK_GetPowerPolicy dynamic driver function id. KUSB_FNID_GetPowerPolicy, //! \ref UsbK_SetConfiguration dynamic driver function id. KUSB_FNID_SetConfiguration, //! \ref UsbK_GetConfiguration dynamic driver function id. KUSB_FNID_GetConfiguration, //! \ref UsbK_ResetDevice dynamic driver function id. KUSB_FNID_ResetDevice, //! \ref UsbK_Initialize dynamic driver function id. KUSB_FNID_Initialize, //! \ref UsbK_SelectInterface dynamic driver function id. KUSB_FNID_SelectInterface, //! \ref UsbK_GetAssociatedInterface dynamic driver function id. KUSB_FNID_GetAssociatedInterface, //! \ref UsbK_Clone dynamic driver function id. KUSB_FNID_Clone, //! \ref UsbK_QueryInterfaceSettings dynamic driver function id. KUSB_FNID_QueryInterfaceSettings, //! \ref UsbK_QueryDeviceInformation dynamic driver function id. KUSB_FNID_QueryDeviceInformation, //! \ref UsbK_SetCurrentAlternateSetting dynamic driver function id. KUSB_FNID_SetCurrentAlternateSetting, //! \ref UsbK_GetCurrentAlternateSetting dynamic driver function id. KUSB_FNID_GetCurrentAlternateSetting, //! \ref UsbK_QueryPipe dynamic driver function id. KUSB_FNID_QueryPipe, //! \ref UsbK_SetPipePolicy dynamic driver function id. KUSB_FNID_SetPipePolicy, //! \ref UsbK_GetPipePolicy dynamic driver function id. KUSB_FNID_GetPipePolicy, //! \ref UsbK_ReadPipe dynamic driver function id. KUSB_FNID_ReadPipe, //! \ref UsbK_WritePipe dynamic driver function id. KUSB_FNID_WritePipe, //! \ref UsbK_ResetPipe dynamic driver function id. KUSB_FNID_ResetPipe, //! \ref UsbK_AbortPipe dynamic driver function id. KUSB_FNID_AbortPipe, //! \ref UsbK_FlushPipe dynamic driver function id. KUSB_FNID_FlushPipe, //! \ref UsbK_IsoReadPipe dynamic driver function id. KUSB_FNID_IsoReadPipe, //! \ref UsbK_IsoWritePipe dynamic driver function id. KUSB_FNID_IsoWritePipe, //! \ref UsbK_GetCurrentFrameNumber dynamic driver function id. KUSB_FNID_GetCurrentFrameNumber, //! \ref UsbK_GetOverlappedResult dynamic driver function id. KUSB_FNID_GetOverlappedResult, //! \ref UsbK_GetProperty dynamic driver function id. KUSB_FNID_GetProperty, //! \ref UsbK_IsochReadPipe dynamic driver function id. KUSB_FNID_IsochReadPipe, //! \ref UsbK_IsochWritePipe dynamic driver function id. KUSB_FNID_IsochWritePipe, //! \ref UsbK_QueryPipeEx dynamic driver function id. KUSB_FNID_QueryPipeEx, //! \ref UsbK_GetSuperSpeedPipeCompanionDescriptor dynamic driver function id. KUSB_FNID_GetSuperSpeedPipeCompanionDescriptor, //! Supported function count KUSB_FNID_COUNT, } KUSB_FNID; typedef BOOL KUSB_API KUSB_Init ( _out KUSB_HANDLE* InterfaceHandle, _in KLST_DEVINFO_HANDLE DevInfo); typedef BOOL KUSB_API KUSB_Free ( _in KUSB_HANDLE InterfaceHandle); typedef BOOL KUSB_API KUSB_ClaimInterface ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR NumberOrIndex, _in BOOL IsIndex); typedef BOOL KUSB_API KUSB_ReleaseInterface ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR NumberOrIndex, _in BOOL IsIndex); typedef BOOL KUSB_API KUSB_SetAltInterface ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR NumberOrIndex, _in BOOL IsIndex, _in UCHAR AltSettingNumber); typedef BOOL KUSB_API KUSB_GetAltInterface ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR NumberOrIndex, _in BOOL IsIndex, _out PUCHAR AltSettingNumber); typedef BOOL KUSB_API KUSB_GetDescriptor ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR DescriptorType, _in UCHAR Index, _in USHORT LanguageID, _out PUCHAR Buffer, _in UINT BufferLength, _outopt PUINT LengthTransferred); typedef BOOL KUSB_API KUSB_ControlTransfer ( _in KUSB_HANDLE InterfaceHandle, _in WINUSB_SETUP_PACKET SetupPacket, _refopt PUCHAR Buffer, _in UINT BufferLength, _outopt PUINT LengthTransferred, _inopt LPOVERLAPPED Overlapped); typedef BOOL KUSB_API KUSB_SetPowerPolicy ( _in KUSB_HANDLE InterfaceHandle, _in UINT PolicyType, _in UINT ValueLength, _in PVOID Value); typedef BOOL KUSB_API KUSB_GetPowerPolicy ( _in KUSB_HANDLE InterfaceHandle, _in UINT PolicyType, _ref PUINT ValueLength, _out PVOID Value); typedef BOOL KUSB_API KUSB_SetConfiguration ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR ConfigurationNumber); typedef BOOL KUSB_API KUSB_GetConfiguration ( _in KUSB_HANDLE InterfaceHandle, _out PUCHAR ConfigurationNumber); typedef BOOL KUSB_API KUSB_ResetDevice ( _in KUSB_HANDLE InterfaceHandle); typedef BOOL KUSB_API KUSB_Initialize ( _in HANDLE DeviceHandle, _out KUSB_HANDLE* InterfaceHandle); typedef BOOL KUSB_API KUSB_SelectInterface ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR NumberOrIndex, _in BOOL IsIndex); typedef BOOL KUSB_API KUSB_GetAssociatedInterface ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR AssociatedInterfaceIndex, _out KUSB_HANDLE* AssociatedInterfaceHandle); typedef BOOL KUSB_API KUSB_Clone ( _in KUSB_HANDLE InterfaceHandle, _out KUSB_HANDLE* DstInterfaceHandle); typedef BOOL KUSB_API KUSB_QueryInterfaceSettings ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR AltSettingIndex, _out PUSB_INTERFACE_DESCRIPTOR UsbAltInterfaceDescriptor); typedef BOOL KUSB_API KUSB_QueryDeviceInformation ( _in KUSB_HANDLE InterfaceHandle, _in UINT InformationType, _ref PUINT BufferLength, _ref PUCHAR Buffer); typedef BOOL KUSB_API KUSB_SetCurrentAlternateSetting ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR AltSettingNumber); typedef BOOL KUSB_API KUSB_GetCurrentAlternateSetting ( _in KUSB_HANDLE InterfaceHandle, _out PUCHAR AltSettingNumber); typedef BOOL KUSB_API KUSB_QueryPipe ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR AltSettingNumber, _in UCHAR PipeIndex, _out PWINUSB_PIPE_INFORMATION PipeInformation); typedef BOOL KUSB_API KUSB_QueryPipeEx( _in KUSB_HANDLE InterfaceHandle, _in UCHAR AlternateSettingNumber, _in UCHAR PipeIndex, _out PWINUSB_PIPE_INFORMATION_EX PipeInformationEx); typedef BOOL KUSB_API KUSB_GetSuperSpeedPipeCompanionDescriptor( __in KUSB_HANDLE Handle, __in UCHAR AltSettingNumber, __in UCHAR PipeIndex, __out PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR PipeCompanionDescriptor); typedef BOOL KUSB_API KUSB_SetPipePolicy ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID, _in UINT PolicyType, _in UINT ValueLength, _in PVOID Value); typedef BOOL KUSB_API KUSB_GetPipePolicy ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID, _in UINT PolicyType, _ref PUINT ValueLength, _out PVOID Value); typedef BOOL KUSB_API KUSB_ReadPipe ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID, _out PUCHAR Buffer, _in UINT BufferLength, _outopt PUINT LengthTransferred, _inopt LPOVERLAPPED Overlapped); typedef BOOL KUSB_API KUSB_WritePipe ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID, _in PUCHAR Buffer, _in UINT BufferLength, _outopt PUINT LengthTransferred, _inopt LPOVERLAPPED Overlapped); typedef BOOL KUSB_API KUSB_ResetPipe ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID); typedef BOOL KUSB_API KUSB_AbortPipe ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID); typedef BOOL KUSB_API KUSB_FlushPipe ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID); typedef BOOL KUSB_API KUSB_IsoReadPipe ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID, _out PUCHAR Buffer, _in UINT BufferLength, _in LPOVERLAPPED Overlapped, _refopt PKISO_CONTEXT IsoContext); typedef BOOL KUSB_API KUSB_IsoWritePipe ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID, _in PUCHAR Buffer, _in UINT BufferLength, _in LPOVERLAPPED Overlapped, _refopt PKISO_CONTEXT IsoContext); typedef BOOL KUSB_API KUSB_GetCurrentFrameNumber ( _in KUSB_HANDLE InterfaceHandle, _out PUINT FrameNumber); typedef BOOL KUSB_API KUSB_GetOverlappedResult ( _in KUSB_HANDLE InterfaceHandle, _in LPOVERLAPPED Overlapped, _out PUINT lpNumberOfBytesTransferred, _in BOOL bWait); typedef BOOL KUSB_API KUSB_GetProperty ( _in KUSB_HANDLE InterfaceHandle, _in KUSB_PROPERTY PropertyType, _ref PUINT PropertySize, _out PVOID Value); typedef BOOL KUSB_API KUSB_IsochReadPipe( _in KISOCH_HANDLE IsochHandle, _inopt UINT DataLength, _refopt PUINT FrameNumber, _inopt UINT NumberOfPackets, _in LPOVERLAPPED Overlapped); typedef BOOL KUSB_API KUSB_IsochWritePipe( _in KISOCH_HANDLE IsochHandle, _inopt UINT DataLength, _refopt PUINT FrameNumber, _inopt UINT NumberOfPackets, _in LPOVERLAPPED Overlapped); //! USB core driver API information structure. /*! * This structure is part of \ref KUSB_DRIVER_API and contains * driver and user specific information. * */ typedef struct _KUSB_DRIVER_API_INFO { //! \readonly Driver id of the driver api. INT DriverID; //! \readonly Number of valid functions contained in the driver API. INT FunctionCount; } KUSB_DRIVER_API_INFO; //! Driver API function set structure. /* * Contains the driver specific USB core function pointer set. * * \note * This structure has a fixed 512 byte structure size. */ typedef struct _KUSB_DRIVER_API { //! Driver API information. KUSB_DRIVER_API_INFO Info; /*! \fn BOOL KUSB_API Init (_out KUSB_HANDLE* InterfaceHandle, _in KLST_DEVINFO_HANDLE DevInfo) * \memberof KUSB_DRIVER_API * \copydoc UsbK_Init */ KUSB_Init* Init; /*! \fn BOOL KUSB_API Free (_in KUSB_HANDLE InterfaceHandle) * \memberof KUSB_DRIVER_API * \copydoc UsbK_Free */ KUSB_Free* Free; /*! \fn BOOL KUSB_API ClaimInterface (_in KUSB_HANDLE InterfaceHandle, _in UCHAR NumberOrIndex, _in BOOL IsIndex) * \memberof KUSB_DRIVER_API * \copydoc UsbK_ClaimInterface */ KUSB_ClaimInterface* ClaimInterface; /*! \fn BOOL KUSB_API ReleaseInterface (_in KUSB_HANDLE InterfaceHandle, _in UCHAR NumberOrIndex, _in BOOL IsIndex) * \memberof KUSB_DRIVER_API * \copydoc UsbK_ReleaseInterface */ KUSB_ReleaseInterface* ReleaseInterface; /*! \fn BOOL KUSB_API SetAltInterface (_in KUSB_HANDLE InterfaceHandle, _in UCHAR NumberOrIndex, _in BOOL IsIndex, _in UCHAR AltSettingNumber) * \memberof KUSB_DRIVER_API * \copydoc UsbK_SetAltInterface */ KUSB_SetAltInterface* SetAltInterface; /*! \fn BOOL KUSB_API GetAltInterface (_in KUSB_HANDLE InterfaceHandle, _in UCHAR NumberOrIndex, _in BOOL IsIndex, _out PUCHAR AltSettingNumber) * \memberof KUSB_DRIVER_API * \copydoc UsbK_GetAltInterface */ KUSB_GetAltInterface* GetAltInterface; /*! \fn BOOL KUSB_API GetDescriptor (_in KUSB_HANDLE InterfaceHandle, _in UCHAR DescriptorType, _in UCHAR Index, _in USHORT LanguageID, _out PUCHAR Buffer, _in UINT BufferLength, _outopt PUINT LengthTransferred) * \memberof KUSB_DRIVER_API * \copydoc UsbK_GetDescriptor */ KUSB_GetDescriptor* GetDescriptor; /*! \fn BOOL KUSB_API ControlTransfer (_in KUSB_HANDLE InterfaceHandle, _in WINUSB_SETUP_PACKET SetupPacket, _refopt PUCHAR Buffer, _in UINT BufferLength, _outopt PUINT LengthTransferred, _inopt LPOVERLAPPED Overlapped) * \memberof KUSB_DRIVER_API * \copydoc UsbK_ControlTransfer */ KUSB_ControlTransfer* ControlTransfer; /*! \fn BOOL KUSB_API SetPowerPolicy (_in KUSB_HANDLE InterfaceHandle, _in UINT PolicyType, _in UINT ValueLength, _in PVOID Value) * \memberof KUSB_DRIVER_API * \copydoc UsbK_SetPowerPolicy */ KUSB_SetPowerPolicy* SetPowerPolicy; /*! \fn BOOL KUSB_API GetPowerPolicy (_in KUSB_HANDLE InterfaceHandle, _in UINT PolicyType, _ref PUINT ValueLength, _out PVOID Value) * \memberof KUSB_DRIVER_API * \copydoc UsbK_GetPowerPolicy */ KUSB_GetPowerPolicy* GetPowerPolicy; /*! \fn BOOL KUSB_API SetConfiguration (_in KUSB_HANDLE InterfaceHandle, _in UCHAR ConfigurationNumber) * \memberof KUSB_DRIVER_API * \copydoc UsbK_SetConfiguration */ KUSB_SetConfiguration* SetConfiguration; /*! \fn BOOL KUSB_API GetConfiguration (_in KUSB_HANDLE InterfaceHandle, _out PUCHAR ConfigurationNumber) * \memberof KUSB_DRIVER_API * \copydoc UsbK_GetConfiguration */ KUSB_GetConfiguration* GetConfiguration; /*! \fn BOOL KUSB_API ResetDevice (_in KUSB_HANDLE InterfaceHandle) * \memberof KUSB_DRIVER_API * \copydoc UsbK_ResetDevice */ KUSB_ResetDevice* ResetDevice; /*! \fn BOOL KUSB_API Initialize (_in HANDLE DeviceHandle, _out KUSB_HANDLE* InterfaceHandle) * \memberof KUSB_DRIVER_API * \copydoc UsbK_Initialize */ KUSB_Initialize* Initialize; /*! \fn BOOL KUSB_API SelectInterface (_in KUSB_HANDLE InterfaceHandle, _in UCHAR NumberOrIndex, _in BOOL IsIndex) * \memberof KUSB_DRIVER_API * \copydoc UsbK_SelectInterface */ KUSB_SelectInterface* SelectInterface; /*! \fn BOOL KUSB_API GetAssociatedInterface (_in KUSB_HANDLE InterfaceHandle, _in UCHAR AssociatedInterfaceIndex, _out KUSB_HANDLE* AssociatedInterfaceHandle) * \memberof KUSB_DRIVER_API * \copydoc UsbK_GetAssociatedInterface */ KUSB_GetAssociatedInterface* GetAssociatedInterface; /*! \fn BOOL KUSB_API Clone (_in KUSB_HANDLE InterfaceHandle, _out KUSB_HANDLE* DstInterfaceHandle) * \memberof KUSB_DRIVER_API * \copydoc UsbK_Clone */ KUSB_Clone* Clone; /*! \fn BOOL KUSB_API QueryInterfaceSettings (_in KUSB_HANDLE InterfaceHandle, _in UCHAR AltSettingIndex, _out PUSB_INTERFACE_DESCRIPTOR UsbAltInterfaceDescriptor) * \memberof KUSB_DRIVER_API * \copydoc UsbK_QueryInterfaceSettings */ KUSB_QueryInterfaceSettings* QueryInterfaceSettings; /*! \fn BOOL KUSB_API QueryDeviceInformation (_in KUSB_HANDLE InterfaceHandle, _in UINT InformationType, _ref PUINT BufferLength, _ref PUCHAR Buffer) * \memberof KUSB_DRIVER_API * \copydoc UsbK_QueryDeviceInformation */ KUSB_QueryDeviceInformation* QueryDeviceInformation; /*! \fn BOOL KUSB_API SetCurrentAlternateSetting (_in KUSB_HANDLE InterfaceHandle, _in UCHAR AltSettingNumber) * \memberof KUSB_DRIVER_API * \copydoc UsbK_SetCurrentAlternateSetting */ KUSB_SetCurrentAlternateSetting* SetCurrentAlternateSetting; /*! \fn BOOL KUSB_API GetCurrentAlternateSetting (_in KUSB_HANDLE InterfaceHandle, _out PUCHAR AltSettingNumber) * \memberof KUSB_DRIVER_API * \copydoc UsbK_GetCurrentAlternateSetting */ KUSB_GetCurrentAlternateSetting* GetCurrentAlternateSetting; /*! \fn BOOL KUSB_API QueryPipe (_in KUSB_HANDLE InterfaceHandle, _in UCHAR AltSettingNumber, _in UCHAR PipeIndex, _out PWINUSB_PIPE_INFORMATION PipeInformation) * \memberof KUSB_DRIVER_API * \copydoc UsbK_QueryPipe */ KUSB_QueryPipe* QueryPipe; /*! \fn BOOL KUSB_API SetPipePolicy (_in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID, _in UINT PolicyType, _in UINT ValueLength, _in PVOID Value) * \memberof KUSB_DRIVER_API * \copydoc UsbK_SetPipePolicy */ KUSB_SetPipePolicy* SetPipePolicy; /*! \fn BOOL KUSB_API GetPipePolicy (_in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID, _in UINT PolicyType, _ref PUINT ValueLength, _out PVOID Value) * \memberof KUSB_DRIVER_API * \copydoc UsbK_GetPipePolicy */ KUSB_GetPipePolicy* GetPipePolicy; /*! \fn BOOL KUSB_API ReadPipe (_in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID, _out PUCHAR Buffer, _in UINT BufferLength, _outopt PUINT LengthTransferred, _inopt LPOVERLAPPED Overlapped) * \memberof KUSB_DRIVER_API * \copydoc UsbK_ReadPipe */ KUSB_ReadPipe* ReadPipe; /*! \fn BOOL KUSB_API WritePipe (_in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID, _in PUCHAR Buffer, _in UINT BufferLength, _outopt PUINT LengthTransferred, _inopt LPOVERLAPPED Overlapped) * \memberof KUSB_DRIVER_API * \copydoc UsbK_WritePipe */ KUSB_WritePipe* WritePipe; /*! \fn BOOL KUSB_API ResetPipe (_in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID) * \memberof KUSB_DRIVER_API * \copydoc UsbK_ResetPipe */ KUSB_ResetPipe* ResetPipe; /*! \fn BOOL KUSB_API AbortPipe (_in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID) * \memberof KUSB_DRIVER_API * \copydoc UsbK_AbortPipe */ KUSB_AbortPipe* AbortPipe; /*! \fn BOOL KUSB_API FlushPipe (_in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID) * \memberof KUSB_DRIVER_API * \copydoc UsbK_FlushPipe */ KUSB_FlushPipe* FlushPipe; /*! \fn BOOL KUSB_API IsoReadPipe (_in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID, _out PUCHAR Buffer, _in UINT BufferLength, _in LPOVERLAPPED Overlapped, _refopt PKISO_CONTEXT IsoContext) * \memberof KUSB_DRIVER_API * \copydoc UsbK_IsoReadPipe */ KUSB_IsoReadPipe* IsoReadPipe; /*! \fn BOOL KUSB_API IsoWritePipe (_in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID, _in PUCHAR Buffer, _in UINT BufferLength, _in LPOVERLAPPED Overlapped, _refopt PKISO_CONTEXT IsoContext) * \memberof KUSB_DRIVER_API * \copydoc UsbK_IsoWritePipe */ KUSB_IsoWritePipe* IsoWritePipe; /*! \fn BOOL KUSB_API GetCurrentFrameNumber (_in KUSB_HANDLE InterfaceHandle, _out PUINT FrameNumber) * \memberof KUSB_DRIVER_API * \copydoc UsbK_GetCurrentFrameNumber */ KUSB_GetCurrentFrameNumber* GetCurrentFrameNumber; /*! \fn BOOL KUSB_API GetOverlappedResult (_in KUSB_HANDLE InterfaceHandle, _in LPOVERLAPPED Overlapped, _out PUINT lpNumberOfBytesTransferred, _in BOOL bWait) * \memberof KUSB_DRIVER_API * \copydoc UsbK_GetOverlappedResult */ KUSB_GetOverlappedResult* GetOverlappedResult; /*! \fn BOOL KUSB_API GetProperty (_in KUSB_HANDLE InterfaceHandle, _in KUSB_PROPERTY PropertyType, _ref PUINT PropertySize, _out PVOID Value) * \memberof KUSB_DRIVER_API * \copydoc UsbK_GetProperty */ KUSB_GetProperty* GetProperty; /*! \fn BOOL KUSB_API IsochReadPipe (_in KISOCH_HANDLE IsochHandle, _inopt UINT DataLength, _refopt PUINT FrameNumber, _inopt UINT NumberOfPackets, _in LPOVERLAPPED Overlapped) * \memberof KUSB_DRIVER_API * \copydoc UsbK_IsochReadPipe */ KUSB_IsochReadPipe* IsochReadPipe; /*! \fn BOOL KUSB_API IsochWritePipe (_in KISOCH_HANDLE IsochHandle, _inopt UINT DataLength, _refopt PUINT FrameNumber, _inopt UINT NumberOfPackets, _in LPOVERLAPPED Overlapped) * \memberof KUSB_DRIVER_API * \copydoc UsbK_IsochWritePipe */ KUSB_IsochWritePipe* IsochWritePipe; /*! \fn BOOL KUSB_API QueryPipeEx (_in KUSB_HANDLE InterfaceHandle, _in UCHAR AltSettingNumber, _in UCHAR PipeIndex, _out PWINUSB_PIPE_INFORMATION_EX PipeInformationEx) * \memberof KUSB_DRIVER_API * \copydoc UsbK_QueryPipeEx */ KUSB_QueryPipeEx* QueryPipeEx; /*! \fn BOOL KUSB_API GetSuperSpeedPipeCompanionDescriptor (_in KUSB_HANDLE InterfaceHandle, _in UCHAR AltSettingNumber, _in UCHAR PipeIndex, _out PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR PipeCompanionDescriptor) * \memberof KUSB_DRIVER_API * \copydoc UsbK_GetSuperSpeedPipeCompanionDescriptor */ KUSB_GetSuperSpeedPipeCompanionDescriptor* GetSuperSpeedPipeCompanionDescriptor; //! fixed structure padding. (reserved for internal use!) UCHAR z_F_i_x_e_d[512 - sizeof(KUSB_DRIVER_API_INFO) - sizeof(UINT_PTR) * KUSB_FNID_COUNT - (KUSB_FNID_COUNT & (sizeof(UINT_PTR) - 1) ? (KUSB_FNID_COUNT & (~(sizeof(UINT_PTR) - 1))) + sizeof(UINT_PTR) : KUSB_FNID_COUNT)]; //! function supported array. Do not access directly! see \ref LibK_IsFunctionSupported UCHAR z_FuncSupported[(KUSB_FNID_COUNT & (sizeof(UINT_PTR) - 1) ? (KUSB_FNID_COUNT & (~(sizeof(UINT_PTR) - 1))) + sizeof(UINT_PTR) : KUSB_FNID_COUNT)]; } KUSB_DRIVER_API; typedef KUSB_DRIVER_API* PKUSB_DRIVER_API; USBK_C_ASSERT(KUSB_DRIVER_API,sizeof(KUSB_DRIVER_API) == 512); /**@}*/ #endif #ifndef _LIBUSBK_HOTK_TYPES /*! \addtogroup hotk * @{ */ //! Hot plug config flags. typedef enum _KHOT_FLAG { //! No flags (or 0) KHOT_FLAG_NONE, //! Notify all devices which match upon a succuessful call to \ref HotK_Init. KHOT_FLAG_PLUG_ALL_ON_INIT = 0x0001, //! Allow other \ref KHOT_HANDLE instances to consume this match. KHOT_FLAG_PASS_DUPE_INSTANCE = 0x0002, //! If a \c UserHwnd is specified, use \c PostMessage instead of \c SendMessage. KHOT_FLAG_POST_USER_MESSAGE = 0x0004, } KHOT_FLAG; //! Hot plug event function definition. typedef VOID KUSB_API KHOT_PLUG_CB( _in KHOT_HANDLE HotHandle, _in KLST_DEVINFO_HANDLE DeviceInfo, _in KLST_SYNC_FLAG PlugType); //! Power broadcast event function definition. typedef VOID KUSB_API KHOT_POWER_BROADCAST_CB( _in KHOT_HANDLE HotHandle, _in KLST_DEVINFO_HANDLE DeviceInfo, _in UINT PbtEvent); //! Hot plug parameter structure. /*! * \fixedstruct{2048} * * This structure is intially passed as a parameter to \ref HotK_Init. * */ typedef struct _KHOT_PARAMS { //! Hot plug event window handle to send/post messages when notifications occur. HWND UserHwnd; //! WM_USER message start offset used when sending/posting messages, See details. /*! * \attention The \ref hotk will send UserMessage+1 for arrival notifications and UserMessage+0 for removal notifications. * * - WPARAM = \ref KHOT_HANDLE * - LPARAM = \ref KLST_DEVINFO_HANDLE */ UINT UserMessage; //! Additional init/config parameters KHOT_FLAG Flags; //! File pattern matches for restricting notifcations to a single/group or all supported usb devices. KLST_PATTERN_MATCH PatternMatch; //! Hot plug event callback function invoked when notifications occur. /*! \fn VOID KUSB_API OnHotPlug (_in KHOT_HANDLE HotHandle, _in KLST_DEVINFO_HANDLE DeviceInfo, _in KLST_SYNC_FLAG PlugType) * \memberof KHOT_PARAMS */ KHOT_PLUG_CB* OnHotPlug; //! \b WM_POWERBROADCAST event callback function invoked when a power-management event has occurred. /*! \fn VOID KUSB_API OnPowerBroadcast (_in KHOT_HANDLE HotHandle, _in KLST_DEVINFO_HANDLE DeviceInfo, _in UINT PbtEvent) * \memberof KHOT_PARAMS */ KHOT_POWER_BROADCAST_CB* OnPowerBroadcast; //! fixed structure padding. UCHAR z_F_i_x_e_d[2048 - sizeof(KLST_PATTERN_MATCH) - sizeof(UINT_PTR) * 3 - sizeof(UINT) * 2]; } KHOT_PARAMS; USBK_C_ASSERT(KHOT_PARAMS,sizeof(KHOT_PARAMS) == 2048); //! Pointer to a \ref KHOT_PARAMS structure. typedef KHOT_PARAMS* PKHOT_PARAMS; /**@}*/ #endif #ifndef _LIBUSBK_OVLK_TYPES /*! \addtogroup ovlk * @{ */ //! \c WaitFlags used by \ref OvlK_Wait. /*! * */ typedef enum _KOVL_WAIT_FLAG { //! Do not perform any additional actions upon exiting \ref OvlK_Wait. KOVL_WAIT_FLAG_NONE = 0L, //! If the i/o operation completes successfully, release the OverlappedK back to it's pool. KOVL_WAIT_FLAG_RELEASE_ON_SUCCESS = 0x0001, //! If the i/o operation fails, release the OverlappedK back to it's pool. KOVL_WAIT_FLAG_RELEASE_ON_FAIL = 0x0002, //! If the i/o operation fails or completes successfully, release the OverlappedK back to its pool. Perform no actions if it times-out. KOVL_WAIT_FLAG_RELEASE_ON_SUCCESS_FAIL = 0x0003, //! If the i/o operation times-out cancel it, but do not release the OverlappedK back to its pool. KOVL_WAIT_FLAG_CANCEL_ON_TIMEOUT = 0x0004, //! If the i/o operation times-out, cancel it and release the OverlappedK back to its pool. KOVL_WAIT_FLAG_RELEASE_ON_TIMEOUT = 0x000C, //! Always release the OverlappedK back to its pool. If the operation timed-out, cancel it before releasing back to its pool. KOVL_WAIT_FLAG_RELEASE_ALWAYS = 0x000F, //! Uses alterable wait functions. See http://msdn.microsoft.com/en-us/library/windows/desktop/ms687036%28v=vs.85%29.aspx KOVL_WAIT_FLAG_ALERTABLE = 0x0010, } KOVL_WAIT_FLAG; //! \c Overlapped pool config flags. /*! * \attention Currently not used. */ typedef enum _KOVL_POOL_FLAG { KOVL_POOL_FLAG_NONE = 0L, } KOVL_POOL_FLAG; /**@}*/ #endif #ifndef _LIBUSBK_STMK_TYPES /*! \addtogroup stmk * @{ */ //! Stream config flags. /*! * \attention Currently not used. */ typedef enum _KSTM_FLAG { //! None KSTM_FLAG_NONE = 0L, KSTM_FLAG_NO_PARTIAL_XFERS = 0x00100000, KSTM_FLAG_USE_TIMEOUT = 0x80000000, KSTM_FLAG_TIMEOUT_MASK = 0x0001FFFF } KSTM_FLAG; //! Stream config flags. /*! * \attention Currently not used. */ typedef enum _KSTM_COMPLETE_RESULT { //! Valid KSTM_COMPLETE_RESULT_VALID = 0L, //! Invalid KSTM_COMPLETE_RESULT_INVALID, } KSTM_COMPLETE_RESULT; //! Stream transfer context structure. /*! * This structure is passed into the stream callback functions. * The stream transfer context list is allocated upon a successful call to \ref StmK_Init. There is one * transfer context for each transfer. (0 to \c MaxPendingTransfers). * */ typedef struct _KSTM_XFER_CONTEXT { //! Internal stream buffer. PUCHAR Buffer; //! Size of internal stream buffer. INT BufferSize; //! Number of bytes to write or number of bytes read. INT TransferLength; //! User defined state. PVOID UserState; } KSTM_XFER_CONTEXT; //! Pointer to a \ref KSTM_XFER_CONTEXT structure. typedef KSTM_XFER_CONTEXT* PKSTM_XFER_CONTEXT; //! Stream information structure. /*! * This structure is passed into the stream callback functions. * The stream context is allocated upon a successful call to \ref StmK_Init. There is only one * stream context per stream. * */ typedef struct _KSTM_INFO { //! \ref KUSB_HANDLE this stream uses. KUSB_HANDLE UsbHandle; //! This parameter corresponds to the bEndpointAddress field in the endpoint descriptor. UCHAR PipeID; //! Maximum transfer read/write request allowed pending. INT MaxPendingTransfers; //! Maximum transfer sage size. INT MaxTransferSize; //! Maximum number of I/O request allowed pending. INT MaxPendingIO; //! Populated with the endpoint descriptor for the specified \c PipeID. USB_ENDPOINT_DESCRIPTOR EndpointDescriptor; //! Populated with the driver api for the specified \c UsbHandle. KUSB_DRIVER_API DriverAPI; //! Populated with the device file handle for the specified \c UsbHandle. HANDLE DeviceHandle; //! Stream handle. KSTM_HANDLE StreamHandle; //! Stream info user defined state. PVOID UserState; } KSTM_INFO; //! Pointer to a \ref KSTM_INFO structure. typedef KSTM_INFO* PKSTM_INFO; //! Function definition for an optional user-defined callback; executed when a transfer error occurs. /*! \fn INT KUSB_API KSTM_ERROR_CB(_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex, _in INT ErrorCode) * \memberof KSTM_CALLBACK */ typedef INT KUSB_API KSTM_ERROR_CB(_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex, _in INT ErrorCode); //! Function definition for an optional user-defined callback; executed to submit a transfer. /*! \fn INT KUSB_API KSTM_SUBMIT_CB(_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex, _in LPOVERLAPPED Overlapped) * \memberof KSTM_CALLBACK */ typedef INT KUSB_API KSTM_SUBMIT_CB(_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex, _in LPOVERLAPPED Overlapped); //! Function definition for an optional user-defined callback; executed for each transfer context when the stream is started with \ref StmK_Start. /*! \fn INT KUSB_API KSTM_STARTED_CB(_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex) * \memberof KSTM_CALLBACK */ typedef INT KUSB_API KSTM_STARTED_CB(_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex); //! Function definition for an optional user-defined callback; executed for each transfer context when the stream is stopped with \ref StmK_Stop. /*! \fn INT KUSB_API KSTM_STOPPED_CB(_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex) * \memberof KSTM_CALLBACK */ typedef INT KUSB_API KSTM_STOPPED_CB(_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex); //! Function definition for an optional user-defined callback; executed when a valid transfer completes. /*! \fn INT KUSB_API KSTM_COMPLETE_CB(_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex, _in INT ErrorCode) * \memberof KSTM_CALLBACK */ typedef INT KUSB_API KSTM_COMPLETE_CB(_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex, _in INT ErrorCode); //! Function definition for an optional user-defined callback; executed immediately after a transfer completes. /*! \fn KSTM_COMPLETE_RESULT KUSB_API KSTM_BEFORE_COMPLETE_CB(_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex, _ref PINT ErrorCode) * \memberof KSTM_CALLBACK * * This callback function allows the user to accept or reject the transfer: * - IN (Read, DeviceToHost) endpoints. * - KSTM_COMPLETE_RESULT_VALID * Continue normal processing; add the transfer to the internal complete list and make it available to \ref StmK_Read. * - KSTM_COMPLETE_RESULT_INVALID * Ignore this transfer. * - OUT (Write, HostToDevice) endpoints. * - KSTM_COMPLETE_RESULT_VALID * Continue normal processing; add the transfer to the internal complete list and make it available subsequent \ref StmK_Write requests. * - KSTM_COMPLETE_RESULT_INVALID * Return this transfer to the internal queued list for automatic resubmission to the device. * */ typedef KSTM_COMPLETE_RESULT KUSB_API KSTM_BEFORE_COMPLETE_CB(_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex, _in PINT ErrorCode); //! Stream callback structure. /*! * \fixedstruct{64} * * These optional callback functions are executed from the streams internal thread at various stages of operation. * */ typedef struct _KSTM_CALLBACK { //! Executed when a transfer error occurs. KSTM_ERROR_CB* Error; //! Executed to submit a transfer. KSTM_SUBMIT_CB* Submit; //! Executed when a valid transfer completes. KSTM_COMPLETE_CB* Complete; //! Executed for every transfer context when the stream is started with \ref StmK_Start. KSTM_STARTED_CB* Started; //! Executed for every transfer context when the stream is stopped with \ref StmK_Stop. KSTM_STOPPED_CB* Stopped; //! Executed immediately after a transfer completes. KSTM_BEFORE_COMPLETE_CB* BeforeComplete; //! fixed structure padding. UCHAR z_F_i_x_e_d[64 - sizeof(UINT_PTR) * 6]; } KSTM_CALLBACK; //! Pointer to a \ref KSTM_CALLBACK structure. typedef KSTM_CALLBACK* PKSTM_CALLBACK; USBK_C_ASSERT(KSTM_CALLBACK,sizeof(KSTM_CALLBACK) == 64); /**@}*/ #endif /////////////////////////////////////////////////////////////////////// // L I B U S B K PUBLIC FUNCTIONS //////////////////////////////////// /////////////////////////////////////////////////////////////////////// #ifdef __cplusplus extern "C" { #endif #ifndef _LIBUSBK_LIBK_FUNCTIONS /*! \addtogroup libk * @{ */ //! Gets the internal user context for the specified \ref KLIB_HANDLE. /*! * * \param[out] Version * Receives the libusbK library verson information. * * \returns NONE */ KUSB_EXP VOID KUSB_API LibK_GetVersion(_out PKLIB_VERSION Version); //! Gets the internal user context for the specified \ref KLIB_HANDLE. /*! * * \param[in] Handle * The handle containg the context to retrieve. * * \param[in] HandleType * Handle type of \c Handle. * * \returns * - on success, The user context value. * - On failure, returns NULL and sets last error to \c ERROR_INVALID_HANDLE. * */ KUSB_EXP KLIB_USER_CONTEXT KUSB_API LibK_GetContext( _in KLIB_HANDLE Handle, _in KLIB_HANDLE_TYPE HandleType); //! Sets internal user context for the specified \ref KLIB_HANDLE. /*! * * \param[in] Handle * The handle containg the context to set. * * \param[in] HandleType * Handle type of \c Handle. * * \param[in] ContextValue * Value to assign to the handle user context space. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * */ KUSB_EXP BOOL KUSB_API LibK_SetContext( _in KLIB_HANDLE Handle, _in KLIB_HANDLE_TYPE HandleType, _in KLIB_USER_CONTEXT ContextValue); //! Assigns a cleanup callback function to a \ref KLIB_HANDLE. /*! * * \param[in] Handle * The handle containg the cleanup callback function to set. * * \param[in] HandleType * Handle type of \c Handle. * * \param[in] CleanupCB * User supplied callback function to execute when the handles internal reference count reaches 0. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * */ KUSB_EXP BOOL KUSB_API LibK_SetCleanupCallback( _in KLIB_HANDLE Handle, _in KLIB_HANDLE_TYPE HandleType, _in KLIB_HANDLE_CLEANUP_CB* CleanupCB); //! Initialize a driver API set. /*! * * \param[out] DriverAPI * A driver API structure to populate. * * \param[in] DriverID * The driver id of the API set to retrieve. See \ref KUSB_DRVID * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * */ KUSB_EXP BOOL KUSB_API LibK_LoadDriverAPI( _out PKUSB_DRIVER_API DriverAPI, _in INT DriverID); //! Checks if the driver supports a function. /*! * * \param[in] DriverAPI * A driver API structure. See \ref LibK_LoadDriverAPI * * \param[in] FunctionID * The function to check. See \ref KUSB_FNID * * \returns TRUE if the specified function is supported. Otherwise FALSE. * */ KUSB_EXP BOOL KUSB_API LibK_IsFunctionSupported( _in PKUSB_DRIVER_API DriverAPI, _in UINT FunctionID); //! Copies the driver API set out of a \ref KUSB_HANDLE /*! * * \param[out] DriverAPI * A driver API structure to populate. * * \param[in] UsbHandle * Handle containing the desired driver API. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * */ KUSB_EXP BOOL KUSB_API LibK_CopyDriverAPI( _out PKUSB_DRIVER_API DriverAPI, _in KUSB_HANDLE UsbHandle); //! Initialize a driver API function. /*! * \param[out] ProcAddress * Reference to a function pointer that will receive the API function pointer. * * \param[in] DriverID * The driver id of the API to use. See \ref KUSB_DRVID * * \param[in] FunctionID * The function id. See \ref KUSB_FNID * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * */ KUSB_EXP BOOL KUSB_API LibK_GetProcAddress( _out KPROC* ProcAddress, _in INT DriverID, _in INT FunctionID); //! Sets the default user context for the specified \ref KLIB_HANDLE_TYPE. /*! * * \param[in] HandleType * The handle type which will be assigned the default ContextValue. * * \param[in] ContextValue * Value assigned to the default user context for the specified \ref KLIB_HANDLE_TYPE. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * */ KUSB_EXP BOOL KUSB_API LibK_SetDefaultContext( _in KLIB_HANDLE_TYPE HandleType, _in KLIB_USER_CONTEXT ContextValue); //! Gets the default user context for the specified \ref KLIB_HANDLE_TYPE. /*! * * \param[in] HandleType * Handle type used to retrieve the default user context. * * \returns * - on success, The default user context value. * - On failure, returns NULL and sets last error to \c ERROR_INVALID_HANDLE. * */ KUSB_EXP KLIB_USER_CONTEXT KUSB_API LibK_GetDefaultContext( _in KLIB_HANDLE_TYPE HandleType); //! Initializes the global libusbK process context. /*! * * If this function is not called at startup, libusbK initializes the global libusbK process context automatically. * * \param[in] Heap * A handle to the memory heap libusbK will use for dynamic memory allocation. * \note The process context itself is always allocated from the proccess heap. * \note If \b Heap is \b NULL, dynamic memory is allocated from the proccess heap. * * \param[in] Reserved * Reserved for future use. Must set to \b NULL. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * */ KUSB_EXP BOOL KUSB_API LibK_Context_Init( _inopt HANDLE Heap, _in PVOID Reserved); //! Frees the global libusbK process context. /*! * * If this function is not called on exit, libusbK frees the global libusbK process context automatically when it terminates. * * \returns NONE. * */ KUSB_EXP VOID KUSB_API LibK_Context_Free(VOID); /**@}*/ #endif #ifndef _LIBUSBK_USBK_FUNCTIONS /*! \addtogroup usbk * @{ */ //! Creates/opens a libusbK interface handle from the device list. This is a preferred method. /*! * * \param[out] InterfaceHandle * Receives a handle configured to the first (default) interface on the device. This handle is required by * other libusbK routines that perform operations on the default interface. The handle is opaque. To release * this handle, call the \ref UsbK_Free function. * * \param[in] DevInfo * The device list element to open. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * \c UsbK_Init performs the same tasks as \ref UsbK_Initialize with the following exceptions: * - Uses a \ref KLST_DEVINFO instead of a file handle created with the Windows CreateFile() API function. * - File handles are managed internally and are closed when the last \ref KUSB_HANDLE is closed with * \ref UsbK_Free. To obtain the internal file device handle, See \ref UsbK_GetProperty. * * \note * A \c KUSB_HANDLE is required by other library routines that perform operations on a device. Once * initialized, it can access all interfaces/endpoints of a device. An initialized handle can be cloned with * \ref UsbK_Clone or \ref UsbK_GetAssociatedInterface. A Cloned handle will behave just as the orignal * except in will maintain it's own \b selected interface setting. * */ KUSB_EXP BOOL KUSB_API UsbK_Init ( _out KUSB_HANDLE* InterfaceHandle, _in KLST_DEVINFO_HANDLE DevInfo); //! Frees a libusbK interface handle. /*! * * \param[in] InterfaceHandle * Handle to an interface on the device. This handle must be created by a previous call to \ref UsbK_Init, * \ref UsbK_Initialize, \ref UsbK_GetAssociatedInterface, or \ref UsbK_Clone. * * \returns TRUE. * * The \ref UsbK_Free function releases resources alocated to the InterfaceHandle. * */ KUSB_EXP BOOL KUSB_API UsbK_Free ( _in KUSB_HANDLE InterfaceHandle); //! Claims the specified interface by number or index. /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[in] NumberOrIndex * Interfaces can be claimed or released by a interface index or \c bInterfaceNumber. * - Interface indexes always start from 0 and continue sequentially for all interfaces of the device. * - An interface number always represents the actual \ref USB_INTERFACE_DESCRIPTOR::bInterfaceNumber. * Interface numbers are not guaranteed to be zero based or sequential. * * \param[in] IsIndex * If TRUE, \c NumberOrIndex represents an interface index.\n if FALSE \c NumberOrIndex represents a * \c bInterfaceNumber. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * Claiming an interface allows applications a way to prevent other applications or multiple instances of the * same application from using an interface at the same time. * * When an interface is claimed with \ref UsbK_ClaimInterface it performs the following actions: * - Checks if the interface exists. If it does not, returns FALSE and sets last error to * ERROR_NO_MORE_ITEMS. * - The default (or current) interface for the device is changed to \c NumberOrIndex. * - libusb0.sys and libusbK.sys: * - A request to claim the interface is sent to the driver. If the interface is not claimed or already * claimed by the application the request succeeds. If the interface is claimed by another application, * \ref UsbK_ClaimInterface returns FALSE and sets last error to \c ERROR_BUSY. In this case the The * default (or current) interface for the device is \b still changed to \c NumberOrIndex. * - WinUSB.sys: All WinUSB device interfaces are claimed when the device is opened. This function performs * identically to \ref UsbK_SelectInterface * */ KUSB_EXP BOOL KUSB_API UsbK_ClaimInterface ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR NumberOrIndex, _in BOOL IsIndex); //! Releases the specified interface by number or index. /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[in] NumberOrIndex * Interfaces can be claimed or released by a interface index or \c bInterfaceNumber. * - Interface indexes always start from 0 and continue sequentially for all interfaces of the device. * - An interface number always represents the actual \ref USB_INTERFACE_DESCRIPTOR::bInterfaceNumber. * Interface numbers are not guaranteed to be zero based or sequential. * * \param[in] IsIndex * If TRUE, \c NumberOrIndex represents an interface index.\n if FALSE \c NumberOrIndex represents a * \c bInterfaceNumber. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * When an interface is release with \ref UsbK_ReleaseInterface it performs the following actions: * - Checks if the interface exists. If it does not, returns FALSE and sets last error to * ERROR_NO_MORE_ITEMS. * - The default (or current) interface for the device is changed to the previously claimed interface. * - libusb0.sys and libusbK.sys: * - A request to release the interface is sent to the driver. If the interface is not claimed by a * different application the request succeeds. If the interface is claimed by another application, * \ref UsbK_ReleaseInterface returns FALSE and sets last error to \c ERROR_BUSY. In this case, the * default/current interface for the device is \b still changed to the previously claimed interface. * - WinUSB.sys: No other action needed, returns TRUE. * * \note * When an interface is released, it is moved to the bottom if an interface stack making a previously claimed * interface the current. This will continue to occur regardless of whether the interface is claimed. For * this reason, \ref UsbK_ReleaseInterface can be used as a means to change the current/default interface of * an \c InterfaceHandle without claiming the interface. * */ KUSB_EXP BOOL KUSB_API UsbK_ReleaseInterface ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR NumberOrIndex, _in BOOL IsIndex); //! Sets the alternate setting of the specified interface. /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[in] NumberOrIndex * Interfaces can be specified by a interface index or \c bInterfaceNumber. * - Interface indexes always start from 0 and continue sequentially for all interfaces of the device. * - An interface number always represents the actual \ref USB_INTERFACE_DESCRIPTOR::bInterfaceNumber. * Interface numbers are not guaranteed to be zero based or sequential. * * \param[in] IsIndex * If TRUE, \c NumberOrIndex represents an interface index.\n if FALSE \c NumberOrIndex represents a * \c bInterfaceNumber. * * \param[in] AltSettingNumber * The bAlternateSetting to activate. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * \ref UsbK_SetAltInterface performs the same task as \ref UsbK_SetCurrentAlternateSetting except it * provides the option of specifying which interfaces alternate setting to activate. * */ KUSB_EXP BOOL KUSB_API UsbK_SetAltInterface ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR NumberOrIndex, _in BOOL IsIndex, _in UCHAR AltSettingNumber); //! Gets the alternate setting for the specified interface. /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[in] NumberOrIndex * Interfaces can be specified by a interface index or \c bInterfaceNumber. * - Interface indexes always start from 0 and continue sequentially for all interfaces of the device. * - An interface number always represents the actual \ref USB_INTERFACE_DESCRIPTOR::bInterfaceNumber. * Interface numbers are not guaranteed to be zero based or sequential. * * \param[in] IsIndex * If TRUE, \c NumberOrIndex represents an interface index.\n if FALSE \c NumberOrIndex represents a * \c bInterfaceNumber. * * \param[out] AltSettingNumber * On success, returns the active bAlternateSetting. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * \ref UsbK_GetAltInterface performs the same task as \ref UsbK_GetCurrentAlternateSetting except it * provides the option of specifying which interfaces alternate setting is to be retrieved. * */ KUSB_EXP BOOL KUSB_API UsbK_GetAltInterface ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR NumberOrIndex, _in BOOL IsIndex, _out PUCHAR AltSettingNumber); //! Gets the requested descriptor. This is a synchronous operation. /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[in] DescriptorType * A value that specifies the type of descriptor to return. This parameter corresponds to the bDescriptorType * field of a standard device descriptor, whose values are described in the Universal Serial Bus * specification. * * \param[in] Index * The descriptor index. For an explanation of the descriptor index, see the Universal Serial Bus * specification (www.usb.org). * * \param[in] LanguageID * A value that specifies the language identifier, if the requested descriptor is a string descriptor. * * \param[out] Buffer * A caller-allocated buffer that receives the requested descriptor. * * \param[in] BufferLength * The length, in bytes, of Buffer. * * \param[out] LengthTransferred * The number of bytes that were copied into Buffer. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * If the device descriptor or active config descriptor is requested, \ref UsbK_GetDescriptor retrieves * cached data and this becomes a non-blocking, non I/O request. * */ KUSB_EXP BOOL KUSB_API UsbK_GetDescriptor ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR DescriptorType, _in UCHAR Index, _in USHORT LanguageID, _out PUCHAR Buffer, _in UINT BufferLength, _outopt PUINT LengthTransferred); //! Transmits control data over a default control endpoint. /*! * * \param[in] InterfaceHandle * A valid libusbK interface handle returned by: * - \ref UsbK_Init * - \ref UsbK_Initialize * - \ref UsbK_GetAssociatedInterface * - \ref UsbK_Clone * * \param[in] SetupPacket * The 8-byte setup packet of type WINUSB_SETUP_PACKET. * * \param[in,out] Buffer * A caller-allocated buffer that contains the data to transfer. * * \param[in] BufferLength * The number of bytes to transfer, not including the setup packet. This number must be less than or equal to * the size, in bytes, of Buffer. * * \param[out] LengthTransferred * A pointer to a UINT variable that receives the actual number of transferred bytes. If the application * does not expect any data to be transferred during the data phase (BufferLength is zero), LengthTransferred * can be NULL. * * \param[in] Overlapped * An optional pointer to an OVERLAPPED structure, which is used for asynchronous operations. If this * parameter is specified, \ref UsbK_ControlTransfer immediately returns, and the event is signaled when the * operation is complete. If Overlapped is not supplied, the \ref UsbK_ControlTransfer function transfers * data synchronously. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. If an * \c Overlapped member is supplied and the operation succeeds this function returns FALSE and sets last * error to ERROR_IO_PENDING. * * A \ref UsbK_ControlTransfer is never cached. These requests always go directly to the usb device. * * \attention * This function should not be used for operations supported by the library.\n e.g. * \ref UsbK_SetConfiguration, \ref UsbK_SetAltInterface, etc.. * */ KUSB_EXP BOOL KUSB_API UsbK_ControlTransfer ( _in KUSB_HANDLE InterfaceHandle, _in WINUSB_SETUP_PACKET SetupPacket, _refopt PUCHAR Buffer, _in UINT BufferLength, _outopt PUINT LengthTransferred, _inopt LPOVERLAPPED Overlapped); //! Sets the power policy for a device. /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[in] PolicyType * A value that specifies the power policy to set. The following table describes symbolic constants that are * defined in \ref lusbk_shared.h. * * - AUTO_SUSPEND (0x81) * - Specifies the auto-suspend policy type; the power policy parameter must be specified by the caller in * the Value parameter. * - For auto-suspend, the Value parameter must point to a UCHAR variable. * - If Value is TRUE (nonzero), the USB stack suspends the device if the device is idle. A device is idle * if there are no transfers pending, or if the only pending transfers are IN transfers to interrupt or * bulk endpoints. * - The default value is determined by the value set in the DefaultIdleState registry setting. By default, * this value is TRUE. * * - SUSPEND_DELAY (0x83) * - Specifies the suspend-delay policy type; the power policy parameter must be specified by the caller in * the Value parameter. * - For suspend-delay, Value must point to a UINT variable. * - Value specifies the minimum amount of time, in milliseconds, that the driver must wait post transfer * before it can suspend the device. * - The default value is determined by the value set in the DefaultIdleTimeout registry setting. By * default, this value is five seconds. * * \param[in] ValueLength * The size, in bytes, of the buffer at Value. * * \param[in] Value * The new value for the power policy parameter. Data type and value for Value depends on the type of power * policy passed in PolicyType. For more information, see PolicyType. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * The following list summarizes the effects of changes to power management states: * - All pipe handles, interface handles, locks, and alternate settings are preserved across power management * events. * - Any transfers that are in progress are suspended when a device transfers to a low power state, and they * are resumed when the device is restored to a working state. * - The device and system must be in a working state before the client can restore a device-specific * configuration. Clients can determine whether the device and system are in a working state from the * WM_POWERBROADCAST message. * - The client can indicate that an interface is idle by calling \ref UsbK_SetPowerPolicy. * */ KUSB_EXP BOOL KUSB_API UsbK_SetPowerPolicy ( _in KUSB_HANDLE InterfaceHandle, _in UINT PolicyType, _in UINT ValueLength, _in PVOID Value); //! Gets the power policy for a device. /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[in] PolicyType * A value that specifies the power policy parameter to retrieve in Value. The following table describes * symbolic constants that are defined in \ref lusbk_shared.h. * * - AUTO_SUSPEND (0x81) * - If the caller specifies a power policy of AUTO_SUSPEND, \ref UsbK_GetPowerPolicy returns the value of * the auto suspend policy parameter in the Value parameter. * - If Value is TRUE (that is, nonzero), the USB stack suspends the device when no transfers are pending * or the only transfers pending are IN transfers on an interrupt or bulk endpoint. * - The value of the DefaultIdleState registry value determines the default value of the auto suspend * policy parameter. * - The Value parameter must point to a UCHAR variable. * * - SUSPEND_DELAY (0x83) * - If the caller specifies a power policy of SUSPEND_DELAY, \ref UsbK_GetPowerPolicy returns the value of * the suspend delay policy parameter in Value. * - The suspend delay policy parameter specifies the minimum amount of time, in milliseconds, that the * driver must wait after any transfer before it can suspend the device. * - Value must point to a UINT variable. * * \param[in,out] ValueLength * A pointer to the size of the buffer that Value. On output, ValueLength receives the size of the data that * was copied into the Value buffer. * * \param[out] Value * A buffer that receives the specified power policy parameter. For more information, see PolicyType. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * */ KUSB_EXP BOOL KUSB_API UsbK_GetPowerPolicy ( _in KUSB_HANDLE InterfaceHandle, _in UINT PolicyType, _ref PUINT ValueLength, _out PVOID Value); //! Sets the device configuration number. /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[in] ConfigurationNumber * The configuration number to activate. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * \ref UsbK_SetConfiguration is only supported with libusb0.sys. If the driver in not libusb0.sys, this * function performs the following emulation actions: * - If the requested configuration number is the current configuration number, returns TRUE. * - If the requested configuration number is one other than the current configuration number, returns FALSE * and set last error to \c ERROR_NO_MORE_ITEMS. * * This function will fail if there are pending I/O operations or there are other libusbK interface handles * referencing the device. \sa UsbK_Free * */ KUSB_EXP BOOL KUSB_API UsbK_SetConfiguration ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR ConfigurationNumber); //! Gets the device current configuration number. /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[out] ConfigurationNumber * On success, receives the active configuration number. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * */ KUSB_EXP BOOL KUSB_API UsbK_GetConfiguration ( _in KUSB_HANDLE InterfaceHandle, _out PUCHAR ConfigurationNumber); //! Resets the usb device of the specified interface handle. (port cycle). /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * */ KUSB_EXP BOOL KUSB_API UsbK_ResetDevice ( _in KUSB_HANDLE InterfaceHandle); //! Creates a libusbK handle for the device specified by a file handle. /*! * * \attention * This function is supported for WinUSB API compatibility only and is not intended for new development. * libusbK library users should use \ref UsbK_Init instead. (regardless of the driver they've selected) * * \param[in] DeviceHandle * The handle to the device that CreateFile returned. libusbK uses overlapped I/O, so FILE_FLAG_OVERLAPPED * must be specified in the dwFlagsAndAttributes parameter of CreateFile call for DeviceHandle to have the * characteristics necessary for this to function properly. * * \param[out] InterfaceHandle * Receives a handle configured to the first (default) interface on the device. This handle is required by * other libusbK routines that perform operations on the default interface. The handle is opaque. To release * this handle, call the \ref UsbK_Free function. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * When \ref UsbK_Initialize is called, the policy settings of the interface are reset to the default values. * * The \ref UsbK_Initialize call queries the underlying USB stack for various descriptors and allocates * enough memory to store the retrieved descriptor data. * * \ref UsbK_Initialize first retrieves the device descriptor and then gets the associated configuration * descriptor. From the configuration descriptor, the call derives the associated interface descriptors and * stores them in an array. The interfaces in the array are identified by zero-based indexes. An index value * of 0 indicates the first interface (the default interface), a value of 1 indicates the second associated * interface, and so on. \ref UsbK_Initialize parses the default interface descriptor for the endpoint * descriptors and caches information such as the associated pipes or state specific data. The handle * received in the InterfaceHandle parameter will have its default interface configured to the first * interface in the array. * * If an application wants to use another interface on the device, it can call * \ref UsbK_GetAssociatedInterface, or \ref UsbK_ClaimInterface. * */ KUSB_EXP BOOL KUSB_API UsbK_Initialize ( _in HANDLE DeviceHandle, _out KUSB_HANDLE* InterfaceHandle); //! Selects the specified interface by number or index as the current interface. /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[in] NumberOrIndex * Interfaces can be claimed or released by a interface index or \c bInterfaceNumber. * - Interface indexes always start from 0 and continue sequentially for all interfaces of the device. * - An interface number always represents the actual \ref USB_INTERFACE_DESCRIPTOR::bInterfaceNumber. * Interface numbers are not guaranteed to be zero based or sequential. * * \param[in] IsIndex * If TRUE, \c NumberOrIndex represents an interface index.\n if FALSE \c NumberOrIndex represents a * \c bInterfaceNumber. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * \sa UsbK_ClaimInterface * */ KUSB_EXP BOOL KUSB_API UsbK_SelectInterface ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR NumberOrIndex, _in BOOL IsIndex); //! Retrieves a handle for an associated interface. /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[in] AssociatedInterfaceIndex * An index that specifies the associated interface to retrieve. A value of 0 indicates the first associated * interface, a value of 1 indicates the second associated interface, and so on. * * \param[out] AssociatedInterfaceHandle * A handle for the associated interface. Callers must pass this interface handle to libusbK Functions * exposed by libusbK.dll. To close this handle, call \ref UsbK_Free. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * The \ref UsbK_GetAssociatedInterface function retrieves an opaque handle for an associated interface. This * is a synchronous operation. * * The first associated interface is the interface that immediately follows the current (or default) * interface of the specified /c InterfaceHandle. * * The handle that \ref UsbK_GetAssociatedInterface returns must be released by calling \ref UsbK_Free. * */ KUSB_EXP BOOL KUSB_API UsbK_GetAssociatedInterface ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR AssociatedInterfaceIndex, _out KUSB_HANDLE* AssociatedInterfaceHandle); //! Clones the specified interface handle. /*! * * Each cloned interface handle maintains it's own selected interface. * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[out] DstInterfaceHandle * On success, the cloned return handle. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * */ KUSB_EXP BOOL KUSB_API UsbK_Clone ( _in KUSB_HANDLE InterfaceHandle, _out KUSB_HANDLE* DstInterfaceHandle); //! Retrieves the interface descriptor for the specified alternate interface settings for a particular interface handle. /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[in] AltSettingIndex * A value that indicates which alternate setting index to return. A value of 0 indicates the first alternate * setting, a value of 1 indicates the second alternate setting, and so on. * * \param[out] UsbAltInterfaceDescriptor * A pointer to a caller-allocated \ref USB_INTERFACE_DESCRIPTOR structure that contains information about * the interface that AltSettingNumber specified. * * The \ref UsbK_QueryInterfaceSettings call searches the current/default interface array for the alternate * interface specified by the caller in the AltSettingIndex. If the specified alternate interface is found, * the function populates the caller-allocated USB_INTERFACE_DESCRIPTOR structure. If the specified alternate * interface is not found, then the call fails with the ERROR_NO_MORE_ITEMS code. * * To change the current/default interface, see \ref UsbK_SelectInterface and \ref UsbK_ClaimInterface * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * */ KUSB_EXP BOOL KUSB_API UsbK_QueryInterfaceSettings ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR AltSettingIndex, _out PUSB_INTERFACE_DESCRIPTOR UsbAltInterfaceDescriptor); //! Retrieves information about the physical device that is associated with a libusbK handle. /*! * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[in] InformationType * A value that specifies which interface information value to retrieve. On input, InformationType must have * the following value: \c DEVICE_SPEED (0x01). * * \param[in,out] BufferLength * The maximum number of bytes to read. This number must be less than or equal to the size, in bytes, of * Buffer. On output, BufferLength is set to the actual number of bytes that were copied into Buffer. * * \param[in,out] Buffer * A caller-allocated buffer that receives the requested value. On output, Buffer indicates the device speed: * - (0x01) low/full speed device. * - (0x03) high speed device. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * */ KUSB_EXP BOOL KUSB_API UsbK_QueryDeviceInformation ( _in KUSB_HANDLE InterfaceHandle, _in UINT InformationType, _ref PUINT BufferLength, _ref PUCHAR Buffer); //! Sets the alternate setting of an interface. /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[in] AltSettingNumber * The value that is contained in the bAlternateSetting member of the \ref USB_INTERFACE_DESCRIPTOR * structure. This structure can be populated by the \ref UsbK_QueryInterfaceSettings routine. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * Sets the active bAlternateSetting for the current/default interface. * * To change the default/current interface see \ref UsbK_ClaimInterface and \ref UsbK_ReleaseInterface * \sa UsbK_SetAltInterface * */ KUSB_EXP BOOL KUSB_API UsbK_SetCurrentAlternateSetting ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR AltSettingNumber); //! Gets the current alternate interface setting for an interface. /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[out] AltSettingNumber * A pointer to an unsigned character that receives an integer that indicates the current alternate setting. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * Gets the active bAlternateSetting for the current/default interface. * * To change the default/current interface see \ref UsbK_ClaimInterface and \ref UsbK_ReleaseInterface * \sa UsbK_GetAltInterface * */ KUSB_EXP BOOL KUSB_API UsbK_GetCurrentAlternateSetting ( _in KUSB_HANDLE InterfaceHandle, _out PUCHAR AltSettingNumber); //! Retrieves information about a pipe that is associated with an interface. /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[in] AltSettingNumber * A value that specifies the alternate interface to return the information for. * * \param[in] PipeIndex * A value that specifies the pipe to return information about. This value is not the same as the * bEndpointAddress field in the endpoint descriptor. A PipeIndex value of 0 signifies the first endpoint * that is associated with the interface, a value of 1 signifies the second endpoint, and so on. PipeIndex * must be less than the value in the bNumEndpoints field of the interface descriptor. * * \param[out] PipeInformation * A pointer, on output, to a caller-allocated \ref WINUSB_PIPE_INFORMATION structure that contains pipe * information. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * The \ref UsbK_QueryPipe function does not retrieve information about the control pipe. * * Each interface on the USB device can have multiple endpoints. To communicate with each of these endpoints, * the bus driver creates pipes for each endpoint on the interface. The pipe indices are zero-based. * Therefore for n number of endpoints, the pipes' indices are set from n-1. \ref UsbK_QueryPipe parses the * configuration descriptor to get the interface specified by the caller. It searches the interface * descriptor for the endpoint descriptor associated with the caller-specified pipe. If the endpoint is * found, the function populates the caller-allocated \ref WINUSB_PIPE_INFORMATION structure with information * from the endpoint descriptor. * */ KUSB_EXP BOOL KUSB_API UsbK_QueryPipe ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR AltSettingNumber, _in UCHAR PipeIndex, _out PWINUSB_PIPE_INFORMATION PipeInformation); //! Retrieves information about a pipe that is associated with an interface. /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[in] AltSettingNumber * A value that specifies the alternate interface to return the information for. * * \param[in] PipeIndex * A value that specifies the pipe to return information about. This value is not the same as the * bEndpointAddress field in the endpoint descriptor. A PipeIndex value of 0 signifies the first endpoint * that is associated with the interface, a value of 1 signifies the second endpoint, and so on. PipeIndex * must be less than the value in the bNumEndpoints field of the interface descriptor. * * \param[out] PipeInformationEx * A pointer, on output, to a caller-allocated \ref WINUSB_PIPE_INFORMATION_EX structure that contains pipe * information. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * The \ref UsbK_QueryPipeEx function does not retrieve information about the control pipe. * * Each interface on the USB device can have multiple endpoints. To communicate with each of these endpoints, * the bus driver creates pipes for each endpoint on the interface. The pipe indices are zero-based. * Therefore for n number of endpoints, the pipes' indices are set from n-1. \ref UsbK_QueryPipeEx parses the * configuration descriptor to get the interface specified by the caller. It searches the interface * descriptor for the endpoint descriptor associated with the caller-specified pipe. If the endpoint is * found, the function populates the caller-allocated \ref WINUSB_PIPE_INFORMATION_EX structure with information * from the endpoint descriptor. * */ KUSB_EXP BOOL KUSB_API UsbK_QueryPipeEx( _in KUSB_HANDLE InterfaceHandle, _in UCHAR AltSettingNumber, _in UCHAR PipeIndex, _out PWINUSB_PIPE_INFORMATION_EX PipeInformationEx); //! Retrieves a pipes super speed endpoint companion descriptor associated with an interface. /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[in] AltSettingNumber * A value that specifies the alternate interface to return the information for. * * \param[in] PipeIndex * A value that specifies the pipe to return information about. This value is not the same as the * bEndpointAddress field in the endpoint descriptor. A PipeIndex value of 0 signifies the first endpoint * that is associated with the interface, a value of 1 signifies the second endpoint, and so on. PipeIndex * must be less than the value in the bNumEndpoints field of the interface descriptor. * * \param[out] PipeCompanionDescriptor * A pointer, on output, to a caller-allocated \ref USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR structure that * contains pipe super speed companion descriptor. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * The \ref UsbK_GetSuperSpeedPipeCompanionDescriptor function does not retrieve information about the control pipe. * */ KUSB_EXP BOOL KUSB_API UsbK_GetSuperSpeedPipeCompanionDescriptor( _in KUSB_HANDLE InterfaceHandle, _in UCHAR AltSettingNumber, _in UCHAR PipeIndex, _out PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR PipeCompanionDescriptor); //! Sets the policy for a specific pipe associated with an endpoint on the device. This is a synchronous operation. /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[in] PipeID * An 8-bit value that consists of a 7-bit address and a direction bit. This parameter corresponds to the * bEndpointAddress field in the endpoint descriptor. * * \param[in] PolicyType * A UINT variable that specifies the policy parameter to change. The Value parameter contains the new value * for the policy parameter. See the remarks section for information about each of the pipe policies and the * resulting behavior. * * \param[in] ValueLength * The size, in bytes, of the buffer at Value. * * \param[in] Value * The new value for the policy parameter that PolicyType specifies. The size of this input parameter depends * on the policy to change. For information about the size of this parameter, see the description of the * PolicyType parameter. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * The following list describes symbolic constants that are defined in \ref lusbk_shared.h * * - \c SHORT_PACKET_TERMINATE (0x01) * - The default value is \c FALSE. * - To enable \c SHORT_PACKET_TERMINATE, in Value pass the address of a caller-allocated \c UCHAR variable * set to \c TRUE (nonzero). * - Enabling \c SHORT_PACKET_TERMINATE causes the driver to send a zero-length packet at the end of every * write request to the host controller. * * - \c AUTO_CLEAR_STALL (0x02) * - The default value is \c FALSE. To enable \c AUTO_CLEAR_STALL, in Value pass the address of a * caller-allocated \c UCHAR variable set to \c TRUE (nonzero). * - Enabling \c AUTO_CLEAR_STALL causes libusbK to reset the pipe in order to automatically clear the * stall condition. Data continues to flow on the bulk and interrupt \c IN endpoints again as soon as a * new or a queued transfer arrives on the endpoint. This policy parameter does not affect control pipes. * - Disabling \c AUTO_CLEAR_STALL causes all transfers (that arrive to the endpoint after the stalled * transfer) to fail until the caller manually resets the endpoint's pipe by calling \ref UsbK_ResetPipe. * * - \c PIPE_TRANSFER_TIMEOUT (0x03) * - The default value is zero. To set a time-out value, in Value pass the address of a caller-allocated * \c UINT variable that contains the time-out interval. * - The \c PIPE_TRANSFER_TIMEOUT value specifies the time-out interval, in milliseconds. The host * controller cancels transfers that do not complete within the specified time-out interval. * - A value of zero (default) indicates that transfers do not time out because the host controller never * cancels the transfer. * * - \c IGNORE_SHORT_PACKETS (0x04) * - The default value is \c FALSE. To enable \c IGNORE_SHORT_PACKETS, in Value pass the address of a * caller-allocated \c UCHAR variable set to \c TRUE (nonzero). * - Enabling \c IGNORE_SHORT_PACKETS causes the host controller to not complete a read operation after it * receives a short packet. Instead, the host controller completes the operation only after the host has * read the specified number of bytes. * - Disabling \c IGNORE_SHORT_PACKETS causes the host controller to complete a read operation when either * the host has read the specified number of bytes or the host has received a short packet. * * - \c ALLOW_PARTIAL_READS (0x05) * - The default value is \c TRUE (nonzero). To disable \c ALLOW_PARTIAL_READS, in Value pass the address * of a caller-allocated \c UCHAR variable set to \c FALSE (zero). * - Disabling \c ALLOW_PARTIAL_READS causes the read requests to fail whenever the device returns more * data (on bulk and interrupt \c IN endpoints) than the caller requested. * - Enabling \c ALLOW_PARTIAL_READS causes libusbK to save or discard the extra data when the device * returns more data (on bulk and interrupt \c IN endpoints) than the caller requested. This behavior is * defined by setting the \c AUTO_FLUSH value. * * - \c AUTO_FLUSH (0x06) * - The default value is \c FALSE (zero). To enable \c AUTO_FLUSH, in Value pass the address of a * caller-allocated \c UCHAR variable set to \c TRUE (nonzero). * - \c AUTO_FLUSH must be used with \c ALLOW_PARTIAL_READS enabled. If \c ALLOW_PARTIAL_READS is \c TRUE, * the value of \c AUTO_FLUSH determines the action taken by libusbK when the device returns more data * than the caller requested. * - Disabling \c ALLOW_PARTIAL_READS causes libusbK to ignore the \c AUTO_FLUSH value. * - Disabling \c AUTO_FLUSH with \c ALLOW_PARTIAL_READS enabled causes libusbK to save the extra data, add * the data to the beginning of the caller's next read request, and send it to the caller in the next * read operation. * - Enabling \c AUTO_FLUSH with \c ALLOW_PARTIAL_READS enabled causes libusbK to discard the extra data * remaining from the read request. * * - \c RAW_IO (0x07) * - The default value is \c FALSE (zero). To enable \c RAW_IO, in Value pass the address of a * caller-allocated \c UCHAR variable set to \c TRUE (nonzero). * - Enabling \c RAW_IO causes libusbK to send data directly to the \c USB driver stack, bypassing * libusbK's queuing and error handling mechanism. * - The buffers that are passed to \ref UsbK_ReadPipe must be configured by the caller as follows: * - The buffer length must be a multiple of the maximum endpoint packet size. * - The length must be less than or equal to the value of \c MAXIMUM_TRANSFER_SIZE retrieved by * \ref UsbK_GetPipePolicy. * - Disabling \c RAW_IO (\c FALSE) does not impose any restriction on the buffers that are passed to * \ref UsbK_ReadPipe. * * - \c RESET_PIPE_ON_RESUME (0x09) * - The default value is \c FALSE (zero). To enable \c RESET_PIPE_ON_RESUME, in Value pass the address of * a caller-allocated \c UCHAR variable set to \c TRUE (nonzero). * - \c TRUE (or a nonzero value) indicates that on resume from suspend, libusbK resets the endpoint before * it allows the caller to send new requests to the endpoint. * */ KUSB_EXP BOOL KUSB_API UsbK_SetPipePolicy ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID, _in UINT PolicyType, _in UINT ValueLength, _in PVOID Value); //! Gets the policy for a specific pipe (endpoint). /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[in] PipeID * An 8-bit value that consists of a 7-bit address and a direction bit. This parameter corresponds to the * bEndpointAddress field in the endpoint descriptor. * * \param[in] PolicyType * A UINT variable that specifies the policy parameter to retrieve. The current value for the policy * parameter is retrieved the Value parameter. * * \param[in,out] ValueLength * A pointer to the size, in bytes, of the buffer that Value points to. On output, ValueLength receives the * size, in bytes, of the data that was copied into the Value buffer. * * \param[out] Value * A pointer to a buffer that receives the specified pipe policy value. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * */ KUSB_EXP BOOL KUSB_API UsbK_GetPipePolicy ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID, _in UINT PolicyType, _ref PUINT ValueLength, _out PVOID Value); //! Reads data from the specified pipe. /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[in] PipeID * An 8-bit value that consists of a 7-bit address and a direction bit. This parameter corresponds to the * bEndpointAddress field in the endpoint descriptor. * * \param[out] Buffer * A caller-allocated buffer that receives the data that is read. * * \param[in] BufferLength * The maximum number of bytes to read. This number must be less than or equal to the size, in bytes, of * Buffer. * * \param[out] LengthTransferred * A pointer to a UINT variable that receives the actual number of bytes that were copied into Buffer. For * more information, see Remarks. * * \param[in] Overlapped * An optional pointer to an overlapped structure for asynchronous operations. This can be a \ref KOVL_HANDLE * or a pointer to a standard windows OVERLAPPED structure. If this parameter is specified, \c UsbK_ReadPipe * returns immediately rather than waiting synchronously for the operation to complete before returning. An * event is signaled when the operation is complete. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * */ KUSB_EXP BOOL KUSB_API UsbK_ReadPipe ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID, _out PUCHAR Buffer, _in UINT BufferLength, _outopt PUINT LengthTransferred, _inopt LPOVERLAPPED Overlapped); //! Writes data to a pipe. /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[in] PipeID * An 8-bit value that consists of a 7-bit address and a direction bit. This parameter corresponds to the * bEndpointAddress field in the endpoint descriptor. * * \param[in] Buffer * A caller-allocated buffer the data is written from. * * \param[in] BufferLength * The maximum number of bytes to write. This number must be less than or equal to the size, in bytes, of * Buffer. * * \param[out] LengthTransferred * A pointer to a UINT variable that receives the actual number of bytes that were transferred from Buffer. * For more information, see Remarks. * * \param[in] Overlapped * An optional pointer to an overlapped structure for asynchronous operations. This can be a \ref KOVL_HANDLE * or a pointer to a standard windows OVERLAPPED structure. If this parameter is specified, \c UsbK_WritePipe * returns immediately rather than waiting synchronously for the operation to complete before returning. An * event is signaled when the operation is complete. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * */ KUSB_EXP BOOL KUSB_API UsbK_WritePipe ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID, _in PUCHAR Buffer, _in UINT BufferLength, _outopt PUINT LengthTransferred, _inopt LPOVERLAPPED Overlapped); //! Resets the data toggle and clears the stall condition on a pipe. /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[in] PipeID * An 8-bit value that consists of a 7-bit address and a direction bit. This parameter corresponds to the * bEndpointAddress field in the endpoint descriptor. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * */ KUSB_EXP BOOL KUSB_API UsbK_ResetPipe ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID); //! Aborts all of the pending transfers for a pipe. /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[in] PipeID * An 8-bit value that consists of a 7-bit address and a direction bit. This parameter corresponds to the * bEndpointAddress field in the endpoint descriptor. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * */ KUSB_EXP BOOL KUSB_API UsbK_AbortPipe ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID); //! Discards any data that is cached in a pipe. /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[in] PipeID * An 8-bit value that consists of a 7-bit address and a direction bit. This parameter corresponds to the * bEndpointAddress field in the endpoint descriptor. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * */ KUSB_EXP BOOL KUSB_API UsbK_FlushPipe ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID); //! Reads from an isochronous pipe. /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[in] PipeID * An 8-bit value that consists of a 7-bit address and a direction bit. This parameter corresponds to the * bEndpointAddress field in the endpoint descriptor. * * \param[out] Buffer * A caller-allocated buffer that receives the data that is read. * * \param[in] BufferLength * The maximum number of bytes to read. This number must be less than or equal to the size, in bytes, of * Buffer. * * \param[in] Overlapped * A \b required pointer to an overlapped structure for asynchronous operations. This can be a * \ref KOVL_HANDLE or a pointer to a standard windows OVERLAPPED structure. If this parameter is specified, * \c UsbK_IsoReadPipe returns immediately rather than waiting synchronously for the operation to complete * before returning. An event is signaled when the operation is complete. * * \param[in,out] IsoContext * Pointer to an isochronous transfer context created with \ref IsoK_Init. If \c IsoContext is NULL, * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * \par Overlapped I/O considerations * If an \c Overlapped parameter is specified and the transfer is submitted successfully, the function * returns \b FALSE and sets last error to \c ERROR_IO_PENDING. When using overlapped I/O, users may ignore * the return results of this function and instead use the return results from one of the \ref ovlk wait * functions or from \ref UsbK_GetOverlappedResult. * */ KUSB_EXP BOOL KUSB_API UsbK_IsoReadPipe ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID, _out PUCHAR Buffer, _in UINT BufferLength, _in LPOVERLAPPED Overlapped, _refopt PKISO_CONTEXT IsoContext); //! Writes to an isochronous pipe. /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[in] PipeID * An 8-bit value that consists of a 7-bit address and a direction bit. This parameter corresponds to the * bEndpointAddress field in the endpoint descriptor. * * \param[in] Buffer * A caller-allocated buffer that receives the data that is read. * * \param[in] BufferLength * The maximum number of bytes to write. This number must be less than or equal to the size, in bytes, of * Buffer. * * \param[in] Overlapped * An optional pointer to an overlapped structure for asynchronous operations. This can be a \ref KOVL_HANDLE * or a pointer to a standard windows OVERLAPPED structure. If this parameter is specified, * \c UsbK_IsoWritePipe returns immediately rather than waiting synchronously for the operation to complete * before returning. An event is signaled when the operation is complete. * * \param[in,out] IsoContext * Pointer to an isochronous transfer context created with \ref IsoK_Init. See remarks below. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * */ KUSB_EXP BOOL KUSB_API UsbK_IsoWritePipe ( _in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID, _in PUCHAR Buffer, _in UINT BufferLength, _in LPOVERLAPPED Overlapped, _refopt PKISO_CONTEXT IsoContext); //! Retrieves the current USB frame number. /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[out] FrameNumber * A pointer to a location that receives the current 32-bit frame number on the USB bus (from the host * controller driver). * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * */ KUSB_EXP BOOL KUSB_API UsbK_GetCurrentFrameNumber ( _in KUSB_HANDLE InterfaceHandle, _out PUINT FrameNumber); //! Reads from an isochronous pipe. Supports LibusbK or WinUsb /*! * * \param[in] IsochHandle * An initialized isochronous transfer handle, see \ref IsochK_Init. * * \param[in] DataLength * The number of bytes to read. This number must be less than or equal to the size in bytes, of * the transfer buffer the \b IsochHandle was initialized with. You may pass \b 0 for this parameter * to use the entire transfer buffer. * * \param[in,out] FrameNumber * Pointer to the frame number this transfer should start on. Use \ref UsbK_GetCurrentFrameNumber when this is unknown. * When the function returns, this value will be updated to the next frame number for a subsequent transfer. * This parameter is ignored if the /b ISO_ALWAYS_START_ASAP pipe policy is set and required otherwise. * /sa UsbK_SetPipePolicy * \code * // Get the current frame number * UINT StartFrameNumber; * Usb.GetCurrentFrameNumber(usbHandle, &StartFrameNumber); * * // Give plenty of time to queue up all of our transfers BEFORE the bus starts consuming them * // Note that this is also the startup delay in milliseconds. * StartFrameNumber += 12 * \endcode * * \param[in] NumberOfPackets * The number of packets to read. This number must be less than or equal to the \b MaxNumberOfPackets value * that the /b IsochHandle was initialized with. You may pass \b 0 for this parameter * to use \b MaxNumberOfPackets. * * \param[in] Overlapped * A \b required pointer to an overlapped structure for asynchronous operations. This can be a * \ref KOVL_HANDLE or a pointer to a standard windows OVERLAPPED structure. * * \returns * This function always returns \b FALSE. You must use \c GetLastError() after calling this function. * If \c GetLastError() returns \c ERROR_IO_PENDING, then the transfer was started successfully and is in progress. * Any other error code indicates a failure. * See /ref OvlK_wait or \ref UsbK_GetOverlappedResult * */ KUSB_EXP BOOL KUSB_API UsbK_IsochReadPipe( _in KISOCH_HANDLE IsochHandle, _inopt UINT DataLength, _refopt PUINT FrameNumber, _inopt UINT NumberOfPackets, _in LPOVERLAPPED Overlapped); //! Writes to an isochronous pipe. Supports LibusbK or WinUsb /*! * * \param[in] IsochHandle * An initialized isochronous transfer handle, see \ref IsochK_Init. * * \param[in] DataLength * The number of bytes to write. This number must be less than or equal to the size in bytes, of * the transfer buffer the \b IsochHandle was initialized with. You may pass \b 0 for this parameter * to use the entire transfer buffer. * * \param[in,out] FrameNumber * Pointer to the frame number this transfer should start on. Use \ref UsbK_GetCurrentFrameNumber when this is unknown. * When the function returns, this value will be updated to the next frame number for a subsequent transfer. * This parameter is ignored if the /b ISO_ALWAYS_START_ASAP pipe policy is set and required otherwise. * /sa UsbK_SetPipePolicy * \code * // Get the current frame number * UINT StartFrameNumber; * Usb.GetCurrentFrameNumber(usbHandle, &StartFrameNumber); * * // Give plenty of time to queue up all of our transfers BEFORE the bus starts consuming them * // Note that this is also the startup delay in milliseconds. * StartFrameNumber += 12 * \endcode * * \param[in] NumberOfPackets * The number of packets to write. This number must be less than or equal to the \b MaxNumberOfPackets value * that the /b IsochHandle was initialized with. You may pass \b 0 for this parameter * to use \b MaxNumberOfPackets. * * \param[in] Overlapped * A \b required pointer to an overlapped structure for asynchronous operations. This can be a * \ref KOVL_HANDLE or a pointer to a standard windows OVERLAPPED structure. * * * \returns * This function always returns \b FALSE. You must use \c GetLastError() after calling this function. * If \c GetLastError() returns \c ERROR_IO_PENDING, then the transfer was started successfully and is in progress. * Any other error code indicates a failure. * See /ref OvlK_wait or \ref UsbK_GetOverlappedResult * */ KUSB_EXP BOOL KUSB_API UsbK_IsochWritePipe( _in KISOCH_HANDLE IsochHandle, _inopt UINT DataLength, _ref PUINT FrameNumber, _inopt UINT NumberOfPackets, _in LPOVERLAPPED Overlapped); //! Retrieves the results of an overlapped operation on the specified libusbK handle. /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[in] Overlapped * A pointer to a standard windows OVERLAPPED structure that was specified when the overlapped operation was * started. * * \param[out] lpNumberOfBytesTransferred * A pointer to a variable that receives the number of bytes that were actually transferred by a read or * write operation. * * \param[in] bWait * If this parameter is TRUE, the function does not return until the operation has been completed. If this * parameter is FALSE and the operation is still pending, the function returns FALSE and the GetLastError * function returns ERROR_IO_INCOMPLETE. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * This function is like the Win32 API routine, GetOverlappedResult, with one difference; instead of passing * a file handle that is returned from CreateFile, the caller passes an interface handle that is returned * from \ref UsbK_Initialize, \ref UsbK_Init, or \ref UsbK_GetAssociatedInterface. The caller can use either * API routine, if the appropriate handle is passed. The \ref UsbK_GetOverlappedResult function extracts the * file handle from the interface handle and then calls GetOverlappedResult. \n * * The results that are reported by the \ref UsbK_GetOverlappedResult function are those from the specified * handle's last overlapped operation to which the specified standard windows OVERLAPPED structure was * provided, and for which the operation's results were pending. A pending operation is indicated when the * function that started the operation returns FALSE, and the GetLastError routine returns ERROR_IO_PENDING. * When an I/O operation is pending, the function that started the operation resets the hEvent member of the * standard windows OVERLAPPED structure to the nonsignaled state. Then when the pending operation has been * completed, the system sets the event object to the signaled state. \n * * The caller can specify that an event object is manually reset in the standard windows OVERLAPPED * structure. If an automatic reset event object is used, the event handle must not be specified in any other * wait operation in the interval between starting the overlapped operation and the call to * \ref UsbK_GetOverlappedResult. For example, the event object is sometimes specified in one of the wait * routines to wait for the operation to be completed. When the wait routine returns, the system sets an * auto-reset event's state to nonsignaled, and a successive call to \ref UsbK_GetOverlappedResult with the * bWait parameter set to TRUE causes the function to be blocked indefinitely. * * If the bWait parameter is TRUE, \ref UsbK_GetOverlappedResult determines whether the pending operation has * been completed by waiting for the event object to be in the signaled state. * * If the hEvent member of the standard windows OVERLAPPED structure is NULL, the system uses the state of * the file handle to signal when the operation has been completed. Do not use file handles for this purpose. * It is better to use an event object because of the confusion that can occur when multiple concurrent * overlapped operations are performed on the same file. In this situation, you cannot know which operation * caused the state of the object to be signaled. * */ KUSB_EXP BOOL KUSB_API UsbK_GetOverlappedResult ( _in KUSB_HANDLE InterfaceHandle, _in LPOVERLAPPED Overlapped, _out PUINT lpNumberOfBytesTransferred, _in BOOL bWait); //! Gets a USB device (driver specific) property from usb handle. /*! * * \param[in] InterfaceHandle * USB handle of the property to retrieve. * * \param[in] PropertyType * The propety type to retrieve. * * \param[in,out] PropertySize * Size in bytes of \c Value. * * \param[out] Value * On success, receives the proprty data. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * */ KUSB_EXP BOOL KUSB_API UsbK_GetProperty ( _in KUSB_HANDLE InterfaceHandle, _in KUSB_PROPERTY PropertyType, _ref PUINT PropertySize, _out PVOID Value); /*! @} */ #endif #ifndef _LIBUSBK_LSTK_FUNCTIONS /*! \addtogroup lstk *@{ */ //! Initializes a new usb device list containing all supported devices. /*! * * \param[out] DeviceList * Pointer reference that will receive a populated device list. * * \param[in] Flags * Search, filter, and listing options. see \c KLST_FLAG * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * \c LstK_Init populates \c DeviceList with connected usb devices that can be used by libusbK. * * \note if \ref LstK_Init returns TRUE, the device list must be freed with \ref LstK_Free when it is no * longer needed. * */ KUSB_EXP BOOL KUSB_API LstK_Init( _out KLST_HANDLE* DeviceList, _in KLST_FLAG Flags); //! Initializes a new usb device list containing only devices matching a specific class GUID. /*! * * \param[out] DeviceList * Pointer reference that will receive a populated device list. * * \param[in] Flags * Search, filter, and listing options. see \c KLST_FLAG * * \param[in] PatternMatch * Pattern Search filter. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * \c LstK_InitEx populates \c DeviceList with usb devices that can be used by libusbK. Only device * matching the \ref KLST_PATTERN_MATCH string are included in the list. * * \note * This function significantly improves performance when used with a device interface guid pattern patch. * * \note if \ref LstK_InitEx returns TRUE, the device list must be freed with \ref LstK_Free when it it's no * longer needed. * */ KUSB_EXP BOOL KUSB_API LstK_InitEx( _out KLST_HANDLE* DeviceList, _in KLST_FLAG Flags, _in PKLST_PATTERN_MATCH PatternMatch); //! Frees a usb device list. /*! * * \note if \ref LstK_Init returns TRUE, the device list must be freed with \ref LstK_Free when it is no * longer needed. * * \param[in] DeviceList * The \c DeviceList to free. * * \returns NONE * * Frees all resources that were allocated to \c DeviceList by \ref LstK_Init. * */ KUSB_EXP BOOL KUSB_API LstK_Free( _in KLST_HANDLE DeviceList); //! Enumerates \ref KLST_DEVINFO elements of a \ref KLST_HANDLE. /*! * * \param[in] DeviceList * The \c DeviceList to enumerate. * * \param[in] EnumDevListCB * Function to call for each iteration. * * \param[in] Context * Optional user context pointer. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * Calls \c EnumDevListCB for each element in the device list or until \c EnumDevListCB returns FALSE. * */ KUSB_EXP BOOL KUSB_API LstK_Enumerate( _in KLST_HANDLE DeviceList, _in KLST_ENUM_DEVINFO_CB* EnumDevListCB, _inopt PVOID Context); //! Gets the \ref KLST_DEVINFO element for the current position. /*! * * \param[in] DeviceList * The \c DeviceList to retrieve a current \ref KLST_DEVINFO for. * * \param[out] DeviceInfo * The device information. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * After a \c DeviceList is created or after the \ref LstK_MoveReset method is called, the \c LstK_MoveNext * method must be called to advance the device list enumerator to the first element of the \c DeviceList * before calling \c LstK_Current otherwise, \c DeviceInfo is undefined. * * \c LstK_Current returns \c FALSE and sets last error to \c ERROR_NO_MORE_ITEMS if the last call to * \c LstK_MoveNext returned \c FALSE, which indicates the end of the \c DeviceList. * * \c LstK_Current does not move the position of the device list enumerator, and consecutive calls to * \c LstK_Current return the same object until either \c LstK_MoveNext or \ref LstK_MoveReset is called. * */ KUSB_EXP BOOL KUSB_API LstK_Current( _in KLST_HANDLE DeviceList, _out KLST_DEVINFO_HANDLE* DeviceInfo); //! Advances the device list current \ref KLST_DEVINFO position. /*! * \param[in] DeviceList * A usb device list returned by \ref LstK_Init * * \param[out] DeviceInfo * On success, contains a pointer to the device information for the current enumerators position. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * After a \c DeviceList is created or after \ref LstK_MoveReset is called, an enumerator is positioned * before the first element of the \c DeviceList and the \b first call to \c LstK_MoveNext moves the * enumerator over the first element of the \c DeviceList. * * If \c LstK_MoveNext passes the end of the \c DeviceList, the enumerator is positioned after the last * element in the \c DeviceList and \c LstK_MoveNext returns \c FALSE. When the enumerator is at this * position, a subsequent call to \c LstK_MoveNext will reset the enumerator and it continues from the * beginning. * */ KUSB_EXP BOOL KUSB_API LstK_MoveNext( _in KLST_HANDLE DeviceList, _outopt KLST_DEVINFO_HANDLE* DeviceInfo); //! Sets the device list to its initial position, which is before the first element in the list. /*! * * \param[in] DeviceList * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * */ KUSB_EXP VOID KUSB_API LstK_MoveReset( _in KLST_HANDLE DeviceList); //! Find a device by vendor and product id /*! * * \param[in] DeviceList * The \c DeviceList to retrieve a current \ref KLST_DEVINFO for. * * \param[in] Vid * ID is used in conjunction with the \c Pid to uniquely identify USB devices, providing traceability to the * OEM. * * \param[in] Pid * ID is used in conjunction with the \c Pid to uniquely identify USB devices, providing traceability to the * OEM. * * \param[out] DeviceInfo * On success, the device information pointer, otherwise NULL. * * \returns * - TRUE if the device was found * - FALSE if the device was \b not found or an error occurred. * - Sets last error to \c ERROR_NO_MORE_ITEMS if the device was \b not found. * * Searches all elements in \c DeviceList for usb device matching the specified. * */ KUSB_EXP BOOL KUSB_API LstK_FindByVidPid( _in KLST_HANDLE DeviceList, _in INT Vid, _in INT Pid, _out KLST_DEVINFO_HANDLE* DeviceInfo); //! Counts the number of device info elements in a device list. /*! * * \param[in] DeviceList * The deice list to count. * * \param[in,out] Count * On success, receives the number of \ref KLST_DEVINFO elements in the list. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * */ KUSB_EXP BOOL KUSB_API LstK_Count( _in KLST_HANDLE DeviceList, _ref PUINT Count); /**@}*/ #endif #ifndef _LIBUSBK_HOTK_FUNCTIONS /*! \addtogroup hotk * @{ */ //! Creates a new hot-plug handle for USB device arrival/removal event monitoring. /*! * * \param[out] Handle * Reference to a handle pointer that will receive the initialized hot-plug handle. * * \param[in,out] InitParams * Hot plug handle initialization structure. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * */ KUSB_EXP BOOL KUSB_API HotK_Init( _out KHOT_HANDLE* Handle, _ref PKHOT_PARAMS InitParams); //! Frees the specified hot-plug handle. /*! * * \param[in] Handle * hot-plug handle pointer to free. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * */ KUSB_EXP BOOL KUSB_API HotK_Free( _in KHOT_HANDLE Handle); //! Frees all hot-plug handles initialized with \ref HotK_Init. /*! * */ KUSB_EXP VOID KUSB_API HotK_FreeAll(VOID); /**@}*/ #endif #ifndef _LIBUSBK_OVLK_FUNCTIONS /*! \addtogroup ovlk * @{ */ //! Gets a preallocated \c OverlappedK structure from the specified/default pool. /*! * * \param[out] OverlappedK * On Success, receives the overlapped handle. * * \param[in] PoolHandle * The overlapped pool used to retrieve the next available \c OverlappedK. * * \returns On success, the next unused overlappedK available in the pool. Otherwise NULL. Use * \c GetLastError() to get extended error information. * * After calling \ref OvlK_Acquire or \ref OvlK_ReUse the \c OverlappedK is ready to be used in an I/O * operation. See one of the \c UsbK core transfer functions such as \ref UsbK_ReadPipe or * \ref UsbK_WritePipe for more information. * * If the pools internal refurbished list (a re-usable list of \c OverlappedK structures) is not empty, the * \ref OvlK_Acquire function will choose an overlapped from the refurbished list. * */ KUSB_EXP BOOL KUSB_API OvlK_Acquire( _out KOVL_HANDLE* OverlappedK, _in KOVL_POOL_HANDLE PoolHandle); //! Returns an \c OverlappedK structure to it's pool. /*! * * \param[in] OverlappedK * The overlappedK to release. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * When an overlapped is returned to pool, it resources are \b not freed. Instead, it is added to an internal * refurbished list (a re-usable list of \c OverlappedK structures). * * \warning This function must not be called when the OverlappedK is in-use. If unsure, consider using * \ref OvlK_WaitAndRelease instead. * */ KUSB_EXP BOOL KUSB_API OvlK_Release( _in KOVL_HANDLE OverlappedK); //! Creates a new overlapped pool. /*! * * \param[out] PoolHandle * On success, receives the new pool handle. * * \param[in] UsbHandle * USB handle to associate with the pool. * * \param[in] MaxOverlappedCount * Maximum number of overkappedK handles allowed in the pool. * * \param[in] Flags * Pool flags. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * */ KUSB_EXP BOOL KUSB_API OvlK_Init ( _out KOVL_POOL_HANDLE* PoolHandle, _in KUSB_HANDLE UsbHandle, _in INT MaxOverlappedCount, _inopt KOVL_POOL_FLAG Flags); //! Destroys the specified pool and all resources it created. /*! * * \param[in] PoolHandle * The overlapped pool to destroy. Once destroyed, the pool and all resources which belong to it can no * longer be used. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * \warning A pool should not be destroyed until all OverlappedKs acquired from it are no longer in-use. For * more information see \ref OvlK_WaitAndRelease or \ref OvlK_Release. * */ KUSB_EXP BOOL KUSB_API OvlK_Free( _in KOVL_POOL_HANDLE PoolHandle); //! Returns the internal event handle used to signal IO operations. /*! * * \param[in] OverlappedK * The overlappedK used to return the internal event handle. * * \returns On success, The manual reset event handle being used by this overlappedK. Otherwise NULL. Use * \c GetLastError() to get extended error information. * * \ref OvlK_GetEventHandle is useful for applications that must to their own event handling. It exposes the * windows \c OVERLAPPED \c hEvent used for i/o completion signaling. This event handle can be used by the * standard event wait functions; /c WaitForMultipleObjectsEx for example. * * \warning Use \ref OvlK_GetEventHandle with caution. Event handles returned by this function should never * be used unless the OverlappedK has been \b acquired by the application. * */ KUSB_EXP HANDLE KUSB_API OvlK_GetEventHandle( _in KOVL_HANDLE OverlappedK); //! Waits for overlapped I/O completion, and performs actions specified in \c WaitFlags. /*! * * \param[in] OverlappedK * The overlappedK to wait on. * * \param[in] TimeoutMS * Number of milliseconds to wait for overlapped completion. * * \param[in] WaitFlags * See /ref KOVL_WAIT_FLAG * * \param[out] TransferredLength * On success, returns the number of bytes transferred by this overlappedK. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. See * the remarks section below for details on relevant error codes. * * \c OvlK_Wait waits the time interval specified in \c TimeoutMS for the overlapped I/O operation to * complete. Different actions can then taken depending on the flags specified in \c WaitFlags. * * \WINERRORTABLE * * \WINERROR{ERROR_CANCELLED,1223} * - The I/O was cancelled by the user. The transfer complete event was not signalled within the alotted * transfer timeout time and the OvlK_Wait function issued a CancelIoEx/CancelIo request because the * \ref KOVL_WAIT_FLAG_CANCEL_ON_TIMEOUT flag bit was set. * \ENDWINERROR * * \WINERROR{ERROR_OPERATION_ABORTED,995} * - The transfer complete event is signalled but the overlapped result was allready cancelled. The * overlapped I/O may have bee cancelled for one of the following reasons: * - Driver cancelled because of pipe timeout policy expiration. * - The device was disconnected. * - A \ref UsbK_AbortPipe request was issued. * \ENDWINERROR * * \ENDWINERRORTABLE * */ KUSB_EXP BOOL KUSB_API OvlK_Wait( _in KOVL_HANDLE OverlappedK, _inopt INT TimeoutMS, _inopt KOVL_WAIT_FLAG WaitFlags, _out PUINT TransferredLength); //! Waits for overlapped I/O completion on the oldest acquired OverlappedK handle and performs actions specified in \c WaitFlags. /*! * * \param[in] PoolHandle * The pool handle containing one or more acuired OverlappedKs. * * \param[out] OverlappedK * On success, set to the oldest overlappedK in the acquired list. * * \param[in] TimeoutMS * See /ref OvlK_Wait * * \param[in] WaitFlags * See /ref KOVL_WAIT_FLAG * * \param[out] TransferredLength * See /ref OvlK_Wait * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. See * See /ref OvlK_Wait */ KUSB_EXP BOOL KUSB_API OvlK_WaitOldest( _in KOVL_POOL_HANDLE PoolHandle, _outopt KOVL_HANDLE* OverlappedK, _inopt INT TimeoutMS, _inopt KOVL_WAIT_FLAG WaitFlags, _out PUINT TransferredLength); //! Waits for overlapped I/O completion, cancels on a timeout error. /*! * * \param[in] OverlappedK * The overlappedK to wait on. * * \param[in] TimeoutMS * Number of milliseconds to wait for overlapped completion. * * \param[out] TransferredLength * On success, returns the number of bytes transferred by this overlappedK. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. See * \ref OvlK_Wait for details on relevant win32 error codes. * * \note This convenience function calls \ref OvlK_Wait with \ref KOVL_WAIT_FLAG_CANCEL_ON_TIMEOUT. * * \c OvlK_WaitOrCancel waits the the time interval specified by \c TimeoutMS for an overlapped result. If * the \c TimeoutMS interval expires the I/O operation is cancelled. The \c OverlappedK is not released back * to its pool. * */ KUSB_EXP BOOL KUSB_API OvlK_WaitOrCancel( _in KOVL_HANDLE OverlappedK, _inopt INT TimeoutMS, _out PUINT TransferredLength); //! Waits for overlapped I/O completion, cancels on a timeout error and always releases the OvlK handle back to its pool. /*! * * \param[in] OverlappedK * The overlappedK to wait on. * * \param[in] TimeoutMS * Number of milliseconds to wait for overlapped completion. * * \param[out] TransferredLength * On success, returns the number of bytes transferred by this overlappedK. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. See * \ref OvlK_Wait for details on relevant win32 error codes. * * \note This convenience function calls \ref OvlK_Wait with \ref KOVL_WAIT_FLAG_RELEASE_ALWAYS. * * \c OvlK_WaitAndRelease waits the the time interval specified by \c TimeoutMS for an overlapped result. * When \c OvlK_WaitOrCancel returns, the I/O operation has either been completed or cancelled. The * \c OverlappedK is always released back to its pool where it can be re-acquired with \ref OvlK_Acquire. * */ KUSB_EXP BOOL KUSB_API OvlK_WaitAndRelease( _in KOVL_HANDLE OverlappedK, _inopt INT TimeoutMS, _out PUINT TransferredLength); //! Checks for i/o completion; returns immediately. (polling) /*! * * \param[in] OverlappedK * The overlappedK to check for completion. * * \warning \ref OvlK_IsComplete does \b no validation on the OverlappedK. It's purpose is to check the event * signal state as fast as possible. * * \returns TRUE if the \c OverlappedK has completed, otherwise FALSE. * * \c OvlK_IsComplete quickly checks if the \c OverlappedK i/o operation has completed. */ KUSB_EXP BOOL KUSB_API OvlK_IsComplete( _in KOVL_HANDLE OverlappedK); //! Initializes an overlappedK for re-use. The overlappedK is not return to its pool. /*! * * \param[in] OverlappedK * The overlappedK to re-use. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * This function performs the following actions: * - Resets the overlapped event to non-signaled via ResetEvent(). * - Clears the internal overlapped information. * - Clears the 'Internal' and 'InternalHigh' members of the windows overlapped structure. * * \note * Re-using OverlappedKs is the most efficient means of OverlappedK management. When an OverlappedK is * "re-used" it is not returned to the pool. Instead, the application retains ownership for use in another * i/o operation. * */ KUSB_EXP BOOL KUSB_API OvlK_ReUse( _in KOVL_HANDLE OverlappedK); /**@}*/ #endif #ifndef _LIBUSBK_STMK_FUNCTIONS /*! \addtogroup stmk * @{ */ //! Initializes a new uni-directional pipe stream. /*! * * \param[out] StreamHandle * On success, receives the new stream handle. * * \param[in] UsbHandle * Usb handle to associate with this stream. * * \param[in] PipeID * Endpoint address of USB pipe to associate with this stream. * * \param[in] MaxTransferSize * Maximum number of bytes transferred at once. Larger transfers committed with the stream read/write * functions are automatically split into multiple smaller chunks. * * \param[in] MaxPendingTransfers * Maximum number of transfers allowed to be outstanding and the total number of transfer contexts that are * allocated to the stream. * * \param[in] MaxPendingIO * Maximum number of I/O requests the internal stream thread is allowed to have submit at any given time. * (Pending I/O) * * \param[in] Callbacks * Optional user callback functions. If specified, these callback functions will be executed in real time * (from within the context of the internal stream thread) as transfers go through the various states. * * \param[in] Flags * Additional stream flags. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * \par * When a stream is initialized, it validates input parameters and allocates the required memory for the * transfer context array and transfer lists from a private memory heap. The stream is not started and no I/O * requests are sent to the device until \ref StmK_Start is executed. * */ KUSB_EXP BOOL KUSB_API StmK_Init( _out KSTM_HANDLE* StreamHandle, _in KUSB_HANDLE UsbHandle, _in UCHAR PipeID, _in INT MaxTransferSize, _in INT MaxPendingTransfers, _in INT MaxPendingIO, _inopt PKSTM_CALLBACK Callbacks, _inopt KSTM_FLAG Flags); //! Frees resources allocated by a stream handle. /*! * * \param[in] StreamHandle * The stream handle to free. * * \returns TRUE. * * If the stream is currently started it is automatically stopped before its resources are freed. * */ KUSB_EXP BOOL KUSB_API StmK_Free( _in KSTM_HANDLE StreamHandle); //! Starts the internal stream thread. /*! * * \param[in] StreamHandle * The stream to start. A stream handle is created with \ref StmK_Init. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * \par * When a stream is started, an internal thread is created for managing pipe I/O operations. If a * \ref KSTM_CALLBACK::Started callback function is assgined, it is executed \b for each transfer context. * (\b MaxPendingTransfers) See \ref StmK_Init. * */ KUSB_EXP BOOL KUSB_API StmK_Start( _in KSTM_HANDLE StreamHandle); //! Stops the internal stream thread. /*! * * \param[in] StreamHandle * The stream to stop. * * \param[in] TimeoutCancelMS * Number of milliseconds the internal stream thread should wait for pending I/O to complete before * cancelling all pending requests. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * */ KUSB_EXP BOOL KUSB_API StmK_Stop( _in KSTM_HANDLE StreamHandle, _in INT TimeoutCancelMS); //! Reads data from the stream buffer. /*! * * \param[in] StreamHandle * The stream to read. * * \param[out] Buffer * A caller-allocated buffer that receives the data that is read. * * \param[in] Offset * Read start offset of \c Buffer. * * \param[in] Length * Size of \c Buffer. * * \param[out] TransferredLength * On success, receives the actual number of bytes that were copied into \c Buffer. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * - Read Stream Operations: * -# The internal stream thread will always try and keep reads pending as specified by \b MaxPendingIO in * \ref StmK_Init. * -# As the stream submits transfers, it increments the \b PendingIO and \b PendingTransfer counts. As it * completes transfers, it decrements the \b PendingIO count. As the user processes transfers with * \ref StmK_Read, it decrements the \b PendingTransfer count and release control of the transfer context * back to the stream where it is re-used. * -# When the pending I/O count reaches \c MaxPendingIO, the stream completes the oldest * \b PendingTransfer and moves it into a FIFO complete where it awaits user processing via the * \ref StmK_Read function. * -# If the stream has not exhausted its MaxPendingTransfers count, another read request is submitted * immediately to satisfy \b MaxPendingIO. * */ KUSB_EXP BOOL KUSB_API StmK_Read( _in KSTM_HANDLE StreamHandle, _out PUCHAR Buffer, _in INT Offset, _in INT Length, _out PUINT TransferredLength); //! Writes data to the stream buffer. /*! * * \param[in] StreamHandle * The stream to write. * * \param[in] Buffer * A caller-allocated buffer the data is written from. * * \param[in] Offset * Write start offset of \c Buffer. * * \param[in] Length * Number of bytes to copy into the stream buffer. * * \param[out] TransferredLength * On success, receives the actual number of bytes that were copied into the stream buffer. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * - Write Stream Operations: * -# The internal stream thread will always try and exhaust all pending transfers submitted by the user * via \ref StmK_Write. * -# As the user submits transfers via \ref StmK_Write, the \b PendingTransfer count is inceremented and * transfers are added to a queued FIFO list where they await processing by the internal stream thread. * -# While the queued FIFO list is not empty and \b PendingIO count is less than \b MaxPendingIO, The * \b PendingIO count increments and the request is sent to the device. * -# When a transfer completes, the internal pending I/O count is decremented and the transfers is moved * back into the idle list where it can be reused again by subsequent \ref StmK_Write requests. * */ KUSB_EXP BOOL KUSB_API StmK_Write( _in KSTM_HANDLE StreamHandle, _in PUCHAR Buffer, _in INT Offset, _in INT Length, _out PUINT TransferredLength); /**@}*/ #endif #ifndef _LIBUSBK_ISOK_FUNCTIONS /*! \addtogroup isok * @{ */ //! Creates a new isochronous transfer context for libusbK only. /*! * * \param[out] IsoContext * Receives a new isochronous transfer context. * * \param[in] NumberOfPackets * The number of \ref KISO_PACKET structures allocated to \c IsoContext. Assigned to * \ref KISO_CONTEXT::NumberOfPackets. The \ref KISO_CONTEXT::NumberOfPackets field is assignable by * \c IsoK_Init only and must not be changed by the user. * * \param[in] StartFrame * The USB frame number this request must start on (or \b 0 for ASAP) and assigned to * \ref KISO_CONTEXT::StartFrame. The \ref KISO_CONTEXT::StartFrame may be chamged by the user in subsequent * request. For more information, see \ref KISO_CONTEXT::StartFrame. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * \c IsoK_Init is performs the following tasks in order: * -# Allocates the \c IsoContext and the required \ref KISO_PACKET structures. * -# Zero-initializes all ISO context memory. * -# Assigns \b NumberOfPackets, \b PipeID, and \b StartFrame to \c IsoContext. * */ KUSB_EXP BOOL KUSB_API IsoK_Init( _out PKISO_CONTEXT* IsoContext, _in INT NumberOfPackets, _inopt INT StartFrame); //! Destroys an isochronous transfer context. /*! * \param[in] IsoContext * A pointer to an isochronous transfer context created with \ref IsoK_Init. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. */ KUSB_EXP BOOL KUSB_API IsoK_Free( _in PKISO_CONTEXT IsoContext); //! Convenience function for setting the offset of all ISO packets of an isochronous transfer context. /*! * \param[in] IsoContext * A pointer to an isochronous transfer context. * * \param[in] PacketSize * The packet size used to calculate and assign the absolute data offset for each \ref KISO_PACKET in * \c IsoContext. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * \c IsoK_SetPackets updates all \ref KISO_PACKET::Offset fields in a \ref KISO_CONTEXT so all offset are * \c PacketSize apart. For example: * - The offset of the first (0-index) packet is 0. * - The offset of the second (1-index) packet is PacketSize. * - The offset of the third (2-index) packet is PacketSize*2. * * \code * for (packetIndex = 0; packetIndex < IsoContext->NumberOfPackets; packetIndex++) * IsoContext->IsoPackets[packetIndex].Offset = packetIndex * PacketSize; * \endcode * */ KUSB_EXP BOOL KUSB_API IsoK_SetPackets( _in PKISO_CONTEXT IsoContext, _in INT PacketSize); //! Convenience function for setting all fields of a \ref KISO_PACKET. /*! * \param[in] IsoContext * A pointer to an isochronous transfer context. * * \param[in] PacketIndex * The packet index to set. * * \param[in] IsoPacket * Pointer to a user allocated \c KISO_PACKET which is copied into the PKISO_CONTEXT::IsoPackets array at the * specified index. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. */ KUSB_EXP BOOL KUSB_API IsoK_SetPacket( _in PKISO_CONTEXT IsoContext, _in INT PacketIndex, _in PKISO_PACKET IsoPacket); //! Convenience function for getting all fields of a \ref KISO_PACKET. /*! * \param[in] IsoContext * A pointer to an isochronous transfer context. * * \param[in] PacketIndex * The packet index to get. * * \param[out] IsoPacket * Pointer to a user allocated \c KISO_PACKET which receives a copy of the ISO packet in the * PKISO_CONTEXT::IsoPackets array at the specified index. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. */ KUSB_EXP BOOL KUSB_API IsoK_GetPacket( _in PKISO_CONTEXT IsoContext, _in INT PacketIndex, _out PKISO_PACKET IsoPacket); //! Convenience function for enumerating ISO packets of an isochronous transfer context. /*! * \param[in] IsoContext * A pointer to an isochronous transfer context. * * \param[in] EnumPackets * Pointer to a user supplied callback function which is executed for all ISO packets in \c IsoContext or * until the user supplied callback function returns \c FALSE. * * \param[in] StartPacketIndex * The zero-based ISO packet index to begin enumeration at. * * \param[in] UserState * A user defined value which is passed as a parameter to the user supplied callback function. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. */ KUSB_EXP BOOL KUSB_API IsoK_EnumPackets( _in PKISO_CONTEXT IsoContext, _in KISO_ENUM_PACKETS_CB* EnumPackets, _inopt INT StartPacketIndex, _inopt PVOID UserState); //! Convenience function for re-using an isochronous transfer context in a subsequent request. /*! * \param[in,out] IsoContext * A pointer to an isochronous transfer context. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * \c IsoK_ReUse does the following: * -# Zero-initializes the \b Length and \b Status fields of all \ref KISO_PACKET structures. * -# Zero-initializes the \b StartFrame and \b ErrorCount of the \ref KISO_CONTEXT. * */ KUSB_EXP BOOL KUSB_API IsoK_ReUse( _ref PKISO_CONTEXT IsoContext); /*! @} */ #endif #ifndef _LIBUSBK_ISOCHK_FUNCTIONS /*! \addtogroup isochk * @{ */ //! Creates a new isochronous transfer handle for libusbK or WinUSB. /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[out] IsochHandle * Receives a new isochronous transfer handle. * * \param[in] PipeId * The USB pipe ID that this transfer handle will be used with. * \note The interface containing this pipe must be selected before calling this function. * \note See /ref UsbK_SelectInterface and /ref UsbK_SetAltInterface. * * \param[in] MaxNumberOfPackets * The number of ISO packet structures allocated to this \c IsochHandle. * * \param[in] TransferBuffer * The buffer to use for reading/writing. * * \param[in] TransferBufferSize * The size (in bytes) of /c TransferBuffer. This is also the number of bytes that will be * written/read from the pipe on every call to /ref UsbK_IsochReadPipe and /ref UsbK_IsochWritePipe * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * \c IsochK_Init is performs the following tasks in order: * -# Allocates the \c IsochHandle and the required ISO packet structures. * -# \sa IsochK_SetPacketOffsets * */ KUSB_EXP BOOL KUSB_API IsochK_Init( _out KISOCH_HANDLE* IsochHandle, _in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeId, _in UINT MaxNumberOfPackets, _in PUCHAR TransferBuffer, _in UINT TransferBufferSize); //! Destroys an isochronous transfer handle. /*! * \param[in] IsochHandle * A pointer to an isochronous transfer handle created with \ref IsochK_Init. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. */ KUSB_EXP BOOL KUSB_API IsochK_Free( _in KISOCH_HANDLE IsochHandle); //! Convenience function for setting the offsets and lengths of all ISO packets of an isochronous transfer handle. /*! * \param[in] IsochHandle * A pointer to an isochronous transfer handle. * * \param[in] PacketSize * The packet size used to calculate and assign the absolute data offset for each ISO packet * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * \c IsoK_SetPackets updates iso packet offsets so all offset are \c PacketSize apart. For example: * - The offset of the first (0-index) packet is 0. * - The offset of the second (1-index) packet is PacketSize. * - The offset of the third (2-index) packet is PacketSize*2. */ KUSB_EXP BOOL KUSB_API IsochK_SetPacketOffsets( _in KISOCH_HANDLE IsochHandle, _in UINT PacketSize); //! Convenience function for setting all fields in an isochronous transfer packet. /*! * \param[in] IsochHandle * A pointer to an isochronous transfer handle. * * \param[in] PacketIndex * The packet index to set. * * \param[out] Offset * The offset in the transfer buffer that this packet starts at. * * \param[out] Length * The Length in bytes of this packet. * * \param[out] Status * The transfer status of this packet. This is set by the driver when the transfer completes. * * \remarks * - For \b Read operations, the length and status are updated by the driver on transfer completion * - For \b Write operations, WinUSB does not use the ISO packet structures. * - For \b Write operations, libusbK will update the status field only. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. */ KUSB_EXP BOOL KUSB_API IsochK_SetPacket( _in KISOCH_HANDLE IsochHandle, _in UINT PacketIndex, _in UINT Offset, _in UINT Length, _in UINT Status); //! Convenience function for getting all fields in an isochronous transfer packet. /*! * \param[in] IsochHandle * A pointer to an isochronous transfer handle. * * \param[in] PacketIndex * The packet index to get. * * \param[out] Offset * The offset in the transfer buffer that this packet starts at. * * \param[out] Length * The Length in bytes of this packet. * * \param[out] Status * The transfer status of this packet. This is set by the driver when the transfer completes. * * \remarks * - For \b Read operations, the length and status are updated by the driver on transfer completion * - For \b Write operations, WinUSB does not use the ISO packet structures. * - For \b Write operations, libusbK will update the status field only. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. */ KUSB_EXP BOOL KUSB_API IsochK_GetPacket( _in KISOCH_HANDLE IsochHandle, _in UINT PacketIndex, _outopt PUINT Offset, _outopt PUINT Length, _outopt PUINT Status); //! Convenience function for enumerating ISO packets of an isochronous transfer context. /*! * \param[in] IsochHandle * A pointer to an isochronous transfer context. * * \param[in] EnumPackets * Pointer to a user supplied callback function which is executed for all ISO packets allocated in the * isochronous transfer handle or until the user supplied callback function returns \c FALSE. * * \param[in] StartPacketIndex * The zero-based ISO packet index to begin enumeration at. * * \param[in] UserState * A user defined value which is passed as a parameter to the user supplied callback function. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. */ KUSB_EXP BOOL KUSB_API IsochK_EnumPackets( _in KISOCH_HANDLE IsochHandle, _in KISOCH_ENUM_PACKETS_CB* EnumPackets, _inopt UINT StartPacketIndex, _inopt PVOID UserState); //! Helper function for isochronous packet/transfer calculations. /*! * \param[in] IsHighSpeed * False if the calculations are for a FullSpeed device. True for HighSpeed and SuperSpeed. * * \param[in] PipeInformationEx * A pointer to a \ref WINUSB_PIPE_INFORMATION_EX structure the was obtained from \ref UsbK_QueryPipeEx. * * \param[out] PacketInformation * Pointer to a /ref KISOCH_PACKET_INFORMATION structure that receives the information * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. */ KUSB_EXP BOOL KUSB_API IsochK_CalcPacketInformation( _in BOOL IsHighSpeed, _in PWINUSB_PIPE_INFORMATION_EX PipeInformationEx, _out PKISOCH_PACKET_INFORMATION PacketInformation); //! Gets the number of iso packets that will be used. /*! * \param[in] IsochHandle * A pointer to an isochronous transfer context. * * \param[out] NumberOfPackets * A pointer to variable that will receive the number of ISO packets. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. */ KUSB_EXP BOOL KUSB_API IsochK_GetNumberOfPackets( _in KISOCH_HANDLE IsochHandle, _out PUINT NumberOfPackets); //! Sets the number of iso packets that will be used. /*! * \param[in] IsochHandle * A pointer to an isochronous transfer context. * * \param[in] NumberOfPackets * The number of ISO packets. This value must be less than or equal to the \b MaxNumberOfIsoPackets that this transfer handle was initialized with. See \ref IsochK_Init * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. */ KUSB_EXP BOOL KUSB_API IsochK_SetNumberOfPackets( _in KISOCH_HANDLE IsochHandle, _in UINT NumberOfPackets); /*! @} */ #endif //! Transmits control data over a default control endpoint. /*! * * \param[in] InterfaceHandle * A valid libusbK interface handle returned by: * - \ref UsbK_Init * - \ref UsbK_Initialize * - \ref UsbK_GetAssociatedInterface * - \ref UsbK_Clone * * \param[in] SetupPacket * The 8-byte setup packet of type WINUSB_SETUP_PACKET. * * \param[in,out] Buffer * A caller-allocated buffer that contains the data to transfer. * * \param[in] BufferLength * The number of bytes to transfer, not including the setup packet. This number must be less than or equal to * the size, in bytes, of Buffer. * * \param[out] LengthTransferred * A pointer to a UINT variable that receives the actual number of transferred bytes. If the application * does not expect any data to be transferred during the data phase (BufferLength is zero), LengthTransferred * can be NULL. * * \param[in] Overlapped * An optional pointer to an OVERLAPPED structure, which is used for asynchronous operations. If this * parameter is specified, \ref UsbK_ControlTransfer immediately returns, and the event is signaled when the * operation is complete. If Overlapped is not supplied, the \ref UsbK_ControlTransfer function transfers * data synchronously. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. If an * \c Overlapped member is supplied and the operation succeeds this function returns FALSE and sets last * error to ERROR_IO_PENDING. * * A \ref UsbK_ControlTransfer is never cached. These requests always go directly to the usb device. * * \attention * This function should not be used for operations supported by the library.\n e.g. * \ref LUsb0_SetConfiguration, \ref UsbK_SetAltInterface, etc.. * */ KUSB_EXP BOOL KUSB_API LUsb0_ControlTransfer( _in KUSB_HANDLE InterfaceHandle, _in WINUSB_SETUP_PACKET SetupPacket, _refopt PUCHAR Buffer, _in UINT BufferLength, _outopt PUINT LengthTransferred, _inopt LPOVERLAPPED Overlapped); //! Sets the device configuration number. /*! * * \param[in] InterfaceHandle * An initialized usb handle, see \ref UsbK_Init. * * \param[in] ConfigurationNumber * The configuration number to activate. * * \returns On success, TRUE. Otherwise FALSE. Use \c GetLastError() to get extended error information. * * \ref LUsb0_SetConfiguration is only supported with libusb0.sys. If the driver in not libusb0.sys, this * function performs the following emulation actions: * - If the requested configuration number is the current configuration number, returns TRUE. * - If the requested configuration number is one other than the current configuration number, returns FALSE * and set last error to \c ERROR_NO_MORE_ITEMS. * * This function will fail if there are pending I/O operations or there are other libusbK interface handles * referencing the device. \sa UsbK_Free * */ KUSB_EXP BOOL KUSB_API LUsb0_SetConfiguration( _in KUSB_HANDLE InterfaceHandle, _in UCHAR ConfigurationNumber); #ifdef __cplusplus } #endif #if _MSC_VER >= 1200 #pragma warning(pop) #endif #endif // _LIBUSBK_H__
1097  */
1099 
1101  UCHAR Rsvd1[1];
1102 
1104  /*
1105  * This field contains the value of the compatible ID to be associated with this function. Any unused bytes
1106  * should be filled with NULLs. If the function does not have a compatible ID, fill the entire field with
1107  * NULLs.
1108  */
1109  UCHAR CompatibleID[8];
1110 
1112  /*
1113  * This field contains the value of the subcompatible ID to be associated with this function. Any
1114  * remaining bytes should be filled with NULLs. If the function does not have a subcompatible ID, fill the
1115  * entire field with NULLs.
1116  */
1117  UCHAR SubCompatibleID[8];
1118 
1120  UCHAR Rsvd2[6];
1121 
1122 }MSOSV1_FUNCTION_DESCRIPTOR, *PMSOSV1_FUNCTION_DESCRIPTOR;
1123 
1124 
1125 // !The extended properties OS descriptor is a Microsoft OS feature descriptor that can be used to store vendor-specific property data.
1126 /*
1127 * The extended properties OS descriptor has two components:
1128 * - A fixed-length header section, which contains information about the entire descriptor, including the
1129 * version number and total size.
1130 * - One or more variable-length custom properties sections, which follow the header section. Each section
1131 * contains the data for a single custom property. Although the length of custom properties sections can
1132 * vary, the format is fixed and vendors must not deviate from it.
1133 */
1134 typedef struct _MSOSV1_EXTENDED_PROP_DESCRIPTOR
1135 {
1137  UINT dwLength;
1138 
1140  USHORT bcdVersion;
1141 
1143  USHORT wIndex;
1144 
1146  USHORT wCount;
1147 
1149  UCHAR CustomProperties[0];
1150 
1151 }MSOSV1_EXTENDED_PROP_DESCRIPTOR, * PMSOSV1_EXTENDED_PROP_DESCRIPTOR;
1152 
1154 /*
1155  * An interface that has an associated extended properties OS feature descriptor can have one or more
1156  * custom property sections following the header section.
1157  *
1158  * This section is followed by a variable length property name and data field:
1159  * - wPropertyNameLength in bytes (USHORT)
1160  * The length of bPropertyName, in bytes, including the trailing NULL character. wPropertyNameLength
1161  * is an unsigned 2-byte value, to support the use of long property names.
1162  * - bPropertyName[wPropertyNameLength]
1163  * The property name, as a NULL-terminated Unicode string.
1164  * - wPropertyDataLength in bytes (USHORT)
1165  * The size of the bPropertyData field, in bytes.
1166  * - bPropertyData[wPropertyDataLength]
1167  * The property data.
1168  *
1169 */
1170 typedef struct _MSOSV1_CUSTOM_PROP_DESCRIPTOR
1171 {
1173  UINT dwSize;
1174 
1176  /*
1177  * - 0 RESERVED
1178  * - 1 A NULL-terminated Unicode String (REG_SZ)
1179  * - 2 A NULL-terminated Unicode String that includes environment variables (REG_EXPAND_SZ)
1180  * - 3 Free-form binary (REG_BINARY)
1181  * - 4 A little-endian 32-bit integer (REG_DWORD_LITTLE_ENDIAN)
1182  * - 5 A big-endian 32-bit integer (REG_DWORD_BIG_ENDIAN)
1183  * - 6 A NULL-terminated Unicode string that contains a symbolic link (REG_LINK)
1184  * - 7 Multiple NULL-terminated Unicode strings (REG_MULTI_SZ)
1185  * - 8 and higher RESERVED
1186  */
1188 
1190  UCHAR CustomProperty[0];
1191 
1192 }MSOSV1_CUSTOM_PROP_DESCRIPTOR, * PMSOSV1_CUSTOM_PROP_DESCRIPTOR;
1193 
1195 typedef struct _MSOS_CUSTOM_PROP_ELEMENT
1196 {
1197  USHORT wPropertyNameLength;
1198  PWCHAR pPropertyName;
1199  USHORT wPropertyDataLength;
1200  PUCHAR pPropertyData;
1201 }MSOS_CUSTOM_PROP_ELEMENT,*PMSOS_CUSTOM_PROP_ELEMENT;
1202 
1209 typedef enum _MSOSV2_DESCRIPTOR_TYPE
1211 {
1214 
1217 
1220 
1223 
1226 
1229 
1232 
1235 
1239 
1241 typedef struct _MSOSV2_COMMON_DESCRIPTOR
1242 {
1244  USHORT wLength;
1245 
1248 
1249 }MSOSV2_COMMON_DESCRIPTOR, * PMSOSV2_COMMON_DESCRIPTOR;
1250 
1252 typedef struct _MSOSV2_SET_HEADER_DESCRIPTOR
1253 {
1255  USHORT wLength;
1256 
1259 
1262 
1265 
1266 }MSOSV2_SET_HEADER_DESCRIPTOR,*PMSOSV2_SET_HEADER_DESCRIPTOR;
1267 
1269 typedef struct _MSOSV2_SUBSET_HEADER_CONFIGURATION_DESCRIPTOR
1270 {
1272  USHORT wLength;
1273 
1276 
1279 
1281  UCHAR bReserved;
1282 
1285 
1286 }MSOSV2_SUBSET_HEADER_CONFIGURATION_DESCRIPTOR, * PMSOSV2_SUBSET_HEADER_CONFIGURATION_DESCRIPTOR;
1287 
1289 typedef struct _MSOSV2_SUBSET_HEADER_FUNCTION_DESCRIPTOR
1290 {
1292  USHORT wLength;
1293 
1296 
1299 
1301  UCHAR bReserved;
1302 
1305 
1306 }MSOSV2_SUBSET_HEADER_FUNCTION_DESCRIPTOR, * PMSOSV2_SUBSET_HEADER_FUNCTION_DESCRIPTOR;
1307 
1309 /*
1310  * The Microsoft OS 2.0 compatible ID descriptor is used to define a compatible device ID. Its usage is
1311  * identical to the Microsoft OS extended configuration descriptor defined in MS OS descriptors specification
1312  * version 1.0.
1313  *
1314  * The compatible ID can be applied to the entire device or a specific function within a composite device.
1315  */
1316 typedef struct _MSOSV2_FEATURE_COMPATBLE_ID_DESCRIPTOR
1317 {
1319  USHORT wLength;
1320 
1323 
1325  /*
1326  * This field contains the value of the compatible ID to be associated with this function. Any unused bytes
1327  * should be filled with NULLs. If the function does not have a compatible ID, fill the entire field with
1328  * NULLs.
1329  */
1330  UCHAR CompatibleID[8];
1331 
1333  /*
1334  * This field contains the value of the subcompatible ID to be associated with this function. Any
1335  * remaining bytes should be filled with NULLs. If the function does not have a subcompatible ID, fill the
1336  * entire field with NULLs.
1337  */
1338  UCHAR SubCompatibleID[8];
1339 
1340 }MSOSV2_FEATURE_COMPATBLE_ID_DESCRIPTOR, * PMSOSV2_FEATURE_COMPATBLE_ID_DESCRIPTOR;
1341 
1343 /*
1344  * The Microsoft OS 2.0 registry property descriptor is used to add per-device or per-function registry values
1345  * that is read by the Windows USB driver stack or the device’s function driver. Usage is similar to Microsoft
1346  * OS extended property descriptor defined MS OS descriptors specification version 1.0.
1347  *
1348  * Windows retrieves MS OS 2.0 registry property descriptor values during device enumeration as part of the
1349  * overall descriptor set. However, only the values that are retrieved during the first device enumeration are
1350  * written to the registry and used subsequently. The behavior is to maintain registry values that might be
1351  * changed by the user.
1352  *
1353  * The registry property descriptor can be applied to the entire device or a specific function within a
1354  * composite device.
1355  */
1356 typedef struct _MSOSV2_FEATURE_REG_PROPERTY_DESCRIPTOR
1357 {
1359  USHORT wLength;
1360 
1363 
1365  /*
1366  * - 0 RESERVED
1367  * - 1 A NULL-terminated Unicode String (REG_SZ)
1368  * - 2 A NULL-terminated Unicode String that includes environment variables (REG_EXPAND_SZ)
1369  * - 3 Free-form binary (REG_BINARY)
1370  * - 4 A little-endian 32-bit integer (REG_DWORD_LITTLE_ENDIAN)
1371  * - 5 A big-endian 32-bit integer (REG_DWORD_BIG_ENDIAN)
1372  * - 6 A NULL-terminated Unicode string that contains a symbolic link (REG_LINK)
1373  * - 7 Multiple NULL-terminated Unicode strings (REG_MULTI_SZ)
1374  * - 8 and higher RESERVED
1375  */
1377 
1379  UCHAR CustomProperty[0];
1380 
1381 }MSOSV2_FEATURE_REG_PROPERTY_DESCRIPTOR, * PMSOSV2_FEATURE_REG_PROPERTY_DESCRIPTOR;
1382 
1384 /*
1385  * The Microsoft OS 2.0 minimum USB resume time descriptor is used to indicate to the Windows USB driver
1386  * stack the minimum time needed to recover after resuming from suspend, and how long the device requires
1387  * resume signaling to be asserted. This descriptor is used for a device operating at high, full, or
1388  * low-speed. It is not used for a device operating at SuperSpeed or higher.
1389  *
1390  * This descriptor allows devices to recover faster than the default 10 millisecond specified in the USB
1391  * 2.0 specification. It can also allow the host to assert resume signaling for less than the 20
1392  * milliseconds required in the USB 2.0 specification, in cases where the timing of resume signaling is
1393  * controlled by software.
1394  *
1395  * The USB resume time descriptor is applied to the entire device.
1396  */
1397 typedef struct _MSOSV2_FEATURE_MIN_RESUME_TIME_DESCRIPTOR
1398 {
1400  USHORT wLength;
1401 
1404 
1407 
1410 }MSOSV2_FEATURE_MIN_RESUME_TIME_DESCRIPTOR, * PMSOSV2_FEATURE_MIN_RESUME_TIME_DESCRIPTOR;
1411 
1413 /*
1414  * The Microsoft OS 2.0 model ID descriptor is used to uniquely identify the physical device.
1415  *
1416  * The model ID descriptor is applied to the entire device.
1417  */
1418 typedef struct _MSOSV2_FEATURE_MODEL_ID_DESCRIPTOR
1419 {
1421  USHORT wLength;
1422 
1425 
1427  UCHAR ModelID[16];
1428 }MSOSV2_FEATURE_MODEL_ID_DESCRIPTOR, * PMSOSV2_FEATURE_MODEL_ID_DESCRIPTOR;
1429 
1431 /*
1432  * The Microsoft OS 2.0 CCGP device descriptor is used to indicate that the device should be treated as a
1433  * composite device by Windows regardless of the number of interfaces, configuration, or class, subclass,
1434  * and protocol codes, the device reports.
1435  *
1436  * The CCGP device descriptor must be applied to the entire device.
1437  */
1438 typedef struct _MSOSV2_FEATURE_CCGP_DESCRIPTOR
1439 {
1441  USHORT wLength;
1442 
1445 
1446 }MSOSV2_FEATURE_CCGP_DESCRIPTOR, * PMSOSV2_FEATURE_CCGP_DESCRIPTOR;
1447 
1449 /*
1450  * The Microsoft OS 2.0 vendor revision descriptor is used to indicate the revision of registry property
1451  * and other MSOS descriptors. If this value changes between enumerations the registry property
1452  * descriptors will be updated in registry during that enumeration. You must always change this value
1453  * if you are adding/ modifying any registry property or other MSOS descriptors.
1454  *
1455  * The vendor revision descriptor must be applied at the device scope for a non-composite device or for
1456  * MSOS descriptors that apply to the device scope of a composite device. Additionally, for a composite
1457  * device, the vendor revision descriptor must be provided in every function subset and may be updated
1458  * independently per-function.
1459  */
1460 typedef struct _MSOSV2_FEATURE_VENDOR_REVISION_DESCRIPTOR
1461 {
1463  USHORT wLength;
1464 
1467 
1469  /*
1470  * Modify it every time you add / modify a registry property or other MSOS descriptor.Shell set to
1471  * greater than or equal to 1.
1472  */
1474 
1475 }MSOSV2_FEATURE_VENDOR_REVISION_DESCRIPTOR, * PMSOSV2_FEATURE_VENDOR_REVISION_DESCRIPTOR;
1478 #if _MSC_VER >= 1200
1479 #pragma warning(pop)
1480 #endif
1481 
1483 /*
1484 *
1485 * This descriptor is documented in section 9.6.3 of the USB 2.0 specification.
1486 * All multiple-byte fields are represented in host-endian format.
1487 *
1488 */
1489 typedef struct _USB_CONFIGURATION_DESCRIPTOR
1490 {
1492  UCHAR bLength;
1493 
1496 
1499 
1502 
1505 
1508 
1511 
1513 
1516  UCHAR MaxPower;
1520 
1522 
1526 typedef struct _USB_INTERFACE_DESCRIPTOR
1527 {
1529  UCHAR bLength;
1530 
1533 
1536 
1539 
1542 
1545 
1548 
1551 
1553  UCHAR iInterface;
1554 
1558 
1560 
1564 typedef struct _USB_STRING_DESCRIPTOR
1565 {
1567  UCHAR bLength;
1568 
1571 
1573  WCHAR bString[1];
1574 
1578 
1580 typedef struct _USB_COMMON_DESCRIPTOR
1581 {
1583  UCHAR bLength;
1584 
1587 
1591 
1592 #if _MSC_VER >= 1200
1593 #pragma warning(push)
1594 #endif
1595 #pragma warning (disable:4201)
1596 #pragma warning(disable:4214) // named type definition in parentheses
1597 
1599 
1612 typedef struct _USB_INTERFACE_ASSOCIATION_DESCRIPTOR
1613 {
1615  UCHAR bLength;
1616 
1619 
1622 
1625 
1628 
1631 
1634 
1636  UCHAR iFunction;
1637 
1641 
1642 #if _MSC_VER >= 1200
1643 #pragma warning(pop)
1644 #endif
1645 
1648 #include <poppack.h>
1649 #endif // __USB_H__
1650 
1651 #ifndef _LIBUSBK_LIBK_TYPES
1652 
1657 typedef enum _KUSB_PROPERTY
1659 {
1662 
1663  KUSB_PROPERTY_COUNT
1664 
1665 } KUSB_PROPERTY;
1666 
1668 typedef enum _KUSB_DRVID
1669 {
1672 
1675 
1678 
1681 
1684 
1685 } KUSB_DRVID;
1686 
1688 typedef enum _KUSB_FNID
1689 {
1692 
1695 
1698 
1701 
1704 
1707 
1710 
1713 
1716 
1719 
1722 
1725 
1728 
1731 
1734 
1737 
1740 
1743 
1746 
1749 
1752 
1755 
1758 
1761 
1764 
1767 
1770 
1773 
1776 
1779 
1782 
1785 
1788 
1791 
1794 
1797 
1800 
1803 
1806 
1807 } KUSB_FNID;
1808 
1809 typedef BOOL KUSB_API KUSB_Init (
1810  _out KUSB_HANDLE* InterfaceHandle,
1811  _in KLST_DEVINFO_HANDLE DevInfo);
1812 
1813 typedef BOOL KUSB_API KUSB_Free (
1814  _in KUSB_HANDLE InterfaceHandle);
1815 
1816 typedef BOOL KUSB_API KUSB_ClaimInterface (
1817  _in KUSB_HANDLE InterfaceHandle,
1818  _in UCHAR NumberOrIndex,
1819  _in BOOL IsIndex);
1820 
1821 typedef BOOL KUSB_API KUSB_ReleaseInterface (
1822  _in KUSB_HANDLE InterfaceHandle,
1823  _in UCHAR NumberOrIndex,
1824  _in BOOL IsIndex);
1825 
1826 typedef BOOL KUSB_API KUSB_SetAltInterface (
1827  _in KUSB_HANDLE InterfaceHandle,
1828  _in UCHAR NumberOrIndex,
1829  _in BOOL IsIndex,
1830  _in UCHAR AltSettingNumber);
1831 
1832 typedef BOOL KUSB_API KUSB_GetAltInterface (
1833  _in KUSB_HANDLE InterfaceHandle,
1834  _in UCHAR NumberOrIndex,
1835  _in BOOL IsIndex,
1836  _out PUCHAR AltSettingNumber);
1837 
1838 typedef BOOL KUSB_API KUSB_GetDescriptor (
1839  _in KUSB_HANDLE InterfaceHandle,
1840  _in UCHAR DescriptorType,
1841  _in UCHAR Index,
1842  _in USHORT LanguageID,
1843  _out PUCHAR Buffer,
1844  _in UINT BufferLength,
1845  _outopt PUINT LengthTransferred);
1846 
1847 typedef BOOL KUSB_API KUSB_ControlTransfer (
1848  _in KUSB_HANDLE InterfaceHandle,
1849  _in WINUSB_SETUP_PACKET SetupPacket,
1850  _refopt PUCHAR Buffer,
1851  _in UINT BufferLength,
1852  _outopt PUINT LengthTransferred,
1853  _inopt LPOVERLAPPED Overlapped);
1854 
1855 typedef BOOL KUSB_API KUSB_SetPowerPolicy (
1856  _in KUSB_HANDLE InterfaceHandle,
1857  _in UINT PolicyType,
1858  _in UINT ValueLength,
1859  _in PVOID Value);
1860 
1861 typedef BOOL KUSB_API KUSB_GetPowerPolicy (
1862  _in KUSB_HANDLE InterfaceHandle,
1863  _in UINT PolicyType,
1864  _ref PUINT ValueLength,
1865  _out PVOID Value);
1866 
1867 typedef BOOL KUSB_API KUSB_SetConfiguration (
1868  _in KUSB_HANDLE InterfaceHandle,
1869  _in UCHAR ConfigurationNumber);
1870 
1871 typedef BOOL KUSB_API KUSB_GetConfiguration (
1872  _in KUSB_HANDLE InterfaceHandle,
1873  _out PUCHAR ConfigurationNumber);
1874 
1875 typedef BOOL KUSB_API KUSB_ResetDevice (
1876  _in KUSB_HANDLE InterfaceHandle);
1877 
1878 typedef BOOL KUSB_API KUSB_Initialize (
1879  _in HANDLE DeviceHandle,
1880  _out KUSB_HANDLE* InterfaceHandle);
1881 
1882 typedef BOOL KUSB_API KUSB_SelectInterface (
1883  _in KUSB_HANDLE InterfaceHandle,
1884  _in UCHAR NumberOrIndex,
1885  _in BOOL IsIndex);
1886 
1887 typedef BOOL KUSB_API KUSB_GetAssociatedInterface (
1888  _in KUSB_HANDLE InterfaceHandle,
1889  _in UCHAR AssociatedInterfaceIndex,
1890  _out KUSB_HANDLE* AssociatedInterfaceHandle);
1891 
1892 typedef BOOL KUSB_API KUSB_Clone (
1893  _in KUSB_HANDLE InterfaceHandle,
1894  _out KUSB_HANDLE* DstInterfaceHandle);
1895 
1896 typedef BOOL KUSB_API KUSB_QueryInterfaceSettings (
1897  _in KUSB_HANDLE InterfaceHandle,
1898  _in UCHAR AltSettingIndex,
1899  _out PUSB_INTERFACE_DESCRIPTOR UsbAltInterfaceDescriptor);
1900 
1901 typedef BOOL KUSB_API KUSB_QueryDeviceInformation (
1902  _in KUSB_HANDLE InterfaceHandle,
1903  _in UINT InformationType,
1904  _ref PUINT BufferLength,
1905  _ref PUCHAR Buffer);
1906 
1907 typedef BOOL KUSB_API KUSB_SetCurrentAlternateSetting (
1908  _in KUSB_HANDLE InterfaceHandle,
1909  _in UCHAR AltSettingNumber);
1910 
1911 typedef BOOL KUSB_API KUSB_GetCurrentAlternateSetting (
1912  _in KUSB_HANDLE InterfaceHandle,
1913  _out PUCHAR AltSettingNumber);
1914 
1915 typedef BOOL KUSB_API KUSB_QueryPipe (
1916  _in KUSB_HANDLE InterfaceHandle,
1917  _in UCHAR AltSettingNumber,
1918  _in UCHAR PipeIndex,
1919  _out PWINUSB_PIPE_INFORMATION PipeInformation);
1920 
1921 typedef BOOL KUSB_API KUSB_QueryPipeEx(
1922  _in KUSB_HANDLE InterfaceHandle,
1923  _in UCHAR AlternateSettingNumber,
1924  _in UCHAR PipeIndex,
1925  _out PWINUSB_PIPE_INFORMATION_EX PipeInformationEx);
1926 
1927 typedef BOOL KUSB_API KUSB_GetSuperSpeedPipeCompanionDescriptor(
1928  __in KUSB_HANDLE Handle,
1929  __in UCHAR AltSettingNumber,
1930  __in UCHAR PipeIndex,
1931  __out PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR PipeCompanionDescriptor);
1932 
1933 typedef BOOL KUSB_API KUSB_SetPipePolicy (
1934  _in KUSB_HANDLE InterfaceHandle,
1935  _in UCHAR PipeID,
1936  _in UINT PolicyType,
1937  _in UINT ValueLength,
1938  _in PVOID Value);
1939 
1940 typedef BOOL KUSB_API KUSB_GetPipePolicy (
1941  _in KUSB_HANDLE InterfaceHandle,
1942  _in UCHAR PipeID,
1943  _in UINT PolicyType,
1944  _ref PUINT ValueLength,
1945  _out PVOID Value);
1946 
1947 typedef BOOL KUSB_API KUSB_ReadPipe (
1948  _in KUSB_HANDLE InterfaceHandle,
1949  _in UCHAR PipeID,
1950  _out PUCHAR Buffer,
1951  _in UINT BufferLength,
1952  _outopt PUINT LengthTransferred,
1953  _inopt LPOVERLAPPED Overlapped);
1954 
1955 typedef BOOL KUSB_API KUSB_WritePipe (
1956  _in KUSB_HANDLE InterfaceHandle,
1957  _in UCHAR PipeID,
1958  _in PUCHAR Buffer,
1959  _in UINT BufferLength,
1960  _outopt PUINT LengthTransferred,
1961  _inopt LPOVERLAPPED Overlapped);
1962 
1963 typedef BOOL KUSB_API KUSB_ResetPipe (
1964  _in KUSB_HANDLE InterfaceHandle,
1965  _in UCHAR PipeID);
1966 
1967 typedef BOOL KUSB_API KUSB_AbortPipe (
1968  _in KUSB_HANDLE InterfaceHandle,
1969  _in UCHAR PipeID);
1970 
1971 typedef BOOL KUSB_API KUSB_FlushPipe (
1972  _in KUSB_HANDLE InterfaceHandle,
1973  _in UCHAR PipeID);
1974 
1975 typedef BOOL KUSB_API KUSB_IsoReadPipe (
1976  _in KUSB_HANDLE InterfaceHandle,
1977  _in UCHAR PipeID,
1978  _out PUCHAR Buffer,
1979  _in UINT BufferLength,
1980  _in LPOVERLAPPED Overlapped,
1981  _refopt PKISO_CONTEXT IsoContext);
1982 
1983 typedef BOOL KUSB_API KUSB_IsoWritePipe (
1984  _in KUSB_HANDLE InterfaceHandle,
1985  _in UCHAR PipeID,
1986  _in PUCHAR Buffer,
1987  _in UINT BufferLength,
1988  _in LPOVERLAPPED Overlapped,
1989  _refopt PKISO_CONTEXT IsoContext);
1990 
1991 typedef BOOL KUSB_API KUSB_GetCurrentFrameNumber (
1992  _in KUSB_HANDLE InterfaceHandle,
1993  _out PUINT FrameNumber);
1994 
1995 typedef BOOL KUSB_API KUSB_GetOverlappedResult (
1996  _in KUSB_HANDLE InterfaceHandle,
1997  _in LPOVERLAPPED Overlapped,
1998  _out PUINT lpNumberOfBytesTransferred,
1999  _in BOOL bWait);
2000 
2001 typedef BOOL KUSB_API KUSB_GetProperty (
2002  _in KUSB_HANDLE InterfaceHandle,
2003  _in KUSB_PROPERTY PropertyType,
2004  _ref PUINT PropertySize,
2005  _out PVOID Value);
2006 
2007 typedef BOOL KUSB_API KUSB_IsochReadPipe(
2008  _in KISOCH_HANDLE IsochHandle,
2009  _inopt UINT DataLength,
2010  _refopt PUINT FrameNumber,
2011  _inopt UINT NumberOfPackets,
2012  _in LPOVERLAPPED Overlapped);
2013 
2014 typedef BOOL KUSB_API KUSB_IsochWritePipe(
2015  _in KISOCH_HANDLE IsochHandle,
2016  _inopt UINT DataLength,
2017  _refopt PUINT FrameNumber,
2018  _inopt UINT NumberOfPackets,
2019  _in LPOVERLAPPED Overlapped);
2020 
2021 
2023 
2028 typedef struct _KUSB_DRIVER_API_INFO
2029 {
2032 
2035 
2037 
2039 /*
2040 * Contains the driver specific USB core function pointer set.
2041 *
2042 * \note
2043 * This structure has a fixed 512 byte structure size.
2044 */
2045 typedef struct _KUSB_DRIVER_API
2046 {
2049 
2054  KUSB_Init* Init;
2055 
2060  KUSB_Free* Free;
2061 
2066  KUSB_ClaimInterface* ClaimInterface;
2067 
2072  KUSB_ReleaseInterface* ReleaseInterface;
2073 
2078  KUSB_SetAltInterface* SetAltInterface;
2079 
2084  KUSB_GetAltInterface* GetAltInterface;
2085 
2090  KUSB_GetDescriptor* GetDescriptor;
2091 
2096  KUSB_ControlTransfer* ControlTransfer;
2097 
2102  KUSB_SetPowerPolicy* SetPowerPolicy;
2103 
2108  KUSB_GetPowerPolicy* GetPowerPolicy;
2109 
2114  KUSB_SetConfiguration* SetConfiguration;
2115 
2120  KUSB_GetConfiguration* GetConfiguration;
2121 
2126  KUSB_ResetDevice* ResetDevice;
2127 
2132  KUSB_Initialize* Initialize;
2133 
2138  KUSB_SelectInterface* SelectInterface;
2139 
2144  KUSB_GetAssociatedInterface* GetAssociatedInterface;
2145 
2150  KUSB_Clone* Clone;
2151 
2156  KUSB_QueryInterfaceSettings* QueryInterfaceSettings;
2157 
2162  KUSB_QueryDeviceInformation* QueryDeviceInformation;
2163 
2168  KUSB_SetCurrentAlternateSetting* SetCurrentAlternateSetting;
2169 
2174  KUSB_GetCurrentAlternateSetting* GetCurrentAlternateSetting;
2175 
2180  KUSB_QueryPipe* QueryPipe;
2181 
2186  KUSB_SetPipePolicy* SetPipePolicy;
2187 
2192  KUSB_GetPipePolicy* GetPipePolicy;
2193 
2198  KUSB_ReadPipe* ReadPipe;
2199 
2204  KUSB_WritePipe* WritePipe;
2205 
2210  KUSB_ResetPipe* ResetPipe;
2211 
2216  KUSB_AbortPipe* AbortPipe;
2217 
2222  KUSB_FlushPipe* FlushPipe;
2223 
2228  KUSB_IsoReadPipe* IsoReadPipe;
2229 
2234  KUSB_IsoWritePipe* IsoWritePipe;
2235 
2240  KUSB_GetCurrentFrameNumber* GetCurrentFrameNumber;
2241 
2246  KUSB_GetOverlappedResult* GetOverlappedResult;
2247 
2252  KUSB_GetProperty* GetProperty;
2253 
2258  KUSB_IsochReadPipe* IsochReadPipe;
2259 
2264  KUSB_IsochWritePipe* IsochWritePipe;
2265 
2270  KUSB_QueryPipeEx* QueryPipeEx;
2271 
2276  KUSB_GetSuperSpeedPipeCompanionDescriptor* GetSuperSpeedPipeCompanionDescriptor;
2277 
2279  UCHAR z_F_i_x_e_d[512 - sizeof(KUSB_DRIVER_API_INFO) - sizeof(UINT_PTR) * KUSB_FNID_COUNT - (KUSB_FNID_COUNT & (sizeof(UINT_PTR) - 1) ? (KUSB_FNID_COUNT & (~(sizeof(UINT_PTR) - 1))) + sizeof(UINT_PTR) : KUSB_FNID_COUNT)];
2280 
2282  UCHAR z_FuncSupported[(KUSB_FNID_COUNT & (sizeof(UINT_PTR) - 1) ? (KUSB_FNID_COUNT & (~(sizeof(UINT_PTR) - 1))) + sizeof(UINT_PTR) : KUSB_FNID_COUNT)];
2283 
2284 } KUSB_DRIVER_API;
2286 USBK_C_ASSERT(KUSB_DRIVER_API,sizeof(KUSB_DRIVER_API) == 512);
2288 #endif
2289 
2290 #ifndef _LIBUSBK_HOTK_TYPES
2291 
2296 typedef enum _KHOT_FLAG
2298 {
2301 
2304 
2307 
2310 } KHOT_FLAG;
2311 
2313 typedef VOID KUSB_API KHOT_PLUG_CB(
2314  _in KHOT_HANDLE HotHandle,
2315  _in KLST_DEVINFO_HANDLE DeviceInfo,
2316  _in KLST_SYNC_FLAG PlugType);
2317 
2320  _in KHOT_HANDLE HotHandle,
2321  _in KLST_DEVINFO_HANDLE DeviceInfo,
2322  _in UINT PbtEvent);
2323 
2325 
2331 typedef struct _KHOT_PARAMS
2332 {
2334  HWND UserHwnd;
2335 
2337 
2344 
2347 
2350 
2352 
2355  KHOT_PLUG_CB* OnHotPlug;
2356 
2358 
2361  KHOT_POWER_BROADCAST_CB* OnPowerBroadcast;
2362 
2364  UCHAR z_F_i_x_e_d[2048 - sizeof(KLST_PATTERN_MATCH) - sizeof(UINT_PTR) * 3 - sizeof(UINT) * 2];
2365 
2366 } KHOT_PARAMS;
2367 USBK_C_ASSERT(KHOT_PARAMS,sizeof(KHOT_PARAMS) == 2048);
2368 
2371 
2374 #endif
2375 
2376 #ifndef _LIBUSBK_OVLK_TYPES
2377 
2382 
2386 typedef enum _KOVL_WAIT_FLAG
2387 {
2390 
2393 
2396 
2399 
2402 
2405 
2408 
2411 
2412 } KOVL_WAIT_FLAG;
2413 
2415 
2418 typedef enum _KOVL_POOL_FLAG
2419 {
2420  KOVL_POOL_FLAG_NONE = 0L,
2421 } KOVL_POOL_FLAG;
2422 
2425 #endif
2426 
2427 #ifndef _LIBUSBK_STMK_TYPES
2428 
2432 
2436 typedef enum _KSTM_FLAG
2437 {
2440  KSTM_FLAG_NO_PARTIAL_XFERS = 0x00100000,
2441  KSTM_FLAG_USE_TIMEOUT = 0x80000000,
2442  KSTM_FLAG_TIMEOUT_MASK = 0x0001FFFF
2443 } KSTM_FLAG;
2444 
2446 
2449 typedef enum _KSTM_COMPLETE_RESULT
2450 {
2456 
2458 
2464 typedef struct _KSTM_XFER_CONTEXT
2465 {
2466 
2468  PUCHAR Buffer;
2469 
2472 
2475 
2477  PVOID UserState;
2478 
2482 
2484 
2490 typedef struct _KSTM_INFO
2491 {
2494 
2496  UCHAR PipeID;
2497 
2500 
2503 
2506 
2509 
2512 
2515 
2518 
2520  PVOID UserState;
2521 
2522 } KSTM_INFO;
2525 
2527 
2530 typedef INT KUSB_API KSTM_ERROR_CB(_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex, _in INT ErrorCode);
2531 
2533 
2536 typedef INT KUSB_API KSTM_SUBMIT_CB(_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex, _in LPOVERLAPPED Overlapped);
2537 
2539 
2542 typedef INT KUSB_API KSTM_STARTED_CB(_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex);
2543 
2545 
2548 typedef INT KUSB_API KSTM_STOPPED_CB(_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex);
2549 
2551 
2554 typedef INT KUSB_API KSTM_COMPLETE_CB(_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex, _in INT ErrorCode);
2555 
2557 
2573 typedef KSTM_COMPLETE_RESULT KUSB_API KSTM_BEFORE_COMPLETE_CB(_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex, _in PINT ErrorCode);
2574 
2576 
2582 typedef struct _KSTM_CALLBACK
2583 {
2585  KSTM_ERROR_CB* Error;
2586 
2588  KSTM_SUBMIT_CB* Submit;
2589 
2591  KSTM_COMPLETE_CB* Complete;
2592 
2594  KSTM_STARTED_CB* Started;
2595 
2597  KSTM_STOPPED_CB* Stopped;
2598 
2600  KSTM_BEFORE_COMPLETE_CB* BeforeComplete;
2601 
2603  UCHAR z_F_i_x_e_d[64 - sizeof(UINT_PTR) * 6];
2604 
2605 } KSTM_CALLBACK;
2608 USBK_C_ASSERT(KSTM_CALLBACK,sizeof(KSTM_CALLBACK) == 64);
2609 
2612 #endif
2613 // L I B U S B K PUBLIC FUNCTIONS ////////////////////////////////////
2616 
2617 #ifdef __cplusplus
2618 extern "C" {
2619 #endif
2620 
2621 #ifndef _LIBUSBK_LIBK_FUNCTIONS
2622 
2626 
2634  KUSB_EXP VOID KUSB_API LibK_GetVersion(_out PKLIB_VERSION Version);
2635 
2637 
2651  _in KLIB_HANDLE Handle,
2652  _in KLIB_HANDLE_TYPE HandleType);
2653 
2655 
2670  _in KLIB_HANDLE Handle,
2671  _in KLIB_HANDLE_TYPE HandleType,
2672  _in KLIB_USER_CONTEXT ContextValue);
2673 
2675 
2690  _in KLIB_HANDLE Handle,
2691  _in KLIB_HANDLE_TYPE HandleType,
2692  _in KLIB_HANDLE_CLEANUP_CB* CleanupCB);
2693 
2695 
2707  _out PKUSB_DRIVER_API DriverAPI,
2708  _in INT DriverID);
2709 
2711 
2723  _in PKUSB_DRIVER_API DriverAPI,
2724  _in UINT FunctionID);
2725 
2727 
2739  _out PKUSB_DRIVER_API DriverAPI,
2740  _in KUSB_HANDLE UsbHandle);
2741 
2743 
2757  _out KPROC* ProcAddress,
2758  _in INT DriverID,
2759  _in INT FunctionID);
2760 
2762 
2774  _in KLIB_HANDLE_TYPE HandleType,
2775  _in KLIB_USER_CONTEXT ContextValue);
2776 
2778 
2789  _in KLIB_HANDLE_TYPE HandleType);
2790 
2792 
2808  _inopt HANDLE Heap,
2809  _in PVOID Reserved);
2810 
2812 
2819  KUSB_EXP VOID KUSB_API LibK_Context_Free(VOID);
2820 
2821 
2823 #endif
2824 
2825 #ifndef _LIBUSBK_USBK_FUNCTIONS
2826 
2830 
2855  KUSB_EXP BOOL KUSB_API UsbK_Init (
2856  _out KUSB_HANDLE* InterfaceHandle,
2857  _in KLST_DEVINFO_HANDLE DevInfo);
2858 
2860 
2871  KUSB_EXP BOOL KUSB_API UsbK_Free (
2872  _in KUSB_HANDLE InterfaceHandle);
2873 
2875 
2909  _in KUSB_HANDLE InterfaceHandle,
2910  _in UCHAR NumberOrIndex,
2911  _in BOOL IsIndex);
2912 
2914 
2950  _in KUSB_HANDLE InterfaceHandle,
2951  _in UCHAR NumberOrIndex,
2952  _in BOOL IsIndex);
2953 
2955 
2980  _in KUSB_HANDLE InterfaceHandle,
2981  _in UCHAR NumberOrIndex,
2982  _in BOOL IsIndex,
2983  _in UCHAR AltSettingNumber);
2984 
2986 
3011  _in KUSB_HANDLE InterfaceHandle,
3012  _in UCHAR NumberOrIndex,
3013  _in BOOL IsIndex,
3014  _out PUCHAR AltSettingNumber);
3015 
3017 
3050  _in KUSB_HANDLE InterfaceHandle,
3051  _in UCHAR DescriptorType,
3052  _in UCHAR Index,
3053  _in USHORT LanguageID,
3054  _out PUCHAR Buffer,
3055  _in UINT BufferLength,
3056  _outopt PUINT LengthTransferred);
3057 
3059 
3101  _in KUSB_HANDLE InterfaceHandle,
3102  _in WINUSB_SETUP_PACKET SetupPacket,
3103  _refopt PUCHAR Buffer,
3104  _in UINT BufferLength,
3105  _outopt PUINT LengthTransferred,
3106  _inopt LPOVERLAPPED Overlapped);
3107 
3109 
3158  _in KUSB_HANDLE InterfaceHandle,
3159  _in UINT PolicyType,
3160  _in UINT ValueLength,
3161  _in PVOID Value);
3162 
3164 
3200  _in KUSB_HANDLE InterfaceHandle,
3201  _in UINT PolicyType,
3202  _ref PUINT ValueLength,
3203  _out PVOID Value);
3204 
3206 
3227  _in KUSB_HANDLE InterfaceHandle,
3228  _in UCHAR ConfigurationNumber);
3229 
3231 
3243  _in KUSB_HANDLE InterfaceHandle,
3244  _out PUCHAR ConfigurationNumber);
3245 
3247 
3256  _in KUSB_HANDLE InterfaceHandle);
3257 
3259 
3296  _in HANDLE DeviceHandle,
3297  _out KUSB_HANDLE* InterfaceHandle);
3298 
3300 
3321  _in KUSB_HANDLE InterfaceHandle,
3322  _in UCHAR NumberOrIndex,
3323  _in BOOL IsIndex);
3324 
3326 
3351  _in KUSB_HANDLE InterfaceHandle,
3352  _in UCHAR AssociatedInterfaceIndex,
3353  _out KUSB_HANDLE* AssociatedInterfaceHandle);
3354 
3356 
3370  _in KUSB_HANDLE InterfaceHandle,
3371  _out KUSB_HANDLE* DstInterfaceHandle);
3372 
3374 
3398  _in KUSB_HANDLE InterfaceHandle,
3399  _in UCHAR AltSettingIndex,
3400  _out PUSB_INTERFACE_DESCRIPTOR UsbAltInterfaceDescriptor);
3401 
3403 
3424  _in KUSB_HANDLE InterfaceHandle,
3425  _in UINT InformationType,
3426  _ref PUINT BufferLength,
3427  _ref PUCHAR Buffer);
3428 
3430 
3448  _in KUSB_HANDLE InterfaceHandle,
3449  _in UCHAR AltSettingNumber);
3450 
3452 
3469  _in KUSB_HANDLE InterfaceHandle,
3470  _out PUCHAR AltSettingNumber);
3471 
3473 
3505  _in KUSB_HANDLE InterfaceHandle,
3506  _in UCHAR AltSettingNumber,
3507  _in UCHAR PipeIndex,
3508  _out PWINUSB_PIPE_INFORMATION PipeInformation);
3509 
3511 
3543  _in KUSB_HANDLE InterfaceHandle,
3544  _in UCHAR AltSettingNumber,
3545  _in UCHAR PipeIndex,
3546  _out PWINUSB_PIPE_INFORMATION_EX PipeInformationEx);
3547 
3549 
3573  _in KUSB_HANDLE InterfaceHandle,
3574  _in UCHAR AltSettingNumber,
3575  _in UCHAR PipeIndex,
3576  _out PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR PipeCompanionDescriptor);
3577 
3579 
3680  _in KUSB_HANDLE InterfaceHandle,
3681  _in UCHAR PipeID,
3682  _in UINT PolicyType,
3683  _in UINT ValueLength,
3684  _in PVOID Value);
3685 
3687 
3711  _in KUSB_HANDLE InterfaceHandle,
3712  _in UCHAR PipeID,
3713  _in UINT PolicyType,
3714  _ref PUINT ValueLength,
3715  _out PVOID Value);
3716 
3718 
3748  _in KUSB_HANDLE InterfaceHandle,
3749  _in UCHAR PipeID,
3750  _out PUCHAR Buffer,
3751  _in UINT BufferLength,
3752  _outopt PUINT LengthTransferred,
3753  _inopt LPOVERLAPPED Overlapped);
3754 
3756 
3786  _in KUSB_HANDLE InterfaceHandle,
3787  _in UCHAR PipeID,
3788  _in PUCHAR Buffer,
3789  _in UINT BufferLength,
3790  _outopt PUINT LengthTransferred,
3791  _inopt LPOVERLAPPED Overlapped);
3792 
3794 
3807  _in KUSB_HANDLE InterfaceHandle,
3808  _in UCHAR PipeID);
3809 
3811 
3824  _in KUSB_HANDLE InterfaceHandle,
3825  _in UCHAR PipeID);
3826 
3828 
3841  _in KUSB_HANDLE InterfaceHandle,
3842  _in UCHAR PipeID);
3843 
3845 
3880  _in KUSB_HANDLE InterfaceHandle,
3881  _in UCHAR PipeID,
3882  _out PUCHAR Buffer,
3883  _in UINT BufferLength,
3884  _in LPOVERLAPPED Overlapped,
3885  _refopt PKISO_CONTEXT IsoContext);
3886 
3888 
3917  _in KUSB_HANDLE InterfaceHandle,
3918  _in UCHAR PipeID,
3919  _in PUCHAR Buffer,
3920  _in UINT BufferLength,
3921  _in LPOVERLAPPED Overlapped,
3922  _refopt PKISO_CONTEXT IsoContext);
3923 
3925 
3938  _in KUSB_HANDLE InterfaceHandle,
3939  _out PUINT FrameNumber);
3940 
3942 
3984  _in KISOCH_HANDLE IsochHandle,
3985  _inopt UINT DataLength,
3986  _refopt PUINT FrameNumber,
3987  _inopt UINT NumberOfPackets,
3988  _in LPOVERLAPPED Overlapped);
3989 
3991 
4034  _in KISOCH_HANDLE IsochHandle,
4035  _inopt UINT DataLength,
4036  _ref PUINT FrameNumber,
4037  _inopt UINT NumberOfPackets,
4038  _in LPOVERLAPPED Overlapped);
4039 
4041 
4094  _in KUSB_HANDLE InterfaceHandle,
4095  _in LPOVERLAPPED Overlapped,
4096  _out PUINT lpNumberOfBytesTransferred,
4097  _in BOOL bWait);
4098 
4100 
4118  _in KUSB_HANDLE InterfaceHandle,
4119  _in KUSB_PROPERTY PropertyType,
4120  _ref PUINT PropertySize,
4121  _out PVOID Value);
4122 
4126 #endif
4127 
4128 #ifndef _LIBUSBK_LSTK_FUNCTIONS
4129 
4133 
4151  _out KLST_HANDLE* DeviceList,
4152  _in KLST_FLAG Flags);
4153 
4155 
4179  _out KLST_HANDLE* DeviceList,
4180  _in KLST_FLAG Flags,
4181  _in PKLST_PATTERN_MATCH PatternMatch);
4182 
4184 
4198  _in KLST_HANDLE DeviceList);
4199 
4201 
4218  _in KLST_HANDLE DeviceList,
4219  _in KLST_ENUM_DEVINFO_CB* EnumDevListCB,
4220  _inopt PVOID Context);
4221 
4223 
4245  _in KLST_HANDLE DeviceList,
4246  _out KLST_DEVINFO_HANDLE* DeviceInfo);
4247 
4249 
4269  _in KLST_HANDLE DeviceList,
4270  _outopt KLST_DEVINFO_HANDLE* DeviceInfo);
4271 
4273 
4281  _in KLST_HANDLE DeviceList);
4282 
4284 
4309  _in KLST_HANDLE DeviceList,
4310  _in INT Vid,
4311  _in INT Pid,
4312  _out KLST_DEVINFO_HANDLE* DeviceInfo);
4313 
4315 
4327  _in KLST_HANDLE DeviceList,
4328  _ref PUINT Count);
4329 
4330 
4333 #endif
4334 
4335 #ifndef _LIBUSBK_HOTK_FUNCTIONS
4336 
4340 
4353  _out KHOT_HANDLE* Handle,
4354  _ref PKHOT_PARAMS InitParams);
4355 
4357 
4366  _in KHOT_HANDLE Handle);
4367 
4369 
4372  KUSB_EXP VOID KUSB_API HotK_FreeAll(VOID);
4373 
4376 #endif
4377 
4378 #ifndef _LIBUSBK_OVLK_FUNCTIONS
4379 
4383 
4404  _out KOVL_HANDLE* OverlappedK,
4405  _in KOVL_POOL_HANDLE PoolHandle);
4406 
4408 
4423  _in KOVL_HANDLE OverlappedK);
4424 
4425 
4427 
4444  KUSB_EXP BOOL KUSB_API OvlK_Init (
4445  _out KOVL_POOL_HANDLE* PoolHandle,
4446  _in KUSB_HANDLE UsbHandle,
4447  _in INT MaxOverlappedCount,
4448  _inopt KOVL_POOL_FLAG Flags);
4449 
4451 
4464  _in KOVL_POOL_HANDLE PoolHandle);
4465 
4466 
4468 
4485  _in KOVL_HANDLE OverlappedK);
4486 
4488 
4528  _in KOVL_HANDLE OverlappedK,
4529  _inopt INT TimeoutMS,
4530  _inopt KOVL_WAIT_FLAG WaitFlags,
4531  _out PUINT TransferredLength);
4532 
4534 
4555  _in KOVL_POOL_HANDLE PoolHandle,
4556  _outopt KOVL_HANDLE* OverlappedK,
4557  _inopt INT TimeoutMS,
4558  _inopt KOVL_WAIT_FLAG WaitFlags,
4559  _out PUINT TransferredLength);
4560 
4562 
4584  _in KOVL_HANDLE OverlappedK,
4585  _inopt INT TimeoutMS,
4586  _out PUINT TransferredLength);
4587 
4589 
4611  _in KOVL_HANDLE OverlappedK,
4612  _inopt INT TimeoutMS,
4613  _out PUINT TransferredLength);
4614 
4616 
4629  _in KOVL_HANDLE OverlappedK);
4630 
4632 
4651  _in KOVL_HANDLE OverlappedK);
4652 
4655 #endif
4656 
4657 #ifndef _LIBUSBK_STMK_FUNCTIONS
4658 
4663 
4703  _out KSTM_HANDLE* StreamHandle,
4704  _in KUSB_HANDLE UsbHandle,
4705  _in UCHAR PipeID,
4706  _in INT MaxTransferSize,
4707  _in INT MaxPendingTransfers,
4708  _in INT MaxPendingIO,
4709  _inopt PKSTM_CALLBACK Callbacks,
4710  _inopt KSTM_FLAG Flags);
4711 
4713 
4724  _in KSTM_HANDLE StreamHandle);
4725 
4727 
4741  _in KSTM_HANDLE StreamHandle);
4742 
4744 
4757  _in KSTM_HANDLE StreamHandle,
4758  _in INT TimeoutCancelMS);
4759 
4761 
4795  _in KSTM_HANDLE StreamHandle,
4796  _out PUCHAR Buffer,
4797  _in INT Offset,
4798  _in INT Length,
4799  _out PUINT TransferredLength);
4800 
4802 
4833  _in KSTM_HANDLE StreamHandle,
4834  _in PUCHAR Buffer,
4835  _in INT Offset,
4836  _in INT Length,
4837  _out PUINT TransferredLength);
4840 #endif
4841 
4842 #ifndef _LIBUSBK_ISOK_FUNCTIONS
4843 
4847 
4872  _out PKISO_CONTEXT* IsoContext,
4873  _in INT NumberOfPackets,
4874  _inopt INT StartFrame);
4875 
4876 
4878 
4885  _in PKISO_CONTEXT IsoContext);
4886 
4888 
4911  _in PKISO_CONTEXT IsoContext,
4912  _in INT PacketSize);
4913 
4915 
4929  _in PKISO_CONTEXT IsoContext,
4930  _in INT PacketIndex,
4931  _in PKISO_PACKET IsoPacket);
4932 
4934 
4948  _in PKISO_CONTEXT IsoContext,
4949  _in INT PacketIndex,
4950  _out PKISO_PACKET IsoPacket);
4951 
4953 
4970  _in PKISO_CONTEXT IsoContext,
4971  _in KISO_ENUM_PACKETS_CB* EnumPackets,
4972  _inopt INT StartPacketIndex,
4973  _inopt PVOID UserState);
4974 
4976 
4988  _ref PKISO_CONTEXT IsoContext);
4989 
4991 #endif
4992 
4993 #ifndef _LIBUSBK_ISOCHK_FUNCTIONS
4994 
4998 
5030  _out KISOCH_HANDLE* IsochHandle,
5031  _in KUSB_HANDLE InterfaceHandle,
5032  _in UCHAR PipeId,
5033  _in UINT MaxNumberOfPackets,
5034  _in PUCHAR TransferBuffer,
5035  _in UINT TransferBufferSize);
5036 
5038 
5045  _in KISOCH_HANDLE IsochHandle);
5046 
5048 
5063  _in KISOCH_HANDLE IsochHandle,
5064  _in UINT PacketSize);
5065 
5066 
5068 
5092  _in KISOCH_HANDLE IsochHandle,
5093  _in UINT PacketIndex,
5094  _in UINT Offset,
5095  _in UINT Length,
5096  _in UINT Status);
5097 
5099 
5123  _in KISOCH_HANDLE IsochHandle,
5124  _in UINT PacketIndex,
5125  _outopt PUINT Offset,
5126  _outopt PUINT Length,
5127  _outopt PUINT Status);
5128 
5130 
5147  _in KISOCH_HANDLE IsochHandle,
5148  _in KISOCH_ENUM_PACKETS_CB* EnumPackets,
5149  _inopt UINT StartPacketIndex,
5150  _inopt PVOID UserState);
5151 
5152 
5154 
5167  _in BOOL IsHighSpeed,
5168  _in PWINUSB_PIPE_INFORMATION_EX PipeInformationEx,
5169  _out PKISOCH_PACKET_INFORMATION PacketInformation);
5170 
5172 
5182  _in KISOCH_HANDLE IsochHandle,
5183  _out PUINT NumberOfPackets);
5184 
5186 
5196  _in KISOCH_HANDLE IsochHandle,
5197  _in UINT NumberOfPackets);
5198 
5200 #endif
5201 
5203 
5246  _in KUSB_HANDLE InterfaceHandle,
5247  _in WINUSB_SETUP_PACKET SetupPacket,
5248  _refopt PUCHAR Buffer,
5249  _in UINT BufferLength,
5250  _outopt PUINT LengthTransferred,
5251  _inopt LPOVERLAPPED Overlapped);
5253 
5274  _in KUSB_HANDLE InterfaceHandle,
5275  _in UCHAR ConfigurationNumber);
5276 
5277 #ifdef __cplusplus
5278 }
5279 #endif
5280 
5281 #if _MSC_VER >= 1200
5282 #pragma warning(pop)
5283 #endif
5284 
5285 #endif // _LIBUSBK_H__
KUSB_EXP BOOL KUSB_API UsbK_GetDescriptor(_in KUSB_HANDLE InterfaceHandle, _in UCHAR DescriptorType, _in UCHAR Index, _in USHORT LanguageID, _out PUCHAR Buffer, _in UINT BufferLength, _outopt PUINT LengthTransferred)
Gets the requested descriptor. This is a synchronous operation.
UCHAR bInterfaceClass
USB-IF class code for this interface.
Definition: libusbk.h:1544
KLST_DEV_COMMON_INFO Common
Common usb device information.
Definition: libusbk.h:287
BMREQUEST_DIR
bmRequest.Dir
Definition: libusbk.h:428
KUSB_EXP BOOL KUSB_API IsochK_SetPacketOffsets(_in KISOCH_HANDLE IsochHandle, _in UINT PacketSize)
Convenience function for setting the offsets and lengths of all ISO packets of an isochronous transfe...
INT KUSB_API KSTM_COMPLETE_CB(_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex, _in INT ErrorCode)
Function definition for an optional user-defined callback; executed when a valid transfer completes...
Summarizes configuration information for a function implemented by the device.
Definition: libusbk.h:867
INT KUSB_API KSTM_SUBMIT_CB(_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex, _in LPOVERLAPPED Overlapped)
Function definition for an optional user-defined callback; executed to submit a transfer.
UsbK_GetProperty dynamic driver function id.
Definition: libusbk.h:1790
Microsoft OS 2.0 model ID descriptor.
Definition: libusbk.h:1231
KUSB_EXP BOOL KUSB_API UsbK_IsochReadPipe(_in KISOCH_HANDLE IsochHandle, _inopt UINT DataLength, _refopt PUINT FrameNumber, _inopt UINT NumberOfPackets, _in LPOVERLAPPED Overlapped)
Reads from an isochronous pipe. Supports LibusbK or WinUsb.
UCHAR bFirstInterface
First interface number of the set of interfaces that follow this descriptor.
Definition: libusbk.h:1621
Set or enable a specific feature.
Definition: libusbk.h:585
INT KUSB_API KSTM_STARTED_CB(_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex)
Function definition for an optional user-defined callback; executed for each transfer context when th...
KUSB_EXP BOOL KUSB_API LibK_Context_Init(_inopt HANDLE Heap, _in PVOID Reserved)
Initializes the global libusbK process context.
UCHAR bDevCapabilityType
Capability type. See BOS_CAPABILITY_TYPE.
Definition: libusbk.h:922
If the i/o operation fails or completes successfully, release the OverlappedK back to its pool...
Definition: libusbk.h:2398
UCHAR bReserved
Reserved.
Definition: libusbk.h:1301
Defines the set of Wireless USB 1.1-specific device level capabilities.
Definition: libusbk.h:855
Shared USB handle. KUSB_HANDLE.
Definition: libusbk.h:159
UsbK_AbortPipe dynamic driver function id.
Definition: libusbk.h:1772
UCHAR bAlternateSetting
Value used to select this alternate setting for this interface.
Definition: libusbk.h:1538
KUSB_EXP BOOL KUSB_API UsbK_ReadPipe(_in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID, _out PUCHAR Buffer, _in UINT BufferLength, _outopt PUINT LengthTransferred, _inopt LPOVERLAPPED Overlapped)
Reads data from the specified pipe.
INT DriverID
Driver id this device element is using.
Definition: libusbk.h:290
UsbK_Initialize dynamic driver function id.
Definition: libusbk.h:1730
Invalid.
Definition: libusbk.h:2454
KUSB_EXP BOOL KUSB_API StmK_Stop(_in KSTM_HANDLE StreamHandle, _in INT TimeoutCancelMS)
Stops the internal stream thread.
KSTM_COMPLETE_RESULT KUSB_API KSTM_BEFORE_COMPLETE_CB(_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex, _ref PINT ErrorCode)
Function definition for an optional user-defined callback; executed immediately after a transfer comp...
Standard request. See USB_REQUEST_ENUM.
Definition: libusbk.h:438
USHORT wLength
The length, in bytes, of this subset header. Shall be set to 8.
Definition: libusbk.h:1292
Container ID type.
Definition: libusbk.h:831
KUSB_EXP BOOL KUSB_API IsochK_SetPacket(_in KISOCH_HANDLE IsochHandle, _in UINT PacketIndex, _in UINT Offset, _in UINT Length, _in UINT Status)
Convenience function for setting all fields in an isochronous transfer packet.
Get the specified descriptor.
Definition: libusbk.h:591
KUSB_EXP BOOL KUSB_API HotK_Init(_out KHOT_HANDLE *Handle, _ref PKHOT_PARAMS InitParams)
Creates a new hot-plug handle for USB device arrival/removal event monitoring.
UCHAR bDescriptorType
Descriptor type.
Definition: libusbk.h:948
BOOL KUSB_API KLST_ENUM_DEVINFO_CB(_in KLST_HANDLE DeviceList, _in KLST_DEVINFO_HANDLE DeviceInfo, _in PVOID Context)
Device list enumeration function callback typedef.
Definition: libusbk.h:406
UCHAR bLength
Size of this descriptor (in bytes)
Definition: libusbk.h:1615
UCHAR bDescriptorType
Descriptor type.
Definition: libusbk.h:968
KUSB_EXP BOOL KUSB_API IsoK_SetPacket(_in PKISO_CONTEXT IsoContext, _in INT PacketIndex, _in PKISO_PACKET IsoPacket)
Convenience function for setting all fields of a KISO_PACKET.
USHORT bcdDevice
Device release number in binary-coded decimal.
Definition: libusbk.h:685
UsbK_QueryPipeEx dynamic driver function id.
Definition: libusbk.h:1799
Always release the OverlappedK back to its pool. If the operation timed-out, cancel it before releasi...
Definition: libusbk.h:2407
KSTM_XFER_CONTEXT * PKSTM_XFER_CONTEXT
Pointer to a KSTM_XFER_CONTEXT structure.
Definition: libusbk.h:2481
KLIB_HANDLE KLST_HANDLE
Opaque LstK handle, see LstK_Init.
Definition: libusbk.h:131
KUSB_EXP BOOL KUSB_API UsbK_SetCurrentAlternateSetting(_in KUSB_HANDLE InterfaceHandle, _in UCHAR AltSettingNumber)
Sets the alternate setting of an interface.
BOS device capability descriptor.
Definition: libusbk.h:803
Configuration descriptor type.
Definition: libusbk.h:483
UCHAR bmAttributes
Configuration characteristics.
Definition: libusbk.h:1510
KUSB_EXP KLIB_USER_CONTEXT KUSB_API LibK_GetContext(_in KLIB_HANDLE Handle, _in KLIB_HANDLE_TYPE HandleType)
Gets the internal user context for the specified KLIB_HANDLE.
Interface power descriptor type.
Definition: libusbk.h:501
KUSB_DRIVER_API_INFO Info
Driver API information.
Definition: libusbk.h:2048
USHORT idProduct
USB-IF product ID.
Definition: libusbk.h:682
USHORT wLength
The length, in bytes, of this descriptor. Shall be set to 4.
Definition: libusbk.h:1441
The provider characteristics of a port on the device.
Definition: libusbk.h:846
UCHAR bDevCapabilityType
Capability type. See BOS_CAPABILITY_TYPE.
Definition: libusbk.h:951
Microsoft OS 2.0 minimum USB resume time descriptor.
Definition: libusbk.h:1397
KOVL_POOL_FLAG
Overlapped pool config flags.
Definition: libusbk.h:2418
Microsoft OS 2.0 function subset header.
Definition: libusbk.h:1219
UsbK_IsochWritePipe dynamic driver function id.
Definition: libusbk.h:1796
A function section defines the compatible ID and a subcompatible ID for a specified interface or func...
Definition: libusbk.h:1087
KUSB_EXP BOOL KUSB_API OvlK_ReUse(_in KOVL_HANDLE OverlappedK)
Initializes an overlappedK for re-use. The overlappedK is not return to its pool. ...
KUSB_EXP BOOL KUSB_API OvlK_Init(_out KOVL_POOL_HANDLE *PoolHandle, _in KUSB_HANDLE UsbHandle, _in INT MaxOverlappedCount, _inopt KOVL_POOL_FLAG Flags)
Creates a new overlapped pool.
Device is self powered.
Definition: libusbk.h:470
The consumer characteristics of a port on the device.
Definition: libusbk.h:843
UsbK_GetSuperSpeedPipeCompanionDescriptor dynamic driver function id.
Definition: libusbk.h:1802
Added (Arrival) state,.
Definition: libusbk.h:247
All MS OS V2.0 descriptors start with these two fields.
Definition: libusbk.h:1241
Hot plug handle. KHOT_HANDLE.
Definition: libusbk.h:153
Get the current device configuration value.
Definition: libusbk.h:597
A structure representing the standard USB endpoint descriptor.
Definition: libusbk.h:708
UCHAR bmAttributes
Attributes which apply to the endpoint when it is configured using the bConfigurationValue.
Definition: libusbk.h:731
The WINUSB_SETUP_PACKET structure describes a USB setup packet.
Definition: lusbk_shared.h:129
KLST_DEVINFO * KLST_DEVINFO_HANDLE
Pointer to a KLST_DEVINFO structure. (semi-opaque)
Definition: libusbk.h:347
vendor-specific class
Definition: libusbk.h:644
KUSB_EXP BOOL KUSB_API LUsb0_SetConfiguration(_in KUSB_HANDLE InterfaceHandle, _in UCHAR ConfigurationNumber)
Sets the device configuration number.
UCHAR bAltEnumCode
Alternate enumeration indicator.
Definition: libusbk.h:1012
Update existing descriptors or add new descriptors.
Definition: libusbk.h:594
USHORT wLength
The length, in bytes, of this subset header. Shall be set to 8.
Definition: libusbk.h:1272
KUSB_EXP BOOL KUSB_API OvlK_Release(_in KOVL_HANDLE OverlappedK)
Returns an OverlappedK structure to it's pool.
KUSB_EXP BOOL KUSB_API UsbK_ResetPipe(_in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID)
Resets the data toggle and clears the stall condition on a pipe.
KUSB_EXP BOOL KUSB_API IsoK_ReUse(_ref PKISO_CONTEXT IsoContext)
Convenience function for re-using an isochronous transfer context in a subsequent request...
USHORT wDescriptorType
MSOSV2_DESCRIPTOR_TYPE_SUBSET_HEADER_CONFIGURATION
Definition: libusbk.h:1275
KUSB_EXP BOOL KUSB_API UsbK_GetProperty(_in KUSB_HANDLE InterfaceHandle, _in KUSB_PROPERTY PropertyType, _ref PUINT PropertySize, _out PVOID Value)
Gets a USB device (driver specific) property from usb handle.
UsbK_QueryInterfaceSettings dynamic driver function id.
Definition: libusbk.h:1742
libusb0.sys driver ID
Definition: libusbk.h:1674
KUSB_EXP BOOL KUSB_API LibK_SetContext(_in KLIB_HANDLE Handle, _in KLIB_HANDLE_TYPE HandleType, _in KLIB_USER_CONTEXT ContextValue)
Sets internal user context for the specified KLIB_HANDLE.
If a UserHwnd is specified, use PostMessage instead of SendMessage.
Definition: libusbk.h:2309
USB core driver API information structure.
Definition: libusbk.h:2028
Interface association descriptor type.
Definition: libusbk.h:504
The WINUSB_PIPE_INFORMATION structure contains pipe information that the UsbK_QueryPipe routine retri...
Definition: lusbk_shared.h:72
UCHAR bLength
Size of this descriptor (in bytes)
Definition: libusbk.h:1583
No flags (or 0)
Definition: libusbk.h:2300
USHORT wTotalLength
Total length of data returned for this configuration.
Definition: libusbk.h:1498
Device capabilities descriptor type.
Definition: libusbk.h:510
If the i/o operation times-out, cancel it and release the OverlappedK back to its pool...
Definition: libusbk.h:2404
UsbK_GetAltInterface dynamic driver function id.
Definition: libusbk.h:1706
UCHAR bFunctionProtocol
bInterfaceProtocol used for the associated interfaces
Definition: libusbk.h:1633
KLST_PATTERN_MATCH PatternMatch
File pattern matches for restricting notifcations to a single/group or all supported usb devices...
Definition: libusbk.h:2349
UCHAR bDescriptorType
Descriptor type.
Definition: libusbk.h:1618
KUSB_EXP BOOL KUSB_API IsoK_SetPackets(_in PKISO_CONTEXT IsoContext, _in INT PacketSize)
Convenience function for setting the offset of all ISO packets of an isochronous transfer context...
The MS OS 2.0 descriptor set header.
Definition: libusbk.h:1213
USHORT wSpeedSupported
Bitmap encoding of the supported speeds.
Definition: libusbk.h:928
UCHAR bmAttributes
Bitmap encoding of supported device level features.
Definition: libusbk.h:925
USHORT Index
wIndex
Definition: libusbk.h:82
Device qualifier descriptor type.
Definition: libusbk.h:495
KUSB_EXP BOOL KUSB_API StmK_Free(_in KSTM_HANDLE StreamHandle)
Frees resources allocated by a stream handle.
UCHAR iManufacturer
Index of string descriptor describing manufacturer.
Definition: libusbk.h:688
Helper structure for parsing a /ref MSOSV1_CUSTOM_PROP_DESCRIPTOR or a MSOSV2_FEATURE_REG_PROPERTY_DE...
Definition: libusbk.h:1195
KUSB_EXP BOOL KUSB_API IsochK_GetNumberOfPackets(_in KISOCH_HANDLE IsochHandle, _out PUINT NumberOfPackets)
Gets the number of iso packets that will be used.
libusb0.sys filter driver ID
Definition: libusbk.h:1680
A structure representing the common USB descriptor.
Definition: libusbk.h:1580
KUSB_HANDLE UsbHandle
KUSB_HANDLE this stream uses.
Definition: libusbk.h:2493
UCHAR bLength
Size of this descriptor (in bytes)
Definition: libusbk.h:1529
PVOID UserState
Stream info user defined state.
Definition: libusbk.h:2520
If the i/o operation times-out cancel it, but do not release the OverlappedK back to its pool...
Definition: libusbk.h:2401
Audio class.
Definition: libusbk.h:623
KUSB_EXP BOOL KUSB_API LibK_SetCleanupCallback(_in KLIB_HANDLE Handle, _in KLIB_HANDLE_TYPE HandleType, _in KLIB_HANDLE_CLEANUP_CB *CleanupCB)
Assigns a cleanup callback function to a KLIB_HANDLE.
USB handle. KUSB_HANDLE.
Definition: libusbk.h:156
Device list/hot-plug pattern match structure.
Definition: libusbk.h:371
Microsoft OS 2.0 vendor revision descriptor.
Definition: libusbk.h:1460
Max handle type count.
Definition: libusbk.h:180
KUSB_EXP BOOL KUSB_API LstK_Free(_in KLST_HANDLE DeviceList)
Frees a usb device list.
KUSB_EXP BOOL KUSB_API HotK_Free(_in KHOT_HANDLE Handle)
Frees the specified hot-plug handle.
UCHAR bInterfaceProtocol
USB-IF protocol code for this interface.
Definition: libusbk.h:1550
UCHAR bLength
Size of this descriptor (in bytes)
Definition: libusbk.h:965
KUSB_EXP BOOL KUSB_API IsochK_SetNumberOfPackets(_in KISOCH_HANDLE IsochHandle, _in UINT NumberOfPackets)
Sets the number of iso packets that will be used.
Hub class.
Definition: libusbk.h:641
KLST_FLAG
Device list initialization flags.
Definition: libusbk.h:350
UCHAR bLength
Size of this descriptor (in bytes)
Definition: libusbk.h:916
UCHAR bResumeSignalingTime
The number of milliseconds the device requires resume signaling to be asserted. (Valid values 1 to 20...
Definition: libusbk.h:1409
UsbK_GetDescriptor dynamic driver function id.
Definition: libusbk.h:1709
Connect changed state.
Definition: libusbk.h:253
UCHAR iInterface
Index of string descriptor describing this interface.
Definition: libusbk.h:1553
USB 2.0 Extension descriptor.
Definition: libusbk.h:896
UINT UserMessage
WM_USER message start offset used when sending/posting messages, See details.
Definition: libusbk.h:2343
VOID KUSB_API KHOT_PLUG_CB(_in KHOT_HANDLE HotHandle, _in KLST_DEVINFO_HANDLE DeviceInfo, _in KLST_SYNC_FLAG PlugType)
Hot plug event function definition.
Definition: libusbk.h:2313
Vendor-specific request.
Definition: libusbk.h:444
UCHAR bLength
Size of this descriptor (in bytes)
Definition: libusbk.h:655
UCHAR bMS_VendorCode
Vendor specific vendor code.
Definition: libusbk.h:1034
Microsoft OS 2.0 minimum USB resume time descriptor.
Definition: libusbk.h:1228
KUSB_EXP BOOL KUSB_API IsochK_EnumPackets(_in KISOCH_HANDLE IsochHandle, _in KISOCH_ENUM_PACKETS_CB *EnumPackets, _inopt UINT StartPacketIndex, _inopt PVOID UserState)
Convenience function for enumerating ISO packets of an isochronous transfer context.
UCHAR bMS_VendorCode
Vendor defined code.
Definition: libusbk.h:1005
KLST_PATTERN_MATCH * PKLST_PATTERN_MATCH
Pointer to a KLST_PATTERN_MATCH structure.
Definition: libusbk.h:389
UINT bmAttributes
Bitmap encoding of supported device level features.
Definition: libusbk.h:908
KLIB_HANDLE KHOT_HANDLE
Opaque HotK handle, see HotK_Init.
Definition: libusbk.h:134
KUSB_EXP BOOL KUSB_API UsbK_Initialize(_in HANDLE DeviceHandle, _out KUSB_HANDLE *InterfaceHandle)
Creates a libusbK handle for the device specified by a file handle.
UCHAR iSerialNumber
Index of string descriptor containing device serial number.
Definition: libusbk.h:694
Return the selected alternate setting for the specified interface.
Definition: libusbk.h:603
Hot plug parameter structure.
Definition: libusbk.h:2331
UsbK_SetConfiguration dynamic driver function id.
Definition: libusbk.h:1721
USHORT wLength
The length, in bytes, of this descriptor. Shall be set to 6.
Definition: libusbk.h:1463
KLST_SYNC_FLAG SyncFlags
Synchronization flags. (internal use only)
Definition: libusbk.h:336
KUSB_EXP BOOL KUSB_API LibK_LoadDriverAPI(_out PKUSB_DRIVER_API DriverAPI, _in INT DriverID)
Initialize a driver API set.
Interface descriptor type.
Definition: libusbk.h:489
Wireless USB device capability.
Definition: libusbk.h:822
USB_INTERFACE_ASSOCIATION_DESCRIPTOR * PUSB_INTERFACE_ASSOCIATION_DESCRIPTOR
pointer to a USB_INTERFACE_ASSOCIATION_DESCRIPTOR
Definition: libusbk.h:1640
Valid.
Definition: libusbk.h:2452
USB_CONFIG_BM_ATTRIBUTE_ENUM
Values used in the bmAttributes field of a USB_CONFIGURATION_DESCRIPTOR.
Definition: libusbk.h:539
UsbK_FlushPipe dynamic driver function id.
Definition: libusbk.h:1775
INT Micro
Micro version number.
Definition: libusbk.h:196
KUSB_EXP BOOL KUSB_API UsbK_GetSuperSpeedPipeCompanionDescriptor(_in KUSB_HANDLE InterfaceHandle, _in UCHAR AltSettingNumber, _in UCHAR PipeIndex, _out PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR PipeCompanionDescriptor)
Retrieves a pipes super speed endpoint companion descriptor associated with an interface.
Notify all devices which match upon a succuessful call to HotK_Init.
Definition: libusbk.h:2303
Pipe stream handle. KSTM_HANDLE.
Definition: libusbk.h:177
Microsoft OS 2.0 model ID descriptor.
Definition: libusbk.h:1418
KUSB_EXP BOOL KUSB_API UsbK_GetAltInterface(_in KUSB_HANDLE InterfaceHandle, _in UCHAR NumberOrIndex, _in BOOL IsIndex, _out PUCHAR AltSettingNumber)
Gets the alternate setting for the specified interface.
Mass storage class.
Definition: libusbk.h:638
A structure representing additional information about super speed (or higher) endpoints.
Definition: libusbk.h:756
Request is for a vendor-specific purpose.
Definition: libusbk.h:460
Pipe stream handle. KSTM_HANDLE.
Definition: libusbk.h:174
KUSB_EXP BOOL KUSB_API UsbK_QueryDeviceInformation(_in KUSB_HANDLE InterfaceHandle, _in UINT InformationType, _ref PUINT BufferLength, _ref PUCHAR Buffer)
Retrieves information about the physical device that is associated with a libusbK handle...
KHOT_FLAG Flags
Additional init/config parameters.
Definition: libusbk.h:2346
KUSB_EXP VOID KUSB_API LibK_GetVersion(_out PKLIB_VERSION Version)
Gets the internal user context for the specified KLIB_HANDLE.
KUSB_EXP BOOL KUSB_API UsbK_GetCurrentFrameNumber(_in KUSB_HANDLE InterfaceHandle, _out PUINT FrameNumber)
Retrieves the current USB frame number.
libusbK.sys driver ID
Definition: libusbk.h:1671
UsbK_QueryPipe dynamic driver function id.
Definition: libusbk.h:1754
UsbK_Free dynamic driver function id.
Definition: libusbk.h:1694
Printer class.
Definition: libusbk.h:635
A structure representing the standard USB interface descriptor.
Definition: libusbk.h:1526
Uses alterable wait functions. See http://msdn.microsoft.com/en-us/library/windows/desktop/ms687036%2...
Definition: libusbk.h:2410
UCHAR bNumInterfaces
Number of interfaces supported by this configuration.
Definition: libusbk.h:1501
UCHAR bConfigurationValue
Identifier value for this configuration.
Definition: libusbk.h:1504
SuperSpeed Device Capability Descriptor.
Definition: libusbk.h:913
UsbK_ClaimInterface dynamic driver function id.
Definition: libusbk.h:1697
UsbK_SetCurrentAlternateSetting dynamic driver function id.
Definition: libusbk.h:1748
UCHAR bNumDeviceCaps
Number of device capability descriptors.
Definition: libusbk.h:889
BOS_CAPABILITY_TYPE
USB BOS capability types.
Definition: libusbk.h:819
UsbK_ResetDevice dynamic driver function id.
Definition: libusbk.h:1727
Get the internal device file handle used for operations such as GetOverlappedResult or DeviceIoContro...
Definition: libusbk.h:1661
KUSB_EXP BOOL KUSB_API OvlK_WaitOrCancel(_in KOVL_HANDLE OverlappedK, _inopt INT TimeoutMS, _out PUINT TransferredLength)
Waits for overlapped I/O completion, cancels on a timeout error.
USB_DEVICE_CLASS_ENUM
USB defined class codes.
Definition: libusbk.h:617
UINT dwSize
The size of this custom properties section.
Definition: libusbk.h:1173
USHORT wLength
The length, in bytes, of this descriptor.
Definition: libusbk.h:1359
UCHAR bLength
Size of this descriptor. Shall always be 18 bytes.
Definition: libusbk.h:1025
KUSB_EXP BOOL KUSB_API UsbK_QueryPipe(_in KUSB_HANDLE InterfaceHandle, _in UCHAR AltSettingNumber, _in UCHAR PipeIndex, _out PWINUSB_PIPE_INFORMATION PipeInformation)
Retrieves information about a pipe that is associated with an interface.
Stream callback structure.
Definition: libusbk.h:2582
KUSB_EXP BOOL KUSB_API LibK_SetDefaultContext(_in KLIB_HANDLE_TYPE HandleType, _in KLIB_USER_CONTEXT ContextValue)
Sets the default user context for the specified KLIB_HANDLE_TYPE.
The WINUSB_PIPE_INFORMATION_EX structure contains pipe information that the UsbK_QueryPipeEx routine ...
Definition: lusbk_shared.h:92
KUSB_EXP BOOL KUSB_API LibK_CopyDriverAPI(_out PKUSB_DRIVER_API DriverAPI, _in KUSB_HANDLE UsbHandle)
Copies the driver API set out of a KUSB_HANDLE.
Microsoft OS V1.0 extended properties descriptor.
Definition: libusbk.h:1051
KSTM_BEFORE_COMPLETE_CB * BeforeComplete
Executed immediately after a transfer completes.
Definition: libusbk.h:2600
UsbK_Init dynamic driver function id.
Definition: libusbk.h:1691
UCHAR bInterfaceCount
The Number of interfaces follow this descriptor that are considered "associated". ...
Definition: libusbk.h:1624
Structure describing an isochronous transfer packet for libusbK.
Definition: lusbk_shared.h:162
A structure representing the standard USB configuration descriptor.
Definition: libusbk.h:1489
UCHAR MaxPower
Maximum power consumption of the USB device from this bus in this configuration when the device is fu...
Definition: libusbk.h:1516
KUSB_EXP BOOL KUSB_API IsoK_EnumPackets(_in PKISO_CONTEXT IsoContext, _in KISO_ENUM_PACKETS_CB *EnumPackets, _inopt INT StartPacketIndex, _inopt PVOID UserState)
Convenience function for enumerating ISO packets of an isochronous transfer context.
Microsoft OS 2.0 configuration subset header.
Definition: libusbk.h:1216
UCHAR bEndpointAddress
The address of the endpoint described by this descriptor.
Definition: libusbk.h:722
MSOSV2_DESCRIPTOR_TYPE
Microsoft OS 2.0 descriptor wDescriptorType values.
Definition: libusbk.h:1210
INT MaxPendingTransfers
Maximum transfer read/write request allowed pending.
Definition: libusbk.h:2499
UsbK_GetCurrentFrameNumber dynamic driver function id.
Definition: libusbk.h:1784
Request is for a device.
Definition: libusbk.h:451
UsbK_IsoReadPipe dynamic driver function id.
Definition: libusbk.h:1778
KUSB_EXP BOOL KUSB_API UsbK_SetConfiguration(_in KUSB_HANDLE InterfaceHandle, _in UCHAR ConfigurationNumber)
Sets the device configuration number.
USHORT wLength
The length, in bytes, of this header. Shall be set to 10.
Definition: libusbk.h:1255
UsbK_GetConfiguration dynamic driver function id.
Definition: libusbk.h:1724
USHORT wDescriptorType
MSOSV2_DESCRIPTOR_TYPE_FEATURE_COMPATIBLE_ID
Definition: libusbk.h:1322
KUSB_EXP BOOL KUSB_API IsochK_Init(_out KISOCH_HANDLE *IsochHandle, _in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeId, _in UINT MaxNumberOfPackets, _in PUCHAR TransferBuffer, _in UINT TransferBufferSize)
Creates a new isochronous transfer handle for libusbK or WinUSB.
Request is for an endpoint of a device.
Definition: libusbk.h:457
BOS descriptor type.
Definition: libusbk.h:507
MSOS_FEATURE_TYPE
Microsoft feature descriptor types.
Definition: libusbk.h:1045
INT MI
Composite interface number parsed from KLST_DEVINFO::DeviceID. Set to -1 for devices that do not have...
Definition: libusbk.h:269
UCHAR bNumConfigurations
Number of possible configurations.
Definition: libusbk.h:697
Driver API function set structure.
Definition: libusbk.h:2045
USB 2.0 extensions.
Definition: libusbk.h:825
Set device address for all future accesses.
Definition: libusbk.h:588
KSTM_CALLBACK * PKSTM_CALLBACK
Pointer to a KSTM_CALLBACK structure.
Definition: libusbk.h:2607
BOOL Connected
Indicates the devices connection state.
Definition: libusbk.h:333
KUSB_EXP BOOL KUSB_API LstK_MoveNext(_in KLST_HANDLE DeviceList, _outopt KLST_DEVINFO_HANDLE *DeviceInfo)
Advances the device list current KLST_DEVINFO position.
KSTM_SUBMIT_CB * Submit
Executed to submit a transfer.
Definition: libusbk.h:2588
UCHAR bReserved
Reserved.
Definition: libusbk.h:974
UCHAR bLength
Size of this descriptor (in bytes)
Definition: libusbk.h:759
Structure describing a user defined isochronous transfer.
Definition: lusbk_shared.h:300
UCHAR bDescriptorType
Descriptor type.
Definition: libusbk.h:1570
Common usb device information structure.
Definition: libusbk.h:260
USHORT wDescriptorType
MSOSV2_DESCRIPTOR_TYPE_FEATURE_REG_PROPERTY
Definition: libusbk.h:1362
The device is capable of waking the the host from a low power/sleeping state.
Definition: libusbk.h:548
Microsoft OS 2.0 CCGP device descriptor.
Definition: libusbk.h:1234
KSTM_HANDLE StreamHandle
Stream handle.
Definition: libusbk.h:2517
UsbK_IsochReadPipe dynamic driver function id.
Definition: libusbk.h:1793
KOVL_WAIT_FLAG
WaitFlags used by OvlK_Wait.
Definition: libusbk.h:2386
KUSB_EXP BOOL KUSB_API StmK_Start(_in KSTM_HANDLE StreamHandle)
Starts the internal stream thread.
HANDLE DeviceHandle
Populated with the device file handle for the specified UsbHandle.
Definition: libusbk.h:2514
UCHAR bFunctionSubClass
bInterfaceSubClass used for the associated interfaces
Definition: libusbk.h:1630
USHORT Value
wValue
Definition: libusbk.h:79
UCHAR bU1DevExitLat
U1 Device Exit Latency. Worst-case latency to transition from U1 to U0.
Definition: libusbk.h:934
UsbK_SelectInterface dynamic driver function id.
Definition: libusbk.h:1733
INT Major
Major version number.
Definition: libusbk.h:190
PVOID UserState
User defined state.
Definition: libusbk.h:2477
KUSB_EXP BOOL KUSB_API OvlK_Acquire(_out KOVL_HANDLE *OverlappedK, _in KOVL_POOL_HANDLE PoolHandle)
Gets a preallocated OverlappedK structure from the specified/default pool.
INT FunctionCount
[ReadOnly] Number of valid functions contained in the driver API.
Definition: libusbk.h:2034
Cleared/invalid state.
Definition: libusbk.h:241
USB_GETSTATUS
Values for the bits returned by the USB_REQUEST_GET_STATUS request.
Definition: libusbk.h:467
UCHAR bDeviceProtocol
USB-IF protocol code for the device.
Definition: libusbk.h:673
Microsoft OS V1.0 compatible IDs descriptor.
Definition: libusbk.h:1048
KUSB_EXP BOOL KUSB_API UsbK_GetPowerPolicy(_in KUSB_HANDLE InterfaceHandle, _in UINT PolicyType, _ref PUINT ValueLength, _out PVOID Value)
Gets the power policy for a device.
USHORT wLength
The length, in bytes, of this descriptor.
Definition: libusbk.h:1244
All states.
Definition: libusbk.h:256
KUSB_EXP BOOL KUSB_API UsbK_Free(_in KUSB_HANDLE InterfaceHandle)
Frees a libusbK interface handle.
Precision Time Measurement (PTM) Capability Descriptor.
Definition: libusbk.h:852
INT KUSB_API KLIB_HANDLE_CLEANUP_CB(_in KLIB_HANDLE Handle, _in KLIB_HANDLE_TYPE HandleType, _in KLIB_USER_CONTEXT UserContext)
Function typedef for LibK_SetCleanupCallback.
Definition: libusbk.h:184
A custom property section contains the information for a single property.
Definition: libusbk.h:1170
Container ID Descriptor.
Definition: libusbk.h:942
The device is powered by it's host.
Definition: libusbk.h:542
USHORT wDescriptorType
MSOSV2_DESCRIPTOR_TYPE_FEATURE_VENDOR_REVISION
Definition: libusbk.h:1466
Select an alternate interface for the specified interface.
Definition: libusbk.h:606
If the i/o operation fails, release the OverlappedK back to it's pool.
Definition: libusbk.h:2395
UCHAR bDevCapabilityType
Capability type. See BOS_CAPABILITY_TYPE.
Definition: libusbk.h:905
Unchanged state,.
Definition: libusbk.h:244
Allow other KHOT_HANDLE instances to consume this match.
Definition: libusbk.h:2306
KSTM_ERROR_CB * Error
Executed when a transfer error occurs.
Definition: libusbk.h:2585
typedef INT_PTR(FAR WINAPI *KPROC)()
UsbK base function pointer, See LibK_GetProcAddress.
Communications class.
Definition: libusbk.h:626
USHORT idVendor
USB-IF vendor ID.
Definition: libusbk.h:679
Endpoint descriptor type.
Definition: libusbk.h:492
KUSB_DRVID
Supported driver id enumeration.
Definition: libusbk.h:1668
Special Microsoft string descriptor used to indicate that a device supports Microsoft OS V1...
Definition: libusbk.h:1022
Microsoft OS 2.0 compatible ID descriptor.
Definition: libusbk.h:1222
UCHAR iFunction
Index of string descriptor describing the associated interfaces.
Definition: libusbk.h:1636
KUSB_EXP BOOL KUSB_API LstK_InitEx(_out KLST_HANDLE *DeviceList, _in KLST_FLAG Flags, _in PKLST_PATTERN_MATCH PatternMatch)
Initializes a new usb device list containing only devices matching a specific class GUID...
USHORT VendorRevision
Revision number associated with the descriptor set.
Definition: libusbk.h:1473
KUSB_EXP BOOL KUSB_API StmK_Write(_in KSTM_HANDLE StreamHandle, _in PUCHAR Buffer, _in INT Offset, _in INT Length, _out PUINT TransferredLength)
Writes data to the stream buffer.
UCHAR PipeID
This parameter corresponds to the bEndpointAddress field in the endpoint descriptor.
Definition: libusbk.h:2496
USHORT bU2DevExitLat
U2 Device Exit Latency. Worst-case latency to transition from U2 to U0.
Definition: libusbk.h:937
#define KUSB_API
Indicates the calling convention. This is always WINAPI (stdcall) by default.
Definition: libusbk.h:42
USB_ENDPOINT_DESCRIPTOR * PUSB_ENDPOINT_DESCRIPTOR
pointer to a USB_ENDPOINT_DESCRIPTOR
Definition: libusbk.h:741
KSTM_FLAG
Stream config flags.
Definition: libusbk.h:2436
UCHAR bDescriptorType
Descriptor type.
Definition: libusbk.h:658
UsbK_ReadPipe dynamic driver function id.
Definition: libusbk.h:1763
KLIB_HANDLE KISOCH_HANDLE
Opaque IsochK handle, see IsochK_Init.
Definition: libusbk.h:147
KUSB_EXP BOOL KUSB_API UsbK_IsoReadPipe(_in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID, _out PUCHAR Buffer, _in UINT BufferLength, _in LPOVERLAPPED Overlapped, _refopt PKISO_CONTEXT IsoContext)
Reads from an isochronous pipe.
KUSB_EXP BOOL KUSB_API OvlK_IsComplete(_in KOVL_HANDLE OverlappedK)
Checks for i/o completion; returns immediately. (polling)
KUSB_FNID
Supported function id enumeration.
Definition: libusbk.h:1688
KUSB_EXP BOOL KUSB_API UsbK_SetPipePolicy(_in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID, _in UINT PolicyType, _in UINT ValueLength, _in PVOID Value)
Sets the policy for a specific pipe associated with an endpoint on the device. This is a synchronous ...
SuperSpeed USB device capability.
Definition: libusbk.h:828
KUSB_EXP BOOL KUSB_API UsbK_GetConfiguration(_in KUSB_HANDLE InterfaceHandle, _out PUCHAR ConfigurationNumber)
Gets the device current configuration number.
KHOT_FLAG
Hot plug config flags.
Definition: libusbk.h:2297
UCHAR bFirstInterfaceNumber
The interface or function number.
Definition: libusbk.h:1098
UsbK_Clone dynamic driver function id.
Definition: libusbk.h:1739
INT TransferLength
Number of bytes to write or number of bytes read.
Definition: libusbk.h:2474
KUSB_EXP BOOL KUSB_API UsbK_Init(_out KUSB_HANDLE *InterfaceHandle, _in KLST_DEVINFO_HANDLE DevInfo)
Creates/opens a libusbK interface handle from the device list. This is a preferred method...
None.
Definition: libusbk.h:2439
Overlapped pool handle. KOVL_POOL_HANDLE.
Definition: libusbk.h:171
VOID KUSB_API KHOT_POWER_BROADCAST_CB(_in KHOT_HANDLE HotHandle, _in KLST_DEVINFO_HANDLE DeviceInfo, _in UINT PbtEvent)
Power broadcast event function definition.
Definition: libusbk.h:2319
UCHAR bLength
Size of this descriptor (in bytes)
Definition: libusbk.h:806
UsbK_ControlTransfer dynamic driver function id.
Definition: libusbk.h:1712
KUSB_DRIVER_API DriverAPI
Populated with the driver api for the specified UsbHandle.
Definition: libusbk.h:2511
KUSB_EXP VOID KUSB_API LibK_Context_Free(VOID)
Frees the global libusbK process context.
KUSB_EXP BOOL KUSB_API StmK_Init(_out KSTM_HANDLE *StreamHandle, _in KUSB_HANDLE UsbHandle, _in UCHAR PipeID, _in INT MaxTransferSize, _in INT MaxPendingTransfers, _in INT MaxPendingIO, _inopt PKSTM_CALLBACK Callbacks, _inopt KSTM_FLAG Flags)
Initializes a new uni-directional pipe stream.
INT LUsb0FilterIndex
libusb-win32 filter index id.
Definition: libusbk.h:330
UCHAR bMaxBurst
Specifies the maximum number of packets that the endpoint can send or receive as a part of a burst...
Definition: libusbk.h:765
UCHAR bDescriptorType
Descriptor type.
Definition: libusbk.h:809
UsbK_SetPipePolicy dynamic driver function id.
Definition: libusbk.h:1757
Config power descriptor type.
Definition: libusbk.h:498
USHORT wPropertyDataType
The type of data associated with the section.
Definition: libusbk.h:1376
Billboard capability.
Definition: libusbk.h:858
USHORT wTotalLength
The size of entire MS OS 2.0 descriptor set. The value shall match the value in the descriptor set in...
Definition: libusbk.h:1264
KUSB_EXP BOOL KUSB_API UsbK_QueryPipeEx(_in KUSB_HANDLE InterfaceHandle, _in UCHAR AltSettingNumber, _in UCHAR PipeIndex, _out PWINUSB_PIPE_INFORMATION_EX PipeInformationEx)
Retrieves information about a pipe that is associated with an interface.
INT MaxPendingIO
Maximum number of I/O request allowed pending.
Definition: libusbk.h:2505
INT Nano
Nano version number.
Definition: libusbk.h:199
Allows hardware manufacturers to define groupings of interfaces.
Definition: libusbk.h:1612
UCHAR bDescriptorType
Descriptor type.
Definition: libusbk.h:902
Platform specific capability.
Definition: libusbk.h:834
INT KUSB_API KSTM_ERROR_CB(_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex, _in INT ErrorCode)
Function definition for an optional user-defined callback; executed when a transfer error occurs...
USHORT wTotalLength
Length of this descriptor and all sub descriptors.
Definition: libusbk.h:886
KUSB_EXP BOOL KUSB_API OvlK_Free(_in KOVL_POOL_HANDLE PoolHandle)
Destroys the specified pool and all resources it created.
Microsoft OS 2.0 descriptor set header.
Definition: libusbk.h:1252
KUSB_EXP BOOL KUSB_API UsbK_SelectInterface(_in KUSB_HANDLE InterfaceHandle, _in UCHAR NumberOrIndex, _in BOOL IsIndex)
Selects the specified interface by number or index as the current interface.
USB_STRING_DESCRIPTOR * PUSB_STRING_DESCRIPTOR
pointer to a USB_STRING_DESCRIPTOR
Definition: libusbk.h:1577
KLIB_HANDLE KSTM_HANDLE
Opaque StmK handle, see StmK_Init.
Definition: libusbk.h:144
KUSB_EXP BOOL KUSB_API UsbK_ReleaseInterface(_in KUSB_HANDLE InterfaceHandle, _in UCHAR NumberOrIndex, _in BOOL IsIndex)
Releases the specified interface by number or index.
UsbK_GetOverlappedResult dynamic driver function id.
Definition: libusbk.h:1787
USHORT Length
wLength ushort value
Definition: libusbk.h:85
KUSB_EXP BOOL KUSB_API UsbK_ControlTransfer(_in KUSB_HANDLE InterfaceHandle, _in WINUSB_SETUP_PACKET SetupPacket, _refopt PUCHAR Buffer, _in UINT BufferLength, _outopt PUINT LengthTransferred, _inopt LPOVERLAPPED Overlapped)
Transmits control data over a default control endpoint.
Microsoft OS 2.0 vendor revision descriptor.
Definition: libusbk.h:1237
KUSB_EXP BOOL KUSB_API IsoK_GetPacket(_in PKISO_CONTEXT IsoContext, _in INT PacketIndex, _out PKISO_PACKET IsoPacket)
Convenience function for getting all fields of a KISO_PACKET.
USB_COMMON_DESCRIPTOR * PUSB_COMMON_DESCRIPTOR
pointer to a USB_COMMON_DESCRIPTOR
Definition: libusbk.h:1590
UsbK_SetAltInterface dynamic driver function id.
Definition: libusbk.h:1703
Microsoft OS 2.0 compatible ID descriptor.
Definition: libusbk.h:1316
KSTM_STARTED_CB * Started
Executed for every transfer context when the stream is started with StmK_Start.
Definition: libusbk.h:2594
If the i/o operation completes successfully, release the OverlappedK back to it's pool...
Definition: libusbk.h:2392
KUSB_EXP VOID KUSB_API LstK_MoveReset(_in KLST_HANDLE DeviceList)
Sets the device list to its initial position, which is before the first element in the list...
INT KUSB_API KSTM_STOPPED_CB(_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex)
Function definition for an optional user-defined callback; executed for each transfer context when th...
UCHAR bDeviceClass
USB-IF class code for the device.
Definition: libusbk.h:667
BMREQUEST_RECIPIENT
bmRequest.Recipient
Definition: libusbk.h:448
Semi-opaque device information structure of a device list.
Definition: libusbk.h:284
KSTM_COMPLETE_RESULT
Stream config flags.
Definition: libusbk.h:2449
KUSB_EXP BOOL KUSB_API UsbK_AbortPipe(_in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID)
Aborts all of the pending transfers for a pipe.
KUSB_EXP BOOL KUSB_API UsbK_GetPipePolicy(_in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID, _in UINT PolicyType, _ref PUINT ValueLength, _out PVOID Value)
Gets the policy for a specific pipe (endpoint).
UCHAR bDescriptorType
Descriptor type.
Definition: libusbk.h:762
BMREQUEST_TYPE
bmRequest.Type
Definition: libusbk.h:435
Authentication Capability Descriptor.
Definition: libusbk.h:861
Microsoft OS 2.0 registry property descriptor.
Definition: libusbk.h:1225
UsbK_ReleaseInterface dynamic driver function id.
Definition: libusbk.h:1700
UCHAR bDescriptorType
Descriptor type.
Definition: libusbk.h:1532
Enable listings for the raw device interface GUID only. {A5DCBF10-6530-11D2-901F-00C04FB951ED}.
Definition: libusbk.h:356
USB_REQUEST_ENUM
USB defined request codes.
Definition: libusbk.h:576
USHORT wMaxPacketSize
Maximum packet size this endpoint is capable of sending/receiving.
Definition: libusbk.h:734
USB_ENDPOINT_DESCRIPTOR EndpointDescriptor
Populated with the endpoint descriptor for the specified PipeID.
Definition: libusbk.h:2508
WinUSB.sys driver ID.
Definition: libusbk.h:1677
UsbK_GetAssociatedInterface dynamic driver function id.
Definition: libusbk.h:1736
UINT dwWindowsVersion
Windows version.
Definition: libusbk.h:1261
UCHAR bLength
Size of this descriptor (in bytes)
Definition: libusbk.h:1492
Billboard Ex capability.
Definition: libusbk.h:864
KLIB_VERSION * PKLIB_VERSION
Pointer to a
Definition: libusbk.h:202
#define KUSB_EXP
Indicates that a function is an exported API call.
Definition: libusbk.h:37
USHORT wDescriptorType
MSOSV2_DESCRIPTOR_TYPE_SUBSET_HEADER_FUNCTION
Definition: libusbk.h:1295
Stream information structure.
Definition: libusbk.h:2490
INT Pid
ProductID parsed from KLST_DEVINFO::DeviceID.
Definition: libusbk.h:266
KLIB_HANDLE KUSB_HANDLE
Opaque UsbK handle, see UsbK_Init.
Definition: libusbk.h:128
libusbK verson information structure.
Definition: libusbk.h:187
USHORT wTotalLength
The size of entire configuration subset including this header.
Definition: libusbk.h:1284
Supported driver count.
Definition: libusbk.h:1683
KUSB_EXP BOOL KUSB_API OvlK_WaitOldest(_in KOVL_POOL_HANDLE PoolHandle, _outopt KOVL_HANDLE *OverlappedK, _inopt INT TimeoutMS, _inopt KOVL_WAIT_FLAG WaitFlags, _out PUINT TransferredLength)
Waits for overlapped I/O completion on the oldest acquired OverlappedK handle and performs actions sp...
KUSB_EXP BOOL KUSB_API IsochK_CalcPacketInformation(_in BOOL IsHighSpeed, _in PWINUSB_PIPE_INFORMATION_EX PipeInformationEx, _out PKISOCH_PACKET_INFORMATION PacketInformation)
Helper function for isochronous packet/transfer calculations.
USHORT wDescriptorType
See MSOSV2_DESCRIPTOR_TYPE.
Definition: libusbk.h:1247
Device descriptor type.
Definition: libusbk.h:480
INT DriverID
[ReadOnly] Driver id of the driver api.
Definition: libusbk.h:2031
BOOL KUSB_API KISOCH_ENUM_PACKETS_CB(_in UINT PacketIndex, _ref PUINT Offset, _ref PUINT Length, _ref PUINT Status, _in PVOID UserState)
Callback function typedef for IsochK_EnumPackets.
Definition: libusbk.h:217
KUSB_EXP BOOL KUSB_API LstK_Current(_in KLST_HANDLE DeviceList, _out KLST_DEVINFO_HANDLE *DeviceInfo)
Gets the KLST_DEVINFO element for the current position.
Request is for an interface of a device.
Definition: libusbk.h:454
UCHAR bNumEndpoints
Number of endpoints used by this interface (excluding the control endpoint)
Definition: libusbk.h:1541
UINT dwPropertyDataType
The type of data associated with the section.
Definition: libusbk.h:1187
KUSB_EXP BOOL KUSB_API UsbK_WritePipe(_in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID, _in PUCHAR Buffer, _in UINT BufferLength, _outopt PUINT LengthTransferred, _inopt LPOVERLAPPED Overlapped)
Writes data to a pipe.
KUSB_EXP BOOL KUSB_API OvlK_Wait(_in KOVL_HANDLE OverlappedK, _inopt INT TimeoutMS, _inopt KOVL_WAIT_FLAG WaitFlags, _out PUINT TransferredLength)
Waits for overlapped I/O completion, and performs actions specified in WaitFlags. ...
KUSB_EXP BOOL KUSB_API UsbK_GetAssociatedInterface(_in KUSB_HANDLE InterfaceHandle, _in UCHAR AssociatedInterfaceIndex, _out KUSB_HANDLE *AssociatedInterfaceHandle)
Retrieves a handle for an associated interface.
UCHAR bLength
Size of this descriptor (in bytes)
Definition: libusbk.h:1567
Provides information on each battery supported by the device.
Definition: libusbk.h:840
KUSB_EXP BOOL KUSB_API UsbK_GetOverlappedResult(_in KUSB_HANDLE InterfaceHandle, _in LPOVERLAPPED Overlapped, _out PUINT lpNumberOfBytesTransferred, _in BOOL bWait)
Retrieves the results of an overlapped operation on the specified libusbK handle. ...
KUSB_EXP BOOL KUSB_API UsbK_IsochWritePipe(_in KISOCH_HANDLE IsochHandle, _inopt UINT DataLength, _ref PUINT FrameNumber, _inopt UINT NumberOfPackets, _in LPOVERLAPPED Overlapped)
Writes to an isochronous pipe. Supports LibusbK or WinUsb.
Do not perform any additional actions upon exiting OvlK_Wait.
Definition: libusbk.h:2389
UsbK_WritePipe dynamic driver function id.
Definition: libusbk.h:1766
Set then report an endpoint's synchronization frame.
Definition: libusbk.h:609
UCHAR bFunctionClass
bInterfaceClass used for this associated interfaces
Definition: libusbk.h:1627
USHORT bcdUSB
USB specification release number in binary-coded decimal.
Definition: libusbk.h:664
KUSB_EXP BOOL KUSB_API LstK_Count(_in KLST_HANDLE DeviceList, _ref PUINT Count)
Counts the number of device info elements in a device list.
USHORT wLength
The length, bytes, of the compatible ID descriptor including value descriptors. Shall be set to 20...
Definition: libusbk.h:1319
Device can wake the system from a low power/sleeping state.
Definition: libusbk.h:473
KSTM_COMPLETE_CB * Complete
Executed when a valid transfer completes.
Definition: libusbk.h:2591
USHORT wDescriptorType
MSOSV2_DESCRIPTOR_TYPE_FEATURE_MODEL_ID
Definition: libusbk.h:1424
USHORT wDescriptorType
MSOSV2_DESCRIPTOR_TYPE_SET_HEADER_DESCRIPTOR
Definition: libusbk.h:1258
USB_DEVICE_DESCRIPTOR * PUSB_DEVICE_DESCRIPTOR
pointer to a USB_DEVICE_DESCRIPTOR
Definition: libusbk.h:701
KUSB control setup packet.
Definition: libusbk.h:60
Human Interface Device class.
Definition: libusbk.h:629
Device list handle. KLST_HANDLE.
Definition: libusbk.h:162
String descriptor type.
Definition: libusbk.h:486
KUSB_EXP BOOL KUSB_API LstK_FindByVidPid(_in KLST_HANDLE DeviceList, _in INT Vid, _in INT Pid, _out KLST_DEVINFO_HANDLE *DeviceInfo)
Find a device by vendor and product id.
UCHAR iConfiguration
Index of string descriptor describing this configuration.
Definition: libusbk.h:1507
KUSB_EXP BOOL KUSB_API UsbK_ResetDevice(_in KUSB_HANDLE InterfaceHandle)
Resets the usb device of the specified interface handle. (port cycle).
KUSB_EXP BOOL KUSB_API UsbK_FlushPipe(_in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID)
Discards any data that is cached in a pipe.
Overlapped handle. KOVL_HANDLE.
Definition: libusbk.h:168
UCHAR bPad
Padding.
Definition: libusbk.h:1037
UsbK_IsoWritePipe dynamic driver function id.
Definition: libusbk.h:1781
KHOT_PARAMS * PKHOT_PARAMS
Pointer to a KHOT_PARAMS structure.
Definition: libusbk.h:2370
UCHAR bInterfaceSubClass
USB-IF subclass code for this interface.
Definition: libusbk.h:1547
INT Vid
VendorID parsed from KLST_DEVINFO::DeviceID.
Definition: libusbk.h:263
KUSB_EXP BOOL KUSB_API OvlK_WaitAndRelease(_in KOVL_HANDLE OverlappedK, _inopt INT TimeoutMS, _out PUINT TransferredLength)
Waits for overlapped I/O completion, cancels on a timeout error and always releases the OvlK handle b...
A structure representing the standard USB string descriptor.
Definition: libusbk.h:1564
USHORT wLength
The length, in bytes, of this descriptor. Shall be set to 6.
Definition: libusbk.h:1400
UCHAR bLength
Size of this descriptor (in bytes)
Definition: libusbk.h:711
KUSB_EXP BOOL KUSB_API IsochK_Free(_in KISOCH_HANDLE IsochHandle)
Destroys an isochronous transfer handle.
UsbK_QueryDeviceInformation dynamic driver function id.
Definition: libusbk.h:1745
UCHAR bLength
Size of this descriptor (in bytes)
Definition: libusbk.h:945
KUSB_EXP BOOL KUSB_API UsbK_ClaimInterface(_in KUSB_HANDLE InterfaceHandle, _in UCHAR NumberOrIndex, _in BOOL IsIndex)
Claims the specified interface by number or index.
UCHAR iProduct
Index of string descriptor describing product.
Definition: libusbk.h:691
Device info handle. KLST_DEVINFO_HANDLE.
Definition: libusbk.h:165
KLIB_HANDLE KOVL_HANDLE
Opaque OvlK handle, see OvlK_Acquire.
Definition: libusbk.h:137
UCHAR bDeviceSubClass
USB-IF subclass code for the device.
Definition: libusbk.h:670
KUSB_EXP BOOL KUSB_API LibK_GetProcAddress(_out KPROC *ProcAddress, _in INT DriverID, _in INT FunctionID)
Initialize a driver API function.
Set device configuration.
Definition: libusbk.h:600
KUSB_EXP KLIB_USER_CONTEXT KUSB_API LibK_GetDefaultContext(_in KLIB_HANDLE_TYPE HandleType)
Gets the default user context for the specified KLIB_HANDLE_TYPE.
UCHAR bReserved
Reserved.
Definition: libusbk.h:1281
UCHAR bLength
Size of this descriptor (in bytes)
Definition: libusbk.h:899
Supported function count.
Definition: libusbk.h:1805
Microsoft OS 2.0 CCGP device descriptor.
Definition: libusbk.h:1438
HWND UserHwnd
Hot plug event window handle to send/post messages when notifications occur.
Definition: libusbk.h:2334
KUSB_EXP HANDLE KUSB_API OvlK_GetEventHandle(_in KOVL_HANDLE OverlappedK)
Returns the internal event handle used to signal IO operations.
UCHAR bDescriptorType
Descriptor type.
Definition: libusbk.h:1495
List all libusbK devices including those not currently connected.
Definition: libusbk.h:359
USB_DESCRIPTOR_TYPE
Standard USB descriptor types. For more information, see section 9-5 of the USB 3.0 specifications.
Definition: libusbk.h:477
Class-specific request.
Definition: libusbk.h:441
KLST_DEV_COMMON_INFO * PKLST_DEV_COMMON_INFO
Pointer to a KLST_DEV_COMMON_INFO structure.
Definition: libusbk.h:276
KUSB_EXP BOOL KUSB_API IsoK_Free(_in PKISO_CONTEXT IsoContext)
Destroys an isochronous transfer context.
KUSB_EXP BOOL KUSB_API LUsb0_ControlTransfer(_in KUSB_HANDLE InterfaceHandle, _in WINUSB_SETUP_PACKET SetupPacket, _refopt PUCHAR Buffer, _in UINT BufferLength, _outopt PUINT LengthTransferred, _inopt LPOVERLAPPED Overlapped)
Transmits control data over a default control endpoint.
KUSB_EXP BOOL KUSB_API IsoK_Init(_out PKISO_CONTEXT *IsoContext, _in INT NumberOfPackets, _inopt INT StartFrame)
Creates a new isochronous transfer context for libusbK only.
KUSB_EXP BOOL KUSB_API IsochK_GetPacket(_in KISOCH_HANDLE IsochHandle, _in UINT PacketIndex, _outopt PUINT Offset, _outopt PUINT Length, _outopt PUINT Status)
Convenience function for getting all fields in an isochronous transfer packet.
UsbK_GetCurrentAlternateSetting dynamic driver function id.
Definition: libusbk.h:1751
KUSB_EXP BOOL KUSB_API UsbK_GetCurrentAlternateSetting(_in KUSB_HANDLE InterfaceHandle, _out PUCHAR AltSettingNumber)
Gets the current alternate interface setting for an interface.
USB_INTERFACE_DESCRIPTOR * PUSB_INTERFACE_DESCRIPTOR
pointer to a USB_INTERFACE_DESCRIPTOR
Definition: libusbk.h:1557
Imaging class.
Definition: libusbk.h:632
Request status of the specific recipient.
Definition: libusbk.h:579
USHORT wDescriptorType
MSOSV2_DESCRIPTOR_TYPE_FEATURE_CCGP_DEVICE
Definition: libusbk.h:1444
USHORT wSubsetLength
The size of entire function subset including this header.
Definition: libusbk.h:1304
UCHAR bDescriptorType
Descriptor type.
Definition: libusbk.h:883
UCHAR bConfigurationValue
The configuration value for the USB configuration to which this subset applies.
Definition: libusbk.h:1278
#define KLST_STRING_MAX_LEN
Allocated length for all strings in a KLST_DEVINFO structure.
Definition: libusbk.h:229
KLIB_HANDLE_TYPE
Handle type enumeration.
Definition: libusbk.h:150
UINT dwWindowsVersion
Minimum version of Windows.
Definition: libusbk.h:995
KUSB_EXP BOOL KUSB_API LstK_Init(_out KLST_HANDLE *DeviceList, _in KLST_FLAG Flags)
Initializes a new usb device list containing all supported devices.
KUSB_PROPERTY
Usb handle specific properties that can be retrieved with UsbK_GetProperty.
Definition: libusbk.h:1658
USHORT wMSOSDescriptorSetTotalLength
The length, in bytes of the MS OS 2.0 descriptor set.
Definition: libusbk.h:998
Defines the various PD Capabilities of this device.
Definition: libusbk.h:837
KUSB_EXP BOOL KUSB_API UsbK_QueryInterfaceSettings(_in KUSB_HANDLE InterfaceHandle, _in UCHAR AltSettingIndex, _out PUSB_INTERFACE_DESCRIPTOR UsbAltInterfaceDescriptor)
Retrieves the interface descriptor for the specified alternate interface settings for a particular in...
Microsoft OS 2.0 function subset header.
Definition: libusbk.h:1289
UCHAR bDescriptorType
Descriptor type.
Definition: libusbk.h:714
INT BufferSize
Size of internal stream buffer.
Definition: libusbk.h:2471
UsbK_GetPipePolicy dynamic driver function id.
Definition: libusbk.h:1760
Reserved class.
Definition: libusbk.h:620
KUSB_EXP BOOL KUSB_API UsbK_SetPowerPolicy(_in KUSB_HANDLE InterfaceHandle, _in UINT PolicyType, _in UINT ValueLength, _in PVOID Value)
Sets the power policy for a device.
UCHAR bDescriptorType
Descriptor type.
Definition: libusbk.h:1586
Types and defines shared with the driver.
Structure describing additional information about how an isochronous pipe transfers data...
Definition: lusbk_shared.h:369
USB 3.0 and USB 2.0 LPM Binary Device Object Store (BOS).
Definition: libusbk.h:877
INT Minor
Minor version number.
Definition: libusbk.h:193
No flags (or 0)
Definition: libusbk.h:353
Platform specific capabilities.
Definition: libusbk.h:962
KUSB_EXP BOOL KUSB_API UsbK_IsoWritePipe(_in KUSB_HANDLE InterfaceHandle, _in UCHAR PipeID, _in PUCHAR Buffer, _in UINT BufferLength, _in LPOVERLAPPED Overlapped, _refopt PKISO_CONTEXT IsoContext)
Writes to an isochronous pipe.
KLIB_HANDLE KOVL_POOL_HANDLE
Opaque OvlPoolK handle, see OvlK_Init.
Definition: libusbk.h:141
KSTM_INFO * PKSTM_INFO
Pointer to a KSTM_INFO structure.
Definition: libusbk.h:2524
USHORT wBytesPerInterval
Number of bytes per interval.
Definition: libusbk.h:791
USHORT wLength
The length, in bytes, of this descriptor. Shall be set to 20.
Definition: libusbk.h:1421
BOOL KUSB_API KISO_ENUM_PACKETS_CB(_in UINT PacketIndex, _in PKISO_PACKET IsoPacket, _in PVOID UserState)
Callback function typedef for IsoK_EnumPackets.
Definition: libusbk.h:214
KUSB_EXP BOOL KUSB_API StmK_Read(_in KSTM_HANDLE StreamHandle, _out PUCHAR Buffer, _in INT Offset, _in INT Length, _out PUINT TransferredLength)
Reads data from the stream buffer.
KUSB_EXP BOOL KUSB_API LstK_Enumerate(_in KLST_HANDLE DeviceList, _in KLST_ENUM_DEVINFO_CB *EnumDevListCB, _inopt PVOID Context)
Enumerates KLST_DEVINFO elements of a KLST_HANDLE.
KUSB_EXP BOOL KUSB_API LibK_IsFunctionSupported(_in PKUSB_DRIVER_API DriverAPI, _in UINT FunctionID)
Checks if the driver supports a function.
UCHAR bDevCapabilityType
Capability type.
Definition: libusbk.h:812
UCHAR bFirstInterface
The interface number for the first interface of the function to which this subset applies...
Definition: libusbk.h:1298
Microsoft OS 2.0 configuration subset header.
Definition: libusbk.h:1269
UCHAR bDescriptorType
Descriptor type.
Definition: libusbk.h:919
UCHAR bLength
Size of this descriptor (in bytes)
Definition: libusbk.h:880
UCHAR bInterval
Interval for polling endpoint for data transfers.
Definition: libusbk.h:737
UsbK_GetPowerPolicy dynamic driver function id.
Definition: libusbk.h:1718
UCHAR bInterfaceNumber
Number of this interface.
Definition: libusbk.h:1535
KUSB_EXP VOID KUSB_API HotK_FreeAll(VOID)
Frees all hot-plug handles initialized with HotK_Init.
PUCHAR Buffer
Internal stream buffer.
Definition: libusbk.h:2468
The device has an external power source.
Definition: libusbk.h:545
INT MaxTransferSize
Maximum transfer sage size.
Definition: libusbk.h:2502
KUSB_EXP BOOL KUSB_API UsbK_Clone(_in KUSB_HANDLE InterfaceHandle, _out KUSB_HANDLE *DstInterfaceHandle)
Clones the specified interface handle.
Microsoft OS V2.0 descriptor set.
Definition: libusbk.h:1054
UCHAR bMaxPacketSize0
Maximum packet size for control endpoint 0.
Definition: libusbk.h:676
INT_PTR KLIB_USER_CONTEXT
User defined handle context space, see LibK_GetContext.
Definition: libusbk.h:53
UCHAR bResumeRecoveryTime
The number of milliseconds the device requires to recover from port resume. (Valid values are 0 to 10...
Definition: libusbk.h:1406
KLST_SYNC_FLAG
Device list sync flags.
Definition: libusbk.h:238
void * KLIB_HANDLE
Base handle type for all library handles, See KLIB_HANDLE_TYPE.
Definition: libusbk.h:125
UsbK_ResetPipe dynamic driver function id.
Definition: libusbk.h:1769
UCHAR bFunctionalitySupport
The lowest speed at which all the functionality supported by the device is available to the user...
Definition: libusbk.h:931
UsbK_SetPowerPolicy dynamic driver function id.
Definition: libusbk.h:1715
Removed (Unplugged) state,.
Definition: libusbk.h:250
UCHAR Request
Request type value.
Definition: libusbk.h:76
Microsoft OS 2.0 registry property descriptor.
Definition: libusbk.h:1356
Defines the set of SuperSpeed Plus USB specific device level capabilities.
Definition: libusbk.h:849
Stream transfer context structure.
Definition: libusbk.h:2464
Clear or disable a specific feature.
Definition: libusbk.h:582
USHORT wDescriptorType
MSOSV2_DESCRIPTOR_TYPE_FEATURE_MIN_RESUME_TIME
Definition: libusbk.h:1403
Superspeed endpoint companion descriptor type.
Definition: libusbk.h:513
KUSB_EXP BOOL KUSB_API UsbK_SetAltInterface(_in KUSB_HANDLE InterfaceHandle, _in UCHAR NumberOrIndex, _in BOOL IsIndex, _in UCHAR AltSettingNumber)
Sets the alternate setting of the specified interface.
UCHAR bDescriptorType
Descriptor type (0x03)
Definition: libusbk.h:1028
USB_CONFIGURATION_DESCRIPTOR * PUSB_CONFIGURATION_DESCRIPTOR
pointer to a USB_CONFIGURATION_DESCRIPTOR
Definition: libusbk.h:1519
KSTM_STOPPED_CB * Stopped
Executed for every transfer context when the stream is stopped with StmK_Stop.
Definition: libusbk.h:2597
This structure represents the windows version records that follow a BOS windows platform descriptor...
Definition: libusbk.h:987
A structure representing the standard USB device descriptor.
Definition: libusbk.h:652