VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Common/Dlgcode.c8
-rw-r--r--src/Common/Dlgcode.h2
-rw-r--r--src/ExpandVolume/WinMain.cpp2
-rw-r--r--src/Format/Tcformat.c8
-rw-r--r--src/Mount/Favorites.cpp17
-rw-r--r--src/Mount/Mount.c14
6 files changed, 28 insertions, 23 deletions
diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c
index d90c1e89..eca8dea5 100644
--- a/src/Common/Dlgcode.c
+++ b/src/Common/Dlgcode.c
@@ -5801,7 +5801,7 @@ BOOL CALLBACK BenchmarkDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
if (benchmarkType == BENCHMARK_TYPE_PRF)
{
- benchmarkPim = GetPim (hwndDlg, IDC_PIM);
+ benchmarkPim = GetPim (hwndDlg, IDC_PIM, 0);
benchmarkPreBoot = GetCheckBox (hwndDlg, IDC_BENCHMARK_PREBOOT);
}
else
@@ -12670,9 +12670,9 @@ std::wstring FindLatestFileOrDirectory (const std::wstring &directory, const wch
return wstring (directory) + L"\\" + name;
}
-int GetPim (HWND hwndDlg, UINT ctrlId)
+int GetPim (HWND hwndDlg, UINT ctrlId, int defaultPim)
{
- int pim = 0;
+ int pim = defaultPim;
HWND hCtrl = GetDlgItem (hwndDlg, ctrlId);
if (IsWindowEnabled (hCtrl) && IsWindowVisible (hCtrl))
{
@@ -12682,7 +12682,7 @@ int GetPim (HWND hwndDlg, UINT ctrlId)
wchar_t* endPtr = NULL;
pim = wcstol(szTmp, &endPtr, 10);
if (pim < 0 || endPtr == szTmp || !endPtr || *endPtr != L'\0')
- pim = 0;
+ pim = defaultPim;
}
}
return pim;
diff --git a/src/Common/Dlgcode.h b/src/Common/Dlgcode.h
index c81c802c..2849aa5e 100644
--- a/src/Common/Dlgcode.h
+++ b/src/Common/Dlgcode.h
@@ -503,7 +503,7 @@ BOOL VolumePathExists (const wchar_t *volumePath);
BOOL IsWindowsIsoBurnerAvailable ();
BOOL LaunchWindowsIsoBurner (HWND hwnd, const wchar_t *isoPath);
BOOL IsApplicationInstalled (const wchar_t *appName);
-int GetPim (HWND hwndDlg, UINT ctrlId);
+int GetPim (HWND hwndDlg, UINT ctrlId, int defaultPim);
void SetPim (HWND hwndDlg, UINT ctrlId, int pim);
BOOL GetPassword (HWND hwndDlg, UINT ctrlID, char* passValue, int bufSize, BOOL bShowError);
void SetPassword (HWND hwndDlg, UINT ctrlID, char* passValue);
diff --git a/src/ExpandVolume/WinMain.cpp b/src/ExpandVolume/WinMain.cpp
index d70b6a47..3fea0407 100644
--- a/src/ExpandVolume/WinMain.cpp
+++ b/src/ExpandVolume/WinMain.cpp
@@ -685,7 +685,7 @@ BOOL CALLBACK ExtcvPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
*pkcs5 = (int) SendMessage (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), CB_GETITEMDATA, SendMessage (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), CB_GETCURSEL, 0, 0), 0);
*truecryptMode = GetCheckBox (hwndDlg, IDC_TRUECRYPT_MODE);
- *pim = GetPim (hwndDlg, IDC_PIM);
+ *pim = GetPim (hwndDlg, IDC_PIM, 0);
/* check that PRF is supported in TrueCrypt Mode */
if ( (*truecryptMode)
diff --git a/src/Format/Tcformat.c b/src/Format/Tcformat.c
index b1c31b26..5b1b0d16 100644
--- a/src/Format/Tcformat.c
+++ b/src/Format/Tcformat.c
@@ -5611,7 +5611,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
{
if (lw == IDC_PIM)
{
- if(GetPim (hwndDlg, IDC_PIM) != 0)
+ if(GetPim (hwndDlg, IDC_PIM, 0) != 0)
{
PimValueChangedWarning = TRUE;
SetDlgItemTextW (hwndDlg, IDC_PIM_HELP, GetString (SysEncInEffect ()? "PIM_SYSENC_CHANGE_WARNING" : "PIM_CHANGE_WARNING"));
@@ -7582,7 +7582,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
else if (nCurPageNo == PIM_PAGE)
{
- volumePim = GetPim (hCurPage, IDC_PIM);
+ volumePim = GetPim (hCurPage, IDC_PIM, 0);
if (!SysEncInEffect() && (volumePim > MAX_PIM_VALUE))
{
@@ -7639,7 +7639,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
hash_algo = (int) SendMessage (GetDlgItem (hCurPage, IDC_PKCS5_PRF_ID), CB_GETITEMDATA, SendMessage (GetDlgItem (hCurPage, IDC_PKCS5_PRF_ID), CB_GETCURSEL, 0, 0), 0);
- volumePim = GetPim (hCurPage, IDC_PIM);
+ volumePim = GetPim (hCurPage, IDC_PIM, 0);
// Store the password in case we need to restore it after keyfile is applied to it
if (!GetPassword (hCurPage, IDC_PASSWORD_DIRECT, szRawPassword, sizeof (szRawPassword), TRUE))
@@ -8764,7 +8764,7 @@ ovf_end:
else if (nCurPageNo == PIM_PAGE)
{
- volumePim = GetPim (hCurPage, IDC_PIM);
+ volumePim = GetPim (hCurPage, IDC_PIM, 0);
}
else if (nCurPageNo == HIDDEN_VOL_HOST_PASSWORD_PAGE
diff --git a/src/Mount/Favorites.cpp b/src/Mount/Favorites.cpp
index ed5e96e0..dab58bc6 100644
--- a/src/Mount/Favorites.cpp
+++ b/src/Mount/Favorites.cpp
@@ -391,7 +391,7 @@ namespace VeraCrypt
case IDC_PIM:
if (hw == EN_CHANGE)
{
- int pim = GetPim (hwndDlg, IDC_PIM);
+ int pim = GetPim (hwndDlg, IDC_PIM, -1);
if (pim > (SystemFavoritesMode? MAX_BOOT_PIM_VALUE: MAX_PIM_VALUE))
{
SetDlgItemText (hwndDlg, IDC_PIM, L"");
@@ -618,9 +618,14 @@ namespace VeraCrypt
/* support old attribute name before it was changed to PIM*/
XmlGetAttributeText (xml, "pin", label, sizeof (label));
}
- favorite.Pim = strtol (label, NULL, 10);
- if (favorite.Pim < 0 || favorite.Pim > (systemFavorites? MAX_BOOT_PIM_VALUE : MAX_PIM_VALUE))
- favorite.Pim = 0;
+ if (label[0])
+ {
+ favorite.Pim = strtol (label, NULL, 10);
+ if (favorite.Pim < 0 || favorite.Pim > (systemFavorites? MAX_BOOT_PIM_VALUE : MAX_PIM_VALUE))
+ favorite.Pim = -1;
+ }
+ else
+ favorite.Pim = -1;
char boolVal[2];
XmlGetAttributeText (xml, "readonly", boolVal, sizeof (boolVal));
@@ -786,7 +791,7 @@ namespace VeraCrypt
if (!favorite.Label.empty())
s += L" label=\"" + favorite.Label + L"\"";
- if (favorite.Pim > 0)
+ if ((favorite.Pim >= 0) && (favorite.TrueCryptMode <= 0))
s += L" pim=\"" + IntToWideString(favorite.Pim) + L"\"";
if (favorite.Pkcs5 > 0)
@@ -1029,7 +1034,7 @@ namespace VeraCrypt
else
favorite.Label.clear();
- favorite.Pim = GetPim (hwndDlg, IDC_PIM);
+ favorite.Pim = GetPim (hwndDlg, IDC_PIM, -1);
favorite.UseLabelInExplorer = (IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_USE_LABEL_IN_EXPLORER) != 0);
favorite.UseVolumeID = (IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_USE_VOLUME_ID) != 0);
int nSelected = (int) SendMessage (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), CB_GETCURSEL, 0, 0);
diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c
index b2113694..b0439ea5 100644
--- a/src/Mount/Mount.c
+++ b/src/Mount/Mount.c
@@ -2434,7 +2434,7 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
if (lw == IDC_PIM)
{
- if(GetPim (hwndDlg, IDC_OLD_PIM) != GetPim (hwndDlg, IDC_PIM))
+ if(GetPim (hwndDlg, IDC_OLD_PIM, 0) != GetPim (hwndDlg, IDC_PIM, 0))
{
PimValueChangedWarning = TRUE;
SetDlgItemTextW (hwndDlg, IDC_PIM_HELP, GetString (bSysEncPwdChangeDlgMode? "PIM_SYSENC_CHANGE_WARNING" : "PIM_CHANGE_WARNING"));
@@ -2631,8 +2631,8 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
SendMessage (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), CB_GETCURSEL, 0, 0), 0);
BOOL truecryptMode = GetCheckBox (hwndDlg, IDC_TRUECRYPT_MODE);
- int old_pim = GetPim (hwndDlg, IDC_OLD_PIM);
- int pim = GetPim (hwndDlg, IDC_PIM);
+ int old_pim = GetPim (hwndDlg, IDC_OLD_PIM, 0);
+ int pim = GetPim (hwndDlg, IDC_PIM, 0);
if (truecryptMode && !is_pkcs5_prf_supported (old_pkcs5, TRUE, PRF_BOOT_NO))
{
@@ -3099,7 +3099,7 @@ BOOL CALLBACK PasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
*pkcs5 = (int) SendMessage (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), CB_GETITEMDATA, SendMessage (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), CB_GETCURSEL, 0, 0), 0);
*truecryptMode = GetCheckBox (hwndDlg, IDC_TRUECRYPT_MODE);
- *pim = GetPim (hwndDlg, IDC_PIM);
+ *pim = GetPim (hwndDlg, IDC_PIM, 0);
/* check that PRF is supported in TrueCrypt Mode */
if ( (*truecryptMode)
@@ -3651,7 +3651,7 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
mountOptions->ProtectedHidVolPkcs5Prf = (int) SendMessage (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), CB_GETITEMDATA,
SendMessage (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), CB_GETCURSEL, 0, 0), 0);
- mountOptions->ProtectedHidVolPim = GetPim (hwndDlg, IDC_PIM);
+ mountOptions->ProtectedHidVolPim = GetPim (hwndDlg, IDC_PIM, 0);
}
// Cleanup
@@ -4816,8 +4816,8 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szFileName, int pim,
// try TrueCrypt mode first as it is quick, only if no custom pim specified
if (EffectiveVolumeTrueCryptMode)
mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &VolumePassword, EffectiveVolumePkcs5, 0, TRUE, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, FALSE);
- else
- mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &VolumePassword, EffectiveVolumePkcs5, EffectiveVolumePim, FALSE, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, FALSE);
+ else // if no PIM specified for favorite, we use also the PIM of the previous volume alongside its password.
+ mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &VolumePassword, EffectiveVolumePkcs5, (EffectiveVolumePim < 0)? VolumePim : EffectiveVolumePim, FALSE, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, FALSE);
}
NormalCursor ();