Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to associate a volume with a physical disk drive?

6 views
Skip to first unread message

ohg

unread,
Jun 17, 2003, 5:54:33 PM6/17/03
to
As a matter of fact there are many resources on the web,however some
are
not helpful or even invalid.

What i want to do is to do what 'hotplug.dll' does,or 'Remove
Hardwares' does.
Up to now i can get the specific volume driver from a drive
letter,thru
2 ways,the one is to use IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS and the
other is
to use native APIs such as ZwQuerySymbolicLinkObject.But I don't know
how to associate a volume with a diskdrive.

We can get the *tree* when right clicking the 'Remove Hardwares' tray
icon,
which clearly illustrates the relationship: volume(s) -- diskdrive --
physical device.

Could anybody give me some hints on how to programmatically illustrate
the relationship above?

Slava M. Usov

unread,
Jun 18, 2003, 6:15:05 AM6/18/03
to
"ohg" <oh...@mails.tsinghua.edu.cn> wrote in message
news:6fb580da.03061...@posting.google.com...

[...]

> But I don't know how to associate a volume with a diskdrive.

Disk drive _letters_, if this is what you mean by 'diskdrive', exist solely
for win32 convenience, as symbolic links from \?? or \Global??. You can
enumerate them by win32's QueryDosDevice(), or by using the native API to do
the same. Look for "*:" names, then get their target devices, and those will
be the volumes. Then you can build a two-way map, and use it anyway you
want.

S


ohg

unread,
Jun 24, 2003, 11:40:47 AM6/24/03
to
er.... I had achieved what you said before I posted the previous message.

Maybe I made myself misunderstood.

What i mean is to build a 2-way map as 'Remove Hardwares' does, i.e.

a map about 'volume letter -- DEVICE'.

More detaily,for instance,suppose
a system contains 2 HDS.The one has C: and D:,and its device description is
'IABCDEF2303030',the other has E: and F:,whose device description is 'WDABCDDD3030'.

How Can I associate 'C: and D:' with 'IABCDEF2303030' and
'E: and F:' with 'WDABCDD3030' ?

By using native APIs I know 'C:' links to "\Device\Harddisk1Volume1".
But what does this NT device name mean? What kinds of hints can it give me?
I consult the DDK docs to find my answer but...

May be it is created by volsnap.sys but not disk.sys.

Can you give me your advice?


"Slava M. Usov" <stripit...@gmx.net> wrote in message news:<#qSx#JYNDH...@TK2MSFTNGP11.phx.gbl>...

Mark Roddy

unread,
Jun 24, 2003, 6:01:39 PM6/24/03
to
On 24 Jun 2003 08:40:47 -0700, oh...@mails.tsinghua.edu.cn (ohg)
wrote:

>er.... I had achieved what you said before I posted the previous message.
>
>Maybe I made myself misunderstood.
>
>What i mean is to build a 2-way map as 'Remove Hardwares' does, i.e.
>
>a map about 'volume letter -- DEVICE'.
>
>More detaily,for instance,suppose
>a system contains 2 HDS.The one has C: and D:,and its device description is
>'IABCDEF2303030',the other has E: and F:,whose device description is 'WDABCDDD3030'.
>
>How Can I associate 'C: and D:' with 'IABCDEF2303030' and
> 'E: and F:' with 'WDABCDD3030' ?
>
>By using native APIs I know 'C:' links to "\Device\Harddisk1Volume1".
>But what does this NT device name mean? What kinds of hints can it give me?
>I consult the DDK docs to find my answer but...
>

The way to associate volumes with physical disks is through the use of
the IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS IOCTL. First use the SetupDi
API to enumerate all the volumes and physical disks on the system. For
each physical disk, use IOCTL_STORAGE_GET_DEVICE_NUMBER to obtain the
DeviceNumber of the disk. For each volume use
IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS to obtain the list of
DISK_EXTENTS associated with each volume. The DISK_EXTENT list
associates volumes to physical disks by DiskNumber, so you just need
to design the appropriate associative data structures and you can
readily produce a list of either volumes by disks or disk by volumes.


=====================
Mark Roddy
Windows XP/2000/NT Consulting, Microsoft DDK MVP
Hollis Technology Solutions 603-321-1032
www.hollistech.com
ma...@hollistech.com
For Windows Device Driver Training: see www.azius.com

0 new messages