From 74e14c070fb5bebe5258dde72e879fe7be1e43cf Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Wed, 23 Oct 2019 00:22:31 +0200 Subject: Windows: A Quick Expand option to VeraCrypt Expander to allow quicker expansion of file containers after warning about security issues associated with it. --- src/ExpandVolume/ExpandVolume.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/ExpandVolume/ExpandVolume.c') 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); -- cgit v1.2.3