: how to get USB busid from minifilter driver

That should do it, you may get back more than one ID. You will have to
resolve that.

Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

From: Dennis Scott [mailto:xxxxx@allaboutif.com]
Posted At: Thursday, March 18, 2010 8:34 AM
Posted To: ntfsd
Conversation: how to get USB busid from minifilter driver
Subject: Re: how to get USB busid from minifilter driver

Thanks Don,

should i use IoGetDeviceProperty with DeviceProperty as
DevicePropertyHardwareID?

is this the correct way to get busid.
On Thu, Mar 18, 2010 at 5:51 PM, Don Burn wrote:
In the InstanceSetupCallback use FltGetDiskDeviceObject to get the
device, then use that to get the bus-id and store it in the context for
the instance. You do not want to get it for every create, it will stay
the same for a volume.

Don Burn (MVP, Windows DKD)

Windows Filesystem and Driver Consulting

Website: http://www.windrvr.com

Blog: http://msmvps.com/blogs/WinDrvr

From: Dennis Scott [mailto:xxxxx@allaboutif.com]
Posted At: Thursday, March 18, 2010 8:12 AM
Posted To: ntfsd
Conversation: how to get USB busid from minifilter driver
Subject: how to get USB busid from minifilter driver

Hi all,

How can i get the usb drive bus-id in an minifilter driver during
IRP_MJ_CREATE.

Thanks and Regards
dennis scott

Information from ESET Smart Security, version of virus
signature database 4954 (20100318)


The message was checked by ESET Smart Security.

http://www.eset.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

Information from ESET Smart Security, version of virus
signature database 4954 (20100318)


The message was checked by ESET Smart Security.

http://www.eset.com

Don,

this is returning “STORAGE\Volume”

the code follows

case FILE_DEVICE_DISK_FILE_SYSTEM:if (NT_SUCCESS(FltGetDiskDeviceObject(FltObjects->Volume,&DiskDeviceObject))) {DbgPrint("FltGetDiskDeviceObject succeded\n");status =IoGetDeviceProperty(DiskDeviceObject,DevicePropertyHardwareID,sizeof(name),name, &junk);if (NT_SUCCESS(status)) DbgPrint("succeeded for '%ws' device\n", name); else DbgPrint("IoGetDeviceProperty failed - %X\n", status); }

thanks
dennis scott

On Thu, Mar 18, 2010 at 6:19 PM, Don Burn wrote:

> That should do it, you may get back more than one ID. You will have to
> resolve that.
>
>
> Don Burn (MVP, Windows DKD)
> Windows Filesystem and Driver Consulting
> Website: http://www.windrvr.com
> Blog: http://msmvps.com/blogs/WinDrvr
>
>
>
> From: Dennis Scott [mailto:xxxxx@allaboutif.com]
> Posted At: Thursday, March 18, 2010 8:34 AM
> Posted To: ntfsd
> Conversation: how to get USB busid from minifilter driver
> Subject: Re: how to get USB busid from minifilter driver
>
> Thanks Don,
>
> should i use IoGetDeviceProperty with DeviceProperty as
> DevicePropertyHardwareID?
>
> is this the correct way to get busid.
> On Thu, Mar 18, 2010 at 5:51 PM, Don Burn wrote:
> In the InstanceSetupCallback use FltGetDiskDeviceObject to get the
> device, then use that to get the bus-id and store it in the context for
> the instance. You do not want to get it for every create, it will stay
> the same for a volume.
>
>
>
>
>
> Don Burn (MVP, Windows DKD)
>
> Windows Filesystem and Driver Consulting
>
> Website: http://www.windrvr.com
>
> Blog: http://msmvps.com/blogs/WinDrvr
>
>
>
>
>
>
>
> From: Dennis Scott [mailto:xxxxx@allaboutif.com]
> Posted At: Thursday, March 18, 2010 8:12 AM
> Posted To: ntfsd
> Conversation: how to get USB busid from minifilter driver
> Subject: how to get USB busid from minifilter driver
>
>
>
> Hi all,
>
> How can i get the usb drive bus-id in an minifilter driver during
> IRP_MJ_CREATE.
>
> Thanks and Regards
> dennis scott
>
>
> Information from ESET Smart Security, version of virus
> signature database 4954 (20100318)

>
>
>
> The message was checked by ESET Smart Security.
>
>
>
> http://www.eset.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
>
>
> Information from ESET Smart Security, version of virus
> signature database 4954 (20100318)

>
> The message was checked by ESET Smart Security.
>
> http://www.eset.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
>

Is this XP or Vista? Prior to Vista you used to be able to do this for disks
that reported themselves as removable since the volume manager didn’t get in
the way of those. For disks that don’t report themselves as removable or on
Vista and later you’re going to have to work harder to map the volume to the
disk. The issue that you have is that in this case disks and storage volumes
exist in different branches of the device tree, so you need some way to
bridge the two starting at the volume.

I haven’t actually tried to do exactly this yet. If you can get away with it
in user mode then you might be better off or maybe there’s a new API that’s
been added to help with this and someone else can chime in. If not, a
starting point might be IoGetDeviceInterfaces and IOCTL_SCSI_GET_ADDRESS,
you’d be looking for the same address to come back from the disk path as you
would the volume. I’ve used this trick in the past from user mode to do
something similar. It’s a bit overkill, but a starting point to get the
creative juices flowing in case no one has a better idea…

Good luck,

-scott


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

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

this is returning “STORAGE\Volume”

the code follows



case FILE_DEVICE_DISK_FILE_SYSTEM:

if (NT_SUCCESS(FltGetDiskDeviceObject(FltObjects->Volume,
&DiskDeviceObject)))
{

DbgPrint(“FltGetDiskDeviceObject succeded\n”);

status =
IoGetDeviceProperty(DiskDeviceObject,DevicePropertyHardwareID,sizeof(name),
name, &junk);

if (NT_SUCCESS(status))
DbgPrint(“succeeded for ‘%ws’ device\n”, name);
else
DbgPrint(“IoGetDeviceProperty failed - %X\n”, status);
}



thanks
dennis scott

On Thu, Mar 18, 2010 at 6:19 PM, Don Burn wrote:

That should do it, you may get back more than one ID. You will have to
resolve that.

Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

From: Dennis Scott [mailto:xxxxx@allaboutif.com]
Posted At: Thursday, March 18, 2010 8:34 AM
Posted To: ntfsd
Conversation: how to get USB busid from minifilter driver
Subject: Re: how to get USB busid from minifilter driver

Thanks Don,

should i use IoGetDeviceProperty with DeviceProperty as
DevicePropertyHardwareID?

is this the correct way to get busid.
On Thu, Mar 18, 2010 at 5:51 PM, Don Burn wrote:
In the InstanceSetupCallback use FltGetDiskDeviceObject to get the
device, then use that to get the bus-id and store it in the context for
the instance. You do not want to get it for every create, it will stay
the same for a volume.

Don Burn (MVP, Windows DKD)

Windows Filesystem and Driver Consulting

Website: http://www.windrvr.com

Blog: http://msmvps.com/blogs/WinDrvr

From: Dennis Scott [mailto:xxxxx@allaboutif.com]
Posted At: Thursday, March 18, 2010 8:12 AM
Posted To: ntfsd
Conversation: how to get USB busid from minifilter driver
Subject: how to get USB busid from minifilter driver

Hi all,

How can i get the usb drive bus-id in an minifilter driver during
IRP_MJ_CREATE.

Thanks and Regards
dennis scott

Information from ESET Smart Security, version of virus
signature database 4954 (20100318)


The message was checked by ESET Smart Security.

http://www.eset.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

Information from ESET Smart Security, version of virus
signature database 4954 (20100318)


The message was checked by ESET Smart Security.

http://www.eset.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

> 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;
}