usb 2.1.3 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/README.md +19 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/usb/bindings.d.ts +4 -0
- package/dist/usb/device.js +5 -0
- package/dist/usb/device.js.map +1 -1
- package/dist/usb/index.js +7 -16
- package/dist/usb/index.js.map +1 -1
- package/dist/webusb/webusb-device.d.ts +0 -1
- package/dist/webusb/webusb-device.js +149 -243
- package/dist/webusb/webusb-device.js.map +1 -1
- package/libusb/.gitattributes +2 -6
- package/libusb/.private/appveyor_build.sh +22 -0
- package/libusb/.private/bm.sh +1 -1
- package/libusb/.private/ci-build.sh +67 -0
- package/libusb/.private/ci-container-build.sh +70 -0
- package/libusb/.private/post-rewrite.sh +5 -1
- package/libusb/.private/pre-commit.sh +5 -1
- package/libusb/.private/wbs.txt +4 -19
- package/libusb/.travis.yml +32 -23
- package/libusb/AUTHORS +86 -3
- package/libusb/ChangeLog +54 -3
- package/libusb/INSTALL_WIN.txt +22 -44
- package/libusb/Makefile.am +32 -10
- package/libusb/{README.md → README} +2 -2
- package/libusb/README.git +3 -3
- package/libusb/Xcode/common.xcconfig +23 -19
- package/libusb/Xcode/config.h +25 -13
- package/libusb/Xcode/libusb.xcodeproj/project.pbxproj +511 -109
- package/libusb/android/README +90 -54
- package/libusb/android/config.h +23 -43
- package/libusb/android/examples/unrooted_android.c +300 -0
- package/libusb/android/examples/unrooted_android.h +36 -0
- package/libusb/android/jni/Android.mk +1 -1
- package/libusb/android/jni/Application.mk +16 -0
- package/libusb/android/jni/examples.mk +63 -29
- package/libusb/android/jni/libusb.mk +14 -8
- package/libusb/android/jni/tests.mk +13 -24
- package/libusb/appveyor.yml +73 -30
- package/libusb/autogen.sh +5 -3
- package/libusb/bootstrap.sh +6 -2
- package/libusb/configure.ac +314 -227
- package/libusb/doc/Makefile.in +22 -0
- package/libusb/doc/doxygen.cfg.in +460 -223
- package/libusb/examples/Makefile.am +6 -13
- package/libusb/examples/dpfp.c +276 -73
- package/libusb/examples/ezusb.c +18 -8
- package/libusb/examples/ezusb.h +6 -17
- package/libusb/examples/fxload.c +4 -5
- package/libusb/examples/hotplugtest.c +1 -1
- package/libusb/examples/sam3u_benchmark.c +59 -24
- package/libusb/examples/testlibusb.c +138 -104
- package/libusb/examples/xusb.c +26 -22
- package/libusb/libusb/Makefile.am +57 -70
- package/libusb/libusb/Makefile.am.extra +26 -0
- package/libusb/libusb/core.c +432 -423
- package/libusb/libusb/descriptor.c +365 -419
- package/libusb/libusb/hotplug.c +200 -104
- package/libusb/libusb/io.c +522 -535
- package/libusb/libusb/libusb-1.0.def +7 -3
- package/libusb/libusb/libusb-1.0.rc +1 -9
- package/libusb/libusb/libusb.h +302 -226
- package/libusb/libusb/libusbi.h +607 -316
- package/libusb/libusb/os/darwin_usb.c +703 -329
- package/libusb/libusb/os/darwin_usb.h +39 -15
- package/libusb/libusb/os/events_posix.c +300 -0
- package/libusb/libusb/os/events_posix.h +59 -0
- package/libusb/libusb/os/events_windows.c +214 -0
- package/libusb/{msvc/missing.h → libusb/os/events_windows.h} +25 -11
- package/libusb/libusb/os/haiku_pollfs.cpp +14 -9
- package/libusb/libusb/os/haiku_usb.h +12 -12
- package/libusb/libusb/os/haiku_usb_backend.cpp +36 -37
- package/libusb/libusb/os/haiku_usb_raw.cpp +80 -116
- package/libusb/libusb/os/linux_netlink.c +55 -63
- package/libusb/libusb/os/linux_udev.c +61 -69
- package/libusb/libusb/os/linux_usbfs.c +926 -1015
- package/libusb/libusb/os/linux_usbfs.h +74 -57
- package/libusb/libusb/os/netbsd_usb.c +103 -168
- package/libusb/libusb/os/null_usb.c +111 -0
- package/libusb/libusb/os/openbsd_usb.c +71 -120
- package/libusb/libusb/os/sunos_usb.c +289 -375
- package/libusb/libusb/os/sunos_usb.h +0 -1
- package/libusb/libusb/os/threads_posix.c +81 -32
- package/libusb/libusb/os/threads_posix.h +19 -23
- package/libusb/libusb/os/threads_windows.c +9 -95
- package/libusb/libusb/os/threads_windows.h +33 -31
- package/libusb/libusb/os/windows_common.c +915 -0
- package/libusb/libusb/os/windows_common.h +330 -42
- package/libusb/libusb/os/windows_usbdk.c +161 -267
- package/libusb/libusb/os/windows_usbdk.h +5 -2
- package/libusb/libusb/os/windows_winusb.c +1355 -1192
- package/libusb/libusb/os/windows_winusb.h +167 -167
- package/libusb/libusb/strerror.c +20 -30
- package/libusb/libusb/sync.c +20 -21
- package/libusb/libusb/version.h +1 -1
- package/libusb/libusb/version_nano.h +1 -1
- package/libusb/msvc/.gitattributes +3 -0
- package/libusb/msvc/config.h +27 -20
- package/libusb/msvc/{hotplugtest_2012.vcxproj → dpfp_2013.vcxproj} +14 -10
- package/libusb/msvc/dpfp_2013.vcxproj.filters +26 -0
- package/libusb/msvc/{hotplugtest_2010.vcxproj → dpfp_2015.vcxproj} +14 -9
- package/libusb/msvc/dpfp_2015.vcxproj.filters +26 -0
- package/libusb/msvc/dpfp_2017.vcxproj +106 -0
- package/libusb/msvc/dpfp_2017.vcxproj.filters +26 -0
- package/libusb/msvc/dpfp_2019.vcxproj +106 -0
- package/libusb/msvc/dpfp_2019.vcxproj.filters +26 -0
- package/libusb/msvc/dpfp_threaded_2013.vcxproj +87 -0
- package/libusb/msvc/dpfp_threaded_2013.vcxproj.filters +26 -0
- package/libusb/msvc/dpfp_threaded_2015.vcxproj +87 -0
- package/libusb/msvc/dpfp_threaded_2015.vcxproj.filters +26 -0
- package/libusb/msvc/dpfp_threaded_2017.vcxproj +106 -0
- package/libusb/msvc/dpfp_threaded_2017.vcxproj.filters +26 -0
- package/libusb/msvc/{fxload_2012.vcxproj → dpfp_threaded_2019.vcxproj} +32 -17
- package/libusb/msvc/dpfp_threaded_2019.vcxproj.filters +26 -0
- package/libusb/msvc/fxload_2013.vcxproj +6 -3
- package/libusb/msvc/fxload_2013.vcxproj.filters +35 -0
- package/libusb/msvc/fxload_2015.vcxproj +6 -3
- package/libusb/msvc/fxload_2015.vcxproj.filters +35 -0
- package/libusb/msvc/fxload_2017.vcxproj +6 -7
- package/libusb/msvc/fxload_2017.vcxproj.filters +35 -0
- package/libusb/msvc/{fxload_2010.vcxproj → fxload_2019.vcxproj} +29 -6
- package/libusb/msvc/fxload_2019.vcxproj.filters +35 -0
- package/libusb/{examples → msvc}/getopt/getopt.c +0 -0
- package/libusb/{examples → msvc}/getopt/getopt.h +0 -0
- package/libusb/{examples → msvc}/getopt/getopt1.c +0 -0
- package/libusb/msvc/getopt_2013.vcxproj +4 -5
- package/libusb/msvc/getopt_2013.vcxproj.filters +26 -0
- package/libusb/msvc/getopt_2015.vcxproj +4 -4
- package/libusb/msvc/getopt_2015.vcxproj.filters +26 -0
- package/libusb/msvc/getopt_2017.vcxproj +4 -10
- package/libusb/msvc/getopt_2017.vcxproj.filters +26 -0
- package/libusb/msvc/{getopt_2010.vcxproj → getopt_2019.vcxproj} +25 -5
- package/libusb/msvc/getopt_2019.vcxproj.filters +26 -0
- package/libusb/msvc/hotplugtest_2013.vcxproj +6 -3
- package/libusb/msvc/hotplugtest_2013.vcxproj.filters +23 -0
- package/libusb/msvc/hotplugtest_2015.vcxproj +6 -3
- package/libusb/msvc/hotplugtest_2015.vcxproj.filters +23 -0
- package/libusb/msvc/hotplugtest_2017.vcxproj +6 -7
- package/libusb/msvc/hotplugtest_2017.vcxproj.filters +23 -0
- package/libusb/msvc/hotplugtest_2019.vcxproj +105 -0
- package/libusb/msvc/hotplugtest_2019.vcxproj.filters +23 -0
- package/libusb/msvc/libusb_2013.sln +50 -20
- package/libusb/msvc/libusb_2015.sln +51 -21
- package/libusb/msvc/libusb_2017.sln +90 -36
- package/libusb/msvc/libusb_2019.sln +240 -0
- package/libusb/msvc/libusb_dll_2013.vcxproj +6 -9
- package/libusb/msvc/libusb_dll_2013.vcxproj.filters +94 -0
- package/libusb/msvc/libusb_dll_2015.vcxproj +6 -8
- package/libusb/msvc/libusb_dll_2015.vcxproj.filters +94 -0
- package/libusb/msvc/libusb_dll_2017.vcxproj +6 -16
- package/libusb/msvc/libusb_dll_2017.vcxproj.filters +94 -0
- package/libusb/msvc/{libusb_dll_2010.vcxproj → libusb_dll_2019.vcxproj} +27 -9
- package/libusb/msvc/libusb_dll_2019.vcxproj.filters +94 -0
- package/libusb/msvc/libusb_static_2013.vcxproj +5 -9
- package/libusb/msvc/libusb_static_2013.vcxproj.filters +80 -0
- package/libusb/msvc/libusb_static_2015.vcxproj +5 -8
- package/libusb/msvc/libusb_static_2015.vcxproj.filters +80 -0
- package/libusb/msvc/libusb_static_2017.vcxproj +5 -8
- package/libusb/msvc/libusb_static_2017.vcxproj.filters +80 -0
- package/libusb/msvc/{libusb_static_2010.vcxproj → libusb_static_2019.vcxproj} +26 -9
- package/libusb/msvc/libusb_static_2019.vcxproj.filters +80 -0
- package/libusb/msvc/listdevs_2013.vcxproj +6 -3
- package/libusb/msvc/listdevs_2013.vcxproj.filters +23 -0
- package/libusb/msvc/listdevs_2015.vcxproj +6 -3
- package/libusb/msvc/listdevs_2015.vcxproj.filters +23 -0
- package/libusb/msvc/listdevs_2017.vcxproj +6 -7
- package/libusb/msvc/listdevs_2017.vcxproj.filters +23 -0
- package/libusb/msvc/listdevs_2019.vcxproj +105 -0
- package/libusb/msvc/listdevs_2019.vcxproj.filters +23 -0
- package/libusb/msvc/{listdevs_2010.vcxproj → sam3u_benchmark_2013.vcxproj} +13 -8
- package/libusb/msvc/sam3u_benchmark_2013.vcxproj.filters +26 -0
- package/libusb/msvc/{listdevs_2012.vcxproj → sam3u_benchmark_2015.vcxproj} +13 -9
- package/libusb/msvc/sam3u_benchmark_2015.vcxproj.filters +26 -0
- package/libusb/msvc/sam3u_benchmark_2017.vcxproj +106 -0
- package/libusb/msvc/sam3u_benchmark_2017.vcxproj.filters +26 -0
- package/libusb/msvc/sam3u_benchmark_2019.vcxproj +106 -0
- package/libusb/msvc/sam3u_benchmark_2019.vcxproj.filters +26 -0
- package/libusb/msvc/stress_2013.vcxproj +4 -2
- package/libusb/msvc/stress_2013.vcxproj.filters +32 -0
- package/libusb/msvc/stress_2015.vcxproj +4 -2
- package/libusb/msvc/stress_2015.vcxproj.filters +32 -0
- package/libusb/msvc/stress_2017.vcxproj +4 -6
- package/libusb/msvc/stress_2017.vcxproj.filters +32 -0
- package/libusb/msvc/{stress_2010.vcxproj → stress_2019.vcxproj} +26 -4
- package/libusb/msvc/stress_2019.vcxproj.filters +32 -0
- package/libusb/msvc/testlibusb_2013.vcxproj +6 -3
- package/libusb/msvc/testlibusb_2013.vcxproj.filters +23 -0
- package/libusb/msvc/testlibusb_2015.vcxproj +6 -3
- package/libusb/msvc/testlibusb_2015.vcxproj.filters +23 -0
- package/libusb/msvc/testlibusb_2017.vcxproj +6 -7
- package/libusb/msvc/testlibusb_2017.vcxproj.filters +23 -0
- package/libusb/msvc/{testlibusb_2010.vcxproj → testlibusb_2019.vcxproj} +28 -5
- package/libusb/msvc/testlibusb_2019.vcxproj.filters +23 -0
- package/libusb/msvc/xusb_2013.vcxproj +6 -3
- package/libusb/msvc/xusb_2013.vcxproj.filters +23 -0
- package/libusb/msvc/xusb_2015.vcxproj +6 -3
- package/libusb/msvc/xusb_2015.vcxproj.filters +23 -0
- package/libusb/msvc/xusb_2017.vcxproj +6 -7
- package/libusb/msvc/xusb_2017.vcxproj.filters +23 -0
- package/libusb/msvc/{xusb_2010.vcxproj → xusb_2019.vcxproj} +28 -5
- package/libusb/msvc/xusb_2019.vcxproj.filters +23 -0
- package/libusb/tests/Makefile.am +13 -1
- package/libusb/tests/libusb_testlib.h +12 -43
- package/libusb/tests/stress.c +59 -50
- package/libusb/tests/testlib.c +78 -171
- package/libusb/tests/umockdev.c +1175 -0
- package/libusb.gypi +10 -11
- package/package.json +1 -1
- package/prebuilds/android-arm/node.napi.armv7.node +0 -0
- package/prebuilds/android-arm64/node.napi.armv8.node +0 -0
- package/prebuilds/darwin-x64+arm64/node.napi.node +0 -0
- package/prebuilds/linux-arm/node.napi.armv6.node +0 -0
- package/prebuilds/linux-arm/node.napi.armv7.node +0 -0
- package/prebuilds/linux-arm64/node.napi.armv8.node +0 -0
- package/prebuilds/linux-ia32/node.napi.node +0 -0
- package/prebuilds/linux-x64/node.napi.glibc.node +0 -0
- package/prebuilds/linux-x64/node.napi.musl.node +0 -0
- package/prebuilds/win32-ia32/node.napi.node +0 -0
- package/prebuilds/win32-x64/node.napi.node +0 -0
- package/src/device.cc +12 -7
- package/src/node_usb.cc +10 -0
- package/test/usb.coffee +6 -0
- package/tsc/index.ts +2 -0
- package/tsc/usb/bindings.ts +5 -0
- package/tsc/usb/device.ts +6 -0
- package/tsc/usb/index.ts +5 -8
- package/tsc/webusb/webusb-device.ts +67 -124
- package/dist/webusb/mutex.d.ts +0 -22
- package/dist/webusb/mutex.js +0 -89
- package/dist/webusb/mutex.js.map +0 -1
- package/libusb/.private/bd.cmd +0 -89
- package/libusb/.private/bwince.cmd +0 -57
- package/libusb/.private/wbs_wince.txt +0 -42
- package/libusb/Brewfile +0 -4
- package/libusb/appveyor_cygwin.bat +0 -11
- package/libusb/appveyor_minGW.bat +0 -19
- package/libusb/doc/Makefile.am +0 -9
- package/libusb/examples/dpfp_threaded.c +0 -557
- package/libusb/libusb/hotplug.h +0 -99
- package/libusb/libusb/os/poll_posix.c +0 -84
- package/libusb/libusb/os/poll_posix.h +0 -14
- package/libusb/libusb/os/poll_windows.c +0 -447
- package/libusb/libusb/os/poll_windows.h +0 -98
- package/libusb/libusb/os/wince_usb.c +0 -888
- package/libusb/libusb/os/wince_usb.h +0 -126
- package/libusb/libusb/os/windows_nt_common.c +0 -1010
- package/libusb/libusb/os/windows_nt_common.h +0 -110
- package/libusb/libusb/os/windows_nt_shared_types.h +0 -147
- package/libusb/msvc/appveyor.bat +0 -27
- package/libusb/msvc/ddk_build.cmd +0 -219
- package/libusb/msvc/errno.h +0 -102
- package/libusb/msvc/fxload_sources +0 -23
- package/libusb/msvc/getopt_2005.vcproj +0 -288
- package/libusb/msvc/getopt_2012.vcxproj +0 -73
- package/libusb/msvc/getopt_sources +0 -24
- package/libusb/msvc/hotplugtest_sources +0 -20
- package/libusb/msvc/inttypes.h +0 -295
- package/libusb/msvc/libusb.dsw +0 -71
- package/libusb/msvc/libusb_2005.sln +0 -95
- package/libusb/msvc/libusb_2010.sln +0 -105
- package/libusb/msvc/libusb_2012.sln +0 -105
- package/libusb/msvc/libusb_dll.dsp +0 -194
- package/libusb/msvc/libusb_dll_2005.vcproj +0 -464
- package/libusb/msvc/libusb_dll_2012.vcxproj +0 -107
- package/libusb/msvc/libusb_dll_wince.vcproj +0 -1251
- package/libusb/msvc/libusb_sources +0 -43
- package/libusb/msvc/libusb_static.dsp +0 -174
- package/libusb/msvc/libusb_static_2005.vcproj +0 -390
- package/libusb/msvc/libusb_static_2012.vcxproj +0 -98
- package/libusb/msvc/libusb_static_wince.vcproj +0 -1179
- package/libusb/msvc/libusb_wince.sln +0 -246
- package/libusb/msvc/listdevs.dsp +0 -103
- package/libusb/msvc/listdevs_2005.vcproj +0 -360
- package/libusb/msvc/listdevs_sources +0 -20
- package/libusb/msvc/listdevs_wince.vcproj +0 -1120
- package/libusb/msvc/missing.c +0 -80
- package/libusb/msvc/stdint.h +0 -256
- package/libusb/msvc/stress_2005.vcproj +0 -390
- package/libusb/msvc/stress_2012.vcxproj +0 -87
- package/libusb/msvc/stress_sources +0 -21
- package/libusb/msvc/stress_wince.vcproj +0 -1128
- package/libusb/msvc/testlibusb_2012.vcxproj +0 -83
- package/libusb/msvc/testlibusb_sources +0 -20
- package/libusb/msvc/xusb.dsp +0 -102
- package/libusb/msvc/xusb_2005.vcproj +0 -344
- package/libusb/msvc/xusb_2012.vcxproj +0 -83
- package/libusb/msvc/xusb_sources +0 -20
- package/libusb/msvc/xusb_wince.vcproj +0 -1120
- package/libusb/travis-autogen.sh +0 -39
- package/tsc/webusb/mutex.ts +0 -38
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
* Windows backend common header for libusb 1.0
|
|
3
3
|
*
|
|
4
4
|
* This file brings together header code common between
|
|
5
|
-
* the desktop Windows
|
|
5
|
+
* the desktop Windows backends.
|
|
6
6
|
* Copyright © 2012-2013 RealVNC Ltd.
|
|
7
7
|
* Copyright © 2009-2012 Pete Batard <pete@akeo.ie>
|
|
8
|
+
* Copyright © 2014-2020 Chris Dickens <christopher.a.dickens@gmail.com>
|
|
8
9
|
* With contributions from Michael Plante, Orin Eman et al.
|
|
9
10
|
* Parts of this code adapted from libusb-win32-v1 by Stephan Meyer
|
|
10
11
|
* Major code testing contribution by Xiaofan Chen
|
|
@@ -24,71 +25,68 @@
|
|
|
24
25
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
25
26
|
*/
|
|
26
27
|
|
|
27
|
-
#
|
|
28
|
+
#ifndef LIBUSB_WINDOWS_COMMON_H
|
|
29
|
+
#define LIBUSB_WINDOWS_COMMON_H
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
#if !defined(bool)
|
|
31
|
-
#define bool BOOL
|
|
32
|
-
#endif
|
|
33
|
-
#if !defined(true)
|
|
34
|
-
#define true TRUE
|
|
35
|
-
#endif
|
|
36
|
-
#if !defined(false)
|
|
37
|
-
#define false FALSE
|
|
38
|
-
#endif
|
|
31
|
+
#include <stdbool.h>
|
|
39
32
|
|
|
40
|
-
|
|
33
|
+
/*
|
|
34
|
+
* Workaround for the mess that exists with the DWORD and ULONG types.
|
|
35
|
+
* Visual Studio unconditionally defines these types as 'unsigned long'
|
|
36
|
+
* and a long is always 32-bits, even on 64-bit builds. GCC on the other
|
|
37
|
+
* hand varies the width of a long, matching it to the build. To make
|
|
38
|
+
* matters worse, the platform headers for these GCC builds define a
|
|
39
|
+
* DWORD/ULONG to be 'unsigned long' on 32-bit builds and 'unsigned int'
|
|
40
|
+
* on 64-bit builds. This creates a great deal of warnings for compilers
|
|
41
|
+
* that support printf format checking since it will never actually be
|
|
42
|
+
* an unsigned long.
|
|
43
|
+
*/
|
|
44
|
+
#if defined(_MSC_VER)
|
|
45
|
+
#define ULONG_CAST(x) (x)
|
|
46
|
+
#else
|
|
47
|
+
#define ULONG_CAST(x) ((unsigned long)(x))
|
|
48
|
+
#endif
|
|
41
49
|
|
|
42
|
-
#if defined(__CYGWIN__
|
|
50
|
+
#if defined(__CYGWIN__)
|
|
43
51
|
#define _stricmp strcasecmp
|
|
44
52
|
#define _strdup strdup
|
|
45
53
|
// _beginthreadex is MSVCRT => unavailable for cygwin. Fallback to using CreateThread
|
|
46
54
|
#define _beginthreadex(a, b, c, d, e, f) CreateThread(a, b, (LPTHREAD_START_ROUTINE)c, d, e, (LPDWORD)f)
|
|
55
|
+
#else
|
|
56
|
+
#include <process.h>
|
|
47
57
|
#endif
|
|
48
58
|
|
|
49
59
|
#define safe_free(p) do {if (p != NULL) {free((void *)p); p = NULL;}} while (0)
|
|
50
60
|
|
|
51
|
-
#ifndef ARRAYSIZE
|
|
52
|
-
#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
|
|
53
|
-
#endif
|
|
54
|
-
|
|
55
|
-
#define ERR_BUFFER_SIZE 256
|
|
56
|
-
|
|
57
61
|
/*
|
|
58
62
|
* API macros - leveraged from libusb-win32 1.x
|
|
59
63
|
*/
|
|
60
|
-
#ifndef _WIN32_WCE
|
|
61
64
|
#define DLL_STRINGIFY(s) #s
|
|
62
|
-
#define DLL_LOAD_LIBRARY(name) LoadLibraryA(DLL_STRINGIFY(name))
|
|
63
|
-
#else
|
|
64
|
-
#define DLL_STRINGIFY(s) L#s
|
|
65
|
-
#define DLL_LOAD_LIBRARY(name) LoadLibrary(DLL_STRINGIFY(name))
|
|
66
|
-
#endif
|
|
67
65
|
|
|
68
66
|
/*
|
|
69
67
|
* Macros for handling DLL themselves
|
|
70
68
|
*/
|
|
71
69
|
#define DLL_HANDLE_NAME(name) __dll_##name##_handle
|
|
72
70
|
|
|
73
|
-
#define DLL_DECLARE_HANDLE(name)
|
|
74
|
-
static HMODULE DLL_HANDLE_NAME(name)
|
|
71
|
+
#define DLL_DECLARE_HANDLE(name) \
|
|
72
|
+
static HMODULE DLL_HANDLE_NAME(name)
|
|
75
73
|
|
|
76
|
-
#define DLL_GET_HANDLE(name) \
|
|
77
|
-
do {
|
|
78
|
-
DLL_HANDLE_NAME(name) =
|
|
79
|
-
|
|
80
|
-
|
|
74
|
+
#define DLL_GET_HANDLE(ctx, name) \
|
|
75
|
+
do { \
|
|
76
|
+
DLL_HANDLE_NAME(name) = load_system_library(ctx, \
|
|
77
|
+
DLL_STRINGIFY(name)); \
|
|
78
|
+
if (!DLL_HANDLE_NAME(name)) \
|
|
79
|
+
return false; \
|
|
81
80
|
} while (0)
|
|
82
81
|
|
|
83
|
-
#define DLL_FREE_HANDLE(name)
|
|
84
|
-
do {
|
|
85
|
-
if (DLL_HANDLE_NAME(name)) {
|
|
86
|
-
FreeLibrary(DLL_HANDLE_NAME(name));
|
|
87
|
-
DLL_HANDLE_NAME(name) = NULL;
|
|
88
|
-
}
|
|
82
|
+
#define DLL_FREE_HANDLE(name) \
|
|
83
|
+
do { \
|
|
84
|
+
if (DLL_HANDLE_NAME(name)) { \
|
|
85
|
+
FreeLibrary(DLL_HANDLE_NAME(name)); \
|
|
86
|
+
DLL_HANDLE_NAME(name) = NULL; \
|
|
87
|
+
} \
|
|
89
88
|
} while (0)
|
|
90
89
|
|
|
91
|
-
|
|
92
90
|
/*
|
|
93
91
|
* Macros for handling functions within a DLL
|
|
94
92
|
*/
|
|
@@ -96,7 +94,7 @@
|
|
|
96
94
|
|
|
97
95
|
#define DLL_DECLARE_FUNC_PREFIXNAME(api, ret, prefixname, name, args) \
|
|
98
96
|
typedef ret (api * DLL_FUNC_NAME(name))args; \
|
|
99
|
-
static DLL_FUNC_NAME(name) prefixname
|
|
97
|
+
static DLL_FUNC_NAME(name) prefixname
|
|
100
98
|
|
|
101
99
|
#define DLL_DECLARE_FUNC(api, ret, name, args) \
|
|
102
100
|
DLL_DECLARE_FUNC_PREFIXNAME(api, ret, name, name, args)
|
|
@@ -119,10 +117,300 @@
|
|
|
119
117
|
if (prefixname) \
|
|
120
118
|
break; \
|
|
121
119
|
if (ret_on_failure) \
|
|
122
|
-
return
|
|
120
|
+
return false; \
|
|
123
121
|
} while (0)
|
|
124
122
|
|
|
125
123
|
#define DLL_LOAD_FUNC(dll, name, ret_on_failure) \
|
|
126
124
|
DLL_LOAD_FUNC_PREFIXNAME(dll, name, name, ret_on_failure)
|
|
127
125
|
#define DLL_LOAD_FUNC_PREFIXED(dll, prefix, name, ret_on_failure) \
|
|
128
126
|
DLL_LOAD_FUNC_PREFIXNAME(dll, prefix##name, name, ret_on_failure)
|
|
127
|
+
|
|
128
|
+
// https://msdn.microsoft.com/en-us/library/windows/hardware/ff539136(v=vs.85).aspx
|
|
129
|
+
#if !defined(USBD_SUCCESS)
|
|
130
|
+
typedef LONG USBD_STATUS;
|
|
131
|
+
|
|
132
|
+
#define USBD_SUCCESS(Status) ((USBD_STATUS)(Status) >= 0)
|
|
133
|
+
|
|
134
|
+
#define USBD_STATUS_ENDPOINT_HALTED ((USBD_STATUS)0xC0000030L)
|
|
135
|
+
#define USBD_STATUS_TIMEOUT ((USBD_STATUS)0xC0006000L)
|
|
136
|
+
#define USBD_STATUS_DEVICE_GONE ((USBD_STATUS)0xC0007000L)
|
|
137
|
+
#define USBD_STATUS_CANCELED ((USBD_STATUS)0xC0010000L)
|
|
138
|
+
#endif
|
|
139
|
+
|
|
140
|
+
// error code added with Windows SDK 10.0.18362
|
|
141
|
+
#ifndef ERROR_NO_SUCH_DEVICE
|
|
142
|
+
#define ERROR_NO_SUCH_DEVICE 433L
|
|
143
|
+
#endif
|
|
144
|
+
|
|
145
|
+
/* Windows versions */
|
|
146
|
+
enum windows_version {
|
|
147
|
+
WINDOWS_UNDEFINED,
|
|
148
|
+
WINDOWS_2000,
|
|
149
|
+
WINDOWS_XP,
|
|
150
|
+
WINDOWS_2003, // Also XP x64
|
|
151
|
+
WINDOWS_VISTA,
|
|
152
|
+
WINDOWS_7,
|
|
153
|
+
WINDOWS_8,
|
|
154
|
+
WINDOWS_8_1,
|
|
155
|
+
WINDOWS_10,
|
|
156
|
+
WINDOWS_11,
|
|
157
|
+
WINDOWS_12_OR_LATER
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
extern enum windows_version windows_version;
|
|
161
|
+
|
|
162
|
+
#include <pshpack1.h>
|
|
163
|
+
|
|
164
|
+
typedef struct USB_DEVICE_DESCRIPTOR {
|
|
165
|
+
UCHAR bLength;
|
|
166
|
+
UCHAR bDescriptorType;
|
|
167
|
+
USHORT bcdUSB;
|
|
168
|
+
UCHAR bDeviceClass;
|
|
169
|
+
UCHAR bDeviceSubClass;
|
|
170
|
+
UCHAR bDeviceProtocol;
|
|
171
|
+
UCHAR bMaxPacketSize0;
|
|
172
|
+
USHORT idVendor;
|
|
173
|
+
USHORT idProduct;
|
|
174
|
+
USHORT bcdDevice;
|
|
175
|
+
UCHAR iManufacturer;
|
|
176
|
+
UCHAR iProduct;
|
|
177
|
+
UCHAR iSerialNumber;
|
|
178
|
+
UCHAR bNumConfigurations;
|
|
179
|
+
} USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR;
|
|
180
|
+
|
|
181
|
+
typedef struct USB_CONFIGURATION_DESCRIPTOR {
|
|
182
|
+
UCHAR bLength;
|
|
183
|
+
UCHAR bDescriptorType;
|
|
184
|
+
USHORT wTotalLength;
|
|
185
|
+
UCHAR bNumInterfaces;
|
|
186
|
+
UCHAR bConfigurationValue;
|
|
187
|
+
UCHAR iConfiguration;
|
|
188
|
+
UCHAR bmAttributes;
|
|
189
|
+
UCHAR MaxPower;
|
|
190
|
+
} USB_CONFIGURATION_DESCRIPTOR, *PUSB_CONFIGURATION_DESCRIPTOR;
|
|
191
|
+
|
|
192
|
+
#include <poppack.h>
|
|
193
|
+
|
|
194
|
+
#define MAX_DEVICE_ID_LEN 200
|
|
195
|
+
|
|
196
|
+
typedef struct USB_DK_DEVICE_ID {
|
|
197
|
+
WCHAR DeviceID[MAX_DEVICE_ID_LEN];
|
|
198
|
+
WCHAR InstanceID[MAX_DEVICE_ID_LEN];
|
|
199
|
+
} USB_DK_DEVICE_ID, *PUSB_DK_DEVICE_ID;
|
|
200
|
+
|
|
201
|
+
typedef struct USB_DK_DEVICE_INFO {
|
|
202
|
+
USB_DK_DEVICE_ID ID;
|
|
203
|
+
ULONG64 FilterID;
|
|
204
|
+
ULONG64 Port;
|
|
205
|
+
ULONG64 Speed;
|
|
206
|
+
USB_DEVICE_DESCRIPTOR DeviceDescriptor;
|
|
207
|
+
} USB_DK_DEVICE_INFO, *PUSB_DK_DEVICE_INFO;
|
|
208
|
+
|
|
209
|
+
typedef struct USB_DK_ISO_TRANSFER_RESULT {
|
|
210
|
+
ULONG64 ActualLength;
|
|
211
|
+
ULONG64 TransferResult;
|
|
212
|
+
} USB_DK_ISO_TRANSFER_RESULT, *PUSB_DK_ISO_TRANSFER_RESULT;
|
|
213
|
+
|
|
214
|
+
typedef struct USB_DK_GEN_TRANSFER_RESULT {
|
|
215
|
+
ULONG64 BytesTransferred;
|
|
216
|
+
ULONG64 UsbdStatus; // USBD_STATUS code
|
|
217
|
+
} USB_DK_GEN_TRANSFER_RESULT, *PUSB_DK_GEN_TRANSFER_RESULT;
|
|
218
|
+
|
|
219
|
+
typedef struct USB_DK_TRANSFER_RESULT {
|
|
220
|
+
USB_DK_GEN_TRANSFER_RESULT GenResult;
|
|
221
|
+
PVOID64 IsochronousResultsArray; // array of USB_DK_ISO_TRANSFER_RESULT
|
|
222
|
+
} USB_DK_TRANSFER_RESULT, *PUSB_DK_TRANSFER_RESULT;
|
|
223
|
+
|
|
224
|
+
typedef struct USB_DK_TRANSFER_REQUEST {
|
|
225
|
+
ULONG64 EndpointAddress;
|
|
226
|
+
PVOID64 Buffer;
|
|
227
|
+
ULONG64 BufferLength;
|
|
228
|
+
ULONG64 TransferType;
|
|
229
|
+
ULONG64 IsochronousPacketsArraySize;
|
|
230
|
+
PVOID64 IsochronousPacketsArray;
|
|
231
|
+
USB_DK_TRANSFER_RESULT Result;
|
|
232
|
+
} USB_DK_TRANSFER_REQUEST, *PUSB_DK_TRANSFER_REQUEST;
|
|
233
|
+
|
|
234
|
+
struct usbdk_device_priv {
|
|
235
|
+
USB_DK_DEVICE_ID ID;
|
|
236
|
+
PUSB_CONFIGURATION_DESCRIPTOR *config_descriptors;
|
|
237
|
+
HANDLE redirector_handle;
|
|
238
|
+
HANDLE system_handle;
|
|
239
|
+
uint8_t active_configuration;
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
struct winusb_device_priv {
|
|
243
|
+
bool initialized;
|
|
244
|
+
bool root_hub;
|
|
245
|
+
uint8_t active_config;
|
|
246
|
+
uint8_t depth; // distance to HCD
|
|
247
|
+
const struct windows_usb_api_backend *apib;
|
|
248
|
+
char *dev_id;
|
|
249
|
+
char *path; // device interface path
|
|
250
|
+
int sub_api; // for WinUSB-like APIs
|
|
251
|
+
struct {
|
|
252
|
+
char *path; // each interface needs a device interface path,
|
|
253
|
+
const struct windows_usb_api_backend *apib; // an API backend (multiple drivers support),
|
|
254
|
+
int sub_api;
|
|
255
|
+
int8_t nb_endpoints; // and a set of endpoint addresses (USB_MAXENDPOINTS)
|
|
256
|
+
uint8_t *endpoint;
|
|
257
|
+
int current_altsetting;
|
|
258
|
+
bool restricted_functionality; // indicates if the interface functionality is restricted
|
|
259
|
+
// by Windows (eg. HID keyboards or mice cannot do R/W)
|
|
260
|
+
} usb_interface[USB_MAXINTERFACES];
|
|
261
|
+
struct hid_device_priv *hid;
|
|
262
|
+
PUSB_CONFIGURATION_DESCRIPTOR *config_descriptor; // list of pointers to the cached config descriptors
|
|
263
|
+
GUID class_guid; // checked for change during re-enumeration
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
struct usbdk_device_handle_priv {
|
|
267
|
+
// Not currently used
|
|
268
|
+
char dummy;
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
enum WINUSB_ZLP {
|
|
272
|
+
WINUSB_ZLP_UNSET = 0,
|
|
273
|
+
WINUSB_ZLP_OFF = 1,
|
|
274
|
+
WINUSB_ZLP_ON = 2
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
struct winusb_device_handle_priv {
|
|
278
|
+
int active_interface;
|
|
279
|
+
struct {
|
|
280
|
+
HANDLE dev_handle; // WinUSB needs an extra handle for the file
|
|
281
|
+
HANDLE api_handle; // used by the API to communicate with the device
|
|
282
|
+
uint8_t zlp[USB_MAXENDPOINTS]; // Current per-endpoint SHORT_PACKET_TERMINATE status (enum WINUSB_ZLP)
|
|
283
|
+
} interface_handle[USB_MAXINTERFACES];
|
|
284
|
+
int autoclaim_count[USB_MAXINTERFACES]; // For auto-release
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
struct usbdk_transfer_priv {
|
|
288
|
+
USB_DK_TRANSFER_REQUEST request;
|
|
289
|
+
PULONG64 IsochronousPacketsArray;
|
|
290
|
+
PUSB_DK_ISO_TRANSFER_RESULT IsochronousResultsArray;
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
struct winusb_transfer_priv {
|
|
294
|
+
uint8_t interface_number;
|
|
295
|
+
|
|
296
|
+
uint8_t *hid_buffer; // 1 byte extended data buffer, required for HID
|
|
297
|
+
uint8_t *hid_dest; // transfer buffer destination, required for HID
|
|
298
|
+
size_t hid_expected_size;
|
|
299
|
+
|
|
300
|
+
// For isochronous transfers with LibUSBk driver:
|
|
301
|
+
void *iso_context;
|
|
302
|
+
|
|
303
|
+
// For isochronous transfers with Microsoft WinUSB driver:
|
|
304
|
+
void *isoch_buffer_handle; // The isoch_buffer_handle to free at the end of the transfer
|
|
305
|
+
BOOL iso_break_stream; // Whether the isoch. stream was to be continued in the last call of libusb_submit_transfer.
|
|
306
|
+
// As we this structure is zeroed out upon initialization, we need to use inverse logic here.
|
|
307
|
+
libusb_transfer_cb_fn iso_user_callback; // Original transfer callback of the user. Might be used for isochronous transfers.
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
struct windows_backend {
|
|
311
|
+
int (*init)(struct libusb_context *ctx);
|
|
312
|
+
void (*exit)(struct libusb_context *ctx);
|
|
313
|
+
int (*get_device_list)(struct libusb_context *ctx,
|
|
314
|
+
struct discovered_devs **discdevs);
|
|
315
|
+
int (*open)(struct libusb_device_handle *dev_handle);
|
|
316
|
+
void (*close)(struct libusb_device_handle *dev_handle);
|
|
317
|
+
int (*get_active_config_descriptor)(struct libusb_device *device,
|
|
318
|
+
void *buffer, size_t len);
|
|
319
|
+
int (*get_config_descriptor)(struct libusb_device *device,
|
|
320
|
+
uint8_t config_index, void *buffer, size_t len);
|
|
321
|
+
int (*get_config_descriptor_by_value)(struct libusb_device *device,
|
|
322
|
+
uint8_t bConfigurationValue, void **buffer);
|
|
323
|
+
int (*get_configuration)(struct libusb_device_handle *dev_handle, uint8_t *config);
|
|
324
|
+
int (*set_configuration)(struct libusb_device_handle *dev_handle, uint8_t config);
|
|
325
|
+
int (*claim_interface)(struct libusb_device_handle *dev_handle, uint8_t interface_number);
|
|
326
|
+
int (*release_interface)(struct libusb_device_handle *dev_handle, uint8_t interface_number);
|
|
327
|
+
int (*set_interface_altsetting)(struct libusb_device_handle *dev_handle,
|
|
328
|
+
uint8_t interface_number, uint8_t altsetting);
|
|
329
|
+
int (*clear_halt)(struct libusb_device_handle *dev_handle,
|
|
330
|
+
unsigned char endpoint);
|
|
331
|
+
int (*reset_device)(struct libusb_device_handle *dev_handle);
|
|
332
|
+
void (*destroy_device)(struct libusb_device *dev);
|
|
333
|
+
int (*submit_transfer)(struct usbi_transfer *itransfer);
|
|
334
|
+
int (*cancel_transfer)(struct usbi_transfer *itransfer);
|
|
335
|
+
void (*clear_transfer_priv)(struct usbi_transfer *itransfer);
|
|
336
|
+
enum libusb_transfer_status (*copy_transfer_data)(struct usbi_transfer *itransfer, DWORD length);
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
struct windows_context_priv {
|
|
340
|
+
const struct windows_backend *backend;
|
|
341
|
+
HANDLE completion_port;
|
|
342
|
+
HANDLE completion_port_thread;
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
union windows_device_priv {
|
|
346
|
+
struct usbdk_device_priv usbdk_priv;
|
|
347
|
+
struct winusb_device_priv winusb_priv;
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
struct windows_device_handle_priv {
|
|
351
|
+
struct list_head active_transfers;
|
|
352
|
+
union {
|
|
353
|
+
struct usbdk_device_handle_priv usbdk_priv;
|
|
354
|
+
struct winusb_device_handle_priv winusb_priv;
|
|
355
|
+
};
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
struct windows_transfer_priv {
|
|
359
|
+
OVERLAPPED overlapped;
|
|
360
|
+
HANDLE handle;
|
|
361
|
+
struct list_head list;
|
|
362
|
+
union {
|
|
363
|
+
struct usbdk_transfer_priv usbdk_priv;
|
|
364
|
+
struct winusb_transfer_priv winusb_priv;
|
|
365
|
+
};
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
static inline struct usbdk_device_handle_priv *get_usbdk_device_handle_priv(struct libusb_device_handle *dev_handle)
|
|
369
|
+
{
|
|
370
|
+
struct windows_device_handle_priv *handle_priv = usbi_get_device_handle_priv(dev_handle);
|
|
371
|
+
return &handle_priv->usbdk_priv;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
static inline struct winusb_device_handle_priv *get_winusb_device_handle_priv(struct libusb_device_handle *dev_handle)
|
|
375
|
+
{
|
|
376
|
+
struct windows_device_handle_priv *handle_priv = usbi_get_device_handle_priv(dev_handle);
|
|
377
|
+
return &handle_priv->winusb_priv;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
static inline OVERLAPPED *get_transfer_priv_overlapped(struct usbi_transfer *itransfer)
|
|
381
|
+
{
|
|
382
|
+
struct windows_transfer_priv *transfer_priv = usbi_get_transfer_priv(itransfer);
|
|
383
|
+
return &transfer_priv->overlapped;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
static inline void set_transfer_priv_handle(struct usbi_transfer *itransfer, HANDLE handle)
|
|
387
|
+
{
|
|
388
|
+
struct windows_transfer_priv *transfer_priv = usbi_get_transfer_priv(itransfer);
|
|
389
|
+
transfer_priv->handle = handle;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
static inline struct usbdk_transfer_priv *get_usbdk_transfer_priv(struct usbi_transfer *itransfer)
|
|
393
|
+
{
|
|
394
|
+
struct windows_transfer_priv *transfer_priv = usbi_get_transfer_priv(itransfer);
|
|
395
|
+
return &transfer_priv->usbdk_priv;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
static inline struct winusb_transfer_priv *get_winusb_transfer_priv(struct usbi_transfer *itransfer)
|
|
399
|
+
{
|
|
400
|
+
struct windows_transfer_priv *transfer_priv = usbi_get_transfer_priv(itransfer);
|
|
401
|
+
return &transfer_priv->winusb_priv;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
extern const struct windows_backend usbdk_backend;
|
|
405
|
+
extern const struct windows_backend winusb_backend;
|
|
406
|
+
|
|
407
|
+
HMODULE load_system_library(struct libusb_context *ctx, const char *name);
|
|
408
|
+
unsigned long htab_hash(const char *str);
|
|
409
|
+
enum libusb_transfer_status usbd_status_to_libusb_transfer_status(USBD_STATUS status);
|
|
410
|
+
void windows_force_sync_completion(struct usbi_transfer *itransfer, ULONG size);
|
|
411
|
+
|
|
412
|
+
#if defined(ENABLE_LOGGING)
|
|
413
|
+
const char *windows_error_str(DWORD error_code);
|
|
414
|
+
#endif
|
|
415
|
+
|
|
416
|
+
#endif
|