diff options
-rw-r--r-- | src/Common/Apidrvr.h | 11 | ||||
-rw-r--r-- | src/Common/BootEncryption.cpp | 20 | ||||
-rw-r--r-- | src/Common/BootEncryption.h | 2 | ||||
-rw-r--r-- | src/Common/Dlgcode.c | 62 | ||||
-rw-r--r-- | src/Common/Dlgcode.h | 2 | ||||
-rw-r--r-- | src/Common/Password.c | 7 | ||||
-rw-r--r-- | src/Common/Volumes.c | 24 | ||||
-rw-r--r-- | src/Driver/Ntdriver.c | 35 | ||||
-rw-r--r-- | src/Driver/Ntvol.c | 10 | ||||
-rw-r--r-- | src/ExpandVolume/ExpandVolume.c | 9 | ||||
-rw-r--r-- | src/Format/InPlace.c | 18 | ||||
-rw-r--r-- | src/Format/Tcformat.c | 9 | ||||
-rw-r--r-- | src/Mount/Mount.c | 7 |
13 files changed, 133 insertions, 83 deletions
diff --git a/src/Common/Apidrvr.h b/src/Common/Apidrvr.h index 07a8448c..28202e61 100644 --- a/src/Common/Apidrvr.h +++ b/src/Common/Apidrvr.h @@ -119,6 +119,9 @@ #define TC_IOCTL_REREAD_DRIVER_CONFIG TC_IOCTL (37) #define TC_IOCTL_GET_SYSTEM_DRIVE_DUMP_CONFIG TC_IOCTL (38) #define VC_IOCTL_GET_BOOT_LOADER_FINGERPRINT TC_IOCTL (39) +// result IOCTL_DISK_GET_DRIVE_GEOMETRY_EX +// IN OUT - DISK_GEOMETRY_EX_STRUCT +#define VC_IOCTL_GET_DRIVE_GEOMETRY_EX TC_IOCTL (40) // Legacy IOCTLs used before version 5.0 #define TC_IOCTL_LEGACY_GET_DRIVER_VERSION 466968 @@ -240,6 +243,14 @@ DISK_GEOMETRY_STRUCT; typedef struct { + WCHAR deviceName[TC_MAX_PATH]; + DISK_GEOMETRY diskGeometry; + LARGE_INTEGER DiskSize; +} +DISK_GEOMETRY_EX_STRUCT; + +typedef struct +{ WCHAR DeviceName[TC_MAX_PATH]; LARGE_INTEGER RealDriveSize; BOOL TimeOut; diff --git a/src/Common/BootEncryption.cpp b/src/Common/BootEncryption.cpp index cd7ea79a..0b684e49 100644 --- a/src/Common/BootEncryption.cpp +++ b/src/Common/BootEncryption.cpp @@ -1053,16 +1053,18 @@ namespace VeraCrypt } - DISK_GEOMETRY BootEncryption::GetDriveGeometry (int driveNumber) +#ifndef SETUP + + DISK_GEOMETRY_EX BootEncryption::GetDriveGeometry (int driveNumber) { wstringstream devName; devName << L"\\Device\\Harddisk" << driveNumber << L"\\Partition0"; - DISK_GEOMETRY geometry; + DISK_GEOMETRY_EX geometry; throw_sys_if (!::GetDriveGeometry (devName.str().c_str(), &geometry)); return geometry; } - +#endif // !SETUP wstring BootEncryption::GetWindowsDirectory () { @@ -3999,9 +4001,9 @@ namespace VeraCrypt if (config.InitialUnallocatedSpace < TC_BOOT_LOADER_AREA_SIZE) throw ErrorException ("NO_SPACE_FOR_BOOT_LOADER", SRC_POS); - DISK_GEOMETRY geometry = GetDriveGeometry (config.DriveNumber); + DISK_GEOMETRY_EX geometry = GetDriveGeometry (config.DriveNumber); - if (geometry.BytesPerSector != TC_SECTOR_SIZE_BIOS) + if (geometry.Geometry.BytesPerSector != TC_SECTOR_SIZE_BIOS) throw ErrorException ("SYSENC_UNSUPPORTED_SECTOR_SIZE_BIOS", SRC_POS); bool activePartitionFound = false; @@ -4425,17 +4427,17 @@ namespace VeraCrypt // Some chipset drivers may prevent access to the last sector of the drive if (!systemPartitionOnly) { - DISK_GEOMETRY geometry = GetDriveGeometry (config.DriveNumber); - if ((geometry.BytesPerSector > 0) && (geometry.BytesPerSector < TC_MAX_VOLUME_SECTOR_SIZE)) + DISK_GEOMETRY_EX geometry = GetDriveGeometry (config.DriveNumber); + if ((geometry.Geometry.BytesPerSector > 0) && (geometry.Geometry.BytesPerSector < TC_MAX_VOLUME_SECTOR_SIZE)) { - Buffer sector (geometry.BytesPerSector); + Buffer sector (geometry.Geometry.BytesPerSector); Device device (config.DevicePath); device.CheckOpened (SRC_POS); try { - device.SeekAt (config.DrivePartition.Info.PartitionLength.QuadPart - geometry.BytesPerSector); + device.SeekAt (config.DrivePartition.Info.PartitionLength.QuadPart - geometry.Geometry.BytesPerSector); device.Read (sector.Ptr(), (DWORD) sector.Size()); } catch (SystemException &e) diff --git a/src/Common/BootEncryption.h b/src/Common/BootEncryption.h index f7f2ec1a..4071a7f5 100644 --- a/src/Common/BootEncryption.h +++ b/src/Common/BootEncryption.h @@ -310,7 +310,7 @@ namespace VeraCrypt void CreateVolumeHeader (uint64 volumeSize, uint64 encryptedAreaStart, Password *password, int ea, int mode, int pkcs5, int pim); wstring GetSystemLoaderBackupPath (); uint32 GetChecksum (byte *data, size_t size); - DISK_GEOMETRY GetDriveGeometry (int driveNumber); + DISK_GEOMETRY_EX GetDriveGeometry (int driveNumber); PartitionList GetDrivePartitions (int driveNumber); wstring GetRemarksOnHiddenOS (); wstring GetWindowsDirectory (); diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c index 73eabfaf..d09e0044 100644 --- a/src/Common/Dlgcode.c +++ b/src/Common/Dlgcode.c @@ -3102,6 +3102,7 @@ BOOL GetDriveLabel (int driveNo, wchar_t *label, int labelSize) return GetVolumeInformationW (root, label, labelSize / 2, NULL, NULL, &fileSystemFlags, NULL, 0); } +#ifndef SETUP /* Stores the device path of the system partition in SysPartitionDevicePath and the device path of the system drive in SysDriveDevicePath. @@ -3254,6 +3255,7 @@ int IsNonSysPartitionOnSysDrive (const wchar_t *path) } } +#endif //!SETUP wstring GetSysEncryptionPretestInfo2String (void) { @@ -3477,6 +3479,7 @@ char * GetLegalNotices () return buf; } +#ifndef SETUP BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -3835,6 +3838,7 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l return 0; } +#endif //!SETUP BOOL DoDriverInstall (HWND hwndDlg) { @@ -7266,6 +7270,8 @@ BOOL GetPhysicalDriveAlignment(UINT nDriveNumber, STORAGE_ACCESS_ALIGNMENT_DESCR return TRUE; } +#ifndef SETUP + /************************************************************/ // implementation of the generic wait dialog mechanism @@ -7980,6 +7986,7 @@ BOOL UnmountVolumeAfterFormatExCall (HWND hwndDlg, int nDosDriveNo) return UnmountVolumeBase (hwndDlg, nDosDriveNo, FALSE, TRUE); } +#endif //!SETUP BOOL IsPasswordCacheEmpty (void) { @@ -8176,29 +8183,31 @@ BOOL GetDeviceInfo (const wchar_t *deviceName, DISK_PARTITION_INFO_STRUCT *info) return DeviceIoControl (hDriver, TC_IOCTL_GET_DRIVE_PARTITION_INFO, info, sizeof (*info), info, sizeof (*info), &dwResult, NULL); } - -BOOL GetDriveGeometry (const wchar_t *deviceName, PDISK_GEOMETRY diskGeometry) +#ifndef SETUP +BOOL GetDriveGeometry (const wchar_t *deviceName, PDISK_GEOMETRY_EX diskGeometry) { BOOL bResult; DWORD dwResult; - DISK_GEOMETRY_STRUCT dg; + DISK_GEOMETRY_EX_STRUCT dg; memset (&dg, 0, sizeof(dg)); StringCbCopyW ((PWSTR) &dg.deviceName, sizeof(dg.deviceName), deviceName); - bResult = DeviceIoControl (hDriver, TC_IOCTL_GET_DRIVE_GEOMETRY, &dg, + bResult = DeviceIoControl (hDriver, VC_IOCTL_GET_DRIVE_GEOMETRY_EX, &dg, sizeof (dg), &dg, sizeof (dg), &dwResult, NULL); if (bResult && (dwResult == sizeof (dg)) && dg.diskGeometry.BytesPerSector) { - memcpy (diskGeometry, &dg.diskGeometry, sizeof (DISK_GEOMETRY)); + ZeroMemory (diskGeometry, sizeof (PDISK_GEOMETRY_EX)); + memcpy (&diskGeometry->Geometry, &dg.diskGeometry, sizeof (DISK_GEOMETRY)); + diskGeometry->DiskSize.QuadPart = dg.DiskSize.QuadPart; return TRUE; } else return FALSE; } -BOOL GetPhysicalDriveGeometry (int driveNumber, PDISK_GEOMETRY diskGeometry) +BOOL GetPhysicalDriveGeometry (int driveNumber, PDISK_GEOMETRY_EX diskGeometry) { HANDLE hDev; BOOL bResult = FALSE; @@ -8210,11 +8219,11 @@ BOOL GetPhysicalDriveGeometry (int driveNumber, PDISK_GEOMETRY diskGeometry) { DWORD bytesRead = 0; - ZeroMemory (diskGeometry, sizeof (DISK_GEOMETRY)); + ZeroMemory (diskGeometry, sizeof (DISK_GEOMETRY_EX)); - if ( DeviceIoControl (hDev, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, diskGeometry, sizeof (DISK_GEOMETRY), &bytesRead, NULL) - && (bytesRead == sizeof (DISK_GEOMETRY)) - && diskGeometry->BytesPerSector) + if ( DeviceIoControl (hDev, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, diskGeometry, sizeof (DISK_GEOMETRY_EX), &bytesRead, NULL) + && (bytesRead == sizeof (DISK_GEOMETRY_EX)) + && diskGeometry->Geometry.BytesPerSector) { bResult = TRUE; } @@ -8224,7 +8233,7 @@ BOOL GetPhysicalDriveGeometry (int driveNumber, PDISK_GEOMETRY diskGeometry) return bResult; } - +#endif // Returns drive letter number assigned to device (-1 if none) int GetDiskDeviceDriveLetter (PWSTR deviceName) @@ -10534,7 +10543,7 @@ int OpenVolume (OpenVolumeContext *context, const wchar_t *volumePath, Password char buffer[TC_VOLUME_HEADER_EFFECTIVE_SIZE]; LARGE_INTEGER headerOffset; DWORD dwResult; - DISK_GEOMETRY deviceGeometry; + DISK_GEOMETRY_EX deviceGeometry; context->VolumeIsOpen = FALSE; context->CryptoInfo = NULL; @@ -10602,15 +10611,15 @@ int OpenVolume (OpenVolumeContext *context, const wchar_t *volumePath, Password } else { - DISK_GEOMETRY driveInfo; + DISK_GEOMETRY_EX driveInfo; - if (!DeviceIoControl (context->HostFileHandle, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &driveInfo, sizeof (driveInfo), &dwResult, NULL)) + if (!DeviceIoControl (context->HostFileHandle, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &driveInfo, sizeof (driveInfo), &dwResult, NULL)) { status = ERR_OS_ERROR; goto error; } - context->HostSize = driveInfo.Cylinders.QuadPart * driveInfo.BytesPerSector * driveInfo.SectorsPerTrack * driveInfo.TracksPerCylinder; + context->HostSize = driveInfo.DiskSize.QuadPart; } if (context->HostSize == 0) @@ -10798,10 +10807,10 @@ BOOL IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly) if (handle == INVALID_HANDLE_VALUE) continue; - DISK_GEOMETRY driveInfo; + DISK_GEOMETRY_EX driveInfo; DWORD dwResult; - if (!DeviceIoControl (handle, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &driveInfo, sizeof (driveInfo), &dwResult, NULL)) + if (!DeviceIoControl (handle, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &driveInfo, sizeof (driveInfo), &dwResult, NULL)) { CloseHandle (handle); continue; @@ -11398,8 +11407,6 @@ BOOL InitSecurityTokenLibrary (HWND hwndDlg) return TRUE; } -#endif // !SETUP - std::vector <HostDevice> GetAvailableHostDevices (bool noDeviceProperties, bool singleList, bool noFloppy, bool detectUnencryptedFilesystems) { vector <HostDevice> devices; @@ -11436,14 +11443,13 @@ std::vector <HostDevice> GetAvailableHostDevices (bool noDeviceProperties, bool } else { - // retrieve size using DISK_GEOMETRY - DISK_GEOMETRY deviceGeometry = {0}; + // retrieve size using DISK_GEOMETRY_EX + DISK_GEOMETRY_EX deviceGeometry = {0}; if ( GetDriveGeometry (devPath, &deviceGeometry) || ((partNumber == 0) && GetPhysicalDriveGeometry (devNumber, &deviceGeometry)) ) { - device.Size = deviceGeometry.Cylinders.QuadPart * (LONGLONG) deviceGeometry.BytesPerSector - * (LONGLONG) deviceGeometry.SectorsPerTrack * (LONGLONG) deviceGeometry.TracksPerCylinder; + device.Size = (uint64) deviceGeometry.DiskSize.QuadPart; } } @@ -11451,7 +11457,7 @@ std::vector <HostDevice> GetAvailableHostDevices (bool noDeviceProperties, bool if (!noDeviceProperties) { - DISK_GEOMETRY geometry; + DISK_GEOMETRY_EX geometry; int driveNumber = GetDiskDeviceDriveLetter ((wchar_t *) devPathStr.c_str()); @@ -11469,7 +11475,7 @@ std::vector <HostDevice> GetAvailableHostDevices (bool noDeviceProperties, bool } if (partNumber == 0 && GetDriveGeometry (devPath, &geometry)) - device.Removable = (geometry.MediaType == RemovableMedia); + device.Removable = (geometry.Geometry.MediaType == RemovableMedia); } if (partNumber == 0) @@ -11601,6 +11607,8 @@ wstring FindDeviceByVolumeID (const BYTE volumeID [VOLUME_ID_SIZE]) return L""; } +#endif // !SETUP + BOOL FileHasReadOnlyAttribute (const wchar_t *path) { DWORD attributes = GetFileAttributes (path); @@ -12207,6 +12215,8 @@ BOOL IsRepeatedByteArray (byte value, const byte* buffer, size_t bufferSize) return FALSE; } +#ifndef SETUP + BOOL TranslateVolumeID (HWND hwndDlg, wchar_t* pathValue, size_t cchPathValue) { BOOL bRet = TRUE; @@ -12243,6 +12253,8 @@ BOOL TranslateVolumeID (HWND hwndDlg, wchar_t* pathValue, size_t cchPathValue) return bRet; } +#endif + BOOL CopyTextToClipboard (LPCWSTR txtValue) { size_t txtLen = wcslen(txtValue); diff --git a/src/Common/Dlgcode.h b/src/Common/Dlgcode.h index d902d3cc..be04bd39 100644 --- a/src/Common/Dlgcode.h +++ b/src/Common/Dlgcode.h @@ -463,7 +463,7 @@ BOOL SelectMultipleFilesNext (wchar_t *lpszFileName, size_t cbFileName); void OpenOnlineHelp (); BOOL GetPartitionInfo (const wchar_t *deviceName, PPARTITION_INFORMATION rpartInfo); BOOL GetDeviceInfo (const wchar_t *deviceName, DISK_PARTITION_INFO_STRUCT *info); -BOOL GetDriveGeometry (const wchar_t *deviceName, PDISK_GEOMETRY diskGeometry); +BOOL GetDriveGeometry (const wchar_t *deviceName, PDISK_GEOMETRY_EX diskGeometry); BOOL GetPhysicalDriveGeometry (int driveNumber, PDISK_GEOMETRY diskGeometry); BOOL IsVolumeDeviceHosted (const wchar_t *lpszDiskFile); int CompensateXDPI (int val); diff --git a/src/Common/Password.c b/src/Common/Password.c index 1c9083a3..b51870f9 100644 --- a/src/Common/Password.c +++ b/src/Common/Password.c @@ -186,7 +186,7 @@ int ChangePwd (const wchar_t *lpszVolume, Password *oldPassword, int old_pkcs5, BOOL bTimeStampValid = FALSE; LARGE_INTEGER headerOffset; BOOL backupHeader; - DISK_GEOMETRY driveInfo; + DISK_GEOMETRY_EX driveInfo; if (oldPassword->Length == 0 || newPassword->Length == 0) return -1; @@ -239,7 +239,7 @@ int ChangePwd (const wchar_t *lpszVolume, Password *oldPassword, int old_pkcs5, DWORD dwResult; BOOL bResult; - bResult = DeviceIoControl (dev, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, + bResult = DeviceIoControl (dev, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &driveInfo, sizeof (driveInfo), &dwResult, NULL); if (!bResult) @@ -253,8 +253,7 @@ int ChangePwd (const wchar_t *lpszVolume, Password *oldPassword, int old_pkcs5, } else { - hostSize = driveInfo.Cylinders.QuadPart * driveInfo.BytesPerSector * - driveInfo.SectorsPerTrack * driveInfo.TracksPerCylinder; + hostSize = driveInfo.DiskSize.QuadPart; } if (hostSize == 0) diff --git a/src/Common/Volumes.c b/src/Common/Volumes.c index d2321769..762adc2b 100644 --- a/src/Common/Volumes.c +++ b/src/Common/Volumes.c @@ -1155,21 +1155,21 @@ BOOL ReadEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header, DW #endif byte sectorBuffer[TC_MAX_VOLUME_SECTOR_SIZE]; - DISK_GEOMETRY geometry; + DISK_GEOMETRY_EX geometry; if (!device) return ReadFile (fileHandle, header, TC_VOLUME_HEADER_EFFECTIVE_SIZE, bytesRead, NULL); - if (!DeviceIoControl (fileHandle, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &geometry, sizeof (geometry), bytesRead, NULL)) + if (!DeviceIoControl (fileHandle, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &geometry, sizeof (geometry), bytesRead, NULL)) return FALSE; - if (geometry.BytesPerSector > sizeof (sectorBuffer) || geometry.BytesPerSector < TC_MIN_VOLUME_SECTOR_SIZE) + if (geometry.Geometry.BytesPerSector > sizeof (sectorBuffer) || geometry.Geometry.BytesPerSector < TC_MIN_VOLUME_SECTOR_SIZE) { SetLastError (ERROR_INVALID_PARAMETER); return FALSE; } - if (!ReadFile (fileHandle, sectorBuffer, max (TC_VOLUME_HEADER_EFFECTIVE_SIZE, geometry.BytesPerSector), bytesRead, NULL)) + if (!ReadFile (fileHandle, sectorBuffer, max (TC_VOLUME_HEADER_EFFECTIVE_SIZE, geometry.Geometry.BytesPerSector), bytesRead, NULL)) return FALSE; memcpy (header, sectorBuffer, min (*bytesRead, TC_VOLUME_HEADER_EFFECTIVE_SIZE)); @@ -1189,7 +1189,7 @@ BOOL WriteEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header) byte sectorBuffer[TC_MAX_VOLUME_SECTOR_SIZE]; DWORD bytesDone; - DISK_GEOMETRY geometry; + DISK_GEOMETRY_EX geometry; if (!device) { @@ -1205,23 +1205,23 @@ BOOL WriteEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header) return TRUE; } - if (!DeviceIoControl (fileHandle, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &geometry, sizeof (geometry), &bytesDone, NULL)) + if (!DeviceIoControl (fileHandle, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &geometry, sizeof (geometry), &bytesDone, NULL)) return FALSE; - if (geometry.BytesPerSector > sizeof (sectorBuffer) || geometry.BytesPerSector < TC_MIN_VOLUME_SECTOR_SIZE) + if (geometry.Geometry.BytesPerSector > sizeof (sectorBuffer) || geometry.Geometry.BytesPerSector < TC_MIN_VOLUME_SECTOR_SIZE) { SetLastError (ERROR_INVALID_PARAMETER); return FALSE; } - if (geometry.BytesPerSector != TC_VOLUME_HEADER_EFFECTIVE_SIZE) + if (geometry.Geometry.BytesPerSector != TC_VOLUME_HEADER_EFFECTIVE_SIZE) { LARGE_INTEGER seekOffset; - if (!ReadFile (fileHandle, sectorBuffer, geometry.BytesPerSector, &bytesDone, NULL)) + if (!ReadFile (fileHandle, sectorBuffer, geometry.Geometry.BytesPerSector, &bytesDone, NULL)) return FALSE; - if (bytesDone != geometry.BytesPerSector) + if (bytesDone != geometry.Geometry.BytesPerSector) { SetLastError (ERROR_INVALID_PARAMETER); return FALSE; @@ -1234,10 +1234,10 @@ BOOL WriteEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header) memcpy (sectorBuffer, header, TC_VOLUME_HEADER_EFFECTIVE_SIZE); - if (!WriteFile (fileHandle, sectorBuffer, geometry.BytesPerSector, &bytesDone, NULL)) + if (!WriteFile (fileHandle, sectorBuffer, geometry.Geometry.BytesPerSector, &bytesDone, NULL)) return FALSE; - if (bytesDone != geometry.BytesPerSector) + if (bytesDone != geometry.Geometry.BytesPerSector) { SetLastError (ERROR_INVALID_PARAMETER); return FALSE; diff --git a/src/Driver/Ntdriver.c b/src/Driver/Ntdriver.c index eaa8fa8c..ea9d725b 100644 --- a/src/Driver/Ntdriver.c +++ b/src/Driver/Ntdriver.c @@ -1483,6 +1483,34 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex } break; + case VC_IOCTL_GET_DRIVE_GEOMETRY_EX: + if (ValidateIOBufferSize (Irp, sizeof (DISK_GEOMETRY_EX_STRUCT), ValidateInputOutput)) + { + DISK_GEOMETRY_EX_STRUCT *g = (DISK_GEOMETRY_EX_STRUCT *) Irp->AssociatedIrp.SystemBuffer; + { + NTSTATUS ntStatus; + DISK_GEOMETRY_EX geo = {0}; + + memset (g, 0, sizeof (DISK_GEOMETRY_EX_STRUCT)); + + EnsureNullTerminatedString (g->deviceName, sizeof (g->deviceName)); + + ntStatus = TCDeviceIoControl (g->deviceName, + IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, + NULL, 0, &geo, sizeof (geo)); + + if (NT_SUCCESS(ntStatus)) + { + memcpy (&g->diskGeometry, &geo.Geometry, sizeof (DISK_GEOMETRY)); + g->DiskSize.QuadPart = geo.DiskSize.QuadPart; + } + + Irp->IoStatus.Information = sizeof (DISK_GEOMETRY_EX_STRUCT); + Irp->IoStatus.Status = ntStatus; + } + } + break; + case TC_IOCTL_PROBE_REAL_DRIVE_SIZE: if (ValidateIOBufferSize (Irp, sizeof (ProbeRealDriveSizeRequest), ValidateInputOutput)) { @@ -2125,6 +2153,7 @@ LPWSTR TCTranslateCode (ULONG ulCode) TC_CASE_RET_NAME (TC_IOCTL_START_DECOY_SYSTEM_WIPE); TC_CASE_RET_NAME (TC_IOCTL_WIPE_PASSWORD_CACHE); TC_CASE_RET_NAME (TC_IOCTL_WRITE_BOOT_DRIVE_SECTOR); + TC_CASE_RET_NAME (VC_IOCTL_GET_DRIVE_GEOMETRY_EX); TC_CASE_RET_NAME (IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS); @@ -3421,14 +3450,14 @@ NTSTATUS WriteRegistryConfigFlags (uint32 flags) NTSTATUS GetDeviceSectorSize (PDEVICE_OBJECT deviceObject, ULONG *bytesPerSector) { NTSTATUS status; - DISK_GEOMETRY geometry; + DISK_GEOMETRY_EX geometry; - status = SendDeviceIoControlRequest (deviceObject, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &geometry, sizeof (geometry)); + status = SendDeviceIoControlRequest (deviceObject, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &geometry, sizeof (geometry)); if (!NT_SUCCESS (status)) return status; - *bytesPerSector = geometry.BytesPerSector; + *bytesPerSector = geometry.Geometry.BytesPerSector; return STATUS_SUCCESS; } diff --git a/src/Driver/Ntvol.c b/src/Driver/Ntvol.c index cfcc45e6..b3e08747 100644 --- a/src/Driver/Ntvol.c +++ b/src/Driver/Ntvol.c @@ -82,7 +82,7 @@ NTSTATUS TCOpenVolume (PDEVICE_OBJECT DeviceObject, PARTITION_INFORMATION pi; PARTITION_INFORMATION_EX pix; LARGE_INTEGER diskLengthInfo; - DISK_GEOMETRY dg; + DISK_GEOMETRY_EX dg; STORAGE_PROPERTY_QUERY storagePropertyQuery = {0}; STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR storageDescriptor = {0}; @@ -94,12 +94,12 @@ NTSTATUS TCOpenVolume (PDEVICE_OBJECT DeviceObject, if (!NT_SUCCESS (ntStatus)) goto error; - ntStatus = TCSendHostDeviceIoControlRequest (DeviceObject, Extension, IOCTL_DISK_GET_DRIVE_GEOMETRY, (char *) &dg, sizeof (dg)); + ntStatus = TCSendHostDeviceIoControlRequest (DeviceObject, Extension, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, (char *) &dg, sizeof (dg)); if (!NT_SUCCESS (ntStatus)) goto error; - lDiskLength.QuadPart = dg.Cylinders.QuadPart * dg.SectorsPerTrack * dg.TracksPerCylinder * dg.BytesPerSector; - Extension->HostBytesPerSector = dg.BytesPerSector; + lDiskLength.QuadPart = dg.DiskSize.QuadPart; + Extension->HostBytesPerSector = dg.Geometry.BytesPerSector; storagePropertyQuery.PropertyId = StorageAccessAlignmentProperty; storagePropertyQuery.QueryType = PropertyStandardQuery; @@ -113,7 +113,7 @@ NTSTATUS TCOpenVolume (PDEVICE_OBJECT DeviceObject, } else { - Extension->HostBytesPerPhysicalSector = dg.BytesPerSector; + Extension->HostBytesPerPhysicalSector = dg.Geometry.BytesPerSector; } // Drive geometry is used only when IOCTL_DISK_GET_PARTITION_INFO fails diff --git a/src/ExpandVolume/ExpandVolume.c b/src/ExpandVolume/ExpandVolume.c index 82c4207e..6167b9c8 100644 --- a/src/ExpandVolume/ExpandVolume.c +++ b/src/ExpandVolume/ExpandVolume.c @@ -559,18 +559,17 @@ static int ExpandVolume (HWND hwndDlg, wchar_t *lpszVolume, Password *pVolumePas } else { - DISK_GEOMETRY driveInfo; + DISK_GEOMETRY_EX driveInfo; - bResult = DeviceIoControl (dev, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, + bResult = DeviceIoControl (dev, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &driveInfo, sizeof (driveInfo), &dwResult, NULL); if (!bResult) goto error; - hostSize = driveInfo.Cylinders.QuadPart * driveInfo.BytesPerSector * - driveInfo.SectorsPerTrack * driveInfo.TracksPerCylinder; + hostSize = driveInfo.DiskSize.QuadPart; - HostSectorSize = driveInfo.BytesPerSector; + HostSectorSize = driveInfo.Geometry.BytesPerSector; } if (hostSize == 0) diff --git a/src/Format/InPlace.c b/src/Format/InPlace.c index f37cb8be..446ae065 100644 --- a/src/Format/InPlace.c +++ b/src/Format/InPlace.c @@ -772,7 +772,7 @@ int EncryptPartitionInPlaceResume (HANDLE dev, Password *password = volParams->password; int pkcs5_prf = volParams->pkcs5; int pim = volParams->pim; - DISK_GEOMETRY driveGeometry; + DISK_GEOMETRY_EX driveGeometry; HWND hwndDlg = volParams->hwndDlg; @@ -855,13 +855,13 @@ int EncryptPartitionInPlaceResume (HANDLE dev, NULL); - if (!DeviceIoControl (dev, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &driveGeometry, sizeof (driveGeometry), &dwResult, NULL)) + if (!DeviceIoControl (dev, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &driveGeometry, sizeof (driveGeometry), &dwResult, NULL)) { nStatus = ERR_OS_ERROR; goto closing_seq; } - sectorSize = driveGeometry.BytesPerSector; + sectorSize = driveGeometry.Geometry.BytesPerSector; nStatus = OpenBackupHeader (dev, devicePath, password, pkcs5_prf, pim, &masterCryptoInfo, headerCryptoInfo, deviceSize); @@ -1282,7 +1282,7 @@ int DecryptPartitionInPlace (volatile FORMAT_VOL_PARAMETERS *volParams, volatile HWND hwndDlg = volParams->hwndDlg; int pkcs5_prf = volParams->pkcs5; int pim = volParams->pim; - DISK_GEOMETRY driveGeometry; + DISK_GEOMETRY_EX driveGeometry; buf = (char *) TCalloc (TC_MAX_NONSYS_INPLACE_ENC_WORK_CHUNK_SIZE); @@ -1357,15 +1357,15 @@ int DecryptPartitionInPlace (volatile FORMAT_VOL_PARAMETERS *volParams, volatile NULL); - if (!DeviceIoControl (dev, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &driveGeometry, sizeof (driveGeometry), &dwResult, NULL)) + if (!DeviceIoControl (dev, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &driveGeometry, sizeof (driveGeometry), &dwResult, NULL)) { nStatus = ERR_OS_ERROR; goto closing_seq; } - if ( (driveGeometry.BytesPerSector == 0) - || (driveGeometry.BytesPerSector > TC_MAX_VOLUME_SECTOR_SIZE) - || (driveGeometry.BytesPerSector % ENCRYPTION_DATA_UNIT_SIZE != 0) + if ( (driveGeometry.Geometry.BytesPerSector == 0) + || (driveGeometry.Geometry.BytesPerSector > TC_MAX_VOLUME_SECTOR_SIZE) + || (driveGeometry.Geometry.BytesPerSector % ENCRYPTION_DATA_UNIT_SIZE != 0) ) { Error ("SECTOR_SIZE_UNSUPPORTED", hwndDlg); @@ -1373,7 +1373,7 @@ int DecryptPartitionInPlace (volatile FORMAT_VOL_PARAMETERS *volParams, volatile goto closing_seq; } - sectorSize = driveGeometry.BytesPerSector; + sectorSize = driveGeometry.Geometry.BytesPerSector; tmpSectorBuf = (byte *) TCalloc (sectorSize); 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; } diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c index e90a0571..c4052f7b 100644 --- a/src/Mount/Mount.c +++ b/src/Mount/Mount.c @@ -10243,16 +10243,15 @@ int RestoreVolumeHeader (HWND hwndDlg, const wchar_t *lpszVolume) } else { - DISK_GEOMETRY driveInfo; + DISK_GEOMETRY_EX driveInfo; - bResult = DeviceIoControl (dev, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, + bResult = DeviceIoControl (dev, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &driveInfo, sizeof (driveInfo), &dwResult, NULL); if (!bResult) goto error; - hostSize = driveInfo.Cylinders.QuadPart * driveInfo.BytesPerSector * - driveInfo.SectorsPerTrack * driveInfo.TracksPerCylinder; + hostSize = driveInfo.DiskSize.QuadPart; } if (hostSize == 0) |