From 74b82118d5f77116ec5f4a1e2438cdc77cead40f Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Mon, 15 May 2017 16:22:48 +0200 Subject: Windows: use IOCTL_DISK_GET_DRIVE_GEOMETRY_EX instead of the deprecated IOCTL_DISK_GET_DRIVE_GEOMETRY in order to get accurate disk size value. --- src/Format/Tcformat.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/Format/Tcformat.c') diff --git a/src/Format/Tcformat.c b/src/Format/Tcformat.c index 02210b15..288eeacf 100644 --- a/src/Format/Tcformat.c +++ b/src/Format/Tcformat.c @@ -3416,7 +3416,7 @@ BOOL QueryFreeSpace (HWND hwndDlg, HWND hwndTextBox, BOOL display) } else { - DISK_GEOMETRY driveInfo; + DISK_GEOMETRY_EX driveInfo; PARTITION_INFORMATION diskInfo; BOOL piValid = FALSE; BOOL gValid = FALSE; @@ -3465,8 +3465,7 @@ BOOL QueryFreeSpace (HWND hwndDlg, HWND hwndTextBox, BOOL display) LARGE_INTEGER lDiskFree; // Drive geometry info is used only when GetPartitionInfo() fails - lDiskFree.QuadPart = driveInfo.Cylinders.QuadPart * driveInfo.BytesPerSector * - driveInfo.SectorsPerTrack * driveInfo.TracksPerCylinder; + lDiskFree.QuadPart = driveInfo.DiskSize.QuadPart; nVolumeSize = lDiskFree.QuadPart; @@ -10320,7 +10319,7 @@ static DWORD GetFormatSectorSize () if (!bDevice) return TC_SECTOR_SIZE_FILE_HOSTED_VOLUME; - DISK_GEOMETRY geometry; + DISK_GEOMETRY_EX geometry; if (!GetDriveGeometry (szDiskFile, &geometry)) { @@ -10328,5 +10327,5 @@ static DWORD GetFormatSectorSize () AbortProcessSilent(); } - return geometry.BytesPerSector; + return geometry.Geometry.BytesPerSector; } -- cgit v1.2.3