mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-11 11:08:02 -06:00
Windows: first implementation of CLI support for creating volumes.
This commit is contained in:
@@ -450,8 +450,8 @@ int EAGetByName (char *name)
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
EAGetName (n, ea, 0);
|
EAGetName (n, ea, 1);
|
||||||
if (strcmp (n, name) == 0)
|
if (_stricmp (n, name) == 0)
|
||||||
return ea;
|
return ea;
|
||||||
}
|
}
|
||||||
while (ea = EAGetNext (ea));
|
while (ea = EAGetNext (ea));
|
||||||
|
|||||||
@@ -284,7 +284,7 @@ begin_format:
|
|||||||
dev = CreateFile (devName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
|
dev = CreateFile (devName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
|
||||||
if (dev != INVALID_HANDLE_VALUE)
|
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;
|
nStatus = ERR_DONT_REPORT;
|
||||||
goto error;
|
goto error;
|
||||||
@@ -381,7 +381,7 @@ begin_format:
|
|||||||
bTimeStampValid = TRUE;
|
bTimeStampValid = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
KillTimer (volParams->hwndDlg, TIMER_ID_RANDVIEW);
|
if (volParams->hwndDlg && volParams->bGuiMode) KillTimer (volParams->hwndDlg, TIMER_ID_RANDVIEW);
|
||||||
|
|
||||||
/* Volume header */
|
/* Volume header */
|
||||||
|
|
||||||
@@ -618,8 +618,11 @@ error:
|
|||||||
|
|
||||||
if (driveNo == -1)
|
if (driveNo == -1)
|
||||||
{
|
{
|
||||||
MessageBoxW (volParams->hwndDlg, GetString ("NO_FREE_DRIVES"), lpszTitle, ICON_HAND);
|
if (!Silent)
|
||||||
MessageBoxW (volParams->hwndDlg, GetString ("FORMAT_NTFS_STOP"), lpszTitle, ICON_HAND);
|
{
|
||||||
|
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;
|
nStatus = ERR_NO_FREE_DRIVES;
|
||||||
goto fv_end;
|
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)
|
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);
|
if (!Silent)
|
||||||
MessageBoxW (volParams->hwndDlg, GetString ("FORMAT_NTFS_STOP"), lpszTitle, ICON_HAND);
|
{
|
||||||
|
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;
|
nStatus = ERR_VOL_MOUNT_FAILED;
|
||||||
goto fv_end;
|
goto fv_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsAdmin () && IsUacSupported ())
|
if (!Silent && !IsAdmin () && IsUacSupported ())
|
||||||
retCode = UacFormatNtfs (volParams->hwndDlg, driveNo, volParams->clusterSize);
|
retCode = UacFormatNtfs (volParams->hwndDlg, driveNo, volParams->clusterSize);
|
||||||
else
|
else
|
||||||
retCode = FormatNtfs (driveNo, volParams->clusterSize);
|
retCode = FormatNtfs (driveNo, volParams->clusterSize);
|
||||||
|
|
||||||
if (retCode != TRUE)
|
if (retCode != TRUE)
|
||||||
{
|
{
|
||||||
if (!UnmountVolumeAfterFormatExCall (volParams->hwndDlg, driveNo))
|
if (!UnmountVolumeAfterFormatExCall (volParams->hwndDlg, driveNo) && !Silent)
|
||||||
MessageBoxW (volParams->hwndDlg, GetString ("CANT_DISMOUNT_VOLUME"), lpszTitle, ICON_HAND);
|
MessageBoxW (volParams->hwndDlg, GetString ("CANT_DISMOUNT_VOLUME"), lpszTitle, ICON_HAND);
|
||||||
|
|
||||||
if (dataAreaSize <= TC_MAX_FAT_SECTOR_COUNT * FormatSectorSize)
|
if (dataAreaSize <= TC_MAX_FAT_SECTOR_COUNT * FormatSectorSize)
|
||||||
@@ -669,7 +675,7 @@ error:
|
|||||||
goto fv_end;
|
goto fv_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!UnmountVolumeAfterFormatExCall (volParams->hwndDlg, driveNo))
|
if (!UnmountVolumeAfterFormatExCall (volParams->hwndDlg, driveNo) && !Silent)
|
||||||
MessageBoxW (volParams->hwndDlg, GetString ("CANT_DISMOUNT_VOLUME"), lpszTitle, ICON_HAND);
|
MessageBoxW (volParams->hwndDlg, GetString ("CANT_DISMOUNT_VOLUME"), lpszTitle, ICON_HAND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,11 +38,13 @@ typedef struct
|
|||||||
unsigned int clusterSize;
|
unsigned int clusterSize;
|
||||||
BOOL sparseFileSwitch;
|
BOOL sparseFileSwitch;
|
||||||
BOOL quickFormat;
|
BOOL quickFormat;
|
||||||
int sectorSize;
|
DWORD sectorSize;
|
||||||
int *realClusterSize;
|
int *realClusterSize;
|
||||||
Password *password;
|
Password *password;
|
||||||
int pim;
|
int pim;
|
||||||
HWND hwndDlg;
|
HWND hwndDlg;
|
||||||
|
BOOL bForceOperation;
|
||||||
|
BOOL bGuiMode;
|
||||||
}
|
}
|
||||||
FORMAT_VOL_PARAMETERS;
|
FORMAT_VOL_PARAMETERS;
|
||||||
|
|
||||||
|
|||||||
@@ -540,7 +540,16 @@
|
|||||||
<string lang="en" key="DECOY_TO_HIDDEN_OS_DATA_TRANSFER_HOWTO">Note: If you need to securely transfer files from the decoy system to the hidden system, follow these steps:\n1) Start the decoy system.\n2) Save the files to an unencrypted volume or to an outer/normal VeraCrypt volume.\n3) Start the hidden system.\n4) If you saved the files to a VeraCrypt volume, mount it (it will be automatically mounted as read-only).\n5) Copy the files to the hidden system partition or to another hidden volume.</string>
|
<string lang="en" key="DECOY_TO_HIDDEN_OS_DATA_TRANSFER_HOWTO">Note: If you need to securely transfer files from the decoy system to the hidden system, follow these steps:\n1) Start the decoy system.\n2) Save the files to an unencrypted volume or to an outer/normal VeraCrypt volume.\n3) Start the hidden system.\n4) If you saved the files to a VeraCrypt volume, mount it (it will be automatically mounted as read-only).\n5) Copy the files to the hidden system partition or to another hidden volume.</string>
|
||||||
<string lang="en" key="CONFIRM_RESTART">Your computer must be restarted.\n\nDo you want to restart it now?</string>
|
<string lang="en" key="CONFIRM_RESTART">Your computer must be restarted.\n\nDo you want to restart it now?</string>
|
||||||
<string lang="en" key="ERR_GETTING_SYSTEM_ENCRYPTION_STATUS">An error occurred when obtaining the system encryption status.</string>
|
<string lang="en" key="ERR_GETTING_SYSTEM_ENCRYPTION_STATUS">An error occurred when obtaining the system encryption status.</string>
|
||||||
<string lang="en" key="INIT_SYS_ENC">Cannot initialize application components for system encryption.</string>
|
<string lang="en" key="ERR_PASSWORD_MISSING">No password specified in the command line. The volume can't be created.</string>
|
||||||
|
<string lang="en" key="ERR_SIZE_MISSING">No volume size specified in the command line. The volume can't be created.</string>
|
||||||
|
<string lang="en" key="ERR_NTFS_INVALID_VOLUME_SIZE">The volume file size specified in the command line is incompatible with selected NTFS filesystem.</string>
|
||||||
|
<string lang="en" key="ERR_FAT_INVALID_VOLUME_SIZE">The volume file size specified in the command line is incompatible with selected FAT32 filesystem.</string>
|
||||||
|
<string lang="en" key="ERR_DYNAMIC_NOT_SUPPORTED">The filesystem on the target drive doesn't support creating sparse files which is required for dynamic volumes.</string>
|
||||||
|
<string lang="en" key="ERR_DEVICE_CLI_CREATE_NOT_SUPPORTED">Only container files can be created through the command line.</string>
|
||||||
|
<string lang="en" key="ERR_CONTAINER_SIZE_TOO_BIG">The container file size specified in the command line is greater than the available disk free space. Volume can't be created.</string>
|
||||||
|
<string lang="en" key="ERR_VOLUME_SIZE_TOO_SMALL">The volume size specified in the command line is too small. The volume can't be created.</string>
|
||||||
|
<string lang="en" key="ERR_VOLUME_SIZE_TOO_BIG">The volume size specified in the command line is too big. The volume can't be created.</string>
|
||||||
|
<string lang="en" key="INIT_SYS_ENC">Cannot initialize application components for system encryption.</string>
|
||||||
<string lang="en" key="INIT_RAND">Failed to initialize the random number generator!\n\n\n(If you report a bug in connection with this, please include the following technical information in the bug report:\n%hs, Last Error = 0x%.8X)</string>
|
<string lang="en" key="INIT_RAND">Failed to initialize the random number generator!\n\n\n(If you report a bug in connection with this, please include the following technical information in the bug report:\n%hs, Last Error = 0x%.8X)</string>
|
||||||
<string lang="en" key="CAPI_RAND">Windows Crypto API failed!\n\n\n(If you report a bug in connection with this, please include the following technical information in the bug report:\n%hs, Last Error = 0x%.8X)</string>
|
<string lang="en" key="CAPI_RAND">Windows Crypto API failed!\n\n\n(If you report a bug in connection with this, please include the following technical information in the bug report:\n%hs, Last Error = 0x%.8X)</string>
|
||||||
<string lang="en" key="INIT_REGISTER">Unable to initialize the application. Failed to register the Dialog class.</string>
|
<string lang="en" key="INIT_REGISTER">Unable to initialize the application. Failed to register the Dialog class.</string>
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ BOOL CheckPasswordCharEncoding (HWND hPassword, Password *ptrPw)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOL CheckPasswordLength (HWND hwndDlg, unsigned __int32 passwordLength, int pim, BOOL bForBoot, BOOL bSkipPasswordWarning)
|
BOOL CheckPasswordLength (HWND hwndDlg, unsigned __int32 passwordLength, int pim, BOOL bForBoot, BOOL bSkipPasswordWarning, BOOL bSkipPimWarning)
|
||||||
{
|
{
|
||||||
BOOL bCustomPimSmall = ((pim != 0) && (pim < (bForBoot? 98 : 485)))? TRUE : FALSE;
|
BOOL bCustomPimSmall = ((pim != 0) && (pim < (bForBoot? 98 : 485)))? TRUE : FALSE;
|
||||||
if (passwordLength < PASSWORD_LEN_WARNING)
|
if (passwordLength < PASSWORD_LEN_WARNING)
|
||||||
@@ -132,7 +132,7 @@ BOOL CheckPasswordLength (HWND hwndDlg, unsigned __int32 passwordLength, int pim
|
|||||||
#ifndef _DEBUG
|
#ifndef _DEBUG
|
||||||
else if (bCustomPimSmall)
|
else if (bCustomPimSmall)
|
||||||
{
|
{
|
||||||
if (MessageBoxW (hwndDlg, GetString ("PIM_SMALL_WARNING"), lpszTitle, MB_YESNO|MB_ICONWARNING|MB_DEFBUTTON2) != IDYES)
|
if (!bSkipPimWarning && AskWarnNoYes ("PIM_SMALL_WARNING", hwndDlg) != IDYES)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -140,7 +140,7 @@ BOOL CheckPasswordLength (HWND hwndDlg, unsigned __int32 passwordLength, int pim
|
|||||||
if ((pim != 0) && (pim > (bForBoot? 98 : 485)))
|
if ((pim != 0) && (pim > (bForBoot? 98 : 485)))
|
||||||
{
|
{
|
||||||
// warn that mount/boot will take more time
|
// warn that mount/boot will take more time
|
||||||
MessageBoxW (hwndDlg, GetString ("PIM_LARGE_WARNING"), lpszTitle, MB_OK|MB_ICONWARNING);
|
Warning ("PIM_LARGE_WARNING", hwndDlg);
|
||||||
|
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ typedef struct
|
|||||||
#if defined(_WIN32) && !defined(TC_WINDOWS_DRIVER)
|
#if defined(_WIN32) && !defined(TC_WINDOWS_DRIVER)
|
||||||
|
|
||||||
void VerifyPasswordAndUpdate ( HWND hwndDlg , HWND hButton , HWND hPassword , HWND hVerify , unsigned char *szPassword , char *szVerify, BOOL keyFilesEnabled );
|
void VerifyPasswordAndUpdate ( HWND hwndDlg , HWND hButton , HWND hPassword , HWND hVerify , unsigned char *szPassword , char *szVerify, BOOL keyFilesEnabled );
|
||||||
BOOL CheckPasswordLength (HWND hwndDlg, unsigned __int32 passwordLength, int pim, BOOL bForBoot, BOOL bSkipPasswordWarning);
|
BOOL CheckPasswordLength (HWND hwndDlg, unsigned __int32 passwordLength, int pim, BOOL bForBoot, BOOL bSkipPasswordWarning, BOOL bSkipPimWarning);
|
||||||
BOOL CheckPasswordCharEncoding (HWND hPassword, Password *ptrPw);
|
BOOL CheckPasswordCharEncoding (HWND hPassword, Password *ptrPw);
|
||||||
int ChangePwd (const char *lpszVolume, Password *oldPassword, int old_pkcs5, int old_pim, BOOL truecryptMode, Password *newPassword, int pkcs5, int pim, int wipePassCount, HWND hwndDlg);
|
int ChangePwd (const char *lpszVolume, Password *oldPassword, int old_pkcs5, int old_pim, BOOL truecryptMode, Password *newPassword, int pkcs5, int pim, int wipePassCount, HWND hwndDlg);
|
||||||
|
|
||||||
|
|||||||
@@ -156,6 +156,8 @@ BOOL DirectNonSysInplaceDecStartMode = FALSE;
|
|||||||
BOOL DirectNonSysInplaceEncResumeMode = FALSE;
|
BOOL DirectNonSysInplaceEncResumeMode = FALSE;
|
||||||
BOOL DirectNonSysInplaceDecResumeMode = FALSE;
|
BOOL DirectNonSysInplaceDecResumeMode = FALSE;
|
||||||
BOOL DirectPromptNonSysInplaceEncResumeMode = FALSE;
|
BOOL DirectPromptNonSysInplaceEncResumeMode = FALSE;
|
||||||
|
BOOL DirectCreationMode = FALSE;
|
||||||
|
|
||||||
volatile BOOL bInPlaceEncNonSys = FALSE; /* If TRUE, existing data on a non-system partition/volume are to be encrypted (or decrypted if bInPlaceDecNonSys is TRUE) in place (for system encryption, this flag is ignored) */
|
volatile BOOL bInPlaceEncNonSys = FALSE; /* If TRUE, existing data on a non-system partition/volume are to be encrypted (or decrypted if bInPlaceDecNonSys is TRUE) in place (for system encryption, this flag is ignored) */
|
||||||
volatile BOOL bInPlaceDecNonSys = FALSE; /* If TRUE, existing data on a non-system partition/volume are to be decrypted in place (for system encryption, this flag is ignored) */
|
volatile BOOL bInPlaceDecNonSys = FALSE; /* If TRUE, existing data on a non-system partition/volume are to be decrypted in place (for system encryption, this flag is ignored) */
|
||||||
volatile BOOL bInPlaceEncNonSysResumed = FALSE; /* If TRUE, the wizard is supposed to resume (or has resumed) process of non-system in-place encryption/decryption. */
|
volatile BOOL bInPlaceEncNonSysResumed = FALSE; /* If TRUE, the wizard is supposed to resume (or has resumed) process of non-system in-place encryption/decryption. */
|
||||||
@@ -236,6 +238,21 @@ int volumePim = 0;
|
|||||||
BOOL bHistoryCmdLine = FALSE; /* History control is always disabled */
|
BOOL bHistoryCmdLine = FALSE; /* History control is always disabled */
|
||||||
BOOL ComServerMode = FALSE;
|
BOOL ComServerMode = FALSE;
|
||||||
|
|
||||||
|
|
||||||
|
Password CmdVolumePassword = {0}; /* Password passed from command line */
|
||||||
|
int CmdVolumeEA = 0;
|
||||||
|
int CmdVolumePkcs5 = 0;
|
||||||
|
int CmdVolumePim = 0;
|
||||||
|
int CmdVolumeFilesystem = FILESYS_NONE;
|
||||||
|
unsigned __int64 CmdVolumeFileSize = 0;
|
||||||
|
BOOL CmdSparseFileSwitch = FALSE;
|
||||||
|
|
||||||
|
BOOL bForceOperation = FALSE;
|
||||||
|
|
||||||
|
BOOL bOperationSuccess = FALSE;
|
||||||
|
|
||||||
|
BOOL bGuiMode = TRUE;
|
||||||
|
|
||||||
int nPbar = 0; /* Control ID of progress bar:- for format code */
|
int nPbar = 0; /* Control ID of progress bar:- for format code */
|
||||||
|
|
||||||
char HeaderKeyGUIView [KEY_GUI_VIEW_SIZE];
|
char HeaderKeyGUIView [KEY_GUI_VIEW_SIZE];
|
||||||
@@ -385,6 +402,8 @@ static void WipePasswordsAndKeyfiles (void)
|
|||||||
burn (&volumePassword, sizeof (volumePassword));
|
burn (&volumePassword, sizeof (volumePassword));
|
||||||
burn (&szRawPassword[0], sizeof (szRawPassword));
|
burn (&szRawPassword[0], sizeof (szRawPassword));
|
||||||
burn (&volumePim, sizeof (volumePim));
|
burn (&volumePim, sizeof (volumePim));
|
||||||
|
burn (&CmdVolumePassword, sizeof (CmdVolumePassword));
|
||||||
|
burn (&CmdVolumePim, sizeof (CmdVolumePim));
|
||||||
|
|
||||||
SetWindowText (hPasswordInputField, "");
|
SetWindowText (hPasswordInputField, "");
|
||||||
SetWindowText (hVerifyPasswordInputField, "");
|
SetWindowText (hVerifyPasswordInputField, "");
|
||||||
@@ -1458,7 +1477,7 @@ static void VerifySizeAndUpdate (HWND hwndDlg, BOOL bUpdate)
|
|||||||
i = nMultiplier;
|
i = nMultiplier;
|
||||||
lTmp = _atoi64 (szTmp);
|
lTmp = _atoi64 (szTmp);
|
||||||
|
|
||||||
int sectorSize = GetFormatSectorSize();
|
DWORD sectorSize = GetFormatSectorSize();
|
||||||
uint32 sectorSizeRem = (lTmp * nMultiplier) % sectorSize;
|
uint32 sectorSizeRem = (lTmp * nMultiplier) % sectorSize;
|
||||||
|
|
||||||
if (sectorSizeRem != 0)
|
if (sectorSizeRem != 0)
|
||||||
@@ -2452,7 +2471,7 @@ static void __cdecl volTransformThreadFunction (void *hwndDlgArg)
|
|||||||
int nStatus;
|
int nStatus;
|
||||||
DWORD dwWin32FormatError;
|
DWORD dwWin32FormatError;
|
||||||
BOOL bHidden;
|
BOOL bHidden;
|
||||||
HWND hwndDlg = (HWND) hwndDlgArg;
|
HWND hwndDlg = (HWND) hwndDlgArg;
|
||||||
volatile FORMAT_VOL_PARAMETERS *volParams = (FORMAT_VOL_PARAMETERS *) malloc (sizeof(FORMAT_VOL_PARAMETERS));
|
volatile FORMAT_VOL_PARAMETERS *volParams = (FORMAT_VOL_PARAMETERS *) malloc (sizeof(FORMAT_VOL_PARAMETERS));
|
||||||
|
|
||||||
if (volParams == NULL)
|
if (volParams == NULL)
|
||||||
@@ -2460,20 +2479,25 @@ static void __cdecl volTransformThreadFunction (void *hwndDlgArg)
|
|||||||
|
|
||||||
VirtualLock ((LPVOID) volParams, sizeof(FORMAT_VOL_PARAMETERS));
|
VirtualLock ((LPVOID) volParams, sizeof(FORMAT_VOL_PARAMETERS));
|
||||||
|
|
||||||
bVolTransformThreadRunning = TRUE;
|
bOperationSuccess = FALSE;
|
||||||
bVolTransformThreadToRun = FALSE;
|
|
||||||
|
if (bGuiMode)
|
||||||
|
{
|
||||||
|
bVolTransformThreadRunning = TRUE;
|
||||||
|
bVolTransformThreadToRun = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
// Check administrator privileges
|
// Check administrator privileges
|
||||||
if (!IsAdmin () && !IsUacSupported ())
|
if (!IsAdmin () && !IsUacSupported ())
|
||||||
{
|
{
|
||||||
if (fileSystem == FILESYS_NTFS)
|
if (fileSystem == FILESYS_NTFS)
|
||||||
{
|
{
|
||||||
if (MessageBoxW (hwndDlg, GetString ("ADMIN_PRIVILEGES_WARN_NTFS"), lpszTitle, MB_OKCANCEL|MB_ICONWARNING|MB_DEFBUTTON2) == IDCANCEL)
|
if (Silent || (MessageBoxW (hwndDlg, GetString ("ADMIN_PRIVILEGES_WARN_NTFS"), lpszTitle, MB_OKCANCEL|MB_ICONWARNING|MB_DEFBUTTON2) == IDCANCEL))
|
||||||
goto cancel;
|
goto cancel;
|
||||||
}
|
}
|
||||||
if (bDevice)
|
if (bDevice)
|
||||||
{
|
{
|
||||||
if (MessageBoxW (hwndDlg, GetString ("ADMIN_PRIVILEGES_WARN_DEVICES"), lpszTitle, MB_OKCANCEL|MB_ICONWARNING|MB_DEFBUTTON2) == IDCANCEL)
|
if (Silent || (MessageBoxW (hwndDlg, GetString ("ADMIN_PRIVILEGES_WARN_DEVICES"), lpszTitle, MB_OKCANCEL|MB_ICONWARNING|MB_DEFBUTTON2) == IDCANCEL))
|
||||||
goto cancel;
|
goto cancel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2487,13 +2511,13 @@ static void __cdecl volTransformThreadFunction (void *hwndDlgArg)
|
|||||||
{
|
{
|
||||||
wchar_t szTmp[512];
|
wchar_t szTmp[512];
|
||||||
|
|
||||||
if (! ((bHiddenVol && !bHiddenVolHost) && errno != EACCES)) // Only ask ask for permission to overwrite an existing volume if we're not creating a hidden volume
|
if (!bForceOperation && !((bHiddenVol && !bHiddenVolHost) && errno != EACCES)) // Only ask ask for permission to overwrite an existing volume if we're not creating a hidden volume
|
||||||
{
|
{
|
||||||
StringCbPrintfW (szTmp, sizeof szTmp,
|
StringCbPrintfW (szTmp, sizeof szTmp,
|
||||||
GetString (errno == EACCES ? "READONLYPROMPT" : "OVERWRITEPROMPT"),
|
GetString (errno == EACCES ? "READONLYPROMPT" : "OVERWRITEPROMPT"),
|
||||||
szDiskFile);
|
szDiskFile);
|
||||||
|
|
||||||
x = MessageBoxW (hwndDlg, szTmp, lpszTitle, YES_NO|MB_ICONWARNING|MB_DEFBUTTON2);
|
x = Silent? IDNO : MessageBoxW (hwndDlg, szTmp, lpszTitle, YES_NO|MB_ICONWARNING|MB_DEFBUTTON2);
|
||||||
|
|
||||||
if (x != IDYES)
|
if (x != IDYES)
|
||||||
goto cancel;
|
goto cancel;
|
||||||
@@ -2506,7 +2530,7 @@ static void __cdecl volTransformThreadFunction (void *hwndDlgArg)
|
|||||||
{
|
{
|
||||||
if (_chmod (szDiskFile, _S_IREAD | _S_IWRITE) != 0)
|
if (_chmod (szDiskFile, _S_IREAD | _S_IWRITE) != 0)
|
||||||
{
|
{
|
||||||
MessageBoxW (hwndDlg, GetString ("ACCESSMODEFAIL"), lpszTitle, ICON_HAND);
|
if (!Silent) MessageBoxW (hwndDlg, GetString ("ACCESSMODEFAIL"), lpszTitle, ICON_HAND);
|
||||||
goto cancel;
|
goto cancel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2544,6 +2568,8 @@ static void __cdecl volTransformThreadFunction (void *hwndDlgArg)
|
|||||||
volParams->password = &volumePassword;
|
volParams->password = &volumePassword;
|
||||||
volParams->pim = volumePim;
|
volParams->pim = volumePim;
|
||||||
volParams->hwndDlg = hwndDlg;
|
volParams->hwndDlg = hwndDlg;
|
||||||
|
volParams->bForceOperation = bForceOperation;
|
||||||
|
volParams->bGuiMode = bGuiMode;
|
||||||
|
|
||||||
if (bInPlaceDecNonSys)
|
if (bInPlaceDecNonSys)
|
||||||
{
|
{
|
||||||
@@ -2587,7 +2613,7 @@ static void __cdecl volTransformThreadFunction (void *hwndDlgArg)
|
|||||||
{
|
{
|
||||||
// Format-encryption
|
// Format-encryption
|
||||||
|
|
||||||
InitProgressBar (GetVolumeDataAreaSize (bHidden, nVolumeSize), 0, FALSE, FALSE, FALSE, TRUE);
|
if (hwndDlg && bGuiMode) InitProgressBar (GetVolumeDataAreaSize (bHidden, nVolumeSize), 0, FALSE, FALSE, FALSE, TRUE);
|
||||||
|
|
||||||
nStatus = TCFormatVolume (volParams);
|
nStatus = TCFormatVolume (volParams);
|
||||||
}
|
}
|
||||||
@@ -2611,19 +2637,19 @@ static void __cdecl volTransformThreadFunction (void *hwndDlgArg)
|
|||||||
|
|
||||||
dwWin32FormatError = GetLastError ();
|
dwWin32FormatError = GetLastError ();
|
||||||
|
|
||||||
if (bHiddenVolHost && !bVolTransformThreadCancel && nStatus == 0)
|
if (bHiddenVolHost && (!bGuiMode || !bVolTransformThreadCancel) && nStatus == 0)
|
||||||
{
|
{
|
||||||
/* Auto mount the newly created hidden volume host */
|
/* Auto mount the newly created hidden volume host */
|
||||||
switch (MountHiddenVolHost (hwndDlg, szDiskFile, &hiddenVolHostDriveNo, &volumePassword, hash_algo, volumePim, FALSE))
|
switch (MountHiddenVolHost (hwndDlg, szDiskFile, &hiddenVolHostDriveNo, &volumePassword, hash_algo, volumePim, FALSE))
|
||||||
{
|
{
|
||||||
case ERR_NO_FREE_DRIVES:
|
case ERR_NO_FREE_DRIVES:
|
||||||
MessageBoxW (hwndDlg, GetString ("NO_FREE_DRIVE_FOR_OUTER_VOL"), lpszTitle, ICON_HAND);
|
if (!Silent) MessageBoxW (hwndDlg, GetString ("NO_FREE_DRIVE_FOR_OUTER_VOL"), lpszTitle, ICON_HAND);
|
||||||
bVolTransformThreadCancel = TRUE;
|
if (bGuiMode) bVolTransformThreadCancel = TRUE;
|
||||||
break;
|
break;
|
||||||
case ERR_VOL_MOUNT_FAILED:
|
case ERR_VOL_MOUNT_FAILED:
|
||||||
case ERR_PASSWORD_WRONG:
|
case ERR_PASSWORD_WRONG:
|
||||||
MessageBoxW (hwndDlg, GetString ("CANT_MOUNT_OUTER_VOL"), lpszTitle, ICON_HAND);
|
if (!Silent) MessageBoxW (hwndDlg, GetString ("CANT_MOUNT_OUTER_VOL"), lpszTitle, ICON_HAND);
|
||||||
bVolTransformThreadCancel = TRUE;
|
if (bGuiMode) bVolTransformThreadCancel = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2668,7 +2694,7 @@ static void __cdecl volTransformThreadFunction (void *hwndDlgArg)
|
|||||||
ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "INPLACE_ENC_GENERIC_ERR_ALT_STEPS", TRUE);
|
ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "INPLACE_ENC_GENERIC_ERR_ALT_STEPS", TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!(bHiddenVolHost && hiddenVolHostDriveNo < 0)) // If the error was not that the hidden volume host could not be mounted (this error has already been reported to the user)
|
else if (!Silent && !(bHiddenVolHost && hiddenVolHostDriveNo < 0)) // If the error was not that the hidden volume host could not be mounted (this error has already been reported to the user)
|
||||||
{
|
{
|
||||||
StringCbPrintfW (szMsg, sizeof(szMsg), GetString ("CREATE_FAILED"), szDiskFile);
|
StringCbPrintfW (szMsg, sizeof(szMsg), GetString ("CREATE_FAILED"), szDiskFile);
|
||||||
MessageBoxW (hwndDlg, szMsg, lpszTitle, ICON_HAND);
|
MessageBoxW (hwndDlg, szMsg, lpszTitle, ICON_HAND);
|
||||||
@@ -2689,6 +2715,8 @@ static void __cdecl volTransformThreadFunction (void *hwndDlgArg)
|
|||||||
|
|
||||||
PimEnable = FALSE;
|
PimEnable = FALSE;
|
||||||
|
|
||||||
|
bOperationSuccess = TRUE;
|
||||||
|
|
||||||
if (bDevice && !bInPlaceEncNonSys)
|
if (bDevice && !bInPlaceEncNonSys)
|
||||||
{
|
{
|
||||||
// Handle assigned drive letter (if any)
|
// Handle assigned drive letter (if any)
|
||||||
@@ -2738,10 +2766,10 @@ static void __cdecl volTransformThreadFunction (void *hwndDlgArg)
|
|||||||
burn(&szVerify[0], sizeof (szVerify));
|
burn(&szVerify[0], sizeof (szVerify));
|
||||||
burn(&szRawPassword[0], sizeof (szRawPassword));
|
burn(&szRawPassword[0], sizeof (szRawPassword));
|
||||||
|
|
||||||
MessageBeep (MB_OK);
|
if (!Silent) MessageBeep (MB_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bInPlaceEncNonSys)
|
if (!bInPlaceEncNonSys && hwndDlg && bGuiMode)
|
||||||
SetTimer (hwndDlg, TIMER_ID_RANDVIEW, TIMER_INTERVAL_RANDVIEW, NULL);
|
SetTimer (hwndDlg, TIMER_ID_RANDVIEW, TIMER_INTERVAL_RANDVIEW, NULL);
|
||||||
|
|
||||||
|
|
||||||
@@ -2751,13 +2779,16 @@ static void __cdecl volTransformThreadFunction (void *hwndDlgArg)
|
|||||||
free ((LPVOID) volParams);
|
free ((LPVOID) volParams);
|
||||||
volParams = NULL;
|
volParams = NULL;
|
||||||
|
|
||||||
bVolTransformThreadRunning = FALSE;
|
if (bGuiMode)
|
||||||
bVolTransformThreadCancel = FALSE;
|
{
|
||||||
|
bVolTransformThreadRunning = FALSE;
|
||||||
|
bVolTransformThreadCancel = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
PostMessage (hwndDlg, bInPlaceEncNonSys ? TC_APPMSG_NONSYS_INPLACE_ENC_FINISHED : TC_APPMSG_FORMAT_FINISHED, 0, 0);
|
if (hwndDlg && bGuiMode) PostMessage (hwndDlg, bInPlaceEncNonSys ? TC_APPMSG_NONSYS_INPLACE_ENC_FINISHED : TC_APPMSG_FORMAT_FINISHED, 0, 0);
|
||||||
|
|
||||||
LastDialogId = "FORMAT_FINISHED";
|
LastDialogId = "FORMAT_FINISHED";
|
||||||
_endthread ();
|
if (bGuiMode) _endthread ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2765,7 +2796,7 @@ cancel:
|
|||||||
|
|
||||||
LastDialogId = (bInPlaceEncNonSys ? "NONSYS_INPLACE_ENC_CANCELED" : "FORMAT_CANCELED");
|
LastDialogId = (bInPlaceEncNonSys ? "NONSYS_INPLACE_ENC_CANCELED" : "FORMAT_CANCELED");
|
||||||
|
|
||||||
if (!bInPlaceEncNonSys)
|
if (!bInPlaceEncNonSys && hwndDlg && bGuiMode)
|
||||||
SetTimer (hwndDlg, TIMER_ID_RANDVIEW, TIMER_INTERVAL_RANDVIEW, NULL);
|
SetTimer (hwndDlg, TIMER_ID_RANDVIEW, TIMER_INTERVAL_RANDVIEW, NULL);
|
||||||
|
|
||||||
if (volParams != NULL)
|
if (volParams != NULL)
|
||||||
@@ -2776,18 +2807,21 @@ cancel:
|
|||||||
volParams = NULL;
|
volParams = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bVolTransformThreadRunning = FALSE;
|
if (bGuiMode)
|
||||||
bVolTransformThreadCancel = FALSE;
|
{
|
||||||
|
bVolTransformThreadRunning = FALSE;
|
||||||
|
bVolTransformThreadCancel = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
// Allow the OS to enter Sleep mode when idle
|
// Allow the OS to enter Sleep mode when idle
|
||||||
SetThreadExecutionState (ES_CONTINUOUS);
|
SetThreadExecutionState (ES_CONTINUOUS);
|
||||||
|
|
||||||
PostMessage (hwndDlg, TC_APPMSG_VOL_TRANSFORM_THREAD_ENDED, 0, 0);
|
if (hwndDlg) PostMessage (hwndDlg, TC_APPMSG_VOL_TRANSFORM_THREAD_ENDED, 0, 0);
|
||||||
|
|
||||||
if (bHiddenVolHost && hiddenVolHostDriveNo < -1 && !bVolTransformThreadCancel) // If hidden volume host could not be mounted
|
if (bHiddenVolHost && hiddenVolHostDriveNo < -1 && !bVolTransformThreadCancel) // If hidden volume host could not be mounted
|
||||||
AbortProcessSilent ();
|
AbortProcessSilent ();
|
||||||
|
|
||||||
_endthread ();
|
if (bGuiMode) _endthread ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LoadPage (HWND hwndDlg, int nPageNo)
|
static void LoadPage (HWND hwndDlg, int nPageNo)
|
||||||
@@ -3321,7 +3355,7 @@ BOOL QueryFreeSpace (HWND hwndDlg, HWND hwndTextBox, BOOL display)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sectorSize = GetFormatSectorSize();
|
DWORD sectorSize = GetFormatSectorSize();
|
||||||
|
|
||||||
if (sectorSize < TC_MIN_VOLUME_SECTOR_SIZE
|
if (sectorSize < TC_MIN_VOLUME_SECTOR_SIZE
|
||||||
|| sectorSize > TC_MAX_VOLUME_SECTOR_SIZE
|
|| sectorSize > TC_MAX_VOLUME_SECTOR_SIZE
|
||||||
@@ -3381,7 +3415,7 @@ static BOOL FinalPreTransformPrompts (void)
|
|||||||
|
|
||||||
driveNo = GetDiskDeviceDriveLetter (deviceName);
|
driveNo = GetDiskDeviceDriveLetter (deviceName);
|
||||||
|
|
||||||
if (!(bHiddenVol && !bHiddenVolHost)) // Do not ask for permission to overwrite an existing volume if we're creating a hidden volume within it
|
if (!bForceOperation && !(bHiddenVol && !bHiddenVolHost)) // Do not ask for permission to overwrite an existing volume if we're creating a hidden volume within it
|
||||||
{
|
{
|
||||||
wchar_t drive[128];
|
wchar_t drive[128];
|
||||||
wchar_t volumeLabel[128];
|
wchar_t volumeLabel[128];
|
||||||
@@ -3408,8 +3442,11 @@ static BOOL FinalPreTransformPrompts (void)
|
|||||||
else
|
else
|
||||||
StringCbPrintfW (szTmp, sizeof(szTmp), GetString (bInPlaceEncNonSys ? (bInPlaceDecNonSys ? "NONSYS_INPLACE_DEC_CONFIRM" : "NONSYS_INPLACE_ENC_CONFIRM") : "OVERWRITEPROMPT_DEVICE"), type, szFileName, drive);
|
StringCbPrintfW (szTmp, sizeof(szTmp), GetString (bInPlaceEncNonSys ? (bInPlaceDecNonSys ? "NONSYS_INPLACE_DEC_CONFIRM" : "NONSYS_INPLACE_ENC_CONFIRM") : "OVERWRITEPROMPT_DEVICE"), type, szFileName, drive);
|
||||||
|
|
||||||
|
if (bInPlaceEncNonSys)
|
||||||
|
x = AskWarnYesNoString (szTmp, MainDlg);
|
||||||
|
else
|
||||||
|
x = AskWarnNoYesString (szTmp, MainDlg);
|
||||||
|
|
||||||
x = MessageBoxW (MainDlg, szTmp, lpszTitle, YES_NO | MB_ICONWARNING | (bInPlaceEncNonSys ? MB_DEFBUTTON1 : MB_DEFBUTTON2));
|
|
||||||
if (x != IDYES)
|
if (x != IDYES)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@@ -3495,7 +3532,7 @@ void HandleOldAssignedDriveLetter (void)
|
|||||||
ToUNICODE ((char *)deviceName, sizeof(deviceName));
|
ToUNICODE ((char *)deviceName, sizeof(deviceName));
|
||||||
driveLetter = GetDiskDeviceDriveLetter (deviceName);
|
driveLetter = GetDiskDeviceDriveLetter (deviceName);
|
||||||
|
|
||||||
if (!bHiddenVolHost
|
if (!Silent && !bHiddenVolHost
|
||||||
&& !bHiddenOS
|
&& !bHiddenOS
|
||||||
&& driveLetter > 1) // If a drive letter is assigned to the device, but not A: or B:
|
&& driveLetter > 1) // If a drive letter is assigned to the device, but not A: or B:
|
||||||
{
|
{
|
||||||
@@ -4748,7 +4785,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|||||||
for (int i = 1; i <= 128; i *= 2)
|
for (int i = 1; i <= 128; i *= 2)
|
||||||
{
|
{
|
||||||
wstringstream s;
|
wstringstream s;
|
||||||
int size = GetFormatSectorSize() * i;
|
DWORD size = GetFormatSectorSize() * i;
|
||||||
|
|
||||||
if (size > TC_MAX_FAT_CLUSTER_SIZE)
|
if (size > TC_MAX_FAT_CLUSTER_SIZE)
|
||||||
break;
|
break;
|
||||||
@@ -5851,6 +5888,167 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (DirectCreationMode)
|
||||||
|
{
|
||||||
|
char root[TC_MAX_PATH];
|
||||||
|
DWORD fileSystemFlags = 0;
|
||||||
|
uint64 dataAreaSize;
|
||||||
|
char szFileSystemNameBuffer[256];
|
||||||
|
ULARGE_INTEGER free;
|
||||||
|
|
||||||
|
showKeys = FALSE;
|
||||||
|
bGuiMode = FALSE;
|
||||||
|
|
||||||
|
if (CmdVolumePassword.Length == 0)
|
||||||
|
AbortProcess ("ERR_PASSWORD_MISSING");
|
||||||
|
|
||||||
|
if (CmdVolumeFileSize == 0)
|
||||||
|
AbortProcess ("ERR_SIZE_MISSING");
|
||||||
|
|
||||||
|
CreateFullVolumePath (szDiskFile, sizeof(szDiskFile), szFileName, &bDevice);
|
||||||
|
|
||||||
|
if (bDevice)
|
||||||
|
AbortProcess ("ERR_DEVICE_CLI_CREATE_NOT_SUPPORTED");
|
||||||
|
|
||||||
|
volumePassword = CmdVolumePassword;
|
||||||
|
volumePim = CmdVolumePim;
|
||||||
|
|
||||||
|
if (CmdVolumeEA > 0)
|
||||||
|
nVolumeEA = CmdVolumeEA;
|
||||||
|
|
||||||
|
if (CmdVolumePkcs5 > 0)
|
||||||
|
hash_algo = CmdVolumePkcs5;
|
||||||
|
|
||||||
|
if (CmdVolumeFilesystem > 0)
|
||||||
|
fileSystem = CmdVolumeFilesystem;
|
||||||
|
else
|
||||||
|
fileSystem = FILESYS_NTFS;
|
||||||
|
|
||||||
|
nVolumeSize = CmdVolumeFileSize;
|
||||||
|
|
||||||
|
// correct volume size to be multiple of sector size
|
||||||
|
if (bDevice && !(bHiddenVol && !bHiddenVolHost)) // If raw device but not a hidden volume
|
||||||
|
{
|
||||||
|
// do nothing. no correction is needed
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unsigned __int64 sectorSize = (unsigned __int64) GetFormatSectorSize();
|
||||||
|
unsigned __int64 sectorSizeRem = nVolumeSize % sectorSize;
|
||||||
|
|
||||||
|
if (sectorSizeRem != 0)
|
||||||
|
nVolumeSize = nVolumeSize + (sectorSize - sectorSizeRem);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nVolumeSize < (bHiddenVolHost ? TC_MIN_HIDDEN_VOLUME_HOST_SIZE : (bHiddenVol ? TC_MIN_HIDDEN_VOLUME_SIZE : TC_MIN_VOLUME_SIZE)))
|
||||||
|
AbortProcess ("ERR_VOLUME_SIZE_TOO_SMALL");
|
||||||
|
|
||||||
|
if ( ((!bHiddenVolHost && bHiddenVol) && (nVolumeSize > nMaximumHiddenVolSize))
|
||||||
|
|| (nVolumeSize > (bHiddenVolHost ? TC_MAX_HIDDEN_VOLUME_HOST_SIZE : TC_MAX_VOLUME_SIZE))
|
||||||
|
)
|
||||||
|
{
|
||||||
|
AbortProcess ("ERR_VOLUME_SIZE_TOO_BIG");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!GetVolumePathName (szFileName, root, sizeof (root)))
|
||||||
|
{
|
||||||
|
handleWin32Error (hwndDlg, SRC_POS);
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CmdSparseFileSwitch)
|
||||||
|
{
|
||||||
|
/* Check if the host file system supports sparse files */
|
||||||
|
GetVolumeInformation (root, NULL, 0, NULL, NULL, &fileSystemFlags, NULL, 0);
|
||||||
|
bSparseFileSwitch = fileSystemFlags & FILE_SUPPORTS_SPARSE_FILES;
|
||||||
|
|
||||||
|
if (!bSparseFileSwitch)
|
||||||
|
{
|
||||||
|
AbortProcess ("ERR_DYNAMIC_NOT_SUPPORTED");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
quickFormat = TRUE;
|
||||||
|
|
||||||
|
if (!GetDiskFreeSpaceEx (root, &free, 0, 0))
|
||||||
|
{
|
||||||
|
wchar_t szTmp[1024];
|
||||||
|
|
||||||
|
if (translateWin32Error (szTmp, sizeof (szTmp) / sizeof(szTmp[0])))
|
||||||
|
{
|
||||||
|
wchar_t szTmp2[1024];
|
||||||
|
StringCbPrintfW (szTmp2, sizeof(szTmp2), L"%s\n%s", GetString ("CANNOT_CALC_SPACE"), szTmp);
|
||||||
|
AbortProcessDirect (szTmp2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
handleWin32Error (hwndDlg, SRC_POS);
|
||||||
|
}
|
||||||
|
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!bSparseFileSwitch && (nVolumeSize > free.QuadPart))
|
||||||
|
{
|
||||||
|
AbortProcess ("ERR_CONTAINER_SIZE_TOO_BIG");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dataAreaSize = GetVolumeDataAreaSize (bHiddenVol && !bHiddenVolHost, nVolumeSize);
|
||||||
|
|
||||||
|
if ( (fileSystem == FILESYS_NTFS) &&
|
||||||
|
(dataAreaSize < TC_MIN_NTFS_FS_SIZE || dataAreaSize > TC_MAX_NTFS_FS_SIZE)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
AbortProcess ("ERR_NTFS_INVALID_VOLUME_SIZE");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( (fileSystem == FILESYS_FAT) &&
|
||||||
|
(dataAreaSize < TC_MIN_FAT_FS_SIZE || dataAreaSize > (TC_MAX_FAT_SECTOR_COUNT * GetFormatSectorSize()))
|
||||||
|
)
|
||||||
|
{
|
||||||
|
AbortProcess ("ERR_FAT_INVALID_VOLUME_SIZE");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Verify that the volume would not be too large for the host file system */
|
||||||
|
if (GetVolumePathName (szDiskFile, root, sizeof (root))
|
||||||
|
&& GetVolumeInformation (root, NULL, 0, NULL, NULL, NULL, szFileSystemNameBuffer, sizeof(szFileSystemNameBuffer))
|
||||||
|
&& !strncmp (szFileSystemNameBuffer, "FAT32", 5))
|
||||||
|
{
|
||||||
|
// The host file system is FAT32
|
||||||
|
if (nVolumeSize >= 4 * BYTES_PER_GB)
|
||||||
|
{
|
||||||
|
AbortProcess ("VOLUME_TOO_LARGE_FOR_FAT32");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Verify that the volume would not be too large for the operating system */
|
||||||
|
if (!IsOSAtLeast (WIN_VISTA)
|
||||||
|
&& nVolumeSize > 2 * BYTES_PER_TB)
|
||||||
|
{
|
||||||
|
AbortProcess ("VOLUME_TOO_LARGE_FOR_WINXP");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (volumePassword.Length > 0)
|
||||||
|
{
|
||||||
|
// Password character encoding
|
||||||
|
if (!CheckPasswordCharEncoding (NULL, &volumePassword))
|
||||||
|
{
|
||||||
|
AbortProcess ("UNSUPPORTED_CHARS_IN_PWD");
|
||||||
|
}
|
||||||
|
// Check password length (check also done for outer volume which is not the case in TrueCrypt).
|
||||||
|
else if (!CheckPasswordLength (NULL, volumePassword.Length, volumePim, FALSE, Silent, Silent))
|
||||||
|
{
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
volTransformThreadFunction (hwndDlg);
|
||||||
|
|
||||||
|
exit (bOperationSuccess? 0 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
SHGetFolderPath (NULL, CSIDL_MYDOCUMENTS, NULL, 0, szRescueDiskISO);
|
SHGetFolderPath (NULL, CSIDL_MYDOCUMENTS, NULL, 0, szRescueDiskISO);
|
||||||
StringCbCatA (szRescueDiskISO, sizeof(szRescueDiskISO), "\\VeraCrypt Rescue Disk.iso");
|
StringCbCatA (szRescueDiskISO, sizeof(szRescueDiskISO), "\\VeraCrypt Rescue Disk.iso");
|
||||||
|
|
||||||
@@ -7102,7 +7300,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
// Check password length (check also done for outer volume which is not the case in TrueCrypt).
|
// Check password length (check also done for outer volume which is not the case in TrueCrypt).
|
||||||
else if (!CheckPasswordLength (hwndDlg, volumePassword.Length, 0, SysEncInEffect(), FALSE))
|
else if (!CheckPasswordLength (hwndDlg, volumePassword.Length, 0, SysEncInEffect(), FALSE, FALSE))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -7181,7 +7379,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
// Check password length (check also done for outer volume which is not the case in TrueCrypt).
|
// Check password length (check also done for outer volume which is not the case in TrueCrypt).
|
||||||
else if (!CheckPasswordLength (hwndDlg, volumePassword.Length, volumePim, SysEncInEffect(), TRUE))
|
else if (!CheckPasswordLength (hwndDlg, volumePassword.Length, volumePim, SysEncInEffect(), TRUE, FALSE))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -8458,6 +8656,16 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
|
|||||||
CommandInplaceDec,
|
CommandInplaceDec,
|
||||||
CommandResumeInplaceDec,
|
CommandResumeInplaceDec,
|
||||||
CommandResumeInplace,
|
CommandResumeInplace,
|
||||||
|
OptionEncryption,
|
||||||
|
OptionFilesystem,
|
||||||
|
OptionPkcs5,
|
||||||
|
OptionPassword,
|
||||||
|
OptionPim,
|
||||||
|
OptionSize,
|
||||||
|
OptionCreate,
|
||||||
|
OptionSilent,
|
||||||
|
OptionDynamic,
|
||||||
|
OptionForce,
|
||||||
};
|
};
|
||||||
|
|
||||||
argument args[]=
|
argument args[]=
|
||||||
@@ -8467,6 +8675,16 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
|
|||||||
{ OptionNoIsoCheck, "/noisocheck", "/n", FALSE },
|
{ OptionNoIsoCheck, "/noisocheck", "/n", FALSE },
|
||||||
{ OptionTokenLib, "/tokenlib", NULL, FALSE },
|
{ OptionTokenLib, "/tokenlib", NULL, FALSE },
|
||||||
{ OptionQuit, "/quit", "/q", FALSE },
|
{ OptionQuit, "/quit", "/q", FALSE },
|
||||||
|
{ OptionEncryption, "/encryption", NULL , FALSE },
|
||||||
|
{ OptionFilesystem, "/filesystem", NULL , FALSE },
|
||||||
|
{ OptionPkcs5, "/hash", NULL , FALSE },
|
||||||
|
{ OptionPassword, "/password", NULL, FALSE },
|
||||||
|
{ OptionPim, "/pim", NULL, FALSE },
|
||||||
|
{ OptionSize, "/size", NULL, FALSE },
|
||||||
|
{ OptionCreate, "/create", NULL, FALSE },
|
||||||
|
{ OptionSilent, "/silent", NULL, FALSE },
|
||||||
|
{ OptionDynamic, "/dynamic", NULL, FALSE },
|
||||||
|
{ OptionForce, "/force", NULL, FALSE },
|
||||||
|
|
||||||
// Internal
|
// Internal
|
||||||
{ CommandResumeSysEncLogOn, "/acsysenc", "/a", TRUE },
|
{ CommandResumeSysEncLogOn, "/acsysenc", "/a", TRUE },
|
||||||
@@ -8496,6 +8714,160 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
|
|||||||
|
|
||||||
switch (x)
|
switch (x)
|
||||||
{
|
{
|
||||||
|
case OptionCreate:
|
||||||
|
{
|
||||||
|
DirectCreationMode = TRUE;
|
||||||
|
|
||||||
|
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs,
|
||||||
|
szFileName, sizeof (szFileName)))
|
||||||
|
{
|
||||||
|
RelativePath2Absolute (szFileName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
AbortProcess ("COMMAND_LINE_ERROR");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case OptionEncryption:
|
||||||
|
{
|
||||||
|
char szTmp[64] = {0};
|
||||||
|
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs,
|
||||||
|
&i, nNoCommandLineArgs, szTmp, sizeof (szTmp)))
|
||||||
|
{
|
||||||
|
CmdVolumeEA = EAGetByName (szTmp);
|
||||||
|
if (CmdVolumeEA == 0)
|
||||||
|
AbortProcess ("COMMAND_LINE_ERROR");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
AbortProcess ("COMMAND_LINE_ERROR");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case OptionFilesystem:
|
||||||
|
{
|
||||||
|
char szTmp[8] = {0};
|
||||||
|
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs,
|
||||||
|
&i, nNoCommandLineArgs, szTmp, sizeof (szTmp)))
|
||||||
|
{
|
||||||
|
if (_stricmp(szTmp, "NONE") == 0)
|
||||||
|
CmdVolumeFilesystem = FILESYS_NONE;
|
||||||
|
else if (_stricmp(szTmp, "FAT32") == 0 || _stricmp(szTmp, "FAT") == 0)
|
||||||
|
CmdVolumeFilesystem = FILESYS_FAT;
|
||||||
|
else if (_stricmp(szTmp, "NTFS") == 0)
|
||||||
|
CmdVolumeFilesystem = FILESYS_NTFS;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AbortProcess ("COMMAND_LINE_ERROR");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
AbortProcess ("COMMAND_LINE_ERROR");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case OptionPassword:
|
||||||
|
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs,
|
||||||
|
(char *) CmdVolumePassword.Text, sizeof (CmdVolumePassword.Text)))
|
||||||
|
{
|
||||||
|
CmdVolumePassword.Length = (unsigned __int32) strlen ((char *) CmdVolumePassword.Text);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
AbortProcess ("COMMAND_LINE_ERROR");
|
||||||
|
break;
|
||||||
|
case OptionPkcs5:
|
||||||
|
{
|
||||||
|
char szTmp[32] = {0};
|
||||||
|
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs,
|
||||||
|
&i, nNoCommandLineArgs, szTmp, sizeof (szTmp)))
|
||||||
|
{
|
||||||
|
if (_stricmp(szTmp, "sha512") == 0 || _stricmp(szTmp, "sha-512") == 0)
|
||||||
|
CmdVolumePkcs5 = SHA512;
|
||||||
|
else if (_stricmp(szTmp, "whirlpool") == 0)
|
||||||
|
CmdVolumePkcs5 = WHIRLPOOL;
|
||||||
|
else if (_stricmp(szTmp, "sha256") == 0 || _stricmp(szTmp, "sha-256") == 0)
|
||||||
|
CmdVolumePkcs5 = SHA256;
|
||||||
|
else if (_stricmp(szTmp, "ripemd160") == 0 || _stricmp(szTmp, "ripemd-160") == 0)
|
||||||
|
CmdVolumePkcs5 = RIPEMD160;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CmdVolumePkcs5 = 0;
|
||||||
|
AbortProcess ("COMMAND_LINE_ERROR");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
AbortProcess ("COMMAND_LINE_ERROR");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OptionPim:
|
||||||
|
{
|
||||||
|
char szTmp[32] = {0};
|
||||||
|
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs,
|
||||||
|
&i, nNoCommandLineArgs, szTmp, sizeof (szTmp)))
|
||||||
|
{
|
||||||
|
char* endPtr = NULL;
|
||||||
|
CmdVolumePim = (int) strtol(szTmp, &endPtr, 0);
|
||||||
|
if (CmdVolumePim < 0 || endPtr == szTmp || *endPtr != '\0')
|
||||||
|
{
|
||||||
|
CmdVolumePim = 0;
|
||||||
|
AbortProcess ("COMMAND_LINE_ERROR");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
AbortProcess ("COMMAND_LINE_ERROR");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case OptionSilent:
|
||||||
|
Silent = TRUE;
|
||||||
|
break;
|
||||||
|
case OptionDynamic:
|
||||||
|
CmdSparseFileSwitch = TRUE;
|
||||||
|
break;
|
||||||
|
case OptionForce:
|
||||||
|
bForceOperation = TRUE;
|
||||||
|
break;
|
||||||
|
case OptionSize:
|
||||||
|
{
|
||||||
|
char szTmp[32] = {0};
|
||||||
|
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs,
|
||||||
|
&i, nNoCommandLineArgs, szTmp, sizeof (szTmp))
|
||||||
|
&& (strlen (szTmp) >= 2)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
/* size can be expressed in bytes or with suffixes K, M,G or T
|
||||||
|
* to indicate the unit to use
|
||||||
|
*/
|
||||||
|
unsigned __int64 multiplier;
|
||||||
|
char* endPtr = NULL;
|
||||||
|
char lastChar = szTmp [strlen (szTmp) - 1];
|
||||||
|
if (lastChar >= '0' && lastChar <= '9')
|
||||||
|
multiplier = 1;
|
||||||
|
else if (lastChar == 'K' || lastChar == 'k')
|
||||||
|
multiplier = BYTES_PER_KB;
|
||||||
|
else if (lastChar == 'M' || lastChar == 'm')
|
||||||
|
multiplier = BYTES_PER_MB;
|
||||||
|
else if (lastChar == 'G' || lastChar == 'g')
|
||||||
|
multiplier = BYTES_PER_GB;
|
||||||
|
else if (lastChar == 'T' || lastChar == 't')
|
||||||
|
multiplier = BYTES_PER_TB;
|
||||||
|
else
|
||||||
|
AbortProcess ("COMMAND_LINE_ERROR");
|
||||||
|
|
||||||
|
if (multiplier != 1)
|
||||||
|
szTmp [strlen (szTmp) - 1] = 0;
|
||||||
|
|
||||||
|
CmdVolumeFileSize = _strtoui64(szTmp, &endPtr, 0);
|
||||||
|
if (CmdVolumeFileSize == 0 || CmdVolumeFileSize == _UI64_MAX
|
||||||
|
|| endPtr == szTmp || *endPtr != '\0')
|
||||||
|
{
|
||||||
|
AbortProcess ("COMMAND_LINE_ERROR");
|
||||||
|
}
|
||||||
|
|
||||||
|
CmdVolumeFileSize *= multiplier;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
AbortProcess ("COMMAND_LINE_ERROR");
|
||||||
|
}
|
||||||
|
break;
|
||||||
case CommandSysEnc:
|
case CommandSysEnc:
|
||||||
// Encrypt system partition/drive (passed by Mount if system encryption hasn't started or to reverse decryption)
|
// Encrypt system partition/drive (passed by Mount if system encryption hasn't started or to reverse decryption)
|
||||||
|
|
||||||
@@ -9693,7 +10065,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, char *lpszComm
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int GetFormatSectorSize ()
|
static DWORD GetFormatSectorSize ()
|
||||||
{
|
{
|
||||||
if (!bDevice)
|
if (!bDevice)
|
||||||
return TC_SECTOR_SIZE_FILE_HOSTED_VOLUME;
|
return TC_SECTOR_SIZE_FILE_HOSTED_VOLUME;
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ static void WipeAbort (void);
|
|||||||
static void UpdateWipeProgressBar (void);
|
static void UpdateWipeProgressBar (void);
|
||||||
static void InitWipeProgressBar (void);
|
static void InitWipeProgressBar (void);
|
||||||
static void UpdateWipeControls (void);
|
static void UpdateWipeControls (void);
|
||||||
static int GetFormatSectorSize ();
|
static DWORD GetFormatSectorSize ();
|
||||||
|
|
||||||
extern BOOL showKeys;
|
extern BOOL showKeys;
|
||||||
extern volatile HWND hMasterKey;
|
extern volatile HWND hMasterKey;
|
||||||
|
|||||||
@@ -2457,7 +2457,7 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
|
|||||||
else if (!(newKeyFilesParam.EnableKeyFiles && newKeyFilesParam.FirstKeyFile != NULL)
|
else if (!(newKeyFilesParam.EnableKeyFiles && newKeyFilesParam.FirstKeyFile != NULL)
|
||||||
&& pwdChangeDlgMode == PCDM_CHANGE_PASSWORD)
|
&& pwdChangeDlgMode == PCDM_CHANGE_PASSWORD)
|
||||||
{
|
{
|
||||||
if (!CheckPasswordLength (hwndDlg, GetWindowTextLength(GetDlgItem (hwndDlg, IDC_PASSWORD)), pim, bSysEncPwdChangeDlgMode, FALSE))
|
if (!CheckPasswordLength (hwndDlg, GetWindowTextLength(GetDlgItem (hwndDlg, IDC_PASSWORD)), pim, bSysEncPwdChangeDlgMode, FALSE, FALSE))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user