VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2015-07-03 02:02:17 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2015-07-03 02:12:28 +0200
commitb4b51bd909de630ca5715a4eedce2a71d43db268 (patch)
tree83e8b85826ae3c0159d22d205e8e47590b3b8666
parentbef713de1a4d87b0505dd19d4da0bbbe52a650f6 (diff)
downloadVeraCrypt-b4b51bd909de630ca5715a4eedce2a71d43db268.tar.gz
VeraCrypt-b4b51bd909de630ca5715a4eedce2a71d43db268.zip
Windows: Solve privacy issue inherited from TrueCrypt and linked to the update of configuration and history XML files everytime VeraCrypt main window is opened, even if there was no modifications. This could give information about the usage of VeraCrypt. Now, configuration and history XML files are updated only when there are modifications.
-rw-r--r--src/Common/Combo.c49
-rw-r--r--src/Common/Combo.h2
-rw-r--r--src/Format/Tcformat.c94
-rw-r--r--src/Mount/Mount.c354
4 files changed, 338 insertions, 161 deletions
diff --git a/src/Common/Combo.c b/src/Common/Combo.c
index cc1d5bbf..6aa7ff2d 100644
--- a/src/Common/Combo.c
+++ b/src/Common/Combo.c
@@ -133,23 +133,64 @@ LPARAM UpdateComboOrder (HWND hComboBox)
return nIndex;
}
-void LoadCombo (HWND hComboBox)
+void LoadCombo (HWND hComboBox, BOOL bEnabled, BOOL bOnlyCheckModified, BOOL *pbModified)
{
DWORD size;
char *history = LoadFile (GetConfigPath (TC_APPD_FILENAME_HISTORY), &size);
char *xml = history;
char volume[MAX_PATH];
+ int i, nComboIdx[SIZEOF_MRU_LIST] = {0};
+ int count = SendMessage (hComboBox, CB_GETCOUNT, 0, 0);
- if (xml == NULL) return;
+ if (xml == NULL)
+ {
+ // No history XML file but history is enabled
+ if (bEnabled && pbModified)
+ *pbModified = TRUE;
+ return;
+ }
+ if (!bEnabled && bOnlyCheckModified)
+ {
+ // History is disable but there is a history XML file
+ if (pbModified)
+ *pbModified = TRUE;
+ free (history);
+ return;
+ }
+
+
+ /* combo list part:- get mru items */
+ for (i = 0; i < SIZEOF_MRU_LIST; i++)
+ nComboIdx[i] = GetOrderComboIdx (hComboBox, &nComboIdx[0], i);
+
+ i = 0;
while (xml = XmlFindElement (xml, "volume"))
{
+ char szTmp[MAX_PATH] = { 0 };
+
+ if (i < count)
+ {
+ if (SendMessage (hComboBox, CB_GETLBTEXTLEN, nComboIdx[i], 0) < sizeof (szTmp))
+ SendMessage (hComboBox, CB_GETLBTEXT, nComboIdx[i], (LPARAM) & szTmp[0]);
+ }
+
XmlGetNodeText (xml, volume, sizeof (volume));
- AddComboItem (hComboBox, volume, TRUE);
+ if (!bOnlyCheckModified)
+ AddComboItem (hComboBox, volume, TRUE);
+
+ if (pbModified && strcmp (volume, szTmp))
+ *pbModified = TRUE;
+
xml++;
+ i++;
}
- SendMessage (hComboBox, CB_SETCURSEL, 0, 0);
+ if (pbModified && (i != count))
+ *pbModified = TRUE;
+
+ if (!bOnlyCheckModified)
+ SendMessage (hComboBox, CB_SETCURSEL, 0, 0);
free (history);
}
diff --git a/src/Common/Combo.h b/src/Common/Combo.h
index f79a8df7..6677439a 100644
--- a/src/Common/Combo.h
+++ b/src/Common/Combo.h
@@ -17,7 +17,7 @@ void AddComboItem (HWND hComboBox, char *lpszFileName, BOOL saveHistory);
LPARAM MoveEditToCombo (HWND hComboBox, BOOL saveHistory);
int GetOrderComboIdx ( HWND hComboBox , int *nIdxList , int nElems );
LPARAM UpdateComboOrder ( HWND hComboBox );
-void LoadCombo ( HWND hComboBox );
+void LoadCombo (HWND hComboBox, BOOL bEnabled, BOOL bOnlyCheckModified, BOOL *pbModified);
void DumpCombo ( HWND hComboBox , int bClear );
void ClearCombo (HWND hComboBox);
int IsComboEmpty (HWND hComboBox);
diff --git a/src/Format/Tcformat.c b/src/Format/Tcformat.c
index e1a1d65e..bee1e028 100644
--- a/src/Format/Tcformat.c
+++ b/src/Format/Tcformat.c
@@ -712,32 +712,69 @@ static BOOL CreatingHiddenSysVol (void)
&& bHiddenVol && !bHiddenVolHost);
}
-static void LoadSettings (HWND hwndDlg)
+static void ConfigReadCompareInt(char *configKey, int defaultValue, int* pOutputValue, BOOL bOnlyCheckModified, BOOL* pbModified)
+{
+ int intValue = ConfigReadInt (configKey, defaultValue);
+ if (pOutputValue)
+ {
+ if (pbModified && (*pOutputValue != intValue))
+ *pbModified = TRUE;
+ if (!bOnlyCheckModified)
+ *pOutputValue = intValue;
+ }
+}
+
+static void ConfigReadCompareString (char *configKey, char *defaultValue, char *str, int maxLen, BOOL bOnlyCheckModified, BOOL *pbModified)
+{
+ char *strValue = (char*) malloc (maxLen);
+ memcpy (strValue, str, maxLen);
+
+ ConfigReadString (configKey, defaultValue, strValue, maxLen);
+
+ if (pbModified && strcmp (str, strValue))
+ *pbModified = TRUE;
+ if (!bOnlyCheckModified)
+ memcpy(str, strValue, maxLen);
+
+ free (strValue);
+}
+
+static void LoadSettingsAndCheckModified (HWND hwndDlg, BOOL bOnlyCheckModified, BOOL* pbSettingsModified, BOOL* pbHistoryModified)
{
- EnableHwEncryption ((ReadDriverConfigurationFlags() & TC_DRIVER_CONFIG_DISABLE_HARDWARE_ENCRYPTION) ? FALSE : TRUE);
+ if (!bOnlyCheckModified)
+ EnableHwEncryption ((ReadDriverConfigurationFlags() & TC_DRIVER_CONFIG_DISABLE_HARDWARE_ENCRYPTION) ? FALSE : TRUE);
WipeAlgorithmId savedWipeAlgorithm = TC_WIPE_NONE;
- LoadSysEncSettings (hwndDlg);
+ if (!bOnlyCheckModified)
+ LoadSysEncSettings (hwndDlg);
- if (LoadNonSysInPlaceEncSettings (&savedWipeAlgorithm) != 0)
+ if (!bOnlyCheckModified && LoadNonSysInPlaceEncSettings (&savedWipeAlgorithm) != 0)
bInPlaceEncNonSysPending = TRUE;
- defaultKeyFilesParam.EnableKeyFiles = FALSE;
+ if (!bOnlyCheckModified)
+ defaultKeyFilesParam.EnableKeyFiles = FALSE;
- bStartOnLogon = ConfigReadInt ("StartOnLogon", FALSE);
+ ConfigReadCompareInt ("StartOnLogon", FALSE, &bStartOnLogon, bOnlyCheckModified, pbSettingsModified);
- HiddenSectorDetectionStatus = ConfigReadInt ("HiddenSectorDetectionStatus", 0);
+ ConfigReadCompareInt ("HiddenSectorDetectionStatus", 0, &HiddenSectorDetectionStatus, bOnlyCheckModified, pbSettingsModified);
- bHistory = ConfigReadInt ("SaveVolumeHistory", FALSE);
+ ConfigReadCompareInt ("SaveVolumeHistory", FALSE, &bHistory, bOnlyCheckModified, pbSettingsModified);
- ConfigReadString ("SecurityTokenLibrary", "", SecurityTokenLibraryPath, sizeof (SecurityTokenLibraryPath) - 1);
- if (SecurityTokenLibraryPath[0])
+ ConfigReadCompareString ("SecurityTokenLibrary", "", SecurityTokenLibraryPath, sizeof (SecurityTokenLibraryPath) - 1, bOnlyCheckModified, pbSettingsModified);
+ if (!bOnlyCheckModified && SecurityTokenLibraryPath[0])
InitSecurityTokenLibrary(hwndDlg);
+ if (bOnlyCheckModified)
+ {
+ char langid[6] = {0};
+ StringCbCopyA (langid, sizeof(langid), GetPreferredLangId ());
+ ConfigReadCompareString ("Language", "", langid, sizeof (langid), TRUE, pbSettingsModified);
+ }
+
if (hwndDlg != NULL)
{
- LoadCombo (GetDlgItem (hwndDlg, IDC_COMBO_BOX));
+ LoadCombo (GetDlgItem (hwndDlg, IDC_COMBO_BOX), bHistory, bOnlyCheckModified, pbHistoryModified);
return;
}
@@ -745,24 +782,39 @@ static void LoadSettings (HWND hwndDlg)
return;
}
+static void LoadSettings (HWND hwndDlg)
+{
+ LoadSettingsAndCheckModified (hwndDlg, FALSE, NULL, NULL);
+}
+
static void SaveSettings (HWND hwndDlg)
{
WaitCursor ();
- if (hwndDlg != NULL)
+ // Check first if modifications ocurred before writing to the settings and history files
+ // This avoids leaking information about VeraCrypt usage when user only mount volumes without changing setttings or history
+ BOOL bSettingsChanged = FALSE;
+ BOOL bHistoryChanged = FALSE;
+
+ LoadSettingsAndCheckModified (hwndDlg, TRUE, &bSettingsChanged, &bHistoryChanged);
+
+ if (bHistoryChanged && hwndDlg != NULL)
DumpCombo (GetDlgItem (hwndDlg, IDC_COMBO_BOX), !bHistory);
- ConfigWriteBegin ();
+ if (bSettingsChanged)
+ {
+ ConfigWriteBegin ();
- ConfigWriteInt ("StartOnLogon", bStartOnLogon);
- ConfigWriteInt ("HiddenSectorDetectionStatus", HiddenSectorDetectionStatus);
- ConfigWriteInt ("SaveVolumeHistory", bHistory);
- ConfigWriteString ("SecurityTokenLibrary", SecurityTokenLibraryPath[0] ? SecurityTokenLibraryPath : "");
+ ConfigWriteInt ("StartOnLogon", bStartOnLogon);
+ ConfigWriteInt ("HiddenSectorDetectionStatus", HiddenSectorDetectionStatus);
+ ConfigWriteInt ("SaveVolumeHistory", bHistory);
+ ConfigWriteString ("SecurityTokenLibrary", SecurityTokenLibraryPath[0] ? SecurityTokenLibraryPath : "");
- if (GetPreferredLangId () != NULL)
- ConfigWriteString ("Language", GetPreferredLangId ());
+ if (GetPreferredLangId () != NULL)
+ ConfigWriteString ("Language", GetPreferredLangId ());
- ConfigWriteEnd (hwndDlg);
+ ConfigWriteEnd (hwndDlg);
+ }
NormalCursor ();
}
@@ -3783,7 +3835,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
SendMessage (GetDlgItem (hwndDlg, IDC_COMBO_BOX), CB_LIMITTEXT, TC_MAX_PATH, 0);
- LoadCombo (GetDlgItem (hwndDlg, IDC_COMBO_BOX));
+ LoadCombo (GetDlgItem (hwndDlg, IDC_COMBO_BOX), bHistory, FALSE, NULL);
SendMessage (GetDlgItem (hwndDlg, IDC_NO_HISTORY), BM_SETCHECK, bHistory ? BST_UNCHECKED : BST_CHECKED, 0);
diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c
index cb32dece..512989ef 100644
--- a/src/Mount/Mount.c
+++ b/src/Mount/Mount.c
@@ -634,16 +634,57 @@ static string ResolveAmbiguousSelection (HWND hwndDlg, int *driveNoPtr)
return retPath;
}
+static void ConfigReadCompareInt(char *configKey, int defaultValue, int* pOutputValue, BOOL bOnlyCheckModified, BOOL* pbModified)
+{
+ int intValue = ConfigReadInt (configKey, defaultValue);
+ if (pOutputValue)
+ {
+ if (pbModified && (*pOutputValue != intValue))
+ *pbModified = TRUE;
+ if (!bOnlyCheckModified)
+ *pOutputValue = intValue;
+ }
+}
-void LoadSettings (HWND hwndDlg)
+static void ConfigReadCompareString (char *configKey, char *defaultValue, char *str, int maxLen, BOOL bOnlyCheckModified, BOOL *pbModified)
{
- EnableHwEncryption ((ReadDriverConfigurationFlags() & TC_DRIVER_CONFIG_DISABLE_HARDWARE_ENCRYPTION) ? FALSE : TRUE);
+ char *strValue = (char*) malloc (maxLen);
+ if (strValue)
+ {
+ memcpy (strValue, str, maxLen);
+
+ ConfigReadString (configKey, defaultValue, strValue, maxLen);
+
+ if (pbModified && strcmp (str, strValue))
+ *pbModified = TRUE;
+ if (!bOnlyCheckModified)
+ memcpy(str, strValue, maxLen);
+
+ free (strValue);
+ }
+ else
+ {
+ /* allocation failed. Suppose that value changed */
+ if (pbModified)
+ *pbModified = TRUE;
+ if (!bOnlyCheckModified)
+ ConfigReadString (configKey, defaultValue, str, maxLen);
+
+ }
+}
+
+void LoadSettingsAndCheckModified (HWND hwndDlg, BOOL bOnlyCheckModified, BOOL* pbSettingsModified, BOOL* pbHistoryModified)
+{
+ char langid[6] = {0};
+ if (!bOnlyCheckModified)
+ EnableHwEncryption ((ReadDriverConfigurationFlags() & TC_DRIVER_CONFIG_DISABLE_HARDWARE_ENCRYPTION) ? FALSE : TRUE);
WipeAlgorithmId savedWipeAlgorithm = TC_WIPE_NONE;
- LoadSysEncSettings (hwndDlg);
+ if (!bOnlyCheckModified)
+ LoadSysEncSettings (hwndDlg);
- if (LoadNonSysInPlaceEncSettings (&savedWipeAlgorithm) != 0)
+ if (!bOnlyCheckModified && LoadNonSysInPlaceEncSettings (&savedWipeAlgorithm) != 0)
bInPlaceEncNonSysPending = TRUE;
// If the config file has already been loaded during this session
@@ -654,188 +695,231 @@ void LoadSettings (HWND hwndDlg)
}
// Options
- bExplore = ConfigReadInt ("OpenExplorerWindowAfterMount", FALSE);
- bUseDifferentTrayIconIfVolMounted = ConfigReadInt ("UseDifferentTrayIconIfVolumesMounted", TRUE);
+ ConfigReadCompareInt ("OpenExplorerWindowAfterMount", FALSE, &bExplore, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("UseDifferentTrayIconIfVolumesMounted", TRUE, &bUseDifferentTrayIconIfVolMounted, bOnlyCheckModified, pbSettingsModified);
- bHistory = ConfigReadInt ("SaveVolumeHistory", FALSE);
+ ConfigReadCompareInt ("SaveVolumeHistory", FALSE, &bHistory, bOnlyCheckModified, pbSettingsModified);
- bCacheInDriverDefault = bCacheInDriver = ConfigReadInt ("CachePasswords", FALSE);
- bCacheDuringMultipleMount = ConfigReadInt ("CachePasswordDuringMultipleMount", FALSE);
- bWipeCacheOnExit = ConfigReadInt ("WipePasswordCacheOnExit", FALSE);
- bWipeCacheOnAutoDismount = ConfigReadInt ("WipeCacheOnAutoDismount", TRUE);
+ ConfigReadCompareInt ("CachePasswords", FALSE, &bCacheInDriverDefault, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("CachePasswordDuringMultipleMount", FALSE, &bCacheDuringMultipleMount, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("WipePasswordCacheOnExit", FALSE, &bWipeCacheOnExit, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("WipeCacheOnAutoDismount", TRUE, &bWipeCacheOnAutoDismount, bOnlyCheckModified, pbSettingsModified);
- bStartOnLogon = ConfigReadInt ("StartOnLogon", FALSE);
- bMountDevicesOnLogon = ConfigReadInt ("MountDevicesOnLogon", FALSE);
- bMountFavoritesOnLogon = ConfigReadInt ("MountFavoritesOnLogon", FALSE);
+ ConfigReadCompareInt ("StartOnLogon", FALSE, &bStartOnLogon, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("MountDevicesOnLogon", FALSE, &bMountDevicesOnLogon, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("MountFavoritesOnLogon", FALSE, &bMountFavoritesOnLogon, bOnlyCheckModified, pbSettingsModified);
- bEnableBkgTask = ConfigReadInt ("EnableBackgroundTask", TRUE);
- bCloseBkgTaskWhenNoVolumes = ConfigReadInt ("CloseBackgroundTaskOnNoVolumes", FALSE);
+ ConfigReadCompareInt ("EnableBackgroundTask", TRUE, &bEnableBkgTask, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("CloseBackgroundTaskOnNoVolumes", FALSE, &bCloseBkgTaskWhenNoVolumes, bOnlyCheckModified, pbSettingsModified);
- bDismountOnLogOff = ConfigReadInt ("DismountOnLogOff", !(IsServerOS() && IsAdmin()));
- bDismountOnSessionLocked = ConfigReadInt ("DismountOnSessionLocked", FALSE);
- bDismountOnPowerSaving = ConfigReadInt ("DismountOnPowerSaving", FALSE);
- bDismountOnScreenSaver = ConfigReadInt ("DismountOnScreenSaver", FALSE);
- bForceAutoDismount = ConfigReadInt ("ForceAutoDismount", TRUE);
- MaxVolumeIdleTime = ConfigReadInt ("MaxVolumeIdleTime", -60);
+ ConfigReadCompareInt ("DismountOnLogOff", !(IsServerOS() && IsAdmin()), &bDismountOnLogOff, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("DismountOnSessionLocked", FALSE, &bDismountOnSessionLocked, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("DismountOnPowerSaving", FALSE, &bDismountOnPowerSaving, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("DismountOnScreenSaver", FALSE, &bDismountOnScreenSaver, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("ForceAutoDismount", TRUE, &bForceAutoDismount, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("MaxVolumeIdleTime", -60, &MaxVolumeIdleTime, bOnlyCheckModified, pbSettingsModified);
- HiddenSectorDetectionStatus = ConfigReadInt ("HiddenSectorDetectionStatus", 0);
+ ConfigReadCompareInt ("HiddenSectorDetectionStatus", 0, &HiddenSectorDetectionStatus, bOnlyCheckModified, pbSettingsModified);
- defaultKeyFilesParam.EnableKeyFiles = ConfigReadInt ("UseKeyfiles", FALSE);
+ ConfigReadCompareInt ("UseKeyfiles", FALSE, &defaultKeyFilesParam.EnableKeyFiles, bOnlyCheckModified, pbSettingsModified);
- bPreserveTimestamp = defaultMountOptions.PreserveTimestamp = ConfigReadInt ("PreserveTimestamps", TRUE);
- defaultMountOptions.Removable = ConfigReadInt ("MountVolumesRemovable", FALSE);
- defaultMountOptions.ReadOnly = ConfigReadInt ("MountVolumesReadOnly", FALSE);
- defaultMountOptions.ProtectHiddenVolume = FALSE;
- defaultMountOptions.ProtectedHidVolPkcs5Prf = 0;
- defaultMountOptions.ProtectedHidVolPin = 0;
- defaultMountOptions.PartitionInInactiveSysEncScope = FALSE;
- defaultMountOptions.RecoveryMode = FALSE;
- defaultMountOptions.UseBackupHeader = FALSE;
+ ConfigReadCompareInt ("PreserveTimestamps", TRUE, &defaultMountOptions.PreserveTimestamp, bOnlyCheckModified, pbSettingsModified);
+ if (!bOnlyCheckModified)
+ bPreserveTimestamp = defaultMountOptions.PreserveTimestamp;
- mountOptions = defaultMountOptions;
+ ConfigReadCompareInt ("MountVolumesRemovable", FALSE, &defaultMountOptions.Removable, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("MountVolumesReadOnly", FALSE, &defaultMountOptions.ReadOnly, bOnlyCheckModified, pbSettingsModified);
+
+ if (!bOnlyCheckModified)
+ {
+ defaultMountOptions.ProtectHiddenVolume = FALSE;
+ defaultMountOptions.ProtectedHidVolPkcs5Prf = 0;
+ defaultMountOptions.ProtectedHidVolPin = 0;
+ defaultMountOptions.PartitionInInactiveSysEncScope = FALSE;
+ defaultMountOptions.RecoveryMode = FALSE;
+ defaultMountOptions.UseBackupHeader = FALSE;
+
+ mountOptions = defaultMountOptions;
+ }
- CloseSecurityTokenSessionsAfterMount = ConfigReadInt ("CloseSecurityTokenSessionsAfterMount", 0);
+ ConfigReadCompareInt ("CloseSecurityTokenSessionsAfterMount", 0, &CloseSecurityTokenSessionsAfterMount, bOnlyCheckModified, pbSettingsModified);
if (IsHiddenOSRunning())
- HiddenSysLeakProtectionNotificationStatus = ConfigReadInt ("HiddenSystemLeakProtNotifStatus", TC_HIDDEN_OS_READ_ONLY_NOTIF_MODE_NONE);
+ ConfigReadCompareInt ("HiddenSystemLeakProtNotifStatus", TC_HIDDEN_OS_READ_ONLY_NOTIF_MODE_NONE, &HiddenSysLeakProtectionNotificationStatus, bOnlyCheckModified, pbSettingsModified);
// Drive letter - command line arg overrides registry
- if (szDriveLetter[0] == 0)
+ if (!bOnlyCheckModified && szDriveLetter[0] == 0)
ConfigReadString ("LastSelectedDrive", "", szDriveLetter, sizeof (szDriveLetter));
+ if (bHistory && pbSettingsModified)
+ {
+ // only check for last drive modification if history enabled
+ char szTmp[32] = {0};
+ LPARAM lLetter;
+ lLetter = GetSelectedLong (GetDlgItem (hwndDlg, IDC_DRIVELIST));
+ if (LOWORD (lLetter) != 0xffff)
+ StringCbPrintfA (szTmp, sizeof(szTmp), "%c:", (char) HIWORD (lLetter));
+
+ ConfigReadCompareString ("LastSelectedDrive", "", szDriveLetter, sizeof (szDriveLetter), bOnlyCheckModified, pbSettingsModified);
+ }
- ConfigReadString ("SecurityTokenLibrary", "", SecurityTokenLibraryPath, sizeof (SecurityTokenLibraryPath) - 1);
- if (SecurityTokenLibraryPath[0])
+ ConfigReadCompareString ("SecurityTokenLibrary", "", SecurityTokenLibraryPath, sizeof (SecurityTokenLibraryPath) - 1, bOnlyCheckModified, pbSettingsModified);
+ if (!bOnlyCheckModified && SecurityTokenLibraryPath[0])
InitSecurityTokenLibrary(hwndDlg);
// Hotkeys
- bPlaySoundOnSuccessfulHkDismount = ConfigReadInt ("PlaySoundOnHotkeyMountDismount", TRUE);
- bDisplayBalloonOnSuccessfulHkDismount = ConfigReadInt ("DisplayMsgBoxOnHotkeyDismount", TRUE);
- Hotkeys [HK_AUTOMOUNT_DEVICES].vKeyModifiers = ConfigReadInt ("HotkeyModAutoMountDevices", 0);
- Hotkeys [HK_AUTOMOUNT_DEVICES].vKeyCode = ConfigReadInt ("HotkeyCodeAutoMountDevices", 0);
- Hotkeys [HK_DISMOUNT_ALL].vKeyModifiers = ConfigReadInt ("HotkeyModDismountAll", 0);
- Hotkeys [HK_DISMOUNT_ALL].vKeyCode = ConfigReadInt ("HotkeyCodeDismountAll", 0);
- Hotkeys [HK_WIPE_CACHE].vKeyModifiers = ConfigReadInt ("HotkeyModWipeCache", 0);
- Hotkeys [HK_WIPE_CACHE].vKeyCode = ConfigReadInt ("HotkeyCodeWipeCache", 0);
- Hotkeys [HK_DISMOUNT_ALL_AND_WIPE].vKeyModifiers = ConfigReadInt ("HotkeyModDismountAllWipe", 0);
- Hotkeys [HK_DISMOUNT_ALL_AND_WIPE].vKeyCode = ConfigReadInt ("HotkeyCodeDismountAllWipe", 0);
- Hotkeys [HK_FORCE_DISMOUNT_ALL_AND_WIPE].vKeyModifiers = ConfigReadInt ("HotkeyModForceDismountAllWipe", 0);
- Hotkeys [HK_FORCE_DISMOUNT_ALL_AND_WIPE].vKeyCode = ConfigReadInt ("HotkeyCodeForceDismountAllWipe", 0);
- Hotkeys [HK_FORCE_DISMOUNT_ALL_AND_WIPE_AND_EXIT].vKeyModifiers = ConfigReadInt ("HotkeyModForceDismountAllWipeExit", 0);
- Hotkeys [HK_FORCE_DISMOUNT_ALL_AND_WIPE_AND_EXIT].vKeyCode = ConfigReadInt ("HotkeyCodeForceDismountAllWipeExit", 0);
- Hotkeys [HK_MOUNT_FAVORITE_VOLUMES].vKeyModifiers = ConfigReadInt ("HotkeyModMountFavoriteVolumes", 0);
- Hotkeys [HK_MOUNT_FAVORITE_VOLUMES].vKeyCode = ConfigReadInt ("HotkeyCodeMountFavoriteVolumes", 0);
- Hotkeys [HK_SHOW_HIDE_MAIN_WINDOW].vKeyModifiers = ConfigReadInt ("HotkeyModShowHideMainWindow", 0);
- Hotkeys [HK_SHOW_HIDE_MAIN_WINDOW].vKeyCode = ConfigReadInt ("HotkeyCodeShowHideMainWindow", 0);
- Hotkeys [HK_CLOSE_SECURITY_TOKEN_SESSIONS].vKeyModifiers = ConfigReadInt ("HotkeyModCloseSecurityTokenSessions", 0);
- Hotkeys [HK_CLOSE_SECURITY_TOKEN_SESSIONS].vKeyCode = ConfigReadInt ("HotkeyCodeCloseSecurityTokenSessions", 0);
+ ConfigReadCompareInt ("PlaySoundOnHotkeyMountDismount", TRUE, &bPlaySoundOnSuccessfulHkDismount, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("DisplayMsgBoxOnHotkeyDismount", TRUE, &bDisplayBalloonOnSuccessfulHkDismount, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("HotkeyModAutoMountDevices", 0, (int*) &Hotkeys [HK_AUTOMOUNT_DEVICES].vKeyModifiers, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("HotkeyCodeAutoMountDevices", 0, (int*) &Hotkeys [HK_AUTOMOUNT_DEVICES].vKeyCode, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("HotkeyModDismountAll", 0, (int*) &Hotkeys [HK_DISMOUNT_ALL].vKeyModifiers, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("HotkeyCodeDismountAll", 0, (int*) &Hotkeys [HK_DISMOUNT_ALL].vKeyCode, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("HotkeyModWipeCache", 0, (int*) &Hotkeys [HK_WIPE_CACHE].vKeyModifiers, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("HotkeyCodeWipeCache", 0, (int*) &Hotkeys [HK_WIPE_CACHE].vKeyCode, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("HotkeyModDismountAllWipe", 0, (int*) &Hotkeys [HK_DISMOUNT_ALL_AND_WIPE].vKeyModifiers, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("HotkeyCodeDismountAllWipe", 0, (int*) &Hotkeys [HK_DISMOUNT_ALL_AND_WIPE].vKeyCode, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("HotkeyModForceDismountAllWipe", 0, (int*) &Hotkeys [HK_FORCE_DISMOUNT_ALL_AND_WIPE].vKeyModifiers, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("HotkeyCodeForceDismountAllWipe", 0, (int*) &Hotkeys [HK_FORCE_DISMOUNT_ALL_AND_WIPE].vKeyCode, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("HotkeyModForceDismountAllWipeExit", 0, (int*) &Hotkeys [HK_FORCE_DISMOUNT_ALL_AND_WIPE_AND_EXIT].vKeyModifiers, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("HotkeyCodeForceDismountAllWipeExit", 0, (int*) &Hotkeys [HK_FORCE_DISMOUNT_ALL_AND_WIPE_AND_EXIT].vKeyCode, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("HotkeyModMountFavoriteVolumes", 0, (int*) &Hotkeys [HK_MOUNT_FAVORITE_VOLUMES].vKeyModifiers, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("HotkeyCodeMountFavoriteVolumes", 0, (int*) &Hotkeys [HK_MOUNT_FAVORITE_VOLUMES].vKeyCode, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("HotkeyModShowHideMainWindow", 0, (int*) &Hotkeys [HK_SHOW_HIDE_MAIN_WINDOW].vKeyModifiers, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("HotkeyCodeShowHideMainWindow", 0, (int*) &Hotkeys [HK_SHOW_HIDE_MAIN_WINDOW].vKeyCode, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("HotkeyModCloseSecurityTokenSessions", 0, (int*) &Hotkeys [HK_CLOSE_SECURITY_TOKEN_SESSIONS].vKeyModifiers, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("HotkeyCodeCloseSecurityTokenSessions", 0, (int*) &Hotkeys [HK_CLOSE_SECURITY_TOKEN_SESSIONS].vKeyCode, bOnlyCheckModified, pbSettingsModified);
// History
if (bHistoryCmdLine != TRUE)
{
- LoadCombo (GetDlgItem (hwndDlg, IDC_VOLUME));
- if (CmdLineVolumeSpecified)
+ LoadCombo (GetDlgItem (hwndDlg, IDC_VOLUME), bHistory, bOnlyCheckModified, pbHistoryModified);
+ if (!bOnlyCheckModified && CmdLineVolumeSpecified)
SetWindowText (GetDlgItem (hwndDlg, IDC_VOLUME), szFileName);
}
// Mount Options
- DefaultVolumePkcs5 = ConfigReadInt ("DefaultPRF", 0);
- DefaultVolumeTrueCryptMode = ConfigReadInt ("DefaultTrueCryptMode", FALSE);
+ ConfigReadCompareInt ("DefaultPRF", 0, &DefaultVolumePkcs5, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("DefaultTrueCryptMode", FALSE, &DefaultVolumeTrueCryptMode, bOnlyCheckModified, pbSettingsModified);
+
+ if (bOnlyCheckModified)
+ {
+ StringCbCopyA (langid, sizeof(langid), GetPreferredLangId ());
+ ConfigReadCompareString ("Language", "", langid, sizeof (langid), TRUE, pbSettingsModified);
+ }
if (DefaultVolumePkcs5 < 0 || DefaultVolumePkcs5 > LAST_PRF_ID)
DefaultVolumePkcs5 = 0;
if (DefaultVolumeTrueCryptMode != TRUE && DefaultVolumeTrueCryptMode != FALSE)
DefaultVolumeTrueCryptMode = FALSE;
+
+}
+
+void LoadSettings ( HWND hwndDlg )
+{
+ LoadSettingsAndCheckModified (hwndDlg, FALSE, NULL, NULL);
}
void SaveSettings (HWND hwndDlg)
{
WaitCursor ();
- char szTmp[32] = {0};
- LPARAM lLetter;
+ // Check first if modifications ocurred before writing to the settings and history files
+ // This avoids leaking information about VeraCrypt usage when user only mount volumes without changing setttings or history
+ BOOL bSettingsChanged = FALSE;
+ BOOL bHistoryChanged = FALSE;
- // Options
- ConfigWriteBegin ();
+ LoadSettingsAndCheckModified (hwndDlg, TRUE, &bSettingsChanged, &bHistoryChanged);
- ConfigWriteInt ("OpenExplorerWindowAfterMount", bExplore);
- ConfigWriteInt ("UseDifferentTrayIconIfVolumesMounted", bUseDifferentTrayIconIfVolMounted);
- ConfigWriteInt ("SaveVolumeHistory", !IsButtonChecked (GetDlgItem (hwndDlg, IDC_NO_HISTORY)));
-
- ConfigWriteInt ("CachePasswords", bCacheInDriverDefault);
- ConfigWriteInt ("CachePasswordDuringMultipleMount", bCacheDuringMultipleMount);
- ConfigWriteInt ("WipePasswordCacheOnExit", bWipeCacheOnExit);
- ConfigWriteInt ("WipeCacheOnAutoDismount", bWipeCacheOnAutoDismount);
-
- ConfigWriteInt ("StartOnLogon", bStartOnLogon);
- ConfigWriteInt ("MountDevicesOnLogon", bMountDevicesOnLogon);
- ConfigWriteInt ("MountFavoritesOnLogon", bMountFavoritesOnLogon);
+ if (bSettingsChanged)
+ {
+ char szTmp[32] = {0};
+ LPARAM lLetter;
- ConfigWriteInt ("MountVolumesReadOnly", defaultMountOptions.ReadOnly);
- ConfigWriteInt ("MountVolumesRemovable", defaultMountOptions.Removable);
- ConfigWriteInt ("PreserveTimestamps", defaultMountOptions.PreserveTimestamp);
+ // Options
+ ConfigWriteBegin ();
- ConfigWriteInt ("EnableBackgroundTask", bEnableBkgTask);
- ConfigWriteInt ("CloseBackgroundTaskOnNoVolumes", bCloseBkgTaskWhenNoVolumes);
+ ConfigWriteInt ("OpenExplorerWindowAfterMount", bExplore);
+ ConfigWriteInt ("UseDifferentTrayIconIfVolumesMounted", bUseDifferentTrayIconIfVolMounted);
+ ConfigWriteInt ("SaveVolumeHistory", !IsButtonChecked (GetDlgItem (hwndDlg, IDC_NO_HISTORY)));
- ConfigWriteInt ("DismountOnLogOff", bDismountOnLogOff);
- ConfigWriteInt ("DismountOnSessionLocked", bDismountOnSessionLocked);
- ConfigWriteInt ("DismountOnPowerSaving", bDismountOnPowerSaving);
- ConfigWriteInt ("DismountOnScreenSaver", bDismountOnScreenSaver);
- ConfigWriteInt ("ForceAutoDismount", bForceAutoDismount);
- ConfigWriteInt ("MaxVolumeIdleTime", MaxVolumeIdleTime);
+ ConfigWriteInt ("CachePasswords", bCacheInDriverDefault);
+ ConfigWriteInt ("CachePasswordDuringMultipleMount", bCacheDuringMultipleMount);
+ ConfigWriteInt ("WipePasswordCacheOnExit", bWipeCacheOnExit);
+ ConfigWriteInt ("WipeCacheOnAutoDismount", bWipeCacheOnAutoDismount);
- ConfigWriteInt ("HiddenSectorDetectionStatus", HiddenSectorDetectionStatus);
+ ConfigWriteInt ("StartOnLogon", bStartOnLogon);
+ ConfigWriteInt ("MountDevicesOnLogon", bMountDevicesOnLogon);
+ ConfigWriteInt ("MountFavoritesOnLogon", bMountFavoritesOnLogon);
- ConfigWriteInt ("UseKeyfiles", defaultKeyFilesParam.EnableKeyFiles);
+ ConfigWriteInt ("MountVolumesReadOnly", defaultMountOptions.ReadOnly);
+ ConfigWriteInt ("MountVolumesRemovable", defaultMountOptions.Removable);
+ ConfigWriteInt ("PreserveTimestamps", defaultMountOptions.PreserveTimestamp);
- if (IsHiddenOSRunning())
- ConfigWriteInt ("HiddenSystemLeakProtNotifStatus", HiddenSysLeakProtectionNotificationStatus);
+ ConfigWriteInt ("EnableBackgroundTask", bEnableBkgTask);
+ ConfigWriteInt ("CloseBackgroundTaskOnNoVolumes", bCloseBkgTaskWhenNoVolumes);
- // Drive Letter
- lLetter = GetSelectedLong (GetDlgItem (hwndDlg, IDC_DRIVELIST));
- if (LOWORD (lLetter) != 0xffff)
- StringCbPrintfA (szTmp, sizeof(szTmp), "%c:", (char) HIWORD (lLetter));
- ConfigWriteString ("LastSelectedDrive", szTmp);
+ ConfigWriteInt ("DismountOnLogOff", bDismountOnLogOff);
+ ConfigWriteInt ("DismountOnSessionLocked", bDismountOnSessionLocked);
+ ConfigWriteInt ("DismountOnPowerSaving", bDismountOnPowerSaving);
+ ConfigWriteInt ("DismountOnScreenSaver", bDismountOnScreenSaver);
+ ConfigWriteInt ("ForceAutoDismount", bForceAutoDismount);
+ ConfigWriteInt ("MaxVolumeIdleTime", MaxVolumeIdleTime);
- ConfigWriteInt ("CloseSecurityTokenSessionsAfterMount", CloseSecurityTokenSessionsAfterMount);
+ ConfigWriteInt ("HiddenSectorDetectionStatus", HiddenSectorDetectionStatus);
- // Hotkeys
- ConfigWriteInt ("HotkeyModAutoMountDevices", Hotkeys[HK_AUTOMOUNT_DEVICES].vKeyModifiers);
- ConfigWriteInt ("HotkeyCodeAutoMountDevices", Hotkeys[HK_AUTOMOUNT_DEVICES].vKeyCode);
- ConfigWriteInt ("HotkeyModDismountAll", Hotkeys[HK_DISMOUNT_ALL].vKeyModifiers);
- ConfigWriteInt ("HotkeyCodeDismountAll", Hotkeys[HK_DISMOUNT_ALL].vKeyCode);
- ConfigWriteInt ("HotkeyModWipeCache", Hotkeys[HK_WIPE_CACHE].vKeyModifiers);
- ConfigWriteInt ("HotkeyCodeWipeCache", Hotkeys[HK_WIPE_CACHE].vKeyCode);
- ConfigWriteInt ("HotkeyModDismountAllWipe", Hotkeys[HK_DISMOUNT_ALL_AND_WIPE].vKeyModifiers);
- ConfigWriteInt ("HotkeyCodeDismountAllWipe", Hotkeys[HK_DISMOUNT_ALL_AND_WIPE].vKeyCode);
- ConfigWriteInt ("HotkeyModForceDismountAllWipe", Hotkeys[HK_FORCE_DISMOUNT_ALL_AND_WIPE].vKeyModifiers);
- ConfigWriteInt ("HotkeyCodeForceDismountAllWipe", Hotkeys[HK_FORCE_DISMOUNT_ALL_AND_WIPE].vKeyCode);
- ConfigWriteInt ("HotkeyModForceDismountAllWipeExit", Hotkeys[HK_FORCE_DISMOUNT_ALL_AND_WIPE_AND_EXIT].vKeyModifiers);
- ConfigWriteInt ("HotkeyCodeForceDismountAllWipeExit", Hotkeys[HK_FORCE_DISMOUNT_ALL_AND_WIPE_AND_EXIT].vKeyCode);
- ConfigWriteInt ("HotkeyModMountFavoriteVolumes", Hotkeys[HK_MOUNT_FAVORITE_VOLUMES].vKeyModifiers);
- ConfigWriteInt ("HotkeyCodeMountFavoriteVolumes", Hotkeys[HK_MOUNT_FAVORITE_VOLUMES].vKeyCode);
- ConfigWriteInt ("HotkeyModShowHideMainWindow", Hotkeys[HK_SHOW_HIDE_MAIN_WINDOW].vKeyModifiers);
- ConfigWriteInt ("HotkeyCodeShowHideMainWindow", Hotkeys[HK_SHOW_HIDE_MAIN_WINDOW].vKeyCode);
- ConfigWriteInt ("HotkeyModCloseSecurityTokenSessions", Hotkeys[HK_CLOSE_SECURITY_TOKEN_SESSIONS].vKeyModifiers);
- ConfigWriteInt ("HotkeyCodeCloseSecurityTokenSessions", Hotkeys[HK_CLOSE_SECURITY_TOKEN_SESSIONS].vKeyCode);
- ConfigWriteInt ("PlaySoundOnHotkeyMountDismount", bPlaySoundOnSuccessfulHkDismount);
- ConfigWriteInt ("DisplayMsgBoxOnHotkeyDismount", bDisplayBalloonOnSuccessfulHkDismount);
-
- // Language
- if (GetPreferredLangId () != NULL)
- ConfigWriteString ("Language", GetPreferredLangId ());
-
- // PKCS#11 Library Path
- ConfigWriteString ("SecurityTokenLibrary", SecurityTokenLibraryPath[0] ? SecurityTokenLibraryPath : "");
+ ConfigWriteInt ("UseKeyfiles", defaultKeyFilesParam.EnableKeyFiles);
- // Mount Options
- ConfigWriteInt ("DefaultPRF", DefaultVolumePkcs5);
- ConfigWriteInt ("DefaultTrueCryptMode", DefaultVolumeTrueCryptMode);
-
- ConfigWriteEnd (hwndDlg);
+ if (IsHiddenOSRunning())
+ ConfigWriteInt ("HiddenSystemLeakProtNotifStatus", HiddenSysLeakProtectionNotificationStatus);
- // History
- DumpCombo (GetDlgItem (hwndDlg, IDC_VOLUME), IsButtonChecked (GetDlgItem (hwndDlg, IDC_NO_HISTORY)));
+ // Drive Letter
+ lLetter = GetSelectedLong (GetDlgItem (hwndDlg, IDC_DRIVELIST));
+ if (LOWORD (lLetter) != 0xffff)
+ StringCbPrintfA (szTmp, sizeof(szTmp), "%c:", (char) HIWORD (lLetter));
+ ConfigWriteString ("LastSelectedDrive", szTmp);
+
+ ConfigWriteInt ("CloseSecurityTokenSessionsAfterMount", CloseSecurityTokenSessionsAfterMount);
+
+ // Hotkeys
+ ConfigWriteInt ("HotkeyModAutoMountDevices", Hotkeys[HK_AUTOMOUNT_DEVICES].vKeyModifiers);
+ ConfigWriteInt ("HotkeyCodeAutoMountDevices", Hotkeys[HK_AUTOMOUNT_DEVICES].vKeyCode);
+ ConfigWriteInt ("HotkeyModDismountAll", Hotkeys[HK_DISMOUNT_ALL].vKeyModifiers);
+ ConfigWriteInt ("HotkeyCodeDismountAll", Hotkeys[HK_DISMOUNT_ALL].vKeyCode);
+ ConfigWriteInt ("HotkeyModWipeCache", Hotkeys[HK_WIPE_CACHE].vKeyModifiers);
+ ConfigWriteInt ("HotkeyCodeWipeCache", Hotkeys[HK_WIPE_CACHE].vKeyCode);
+ ConfigWriteInt ("HotkeyModDismountAllWipe", Hotkeys[HK_DISMOUNT_ALL_AND_WIPE].vKeyModifiers);
+ ConfigWriteInt ("HotkeyCodeDismountAllWipe", Hotkeys[HK_DISMOUNT_ALL_AND_WIPE].vKeyCode);
+ ConfigWriteInt ("HotkeyModForceDismountAllWipe", Hotkeys[HK_FORCE_DISMOUNT_ALL_AND_WIPE].vKeyModifiers);
+ ConfigWriteInt ("HotkeyCodeForceDismountAllWipe", Hotkeys[HK_FORCE_DISMOUNT_ALL_AND_WIPE].vKeyCode);
+ ConfigWriteInt ("HotkeyModForceDismountAllWipeExit", Hotkeys[HK_FORCE_DISMOUNT_ALL_AND_WIPE_AND_EXIT].vKeyModifiers);
+ ConfigWriteInt ("HotkeyCodeForceDismountAllWipeExit", Hotkeys[HK_FORCE_DISMOUNT_ALL_AND_WIPE_AND_EXIT].vKeyCode);
+ ConfigWriteInt ("HotkeyModMountFavoriteVolumes", Hotkeys[HK_MOUNT_FAVORITE_VOLUMES].vKeyModifiers);
+ ConfigWriteInt ("HotkeyCodeMountFavoriteVolumes", Hotkeys[HK_MOUNT_FAVORITE_VOLUMES].vKeyCode);
+ ConfigWriteInt ("HotkeyModShowHideMainWindow", Hotkeys[HK_SHOW_HIDE_MAIN_WINDOW].vKeyModifiers);
+ ConfigWriteInt ("HotkeyCodeShowHideMainWindow", Hotkeys[HK_SHOW_HIDE_MAIN_WINDOW].vKeyCode);
+ ConfigWriteInt ("HotkeyModCloseSecurityTokenSessions", Hotkeys[HK_CLOSE_SECURITY_TOKEN_SESSIONS].vKeyModifiers);
+ ConfigWriteInt ("HotkeyCodeCloseSecurityTokenSessions", Hotkeys[HK_CLOSE_SECURITY_TOKEN_SESSIONS].vKeyCode);
+ ConfigWriteInt ("PlaySoundOnHotkeyMountDismount", bPlaySoundOnSuccessfulHkDismount);
+ ConfigWriteInt ("DisplayMsgBoxOnHotkeyDismount", bDisplayBalloonOnSuccessfulHkDismount);
+
+ // Language
+ if (GetPreferredLangId () != NULL)
+ ConfigWriteString ("Language", GetPreferredLangId ());
+
+ // PKCS#11 Library Path
+ ConfigWriteString ("SecurityTokenLibrary", SecurityTokenLibraryPath[0] ? SecurityTokenLibraryPath : "");
+
+ // Mount Options
+ ConfigWriteInt ("DefaultPRF", DefaultVolumePkcs5);
+ ConfigWriteInt ("DefaultTrueCryptMode", DefaultVolumeTrueCryptMode);
+
+ ConfigWriteEnd (hwndDlg);
+ }
+
+ if (bHistoryChanged)
+ {
+ // History
+ DumpCombo (GetDlgItem (hwndDlg, IDC_VOLUME), IsButtonChecked (GetDlgItem (hwndDlg, IDC_NO_HISTORY)));
+ }
NormalCursor ();
}