Hi Pete,

On 08/08/2012 02:41 AM, Pete Batard wrote:
All,

If you have some interest with regards to libusb-win32 and libusbK
driver support, you may want to have a look at the new 0K ("zero K")
branch from the pbatard/libusbx repo on github [1].

Great news. Thanks.

I have now pushed a patch that adds libusb0.sys and libusbK.sys support
there, for testing.

To fetch the branch:

   git clone git://github.com/pbatard/libusbx.git libusbx-pbatard
   cd libusbx-pbatard
   git checkout 0K


For testing, you may also want to install the libusb-win32 and libusbK
drivers, in which case you can use the latest Zadig, released today, and
that include support for libusb0.sys v1.2.6.0&  libusbK v3.0.5.16 RC
(Will K 3.0.5 ever go out of RC?).
As usual, Zadig can be downloaded at [2].


I gave it a run.

Short story: With some changes, I could read a block from a usb disk.

Long story: I've installed the filter-driver using Zadig (build 156), and ran xusb with a USB disk.
It failed (segfault).
I debugged it, and with came up with the attached patch.

Still failed, now with an error message "The parameter is incorrect" for control and bulk transfers.

I downloaded libusbk-3.0.5.16-setup.exe and installed it's filter driver.
 - note 1: first the filter-driver installed by zadig was removed.
- note 2: libusbK and libusb0 drivers were not installed, only the filter driver.

After that xusb was able to successfully read read a block from a usb mass storage device.

Hoping for a miracle, I tried usbredir, but it failed with a bunch of "the device is not connected" error messages.

Two notes about zadig (build 156):
1. It seems the new version installs WdfCoInstaller01011.dll but is looking for WdfCoInstaller01009.dll Copying the required dll to the appropriate place (e.g. c:\usb_driver\x86) solved that problem.

2. zadig_v2.0.1.156 - contains libusb0 filter driver version 1.2.5.0
libusbk-3.0.5.16-setup.exe contains libusb0 filter driver version 1.2.6.0

Thanks,
    Uri.



>From a123d7c126b0511fe178f4a36b613f40a16e5eff Mon Sep 17 00:00:00 2001
From: Uri Lublin <u...@redhat.com>
Date: Sun, 12 Aug 2012 18:13:52 +0300
Subject: [PATCH] windows_usb: filter_driver: pass char* filter_driver

Since the callee function does not allocate the buffer, only fills it
there is no need to pass char **.

Also since the buffer is being modified, declare it as an array,
instead of a pointer that is initialized to a non-malleable string.
---
 libusb/os/windows_usb.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c
index fde328e..104f2b9 100644
--- a/libusb/os/windows_usb.c
+++ b/libusb/os/windows_usb.c
@@ -298,7 +298,7 @@ static bool get_devinfo_data(struct libusb_context *ctx,
  * incremented index starting at zero) until all interfaces have been returned.
  */
 static SP_DEVICE_INTERFACE_DETAIL_DATA_A *get_interface_details(struct 
libusb_context *ctx,
-       HDEVINFO *dev_info, SP_DEVINFO_DATA *dev_info_data, const GUID* guid, 
unsigned _index, char** filter_path)
+       HDEVINFO *dev_info, SP_DEVINFO_DATA *dev_info_data, const GUID* guid, 
unsigned _index, char* filter_path)
 {
        SP_DEVICE_INTERFACE_DATA dev_interface_data;
        SP_DEVICE_INTERFACE_DETAIL_DATA_A *dev_interface_details = NULL;
@@ -370,8 +370,8 @@ static SP_DEVICE_INTERFACE_DETAIL_DATA_A 
*get_interface_details(struct libusb_co
                                if (libusb0_symboliclink_index < 256) {
                                        // libusb0.sys is connected to this 
device instance
                                        // If the the device interface guid is 
{F9F3FF14-AE21-48A0-8A25-8011A7A931D9} then it's a filter
-                                       safe_sprintf(*filter_path, 
sizeof("\\\\.\\libusb0-0000"), "\\\\.\\libusb0-%04d", 
libusb0_symboliclink_index);
-                                       usbi_info(ctx,"assigned libusb0 
symbolic link %s", *filter_path);
+                                       safe_sprintf(filter_path, 
sizeof("\\\\.\\libusb0-0000"), "\\\\.\\libusb0-%04d", 
libusb0_symboliclink_index);
+                                       usbi_info(ctx, "assigned libusb0 
symbolic link %s", filter_path);
                                } else {
                                        // libusb0.sys was connected to this 
device instance at one time; but not anymore
                                }
@@ -2626,11 +2626,12 @@ static int winusbx_claim_interface(int sub_api, struct 
libusb_device_handle *dev
        HDEVINFO dev_info;
        SP_DEVINFO_DATA dev_info_data;
        char* dev_path_no_guid = NULL;
-       char* filter_path = "\\\\.\\libusb0-0000";
+       char filter_path[sizeof("\\\\.\\libusb0-0000")];
        bool found_filter = false;

        CHECK_WINUSBX_AVAILABLE(sub_api);

+       strcpy(filter_path, "\\\\.\\libusb0-0000");
        // If the device is composite, but using the default Windows composite 
parent driver (usbccgp)
        // or if it's the first WinUSB-like interface, we get a handle through 
Initialize().
        if ((is_using_usbccgp) || (iface == 0)) {
@@ -2654,7 +2655,7 @@ static int winusbx_claim_interface(int sub_api, struct 
libusb_device_handle *dev
                                for (i = 0; ; i++) {
                                        safe_free(dev_interface_details);
                                        safe_free(dev_path_no_guid);
-                                       dev_interface_details = 
get_interface_details(ctx, &dev_info, &dev_info_data, 
&GUID_DEVINTERFACE_LIBUSB0_FILTER, i, &filter_path);
+                                       dev_interface_details = 
get_interface_details(ctx, &dev_info, &dev_info_data, 
&GUID_DEVINTERFACE_LIBUSB0_FILTER, i, filter_path);
                                        if ((found_filter) || 
(dev_interface_details == NULL)) {
                                                break;
                                        }
-- 
1.7.7.6

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel

Reply via email to