libusb-win32
libusb-win32 copied to clipboard
libusb_dyn.c is missing stubs for several of the libusb-win32 functions
Updated: 2012-08-09 Created: 2012-05-20 Creator: Benjamin Moody
libusb_dyn.c is missing stubs for several of the libusb-win32 functions:
usb_touch_inf_file_np
usb_install_needs_restart_np
usb_install_npW
usb_install_npA
usb_reap_async_nocancel
usb_cancel_async
(It's also missing the various _rundll stubs, but I doubt there's any point in including those.)
The first four are related to driver installation, and any program that uses those will probably want to link to libusb0.dll directly. But usb_reap_async_nocancel and usb_cancel_async should at least be included.
(I'm trying to compile a program (tilem) that links to a library (libticables2) that links to libusb (and uses those two functions), but my program doesn't currently make use of the USB features of libticables2, so I would like to avoid the libusb0.dll dependency if possible.)
Patch is attached; I have not tested it beyond making sure it compiles, but it's pretty straightforward.
--- libusb_dyn.c.orig 2011-07-12 07:20:28.000000000 -0400
+++ libusb_dyn.c 2012-05-19 20:59:06.000000000 -0400
@@ -66,6 +66,10 @@
typedef int (*usb_install_service_np_t)(void);
typedef int (*usb_uninstall_service_np_t)(void);
typedef int (*usb_install_driver_np_t)(const char *inf_file);
+typedef int (*usb_touch_inf_file_np_t)(const char *inf_file);
+typedef int (*usb_install_needs_restart_np_t)(void);
+typedef int (*usb_install_npW_t)(HWND hwnd, HINSTANCE instance, LPCWSTR cmd_line, int starg_arg);
+typedef int (*usb_install_npA_t)(HWND hwnd, HINSTANCE instance, LPCSTR cmd_line, int starg_arg);
typedef const struct usb_version * (*usb_get_version_t)(void);
typedef int (*usb_isochronous_setup_async_t)(usb_dev_handle *dev,
void **context,
@@ -76,6 +80,8 @@
unsigned char ep);
typedef int (*usb_submit_async_t)(void *context, char *bytes, int size);
typedef int (*usb_reap_async_t)(void *context, int timeout);
+typedef int (*usb_reap_async_nocancel_t)(void *context, int timeout);
+typedef int (*usb_cancel_async_t)(void *context);
typedef int (*usb_free_async_t)(void **context);
@@ -108,12 +114,18 @@
static usb_install_service_np_t _usb_install_service_np = NULL;
static usb_uninstall_service_np_t _usb_uninstall_service_np = NULL;
static usb_install_driver_np_t _usb_install_driver_np = NULL;
+static usb_touch_inf_file_np_t _usb_touch_inf_file_np = NULL;
+static usb_install_needs_restart_np_t _usb_install_needs_restart_np = NULL;
+static usb_install_npW_t _usb_install_npW = NULL;
+static usb_install_npA_t _usb_install_npA = NULL;
static usb_get_version_t _usb_get_version = NULL;
static usb_isochronous_setup_async_t _usb_isochronous_setup_async = NULL;
static usb_bulk_setup_async_t _usb_bulk_setup_async = NULL;
static usb_interrupt_setup_async_t _usb_interrupt_setup_async = NULL;
static usb_submit_async_t _usb_submit_async = NULL;
static usb_reap_async_t _usb_reap_async = NULL;
+static usb_reap_async_nocancel_t _usb_reap_async_nocancel = NULL;
+static usb_cancel_async_t _usb_cancel_async = NULL;
static usb_free_async_t _usb_free_async = NULL;
@@ -184,6 +196,14 @@
GetProcAddress(libusb_dll, "usb_uninstall_service_np");
_usb_install_driver_np = (usb_install_driver_np_t)
GetProcAddress(libusb_dll, "usb_install_driver_np");
+ _usb_touch_inf_file_np = (usb_touch_inf_file_np_t)
+ GetProcAddress(libusb_dll, "usb_touch_inf_file_np");
+ _usb_install_needs_restart_np = (usb_install_needs_restart_np_t)
+ GetProcAddress(libusb_dll, "usb_install_needs_restart_np");
+ _usb_install_npW = (usb_install_npW_t)
+ GetProcAddress(libusb_dll, "usb_install_npW");
+ _usb_install_npA = (usb_install_npA_t)
+ GetProcAddress(libusb_dll, "usb_install_npA");
_usb_get_version = (usb_get_version_t)
GetProcAddress(libusb_dll, "usb_get_version");
_usb_isochronous_setup_async = (usb_isochronous_setup_async_t)
@@ -196,6 +216,10 @@
GetProcAddress(libusb_dll, "usb_submit_async");
_usb_reap_async = (usb_reap_async_t)
GetProcAddress(libusb_dll, "usb_reap_async");
+ _usb_reap_async_nocancel = (usb_reap_async_nocancel_t)
+ GetProcAddress(libusb_dll, "usb_reap_async_nocancel");
+ _usb_cancel_async = (usb_cancel_async_t)
+ GetProcAddress(libusb_dll, "usb_cancel_async");
_usb_free_async = (usb_free_async_t)
GetProcAddress(libusb_dll, "usb_free_async");
@@ -437,6 +461,38 @@
return -ENOFILE;
}
+int usb_touch_inf_file_np(const char *inf_file)
+{
+ if (_usb_touch_inf_file_np)
+ return _usb_touch_inf_file_np(inf_file);
+ else
+ return -1;
+}
+
+int usb_install_needs_restart_np(void)
+{
+ if (_usb_install_needs_restart_np)
+ return _usb_install_needs_restart_np();
+ else
+ return FALSE;
+}
+
+int usb_install_npW(HWND hwnd, HINSTANCE instance, LPCWSTR cmd_line, int starg_arg)
+{
+ if (_usb_install_npW)
+ return _usb_install_npW(hwnd, instance, cmd_line, starg_arg);
+ else
+ return -1;
+}
+
+int usb_install_npA(HWND hwnd, HINSTANCE instance, LPCSTR cmd_line, int starg_arg)
+{
+ if (_usb_install_npA)
+ return _usb_install_npA(hwnd, instance, cmd_line, starg_arg);
+ else
+ return -1;
+}
+
const struct usb_version *usb_get_version(void)
{
if (_usb_get_version)
@@ -487,6 +543,22 @@
else
return -ENOFILE;
}
+
+int usb_reap_async_nocancel(void *context, int timeout)
+{
+ if (_usb_reap_async_nocancel)
+ return _usb_reap_async_nocancel(context, timeout);
+ else
+ return -ENOFILE;
+}
+
+int usb_cancel_async(void *context)
+{
+ if (_usb_cancel_async)
+ return _usb_cancel_async(context);
+ else
+ return -ENOFILE;
+}
int usb_free_async(void **context)
{
From: Travis These two should be in there, If not we need to add them. ;)
- usb_reap_async_nocancel
- usb_cancel_async
The others have been deprecated. They are inadequate because of UAC and 64bit.
@dontech Please check if you can add the two functions that Travis mentioned.
usb_reap_async_nocancel
usb_cancel_async
https://github.com/mcuee/libusb-win32/commit/b559bead6d2a8f81d5c5593038d08d8a31de9faf
FIXED