How to get PhysicalDiskX from GUID

Hi,

I know this has been discussed before, but I have still not found a
satisfactory answer. I am hoping that someone out there has.

Suppose you find all of the physical disks in the system using
SetupDiGetClassDevs. Now you have all of them in GUID form. What I want to
do is translate from the GUID form to PhysicalDiskX form. My reason for
doing this is that I want to identify which Volumes (partitions) are on
which disks. I can use IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
to find out which PhysicalDisk each volume is on. But I still need to
somehow associate the PhysicalDiskNumbers with the GUIDs.

I looked in the registry under
HKLM\SYSTEM\CurrentControlSet\Services\Disk\Enum and found a sort of
enumeration of the GUIDs, but I was not sure if this would always match
the PhysicalDiskX.

What I am really trying to do here is duplicate the information that the
Disk Manager application presents, what disks exist, what volumes are on
those disks, and what file systems are on the volumes.

I am about ready to enumerate from PhysicalDisk0 to some large number, say
PhysicalDisk1000 and just ignore any holes that are there. It seemed like
there ought to be a better way though.

I would sure appreciate any ideas.

Thanks,

Don

I’d personally choose to consider the PhysicalDiskNNNN stuff to be obsolete
legacy crap. You got the disk number, and that produces a unique ordering of
the disks, why perpetuate the NT4 nonsense? Oh, and I think the answer is to
do the hideous enumeration you outlined, the obsolete ‘enumerate some
arbitrary namespace using some arbitrary naming convention’ method. I find
it hard to program using a ten foot pole to access the keyboard, but that is
just my own idiosyncracy :slight_smile:

=====================
Mark Roddy
Hollis Technology Solutions
www.hollistech.com
xxxxx@hollistech.com

-----Original Message-----
From: Don Edvalson [mailto:xxxxx@pinnaclesys.com]
Sent: Wednesday, August 13, 2003 10:56 AM
To: Windows System Software Developers Interest List
Subject: [ntdev] How to get PhysicalDiskX from GUID

Hi,

I know this has been discussed before, but I have still not found a
satisfactory answer. I am hoping that someone out there has.

Suppose you find all of the physical disks in the system using
SetupDiGetClassDevs. Now you have all of them in GUID form. What I want to
do is translate from the GUID form to PhysicalDiskX form. My reason for
doing this is that I want to identify which Volumes (partitions) are on
which disks. I can use IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
to find out which PhysicalDisk each volume is on. But I still need to
somehow associate the PhysicalDiskNumbers with the GUIDs.

I looked in the registry under
HKLM\SYSTEM\CurrentControlSet\Services\Disk\Enum and found a sort of
enumeration of the GUIDs, but I was not sure if this would always match the
PhysicalDiskX.

What I am really trying to do here is duplicate the information that the
Disk Manager application presents, what disks exist, what volumes are on
those disks, and what file systems are on the volumes.

I am about ready to enumerate from PhysicalDisk0 to some large number, say
PhysicalDisk1000 and just ignore any holes that are there. It seemed like
there ought to be a better way though.

I would sure appreciate any ideas.

Thanks,

Don


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@stratus.com To
unsubscribe send a blank email to xxxxx@lists.osr.com

Mark,

I agree completely that the PhysicalDiskX stuff is (or should be)
obsolete). However, what I can’t find is a way to say that this particluar
volume exists on this particluar disk. What I am looking for is the
association between disks and volumes. What I would really like is an
IOCTL or something that will accept that volume “GUID…” is on disk
“GUID…”. Of course the volume may span disks, but that is OK, I can deal
with that.

The problem as I see is it is that IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
still
returns a simple number instead of a GUID.

The documentation for all of this is, to put it mildly, obscure, but…

The value returned from IOCTL_STORAGE_GET_DEVICE_NUMBER matches the disk
number returned in the extent list supplied by
IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS. You just need to map disk number to
‘disk name’ and then volumes to disks by their number, and you are done. You
have the disk name from the setupapi. You can get the associated disk number
as noted above. What am I missing?

=====================
Mark Roddy
Hollis Technology Solutions
www.hollistech.com
xxxxx@hollistech.com

-----Original Message-----
From: Don Edvalson [mailto:xxxxx@pinnaclesys.com]
Sent: Wednesday, August 13, 2003 12:16 PM
To: Windows System Software Developers Interest List
Subject: [ntdev] RE: How to get PhysicalDiskX from GUID

Mark,

I agree completely that the PhysicalDiskX stuff is (or should be) obsolete).
However, what I can’t find is a way to say that this particluar volume
exists on this particluar disk. What I am looking for is the association
between disks and volumes. What I would really like is an IOCTL or something
that will accept that volume “GUID…” is on disk “GUID…”. Of course the
volume may span disks, but that is OK, I can deal with that.

The problem as I see is it is that IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
still
returns a simple number instead of a GUID.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@stratus.com To
unsubscribe send a blank email to xxxxx@lists.osr.com

Mark,

You weren’t missing anything, I was being brain dead. Since I was working
in user space, it never occured to me to use
IOCTL_STORAGE_GET_DEVICE_NUMBER. That is exactly what I needed.

Thanks Much,

Don

The documentation for all of this is, to put it mildly, obscure, but…

The value returned from IOCTL_STORAGE_GET_DEVICE_NUMBER matches the disk
number returned in the extent list supplied by
IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS. You just need to map disk number to
‘disk name’ and then volumes to disks by their number, and you are done. You
have the disk name from the setupapi. You can get the associated disk number
as noted above. What am I missing?

=====================
Mark Roddy
Hollis Technology Solutions
www.hollistech.com
xxxxx@hollistech.com

-----Original Message-----
From: Don Edvalson [mailto:xxxxx@pinnaclesys.com]
Sent: Wednesday, August 13, 2003 12:16 PM
To: Windows System Software Developers Interest List
Subject: [ntdev] RE: How to get PhysicalDiskX from GUID

Mark,

I agree completely that the PhysicalDiskX stuff is (or should be) obsolete).
However, what I can’t find is a way to say that this particluar volume
exists on this particluar disk. What I am looking for is the association
between disks and volumes. What I would really like is an IOCTL or something
that will accept that volume “GUID…” is on disk “GUID…”. Of course the
volume may span disks, but that is OK, I can deal with that.

The problem as I see is it is that IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
still
returns a simple number instead of a GUID.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@stratus.com To
unsubscribe send a blank email to xxxxx@lists.osr.com

> SetupDiGetClassDevs. Now you have all of them in GUID form. What I want to

do is translate from the GUID form to PhysicalDiskX form. My reason for

Open the disk using the device interface string from SetupDixxx API and send
IOCTL_STORAGE_GET_DEVICE_NUMBER.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com