diff options
-rw-r--r-- | src/Format/Format.rc | 7 | ||||
-rw-r--r-- | src/Format/Resource.h | 5 | ||||
-rw-r--r-- | src/Format/Tcformat.c | 70 |
3 files changed, 55 insertions, 27 deletions
diff --git a/src/Format/Format.rc b/src/Format/Format.rc index f42480ac..b98c5bd2 100644 --- a/src/Format/Format.rc +++ b/src/Format/Format.rc @@ -154,7 +154,7 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN COMBOBOX IDC_FILESYS,43,13,36,90,CBS_DROPDOWNLIST | WS_TABSTOP COMBOBOX IDC_CLUSTERSIZE,112,13,42,90,CBS_DROPDOWNLIST | WS_TABSTOP - CONTROL "Quick Format",IDC_QUICKFORMAT,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,163,11,60,18 + CONTROL "Quick Format",IDC_QUICKFORMAT,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,163,9,60,8 CONTROL "",IDC_SHOW_KEYS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,214,38,9,8 PUSHBUTTON "Abort",IDC_ABORT_BUTTON,169,75,50,14 RTEXT "Header Key: ",IDT_HEADER_KEY,2,47,54,8 @@ -178,6 +178,7 @@ BEGIN CONTROL "",IDC_RANDOM_BYTES,"Static",SS_SIMPLE | WS_GROUP,57,38,155,8,WS_EX_TRANSPARENT GROUPBOX "Randomness Collected From Mouse Movements",IDT_ENTROPY_BAR,0,153,224,18 CONTROL "",IDC_ENTROPY_BAR,"msctls_progress32",WS_BORDER,11,162,202,6 + CONTROL "Dynamic",SPARSE_FILE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,163,21,60,8 END IDD_INTRO_PAGE_DLG DIALOGEX 0, 0, 226, 172 @@ -486,7 +487,7 @@ END // #ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO +GUIDELINES DESIGNINFO BEGIN IDD_VOL_CREATION_WIZARD_DLG, DIALOG BEGIN @@ -725,7 +726,7 @@ IDB_WIZARD BITMAP "VeraCrypt_wizard.bmp" // String Table // -STRINGTABLE +STRINGTABLE BEGIN IDS_UACSTRING_FMT "VeraCrypt" END diff --git a/src/Format/Resource.h b/src/Format/Resource.h index 1bdc2f5c..c37a6f4a 100644 --- a/src/Format/Resource.h +++ b/src/Format/Resource.h @@ -145,15 +145,16 @@ #define IDC_SHOW_PIM 1106 #define IDC_TB 1107 #define IDC_SKIP_RESCUE_VERIFICATION 1108 +#define SPARSE_FILE 1109 // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NO_MFC 1 #define _APS_NEXT_RESOURCE_VALUE 134 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1109 +#define _APS_NEXT_CONTROL_VALUE 1110 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/src/Format/Tcformat.c b/src/Format/Tcformat.c index 5f77c770..128f927f 100644 --- a/src/Format/Tcformat.c +++ b/src/Format/Tcformat.c @@ -281,7 +281,8 @@ wchar_t outRandPoolDispBuffer [RANDPOOL_DISPLAY_SIZE]; BOOL bDisplayPoolContents = TRUE; volatile BOOL bSparseFileSwitch = FALSE; -volatile BOOL quickFormat = FALSE; /* WARNING: Meaning of this variable depends on bSparseFileSwitch. If bSparseFileSwitch is TRUE, this variable represents the sparse file flag. */ +volatile BOOL quickFormat = FALSE; +volatile BOOL dynamicFormat = FALSE; /* this variable represents the sparse file flag. */ volatile int fileSystem = FILESYS_NONE; volatile int clusterSize = 0; @@ -2632,7 +2633,7 @@ static void __cdecl volTransformThreadFunction (void *hwndDlgArg) volParams->headerFlags = (CreatingHiddenSysVol() ? TC_HEADER_FLAG_ENCRYPTED_SYSTEM : 0); volParams->fileSystem = fileSystem; volParams->clusterSize = clusterSize; - volParams->sparseFileSwitch = bSparseFileSwitch; + volParams->sparseFileSwitch = dynamicFormat; volParams->quickFormat = quickFormat; volParams->sectorSize = GetFormatSectorSize(); volParams->realClusterSize = &realClusterSize; @@ -2821,7 +2822,7 @@ static void __cdecl volTransformThreadFunction (void *hwndDlgArg) { Info("FORMAT_FINISHED_INFO", hwndDlg); - if (bSparseFileSwitch && quickFormat) + if (dynamicFormat) Warning("SPARSE_FILE_SIZE_NOTE", hwndDlg); } } @@ -4934,18 +4935,23 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa if (bHiddenVol) { quickFormat = !bHiddenVolHost; + dynamicFormat = FALSE; bSparseFileSwitch = FALSE; + SetCheckBox (hwndDlg, SPARSE_FILE, FALSE); + EnableWindow (GetDlgItem (hwndDlg, SPARSE_FILE), FALSE); + SetCheckBox (hwndDlg, IDC_QUICKFORMAT, quickFormat); - SetWindowTextW (GetDlgItem (hwndDlg, IDC_QUICKFORMAT), GetString ((bDevice || !bHiddenVolHost) ? "IDC_QUICKFORMAT" : "SPARSE_FILE")); - EnableWindow (GetDlgItem (hwndDlg, IDC_QUICKFORMAT), bDevice && bHiddenVolHost); + EnableWindow (GetDlgItem (hwndDlg, IDC_QUICKFORMAT), bHiddenVolHost); } else { if (bDevice) { + dynamicFormat = FALSE; bSparseFileSwitch = FALSE; - SetWindowTextW (GetDlgItem (hwndDlg, IDC_QUICKFORMAT), GetString("IDC_QUICKFORMAT")); + SetCheckBox (hwndDlg, SPARSE_FILE, FALSE); + EnableWindow (GetDlgItem (hwndDlg, SPARSE_FILE), FALSE); EnableWindow (GetDlgItem (hwndDlg, IDC_QUICKFORMAT), TRUE); } else @@ -4953,8 +4959,6 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa wchar_t root[TC_MAX_PATH]; DWORD fileSystemFlags = 0; - SetWindowTextW (GetDlgItem (hwndDlg, IDC_QUICKFORMAT), GetString("SPARSE_FILE")); - /* Check if the host file system supports sparse files */ if (GetVolumePathName (szFileName, root, array_capacity (root))) @@ -4964,8 +4968,13 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } else bSparseFileSwitch = FALSE; - - EnableWindow (GetDlgItem (hwndDlg, IDC_QUICKFORMAT), bSparseFileSwitch); + if (!bSparseFileSwitch) + { + dynamicFormat = FALSE; + SetCheckBox (hwndDlg, SPARSE_FILE, FALSE); + } + EnableWindow (GetDlgItem (hwndDlg, SPARSE_FILE), bSparseFileSwitch); + EnableWindow (GetDlgItem (hwndDlg, IDC_QUICKFORMAT), TRUE); } } @@ -5866,6 +5875,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa bHiddenVolHost = FALSE; bSparseFileSwitch = FALSE; quickFormat = FALSE; + dynamicFormat = FALSE; return 1; } @@ -5904,17 +5914,29 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } - if (lw == IDC_QUICKFORMAT && IsButtonChecked (GetDlgItem (hCurPage, IDC_QUICKFORMAT))) + if (lw == IDC_QUICKFORMAT) { - if (bSparseFileSwitch) + if (IsButtonChecked (GetDlgItem (hCurPage, IDC_QUICKFORMAT))) { - if (AskWarnYesNo("CONFIRM_SPARSE_FILE", MainDlg) == IDNO) + if (AskWarnYesNo("WARN_QUICK_FORMAT", MainDlg) == IDNO) SetCheckBox (hwndDlg, IDC_QUICKFORMAT, FALSE); } - else + else if (IsButtonChecked (GetDlgItem (hCurPage, SPARSE_FILE))) { - if (AskWarnYesNo("WARN_QUICK_FORMAT", MainDlg) == IDNO) - SetCheckBox (hwndDlg, IDC_QUICKFORMAT, FALSE); + /* sparse file require quick format */ + SetCheckBox (hwndDlg, SPARSE_FILE, FALSE); + } + return 1; + } + + if (lw == SPARSE_FILE && IsButtonChecked (GetDlgItem (hCurPage, SPARSE_FILE))) + { + if (AskWarnYesNo("CONFIRM_SPARSE_FILE", MainDlg) == IDNO) + SetCheckBox (hwndDlg, SPARSE_FILE, FALSE); + else if (!IsButtonChecked (GetDlgItem (hCurPage, IDC_QUICKFORMAT)) && IsWindowEnabled (GetDlgItem (hCurPage, IDC_QUICKFORMAT))) + { + /* sparse file require quick format */ + SetCheckBox (hwndDlg, IDC_QUICKFORMAT, TRUE); } return 1; } @@ -6194,6 +6216,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } quickFormat = CmdQuickFormat; + dynamicFormat = CmdSparseFileSwitch; if (!GetDiskFreeSpaceEx (root, &free, 0, 0)) { @@ -6214,7 +6237,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } else { - if (!bSparseFileSwitch && (nVolumeSize > free.QuadPart)) + if (!dynamicFormat && (nVolumeSize > free.QuadPart)) { AbortProcess ("ERR_CONTAINER_SIZE_TOO_BIG"); } @@ -6801,7 +6824,8 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa { // Format has been aborted (did not finish) - EnableWindow (GetDlgItem (hCurPage, IDC_QUICKFORMAT), (bDevice || bSparseFileSwitch) && !(bHiddenVol && !bHiddenVolHost)); + EnableWindow (GetDlgItem (hCurPage, IDC_QUICKFORMAT), !(bHiddenVol && !bHiddenVolHost)); + EnableWindow (GetDlgItem (hCurPage, SPARSE_FILE), (bSparseFileSwitch) && !(bHiddenVol && !bHiddenVolHost)); EnableWindow (GetDlgItem (hCurPage, IDC_FILESYS), TRUE); EnableWindow (GetDlgItem (hCurPage, IDC_CLUSTERSIZE), TRUE); EnableWindow (GetDlgItem (hwndDlg, IDC_PREV), TRUE); @@ -8354,8 +8378,9 @@ retryCDDriveCheck: SendMessage (GetDlgItem (hCurPage, IDC_CLUSTERSIZE), CB_GETCURSEL, 0, 0) , 0); quickFormat = IsButtonChecked (GetDlgItem (hCurPage, IDC_QUICKFORMAT)); + dynamicFormat = IsButtonChecked (GetDlgItem (hCurPage, SPARSE_FILE)); - if (!quickFormat && !bDevice && !(bHiddenVol && !bHiddenVolHost) && (nVolumeSize > (ULONGLONG) nAvailableFreeSpace)) + if (!dynamicFormat && !bDevice && !(bHiddenVol && !bHiddenVolHost) && (nVolumeSize > (ULONGLONG) nAvailableFreeSpace)) { Error("VOLUME_TOO_LARGE_FOR_HOST", hwndDlg); bVolTransformThreadToRun = FALSE; @@ -8439,9 +8464,9 @@ retryCDDriveCheck: } else if (bHiddenVol) { - // Hidden volume is always quick-formatted (if, however, the meaning of quickFormat is - // whether to create a sparse file, it must be set to FALSE). - quickFormat = !bSparseFileSwitch; + // Hidden volume is always quick-formatted. + quickFormat = TRUE; + dynamicFormat = FALSE; } @@ -8458,6 +8483,7 @@ retryCDDriveCheck: EnableWindow (GetDlgItem (hwndDlg, IDHELP), FALSE); EnableWindow (GetDlgItem (hwndDlg, IDCANCEL), FALSE); EnableWindow (GetDlgItem (hCurPage, IDC_QUICKFORMAT), FALSE); + EnableWindow (GetDlgItem (hCurPage, SPARSE_FILE), FALSE); EnableWindow (GetDlgItem (hCurPage, IDC_CLUSTERSIZE), FALSE); EnableWindow (GetDlgItem (hCurPage, IDC_FILESYS), FALSE); EnableWindow (GetDlgItem (hCurPage, IDC_ABORT_BUTTON), TRUE); |