Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. IOCTL_STORAGE_GET_DEVICE_NUMBER fail to get disk number

IOCTL_STORAGE_GET_DEVICE_NUMBER fail to get disk number

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MKC002
    wrote on last edited by
    #1

    To get disk number for any drive i open drive (like \\.\c:) and pass its handle with IOCTL_STORAGE_GET_DEVICE_NUMBER in DeviceIoControl and get data in STORAGE_DEVICE_NUMBER structure. This structure returns the device number and partition number. This works perfectly on basic disk but when i use the same on dynamic disk then it's fail. Please suggest how to get disk number and partition number for dynamic disk.

    V A 2 Replies Last reply
    0
    • M MKC002

      To get disk number for any drive i open drive (like \\.\c:) and pass its handle with IOCTL_STORAGE_GET_DEVICE_NUMBER in DeviceIoControl and get data in STORAGE_DEVICE_NUMBER structure. This structure returns the device number and partition number. This works perfectly on basic disk but when i use the same on dynamic disk then it's fail. Please suggest how to get disk number and partition number for dynamic disk.

      V Offline
      V Offline
      vasu_sri
      wrote on last edited by
      #2

      u can try with this IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS structure. it gives pratition number. like this, VOLUME_DISK_EXTENTS pdg; .... DeviceIoControl(...,IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS,...); .... pdg.Extents->DiskNumber; thats it.

      Regards, Srinivas

      M 1 Reply Last reply
      0
      • V vasu_sri

        u can try with this IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS structure. it gives pratition number. like this, VOLUME_DISK_EXTENTS pdg; .... DeviceIoControl(...,IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS,...); .... pdg.Extents->DiskNumber; thats it.

        Regards, Srinivas

        M Offline
        M Offline
        MKC002
        wrote on last edited by
        #3

        Thanks After using that i get correct disk number. But i found starting offset and extent length different.It shows very large value for starting offset.And extent length shows a value(0x7e00) which is the position in disk from where this partition start. Does extentlength means total size of drive or position of drive in disk? typedef struct _DISK_EXTENT { DWORD DiskNumber; LARGE_INTEGER StartingOffset; LARGE_INTEGER ExtentLength; } DISK_EXTENT, *PDISK_EXTENT; typedef struct _VOLUME_DISK_EXTENTS { DWORD NumberOfDiskExtents; DISK_EXTENT Extents[1]; } VOLUME_DISK_EXTENTS, *PVOLUME_DISK_EXTENTS;

        V 1 Reply Last reply
        0
        • M MKC002

          Thanks After using that i get correct disk number. But i found starting offset and extent length different.It shows very large value for starting offset.And extent length shows a value(0x7e00) which is the position in disk from where this partition start. Does extentlength means total size of drive or position of drive in disk? typedef struct _DISK_EXTENT { DWORD DiskNumber; LARGE_INTEGER StartingOffset; LARGE_INTEGER ExtentLength; } DISK_EXTENT, *PDISK_EXTENT; typedef struct _VOLUME_DISK_EXTENTS { DWORD NumberOfDiskExtents; DISK_EXTENT Extents[1]; } VOLUME_DISK_EXTENTS, *PVOLUME_DISK_EXTENTS;

          V Offline
          V Offline
          vasu_sri
          wrote on last edited by
          #4

          u can get size of disk like this, ULONGLONG ulLength = pdg.Extents->ExtentLength.QuadPart;

          Regards, Srinivas

          1 Reply Last reply
          0
          • M MKC002

            To get disk number for any drive i open drive (like \\.\c:) and pass its handle with IOCTL_STORAGE_GET_DEVICE_NUMBER in DeviceIoControl and get data in STORAGE_DEVICE_NUMBER structure. This structure returns the device number and partition number. This works perfectly on basic disk but when i use the same on dynamic disk then it's fail. Please suggest how to get disk number and partition number for dynamic disk.

            A Offline
            A Offline
            Adam Roderick J
            wrote on last edited by
            #5

            I have two doubts regarding ur question 1. If DeviceIoControl API is failing, can you check error with GetLastError API([^]). 2. What type of dynamic device you are using and hope it comes in one of the define type([^])

            Величие не Бога может быть недооценена.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups