: how to get USB busid from minifilter driver

> starting point might be IoGetDeviceInterfaces and IOCTL_SCSI_GET_ADDRESS,

IOCTL_STORAGE_GET_DEVICE_NUMBER also helps.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

Hello scott,

Thanks,

This has to be done in both Xp, and Vista, the code returned
“STORAGE\Volume” in Xp and i have to test in vista,

Maxim,

I ll test with IoGetDeviceInterfaces with IOCTL_SCSI_GET_ADDRESS or
IOCTL_STORAGE_GET_DEVICE_
NUMBER and let you know.

On Fri, Mar 19, 2010 at 5:27 AM, Maxim S. Shatskih
wrote:

> > starting point might be IoGetDeviceInterfaces and IOCTL_SCSI_GET_ADDRESS,
>
> IOCTL_STORAGE_GET_DEVICE_NUMBER also helps.
>
> –
> Maxim S. Shatskih
> Windows DDK MVP
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars
> (including our new fs mini-filter seminar) 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
>

Guys,

IOCTL_SCSI_GET_ADDRESS discription says “This request is not relevant to
storage class drivers that support Plug and Play because the port driver
supplies the address information on behalf of the class driver” Then how can
i use this to get USB busid?

On Fri, Mar 19, 2010 at 9:06 AM, Dennis Scott
wrote:

> Hello scott,
>
> Thanks,
>
> This has to be done in both Xp, and Vista, the code returned
> “STORAGE\Volume” in Xp and i have to test in vista,
>
> Maxim,
>
> I ll test with IoGetDeviceInterfaces with IOCTL_SCSI_GET_ADDRESS or
> IOCTL_STORAGE_GET_DEVICE_
> NUMBER and let you know.
>
>
> On Fri, Mar 19, 2010 at 5:27 AM, Maxim S. Shatskih > > wrote:
>
>> > starting point might be IoGetDeviceInterfaces and
>> IOCTL_SCSI_GET_ADDRESS,
>>
>> IOCTL_STORAGE_GET_DEVICE_NUMBER also helps.
>>
>> –
>> Maxim S. Shatskih
>> Windows DDK MVP
>> xxxxx@storagecraft.com
>> http://www.storagecraft.com
>>
>>
>> —
>> NTFSD is sponsored by OSR
>>
>> For our schedule of debugging and file system seminars
>> (including our new fs mini-filter seminar) 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
>>
>
>

That note is for implementers of storage class drivers, so it’s not really
relevant.

Then how can i use this to get USB busid?

You have to figure out which disk maps to the volume that you have. One way
to do this is to send a request to the volume that the volume will pass
through to the disk and save the results. Then grab all of the disk devices
in the system and send the same request to each disk until you get a match.
Then you have a device object in the disk stack that you can get the
hardware ID from.

There’s also IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS which will give you the
disk number (forgot about this one yesterday). You can then open
\Global??\PhysicalDriveN (I think, you need to verify) and do the same sort
of thing.

-scott


Scott Noone
Consulting Associate
OSR Open Systems Resources, Inc.
http://www.osronline.com

“Dennis Scott” wrote in message
news:xxxxx@ntfsd…
Guys,

IOCTL_SCSI_GET_ADDRESS discription says “This request is not relevant to
storage class drivers that support Plug and Play because the port driver
supplies the address information on behalf of the class driver” Then how can
i use this to get USB busid?

On Fri, Mar 19, 2010 at 9:06 AM, Dennis Scott
wrote:

Hello scott,

Thanks,

This has to be done in both Xp, and Vista, the code returned
“STORAGE\Volume” in Xp and i have to test in vista,

Maxim,

I ll test with IoGetDeviceInterfaces with IOCTL_SCSI_GET_ADDRESS or
IOCTL_STORAGE_GET_DEVICE_
NUMBER and let you know.

On Fri, Mar 19, 2010 at 5:27 AM, Maxim S. Shatskih
wrote:

> starting point might be IoGetDeviceInterfaces and IOCTL_SCSI_GET_ADDRESS,

IOCTL_STORAGE_GET_DEVICE_NUMBER also helps.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com


NTFSD is sponsored by OSR

For our schedule of debugging and file system seminars
(including our new fs mini-filter seminar) 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 Scott,

I ll try this one.

On Fri, Mar 19, 2010 at 6:05 PM, Scott Noone wrote:

> That note is for implementers of storage class drivers, so it’s not really
> relevant.
>
>
> Then how can i use this to get USB busid?
>>
>
> You have to figure out which disk maps to the volume that you have. One way
> to do this is to send a request to the volume that the volume will pass
> through to the disk and save the results. Then grab all of the disk devices
> in the system and send the same request to each disk until you get a match.
> Then you have a device object in the disk stack that you can get the
> hardware ID from.
>
> There’s also IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS which will give you the
> disk number (forgot about this one yesterday). You can then open
> \Global??\PhysicalDriveN (I think, you need to verify) and do the same sort
> of thing.
>
>
> -scott
>
> –
> Scott Noone
> Consulting Associate
> OSR Open Systems Resources, Inc.
> http://www.osronline.com
>
>
>
> “Dennis Scott” wrote in message
> news:xxxxx@ntfsd…
>
> Guys,
>
> IOCTL_SCSI_GET_ADDRESS discription says “This request is not relevant to
> storage class drivers that support Plug and Play because the port driver
> supplies the address information on behalf of the class driver” Then how can
> i use this to get USB busid?
>
>
> On Fri, Mar 19, 2010 at 9:06 AM, Dennis Scott
> wrote:
>
> Hello scott,
>
> Thanks,
>
> This has to be done in both Xp, and Vista, the code returned
> “STORAGE\Volume” in Xp and i have to test in vista,
>
> Maxim,
>
> I ll test with IoGetDeviceInterfaces with IOCTL_SCSI_GET_ADDRESS or
> IOCTL_STORAGE_GET_DEVICE_
> NUMBER and let you know.
>
>
>
>
> On Fri, Mar 19, 2010 at 5:27 AM, Maxim S. Shatskih
> wrote:
>
> starting point might be IoGetDeviceInterfaces and IOCTL_SCSI_GET_ADDRESS,
>>
>
>
> IOCTL_STORAGE_GET_DEVICE_NUMBER also helps.
>
> –
> Maxim S. Shatskih
> Windows DDK MVP
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
>
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars
> (including our new fs mini-filter seminar) 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
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars
> (including our new fs mini-filter seminar) 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
>

scott,

I am not able to get the busid with the steps you mentioned in previous
mail,

can you just confirm me with these queries.

“send a request to the volume that the volume will pass through to the disk
and save the results”
which request you are mentioning here? IOCTL_SCSI_GET_ADDRESS? this ioclt
returns not supported.

“Then grab all of the disk devices in the system and send the same request
to each disk until you get a match”
Done, No problems, but some disks says IOCTL_SCSI_GET_ADDRESS not supported.

and hence i am not able to get PDO.

On Fri, Mar 19, 2010 at 6:12 PM, Dennis Scott
wrote:

> Thanks Scott,
>
> I ll try this one.
>
>
> On Fri, Mar 19, 2010 at 6:05 PM, Scott Noone wrote:
>
>> That note is for implementers of storage class drivers, so it’s not really
>> relevant.
>>
>>
>> Then how can i use this to get USB busid?
>>>
>>
>> You have to figure out which disk maps to the volume that you have. One
>> way to do this is to send a request to the volume that the volume will pass
>> through to the disk and save the results. Then grab all of the disk devices
>> in the system and send the same request to each disk until you get a match.
>> Then you have a device object in the disk stack that you can get the
>> hardware ID from.
>>
>> There’s also IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS which will give you the
>> disk number (forgot about this one yesterday). You can then open
>> \Global??\PhysicalDriveN (I think, you need to verify) and do the same sort
>> of thing.
>>
>>
>> -scott
>>
>> –
>> Scott Noone
>> Consulting Associate
>> OSR Open Systems Resources, Inc.
>> http://www.osronline.com
>>
>>
>>
>> “Dennis Scott” wrote in message
>> news:xxxxx@ntfsd…
>>
>> Guys,
>>
>> IOCTL_SCSI_GET_ADDRESS discription says “This request is not relevant to
>> storage class drivers that support Plug and Play because the port driver
>> supplies the address information on behalf of the class driver” Then how can
>> i use this to get USB busid?
>>
>>
>> On Fri, Mar 19, 2010 at 9:06 AM, Dennis Scott <
>> xxxxx@allaboutif.com> wrote:
>>
>> Hello scott,
>>
>> Thanks,
>>
>> This has to be done in both Xp, and Vista, the code returned
>> “STORAGE\Volume” in Xp and i have to test in vista,
>>
>> Maxim,
>>
>> I ll test with IoGetDeviceInterfaces with IOCTL_SCSI_GET_ADDRESS or
>> IOCTL_STORAGE_GET_DEVICE_
>> NUMBER and let you know.
>>
>>
>>
>>
>> On Fri, Mar 19, 2010 at 5:27 AM, Maxim S. Shatskih <
>> xxxxx@storagecraft.com> wrote:
>>
>> starting point might be IoGetDeviceInterfaces and IOCTL_SCSI_GET_ADDRESS,
>>>
>>
>>
>> IOCTL_STORAGE_GET_DEVICE_NUMBER also helps.
>>
>> –
>> Maxim S. Shatskih
>> Windows DDK MVP
>> xxxxx@storagecraft.com
>> http://www.storagecraft.com
>>
>>
>>
>> —
>> NTFSD is sponsored by OSR
>>
>> For our schedule of debugging and file system seminars
>> (including our new fs mini-filter seminar) 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
>>
>> —
>> NTFSD is sponsored by OSR
>>
>> For our schedule of debugging and file system seminars
>> (including our new fs mini-filter seminar) 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
>>
>
>

Well look at that, USBSTOR doesn’t support this request. That’s a real pain,
I guess we’ve only ever needed to do this for fixed disks. Sorry about that.

I believe that the other method should still work, in that case you don’t
need IOCTL_SCSI_GET_ADDRESS since the IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
request uniquely identifies the underlying disk (I’m making an assumption
here that no one would somehow stripe a set of USB disks, though you could
handle that). Just build the \Global??\PhysicalDriveN name then use
IoGetDeviceObjectPointer and IoGetDeviceAttachmentBaseRef to get the USBSTOR
enumerated PDO. From there IoGetDeviceProperty should give you some
identifying information that you can use to determine it’s a USB disk (e.g.
“USBSTOR” as the enumerator).

-scott


Scott Noone
Consulting Associate
OSR Open Systems Resources, Inc.
http://www.osronline.com

“Dennis Scott” wrote in message
news:xxxxx@ntfsd…
scott,

I am not able to get the busid with the steps you mentioned in previous
mail,

can you just confirm me with these queries.

“send a request to the volume that the volume will pass through to the disk
and save the results”
which request you are mentioning here? IOCTL_SCSI_GET_ADDRESS? this ioclt
returns not supported.

“Then grab all of the disk devices in the system and send the same request
to each disk until you get a match”
Done, No problems, but some disks says IOCTL_SCSI_GET_ADDRESS not supported.

and hence i am not able to get PDO.

On Fri, Mar 19, 2010 at 6:12 PM, Dennis Scott
wrote:

Thanks Scott,

I ll try this one.

On Fri, Mar 19, 2010 at 6:05 PM, Scott Noone wrote:

That note is for implementers of storage class drivers, so it’s not really
relevant.

Then how can i use this to get USB busid?

You have to figure out which disk maps to the volume that you have. One way
to do this is to send a request to the volume that the volume will pass
through to the disk and save the results. Then grab all of the disk devices
in the system and send the same request to each disk until you get a match.
Then you have a device object in the disk stack that you can get the
hardware ID from.

There’s also IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS which will give you the
disk number (forgot about this one yesterday). You can then open
\Global??\PhysicalDriveN (I think, you need to verify) and do the same sort
of thing.

-scott


Scott Noone
Consulting Associate
OSR Open Systems Resources, Inc.
http://www.osronline.com

“Dennis Scott” wrote in message
news:xxxxx@ntfsd…

Guys,

IOCTL_SCSI_GET_ADDRESS discription says “This request is not relevant to
storage class drivers that support Plug and Play because the port driver
supplies the address information on behalf of the class driver” Then how can
i use this to get USB busid?

On Fri, Mar 19, 2010 at 9:06 AM, Dennis Scott
wrote:

Hello scott,

Thanks,

This has to be done in both Xp, and Vista, the code returned
“STORAGE\Volume” in Xp and i have to test in vista,

Maxim,

I ll test with IoGetDeviceInterfaces with IOCTL_SCSI_GET_ADDRESS or
IOCTL_STORAGE_GET_DEVICE_
NUMBER and let you know.

On Fri, Mar 19, 2010 at 5:27 AM, Maxim S. Shatskih
wrote:

starting point might be IoGetDeviceInterfaces and IOCTL_SCSI_GET_ADDRESS,

IOCTL_STORAGE_GET_DEVICE_NUMBER also helps.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com


NTFSD is sponsored by OSR

For our schedule of debugging and file system seminars
(including our new fs mini-filter seminar) 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


NTFSD is sponsored by OSR

For our schedule of debugging and file system seminars
(including our new fs mini-filter seminar) 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

Scott,

Thanks a lot i Finally got the USBSTOR Device Object from that method, And
now i can get Hardware Id (USBSTOR\DiskJetFlashTranscend_2GB___8.07 etc.),
and other info from IoGetDeviceProperty,

Is their any way to get actual location of the device on bus? i tried
*DevicePropertyLocationInformation
*but it is failing with STATUS_OBJECT_NAME_NOT_FOUND.

On Wed, Mar 24, 2010 at 12:48 AM, Scott Noone wrote:

> Well look at that, USBSTOR doesn’t support this request. That’s a real
> pain, I guess we’ve only ever needed to do this for fixed disks. Sorry about
> that.
>
> I believe that the other method should still work, in that case you don’t
> need IOCTL_SCSI_GET_ADDRESS since the IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
> request uniquely identifies the underlying disk (I’m making an assumption
> here that no one would somehow stripe a set of USB disks, though you could
> handle that). Just build the \Global??\PhysicalDriveN name then use
> IoGetDeviceObjectPointer and IoGetDeviceAttachmentBaseRef to get the USBSTOR
> enumerated PDO. From there IoGetDeviceProperty should give you some
> identifying information that you can use to determine it’s a USB disk (e.g.
> “USBSTOR” as the enumerator).
>
>
> -scott
>
> –
> Scott Noone
> Consulting Associate
> OSR Open Systems Resources, Inc.
> http://www.osronline.com
>
>
> “Dennis Scott” wrote in message
> news:xxxxx@ntfsd…
>
> scott,
>
> I am not able to get the busid with the steps you mentioned in previous
> mail,
>
> can you just confirm me with these queries.
>
> “send a request to the volume that the volume will pass through to the disk
> and save the results”
> which request you are mentioning here? IOCTL_SCSI_GET_ADDRESS? this ioclt
> returns not supported.
>
> “Then grab all of the disk devices in the system and send the same request
> to each disk until you get a match”
> Done, No problems, but some disks says IOCTL_SCSI_GET_ADDRESS not
> supported.
>
> and hence i am not able to get PDO.
>
>
> On Fri, Mar 19, 2010 at 6:12 PM, Dennis Scott
> wrote:
>
> Thanks Scott,
>
> I ll try this one.
>
>
>
> On Fri, Mar 19, 2010 at 6:05 PM, Scott Noone wrote:
>
> That note is for implementers of storage class drivers, so it’s not really
> relevant.
>
>
>
> Then how can i use this to get USB busid?
>
>
>
> You have to figure out which disk maps to the volume that you have. One way
> to do this is to send a request to the volume that the volume will pass
> through to the disk and save the results. Then grab all of the disk devices
> in the system and send the same request to each disk until you get a match.
> Then you have a device object in the disk stack that you can get the
> hardware ID from.
>
> There’s also IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS which will give you the
> disk number (forgot about this one yesterday). You can then open
> \Global??\PhysicalDriveN (I think, you need to verify) and do the same sort
> of thing.
>
>
> -scott
>
> –
> Scott Noone
> Consulting Associate
> OSR Open Systems Resources, Inc.
> http://www.osronline.com
>
>
>
>
> “Dennis Scott” wrote in message
> news:xxxxx@ntfsd…
>
> Guys,
>
> IOCTL_SCSI_GET_ADDRESS discription says “This request is not relevant to
> storage class drivers that support Plug and Play because the port driver
> supplies the address information on behalf of the class driver” Then how can
> i use this to get USB busid?
>
>
> On Fri, Mar 19, 2010 at 9:06 AM, Dennis Scott
> wrote:
>
>
> Hello scott,
>
> Thanks,
>
> This has to be done in both Xp, and Vista, the code returned
> “STORAGE\Volume” in Xp and i have to test in vista,
>
> Maxim,
>
> I ll test with IoGetDeviceInterfaces with IOCTL_SCSI_GET_ADDRESS or
> IOCTL_STORAGE_GET_DEVICE_
> NUMBER and let you know.
>
>
>
>
> On Fri, Mar 19, 2010 at 5:27 AM, Maxim S. Shatskih
> wrote:
>
>
> starting point might be IoGetDeviceInterfaces and IOCTL_SCSI_GET_ADDRESS,
>
>
>
> IOCTL_STORAGE_GET_DEVICE_NUMBER also helps.
>
> –
> Maxim S. Shatskih
> Windows DDK MVP
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
>
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars
> (including our new fs mini-filter seminar) 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
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars
> (including our new fs mini-filter seminar) 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
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars
> (including our new fs mini-filter seminar) 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
>

>Is their any way to get actual location of the device on bus?

Like, which port it’s plugged in to? It’s generally not very useful, but
ignoring that…Not really, you can’t get that information from this PDO.
For that, you need the USB hub’s PDO or the USBSTOR FDO so that you can send
some USB specific IOCTL to it.

You should play with DeviceTree a bit so that you can visualize what pieces
you’re talking to, that should give you an idea about the boundaries that
you’re running in to. I’d also really recommend trying to do this work in
user mode and sending the results back to the driver, if you look at the
USBView sample in the WDK you can see how much easier it is to get this sort
of information using the UM APIs.

-scott


Scott Noone
Consulting Associate
OSR Open Systems Resources, Inc.
http://www.osronline.com

“Dennis Scott” wrote in message
news:xxxxx@ntfsd…
Scott,

Thanks a lot i Finally got the USBSTOR Device Object from that method, And
now i can get Hardware Id (USBSTOR\DiskJetFlashTranscend_2GB___8.07 etc.),
and other info from IoGetDeviceProperty,

Is their any way to get actual location of the device on bus? i tried
DevicePropertyLocationInformation but it is failing with
STATUS_OBJECT_NAME_NOT_FOUND.

On Wed, Mar 24, 2010 at 12:48 AM, Scott Noone wrote:

Well look at that, USBSTOR doesn’t support this request. That’s a real pain,
I guess we’ve only ever needed to do this for fixed disks. Sorry about that.

I believe that the other method should still work, in that case you don’t
need IOCTL_SCSI_GET_ADDRESS since the IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
request uniquely identifies the underlying disk (I’m making an assumption
here that no one would somehow stripe a set of USB disks, though you could
handle that). Just build the \Global??\PhysicalDriveN name then use
IoGetDeviceObjectPointer and IoGetDeviceAttachmentBaseRef to get the USBSTOR
enumerated PDO. From there IoGetDeviceProperty should give you some
identifying information that you can use to determine it’s a USB disk (e.g.
“USBSTOR” as the enumerator).

-scott


Scott Noone
Consulting Associate
OSR Open Systems Resources, Inc.
http://www.osronline.com

“Dennis Scott” wrote in message
news:xxxxx@ntfsd…

scott,

I am not able to get the busid with the steps you mentioned in previous
mail,

can you just confirm me with these queries.

“send a request to the volume that the volume will pass through to the disk
and save the results”

which request you are mentioning here? IOCTL_SCSI_GET_ADDRESS? this ioclt
returns not supported.

“Then grab all of the disk devices in the system and send the same request
to each disk until you get a match”

Done, No problems, but some disks says IOCTL_SCSI_GET_ADDRESS not supported.

and hence i am not able to get PDO.

On Fri, Mar 19, 2010 at 6:12 PM, Dennis Scott
wrote:

Thanks Scott,

I ll try this one.

On Fri, Mar 19, 2010 at 6:05 PM, Scott Noone wrote:

That note is for implementers of storage class drivers, so it’s not really
relevant.

Then how can i use this to get USB busid?

You have to figure out which disk maps to the volume that you have. One way
to do this is to send a request to the volume that the volume will pass
through to the disk and save the results. Then grab all of the disk devices
in the system and send the same request to each disk until you get a match.
Then you have a device object in the disk stack that you can get the
hardware ID from.

There’s also IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS which will give you the
disk number (forgot about this one yesterday). You can then open
\Global??\PhysicalDriveN (I think, you need to verify) and do the same sort
of thing.

-scott


Scott Noone
Consulting Associate
OSR Open Systems Resources, Inc.
http://www.osronline.com

“Dennis Scott” wrote in message
news:xxxxx@ntfsd…

Guys,

IOCTL_SCSI_GET_ADDRESS discription says “This request is not relevant to
storage class drivers that support Plug and Play because the port driver
supplies the address information on behalf of the class driver” Then how can
i use this to get USB busid?

On Fri, Mar 19, 2010 at 9:06 AM, Dennis Scott
wrote:

Hello scott,

Thanks,

This has to be done in both Xp, and Vista, the code returned
“STORAGE\Volume” in Xp and i have to test in vista,

Maxim,

I ll test with IoGetDeviceInterfaces with IOCTL_SCSI_GET_ADDRESS or
IOCTL_STORAGE_GET_DEVICE_
NUMBER and let you know.

On Fri, Mar 19, 2010 at 5:27 AM, Maxim S. Shatskih
wrote:

starting point might be IoGetDeviceInterfaces and IOCTL_SCSI_GET_ADDRESS,

IOCTL_STORAGE_GET_DEVICE_NUMBER also helps.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com


NTFSD is sponsored by OSR

For our schedule of debugging and file system seminars
(including our new fs mini-filter seminar) 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


NTFSD is sponsored by OSR

For our schedule of debugging and file system seminars
(including our new fs mini-filter seminar) 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


NTFSD is sponsored by OSR

For our schedule of debugging and file system seminars
(including our new fs mini-filter seminar) 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

>

Like, which port it’s plugged in to?

Yes,

Thanks for your help,

I am using Device tree for comparing the PDO and device address i am getting
in my driver, yes it is very use full, example my USBSTOR device object is
0X829DDA80 and is same as PDO address i got from
IoGetDeviceAttachmentBaseRef.

It’s generally not very useful, but ignoring that…Not really, you can’t
get that information from this PDO. For that, you need the USB hub’s PDO or
the USBSTOR FDO so that you can send some USB specific IOCTL to it.

You should play with DeviceTree a bit so that you can visualize what pieces
you’re talking to, that should give you an idea about the boundaries that
you’re running in to. I’d also really recommend trying to do this work in
user mode and sending the results back to the driver, if you look at the
USBView sample in the WDK you can see how much easier it is to get this sort
of information using the UM APIs.

-scott


Scott Noone
Consulting Associate
OSR Open Systems Resources, Inc.
http://www.osronline.com

“Dennis Scott” wrote in message
> news:xxxxx@ntfsd…
>
> Scott,
>
> Thanks a lot i Finally got the USBSTOR Device Object from that method, And
> now i can get Hardware Id (USBSTOR\DiskJetFlashTranscend_2GB___8.07 etc.),
> and other info from IoGetDeviceProperty,
>
> Is their any way to get actual location of the device on bus? i tried
> DevicePropertyLocationInformation but it is failing with
> STATUS_OBJECT_NAME_NOT_FOUND.
>
>
> On Wed, Mar 24, 2010 at 12:48 AM, Scott Noone wrote:
>
> Well look at that, USBSTOR doesn’t support this request. That’s a real
> pain, I guess we’ve only ever needed to do this for fixed disks. Sorry about
> that.
>
> I believe that the other method should still work, in that case you don’t
> need IOCTL_SCSI_GET_ADDRESS since the IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
> request uniquely identifies the underlying disk (I’m making an assumption
> here that no one would somehow stripe a set of USB disks, though you could
> handle that). Just build the \Global??\PhysicalDriveN name then use
> IoGetDeviceObjectPointer and IoGetDeviceAttachmentBaseRef to get the USBSTOR
> enumerated PDO. From there IoGetDeviceProperty should give you some
> identifying information that you can use to determine it’s a USB disk (e.g.
> “USBSTOR” as the enumerator).
>
>
> -scott
>
> –
> Scott Noone
> Consulting Associate
> OSR Open Systems Resources, Inc.
> http://www.osronline.com
>
>
>
> “Dennis Scott” wrote in message
> news:xxxxx@ntfsd…
>
> scott,
>
> I am not able to get the busid with the steps you mentioned in previous
> mail,
>
> can you just confirm me with these queries.
>
>
> “send a request to the volume that the volume will pass through to the disk
> and save the results”
>
> which request you are mentioning here? IOCTL_SCSI_GET_ADDRESS? this ioclt
> returns not supported.
>
>
> “Then grab all of the disk devices in the system and send the same request
> to each disk until you get a match”
>
> Done, No problems, but some disks says IOCTL_SCSI_GET_ADDRESS not
> supported.
>
> and hence i am not able to get PDO.
>
>
>
> On Fri, Mar 19, 2010 at 6:12 PM, Dennis Scott
> wrote:
>
> Thanks Scott,
>
> I ll try this one.
>
>
>
> On Fri, Mar 19, 2010 at 6:05 PM, Scott Noone wrote:
>
> That note is for implementers of storage class drivers, so it’s not really
> relevant.
>
>
>
> Then how can i use this to get USB busid?
>
>
>
> You have to figure out which disk maps to the volume that you have. One way
> to do this is to send a request to the volume that the volume will pass
> through to the disk and save the results. Then grab all of the disk devices
> in the system and send the same request to each disk until you get a match.
> Then you have a device object in the disk stack that you can get the
> hardware ID from.
>
> There’s also IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS which will give you the
> disk number (forgot about this one yesterday). You can then open
> \Global??\PhysicalDriveN (I think, you need to verify) and do the same sort
> of thing.
>
>
> -scott
>
> –
> Scott Noone
> Consulting Associate
> OSR Open Systems Resources, Inc.
> http://www.osronline.com
>
>
>
>
> “Dennis Scott” wrote in message
> news:xxxxx@ntfsd…
>
> Guys,
>
> IOCTL_SCSI_GET_ADDRESS discription says “This request is not relevant to
> storage class drivers that support Plug and Play because the port driver
> supplies the address information on behalf of the class driver” Then how can
> i use this to get USB busid?
>
>
> On Fri, Mar 19, 2010 at 9:06 AM, Dennis Scott
> wrote:
>
>
> Hello scott,
>
> Thanks,
>
> This has to be done in both Xp, and Vista, the code returned
> “STORAGE\Volume” in Xp and i have to test in vista,
>
> Maxim,
>
> I ll test with IoGetDeviceInterfaces with IOCTL_SCSI_GET_ADDRESS or
> IOCTL_STORAGE_GET_DEVICE_
> NUMBER and let you know.
>
>
>
>
> On Fri, Mar 19, 2010 at 5:27 AM, Maxim S. Shatskih
> wrote:
>
>
> starting point might be IoGetDeviceInterfaces and IOCTL_SCSI_GET_ADDRESS,
>
>
>
> IOCTL_STORAGE_GET_DEVICE_NUMBER also helps.
>
> –
> Maxim S. Shatskih
> Windows DDK MVP
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
>
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars
> (including our new fs mini-filter seminar) 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
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars
> (including our new fs mini-filter seminar) 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
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars
> (including our new fs mini-filter seminar) 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
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars
> (including our new fs mini-filter seminar) 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 you got the USBSTOR device object.
I tried FltGetVolumeName then IoGetDeviceObjectPointer,IoGetDeviceAttachmentBaseRef.
IoGetDeviceAttachmentBaseRef give me a pointer to fastfat back.
What have i made wrong?

send IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS for device object obtained from
FltGetDiskDeviceObject,

once you get the volume extent *N* append this number to “*
\GLOBAL??\PhysicalDrive*”

Create unicode string and call IoGetDeviceObjectPointer,

once you get the deviceobject then call IoGetDeviceAttachmentBaseRef

this will return you USBSTOR device object, now on this you can call
IoGetDeviceProperty.

On Wed, Mar 31, 2010 at 12:44 AM, wrote:

> How you got the USBSTOR device object.
> I tried FltGetVolumeName then
> IoGetDeviceObjectPointer,IoGetDeviceAttachmentBaseRef.
> IoGetDeviceAttachmentBaseRef give me a pointer to fastfat back.
> What have i made wrong?
>
>
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars
> (including our new fs mini-filter seminar) 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 for the fast reply.
Now i have a simple question how will i get the unicodestring?
I tried it so, but it’s not right.
UNICODE_STRING devicename;
devicename.Buffer = “\Global??\PhysicalDrive” + volumeextents->Extents->DiskNumber;
Please help me!
Best Regards

This works for me.

UNICODE_STRING devicename;
wchar_t globalpath[30];
.
.
.
.
.
wcscpy(globalpath,L"\GLOBAL??\PhysicalDrive");

globalpath[23]=(WORD)pvdExtents->Extents[0].DiskNumber+0x30; // Some bad
“hardcoding”

globalpath[24]=0;

RtlInitUnicodeString(&devicename,globalpath);

Now use

IoGetDeviceObjectPointer(&devicename,FILE_READ_ATTRIBUTES,&FileObject,&DeviceObject)

On Wed, Mar 31, 2010 at 8:07 PM, wrote:

> Thanks for the fast reply.
> Now i have a simple question how will i get the unicodestring?
> I tried it so, but it’s not right.
> UNICODE_STRING devicename;
> devicename.Buffer = “\Global??\PhysicalDrive” +
> volumeextents->Extents->DiskNumber;
> Please help me!
> Best Regards
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars
> (including our new fs mini-filter seminar) 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
>

So now i tried:
\GLOBAL??\PhysicalDrive1

  • IoGetDeviceObjectPointer i get a pointer to FILE_DEVICE_DISK_FILE_SYSTEM at \Filesystem\FltMgr
  • IoGetDeviceAttachmentBaseRef i get a pointer to FILE_DEVICE_DISK_FILE_SYSTEM at \Filesystem\RAW
  • IoGetDeviceProperty failed with STATUS_INVALID_DEVICE_REQUEST

Have you any idea how i can work?

IoGetDeviceAttachmentBaseRef should give you the USBSTOR object, If you can
put the code out, some one on the list can figure out the problem.

On Thu, Apr 1, 2010 at 4:07 PM, wrote:

> So now i tried:
> \GLOBAL??\PhysicalDrive1
> - IoGetDeviceObjectPointer i get a pointer to FILE_DEVICE_DISK_FILE_SYSTEM
> at \Filesystem\FltMgr
> - IoGetDeviceAttachmentBaseRef i get a pointer to
> FILE_DEVICE_DISK_FILE_SYSTEM at \Filesystem\RAW
> - IoGetDeviceProperty failed with STATUS_INVALID_DEVICE_REQUEST
>
> Have you any idea how i can work?
>
>
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars
> (including our new fs mini-filter seminar) 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 would be glad, if someone can say me how to get the USBSTOR object.

KEVENT WaitEvent;
PIRP NewIrp;
NTSTATUS status1;
PDEVICE_OBJECT ndevice;
PDEVICE_OBJECT device;
PFILE_OBJECT file;
ULONG lenght;
WCHAR hwId[256];
PVOLUME_DISK_EXTENTS volumeextents;
PUNICODE_STRING devicename;
wchar_t data[25];

KeInitializeEvent(&WaitEvent, NotificationEvent, FALSE);
volumeextents = ExAllocatePoolWithTag(NonPagedPool,sizeof(VOLUME_DISK_EXTENTS), 500);
NewIrp = IoBuildDeviceIoControlRequest(IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS,
DeviceObject,
NULL, 0,
(PVOID)volumeextents, sizeof(VOLUME_DISK_EXTENTS),
FALSE, &WaitEvent, &IoStatus);

if (!NewIrp) {
DbgPrint(“Failed to create new IRP,IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS”);
ExFreePoolWithTag(volumeextents, 500);
return;
}

// send this irp to the storage device
irpnext = IoGetNextIrpStackLocation(NewIrp);
DbgPrint(“Setze jetz IoCall ab!\n”);
Status = IoCallDriver(DeviceObject, NewIrp);

if (Status == STATUS_PENDING) {
Status = KeWaitForSingleObject(&WaitEvent, Executive, KernelMode, FALSE,
NULL);
Status = IoStatus.Status;
}

if (!NT_SUCCESS(Status)) {
DbgPrint(“IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS failed, status =0x%x”, Status);
ExFreePoolWithTag(volumeextents, 500);
return;
}

wcscpy(data,L"\GLOBAL??\PhysicalDrive");
data[23]= volumeextents->Extents[0].DiskNumber+0x30;
data[24]=0;
RtlInitUnicodeString(&devicename,data);
ExFreePoolWithTag(volumeextents, 500);
IoGetDeviceObjectPointer(&devicename,FILE_WRITE_DATA,&file,&device);
ndevice = IoGetDeviceAttachmentBaseRef(device);
status1 = IoGetDeviceProperty(ndevice,DevicePropertyHardwareID,sizeof (hwId),hwId,&lenght);
if (!NT_SUCCESS(status1)) {
DbgPrint(" failed, status =0x%x", status1);
return;
}

i dont see much difference but surely, make these changes

data[23]= *(DWORD)*volumeextents->Extents[0].DiskNumber+0x30;

and

IoGetDeviceObjectPointer(&devicename,*FILE_READ_ATTRIBUTES*,&file,&device);

On Thu, Apr 1, 2010 at 5:01 PM, wrote:

> I would be glad, if someone can say me how to get the USBSTOR object.
>
> KEVENT WaitEvent;
> PIRP NewIrp;
> NTSTATUS status1;
> PDEVICE_OBJECT ndevice;
> PDEVICE_OBJECT device;
> PFILE_OBJECT file;
> ULONG lenght;
> WCHAR hwId[256];
> PVOLUME_DISK_EXTENTS volumeextents;
> PUNICODE_STRING devicename;
> wchar_t data[25];
>
> KeInitializeEvent(&WaitEvent, NotificationEvent, FALSE);
> volumeextents =
> ExAllocatePoolWithTag(NonPagedPool,sizeof(VOLUME_DISK_EXTENTS), 500);
> NewIrp =
> IoBuildDeviceIoControlRequest(IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS,
> DeviceObject,
> NULL, 0,
> (PVOID)volumeextents, sizeof(VOLUME_DISK_EXTENTS),
> FALSE, &WaitEvent, &IoStatus);
>
> if (!NewIrp) {
> DbgPrint(“Failed to create new
> IRP,IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS”);
> ExFreePoolWithTag(volumeextents, 500);
> return;
> }
>
> // send this irp to the storage device
> irpnext = IoGetNextIrpStackLocation(NewIrp);
> DbgPrint(“Setze jetz IoCall ab!\n”);
> Status = IoCallDriver(DeviceObject, NewIrp);
>
> if (Status == STATUS_PENDING) {
> Status = KeWaitForSingleObject(&WaitEvent, Executive,
> KernelMode, FALSE,
> NULL);
> Status = IoStatus.Status;
> }
>
> if (!NT_SUCCESS(Status)) {
> DbgPrint(“IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS failed,
> status =0x%x”, Status);
> ExFreePoolWithTag(volumeextents, 500);
> return;
> }
>
> wcscpy(data,L"\GLOBAL??\PhysicalDrive");
> data[23]= volumeextents->Extents[0].DiskNumber+0x30;
> data[24]=0;
> RtlInitUnicodeString(&devicename,data);
> ExFreePoolWithTag(volumeextents, 500);
> IoGetDeviceObjectPointer(&devicename,FILE_WRITE_DATA,&file,&device);
> ndevice = IoGetDeviceAttachmentBaseRef(device);
> status1 = IoGetDeviceProperty(ndevice,DevicePropertyHardwareID,sizeof
> (hwId),hwId,&lenght);
> if (!NT_SUCCESS(status1)) {
> DbgPrint(" failed, status =0x%x", status1);
> return;
> }
>
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars
> (including our new fs mini-filter seminar) 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
>

great!!! thanks, that was it - now i got the USBSTOR object :-))))

Good to hear.

any how what made the difference?

On Thu, Apr 1, 2010 at 5:42 PM, wrote:

> great!!! thanks, that was it - now i got the USBSTOR object :-))))
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars
> (including our new fs mini-filter seminar) 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
>