diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2019-10-23 00:22:31 +0200 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2019-10-23 00:24:02 +0200 |
commit | 74e14c070fb5bebe5258dde72e879fe7be1e43cf (patch) | |
tree | 16b35bea9c9bae357473c371090e6db6ab2998c4 /src/ExpandVolume/ExpandVolume.c | |
parent | 11f1a21652b2509be9b526ef0c0ed575a0fc5908 (diff) | |
download | VeraCrypt-74e14c070fb5bebe5258dde72e879fe7be1e43cf.tar.gz VeraCrypt-74e14c070fb5bebe5258dde72e879fe7be1e43cf.zip |
Windows: A Quick Expand option to VeraCrypt Expander to allow quicker expansion of file containers after warning about security issues associated with it.
Diffstat (limited to 'src/ExpandVolume/ExpandVolume.c')
-rw-r--r-- | src/ExpandVolume/ExpandVolume.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/ExpandVolume/ExpandVolume.c b/src/ExpandVolume/ExpandVolume.c index 588e7688..ec78a36f 100644 --- a/src/ExpandVolume/ExpandVolume.c +++ b/src/ExpandVolume/ExpandVolume.c @@ -492,7 +492,7 @@ error: Remarks: a lot of code is from TrueCrypt 'Common\Password.c' :: ChangePwd() */ -static int ExpandVolume (HWND hwndDlg, wchar_t *lpszVolume, Password *pVolumePassword, int VolumePkcs5, int VolumePim, uint64 newHostSize, BOOL initFreeSpace) +static int ExpandVolume (HWND hwndDlg, wchar_t *lpszVolume, Password *pVolumePassword, int VolumePkcs5, int VolumePim, uint64 newHostSize, BOOL initFreeSpace, BOOL bQuickExpand) { int nDosLinkCreated = 1, nStatus = ERR_OS_ERROR; wchar_t szDiskFile[TC_MAX_PATH], szCFDevice[TC_MAX_PATH]; @@ -754,8 +754,21 @@ static int ExpandVolume (HWND hwndDlg, wchar_t *lpszVolume, Password *pVolumePas { // Preallocate the file if (!SetFilePointerEx (dev, liNewSize, NULL, FILE_BEGIN) - || !SetEndOfFile (dev) - || SetFilePointer (dev, 0, NULL, FILE_BEGIN) != 0) + || !SetEndOfFile (dev)) + { + nStatus = ERR_OS_ERROR; + goto error; + } + + if (bQuickExpand) + { + if (!SetFileValidData (dev, liNewSize.QuadPart)) + { + DebugAddProgressDlgStatus(hwndDlg, L"Warning: Failed to perform Quick Expand. Continuing with standard expanding...\r\n"); + } + } + + if (SetFilePointer (dev, 0, NULL, FILE_BEGIN) != 0) { nStatus = ERR_OS_ERROR; goto error; @@ -1061,7 +1074,7 @@ void __cdecl volTransformThreadFunction (void *pExpandDlgParam) HWND hwndDlg = (HWND) pParam->hwndDlg; nStatus = ExpandVolume (hwndDlg, (wchar_t*)pParam->szVolumeName, pParam->pVolumePassword, - pParam->VolumePkcs5, pParam->VolumePim, pParam->newSize, pParam->bInitFreeSpace ); + pParam->VolumePkcs5, pParam->VolumePim, pParam->newSize, pParam->bInitFreeSpace, pParam->bQuickExpand ); if (nStatus!=ERR_SUCCESS && nStatus!=ERR_USER_ABORT) handleError (hwndDlg, nStatus, SRC_POS); |