-
Notifications
You must be signed in to change notification settings - Fork 36
/
libusbK.cs
4530 lines (3446 loc) · 199 KB
/
libusbK.cs
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
#region Copyright (c) Travis Robinson
// Copyright (c) 2011-2021 Travis Robinson <libusbdotnet@gmail.com>
// All rights reserved.
//
// C# libusbK Bindings
// Auto-generated on: 07.08.2021
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL TRAVIS LEE ROBINSON
// BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
// THE POSSIBILITY OF SUCH DAMAGE.
#endregion
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
// ReSharper disable InconsistentNaming
// ReSharper disable CheckNamespace
// ReSharper disable UnassignedReadonlyField
namespace libusbK
{
public static class AllKOptions
{
/// <summary>
/// Alternate libusbK library to use. This must be assigned before any libusbK functions are called and it must be the
/// full path and file name to a libusbK.dll.
/// </summary>
public static string LIBUSBK_FULLPATH_TO_ALTERNATE_DLL;
}
public static class AllKConstants
{
/// <summary>
/// Allocated length for all strings in a \ref KLST_DEVINFO structure.
/// </summary>
public const int KLST_STRING_MAX_LEN = 256;
/// <summary>
/// libusbK library
/// </summary>
public const string LIBUSBK_DLL = "libusbK.dll";
/// <summary>
/// Config power mask for the \c bmAttributes field of a \ref USB_CONFIGURATION_DESCRIPTOR
/// </summary>
public const byte USB_CONFIG_POWERED_MASK = 0xC0;
/// <summary>
/// Endpoint direction mask for the \c bEndpointAddress field of a \ref USB_ENDPOINT_DESCRIPTOR
/// </summary>
public const byte USB_ENDPOINT_DIRECTION_MASK = 0x80;
/// <summary>
/// Endpoint address mask for the \c bEndpointAddress field of a \ref USB_ENDPOINT_DESCRIPTOR
/// </summary>
public const byte USB_ENDPOINT_ADDRESS_MASK = 0x0F;
}
public enum PipePolicyType
{
SHORT_PACKET_TERMINATE = 0x01,
AUTO_CLEAR_STALL = 0x02,
PIPE_TRANSFER_TIMEOUT = 0x03,
IGNORE_SHORT_PACKETS = 0x04,
ALLOW_PARTIAL_READS = 0x05,
AUTO_FLUSH = 0x06,
RAW_IO = 0x07,
MAXIMUM_TRANSFER_SIZE = 0x08,
RESET_PIPE_ON_RESUME = 0x09,
ISO_START_LATENCY = 0x20,
ISO_ALWAYS_START_ASAP = 0x21,
ISO_NUM_FIXED_PACKETS = 0x22,
SIMUL_PARALLEL_REQUESTS = 0x30,
}
public enum PowerPolicyType
{
AUTO_SUSPEND = 0x81,
SUSPEND_DELAY = 0x83,
}
public enum DeviceInformationType
{
DEVICE_SPEED = 0x01,
}
public enum EndpointType
{
/// <summary>
/// Indicates a control endpoint
/// </summary>
CONTROL = 0x00,
/// <summary>
/// Indicates an isochronous endpoint
/// </summary>
ISOCHRONOUS = 0x01,
/// <summary>
/// Indicates a bulk endpoint
/// </summary>
BULK = 0x02,
/// <summary>
/// Indicates an interrupt endpoint
/// </summary>
INTERRUPT = 0x03,
/// <summary>
/// Endpoint type mask for the \c bmAttributes field of a \ref USB_ENDPOINT_DESCRIPTOR
/// </summary>
MASK = 0x03,
}
public static class ErrorCodes
{
/// <summary>
/// The operation completed successfully.
/// </summary>
public const int Success = 0;
/// <summary>
/// Access is denied.
/// </summary>
public const int AccessDenied = 5;
/// <summary>
/// The handle is invalid.
/// </summary>
public const int InvalidHandle = 6;
/// <summary>
/// Not enough storage is available to process this command.
/// </summary>
public const int NotEnoughMemory = 8;
/// <summary>
/// The request is not supported.
/// </summary>
public const int NotSupported = 50;
/// <summary>
/// The parameter is incorrect.
/// </summary>
public const int InvalidParameter = 87;
/// <summary>
/// The semaphore timeout period has expired.
/// </summary>
public const int SemTimeout = 121;
/// <summary>
/// The requested resource is in use.
/// </summary>
public const int Busy = 170;
/// <summary>
/// Too many dynamic-link modules are attached to this program or dynamic-link module.
/// </summary>
public const int TooManyModules = 214;
/// <summary>
/// More data is available.
/// </summary>
public const int MoreData = 234;
/// <summary>
/// No more data is available.
/// </summary>
public const int NoMoreItems = 259;
/// <summary>
/// An attempt was made to operate on a thread within a specific process, but the thread specified is not in the
/// process specified.
/// </summary>
public const int ThreadNotInProcess = 566;
/// <summary>
/// A thread termination occurred while the thread was suspended. The thread was resumed, and termination proceeded.
/// </summary>
public const int ThreadWasSuspended = 699;
/// <summary>
/// The I/O operation has been aborted because of either a thread exit or an application request.
/// </summary>
public const int OperationAborted = 995;
/// <summary>
/// Overlapped I/O event is not in a signaled state.
/// </summary>
public const int IoIncomplete = 996;
/// <summary>
/// Overlapped I/O operation is in progress.
/// </summary>
public const int IoPending = 997;
/// <summary>
/// Element not found.
/// </summary>
public const int NotFound = 1168;
/// <summary>
/// The operation was canceled by the user.
/// </summary>
public const int Cancelled = 1223;
/// <summary>
/// The library, drive, or media pool is empty.
/// </summary>
public const int Empty = 4306;
/// <summary>
/// The cluster resource is not available.
/// </summary>
public const int ResourceNotAvailable = 5006;
/// <summary>
/// The cluster resource could not be found.
/// </summary>
public const int ResourceNotFound = 5007;
}
public interface IKLIB_HANDLE
{
KLIB_HANDLE_TYPE HandleType { get; }
IntPtr Pointer { get; }
IntPtr GetContext();
bool SetContext(IntPtr UserContext);
bool SetCleanupCallback(KLIB_HANDLE_CLEANUP_CB CleanupCallback);
}
/// <Summary>
/// A structure representing additional information about super speed (or higher) endpoints.
/// </Summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct USB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR
{
/// <Summary>Size of this descriptor (in bytes)</Summary>
public byte bLength;
/// <Summary>Descriptor type</Summary>
public byte bDescriptorType;
/// <Summary>Specifies the maximum number of packets that the endpoint can send or receive as a part of a burst.</Summary>
public byte bMaxBurst;
public byte AsUchar;
/// <Summary>Number of bytes per interval</Summary>
public ushort wBytesPerInterval;
/// <Summary>Specifies the maximum number of streams supported by the bulk endpoint.</Summary>
public byte BulkMaxStreams
{
get { return (byte) (AsUchar & 0x1F); }
}
/// <Summary>
/// 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.
/// </Summary>
public byte IsoMult
{
get { return (byte) (AsUchar & 0x3); }
}
public byte SspCompanion
{
get { return (byte) (AsUchar >> 7); }
}
}
#region Opaque library handles
public struct KLST_HANDLE : IKLIB_HANDLE
{
private readonly IntPtr mHandlePtr;
public KLST_HANDLE(IntPtr Handle)
{
mHandlePtr = Handle;
}
public IntPtr Pointer
{
get { return mHandlePtr; }
}
public KLIB_HANDLE_TYPE HandleType
{
get { return KLIB_HANDLE_TYPE.LSTK; }
}
public IntPtr GetContext()
{
return AllKFunctions.LibK_GetContext(mHandlePtr, HandleType);
}
public bool SetContext(IntPtr UserContext)
{
return AllKFunctions.LibK_SetContext(mHandlePtr, HandleType, UserContext);
}
public bool SetCleanupCallback(KLIB_HANDLE_CLEANUP_CB CleanupCallback)
{
return AllKFunctions.LibK_SetCleanupCallback(mHandlePtr, HandleType, CleanupCallback);
}
}
public struct KHOT_HANDLE : IKLIB_HANDLE
{
private readonly IntPtr mHandlePtr;
public KHOT_HANDLE(IntPtr Handle)
{
mHandlePtr = Handle;
}
public IntPtr Pointer
{
get { return mHandlePtr; }
}
public KLIB_HANDLE_TYPE HandleType
{
get { return KLIB_HANDLE_TYPE.HOTK; }
}
public IntPtr GetContext()
{
return AllKFunctions.LibK_GetContext(mHandlePtr, HandleType);
}
public bool SetContext(IntPtr UserContext)
{
return AllKFunctions.LibK_SetContext(mHandlePtr, HandleType, UserContext);
}
public bool SetCleanupCallback(KLIB_HANDLE_CLEANUP_CB CleanupCallback)
{
return AllKFunctions.LibK_SetCleanupCallback(mHandlePtr, HandleType, CleanupCallback);
}
}
public struct KUSB_HANDLE : IKLIB_HANDLE
{
private readonly IntPtr mHandlePtr;
public KUSB_HANDLE(IntPtr Handle)
{
mHandlePtr = Handle;
}
public IntPtr Pointer
{
get { return mHandlePtr; }
}
public KLIB_HANDLE_TYPE HandleType
{
get { return KLIB_HANDLE_TYPE.USBK; }
}
public IntPtr GetContext()
{
return AllKFunctions.LibK_GetContext(mHandlePtr, HandleType);
}
public bool SetContext(IntPtr UserContext)
{
return AllKFunctions.LibK_SetContext(mHandlePtr, HandleType, UserContext);
}
public bool SetCleanupCallback(KLIB_HANDLE_CLEANUP_CB CleanupCallback)
{
return AllKFunctions.LibK_SetCleanupCallback(mHandlePtr, HandleType, CleanupCallback);
}
#region USB Shared Device Context
public IntPtr GetSharedContext()
{
return AllKFunctions.LibK_GetContext(mHandlePtr, KLIB_HANDLE_TYPE.USBSHAREDK);
}
public bool SetSharedContext(IntPtr UserContext)
{
return AllKFunctions.LibK_SetContext(mHandlePtr, KLIB_HANDLE_TYPE.USBSHAREDK, UserContext);
}
public bool SetSharedCleanupCallback(KLIB_HANDLE_CLEANUP_CB CleanupCallback)
{
return AllKFunctions.LibK_SetCleanupCallback(mHandlePtr, KLIB_HANDLE_TYPE.USBSHAREDK, CleanupCallback);
}
#endregion
}
public struct KOVL_POOL_HANDLE : IKLIB_HANDLE
{
private readonly IntPtr mHandlePtr;
public KOVL_POOL_HANDLE(IntPtr Handle)
{
mHandlePtr = Handle;
}
public IntPtr Pointer
{
get { return mHandlePtr; }
}
public KLIB_HANDLE_TYPE HandleType
{
get { return KLIB_HANDLE_TYPE.OVLPOOLK; }
}
public IntPtr GetContext()
{
return AllKFunctions.LibK_GetContext(mHandlePtr, HandleType);
}
public bool SetContext(IntPtr UserContext)
{
return AllKFunctions.LibK_SetContext(mHandlePtr, HandleType, UserContext);
}
public bool SetCleanupCallback(KLIB_HANDLE_CLEANUP_CB CleanupCallback)
{
return AllKFunctions.LibK_SetCleanupCallback(mHandlePtr, HandleType, CleanupCallback);
}
}
public struct KOVL_HANDLE : IKLIB_HANDLE
{
private readonly IntPtr mHandlePtr;
public KOVL_HANDLE(IntPtr Handle)
{
mHandlePtr = Handle;
}
public IntPtr Pointer
{
get { return mHandlePtr; }
}
public KLIB_HANDLE_TYPE HandleType
{
get { return KLIB_HANDLE_TYPE.OVLK; }
}
public IntPtr GetContext()
{
return AllKFunctions.LibK_GetContext(mHandlePtr, HandleType);
}
public bool SetContext(IntPtr UserContext)
{
return AllKFunctions.LibK_SetContext(mHandlePtr, HandleType, UserContext);
}
public bool SetCleanupCallback(KLIB_HANDLE_CLEANUP_CB CleanupCallback)
{
return AllKFunctions.LibK_SetCleanupCallback(mHandlePtr, HandleType, CleanupCallback);
}
}
public struct KSTM_HANDLE : IKLIB_HANDLE
{
private readonly IntPtr mHandlePtr;
public KSTM_HANDLE(IntPtr Handle)
{
mHandlePtr = Handle;
}
public IntPtr Pointer
{
get { return mHandlePtr; }
}
public KLIB_HANDLE_TYPE HandleType
{
get { return KLIB_HANDLE_TYPE.STMK; }
}
public IntPtr GetContext()
{
return AllKFunctions.LibK_GetContext(mHandlePtr, HandleType);
}
public bool SetContext(IntPtr UserContext)
{
return AllKFunctions.LibK_SetContext(mHandlePtr, HandleType, UserContext);
}
public bool SetCleanupCallback(KLIB_HANDLE_CLEANUP_CB CleanupCallback)
{
return AllKFunctions.LibK_SetCleanupCallback(mHandlePtr, HandleType, CleanupCallback);
}
}
public struct KISOCH_HANDLE : IKLIB_HANDLE
{
private readonly IntPtr mHandlePtr;
public KISOCH_HANDLE(IntPtr Handle)
{
mHandlePtr = Handle;
}
public IntPtr Pointer
{
get { return mHandlePtr; }
}
public KLIB_HANDLE_TYPE HandleType
{
get { return KLIB_HANDLE_TYPE.ISOCHK; }
}
public IntPtr GetContext()
{
return AllKFunctions.LibK_GetContext(mHandlePtr, HandleType);
}
public bool SetContext(IntPtr UserContext)
{
return AllKFunctions.LibK_SetContext(mHandlePtr, HandleType, UserContext);
}
public bool SetCleanupCallback(KLIB_HANDLE_CLEANUP_CB CleanupCallback)
{
return AllKFunctions.LibK_SetCleanupCallback(mHandlePtr, HandleType, CleanupCallback);
}
}
#endregion
#region Internal Function Imports
internal static class AllKFunctions
{
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate void HotK_FreeAllDelegate();
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool HotK_FreeDelegate([In] KHOT_HANDLE Handle);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool HotK_InitDelegate([Out] out KHOT_HANDLE Handle, [In] [Out] ref KHOT_PARAMS InitParams);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool IsochK_CalcPacketInformationDelegate(bool IsHighSpeed, [In] ref WINUSB_PIPE_INFORMATION_EX PipeInformationEx, [Out] out KISOCH_PACKET_INFORMATION PacketInformation);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool IsochK_EnumPacketsDelegate([In] KISOCH_HANDLE IsochHandle, KISOCH_ENUM_PACKETS_CB EnumPackets, uint StartPacketIndex, IntPtr UserState);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool IsochK_FreeDelegate([In] KISOCH_HANDLE IsochHandle);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool IsochK_GetNumberOfPacketsDelegate([In] KISOCH_HANDLE IsochHandle, out uint NumberOfPackets);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool IsochK_GetPacketDelegate([In] KISOCH_HANDLE IsochHandle, uint PacketIndex, out uint Offset, out uint Length, out uint Status);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool IsochK_InitDelegate([Out] out KISOCH_HANDLE IsochHandle, [In] KUSB_HANDLE InterfaceHandle, byte PipeId, uint MaxNumberOfPackets, IntPtr TransferBuffer, uint TransferBufferSize);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool IsochK_SetNumberOfPacketsDelegate([In] KISOCH_HANDLE IsochHandle, uint NumberOfPackets);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool IsochK_SetPacketDelegate([In] KISOCH_HANDLE IsochHandle, uint PacketIndex, uint Offset, uint Length, uint Status);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool IsochK_SetPacketOffsetsDelegate([In] KISOCH_HANDLE IsochHandle, uint PacketSize);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool IsoK_EnumPacketsDelegate([In] KISO_CONTEXT IsoContext, KISO_ENUM_PACKETS_CB EnumPackets, int StartPacketIndex, IntPtr UserState);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool IsoK_FreeDelegate([In] KISO_CONTEXT IsoContext);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool IsoK_GetPacketDelegate([In] KISO_CONTEXT IsoContext, int PacketIndex, [Out] out KISO_PACKET IsoPacket);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool IsoK_InitDelegate([Out] out KISO_CONTEXT IsoContext, int NumberOfPackets, int StartFrame);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool IsoK_ReUseDelegate([In] KISO_CONTEXT IsoContext);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool IsoK_SetPacketDelegate([In] KISO_CONTEXT IsoContext, int PacketIndex, [In] ref KISO_PACKET IsoPacket);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool IsoK_SetPacketsDelegate([In] KISO_CONTEXT IsoContext, int PacketSize);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate void LibK_Context_FreeDelegate();
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool LibK_Context_InitDelegate(IntPtr Heap, IntPtr Reserved);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool LibK_CopyDriverAPIDelegate([Out] out KUSB_DRIVER_API DriverAPI, [In] KUSB_HANDLE UsbHandle);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate IntPtr LibK_GetContextDelegate([In] IntPtr Handle, KLIB_HANDLE_TYPE HandleType);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate IntPtr LibK_GetDefaultContextDelegate(KLIB_HANDLE_TYPE HandleType);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool LibK_GetProcAddressDelegate(IntPtr ProcAddress, int DriverID, int FunctionID);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate void LibK_GetVersionDelegate([Out] out KLIB_VERSION Version);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool LibK_IsFunctionSupportedDelegate([In] ref KUSB_DRIVER_API DriverAPI, uint FunctionID);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool LibK_LoadDriverAPIDelegate([Out] out KUSB_DRIVER_API DriverAPI, int DriverID);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool LibK_SetCleanupCallbackDelegate([In] IntPtr Handle, KLIB_HANDLE_TYPE HandleType, KLIB_HANDLE_CLEANUP_CB CleanupCB);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool LibK_SetContextDelegate([In] IntPtr Handle, KLIB_HANDLE_TYPE HandleType, IntPtr ContextValue);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool LibK_SetDefaultContextDelegate(KLIB_HANDLE_TYPE HandleType, IntPtr ContextValue);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool LstK_CountDelegate([In] KLST_HANDLE DeviceList, ref uint Count);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool LstK_CurrentDelegate([In] KLST_HANDLE DeviceList, [Out] out KLST_DEVINFO_HANDLE DeviceInfo);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool LstK_EnumerateDelegate([In] KLST_HANDLE DeviceList, KLST_ENUM_DEVINFO_CB EnumDevListCB, IntPtr Context);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool LstK_FindByVidPidDelegate([In] KLST_HANDLE DeviceList, int Vid, int Pid, [Out] out KLST_DEVINFO_HANDLE DeviceInfo);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool LstK_FreeDelegate([In] KLST_HANDLE DeviceList);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool LstK_InitDelegate([Out] out KLST_HANDLE DeviceList, KLST_FLAG Flags);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool LstK_InitExDelegate([Out] out KLST_HANDLE DeviceList, KLST_FLAG Flags, [In] ref KLST_PATTERN_MATCH PatternMatch);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool LstK_MoveNextDelegate([In] KLST_HANDLE DeviceList, [Out] out KLST_DEVINFO_HANDLE DeviceInfo);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate void LstK_MoveResetDelegate([In] KLST_HANDLE DeviceList);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool LUsb0_ControlTransferDelegate([In] KUSB_HANDLE InterfaceHandle, WINUSB_SETUP_PACKET SetupPacket, IntPtr Buffer, uint BufferLength, out uint LengthTransferred, IntPtr Overlapped);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool LUsb0_SetConfigurationDelegate([In] KUSB_HANDLE InterfaceHandle, byte ConfigurationNumber);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool OvlK_AcquireDelegate([Out] out KOVL_HANDLE OverlappedK, [In] KOVL_POOL_HANDLE PoolHandle);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool OvlK_FreeDelegate([In] KOVL_POOL_HANDLE PoolHandle);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate IntPtr OvlK_GetEventHandleDelegate([In] KOVL_HANDLE OverlappedK);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool OvlK_InitDelegate([Out] out KOVL_POOL_HANDLE PoolHandle, [In] KUSB_HANDLE UsbHandle, int MaxOverlappedCount, KOVL_POOL_FLAG Flags);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool OvlK_IsCompleteDelegate([In] KOVL_HANDLE OverlappedK);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool OvlK_ReleaseDelegate([In] KOVL_HANDLE OverlappedK);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool OvlK_ReUseDelegate([In] KOVL_HANDLE OverlappedK);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool OvlK_WaitAndReleaseDelegate([In] KOVL_HANDLE OverlappedK, int TimeoutMS, out uint TransferredLength);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool OvlK_WaitDelegate([In] KOVL_HANDLE OverlappedK, int TimeoutMS, KOVL_WAIT_FLAG WaitFlags, out uint TransferredLength);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool OvlK_WaitOldestDelegate([In] KOVL_POOL_HANDLE PoolHandle, [Out] out KOVL_HANDLE OverlappedK, int TimeoutMS, KOVL_WAIT_FLAG WaitFlags, out uint TransferredLength);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool OvlK_WaitOrCancelDelegate([In] KOVL_HANDLE OverlappedK, int TimeoutMS, out uint TransferredLength);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool StmK_FreeDelegate([In] KSTM_HANDLE StreamHandle);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool StmK_InitDelegate([Out] out KSTM_HANDLE StreamHandle, [In] KUSB_HANDLE UsbHandle, byte PipeID, int MaxTransferSize, int MaxPendingTransfers, int MaxPendingIO, [In] ref KSTM_CALLBACK Callbacks, KSTM_FLAG Flags);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool StmK_ReadDelegate([In] KSTM_HANDLE StreamHandle, IntPtr Buffer, int Offset, int Length, out uint TransferredLength);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool StmK_StartDelegate([In] KSTM_HANDLE StreamHandle);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool StmK_StopDelegate([In] KSTM_HANDLE StreamHandle, int TimeoutCancelMS);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool StmK_WriteDelegate([In] KSTM_HANDLE StreamHandle, IntPtr Buffer, int Offset, int Length, out uint TransferredLength);
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
public delegate bool UsbK_FreeDelegate([In] KUSB_HANDLE InterfaceHandle);
private static readonly IntPtr mModuleLibusbK = IntPtr.Zero;
public static LibK_GetVersionDelegate LibK_GetVersion;
public static LibK_GetContextDelegate LibK_GetContext;
public static LibK_SetContextDelegate LibK_SetContext;
public static LibK_SetCleanupCallbackDelegate LibK_SetCleanupCallback;
public static LibK_LoadDriverAPIDelegate LibK_LoadDriverAPI;
public static LibK_IsFunctionSupportedDelegate LibK_IsFunctionSupported;
public static LibK_CopyDriverAPIDelegate LibK_CopyDriverAPI;
public static LibK_GetProcAddressDelegate LibK_GetProcAddress;
public static LibK_SetDefaultContextDelegate LibK_SetDefaultContext;
public static LibK_GetDefaultContextDelegate LibK_GetDefaultContext;
public static LibK_Context_InitDelegate LibK_Context_Init;
public static LibK_Context_FreeDelegate LibK_Context_Free;
public static UsbK_FreeDelegate UsbK_Free;
public static LstK_InitDelegate LstK_Init;
public static LstK_InitExDelegate LstK_InitEx;
public static LstK_FreeDelegate LstK_Free;
public static LstK_EnumerateDelegate LstK_Enumerate;
public static LstK_CurrentDelegate LstK_Current;
public static LstK_MoveNextDelegate LstK_MoveNext;
public static LstK_MoveResetDelegate LstK_MoveReset;
public static LstK_FindByVidPidDelegate LstK_FindByVidPid;
public static LstK_CountDelegate LstK_Count;
public static HotK_InitDelegate HotK_Init;
public static HotK_FreeDelegate HotK_Free;
public static HotK_FreeAllDelegate HotK_FreeAll;
public static OvlK_AcquireDelegate OvlK_Acquire;
public static OvlK_ReleaseDelegate OvlK_Release;
public static OvlK_InitDelegate OvlK_Init;
public static OvlK_FreeDelegate OvlK_Free;
public static OvlK_GetEventHandleDelegate OvlK_GetEventHandle;
public static OvlK_WaitDelegate OvlK_Wait;
public static OvlK_WaitOldestDelegate OvlK_WaitOldest;
public static OvlK_WaitOrCancelDelegate OvlK_WaitOrCancel;
public static OvlK_WaitAndReleaseDelegate OvlK_WaitAndRelease;
public static OvlK_IsCompleteDelegate OvlK_IsComplete;
public static OvlK_ReUseDelegate OvlK_ReUse;
public static StmK_InitDelegate StmK_Init;
public static StmK_FreeDelegate StmK_Free;
public static StmK_StartDelegate StmK_Start;
public static StmK_StopDelegate StmK_Stop;
public static StmK_ReadDelegate StmK_Read;
public static StmK_WriteDelegate StmK_Write;
public static IsoK_InitDelegate IsoK_Init;
public static IsoK_FreeDelegate IsoK_Free;
public static IsoK_SetPacketsDelegate IsoK_SetPackets;
public static IsoK_SetPacketDelegate IsoK_SetPacket;
public static IsoK_GetPacketDelegate IsoK_GetPacket;
public static IsoK_EnumPacketsDelegate IsoK_EnumPackets;
public static IsoK_ReUseDelegate IsoK_ReUse;
public static IsochK_InitDelegate IsochK_Init;
public static IsochK_FreeDelegate IsochK_Free;
public static IsochK_SetPacketOffsetsDelegate IsochK_SetPacketOffsets;
public static IsochK_SetPacketDelegate IsochK_SetPacket;
public static IsochK_GetPacketDelegate IsochK_GetPacket;
public static IsochK_EnumPacketsDelegate IsochK_EnumPackets;
public static IsochK_CalcPacketInformationDelegate IsochK_CalcPacketInformation;
public static IsochK_GetNumberOfPacketsDelegate IsochK_GetNumberOfPackets;
public static IsochK_SetNumberOfPacketsDelegate IsochK_SetNumberOfPackets;
public static LUsb0_ControlTransferDelegate LUsb0_ControlTransfer;
public static LUsb0_SetConfigurationDelegate LUsb0_SetConfiguration;
static AllKFunctions()
{
if (string.IsNullOrEmpty(AllKOptions.LIBUSBK_FULLPATH_TO_ALTERNATE_DLL))
mModuleLibusbK = LoadLibraryEx(AllKConstants.LIBUSBK_DLL, IntPtr.Zero, LoadLibraryFlags.NONE);
else
mModuleLibusbK = LoadLibraryEx(AllKOptions.LIBUSBK_FULLPATH_TO_ALTERNATE_DLL, IntPtr.Zero, LoadLibraryFlags.LOAD_WITH_ALTERED_SEARCH_PATH);
if (mModuleLibusbK == IntPtr.Zero)
throw new DllNotFoundException("libusbK.dll not found. Please install drivers/applications and retry.");
LoadDynamicFunctions();
}
[DllImport("kernel32.dll")]
private static extern IntPtr LoadLibraryEx(string lpFileName, IntPtr hReservedNull, LoadLibraryFlags dwFlags);
[DllImport("kernel32.dll", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
private static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
private static void LoadDynamicFunctions()
{
LibK_GetVersion = (LibK_GetVersionDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "LibK_GetVersion"), typeof(LibK_GetVersionDelegate));
LibK_GetContext = (LibK_GetContextDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "LibK_GetContext"), typeof(LibK_GetContextDelegate));
LibK_SetContext = (LibK_SetContextDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "LibK_SetContext"), typeof(LibK_SetContextDelegate));
LibK_SetCleanupCallback = (LibK_SetCleanupCallbackDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "LibK_SetCleanupCallback"), typeof(LibK_SetCleanupCallbackDelegate));
LibK_LoadDriverAPI = (LibK_LoadDriverAPIDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "LibK_LoadDriverAPI"), typeof(LibK_LoadDriverAPIDelegate));
LibK_IsFunctionSupported = (LibK_IsFunctionSupportedDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "LibK_IsFunctionSupported"), typeof(LibK_IsFunctionSupportedDelegate));
LibK_CopyDriverAPI = (LibK_CopyDriverAPIDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "LibK_CopyDriverAPI"), typeof(LibK_CopyDriverAPIDelegate));
LibK_GetProcAddress = (LibK_GetProcAddressDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "LibK_GetProcAddress"), typeof(LibK_GetProcAddressDelegate));
LibK_SetDefaultContext = (LibK_SetDefaultContextDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "LibK_SetDefaultContext"), typeof(LibK_SetDefaultContextDelegate));
LibK_GetDefaultContext = (LibK_GetDefaultContextDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "LibK_GetDefaultContext"), typeof(LibK_GetDefaultContextDelegate));
LibK_Context_Init = (LibK_Context_InitDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "LibK_Context_Init"), typeof(LibK_Context_InitDelegate));
LibK_Context_Free = (LibK_Context_FreeDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "LibK_Context_Free"), typeof(LibK_Context_FreeDelegate));
UsbK_Free = (UsbK_FreeDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "UsbK_Free"), typeof(UsbK_FreeDelegate));
LstK_Init = (LstK_InitDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "LstK_Init"), typeof(LstK_InitDelegate));
LstK_InitEx = (LstK_InitExDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "LstK_InitEx"), typeof(LstK_InitExDelegate));
LstK_Free = (LstK_FreeDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "LstK_Free"), typeof(LstK_FreeDelegate));
LstK_Enumerate = (LstK_EnumerateDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "LstK_Enumerate"), typeof(LstK_EnumerateDelegate));
LstK_Current = (LstK_CurrentDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "LstK_Current"), typeof(LstK_CurrentDelegate));
LstK_MoveNext = (LstK_MoveNextDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "LstK_MoveNext"), typeof(LstK_MoveNextDelegate));
LstK_MoveReset = (LstK_MoveResetDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "LstK_MoveReset"), typeof(LstK_MoveResetDelegate));
LstK_FindByVidPid = (LstK_FindByVidPidDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "LstK_FindByVidPid"), typeof(LstK_FindByVidPidDelegate));
LstK_Count = (LstK_CountDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "LstK_Count"), typeof(LstK_CountDelegate));
HotK_Init = (HotK_InitDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "HotK_Init"), typeof(HotK_InitDelegate));
HotK_Free = (HotK_FreeDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "HotK_Free"), typeof(HotK_FreeDelegate));
HotK_FreeAll = (HotK_FreeAllDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "HotK_FreeAll"), typeof(HotK_FreeAllDelegate));
OvlK_Acquire = (OvlK_AcquireDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "OvlK_Acquire"), typeof(OvlK_AcquireDelegate));
OvlK_Release = (OvlK_ReleaseDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "OvlK_Release"), typeof(OvlK_ReleaseDelegate));
OvlK_Init = (OvlK_InitDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "OvlK_Init"), typeof(OvlK_InitDelegate));
OvlK_Free = (OvlK_FreeDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "OvlK_Free"), typeof(OvlK_FreeDelegate));
OvlK_GetEventHandle = (OvlK_GetEventHandleDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "OvlK_GetEventHandle"), typeof(OvlK_GetEventHandleDelegate));
OvlK_Wait = (OvlK_WaitDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "OvlK_Wait"), typeof(OvlK_WaitDelegate));
OvlK_WaitOldest = (OvlK_WaitOldestDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "OvlK_WaitOldest"), typeof(OvlK_WaitOldestDelegate));
OvlK_WaitOrCancel = (OvlK_WaitOrCancelDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "OvlK_WaitOrCancel"), typeof(OvlK_WaitOrCancelDelegate));
OvlK_WaitAndRelease = (OvlK_WaitAndReleaseDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "OvlK_WaitAndRelease"), typeof(OvlK_WaitAndReleaseDelegate));
OvlK_IsComplete = (OvlK_IsCompleteDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "OvlK_IsComplete"), typeof(OvlK_IsCompleteDelegate));
OvlK_ReUse = (OvlK_ReUseDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "OvlK_ReUse"), typeof(OvlK_ReUseDelegate));
StmK_Init = (StmK_InitDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "StmK_Init"), typeof(StmK_InitDelegate));
StmK_Free = (StmK_FreeDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "StmK_Free"), typeof(StmK_FreeDelegate));
StmK_Start = (StmK_StartDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "StmK_Start"), typeof(StmK_StartDelegate));
StmK_Stop = (StmK_StopDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "StmK_Stop"), typeof(StmK_StopDelegate));
StmK_Read = (StmK_ReadDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "StmK_Read"), typeof(StmK_ReadDelegate));
StmK_Write = (StmK_WriteDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "StmK_Write"), typeof(StmK_WriteDelegate));
IsoK_Init = (IsoK_InitDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "IsoK_Init"), typeof(IsoK_InitDelegate));
IsoK_Free = (IsoK_FreeDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "IsoK_Free"), typeof(IsoK_FreeDelegate));
IsoK_SetPackets = (IsoK_SetPacketsDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "IsoK_SetPackets"), typeof(IsoK_SetPacketsDelegate));
IsoK_SetPacket = (IsoK_SetPacketDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "IsoK_SetPacket"), typeof(IsoK_SetPacketDelegate));
IsoK_GetPacket = (IsoK_GetPacketDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "IsoK_GetPacket"), typeof(IsoK_GetPacketDelegate));
IsoK_EnumPackets = (IsoK_EnumPacketsDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "IsoK_EnumPackets"), typeof(IsoK_EnumPacketsDelegate));
IsoK_ReUse = (IsoK_ReUseDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "IsoK_ReUse"), typeof(IsoK_ReUseDelegate));
IsochK_Init = (IsochK_InitDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "IsochK_Init"), typeof(IsochK_InitDelegate));
IsochK_Free = (IsochK_FreeDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "IsochK_Free"), typeof(IsochK_FreeDelegate));
IsochK_SetPacketOffsets = (IsochK_SetPacketOffsetsDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "IsochK_SetPacketOffsets"), typeof(IsochK_SetPacketOffsetsDelegate));
IsochK_SetPacket = (IsochK_SetPacketDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "IsochK_SetPacket"), typeof(IsochK_SetPacketDelegate));
IsochK_GetPacket = (IsochK_GetPacketDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "IsochK_GetPacket"), typeof(IsochK_GetPacketDelegate));
IsochK_EnumPackets = (IsochK_EnumPacketsDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "IsochK_EnumPackets"), typeof(IsochK_EnumPacketsDelegate));
IsochK_CalcPacketInformation = (IsochK_CalcPacketInformationDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "IsochK_CalcPacketInformation"), typeof(IsochK_CalcPacketInformationDelegate));
IsochK_GetNumberOfPackets = (IsochK_GetNumberOfPacketsDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "IsochK_GetNumberOfPackets"), typeof(IsochK_GetNumberOfPacketsDelegate));
IsochK_SetNumberOfPackets = (IsochK_SetNumberOfPacketsDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "IsochK_SetNumberOfPackets"), typeof(IsochK_SetNumberOfPacketsDelegate));
LUsb0_ControlTransfer = (LUsb0_ControlTransferDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "LUsb0_ControlTransfer"), typeof(LUsb0_ControlTransferDelegate));
LUsb0_SetConfiguration = (LUsb0_SetConfigurationDelegate) Marshal.GetDelegateForFunctionPointer(GetProcAddress(mModuleLibusbK, "LUsb0_SetConfiguration"), typeof(LUsb0_SetConfigurationDelegate));
}
[Flags]
enum LoadLibraryFlags
{
NONE = 0,
DONT_RESOLVE_DLL_REFERENCES = 0x00000001,
LOAD_IGNORE_CODE_AUTHZ_LEVEL = 0x00000010,
LOAD_LIBRARY_AS_DATAFILE = 0x00000002,
LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE = 0x00000040,
LOAD_LIBRARY_AS_IMAGE_RESOURCE = 0x00000020,
LOAD_WITH_ALTERED_SEARCH_PATH = 0x00000008
}
}
#endregion
#region Enumerations
/// <Summary>Values used in the \c bmAttributes field of a \ref USB_ENDPOINT_DESCRIPTOR</Summary>
public enum USBD_PIPE_TYPE
{
/// <Summary>Indicates a control endpoint</Summary>
UsbdPipeTypeControl,
/// <Summary>Indicates an isochronous endpoint</Summary>
UsbdPipeTypeIsochronous,
/// <Summary>Indicates a bulk endpoint</Summary>
UsbdPipeTypeBulk,
/// <Summary>Indicates an interrupt endpoint</Summary>
UsbdPipeTypeInterrupt,
}
/// <Summary>Additional ISO transfer flags.</Summary>
[Flags]
public enum KISO_FLAG
{
NONE = 0,
/// <Summary>Do not start the transfer immediately, instead use \ref KISO_CONTEXT::StartFrame.</Summary>
SET_START_FRAME = 0x00000001,
}
/// <Summary>Handle type enumeration.</Summary>
public enum KLIB_HANDLE_TYPE
{
/// <Summary>Hot plug handle. \ref KHOT_HANDLE</Summary>
HOTK,
/// <Summary>USB handle. \ref KUSB_HANDLE</Summary>
USBK,
/// <Summary>Shared USB handle. \ref KUSB_HANDLE</Summary>
USBSHAREDK,
/// <Summary>Device list handle. \ref KLST_HANDLE</Summary>
LSTK,
/// <Summary>Device info handle. \ref KLST_DEVINFO_HANDLE</Summary>
LSTINFOK,
/// <Summary>Overlapped handle. \ref KOVL_HANDLE</Summary>
OVLK,
/// <Summary>Overlapped pool handle. \ref KOVL_POOL_HANDLE</Summary>
OVLPOOLK,
/// <Summary>Pipe stream handle. \ref KSTM_HANDLE</Summary>
STMK,
/// <Summary>Pipe stream handle. \ref KSTM_HANDLE</Summary>
ISOCHK,
/// <Summary>Max handle type count.</Summary>
COUNT
}
/// <Summary>Device list sync flags.</Summary>
[Flags]
public enum KLST_SYNC_FLAG
{
/// <Summary>Cleared/invalid state.</Summary>
NONE = 0,
/// <Summary>Unchanged state,</Summary>
UNCHANGED = 0x0001,
/// <Summary>Added (Arrival) state,</Summary>
ADDED = 0x0002,
/// <Summary>Removed (Unplugged) state,</Summary>
REMOVED = 0x0004,
/// <Summary>Connect changed state.</Summary>
CONNECT_CHANGE = 0x0008,
/// <Summary>All states.</Summary>
MASK = 0x000F,
}
/// <Summary>Device list initialization flags.</Summary>
[Flags]
public enum KLST_FLAG
{
/// <Summary>No flags (or 0)</Summary>
NONE = 0,
/// <Summary>Enable listings for the raw device interface GUID \b only. {A5DCBF10-6530-11D2-901F-00C04FB951ED}</Summary>