wineusb.sys: New stub driver.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2020-04-15 09:43:18 -05:00 committed by Alexandre Julliard
parent 234fa118d4
commit 3c39209444
6 changed files with 187 additions and 0 deletions

101
configure vendored
View File

@ -682,6 +682,8 @@ GPHOTO2_PORT_LIBS
GPHOTO2_PORT_CFLAGS
GPHOTO2_LIBS
GPHOTO2_CFLAGS
USB_LIBS
USB_CFLAGS
SANE_LIBS
SANE_CFLAGS
GNUTLS_LIBS
@ -880,6 +882,7 @@ with_sdl
with_tiff
with_udev
with_unwind
with_usb
with_v4l2
with_vkd3d
with_vulkan
@ -1645,6 +1648,7 @@ enable_wineoss_drv
enable_wineps_drv
enable_winepulse_drv
enable_wineqtdecoder
enable_wineusb_sys
enable_winevulkan
enable_winex11_drv
enable_wing32
@ -1857,6 +1861,8 @@ GNUTLS_CFLAGS
GNUTLS_LIBS
SANE_CFLAGS
SANE_LIBS
USB_CFLAGS
USB_LIBS
GPHOTO2_CFLAGS
GPHOTO2_LIBS
GPHOTO2_PORT_CFLAGS
@ -2583,6 +2589,7 @@ Optional Packages:
--without-udev do not use udev (plug and play support)
--without-unwind do not use the libunwind library (exception
handling)
--without-usb do not use the libusb library
--without-v4l2 do not use v4l2 (video capture)
--without-vkd3d do not use vkd3d (Direct3D 12 support)
--without-vulkan do not use Vulkan
@ -2635,6 +2642,8 @@ Some influential environment variables:
GNUTLS_LIBS Linker flags for gnutls, overriding pkg-config
SANE_CFLAGS C compiler flags for libsane, overriding pkg-config
SANE_LIBS Linker flags for libsane, overriding pkg-config
USB_CFLAGS C compiler flags for libusb-1.0, overriding pkg-config
USB_LIBS Linker flags for libusb-1.0, overriding pkg-config
GPHOTO2_CFLAGS
C compiler flags for libgphoto2, overriding pkg-config
GPHOTO2_LIBS
@ -4110,6 +4119,12 @@ if test "${with_unwind+set}" = set; then :
fi
# Check whether --with-usb was given.
if test "${with_usb+set}" = set; then :
withval=$with_usb;
fi
# Check whether --with-v4l2 was given.
if test "${with_v4l2+set}" = set; then :
withval=$with_v4l2;
@ -13905,6 +13920,89 @@ esac
fi
if test "x$with_usb" != "xno"
then
if ${USB_CFLAGS:+false} :; then :
if ${PKG_CONFIG+:} false; then :
USB_CFLAGS=`$PKG_CONFIG --cflags libusb-1.0 2>/dev/null`
fi
fi
if ${USB_LIBS:+false} :; then :
if ${PKG_CONFIG+:} false; then :
USB_LIBS=`$PKG_CONFIG --libs libusb-1.0 2>/dev/null`
fi
fi
USB_LIBS=${USB_LIBS:-"-lusb-1.0"}
$as_echo "$as_me:${as_lineno-$LINENO}: libusb-1.0 cflags: $USB_CFLAGS" >&5
$as_echo "$as_me:${as_lineno-$LINENO}: libusb-1.0 libs: $USB_LIBS" >&5
ac_save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $USB_CFLAGS"
ac_fn_c_check_header_mongrel "$LINENO" "libusb.h" "ac_cv_header_libusb_h" "$ac_includes_default"
if test "x$ac_cv_header_libusb_h" = xyes; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libusb_init in -lusb-1.0" >&5
$as_echo_n "checking for libusb_init in -lusb-1.0... " >&6; }
if ${ac_cv_lib_usb_1_0_libusb_init+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lusb-1.0 $USB_LIBS $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char libusb_init ();
int
main ()
{
return libusb_init ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_usb_1_0_libusb_init=yes
else
ac_cv_lib_usb_1_0_libusb_init=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_usb_1_0_libusb_init" >&5
$as_echo "$ac_cv_lib_usb_1_0_libusb_init" >&6; }
if test "x$ac_cv_lib_usb_1_0_libusb_init" = xyes; then :
:
else
USB_LIBS=""
fi
else
USB_LIBS=""
fi
CPPFLAGS=$ac_save_CPPFLAGS
test -z "$USB_CFLAGS" || USB_CFLAGS=`echo " $USB_CFLAGS" | sed 's/ -I\([^/]\)/ -I\$(top_builddir)\/\1/g'`
test -z "$USB_LIBS" || USB_LIBS=`echo " $USB_LIBS" | sed 's/ -L\([^/]\)/ -L\$(top_builddir)\/\1/g'`
fi
if test "$ac_cv_lib_usb_1_0_libusb_init" != "yes"; then :
case "x$with_usb" in
x) as_fn_append wine_notices "|libusb-1.0 ${notice_platform}development files not found, USB devices won't be supported." ;;
xno) ;;
*) as_fn_error $? "libusb-1.0 ${notice_platform}development files not found, USB devices won't be supported.
This is an error since --with-usb was requested." "$LINENO" 5 ;;
esac
enable_wineusb_sys=${enable_wineusb_sys:-no}
fi
if test "x$with_v4l2" != "xno"
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -lv4l2" >&5
@ -19925,6 +20023,8 @@ GNUTLS_CFLAGS = $GNUTLS_CFLAGS
GNUTLS_LIBS = $GNUTLS_LIBS
SANE_CFLAGS = $SANE_CFLAGS
SANE_LIBS = $SANE_LIBS
USB_CFLAGS = $USB_CFLAGS
USB_LIBS = $USB_LIBS
GPHOTO2_CFLAGS = $GPHOTO2_CFLAGS
GPHOTO2_LIBS = $GPHOTO2_LIBS
GPHOTO2_PORT_CFLAGS = $GPHOTO2_PORT_CFLAGS
@ -21003,6 +21103,7 @@ wine_fn_config_makefile dlls/wineps.drv enable_wineps_drv
wine_fn_config_makefile dlls/wineps16.drv16 enable_win16
wine_fn_config_makefile dlls/winepulse.drv enable_winepulse_drv
wine_fn_config_makefile dlls/wineqtdecoder enable_wineqtdecoder
wine_fn_config_makefile dlls/wineusb.sys enable_wineusb_sys
wine_fn_config_makefile dlls/winevulkan enable_winevulkan
wine_fn_config_makefile dlls/winex11.drv enable_winex11_drv
wine_fn_config_makefile dlls/wing.dll16 enable_win16

View File

@ -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
@ -3780,6 +3793,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)

View File

@ -0,0 +1,8 @@
MODULE = wineusb.sys
IMPORTS = ntoskrnl
EXTRALIBS = $(USB_LIBS)
EXTRAINCL = $(USB_CFLAGS)
EXTRADLLFLAGS = -Wl,--subsystem,native
C_SRCS = \
wineusb.c

View File

@ -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;
}

View File

@ -0,0 +1 @@
# nothing to export

View File

@ -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,-