Signed-off-by: Zebediah Figura z.figura12@gmail.com --- v2: Actually disable wineusb.sys when libusb is missing.
configure.ac | 14 +++++++ dlls/wineusb.sys/Makefile.in | 8 ++++ dlls/wineusb.sys/wineusb.c | 61 +++++++++++++++++++++++++++++++ dlls/wineusb.sys/wineusb.sys.spec | 1 + loader/wine.inf.in | 2 + 5 files changed, 86 insertions(+) create mode 100644 dlls/wineusb.sys/Makefile.in create mode 100644 dlls/wineusb.sys/wineusb.c create mode 100644 dlls/wineusb.sys/wineusb.sys.spec
diff --git a/configure.ac b/configure.ac index 862745ef62..b8d70b6fe3 100644 --- a/configure.ac +++ b/configure.ac @@ -84,6 +84,7 @@ AC_ARG_WITH(sdl, AS_HELP_STRING([--without-sdl],[do not use SDL])) AC_ARG_WITH(tiff, AS_HELP_STRING([--without-tiff],[do not use TIFF])) AC_ARG_WITH(udev, AS_HELP_STRING([--without-udev],[do not use udev (plug and play support)])) AC_ARG_WITH(unwind, AS_HELP_STRING([--without-unwind],[do not use the libunwind library (exception handling)])) +AC_ARG_WITH(usb, AS_HELP_STRING([--without-usb],[do not use the libusb library])) AC_ARG_WITH(v4l2, AS_HELP_STRING([--without-v4l2],[do not use v4l2 (video capture)])) AC_ARG_WITH(vkd3d, AS_HELP_STRING([--without-vkd3d],[do not use vkd3d (Direct3D 12 support)])) AC_ARG_WITH(vulkan, AS_HELP_STRING([--without-vulkan],[do not use Vulkan])) @@ -1474,6 +1475,18 @@ fi WINE_NOTICE_WITH(sane,[test "x$ac_cv_lib_soname_sane" = "x"], [libsane ${notice_platform}development files not found, scanners won't be supported.])
+dnl **** Check for libusb **** +if test "x$with_usb" != "xno" +then + WINE_PACKAGE_FLAGS(USB,[libusb-1.0],[-lusb-1.0],,, + [AC_CHECK_HEADER([libusb.h], + [AC_CHECK_LIB(usb-1.0,libusb_init,[:],[USB_LIBS=""],[$USB_LIBS])], + [USB_LIBS=""])]) +fi +WINE_NOTICE_WITH(usb,[test "$ac_cv_lib_usb_1_0_libusb_init" != "yes"], + [libusb-1.0 ${notice_platform}development files not found, USB devices won't be supported.], + [enable_wineusb_sys]) + dnl **** Check for libv4l2 **** if test "x$with_v4l2" != "xno" then @@ -3781,6 +3794,7 @@ WINE_CONFIG_MAKEFILE(dlls/wineps.drv) WINE_CONFIG_MAKEFILE(dlls/wineps16.drv16,enable_win16) WINE_CONFIG_MAKEFILE(dlls/winepulse.drv) WINE_CONFIG_MAKEFILE(dlls/wineqtdecoder) +WINE_CONFIG_MAKEFILE(dlls/wineusb.sys) WINE_CONFIG_MAKEFILE(dlls/winevulkan) WINE_CONFIG_MAKEFILE(dlls/winex11.drv) WINE_CONFIG_MAKEFILE(dlls/wing.dll16,enable_win16) diff --git a/dlls/wineusb.sys/Makefile.in b/dlls/wineusb.sys/Makefile.in new file mode 100644 index 0000000000..bac79f668e --- /dev/null +++ b/dlls/wineusb.sys/Makefile.in @@ -0,0 +1,8 @@ +MODULE = wineusb.sys +IMPORTS = ntoskrnl +EXTRALIBS = $(USB_LIBS) +EXTRAINCL = $(USB_CFLAGS) +EXTRADLLFLAGS = -Wl,--subsystem,native + +C_SRCS = \ + wineusb.c diff --git a/dlls/wineusb.sys/wineusb.c b/dlls/wineusb.sys/wineusb.c new file mode 100644 index 0000000000..b26f1036d8 --- /dev/null +++ b/dlls/wineusb.sys/wineusb.c @@ -0,0 +1,61 @@ +/* + * USB root device enumerator using libusb + * + * Copyright 2020 Zebediah Figura + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <assert.h> +#include <stdarg.h> +#include <stdlib.h> +#include <libusb.h> + +#include "ntstatus.h" +#define WIN32_NO_STATUS +#include "windef.h" +#include "winioctl.h" +#include "winternl.h" +#include "ddk/wdm.h" +#include "ddk/usb.h" +#include "ddk/usbioctl.h" +#include "wine/asm.h" +#include "wine/debug.h" +#include "wine/list.h" +#include "wine/unicode.h" + +WINE_DEFAULT_DEBUG_CHANNEL(wineusb); + +static void WINAPI driver_unload(DRIVER_OBJECT *driver) +{ + libusb_exit(NULL); +} + +NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, UNICODE_STRING *path) +{ + int err; + + TRACE("driver %p, path %s.\n", driver, debugstr_w(path->Buffer)); + + if ((err = libusb_init(NULL))) + { + ERR("Failed to initialize libusb: %s\n", libusb_strerror(err)); + return STATUS_UNSUCCESSFUL; + } + + driver->DriverUnload = driver_unload; + + return STATUS_SUCCESS; +} diff --git a/dlls/wineusb.sys/wineusb.sys.spec b/dlls/wineusb.sys/wineusb.sys.spec new file mode 100644 index 0000000000..76421d7e35 --- /dev/null +++ b/dlls/wineusb.sys/wineusb.sys.spec @@ -0,0 +1 @@ +# nothing to export diff --git a/loader/wine.inf.in b/loader/wine.inf.in index d321c4c826..e1546713db 100644 --- a/loader/wine.inf.in +++ b/loader/wine.inf.in @@ -2614,6 +2614,7 @@ HKLM,%CurrentVersion%\Telephony\Country List\998,"SameAreaRule",,"G" 12,,tdi.sys,- 12,,winebus.sys,- 12,,winehid.sys,- +12,,wineusb.sys,- ; skip .NET fake dlls in Wine Mono package 11,,aspnet_regiis.exe,- 11,,ngen.exe,- @@ -2665,6 +2666,7 @@ HKLM,%CurrentVersion%\Telephony\Country List\998,"SameAreaRule",,"G" 12,,tdi.sys 12,,winebus.sys 12,,winehid.sys +12,,wineusb.sys ; skip .NET fake dlls in Wine Mono package 11,,aspnet_regiis.exe,- 11,,ngen.exe,-