14

I'm investigating options available for creating a virtual USB device (say, a keyboard or a mass storage device), so to emulate its function as needed and to allow a userspace app to emulate its insertion/removal at will.

What I am not clear about is how to go about the emulation of insertion/removal. It seems that one option is to emulate a (virtual) USB hub and have it fake the device arrival/departure events (and I would also supply the device driver for my virtual USB device and that's where my device logic will reside).

I know my way around Windows kernel (having written NDIS miniport drivers), not afraid of SoftICE, but USB is not my domain, just starting out with it.

Am I on the right track with the virtual hub approach? If so, is developing virtual hub drivers supported by WDK (it doesn't seem to be)?

Any other options?

--

(Edit) Forgot to mention - I am aware of DSF, but it is not supported on W8.

Angstrom
  • 352
  • 1
  • 2
  • 16
  • 6
    Have you looked at the USBIP project (ons sourceforge)? Their USB over IP implementation does exactly that, and they provide very stable Windows drivers! You might end up writing an USB/IP server as th easier (and network-transparent as a bonus) alternative. – Eugen Rieck Dec 15 '13 at 21:09
  • Duh! I know of the project, but I have no idea why I haven't looked at how they emulate device insertion/removal. Very helpful, Eugen. Thanks a lot. – Angstrom Dec 15 '13 at 21:16
  • 2
    Angstrom, I might have forgotten myself, had I not just been fooling around with it a short while ago: Two USB devices, both using the exact same chip, but different VID/PIDs - one vendor providing no drivers for newer Windows versions, the other does, but hard-locked to VID/PID ... trivially patch USBIP to change VID/PID on the fly, problem solved. – Eugen Rieck Dec 15 '13 at 21:20
  • 1
    Elegant :) Have you tested it in W8? – Angstrom Dec 15 '13 at 21:24
  • TBH: None of our software supports W8 (or Vista). Only usable Windows versions are supported. Our customers ar VERY fine with this. I can ask the guys about W8.1 tomorrow and post back. The beforementioned patch was done server-sided. – Eugen Rieck Dec 15 '13 at 21:28
  • @Angstrom have you ever finished the software to emulate usb hub+device? If yes, it is available for public? There are some OS/boot installers that ask for usb devices instead of accepting virtual removable images – Costin Gușă Sep 14 '20 at 15:27

2 Answers2

6

Am I on the right track with the virtual hub approach?

In short - yes, I was right.

That's how USBIP does it and it's a relatively simple way to go. Also, see this comment by Eugen.

Community
  • 1
  • 1
Angstrom
  • 352
  • 1
  • 2
  • 16
  • have you written a blog post about how you wrote your own virtual USB device? Some of us are quite interested in doing the same, and there are (still, in 2017) no good articles that can be found with a google or duckduckgo search. – Mike 'Pomax' Kamermans Nov 02 '17 at 16:11
  • I am not of a blog post writing variety. Sorry. – Angstrom Nov 24 '17 at 22:09
  • that is unfortunate for the rest of us. – Mike 'Pomax' Kamermans Dec 02 '17 at 16:56
  • 3
    Don't get me wrong: I didn't mean to slight you, I genuinely mean that's unfortunate for the rest of us. This is a QA site, you found the answer, but didn't write it out in full here, to the degree that (based on the answer text) we can easily do the same. You are not the blogging type, and that's no one else's business, but it _is_ unfortunate for us. We, (e.g. everyone on SO who finds this question and hopes the answer will help them) will not _really_ find the answer they were hoping to find, so we have to keep looking for some future Q/A on the subject. – Mike 'Pomax' Kamermans Dec 03 '17 at 16:50
3

I don't know if you are aware, but Microsoft released to Win10 the UDE (USB device emulation).

In the section Write a UDE client driver they describe exactly what you want.

Luiz Vaz
  • 1,669
  • 1
  • 19
  • 32