USB redirection

Hi all,

I am going through the example code shared at

here client side code is for windows, but server side its there for LINUX, what I want is server side also should be for windows, any link is there so that i can just refer and learn

or if I can get some hint how to proceed would be very helpful, client side I am able to install virtual driver , but server side where actuall USB will be attached , I think server should be there so that communication can happen.

please provide some idea how to proceed, basically I need win to win .

thanks.

The docs are a bit confusing but it supports windows as either a client or a server.

but how to use it as server, if i go through the documentation its not clear, the command which is mentioned is for linux machine right, need some idea how to achieve this, actually i have remote application which uses TCP channel to communicate,where i just want to redirect USB from host machine to local machine. just to achieve that i am referring this but not able to get how to redirect actual host side attached USB to local machine where virtual driver will be installed

As I said, the readme is confusing. However in the Windows server section when you get to the last step:

  • Attach USB/IP device on Linux machine
  • # usbip attach -r <usbip server ip> -b 1-59

Just ignore that and follow the windows client install (ignoring the linux server install steps)./

so if i am not wrong, the above steps itself not required for windows as server

  • Run usbipd.exe
    • > usbipd.exe -d -4
    • TCP port 3240 should be allowed by firewall

above command will run the server, and at client side we need to attach to server ip

using

  • Attach a remote USB device
    • PS> usbip.exe attach -r <usbip server ip> -b 2-2

plz correct me if i am wrong

thanks

Hi all

when i run below command in server machine

usbipd.exe -d -4
usbipd: info: starting usbipd (usbip-win 0.3.5)
usbipd: debug: usbipd_sock.c:38:[build_sockfd] opening 0.0.0.0:3240
usbipd: info: listening on 0.0.0.0:3240

here port number is 3240 but what is 0.0.0.0?
is it ip of usbip server?

if so when i try to
run below command in client
usbip.exe attach -r 0.0.0.0 -b 3-2

its saying
usbip: error: failed to connect a remote host: 0.0.0.0

plz help , what I am doing wrong?

@Mark_Roddy @Tim_Roberts need your help

Hi mark

when i run below command in server machine

usbipd.exe -d -4
usbipd: info: starting usbipd (usbip-win 0.3.5)
usbipd: debug: usbipd_sock.c:38:[build_sockfd] opening 0.0.0.0:3240
usbipd: info: listening on 0.0.0.0:3240

here port number is 3240 but what is 0.0.0.0?
is it ip of usbip server?

if so when i try to
run below command in client
usbip.exe attach -r 0.0.0.0 -b 3-2

its saying
usbip: error: failed to connect a remote host: 0.0.0.0

plz help , what I am doing wrong?

Have you not done TCP/IP socket code? When a server binds to 0.0.0.0, that just means "we are listening on all the interfaces". You should be able to use any IP address that the server exposes. If you're on the same system, use 127.0.0.1. Otherwise, you'll need its IP address.

Hi tim,

i am using usbip-win code from the git path i shared above, i think they already have handled socket part and as per their doc we just need to call usbipd.exe -d -4

but after running this command the ip i got is 0.0.0.0 and same i am using at server side to attach

usbip.exe attach -r 0.0.0.0 -b busid

but the connection keeps failing

so what is the issue here, do i need to code my own tcp ip channel and that we can use for communication between usb ip server and client or this usbip-win code itself has some issue?

Hi tim,

I have completed basic of USB redirection project, and i am able to redirect mice, so i just want to know is it possible to have generic .inf file which can work with different hardware id, not only specific to one .....i have tried putting multiple hardware id in inf file but some how its not working, if i put just one then its working fine

my inf file is below

;/++
;
; INF file for installing USB/IP stub driver
;
;--
/
[Version]
Signature="$WINDOWS NT$"
; USB class cannot be installed via legacy hardware. It can be done via devcon
;Class=USB
;ClassGUID={36FC9E60-C465-11CF-8056-444553540000}
Class=System
ClassGuid={4D36E97D-E325-11CE-BFC1-08002BE10318}
Provider=%OpenSource%
CatalogFile=usbip_stub.cat
DriverVer = 07/19/2021,0.3.5.0

[Manufacturer]
%StdMfg%=Standard,NTamd64

[Standard.NTamd64]
;%DeviceDesc%=usbip_stub_Device, USB\VID_046D&PID_C52B&REV_1211
;%DeviceDesc%=usbip_stub_Device, USB\VID_046D&PID_C077&REV_7200
%DeviceDesc%=usbip_stub_Device, USB\VID_1EA7&PID_0064&REV_0200
[DestinationDirs]
DefaultDestDir = 12

[SourceDisksNames]
1 = %DiskId1%,,,""

[SourceDisksFiles]
usbip_stub.sys = 1,,

[Drivers_Dir]
usbip_stub.sys

[usbip_stub_Device.NTamd64]
CopyFiles=Drivers_Dir

[usbip_stub_Device.NTamd64.HW]
AddReg=usbip_stub_Device_AddReg

[usbip_stub_Device_AddReg]
HKR,,DeviceCharacteristics,0x10001,0x0100 ; Use same security checks on relative opens
;Using default permissions so comment out next lines
;HKR,,Security,,"D:P(A;;GA;;;SY)(A;;GRGWGX;;;BA)(A;;GRGWGX;;;WD)(A;;GRGWGX;;;RC)" ; Allow generic-all access to all users
;HKR,,Security,,"D:P(A;;GA;;;BA)(A;;GA;;;SY)" ; Allow generic-all access to Built-in administrators and Local system

;-------------- Service installation
[usbip_stub_Device.NTamd64.Services]
AddService = usbip_stub,%SPSVCINST_ASSOCSERVICE%, usbip_stub_Service_Inst

; -------------- stub driver install sections
[usbip_stub_Service_Inst]
DisplayName = %ServiceDesc%
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 3 ; SERVICE_DEMAND_START
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
ServiceBinary = %12%\usbip_stub.sys
LoadOrderGroup = Extended Base

[Strings]
SPSVCINST_ASSOCSERVICE= 0x00000002
OpenSource = "Open Source"
StdMfg = "USB/IP Project"
DiskId1 = "USB/IP STUB Disk"
DeviceDesc = "USB/IP STUB"
ServiceDesc = "USB/IP STUB Service"

need help on this, how to achieve this, in case of multiple hardware id in single inf file i am getting error USB :failed to select driver: 0x6f8 , how to proceed

thanks

Well, it is possible to install yourself as an upper class filter for all devices in the "USB Device" class. That's just a simple registry entry. But that means you had better be prepared to handle ALL USB devices. Have you tried an assortment of devices to make sure your forwarding works? Disk drives? Audio devices? Web cams?

1 Like

Thanks for quick response, tim

actually for now i have tried only mouse, keyboard its working as expected

can you plz provide some link to follow for upper class filter for all devices in the "USB Device" class

that would be helpful to understand how to proceed..

thanks

hi tim, i have tried changing the inf

;/++
;
; INF file for installing USB/IP stub driver as an upper-class filter
;
;--
/
[Version]
Signature="$WINDOWS NT$"
; USB class cannot be installed via legacy hardware. It can be done via devcon
Class=USB
ClassGUID={36FC9E60-C465-11CF-8056-444553540000}
Provider=%OpenSource%
CatalogFile=usbip_stub.cat
DriverVer = 09/06/2024,0.3.0.0

[Manufacturer]
%StdMfg%=Standard,NTamd64

[Standard.NTamd64]
%DeviceDesc%=usbip_stub_Device, USB*

[DestinationDirs]
DefaultDestDir = 12

[SourceDisksNames]
1 = %DiskId1%,,,""

[SourceDisksFiles]
usbip_stub.sys = 1,,

[Drivers_Dir]
usbip_stub.sys

[usbip_stub_Device.NTamd64]
CopyFiles=Drivers_Dir

[usbip_stub_Device.NTamd64.HW]
AddReg=usbip_stub_Device_AddReg

[usbip_stub_Device_AddReg]
HKR,,DeviceCharacteristics,0x10001,0x0100 ; Use same security checks on relative opens
;Using default permissions so comment out next lines
;HKR,,Security,,"D:P(A;;GA;;;SY)(A;;GRGWGX;;;BA)(A;;GRGWGX;;;WD)(A;;GRGWGX;;;RC)" ; Allow generic-all access to all users
;HKR,,Security,,"D:P(A;;GA;;;BA)(A;;GA;;;SY)" ; Allow generic-all access to Built-in administrators and Local system

;-------------- Service installation
[usbip_stub_Device.NTamd64.Services]
AddService = usbip_stub,%SPSVCINST_ASSOCSERVICE%, usbip_stub_Service_Inst

; -------------- stub driver install sections
[usbip_stub_Service_Inst]
DisplayName = %ServiceDesc%
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 3 ; SERVICE_DEMAND_START
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
ServiceBinary = %12%\usbip_stub.sys
LoadOrderGroup = Extended Base

[ClassInstall32]
AddReg=AddUpperFilter

[AddUpperFilter]
HKLM,System\CurrentControlSet\Control\Class{36FC9E60-C465-11CF-8056-444553540000},UpperFilters,0x00000000,usbip_stub

[Strings]
SPSVCINST_ASSOCSERVICE= 0x00000002
OpenSource = "Open Source"
StdMfg = "USB/IP Project"
DiskId1 = "USB/IP STUB Disk"
DeviceDesc = "USB/IP STUB"
ServiceDesc = "USB/IP STUB Service"

but while checking with different hardware id its giving error

USB :driver installation with hid====USB\VID_1EA7&PID_0064&REV_0200
USB :failed to select driver: 0x6f8

The open source usb-ip project for Windows is here: GitHub - dorssel/usbipd-win: Windows software for sharing locally connected USB devices to other machines, including Hyper-V guests and WSL 2.

hi mark

actually i have referred GitHub - cezanne/usbip-win: USB/IP for Windows and i am able to redirect also, but here the issue is for every new hardware id , inf file need to be modified, which i dont want..my requirement is to have generic inf file which i can sign once to use with all types of hardware id....need this for stub driver installation

Then you really need to consider implementing a usb bus filter driver. This is what the horrible vbox driver is doing in a truly awful way, but there are supported if mostly undocumented ways to do this correctly.

A usb bus filter driver sits on top of a usb controller (or controllers) and attaches its own device objects to every pdo enumerated by the controller. By default these pdo-attached device objects are just passive. Your management interface can then activate whichever pdo is needed.

That above description is grossly simplified. The usb architecture is tree based and complicated. You really are interested in the PDOs enumerated by the assorted usb hubs. However hubs and controllers are all the same class, so installing a class filter in the registry (which is the easiest way to do this) attaches to controllers and hubs (and legacy errant nonsense that continues to use 'USB' as their class.) But again, your filter just ignores the PDO's you don't really care about.