Enumerating disks attached to the system

Hi Guys,

I’am currently writing a kernel mode driver and i need to enumerate the disks attached to the system (eg : I have 2 physical disks attached to my system \.\PhysicalDrive1 and \.\PhysicalDrive2). Is there some way in which i could get this information?

I have tried using the IOGetDeviceInterface API with DISK GUID, but it give me symbolic link such as \??\SCSI… which when checked in Winobj maps to \Device\00…21.

Device interface enumeration is the way to go. What underlying device objects do the \.\phsyicaldriveX symbolic links point to? Remember that there can be many symbolic link names to the same underlying device object name, so both a device interface (which is a symbolic link) and legacy symbolic link name can point to the same device.

Bent from my phone


From: xxxxx@lists.osr.com on behalf of xxxxx@gmail.com
Sent: Wednesday, December 27, 2017 7:52:17 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Enumerating disks attached to the system

Hi Guys,

I’am currently writing a kernel mode driver and i need to enumerate the disks attached to the system (eg : I have 2 physical disks attached to my system \.\PhysicalDrive1 and \.\PhysicalDrive2). Is there some way in which i could get this information?

I have tried using the IOGetDeviceInterface API with DISK GUID, but it give me symbolic link such as \??\SCSI… which when checked in Winobj maps to \Device\00…21.


NTDEV is sponsored by OSR

Visit the list online at: https:

MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
Details at https:

To unsubscribe, visit the List Server section of OSR Online at https:</https:></https:></https:>

Hi Doron,

“What underlying device objects do
the \.\phsyicaldriveX symbolic links point to?”

PhysicalDrive0 points to \Device\Harddisk0\DR0
PhysicalDrive1 points to \Device\Harddisk1\DR1

I’am using IOGetDeviceInterface as follows

ntStatus = IoGetDeviceInterfaces(&GUID_DEVINTERFACE_DISK,
NULL,
0,
&SymbolicLinkList
);

It returns me following Symbolic Links
SCSI#Disk&Ven_VBOX&Prod_HARDDISK#4&… points to \Device\00000021
SCSI#Disk&Ven_VBOX&Prod_HARDDISK#4&… points to \Device\00000022

The SCSI name is for the disk device pdo. See the routines
DiskGenerateDeviceName
https:and
DiskCreateFdo
https:
on
github for how this works. The FDO created by the disk class driver is
attached to the scsi pdo device. and has a name like \Device\Harddisk0\DR0.

Note that pre-pnp style (NT4 or earlier) enumeration of disk devices still
works :slight_smile:

Mark Roddy

On Wed, Dec 27, 2017 at 11:40 PM, xxxxx@gmail.com
wrote:

> Hi Doron,
>
> “What underlying device objects do
> the \.\phsyicaldriveX symbolic links point to?”
>
> PhysicalDrive0 points to \Device\Harddisk0\DR0
> PhysicalDrive1 points to \Device\Harddisk1\DR1
>
> I’am using IOGetDeviceInterface as follows
>
> ntStatus = IoGetDeviceInterfaces(&GUID_DEVINTERFACE_DISK,
> NULL,
> 0,
> &SymbolicLinkList
> );
>
> It returns me following Symbolic Links
> SCSI#Disk&Ven_VBOX&Prod_HARDDISK#4&… points to \Device\00000021
> SCSI#Disk&Ven_VBOX&Prod_HARDDISK#4&… points to \Device\00000022
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: http:> showlists.cfm?list=ntdev>
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at <
> http://www.osronline.com/page.cfm?name=ListServer&gt;
></http:></http:></https:></https:>