VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common
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/Common
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/Common')
-rw-r--r--src/Common/Dlgcode.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c
index 6ae4062..5f5d221 100644
--- a/src/Common/Dlgcode.c
+++ b/src/Common/Dlgcode.c
@@ -6317,6 +6317,7 @@ typedef struct
MOUNT_STRUCT* pmount;
BOOL* pbResult;
DWORD* pdwResult;
+ DWORD dwLastError;
} MountThreadParam;
void CALLBACK MountWaitThreadProc(void* pArg, HWND )
@@ -6325,6 +6326,8 @@ void CALLBACK MountWaitThreadProc(void* pArg, HWND )
*(pThreadParam->pbResult) = DeviceIoControl (hDriver, TC_IOCTL_MOUNT_VOLUME, pThreadParam->pmount,
sizeof (MOUNT_STRUCT),pThreadParam->pmount, sizeof (MOUNT_STRUCT), pThreadParam->pdwResult, NULL);
+
+ pThreadParam->dwLastError = GetLastError ();
}
/************************************************************************/
@@ -6353,7 +6356,7 @@ int MountVolume (HWND hwndDlg,
BOOL bReportWrongPassword)
{
MOUNT_STRUCT mount;
- DWORD dwResult;
+ DWORD dwResult, dwLastError = ERROR_SUCCESS;
BOOL bResult, bDevice;
char root[MAX_PATH];
int favoriteMountOnArrivalRetryCount = 0;
@@ -6484,13 +6487,17 @@ retry:
mountThreadParam.pmount = &mount;
mountThreadParam.pbResult = &bResult;
mountThreadParam.pdwResult = &dwResult;
+ mountThreadParam.dwLastError = ERROR_SUCCESS;
ShowWaitDialog (hwndDlg, FALSE, MountWaitThreadProc, &mountThreadParam);
+
+ dwLastError = mountThreadParam.dwLastError;
}
else
{
bResult = DeviceIoControl (hDriver, TC_IOCTL_MOUNT_VOLUME, &mount,
sizeof (mount), &mount, sizeof (mount), &dwResult, NULL);
+ dwLastError = GetLastError ();
}
burn (&mount.VolumePassword, sizeof (mount.VolumePassword));
@@ -6499,6 +6506,7 @@ retry:
burn (&mount.bTrueCryptMode, sizeof (mount.bTrueCryptMode));
burn (&mount.ProtectedHidVolPkcs5Prf, sizeof (mount.ProtectedHidVolPkcs5Prf));
+ SetLastError (dwLastError);
if (bResult == FALSE)
{
// Volume already open by another process
@@ -10270,7 +10278,16 @@ BOOL VolumePathExists (const char *volumePath)
return TRUE;
}
- return _access (volumePath, 0) == 0;
+ if (_access (volumePath, 0) == 0)
+ return TRUE;
+ else
+ {
+ DWORD dwResult = GetLastError ();
+ if (dwResult == ERROR_SHARING_VIOLATION)
+ return TRUE;
+ else
+ return FALSE;
+ }
}