VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Mount
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2015-03-18 23:13:56 (GMT)
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2015-03-18 23:16:38 (GMT)
commitd3db2548b52b07481185dd966f4819c23d02c0e0 (patch)
treea04bf43f1c8c83d1514b9051851a9f27a31c77b9 /src/Mount
parentf397f70fbe8e43eaa502db00a768e76d7ec377a8 (diff)
downloadVeraCrypt-d3db2548b52b07481185dd966f4819c23d02c0e0.zip
VeraCrypt-d3db2548b52b07481185dd966f4819c23d02c0e0.tar.gz
Windows: correctly handle WIN32 LastError when mounting. Harmonize file access checks between GUI and console. Skip ERROR_SHARING_VIOLATION in primary check in order to let the driver handle it more thoroughly.
Diffstat (limited to 'src/Mount')
-rw-r--r--src/Mount/Mount.c109
1 files changed, 58 insertions, 51 deletions
diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c
index 61bc5ad..3e56754 100644
--- a/src/Mount/Mount.c
+++ b/src/Mount/Mount.c
@@ -5182,74 +5182,81 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (szFileName[0] != 0 && !IsMountedVolume (szFileName))
{
- BOOL mounted;
+ BOOL mounted = FALSE;
int EffectiveVolumePkcs5 = CmdVolumePkcs5;
BOOL EffectiveVolumeTrueCryptMode = CmdVolumeTrueCryptMode;
- /* Priority is given to command line parameters
- * Default values used only when nothing specified in command line
- */
- if (EffectiveVolumePkcs5 == 0)
- EffectiveVolumePkcs5 = DefaultVolumePkcs5;
- if (!EffectiveVolumeTrueCryptMode)
- EffectiveVolumeTrueCryptMode = DefaultVolumeTrueCryptMode;
-
- // Cached password
- mounted = MountVolume (hwndDlg, szDriveLetter[0] - 'A', szFileName, NULL, EffectiveVolumePkcs5, EffectiveVolumeTrueCryptMode, bCacheInDriver, bForceMount, &mountOptions, Silent, FALSE);
-
- // Command line password or keyfiles
- if (!mounted && (CmdVolumePassword.Length != 0 || FirstCmdKeyFile))
+ if (!VolumePathExists (szFileName))
+ {
+ handleWin32Error (hwndDlg);
+ }
+ else
{
- BOOL reportBadPasswd = CmdVolumePassword.Length > 0;
+ /* Priority is given to command line parameters
+ * Default values used only when nothing specified in command line
+ */
+ if (EffectiveVolumePkcs5 == 0)
+ EffectiveVolumePkcs5 = DefaultVolumePkcs5;
+ if (!EffectiveVolumeTrueCryptMode)
+ EffectiveVolumeTrueCryptMode = DefaultVolumeTrueCryptMode;
- if (FirstCmdKeyFile)
- KeyFilesApply (hwndDlg, &CmdVolumePassword, FirstCmdKeyFile);
+ // Cached password
+ mounted = MountVolume (hwndDlg, szDriveLetter[0] - 'A', szFileName, NULL, EffectiveVolumePkcs5, EffectiveVolumeTrueCryptMode, bCacheInDriver, bForceMount, &mountOptions, Silent, FALSE);
- mounted = MountVolume (hwndDlg, szDriveLetter[0] - 'A',
- szFileName, &CmdVolumePassword, EffectiveVolumePkcs5, EffectiveVolumeTrueCryptMode, bCacheInDriver, bForceMount,
- &mountOptions, Silent, reportBadPasswd);
+ // Command line password or keyfiles
+ if (!mounted && (CmdVolumePassword.Length != 0 || FirstCmdKeyFile))
+ {
+ BOOL reportBadPasswd = CmdVolumePassword.Length > 0;
- burn (&CmdVolumePassword, sizeof (CmdVolumePassword));
- }
+ if (FirstCmdKeyFile)
+ KeyFilesApply (hwndDlg, &CmdVolumePassword, FirstCmdKeyFile);
- if (FirstCmdKeyFile)
- {
- FirstKeyFile = FirstCmdKeyFile;
- KeyFilesEnable = TRUE;
- }
+ mounted = MountVolume (hwndDlg, szDriveLetter[0] - 'A',
+ szFileName, &CmdVolumePassword, EffectiveVolumePkcs5, EffectiveVolumeTrueCryptMode, bCacheInDriver, bForceMount,
+ &mountOptions, Silent, reportBadPasswd);
- // Ask user for password
- while (!mounted && !Silent)
- {
- int GuiPkcs5 = EffectiveVolumePkcs5;
- BOOL GuiTrueCryptMode = EffectiveVolumeTrueCryptMode;
- VolumePassword.Length = 0;
+ burn (&CmdVolumePassword, sizeof (CmdVolumePassword));
+ }
- StringCbCopyA (PasswordDlgVolume, sizeof(PasswordDlgVolume),szFileName);
- if (!AskVolumePassword (hwndDlg, &VolumePassword, &GuiPkcs5, &GuiTrueCryptMode, NULL, TRUE))
- break;
- else
+ if (FirstCmdKeyFile)
{
- VolumePkcs5 = GuiPkcs5;
- VolumeTrueCryptMode = GuiTrueCryptMode;
- burn (&GuiPkcs5, sizeof(GuiPkcs5));
- burn (&GuiTrueCryptMode, sizeof(GuiTrueCryptMode));
+ FirstKeyFile = FirstCmdKeyFile;
+ KeyFilesEnable = TRUE;
}
- WaitCursor ();
+ // Ask user for password
+ while (!mounted && !Silent)
+ {
+ int GuiPkcs5 = EffectiveVolumePkcs5;
+ BOOL GuiTrueCryptMode = EffectiveVolumeTrueCryptMode;
+ VolumePassword.Length = 0;
+
+ StringCbCopyA (PasswordDlgVolume, sizeof(PasswordDlgVolume),szFileName);
+ if (!AskVolumePassword (hwndDlg, &VolumePassword, &GuiPkcs5, &GuiTrueCryptMode, NULL, TRUE))
+ break;
+ else
+ {
+ VolumePkcs5 = GuiPkcs5;
+ VolumeTrueCryptMode = GuiTrueCryptMode;
+ burn (&GuiPkcs5, sizeof(GuiPkcs5));
+ burn (&GuiTrueCryptMode, sizeof(GuiTrueCryptMode));
+ }
- if (KeyFilesEnable && FirstKeyFile)
- KeyFilesApply (hwndDlg, &VolumePassword, FirstKeyFile);
+ WaitCursor ();
- mounted = MountVolume (hwndDlg, szDriveLetter[0] - 'A', szFileName, &VolumePassword, VolumePkcs5, VolumeTrueCryptMode, bCacheInDriver, bForceMount, &mountOptions, FALSE, TRUE);
+ if (KeyFilesEnable && FirstKeyFile)
+ KeyFilesApply (hwndDlg, &VolumePassword, FirstKeyFile);
- burn (&VolumePassword, sizeof (VolumePassword));
- burn (&VolumePkcs5, sizeof (VolumePkcs5));
- burn (&VolumeTrueCryptMode, sizeof (VolumeTrueCryptMode));
- burn (&mountOptions.ProtectedHidVolPassword, sizeof (mountOptions.ProtectedHidVolPassword));
- burn (&mountOptions.ProtectedHidVolPkcs5Prf, sizeof (mountOptions.ProtectedHidVolPkcs5Prf));
+ mounted = MountVolume (hwndDlg, szDriveLetter[0] - 'A', szFileName, &VolumePassword, VolumePkcs5, VolumeTrueCryptMode, bCacheInDriver, bForceMount, &mountOptions, FALSE, TRUE);
- NormalCursor ();
+ burn (&VolumePassword, sizeof (VolumePassword));
+ burn (&VolumePkcs5, sizeof (VolumePkcs5));
+ burn (&VolumeTrueCryptMode, sizeof (VolumeTrueCryptMode));
+ burn (&mountOptions.ProtectedHidVolPassword, sizeof (mountOptions.ProtectedHidVolPassword));
+ burn (&mountOptions.ProtectedHidVolPkcs5Prf, sizeof (mountOptions.ProtectedHidVolPkcs5Prf));
+
+ NormalCursor ();
+ }
}
if (UsePreferences)