Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting... Please check out the Community Guidelines in the
Announcements and Administration Category, below.

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.

Comments

  • Doron_HolanDoron_Holan Posts: 10,353
    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:

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

    To unsubscribe, visit the List Server section of OSR Online at
  • 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
  • Mark_RoddyMark_Roddy Posts: 4,262
    The SCSI name is for the disk device pdo. See the routines
    DiskGenerateDeviceName
    and
    DiskCreateFdo

    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 :-)


    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: showlists.cfm?list=ntdev>
    >
    > MONTHLY seminars on crash dump analysis, WDF, Windows internals and
    > software drivers!
    > Details at
    >
    > To unsubscribe, visit the List Server section of OSR Online at <
    > http://www.osronline.com/page.cfm?name=ListServer>;
    >
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!