usbser + vendor commands?

Hi,
I have a CDC compatible device, however I need to do some extension on
firmware level with vendor commands (WDF_USB_CONTROL_SETUP_PACKET_INIT_VENDOR).
Is there any “standard” way within usbser.sys to do that so (i.e. route vendor
commands to the device)? Or must I create
my own driver for that?
Thanks,

I don’t think usbser has vendor cmd pass through , but you could probably what you want by using usbser as the fdo and writing a lower filter which sends the vendor command.

d

dent from a phpne with no keynoard

-----Original Message-----
From: xxxxx@chello.hu
Sent: July 03, 2010 9:05 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] usbser + vendor commands?

Hi,
I have a CDC compatible device, however I need to do some extension on
firmware level with vendor commands (WDF_USB_CONTROL_SETUP_PACKET_INIT_VENDOR).
Is there any “standard” way within usbser.sys to do that so (i.e. route vendor
commands to the device)? Or must I create
my own driver for that?
Thanks,


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Thanks Doron,

however is there any good example/source code on lower filters? I have never/ever ued them.
Is the src\usb\osrusbfx2\umdf\filter\ under WDK is a good place to start? Or?

I would start with the kmdf toaster filter example.

d

dent from a phpne with no keynoard

-----Original Message-----
From: xxxxx@chello.hu
Sent: July 04, 2010 12:25 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] usbser + vendor commands?

Thanks Doron,

however is there any good example/source code on lower filters? I have never/ever ued them.
Is the src\usb\osrusbfx2\umdf\filter\ under WDK is a good place to start? Or?


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Sorry for the pretty dumb question, but I can’t seem to get it :frowning:

How can I get the FDO’s WDFUSBDEVICE (i.e. USBSER’s WDFUSBDEVICE) handle?
As “usually” that is stored within the device extension, but I don’t (?) have access
within the filter’s code to USBSER’s WDFUSBDEVICE handle how can I
WdfUsbTargetDeviceSendControlTransferSynchronously?
Thanks

So (I guess) practically I am looking for a method to “convert” WdfIoTarget to WdfUsbDevice.
Or a layman’s example for USB filter driver (yeah I know that there are numerous examples
in WDK with regards to filter drivers, but: a.) haven’t seen a KMDF USB filter example only toaster b.) the firefly HID example). Or at least a well written documentation about how to implement USB filter devices within KMDF. So? Any help?

xxxxx@chello.hu wrote:

Sorry for the pretty dumb question, but I can’t seem to get it :frowning:

How can I get the FDO’s WDFUSBDEVICE (i.e. USBSER’s WDFUSBDEVICE) handle?
As “usually” that is stored within the device extension, but I don’t (?) have access
within the filter’s code to USBSER’s WDFUSBDEVICE handle how can I
WdfUsbTargetDeviceSendControlTransferSynchronously?

If you are a filter driver above usbser.sys, then what you are asking is
impossible. All you can do is send requests to the usbser.sys top-edge,
and that edge speaks COM, not USB. If you want to send URBs as if you
were usbser.sys, then you need to be a LOWER filter to usbser.sys. It’s
not uncommon to need both an upper filter and a lower filter for some
particular device.

Once you are the lower filter, you simply call
WdfUsbTargetDeviceCreate. All that really does is give you a convenient
handle for sending USB-specific requests to the driver immediately below
you.

Remember that usbser.sys is not KMDF – it does not have a
WDFUSBDEVICE. Also remember that KMDF handles cannot be shared between
drivers – they are strictly local.


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

the easiest thing for you to do here is to create your own WDFUSBDEVICE. The trick is that you want to use usbser’s select config URB when you create the WDFUSBTARGET. You need to register a handlter for internal IOCTLs and capture the select config (and probably select interface) URB(s). instead of sending these 2 down the stack yourself, you do this

WDF_USB_DEVICE_SELECT_CONFIG_PARAMS params;
WDFUSBDEVICE usbdevice;
NTSTATUS status;

WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_URB(&params, );
status = WdfUsbTargetDeviceCreate(device, WDF_NO_OBJECT_ATTRIBUTES, &usbdevice); <– this will send the urb down the stack for you
…other init stuff
WdfRequestComplete(request, status);

For select interface you just use WDF_USB_INTERFACE_SELECT_SETTING_PARAMS_INIT_URB and call WdfUsbInterfaceSelectSetting and follow the same pattern

d
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@chello.hu
Sent: Thursday, July 08, 2010 9:03 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] usbser + vendor commands?

So (I guess) practically I am looking for a method to “convert” WdfIoTarget to WdfUsbDevice.
Or a layman’s example for USB filter driver (yeah I know that there are numerous examples in WDK with regards to filter drivers, but: a.) haven’t seen a KMDF USB filter example only toaster b.) the firefly HID example). Or at least a well written documentation about how to implement USB filter devices within KMDF. So? Any help?


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Tim Roberts wrote:

If you are a filter driver above usbser.sys, then what you
are asking is impossible. All you can do is send requests
to the usbser.sys top-edge, and that edge speaks COM,
not USB.

I don’t think this is impossible. We had an upper filter that sent URBs directly to the PDO of the stack, bypassing usbser (or whomever, it worked for an NDIS-USB driver that we had too). However I forget how this was accomplished. I think we just used IoGetDeviceObject() or whatever?

Thanks guys, will try these out!

Guys, is there an example for that. Sorry to ask lame questions.

I’ve tried to google/sarch WDK for EvtIoInternalDeviceControl
usage and WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_URB and so,
but have found nothing. Also fail to find the IOCTL code for the URB_FUNCTION_SELECT_CONFIGURATION, is that IOCTL_INTERNAL_USB_SUBMIT_URB
Or?

what am I missing? Where should I look? Sorry :frowning:

Hi managed to sort out the following.

* add EvtIoInternalDeviceControl
* capture IOCTL_INTERNAL_USB_SUBMIT_URB
* extract URB with IoGetCurrentIrpStackLocation()->Parameters.Others.Argument1
* handle ->UrbHeader.Function

However what is not quite clear:

* within URB_FUNCTION_SELECT_CONFIGURATION
after constructing the config params with WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_URB,
shall I also call WdfUsbTargetDeviceSelectConfig or WdfUsbTargetDeviceCreate only ?

* within URB_FUNCTION_SELECT_INTERFACE
do I also do WdfUsbInterfaceSelectSetting() ?

I thought that these will be done by USBSER, or?
Can anyone point me to an example where:

EvtIoInternalDeviceControl + IOCTL_INTERNAL_USB_SUBMIT_URB + URB_FUNCTION_SELECT_CONFIGURATION
is used?

(I am also missing the information how to “push” the IOCTLs further
to USBSER. Is it automatically done by WdfRequestComplete? Or?

Sorry for the dumb questions but I really failed to find a complete set
of manual/guide/example how to write a lower USB filter driver :frowning:

Yes, the select config URB comes IOCTL_INTERNAL_SUBMIT_URB. You have to capture this ioctl then look at the URB’s type to see what type of URB it is

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@chello.hu
Sent: Friday, July 09, 2010 12:02 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] usbser + vendor commands?

Guys, is there an example for that. Sorry to ask lame questions.

I’ve tried to google/sarch WDK for EvtIoInternalDeviceControl usage and WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_URB and so, but have found nothing. Also fail to find the IOCTL code for the URB_FUNCTION_SELECT_CONFIGURATION, is that IOCTL_INTERNAL_USB_SUBMIT_URB Or?

what am I missing? Where should I look? Sorry :frowning:


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Ok, about forwarding the internal IOCTL, should I really
WdfRequestComplete() ONLY after URB_FUNCTION_SELECT_INTERFACE+URB_FUNCTION_SELECT_CONFIGURATION?

Or should WdfRequestComplete() AND
then also WdfRequestSend() the same WDFREQUEST to WdfDeviceGetIoTarget(device)?
(i.e. forward the req)

You call WdfUsbTargetDeviceCreate and then WdfUsbTargetDeviceSelectConfig. USBser is selecting the config. You are fooling KMDF by thinking you are selecting the config by passing your own URB (which is usbser’s). in the end, the select config URB is sent down the stack once. Usbser just sees it coming back, it doesn’t know you created a KMDF object to wrap the config.

Yes, you also need to capture select interface and call WdfUsbInterfaceSelectSetting

There is no sample. you need to figure it out

(I am also missing the information how to “push” the IOCTLs further to USBSER. Is it automatically done by WdfRequestComplete? Or?
As a lower filter you do not push ioctls to usbser. You complete them and usbser processes the completion of the io it sent through your driver

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@chello.hu
Sent: Friday, July 09, 2010 12:31 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] usbser + vendor commands?

Hi managed to sort out the following.

* add EvtIoInternalDeviceControl
* capture IOCTL_INTERNAL_USB_SUBMIT_URB
* extract URB with IoGetCurrentIrpStackLocation()->Parameters.Others.Argument1
* handle ->UrbHeader.Function

However what is not quite clear:

* within URB_FUNCTION_SELECT_CONFIGURATION after constructing the config params with WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_URB,
shall I also call WdfUsbTargetDeviceSelectConfig or WdfUsbTargetDeviceCreate only ?

* within URB_FUNCTION_SELECT_INTERFACE
do I also do WdfUsbInterfaceSelectSetting() ?

I thought that these will be done by USBSER, or?
Can anyone point me to an example where:

EvtIoInternalDeviceControl + IOCTL_INTERNAL_USB_SUBMIT_URB + URB_FUNCTION_SELECT_CONFIGURATION is used?

(I am also missing the information how to “push” the IOCTLs further to USBSER. Is it automatically done by WdfRequestComplete? Or?

Sorry for the dumb questions but I really failed to find a complete set of manual/guide/example how to write a lower USB filter driver :frowning:


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Superb, thanks a lot Doron for the great explanation!!!

One more (hopefully last) question. Shall I reject with STATUS_NOT_SUPPORTED
any other URB than URB_FUNCTION_SELECT_CONFIGURATION/URB_FUNCTION_SELECT_INTERFACE.
Or shall I WdfRequestComplete() with another error status?

Ooops one more last-last question. About “regular” EvtIoDeviceControl commands.
What should I do with “undhandled” IOCTLs (i.e. the ones that are not “mine”)?
Currently with the handled ones I do a WdfRequestCompleteWithInformation()
but with the unhandled ones I do a WdfRequestSend() (a forward technically).
This one came from the toaster code. Should I NOT forward the normal IOCTLs
neither? Or?

You are a filter so or every irp major type and then for every subtype, be it ioctls, internal ioctls, or urbs, that you don’t handle you send them down the stack with wdfrequestsend and use the send_and_forget flag.

d

dent from a phpne with no keynoard

-----Original Message-----
From: xxxxx@chello.hu
Sent: July 09, 2010 2:15 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] usbser + vendor commands?

Ooops one more last-last question. About “regular” EvtIoDeviceControl commands.
What should I do with “undhandled” IOCTLs (i.e. the ones that are not “mine”)?
Currently with the handled ones I do a WdfRequestCompleteWithInformation()
but with the unhandled ones I do a WdfRequestSend() (a forward technically).
This one came from the toaster code. Should I NOT forward the normal IOCTLs
neither? Or?


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

God, how lame I am.
From your sentence

“As a lower filter you do not push ioctls to usbser. You complete them and
usbser processes the completion of the io it sent through your driver”

I draw the bad conclusion down :frowning: As I am BELOW UBSER naturally sending the WDFREQUEST
via WdfRequestSend means sending it DOWN to the USB stack not UP to USBSER :frowning:
Oh god how lame I am. Thanks Doron again!