From 0bfed6553d08131fd8e0bd725642ff8509a2a1d4 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sat, 1 Jul 2023 15:16:46 +0200 Subject: Windows: Fix formatting issue during volume creation by using /Y for format.com and specifying removal parameter in FormatEx The usage of /Y parameter in format.com simplifies the logic and makes the code robust since we don't need to send \n to the format.com process. Specifying RemovableMedia parameter to FormatEx fixes its failure in Windows 10 and later to perform quick format. This is also more adequate since we are mounting the volume as removable media for the formatting process. We also add better error management in order to display adequate error message to the user in case of failure --- src/Common/Format.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/Common/Format.h') diff --git a/src/Common/Format.h b/src/Common/Format.h index 826b8f6c..204feee1 100644 --- a/src/Common/Format.h +++ b/src/Common/Format.h @@ -69,14 +69,16 @@ FORMAT_VOL_PARAMETERS; #define FMIFS_CHECKDISK_PROGRESS 0x19 #define FMIFS_READ_ONLY_MODE 0x20 +#define FMIFS_REMOVAL 0xB #define FMIFS_HARDDISK 0xC extern int FormatWriteBufferSize; int TCFormatVolume (volatile FORMAT_VOL_PARAMETERS *volParams); -BOOL FormatNtfs (int driveNo, int clusterSize); -BOOL FormatFs (int driveNo, int clusterSize, int fsType); -BOOL ExternalFormatFs (int driveNo, int clusterSize, int fsType); +int FormatNtfs (int driveNo, int clusterSize); +int FormatFs (int driveNo, int clusterSize, int fsType); +int ExternalFormatFs (int driveNo, int clusterSize, int fsType); +LPCWSTR FormatExGetMessage (int command); uint64 GetVolumeDataAreaSize (BOOL hiddenVolume, uint64 volumeSize); int FormatNoFs (HWND hwndDlg, unsigned __int64 startSector, unsigned __int64 num_sectors, void *dev, PCRYPTO_INFO cryptoInfo, BOOL quickFormat, BOOL bDevice); BOOL WriteSector ( void *dev , char *sector , char *write_buf , int *write_buf_cnt , unsigned __int64 *nSecNo , unsigned __int64 startSector, PCRYPTO_INFO cryptoInfo ); -- cgit v1.2.3