libusbk-sys 0.2.0

Rust Windows library for accessing USB devices via libusbK
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
/*! \file libusbk.h
* \brief functions for usb device communication.
*
* \note
* This is the \b main libusbK USB user include file.
*/

#ifndef _LIBUSBK_H__
#define _LIBUSBK_H__


#include "lusbk_shared.h"

///////////////////////////////////////////////////////////////////////
// L I B U S B K  PUBLIC STRUCTS, DEFINES, AND ENUMS //////////////////
///////////////////////////////////////////////////////////////////////

#ifndef _LIBUSBK_LIBK_TYPES

/*! \addtogroup libk
* @{
*/

#define _in

#define _inopt

#define _out

#define _outopt

#define _ref

#define _refopt


//! UsbK base function pointer, See \ref LibK_GetProcAddress.
typedef INT_PTR (FAR WINAPI* KPROC)();

//! Indicates that a function is an exported API call.
#if defined(DYNAMIC_DLL)
#define KUSB_EXP

#else
#define KUSB_EXP

#endif

//! Indicates the calling convention. This is always WINAPI (stdcall) by default.
#if !defined(KUSB_API)
#define KUSB_API WINAPI

#endif

#if _MSC_VER >= 1200
#pragma warning(push)
#endif
#pragma warning(disable:4200)
#pragma warning(disable:4201)
#pragma warning(disable:4214) // named type definition in parentheses


//! User defined handle context space, see \ref LibK_GetContext.
typedef INT_PTR KLIB_USER_CONTEXT;

//! KUSB control setup packet.
/*!
* This union structure is identical in size to a \ref WINUSB_SETUP_PACKET,
* but provides additional field accessors. (see \ref libusbk.h for structure details)
*/
typedef union _KUSB_SETUP_PACKET
{
	UCHAR	Bytes[8];
	USHORT	Words[4];
	struct
	{
		//! Request value
		struct
		{
			UCHAR Recipient: 2;
			UCHAR Reserved: 3;
			UCHAR Type: 2;
			UCHAR Dir: 1;
		} BmRequest;

		//! Request type value
		UCHAR Request;

		//! wValue
		USHORT Value;

		//! wIndex
		USHORT Index;

		//! wLength ushort value
		USHORT Length;
	};
	struct
	{
		struct
		{
			UCHAR b0: 1;
			UCHAR b1: 1;
			UCHAR b2: 1;
			UCHAR b3: 1;
			UCHAR b4: 1;
			UCHAR b5: 1;
			UCHAR b6: 1;
			UCHAR b7: 1;
		} BmRequestBits;

		struct
		{
			UCHAR b0: 1;
			UCHAR b1: 1;
			UCHAR b2: 1;
			UCHAR b3: 1;
			UCHAR b4: 1;
			UCHAR b5: 1;
			UCHAR b6: 1;
			UCHAR b7: 1;
		} RequestBits;

		UCHAR ValueLo;
		UCHAR ValueHi;
		UCHAR IndexLo;
		UCHAR IndexHi;
		UCHAR LengthLo;
		UCHAR LengthHi;
	};
} KUSB_SETUP_PACKET;
// setup packet is eight bytes -- defined by spec
USBK_C_ASSERT(KUSB_SETUP_PACKET,sizeof(KUSB_SETUP_PACKET) == 8);

//! Base handle type for all library handles, See \ref KLIB_HANDLE_TYPE.
typedef void* KLIB_HANDLE;

//! Opaque UsbK handle, see \ref UsbK_Init.
typedef KLIB_HANDLE KUSB_HANDLE;

//! Opaque LstK handle, see \ref LstK_Init.
typedef KLIB_HANDLE KLST_HANDLE;

//! Opaque HotK handle, see \ref HotK_Init.
typedef KLIB_HANDLE KHOT_HANDLE;

//! Opaque OvlK handle, see \ref OvlK_Acquire.
typedef KLIB_HANDLE KOVL_HANDLE;


//! Opaque OvlPoolK handle, see \ref OvlK_Init.
typedef KLIB_HANDLE KOVL_POOL_HANDLE;

//! Opaque StmK handle, see \ref StmK_Init.
typedef KLIB_HANDLE KSTM_HANDLE;

//! Opaque IsochK handle, see \ref IsochK_Init.
typedef KLIB_HANDLE KISOCH_HANDLE;

//! Handle type enumeration.
typedef enum _KLIB_HANDLE_TYPE
{
    //! Hot plug handle. \ref KHOT_HANDLE
    KLIB_HANDLE_TYPE_HOTK,

    //! USB handle. \ref KUSB_HANDLE
    KLIB_HANDLE_TYPE_USBK,

    //! Shared USB handle. \ref KUSB_HANDLE
    KLIB_HANDLE_TYPE_USBSHAREDK,

    //! Device list handle. \ref KLST_HANDLE
    KLIB_HANDLE_TYPE_LSTK,

    //! Device info handle. \ref KLST_DEVINFO_HANDLE
    KLIB_HANDLE_TYPE_LSTINFOK,

    //! Overlapped handle. \ref KOVL_HANDLE
    KLIB_HANDLE_TYPE_OVLK,

    //! Overlapped pool handle. \ref KOVL_POOL_HANDLE
    KLIB_HANDLE_TYPE_OVLPOOLK,

    //! Pipe stream handle. \ref KSTM_HANDLE
    KLIB_HANDLE_TYPE_STMK,

	//! Pipe stream handle. \ref KSTM_HANDLE
	KLIB_HANDLE_TYPE_ISOCHK,
	
	//! Max handle type count.
    KLIB_HANDLE_TYPE_COUNT
} KLIB_HANDLE_TYPE;

//! Function typedef for \ref LibK_SetCleanupCallback.
typedef INT KUSB_API KLIB_HANDLE_CLEANUP_CB (_in KLIB_HANDLE Handle, _in KLIB_HANDLE_TYPE HandleType, _in KLIB_USER_CONTEXT UserContext);

//! libusbK verson information structure.
typedef struct _KLIB_VERSION
{
	//! Major version number.
	INT Major;

	//! Minor version number.
	INT Minor;

	//! Micro version number.
	INT Micro;

	//! Nano version number.
	INT Nano;
} KLIB_VERSION;
//! Pointer to a \copybrief KLIB_VERSION
typedef KLIB_VERSION* PKLIB_VERSION;

/*! @} */
#endif

#ifndef _LIBUSBK_ISOK_TYPES
/*! \addtogroup isok
* @{
*/


//! Callback function typedef for \ref IsoK_EnumPackets
typedef BOOL KUSB_API KISO_ENUM_PACKETS_CB (_in UINT PacketIndex, _in PKISO_PACKET IsoPacket, _in PVOID UserState);

//! Callback function typedef for \ref IsochK_EnumPackets
typedef BOOL KUSB_API KISOCH_ENUM_PACKETS_CB(_in UINT PacketIndex, _ref PUINT Offset, _ref PUINT Length, _ref PUINT Status, _in PVOID UserState);

/*! @} */
#endif

#ifndef _LIBUSBK_LSTK_TYPES

/*! \addtogroup lstk
* @{
*/

//!  Allocated length for all strings in a \ref KLST_DEVINFO structure.
#define KLST_STRING_MAX_LEN 256


//! Device list sync flags.
/*!
* These sync flags are also use by the hot plug module to indicate device
* arrival/removal notifications:
* - \b DeviceArrival = KLST_SYNC_FLAG_ADDED
* - \b DeviceRemoval = KLST_SYNC_FLAG_REMOVED
*/
typedef enum _KLST_SYNC_FLAG
{
    //! Cleared/invalid state.
    KLST_SYNC_FLAG_NONE				= 0L,

    //! Unchanged state,
    KLST_SYNC_FLAG_UNCHANGED		= 0x0001,

    //! Added (Arrival) state,
    KLST_SYNC_FLAG_ADDED			= 0x0002,

    //! Removed (Unplugged) state,
    KLST_SYNC_FLAG_REMOVED			= 0x0004,

    //! Connect changed state.
    KLST_SYNC_FLAG_CONNECT_CHANGE	= 0x0008,

    //! All states.
    KLST_SYNC_FLAG_MASK				= 0x000F,
} KLST_SYNC_FLAG;

//! Common usb device information structure
typedef struct _KLST_DEV_COMMON_INFO
{
	//! VendorID parsed from \ref KLST_DEVINFO::DeviceID
	INT Vid;

	//! ProductID parsed from \ref KLST_DEVINFO::DeviceID
	INT Pid;

	//! Composite interface number parsed from \ref KLST_DEVINFO::DeviceID.  Set to \b -1 for devices that do not have the composite parent driver.
	INT MI;

	// An ID that uniquely identifies a USB device.
	CHAR InstanceID[KLST_STRING_MAX_LEN];

} KLST_DEV_COMMON_INFO;
//! Pointer to a \c KLST_DEV_COMMON_INFO structure.
typedef KLST_DEV_COMMON_INFO* PKLST_DEV_COMMON_INFO;

//! Semi-opaque device information structure of a device list.
/*!
*
* \attention This structure is semi-opaque.
*
*/
typedef struct _KLST_DEVINFO
{
	//! Common usb device information
	KLST_DEV_COMMON_INFO Common;

	//! Driver id this device element is using
	INT DriverID;

	//! Device interface GUID
	CHAR DeviceInterfaceGUID[KLST_STRING_MAX_LEN];

	//! Device instance ID.
	/*!
	* A Device instance ID has the following format:
	* [enumerator]\[enumerator-specific-device-ID]\[instance-specific-ID]
	* - [enumerator]
	*   - For USB device, the enumerator is always \c USB
	* - [enumerator-specific-device-ID]
	*   - Contains the vendor and product id (VID_xxxx&PID_xxxx)
	*   - If present, contains the usbccgp (windows composite device layer) interface number (MI_xx)
	* - [instance-specific-ID]
	*   - If the device is composite, contains a unique interface ID generated by Windows.
	*   - If the device is not composite and has a serial number, contains the devices serial number.
	*   - If the device does not have a serial number, contains a unique ID generated by Windows.
	*/
	CHAR DeviceID[KLST_STRING_MAX_LEN];

	//! Class GUID.
	CHAR ClassGUID[KLST_STRING_MAX_LEN];

	//! Manufacturer name as specified in the INF file.
	CHAR Mfg[KLST_STRING_MAX_LEN];

	//! Device description as specified in the INF file.
	CHAR DeviceDesc[KLST_STRING_MAX_LEN];

	//! Driver service name.
	CHAR Service[KLST_STRING_MAX_LEN];

	//! Unique identifier.
	CHAR SymbolicLink[KLST_STRING_MAX_LEN];

	//! physical device filename used with the Windows \c CreateFile()
	CHAR DevicePath[KLST_STRING_MAX_LEN];

	//! libusb-win32 filter index id.
	INT LUsb0FilterIndex;

	//! Indicates the devices connection state.
	BOOL Connected;

	//! Synchronization flags. (internal use only)
	KLST_SYNC_FLAG SyncFlags;

	INT BusNumber;

	INT DeviceAddress;

	//! If the the device is serialized, represents the string value of \ref USB_DEVICE_DESCRIPTOR::iSerialNumber. For Devices without a \b iSerialNumber, represents the unique \b InstanceID assigned by \b Windows.
	CHAR SerialNumber[KLST_STRING_MAX_LEN];

} KLST_DEVINFO;
//! Pointer to a \ref KLST_DEVINFO structure. (semi-opaque)
typedef KLST_DEVINFO* KLST_DEVINFO_HANDLE;

//! Device list initialization flags.
typedef enum _KLST_FLAG
{
    //! No flags (or 0)
    KLST_FLAG_NONE = 0L,

    //! Enable listings for the raw device interface GUID \b only. {A5DCBF10-6530-11D2-901F-00C04FB951ED}
    KLST_FLAG_INCLUDE_RAWGUID = 0x0001,

    //! List all libusbK devices including those not currently connected.
    KLST_FLAG_INCLUDE_DISCONNECT = 0x0002,

} KLST_FLAG;

//! Device list/hot-plug pattern match structure.
/*!
* \fixedstruct{1024}
*
* These ansi char strings are used to specify which devices should be included in a device list.
* All strings file pattern match strings allowing asterisk or question mark chars as wildcards.
*
*/
typedef struct _KLST_PATTERN_MATCH
{
	//! Pattern match a device instance id.
	CHAR DeviceID[KLST_STRING_MAX_LEN];

	//! Pattern match a device interface guid.
	CHAR DeviceInterfaceGUID[KLST_STRING_MAX_LEN];

	//! Pattern match a symbolic link.
	CHAR ClassGUID[KLST_STRING_MAX_LEN];

	//! fixed structure padding.
	UCHAR z_F_i_x_e_d[1024 - KLST_STRING_MAX_LEN * 3];

} KLST_PATTERN_MATCH;
USBK_C_ASSERT(KLST_PATTERN_MATCH,sizeof(KLST_PATTERN_MATCH) == 1024);

//! Pointer to a \ref KLST_PATTERN_MATCH structure.
typedef KLST_PATTERN_MATCH* PKLST_PATTERN_MATCH;

//! Device list enumeration function callback typedef.
/*!
*
* \param DeviceList
* The device list \c DeviceInfo belongs to
*
* \param DeviceInfo
* Device information
*
* \param Context
* User context that was passed into \ref LstK_Enumerate
*
* Use this typedef as a prototype for an enumeration function with \ref LstK_Enumerate.
*
*/
typedef BOOL KUSB_API KLST_ENUM_DEVINFO_CB (
    _in KLST_HANDLE DeviceList,
    _in KLST_DEVINFO_HANDLE DeviceInfo,
    _in PVOID Context);

/*! @} */

#endif

#ifndef   __USB_H__

#include <pshpack1.h>

/*! \addtogroup libk
* @{
*/

//! Maximum value that can be added to the current start frame.
#define USBD_ISO_START_FRAME_RANGE 1024



//! bmRequest.Dir
typedef enum _BMREQUEST_DIR
{
    BMREQUEST_DIR_HOST_TO_DEVICE = 0,
    BMREQUEST_DIR_DEVICE_TO_HOST = 1,
} BMREQUEST_DIR;

//! bmRequest.Type
typedef enum _BMREQUEST_TYPE
{
    //! Standard request. See \ref USB_REQUEST_ENUM
    BMREQUEST_TYPE_STANDARD = 0,

    //! Class-specific request.
    BMREQUEST_TYPE_CLASS = 1,

    //! Vendor-specific request
    BMREQUEST_TYPE_VENDOR = 2,
} BMREQUEST_TYPE;

//! bmRequest.Recipient
typedef enum _BMREQUEST_RECIPIENT
{
    //! Request is for a device.
    BMREQUEST_RECIPIENT_DEVICE = 0,

    //! Request is for an interface of a device.
    BMREQUEST_RECIPIENT_INTERFACE = 1,

    //! Request is for an endpoint of a device.
    BMREQUEST_RECIPIENT_ENDPOINT = 2,

    //! Request is for a vendor-specific purpose.
    BMREQUEST_RECIPIENT_OTHER = 3,
} BMREQUEST_RECIPIENT;

//! Maximum length (in bytes) of a usb string. USB strings are always stored in wide-char format.
#define MAXIMUM_USB_STRING_LENGTH 255


//! Values for the bits returned by the \ref USB_REQUEST_GET_STATUS request.
typedef enum _USB_GETSTATUS
{
    //! Device is self powered
    USB_GETSTATUS_SELF_POWERED = 0x01,

    //! Device can wake the system from a low power/sleeping state.
    USB_GETSTATUS_REMOTE_WAKEUP_ENABLED = 0x02
} USB_GETSTATUS;

//! Standard USB descriptor types. For more information, see section 9-5 of the USB 3.0 specifications.
typedef enum _USB_DESCRIPTOR_TYPE
{
    //! Device descriptor type.
    USB_DESCRIPTOR_TYPE_DEVICE = 0x01,

    //! Configuration descriptor type.
    USB_DESCRIPTOR_TYPE_CONFIGURATION = 0x02,

    //! String descriptor type.
    USB_DESCRIPTOR_TYPE_STRING = 0x03,

    //! Interface descriptor type.
    USB_DESCRIPTOR_TYPE_INTERFACE = 0x04,

    //! Endpoint descriptor type.
    USB_DESCRIPTOR_TYPE_ENDPOINT = 0x05,

    //! Device qualifier descriptor type.
    USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER = 0x06,

    //! Config power descriptor type.
    USB_DESCRIPTOR_TYPE_CONFIG_POWER = 0x07,

    //! Interface power descriptor type.
    USB_DESCRIPTOR_TYPE_INTERFACE_POWER = 0x08,
	
    //! Interface association descriptor type.
    USB_DESCRIPTOR_TYPE_INTERFACE_ASSOCIATION = 0x0B,

	//! BOS descriptor type
	USB_DESCRIPTOR_TYPE_BOS = 0x0F,
	
	//! Device capabilities descriptor type
	USB_DESCRIPTOR_TYPE_DEVICE_CAPS = 0x10,

	//! Superspeed endpoint companion descriptor type
	USB_SUPERSPEED_ENDPOINT_COMPANION = 0x30,
} USB_DESCRIPTOR_TYPE;

//! Makes \c wValue for a \ref USB_REQUEST_GET_DESCRIPTOR or \ref USB_REQUEST_SET_DESCRIPTOR request.
#define USB_DESCRIPTOR_MAKE_TYPE_AND_INDEX(d, i)	\

	((USHORT)((USHORT)d<<8 | i))

//! Endpoint type mask for the \c bmAttributes field of a \ref USB_ENDPOINT_DESCRIPTOR
#define USB_ENDPOINT_TYPE_MASK                    0x03


//! Indicates a control endpoint
#define USB_ENDPOINT_TYPE_CONTROL                 0x00


//! Indicates an isochronous endpoint
#define USB_ENDPOINT_TYPE_ISOCHRONOUS             0x01


//! Indicates a bulk endpoint
#define USB_ENDPOINT_TYPE_BULK                    0x02


//! Indicates an interrupt endpoint
#define USB_ENDPOINT_TYPE_INTERRUPT               0x03


//! Config power mask for the \c bmAttributes field of a \ref USB_CONFIGURATION_DESCRIPTOR
#define USB_CONFIG_POWERED_MASK                   0xc0


//! Values used in the \c bmAttributes field of a \ref USB_CONFIGURATION_DESCRIPTOR
typedef enum _USB_CONFIG_BM_ATTRIBUTE_ENUM
{
    //! The device is powered by it's host.
    USB_CONFIG_BUS_POWERED = 0x80,

    //! The device has an external power source.
    USB_CONFIG_SELF_POWERED = 0x40,

    //! The device is capable of waking the the host from a low power/sleeping state.
    USB_CONFIG_REMOTE_WAKEUP = 0x20,
}USB_CONFIG_BM_ATTRIBUTE_ENUM;

//! Endpoint direction mask for the \c bEndpointAddress field of a \ref USB_ENDPOINT_DESCRIPTOR
#define USB_ENDPOINT_DIRECTION_MASK               0x80


//! Endpoint address mask for the \c bEndpointAddress field of a \ref USB_ENDPOINT_DESCRIPTOR
#define USB_ENDPOINT_ADDRESS_MASK 0x0F


//! Tests the \c bEndpointAddress direction bit. TRUE if the endpoint address is an OUT endpoint. (HostToDevice, PC Write)
/*!
* \param addr \c bEndpointAddress field of a \ref USB_ENDPOINT_DESCRIPTOR
*/
#define USB_ENDPOINT_DIRECTION_OUT(addr)          (!((addr) & USB_ENDPOINT_DIRECTION_MASK))


//!  Tests the \c bEndpointAddress direction bit. TRUE if the endpoint address is an IN endpoint. (DeviceToHost, PC Read)
/*!
* \param addr \c bEndpointAddress field of a \ref USB_ENDPOINT_DESCRIPTOR
*/
#define USB_ENDPOINT_DIRECTION_IN(addr)           ((addr) & USB_ENDPOINT_DIRECTION_MASK)


//! USB defined request codes
/*
* see Chapter 9 of the USB 2.0 specification for
* more information.
*
* These are the correct values based on the USB 2.0 specification.
*/
typedef enum _USB_REQUEST_ENUM
{
    //! Request status of the specific recipient
    USB_REQUEST_GET_STATUS = 0x00,

    //! Clear or disable a specific feature
    USB_REQUEST_CLEAR_FEATURE = 0x01,

    //! Set or enable a specific feature
    USB_REQUEST_SET_FEATURE = 0x03,

    //! Set device address for all future accesses
    USB_REQUEST_SET_ADDRESS = 0x05,

    //! Get the specified descriptor
    USB_REQUEST_GET_DESCRIPTOR = 0x06,

    //! Update existing descriptors or add new descriptors
    USB_REQUEST_SET_DESCRIPTOR = 0x07,

    //! Get the current device configuration value
    USB_REQUEST_GET_CONFIGURATION = 0x08,

    //! Set device configuration
    USB_REQUEST_SET_CONFIGURATION = 0x09,

    //! Return the selected alternate setting for the specified interface
    USB_REQUEST_GET_INTERFACE = 0x0A,

    //! Select an alternate interface for the specified interface
    USB_REQUEST_SET_INTERFACE = 0x0B,

    //! Set then report an endpoint's synchronization frame
    USB_REQUEST_SYNC_FRAME = 0x0C,
}USB_REQUEST_ENUM;

//! USB defined class codes
/*!
* see http://www.usb.org/developers/defined_class for more information.
*
*/
typedef enum _USB_DEVICE_CLASS_ENUM
{
    //! Reserved class
    USB_DEVICE_CLASS_RESERVED = 0x00,

    //! Audio class
    USB_DEVICE_CLASS_AUDIO = 0x01,

    //! Communications class
    USB_DEVICE_CLASS_COMMUNICATIONS = 0x02,

    //! Human Interface Device class
    USB_DEVICE_CLASS_HUMAN_INTERFACE = 0x03,

    //! Imaging class
    USB_DEVICE_CLASS_IMAGING = 0x06,

    //! Printer class
    USB_DEVICE_CLASS_PRINTER = 0x07,

    //! Mass storage class
    USB_DEVICE_CLASS_STORAGE = 0x08,

    //! Hub class
    USB_DEVICE_CLASS_HUB = 0x09,

    //! vendor-specific class
    USB_DEVICE_CLASS_VENDOR_SPECIFIC = 0xFF,
}USB_DEVICE_CLASS_ENUM;

//! A structure representing the standard USB device descriptor.
/*!
* This descriptor is documented in section 9.6.1 of the USB 2.0 specification.
* All multiple-byte fields are represented in host-endian format.
*/
typedef struct _USB_DEVICE_DESCRIPTOR
{
	//! Size of this descriptor (in bytes)
	UCHAR bLength;

	//! Descriptor type
	UCHAR bDescriptorType;

	//! USB specification release number in binary-coded decimal.
	/*!
	* A value of 0x0200 indicates USB 2.0, 0x0110 indicates USB 1.1, etc.
	*/
	USHORT bcdUSB;

	//! USB-IF class code for the device
	UCHAR bDeviceClass;

	//! USB-IF subclass code for the device
	UCHAR bDeviceSubClass;

	//! USB-IF protocol code for the device
	UCHAR bDeviceProtocol;

	//! Maximum packet size for control endpoint 0
	UCHAR bMaxPacketSize0;

	//! USB-IF vendor ID
	USHORT idVendor;

	//! USB-IF product ID
	USHORT idProduct;

	//! Device release number in binary-coded decimal
	USHORT bcdDevice;

	//! Index of string descriptor describing manufacturer
	UCHAR iManufacturer;

	//! Index of string descriptor describing product
	UCHAR iProduct;

	//! Index of string descriptor containing device serial number
	UCHAR iSerialNumber;

	//! Number of possible configurations
	UCHAR bNumConfigurations;

} USB_DEVICE_DESCRIPTOR;
//! pointer to a \c USB_DEVICE_DESCRIPTOR
typedef USB_DEVICE_DESCRIPTOR* PUSB_DEVICE_DESCRIPTOR;

//! A structure representing the standard USB endpoint 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_ENDPOINT_DESCRIPTOR
{
	//! Size of this descriptor (in bytes)
	UCHAR bLength;

	//! Descriptor type
	UCHAR bDescriptorType;

	//! The address of the endpoint described by this descriptor.
	/*!
	* - Bits 0:3 are the endpoint number
	* - Bits 4:6 are reserved
	* - Bit 7 indicates direction
	*/
	UCHAR bEndpointAddress;

	//! Attributes which apply to the endpoint when it is configured using the bConfigurationValue.
	/*!
	* - Bits 0:1 determine the transfer type.
	* - Bits 2:3 are only used for isochronous endpoints and refer to sync type.
	* - Bits 4:5 are also only used for isochronous endpoints and refer to usage type.
	* - Bits 6:7 are reserved.
	*/
	UCHAR bmAttributes;

	//! Maximum packet size this endpoint is capable of sending/receiving.
	USHORT wMaxPacketSize;

	//! Interval for polling endpoint for data transfers.
	UCHAR bInterval;

} USB_ENDPOINT_DESCRIPTOR;
//! pointer to a \c USB_ENDPOINT_DESCRIPTOR
typedef USB_ENDPOINT_DESCRIPTOR* PUSB_ENDPOINT_DESCRIPTOR;

#if _MSC_VER >= 1200
#pragma warning(push)
#endif
#pragma warning (disable:4201)
#pragma warning(disable:4214) // named type definition in parentheses


//! A structure representing additional information about super speed (or higher) endpoints.
/*
*
* This descriptor is documented in the USB 3.0 specification.
* All multiple-byte fields are represented in host-endian format.
*
*/
typedef struct _USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR 
{
	//! Size of this descriptor (in bytes)
	UCHAR  bLength;
	
	//! Descriptor type
	UCHAR  bDescriptorType;

	//! Specifies the maximum number of packets that the endpoint can send or receive as a part of a burst.
	UCHAR  bMaxBurst;
	
	union
	{
		UCHAR AsUchar;
		struct
		{

			//! Specifies the maximum number of streams supported by the bulk endpoint.
			UCHAR MaxStreams : 5;
			
			UCHAR Reserved1 : 3;
		} Bulk;
		struct
		{

			//! Specifies a zero-based number that determines the maximum number of packets (bMaxBurst * (Mult + 1)) that can be sent to the endpoint within a service interval.
			UCHAR Mult : 2;
			
			UCHAR Reserved2 : 5;
			
			UCHAR SspCompanion : 1;
		} Isochronous;
	} bmAttributes;

	//! Number of bytes per interval
	USHORT wBytesPerInterval;
} USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR, *PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR;

/*! \addtogroup usb_bos_desc
* @{
*/

//! BOS device capability descriptor
/*
 * This is a variable length descriptor.  The length of the \b CapabilityData is determined using the \b bLength member.
 * 
 */
typedef struct _BOS_DEV_CAPABILITY_DESCRIPTOR
{
	//! Size of this descriptor (in bytes)
	UCHAR  bLength;

	//! Descriptor type
	UCHAR  bDescriptorType;

	//! Capability type
	UCHAR  bDevCapabilityType;

	//! Capability Data
	UCHAR  CapabilityData[0];
}BOS_DEV_CAPABILITY_DESCRIPTOR, *PBOS_DEV_CAPABILITY_DESCRIPTOR;

//! USB BOS capability types
typedef enum _BOS_CAPABILITY_TYPE
{
	//! Wireless USB device capability. 
	BOS_CAPABILITY_TYPE_WIRELESS_USB_DEVICE_CAPABILITY = 0x01,

	//! USB 2.0 extensions. 
	BOS_CAPABILITY_TYPE_USB_2_0_EXTENSION = 0x02,

	//! SuperSpeed USB device capability. 
	BOS_CAPABILITY_TYPE_SS_USB_DEVICE_CAPABILITY = 0x03,

	//! Container ID type. 
	BOS_CAPABILITY_TYPE_CONTAINER_ID = 0x04,

	//! Platform specific capability.
	BOS_CAPABILITY_TYPE_PLATFORM = 0x05,

	//! Defines the various PD Capabilities of this device.
	BOS_POWER_DELIVERY_CAPABILITY = 0x06,

	//! Provides information on each battery supported by the device.
	BOS_BATTERY_INFO_CAPABILITY = 0x07,

	//! The consumer characteristics of a port on the device.
	BOS_PD_CONSUMER_PORT_CAPABILITY = 0x08,

	//! The provider characteristics of a port on the device.
	BOS_PD_PROVIDER_PORT_CAPABILITY = 0x09,

	//! Defines the set of SuperSpeed Plus USB specific device level capabilities.
	BOS_SUPERSPEED_PLUS = 0x0A,

	//! Precision Time Measurement (PTM) Capability Descriptor.
	BOS_PRECISION_TIME_MEASUREMENT = 0x0B,

	//! Defines the set of Wireless USB 1.1-specific device level capabilities.
	BOS_WIRELESS_USB_EXT = 0x0C,

	//! Billboard capability.
	BOS_BILLBOARD = 0x0D,

	//! Authentication Capability Descriptor.
	BOS_AUTHENTICATION = 0x0E,

	//! Billboard Ex capability.
	BOS_BILLBOARD_EX = 0x0F,

	//! Summarizes configuration information for a function implemented by the device.
	BOS_CONFIGURATION_SUMMARY = 0x10,
}BOS_CAPABILITY_TYPE;

//!  USB 3.0 and USB 2.0 LPM Binary Device Object Store (BOS).
/*
 * The BOS descriptor returns a set of device - level capability descriptors for the USB device.
 *
 * This descriptor is followed by and array of /ref BOS_DEV_CAPABILITY_DESCRIPTOR descriptors.
 * The number of elements in this array is specified by /b bNumDeviceCaps.
 */
typedef struct _BOS_DESCRIPTOR
{
	//! Size of this descriptor (in bytes)
	UCHAR  bLength;

	//! Descriptor type
	UCHAR  bDescriptorType;
	
	//! Length of this descriptor and all sub descriptors
	USHORT wTotalLength;

	//! Number of device capability descriptors
	UCHAR bNumDeviceCaps;

	UCHAR DevCapabilityDescriptors[0];
	
}BOS_DESCRIPTOR, *PBOS_DESCRIPTOR;

//! USB 2.0 Extension descriptor
typedef struct _BOS_USB_2_0_EXTENSION_DESCRIPTOR
{
	//! Size of this descriptor (in bytes)
	UCHAR  bLength;

	//! Descriptor type
	UCHAR  bDescriptorType;

	//! Capability type. See \ref BOS_CAPABILITY_TYPE
	UCHAR  bDevCapabilityType;

	//! Bitmap encoding of supported device level features.
	UINT bmAttributes;
	
}BOS_USB_2_0_EXTENSION_DESCRIPTOR, *PBOS_USB_2_0_EXTENSION_DESCRIPTOR;

//! SuperSpeed Device Capability Descriptor
typedef struct _BOS_SS_USB_DEVICE_CAPABILITY_DESCRIPTOR
{
	//! Size of this descriptor (in bytes)
	UCHAR  bLength;

	//! Descriptor type
	UCHAR  bDescriptorType;

	//! Capability type. See \ref BOS_CAPABILITY_TYPE
	UCHAR  bDevCapabilityType;

	//! Bitmap encoding of supported device level features.
	UCHAR  bmAttributes;

	//! Bitmap encoding of the supported speeds. 
	USHORT wSpeedSupported;

	//! The lowest speed at which all the functionality	supported by the device is available to the user
	UCHAR  bFunctionalitySupport;
	
	//! U1 Device Exit Latency. Worst-case latency to transition from U1 to U0.
	UCHAR  bU1DevExitLat;

	//! U2 Device Exit Latency. Worst-case latency to transition from U2 to U0.
	USHORT bU2DevExitLat;
	
}BOS_SS_USB_DEVICE_CAPABILITY_DESCRIPTOR, *PBOS_SS_USB_DEVICE_CAPABILITY_DESCRIPTOR;

//! Container ID Descriptor
typedef struct _BOS_CONTAINER_ID_DESCRIPTOR
{
	//! Size of this descriptor (in bytes)
	UCHAR  bLength;

	//! Descriptor type
	UCHAR  bDescriptorType;

	//! Capability type. See \ref BOS_CAPABILITY_TYPE
	UCHAR  bDevCapabilityType;

	// Reserved.
	UCHAR  bReserved;

	//! This is a 128-bit number that is used to uniquely identify the device instance across all modes of operation.
	UCHAR  ContainerID[16];
	
}BOS_CONTAINER_ID_DESCRIPTOR, *PBOS_CONTAINER_ID_DESCRIPTOR;

//! Platform specific capabilities
typedef struct _BOS_PLATFORM_DESCRIPTOR
{
	//! Size of this descriptor (in bytes)
	UCHAR  bLength;

	//! Descriptor type
	UCHAR  bDescriptorType;

	// Capability type. See \ref BOS_CAPABILITY_TYPE
	UCHAR  bDevCapabilityType;

	//! Reserved
	UCHAR  bReserved;

	//! A 128-bit number that uniquely identifies a platform-specific capability of the device.
	/*
	 * For Windows OS 2.0 descriptor support, this is "D8DD60DF-4589-4CC7-9CD2-659D9E648A9F" (dashes not included in actual data)
	 */
	UCHAR  PlatformCapabilityUUID[16];
	
	//! Capability Data
	UCHAR CapabilityData[0];
}BOS_PLATFORM_DESCRIPTOR, * PBOS_PLATFORM_DESCRIPTOR;

//! This structure represents the windows version records that follow a BOS windows platform descriptor.
typedef struct _BOS_WINDOWS_PLATFORM_VERSION
{
	//! Minimum version of Windows
/*
 * The Windows version indicates the minimum version of Windows that the descriptor set can be applied to.The DWORD value
 * corresponds to the published NTDDI version constants in SDKDDKVER.H
 *
 */
	UINT dwWindowsVersion;

	//! The length, in bytes of the MS OS 2.0 descriptor set.
	USHORT wMSOSDescriptorSetTotalLength;

	//! Vendor defined code.
	/*
	 * Vendor defined code to use to retrieve this version of the MS OS 2.0 descriptor and also to set alternate enumeration
	 * behavior on the device.
	 */
	UCHAR bMS_VendorCode;

	//! Alternate enumeration indicator.
	/*
	 * A non-zero value to send to the device to indicate that the device may return non-default USB descriptors for
	 * enumeration.  If the device does not support alternate enumeration, this value shall be 0.
	 */
	UCHAR bAltEnumCode;

}BOS_WINDOWS_PLATFORM_VERSION, *PBOS_WINDOWS_PLATFORM_VERSION;
/*! @} */

/*! \addtogroup msosv1_desc
* @{
*/

//! Special Microsoft string descriptor used to indicate that a device supports Microsoft OS V1.0 descriptors.
typedef struct _USB_MSOSV1_STRING_DESCRIPTOR
{
	//! Size of this descriptor. Shall always be 18 bytes
	UCHAR bLength;

	//! Descriptor type (0x03)
	UCHAR bDescriptorType;

	//! Microsoft signature. Shall always be "MSFT100"
	UCHAR qwSignature[14];

	//! Vendor specific vendor code
	UCHAR bMS_VendorCode;

	//! Padding
	UCHAR bPad;
}USB_MSOSV1_STRING_DESCRIPTOR, *PUSB_MSOSV1_STRING_DESCRIPTOR;

//! Microsoft feature descriptor types.
/*
 * When requesting Microsoft OS feature descriptors, these values are used in the \b wIndex of the control packet
 * to indicate the feature descriptor that is being requested.
 */
typedef enum _MSOS_FEATURE_TYPE
{
	//! Microsoft OS V1.0 compatible IDs descriptor
	MSOS_FEATURE_TYPE_V1_EXTENDED_COMPAT_ID = 0x0004,

	//! Microsoft OS V1.0 extended properties descriptor
	MSOS_FEATURE_TYPE_V1_EXTENDED_PROPS = 0x0005,

	//! Microsoft OS V2.0 descriptor set
	MSOS_FEATURE_TYPE_V2_DESCRIPTOR_SET = 0x0007,
}MSOS_FEATURE_TYPE;

// !The extended compat ID OS descriptor has two components:
/*
*
* - A fixed-length header section, which contains information about the entire descriptor including the version number,
*   the number of function sections, and the descriptor�s total length.
* - One or more fixed-length function sections, which follow the header section. Each function section contains the
*   data for the device, or a single interface, function, or single-function group of interfaces. It is not necessary
*   to define IDs for every function or interface, but each of them must still have an associated function section.
*
*/
typedef struct _MSOSV1_EXTENDED_COMPAT_ID_DESCRIPTOR
{
	//! The length, in bytes, of the complete extended compat ID descriptor
	UINT dwLength;

	//! The descriptor�s version number, in binary coded decimal (BCD) format
	USHORT bcdVersion;

	//! An index that identifies the particular OS feature descriptor
	USHORT wIndex;
	
	//! The number of custom property sections
	UCHAR bCount;
	
	//! Reserved
	UCHAR Rsvd[7];
	
}MSOSV1_EXTENDED_COMPAT_ID_DESCRIPTOR, *PMSOSV1_EXTENDED_COMPAT_ID_DESCRIPTOR;

//! A function section defines the compatible ID and a subcompatible ID for a specified interface or function. 
typedef struct _MSOSV1_FUNCTION_DESCRIPTOR
{
	//! The interface or function number
	/*
	 * This field specifies the interface or function that is associated with the IDs in this section. To use this
	 * function section to associate a single-function group of interfaces with a single pair of IDs, set
	 * bFirstInterfaceNumber to the first interface in the group. Then use an IAD in that interface�s interface
	 * descriptor to specify which additional interfaces should be included in the group. The interfaces in the
	 * group must be consecutively numbered. For details, see �Support for USB Interface Association Descriptor
	 * 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__