diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2015-08-25 11:42:01 +0200 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2015-09-16 01:33:11 +0200 |
commit | 4d7dc3ba25f562bea4be8898f11a97e911c48b99 (patch) | |
tree | 3a88d9a447e86a66017c145949e30406bdbf556c /src/Common/Format.c | |
parent | 85c1bc34e39a5e7682778c53ce68d6768346999c (diff) | |
download | VeraCrypt-4d7dc3ba25f562bea4be8898f11a97e911c48b99.tar.gz VeraCrypt-4d7dc3ba25f562bea4be8898f11a97e911c48b99.zip |
Windows: first implementation of CLI support for creating volumes.
Diffstat (limited to 'src/Common/Format.c')
-rw-r--r-- | src/Common/Format.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/Common/Format.c b/src/Common/Format.c index fe1f271f..3fede6d5 100644 --- a/src/Common/Format.c +++ b/src/Common/Format.c @@ -284,7 +284,7 @@ begin_format: dev = CreateFile (devName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
if (dev != INVALID_HANDLE_VALUE)
{
- if (IDNO == MessageBoxW (volParams->hwndDlg, GetString ("DEVICE_IN_USE_FORMAT"), lpszTitle, MB_YESNO|MB_ICONWARNING|MB_DEFBUTTON2))
+ if (!volParams->bForceOperation && (Silent || (IDNO == MessageBoxW (volParams->hwndDlg, GetString ("DEVICE_IN_USE_FORMAT"), lpszTitle, MB_YESNO|MB_ICONWARNING|MB_DEFBUTTON2))))
{
nStatus = ERR_DONT_REPORT;
goto error;
@@ -381,7 +381,7 @@ begin_format: bTimeStampValid = TRUE;
}
- KillTimer (volParams->hwndDlg, TIMER_ID_RANDVIEW);
+ if (volParams->hwndDlg && volParams->bGuiMode) KillTimer (volParams->hwndDlg, TIMER_ID_RANDVIEW);
/* Volume header */
@@ -618,8 +618,11 @@ error: if (driveNo == -1)
{
- MessageBoxW (volParams->hwndDlg, GetString ("NO_FREE_DRIVES"), lpszTitle, ICON_HAND);
- MessageBoxW (volParams->hwndDlg, GetString ("FORMAT_NTFS_STOP"), lpszTitle, ICON_HAND);
+ if (!Silent)
+ {
+ MessageBoxW (volParams->hwndDlg, GetString ("NO_FREE_DRIVES"), lpszTitle, ICON_HAND);
+ MessageBoxW (volParams->hwndDlg, GetString ("FORMAT_NTFS_STOP"), lpszTitle, ICON_HAND);
+ }
nStatus = ERR_NO_FREE_DRIVES;
goto fv_end;
@@ -634,20 +637,23 @@ error: if (MountVolume (volParams->hwndDlg, driveNo, volParams->volumePath, volParams->password, volParams->pkcs5, volParams->pim, FALSE, FALSE, TRUE, &mountOptions, FALSE, TRUE) < 1)
{
- MessageBoxW (volParams->hwndDlg, GetString ("CANT_MOUNT_VOLUME"), lpszTitle, ICON_HAND);
- MessageBoxW (volParams->hwndDlg, GetString ("FORMAT_NTFS_STOP"), lpszTitle, ICON_HAND);
+ if (!Silent)
+ {
+ MessageBoxW (volParams->hwndDlg, GetString ("CANT_MOUNT_VOLUME"), lpszTitle, ICON_HAND);
+ MessageBoxW (volParams->hwndDlg, GetString ("FORMAT_NTFS_STOP"), lpszTitle, ICON_HAND);
+ }
nStatus = ERR_VOL_MOUNT_FAILED;
goto fv_end;
}
- if (!IsAdmin () && IsUacSupported ())
+ if (!Silent && !IsAdmin () && IsUacSupported ())
retCode = UacFormatNtfs (volParams->hwndDlg, driveNo, volParams->clusterSize);
else
retCode = FormatNtfs (driveNo, volParams->clusterSize);
if (retCode != TRUE)
{
- if (!UnmountVolumeAfterFormatExCall (volParams->hwndDlg, driveNo))
+ if (!UnmountVolumeAfterFormatExCall (volParams->hwndDlg, driveNo) && !Silent)
MessageBoxW (volParams->hwndDlg, GetString ("CANT_DISMOUNT_VOLUME"), lpszTitle, ICON_HAND);
if (dataAreaSize <= TC_MAX_FAT_SECTOR_COUNT * FormatSectorSize)
@@ -669,7 +675,7 @@ error: goto fv_end;
}
- if (!UnmountVolumeAfterFormatExCall (volParams->hwndDlg, driveNo))
+ if (!UnmountVolumeAfterFormatExCall (volParams->hwndDlg, driveNo) && !Silent)
MessageBoxW (volParams->hwndDlg, GetString ("CANT_DISMOUNT_VOLUME"), lpszTitle, ICON_HAND);
}
|