From 1c51a76c7eab117bb6c74a3897a6df8197945c90 Mon Sep 17 00:00:00 2001 From: Bruna2803 Date: Wed, 5 May 2021 01:06:24 +0200 Subject: New VeraCrypt interface (for system encryption) with improved usability --- src/Format/Format.rc | 160 ++++-- src/Format/Resource.h | 33 +- src/Format/Tcformat.c | 1331 +++++++++++++++++++++++++++++++++++++++---------- src/Format/Tcformat.h | 19 +- 4 files changed, 1220 insertions(+), 323 deletions(-) (limited to 'src/Format') diff --git a/src/Format/Format.rc b/src/Format/Format.rc index a83c5a99..4e7aebe8 100644 --- a/src/Format/Format.rc +++ b/src/Format/Format.rc @@ -85,13 +85,13 @@ CAPTION "VeraCrypt Volume Creation Wizard" CLASS "VeraCryptCustomDlg" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - PUSHBUTTON "&Help",IDHELP,166,234,60,14 - PUSHBUTTON "",IDC_PREV,238,234,60,14 - DEFPUSHBUTTON "",IDC_NEXT,310,234,60,14 + PUSHBUTTON "&Documentation",IDHELP,166,234,60,14 + PUSHBUTTON "",IDC_PREV,243,234,60,14 + DEFPUSHBUTTON "",IDC_NEXT,305,234,60,14 PUSHBUTTON "Cancel",IDCANCEL,382,234,60,14 - LTEXT "",IDC_BOX_TITLE,160,8,283,17 - GROUPBOX "",IDC_STATIC,4,0,439,230 - CONTROL 116,IDC_BITMAP_WIZARD,"Static",SS_BITMAP | SS_SUNKEN,10,9,137,193 + LTEXT "",IDC_BOX_TITLE,160,10,283,40 + GROUPBOX "",IDC_STATIC,4,0,440,230 + CONTROL 116,IDC_BITMAP_WIZARD,"Static",SS_BITMAP | SS_SUNKEN,10,18,137,200 LTEXT "",IDC_POS_BOX,160,24,281,193 END @@ -99,10 +99,10 @@ IDD_CIPHER_PAGE_DLG DIALOGEX 0, 0, 276, 193 STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN + COMBOBOX IDC_COMBO_BOX_HASH_ALGO,7,169,95,126,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_COMBO_BOX,7,23,172,126,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "&Test",IDC_CIPHER_TEST,191,22,81,14 PUSHBUTTON "&Benchmark",IDC_BENCHMARK,191,122,81,14 - COMBOBOX IDC_COMBO_BOX_HASH_ALGO,7,169,95,126,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "",IDC_BOX_HELP,7,40,266,78 GROUPBOX "Encryption Algorithm",IDT_ENCRYPTION_ALGO,0,10,273,131 GROUPBOX "Hash Algorithm",IDT_HASH_ALGO,0,156,273,35 @@ -114,15 +114,17 @@ IDD_PASSWORD_PAGE_DLG DIALOGEX 0, 0, 276, 193 STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - EDITTEXT IDC_PASSWORD,71,3,202,14,ES_PASSWORD | ES_AUTOHSCROLL - EDITTEXT IDC_VERIFY,71,19,202,14,ES_PASSWORD | ES_AUTOHSCROLL - CONTROL "U&se keyfiles",IDC_KEYFILES_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,71,35,103,10 - PUSHBUTTON "&Keyfiles...",IDC_KEY_FILES,182,36,91,14,WS_DISABLED - CONTROL "&Display password",IDC_SHOW_PASSWORD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,71,45,108,11,WS_EX_TRANSPARENT - CONTROL "Use P&IM",IDC_PIM_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,71,56,114,10 - RTEXT "Password:",IDT_PASSWORD,1,6,68,8 - RTEXT "&Confirm:",IDT_CONFIRM,1,23,68,8 - LTEXT "",IDC_BOX_HELP,0,71,273,121 + EDITTEXT IDC_PASSWORD,69,3,202,14,ES_PASSWORD | ES_AUTOHSCROLL + EDITTEXT IDC_VERIFY,69,20,202,14,ES_PASSWORD | ES_AUTOHSCROLL + LTEXT "Password strength: ", IDT_PASSWORD_STRENGTH, 71, 55, 70, 20 + LTEXT "", PASSWORDMETER, 140, 55, 50, 20 + CONTROL "&Display password",IDC_SHOW_PASSWORD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,71,43,108,11,WS_EX_TRANSPARENT + RTEXT "Password:", IDT_PASSWORD, 1, 6, 40, 8 + RTEXT "&Confirm:", IDT_CONFIRM, 1, 23, 40, 8 + LTEXT "Please choose a password that is indicated as 'very strong' but at least 'medium'. \n\nKeep in mind that if you forget your password, there is no possibility to get access to your encrypted data.", IDT_PASSWORD_HELP, 1, 93, 270, 60 + PUSHBUTTON "Advanced features", IDC_ADVANCE, 203, 156, 68, 14 + CONTROL "",IDC_SYS_POOL_CONTENTS,"Static",SS_LEFTNOWORDWRAP | WS_GROUP | NOT WS_VISIBLE,33,17,209,63,WS_EX_TRANSPARENT + CONTROL "", IDC_ENTROPY_BAR, "msctls_progress32", WS_BORDER | NOT WS_VISIBLE, 11, 140, 202, 6 END IDD_SIZE_PAGE_DLG DIALOGEX 0, 0, 276, 193 @@ -202,7 +204,7 @@ IDD_INFO_PAGE_DLG DIALOGEX 0, 0, 276, 193 STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - LTEXT "",IDC_BOX_HELP,0,31,269,155 + LTEXT "",IDC_BOX_HELP,0,15,267,155 END IDD_HIDVOL_HOST_FILL_PAGE_DLG DIALOGEX 0, 0, 276, 193 @@ -267,11 +269,12 @@ IDD_SYSENC_RESCUE_DISK_CREATION_DLG DIALOGEX 0, 0, 276, 193 STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - EDITTEXT IDC_RESCUE_DISK_ISO_PATH,0,180,201,13,ES_AUTOHSCROLL - PUSHBUTTON "Bro&wse...",IDC_BROWSE,204,179,70,14 - LTEXT "",IDT_RESCUE_DISK_INFO,0,1,273,137 + EDITTEXT IDC_RESCUE_DISK_ISO_PATH, 0, 159, 180, 13, ES_AUTOHSCROLL + PUSHBUTTON "Bro&wse...",IDC_BROWSE,185,159,70,14 + LTEXT "",IDT_RESCUE_DISK_INFO,0,1,266,137 + LTEXT "",IDT_RESCUE_DISK_INFO_2,0,135,266,20 CONTROL "Skip Rescue Disk verification",IDC_SKIP_RESCUE_VERIFICATION, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,0,166,273,10 + "Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,0,166,273,10 END IDD_SYSENC_COLLECTING_RANDOM_DATA_DLG DIALOGEX 0, 0, 276, 193 @@ -296,41 +299,50 @@ BEGIN LTEXT "Select this option if there are two or more operating systems installed on this computer.\n\nFor example:\n- Windows XP and Windows XP\n- Windows XP and Windows Vista\n- Windows and Mac OS X\n- Windows and Linux\n- Windows, Linux and Mac OS X",IDT_MULTI_BOOT,16,89,253,90 END + IDD_SYSENC_RESCUE_DISK_BURN_PAGE_DLG DIALOGEX 0, 0, 276, 193 STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - LTEXT "Download CD/DVD recording software",IDC_DOWNLOAD_CD_BURN_SOFTWARE,0,159,273,10,SS_NOTIFY - LTEXT "",IDT_RESCUE_DISK_BURN_INFO,0,4,273,148 + LTEXT "",IDT_RESCUE_DISK_BURN_INFO,0,15,275,170 + //EDITTEXT IDC_EMAIL, 0, 150, 150, 14, ES_AUTOHSCROLL// + //PUSHBUTTON "Send", IDC_SENDMAILBUTTON, 160, 150, 30, 16, END IDD_SYSENC_WIPE_MODE_PAGE_DLG DIALOGEX 0, 0, 276, 193 STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - COMBOBOX IDC_WIPE_MODE,88,0,138,90,CBS_DROPDOWNLIST | WS_TABSTOP - RTEXT "Wipe mode:",IDT_WIPE_MODE,0,2,83,8,0,WS_EX_RIGHT - LTEXT "",IDT_WIPE_MODE_INFO,0,19,269,167 + CONTROL "A", IDC_CHECKLIST_A, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 0, 13, 10, 10 + CONTROL "B", IDC_CHECKLIST_B, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 0, 60, 10, 10 + CONTROL "C", IDC_CHECKLIST_C, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 0, 120, 10, 10 + LTEXT " I remember my Password", IDC_REMEMBER_PASSWORD, 11, 13, 212, 10 + LTEXT " I securely stored the Rescue Disk", IDC_STORE_RESCUE_DISK, 11, 60, 217, 10 + LTEXT " I considered doing a backup of my personal Data", IDC_BACKUP_DATA, 11, 120, 226, 10 + LTEXT "", IDT_REMEMBER_PASSWORD, 16, 26, 205, 32 + LTEXT "", IDT_STORE_RESCUE_DISK, 16, 73, 205, 43 + LTEXT "", IDT_BACKUP_DATA, 16, 131, 205, 72 + LTEXT "", IDT_WIPE_MODE_INFO, 0, 19, 225, 128, NOT WS_VISIBLE END IDD_INPLACE_ENCRYPTION_PAGE_DLG DIALOGEX 0, 0, 276, 193 STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - COMBOBOX IDC_WIPE_MODE,96,13,125,90,CBS_DROPDOWNLIST | WS_TABSTOP - PUSHBUTTON "&Pause",IDC_PAUSE,204,40,63,14 - LTEXT "More information",IDC_MORE_INFO_SYS_ENCRYPTION,1,176,266,10,SS_NOTIFY - LTEXT "",IDC_BYTESWRITTEN,29,58,39,11,SS_CENTERIMAGE,WS_EX_TRANSPARENT | WS_EX_RIGHT | WS_EX_STATICEDGE - RTEXT "",IDC_WRITESPEED,110,58,56,11,SS_CENTERIMAGE,WS_EX_TRANSPARENT | WS_EX_RIGHT | WS_EX_STATICEDGE - RTEXT "",IDC_TIMEREMAIN,212,58,54,11,SS_CENTERIMAGE,WS_EX_TRANSPARENT | WS_EX_RIGHT | WS_EX_STATICEDGE - RTEXT "Wipe mode:",IDT_WIPE_MODE,6,15,85,8,0,WS_EX_RIGHT - CONTROL "",IDC_PROGRESS_BAR,"msctls_progress32",PBS_SMOOTH | WS_BORDER,6,41,192,12 - RTEXT "Done",IDT_DONE,5,59,22,8 - RTEXT "Status",IDT_STATUS,73,59,33,8 - RTEXT "Left",IDT_LEFT,172,59,35,8 + COMBOBOX IDC_WIPE_MODE,96,60,125,90,CBS_DROPDOWNLIST | WS_TABSTOP + PUSHBUTTON "&Pause",IDC_PAUSE,204,8,63,14 + LTEXT "More information",IDC_MORE_INFO_SYS_ENCRYPTION,1,176,266,10,SS_NOTIFY | NOT WS_VISIBLE + LTEXT "",IDC_BYTESWRITTEN,29,26,39,11,SS_CENTERIMAGE,WS_EX_TRANSPARENT | WS_EX_RIGHT | WS_EX_STATICEDGE + RTEXT "",IDC_WRITESPEED,110,26,56,11,SS_CENTERIMAGE,WS_EX_TRANSPARENT | WS_EX_RIGHT | WS_EX_STATICEDGE + RTEXT "",IDC_TIMEREMAIN,212,26,54,11,SS_CENTERIMAGE,WS_EX_TRANSPARENT | WS_EX_RIGHT | WS_EX_STATICEDGE + RTEXT "Wipe mode:",IDT_WIPE_MODE,6,62,85,8,0,WS_EX_RIGHT + CONTROL "",IDC_PROGRESS_BAR,"msctls_progress32",PBS_SMOOTH | WS_BORDER,6,9,192,12 + RTEXT "Done",IDT_DONE,5,27,22,8 + RTEXT "Status",IDT_STATUS,73,27,33,8 + RTEXT "Left",IDT_LEFT,172,27,35,8 LTEXT "",IDC_BOX_HELP,1,77,266,95 - GROUPBOX "Options",IDT_FORMAT_OPTIONS,0,3,267,29 - GROUPBOX "",IDC_STATIC,0,32,267,41 + GROUPBOX "",IDC_STATIC,0,3,268,41 + GROUPBOX "Options",IDT_FORMAT_OPTIONS,0,50,268,29 END IDD_SYSENC_KEYS_GEN_PAGE_DLG DIALOGEX 0, 0, 276, 193 @@ -365,15 +377,34 @@ BEGIN LTEXT "Progress:",IDT_PROGRESS,2,124,172,8 END + IDD_SYSENC_TYPE_PAGE_DLG DIALOGEX 0, 0, 276, 193 STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - CONTROL "Normal",IDC_SYSENC_NORMAL,"Button",BS_AUTORADIOBUTTON,0,7,269,10 - CONTROL "Hi&dden",IDC_SYSENC_HIDDEN,"Button",BS_AUTORADIOBUTTON,0,64,269,10 - LTEXT "More information",IDC_HIDDEN_SYSENC_INFO_LINK,16,173,253,10,SS_NOTIFY - LTEXT "",IDC_BOX_HELP_SYSENC_NORMAL,16,20,253,41 - LTEXT "",IDC_BOX_HELP,16,78,253,90 + LTEXT "This configuration tool will guide you to create a drive (C:) system encryption.", IDT_FILE_CONTAINER, 5, 20, 250, 16 + LTEXT "After the configuration, the computer has to be restarted and VeraCrypt will start automatically. But no changes will be made on your system before you press 'Encrypt' at the last page after the restart.", -1, 5, 50, 250, 60 + LTEXT "",ADVANCED_NOTE, 5, 120, 250, 33, + PUSHBUTTON "Advanced features", IDC_ADVANCE_INTRO, 190, 160, 68, 14 + CONTROL "", IDC_INFORMATION_TIP, "Static", SS_ICON | SS_NOTIFY, 262,163,10,5 +END + +IDD_ADVANCE_MBR DIALOGEX 102, -10, 245, 233 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Advanced Options" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + CONTROL " Normal",IDC_SYSENC_NORMAL,"Button", BS_AUTOCHECKBOX, 10,40,200,10 + CONTROL " Hi&dden",IDC_SYSENC_HIDDEN,"Button", BS_AUTOCHECKBOX, 10,99,200,10 + LTEXT "Select this option if you merely want to encrypt the system partition or the entire system drive.",-1,26,57,200,30 + LTEXT "If you select this option, you will create a hidden operating system whose existence should be impossible to prove (provided that certain guidelines are followed). Thus, you will not have to decrypt or reveal the password to the hidden operating system.",-1,26,116,200,50 + LTEXT "For a detailed explanation, please click the Help button. ",-1,26,180,200,10 + LTEXT "IMPORTANT: Only advanced users should make modifications on this page.", -1, 10, 12, 217, 19, + + GROUPBOX "", -1, 6, 30, 232, 178 + DEFPUSHBUTTON "OK", IDOK, 129, 213, 50, 14 + PUSHBUTTON "Cancel", IDCANCEL, 180, 213, 50, 14 + PUSHBUTTON "&Help",IDHELP,15,213,50,14 END IDD_SYSENC_HIDDEN_OS_REQ_CHECK_PAGE_DLG DIALOGEX 0, 0, 276, 193 @@ -453,6 +484,31 @@ BEGIN CONTROL "Display PIM",IDC_SHOW_PIM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,74,17,196,10 END +IDD_ADVANCE DIALOGEX 75, -39, 245, 333 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Advanced Algorithm Options" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + DEFPUSHBUTTON "OK", IDOK, 129, 313, 50, 14 + PUSHBUTTON "Cancel", IDCANCEL, 180, 313, 50, 14 + COMBOBOX IDC_COMBO_BOX_HASH_ALGO, 21, 53, 137, 126, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "", IDC_SHA512_HELP, 21, 72, 205, 40 + COMBOBOX IDC_COMBO_BOX, 21, 120, 137, 126, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "", IDC_BOX_HELP, 21, 137, 205, 40 + PUSHBUTTON "&Test", IDC_CIPHER_TEST, 163, 120, 59, 14 + PUSHBUTTON "&Benchmark", IDC_BENCHMARK, 163, 150, 59, 14, BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE + GROUPBOX "Encryption Algorithm", IDT_ENCRYPTION_ALGO, 14, 107, 217, 65 + GROUPBOX "Hash Algorithm", IDT_HASH_ALGO, 14, 40, 217, 55 + GROUPBOX "PIM", -1, 14, 180, 217, 59 + CONTROL "Use P&IM", IDC_PIM_ENABLE, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 19, 189, 97, 10 + LTEXT "A PIM is an additional secret to the password. It can be used to influence the decryption speed.", -1, 21, 205, 203, 25 + + GROUPBOX "Wipe Mode", IDT_WIPE_MODE, 14, 245, 217, 60 + COMBOBOX IDC_WIPE_MODE, 21, 260, 127, 90, CBS_DROPDOWNLIST | WS_TABSTOP + LTEXT "The wipe mode is used to override your data before the encryption prenventing possible data recovery.", -1, 21, 278, 200, 20, + LTEXT "IMPORTANT: Only advanced users should make modifications on this page.", -1, 21, 11, 217, 19, + +END #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// @@ -623,6 +679,22 @@ BEGIN HORZGUIDE, 96 END + IDD_ADVANCE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 238 + TOPMARGIN, 7 + BOTTOMMARGIN, 242 + END + + IDD_ADVANCE_MBR, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 238 + TOPMARGIN, 7 + BOTTOMMARGIN, 242 + END + IDD_SYSENC_KEYS_GEN_PAGE_DLG, DIALOG BEGIN RIGHTMARGIN, 267 diff --git a/src/Format/Resource.h b/src/Format/Resource.h index c37a6f4a..4f0af995 100644 --- a/src/Format/Resource.h +++ b/src/Format/Resource.h @@ -145,16 +145,43 @@ #define IDC_SHOW_PIM 1106 #define IDC_TB 1107 #define IDC_SKIP_RESCUE_VERIFICATION 1108 -#define SPARSE_FILE 1109 +#define SPARSE_FILE 1109 +#define IDC_ADVANCE_INTRO 1110 //Advanced Button in the intro page +#define IDC_ADVANCE_PW 1111 +#define IDC_HIDE_PW 1112 //Path to hide bmp +#define IDC_HIDE_CFM 1113 +#define HIDDEN_EYE_BUTTON 1114 //Hide Button in password page +#define IDD_ADVANCE 1115 //Advanced password page identifier +#define IDC_ADVANCE 1116 //Advanced Button in the password page +#define PASSWORDMETER 1117 +#define IDC_EMAIL 1118 +#define IDC_SENDMAILBUTTON 1119 +#define IDC_REMEMBER_PASSWORD 1120 +#define IDC_STORE_RESCUE_DISK 1121 +#define IDC_BACKUP_DATA 1122 +#define IDT_REMEMBER_PASSWORD 1123 +#define IDT_STORE_RESCUE_DISK 1124 +#define IDT_BACKUP_DATA 1125 +#define IDC_CHECKLIST_A 1126 +#define IDC_CHECKLIST_B 1127 +#define IDC_CHECKLIST_C 1128 +#define ADVANCED_NOTE 1129 +#define IDD_ADVANCE_MBR 1130 +#define IDC_INFORMATION_TIP 1131 +#define IDC_SHA512_HELP 1132 +#define IDT_PASSWORD_STRENGTH 1133 +#define IDT_PASSWORD_HELP 1134 +#define IDT_RESCUE_DISK_INFO_2 1135 + // 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 1110 +#define _APS_NEXT_CONTROL_VALUE 1109 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/src/Format/Tcformat.c b/src/Format/Tcformat.c index f12a0777..842646f7 100644 --- a/src/Format/Tcformat.c +++ b/src/Format/Tcformat.c @@ -13,6 +13,10 @@ #include "Tcdefs.h" +#include +#include +#include +#include #include #include #include @@ -20,6 +24,7 @@ #include #include #include +#include #include "Crypto.h" #include "cpu.h" @@ -127,6 +132,15 @@ enum sys_encryption_cmd_line_switches SYSENC_COMMAND_CREATE_HIDDEN_OS, SYSENC_COMMAND_CREATE_HIDDEN_OS_ELEV }; + +enum password_status +{ + very_weak = 0, + weak, + medium, + strong, + very_strong +}; typedef struct { @@ -149,7 +163,19 @@ BootEncryptionStatus BootEncStatus; HWND hCurPage = NULL; /* Handle to current wizard page */ int nCurPageNo = -1; /* The current wizard page */ int nLastPageNo = -1; -volatile int WizardMode = DEFAULT_VOL_CREATION_WIZARD_MODE; /* IMPORTANT: Never change this value directly -- always use ChangeWizardMode() instead. */ + +int iIconX=0; +int iIconY=0; +HWND hDlgItemTooltip = NULL; +HANDLE hIconTooltip = NULL; + +volatile int WizardMode = WIZARD_MODE_SYS_DEVICE; /* IMPORTANT: Never change this value directly -- always use ChangeWizardMode() instead. */ +char tmp_password[127]; +int pw_strength; +bool passwordAcceptable = false; +char mailAdressRcv[128]; +bool emailExists = false; + volatile BOOL bHiddenOS = FALSE; /* If TRUE, we are performing or (or supposed to perform) actions relating to an operating system installed in a hidden volume (i.e., encrypting a decoy OS partition or creating the outer/hidden volume for the hidden OS). To determine or set the phase of the process, call ChangeHiddenOSCreationPhase() and DetermineHiddenOSCreationPhase()) */ BOOL bDirectSysEncMode = FALSE; BOOL bDirectSysEncModeCommand = SYSENC_COMMAND_NONE; @@ -166,7 +192,8 @@ volatile BOOL bInPlaceEncNonSysResumed = FALSE; /* If TRUE, the wizard is suppos volatile BOOL bFirstNonSysInPlaceEncResumeDone = FALSE; __int64 NonSysInplaceEncBytesDone = 0; __int64 NonSysInplaceEncTotalSize = 0; -BOOL bDeviceTransformModeChoiceMade = FALSE; /* TRUE if the user has at least once manually selected the 'in-place' or 'format' option (on the 'device transform mode' page). */ + +BOOL bDeviceTransformModeChoiceMade = TRUE; /* TRUE if the user has at least once manually selected the 'in-place' or 'format' option (on the 'device transform mode' page). */ int nNeedToStoreFilesOver4GB = 0; /* Whether the user wants to be able to store files larger than 4GB on the volume: -1 = Undecided or error, 0 = No, 1 = Yes */ int nVolumeEA = 1; /* Default encryption algorithm */ BOOL bSystemEncryptionInProgress = FALSE; /* TRUE when encrypting/decrypting the system partition/drive (FALSE when paused). */ @@ -176,10 +203,12 @@ volatile BOOL bSysEncDriveAnalysisInProgress = FALSE; volatile BOOL bSysEncDriveAnalysisTimeOutOccurred = FALSE; int SysEncDetectHiddenSectors = -1; /* Whether the user wants us to detect and encrypt the Host Protect Area (if any): -1 = Undecided or error, 0 = No, 1 = Yes */ int SysEncDriveAnalysisStart; -BOOL bDontVerifyRescueDisk = FALSE; +BOOL bDontVerifyRescueDisk = TRUE; // TODO, for now always skip the 'Verification' BOOL bFirstSysEncResumeDone = FALSE; BOOL bDontCheckFileContainerSize = FALSE; /* If true, we don't check if the given size of file container is smaller than the available size on the hosting disk */ + int nMultiBoot = 0; /* The number of operating systems installed on the computer, according to the user. 0: undetermined, 1: one, 2: two or more */ + volatile BOOL bHiddenVol = FALSE; /* If true, we are (or will be) creating a hidden volume. */ volatile BOOL bHiddenVolHost = FALSE; /* If true, we are (or will be) creating the host volume (called "outer") for a hidden volume. */ volatile BOOL bHiddenVolDirect = FALSE; /* If true, the wizard omits creating a host volume in the course of the process of hidden volume creation. */ @@ -219,7 +248,6 @@ volatile HWND hPasswordInputField = NULL; /* Password input field */ volatile HWND hVerifyPasswordInputField = NULL; /* Verify-password input field */ HBITMAP hbmWizardBitmapRescaled = NULL; - wchar_t OrigKeyboardLayout [8+1] = L"00000409"; BOOL bKeyboardLayoutChanged = FALSE; /* TRUE if the keyboard layout was changed to the standard US keyboard layout (from any other layout). */ BOOL bKeybLayoutAltKeyWarningShown = FALSE; /* TRUE if the user has been informed that it is not possible to type characters by pressing keys while the right Alt key is held down. */ @@ -286,7 +314,8 @@ wchar_t outRandPoolDispBuffer [RANDPOOL_DISPLAY_SIZE]; BOOL bDisplayPoolContents = TRUE; volatile BOOL bSparseFileSwitch = FALSE; -volatile BOOL quickFormat = 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 fastCreateFile = FALSE; volatile BOOL dynamicFormat = FALSE; /* this variable represents the sparse file flag. */ volatile int fileSystem = FILESYS_NONE; @@ -300,6 +329,10 @@ LONGLONG nAvailableFreeSpace = -1; BOOL bIsSparseFilesSupportedByHost = FALSE; vector DeferredNonSysInPlaceEncDevices; + +BOOL CHECKLIST_A; +BOOL CHECKLIST_B; +BOOL CHECKLIST_C; int iMaxPasswordLength = MAX_PASSWORD; @@ -1419,89 +1452,11 @@ void ComboSelChangeEA (HWND hwndDlg) else { wchar_t name[100]; - wchar_t auxLine[4096]; - wchar_t hyperLink[256] = { 0 }; - int cipherIDs[5]; - int i, cnt = 0; - + nIndex = (int) SendMessage (GetDlgItem (hwndDlg, IDC_COMBO_BOX), CB_GETITEMDATA, nIndex, 0); EAGetName (name, nIndex, 0); - - if (wcscmp (name, L"AES") == 0) - { - StringCbPrintfW (hyperLink, sizeof(hyperLink) / 2, GetString ("MORE_INFO_ABOUT"), name); - - SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("AES_HELP")); - } - else if (wcscmp (name, L"Serpent") == 0) - { - StringCbPrintfW (hyperLink, sizeof(hyperLink) / 2, GetString ("MORE_INFO_ABOUT"), name); - - SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("SERPENT_HELP")); - } - else if (wcscmp (name, L"Twofish") == 0) - { - StringCbPrintfW (hyperLink, sizeof(hyperLink) / 2, GetString ("MORE_INFO_ABOUT"), name); - - SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("TWOFISH_HELP")); - } - else if (wcscmp (name, L"Kuznyechik") == 0) - { - StringCbPrintfW (hyperLink, sizeof(hyperLink) / 2, GetString ("MORE_INFO_ABOUT"), name); - - SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("KUZNYECHIK_HELP")); - } - else if (wcscmp (name, L"Camellia") == 0) - { - StringCbPrintfW (hyperLink, sizeof(hyperLink) / 2, GetString ("MORE_INFO_ABOUT"), name); - - SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("CAMELLIA_HELP")); - } - else if (EAGetCipherCount (nIndex) > 1) - { - // Cascade - cipherIDs[cnt++] = i = EAGetLastCipher(nIndex); - while (i = EAGetPreviousCipher(nIndex, i)) - { - cipherIDs[cnt] = i; - cnt++; - } - - switch (cnt) // Number of ciphers in the cascade - { - case 2: - StringCbPrintfW (auxLine, sizeof(auxLine), GetString ("TWO_LAYER_CASCADE_HELP"), - CipherGetName (cipherIDs[1]), - CipherGetKeySize (cipherIDs[1])*8, - CipherGetName (cipherIDs[0]), - CipherGetKeySize (cipherIDs[0])*8); - break; - - case 3: - StringCbPrintfW (auxLine, sizeof(auxLine), GetString ("THREE_LAYER_CASCADE_HELP"), - CipherGetName (cipherIDs[2]), - CipherGetKeySize (cipherIDs[2])*8, - CipherGetName (cipherIDs[1]), - CipherGetKeySize (cipherIDs[1])*8, - CipherGetName (cipherIDs[0]), - CipherGetKeySize (cipherIDs[0])*8); - break; - } - - StringCbCopyW (hyperLink, sizeof(hyperLink), GetString ("IDC_LINK_MORE_INFO_ABOUT_CIPHER")); - - SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), auxLine); - } - else - { - // No info available for this encryption algorithm - SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), L""); - } - - - // Update hyperlink - SetWindowTextW (GetDlgItem (hwndDlg, IDC_LINK_MORE_INFO_ABOUT_CIPHER), hyperLink); - AccommodateTextField (hwndDlg, IDC_LINK_MORE_INFO_ABOUT_CIPHER, FALSE, hUserUnderlineFont); + + SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("AES_HELP_NEW")); } } @@ -1765,11 +1720,15 @@ static void UpdateSysEncControls (void) { return; } - + EnableWindow (GetDlgItem (hCurPage, IDC_WIPE_MODE), !locBootEncStatus.SetupInProgress && SystemEncryptionStatus == SYSENC_STATUS_ENCRYPTING); + // TODO: try to make the pause button visible without having to hover over it + SetWindowTextW (GetDlgItem (hCurPage, IDC_PAUSE), + GetString ("IDC_PAUSE")); + SetWindowTextW (GetDlgItem (hCurPage, IDC_PAUSE), GetString (locBootEncStatus.SetupInProgress ? "IDC_PAUSE" : "RESUME")); @@ -2651,9 +2610,11 @@ static void __cdecl volTransformThreadFunction (void *hwndDlgArg) volParams->headerFlags = (CreatingHiddenSysVol() ? TC_HEADER_FLAG_ENCRYPTED_SYSTEM : 0); volParams->fileSystem = fileSystem; volParams->clusterSize = clusterSize; - volParams->sparseFileSwitch = dynamicFormat; + //volParams->sparseFileSwitch = dynamicFormat; //1.24 + volParams->sparseFileSwitch = bSparseFileSwitch; + volParams->quickFormat = quickFormat; - volParams->fastCreateFile = fastCreateFile; + volParams->fastCreateFile = fastCreateFile; volParams->sectorSize = GetFormatSectorSize(); volParams->realClusterSize = &realClusterSize; volParams->password = &volumePassword; @@ -2841,7 +2802,7 @@ static void __cdecl volTransformThreadFunction (void *hwndDlgArg) { Info("FORMAT_FINISHED_INFO", hwndDlg); - if (dynamicFormat) + if (bSparseFileSwitch && quickFormat) //u 1.24. if(dynamicFormat) Warning("SPARSE_FILE_SIZE_NOTE", hwndDlg); } } @@ -2939,6 +2900,7 @@ static void LoadPage (HWND hwndDlg, int nPageNo) case PASSWORD_PAGE: { wchar_t tmp[MAX_PASSWORD+1]; + char *passTmp[MAX_PASSWORD+1]; // Attempt to wipe passwords stored in the input field buffers. This is performed here (and // not in the IDC_PREV or IDC_NEXT sections) in order to prevent certain race conditions @@ -2947,6 +2909,7 @@ static void LoadPage (HWND hwndDlg, int nPageNo) tmp [MAX_PASSWORD] = 0; SetWindowText (hPasswordInputField, tmp); SetWindowText (hVerifyPasswordInputField, tmp); + } break; } @@ -3406,7 +3369,6 @@ BOOL GetFileVolSize (HWND hwndDlg, unsigned __int64 *size) return TRUE; } - BOOL QueryFreeSpace (HWND hwndDlg, HWND hwndTextBox, BOOL display, LONGLONG *pFreeSpaceValue, BOOL* pbIsSparceFilesSupported) { if (pFreeSpaceValue) @@ -3775,30 +3737,49 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa UpdateWizardModeControls (hwndDlg, WizardMode); break; - case SYSENC_TYPE_PAGE: - + case SYSENC_TYPE_PAGE: bHiddenVolHost = bHiddenVol = bHiddenOS; - SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SYSENC_TYPE_PAGE_TITLE")); - - SendMessage (GetDlgItem (hwndDlg, IDC_SYSENC_HIDDEN), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE); - SendMessage (GetDlgItem (hwndDlg, IDC_SYSENC_NORMAL), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE); - - DisableIfGpt(GetDlgItem(hwndDlg, IDC_SYSENC_HIDDEN)); - - CheckButton (GetDlgItem (hwndDlg, bHiddenOS ? IDC_SYSENC_HIDDEN : IDC_SYSENC_NORMAL)); + SetWindowTextW(GetDlgItem(GetParent(hwndDlg), IDC_BOX_TITLE), GetString("PAGE_1_TITLE")); SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("SYSENC_HIDDEN_TYPE_HELP")); SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP_SYSENC_NORMAL), GetString ("SYSENC_NORMAL_TYPE_HELP")); - ToHyperlink (hwndDlg, IDC_HIDDEN_SYSENC_INFO_LINK); + if(bSystemIsGPT) + { + ShowWindow (GetDlgItem(hwndDlg, IDC_ADVANCE_INTRO), SW_HIDE); + ShowWindow (GetDlgItem(hwndDlg, IDC_INFORMATION_TIP), SW_HIDE); + } + else + { + EnableWindow(GetDlgItem(hwndDlg, IDC_ADVANCE_INTRO), TRUE); + iIconX = GetSystemMetrics(SM_CXSMICON); + iIconY = GetSystemMetrics(SM_CYSMICON); - EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE); - EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), !bDirectSysEncMode); + hIconTooltip = LoadImage(NULL, MAKEINTRESOURCE(104), IMAGE_ICON, iIconX, iIconY, LR_DEFAULTCOLOR); + SendDlgItemMessage(hwndDlg, IDC_INFORMATION_TIP, STM_SETICON, (WPARAM) hIconTooltip, 0); + + hDlgItemTooltip = GetDlgItem(hwndDlg, IDC_INFORMATION_TIP); + if(hDlgItemTooltip) + { + // TODO Add string for tooltip here + CreateToolTip(hwndDlg, hDlgItemTooltip, L"TESTING"); + } + else + { + MessageBox(0, TEXT("Cannot find dialog item"), 0, 0); + } + } + EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE); + EnableWindow(GetDlgItem(GetParent(hwndDlg), IDC_PREV), FALSE); SetWindowTextW (GetDlgItem (MainDlg, IDC_NEXT), GetString ("NEXT")); SetWindowTextW (GetDlgItem (MainDlg, IDC_PREV), GetString ("PREV")); SetWindowTextW (GetDlgItem (MainDlg, IDCANCEL), GetString ("CANCEL")); + + // Start loading the password dictonary into memory ("need" is just a random word for initializing the process) + CheckWord("need"); + break; case SYSENC_HIDDEN_OS_REQ_CHECK_PAGE: @@ -3903,11 +3884,12 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDCANCEL), GetString ("CANCEL")); RefreshMultiBootControls (hwndDlg); + EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), nMultiBoot > 0); EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE); EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE); break; - + case SYSENC_MULTI_BOOT_SYS_EQ_BOOT_PAGE: @@ -4148,66 +4130,65 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } break; - case CIPHER_PAGE: - { - int ea, hid; - wchar_t buf[100]; + case CIPHER_PAGE: + int ea, hid; + wchar_t buf[100]; - // Encryption algorithms + // Encryption algorithms - SendMessage (GetDlgItem (hwndDlg, IDC_COMBO_BOX), CB_RESETCONTENT, 0, 0); + SendMessage (GetDlgItem (hwndDlg, IDC_COMBO_BOX), CB_RESETCONTENT, 0, 0); - if (bHiddenVol) - SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString (bHiddenVolHost ? "CIPHER_HIDVOL_HOST_TITLE" : "CIPHER_HIDVOL_TITLE")); - else - SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("CIPHER_TITLE")); + if (bHiddenVol) + SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString (bHiddenVolHost ? "CIPHER_HIDVOL_HOST_TITLE" : "CIPHER_HIDVOL_TITLE")); + else + SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("CIPHER_TITLE")); - for (ea = EAGetFirst (); ea != 0; ea = EAGetNext (ea)) - { - if (EAIsFormatEnabled (ea) && (!SysEncInEffect () || bSystemIsGPT || EAIsMbrSysEncEnabled (ea))) - AddComboPair (GetDlgItem (hwndDlg, IDC_COMBO_BOX), EAGetName (buf, ea, 1), ea); - } + for (ea = EAGetFirst (); ea != 0; ea = EAGetNext (ea)) + { + if (EAIsFormatEnabled (ea) && (!SysEncInEffect () || bSystemIsGPT || EAIsMbrSysEncEnabled (ea))) + AddComboPair (GetDlgItem (hwndDlg, IDC_COMBO_BOX), EAGetName (buf, ea, 1), ea); + } - SelectAlgo (GetDlgItem (hwndDlg, IDC_COMBO_BOX), &nVolumeEA); - ComboSelChangeEA (hwndDlg); - SetFocus (GetDlgItem (hwndDlg, IDC_COMBO_BOX)); + SelectAlgo (GetDlgItem (hwndDlg, IDC_COMBO_BOX), &nVolumeEA); + ComboSelChangeEA (hwndDlg); + SetFocus (GetDlgItem (hwndDlg, IDC_COMBO_BOX)); - ToHyperlink (hwndDlg, IDC_LINK_MORE_INFO_ABOUT_CIPHER); + ToHyperlink (hwndDlg, IDC_LINK_MORE_INFO_ABOUT_CIPHER); - // Hash algorithms + // Hash algorithms - if (SysEncInEffect ()) - { - hash_algo = bSystemIsGPT? SHA512 : DEFAULT_HASH_ALGORITHM_BOOT; - RandSetHashFunction (hash_algo); + if (SysEncInEffect ()) + { + hash_algo = bSystemIsGPT? SHA512 : DEFAULT_HASH_ALGORITHM_BOOT; + RandSetHashFunction (hash_algo); - for (hid = FIRST_PRF_ID; hid <= LAST_PRF_ID; hid++) - { - // For now, we keep RIPEMD160 for system encryption - if (((hid == RIPEMD160) || !HashIsDeprecated (hid)) && (bSystemIsGPT || HashForSystemEncryption (hid))) - AddComboPair (GetDlgItem (hwndDlg, IDC_COMBO_BOX_HASH_ALGO), HashGetName(hid), hid); - } + for (hid = FIRST_PRF_ID; hid <= LAST_PRF_ID; hid++) + { + // For now, we keep RIPEMD160 for system encryption + if (((hid == RIPEMD160) || !HashIsDeprecated (hid)) && (bSystemIsGPT || HashForSystemEncryption (hid))) + AddComboPair (GetDlgItem (hwndDlg, IDC_COMBO_BOX_HASH_ALGO), HashGetName(hid), hid); } - else + } + else + { + hash_algo = RandGetHashFunction(); + for (hid = FIRST_PRF_ID; hid <= LAST_PRF_ID; hid++) { - hash_algo = RandGetHashFunction(); - for (hid = FIRST_PRF_ID; hid <= LAST_PRF_ID; hid++) - { - if (!HashIsDeprecated (hid)) - AddComboPair (GetDlgItem (hwndDlg, IDC_COMBO_BOX_HASH_ALGO), HashGetName(hid), hid); - } + if (!HashIsDeprecated (hid)) + AddComboPair (GetDlgItem (hwndDlg, IDC_COMBO_BOX_HASH_ALGO), HashGetName(hid), hid); } + } - SelectAlgo (GetDlgItem (hwndDlg, IDC_COMBO_BOX_HASH_ALGO), &hash_algo); + SelectAlgo (GetDlgItem (hwndDlg, IDC_COMBO_BOX_HASH_ALGO), &hash_algo); - ToHyperlink (hwndDlg, IDC_LINK_HASH_INFO); + ToHyperlink (hwndDlg, IDC_LINK_HASH_INFO); - // Wizard buttons - SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT")); - SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV")); - EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE); - EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE); - } + // Wizard buttons + SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT")); + SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV")); + EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE); + EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE); + break; case SIZE_PAGE: @@ -4361,8 +4342,8 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa break; case PASSWORD_PAGE: - { - wchar_t str[1000]; + { + EnableWindow(GetDlgItem(hwndDlg, IDC_VERIFY), FALSE); hPasswordInputField = GetDlgItem (hwndDlg, IDC_PASSWORD); hVerifyPasswordInputField = GetDlgItem (hwndDlg, IDC_VERIFY); @@ -4389,8 +4370,8 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } bKeyboardLayoutChanged = TRUE; } - - + + if (SetTimer (MainDlg, TIMER_ID_KEYB_LAYOUT_GUARD, TIMER_INTERVAL_KEYB_LAYOUT_GUARD, NULL) == 0) { Error ("CANNOT_SET_TIMER", MainDlg); @@ -4399,43 +4380,20 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } } - if (bHiddenVolHost) - { - StringCbCopyW (str, sizeof(str), GetString (bHiddenOS ? "PASSWORD_SYSENC_OUTERVOL_HELP" : "PASSWORD_HIDDENVOL_HOST_HELP")); - } - else if (bHiddenVol) - { - StringCbPrintfW (str, sizeof str, L"%s%s", - GetString (bHiddenOS ? "PASSWORD_HIDDEN_OS_HELP" : "PASSWORD_HIDDENVOL_HELP"), - GetString ("PASSWORD_HELP")); - } - else - { - StringCbCopyW (str, sizeof(str), GetString ("PASSWORD_HELP")); - } - SetPassword (hwndDlg, IDC_PASSWORD, szRawPassword); SetPassword (hwndDlg, IDC_VERIFY, szVerify); - + SetFocus (GetDlgItem (hwndDlg, IDC_PASSWORD)); - SetCheckBox (hwndDlg, IDC_PIM_ENABLE, PimEnable); - - SetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE, KeyFilesEnable && !SysEncInEffect()); - EnableWindow (GetDlgItem (hwndDlg, IDC_KEY_FILES), KeyFilesEnable && !SysEncInEffect()); - EnableWindow (GetDlgItem (hwndDlg, IDC_KEYFILES_ENABLE), !SysEncInEffect()); - - SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), str); - if (CreatingHiddenSysVol()) SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("PASSWORD_HIDDEN_OS_TITLE")); else if (bHiddenVol) SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString (bHiddenVolHost ? "PASSWORD_HIDVOL_HOST_TITLE" : "PASSWORD_HIDVOL_TITLE")); else if (WizardMode == WIZARD_MODE_SYS_DEVICE) - SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("PASSWORD")); + SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("CHOOSE_PASSWORD_TITLE")); else SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("PASSWORD_TITLE")); - + SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT")); SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV")); @@ -4447,9 +4405,41 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa NULL, NULL, KeyFilesEnable && FirstKeyFile!=NULL && !SysEncInEffect()); + volumePassword.Length = (unsigned __int32) strlen ((char *) volumePassword.Text); + + /* Random pool parameter */ - } + mouseEntropyGathered = 0xFFFFFFFF; + mouseEventsInitialCount = 0; + bUseMask = FALSE; + + { + HCRYPTPROV hRngProv; + if (CryptAcquireContext (&hRngProv, NULL, MS_ENHANCED_PROV, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) + { + if (CryptGenRandom (hRngProv, sizeof (maskRandPool), maskRandPool)) + bUseMask = TRUE; + CryptReleaseContext (hRngProv, 0); + } + } + + SetTimer(GetParent(hwndDlg), TIMER_ID_RANDVIEW, TIMER_INTERVAL_RANDVIEW, NULL); + + hRandPoolSys = GetDlgItem(hwndDlg, IDC_SYS_POOL_CONTENTS); + hEntropyBar = GetDlgItem(hwndDlg, IDC_ENTROPY_BAR); + SendMessage(hEntropyBar, PBM_SETRANGE32, 0, maxEntropyLevel); + SendMessage(hEntropyBar, PBM_SETSTEP, 1, 0); + SendMessage(GetDlgItem(hwndDlg, IDC_SYS_POOL_CONTENTS), WM_SETFONT, (WPARAM)hFixedDigitFont, (LPARAM)TRUE); + + + /* set default values */ + + hash_algo = bSystemIsGPT ? SHA512 : DEFAULT_HASH_ALGORITHM_BOOT; + RandSetHashFunction(hash_algo); + + nWipeMode = TC_WIPE_1_RAND; + } break; case PIM_PAGE: @@ -4577,7 +4567,9 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("RESCUE_DISK")); SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT")); SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV")); - SetWindowTextW (GetDlgItem (hwndDlg, IDT_RESCUE_DISK_INFO), bSystemIsGPT? GetString ("RESCUE_DISK_EFI_INFO"): GetString ("RESCUE_DISK_INFO")); + SetWindowTextW(GetDlgItem(hwndDlg, IDT_RESCUE_DISK_INFO), GetString("RESCUE_DISK_NEW")); + SetWindowTextW(GetDlgItem(hwndDlg, IDT_RESCUE_DISK_INFO_2), GetString("RESCUE_DISK_INFO_2")); + SetCheckBox (hwndDlg, IDC_SKIP_RESCUE_VERIFICATION, bDontVerifyRescueDisk); SetDlgItemText (hwndDlg, IDC_RESCUE_DISK_ISO_PATH, szRescueDiskISO); EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), (GetWindowTextLength (GetDlgItem (hwndDlg, IDC_RESCUE_DISK_ISO_PATH)) > 1)); @@ -4607,28 +4599,15 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } SetWindowTextW (GetDlgItem (hwndDlg, IDT_RESCUE_DISK_BURN_INFO), szTmp); + EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE); + + /* The 'Back' button is enabled but user can't go back, instead warning is provided */ + EnableWindow(GetDlgItem(GetParent(hwndDlg), IDC_PREV), TRUE); + + ShowWindow(GetDlgItem(hwndDlg, IDC_DOWNLOAD_CD_BURN_SOFTWARE), SW_HIDE); + } - /* The 'Back' button must be disabled now because the user could burn a Rescue Disk, then go back, and - generate a different master key, which would cause the Rescue Disk verification to fail (the result - would be confusion and bug reports). */ - EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), FALSE); - - if (bSystemIsGPT) - { - ShowWindow (GetDlgItem (hwndDlg, IDC_DOWNLOAD_CD_BURN_SOFTWARE), SW_HIDE); - } - else - { - if (IsWindowsIsoBurnerAvailable()) - SetWindowTextW (GetDlgItem (hwndDlg, IDC_DOWNLOAD_CD_BURN_SOFTWARE), GetString ("LAUNCH_WIN_ISOBURN")); - - ToHyperlink (hwndDlg, IDC_DOWNLOAD_CD_BURN_SOFTWARE); - - if (IsWindowsIsoBurnerAvailable() && !bDontVerifyRescueDisk) - LaunchWindowsIsoBurner (hwndDlg, szRescueDiskISO); - } - } break; case SYSENC_RESCUE_DISK_VERIFIED_PAGE: @@ -4650,27 +4629,41 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa break; case SYSENC_WIPE_MODE_PAGE: - case NONSYS_INPLACE_ENC_WIPE_MODE_PAGE: - { - if (nWipeMode == TC_WIPE_1_RAND) - nWipeMode = TC_WIPE_NONE; - - SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("WIPE_MODE_TITLE")); - SetWindowTextW (GetDlgItem (hwndDlg, IDT_WIPE_MODE_INFO), GetString ("INPLACE_ENC_WIPE_MODE_INFO")); - - PopulateWipeModeCombo (GetDlgItem (hwndDlg, IDC_WIPE_MODE), - SystemEncryptionStatus == SYSENC_STATUS_DECRYPTING && !bInPlaceEncNonSys, - TRUE, - FALSE); + case NONSYS_INPLACE_ENC_WIPE_MODE_PAGE:// Checklist page + + wchar_t szTmp[8192]; - SelectAlgo (GetDlgItem (hwndDlg, IDC_WIPE_MODE), (int *) &nWipeMode); + SetWindowTextW (GetDlgItem (hwndDlg, IDC_REMEMBER_PASSWORD), GetString ("REMEMBER_PASSWORD")); + SetWindowTextW (GetDlgItem (hwndDlg, IDC_STORE_RESCUE_DISK), GetString ("STORE_RESCUE_DISK")); + SetWindowTextW (GetDlgItem (hwndDlg, IDC_BACKUP_DATA), GetString ("BACKUP_DATA")); + + SendMessage(GetDlgItem(hwndDlg, IDC_REMEMBER_PASSWORD), WM_SETFONT, (WPARAM)hUserBoldFont, (LPARAM)TRUE); + SendMessage(GetDlgItem(hwndDlg, IDC_STORE_RESCUE_DISK), WM_SETFONT, (WPARAM)hUserBoldFont, (LPARAM)TRUE); + SendMessage(GetDlgItem(hwndDlg, IDC_BACKUP_DATA), WM_SETFONT, (WPARAM)hUserBoldFont, (LPARAM)TRUE); + + CHECKLIST_A = FALSE; + CHECKLIST_B = FALSE; + CHECKLIST_C = FALSE; + + SetWindowTextW(GetDlgItem(GetParent(hwndDlg), IDC_BOX_TITLE), GetString("CHECKLIST_TITLE")); + + StringCbPrintfW(szTmp, sizeof szTmp, + GetString("RESCUE_DISK_CHECKLIST_B"), + szRescueDiskISO, ""); + SetDlgItemText(hwndDlg, IDT_STORE_RESCUE_DISK, szTmp); + SetWindowTextW (GetDlgItem (hwndDlg, IDT_REMEMBER_PASSWORD), GetString ("RESCUE_DISK_CHECKLIST_A")); + SetWindowTextW (GetDlgItem (hwndDlg, IDT_BACKUP_DATA), GetString ("RESCUE_DISK_CHECKLIST_C")); + + EnableWindow(GetDlgItem(hwndDlg, IDC_REMEMBER_PASSWORD), TRUE); + EnableWindow(GetDlgItem(hwndDlg, IDC_STORE_RESCUE_DISK), TRUE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BACKUP_DATA), TRUE); - SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT")); + SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT")); - SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV")); - EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE); - EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE); - } + SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV")); + EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE); + EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), FALSE); + break; case SYSENC_PRETEST_INFO_PAGE: @@ -4746,7 +4739,6 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString (SystemEncryptionStatus != SYSENC_STATUS_DECRYPTING ? "ENCRYPTION" : "DECRYPTION")); - SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("SYSENC_ENCRYPTION_PAGE_INFO")); SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDCANCEL), GetString ("DEFER")); @@ -4755,6 +4747,11 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString (SystemEncryptionStatus != SYSENC_STATUS_DECRYPTING ? "ENCRYPT" : "DECRYPT")); + //TODO current: 'Pause' button is not vidible until hover over it + SetWindowTextW (GetDlgItem (hwndDlg, IDC_PAUSE), + GetString ( "IDC_PAUSE")); + EnableWindow (GetDlgItem (hwndDlg, IDC_PAUSE), TRUE); + SetWindowTextW (GetDlgItem (hwndDlg, IDC_PAUSE), GetString (bSystemEncryptionInProgress ? "IDC_PAUSE" : "RESUME")); @@ -4764,7 +4761,6 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE); EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), TRUE); - ToHyperlink (hwndDlg, IDC_MORE_INFO_SYS_ENCRYPTION); if (SystemEncryptionStatus == SYSENC_STATUS_DECRYPTING) { @@ -4772,7 +4768,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa EnableWindow (GetDlgItem (hwndDlg, IDC_WIPE_MODE), FALSE); EnableWindow (GetDlgItem (hwndDlg, IDT_WIPE_MODE), FALSE); PopulateWipeModeCombo (GetDlgItem (hwndDlg, IDC_WIPE_MODE), TRUE, TRUE, FALSE); - SelectAlgo (GetDlgItem (hwndDlg, IDC_WIPE_MODE), (int *) &nWipeMode); + SelectAlgo (GetDlgItem (hwndDlg, IDC_WIPE_MODE), (int *) &nWipeMode); } else { @@ -4780,7 +4776,13 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa PopulateWipeModeCombo (GetDlgItem (hwndDlg, IDC_WIPE_MODE), FALSE, TRUE, FALSE); SelectAlgo (GetDlgItem (hwndDlg, IDC_WIPE_MODE), (int *) &nWipeMode); } - + + if (nWipeMode == TC_WIPE_NONE || nWipeMode == TC_WIPE_1_RAND) + { + ShowWindow (GetDlgItem(hwndDlg, IDC_WIPE_MODE), SW_HIDE); + ShowWindow (GetDlgItem(hwndDlg, IDT_FORMAT_OPTIONS), SW_HIDE); + ShowWindow (GetDlgItem(hwndDlg, IDT_WIPE_MODE), SW_HIDE); + } PostMessage (hwndDlg, TC_APPMSG_PERFORM_POST_SYSENC_WMINIT_TASKS, 0, 0); } else @@ -4840,7 +4842,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa EnableWindow (GetDlgItem (hwndDlg, IDC_PAUSE), FALSE); ShowWindow (GetDlgItem (hwndDlg, IDC_MORE_INFO_SYS_ENCRYPTION), SW_HIDE); - + if (bInPlaceDecNonSys) { ShowWindow(GetDlgItem(hwndDlg, IDT_FORMAT_OPTIONS), SW_HIDE); @@ -4852,8 +4854,15 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa EnableWindow (GetDlgItem (hwndDlg, IDC_WIPE_MODE), TRUE); PopulateWipeModeCombo (GetDlgItem (hwndDlg, IDC_WIPE_MODE), FALSE, TRUE, FALSE); SelectAlgo (GetDlgItem (hwndDlg, IDC_WIPE_MODE), (int *) &nWipeMode); + + } + + if (nWipeMode == TC_WIPE_NONE || nWipeMode == TC_WIPE_1_RAND) + { + ShowWindow (GetDlgItem(hwndDlg, IDC_WIPE_MODE), SW_HIDE); + ShowWindow (GetDlgItem(hwndDlg, IDT_FORMAT_OPTIONS), SW_HIDE); + ShowWindow (GetDlgItem(hwndDlg, IDT_WIPE_MODE), SW_HIDE); } - break; case NONSYS_INPLACE_ENC_TRANSFORM_FINISHED_PAGE: @@ -4982,6 +4991,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa { dynamicFormat = FALSE; bSparseFileSwitch = FALSE; + SetCheckBox (hwndDlg, SPARSE_FILE, FALSE); EnableWindow (GetDlgItem (hwndDlg, SPARSE_FILE), FALSE); EnableWindow (GetDlgItem (hwndDlg, IDC_QUICKFORMAT), TRUE); @@ -4990,7 +5000,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa { wchar_t root[TC_MAX_PATH]; DWORD fileSystemFlags = 0; - + /* Check if the host file system supports sparse files */ if (GetVolumePathName (szFileName, root, array_capacity (root))) @@ -5005,6 +5015,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa dynamicFormat = FALSE; SetCheckBox (hwndDlg, SPARSE_FILE, FALSE); } + EnableWindow (GetDlgItem (hwndDlg, SPARSE_FILE), bSparseFileSwitch); EnableWindow (GetDlgItem (hwndDlg, IDC_QUICKFORMAT), TRUE); } @@ -5235,7 +5246,6 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa break; case DEVICE_WIPE_PAGE: - if (bHiddenOS && IsHiddenOSRunning()) { // Decoy system partition wipe @@ -5270,15 +5280,46 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa case WM_CTLCOLORSTATIC: { - if (PimValueChangedWarning && ((HWND)lParam == GetDlgItem(hwndDlg, IDC_PIM_HELP)) ) + if ((HWND)lParam == GetDlgItem (hwndDlg, PASSWORDMETER) && pw_strength == 1) { // we're about to draw the static // set the text colour in (HDC)lParam - SetBkMode((HDC)wParam,TRANSPARENT); - SetTextColor((HDC)wParam, RGB(255,0,0)); - // NOTE: per documentation as pointed out by selbie, GetSolidBrush would leak a GDI handle. + SetBkMode ((HDC)wParam, TRANSPARENT); + SetTextColor ((HDC)wParam, RGB(255, 0, 0)); // password weak red return (BOOL)GetSysColorBrush(COLOR_MENU); } + if ((HWND)lParam == GetDlgItem (hwndDlg, PASSWORDMETER) && pw_strength == 2) + { + // we're about to draw the static + // set the text colour in (HDC)lParam + SetBkMode ((HDC)wParam, TRANSPARENT); + SetTextColor ((HDC)wParam, RGB (255, 165, 0)); // password medium orange + return (BOOL) GetSysColorBrush (COLOR_MENU); + } + + if ((HWND)lParam == GetDlgItem (hwndDlg, PASSWORDMETER) && pw_strength == 3) + { + SetBkMode ((HDC)wParam, TRANSPARENT); + SetTextColor ((HDC)wParam, RGB (218, 218, 0)); // password strong yellow + return (BOOL) GetSysColorBrush (COLOR_MENU); + } + + if ((HWND)lParam == GetDlgItem (hwndDlg, PASSWORDMETER) && pw_strength == 4) + { + SetBkMode((HDC)wParam, TRANSPARENT); + SetTextColor((HDC)wParam, RGB(50, 205, 50)); // password very strong green + return (BOOL) GetSysColorBrush (COLOR_MENU); + } + + if (PimValueChangedWarning && ((HWND)lParam == GetDlgItem (hwndDlg, IDC_PIM_HELP)) ) + { + // we're about to draw the static + // set the text colour in (HDC)lParam + SetBkMode ((HDC)wParam,TRANSPARENT); + SetTextColor ((HDC)wParam, RGB (255,0,0)); + // NOTE: per documentation as pointed out by selbie, GetSolidBrush would leak a GDI handle. + return (BOOL) GetSysColorBrush (COLOR_MENU); + } } return 0; @@ -5331,7 +5372,14 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa return 1; } } - + if (lw == IDC_ADVANCE_INTRO && nCurPageNo == SYSENC_TYPE_PAGE) + { + DialogBoxParamW(hInst, + MAKEINTRESOURCEW(IDD_ADVANCE_MBR), hwndDlg, + (DLGPROC)AdvanceDlgProcIntro, NULL); + return 1; + } + if (nCurPageNo == SYSENC_HIDDEN_OS_REQ_CHECK_PAGE && lw == IDC_HIDDEN_SYSENC_INFO_LINK) { Applink ("hiddensysenc"); @@ -5384,6 +5432,14 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa break; } + if (lw == IDC_ADVANCE && nCurPageNo == PASSWORD_PAGE) + { + DialogBoxParamW(hInst, + MAKEINTRESOURCEW(IDD_ADVANCE), hwndDlg, + (DLGPROC)AdvanceDlgProc, NULL); + return 1; + } + if (nCurPageNo == FILESYS_PAGE && (lw == IDC_CHOICE1 || lw == IDC_CHOICE2)) { if (bWarnOuterVolSuitableFileSys && lw == IDC_CHOICE1 && bHiddenVolHost) @@ -5647,6 +5703,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa bValidEntry = FALSE; } } + EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), bValidEntry); @@ -5683,13 +5740,48 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa if (hw == EN_CHANGE && nCurPageNo == PASSWORD_PAGE) { VerifyPasswordAndUpdate (hwndDlg, GetDlgItem (GetParent (hwndDlg), IDC_NEXT), - GetDlgItem (hwndDlg, IDC_PASSWORD), - GetDlgItem (hwndDlg, IDC_VERIFY), - NULL, - NULL, - KeyFilesEnable && FirstKeyFile!=NULL && !SysEncInEffect()); + GetDlgItem(hCurPage, IDC_PASSWORD), + GetDlgItem(hCurPage, IDC_VERIFY), + volumePassword.Text, + szVerify, + KeyFilesEnable && FirstKeyFile != NULL && !SysEncInEffect()); + volumePassword.Length = (unsigned __int32) strlen ((char *) volumePassword.Text); + + SendMessage(GetDlgItem(hwndDlg, PASSWORDMETER), WM_SETFONT, (WPARAM)hUserBoldFont, (LPARAM)TRUE); + + memset(&tmp_password[0], 0, sizeof(tmp_password)); + for (unsigned int i = 0; i < volumePassword.Length; i++) + { + tmp_password[i] = volumePassword.Text[i]; + } + pw_strength = printStrongNess(tmp_password, volumePassword.Length); + + if (pw_strength == very_strong) + { + SetWindowTextW(GetDlgItem (hwndDlg, PASSWORDMETER), GetString ("VERY_STRONG_PASSWORD")); + EnableWindow(GetDlgItem (hwndDlg, IDC_VERIFY), TRUE); + } + else if (pw_strength == strong) + { + SetWindowTextW(GetDlgItem (hwndDlg, PASSWORDMETER), GetString ("STRONG_PASSWORD")); + EnableWindow(GetDlgItem (hwndDlg, IDC_VERIFY), TRUE); + } + else if (pw_strength == medium) + { + EnableWindow(GetDlgItem (hwndDlg, IDC_VERIFY), TRUE); + SetWindowTextW(GetDlgItem (hwndDlg, PASSWORDMETER), GetString ("MEDIUM_PASSWORD")); + } + else if (pw_strength == weak) + { + EnableWindow(GetDlgItem (hwndDlg, IDC_VERIFY), FALSE); + SetWindowTextW(GetDlgItem (hwndDlg, PASSWORDMETER), GetString ("WEAK_PASSWORD")); + } + else + { + SetWindowTextW(GetDlgItem(hwndDlg, PASSWORDMETER), GetString ("VERY_WEAK_PASSWORD")); + } return 1; } @@ -5717,12 +5809,26 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PASSWORD, IDC_PASSWORD, IDC_VERIFY); return 1; } - + + if (lw == IDC_SHOW_PIM && nCurPageNo == PIM_PAGE) { HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PIM, IDC_PIM, 0); return 1; } + + if (lw == IDC_CHECKLIST_A) + { + CHECKLIST_A = GetCheckBox(hwndDlg, IDC_CHECKLIST_A); + CHECKLIST_B = GetCheckBox(hwndDlg, IDC_CHECKLIST_B); + + } + + if (lw == IDC_CHECKLIST_B) + { + CHECKLIST_B = GetCheckBox(hwndDlg, IDC_CHECKLIST_B); + CHECKLIST_A = GetCheckBox(hwndDlg, IDC_CHECKLIST_A); + } if (lw == IDC_PIM_ENABLE) { @@ -5961,7 +6067,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa return 1; } - + if (lw == IDC_QUICKFORMAT) { if (IsButtonChecked (GetDlgItem (hCurPage, IDC_QUICKFORMAT))) @@ -5976,7 +6082,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } return 1; } - + if (lw == SPARSE_FILE && IsButtonChecked (GetDlgItem (hCurPage, SPARSE_FILE))) { if (AskWarnYesNo("CONFIRM_SPARSE_FILE", MainDlg) == IDNO) @@ -6011,7 +6117,6 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa SetWindowText (GetDlgItem (hCurPage, IDC_DISK_KEY), showKeys ? L"" : L"******************************** "); return 1; } - if (lw == IDC_DISPLAY_POOL_CONTENTS && (nCurPageNo == SYSENC_COLLECTING_RANDOM_DATA_PAGE || nCurPageNo == NONSYS_INPLACE_ENC_RAND_DATA_PAGE)) { @@ -6052,7 +6157,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa return 1; } } - + if (nCurPageNo == SYSENC_RESCUE_DISK_BURN_PAGE && lw == IDC_DOWNLOAD_CD_BURN_SOFTWARE) { if (IsWindowsIsoBurnerAvailable()) @@ -6062,7 +6167,20 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa return 1; } - + + /* The password and rescue checkbox have to be clicked in order to enable the next button */ + if ((nCurPageNo == SYSENC_WIPE_MODE_PAGE || nCurPageNo == NONSYS_INPLACE_ENC_WIPE_MODE_PAGE) && (lw == IDC_CHECKLIST_A || lw == IDC_CHECKLIST_B)) + { + if (CHECKLIST_A && CHECKLIST_B) + { + EnableWindow(GetDlgItem(GetParent(hwndDlg), IDC_NEXT), TRUE); + } + else + { + EnableWindow(GetDlgItem(GetParent(hwndDlg), IDC_NEXT), FALSE); + } + } + if ((nCurPageNo == SYSENC_WIPE_MODE_PAGE || nCurPageNo == NONSYS_INPLACE_ENC_WIPE_MODE_PAGE || nCurPageNo == DEVICE_WIPE_MODE_PAGE) @@ -6098,7 +6216,21 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } return 0; - } + /*case WM_CHAR: + if(nCurPageNo == PASSWORD_PAGE) + { + OnKeyPress(wParam); + }*/ + /*case WM_INPUT: + if(nCurPageNo == PASSWORD_PAGE) + { + UINT virtualKey; + UINT scanCode = (lParam >> 16) & 0xFF; + // UINT scanCode = (lparam >> 16) & 0x7f) | ((lparam & (1 << 24)) != 0 ? 0x80 : 0; + virtualKey = MapVirtualKeyExW(scanCode, MAPVK_VSC_TO_VK_EX, OrigEnUSKeyboardLayout); + + } */ + }// closes the first switch (uMsg) return 0; } @@ -6165,7 +6297,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } try - { + {//variable is set if it is gpt instead of mbr bSystemIsGPT = BootEncObj->GetSystemDriveConfiguration().SystemPartition.IsGPT; } catch (...) @@ -6353,7 +6485,6 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa { AbortProcess ("VOLUME_TOO_LARGE_FOR_WINXP"); } - if (volumePassword.Length > 0) { // Check password length (check also done for outer volume which is not the case in TrueCrypt). @@ -6374,10 +6505,9 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } SHGetFolderPath (NULL, CSIDL_MYDOCUMENTS, NULL, 0, szRescueDiskISO); - if (bSystemIsGPT) - StringCbCatW (szRescueDiskISO, sizeof(szRescueDiskISO), L"\\VeraCrypt Rescue Disk.zip"); - else - StringCbCatW (szRescueDiskISO, sizeof(szRescueDiskISO), L"\\VeraCrypt Rescue Disk.iso"); + + // Zip rescue for both GPT and MBR + StringCbCatW (szRescueDiskISO, sizeof(szRescueDiskISO), L"\\VeraCrypt Rescue Disk.zip"); if (IsOSAtLeast (WIN_VISTA)) { @@ -6467,7 +6597,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa case TIMER_ID_SYSENC_PROGRESS: { // Manage system encryption/decryption and update related GUI - + try { BootEncStatus = BootEncObj->GetStatus(); @@ -6648,6 +6778,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa if (SysEncInEffect ()) { DWORD keybLayout = (DWORD) GetKeyboardLayout (NULL); + bKeyboardLayoutChanged = FALSE; /* Watch the keyboard layout */ @@ -6678,10 +6809,35 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa StringCbCatW (szTmp, sizeof(szTmp), GetString ("KEYB_LAYOUT_SYS_ENC_EXPLANATION")); MessageBoxW (MainDlg, szTmp, lpszTitle, MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST); } + /*if (keybLayout != 0x00000409 && keybLayout != 0x04090409) + { + // Keyboard layout is not standard US + + bKeyboardLayoutChanged = FALSE; + /*switch (uMsg){ + case WM_INPUT: + if(nCurPageNo == PASSWORD_PAGE) + { + wchar_t c [4096]={0}; + + UINT virtualKey; + UINT scanCode = (lParam >> 16) & 0xFF; + // UINT scanCode = (lparam >> 16) & 0x7f) | ((lparam & (1 << 24)) != 0 ? 0x80 : 0; + virtualKey = MapVirtualKeyExW(scanCode, MAPVK_VSC_TO_VK_EX, OrigEnUSKeyboardLayout); + c[i] = MapVirtualKeyExW(scanCode, MAPVK_VK_TO_CHAR, OrigEnUSKeyboardLayout); + i++; + + MessageBoxW (MainDlg, c, lpszTitle, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TOPMOST); + + } + + } + }*/ + /* Watch the right Alt key (which is used to enter various characters on non-US keyboards) */ - if (bKeyboardLayoutChanged && !bKeybLayoutAltKeyWarningShown) + if (!bKeybLayoutAltKeyWarningShown) { if (GetAsyncKeyState (VK_RMENU) < 0) { @@ -6947,7 +7103,11 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa return 1; } else - return 1; // Disallow close + return 1; // Disallow close + bVolTransformThreadCancel = TRUE; + + EndMainDlg (hwndDlg); + return 1; } else if ((nCurPageNo == SYSENC_ENCRYPTION_PAGE || nCurPageNo == SYSENC_PRETEST_RESULT_PAGE) && SystemEncryptionStatus != SYSENC_STATUS_NONE @@ -7016,8 +7176,21 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa case WM_COMMAND: if (lw == IDHELP) - { - OpenPageHelp (hwndDlg, nCurPageNo); + { + if (nCurPageNo == SYSENC_RESCUE_DISK_CREATION_PAGE || + nCurPageNo == SYSENC_RESCUE_DISK_BURN_PAGE || + nCurPageNo == SYSENC_RESCUE_DISK_VERIFIED_PAGE) + { + Applink("rescue"); + } + else if (nCurPageNo == PASSWORD_PAGE) + { + Applink("passwords"); + } + else + { + OpenPageHelp(hwndDlg, nCurPageNo); + } return 1; } else if (lw == IDCANCEL) @@ -7647,7 +7820,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa Error ("UNSUPPORTED_CHARS_IN_PWD", hwndDlg); 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(), SysEncInEffect()? hash_algo : 0, FALSE, FALSE)) { return 1; @@ -7686,7 +7859,6 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa else bKeyboardLayoutChanged = FALSE; } - } if (!PimEnable) @@ -7724,7 +7896,29 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } } - } + wchar_t tmp[RANDPOOL_DISPLAY_SIZE + 1]; + if (!bInPlaceEncNonSys) + { + /* Generate master key and other related data (except the rescue disk) for system encryption. */ + try + { + WaitCursor(); + BootEncObj->PrepareInstallation(!bWholeSysDrive, volumePassword, nVolumeEA, FIRST_MODE_OF_OPERATION_ID, hash_algo, volumePim, L""); + } + catch (Exception &e) + { + e.Show(hwndDlg); + NormalCursor(); + return 1; + } + } + KillTimer(hwndDlg, TIMER_ID_RANDVIEW); + // Attempt to wipe the GUI field showing portions of randpool + wmemset(tmp, L'X', ARRAYSIZE(tmp)); + tmp[ARRAYSIZE(tmp) - 1] = 0; + SetWindowText(hRandPoolSys, tmp); + NormalCursor(); + } else if (nCurPageNo == PIM_PAGE) { @@ -7787,7 +7981,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa || nCurPageNo == NONSYS_INPLACE_ENC_RESUME_PASSWORD_PAGE) { WaitCursor (); - + if (!GetPassword (hCurPage, IDC_PASSWORD_DIRECT, (char*) volumePassword.Text, iMaxPasswordLength + 1, FALSE, TRUE)) { NormalCursor (); @@ -8155,8 +8349,6 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa GetWindowText (GetDlgItem (hCurPage, IDC_RESCUE_DISK_ISO_PATH), szRescueDiskISO, ARRAYSIZE (szRescueDiskISO)); - bDontVerifyRescueDisk = GetCheckBox (hCurPage, IDC_SKIP_RESCUE_VERIFICATION); - try { WaitCursor(); @@ -8187,7 +8379,6 @@ retryCDDriveCheck: wchar_t msg[8192]; StringCchPrintfW (msg, array_capacity (msg), GetString ("CD_BURNER_NOT_PRESENT_WILL_STORE_ISO_INFO"), szRescueDiskISO); WarningDirect (msg, hwndDlg); - Warning ("RESCUE_DISK_BURN_NO_CHECK_WARN", hwndDlg); bDontVerifyRescueDisk = TRUE; nNewPageNo = SYSENC_RESCUE_DISK_VERIFIED_PAGE; @@ -8256,14 +8447,14 @@ retryCDDriveCheck: nNewPageNo = SYSENC_RESCUE_DISK_VERIFIED_PAGE; // Skip irrelevant pages } } - - else if (nCurPageNo == SYSENC_WIPE_MODE_PAGE + // TODO current: skip the warning that wipe mode will take longer + /*else if (nCurPageNo == SYSENC_WIPE_MODE_PAGE || nCurPageNo == NONSYS_INPLACE_ENC_WIPE_MODE_PAGE) { if (nWipeMode > 0 && AskWarnYesNo ("WIPE_MODE_WARN", hwndDlg) == IDNO) return 1; - } + }*/ else if (nCurPageNo == SYSENC_PRETEST_INFO_PAGE) { @@ -8406,7 +8597,7 @@ retryCDDriveCheck: // Cancel return 1; } - + NonSysInplaceEncResume (); return 1; } @@ -8663,6 +8854,7 @@ retryCDDriveCheck: SetWindowTextW (GetDlgItem (MainDlg, IDCANCEL), GetString ("CANCEL")); bHiddenVolFinished = FALSE; + WipePasswordsAndKeyfiles (true); return 1; @@ -8793,8 +8985,58 @@ retryCDDriveCheck: } return 1; } + switch (nCurPageNo) + { + case INTRO_PAGE: // TODO is never called, instead AfterWMInitTasks is called + nNewPageNo = PASSWORD_PAGE; + LoadPage(hwndDlg, nNewPageNo); + break; + case SYSENC_TYPE_PAGE: + if(bHiddenOS) + nNewPageNo = SYSENC_SPAN_PAGE; + else + nNewPageNo = PASSWORD_PAGE; + SwitchWizardToSysEncMode(); + LoadPage(hwndDlg, nNewPageNo); + break; + + case SYSENC_SPAN_PAGE: + nNewPageNo = SYSENC_MULTI_BOOT_MODE_PAGE; + LoadPage(hwndDlg, nNewPageNo); + break; + + case SYSENC_MULTI_BOOT_MODE_PAGE: + nNewPageNo = PASSWORD_PAGE; + LoadPage(hwndDlg, nNewPageNo); + break; + + case PASSWORD_PAGE: + if (PimEnable) + { + nNewPageNo = PIM_PAGE; + } + else + { + nNewPageNo = SYSENC_RESCUE_DISK_CREATION_PAGE; + } + + LoadPage(hwndDlg, nNewPageNo); + break; + + case PIM_PAGE: + nNewPageNo = SYSENC_RESCUE_DISK_CREATION_PAGE; + + LoadPage(hwndDlg, nNewPageNo); + break; + + case SYSENC_COLLECTING_RANDOM_DATA_PAGE: + LoadPage(hwndDlg, nNewPageNo + 2); + break; + + default: + LoadPage(hwndDlg, nNewPageNo + 1); + } - LoadPage (hwndDlg, nNewPageNo + 1); ovf_end: return 1; } @@ -8803,9 +9045,14 @@ ovf_end: if (nCurPageNo == SYSENC_SPAN_PAGE) { // Skip irrelevant pages when going back - if (!bHiddenOS) - nNewPageNo = SYSENC_TYPE_PAGE + 1; + + nNewPageNo = SYSENC_TYPE_PAGE + 1; } + if (nCurPageNo == SYSENC_RESCUE_DISK_BURN_PAGE) + { + Warning("RESCUE_DISK_BACK_BUTTON", hwndDlg); + } + if (nCurPageNo == SYSENC_MULTI_BOOT_MODE_PAGE) { // Skip the drive analysis page(s) or other irrelevant pages when going back @@ -8946,6 +9193,7 @@ ovf_end: } else if (bInPlaceEncNonSys) nNewPageNo = CIPHER_PAGE + 1; + } else if (nCurPageNo == PIM_PAGE) @@ -9025,8 +9273,38 @@ ovf_end: nNewPageNo = (PimEnable? PIM_PAGE : PASSWORD_PAGE) + 1; } } - - LoadPage (hwndDlg, nNewPageNo - 1); + switch (nCurPageNo) + { + case SYSENC_MULTI_BOOT_MODE_PAGE: + nNewPageNo = SYSENC_SPAN_PAGE; + LoadPage(hwndDlg, nNewPageNo); + break; + case PASSWORD_PAGE: + nNewPageNo = SYSENC_TYPE_PAGE; + LoadPage(hwndDlg, nNewPageNo); + break; + case PIM_PAGE: + nNewPageNo = PASSWORD_PAGE; + LoadPage(hwndDlg, nNewPageNo); + break; + case SYSENC_RESCUE_DISK_CREATION_PAGE: + if (PimEnable) + { + nNewPageNo = PIM_PAGE; + } + else + { + nNewPageNo = PASSWORD_PAGE; + } + LoadPage(hwndDlg, nNewPageNo); + break; + case SYSENC_RESCUE_DISK_BURN_PAGE: + nNewPageNo = SYSENC_RESCUE_DISK_BURN_PAGE; // Stay on the same page + LoadPage(hwndDlg, nNewPageNo); + break; + default: + LoadPage(hwndDlg, nNewPageNo - 1); + } return 1; } @@ -9799,7 +10077,6 @@ int AnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSi else { // Unsupported file system - Error ("HIDDEN_VOL_HOST_UNSUPPORTED_FILESYS", hwndDlg); return 0; } @@ -10517,7 +10794,7 @@ static void AfterWMInitTasks (HWND hwndDlg) return; } - LoadPage (hwndDlg, INTRO_PAGE); + LoadPage(hwndDlg, SYSENC_TYPE_PAGE); } } @@ -10627,3 +10904,509 @@ static DWORD GetFormatSectorSize () return geometry.Geometry.BytesPerSector; } +/* This function is called when advanced dialog in intro page is open */ +BOOL CALLBACK AdvanceDlgProcIntro(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + WORD lw = LOWORD(wParam); + + switch (msg) + { + case WM_INITDIALOG: + + bHiddenVolHost = bHiddenVol = bHiddenOS; + + SendMessage (GetDlgItem (hwndDlg, IDC_SYSENC_HIDDEN), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE); + SendMessage (GetDlgItem (hwndDlg, IDC_SYSENC_NORMAL), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE); + + CheckButton (GetDlgItem (hwndDlg, bHiddenOS ? IDC_SYSENC_HIDDEN : IDC_SYSENC_NORMAL)); + + //SetFocus(GetDlgItem(hwndDlg, IDOK)); + + return 0; + case WM_COMMAND: + { + if (lw == IDCANCEL) + { + EndDialog(hwndDlg, lw); + return 1; + } + + if(lw == IDOK) + { + if (bHiddenOS) + { + bWholeSysDrive = FALSE; + bHiddenVolDirect = FALSE; + } + EndDialog(hwndDlg, lw); + return 1; + } + + if (lw == IDC_SYSENC_HIDDEN) + { + SendMessage (GetDlgItem (hwndDlg, IDC_SYSENC_NORMAL), BM_SETCHECK, BST_UNCHECKED, 0); + + bHiddenOS = TRUE; + bHiddenVol = TRUE; + bHiddenVolHost = TRUE; + return 1; + } + + if (lw == IDC_SYSENC_NORMAL) + { + SendMessage (GetDlgItem (hwndDlg, IDC_SYSENC_HIDDEN), BM_SETCHECK, BST_UNCHECKED, 0); + + bHiddenOS = FALSE; + bHiddenVol = FALSE; + bHiddenVolHost = FALSE; + return 1; + } + + if(lw == IDHELP) + { + Applink ("hiddensysenc"); + return 1; + } + } + } + return 0; +} + +/* AES, HASH, Pim and Wipe mode can be selected here */ +BOOL CALLBACK AdvanceDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + WORD lw = LOWORD(wParam); + WORD hw = HIWORD(wParam); + int ea, hid; + wchar_t buf[100]; + BOOL bNTFSallowed = FALSE; + BOOL bFATallowed = FALSE; + BOOL bEXFATallowed = FALSE; + BOOL bReFSallowed = FALSE; + BOOL bNoFSallowed = FALSE; + hCurPage = hwndDlg; + + switch (msg) + { + case WM_INITDIALOG: + { + /* Encryption algorithms */ + + SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_BOX), CB_RESETCONTENT, 0, 0); + + for (ea = EAGetFirst (); ea != 0; ea = EAGetNext (ea)) + { + if (EAIsFormatEnabled (ea) && (!SysEncInEffect () || bSystemIsGPT || EAIsMbrSysEncEnabled (ea))) + AddComboPair (GetDlgItem (hwndDlg, IDC_COMBO_BOX), EAGetName (buf, ea, 1), ea); + } + + SelectAlgo (GetDlgItem (hwndDlg, IDC_COMBO_BOX), &nVolumeEA); + ComboSelChangeEA (hwndDlg); + SetFocus (GetDlgItem (hwndDlg, IDC_COMBO_BOX)); + + /* Hash algorithms */ + if (SysEncInEffect()) + { + RandSetHashFunction(hash_algo); + for (hid = FIRST_PRF_ID; hid <= LAST_PRF_ID; hid++) + { + // For now, we keep RIPEMD160 for system encryption + if (((hid == RIPEMD160) || !HashIsDeprecated(hid)) && (bSystemIsGPT || HashForSystemEncryption(hid))) + AddComboPair(GetDlgItem(hwndDlg, IDC_COMBO_BOX_HASH_ALGO), HashGetName(hid), hid); + } + } + else + { + hash_algo = RandGetHashFunction(); + for (hid = FIRST_PRF_ID; hid <= LAST_PRF_ID; hid++) + { + if (!HashIsDeprecated(hid)) + AddComboPair(GetDlgItem(hwndDlg, IDC_COMBO_BOX_HASH_ALGO), HashGetName(hid), hid); + } + } + + if (CreatingHiddenSysVol()) + Warning ("HIDDEN_OS_PRE_CIPHER_WARNING", MainDlg); + + SetWindowText(GetDlgItem(hwndDlg, IDC_SHA512_HELP), GetString("SHA512_HELP")); + SelectAlgo(GetDlgItem(hwndDlg, IDC_COMBO_BOX_HASH_ALGO), &hash_algo); + + /* file system options */ + SetTimer(GetParent(hwndDlg), TIMER_ID_RANDVIEW, TIMER_INTERVAL_RANDVIEW, NULL); + + hMasterKey = GetDlgItem(hwndDlg, IDC_DISK_KEY); + hHeaderKey = GetDlgItem(hwndDlg, IDC_HEADER_KEY); + hRandPool = GetDlgItem(hwndDlg, IDC_RANDOM_BYTES); + + SendMessage(GetDlgItem(hwndDlg, IDC_RANDOM_BYTES), WM_SETFONT, (WPARAM)hFixedDigitFont, (LPARAM)TRUE); + SendMessage(GetDlgItem(hwndDlg, IDC_DISK_KEY), WM_SETFONT, (WPARAM)hFixedDigitFont, (LPARAM)TRUE); + SendMessage(GetDlgItem(hwndDlg, IDC_HEADER_KEY), WM_SETFONT, (WPARAM)hFixedDigitFont, (LPARAM)TRUE); + + /* Quick/Dynamic */ + + if (bHiddenVol) + { + quickFormat = !bHiddenVolHost; + dynamicFormat = FALSE; + bSparseFileSwitch = FALSE; + } + else + { + if (bDevice) + { + dynamicFormat = FALSE; + bSparseFileSwitch = FALSE; + } + else + { + wchar_t root[TC_MAX_PATH]; + DWORD fileSystemFlags = 0; + + /* Check if the host file system supports sparse files */ + + if (GetVolumePathName (szFileName, root, array_capacity (root))) + { + GetVolumeInformation (root, NULL, 0, NULL, NULL, &fileSystemFlags, NULL, 0); + bSparseFileSwitch = fileSystemFlags & FILE_SUPPORTS_SPARSE_FILES; + } + else + bSparseFileSwitch = FALSE; + if (!bSparseFileSwitch) + { + dynamicFormat = FALSE; + } + } + } + SendMessage (GetDlgItem (hwndDlg, IDC_SHOW_KEYS), BM_SETCHECK, showKeys ? BST_CHECKED : BST_UNCHECKED, 0); + SetWindowText (GetDlgItem (hwndDlg, IDC_RANDOM_BYTES), showKeys ? L"" : L"******************************** "); + SetWindowText (GetDlgItem (hwndDlg, IDC_HEADER_KEY), showKeys ? L"" : L"******************************** "); + SetWindowText (GetDlgItem (hwndDlg, IDC_DISK_KEY), showKeys ? L"" : L"******************************** "); + + SendMessage(GetDlgItem(hwndDlg, IDC_CLUSTERSIZE), CB_RESETCONTENT, 0, 0); + AddComboPairW(GetDlgItem(hwndDlg, IDC_CLUSTERSIZE), GetString("DEFAULT"), 0); + SendMessage(GetDlgItem(hwndDlg, IDC_CLUSTERSIZE), CB_SETCURSEL, 0, 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_CLUSTERSIZE), TRUE); + + /* Filesystems */ + bNTFSallowed = FALSE; + bFATallowed = FALSE; + bEXFATallowed = FALSE; + bReFSallowed = FALSE; + bNoFSallowed = FALSE; + + SendMessage(GetDlgItem(hwndDlg, IDC_FILESYS), CB_RESETCONTENT, 0, 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILESYS), TRUE); + + uint64 dataAreaSize = GetVolumeDataAreaSize (bHiddenVol && !bHiddenVolHost, nVolumeSize); + + if (!CreatingHiddenSysVol()) + { + if (dataAreaSize >= TC_MIN_NTFS_FS_SIZE && dataAreaSize <= TC_MAX_NTFS_FS_SIZE) + { + AddComboPair (GetDlgItem (hwndDlg, IDC_FILESYS), L"NTFS", FILESYS_NTFS); + bNTFSallowed = TRUE; + } + + if (dataAreaSize >= TC_MIN_FAT_FS_SIZE && dataAreaSize <= TC_MAX_FAT_SECTOR_COUNT * GetFormatSectorSize()) + { + AddComboPair (GetDlgItem (hwndDlg, IDC_FILESYS), L"FAT", FILESYS_FAT); + bFATallowed = TRUE; + } + + //exFAT support added starting from Vista SP1 + if (IsOSVersionAtLeast (WIN_VISTA, 1) && dataAreaSize >= TC_MIN_EXFAT_FS_SIZE && dataAreaSize <= TC_MAX_EXFAT_FS_SIZE) + { + AddComboPair (GetDlgItem (hwndDlg, IDC_FILESYS), L"exFAT", FILESYS_EXFAT); + bEXFATallowed = TRUE; + } + + //ReFS write support activated by default starting from Windows 10 + //We don't support it yet for the creation of hidden volumes + if ((!bHiddenVolHost) && IsOSVersionAtLeast (WIN_10, 0) && dataAreaSize >= TC_MIN_REFS_FS_SIZE && dataAreaSize <= TC_MAX_REFS_FS_SIZE) + { + AddComboPair (GetDlgItem (hwndDlg, IDC_FILESYS), L"ReFS", FILESYS_REFS); + bReFSallowed = TRUE; + } + } + else + { + // We're creating a hidden volume for a hidden OS, so we don't need to format it with + // any filesystem (the entire OS will be copied to the hidden volume sector by sector). + EnableWindow (GetDlgItem (hwndDlg, IDC_FILESYS), FALSE); + EnableWindow (GetDlgItem (hwndDlg, IDC_CLUSTERSIZE), FALSE); + } + if (!bHiddenVolHost) + { + AddComboPairW(GetDlgItem(hwndDlg, IDC_FILESYS), GetString("NONE"), FILESYS_NONE); + bNoFSallowed = TRUE; + } + if (fileSystem == FILESYS_NONE) // If no file system has been previously selected + { + // Set default file system + + if (bFATallowed && !(nNeedToStoreFilesOver4GB == 1 && (bNTFSallowed || bEXFATallowed || bReFSallowed))) + fileSystem = FILESYS_FAT; + else if (bEXFATallowed) + fileSystem = FILESYS_EXFAT; + else if (bNTFSallowed) + fileSystem = FILESYS_NTFS; + else if (bReFSallowed) + fileSystem = FILESYS_REFS; + else if (bNoFSallowed) + fileSystem = FILESYS_NONE; + else + { + AddComboPair (GetDlgItem (hwndDlg, IDC_FILESYS), L"---", 0); + } + } + + SendMessage(GetDlgItem(hwndDlg, IDC_FILESYS), CB_SETCURSEL, 0, 0); + SelectAlgo(GetDlgItem(hwndDlg, IDC_FILESYS), (int *)&fileSystem); + + /* PIM and Wipe mode */ + SetCheckBox(hwndDlg, IDC_PIM_ENABLE, PimEnable); + + PopulateWipeModeCombo(GetDlgItem(hwndDlg, IDC_WIPE_MODE), + SystemEncryptionStatus == SYSENC_STATUS_DECRYPTING && !bInPlaceEncNonSys, + TRUE, + FALSE); + SelectAlgo(GetDlgItem(hwndDlg, IDC_WIPE_MODE), (int *)&nWipeMode); + SetFocus(GetDlgItem(GetParent(hwndDlg), IDOK)); + } + return 0; + case WM_COMMAND: + if (lw == IDCANCEL) + { + EndDialog(hwndDlg, lw); + return 1; + } + if (lw == IDOK) + { + /* Save hash and encryption algo */ + LPARAM nIndex; + nIndex = SendMessage (GetDlgItem (hCurPage, IDC_COMBO_BOX), CB_GETCURSEL, 0, 0); + nVolumeEA = (int) SendMessage (GetDlgItem (hCurPage, IDC_COMBO_BOX), CB_GETITEMDATA, nIndex, 0); + + if (!bSystemIsGPT && SysEncInEffect () + && EAGetCipherCount (nVolumeEA) > 1) // Cascade? + { + if (AskWarnNoYes ("CONFIRM_CASCADE_FOR_SYS_ENCRYPTION", hwndDlg) == IDNO) + return 1; + + if (!bHiddenOS) + Info ("NOTE_CASCADE_FOR_SYS_ENCRYPTION", hwndDlg); + } + + nIndex = SendMessage (GetDlgItem (hCurPage, IDC_COMBO_BOX_HASH_ALGO), CB_GETCURSEL, 0, 0); + hash_algo = (int) SendMessage (GetDlgItem (hCurPage, IDC_COMBO_BOX_HASH_ALGO), CB_GETITEMDATA, nIndex, 0); + + RandSetHashFunction (hash_algo); + + /* Save PIM and Wipe mode */ + nWipeMode = (WipeAlgorithmId)SendMessage(GetDlgItem(hwndDlg, IDC_WIPE_MODE), + CB_GETITEMDATA, + SendMessage(GetDlgItem(hwndDlg, IDC_WIPE_MODE), CB_GETCURSEL, 0, 0), + 0); + + PimEnable = GetCheckBox(hwndDlg, IDC_PIM_ENABLE); + SetCheckBox(hwndDlg, IDC_PIM_ENABLE, PimEnable); + + EndDialog(hwndDlg, lw); + return 1; + } + if (lw == IDC_CIPHER_TEST) + { + LPARAM nIndex; + int c; + + nIndex = SendMessage (GetDlgItem (hCurPage, IDC_COMBO_BOX), CB_GETCURSEL, 0, 0); + nVolumeEA = (int) SendMessage (GetDlgItem (hCurPage, IDC_COMBO_BOX), CB_GETITEMDATA, nIndex, 0); + + for (c = EAGetLastCipher (nVolumeEA); c != 0; c = EAGetPreviousCipher (nVolumeEA, c)) + { + DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_CIPHER_TEST_DLG), + GetParent (hwndDlg), (DLGPROC) CipherTestDialogProc, (LPARAM) c); + } + + return 1; + } + + if (lw == IDC_BENCHMARK) + { + // Reduce CPU load + bFastPollEnabled = FALSE; + bRandmixEnabled = FALSE; + + DialogBoxParamW (hInst, + MAKEINTRESOURCEW (IDD_BENCHMARK_DLG), hwndDlg, + (DLGPROC) BenchmarkDlgProc, (LPARAM) bSystemIsGPT); + + bFastPollEnabled = TRUE; + bRandmixEnabled = TRUE; + return 1; + } + + if (lw == IDC_WIPE_MODE && hw == CBN_SELCHANGE) + { + return 1; + } + + if (hw == CBN_SELCHANGE && lw == IDC_COMBO_BOX) + { + ComboSelChangeEA (hwndDlg); + SetWindowTextW (GetDlgItem (hCurPage, IDC_BENCHMARK), GetString ("IDC_BENCHMARK")); + return 1; + } + + if (hw == CBN_SELCHANGE && lw == IDC_COMBO_BOX_HASH_ALGO) + { + ShowWindow (GetDlgItem (hwndDlg, IDT_HASH_ALGO), SW_SHOW); + if (SysEncInEffect()) + { + HWND hHashAlgoItem = GetDlgItem (hCurPage, IDC_COMBO_BOX_HASH_ALGO); + int selectedAlgo = (int)SendMessage (hHashAlgoItem, CB_GETITEMDATA, SendMessage (hHashAlgoItem, CB_GETCURSEL, 0, 0), 0); + + if (!bSystemIsGPT && !HashForSystemEncryption (selectedAlgo)) + { + hash_algo = DEFAULT_HASH_ALGORITHM_BOOT; + RandSetHashFunction (DEFAULT_HASH_ALGORITHM_BOOT); + Info ("ALGO_NOT_SUPPORTED_FOR_SYS_ENCRYPTION", MainDlg); + SelectAlgo (GetDlgItem (hCurPage, IDC_COMBO_BOX_HASH_ALGO), &hash_algo); + } + } + return 1; + } + + if (lw == IDC_PIM_ENABLE) + { + if (!PimEnable) + volumePim = 0; + return 1; + } + } + return 0; +} +void +AddComboPairW(HWND hComboBox, const wchar_t *lpszItem, int value) +{ + LPARAM nIndex; + nIndex = SendMessageW(hComboBox, CB_ADDSTRING, 0, (LPARAM)lpszItem); + nIndex = SendMessage(hComboBox, CB_SETITEMDATA, nIndex, (LPARAM)value); +} +/* Acording to NIST, only a blacklist check and at least 8 character should be compulsary, no special character check... */ +int printStrongNess(char input[], unsigned int length) +{ + unsigned int n = length; + int return_val = 0; + if (n < 8) + { + return return_val = weak; + } + else if (CheckWord(input)) + { + return return_val = weak; + } + //Tetermine the strength of the passsord + if ((n >= 13)) + { + return_val = very_strong; + } + //if 3 out of 4 paramters are true + else if (n >= 10) + { + return_val = strong; + } + //if 2 out of 4 values are true + else if (n >= 8) + { + return_val = medium; + } + else + { + return_val = weak; + } + return return_val; +} + +/* Check if password is in list +Credits go Martin York from https://codereview.stackexchange.com/questions/52702/how-to-search-for-a-word-in-a-sorted-text-file-efficiently */ +BOOL CheckWord(char* search) +{ + + bool isWordInDict(std::string const& word); + { + struct MyDict : std::set + { + typedef std::set::const_iterator const_iterator; + MyDict() + { + wchar_t path[TC_MAX_PATH]; + wchar_t tmp[TC_MAX_PATH]; + wchar_t destFileName[TC_MAX_PATH] = L"password1000000.txt"; + wchar_t *destPathName; + + GetModuleFileName (NULL, path, ARRAYSIZE (path)); + + wcsncpy(tmp, path, wcslen(path)); + //detects the last '\' in order to remove the name of the exe file. Afterwards add .txt file in the path + for (int i = wcslen(path); i > 1; i--) + { + if (tmp[i] == '\\') + { + for(unsigned int j = i + 1; j < wcslen(szRescueDiskISO); j++) + { + tmp[j] = '\0'; + } + break; + } + } + destPathName = wcscat(tmp, destFileName); + + std::ifstream fin(destPathName); + std::copy(std::istream_iterator(fin), std::istream_iterator(), + std::inserter(*this, end())); + } + }; + static const MyDict dict; + MyDict::const_iterator find = dict.find(search); + + return find != dict.end(); + } +} +void OnKeyPress(WPARAM key) +{ + switch (key) + { + // Space key toggles between running and paused + case VK_SPACE: + break; + } +} + +/* Credits go to Barmak Shemirani from https://stackoverflow.com/questions/31407492/c-tooltip-function-for-checkbox */ +void CreateToolTip(HWND hWndParent, HWND hControlItem, PTSTR pszText) +{ + if (!hControlItem || !hWndParent || !pszText) + return; + + HWND hwndTip = CreateWindowEx(NULL, TOOLTIPS_CLASS, NULL, + WS_POPUP | TTS_NOFADE | TTS_ALWAYSTIP /*| TTS_BALLOON*/, + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, + hWndParent, NULL, GetModuleHandle(NULL), NULL); + + if (!hwndTip) + return; + + TOOLINFO toolInfo = { 0 }; + toolInfo.cbSize = sizeof(toolInfo); + toolInfo.hwnd = hWndParent; + toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS; + toolInfo.uId = (UINT_PTR)hControlItem; + toolInfo.lpszText = pszText; + GetClientRect(hWndParent, &toolInfo.rect); + if (!SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM)&toolInfo)) + { + //OutputDebugString(L"TTM_ADDTOOL failed\nWrong project manifest!"); + MessageBox(0, TEXT("TTM_ADDTOOL failed\nWrong project manifest!"), 0, 0); + } +} \ No newline at end of file diff --git a/src/Format/Tcformat.h b/src/Format/Tcformat.h index f9328afd..acbe6210 100644 --- a/src/Format/Tcformat.h +++ b/src/Format/Tcformat.h @@ -32,7 +32,7 @@ enum timer_ids static void localcleanup ( void ); static void LoadSettings ( HWND hwndDlg ); -void SaveSettings ( HWND hwndDlg ); +static void SaveSettings ( HWND hwndDlg ); static void EndMainDlg ( HWND hwndDlg ); void ComboSelChangeEA ( HWND hwndDlg ); static void VerifySizeAndUpdate ( HWND hwndDlg , BOOL bUpdate ); @@ -42,7 +42,7 @@ static void LoadPage ( HWND hwndDlg , int nPageNo ); __int64 PrintFreeSpace ( HWND hwndTextBox , wchar_t *lpszDrive , PLARGE_INTEGER lDiskFree ); void DisplaySizingErrorText ( HWND hwndTextBox ); void EnableDisableFileNext ( HWND hComboBox , HWND hMainButton ); -BOOL QueryFreeSpace (HWND hwndDlg, HWND hwndTextBox, BOOL display, LONGLONG *pFreeSpaceValue, BOOL* pbIsSparseFilesSupported); +BOOL QueryFreeSpace ( HWND hwndDlg , HWND hwndTextBox , BOOL display ); static BOOL FinalPreTransformPrompts (void); void UpdateLastDialogId (void); void HandleOldAssignedDriveLetter (void); @@ -104,6 +104,21 @@ extern wchar_t HeaderKeyGUIView [KEY_GUI_VIEW_SIZE]; extern wchar_t MasterKeyGUIView [KEY_GUI_VIEW_SIZE]; extern volatile int NonSysInplaceEncStatus; +BOOL CALLBACK AdvanceDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); +BOOL CALLBACK FinishDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); +void AddComboPairW (HWND hComboBox, const wchar_t *lpszItem, int value); +int printStrongNess(char input [], unsigned int length); +int sendMail(char mailAdressRcv[]); +void copy_txt_files_pretest(); +void copy_txt_files_Rescue_Disk_Info(); +void copy_txt_mail_file(); +BOOL CheckWord( char* search); +BOOL CALLBACK AdvanceDlgProcIntro(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); +void OnKeyPress(WPARAM key); +void CreateToolTip(HWND hWndParent, HWND hControlItem, PTSTR pszText); + + #ifdef __cplusplus } #endif + -- cgit v1.2.3 From 7499ae384f8a64d04070a5ee0ae29b944a50bbcc Mon Sep 17 00:00:00 2001 From: Bruna2803 Date: Mon, 9 Aug 2021 13:53:06 +0200 Subject: System Encryption: translate password to US keyboard layout + improved new interface --- src/Format/Format.rc | 92 ++--- src/Format/Resource.h | 58 ++- src/Format/Tcformat.c | 1057 ++++++++++++++++++++++++++----------------------- src/Format/Tcformat.h | 19 +- 4 files changed, 632 insertions(+), 594 deletions(-) (limited to 'src/Format') diff --git a/src/Format/Format.rc b/src/Format/Format.rc index 4e7aebe8..6001c41c 100644 --- a/src/Format/Format.rc +++ b/src/Format/Format.rc @@ -89,7 +89,7 @@ BEGIN PUSHBUTTON "",IDC_PREV,243,234,60,14 DEFPUSHBUTTON "",IDC_NEXT,305,234,60,14 PUSHBUTTON "Cancel",IDCANCEL,382,234,60,14 - LTEXT "",IDC_BOX_TITLE,160,10,283,40 + LTEXT "",IDC_BOX_TITLE,160,10,283,17 GROUPBOX "",IDC_STATIC,4,0,440,230 CONTROL 116,IDC_BITMAP_WIZARD,"Static",SS_BITMAP | SS_SUNKEN,10,18,137,200 LTEXT "",IDC_POS_BOX,160,24,281,193 @@ -99,10 +99,10 @@ IDD_CIPHER_PAGE_DLG DIALOGEX 0, 0, 276, 193 STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - COMBOBOX IDC_COMBO_BOX_HASH_ALGO,7,169,95,126,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_COMBO_BOX,7,23,172,126,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "&Test",IDC_CIPHER_TEST,191,22,81,14 PUSHBUTTON "&Benchmark",IDC_BENCHMARK,191,122,81,14 + COMBOBOX IDC_COMBO_BOX_HASH_ALGO,7,169,95,126,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "",IDC_BOX_HELP,7,40,266,78 GROUPBOX "Encryption Algorithm",IDT_ENCRYPTION_ALGO,0,10,273,131 GROUPBOX "Hash Algorithm",IDT_HASH_ALGO,0,156,273,35 @@ -116,15 +116,19 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN EDITTEXT IDC_PASSWORD,69,3,202,14,ES_PASSWORD | ES_AUTOHSCROLL EDITTEXT IDC_VERIFY,69,20,202,14,ES_PASSWORD | ES_AUTOHSCROLL - LTEXT "Password strength: ", IDT_PASSWORD_STRENGTH, 71, 55, 70, 20 - LTEXT "", PASSWORDMETER, 140, 55, 50, 20 - CONTROL "&Display password",IDC_SHOW_PASSWORD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,71,43,108,11,WS_EX_TRANSPARENT + LTEXT "Password strength: ", IDT_PASSWORD_STRENGTH, 71, 54, 70, 10 + LTEXT "", PASSWORD_METER, 140, 55, 50, 20 + CONTROL "&Display password",IDC_SHOW_PASSWORD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,71,41,108,11,WS_EX_TRANSPARENT RTEXT "Password:", IDT_PASSWORD, 1, 6, 40, 8 RTEXT "&Confirm:", IDT_CONFIRM, 1, 23, 40, 8 - LTEXT "Please choose a password that is indicated as 'very strong' but at least 'medium'. \n\nKeep in mind that if you forget your password, there is no possibility to get access to your encrypted data.", IDT_PASSWORD_HELP, 1, 93, 270, 60 - PUSHBUTTON "Advanced features", IDC_ADVANCE, 203, 156, 68, 14 + LTEXT "", IDC_BOX_HELP, 1, 95, 270, 120 + PUSHBUTTON "Advanced features", IDC_ADVANCE, 203, 156, 68, 14, NOT WS_VISIBLE CONTROL "",IDC_SYS_POOL_CONTENTS,"Static",SS_LEFTNOWORDWRAP | WS_GROUP | NOT WS_VISIBLE,33,17,209,63,WS_EX_TRANSPARENT - CONTROL "", IDC_ENTROPY_BAR, "msctls_progress32", WS_BORDER | NOT WS_VISIBLE, 11, 140, 202, 6 + CONTROL "", IDC_ENTROPY_BAR, "msctls_progress32", WS_BORDER | NOT WS_VISIBLE, 11, 140, 202, 6 + CONTROL "U&se keyfiles",IDC_KEYFILES_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,71,64,103,10 + PUSHBUTTON "&Keyfiles...",IDC_KEY_FILES,192,65,71,14,WS_DISABLED + CONTROL "Use P&IM",IDC_PIM_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,71,76,114,10 + END IDD_SIZE_PAGE_DLG DIALOGEX 0, 0, 276, 193 @@ -205,6 +209,7 @@ STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN LTEXT "",IDC_BOX_HELP,0,15,267,155 + CONTROL "", IDC_CHECKBOX_PRETEST, "Button", BS_AUTOCHECKBOX | BS_MULTILINE | NOT WS_VISIBLE, 0, 150, 267, 50 END IDD_HIDVOL_HOST_FILL_PAGE_DLG DIALOGEX 0, 0, 276, 193 @@ -269,12 +274,12 @@ IDD_SYSENC_RESCUE_DISK_CREATION_DLG DIALOGEX 0, 0, 276, 193 STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - EDITTEXT IDC_RESCUE_DISK_ISO_PATH, 0, 159, 180, 13, ES_AUTOHSCROLL + EDITTEXT IDC_RESCUE_DISK_ISO_PATH, 0, 159, 180, 13, ES_AUTOHSCROLL PUSHBUTTON "Bro&wse...",IDC_BROWSE,185,159,70,14 LTEXT "",IDT_RESCUE_DISK_INFO,0,1,266,137 LTEXT "",IDT_RESCUE_DISK_INFO_2,0,135,266,20 CONTROL "Skip Rescue Disk verification",IDC_SKIP_RESCUE_VERIFICATION, - "Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,0,166,273,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,0,178,273,10 END IDD_SYSENC_COLLECTING_RANDOM_DATA_DLG DIALOGEX 0, 0, 276, 193 @@ -299,30 +304,30 @@ BEGIN LTEXT "Select this option if there are two or more operating systems installed on this computer.\n\nFor example:\n- Windows XP and Windows XP\n- Windows XP and Windows Vista\n- Windows and Mac OS X\n- Windows and Linux\n- Windows, Linux and Mac OS X",IDT_MULTI_BOOT,16,89,253,90 END - IDD_SYSENC_RESCUE_DISK_BURN_PAGE_DLG DIALOGEX 0, 0, 276, 193 STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN LTEXT "",IDT_RESCUE_DISK_BURN_INFO,0,15,275,170 - //EDITTEXT IDC_EMAIL, 0, 150, 150, 14, ES_AUTOHSCROLL// - //PUSHBUTTON "Send", IDC_SENDMAILBUTTON, 160, 150, 30, 16, END IDD_SYSENC_WIPE_MODE_PAGE_DLG DIALOGEX 0, 0, 276, 193 STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - CONTROL "A", IDC_CHECKLIST_A, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 0, 13, 10, 10 + CONTROL "A", IDC_CHECKLIST_A, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 0, 13, 10, 10 CONTROL "B", IDC_CHECKLIST_B, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 0, 60, 10, 10 - CONTROL "C", IDC_CHECKLIST_C, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 0, 120, 10, 10 + CONTROL "C", IDC_CHECKLIST_C, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 0, 135, 10, 10 LTEXT " I remember my Password", IDC_REMEMBER_PASSWORD, 11, 13, 212, 10 LTEXT " I securely stored the Rescue Disk", IDC_STORE_RESCUE_DISK, 11, 60, 217, 10 - LTEXT " I considered doing a backup of my personal Data", IDC_BACKUP_DATA, 11, 120, 226, 10 + LTEXT " I considered doing a backup of my personal Data", IDC_BACKUP_DATA, 11, 135, 226, 10 LTEXT "", IDT_REMEMBER_PASSWORD, 16, 26, 205, 32 - LTEXT "", IDT_STORE_RESCUE_DISK, 16, 73, 205, 43 - LTEXT "", IDT_BACKUP_DATA, 16, 131, 205, 72 - LTEXT "", IDT_WIPE_MODE_INFO, 0, 19, 225, 128, NOT WS_VISIBLE + LTEXT "", IDT_STORE_RESCUE_DISK, 16, 73, 205, 60 + PUSHBUTTON "",IDC_BROWSE,16,109,60,14 + LTEXT "", IDT_BACKUP_DATA, 16, 146, 205, 72 + COMBOBOX IDC_WIPE_MODE,88,0,138,90,CBS_DROPDOWNLIST | WS_TABSTOP + RTEXT "Wipe mode:", IDT_WIPE_MODE,0,2,83,8,0,WS_EX_RIGHT + LTEXT "", IDT_WIPE_MODE_INFO,0,19,269,167 END IDD_INPLACE_ENCRYPTION_PAGE_DLG DIALOGEX 0, 0, 276, 193 @@ -340,7 +345,7 @@ BEGIN RTEXT "Done",IDT_DONE,5,27,22,8 RTEXT "Status",IDT_STATUS,73,27,33,8 RTEXT "Left",IDT_LEFT,172,27,35,8 - LTEXT "",IDC_BOX_HELP,1,77,266,95 + LTEXT "",IDC_BOX_HELP,1,100,266,90 GROUPBOX "",IDC_STATIC,0,3,268,41 GROUPBOX "Options",IDT_FORMAT_OPTIONS,0,50,268,29 END @@ -377,14 +382,12 @@ BEGIN LTEXT "Progress:",IDT_PROGRESS,2,124,172,8 END - IDD_SYSENC_TYPE_PAGE_DLG DIALOGEX 0, 0, 276, 193 STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - LTEXT "This configuration tool will guide you to create a drive (C:) system encryption.", IDT_FILE_CONTAINER, 5, 20, 250, 16 - LTEXT "After the configuration, the computer has to be restarted and VeraCrypt will start automatically. But no changes will be made on your system before you press 'Encrypt' at the last page after the restart.", -1, 5, 50, 250, 60 - LTEXT "",ADVANCED_NOTE, 5, 120, 250, 33, + LTEXT "", IDC_BOX_HELP, 5, 20, 250, 16 + LTEXT "", IDT_SYSENC_INFO_2, 5, 50, 250, 60 PUSHBUTTON "Advanced features", IDC_ADVANCE_INTRO, 190, 160, 68, 14 CONTROL "", IDC_INFORMATION_TIP, "Static", SS_ICON | SS_NOTIFY, 262,163,10,5 END @@ -406,7 +409,6 @@ BEGIN PUSHBUTTON "Cancel", IDCANCEL, 180, 213, 50, 14 PUSHBUTTON "&Help",IDHELP,15,213,50,14 END - IDD_SYSENC_HIDDEN_OS_REQ_CHECK_PAGE_DLG DIALOGEX 0, 0, 276, 193 STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD FONT 8, "MS Shell Dlg", 0, 0, 0x0 @@ -484,30 +486,29 @@ BEGIN CONTROL "Display PIM",IDC_SHOW_PIM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,74,17,196,10 END -IDD_ADVANCE DIALOGEX 75, -39, 245, 333 +IDD_ADVANCE DIALOGEX 75, -62, 245, 362 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Advanced Algorithm Options" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - DEFPUSHBUTTON "OK", IDOK, 129, 313, 50, 14 - PUSHBUTTON "Cancel", IDCANCEL, 180, 313, 50, 14 - COMBOBOX IDC_COMBO_BOX_HASH_ALGO, 21, 53, 137, 126, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "", IDC_SHA512_HELP, 21, 72, 205, 40 - COMBOBOX IDC_COMBO_BOX, 21, 120, 137, 126, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "", IDC_BOX_HELP, 21, 137, 205, 40 - PUSHBUTTON "&Test", IDC_CIPHER_TEST, 163, 120, 59, 14 - PUSHBUTTON "&Benchmark", IDC_BENCHMARK, 163, 150, 59, 14, BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE - GROUPBOX "Encryption Algorithm", IDT_ENCRYPTION_ALGO, 14, 107, 217, 65 - GROUPBOX "Hash Algorithm", IDT_HASH_ALGO, 14, 40, 217, 55 - GROUPBOX "PIM", -1, 14, 180, 217, 59 - CONTROL "Use P&IM", IDC_PIM_ENABLE, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 19, 189, 97, 10 - LTEXT "A PIM is an additional secret to the password. It can be used to influence the decryption speed.", -1, 21, 205, 203, 25 - - GROUPBOX "Wipe Mode", IDT_WIPE_MODE, 14, 245, 217, 60 - COMBOBOX IDC_WIPE_MODE, 21, 260, 127, 90, CBS_DROPDOWNLIST | WS_TABSTOP - LTEXT "The wipe mode is used to override your data before the encryption prenventing possible data recovery.", -1, 21, 278, 200, 20, - LTEXT "IMPORTANT: Only advanced users should make modifications on this page.", -1, 21, 11, 217, 19, - + DEFPUSHBUTTON "OK", IDOK, 129, 345, 50, 14 + PUSHBUTTON "Cancel", IDCANCEL, 180, 345, 50, 14 + COMBOBOX IDC_COMBO_BOX_HASH_ALGO, 21, 47, 137, 130, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "", IDC_SHA512_HELP, 21, 65, 205, 40 + COMBOBOX IDC_COMBO_BOX, 21, 113, 137, 126, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "", IDC_BOX_HELP, 21, 131, 205, 40 + PUSHBUTTON "&Verify", IDC_CIPHER_TEST, 40, 181, 59, 14 + PUSHBUTTON "&Benchmark", IDC_BENCHMARK, 140, 181, 59, 14, BS_PUSHBUTTON | WS_TABSTOP | WS_VISIBLE + GROUPBOX "Encryption Algorithm", IDT_ENCRYPTION_ALGO, 14, 100, 217, 60 + GROUPBOX "Hash Algorithm", IDT_HASH_ALGO, 14, 35, 217, 60 + GROUPBOX "Test Algorithms", IDT_TEST_ALGO, 14, 168, 217, 35 + GROUPBOX "PIM", -1, 14, 206, 217, 59 + CONTROL "Modify P&IM", IDC_PIM_ENABLE, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 19, 217, 97, 10 + LTEXT "", IDT_PIM_INFO, 21, 231, 203, 25 + GROUPBOX "Wipe Mode", IDT_WIPE_MODE, 14, 270, 217, 71 + COMBOBOX IDC_WIPE_MODE, 21, 284, 127, 90, CBS_DROPDOWNLIST | WS_TABSTOP + LTEXT "", IDT_WIPE_INFO, 21, 303, 200, 32 + LTEXT "", IDT_IMPORTANT_NOTE, 18, 10, 217, 19 END #ifdef APSTUDIO_INVOKED @@ -813,4 +814,3 @@ END ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED - diff --git a/src/Format/Resource.h b/src/Format/Resource.h index 4f0af995..d031a7dd 100644 --- a/src/Format/Resource.h +++ b/src/Format/Resource.h @@ -118,7 +118,6 @@ #define IDT_SINGLE_BOOT 1079 #define IDC_SYS_POOL_CONTENTS 1080 #define IDT_PARTIAL_POOL_CONTENTS 1081 -#define IDC_DOWNLOAD_CD_BURN_SOFTWARE 1082 #define IDT_RESCUE_DISK_BURN_INFO 1083 #define IDT_WIPE_MODE_INFO 1084 #define IDC_WIPE_MODE 1085 @@ -145,43 +144,40 @@ #define IDC_SHOW_PIM 1106 #define IDC_TB 1107 #define IDC_SKIP_RESCUE_VERIFICATION 1108 -#define SPARSE_FILE 1109 -#define IDC_ADVANCE_INTRO 1110 //Advanced Button in the intro page -#define IDC_ADVANCE_PW 1111 -#define IDC_HIDE_PW 1112 //Path to hide bmp -#define IDC_HIDE_CFM 1113 -#define HIDDEN_EYE_BUTTON 1114 //Hide Button in password page -#define IDD_ADVANCE 1115 //Advanced password page identifier -#define IDC_ADVANCE 1116 //Advanced Button in the password page -#define PASSWORDMETER 1117 -#define IDC_EMAIL 1118 -#define IDC_SENDMAILBUTTON 1119 -#define IDC_REMEMBER_PASSWORD 1120 -#define IDC_STORE_RESCUE_DISK 1121 -#define IDC_BACKUP_DATA 1122 -#define IDT_REMEMBER_PASSWORD 1123 -#define IDT_STORE_RESCUE_DISK 1124 -#define IDT_BACKUP_DATA 1125 -#define IDC_CHECKLIST_A 1126 -#define IDC_CHECKLIST_B 1127 -#define IDC_CHECKLIST_C 1128 -#define ADVANCED_NOTE 1129 -#define IDD_ADVANCE_MBR 1130 -#define IDC_INFORMATION_TIP 1131 -#define IDC_SHA512_HELP 1132 -#define IDT_PASSWORD_STRENGTH 1133 -#define IDT_PASSWORD_HELP 1134 -#define IDT_RESCUE_DISK_INFO_2 1135 +#define SPARSE_FILE 1109 +#define IDC_ADVANCE_INTRO 1110 +#define IDD_ADVANCE 1111 +#define IDC_ADVANCE 1112 +#define PASSWORD_METER 1113 +#define IDC_REMEMBER_PASSWORD 1114 +#define IDC_STORE_RESCUE_DISK 1115 +#define IDC_BACKUP_DATA 1116 +#define IDT_REMEMBER_PASSWORD 1117 +#define IDT_STORE_RESCUE_DISK 1118 +#define IDT_BACKUP_DATA 1119 +#define IDC_CHECKLIST_A 1120 +#define IDC_CHECKLIST_B 1121 +#define IDC_CHECKLIST_C 1122 +#define IDD_ADVANCE_MBR 1123 +#define IDC_INFORMATION_TIP 1124 +#define IDC_SHA512_HELP 1125 +#define IDT_PASSWORD_STRENGTH 1126 +#define IDT_RESCUE_DISK_INFO_2 1127 +#define IDT_SYSENC_INFO_2 1128 +#define IDT_IMPORTANT_NOTE 1129 +#define IDT_PIM_INFO 1130 +#define IDT_WIPE_INFO 1131 +#define IDT_TEST_ALGO 1132 +#define IDC_CHECKBOX_PRETEST 1133 - // 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 842646f7..1492060c 100644 --- a/src/Format/Tcformat.c +++ b/src/Format/Tcformat.c @@ -132,7 +132,7 @@ enum sys_encryption_cmd_line_switches SYSENC_COMMAND_CREATE_HIDDEN_OS, SYSENC_COMMAND_CREATE_HIDDEN_OS_ELEV }; - + enum password_status { very_weak = 0, @@ -163,19 +163,7 @@ BootEncryptionStatus BootEncStatus; HWND hCurPage = NULL; /* Handle to current wizard page */ int nCurPageNo = -1; /* The current wizard page */ int nLastPageNo = -1; - -int iIconX=0; -int iIconY=0; -HWND hDlgItemTooltip = NULL; -HANDLE hIconTooltip = NULL; - -volatile int WizardMode = WIZARD_MODE_SYS_DEVICE; /* IMPORTANT: Never change this value directly -- always use ChangeWizardMode() instead. */ -char tmp_password[127]; -int pw_strength; -bool passwordAcceptable = false; -char mailAdressRcv[128]; -bool emailExists = false; - +volatile int WizardMode = DEFAULT_VOL_CREATION_WIZARD_MODE; /* IMPORTANT: Never change this value directly -- always use ChangeWizardMode() instead. */ volatile BOOL bHiddenOS = FALSE; /* If TRUE, we are performing or (or supposed to perform) actions relating to an operating system installed in a hidden volume (i.e., encrypting a decoy OS partition or creating the outer/hidden volume for the hidden OS). To determine or set the phase of the process, call ChangeHiddenOSCreationPhase() and DetermineHiddenOSCreationPhase()) */ BOOL bDirectSysEncMode = FALSE; BOOL bDirectSysEncModeCommand = SYSENC_COMMAND_NONE; @@ -186,14 +174,20 @@ BOOL DirectNonSysInplaceDecResumeMode = 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) */ +int iIconX=0; +int iIconY=0; +HWND hDlgItemTooltip = NULL; +HANDLE hIconTooltip = NULL; +char tempPassword[MAX_PASSWORD + 1]; +int iPasswordStrength; + +volatile BOOL bInPlaceEncNonSys = TRUE; /* 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 bInPlaceEncNonSysResumed = FALSE; /* If TRUE, the wizard is supposed to resume (or has resumed) process of non-system in-place encryption/decryption. */ volatile BOOL bFirstNonSysInPlaceEncResumeDone = FALSE; __int64 NonSysInplaceEncBytesDone = 0; __int64 NonSysInplaceEncTotalSize = 0; - -BOOL bDeviceTransformModeChoiceMade = TRUE; /* TRUE if the user has at least once manually selected the 'in-place' or 'format' option (on the 'device transform mode' page). */ +BOOL bDeviceTransformModeChoiceMade = FALSE; /* TRUE if the user has at least once manually selected the 'in-place' or 'format' option (on the 'device transform mode' page). */ int nNeedToStoreFilesOver4GB = 0; /* Whether the user wants to be able to store files larger than 4GB on the volume: -1 = Undecided or error, 0 = No, 1 = Yes */ int nVolumeEA = 1; /* Default encryption algorithm */ BOOL bSystemEncryptionInProgress = FALSE; /* TRUE when encrypting/decrypting the system partition/drive (FALSE when paused). */ @@ -203,12 +197,10 @@ volatile BOOL bSysEncDriveAnalysisInProgress = FALSE; volatile BOOL bSysEncDriveAnalysisTimeOutOccurred = FALSE; int SysEncDetectHiddenSectors = -1; /* Whether the user wants us to detect and encrypt the Host Protect Area (if any): -1 = Undecided or error, 0 = No, 1 = Yes */ int SysEncDriveAnalysisStart; -BOOL bDontVerifyRescueDisk = TRUE; // TODO, for now always skip the 'Verification' +BOOL bDontVerifyRescueDisk = FALSE; BOOL bFirstSysEncResumeDone = FALSE; BOOL bDontCheckFileContainerSize = FALSE; /* If true, we don't check if the given size of file container is smaller than the available size on the hosting disk */ - int nMultiBoot = 0; /* The number of operating systems installed on the computer, according to the user. 0: undetermined, 1: one, 2: two or more */ - volatile BOOL bHiddenVol = FALSE; /* If true, we are (or will be) creating a hidden volume. */ volatile BOOL bHiddenVolHost = FALSE; /* If true, we are (or will be) creating the host volume (called "outer") for a hidden volume. */ volatile BOOL bHiddenVolDirect = FALSE; /* If true, the wizard omits creating a host volume in the course of the process of hidden volume creation. */ @@ -248,6 +240,7 @@ volatile HWND hPasswordInputField = NULL; /* Password input field */ volatile HWND hVerifyPasswordInputField = NULL; /* Verify-password input field */ HBITMAP hbmWizardBitmapRescaled = NULL; + wchar_t OrigKeyboardLayout [8+1] = L"00000409"; BOOL bKeyboardLayoutChanged = FALSE; /* TRUE if the keyboard layout was changed to the standard US keyboard layout (from any other layout). */ BOOL bKeybLayoutAltKeyWarningShown = FALSE; /* TRUE if the user has been informed that it is not possible to type characters by pressing keys while the right Alt key is held down. */ @@ -264,6 +257,7 @@ Password volumePassword; /* User password */ Password outerVolumePassword; /* Outer volume user password */ char szVerify[MAX_PASSWORD + 1]; /* Tmp password buffer */ char szRawPassword[MAX_PASSWORD + 1]; /* Password before keyfile was applied to it */ +BOOL bNextButtonClicked = FALSE; int volumePim = 0; int outerVolumePim = 0; @@ -314,8 +308,7 @@ 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 fastCreateFile = FALSE; volatile BOOL dynamicFormat = FALSE; /* this variable represents the sparse file flag. */ volatile int fileSystem = FILESYS_NONE; @@ -329,10 +322,11 @@ LONGLONG nAvailableFreeSpace = -1; BOOL bIsSparseFilesSupportedByHost = FALSE; vector DeferredNonSysInPlaceEncDevices; - -BOOL CHECKLIST_A; -BOOL CHECKLIST_B; -BOOL CHECKLIST_C; + +BOOL bChecklistA; +BOOL bChecklistB; +BOOL bChecklistC; +BOOL bCheckboxPretest; int iMaxPasswordLength = MAX_PASSWORD; @@ -1452,10 +1446,10 @@ void ComboSelChangeEA (HWND hwndDlg) else { wchar_t name[100]; - + nIndex = (int) SendMessage (GetDlgItem (hwndDlg, IDC_COMBO_BOX), CB_GETITEMDATA, nIndex, 0); EAGetName (name, nIndex, 0); - + SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("AES_HELP_NEW")); } } @@ -1720,15 +1714,11 @@ static void UpdateSysEncControls (void) { return; } - + EnableWindow (GetDlgItem (hCurPage, IDC_WIPE_MODE), !locBootEncStatus.SetupInProgress && SystemEncryptionStatus == SYSENC_STATUS_ENCRYPTING); - // TODO: try to make the pause button visible without having to hover over it - SetWindowTextW (GetDlgItem (hCurPage, IDC_PAUSE), - GetString ("IDC_PAUSE")); - SetWindowTextW (GetDlgItem (hCurPage, IDC_PAUSE), GetString (locBootEncStatus.SetupInProgress ? "IDC_PAUSE" : "RESUME")); @@ -2610,11 +2600,9 @@ static void __cdecl volTransformThreadFunction (void *hwndDlgArg) volParams->headerFlags = (CreatingHiddenSysVol() ? TC_HEADER_FLAG_ENCRYPTED_SYSTEM : 0); volParams->fileSystem = fileSystem; volParams->clusterSize = clusterSize; - //volParams->sparseFileSwitch = dynamicFormat; //1.24 - volParams->sparseFileSwitch = bSparseFileSwitch; - + volParams->sparseFileSwitch = dynamicFormat; volParams->quickFormat = quickFormat; - volParams->fastCreateFile = fastCreateFile; + volParams->fastCreateFile = fastCreateFile; volParams->sectorSize = GetFormatSectorSize(); volParams->realClusterSize = &realClusterSize; volParams->password = &volumePassword; @@ -2802,7 +2790,7 @@ static void __cdecl volTransformThreadFunction (void *hwndDlgArg) { Info("FORMAT_FINISHED_INFO", hwndDlg); - if (bSparseFileSwitch && quickFormat) //u 1.24. if(dynamicFormat) + if (dynamicFormat) Warning("SPARSE_FILE_SIZE_NOTE", hwndDlg); } } @@ -2900,7 +2888,6 @@ static void LoadPage (HWND hwndDlg, int nPageNo) case PASSWORD_PAGE: { wchar_t tmp[MAX_PASSWORD+1]; - char *passTmp[MAX_PASSWORD+1]; // Attempt to wipe passwords stored in the input field buffers. This is performed here (and // not in the IDC_PREV or IDC_NEXT sections) in order to prevent certain race conditions @@ -2909,7 +2896,6 @@ static void LoadPage (HWND hwndDlg, int nPageNo) tmp [MAX_PASSWORD] = 0; SetWindowText (hPasswordInputField, tmp); SetWindowText (hVerifyPasswordInputField, tmp); - } break; } @@ -3369,6 +3355,7 @@ BOOL GetFileVolSize (HWND hwndDlg, unsigned __int64 *size) return TRUE; } + BOOL QueryFreeSpace (HWND hwndDlg, HWND hwndTextBox, BOOL display, LONGLONG *pFreeSpaceValue, BOOL* pbIsSparceFilesSupported) { if (pFreeSpaceValue) @@ -3737,51 +3724,81 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa UpdateWizardModeControls (hwndDlg, WizardMode); break; - case SYSENC_TYPE_PAGE: + case SYSENC_TYPE_PAGE: + { + bHiddenVolHost = bHiddenVol = bHiddenOS; - SetWindowTextW(GetDlgItem(GetParent(hwndDlg), IDC_BOX_TITLE), GetString("PAGE_1_TITLE")); + wchar_t finalMsg[8024] = {0}; - SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("SYSENC_HIDDEN_TYPE_HELP")); - SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP_SYSENC_NORMAL), GetString ("SYSENC_NORMAL_TYPE_HELP")); + try + { + StringCbPrintfW (finalMsg, sizeof(finalMsg), + GetString ("SYSENC_TYPE_PAGE_TITLE"), + GetSystemDriveLetter ()); + } + catch (Exception &e) + { + e.Show (hwndDlg); + EndMainDlg (MainDlg); + return 0; + } - if(bSystemIsGPT) + SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), finalMsg); + + wmemset (finalMsg, 0, sizeof (finalMsg)); + try + { + StringCbPrintfW (finalMsg, sizeof(finalMsg), + GetString ("SYSENC_INFO"), + GetSystemDriveLetter ()); + } + catch (Exception &e) + { + e.Show (hwndDlg); + EndMainDlg (MainDlg); + return 0; + } + + SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), finalMsg); + SetWindowTextW (GetDlgItem (hwndDlg, IDT_SYSENC_INFO_2), GetString ("SYSENC_INFO_2")); + + if (bSystemIsGPT) { ShowWindow (GetDlgItem(hwndDlg, IDC_ADVANCE_INTRO), SW_HIDE); ShowWindow (GetDlgItem(hwndDlg, IDC_INFORMATION_TIP), SW_HIDE); } else { - EnableWindow(GetDlgItem(hwndDlg, IDC_ADVANCE_INTRO), TRUE); - iIconX = GetSystemMetrics(SM_CXSMICON); - iIconY = GetSystemMetrics(SM_CYSMICON); + EnableWindow (GetDlgItem(hwndDlg, IDC_ADVANCE_INTRO), TRUE); + iIconX = GetSystemMetrics (SM_CXSMICON); + iIconY = GetSystemMetrics (SM_CYSMICON); - hIconTooltip = LoadImage(NULL, MAKEINTRESOURCE(104), IMAGE_ICON, iIconX, iIconY, LR_DEFAULTCOLOR); - SendDlgItemMessage(hwndDlg, IDC_INFORMATION_TIP, STM_SETICON, (WPARAM) hIconTooltip, 0); + hIconTooltip = LoadImage (NULL, MAKEINTRESOURCE (104), IMAGE_ICON, iIconX, iIconY, LR_DEFAULTCOLOR); + SendDlgItemMessage (hwndDlg, IDC_INFORMATION_TIP, STM_SETICON, (WPARAM) hIconTooltip, 0); - hDlgItemTooltip = GetDlgItem(hwndDlg, IDC_INFORMATION_TIP); - if(hDlgItemTooltip) + hDlgItemTooltip = GetDlgItem (hwndDlg, IDC_INFORMATION_TIP); + if (hDlgItemTooltip) { - // TODO Add string for tooltip here - CreateToolTip(hwndDlg, hDlgItemTooltip, L"TESTING"); + CreateToolTip (hwndDlg, hDlgItemTooltip, GetString ("ADV_FEATURES_INTRO_TOOLTIP")); } else { - MessageBox(0, TEXT("Cannot find dialog item"), 0, 0); + MessageBox (0, TEXT("Cannot find dialog item"), 0, 0); } } - EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE); - EnableWindow(GetDlgItem(GetParent(hwndDlg), IDC_PREV), FALSE); + + EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE); + EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), !bDirectSysEncMode); SetWindowTextW (GetDlgItem (MainDlg, IDC_NEXT), GetString ("NEXT")); SetWindowTextW (GetDlgItem (MainDlg, IDC_PREV), GetString ("PREV")); SetWindowTextW (GetDlgItem (MainDlg, IDCANCEL), GetString ("CANCEL")); - + // Start loading the password dictonary into memory ("need" is just a random word for initializing the process) CheckWord("need"); - break; - + } case SYSENC_HIDDEN_OS_REQ_CHECK_PAGE: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SYSENC_HIDDEN_OS_REQ_CHECK_PAGE_TITLE")); @@ -3816,7 +3833,6 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE); break; - case SYSENC_PRE_DRIVE_ANALYSIS_PAGE: Init2RadButtonPageYesNo (SysEncDetectHiddenSectors); @@ -3884,12 +3900,11 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDCANCEL), GetString ("CANCEL")); RefreshMultiBootControls (hwndDlg); - EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), nMultiBoot > 0); EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE); EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE); break; - + case SYSENC_MULTI_BOOT_SYS_EQ_BOOT_PAGE: @@ -4130,65 +4145,66 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } break; - case CIPHER_PAGE: - int ea, hid; - wchar_t buf[100]; - - // Encryption algorithms + case CIPHER_PAGE: + { + int ea, hid; + wchar_t buf[100]; - SendMessage (GetDlgItem (hwndDlg, IDC_COMBO_BOX), CB_RESETCONTENT, 0, 0); + // Encryption algorithms - if (bHiddenVol) - SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString (bHiddenVolHost ? "CIPHER_HIDVOL_HOST_TITLE" : "CIPHER_HIDVOL_TITLE")); - else - SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("CIPHER_TITLE")); + SendMessage (GetDlgItem (hwndDlg, IDC_COMBO_BOX), CB_RESETCONTENT, 0, 0); - for (ea = EAGetFirst (); ea != 0; ea = EAGetNext (ea)) - { - if (EAIsFormatEnabled (ea) && (!SysEncInEffect () || bSystemIsGPT || EAIsMbrSysEncEnabled (ea))) - AddComboPair (GetDlgItem (hwndDlg, IDC_COMBO_BOX), EAGetName (buf, ea, 1), ea); - } + if (bHiddenVol) + SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString (bHiddenVolHost ? "CIPHER_HIDVOL_HOST_TITLE" : "CIPHER_HIDVOL_TITLE")); + else + SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("CIPHER_TITLE")); - SelectAlgo (GetDlgItem (hwndDlg, IDC_COMBO_BOX), &nVolumeEA); - ComboSelChangeEA (hwndDlg); - SetFocus (GetDlgItem (hwndDlg, IDC_COMBO_BOX)); + for (ea = EAGetFirst (); ea != 0; ea = EAGetNext (ea)) + { + if (EAIsFormatEnabled (ea) && (!SysEncInEffect () || bSystemIsGPT || EAIsMbrSysEncEnabled (ea))) + AddComboPair (GetDlgItem (hwndDlg, IDC_COMBO_BOX), EAGetName (buf, ea, 1), ea); + } - ToHyperlink (hwndDlg, IDC_LINK_MORE_INFO_ABOUT_CIPHER); + SelectAlgo (GetDlgItem (hwndDlg, IDC_COMBO_BOX), &nVolumeEA); + ComboSelChangeEA (hwndDlg); + SetFocus (GetDlgItem (hwndDlg, IDC_COMBO_BOX)); - // Hash algorithms + ToHyperlink (hwndDlg, IDC_LINK_MORE_INFO_ABOUT_CIPHER); - if (SysEncInEffect ()) - { - hash_algo = bSystemIsGPT? SHA512 : DEFAULT_HASH_ALGORITHM_BOOT; - RandSetHashFunction (hash_algo); + // Hash algorithms - for (hid = FIRST_PRF_ID; hid <= LAST_PRF_ID; hid++) + if (SysEncInEffect ()) { - // For now, we keep RIPEMD160 for system encryption - if (((hid == RIPEMD160) || !HashIsDeprecated (hid)) && (bSystemIsGPT || HashForSystemEncryption (hid))) - AddComboPair (GetDlgItem (hwndDlg, IDC_COMBO_BOX_HASH_ALGO), HashGetName(hid), hid); + hash_algo = bSystemIsGPT? SHA512 : DEFAULT_HASH_ALGORITHM_BOOT; + RandSetHashFunction (hash_algo); + + for (hid = FIRST_PRF_ID; hid <= LAST_PRF_ID; hid++) + { + // For now, we keep RIPEMD160 for system encryption + if (((hid == RIPEMD160) || !HashIsDeprecated (hid)) && (bSystemIsGPT || HashForSystemEncryption (hid))) + AddComboPair (GetDlgItem (hwndDlg, IDC_COMBO_BOX_HASH_ALGO), HashGetName(hid), hid); + } } - } - else - { - hash_algo = RandGetHashFunction(); - for (hid = FIRST_PRF_ID; hid <= LAST_PRF_ID; hid++) + else { - if (!HashIsDeprecated (hid)) - AddComboPair (GetDlgItem (hwndDlg, IDC_COMBO_BOX_HASH_ALGO), HashGetName(hid), hid); + hash_algo = RandGetHashFunction(); + for (hid = FIRST_PRF_ID; hid <= LAST_PRF_ID; hid++) + { + if (!HashIsDeprecated (hid)) + AddComboPair (GetDlgItem (hwndDlg, IDC_COMBO_BOX_HASH_ALGO), HashGetName(hid), hid); + } } - } - SelectAlgo (GetDlgItem (hwndDlg, IDC_COMBO_BOX_HASH_ALGO), &hash_algo); + SelectAlgo (GetDlgItem (hwndDlg, IDC_COMBO_BOX_HASH_ALGO), &hash_algo); - ToHyperlink (hwndDlg, IDC_LINK_HASH_INFO); + ToHyperlink (hwndDlg, IDC_LINK_HASH_INFO); - // Wizard buttons - SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT")); - SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV")); - EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE); - EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE); - + // Wizard buttons + SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT")); + SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV")); + EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE); + EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE); + } break; case SIZE_PAGE: @@ -4342,7 +4358,9 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa break; case PASSWORD_PAGE: - { + { + wchar_t str[1000]; + EnableWindow(GetDlgItem(hwndDlg, IDC_VERIFY), FALSE); hPasswordInputField = GetDlgItem (hwndDlg, IDC_PASSWORD); @@ -4356,35 +4374,69 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa ToBootPwdField (hwndDlg, IDC_PASSWORD); ToBootPwdField (hwndDlg, IDC_VERIFY); - StringCbPrintfW (OrigKeyboardLayout, sizeof(OrigKeyboardLayout), L"%08X", (DWORD) GetKeyboardLayout (NULL) & 0xFFFF); + bKeyboardLayoutChanged = FALSE; - if ((DWORD) GetKeyboardLayout (NULL) != 0x00000409 && (DWORD) GetKeyboardLayout (NULL) != 0x04090409) + if (CheckIsIMESupported ()) { - DWORD keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE); - - if (keybLayout != 0x00000409 && keybLayout != 0x04090409) + // East Asian languages are not translated to US keyboard layout so we need to change keyboard layout + if ((DWORD) GetKeyboardLayout (NULL) != 0x00000409 && (DWORD) GetKeyboardLayout (NULL) != 0x04090409) { - Error ("CANT_CHANGE_KEYB_LAYOUT_FOR_SYS_ENCRYPTION", MainDlg); - EndMainDlg (MainDlg); - return 1; + DWORD keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE); + + if (keybLayout != 0x00000409 && keybLayout != 0x04090409) + { + Error ("CANT_CHANGE_KEYB_LAYOUT_FOR_SYS_ENCRYPTION", MainDlg); + EndMainDlg (MainDlg); + return 1; + } + bKeyboardLayoutChanged = TRUE; } - bKeyboardLayoutChanged = TRUE; } - - + if (SetTimer (MainDlg, TIMER_ID_KEYB_LAYOUT_GUARD, TIMER_INTERVAL_KEYB_LAYOUT_GUARD, NULL) == 0) { Error ("CANNOT_SET_TIMER", MainDlg); EndMainDlg (MainDlg); return 1; } + + ShowWindow(GetDlgItem(hwndDlg, IDC_KEYFILES_ENABLE), SW_HIDE); + ShowWindow(GetDlgItem(hwndDlg, IDC_KEY_FILES), SW_HIDE); + ShowWindow(GetDlgItem(hwndDlg, IDC_PIM_ENABLE), SW_HIDE); + + ShowWindow(GetDlgItem(hwndDlg, IDC_ADVANCE), SW_SHOW); + } + else + { + SetCheckBox (hwndDlg, IDC_PIM_ENABLE, PimEnable); + + SetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE, KeyFilesEnable && !SysEncInEffect()); + EnableWindow (GetDlgItem (hwndDlg, IDC_KEY_FILES), KeyFilesEnable && !SysEncInEffect()); + EnableWindow (GetDlgItem (hwndDlg, IDC_KEYFILES_ENABLE), !SysEncInEffect()); + + SetPassword (hwndDlg, IDC_PASSWORD, szRawPassword); + SetPassword (hwndDlg, IDC_VERIFY, szVerify); + } + + if (bHiddenVolHost) + { + StringCbCopyW (str, sizeof(str), GetString (bHiddenOS ? "PASSWORD_SYSENC_OUTERVOL_HELP" : "PASSWORD_HIDDENVOL_HOST_HELP")); + } + else if (bHiddenVol) + { + StringCbPrintfW (str, sizeof str, L"%s%s", + GetString (bHiddenOS ? "PASSWORD_HIDDEN_OS_HELP" : "PASSWORD_HIDDENVOL_HELP"), + GetString ("PASSWORD_HELP")); + } + else + { + StringCbCopyW (str, sizeof(str), GetString ("PASSWORD_HELP_SYSENC")); } - SetPassword (hwndDlg, IDC_PASSWORD, szRawPassword); - SetPassword (hwndDlg, IDC_VERIFY, szVerify); - SetFocus (GetDlgItem (hwndDlg, IDC_PASSWORD)); + SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), str); + if (CreatingHiddenSysVol()) SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("PASSWORD_HIDDEN_OS_TITLE")); else if (bHiddenVol) @@ -4393,7 +4445,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("CHOOSE_PASSWORD_TITLE")); else SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("PASSWORD_TITLE")); - + SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT")); SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV")); @@ -4405,41 +4457,42 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa NULL, NULL, KeyFilesEnable && FirstKeyFile!=NULL && !SysEncInEffect()); - volumePassword.Length = (unsigned __int32) strlen ((char *) volumePassword.Text); - - /* Random pool parameter */ + + if(SysEncInEffect ()) + { + /* Random pool parameter is here because random page is removed */ - mouseEntropyGathered = 0xFFFFFFFF; - mouseEventsInitialCount = 0; - bUseMask = FALSE; + mouseEntropyGathered = 0xFFFFFFFF; + mouseEventsInitialCount = 0; + bUseMask = FALSE; - { - HCRYPTPROV hRngProv; - if (CryptAcquireContext (&hRngProv, NULL, MS_ENHANCED_PROV, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) { - if (CryptGenRandom (hRngProv, sizeof (maskRandPool), maskRandPool)) - bUseMask = TRUE; - CryptReleaseContext (hRngProv, 0); + HCRYPTPROV hRngProv; + if (CryptAcquireContext (&hRngProv, NULL, MS_ENHANCED_PROV, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) + { + if (CryptGenRandom (hRngProv, sizeof (maskRandPool), maskRandPool)) + bUseMask = TRUE; + CryptReleaseContext (hRngProv, 0); + } } - } - SetTimer(GetParent(hwndDlg), TIMER_ID_RANDVIEW, TIMER_INTERVAL_RANDVIEW, NULL); + SetTimer(GetParent(hwndDlg), TIMER_ID_RANDVIEW, TIMER_INTERVAL_RANDVIEW, NULL); - hRandPoolSys = GetDlgItem(hwndDlg, IDC_SYS_POOL_CONTENTS); - hEntropyBar = GetDlgItem(hwndDlg, IDC_ENTROPY_BAR); - SendMessage(hEntropyBar, PBM_SETRANGE32, 0, maxEntropyLevel); - SendMessage(hEntropyBar, PBM_SETSTEP, 1, 0); - SendMessage(GetDlgItem(hwndDlg, IDC_SYS_POOL_CONTENTS), WM_SETFONT, (WPARAM)hFixedDigitFont, (LPARAM)TRUE); - + hRandPoolSys = GetDlgItem(hwndDlg, IDC_SYS_POOL_CONTENTS); + hEntropyBar = GetDlgItem(hwndDlg, IDC_ENTROPY_BAR); + SendMessage(hEntropyBar, PBM_SETRANGE32, 0, maxEntropyLevel); + SendMessage(hEntropyBar, PBM_SETSTEP, 1, 0); + SendMessage(GetDlgItem(hwndDlg, IDC_SYS_POOL_CONTENTS), WM_SETFONT, (WPARAM)hFixedDigitFont, (LPARAM)TRUE); - /* set default values */ + /* set default values */ - hash_algo = bSystemIsGPT ? SHA512 : DEFAULT_HASH_ALGORITHM_BOOT; - RandSetHashFunction(hash_algo); + hash_algo = bSystemIsGPT ? SHA512 : DEFAULT_HASH_ALGORITHM_BOOT; + RandSetHashFunction(hash_algo); - nWipeMode = TC_WIPE_1_RAND; + nWipeMode = TC_WIPE_NONE; } + } break; case PIM_PAGE: @@ -4567,7 +4620,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("RESCUE_DISK")); SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT")); SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV")); - SetWindowTextW(GetDlgItem(hwndDlg, IDT_RESCUE_DISK_INFO), GetString("RESCUE_DISK_NEW")); + SetWindowTextW (GetDlgItem (hwndDlg, IDT_RESCUE_DISK_INFO), bSystemIsGPT? GetString ("RESCUE_DISK_EFI_INFO"): GetString ("RESCUE_DISK_INFO")); SetWindowTextW(GetDlgItem(hwndDlg, IDT_RESCUE_DISK_INFO_2), GetString("RESCUE_DISK_INFO_2")); SetCheckBox (hwndDlg, IDC_SKIP_RESCUE_VERIFICATION, bDontVerifyRescueDisk); @@ -4599,15 +4652,12 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } SetWindowTextW (GetDlgItem (hwndDlg, IDT_RESCUE_DISK_BURN_INFO), szTmp); - EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE); - + /* The 'Back' button is enabled but user can't go back, instead warning is provided */ EnableWindow(GetDlgItem(GetParent(hwndDlg), IDC_PREV), TRUE); - ShowWindow(GetDlgItem(hwndDlg, IDC_DOWNLOAD_CD_BURN_SOFTWARE), SW_HIDE); - } - + } break; case SYSENC_RESCUE_DISK_VERIFIED_PAGE: @@ -4629,41 +4679,79 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa break; case SYSENC_WIPE_MODE_PAGE: - case NONSYS_INPLACE_ENC_WIPE_MODE_PAGE:// Checklist page - - wchar_t szTmp[8192]; + case NONSYS_INPLACE_ENC_WIPE_MODE_PAGE: + { + if (SysEncInEffect ()) + { + /* Wipe mode page is now checklist page */ + ShowWindow (GetDlgItem (hwndDlg, IDC_WIPE_MODE), SW_HIDE); + ShowWindow (GetDlgItem (hwndDlg, IDT_WIPE_MODE), SW_HIDE); + ShowWindow (GetDlgItem (hwndDlg, IDT_WIPE_MODE_INFO), SW_HIDE); - SetWindowTextW (GetDlgItem (hwndDlg, IDC_REMEMBER_PASSWORD), GetString ("REMEMBER_PASSWORD")); - SetWindowTextW (GetDlgItem (hwndDlg, IDC_STORE_RESCUE_DISK), GetString ("STORE_RESCUE_DISK")); - SetWindowTextW (GetDlgItem (hwndDlg, IDC_BACKUP_DATA), GetString ("BACKUP_DATA")); + SetWindowTextW (GetDlgItem (hwndDlg, IDC_REMEMBER_PASSWORD), GetString ("REMEMBER_PASSWORD")); + SetWindowTextW (GetDlgItem (hwndDlg, IDC_STORE_RESCUE_DISK), GetString ("STORE_RESCUE_DISK")); + SetWindowTextW (GetDlgItem (hwndDlg, IDC_BACKUP_DATA), GetString ("BACKUP_DATA")); - SendMessage(GetDlgItem(hwndDlg, IDC_REMEMBER_PASSWORD), WM_SETFONT, (WPARAM)hUserBoldFont, (LPARAM)TRUE); - SendMessage(GetDlgItem(hwndDlg, IDC_STORE_RESCUE_DISK), WM_SETFONT, (WPARAM)hUserBoldFont, (LPARAM)TRUE); - SendMessage(GetDlgItem(hwndDlg, IDC_BACKUP_DATA), WM_SETFONT, (WPARAM)hUserBoldFont, (LPARAM)TRUE); - - CHECKLIST_A = FALSE; - CHECKLIST_B = FALSE; - CHECKLIST_C = FALSE; + SendMessage(GetDlgItem(hwndDlg, IDC_REMEMBER_PASSWORD), WM_SETFONT, (WPARAM)hUserBoldFont, (LPARAM)TRUE); + SendMessage(GetDlgItem(hwndDlg, IDC_STORE_RESCUE_DISK), WM_SETFONT, (WPARAM)hUserBoldFont, (LPARAM)TRUE); + SendMessage(GetDlgItem(hwndDlg, IDC_BACKUP_DATA), WM_SETFONT, (WPARAM)hUserBoldFont, (LPARAM)TRUE); + + bChecklistA = FALSE; + bChecklistB = FALSE; + bChecklistC = FALSE; - SetWindowTextW(GetDlgItem(GetParent(hwndDlg), IDC_BOX_TITLE), GetString("CHECKLIST_TITLE")); + SetWindowTextW(GetDlgItem(GetParent(hwndDlg), IDC_BOX_TITLE), GetString("CHECKLIST_TITLE")); - StringCbPrintfW(szTmp, sizeof szTmp, - GetString("RESCUE_DISK_CHECKLIST_B"), - szRescueDiskISO, ""); - SetDlgItemText(hwndDlg, IDT_STORE_RESCUE_DISK, szTmp); - SetWindowTextW (GetDlgItem (hwndDlg, IDT_REMEMBER_PASSWORD), GetString ("RESCUE_DISK_CHECKLIST_A")); - SetWindowTextW (GetDlgItem (hwndDlg, IDT_BACKUP_DATA), GetString ("RESCUE_DISK_CHECKLIST_C")); + SetDlgItemText(hwndDlg, IDC_BROWSE, GetString ("OPEN_PATH_CHECKLIST_PAGE")); + SetWindowTextW (GetDlgItem (hwndDlg, IDT_STORE_RESCUE_DISK), GetString ("RESCUE_DISK_CHECKLIST_B")); + SetWindowTextW (GetDlgItem (hwndDlg, IDT_REMEMBER_PASSWORD), GetString ("RESCUE_DISK_CHECKLIST_A")); + SetWindowTextW (GetDlgItem (hwndDlg, IDT_BACKUP_DATA), GetString ("RESCUE_DISK_CHECKLIST_C")); - EnableWindow(GetDlgItem(hwndDlg, IDC_REMEMBER_PASSWORD), TRUE); - EnableWindow(GetDlgItem(hwndDlg, IDC_STORE_RESCUE_DISK), TRUE); - EnableWindow(GetDlgItem(hwndDlg, IDC_BACKUP_DATA), TRUE); + EnableWindow(GetDlgItem(hwndDlg, IDC_REMEMBER_PASSWORD), TRUE); + EnableWindow(GetDlgItem(hwndDlg, IDC_STORE_RESCUE_DISK), TRUE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BACKUP_DATA), TRUE); - SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT")); + SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT")); - SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV")); - EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE); - EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), FALSE); - + SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV")); + EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE); + EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), FALSE); + } + else + { + /* Hide elements from Checklist page and show Wipe mode page */ + ShowWindow (GetDlgItem (hwndDlg, IDC_CHECKLIST_A), SW_HIDE); + ShowWindow (GetDlgItem (hwndDlg, IDC_CHECKLIST_B), SW_HIDE); + ShowWindow (GetDlgItem (hwndDlg, IDC_CHECKLIST_C), SW_HIDE); + ShowWindow (GetDlgItem (hwndDlg, IDC_STORE_RESCUE_DISK), SW_HIDE); + ShowWindow (GetDlgItem (hwndDlg, IDC_REMEMBER_PASSWORD), SW_HIDE); + ShowWindow (GetDlgItem (hwndDlg, IDC_BACKUP_DATA), SW_HIDE); + ShowWindow (GetDlgItem (hwndDlg, IDT_REMEMBER_PASSWORD), SW_HIDE); + ShowWindow (GetDlgItem (hwndDlg, IDT_STORE_RESCUE_DISK), SW_HIDE); + ShowWindow (GetDlgItem (hwndDlg, IDT_BACKUP_DATA), SW_HIDE); + ShowWindow (GetDlgItem (hwndDlg, IDC_BROWSE), SW_HIDE); + ShowWindow (GetDlgItem (hwndDlg, IDC_RESCUE_DISK_ISO_PATH), SW_HIDE); + + if (nWipeMode == TC_WIPE_1_RAND) + nWipeMode = TC_WIPE_NONE; + + SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("WIPE_MODE_TITLE")); + SetWindowTextW (GetDlgItem (hwndDlg, IDT_WIPE_MODE_INFO), GetString ("INPLACE_ENC_WIPE_MODE_INFO")); + + PopulateWipeModeCombo (GetDlgItem (hwndDlg, IDC_WIPE_MODE), + SystemEncryptionStatus == SYSENC_STATUS_DECRYPTING && !bInPlaceEncNonSys, + TRUE, + FALSE); + + SelectAlgo (GetDlgItem (hwndDlg, IDC_WIPE_MODE), (int *) &nWipeMode); + + SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT")); + + SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV")); + EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE); + EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE); + } + } break; case SYSENC_PRETEST_INFO_PAGE: @@ -4685,7 +4773,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa { StringCbPrintfW (finalMsg, sizeof(finalMsg), GetString ("SYS_ENCRYPTION_PRETEST_INFO"), - BootEncObj->GetSystemDriveConfiguration().DriveNumber); + GetSystemDriveLetter ()); } catch (Exception &e) { @@ -4709,14 +4797,30 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SYS_ENCRYPTION_PRETEST_RESULT_TITLE")); SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("SYS_ENCRYPTION_PRETEST_RESULT_INFO")); + ShowWindow (GetDlgItem (hwndDlg, IDC_CHECKBOX_PRETEST), SW_SHOW); + SetWindowTextW (GetDlgItem (hwndDlg, IDC_CHECKBOX_PRETEST), GetString ("PRETEST_CHECKBOX")); + + bCheckboxPretest = FALSE; + SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("ENCRYPT")); SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV")); SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDCANCEL), GetString ("DEFER")); - EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE); - EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), FALSE); + EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), FALSE); + EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE); EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE); + HWND hTooltip; + hTooltip = GetDlgItem (GetParent (hwndDlg), IDC_PREV); + if (hTooltip) + { + CreateToolTip (hwndDlg, hTooltip, GetString ("PRETEST_BACK_BUTTON")); + } + else + { + MessageBox (0, TEXT ("Cannot find dialog item for tooltip!"), 0, 0); + } + break; case SYSENC_ENCRYPTION_PAGE: @@ -4738,7 +4842,9 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString (SystemEncryptionStatus != SYSENC_STATUS_DECRYPTING ? "ENCRYPTION" : "DECRYPTION")); - + + SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), + GetString (SystemEncryptionStatus != SYSENC_STATUS_DECRYPTING ? "SYSENC_ENCRYPTION_PAGE_INFO" : "SYSENC_DECRYPTION_PAGE_INFO")); SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDCANCEL), GetString ("DEFER")); @@ -4747,11 +4853,6 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString (SystemEncryptionStatus != SYSENC_STATUS_DECRYPTING ? "ENCRYPT" : "DECRYPT")); - //TODO current: 'Pause' button is not vidible until hover over it - SetWindowTextW (GetDlgItem (hwndDlg, IDC_PAUSE), - GetString ( "IDC_PAUSE")); - EnableWindow (GetDlgItem (hwndDlg, IDC_PAUSE), TRUE); - SetWindowTextW (GetDlgItem (hwndDlg, IDC_PAUSE), GetString (bSystemEncryptionInProgress ? "IDC_PAUSE" : "RESUME")); @@ -4761,14 +4862,13 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE); EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), TRUE); - if (SystemEncryptionStatus == SYSENC_STATUS_DECRYPTING) { nWipeMode = TC_WIPE_NONE; EnableWindow (GetDlgItem (hwndDlg, IDC_WIPE_MODE), FALSE); EnableWindow (GetDlgItem (hwndDlg, IDT_WIPE_MODE), FALSE); PopulateWipeModeCombo (GetDlgItem (hwndDlg, IDC_WIPE_MODE), TRUE, TRUE, FALSE); - SelectAlgo (GetDlgItem (hwndDlg, IDC_WIPE_MODE), (int *) &nWipeMode); + SelectAlgo (GetDlgItem (hwndDlg, IDC_WIPE_MODE), (int *) &nWipeMode); } else { @@ -4776,13 +4876,14 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa PopulateWipeModeCombo (GetDlgItem (hwndDlg, IDC_WIPE_MODE), FALSE, TRUE, FALSE); SelectAlgo (GetDlgItem (hwndDlg, IDC_WIPE_MODE), (int *) &nWipeMode); } - - if (nWipeMode == TC_WIPE_NONE || nWipeMode == TC_WIPE_1_RAND) + + if (nWipeMode == TC_WIPE_NONE) { ShowWindow (GetDlgItem(hwndDlg, IDC_WIPE_MODE), SW_HIDE); ShowWindow (GetDlgItem(hwndDlg, IDT_FORMAT_OPTIONS), SW_HIDE); ShowWindow (GetDlgItem(hwndDlg, IDT_WIPE_MODE), SW_HIDE); } + PostMessage (hwndDlg, TC_APPMSG_PERFORM_POST_SYSENC_WMINIT_TASKS, 0, 0); } else @@ -4842,7 +4943,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa EnableWindow (GetDlgItem (hwndDlg, IDC_PAUSE), FALSE); ShowWindow (GetDlgItem (hwndDlg, IDC_MORE_INFO_SYS_ENCRYPTION), SW_HIDE); - + if (bInPlaceDecNonSys) { ShowWindow(GetDlgItem(hwndDlg, IDT_FORMAT_OPTIONS), SW_HIDE); @@ -4854,15 +4955,8 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa EnableWindow (GetDlgItem (hwndDlg, IDC_WIPE_MODE), TRUE); PopulateWipeModeCombo (GetDlgItem (hwndDlg, IDC_WIPE_MODE), FALSE, TRUE, FALSE); SelectAlgo (GetDlgItem (hwndDlg, IDC_WIPE_MODE), (int *) &nWipeMode); - - } - - if (nWipeMode == TC_WIPE_NONE || nWipeMode == TC_WIPE_1_RAND) - { - ShowWindow (GetDlgItem(hwndDlg, IDC_WIPE_MODE), SW_HIDE); - ShowWindow (GetDlgItem(hwndDlg, IDT_FORMAT_OPTIONS), SW_HIDE); - ShowWindow (GetDlgItem(hwndDlg, IDT_WIPE_MODE), SW_HIDE); } + break; case NONSYS_INPLACE_ENC_TRANSFORM_FINISHED_PAGE: @@ -4991,7 +5085,6 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa { dynamicFormat = FALSE; bSparseFileSwitch = FALSE; - SetCheckBox (hwndDlg, SPARSE_FILE, FALSE); EnableWindow (GetDlgItem (hwndDlg, SPARSE_FILE), FALSE); EnableWindow (GetDlgItem (hwndDlg, IDC_QUICKFORMAT), TRUE); @@ -5000,7 +5093,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa { wchar_t root[TC_MAX_PATH]; DWORD fileSystemFlags = 0; - + /* Check if the host file system supports sparse files */ if (GetVolumePathName (szFileName, root, array_capacity (root))) @@ -5015,7 +5108,6 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa dynamicFormat = FALSE; SetCheckBox (hwndDlg, SPARSE_FILE, FALSE); } - EnableWindow (GetDlgItem (hwndDlg, SPARSE_FILE), bSparseFileSwitch); EnableWindow (GetDlgItem (hwndDlg, IDC_QUICKFORMAT), TRUE); } @@ -5246,6 +5338,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa break; case DEVICE_WIPE_PAGE: + if (bHiddenOS && IsHiddenOSRunning()) { // Decoy system partition wipe @@ -5280,7 +5373,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa case WM_CTLCOLORSTATIC: { - if ((HWND)lParam == GetDlgItem (hwndDlg, PASSWORDMETER) && pw_strength == 1) + if ((HWND)lParam == GetDlgItem (hwndDlg, PASSWORD_METER) && iPasswordStrength == 1) { // we're about to draw the static // set the text colour in (HDC)lParam @@ -5288,7 +5381,8 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa SetTextColor ((HDC)wParam, RGB(255, 0, 0)); // password weak red return (BOOL)GetSysColorBrush(COLOR_MENU); } - if ((HWND)lParam == GetDlgItem (hwndDlg, PASSWORDMETER) && pw_strength == 2) + + if ((HWND)lParam == GetDlgItem (hwndDlg, PASSWORD_METER) && iPasswordStrength == 2) { // we're about to draw the static // set the text colour in (HDC)lParam @@ -5297,28 +5391,28 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa return (BOOL) GetSysColorBrush (COLOR_MENU); } - if ((HWND)lParam == GetDlgItem (hwndDlg, PASSWORDMETER) && pw_strength == 3) + if ((HWND)lParam == GetDlgItem (hwndDlg, PASSWORD_METER) && iPasswordStrength == 3) { SetBkMode ((HDC)wParam, TRANSPARENT); SetTextColor ((HDC)wParam, RGB (218, 218, 0)); // password strong yellow return (BOOL) GetSysColorBrush (COLOR_MENU); } - if ((HWND)lParam == GetDlgItem (hwndDlg, PASSWORDMETER) && pw_strength == 4) + if ((HWND)lParam == GetDlgItem (hwndDlg, PASSWORD_METER) && iPasswordStrength == 4) { SetBkMode((HDC)wParam, TRANSPARENT); SetTextColor((HDC)wParam, RGB(50, 205, 50)); // password very strong green return (BOOL) GetSysColorBrush (COLOR_MENU); } - - if (PimValueChangedWarning && ((HWND)lParam == GetDlgItem (hwndDlg, IDC_PIM_HELP)) ) + + if (PimValueChangedWarning && ((HWND)lParam == GetDlgItem(hwndDlg, IDC_PIM_HELP)) ) { // we're about to draw the static // set the text colour in (HDC)lParam - SetBkMode ((HDC)wParam,TRANSPARENT); - SetTextColor ((HDC)wParam, RGB (255,0,0)); + SetBkMode((HDC)wParam,TRANSPARENT); + SetTextColor((HDC)wParam, RGB(255,0,0)); // NOTE: per documentation as pointed out by selbie, GetSolidBrush would leak a GDI handle. - return (BOOL) GetSysColorBrush (COLOR_MENU); + return (BOOL)GetSysColorBrush(COLOR_MENU); } } return 0; @@ -5372,6 +5466,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa return 1; } } + if (lw == IDC_ADVANCE_INTRO && nCurPageNo == SYSENC_TYPE_PAGE) { DialogBoxParamW(hInst, @@ -5379,7 +5474,15 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa (DLGPROC)AdvanceDlgProcIntro, NULL); return 1; } - + + if (lw == IDC_ADVANCE && nCurPageNo == PASSWORD_PAGE) + { + DialogBoxParamW(hInst, + MAKEINTRESOURCEW(IDD_ADVANCE), hwndDlg, + (DLGPROC)AdvanceDlgProc, NULL); + return 1; + } + if (nCurPageNo == SYSENC_HIDDEN_OS_REQ_CHECK_PAGE && lw == IDC_HIDDEN_SYSENC_INFO_LINK) { Applink ("hiddensysenc"); @@ -5432,14 +5535,6 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa break; } - if (lw == IDC_ADVANCE && nCurPageNo == PASSWORD_PAGE) - { - DialogBoxParamW(hInst, - MAKEINTRESOURCEW(IDD_ADVANCE), hwndDlg, - (DLGPROC)AdvanceDlgProc, NULL); - return 1; - } - if (nCurPageNo == FILESYS_PAGE && (lw == IDC_CHOICE1 || lw == IDC_CHOICE2)) { if (bWarnOuterVolSuitableFileSys && lw == IDC_CHOICE1 && bHiddenVolHost) @@ -5703,7 +5798,6 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa bValidEntry = FALSE; } } - EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), bValidEntry); @@ -5739,48 +5833,55 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa if (hw == EN_CHANGE && nCurPageNo == PASSWORD_PAGE) { - VerifyPasswordAndUpdate (hwndDlg, GetDlgItem (GetParent (hwndDlg), IDC_NEXT), - GetDlgItem(hCurPage, IDC_PASSWORD), - GetDlgItem(hCurPage, IDC_VERIFY), - volumePassword.Text, - szVerify, - KeyFilesEnable && FirstKeyFile != NULL && !SysEncInEffect()); - + // If 'Next' button was clicked (and keyboard layout is not US), don't verify + if (!bNextButtonClicked) + { + VerifyPasswordAndUpdate (hwndDlg, GetDlgItem (GetParent (hwndDlg), IDC_NEXT), + GetDlgItem(hCurPage, IDC_PASSWORD), + GetDlgItem(hCurPage, IDC_VERIFY), + NULL, + NULL, + KeyFilesEnable && FirstKeyFile != NULL && !SysEncInEffect()); + + bNextButtonClicked = FALSE; + } + volumePassword.Length = (unsigned __int32) strlen ((char *) volumePassword.Text); - SendMessage(GetDlgItem(hwndDlg, PASSWORDMETER), WM_SETFONT, (WPARAM)hUserBoldFont, (LPARAM)TRUE); + SendMessage (GetDlgItem (hwndDlg, PASSWORD_METER), WM_SETFONT, (WPARAM)hUserBoldFont, (LPARAM)TRUE); - memset(&tmp_password[0], 0, sizeof(tmp_password)); - for (unsigned int i = 0; i < volumePassword.Length; i++) - { - tmp_password[i] = volumePassword.Text[i]; - } + memset (&tempPassword[0], 0, sizeof (tempPassword)); + + if (GetPassword (hCurPage, IDC_PASSWORD, tempPassword, iMaxPasswordLength + 1, FALSE, TRUE)) + iPasswordStrength = PrintStrongness (tempPassword, strlen (tempPassword)); + else + Error ("ERROR_GETTING_PWD", hwndDlg); - pw_strength = printStrongNess(tmp_password, volumePassword.Length); + burn (tempPassword, sizeof (tempPassword)); - if (pw_strength == very_strong) + if (iPasswordStrength == very_strong) { - SetWindowTextW(GetDlgItem (hwndDlg, PASSWORDMETER), GetString ("VERY_STRONG_PASSWORD")); - EnableWindow(GetDlgItem (hwndDlg, IDC_VERIFY), TRUE); + SetWindowTextW (GetDlgItem (hwndDlg, PASSWORD_METER), GetString ("VERY_STRONG_PASSWORD")); + EnableWindow (GetDlgItem (hwndDlg, IDC_VERIFY), TRUE); } - else if (pw_strength == strong) + else if (iPasswordStrength == strong) { - SetWindowTextW(GetDlgItem (hwndDlg, PASSWORDMETER), GetString ("STRONG_PASSWORD")); - EnableWindow(GetDlgItem (hwndDlg, IDC_VERIFY), TRUE); + SetWindowTextW (GetDlgItem (hwndDlg, PASSWORD_METER), GetString ("STRONG_PASSWORD")); + EnableWindow (GetDlgItem (hwndDlg, IDC_VERIFY), TRUE); } - else if (pw_strength == medium) + else if (iPasswordStrength == medium) { - EnableWindow(GetDlgItem (hwndDlg, IDC_VERIFY), TRUE); - SetWindowTextW(GetDlgItem (hwndDlg, PASSWORDMETER), GetString ("MEDIUM_PASSWORD")); + EnableWindow (GetDlgItem (hwndDlg, IDC_VERIFY), TRUE); + SetWindowTextW (GetDlgItem (hwndDlg, PASSWORD_METER), GetString ("MEDIUM_PASSWORD")); } - else if (pw_strength == weak) + else if (iPasswordStrength == weak) { - EnableWindow(GetDlgItem (hwndDlg, IDC_VERIFY), FALSE); - SetWindowTextW(GetDlgItem (hwndDlg, PASSWORDMETER), GetString ("WEAK_PASSWORD")); + EnableWindow (GetDlgItem (hwndDlg, IDC_VERIFY), FALSE); + SetWindowTextW (GetDlgItem (hwndDlg, PASSWORD_METER), GetString ("WEAK_PASSWORD")); } else { - SetWindowTextW(GetDlgItem(hwndDlg, PASSWORDMETER), GetString ("VERY_WEAK_PASSWORD")); + SetWindowTextW (GetDlgItem (hwndDlg, PASSWORD_METER), GetString ("VERY_WEAK_PASSWORD")); } return 1; } @@ -5809,25 +5910,37 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PASSWORD, IDC_PASSWORD, IDC_VERIFY); return 1; } - - + if (lw == IDC_SHOW_PIM && nCurPageNo == PIM_PAGE) { HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PIM, IDC_PIM, 0); return 1; } - + if (lw == IDC_CHECKLIST_A) { - CHECKLIST_A = GetCheckBox(hwndDlg, IDC_CHECKLIST_A); - CHECKLIST_B = GetCheckBox(hwndDlg, IDC_CHECKLIST_B); - + bChecklistA = GetCheckBox (hwndDlg, IDC_CHECKLIST_A); + bChecklistB = GetCheckBox (hwndDlg, IDC_CHECKLIST_B); + bChecklistC = GetCheckBox (hwndDlg, IDC_CHECKLIST_C); } if (lw == IDC_CHECKLIST_B) { - CHECKLIST_B = GetCheckBox(hwndDlg, IDC_CHECKLIST_B); - CHECKLIST_A = GetCheckBox(hwndDlg, IDC_CHECKLIST_A); + bChecklistA = GetCheckBox (hwndDlg, IDC_CHECKLIST_A); + bChecklistB = GetCheckBox (hwndDlg, IDC_CHECKLIST_B); + bChecklistC = GetCheckBox (hwndDlg, IDC_CHECKLIST_C); + } + + if (lw == IDC_CHECKLIST_C) + { + bChecklistA = GetCheckBox (hwndDlg, IDC_CHECKLIST_A); + bChecklistB = GetCheckBox (hwndDlg, IDC_CHECKLIST_B); + bChecklistC = GetCheckBox (hwndDlg, IDC_CHECKLIST_C); + } + + if (lw == IDC_CHECKBOX_PRETEST) + { + bCheckboxPretest = GetCheckBox (hwndDlg, IDC_CHECKBOX_PRETEST); } if (lw == IDC_PIM_ENABLE) @@ -6067,7 +6180,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa return 1; } - + if (lw == IDC_QUICKFORMAT) { if (IsButtonChecked (GetDlgItem (hCurPage, IDC_QUICKFORMAT))) @@ -6082,7 +6195,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } return 1; } - + if (lw == SPARSE_FILE && IsButtonChecked (GetDlgItem (hCurPage, SPARSE_FILE))) { if (AskWarnYesNo("CONFIRM_SPARSE_FILE", MainDlg) == IDNO) @@ -6117,6 +6230,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa SetWindowText (GetDlgItem (hCurPage, IDC_DISK_KEY), showKeys ? L"" : L"******************************** "); return 1; } + if (lw == IDC_DISPLAY_POOL_CONTENTS && (nCurPageNo == SYSENC_COLLECTING_RANDOM_DATA_PAGE || nCurPageNo == NONSYS_INPLACE_ENC_RAND_DATA_PAGE)) { @@ -6157,30 +6271,50 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa return 1; } } - - if (nCurPageNo == SYSENC_RESCUE_DISK_BURN_PAGE && lw == IDC_DOWNLOAD_CD_BURN_SOFTWARE) - { - if (IsWindowsIsoBurnerAvailable()) - LaunchWindowsIsoBurner (hwndDlg, szRescueDiskISO); - else - Applink ("isoburning"); - return 1; - } - /* The password and rescue checkbox have to be clicked in order to enable the next button */ - if ((nCurPageNo == SYSENC_WIPE_MODE_PAGE || nCurPageNo == NONSYS_INPLACE_ENC_WIPE_MODE_PAGE) && (lw == IDC_CHECKLIST_A || lw == IDC_CHECKLIST_B)) + if ((nCurPageNo == SYSENC_WIPE_MODE_PAGE || nCurPageNo == NONSYS_INPLACE_ENC_WIPE_MODE_PAGE) && + (lw == IDC_CHECKLIST_A || lw == IDC_CHECKLIST_B || lw == IDC_CHECKLIST_C)) { - if (CHECKLIST_A && CHECKLIST_B) + if (SysEncInEffect ()) { - EnableWindow(GetDlgItem(GetParent(hwndDlg), IDC_NEXT), TRUE); + if (bChecklistA && bChecklistB && bChecklistC) + EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE); + else + EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), FALSE); } - else + } + + if (lw == IDC_BROWSE && (nCurPageNo == SYSENC_WIPE_MODE_PAGE || nCurPageNo == NONSYS_INPLACE_ENC_WIPE_MODE_PAGE)) + { + wchar_t tmpszRescueDiskISO [TC_MAX_PATH+1]; + + StringCbCopyW (tmpszRescueDiskISO, sizeof(tmpszRescueDiskISO), szRescueDiskISO); + + //detects the last '\' in order to remove the name of the zip file and save file name + for (int i = wcslen(tmpszRescueDiskISO); i > 1; i--) { - EnableWindow(GetDlgItem(GetParent(hwndDlg), IDC_NEXT), FALSE); + if (tmpszRescueDiskISO[i] == '\\') + { + for (int j = i + 1; i < wcslen(tmpszRescueDiskISO); i++) + tmpszRescueDiskISO[j] = '\0'; + break; + } } + + if(!BrowseFile (hwndDlg, "RESCUE_DISK_PATH", tmpszRescueDiskISO)) + return 1; + + return 1; } - + if (nCurPageNo == SYSENC_PRETEST_RESULT_PAGE && lw == IDC_CHECKBOX_PRETEST) + { + if (bCheckboxPretest) + EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE); + else + EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), FALSE); + } + if ((nCurPageNo == SYSENC_WIPE_MODE_PAGE || nCurPageNo == NONSYS_INPLACE_ENC_WIPE_MODE_PAGE || nCurPageNo == DEVICE_WIPE_MODE_PAGE) @@ -6216,21 +6350,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } return 0; - /*case WM_CHAR: - if(nCurPageNo == PASSWORD_PAGE) - { - OnKeyPress(wParam); - }*/ - /*case WM_INPUT: - if(nCurPageNo == PASSWORD_PAGE) - { - UINT virtualKey; - UINT scanCode = (lParam >> 16) & 0xFF; - // UINT scanCode = (lparam >> 16) & 0x7f) | ((lparam & (1 << 24)) != 0 ? 0x80 : 0; - virtualKey = MapVirtualKeyExW(scanCode, MAPVK_VSC_TO_VK_EX, OrigEnUSKeyboardLayout); - - } */ - }// closes the first switch (uMsg) + } return 0; } @@ -6297,7 +6417,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } try - {//variable is set if it is gpt instead of mbr + { bSystemIsGPT = BootEncObj->GetSystemDriveConfiguration().SystemPartition.IsGPT; } catch (...) @@ -6485,6 +6605,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa { AbortProcess ("VOLUME_TOO_LARGE_FOR_WINXP"); } + if (volumePassword.Length > 0) { // Check password length (check also done for outer volume which is not the case in TrueCrypt). @@ -6506,9 +6627,8 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa SHGetFolderPath (NULL, CSIDL_MYDOCUMENTS, NULL, 0, szRescueDiskISO); - // Zip rescue for both GPT and MBR StringCbCatW (szRescueDiskISO, sizeof(szRescueDiskISO), L"\\VeraCrypt Rescue Disk.zip"); - + if (IsOSAtLeast (WIN_VISTA)) { // Availability of in-place encryption (which is pre-selected by default whenever @@ -6597,7 +6717,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa case TIMER_ID_SYSENC_PROGRESS: { // Manage system encryption/decryption and update related GUI - + try { BootEncStatus = BootEncObj->GetStatus(); @@ -6777,82 +6897,39 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa case TIMER_ID_KEYB_LAYOUT_GUARD: if (SysEncInEffect ()) { - DWORD keybLayout = (DWORD) GetKeyboardLayout (NULL); - bKeyboardLayoutChanged = FALSE; - - /* Watch the keyboard layout */ - - if (keybLayout != 0x00000409 && keybLayout != 0x04090409) + if (CheckIsIMESupported ()) { - // Keyboard layout is not standard US - - WipePasswordsAndKeyfiles (true); - - SetPassword (hCurPage, IDC_PASSWORD, szRawPassword); - SetPassword (hCurPage, IDC_VERIFY, szVerify); - - keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE); + DWORD keybLayout = (DWORD) GetKeyboardLayout (NULL); + // East Asian languages are not translated to US keyboard layout so we need to change keyboard layout if (keybLayout != 0x00000409 && keybLayout != 0x04090409) { - KillTimer (hwndDlg, TIMER_ID_KEYB_LAYOUT_GUARD); - Error ("CANT_CHANGE_KEYB_LAYOUT_FOR_SYS_ENCRYPTION", MainDlg); - EndMainDlg (MainDlg); - return 1; - } + WipePasswordsAndKeyfiles (true); - bKeyboardLayoutChanged = TRUE; + SetPassword (hCurPage, IDC_PASSWORD, szRawPassword); + SetPassword (hCurPage, IDC_VERIFY, szVerify); - wchar_t szTmp [4096]; - StringCbCopyW (szTmp, sizeof(szTmp), GetString ("KEYB_LAYOUT_CHANGE_PREVENTED")); - StringCbCatW (szTmp, sizeof(szTmp), L"\n\n"); - StringCbCatW (szTmp, sizeof(szTmp), GetString ("KEYB_LAYOUT_SYS_ENC_EXPLANATION")); - MessageBoxW (MainDlg, szTmp, lpszTitle, MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST); - } - /*if (keybLayout != 0x00000409 && keybLayout != 0x04090409) - { - // Keyboard layout is not standard US + keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE); - - bKeyboardLayoutChanged = FALSE; - /*switch (uMsg){ - case WM_INPUT: - if(nCurPageNo == PASSWORD_PAGE) - { - wchar_t c [4096]={0}; - - UINT virtualKey; - UINT scanCode = (lParam >> 16) & 0xFF; - // UINT scanCode = (lparam >> 16) & 0x7f) | ((lparam & (1 << 24)) != 0 ? 0x80 : 0; - virtualKey = MapVirtualKeyExW(scanCode, MAPVK_VSC_TO_VK_EX, OrigEnUSKeyboardLayout); - c[i] = MapVirtualKeyExW(scanCode, MAPVK_VK_TO_CHAR, OrigEnUSKeyboardLayout); - i++; - - MessageBoxW (MainDlg, c, lpszTitle, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TOPMOST); - - } - - } - }*/ - - /* Watch the right Alt key (which is used to enter various characters on non-US keyboards) */ + if (keybLayout != 0x00000409 && keybLayout != 0x04090409) + { + KillTimer (hwndDlg, TIMER_ID_KEYB_LAYOUT_GUARD); + Error ("CANT_CHANGE_KEYB_LAYOUT_FOR_SYS_ENCRYPTION", MainDlg); + EndMainDlg (MainDlg); + return 1; + } - if (!bKeybLayoutAltKeyWarningShown) - { - if (GetAsyncKeyState (VK_RMENU) < 0) - { - bKeybLayoutAltKeyWarningShown = TRUE; + bKeyboardLayoutChanged = TRUE; wchar_t szTmp [4096]; - StringCbCopyW (szTmp, sizeof(szTmp), GetString ("ALT_KEY_CHARS_NOT_FOR_SYS_ENCRYPTION")); + StringCbCopyW (szTmp, sizeof(szTmp), GetString ("KEYB_LAYOUT_CHANGE_PREVENTED")); StringCbCatW (szTmp, sizeof(szTmp), L"\n\n"); StringCbCatW (szTmp, sizeof(szTmp), GetString ("KEYB_LAYOUT_SYS_ENC_EXPLANATION")); - MessageBoxW (MainDlg, szTmp, lpszTitle, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TOPMOST); + MessageBoxW (MainDlg, szTmp, lpszTitle, MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST); } } } return 1; - case TIMER_ID_SYSENC_DRIVE_ANALYSIS_PROGRESS: if (bSysEncDriveAnalysisInProgress) @@ -7103,11 +7180,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa return 1; } else - return 1; // Disallow close - bVolTransformThreadCancel = TRUE; - - EndMainDlg (hwndDlg); - return 1; + return 1; // Disallow close } else if ((nCurPageNo == SYSENC_ENCRYPTION_PAGE || nCurPageNo == SYSENC_PRETEST_RESULT_PAGE) && SystemEncryptionStatus != SYSENC_STATUS_NONE @@ -7176,7 +7249,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa case WM_COMMAND: if (lw == IDHELP) - { + { if (nCurPageNo == SYSENC_RESCUE_DISK_CREATION_PAGE || nCurPageNo == SYSENC_RESCUE_DISK_BURN_PAGE || nCurPageNo == SYSENC_RESCUE_DISK_VERIFIED_PAGE) @@ -7259,7 +7332,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } if (!bHiddenOS) - nNewPageNo = SYSENC_SPAN_PAGE - 1; // Skip irrelevant pages + nNewPageNo = PASSWORD_PAGE - 1; // Skip irrelevant pages } else if (nCurPageNo == SYSENC_HIDDEN_OS_REQ_CHECK_PAGE) { @@ -7803,6 +7876,34 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa else if (nCurPageNo == PASSWORD_PAGE) { + if (SysEncInEffect ()) + { + wchar_t tmpPwd[MAX_PASSWORD + 1]; + GetWindowText (GetDlgItem (hCurPage, IDC_PASSWORD), tmpPwd, iMaxPasswordLength + 1); + + if (wcscmp (tmpPwd, GetTranslatedPassword ()) != 0) + { + if (wcslen (GetTranslatedPassword ()) == wcslen (tmpPwd)) + { + bNextButtonClicked = TRUE; + BOOL bWritePwd = SetWindowTextW (GetDlgItem (hCurPage, IDC_PASSWORD), GetTranslatedPassword ()); + BOOL bWriteVerifyPwd = SetWindowTextW (GetDlgItem (hCurPage, IDC_VERIFY), GetTranslatedPassword ()); + if (!bWritePwd || !bWriteVerifyPwd) + { + Error ("TRANSLATED_PWD_NOT_WRITTEN", hwndDlg); + return 1; + } + } + else + { + Error ("ERROR_TRANSLATE_PWD", hwndDlg); + return 1; + } + + burn (tmpPwd, sizeof (tmpPwd)); + WipeTranslatedPassword (); + } + } VerifyPasswordAndUpdate (hwndDlg, GetDlgItem (MainDlg, IDC_NEXT), GetDlgItem (hCurPage, IDC_PASSWORD), GetDlgItem (hCurPage, IDC_VERIFY), @@ -7879,11 +7980,6 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } } - if (SysEncInEffect ()) - { - nNewPageNo = SYSENC_COLLECTING_RANDOM_DATA_PAGE - 1; // Skip irrelevant pages - } - if (bInPlaceEncNonSys) { nNewPageNo = NONSYS_INPLACE_ENC_RAND_DATA_PAGE - 1; // Skip irrelevant pages @@ -7896,6 +7992,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } } + wchar_t tmp[RANDPOOL_DISPLAY_SIZE + 1]; if (!bInPlaceEncNonSys) { @@ -7918,6 +8015,15 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa tmp[ARRAYSIZE(tmp) - 1] = 0; SetWindowText(hRandPoolSys, tmp); NormalCursor(); + + if (SysEncInEffect ()) + { + if (PimEnable) + nNewPageNo = PIM_PAGE - 1; + else + nNewPageNo = SYSENC_RESCUE_DISK_CREATION_PAGE - 1; // Skip irrelevant pages + + } } else if (nCurPageNo == PIM_PAGE) @@ -7953,18 +8059,12 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa return 1; } // Check password length (check also done for outer volume which is not the case in TrueCrypt). - else if (!CheckPasswordLength (hwndDlg, volumePassword.Length, volumePim, SysEncInEffect(), SysEncInEffect()? hash_algo : 0, TRUE, FALSE)) + else if (!CheckPasswordLength (hwndDlg, volumePassword.Length, volumePim, SysEncInEffect(), SysEncInEffect()? hash_algo : 0, FALSE, FALSE)) { return 1; } } - if (SysEncInEffect ()) - { - - nNewPageNo = SYSENC_COLLECTING_RANDOM_DATA_PAGE - 1; // Skip irrelevant pages - } - if (bInPlaceEncNonSys) { nNewPageNo = NONSYS_INPLACE_ENC_RAND_DATA_PAGE - 1; // Skip irrelevant pages @@ -7975,13 +8075,18 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa { nNewPageNo = FORMAT_PAGE - 1; // Skip irrelevant pages } + + if (SysEncInEffect ()) + { + nNewPageNo = SYSENC_RESCUE_DISK_CREATION_PAGE - 1; // Skip irrelevant pages + } } else if (nCurPageNo == HIDDEN_VOL_HOST_PASSWORD_PAGE || nCurPageNo == NONSYS_INPLACE_ENC_RESUME_PASSWORD_PAGE) { WaitCursor (); - + if (!GetPassword (hCurPage, IDC_PASSWORD_DIRECT, (char*) volumePassword.Text, iMaxPasswordLength + 1, FALSE, TRUE)) { NormalCursor (); @@ -8349,6 +8454,8 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa GetWindowText (GetDlgItem (hCurPage, IDC_RESCUE_DISK_ISO_PATH), szRescueDiskISO, ARRAYSIZE (szRescueDiskISO)); + bDontVerifyRescueDisk = GetCheckBox (hCurPage, IDC_SKIP_RESCUE_VERIFICATION); + try { WaitCursor(); @@ -8379,6 +8486,7 @@ retryCDDriveCheck: wchar_t msg[8192]; StringCchPrintfW (msg, array_capacity (msg), GetString ("CD_BURNER_NOT_PRESENT_WILL_STORE_ISO_INFO"), szRescueDiskISO); WarningDirect (msg, hwndDlg); + Warning ("RESCUE_DISK_BURN_NO_CHECK_WARN", hwndDlg); bDontVerifyRescueDisk = TRUE; nNewPageNo = SYSENC_RESCUE_DISK_VERIFIED_PAGE; @@ -8447,14 +8555,14 @@ retryCDDriveCheck: nNewPageNo = SYSENC_RESCUE_DISK_VERIFIED_PAGE; // Skip irrelevant pages } } - // TODO current: skip the warning that wipe mode will take longer - /*else if (nCurPageNo == SYSENC_WIPE_MODE_PAGE + + else if (nCurPageNo == SYSENC_WIPE_MODE_PAGE || nCurPageNo == NONSYS_INPLACE_ENC_WIPE_MODE_PAGE) { if (nWipeMode > 0 && AskWarnYesNo ("WIPE_MODE_WARN", hwndDlg) == IDNO) return 1; - }*/ + } else if (nCurPageNo == SYSENC_PRETEST_INFO_PAGE) { @@ -8597,7 +8705,7 @@ retryCDDriveCheck: // Cancel return 1; } - + NonSysInplaceEncResume (); return 1; } @@ -8854,7 +8962,6 @@ retryCDDriveCheck: SetWindowTextW (GetDlgItem (MainDlg, IDCANCEL), GetString ("CANCEL")); bHiddenVolFinished = FALSE; - WipePasswordsAndKeyfiles (true); return 1; @@ -8985,58 +9092,8 @@ retryCDDriveCheck: } return 1; } - switch (nCurPageNo) - { - case INTRO_PAGE: // TODO is never called, instead AfterWMInitTasks is called - nNewPageNo = PASSWORD_PAGE; - LoadPage(hwndDlg, nNewPageNo); - break; - case SYSENC_TYPE_PAGE: - if(bHiddenOS) - nNewPageNo = SYSENC_SPAN_PAGE; - else - nNewPageNo = PASSWORD_PAGE; - SwitchWizardToSysEncMode(); - LoadPage(hwndDlg, nNewPageNo); - break; - - case SYSENC_SPAN_PAGE: - nNewPageNo = SYSENC_MULTI_BOOT_MODE_PAGE; - LoadPage(hwndDlg, nNewPageNo); - break; - - case SYSENC_MULTI_BOOT_MODE_PAGE: - nNewPageNo = PASSWORD_PAGE; - LoadPage(hwndDlg, nNewPageNo); - break; - - case PASSWORD_PAGE: - if (PimEnable) - { - nNewPageNo = PIM_PAGE; - } - else - { - nNewPageNo = SYSENC_RESCUE_DISK_CREATION_PAGE; - } - - LoadPage(hwndDlg, nNewPageNo); - break; - - case PIM_PAGE: - nNewPageNo = SYSENC_RESCUE_DISK_CREATION_PAGE; - - LoadPage(hwndDlg, nNewPageNo); - break; - - case SYSENC_COLLECTING_RANDOM_DATA_PAGE: - LoadPage(hwndDlg, nNewPageNo + 2); - break; - - default: - LoadPage(hwndDlg, nNewPageNo + 1); - } + LoadPage (hwndDlg, nNewPageNo + 1); ovf_end: return 1; } @@ -9045,14 +9102,29 @@ ovf_end: if (nCurPageNo == SYSENC_SPAN_PAGE) { // Skip irrelevant pages when going back - - nNewPageNo = SYSENC_TYPE_PAGE + 1; + if (!bHiddenOS) + nNewPageNo = SYSENC_TYPE_PAGE + 1; } + + if (nCurPageNo == SYSENC_RESCUE_DISK_CREATION_PAGE) + { + if (SysEncInEffect ()) + { + nNewPageNo = (PimEnable? PIM_PAGE : PASSWORD_PAGE) + 1; + } + } + if (nCurPageNo == SYSENC_RESCUE_DISK_BURN_PAGE) { + nNewPageNo = SYSENC_RESCUE_DISK_BURN_PAGE + 1; // Stay on the same page Warning("RESCUE_DISK_BACK_BUTTON", hwndDlg); } + if (nCurPageNo == SYSENC_PRETEST_RESULT_PAGE) + { + nNewPageNo = SYSENC_PRETEST_RESULT_PAGE + 1; // Stay on the same page + } + if (nCurPageNo == SYSENC_MULTI_BOOT_MODE_PAGE) { // Skip the drive analysis page(s) or other irrelevant pages when going back @@ -9178,7 +9250,10 @@ ovf_end: if (SysEncInEffect ()) { - nNewPageNo = CIPHER_PAGE + 1; // Skip irrelevant pages + if (!bHiddenOS) + nNewPageNo = SYSENC_TYPE_PAGE + 1; // Skip irrelevant pages + else + nNewPageNo = CIPHER_PAGE + 1; // Skip irrelevant pages KillTimer (hwndDlg, TIMER_ID_KEYB_LAYOUT_GUARD); @@ -9193,7 +9268,6 @@ ovf_end: } else if (bInPlaceEncNonSys) nNewPageNo = CIPHER_PAGE + 1; - } else if (nCurPageNo == PIM_PAGE) @@ -9273,38 +9347,8 @@ ovf_end: nNewPageNo = (PimEnable? PIM_PAGE : PASSWORD_PAGE) + 1; } } - switch (nCurPageNo) - { - case SYSENC_MULTI_BOOT_MODE_PAGE: - nNewPageNo = SYSENC_SPAN_PAGE; - LoadPage(hwndDlg, nNewPageNo); - break; - case PASSWORD_PAGE: - nNewPageNo = SYSENC_TYPE_PAGE; - LoadPage(hwndDlg, nNewPageNo); - break; - case PIM_PAGE: - nNewPageNo = PASSWORD_PAGE; - LoadPage(hwndDlg, nNewPageNo); - break; - case SYSENC_RESCUE_DISK_CREATION_PAGE: - if (PimEnable) - { - nNewPageNo = PIM_PAGE; - } - else - { - nNewPageNo = PASSWORD_PAGE; - } - LoadPage(hwndDlg, nNewPageNo); - break; - case SYSENC_RESCUE_DISK_BURN_PAGE: - nNewPageNo = SYSENC_RESCUE_DISK_BURN_PAGE; // Stay on the same page - LoadPage(hwndDlg, nNewPageNo); - break; - default: - LoadPage(hwndDlg, nNewPageNo - 1); - } + + LoadPage (hwndDlg, nNewPageNo - 1); return 1; } @@ -10077,6 +10121,7 @@ int AnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSi else { // Unsupported file system + Error ("HIDDEN_VOL_HOST_UNSUPPORTED_FILESYS", hwndDlg); return 0; } @@ -10794,7 +10839,7 @@ static void AfterWMInitTasks (HWND hwndDlg) return; } - LoadPage(hwndDlg, SYSENC_TYPE_PAGE); + LoadPage (hwndDlg, INTRO_PAGE); } } @@ -10904,8 +10949,9 @@ static DWORD GetFormatSectorSize () return geometry.Geometry.BytesPerSector; } + /* This function is called when advanced dialog in intro page is open */ -BOOL CALLBACK AdvanceDlgProcIntro(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +BOOL CALLBACK AdvanceDlgProcIntro (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { WORD lw = LOWORD(wParam); @@ -10919,10 +10965,8 @@ BOOL CALLBACK AdvanceDlgProcIntro(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM SendMessage (GetDlgItem (hwndDlg, IDC_SYSENC_NORMAL), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE); CheckButton (GetDlgItem (hwndDlg, bHiddenOS ? IDC_SYSENC_HIDDEN : IDC_SYSENC_NORMAL)); - - //SetFocus(GetDlgItem(hwndDlg, IDOK)); - return 0; + return 1; case WM_COMMAND: { if (lw == IDCANCEL) @@ -10973,7 +11017,7 @@ BOOL CALLBACK AdvanceDlgProcIntro(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM } /* AES, HASH, Pim and Wipe mode can be selected here */ -BOOL CALLBACK AdvanceDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +BOOL CALLBACK AdvanceDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { WORD lw = LOWORD(wParam); WORD hw = HIWORD(wParam); @@ -10990,6 +11034,10 @@ BOOL CALLBACK AdvanceDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara { case WM_INITDIALOG: { + SetWindowTextW ( GetDlgItem (hwndDlg, IDT_IMPORTANT_NOTE), GetString ("ADV_FEATURES_NOTE")); + SetWindowTextW ( GetDlgItem (hwndDlg, IDT_PIM_INFO), GetString ("PIM_INFO")); + SetWindowTextW ( GetDlgItem (hwndDlg, IDT_WIPE_INFO), GetString ("WIPE_INFO")); + /* Encryption algorithms */ SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_BOX), CB_RESETCONTENT, 0, 0); @@ -11173,7 +11221,7 @@ BOOL CALLBACK AdvanceDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara SelectAlgo(GetDlgItem(hwndDlg, IDC_WIPE_MODE), (int *)&nWipeMode); SetFocus(GetDlgItem(GetParent(hwndDlg), IDOK)); } - return 0; + return 1; case WM_COMMAND: if (lw == IDCANCEL) { @@ -11248,6 +11296,7 @@ BOOL CALLBACK AdvanceDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara if (lw == IDC_WIPE_MODE && hw == CBN_SELCHANGE) { + Warning ("WIPE_WARNING", hwndDlg); return 1; } @@ -11279,6 +11328,7 @@ BOOL CALLBACK AdvanceDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara if (lw == IDC_PIM_ENABLE) { + PimEnable = GetCheckBox (hwndDlg, IDC_PIM_ENABLE); if (!PimEnable) volumePim = 0; return 1; @@ -11286,51 +11336,56 @@ BOOL CALLBACK AdvanceDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara } return 0; } + void -AddComboPairW(HWND hComboBox, const wchar_t *lpszItem, int value) +AddComboPairW (HWND hComboBox, const wchar_t *lpszItem, int value) { LPARAM nIndex; nIndex = SendMessageW(hComboBox, CB_ADDSTRING, 0, (LPARAM)lpszItem); nIndex = SendMessage(hComboBox, CB_SETITEMDATA, nIndex, (LPARAM)value); } + /* Acording to NIST, only a blacklist check and at least 8 character should be compulsary, no special character check... */ -int printStrongNess(char input[], unsigned int length) +int PrintStrongness (char input[], unsigned int length) { unsigned int n = length; - int return_val = 0; - if (n < 8) + int iReturnValue = 0; + if (n < 10) { - return return_val = weak; + burn (input, sizeof(input)); + return iReturnValue = weak; } else if (CheckWord(input)) { - return return_val = weak; + burn (input, sizeof(input)); + return iReturnValue = weak; } //Tetermine the strength of the passsord if ((n >= 13)) { - return_val = very_strong; + iReturnValue = very_strong; } //if 3 out of 4 paramters are true else if (n >= 10) { - return_val = strong; + iReturnValue = strong; } //if 2 out of 4 values are true else if (n >= 8) { - return_val = medium; + iReturnValue = medium; } else { - return_val = weak; + iReturnValue = weak; } - return return_val; + burn (input, sizeof(input)); + return iReturnValue; } /* Check if password is in list Credits go Martin York from https://codereview.stackexchange.com/questions/52702/how-to-search-for-a-word-in-a-sorted-text-file-efficiently */ -BOOL CheckWord(char* search) +BOOL CheckWord (char* search) { bool isWordInDict(std::string const& word); @@ -11345,15 +11400,19 @@ BOOL CheckWord(char* search) wchar_t destFileName[TC_MAX_PATH] = L"password1000000.txt"; wchar_t *destPathName; - GetModuleFileName (NULL, path, ARRAYSIZE (path)); + if (GetModuleFileName (NULL, path, ARRAYSIZE (path)) == 0) + { + Error ("ERROR_GETTING_PATH", MainDlg); + } wcsncpy(tmp, path, wcslen(path)); + //detects the last '\' in order to remove the name of the exe file. Afterwards add .txt file in the path for (int i = wcslen(path); i > 1; i--) { if (tmp[i] == '\\') { - for(unsigned int j = i + 1; j < wcslen(szRescueDiskISO); j++) + for(unsigned int j = i + 1; j < wcslen(path); j++) { tmp[j] = '\0'; } @@ -11361,27 +11420,18 @@ BOOL CheckWord(char* search) } } destPathName = wcscat(tmp, destFileName); - + std::ifstream fin(destPathName); std::copy(std::istream_iterator(fin), std::istream_iterator(), std::inserter(*this, end())); } }; - static const MyDict dict; + static const MyDict dict; MyDict::const_iterator find = dict.find(search); - + return find != dict.end(); } } -void OnKeyPress(WPARAM key) -{ - switch (key) - { - // Space key toggles between running and paused - case VK_SPACE: - break; - } -} /* Credits go to Barmak Shemirani from https://stackoverflow.com/questions/31407492/c-tooltip-function-for-checkbox */ void CreateToolTip(HWND hWndParent, HWND hControlItem, PTSTR pszText) @@ -11406,7 +11456,6 @@ void CreateToolTip(HWND hWndParent, HWND hControlItem, PTSTR pszText) GetClientRect(hWndParent, &toolInfo.rect); if (!SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM)&toolInfo)) { - //OutputDebugString(L"TTM_ADDTOOL failed\nWrong project manifest!"); MessageBox(0, TEXT("TTM_ADDTOOL failed\nWrong project manifest!"), 0, 0); } -} \ No newline at end of file +} diff --git a/src/Format/Tcformat.h b/src/Format/Tcformat.h index acbe6210..a8237521 100644 --- a/src/Format/Tcformat.h +++ b/src/Format/Tcformat.h @@ -32,7 +32,7 @@ enum timer_ids static void localcleanup ( void ); static void LoadSettings ( HWND hwndDlg ); -static void SaveSettings ( HWND hwndDlg ); +void SaveSettings ( HWND hwndDlg ); static void EndMainDlg ( HWND hwndDlg ); void ComboSelChangeEA ( HWND hwndDlg ); static void VerifySizeAndUpdate ( HWND hwndDlg , BOOL bUpdate ); @@ -42,7 +42,7 @@ static void LoadPage ( HWND hwndDlg , int nPageNo ); __int64 PrintFreeSpace ( HWND hwndTextBox , wchar_t *lpszDrive , PLARGE_INTEGER lDiskFree ); void DisplaySizingErrorText ( HWND hwndTextBox ); void EnableDisableFileNext ( HWND hComboBox , HWND hMainButton ); -BOOL QueryFreeSpace ( HWND hwndDlg , HWND hwndTextBox , BOOL display ); +BOOL QueryFreeSpace (HWND hwndDlg, HWND hwndTextBox, BOOL display, LONGLONG *pFreeSpaceValue, BOOL* pbIsSparseFilesSupported); static BOOL FinalPreTransformPrompts (void); void UpdateLastDialogId (void); void HandleOldAssignedDriveLetter (void); @@ -107,18 +107,11 @@ extern volatile int NonSysInplaceEncStatus; BOOL CALLBACK AdvanceDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); BOOL CALLBACK FinishDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); void AddComboPairW (HWND hComboBox, const wchar_t *lpszItem, int value); -int printStrongNess(char input [], unsigned int length); -int sendMail(char mailAdressRcv[]); -void copy_txt_files_pretest(); -void copy_txt_files_Rescue_Disk_Info(); -void copy_txt_mail_file(); -BOOL CheckWord( char* search); -BOOL CALLBACK AdvanceDlgProcIntro(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); -void OnKeyPress(WPARAM key); -void CreateToolTip(HWND hWndParent, HWND hControlItem, PTSTR pszText); - +int PrintStrongness (char* input, unsigned int length); +BOOL CheckWord (char search[]); +BOOL CALLBACK AdvanceDlgProcIntro (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); +void CreateToolTip (HWND hWndParent, HWND hControlItem, PTSTR pszText); #ifdef __cplusplus } #endif - -- cgit v1.2.3