2 questions about usbhub.sys and usbstor.sys

Hi, I have 2 questions about usbhub.sys and usbstor.sys.

  1. According to WDK, under ‘Device Object Example for USB Mass Storage
    Device’, it says the usb hub driver detects and enumerates the USB mass
    storage device and creates a PDO for it. Then the USB storage port driver,
    usbstor.sys, creates its own FDO. And USB storage port driver can divide the
    physical storage device into as many as 16 logical units and create PDO for
    each of the unit. My question is: If I have the PDO for one of the logical
    units, how can I know the corresponding FDO created by the USB storage port
    driver, usbstor.sys, of this PDO? Is there anyway that I can link the
    storage device FDO and the LUN PDO together?

  2. WDK says drivers must not send IRP_MN_QUERY_DEVICE_RELATIONS to request
    BusRelations. Why Microsoft has this restriction? I mean why the driver
    couldn’t send IRP_MN_QUERY_DEVICE_RELATIONS to request BusRelations?

Thanks.

Ignoring the entire issue of whether this is the USB stack or any OTHER stack, you can see which FDO and Filters are presently attached to a PDO via the AttachedDevice pointer in the device objects. The only problem with this approach is that there’s no lock available that’ll guarantee you that you can run this list.

To make it simpler for bus driver, as far as I know. They may thus only expect to receive this IRP under certain circumstances in their state machine, and not randomly and not in parallel.

I can vouch for the fact that there have been several otherwise reasonably well-written in-box drivers that crash when they receive this IRP at random times.

Peter
OSR

Thanks Peter. I am afraid this is not the case as you described. I think you
may not read my question very clearly. If I plug in a USB flash drive, then
usbstor.sys will create 2 device objects. One is the FDO of the underlying
PDO created by usbhub.sys. The other is the logical unit PDO. From the
DeviceTree.exe utility I couldn’t see any direct relation between these 2
device objects. I can see the FDO attached to the usbhub.sys created PDO.
But I want to know the relationship between the 2 device objects created by
usbstor.sys. If I know the logical unit PDO, how can I know the
corresponding FDO which is also created by usbstor.sys.

As to sending IRP_MN_QUERY_DEVICE_RELATIONS to request BusRelations, MS has
this restriction only to avoid system crash which may be caused potentially
by their own in-box drivers, right?

On Tue, Aug 25, 2009 at 9:34 AM, wrote:

>


>
> Ignoring the entire issue of whether this is the USB stack or any OTHER
> stack, you can see which FDO and Filters are presently attached to a PDO via
> the AttachedDevice pointer in the device objects. The only problem with
> this approach is that there’s no lock available that’ll guarantee you that
> you can run this list.
>
>


>
> To make it simpler for bus driver, as far as I know. They may thus only
> expect to receive this IRP under certain circumstances in their state
> machine, and not randomly and not in parallel.
>
> I can vouch for the fact that there have been several otherwise reasonably
> well-written in-box drivers that crash when they receive this IRP at random
> times.
>
> Peter
> OSR
>
>
> —
> 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
>

I’m afraid you didn’t read my answer very clearly.

This restriction exists to guard ALL drivers from having to deal with handing this IRP at various states in their state machine. It’s an architectural restriction… period. You asked why it was there, I told you.

You’re right… I didn’t understand your question clearly. Too much USBSTOR/USBHUB noise.

As I mentioned earlier, let’s please ignore WHICH specific device branch you’re talking about. It matters not a whit whether we’re talking about USB or 1394 – Trying to make your question USB specific just makes it more complicated.

I THINK you’re asking: “Given a PDO, how can I know the FDO of the bus driver that created the PDO”? Stripped of all the USBSTOR noise, is THAT your question?

If it is, the answer is that the PDO will be in the same device object list as the FDO (listheaded in DriverObject->DeviceObject). And the risk of running this list is that you don’t have the lock that protects this list when you run it.

If that’s not your question, I apologize in advance… please ask it again :slight_smile:

Peter
OSR

From a stack’s pdo, there is no way to get to the pdo’s parent fdo (which could also be a filter devobj). There is no need for you to know the topology of you parent stack.

As for busrelations, it has nothing really to do with when it is sent, but rather everything to do with the side effects of its completion. QDR/busrelations is a pnp state changing request (like start, stop, remove, etc). Only the pnp manager is allowed to send state changing pnp irps because there are rules around them that you would violate if you sent them yourself. So from this perspective, sending them from your driver could cause the underlying driver to get the busrelations in the wrong state, but that is 2mdary to the real problem. The reral issue is that what is reported by the relations list is lost to the pnp manager if your driver sends its own busrelations, but it is not lost on the driver which reported the relations. For instance, if the underlying driver reports a PDO as missing, the pnp manager in response to the result will surprise remove the PDO’s tack. The driver will think it has sucessfuly marked the pdo as missing and when it gets the remove irp, delete the pdo.

Now let’s say the driver reports the pdo as missing in response to the qdr/busrelations your driver sent. Now there is a mismatch. Pnp does not know it is missing, but the driver thinks it is. Pnp now sends a graceful remove where it expects the pdo to stay, but the driver deletes the pdo because it thought it reported it as missing and things start to bloe up in the pnp manager because the driver is not appearing to obey the rules, where in reality this was all due to some other driver not following the rules and sending its own QDR/BusRelations when it should have never done that.

hth
d

Sent from my phone with no t9, all spilling mistakes are not intentional.


From: Michael Zhu
Sent: Tuesday, August 25, 2009 6:59 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] 2 questions about usbhub.sys and usbstor.sys

Thanks Peter. I am afraid this is not the case as you described. I think you may not read my question very clearly. If I plug in a USB flash drive, then usbstor.sys will create 2 device objects. One is the FDO of the underlying PDO created by usbhub.sys. The other is the logical unit PDO. From the DeviceTree.exe utility I couldn’t see any direct relation between these 2 device objects. I can see the FDO attached to the usbhub.sys created PDO. But I want to know the relationship between the 2 device objects created by usbstor.sys. If I know the logical unit PDO, how can I know the corresponding FDO which is also created by usbstor.sys.

As to sending IRP_MN_QUERY_DEVICE_RELATIONS to request BusRelations, MS has this restriction only to avoid system crash which may be caused potentially by their own in-box drivers, right?

On Tue, Aug 25, 2009 at 9:34 AM, > wrote:



Ignoring the entire issue of whether this is the USB stack or any OTHER stack, you can see which FDO and Filters are presently attached to a PDO via the AttachedDevice pointer in the device objects. The only problem with this approach is that there’s no lock available that’ll guarantee you that you can run this list.



To make it simpler for bus driver, as far as I know. They may thus only expect to receive this IRP under certain circumstances in their state machine, and not randomly and not in parallel.

I can vouch for the fact that there have been several otherwise reasonably well-written in-box drivers that crash when they receive this IRP at random times.

Peter
OSR


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

— 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

Even if you run through the driver’s device object list, you have now way of knowing which devobj in the list is the fdo (vs more PDOs or other FDOs for other devices). Plain and simple, there is no public structure or API that exposes how to get a PDO’s parent device

d

Sent from my phone with no t9, all spilling mistakes are not intentional.

-----Original Message-----
From: xxxxx@osr.com
Sent: Tuesday, August 25, 2009 7:13 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] 2 questions about usbhub.sys and usbstor.sys



I’m afraid you didn’t read my answer very clearly.

This restriction exists to guard ALL drivers from having to deal with handing this IRP at various states in their state machine. It’s an architectural restriction… period. You asked why it was there, I told you.



You’re right… I didn’t understand your question clearly. Too much USBSTOR/USBHUB noise.

As I mentioned earlier, let’s please ignore WHICH specific device branch you’re talking about. It matters not a whit whether we’re talking about USB or 1394 – Trying to make your question USB specific just makes it more complicated.

I THINK you’re asking: “Given a PDO, how can I know the FDO of the bus driver that created the PDO”? Stripped of all the USBSTOR noise, is THAT your question?

If it is, the answer is that the PDO will be in the same device object list as the FDO (listheaded in DriverObject->DeviceObject). And the risk of running this list is that you don’t have the lock that protects this list when you run it.

If that’s not your question, I apologize in advance… please ask it again :slight_smile:

Peter
OSR


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

Ah, quite true. Just WHICH driver it belongs to… In the case of multiple FDOs and multiple PDOs, there’d be no way to know which is which. You’re absolutely correct.

Peter
OSR

Thanks Peter and Doron for the explanation. Actually the real reason that I
ask these 2 questions is because I want to send URB down by
IOCTL_INTERNAL_USB_SUBMIT_URB at disk class upper filter level. I have a
disk class upper filter to monitor all the mass storage devices. Once there
is a USB flash drive or external HDD plugged in I want to get the real
VID&PID (I mean the number, not the string description) of this USB drive.
And the USB hub PDO is the target of IOCTL_INTERNAL_USB_SUBMIT_URB. So I
hope I can find the USB hub PDO in my disk class upper filter. But I only
know the logical unit PDO in my driver. That is why I want to get the bus
FDO who created the logical unit PDO. Then I can send down
IRP_MN_QUERY_DEVICE_RELATIONS to request TargetDeviceRelations to get the
UDB hub PDO.

Base on you guys’ explanation, it seems there is no way I can do this
without a bus controller filter, right?

In my case I don’t need to know exactly which FDO creates the PDO. I just
need to know on which FDO I need to send down the URB query.

On Tue, Aug 25, 2009 at 10:26 AM, wrote:

>


>
> Ah, quite true. Just WHICH driver it belongs to… In the case of
> multiple FDOs and multiple PDOs, there’d be no way to know which is which.
> You’re absolutely correct.
>
> Peter
> OSR
>
>
> —
> 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
>

A bus filter is overkill. What re you going to do once you match the vid/pid? You can always add a lower to usbstor and that filter is installed on a vid/pid match so that removes the need to even query for the vid/pid

d

Sent from my phone with no t9, all spilling mistakes are not intentional.


From: Michael Zhu
Sent: Tuesday, August 25, 2009 7:59 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] 2 questions about usbhub.sys and usbstor.sys

In my case I don’t need to know exactly which FDO creates the PDO. I just need to know on which FDO I need to send down the URB query.

On Tue, Aug 25, 2009 at 10:26 AM, > wrote:



Ah, quite true. Just WHICH driver it belongs to… In the case of multiple FDOs and multiple PDOs, there’d be no way to know which is which. You’re absolutely correct.

Peter
OSR


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

— 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. I don’t need to match the vid&pid. I just want to use the
vid&pid to identify different USB storage devices.

Even I add a lower filter to usbstor and get the vid&pid I still don’t know
this vid&pid is for which USB storage disk in my disk class upper filter. I
have to find some other ways to accomplish this.

On Tue, Aug 25, 2009 at 11:08 AM, Doron Holan wrote:

> A bus filter is overkill. What re you going to do once you match the
> vid/pid? You can always add a lower to usbstor and that filter is installed
> on a vid/pid match so that removes the need to even query for the vid/pid
>
> d
>
> Sent from my phone with no t9, all spilling mistakes are not intentional.
>
> ------------------------------
> From: Michael Zhu
> Sent: Tuesday, August 25, 2009 7:59 AM
> To: Windows System Software Devs Interest List
> Subject: Re: [ntdev] 2 questions about usbhub.sys and usbstor.sys
>
> In my case I don’t need to know exactly which FDO creates the PDO. I just
> need to know on which FDO I need to send down the URB query.
>
> On Tue, Aug 25, 2009 at 10:26 AM, wrote:
>
>>


>>
>> Ah, quite true. Just WHICH driver it belongs to… In the case of
>> multiple FDOs and multiple PDOs, there’d be no way to know which is which.
>> You’re absolutely correct.
>>
>> Peter
>> OSR
>>
>>
>> —
>> 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
>>
>
> — 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
>
> —
> 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
>

Michael Zhu wrote:

Thanks Doron. I don’t need to match the vid&pid. I just want to use
the vid&pid to identify different USB storage devices.

Even I add a lower filter to usbstor and get the vid&pid I still don’t
know this vid&pid is for which USB storage disk in my disk class upper
filter. I have to find some other ways to accomplish this.

You don’t seem to be thinking outside the box very much. Once you have
a lower filter to usbstor that has the VID & PID, you can have your disk
class upper filter send an IRP_MN_QUERY_INTERFACE down the stack, and
return a set of function pointers. Now your disk upper filter can call
directly into your usbstor lower filter to exchange whatever information
they need to exchange.

The contract for IRP_MN_QUERY_INTERFACE is that all drivers should pass
it along until someone recognizes the GUID.


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

One more question. What is the best way to add a lower filter to usbstor?
I’ve searched for a while. But couldn’t figure it out. And this filter
should be device lower filter?

On Tue, Aug 25, 2009 at 12:19 PM, Tim Roberts wrote:

> Michael Zhu wrote:
> > Thanks Doron. I don’t need to match the vid&pid. I just want to use
> > the vid&pid to identify different USB storage devices.
> >
> > Even I add a lower filter to usbstor and get the vid&pid I still don’t
> > know this vid&pid is for which USB storage disk in my disk class upper
> > filter. I have to find some other ways to accomplish this.
>
> You don’t seem to be thinking outside the box very much. Once you have
> a lower filter to usbstor that has the VID & PID, you can have your disk
> class upper filter send an IRP_MN_QUERY_INTERFACE down the stack, and
> return a set of function pointers. Now your disk upper filter can call
> directly into your usbstor lower filter to exchange whatever information
> they need to exchange.
>
> The contract for IRP_MN_QUERY_INTERFACE is that all drivers should pass
> it along until someone recognizes the GUID.
>
> –
> Tim Roberts, xxxxx@probo.com
> Providenza & Boekelheide, Inc.
>
>
> —
> 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
>

Use and inf and match on hwid and yes, it should be a device lower filter, not a class lower filter

d

Sent from my phone with no t9, all spilling mistakes are not intentional.


From: Michael Zhu
Sent: Wednesday, August 26, 2009 6:46 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] 2 questions about usbhub.sys and usbstor.sys

One more question. What is the best way to add a lower filter to usbstor? I’ve searched for a while. But couldn’t figure it out. And this filter should be device lower filter?

On Tue, Aug 25, 2009 at 12:19 PM, Tim Roberts > wrote:
Michael Zhu wrote:
> Thanks Doron. I don’t need to match the vid&pid. I just want to use
> the vid&pid to identify different USB storage devices.
>
> Even I add a lower filter to usbstor and get the vid&pid I still don’t
> know this vid&pid is for which USB storage disk in my disk class upper
> filter. I have to find some other ways to accomplish this.

You don’t seem to be thinking outside the box very much. Once you have
a lower filter to usbstor that has the VID & PID, you can have your disk
class upper filter send an IRP_MN_QUERY_INTERFACE down the stack, and
return a set of function pointers. Now your disk upper filter can call
directly into your usbstor lower filter to exchange whatever information
they need to exchange.

The contract for IRP_MN_QUERY_INTERFACE is that all drivers should pass
it along until someone recognizes the GUID.


Tim Roberts, xxxxx@probo.commailto:xxxxx
Providenza & Boekelheide, Inc.


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

— 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</mailto:xxxxx>

Thanks Doron. So I need to use an INF file to register lower filter to
usbstor. But how to match on hwid? Different USB storage deivce has
different hwid, right? If I plug in a USB flash drive, how the system can
add a lower filter to usbstor for this flash drive?

Appreciate your help.

On Wed, Aug 26, 2009 at 10:15 AM, Doron Holan wrote:

> Use and inf and match on hwid and yes, it should be a device lower
> filter, not a class lower filter
>
> d
>
> Sent from my phone with no t9, all spilling mistakes are not intentional.
>
> ------------------------------
> From: Michael Zhu
> Sent: Wednesday, August 26, 2009 6:46 AM
> To: Windows System Software Devs Interest List
> Subject: Re: [ntdev] 2 questions about usbhub.sys and usbstor.sys
>
> One more question. What is the best way to add a lower filter to usbstor?
> I’ve searched for a while. But couldn’t figure it out. And this filter
> should be device lower filter?
>
> On Tue, Aug 25, 2009 at 12:19 PM, Tim Roberts wrote:
>
>> Michael Zhu wrote:
>> > Thanks Doron. I don’t need to match the vid&pid. I just want to use
>> > the vid&pid to identify different USB storage devices.
>> >
>> > Even I add a lower filter to usbstor and get the vid&pid I still don’t
>> > know this vid&pid is for which USB storage disk in my disk class upper
>> > filter. I have to find some other ways to accomplish this.
>>
>> You don’t seem to be thinking outside the box very much. Once you have
>> a lower filter to usbstor that has the VID & PID, you can have your disk
>> class upper filter send an IRP_MN_QUERY_INTERFACE down the stack, and
>> return a set of function pointers. Now your disk upper filter can call
>> directly into your usbstor lower filter to exchange whatever information
>> they need to exchange.
>>
>> The contract for IRP_MN_QUERY_INTERFACE is that all drivers should pass
>> it along until someone recognizes the GUID.
>>
>> –
>> Tim Roberts, xxxxx@probo.com
>> Providenza & Boekelheide, Inc.
>>
>>
>> —
>> 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
>>
>
> — 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
>
> —
> 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
>

They al have the same compat id which is what usbstor matches on. You were saying that you wanted to do something specific for a vid/pid. Match against the hwid which contains the vid/pid

d

Sent from my phone with no t9, all spilling mistakes are not intentional.


From: Michael Zhu
Sent: Wednesday, August 26, 2009 7:51 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] 2 questions about usbhub.sys and usbstor.sys

Thanks Doron. So I need to use an INF file to register lower filter to usbstor. But how to match on hwid? Different USB storage deivce has different hwid, right? If I plug in a USB flash drive, how the system can add a lower filter to usbstor for this flash drive?

Appreciate your help.

On Wed, Aug 26, 2009 at 10:15 AM, Doron Holan > wrote:
Use and inf and match on hwid and yes, it should be a device lower filter, not a class lower filter

d

Sent from my phone with no t9, all spilling mistakes are not intentional.

________________________________
From: Michael Zhu >
Sent: Wednesday, August 26, 2009 6:46 AM

To: Windows System Software Devs Interest List >
Subject: Re: [ntdev] 2 questions about usbhub.sys and usbstor.sys

One more question. What is the best way to add a lower filter to usbstor? I’ve searched for a while. But couldn’t figure it out. And this filter should be device lower filter?

On Tue, Aug 25, 2009 at 12:19 PM, Tim Roberts > wrote:
Michael Zhu wrote:
> Thanks Doron. I don’t need to match the vid&pid. I just want to use
> the vid&pid to identify different USB storage devices.
>
> Even I add a lower filter to usbstor and get the vid&pid I still don’t
> know this vid&pid is for which USB storage disk in my disk class upper
> filter. I have to find some other ways to accomplish this.

You don’t seem to be thinking outside the box very much. Once you have
a lower filter to usbstor that has the VID & PID, you can have your disk
class upper filter send an IRP_MN_QUERY_INTERFACE down the stack, and
return a set of function pointers. Now your disk upper filter can call
directly into your usbstor lower filter to exchange whatever information
they need to exchange.

The contract for IRP_MN_QUERY_INTERFACE is that all drivers should pass
it along until someone recognizes the GUID.


Tim Roberts, xxxxx@probo.commailto:xxxxx
Providenza & Boekelheide, Inc.


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

— 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


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

— 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</mailto:xxxxx>

Where I can find that compat id? And how I can match that compat id in my
inf file? Thanks.

On Wed, Aug 26, 2009 at 10:57 AM, Doron Holan wrote:

> They al have the same compat id which is what usbstor matches on. You
> were saying that you wanted to do something specific for a vid/pid. Match
> against the hwid which contains the vid/pid
>
> d
>
> Sent from my phone with no t9, all spilling mistakes are not intentional.
>
> ------------------------------
> From: Michael Zhu
> Sent: Wednesday, August 26, 2009 7:51 AM
>
> To: Windows System Software Devs Interest List
> Subject: Re: [ntdev] 2 questions about usbhub.sys and usbstor.sys
>
> Thanks Doron. So I need to use an INF file to register lower filter to
> usbstor. But how to match on hwid? Different USB storage deivce has
> different hwid, right? If I plug in a USB flash drive, how the system can
> add a lower filter to usbstor for this flash drive?
>
> Appreciate your help.
>
>
>
> On Wed, Aug 26, 2009 at 10:15 AM, Doron Holan wrote:
>
>> Use and inf and match on hwid and yes, it should be a device lower filter,
>> not a class lower filter
>>
>> d
>>
>> Sent from my phone with no t9, all spilling mistakes are not intentional.
>>
>> ------------------------------
>> From: Michael Zhu
>> Sent: Wednesday, August 26, 2009 6:46 AM
>> To: Windows System Software Devs Interest List
>> Subject: Re: [ntdev] 2 questions about usbhub.sys and usbstor.sys
>>
>> One more question. What is the best way to add a lower filter to
>> usbstor? I’ve searched for a while. But couldn’t figure it out. And this
>> filter should be device lower filter?
>>
>> On Tue, Aug 25, 2009 at 12:19 PM, Tim Roberts wrote:
>>
>>> Michael Zhu wrote:
>>> > Thanks Doron. I don’t need to match the vid&pid. I just want to use
>>> > the vid&pid to identify different USB storage devices.
>>> >
>>> > Even I add a lower filter to usbstor and get the vid&pid I still don’t
>>> > know this vid&pid is for which USB storage disk in my disk class upper
>>> > filter. I have to find some other ways to accomplish this.
>>>
>>> You don’t seem to be thinking outside the box very much. Once you have
>>> a lower filter to usbstor that has the VID & PID, you can have your disk
>>> class upper filter send an IRP_MN_QUERY_INTERFACE down the stack, and
>>> return a set of function pointers. Now your disk upper filter can call
>>> directly into your usbstor lower filter to exchange whatever information
>>> they need to exchange.
>>>
>>> The contract for IRP_MN_QUERY_INTERFACE is that all drivers should pass
>>> it along until someone recognizes the GUID.
>>>
>>> –
>>> Tim Roberts, xxxxx@probo.com
>>> Providenza & Boekelheide, Inc.
>>>
>>>
>>> —
>>> 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
>>>
>>
>> — 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
>>
>> —
>> 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
>>
>
> — 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
>
> —
> 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
>

Open the usbstor fdo properties in device manager. The details tab will include all of the compat and hw ids as well as the matched id. Why would you filter all usb mass storage devices vs the few vid/pids (you can specify more than one match in your inf btw) inparticular?

d

Sent from my phone with no t9, all spilling mistakes are not intentional.


From: Michael Zhu
Sent: Wednesday, August 26, 2009 8:33 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] 2 questions about usbhub.sys and usbstor.sys

Where I can find that compat id? And how I can match that compat id in my inf file? Thanks.

On Wed, Aug 26, 2009 at 10:57 AM, Doron Holan > wrote:
They al have the same compat id which is what usbstor matches on. You were saying that you wanted to do something specific for a vid/pid. Match against the hwid which contains the vid/pid

d

Sent from my phone with no t9, all spilling mistakes are not intentional.


From: Michael Zhu >
Sent: Wednesday, August 26, 2009 7:51 AM

To: Windows System Software Devs Interest List >
Subject: Re: [ntdev] 2 questions about usbhub.sys and usbstor.sys

Thanks Doron. So I need to use an INF file to register lower filter to usbstor. But how to match on hwid? Different USB storage deivce has different hwid, right? If I plug in a USB flash drive, how the system can add a lower filter to usbstor for this flash drive?

Appreciate your help.

On Wed, Aug 26, 2009 at 10:15 AM, Doron Holan > wrote:
Use and inf and match on hwid and yes, it should be a device lower filter, not a class lower filter

d

Sent from my phone with no t9, all spilling mistakes are not intentional.


From: Michael Zhu >
Sent: Wednesday, August 26, 2009 6:46 AM

To: Windows System Software Devs Interest List >
Subject: Re: [ntdev] 2 questions about usbhub.sys and usbstor.sys

One more question. What is the best way to add a lower filter to usbstor? I’ve searched for a while. But couldn’t figure it out. And this filter should be device lower filter?

On Tue, Aug 25, 2009 at 12:19 PM, Tim Roberts > wrote:
Michael Zhu wrote:
> Thanks Doron. I don’t need to match the vid&pid. I just want to use
> the vid&pid to identify different USB storage devices.
>
> Even I add a lower filter to usbstor and get the vid&pid I still don’t
> know this vid&pid is for which USB storage disk in my disk class upper
> filter. I have to find some other ways to accomplish this.

You don’t seem to be thinking outside the box very much. Once you have
a lower filter to usbstor that has the VID & PID, you can have your disk
class upper filter send an IRP_MN_QUERY_INTERFACE down the stack, and
return a set of function pointers. Now your disk upper filter can call
directly into your usbstor lower filter to exchange whatever information
they need to exchange.

The contract for IRP_MN_QUERY_INTERFACE is that all drivers should pass
it along until someone recognizes the GUID.


Tim Roberts, xxxxx@probo.commailto:xxxxx
Providenza & Boekelheide, Inc.


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

— 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


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

— 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


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

— 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</mailto:xxxxx>

I do want to filter all usb mass storage devices. And I just want to use the
vid/pid to uniquely identify the device.

On Wed, Aug 26, 2009 at 12:48 PM, Doron Holan wrote:

> Open the usbstor fdo properties in device manager. The details tab will
> include all of the compat and hw ids as well as the matched id. Why would
> you filter all usb mass storage devices vs the few vid/pids (you can specify
> more than one match in your inf btw) inparticular?
>
> d
>
> Sent from my phone with no t9, all spilling mistakes are not intentional.
>
> ------------------------------
> From: Michael Zhu
> Sent: Wednesday, August 26, 2009 8:33 AM
>
> To: Windows System Software Devs Interest List
> Subject: Re: [ntdev] 2 questions about usbhub.sys and usbstor.sys
>
> Where I can find that compat id? And how I can match that compat id in my
> inf file? Thanks.
>
> On Wed, Aug 26, 2009 at 10:57 AM, Doron Holan wrote:
>
>> They al have the same compat id which is what usbstor matches on. You were
>> saying that you wanted to do something specific for a vid/pid. Match against
>> the hwid which contains the vid/pid
>>
>> d
>>
>> Sent from my phone with no t9, all spilling mistakes are not intentional.
>>
>> ------------------------------
>> From: Michael Zhu
>> Sent: Wednesday, August 26, 2009 7:51 AM
>>
>> To: Windows System Software Devs Interest List
>> Subject: Re: [ntdev] 2 questions about usbhub.sys and usbstor.sys
>>
>> Thanks Doron. So I need to use an INF file to register lower filter to
>> usbstor. But how to match on hwid? Different USB storage deivce has
>> different hwid, right? If I plug in a USB flash drive, how the system can
>> add a lower filter to usbstor for this flash drive?
>>
>> Appreciate your help.
>>
>>
>>
>> On Wed, Aug 26, 2009 at 10:15 AM, Doron Holan wrote:
>>
>>> Use and inf and match on hwid and yes, it should be a device lower
>>> filter, not a class lower filter
>>>
>>> d
>>>
>>> Sent from my phone with no t9, all spilling mistakes are not intentional.
>>>
>>> ------------------------------
>>> From: Michael Zhu
>>> Sent: Wednesday, August 26, 2009 6:46 AM
>>> To: Windows System Software Devs Interest List
>>> Subject: Re: [ntdev] 2 questions about usbhub.sys and usbstor.sys
>>>
>>> One more question. What is the best way to add a lower filter to
>>> usbstor? I’ve searched for a while. But couldn’t figure it out. And this
>>> filter should be device lower filter?
>>>
>>> On Tue, Aug 25, 2009 at 12:19 PM, Tim Roberts wrote:
>>>
>>>> Michael Zhu wrote:
>>>> > Thanks Doron. I don’t need to match the vid&pid. I just want to use
>>>> > the vid&pid to identify different USB storage devices.
>>>> >
>>>> > Even I add a lower filter to usbstor and get the vid&pid I still don’t
>>>> > know this vid&pid is for which USB storage disk in my disk class upper
>>>> > filter. I have to find some other ways to accomplish this.
>>>>
>>>> You don’t seem to be thinking outside the box very much. Once you have
>>>> a lower filter to usbstor that has the VID & PID, you can have your disk
>>>> class upper filter send an IRP_MN_QUERY_INTERFACE down the stack, and
>>>> return a set of function pointers. Now your disk upper filter can call
>>>> directly into your usbstor lower filter to exchange whatever information
>>>> they need to exchange.
>>>>
>>>> The contract for IRP_MN_QUERY_INTERFACE is that all drivers should pass
>>>> it along until someone recognizes the GUID.
>>>>
>>>> –
>>>> Tim Roberts, xxxxx@probo.com
>>>> Providenza & Boekelheide, Inc.
>>>>
>>>>
>>>> —
>>>> 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
>>>>
>>>
>>> — 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
>>>
>>> —
>>> 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
>>>
>>
>> — 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
>>
>> —
>> 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
>>
>
> — 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
>
> —
> 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
>

How are you going to use the vid/pid as an ID? Is this id something you are going to store somewhere (disk, registry, etc)? Or just internal bookkeeping? Or as an id to some app to give a disk and identity? What happens if 2 instances of a device with the same vid/pid are plugged in at the same time?

Basically the vid/pid is not a unique id in and of itself. If you tell us how you are going to use the id, i think there will be much simpler solutions for your problem.

d

Sent from my phone with no t9, all spilling mistakes are not intentional.


From: Michael Zhu
Sent: Wednesday, August 26, 2009 10:59 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] 2 questions about usbhub.sys and usbstor.sys

I do want to filter all usb mass storage devices. And I just want to use the vid/pid to uniquely identify the device.

On Wed, Aug 26, 2009 at 12:48 PM, Doron Holan > wrote:
Open the usbstor fdo properties in device manager. The details tab will include all of the compat and hw ids as well as the matched id. Why would you filter all usb mass storage devices vs the few vid/pids (you can specify more than one match in your inf btw) inparticular?

d

Sent from my phone with no t9, all spilling mistakes are not intentional.


From: Michael Zhu >
Sent: Wednesday, August 26, 2009 8:33 AM

To: Windows System Software Devs Interest List >
Subject: Re: [ntdev] 2 questions about usbhub.sys and usbstor.sys

Where I can find that compat id? And how I can match that compat id in my inf file? Thanks.

On Wed, Aug 26, 2009 at 10:57 AM, Doron Holan > wrote:
They al have the same compat id which is what usbstor matches on. You were saying that you wanted to do something specific for a vid/pid. Match against the hwid which contains the vid/pid

d

Sent from my phone with no t9, all spilling mistakes are not intentional.


From: Michael Zhu >
Sent: Wednesday, August 26, 2009 7:51 AM

To: Windows System Software Devs Interest List >
Subject: Re: [ntdev] 2 questions about usbhub.sys and usbstor.sys

Thanks Doron. So I need to use an INF file to register lower filter to usbstor. But how to match on hwid? Different USB storage deivce has different hwid, right? If I plug in a USB flash drive, how the system can add a lower filter to usbstor for this flash drive?

Appreciate your help.

On Wed, Aug 26, 2009 at 10:15 AM, Doron Holan > wrote:
Use and inf and match on hwid and yes, it should be a device lower filter, not a class lower filter

d

Sent from my phone with no t9, all spilling mistakes are not intentional.

________________________________
From: Michael Zhu >
Sent: Wednesday, August 26, 2009 6:46 AM

To: Windows System Software Devs Interest List >
Subject: Re: [ntdev] 2 questions about usbhub.sys and usbstor.sys

One more question. What is the best way to add a lower filter to usbstor? I’ve searched for a while. But couldn’t figure it out. And this filter should be device lower filter?

On Tue, Aug 25, 2009 at 12:19 PM, Tim Roberts > wrote:
Michael Zhu wrote:
> Thanks Doron. I don’t need to match the vid&pid. I just want to use
> the vid&pid to identify different USB storage devices.
>
> Even I add a lower filter to usbstor and get the vid&pid I still don’t
> know this vid&pid is for which USB storage disk in my disk class upper
> filter. I have to find some other ways to accomplish this.

You don’t seem to be thinking outside the box very much. Once you have
a lower filter to usbstor that has the VID & PID, you can have your disk
class upper filter send an IRP_MN_QUERY_INTERFACE down the stack, and
return a set of function pointers. Now your disk upper filter can call
directly into your usbstor lower filter to exchange whatever information
they need to exchange.

The contract for IRP_MN_QUERY_INTERFACE is that all drivers should pass
it along until someone recognizes the GUID.


Tim Roberts, xxxxx@probo.commailto:xxxxx
Providenza & Boekelheide, Inc.


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

— 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


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

— 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


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

— 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


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

— 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</mailto:xxxxx>