Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

usbmuxd link dependency libusb0.lib #9

Open
xJonPx opened this issue Sep 10, 2019 · 5 comments
Open

usbmuxd link dependency libusb0.lib #9

xJonPx opened this issue Sep 10, 2019 · 5 comments

Comments

@xJonPx
Copy link

xJonPx commented Sep 10, 2019

Error: usbmuxd won't link as there is a build configuration link library dependency with libusb0.lib. libusb0.lib does not appear to be part of the libusb library or the winusb ddk library.

What is the source of the mystery libusb0.lib?

@qmfrederik
Copy link
Contributor

usbmuxd uses libusb-win32. That said, you'll need specific patches/drivers so that you can change the USB configuration of the device.

What's your use case for using usbmuxd on Windows? It's much easier to use the Apple Mobile Device Service instead.

@xJonPx
Copy link
Author

xJonPx commented Sep 14, 2019

Hi qmfrederik,

Ref libusbmux-win32

I now see what you mean about the need to change the USB configuration of the device which is not possible with the libusb1.0 api and libusb0.sys under windows.

In this code it seems to fall back to the old libusb0 api to achieve this USB configuration change in the main usb discover thread.

However, to set the USB configuration with the old libusb0 api there is a need for the UDID serial.

The latest code here attempts to use the libusb1.0 api to get the necessary UDID serial but that is just not supported or possible.

I've pulled down the latest libimobiledevice-win32 binaries and usbmuxd seems to work fine under windows, the UDID serial gets read and the USB configuration changes.

Do you know if these binaries obtain the UDID serial in a different way in order to change the USB configuration?

Grateful for any advice as I'm keen to repeat what I see using the latest libimobiledevice-win32 release binaries.

Hopefully this makes some sense :-)

@qmfrederik
Copy link
Contributor

It's been a while since I last worked with usbmuxd on Windows (for the reasons above, the Apple Mobile Device Service is a good option in most cases).

That said, the bulk of the code which gets the UDID and changes the configuration comes from this patch: libimobiledevice-win32/usbmuxd@8043f71
The idea was to use libusb-win32 instead of libusb on Windows.

However, I also submitted patches for libusb (libusb/libusb#473) with which you can use libusb to set the configuration of an USB device on Windows, at the condition that you are using the libusb0.sys driver (i.e. the libusb-win32 kernel driver, but the 'standard' libusb user mode code).

To make things a bit more complicated, I also changed the build system for libimobiledevice-win32 to use a single repository with the Visual Studio project files and to us VCPKG for the dependencies (instead of CoApp).

You'll probably need to do some digging around in the code to get all the pieces together; but you should be able to make things work.

Let me know how it goes, and happy to review any patches you may send our way ;-).

@xJonPx
Copy link
Author

xJonPx commented Sep 17, 2019

qmfrederik

Thank you for coming back on this. I'm really keen to get this going on windows just to keep everything open source.

It's all a bit nasty using both the latest and legacy libusb API on Windows but it seems to work.

The problem in win32 seems to be line 430 of the patch: libimobiledevice-win32/usbmuxd@8043f71, i find it fails getting the serial (UDID).

If I hard code my serial (UDID) everything seem to works well and the configuration changes.

I'm really at a loss how the win32 binary seems to be working.

I'm currently exploring another win32 method to obtain serial for the found device. I'll post back if I can get a method that works.

Really great work with the VCPKG dependencies. There were a few more that I needed to pull down to get things working. I'll drop you a note of the extra ones I needed to pull through VCPKG so you have a complete list.

@qmfrederik
Copy link
Contributor

That's really odd, though; it used to work (at least when I tried it a couple of years ago).

Things you can look at:

  • What error code do you get?
  • What is the value of devdesc.iSerialNumber?
  • If you enable libusb debugging, is there any output pointing at a potential problem?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants