reqiured Reference code for writing virtual host controller in windows

Dear All,
Currently virtual host controller which handles MAUSB protocol. which we are loading as root bus drivers. further this bus driver will create pdos for the device which need to enumerate.

But current root driver devices which it enumerated is not shown in usbview or usblyzer.
looks like no hub driver dont have the mausb(hostcontroller details).

Can anybody help me to make mausb bus driver as host controller to so that any hub driver can respond to IOCTL_USB_GET_CONNECTION_INFORMATION, IOCTL_USB_GET_CONNECTION_NAME,
IOCTL_USB_GET_CONNECTION_INFORMATION_EX, IOCTL_USB_PORT_CONNECTOR_PROPERTIES

INF :
; USB class cannot be installed via legacy hardware. It can be done via devcon
Class=USB
ClassGUID={36FC9E60-C465-11CF-8056-444553540000}
[Standard]
%DeviceDesc%=Mausb_Device, root\MAUSBEnum

MAUSB Bus driver:
status = IoCreateDevice(
DriverObject, // our driver object
sizeof (struct FDO_DEVICE_DATA), // device object extension size
NULL, // FDOs do not have names
FILE_DEVICE_BUS_EXTENDER, // We are a bus
FILE_DEVICE_SECURE_OPEN, //
TRUE, // our FDO is exclusive
&deviceObject); // The device object created

There is no reference source code until MSFT open sources windows.

There is a new-ish microsoft interface for USB controller drivers: “UCX
provides functionality to assist a host controller client driver in
managing a USB host controller device.”
https://msdn.microsoft.com/en-us/library/windows/hardware/mt188009(v=vs.85).aspx

This may or may not meet your needs. In particular if you need to support
OS version prior to W10, you have to reverse engineer the controller/hub
architecture and support all the interfaces and ioctls required to convince
the OS to use your controller enumerated pdos.

Mark Roddy

On Fri, Jul 21, 2017 at 6:02 AM, xxxxx@lge.com > wrote:

> Dear All,
> Currently virtual host controller which handles MAUSB protocol. which we
> are loading as root bus drivers. further this bus driver will create pdos
> for the device which need to enumerate.
>
> But current root driver devices which it enumerated is not shown in
> usbview or usblyzer.
> looks like no hub driver dont have the mausb(hostcontroller details).
>
> Can anybody help me to make mausb bus driver as host controller to so that
> any hub driver can respond to IOCTL_USB_GET_CONNECTION_INFORMATION,
> IOCTL_USB_GET_CONNECTION_NAME,
> IOCTL_USB_GET_CONNECTION_INFORMATION_EX, IOCTL_USB_PORT_CONNECTOR_
> PROPERTIES
>
> INF :
> ; USB class cannot be installed via legacy hardware. It can be done via
> devcon
> Class=USB
> ClassGUID={36FC9E60-C465-11CF-8056-444553540000}
> [Standard]
> %DeviceDesc%=Mausb_Device, root\MAUSBEnum
>
> MAUSB Bus driver:
> status = IoCreateDevice(
> DriverObject, //
> our driver object
> sizeof (struct FDO_DEVICE_DATA), // device object
> extension size
> NULL,
> // FDOs do not have names
> FILE_DEVICE_BUS_EXTENDER, // We are
> a bus
> FILE_DEVICE_SECURE_OPEN, //
> TRUE,
> // our FDO is exclusive
> &deviceObject); //
> The device object created
>
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: http:> showlists.cfm?list=ntdev>
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at <
> http://www.osronline.com/page.cfm?name=ListServer&gt;
></http:></http:>

xxxxx@lge.com xxxxx@lists.osr.com wrote:

Currently virtual host controller which handles MAUSB protocol. which we are loading as root bus drivers. further this bus driver will create pdos for the device which need to enumerate.

You have embarked on a difficult journey. There is a fair amount of
not-fully-documented communication between the stock drivers in a given
USB stack, from host controller to root hub to secondary hub. It has,
in general, not been possible to replace one without replacing them all.

But current root driver devices which it enumerated is not shown in usbview or usblyzer.

What PnP IDs are you using to expose your root hub(s)? Do you see your
enumerated devices in Device Manager? Do they have drivers assigned?

looks like no hub driver dont have the mausb(hostcontroller details).

I don’t know what that means.

MAUSB Bus driver:
status = IoCreateDevice(
DriverObject, // our driver object
sizeof (struct FDO_DEVICE_DATA), // device object extension size
NULL, // FDOs do not have names
FILE_DEVICE_BUS_EXTENDER, // We are a bus
FILE_DEVICE_SECURE_OPEN, //
TRUE, // our FDO is exclusive
&deviceObject); // The device object created

Did you not write this in KMDF? Why on earth not? You’re just asking
for trouble.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

@Tim Roberts thanks for reply
Quick reference for this development usbip(http://usbip.sourceforge.net/) is take as reference code currently and merged mausb protocol specfic. Now its required to implement some of HCD functionality to handle some hub specfic ioctls which i mentioned in above thread.

What PnP IDs are you using to expose your root hub(s)?
%DeviceDesc%=Mausb_Device, root\MAUSBEnum
in devicemanager hardware ids are show as root\MAUSBEnum

Do you see your enumerated devices in Device Manager? Do they have drivers assigned?

yes i am able to see enumerated devices and drivers loaded in device manager and functionality is also working.

In INF file following details are mentioned for this root bus to get enumerated.
[MAUSB_Device_AddReg]
HKR,DeviceCharacteristics,0x10001,0x0100 ; Use same security checks on relative opens

[MAUSB_Service_Inst]
DisplayName = %ServiceDesc%
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 3 ; SERVICE_DEMAND_START
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
ServiceBinary = %12%\MAUSBEnum.sys
LoadOrderGroup = Extended Base

%DeviceDesc%=Mausb_Device, root\MAUSBEnum

mausbenum bus driver is listed under USB controllers in device manager.
But when i try to see the pdos created in usbview it is not listed…

@Mark Roddy
Thanks I will go through the links…

On Jul 21, 2017, at 8:16 PM, xxxxx@gmail.com xxxxx@lists.osr.com wrote:

@Tim Roberts thanks for reply
Quick reference for this development usbip(http://usbip.sourceforge.net/) is take as reference code currently and merged mausb protocol specfic. Now its required to implement some of HCD functionality to handle some hub specfic ioctls which i mentioned in above thread.

What PnP IDs are you using to expose your root hub(s)?
%DeviceDesc%=Mausb_Device, root\MAUSBEnum
in devicemanager hardware ids are show as root\MAUSBEnum

But that’s your host controller, right? Your host controller has to expose a root hub, which can then expose the individual buses on your device. That’s what I’m asking – what IDs are YOU creating to get other drivers loaded?

Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

@Tim Roberts

But that’s your host controller, right? Your host controller has to expose a
root hub, which can then expose the individual buses on your device. That’s
what I’m asking – what IDs are YOU creating to get other drivers loaded?

its not complete host controller, basic bus driver which will create device object(pdo) for device need to be enumerated and calls IoInvalidateDeviceRelations with busrelations. from device we will query over wifi for pid/vid and class sub class details and will call validate details. And also based device mode composite(usbccgp) and vendor specific composite drivers is loaded. Then composite driver will be creating further pdos for supported interfaces(mtp/serial/acm etc).

USB\VID_xxxx&PID_xxxx&REV_0xxx
USB\Class_06&SubClass_01&Prot_01
USB\Class_06&SubClass_01
USB\Class_06

On Jul 23, 2017, at 10:56 PM, xxxxx@lge.com xxxxx@lists.osr.com wrote:

@Tim Roberts
> But that’s your host controller, right? Your host controller has to expose a
> root hub, which can then expose the individual buses on your device. That’s
> what I’m asking – what IDs are YOU creating to get other drivers loaded?

its not complete host controller, basic bus driver which will create device object(pdo) for device need to be enumerated and calls IoInvalidateDeviceRelations with busrelations. from device we will query over wifi for pid/vid and class sub class details and will call validate details. And also based device mode composite(usbccgp) and vendor specific composite drivers is loaded. Then composite driver will be creating further pdos for supported interfaces(mtp/serial/acm etc).

USB\VID_xxxx&PID_xxxx&REV_0xxx
USB\Class_06&SubClass_01&Prot_01
USB\Class_06&SubClass_01
USB\Class_06

In that case, USBView is never going to show your devices. The source code for USBView is publicly available – have you looked at it? It works by enumerating all of the host controllers in the system, then enumerating all of the hubs on that controller and all of the ports on those hubs. If you don’t register as a host controller, USBView will never see you. Just that simple.

Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

>In that case, USBView is never going to show your devices. The source code for

USBView is publicly available – have you looked at it? It works by enumerating
all of the host controllers in the system, then enumerating all of the hubs on
that controller and all of the ports on those hubs. If you don’t register as a
host controller, USBView will never see you. Just that simple.
@Tim,
yeah Tim, that’s why i am asking any reference code where i can register this driver as host controller and emulate as virtual host controller. so that my driver will support corresponding ioctls that can be viewed by any software like usbview, usblyzer.

starting from windows 10 UCX support is there for writing our own host controllers. But currently we need to support windows 7 WDM based driver

I tried to create FDO, FILE_DEVICE_CONTROLLER, and exploring using reactos code as reference.

You need to reverse engineer usb controller devices and their associated
root hub device objects. .It is a non-trivial endeavor.

The root hubs present the usb target pdos, not the controller. The
controller enumerates one or more root hub pdos. Both hubs and controllers
must respond to a set of IOCTLs that are specific to either hubs or
controllers, many of which are undocumented. If I recall correctly there is
also a driver interface you need to implemet: USB_BUS_INTERFACE_USBDI_GUID.

Root hub pdos are FILE_DEVICE_USB and have pnp id’s based off of
“USB\ROOT_HUB” You have to provide device, configuration, interface,
endpoint, pipe and hub descriptors as defined by the usb spec for hubs.

Mark Roddy

On Tue, Jul 25, 2017 at 3:55 AM, xxxxx@lge.com > wrote:

> >In that case, USBView is never going to show your devices. The source
> code for
> >USBView is publicly available – have you looked at it? It works by
> enumerating
> >all of the host controllers in the system, then enumerating all of the
> hubs on
> >that controller and all of the ports on those hubs. If you don’t
> register as a
> >host controller, USBView will never see you. Just that simple.
> @Tim,
> yeah Tim, that’s why i am asking any reference code where i can register
> this driver as host controller and emulate as virtual host controller. so
> that my driver will support corresponding ioctls that can be viewed by any
> software like usbview, usblyzer.
>
> starting from windows 10 UCX support is there for writing our own host
> controllers. But currently we need to support windows 7 WDM based driver
>
> I tried to create FDO, FILE_DEVICE_CONTROLLER, and exploring using reactos
> code as reference.
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: http:> showlists.cfm?list=ntdev>
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at <
> http://www.osronline.com/page.cfm?name=ListServer&gt;
></http:></http:>

@Mark Roddy,
Thanks for your reply… Now it is clear up-to some extent.
looks like, usb hub driver also need to develop, to get attached for the pdo created in virtual host controller for root hub.

Now target device pdo(details are got from device through kernel sockets) is created in virtual host controller(mausb extended bus) there is no concept of root hub in virtual host controller(mausb extended bus) which we created.

In this case how to go ahead, in order emulate actual HCD and root hub?

Can i know what is the role of usbport.inf ? one of ehci inf file it is mentioned like this
[INTEL_USB2.NT]
Include=usbport.inf
Needs=EHCI.Dev.NT

Root hub and controller can be the same driver presenting two separate
types of device objects, one a child of the other. KMDF supports a single
driver parent/child model. Controller enumerates 1 or more root hubs. Root
hubs enumerate 0-N usb devices (N is the number of ports the hub claims to
have.)

Mark Roddy

On Wed, Jul 26, 2017 at 6:40 AM, xxxxx@lge.com > wrote:

> @Mark Roddy,
> Thanks for your reply… Now it is clear up-to some extent.
> looks like, usb hub driver also need to develop, to get attached for the
> pdo created in virtual host controller for root hub.
>
> Now target device pdo(details are got from device through kernel sockets)
> is created in virtual host controller(mausb extended bus) there is no
> concept of root hub in virtual host controller(mausb extended bus) which we
> created.
>
> In this case how to go ahead, in order emulate actual HCD and root hub?
>
> Can i know what is the role of usbport.inf ? one of ehci inf file it is
> mentioned like this
> [INTEL_USB2.NT]
> Include=usbport.inf
> Needs=EHCI.Dev.NT
>
>
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: http:> showlists.cfm?list=ntdev>
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at <
> http://www.osronline.com/page.cfm?name=ListServer&gt;
></http:></http:>

On Jul 26, 2017, at 3:40 AM, xxxxx@lge.com xxxxx@lists.osr.com wrote:

Thanks for your reply… Now it is clear up-to some extent.
looks like, usb hub driver also need to develop, to get attached for the pdo created in virtual host controller for root hub.

Did you actually create a PDO for a root hub? What happened?

Now target device pdo(details are got from device through kernel sockets) is created in virtual host controller(mausb extended bus) there is no concept of root hub in virtual host controller(mausb extended bus) which we created.

Of course there is. It is a virtual concept, but your virtual host controller has to have one.

In this case how to go ahead, in order emulate actual HCD and root hub?

Reverse engineering. It’s hard.

Can i know what is the role of usbport.inf ? one of ehci inf file it is mentioned like this
[INTEL_USB2.NT]
Include=usbport.inf
Needs=EHCI.Dev.NT

Did you even go look, for gosh sakes? Every Windows system has this INF.

Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Oh well, you’ve scared the guy.
Can he be helped in a simple way? Basically, the whole issue is that his devices don’t show up in USBbView. Source of USBView and that another program is available, so … just enhance the USBView to show his devices too? Bingo, done, enjoy the weekend.

– pa

His devices will not work if he doesn’t support the core set of IOCTLs and
driver interfaces. For Win7 and earlier (assuming that win8 is a dead end)
that means reverse engineering these interfaces.

Mark Roddy

On Fri, Jul 28, 2017 at 9:18 AM, xxxxx@fastmail.fm
wrote:

> Oh well, you’ve scared the guy.
> Can he be helped in a simple way? Basically, the whole issue is that his
> devices don’t show up in USBbView. Source of USBView and that another
> program is available, so … just enhance the USBView to show his devices
> too? Bingo, done, enjoy the weekend.
>
> – pa
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: http:> showlists.cfm?list=ntdev>
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at <
> http://www.osronline.com/page.cfm?name=ListServer&gt;
></http:></http:>

@Tim Roberts
Did you actually create a PDO for a root hub? What happened?
I took quite time to implement i gathered information from you guys. Did some reverse engineering using usb analyzers.
Yes I created pdo for hub. And i have loaded dummy hub driver. I need to support below two ioctls. so that some of the applications like usbtree, usblyzer are listing in UI.
IOCTL_GET_HCD_DRIVERKEY_NAME
IOCTL_USB_GET_ROOT_HUB_NAME

@Pavel A
Thanks Pavel this would be one solution for me. Some other applications need to support by giving port connection information. These IOCTLS are not reachable to our root device. Thats why want to support Hub driver as well.

So actually citrix open sourced my xen pv usb kmdf drivers here:
https://github.com/OpenXT/xc-vusb

You can use these as reference sources for a v2 usb controller/root hub
driver stack. It should answer all of your questions on how to implement
all of the undocumented stuff you need to implement. Plus it is kmdf.

Have fun.

Mark Roddy

On Tue, Aug 22, 2017 at 6:06 AM, xxxxx@gmail.com <
xxxxx@lists.osr.com> wrote:

@Pavel A
Thanks Pavel this would be one solution for me. Some other applications
need to support by giving port connection information. These IOCTLS are not
reachable to our root device. Thats why want to support Hub driver as well.


NTDEV is sponsored by OSR

Visit the list online at: http:> showlists.cfm?list=ntdev>
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at <
> http://www.osronline.com/page.cfm?name=ListServer&gt;
></http:></http:>

@Mark Roddy
Thank you very much.