IOCTL_STORAGE_GET_DEVICE_NUMBER fail to get disk number
-
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.
-
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.
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
-
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
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;
-
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;
-
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.