VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2015-01-20 08:02:17 (GMT)
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2015-01-20 11:42:04 (GMT)
commit1efb78266631d4c3aa0cd28e32485a9f2016f9de (patch)
treee6c5bda4e202e4858e2f27db8413356e9ccd875f /src
parent38f3fc816ac1a9f894bc01a6cf9d9b97c2a2e21a (diff)
downloadVeraCrypt-1efb78266631d4c3aa0cd28e32485a9f2016f9de.zip
VeraCrypt-1efb78266631d4c3aa0cd28e32485a9f2016f9de.tar.gz
Windows: Add first version of VeraCryptExpander who is based on extcv. Minor modification to Mount.c to avoid link errors when building VeraCryptExpander.
Diffstat (limited to 'src')
-rw-r--r--src/ExpandVolume/DlgExpandVolume.cpp735
-rw-r--r--src/ExpandVolume/ExpandVolume.c971
-rw-r--r--src/ExpandVolume/ExpandVolume.h94
-rw-r--r--src/ExpandVolume/ExpandVolume.rc317
-rw-r--r--src/ExpandVolume/ExpandVolume.vcproj672
-rw-r--r--src/ExpandVolume/InitDataArea.c358
-rw-r--r--src/ExpandVolume/InitDataArea.h44
-rw-r--r--src/ExpandVolume/Logo_288dpi.bmpbin0 -> 50168 bytes
-rw-r--r--src/ExpandVolume/Logo_96dpi.bmpbin0 -> 5624 bytes
-rw-r--r--src/ExpandVolume/VeraCryptExpander.manifest22
-rw-r--r--src/ExpandVolume/WinMain.cpp971
-rw-r--r--src/ExpandVolume/resource.h143
-rw-r--r--src/Mount/Mount.c7
-rw-r--r--src/Signing/sign.bat1
-rw-r--r--src/VeraCrypt.sln64
15 files changed, 4396 insertions, 3 deletions
diff --git a/src/ExpandVolume/DlgExpandVolume.cpp b/src/ExpandVolume/DlgExpandVolume.cpp
new file mode 100644
index 0000000..966650b
--- /dev/null
+++ b/src/ExpandVolume/DlgExpandVolume.cpp
@@ -0,0 +1,735 @@
+/*
+
+Some portions of the source code contained in this file were derived from the
+source code of TrueCrypt 7.0a, which is governed by the TrueCrypt License 3.0
+that can be found in the file 'License.txt' in the folder 'TrueCrypt-License'.
+
+Modifications and additions to the original source code (contained in this file)
+and all other portions of this file are Copyright (c) 2009-2010 by Kih-Oskh or
+Copyright (c) 2012-2013 Josef Schneider <josef@netpage.dk>
+
+
+Some portions of the source code here are derived from 'Mount\Mount.c'
+
+-------------------------------------------------------------------------------
+
+Original legal notice of the TrueCrypt source:
+
+ Legal Notice: Some portions of the source code contained in this file were
+ derived from the source code of Encryption for the Masses 2.02a, which is
+ Copyright (c) 1998-2000 Paul Le Roux and which is governed by the 'License
+ Agreement for Encryption for the Masses'. Modifications and additions to
+ the original source code (contained in this file) and all other portions
+ of this file are Copyright (c) 2003-2009 TrueCrypt Developers Association
+ and are governed by the TrueCrypt License 3.0 the full text of which is
+ contained in the file License.txt included in TrueCrypt binary and source
+ code distribution packages.
+
+*/
+
+#include "Tcdefs.h"
+
+#include <time.h>
+#include <math.h>
+#include <dbt.h>
+#include <fcntl.h>
+#include <io.h>
+#include <sys/stat.h>
+#include <windowsx.h>
+#include <stdio.h>
+
+#include "Apidrvr.h"
+#include "Volumes.h"
+#include "Crypto.h"
+#include "Dlgcode.h"
+#include "Language.h"
+#include "Pkcs5.h"
+#include "Random.h"
+// #include "../Mount/Mount.h"
+
+#include "../Common/Dictionary.h"
+#include "../Common/Common.h"
+#include "../Common/Resource.h"
+#include "../Common/SecurityToken.h"
+#include "../Common/Progress.h"
+
+#include "ExpandVolume.h"
+#include "Resource.h"
+
+// TO DO: display sector sizes different than 512 bytes
+#define SECTOR_SIZE_MSG 512
+
+#define TIMER_ID_RANDVIEW 0xff
+#define TIMER_INTERVAL_RANDVIEW 50
+
+// see definition of enum EV_FileSystem
+const char * szFileSystemStr[3] = {"RAW","FAT","NTFS"};
+
+// prototypes for internal functions
+BOOL CALLBACK ExpandVolSizeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+BOOL CALLBACK ExpandVolProgressDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+
+namespace VeraCryptExpander
+{
+/* defined in WinMain.c, referenced by ExpandVolumeWizard() */
+int ExtcvAskVolumePassword (HWND hwndDlg, Password *password, int *pkcs5, BOOL* truecryptMode, char *titleStringId, BOOL enableMountOptions);
+}
+
+
+int GetSpaceString(char *dest, size_t maxlen, uint64 size, BOOL bDevice)
+{
+ const char * szFmtBytes = "%.0lf %s";
+ const char * szFmtOther = "%.2lf %s";
+ const char * SuffixStr[] = {"Byte", "kB", "MB", "GB", "TB"};
+ const uint64 Muliplier[] = {1, BYTES_PER_KB, BYTES_PER_MB, BYTES_PER_GB, BYTES_PER_TB};
+ const int nMaxSuffix = sizeof(Muliplier)/sizeof(uint64) - 1;
+ int i;
+
+ for (i=1; i<=nMaxSuffix && size>Muliplier[i]; i++) ;
+
+ --i;
+
+ if (bDevice) {
+ char szTemp[512];
+
+ if (sprintf_s(szTemp, sizeof(szTemp),i?szFmtOther:szFmtBytes, size/(double)Muliplier[i], SuffixStr[i]) < 0 )
+ return -1;
+
+ return sprintf_s(dest, maxlen, "%I64u sectors (%s)", size/SECTOR_SIZE_MSG , szTemp);
+ }
+
+ return sprintf_s(dest, maxlen,i?szFmtOther:szFmtBytes, size/(double)Muliplier[i], SuffixStr[i]);
+}
+
+void SetCurrentVolSize(HWND hwndDlg, uint64 size)
+{
+ const uint64 Muliplier[] = {BYTES_PER_KB, BYTES_PER_MB, BYTES_PER_GB};
+ const int IdRadioBtn[] = {IDC_KB, IDC_MB, IDC_GB};
+ const int nMaxSuffix = sizeof(Muliplier)/sizeof(uint64) - 1;
+ int i;
+ char szTemp[256];
+
+ for (i=1; i<=nMaxSuffix && size>Muliplier[i]; i++) ;
+
+ --i;
+
+ SendDlgItemMessage (hwndDlg, IdRadioBtn[i], BM_SETCHECK, BST_CHECKED, 0);
+ sprintf(szTemp,"%I64u",size/Muliplier[i]);
+ SetWindowText (GetDlgItem (hwndDlg, IDC_SIZEBOX), szTemp);
+}
+
+uint64 GetSizeBoxMultiplier(HWND hwndDlg)
+{
+ const uint64 Muliplier[] = {BYTES_PER_KB, BYTES_PER_MB, BYTES_PER_GB};
+ const int IdRadioBtn[] = {IDC_KB, IDC_MB, IDC_GB};
+ const int nMaxSuffix = sizeof(Muliplier)/sizeof(uint64) - 1;
+ int i;
+
+ for (i=nMaxSuffix; i>0 && !IsButtonChecked (GetDlgItem (hwndDlg, IdRadioBtn[i])); --i) ;
+
+ return Muliplier[i];
+}
+
+BOOL CALLBACK ExpandVolSizeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ static EXPAND_VOL_THREAD_PARAMS *pVolExpandParam;
+
+ WORD lw = LOWORD (wParam);
+
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ char szTemp[4096];
+
+ pVolExpandParam = (EXPAND_VOL_THREAD_PARAMS*)lParam;
+
+ EnableWindow (GetDlgItem (hwndDlg, IDC_SIZEBOX), !pVolExpandParam->bIsDevice);
+ EnableWindow (GetDlgItem (hwndDlg, IDC_KB), !pVolExpandParam->bIsDevice);
+ EnableWindow (GetDlgItem (hwndDlg, IDC_MB), !pVolExpandParam->bIsDevice);
+ EnableWindow (GetDlgItem (hwndDlg, IDC_GB), !pVolExpandParam->bIsDevice);
+
+ EnableWindow (GetDlgItem (hwndDlg, IDC_INIT_NEWSPACE),
+ !(pVolExpandParam->bIsLegacy && pVolExpandParam->bIsDevice));
+ SendDlgItemMessage (hwndDlg, IDC_INIT_NEWSPACE, BM_SETCHECK,
+ pVolExpandParam->bInitFreeSpace ? BST_CHECKED : BST_UNCHECKED, 0);
+
+ if (!pVolExpandParam->bIsDevice)
+ SetCurrentVolSize(hwndDlg,pVolExpandParam->oldSize);
+
+ SendMessage (GetDlgItem (hwndDlg, IDC_BOX_HELP), WM_SETFONT, (WPARAM) hBoldFont, (LPARAM) TRUE);
+
+ GetSpaceString(szTemp,sizeof(szTemp),pVolExpandParam->oldSize,pVolExpandParam->bIsDevice);
+
+ SetWindowText (GetDlgItem (hwndDlg, IDC_EXPAND_VOLUME_OLDSIZE), szTemp);
+ SetWindowText (GetDlgItem (hwndDlg, IDC_EXPAND_VOLUME_NAME), pVolExpandParam->szVolumeName);
+ SetWindowText (GetDlgItem (hwndDlg, IDC_EXPAND_FILE_SYSTEM), szFileSystemStr[pVolExpandParam->FileSystem]);
+
+ if (pVolExpandParam->bIsDevice)
+ {
+ GetSpaceString(szTemp,sizeof(szTemp),pVolExpandParam->newSize,TRUE);
+ }
+ else
+ {
+ char szHostFreeStr[256];
+
+ SetWindowText (GetDlgItem (hwndDlg, IDT_NEW_SIZE), "");
+ GetSpaceString(szHostFreeStr,sizeof(szHostFreeStr),pVolExpandParam->hostSizeFree,FALSE);
+ sprintf (szTemp,"%s available on host drive", szHostFreeStr);
+ }
+
+ SetWindowText (GetDlgItem (hwndDlg, IDC_EXPAND_VOLUME_NEWSIZE), szTemp);
+
+ // set help text
+ if (pVolExpandParam->bIsDevice)
+ {
+ sprintf (szTemp,"This is a device-based VeraCrypt volume.\n\nThe new volume size will be choosen automatically as the size of the host device.");
+ if (pVolExpandParam->bIsLegacy)
+ strcat(szTemp," Note: filling the new space with random data is not supported for legacy volumes.");
+ }
+ else
+ {
+ sprintf (szTemp,"Please specify the new size of the VeraCrypt volume (must be at least %I64u KB larger than the current size).",TC_MINVAL_FS_EXPAND/1024);
+ }
+ SetWindowText (GetDlgItem (hwndDlg, IDC_BOX_HELP), szTemp);
+
+ }
+ return 0;
+
+
+ case WM_COMMAND:
+ if (lw == IDCANCEL)
+ {
+ EndDialog (hwndDlg, lw);
+ return 1;
+ }
+
+ if (lw == IDOK)
+ {
+ char szTemp[4096];
+
+ pVolExpandParam->bInitFreeSpace = IsButtonChecked (GetDlgItem (hwndDlg, IDC_INIT_NEWSPACE));
+ if (!pVolExpandParam->bIsDevice) // for devices new size is set by calling function
+ {
+ GetWindowText (GetDlgItem (hwndDlg, IDC_SIZEBOX), szTemp, sizeof (szTemp));
+ pVolExpandParam->newSize = _atoi64(szTemp) * GetSizeBoxMultiplier(hwndDlg);
+ }
+
+ EndDialog (hwndDlg, lw);
+ return 1;
+ }
+
+ return 0;
+ }
+
+ return 0;
+}
+
+
+extern "C" void AddProgressDlgStatus(HWND hwndDlg, const char* szText)
+{
+ HWND hwndCtrl;
+
+ hwndCtrl = GetDlgItem (hwndDlg,IDC_BOX_STATUS);
+ SendMessage(hwndCtrl,EM_REPLACESEL,FALSE,(LPARAM)szText);
+ SendMessage(hwndCtrl,EM_SCROLLCARET,0,0);
+}
+
+
+extern "C" void SetProgressDlgStatus(HWND hwndDlg, const char* szText)
+{
+ HWND hwndCtrl;
+
+ hwndCtrl = GetDlgItem (hwndDlg,IDC_BOX_STATUS);
+ SendMessage(hwndCtrl,EM_SETSEL,0,-1);
+ SendMessage(hwndCtrl,EM_REPLACESEL,FALSE,(LPARAM)szText);
+ SendMessage(hwndCtrl,EM_SCROLLCARET,0,0);
+}
+
+
+BOOL CALLBACK ExpandVolProgressDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ static EXPAND_VOL_THREAD_PARAMS *pProgressDlgParam;
+ static BOOL bVolTransformStarted = FALSE;
+ static BOOL showRandPool = TRUE;
+
+ WORD lw = LOWORD (wParam);
+
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ char szOldHostSize[512], szNewHostSize[512];
+
+ pProgressDlgParam = (EXPAND_VOL_THREAD_PARAMS*)lParam;
+ bVolTransformStarted = FALSE;
+ showRandPool = TRUE;
+
+ hCurPage = hwndDlg;
+ nPbar = IDC_PROGRESS_BAR;
+
+ GetSpaceString(szOldHostSize,sizeof(szOldHostSize),pProgressDlgParam->oldSize,pProgressDlgParam->bIsDevice);
+ GetSpaceString(szNewHostSize,sizeof(szNewHostSize),pProgressDlgParam->newSize,pProgressDlgParam->bIsDevice);
+
+ SetWindowText (GetDlgItem (hwndDlg, IDC_EXPAND_VOLUME_OLDSIZE), szOldHostSize);
+ SetWindowText (GetDlgItem (hwndDlg, IDC_EXPAND_VOLUME_NEWSIZE), szNewHostSize);
+ SetWindowText (GetDlgItem (hwndDlg, IDC_EXPAND_VOLUME_NAME), pProgressDlgParam->szVolumeName);
+ SetWindowText (GetDlgItem (hwndDlg, IDC_EXPAND_FILE_SYSTEM), szFileSystemStr[pProgressDlgParam->FileSystem]);
+ SetWindowText (GetDlgItem (hwndDlg, IDC_EXPAND_VOLUME_INITSPACE), pProgressDlgParam->bInitFreeSpace?"Yes":"No");
+
+ SendMessage (GetDlgItem (hwndDlg, IDC_BOX_STATUS), WM_SETFONT, (WPARAM) hBoldFont, (LPARAM) TRUE);
+
+ SendMessage (GetDlgItem (hwndDlg, IDC_RANDOM_BYTES), WM_SETFONT, (WPARAM) hFixedDigitFont, (LPARAM) TRUE);
+
+ // set status text
+ if ( !pProgressDlgParam->bInitFreeSpace && pProgressDlgParam->bIsLegacy )
+ {
+ showRandPool = FALSE;
+ EnableWindow (GetDlgItem (hwndDlg, IDC_DISPLAY_POOL_CONTENTS), FALSE);
+ EnableWindow (GetDlgItem (hwndDlg, IDC_RANDOM_BYTES), FALSE);
+ SetDlgItemText(hwndDlg, IDC_BOX_STATUS, "Click 'Continue' to expand the volume.");
+ }
+ else
+ {
+ SetDlgItemText(hwndDlg, IDC_BOX_STATUS, "IMPORTANT: Move your mouse as randomly as possible within this window. The longer you move it, the better. This significantly increases the cryptographic strength of the encryption keys. Then click 'Continue' to expand the volume.");
+ }
+
+ SendMessage (GetDlgItem (hwndDlg, IDC_DISPLAY_POOL_CONTENTS), BM_SETCHECK, showRandPool ? BST_CHECKED : BST_UNCHECKED, 0);
+ SetTimer (hwndDlg, TIMER_ID_RANDVIEW, TIMER_INTERVAL_RANDVIEW, NULL);
+ }
+ return 0;
+ case TC_APPMSG_VOL_TRANSFORM_THREAD_ENDED:
+ {
+ int nStatus = (int)lParam;
+
+ NormalCursor ();
+ if (nStatus != 0)
+ {
+ if ( nStatus != ERR_USER_ABORT )
+ AddProgressDlgStatus (hwndDlg, "Error: volume expansion failed.");
+ else
+ AddProgressDlgStatus (hwndDlg, "Error: operation aborted by user.");
+ }
+ else
+ {
+ AddProgressDlgStatus (hwndDlg, "Finished. Volume successfully expanded.");
+ }
+
+ SetWindowText (GetDlgItem (hwndDlg, IDOK), "Exit");
+ EnableWindow (GetDlgItem (hwndDlg, IDOK), TRUE);
+ EnableWindow (GetDlgItem (hwndDlg, IDCANCEL), FALSE);
+ }
+ return 1;
+
+ case WM_TIMER:
+
+ switch (wParam)
+ {
+ case TIMER_ID_RANDVIEW:
+ {
+ unsigned char tmp[16];
+ char szRndPool[64], *t;
+ DWORD *p;
+
+ if (!showRandPool)
+ return 1;
+
+ RandpeekBytes (hwndDlg, tmp, sizeof (tmp));
+
+ for ( p = (DWORD*)(tmp + sizeof(tmp)), t=szRndPool; p > (DWORD*)tmp; )
+ {
+ int len;
+ if ( (len = sprintf ( t, "%08X", *--p)) < 0 )
+ return 1;
+ t += len;
+ }
+
+ SetWindowText (GetDlgItem (hwndDlg, IDC_RANDOM_BYTES), szRndPool);
+
+ burn (tmp, sizeof(tmp));
+ burn (szRndPool, sizeof(szRndPool));
+ }
+ return 1;
+ }
+ return 0;
+
+ case WM_COMMAND:
+ if (lw == IDC_DISPLAY_POOL_CONTENTS)
+ {
+ showRandPool = IsButtonChecked (GetDlgItem (hwndDlg, IDC_DISPLAY_POOL_CONTENTS));
+ return 1;
+ }
+ if (lw == IDCANCEL)
+ {
+ if (bVolTransformStarted)
+ {
+ if (MessageBoxW (hwndDlg, L"Warning: Volume expansion is in progress!\n\nStopping now may result in a damaged volume.\n\nDo you really want to cancel?", lpszTitle, YES_NO|MB_ICONQUESTION|MB_DEFBUTTON2) == IDNO)
+ return 1;
+
+ // tell the volume transform thread to terminate
+ bVolTransformThreadCancel = TRUE;
+ }
+ EndDialog (hwndDlg, lw);
+ return 1;
+ }
+
+ if (lw == IDOK)
+ {
+ if (bVolTransformStarted)
+ {
+ // TransformThreadFunction finished -> OK button is now exit
+ EndDialog (hwndDlg, lw);
+ }
+ else
+ {
+ showRandPool = FALSE;
+ KillTimer (hwndDlg, TIMER_ID_RANDVIEW);
+ EnableWindow (GetDlgItem (hwndDlg, IDC_DISPLAY_POOL_CONTENTS), FALSE);
+ EnableWindow (GetDlgItem (hwndDlg, IDOK), FALSE);
+ SetProgressDlgStatus (hwndDlg, "Starting volume expansion ...\r\n");
+ bVolTransformStarted = TRUE;
+ pProgressDlgParam->hwndDlg = hwndDlg;
+ if ( _beginthread (volTransformThreadFunction, 0, pProgressDlgParam) == -1L )
+ {
+ handleError (hwndDlg, ERR_OS_ERROR);
+ EndDialog (hwndDlg, lw);
+ }
+ WaitCursor();
+ }
+ return 1;
+ }
+
+ return 0;
+ }
+
+ return 0;
+}
+
+
+typedef struct
+{
+ OpenVolumeContext *context;
+ const char *volumePath;
+ Password *password;
+ int pkcs5_prf;
+ BOOL truecryptMode;
+ BOOL write;
+ BOOL preserveTimestamps;
+ BOOL useBackupHeader;
+ int* nStatus;
+} OpenVolumeThreadParam;
+
+void CALLBACK OpenVolumeWaitThreadProc(void* pArg, HWND hwndDlg)
+{
+ OpenVolumeThreadParam* pThreadParam = (OpenVolumeThreadParam*) pArg;
+
+ *(pThreadParam)->nStatus = OpenVolume(pThreadParam->context, pThreadParam->volumePath, pThreadParam->password, pThreadParam->pkcs5_prf,
+ pThreadParam->truecryptMode, pThreadParam->write, pThreadParam->preserveTimestamps, pThreadParam->useBackupHeader);
+}
+
+/*
+ ExpandVolumeWizard
+
+ Expands a trucrypt volume (wizard for user interface)
+
+ Parameters:
+
+ hwndDlg : HWND
+ [in] handle to parent window (if any)
+
+ szVolume : char *
+ [in] Pointer to a string with the volume name (e.g. '\Device\Harddisk0\Partition1' or 'C:\topsecret.tc')
+
+ Return value:
+
+ none
+
+*/
+void ExpandVolumeWizard (HWND hwndDlg, char *lpszVolume)
+{
+ int nStatus = ERR_OS_ERROR;
+ wchar_t szTmp[4096];
+ Password VolumePassword;
+ int VolumePkcs5 = 0;
+ uint64 hostSize, volSize, hostSizeFree, maxSizeFS;
+ BOOL bIsDevice, bIsLegacy;
+ DWORD dwError;
+ int driveNo;
+ enum EV_FileSystem volFSType;
+ char rootPath[] = "A:\\";
+
+ switch (IsSystemDevicePath (lpszVolume, hwndDlg, TRUE))
+ {
+ case 1:
+ case 2:
+ MessageBoxW (hwndDlg, L"A VeraCrypt system volume can't be expanded.", lpszTitle, MB_OK|MB_ICONEXCLAMATION);
+ goto ret;
+ }
+
+ EnableElevatedCursorChange (hwndDlg);
+ WaitCursor();
+
+ if (IsMountedVolume (lpszVolume))
+ {
+ Warning ("DISMOUNT_FIRST", hwndDlg);
+ goto ret;
+ }
+
+ if (Randinit() != ERR_SUCCESS) {
+ nStatus = ERR_PARAMETER_INCORRECT;
+ goto error;
+ }
+
+ NormalCursor();
+
+ // Ask the user if there is a hidden volume
+ char *volTypeChoices[] = {0, "DOES_VOLUME_CONTAIN_HIDDEN", "VOLUME_CONTAINS_HIDDEN", "VOLUME_DOES_NOT_CONTAIN_HIDDEN", "IDCANCEL", 0};
+ switch (AskMultiChoice ((void **) volTypeChoices, FALSE, hwndDlg))
+ {
+ case 1:
+ MessageBoxW (hwndDlg, L"An outer volume containing a hidden volume can't be expanded, because this destroys the hidden volume.", lpszTitle, MB_OK|MB_ICONEXCLAMATION);
+ goto ret;
+
+ case 2:
+ break;
+
+ default:
+ nStatus = ERR_SUCCESS;
+ goto ret;
+ }
+
+ WaitCursor();
+
+ nStatus = QueryVolumeInfo(hwndDlg,lpszVolume,&hostSizeFree,&maxSizeFS);
+
+ if (nStatus!=ERR_SUCCESS)
+ {
+ nStatus = ERR_OS_ERROR;
+ goto error;
+ }
+
+ NormalCursor();
+
+ while (TRUE)
+ {
+ OpenVolumeContext expandVol;
+ BOOL truecryptMode = FALSE;
+
+ if (!VeraCryptExpander::ExtcvAskVolumePassword (hwndDlg, &VolumePassword, &VolumePkcs5, &truecryptMode, "ENTER_NORMAL_VOL_PASSWORD", FALSE))
+ {
+ goto ret;
+ }
+
+ EnableElevatedCursorChange (hwndDlg);
+ WaitCursor();
+
+ if (KeyFilesEnable && FirstKeyFile)
+ KeyFilesApply (hwndDlg, &VolumePassword, FirstKeyFile);
+
+ WaitCursor ();
+
+ OpenVolumeThreadParam threadParam;
+ threadParam.context = &expandVol;
+ threadParam.volumePath = lpszVolume;
+ threadParam.password = &VolumePassword;
+ threadParam.pkcs5_prf = VolumePkcs5;
+ threadParam.truecryptMode = FALSE;
+ threadParam.write = FALSE;
+ threadParam.preserveTimestamps = bPreserveTimestamp;
+ threadParam.useBackupHeader = FALSE;
+ threadParam.nStatus = &nStatus;
+
+ ShowWaitDialog (hwndDlg, TRUE, OpenVolumeWaitThreadProc, &threadParam);
+
+ NormalCursor ();
+
+ dwError = GetLastError();
+
+ if (nStatus == ERR_SUCCESS)
+ {
+ bIsDevice = expandVol.IsDevice;
+ bIsLegacy = expandVol.CryptoInfo->LegacyVolume;
+ hostSize = expandVol.HostSize;
+ VolumePkcs5 = expandVol.CryptoInfo->pkcs5;
+ if ( bIsLegacy )
+ {
+ if ( bIsDevice )
+ volSize = 0; // updated later
+ else
+ volSize = hostSize;
+ }
+ else
+ {
+ volSize = GetVolumeSizeByDataAreaSize (expandVol.CryptoInfo->VolumeSize.Value, bIsLegacy);
+ }
+ CloseVolume (&expandVol);
+ break;
+ }
+ else if (nStatus != ERR_PASSWORD_WRONG)
+ {
+ SetLastError (dwError);
+ goto error;
+ }
+
+ NormalCursor();
+
+ handleError (hwndDlg, nStatus);
+ }
+
+ WaitCursor();
+
+ // auto mount the volume to check the file system type
+ nStatus=MountVolTemp(hwndDlg, lpszVolume, &driveNo, &VolumePassword, VolumePkcs5);
+
+ if (nStatus != ERR_SUCCESS)
+ goto error;
+
+ rootPath[0] += driveNo;
+
+ if ( !GetFileSystemType(rootPath,&volFSType) )
+ volFSType = EV_FS_TYPE_RAW;
+
+ if ( bIsLegacy && bIsDevice && volFSType == EV_FS_TYPE_NTFS )
+ {
+ uint64 NumberOfSectors;
+ DWORD BytesPerSector;
+
+ if ( !GetNtfsNumberOfSectors(rootPath, &NumberOfSectors, &BytesPerSector) )
+ nStatus = ERR_OS_ERROR;
+
+ // NTFS reported size does not include boot sector copy at volume end
+ volSize = ( NumberOfSectors + 1 ) * BytesPerSector;
+ }
+
+ UnmountVolume (hwndDlg, driveNo, TRUE);
+
+ NormalCursor();
+
+ if (nStatus != ERR_SUCCESS)
+ goto error;
+
+ if ( bIsDevice && bIsLegacy && volFSType != EV_FS_TYPE_NTFS )
+ {
+ MessageBoxW (hwndDlg,
+ L"Expanding a device hosted legacy volume with no NTFS file system\n"
+ L"is unsupported.\n"
+ L"Note that expanding the VeraCrypt volume itself is not neccessary\n"
+ L"for legacy volumes.\n",
+ lpszTitle, MB_OK|MB_ICONEXCLAMATION);
+ goto ret;
+ }
+
+ // check if there is enough free space on host device/drive to expand the volume
+ if ( (bIsDevice && hostSize < volSize + TC_MINVAL_FS_EXPAND) || (!bIsDevice && hostSizeFree < TC_MINVAL_FS_EXPAND) )
+ {
+ MessageBoxW (hwndDlg, L"Not enough free space to expand the volume", lpszTitle, MB_OK|MB_ICONEXCLAMATION);
+ goto ret;
+ }
+
+ if (!bIsDevice && hostSize != volSize ) {
+ // there is some junk data at the end of the volume
+ if (MessageBoxW (hwndDlg, L"Warning: The container file is larger than the VeraCrypt volume area. The data after the VeraCrypt volume area will be overwritten.\n\nDo you want to continue?", lpszTitle, YES_NO|MB_ICONQUESTION|MB_DEFBUTTON2) == IDNO)
+ goto ret;
+ }
+
+ switch (volFSType)
+ {
+ case EV_FS_TYPE_NTFS:
+ break;
+ case EV_FS_TYPE_FAT:
+ if (MessageBoxW (hwndDlg,L"Warning: The VeraCrypt volume contains a FAT file system!\n\nOnly the VeraCrypt volume itself will be expanded, but not the file system.\n\nDo you want to continue?",
+ lpszTitle, YES_NO|MB_ICONQUESTION|MB_DEFBUTTON2) == IDNO)
+ goto ret;
+ break;
+ default:
+ if (MessageBoxW (hwndDlg,L"Warning: The VeraCrypt volume contains an unknown or no file system!\n\nOnly the VeraCrypt volume itself will be expanded, the file system remains unchanged.\n\nDo you want to continue?",
+ lpszTitle, YES_NO|MB_ICONQUESTION|MB_DEFBUTTON2) == IDNO)
+ goto ret;
+ }
+
+ EXPAND_VOL_THREAD_PARAMS VolExpandParam;
+
+ VolExpandParam.bInitFreeSpace = (bIsLegacy && bIsDevice) ? FALSE:TRUE;
+ VolExpandParam.szVolumeName = lpszVolume;
+ VolExpandParam.FileSystem = volFSType;
+ VolExpandParam.pVolumePassword = &VolumePassword;
+ VolExpandParam.VolumePkcs5 = VolumePkcs5;
+ VolExpandParam.bIsDevice = bIsDevice;
+ VolExpandParam.bIsLegacy = bIsLegacy;
+ VolExpandParam.oldSize = bIsDevice ? volSize : hostSize;
+ VolExpandParam.newSize = hostSize;
+ VolExpandParam.hostSizeFree = hostSizeFree;
+
+ while (1)
+ {
+ uint64 newVolumeSize;
+
+ if (IDCANCEL == DialogBoxParamW (hInst,
+ MAKEINTRESOURCEW (IDD_SIZE_DIALOG), hwndDlg,
+ (DLGPROC) ExpandVolSizeDlgProc, (LPARAM) &VolExpandParam))
+ {
+ goto ret;
+ }
+
+ newVolumeSize = VolExpandParam.newSize;
+
+ if ( !bIsDevice )
+ {
+ if ( newVolumeSize < hostSize + TC_MINVAL_FS_EXPAND)
+ {
+ swprintf(szTmp,L"New volume size too small, must be at least %I64u kB larger than the current size.",TC_MINVAL_FS_EXPAND/BYTES_PER_KB);
+ MessageBoxW (hwndDlg, szTmp, lpszTitle, MB_OK | MB_ICONEXCLAMATION );
+ continue;
+ }
+
+ if ( newVolumeSize - hostSize > hostSizeFree )
+ {
+ swprintf(szTmp,L"New volume size too large, not enough space on host drive.");
+ MessageBoxW (hwndDlg, szTmp, lpszTitle, MB_OK | MB_ICONEXCLAMATION );
+ continue;
+ }
+
+ if ( newVolumeSize>maxSizeFS )
+ {
+ swprintf(szTmp,L"Maximum file size of %I64u MB on host drive exceeded.",maxSizeFS/BYTES_PER_MB);
+ MessageBoxW (hwndDlg, L"!\n",lpszTitle, MB_OK | MB_ICONEXCLAMATION );
+ continue;
+ }
+ }
+
+ if ( newVolumeSize > TC_MAX_VOLUME_SIZE )
+ {
+ // note: current limit TC_MAX_VOLUME_SIZE is 1 PetaByte
+ swprintf(szTmp,L"Maximum VeraCrypt volume size of %I64u TB exceeded!\n",TC_MAX_VOLUME_SIZE/BYTES_PER_TB);
+ MessageBoxW (hwndDlg, szTmp,lpszTitle, MB_OK | MB_ICONEXCLAMATION );
+ if (bIsDevice)
+ break; // TODO: ask to limit volume size to TC_MAX_VOLUME_SIZE
+ continue;
+ }
+
+ break;
+ }
+
+ VolExpandParam.oldSize = volSize;
+
+ // start progress dialog
+ DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_EXPAND_PROGRESS_DLG), hwndDlg,
+ (DLGPROC) ExpandVolProgressDlgProc, (LPARAM) &VolExpandParam );
+
+ret:
+ nStatus = ERR_SUCCESS;
+
+error:
+
+ if (nStatus != 0)
+ handleError (hwndDlg, nStatus);
+
+ burn (&VolumePassword, sizeof (VolumePassword));
+
+ RestoreDefaultKeyFilesParam();
+ RandStop (FALSE);
+ NormalCursor();
+
+ return;
+}
+
diff --git a/src/ExpandVolume/ExpandVolume.c b/src/ExpandVolume/ExpandVolume.c
new file mode 100644
index 0000000..53ad7ce
--- /dev/null
+++ b/src/ExpandVolume/ExpandVolume.c
@@ -0,0 +1,971 @@
+/*
+
+Some portions of the source code contained in this file were derived from the
+source code of TrueCrypt 7.0a, which is governed by the TrueCrypt License 3.0
+that can be found in the file 'License.txt' in the folder 'TrueCrypt-License'.
+
+Modifications and additions to the original source code (contained in this file)
+and all other portions of this file are Copyright (c) 2009-2010 by Kih-Oskh or
+Copyright (c) 2012-2013 Josef Schneider <josef@netpage.dk>
+
+TrueCrypt source files used to derive some portions of the source code in this
+file are:
+
+ - 'Mount\Mount.c'
+ - 'Common\Format.c'
+ - 'Common\Password.c'
+ - 'Format\Tcformat.c'
+
+-------------------------------------------------------------------------------
+
+Original legal notice of the TrueCrypt source files:
+
+ Legal Notice: Some portions of the source code contained in this file were
+ derived from the source code of Encryption for the Masses 2.02a, which is
+ Copyright (c) 1998-2000 Paul Le Roux and which is governed by the 'License
+ Agreement for Encryption for the Masses'. Modifications and additions to
+ the original source code (contained in this file) and all other portions
+ of this file are Copyright (c) 2003-2009 TrueCrypt Developers Association
+ and are governed by the TrueCrypt License 3.0 the full text of which is
+ contained in the file License.txt included in TrueCrypt binary and source
+ code distribution packages.
+
+*/
+
+#include "Tcdefs.h"
+
+#include <time.h>
+#include <math.h>
+#include <dbt.h>
+#include <fcntl.h>
+#include <io.h>
+#include <sys/stat.h>
+#include <windowsx.h>
+#include <stdio.h>
+
+#include "Apidrvr.h"
+#include "Volumes.h"
+#include "Crypto.h"
+#include "Dlgcode.h"
+#include "Language.h"
+#include "Pkcs5.h"
+#include "Random.h"
+#include "Progress.h"
+
+#include "InitDataArea.h"
+#include "ExpandVolume.h"
+#include "Resource.h"
+
+#define DEBUG_EXPAND_VOLUME
+
+#ifdef DEBUG_EXPAND_VOLUME
+#define DebugAddProgressDlgStatus AddProgressDlgStatus
+#else
+#define DebugAddProgressDlgStatus(a,b)
+#endif
+
+
+HWND hCurPage; /* Handle to window with progress bar (used by FormatNoFs)*/
+int nPbar; /* Control ID of progress bar (used by FormatNoFs) */
+volatile BOOL bVolTransformThreadCancel = FALSE; /* TRUE if the user cancels/pauses volume expansion */
+
+// internal functions
+static int UpdateVolumeHeaderHostSize (char *lpszVolume, Password *pVolumePassword, HWND hwndDlg, uint64 newHostSize, uint64 *pDataSize, BOOL initFreeSpace);
+static int FsctlExtendVolume(char * szVolume, LONGLONG nTotalSectors );
+
+
+/*
+ MountVolTemp
+
+ Mounts a trucrypt volume temporarily (using any free drive number)
+
+ Parameters:
+
+ hwndDlg : HWND
+ [in] handle to parent window
+
+ volumePath : char *
+ [in] Pointer to a string that contains the volume path
+
+ driveNo : int *
+ [out] returns the drive number (0='A',...)
+
+ password : Password *
+ [in] Pointer to the volume password
+
+ Return value:
+
+ int with Truecrypt error code (ERR_SUCCESS on success)
+
+*/
+int MountVolTemp (HWND hwndDlg, char *volumePath, int *driveNo, Password *password, int pkcs5)
+{
+ MountOptions mountOptions;
+ ZeroMemory (&mountOptions, sizeof (mountOptions));
+
+ *driveNo = GetLastAvailableDrive ();
+
+ if (*driveNo == -1)
+ {
+ *driveNo = -2;
+ return ERR_NO_FREE_DRIVES;
+ }
+
+ mountOptions.ReadOnly = FALSE;
+ mountOptions.Removable = ConfigReadInt ("MountVolumesRemovable", FALSE);
+ mountOptions.ProtectHiddenVolume = FALSE;
+ mountOptions.PreserveTimestamp = bPreserveTimestamp;
+ mountOptions.PartitionInInactiveSysEncScope = FALSE;
+ mountOptions.UseBackupHeader = FALSE;
+
+ if (MountVolume (hwndDlg, *driveNo, volumePath, password, pkcs5, FALSE, FALSE, TRUE, &mountOptions, FALSE, FALSE) < 1)
+ {
+ *driveNo = -3;
+ return ERR_VOL_MOUNT_FAILED;
+ }
+ return 0;
+}
+
+
+/*
+ FsctlExtendVolume
+
+ Expands a volume by sending the FSCTL_EXTEND_VOLUME ioctl command to the volume
+
+ Parameters:
+
+ szVolume : char *
+ [in] Pointer to a string that contains the volume GUID
+
+ nTotalSectors : LONGLONG
+ [in] specifies the total size of the volume, in sectors
+
+ Return value:
+
+ int with Truecrypt error code (ERR_SUCCESS on success)
+
+ Remarks: only supported by NTFS and RAW file systems
+
+*/
+static int FsctlExtendVolume(char * szVolume, LONGLONG nTotalSectors )
+{
+ HANDLE hDevice; // handle to the volume to be extended
+ BOOL bResult; // results flag
+ DWORD nbytes; // discard results
+ DWORD dwError;
+ int nStatus = ERR_OS_ERROR;
+
+ hDevice = CreateFile(szVolume,
+ GENERIC_READ,
+ FILE_SHARE_READ |
+ FILE_SHARE_WRITE,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+
+ if (hDevice == INVALID_HANDLE_VALUE)
+ goto error;
+
+ bResult = DeviceIoControl(hDevice,
+ FSCTL_EXTEND_VOLUME,
+ &nTotalSectors, sizeof(nTotalSectors),
+ NULL, 0,
+ &nbytes,
+ (LPOVERLAPPED) NULL);
+
+ if (bResult)
+ nStatus = ERR_SUCCESS;
+
+error:
+
+ dwError = GetLastError ();
+
+ if (hDevice != INVALID_HANDLE_VALUE)
+ CloseHandle (hDevice);
+
+ SetLastError (dwError);
+
+ return nStatus;
+}
+
+
+BOOL GetFileSystemType(const char *szFileName, enum EV_FileSystem *pFS)
+{
+ char szFS[256];
+ char root[MAX_PATH];
+
+ *pFS = EV_FS_TYPE_RAW;
+
+ if (!GetVolumePathName (szFileName, root, sizeof (root)))
+ return FALSE;
+
+ if ( GetVolumeInformation (root, NULL, 0, NULL, NULL, NULL, szFS, sizeof(szFS)) )
+ {
+ if (!strncmp (szFS, "NTFS", 4))
+ *pFS = EV_FS_TYPE_NTFS;
+ else if (!strncmp (szFS, "FAT", 3)) // FAT16, FAT32
+ *pFS = EV_FS_TYPE_FAT;
+ else
+ *pFS = EV_FS_TYPE_RAW;
+ }
+ else
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/*
+ QueryVolumeInfo
+
+ Retrieves the free disk space and file size limit on the truecrypt volume host
+
+ Parameters:
+
+ hwndDlg : HWND
+ [in] handle to parent window
+
+ lpszVolume : char *
+ [in] Pointer to a string that contains the volume path
+
+ pHostSizeFree : uint64 *
+ [out] returns the free space available on the host (always zero for devices)
+
+ pSizeLimitFS : uint64 *
+ [out] returns the file size limit of the host file system
+
+ Return value:
+
+ int with TrueCrypt error code (ERR_SUCCESS on success)
+
+*/
+int QueryVolumeInfo (HWND hwndDlg, const char *lpszVolume, uint64 * pHostSizeFree, uint64 * pSizeLimitFS )
+{
+ int nStatus = ERR_OS_ERROR;
+ char szDiskFile[TC_MAX_PATH], root[MAX_PATH];
+ BOOL bDevice;
+ enum EV_FileSystem fs;
+
+ *pSizeLimitFS = (uint64)-1;
+
+ CreateFullVolumePath (szDiskFile, sizeof(szDiskFile), lpszVolume, &bDevice);
+
+ if (bDevice)
+ {
+ *pHostSizeFree=0;
+ return ERR_SUCCESS;
+ }
+
+ if (!GetVolumePathName (szDiskFile, root, sizeof (root)))
+ {
+ nStatus = ERR_OS_ERROR;
+ goto error;
+ }
+
+ if( ! GetDiskFreeSpaceEx (root,(PULARGE_INTEGER)pHostSizeFree,NULL,NULL) )
+ {
+ nStatus = ERR_OS_ERROR;
+ goto error;
+ }
+
+ if ( ! GetFileSystemType(root,&fs) )
+ {
+ nStatus = ERR_OS_ERROR;
+ goto error;
+ }
+
+ /* file size limits
+ FAT16 / FAT32 : 4 GB minus 1 byte (2^32 bytes minus 1 byte)
+ NTFS : Architecturally : 16 exabytes minus 1 KB (26^4 bytes minus 1 KB)
+ Implementation (Windows Server 2008): 16 terabytes minus 64 KB (2^44 bytes minus 64 KB)
+ */
+ switch (fs)
+ {
+ case EV_FS_TYPE_NTFS:
+ *pSizeLimitFS = 16 * BYTES_PER_TB - 64 * BYTES_PER_KB;
+ break;
+ case EV_FS_TYPE_FAT:
+ *pSizeLimitFS = 4 * BYTES_PER_GB - 1;
+ default:
+ *pSizeLimitFS = (uint64)-1;
+ }
+
+ nStatus = ERR_SUCCESS;
+
+error:
+
+ return nStatus;
+}
+
+BOOL GetNtfsNumberOfSectors(char * rootPath, uint64 * pNumberOfSectors, DWORD *pBytesPerSector)
+{
+ HANDLE hDevice;
+ BOOL bResult;
+ DWORD nbytes, dwError;
+ size_t len;
+ NTFS_VOLUME_DATA_BUFFER ntfsvdb;
+ char szVolumeGUID[128];
+
+ // get volume name
+ if (!GetVolumeNameForVolumeMountPoint(rootPath,szVolumeGUID,sizeof(szVolumeGUID)))
+ {
+ return FALSE;
+ }
+
+ // strip trailing backslash from volume GUID (otherwise it means root dir)
+ len = strlen(szVolumeGUID);
+ if (len>0)
+ --len;
+ if (szVolumeGUID[len]=='\\')
+ szVolumeGUID[len]=0;
+
+ hDevice = CreateFile(szVolumeGUID,
+ GENERIC_READ,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+
+ if (hDevice == INVALID_HANDLE_VALUE)
+ return (FALSE);
+
+ bResult = DeviceIoControl(hDevice,
+ FSCTL_GET_NTFS_VOLUME_DATA,
+ NULL, 0,
+ &ntfsvdb, sizeof(ntfsvdb),
+ &nbytes,
+ (LPOVERLAPPED) NULL);
+
+ if (bResult)
+ {
+ if (pNumberOfSectors)
+ *pNumberOfSectors = ntfsvdb.NumberSectors.QuadPart;
+ if (pBytesPerSector)
+ *pBytesPerSector = ntfsvdb.BytesPerSector;
+ }
+
+ dwError = GetLastError ();
+ CloseHandle(hDevice);
+ SetLastError (dwError);
+
+ return (bResult);
+}
+
+
+uint64 GetVolumeDataAreaSize (uint64 volumeSize, BOOL legacyVolume)
+{
+ uint64 reservedSize;
+
+ if (legacyVolume)
+ reservedSize = TC_VOLUME_HEADER_SIZE_LEGACY;
+ else
+ reservedSize = TC_TOTAL_VOLUME_HEADERS_SIZE;
+
+ if (volumeSize < reservedSize)
+ return 0;
+
+ return volumeSize - reservedSize;
+}
+
+
+uint64 GetVolumeSizeByDataAreaSize (uint64 dataAreaSize, BOOL legacyVolume)
+{
+ uint64 reservedSize;
+
+ if (legacyVolume)
+ reservedSize = TC_VOLUME_HEADER_SIZE_LEGACY;
+ else
+ reservedSize = TC_TOTAL_VOLUME_HEADERS_SIZE;
+
+ return dataAreaSize + reservedSize;
+}
+
+
+int ExtendFileSystem (HWND hwndDlg , char *lpszVolume, Password *pVolumePassword, int VolumePkcs5, uint64 newDataAreaSize)
+{
+ char szVolumeGUID[128];
+ int driveNo = -1;
+ char rootPath[] = "A:\\";
+ enum EV_FileSystem fs;
+ DWORD dwError;
+ int nStatus = ERR_SUCCESS;
+ DWORD BytesPerSector;
+
+ // mount and resize file system
+
+ DebugAddProgressDlgStatus (hwndDlg, "Mounting volume ...\r\n");
+
+ nStatus=MountVolTemp(hwndDlg, lpszVolume, &driveNo, pVolumePassword, VolumePkcs5);
+ if (nStatus!=ERR_SUCCESS)
+ {
+ driveNo = -1;
+ goto error;
+ }
+
+ rootPath[0] += driveNo;
+
+ if ( !GetFileSystemType(rootPath,&fs) )
+ {
+ dwError = GetLastError();
+ if (dwError = ERROR_UNRECOGNIZED_VOLUME)
+ {
+ // raw volume with unrecognized file system -> return with no error
+ nStatus = ERR_SUCCESS;
+ goto error;
+ }
+ nStatus = ERR_OS_ERROR;
+ goto error;
+ }
+
+ if (fs != EV_FS_TYPE_RAW && fs != EV_FS_TYPE_NTFS )
+ {
+ // FsctlExtendVolume only supports NTFS and RAW -> return with no error
+ nStatus = ERR_SUCCESS;
+ goto error;
+ }
+
+ // Get volume GUID
+ if (!GetVolumeNameForVolumeMountPoint(rootPath,szVolumeGUID,sizeof(szVolumeGUID)))
+ {
+ nStatus = ERR_OS_ERROR;
+ goto error;
+ }
+ else
+ {
+ // strip trailing backslash from volume GUID (otherwise it means root dir)
+ size_t len = strlen(szVolumeGUID);
+ if (len>0) --len;
+ if (szVolumeGUID[len]=='\\') szVolumeGUID[len]=0;
+ }
+
+ // Get Sector Size
+ if ( !GetNtfsNumberOfSectors(rootPath, NULL, &BytesPerSector) )
+ {
+ nStatus = ERR_OS_ERROR;
+ goto error;
+ }
+
+ DebugAddProgressDlgStatus (hwndDlg, "Extending file system ...\r\n");
+
+ // extend volume
+ nStatus = FsctlExtendVolume(szVolumeGUID, newDataAreaSize/BytesPerSector );
+
+error:
+
+ dwError = GetLastError();
+
+ if (driveNo>=0)
+ {
+ DebugAddProgressDlgStatus (hwndDlg, "Unmounting volume ...\r\n");
+ UnmountVolume (hwndDlg, driveNo, TRUE);
+ }
+
+ SetLastError (dwError);
+
+ return nStatus;
+}
+
+/*
+ ExpandVolume
+
+ Sets the volume size in the volume header (and backup header) to a larger value,
+ and resizes the filesystem within the volume (only NTFS supported)
+
+ Parameters:
+
+ hwndDlg : HWND
+ [in] handle to progress dialog
+
+ lpszVolume : char *
+ [in] Pointer to a string that contains the path to the truecrypt volume
+
+ pVolumePassword : Password *
+ [in] Pointer to the volume password
+
+ newHostSize : uint64
+ [in] new value of the volume host size (can be zero for devices,
+ which means the volume should use all space of the host device)
+
+ initFreeSpace : BOOL
+ [in] if true, the new volume space will be initalized with random data
+
+ Return value:
+
+ int with Truecrypt error code (ERR_SUCCESS on success)
+
+ Remarks: a lot of code is from TrueCrypt 'Common\Password.c' :: ChangePwd()
+
+*/
+static int ExpandVolume (HWND hwndDlg, char *lpszVolume, Password *pVolumePassword, int VolumePkcs5, uint64 newHostSize, BOOL initFreeSpace)
+{
+ int nDosLinkCreated = 1, nStatus = ERR_OS_ERROR;
+ char szDiskFile[TC_MAX_PATH], szCFDevice[TC_MAX_PATH];
+ char szDosDevice[TC_MAX_PATH];
+ char buffer[TC_VOLUME_HEADER_EFFECTIVE_SIZE];
+ PCRYPTO_INFO cryptoInfo = NULL, ci = NULL;
+ void *dev = INVALID_HANDLE_VALUE;
+ DWORD dwError;
+ BOOL bDevice;
+ uint64 hostSize=0, newDataAreaSize, currentVolSize;
+ DWORD HostSectorSize;
+ FILETIME ftCreationTime;
+ FILETIME ftLastWriteTime;
+ FILETIME ftLastAccessTime;
+ BOOL bTimeStampValid = FALSE;
+ LARGE_INTEGER headerOffset;
+ BOOL backupHeader;
+
+ if (pVolumePassword->Length == 0) return -1;
+
+ WaitCursor ();
+
+ CreateFullVolumePath (szDiskFile, sizeof(szDiskFile), lpszVolume, &bDevice);
+
+ if (bDevice == FALSE)
+ {
+ strcpy (szCFDevice, szDiskFile);
+ }
+ else
+ {
+ nDosLinkCreated = FakeDosNameForDevice (szDiskFile, szDosDevice, sizeof(szDosDevice), szCFDevice, sizeof(szCFDevice), FALSE);
+
+ if (nDosLinkCreated != 0) // note: nStatus == ERR_OS_ERROR
+ goto error;
+ }
+
+ dev = CreateFile (szCFDevice, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
+
+ if (dev == INVALID_HANDLE_VALUE)
+ goto error;
+
+ if (bDevice)
+ {
+ /* This is necessary to determine the hidden volume header offset */
+
+ if (dev == INVALID_HANDLE_VALUE)
+ {
+ goto error;
+ }
+ else
+ {
+ PARTITION_INFORMATION diskInfo;
+ DWORD dwResult;
+ BOOL bResult;
+
+ bResult = GetPartitionInfo (lpszVolume, &diskInfo);
+
+ if (bResult)
+ {
+ hostSize = diskInfo.PartitionLength.QuadPart;
+ HostSectorSize = TC_SECTOR_SIZE_FILE_HOSTED_VOLUME; //TO DO: get the real host disk sector size
+ }
+ else
+ {
+ DISK_GEOMETRY driveInfo;
+
+ bResult = DeviceIoControl (dev, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0,
+ &driveInfo, sizeof (driveInfo), &dwResult, NULL);
+
+ if (!bResult)
+ goto error;
+
+ hostSize = driveInfo.Cylinders.QuadPart * driveInfo.BytesPerSector *
+ driveInfo.SectorsPerTrack * driveInfo.TracksPerCylinder;
+
+ HostSectorSize = driveInfo.BytesPerSector;
+ }
+
+ if (hostSize == 0)
+ {
+ nStatus = ERR_VOL_SIZE_WRONG;
+ goto error;
+ }
+ }
+ }
+ else
+ {
+ LARGE_INTEGER fileSize;
+ if (!GetFileSizeEx (dev, &fileSize))
+ {
+ nStatus = ERR_OS_ERROR;
+ goto error;
+ }
+
+ hostSize = fileSize.QuadPart;
+ HostSectorSize = TC_SECTOR_SIZE_FILE_HOSTED_VOLUME; //TO DO: get the real host disk sector size
+ }
+
+ if (Randinit ())
+ goto error; // note: nStatus == ERR_OS_ERROR
+
+ if (!bDevice && bPreserveTimestamp)
+ {
+ /* Remember the container modification/creation date and time, (used to reset file date and time of
+ file-hosted volumes after password change (or attempt to), in order to preserve plausible deniability
+ of hidden volumes (last password change time is stored in the volume header). */
+
+ if (GetFileTime ((HANDLE) dev, &ftCreationTime, &ftLastAccessTime, &ftLastWriteTime) == 0)
+ {
+ bTimeStampValid = FALSE;
+ MessageBoxW (hwndDlg, GetString ("GETFILETIME_FAILED_PW"), lpszTitle, MB_OK | MB_ICONEXCLAMATION);
+ }
+ else
+ bTimeStampValid = TRUE;
+ }
+
+ // Seek the volume header
+ headerOffset.QuadPart = TC_VOLUME_HEADER_OFFSET;
+
+ if (!SetFilePointerEx ((HANDLE) dev, headerOffset, NULL, FILE_BEGIN))
+ {
+ nStatus = ERR_OS_ERROR;
+ goto error;
+ }
+
+ /* Read in volume header */
+ nStatus = _lread ((HFILE) dev, buffer, sizeof (buffer));
+ if (nStatus != sizeof (buffer))
+ {
+ // Windows may report EOF when reading sectors from the last cluster of a device formatted as NTFS
+ memset (buffer, 0, sizeof (buffer));
+ }
+
+ /* Try to decrypt the header */
+
+ nStatus = ReadVolumeHeader (FALSE, buffer, pVolumePassword, VolumePkcs5, FALSE, &cryptoInfo, NULL);
+ if (nStatus == ERR_CIPHER_INIT_WEAK_KEY)
+ nStatus = 0; // We can ignore this error here
+
+ if (nStatus != 0)
+ {
+ cryptoInfo = NULL;
+ goto error;
+ }
+
+ if (cryptoInfo->HeaderFlags & TC_HEADER_FLAG_ENCRYPTED_SYSTEM)
+ {
+ nStatus = ERR_SYS_HIDVOL_HEAD_REENC_MODE_WRONG;
+ goto error;
+ }
+
+ if (bDevice && newHostSize == 0)
+ {
+ // this means we shall take all host space as new volume size
+ newHostSize = hostSize;
+ }
+
+ if ( newHostSize % cryptoInfo->SectorSize != 0 || newHostSize > TC_MAX_VOLUME_SIZE || (bDevice && newHostSize > hostSize) )
+ {
+ // 1. must be multiple of sector size
+ // 2. truecrypt volume size limit
+ // 3. for devices volume size can't be larger than host size
+ cryptoInfo = NULL;
+ nStatus = ERR_PARAMETER_INCORRECT;
+ goto error;
+ }
+
+ newDataAreaSize = GetVolumeDataAreaSize (newHostSize, cryptoInfo->LegacyVolume);
+
+ if (cryptoInfo->LegacyVolume)
+ {
+ if (bDevice)
+ {
+ if (initFreeSpace)
+ {
+ // unsupported
+ cryptoInfo = NULL;
+ nStatus = ERR_PARAMETER_INCORRECT;
+ goto error;
+ }
+ else
+ {
+ // note: dummy value (only used for parameter checks)
+ cryptoInfo->VolumeSize.Value = newDataAreaSize - TC_MINVAL_FS_EXPAND;
+ }
+ }
+ else
+ {
+ cryptoInfo->VolumeSize.Value = GetVolumeDataAreaSize (hostSize, TRUE);
+ }
+ }
+
+ currentVolSize = GetVolumeSizeByDataAreaSize (cryptoInfo->VolumeSize.Value, cryptoInfo->LegacyVolume);
+
+ if ( newDataAreaSize < cryptoInfo->VolumeSize.Value + TC_MINVAL_FS_EXPAND )
+ {
+ // shrinking a volume or enlarging by less then TC_MINVAL_FS_EXPAND is not allowed
+ cryptoInfo = NULL;
+ nStatus = ERR_PARAMETER_INCORRECT;
+ goto error;
+ }
+
+ InitProgressBar ( newHostSize, currentVolSize, FALSE, FALSE, FALSE, TRUE);
+
+ if (bVolTransformThreadCancel)
+ {
+ SetLastError(0);
+ nStatus = ERR_USER_ABORT;
+ goto error;
+ }
+
+ if (!bDevice) {
+ LARGE_INTEGER liNewSize;
+
+ liNewSize.QuadPart=(LONGLONG)newHostSize;
+
+ // Preallocate the file
+ if (!SetFilePointerEx (dev, liNewSize, NULL, FILE_BEGIN)
+ || !SetEndOfFile (dev)
+ || SetFilePointer (dev, 0, NULL, FILE_BEGIN) != 0)
+ {
+ nStatus = ERR_OS_ERROR;
+ goto error;
+ }
+ }
+
+ if (initFreeSpace)
+ {
+ uint64 startSector;
+ int64 num_sectors;
+
+ // fill new space with random data
+ startSector = currentVolSize/HostSectorSize ;
+ num_sectors = (newHostSize/HostSectorSize) - startSector;
+
+ if (bDevice && !StartFormatWriteThread())
+ {
+ nStatus = ERR_OS_ERROR;
+ goto error;
+ }
+
+ DebugAddProgressDlgStatus(hwndDlg, "Writing random data to new space ...\r\n");
+
+ SetFormatSectorSize(HostSectorSize);
+ nStatus = FormatNoFs (hwndDlg, startSector, num_sectors, dev, cryptoInfo, FALSE);
+
+ dwError = GetLastError();
+ StopFormatWriteThread();
+ SetLastError (dwError);
+ }
+ else
+ {
+ UpdateProgressBar(newHostSize);
+ }
+
+ if (nStatus != ERR_SUCCESS)
+ {
+ dwError = GetLastError();
+ DebugAddProgressDlgStatus(hwndDlg, "Error: failed to write random data ...\r\n");
+ if ( !bDevice ) {
+ // restore original size of the container file
+ LARGE_INTEGER liOldSize;
+ liOldSize.QuadPart=(LONGLONG)hostSize;
+ if (!SetFilePointerEx (dev, liOldSize, NULL, FILE_BEGIN) || !SetEndOfFile (dev))
+ {
+ DebugAddProgressDlgStatus(hwndDlg, "Warning: failed to restore original size of the container file\r\n");
+ }
+ }
+ SetLastError (dwError);
+ goto error;
+ }
+
+ RandSetHashFunction (cryptoInfo->pkcs5);
+
+ // Re-encrypt the volume header forn non-legacy volumes: backup header first
+ backupHeader = TRUE;
+ headerOffset.QuadPart = TC_VOLUME_HEADER_OFFSET + newHostSize - TC_VOLUME_HEADER_GROUP_SIZE;
+
+ /* note: updating the header is not neccessary for legay volumes */
+ while ( !cryptoInfo->LegacyVolume )
+ {
+ if (backupHeader)
+ DebugAddProgressDlgStatus(hwndDlg, "Writing re-encrypted backup header ...\r\n");
+ else
+ DebugAddProgressDlgStatus(hwndDlg, "Writing re-encrypted primary header ...\r\n");
+
+ // Prepare new volume header
+ nStatus = CreateVolumeHeaderInMemory (hwndDlg, FALSE,
+ buffer,
+ cryptoInfo->ea,
+ cryptoInfo->mode,
+ pVolumePassword,
+ cryptoInfo->pkcs5,
+ (char*)(cryptoInfo->master_keydata),
+ &ci,
+ newDataAreaSize,
+ 0, // hiddenVolumeSize
+ cryptoInfo->EncryptedAreaStart.Value,
+ newDataAreaSize,
+ cryptoInfo->RequiredProgramVersion,
+ cryptoInfo->HeaderFlags,
+ cryptoInfo->SectorSize,
+ TRUE ); // use slow poll
+
+ if (ci != NULL)
+ crypto_close (ci);
+
+ if (nStatus != 0)
+ goto error;
+
+ if (!SetFilePointerEx ((HANDLE) dev, headerOffset, NULL, FILE_BEGIN))
+ {
+ nStatus = ERR_OS_ERROR;
+ goto error;
+ }
+
+ nStatus = _lwrite ((HFILE) dev, buffer, TC_VOLUME_HEADER_EFFECTIVE_SIZE);
+ if (nStatus != TC_VOLUME_HEADER_EFFECTIVE_SIZE)
+ {
+ nStatus = ERR_OS_ERROR;
+ goto error;
+ }
+
+ if ( ( backupHeader && !initFreeSpace )
+ || ( bDevice
+ && !cryptoInfo->LegacyVolume
+ && !cryptoInfo->hiddenVolume
+ && cryptoInfo->HeaderVersion == 4 // BUG in TrueCrypt: doing this only for v4 make no sense
+ && (cryptoInfo->HeaderFlags & TC_HEADER_FLAG_NONSYS_INPLACE_ENC) != 0
+ && (cryptoInfo->HeaderFlags & ~TC_HEADER_FLAG_NONSYS_INPLACE_ENC) == 0 )
+ )
+ {
+ //DebugAddProgressDlgStatus(hwndDlg, "WriteRandomDataToReservedHeaderAreas() ...\r\n");
+ nStatus = WriteRandomDataToReservedHeaderAreas (hwndDlg, dev, cryptoInfo, newDataAreaSize, !backupHeader, backupHeader);
+ if (nStatus != ERR_SUCCESS)
+ goto error;
+ }
+
+ FlushFileBuffers (dev);
+
+ if (!backupHeader)
+ break;
+
+ backupHeader = FALSE;
+ headerOffset.QuadPart = TC_VOLUME_HEADER_OFFSET; // offset for main header
+ }
+
+ /* header successfully updated */
+ nStatus = ERR_SUCCESS;
+
+ if (bVolTransformThreadCancel)
+ {
+ nStatus = ERR_USER_ABORT;
+ goto error;
+ }
+
+ /* wipe old backup header */
+ if ( !cryptoInfo->LegacyVolume )
+ {
+ byte *wipeBuffer = NULL;
+ byte wipeRandChars [TC_WIPE_RAND_CHAR_COUNT];
+ byte wipeRandCharsUpdate [TC_WIPE_RAND_CHAR_COUNT];
+ byte wipePass;
+ uint32 workChunkSize = TC_VOLUME_HEADER_GROUP_SIZE;
+ UINT64_STRUCT unitNo;
+ LARGE_INTEGER offset;
+ WipeAlgorithmId wipeAlgorithm = TC_WIPE_35_GUTMANN;
+
+ DebugAddProgressDlgStatus(hwndDlg, "Wiping old backup header ...\r\n");
+
+ wipeBuffer = (byte *) TCalloc (workChunkSize);
+ if (!wipeBuffer)
+ {
+ nStatus = ERR_OUTOFMEMORY;
+ goto error;
+ }
+
+ offset.QuadPart = currentVolSize - TC_VOLUME_HEADER_GROUP_SIZE;
+ unitNo.Value = offset.QuadPart;
+
+ for (wipePass = 1; wipePass <= GetWipePassCount (wipeAlgorithm); ++wipePass)
+ {
+ if (!WipeBuffer (wipeAlgorithm, wipeRandChars, wipePass, wipeBuffer, workChunkSize))
+ {
+ ULONG i;
+ for (i = 0; i < workChunkSize; ++i)
+ {
+ wipeBuffer[i] = wipePass;
+ }
+
+ EncryptDataUnits (wipeBuffer, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, cryptoInfo);
+ memcpy (wipeRandCharsUpdate, wipeBuffer, sizeof (wipeRandCharsUpdate));
+ }
+
+ if ( !SetFilePointerEx (dev, offset, NULL, FILE_BEGIN)
+ || _lwrite ((HFILE)dev, (LPCSTR)wipeBuffer, workChunkSize) == HFILE_ERROR
+ )
+ {
+ // Write error
+ DebugAddProgressDlgStatus(hwndDlg, "Warning: Failed to wipe old backup header\r\n");
+ MessageBoxW (hwndDlg, L"WARNING: Failed to wipe old backup header!\n\nIt may be possible to use the current volume password to decrypt the old backup header even after a future password change.\n", lpszTitle, MB_OK | MB_ICONEXCLAMATION);
+ if (wipePass == 1)
+ continue; // retry once
+ // non-critical error - it's better to continue
+ nStatus = ERR_SUCCESS;
+ goto error;
+ }
+ FlushFileBuffers(dev);
+ // we don't check FlushFileBuffers() return code, because it fails for devices
+ // (same implementation in password.c - a bug or not ???)
+ }
+ }
+
+error:
+ dwError = GetLastError ();
+
+ burn (buffer, sizeof (buffer));
+
+ if (cryptoInfo != NULL)
+ crypto_close (cryptoInfo);
+
+ if (bTimeStampValid)
+ {
+ // Restore the container timestamp (to preserve plausible deniability of possible hidden volume).
+ if (SetFileTime (dev, &ftCreationTime, &ftLastAccessTime, &ftLastWriteTime) == 0)
+ MessageBoxW (hwndDlg, GetString ("SETFILETIME_FAILED_PW"), lpszTitle, MB_OK | MB_ICONEXCLAMATION);
+ }
+
+ if (dev != INVALID_HANDLE_VALUE)
+ CloseHandle ((HANDLE) dev);
+
+ if (nDosLinkCreated == 0)
+ RemoveFakeDosName (szDiskFile, szDosDevice);
+
+ RandStop (FALSE);
+
+ if (bVolTransformThreadCancel)
+ nStatus = ERR_USER_ABORT;
+
+ SetLastError (dwError);
+
+ if (nStatus == ERR_SUCCESS)
+ {
+ nStatus = ExtendFileSystem (hwndDlg, lpszVolume, pVolumePassword, VolumePkcs5, newDataAreaSize);
+ }
+
+ return nStatus;
+}
+
+
+
+void __cdecl volTransformThreadFunction (void *pExpandDlgParam)
+{
+ int nStatus;
+ EXPAND_VOL_THREAD_PARAMS *pParam=(EXPAND_VOL_THREAD_PARAMS *)pExpandDlgParam;
+ HWND hwndDlg = (HWND) pParam->hwndDlg;
+
+ nStatus = ExpandVolume (hwndDlg, (char*)pParam->szVolumeName, pParam->pVolumePassword,
+ pParam->VolumePkcs5, pParam->newSize, pParam->bInitFreeSpace );
+
+ if (nStatus!=ERR_SUCCESS && nStatus!=ERR_USER_ABORT)
+ handleError (hwndDlg, nStatus);
+
+ bVolTransformThreadCancel = FALSE;
+
+ PostMessage (hwndDlg, TC_APPMSG_VOL_TRANSFORM_THREAD_ENDED, 0, nStatus);
+
+ _endthread ();
+}
diff --git a/src/ExpandVolume/ExpandVolume.h b/src/ExpandVolume/ExpandVolume.h
new file mode 100644
index 0000000..805f1c0
--- /dev/null
+++ b/src/ExpandVolume/ExpandVolume.h
@@ -0,0 +1,94 @@
+/*
+
+Some portions of the source code contained in this file were derived from the
+source code of TrueCrypt 7.0a, which is governed by the TrueCrypt License 3.0
+that can be found in the file 'License.txt' in the folder 'TrueCrypt-License'.
+
+Modifications and additions to the original source code (contained in this file)
+and all other portions of this file are Copyright (c) 2009-2010 by Kih-Oskh or
+Copyright (c) 2012-2013 Josef Schneider <josef@netpage.dk>
+
+TrueCrypt source files used to derive some portions of the source code in this
+file are:
+
+ - 'Mount\Mount.c'
+ - 'Common\Format.c'
+ - 'Common\Password.c'
+ - 'Format\Tcformat.c'
+
+-------------------------------------------------------------------------------
+
+Original legal notice of the TrueCrypt source files:
+
+ Legal Notice: Some portions of the source code contained in this file were
+ derived from the source code of Encryption for the Masses 2.02a, which is
+ Copyright (c) 1998-2000 Paul Le Roux and which is governed by the 'License
+ Agreement for Encryption for the Masses'. Modifications and additions to
+ the original source code (contained in this file) and all other portions
+ of this file are Copyright (c) 2003-2009 TrueCrypt Developers Association
+ and are governed by the TrueCrypt License 3.0 the full text of which is
+ contained in the file License.txt included in TrueCrypt binary and source
+ code distribution packages.
+
+*/
+
+#ifndef TC_HEADER_ExpandVolume
+#define TC_HEADER_ExpandVolume
+
+/* NTFS must be extended at least by one cluster (max. cluster size is 64kB) */
+#define TC_MINVAL_FS_EXPAND (64*1024LL)
+
+enum EV_FileSystem
+{
+ EV_FS_TYPE_RAW = 0,
+ EV_FS_TYPE_FAT = 1,
+ EV_FS_TYPE_NTFS = 2,
+};
+
+extern const char * szFileSystemStr[3];
+
+typedef struct
+{
+ uint64 oldSize;
+ uint64 newSize;
+ uint64 hostSizeFree;
+ const char *szVolumeName;
+ enum EV_FileSystem FileSystem;
+ BOOL bIsDevice;
+ BOOL bIsLegacy;
+ BOOL bInitFreeSpace;
+ Password *pVolumePassword;
+ int VolumePkcs5;
+ HWND hwndDlg;
+} EXPAND_VOL_THREAD_PARAMS;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern HWND hCurPage; /* Handle to current wizard page */
+extern int nPbar; /* Control ID of progress bar:- for format code */
+extern volatile BOOL bVolTransformThreadCancel; /* TRUE if the user cancels/pauses volume expansion */
+
+/* defined in ExpandVolume.c */
+uint64 GetVolumeDataAreaSize (uint64 volumeSize, BOOL legacyVolume);
+uint64 GetVolumeSizeByDataAreaSize (uint64 dataSize, BOOL legacyVolume);
+int QueryVolumeInfo (HWND hwndDlg, const char *lpszVolume, uint64 * pHostSizeFree, uint64 * pSizeLimitFS );
+int MountVolTemp (HWND hwndDlg, char *volumePath, int *driveNo, Password *password, int pkcs5);
+BOOL GetFileSystemType(const char *szFileName, enum EV_FileSystem *pFS);
+BOOL GetNtfsNumberOfSectors(char *rootPath, uint64 *pNumberOfSectors, DWORD *pBytesPerSector);
+void __cdecl volTransformThreadFunction (void *hwndDlgArg);
+
+/* defined in DlgExpandVolume.cpp */
+void AddProgressDlgStatus(HWND hwndDlg, const char* szText);
+void SetProgressDlgStatus(HWND hwndDlg, const char* szText);
+
+#ifdef __cplusplus
+}
+#endif
+
+/* defined in DlgExpandVolume.cpp */
+void ExpandVolumeWizard (HWND hwndDlg, char *lpszVolume);
+
+
+#endif /* TC_HEADER_ExpandVolume */ \ No newline at end of file
diff --git a/src/ExpandVolume/ExpandVolume.rc b/src/ExpandVolume/ExpandVolume.rc
new file mode 100644
index 0000000..87a85f2
--- /dev/null
+++ b/src/ExpandVolume/ExpandVolume.rc
@@ -0,0 +1,317 @@
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+#include "..\\common\\resource.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// German (Germany) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
+#ifdef _WIN32
+LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_SIZE_DIALOG DIALOGEX 0, 0, 376, 271
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "VeraCrypt Expander"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ EDITTEXT IDC_SIZEBOX,30,102,109,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER
+ CONTROL "&KB",IDC_KB,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,169,105,38,10
+ CONTROL "&MB",IDC_MB,"Button",BS_AUTORADIOBUTTON,209,105,38,10
+ CONTROL "&GB",IDC_GB,"Button",BS_AUTORADIOBUTTON,247,105,38,10
+ CONTROL "Fill new space with random data",IDC_INIT_NEWSPACE,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,30,127,118,10
+ DEFPUSHBUTTON "Continue",IDOK,15,238,84,18
+ PUSHBUTTON "Cancel",IDCANCEL,277,238,84,18
+ LTEXT "Help Text",IDC_BOX_HELP,15,165,346,58,0,WS_EX_CLIENTEDGE
+ GROUPBOX "Enter new volume size",IDC_STATIC,15,83,346,63
+ RTEXT "Current size: ",IDT_CURRENT_SIZE,27,42,46,8
+ CONTROL "",IDC_EXPAND_VOLUME_OLDSIZE,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,80,42,275,8,WS_EX_TRANSPARENT
+ RTEXT "New size: ",IDT_NEW_SIZE,28,54,45,8
+ LTEXT "",IDC_EXPAND_VOLUME_NEWSIZE,80,54,275,8,0,WS_EX_TRANSPARENT
+ RTEXT "Volume: ",IDT_VOL_NAME,31,18,42,8
+ GROUPBOX "",IDC_STATIC,15,9,346,59
+ CONTROL "",IDC_EXPAND_VOLUME_NAME,"Static",SS_SIMPLE | WS_GROUP,80,18,275,8,WS_EX_TRANSPARENT
+ RTEXT "File system: ",IDT_FILE_SYS,31,30,42,8
+ CONTROL "",IDC_EXPAND_FILE_SYSTEM,"Static",SS_SIMPLE | WS_GROUP,80,30,275,8,WS_EX_TRANSPARENT
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_SIZE_DIALOG, DIALOG
+ BEGIN
+ LEFTMARGIN, 15
+ RIGHTMARGIN, 361
+ VERTGUIDE, 30
+ TOPMARGIN, 14
+ BOTTOMMARGIN, 256
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+#endif // German (Germany) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_MOUNT_DLG DIALOGEX 0, 0, 376, 271
+STYLE DS_SETFONT | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "VeraCrypt Expander"
+MENU IDR_MENU
+CLASS "CustomDlg"
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ COMBOBOX IDC_VOLUME,56,192,212,74,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
+ PUSHBUTTON "Select &File...",IDC_SELECT_FILE,276,192,84,14
+ PUSHBUTTON "Select D&evice...",IDC_SELECT_DEVICE,276,211,84,14
+ DEFPUSHBUTTON "Start",IDOK,8,243,84,18,WS_GROUP
+ PUSHBUTTON "E&xit",IDC_EXIT,284,243,84,18,WS_GROUP
+ CONTROL 112,IDC_LOGO,"Static",SS_BITMAP | SS_NOTIFY | WS_BORDER,16,192,27,31
+ GROUPBOX "Volume",IDT_VOLUME,8,179,360,53
+ CONTROL "",IDC_STATIC,"Static",SS_ETCHEDFRAME,1,0,373,147
+ GROUPBOX "",IDC_STATIC,282,238,88,24
+ GROUPBOX "",IDC_STATIC,6,238,88,24
+ GROUPBOX "",IDC_STATIC,1,147,373,123,BS_CENTER
+ LTEXT "1. Select the VeraCrypt volume to be expanded\n2. Click the 'Start' button",IDC_STATIC,15,156,293,21
+ LTEXT "Static",IDC_INFOEXPAND,8,6,361,134,SS_NOPREFIX | SS_SUNKEN,WS_EX_STATICEDGE
+END
+
+IDD_PASSWORD_DLG DIALOGEX 0, 0, 322, 91
+STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
+CAPTION "Enter VeraCrypt Volume Password"
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ EDITTEXT IDC_PASSWORD,69,8,166,14,ES_PASSWORD | ES_AUTOHSCROLL
+ CONTROL "Cache passwords and keyfil&es in memory",IDC_CACHE,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,70,50,153,10
+ CONTROL "&Display password",IDC_SHOW_PASSWORD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,70,63,83,10
+ CONTROL "U&se keyfiles",IDC_KEYFILES_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,70,75,83,11
+ PUSHBUTTON "&Keyfiles...",IDC_KEY_FILES,171,72,64,14
+ PUSHBUTTON "Mount Opti&ons...",IDC_MOUNT_OPTIONS,243,72,64,14
+ DEFPUSHBUTTON "OK",IDOK,243,8,64,14
+ PUSHBUTTON "Cancel",IDCANCEL,243,25,64,14
+ RTEXT "Password:",IDT_PASSWORD,0,10,65,13
+ COMBOBOX IDC_PKCS5_PRF_ID,69,26,86,90,CBS_DROPDOWNLIST | WS_TABSTOP
+ RTEXT "PKCS-5 PRF:",IDT_PKCS5_PRF,0,27,65,13
+ CONTROL "TrueCrypt Mode",IDC_TRUECRYPT_MODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,159,28,76,10
+END
+
+IDD_EXPAND_PROGRESS_DLG DIALOGEX 0, 0, 376, 271
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "VeraCrypt Expander"
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ RTEXT "Current size: ",IDT_CURRENT_SIZE,27,40,46,8
+ CONTROL "",IDC_EXPAND_VOLUME_OLDSIZE,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,80,40,275,8,WS_EX_TRANSPARENT
+ RTEXT "New size: ",IDT_NEW_SIZE,28,52,45,8
+ LTEXT "",IDC_EXPAND_VOLUME_NEWSIZE,80,52,275,8,0,WS_EX_TRANSPARENT
+ CONTROL "",IDC_PROGRESS_BAR,"msctls_progress32",PBS_SMOOTH | WS_BORDER,22,96,332,12
+ RTEXT "",IDC_TIMEREMAIN,275,114,42,11,SS_CENTERIMAGE,WS_EX_TRANSPARENT | WS_EX_RIGHT | WS_EX_STATICEDGE
+ RTEXT "",IDC_WRITESPEED,178,114,42,11,SS_CENTERIMAGE,WS_EX_TRANSPARENT | WS_EX_RIGHT | WS_EX_STATICEDGE
+ LTEXT "",IDC_BYTESWRITTEN,77,114,39,11,SS_CENTERIMAGE,WS_EX_TRANSPARENT | WS_EX_RIGHT | WS_EX_STATICEDGE
+ RTEXT "Done",IDT_DONE,53,115,22,8
+ RTEXT "Speed",IDT_SPEED,142,115,34,8
+ RTEXT "Left",IDT_LEFT,248,115,25,8
+ GROUPBOX "",IDC_STATIC,15,84,346,49
+ RTEXT "Volume: ",IDT_VOL_NAME,31,16,42,8
+ GROUPBOX "",IDC_STATIC,15,7,346,72
+ CONTROL "",IDC_EXPAND_VOLUME_NAME,"Static",SS_SIMPLE | WS_GROUP,80,16,275,8,WS_EX_TRANSPARENT
+ DEFPUSHBUTTON "Continue",IDOK,15,238,84,18
+ PUSHBUTTON "Cancel",IDCANCEL,277,238,84,18
+ EDITTEXT IDC_BOX_STATUS,15,162,346,66,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | ES_WANTRETURN | WS_VSCROLL
+ CONTROL "",IDC_EXPAND_VOLUME_INITSPACE,"Static",SS_SIMPLE | WS_GROUP,80,64,275,8,WS_EX_TRANSPARENT
+ RTEXT "Fill new space: ",IDT_INIT_SPACE,20,64,53,8
+ RTEXT "File system: ",IDT_FILE_SYS,31,28,42,8
+ CONTROL "",IDC_EXPAND_FILE_SYSTEM,"Static",SS_SIMPLE | WS_GROUP,80,28,275,8,WS_EX_TRANSPARENT
+ RTEXT "Random Pool: ",IDT_RANDOM_POOL2,20,144,53,8
+ CONTROL "",IDC_RANDOM_BYTES,"Static",SS_SIMPLE | WS_GROUP,80,144,149,8,WS_EX_TRANSPARENT
+ CONTROL "",IDC_DISPLAY_POOL_CONTENTS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,236,142,14,12
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_MOUNT_DLG, DIALOG
+ BEGIN
+ RIGHTMARGIN, 369
+ VERTGUIDE, 8
+ BOTTOMMARGIN, 269
+ END
+
+ IDD_PASSWORD_DLG, DIALOG
+ BEGIN
+ BOTTOMMARGIN, 63
+ END
+
+ IDD_EXPAND_PROGRESS_DLG, DIALOG
+ BEGIN
+ RIGHTMARGIN, 361
+ VERTGUIDE, 15
+ VERTGUIDE, 73
+ VERTGUIDE, 80
+ VERTGUIDE, 355
+ TOPMARGIN, 9
+ BOTTOMMARGIN, 256
+ HORZGUIDE, 162
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// HEADER
+//
+
+IDR_MOUNT_RSRC_HEADER HEADER "resource.h"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 0,7,0,0
+ PRODUCTVERSION 0,7,0,0
+ FILEFLAGSMASK 0x17L
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "FileDescription", "VeraCrypt Expander"
+ VALUE "FileVersion", "0.7"
+ VALUE "LegalCopyright", "Copyright 2015 IDRIX"
+ VALUE "ProductVersion", "0.7"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "#include ""..\\\\common\\\\resource.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "#include ""..\\\\common\\\\common.rc""\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Bitmap
+//
+
+IDB_LOGO_96DPI BITMAP "Logo_96dpi.bmp"
+IDB_LOGO_288DPI BITMAP "Logo_288dpi.bmp"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Menu
+//
+
+IDR_MENU MENUEX
+BEGIN
+ MENUITEM "About", IDM_ABOUT,MFT_STRING,MFS_ENABLED
+ MENUITEM "Homepage", IDM_HOMEPAGE,MFT_STRING | MFT_RIGHTJUSTIFY,MFS_ENABLED
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE
+BEGIN
+ IDS_UACSTRING "VeraCrypt Expander"
+END
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+#include "..\\common\\common.rc"
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/src/ExpandVolume/ExpandVolume.vcproj b/src/ExpandVolume/ExpandVolume.vcproj
new file mode 100644
index 0000000..5881884
--- /dev/null
+++ b/src/ExpandVolume/ExpandVolume.vcproj
@@ -0,0 +1,672 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="ExpandVolume"
+ ProjectGUID="{9715FF1D-599B-4BBC-AD96-BEF6E08FF827}"
+ RootNamespace="ExpandVolume"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine=""
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ AdditionalIncludeDirectories=""
+ TypeLibraryName="$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb"
+ OutputDirectory=""
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\Common;..\Crypto;..\;..\pkcs11"
+ PreprocessorDefinitions="VCEXPANDER;TCMOUNT;WIN32;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS"
+ MinimalRebuild="true"
+ ExceptionHandling="1"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ BufferSecurityCheck="true"
+ EnableFunctionLevelLinking="false"
+ UsePrecompiledHeader="0"
+ BrowseInformation="0"
+ BrowseInformationFile=""
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ DisableSpecificWarnings="4311"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="version.lib comctl32.lib setupapi.lib ..\Crypto\Debug\crypto.lib"
+ OutputFile="$(OutDir)/VeraCryptExpander.exe"
+ LinkIncremental="2"
+ GenerateManifest="false"
+ IgnoreAllDefaultLibraries="false"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile="$(OutDir)/ExpandVolume.pdb"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ AdditionalManifestFiles="VeraCryptExpander.manifest"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ CommandLine="md &quot;..\Debug\Setup Files&quot; 2&gt;NUL:&#x0D;&#x0A;copy Debug\VeraCryptExpander.exe &quot;..\Debug\Setup Files&quot; &gt;NUL:"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ AdditionalIncludeDirectories=""
+ TypeLibraryName="$(SolutionDir)/Mount/$(ProjectName).tlb"
+ OutputDirectory=""
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/w34189"
+ Optimization="2"
+ AdditionalIncludeDirectories="..\Common;..\Crypto;..\;..\pkcs11"
+ PreprocessorDefinitions="VCEXPANDER;TCMOUNT;WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS"
+ RuntimeLibrary="0"
+ BufferSecurityCheck="true"
+ UsePrecompiledHeader="0"
+ AssemblerOutput="2"
+ AssemblerListingLocation="$(IntDir)/"
+ WarningLevel="3"
+ DebugInformationFormat="0"
+ DisableSpecificWarnings="4311"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="comctl32.lib setupapi.lib version.lib ..\Crypto\Release\crypto.lib"
+ OutputFile="$(OutDir)/VeraCryptExpander.exe"
+ LinkIncremental="1"
+ GenerateManifest="false"
+ IgnoreAllDefaultLibraries="false"
+ GenerateDebugInformation="false"
+ GenerateMapFile="true"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ AdditionalManifestFiles="VeraCryptExpander.manifest"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ CommandLine="copy Release\VeraCryptExpander.exe &quot;..\Release\Setup Files\&quot;"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ <ProjectReference
+ ReferencedProjectIdentifier="{993245CF-6B70-47EE-91BB-39F8FC6DC0E7}"
+ RelativePathToProject=".\Crypto\Crypto.vcproj"
+ />
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\DlgExpandVolume.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\ExpandVolume.c"
+ >
+ </File>
+ <File
+ RelativePath=".\InitDataArea.c"
+ >
+ </File>
+ <File
+ RelativePath=".\WinMain.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ CompileAs="2"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ CompileAs="2"
+ />
+ </FileConfiguration>
+ </File>
+ <Filter
+ Name="Common"
+ >
+ <File
+ RelativePath="..\Common\BaseCom.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\BootEncryption.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Cmdline.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Combo.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Crc.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Crypto.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Dictionary.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ CompileAs="2"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ CompileAs="2"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\Common\Dlgcode.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ CompileAs="2"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ CompileAs="2"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\Common\EncryptionThreadPool.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Endian.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\GfMul.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Keyfiles.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ CompileAs="2"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ CompileAs="2"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\Common\Language.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Password.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Pkcs5.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Progress.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Random.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Registry.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\SecurityToken.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Tests.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Volumes.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Wipe.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Wipe.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Xml.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Xts.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Mount"
+ >
+ <File
+ RelativePath="..\Mount\Favorites.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\Mount\Hotkeys.c"
+ >
+ </File>
+ <File
+ RelativePath="..\Mount\MainCom.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\Mount\MainCom.idl"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCMIDLTool"
+ OutputDirectory="$(SolutionDir)/Mount"
+ HeaderFileName="$(SolutionDir)/Mount/$(InputName)_h.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCMIDLTool"
+ OutputDirectory="$(SolutionDir)/Mount"
+ HeaderFileName="$(SolutionDir)/Mount/$(InputName)_h.h"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\Mount\Mount.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ CompileAs="2"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ CompileAs="2"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\Common\Apidrvr.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\BaseCom.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\BootEncryption.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Cmdline.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Combo.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Common.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Crc.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Crypto.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Dictionary.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Dlgcode.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\EncryptionThreadPool.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Exception.h"
+ >
+ </File>
+ <File
+ RelativePath=".\ExpandVolume.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\GfMul.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Hotkeys.h"
+ >
+ </File>
+ <File
+ RelativePath=".\InitDataArea.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Keyfiles.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Language.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Mount\MainCom.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Mount\Mount.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Password.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Pkcs5.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Progress.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Random.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Registry.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Resource.h"
+ >
+ </File>
+ <File
+ RelativePath=".\resource.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\SecurityToken.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Tcdefs.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Tests.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Volumes.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Xml.h"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Xts.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ <File
+ RelativePath=".\ExpandVolume.rc"
+ >
+ </File>
+ <File
+ RelativePath=".\Logo_288dpi.bmp"
+ >
+ </File>
+ <File
+ RelativePath=".\Logo_96dpi.bmp"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Textual_logo_288dpi.bmp"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Textual_logo_96dpi.bmp"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\Textual_logo_background.bmp"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\VeraCrypt.ico"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\VeraCrypt_mounted.ico"
+ >
+ </File>
+ <File
+ RelativePath="..\Common\VeraCrypt_Volume.ico"
+ >
+ </File>
+ <File
+ RelativePath=".\VeraCryptExpander.manifest"
+ >
+ </File>
+ <Filter
+ Name="Common"
+ >
+ <File
+ RelativePath="..\Common\Common.rc"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\Common\Language.xml"
+ >
+ </File>
+ </Filter>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/src/ExpandVolume/InitDataArea.c b/src/ExpandVolume/InitDataArea.c
new file mode 100644
index 0000000..a3793e8
--- /dev/null
+++ b/src/ExpandVolume/InitDataArea.c
@@ -0,0 +1,358 @@
+/*
+
+Most of the source code contained in this file is taken from the source code of
+TrueCrypt 7.0a, which is governed by the TrueCrypt License 3.0 that can be found
+in the file 'License.txt' in the folder 'TrueCrypt-License'.
+
+Modifications and additions to the original source code (contained in this file)
+and all other portions of this file are Copyright (c) 2009-2010 by Kih-Oskh or
+Copyright (c) 2012-2013 Josef Schneider <josef@netpage.dk>
+
+
+Source code here is copied from 'Common/Format.c' with the following changes:
+
+ - functions removed:
+ GetVolumeDataAreaSize (BOOL hiddenVolume, uint64 volumeSize)
+ TCFormatVolume (volatile FORMAT_VOL_PARAMETERS *volParams)
+ FormatNtfs (int driveNo, int clusterSize)
+ FormatExCallback (int command, DWORD subCommand, PVOID parameter)
+
+ - variables removed:
+ volatile BOOLEAN FormatExResult;
+
+ - removed static linkage class from StartFormatWriteThread() and
+ StopFormatWriteThread()
+
+ - new functions:
+ SetFormatSectorSize(uint32 sector_size)
+
+
+-------------------------------------------------------------------------------
+
+Original legal notice of the TrueCrypt source:
+
+ Legal Notice: Some portions of the source code contained in this file were
+ derived from the source code of Encryption for the Masses 2.02a, which is
+ Copyright (c) 1998-2000 Paul Le Roux and which is governed by the 'License
+ Agreement for Encryption for the Masses'. Modifications and additions to
+ the original source code (contained in this file) and all other portions
+ of this file are Copyright (c) 2003-2010 TrueCrypt Developers Association
+ and are governed by the TrueCrypt License 3.0 the full text of which is
+ contained in the file License.txt included in TrueCrypt binary and source
+ code distribution packages. */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "Tcdefs.h"
+
+#include "Common.h"
+#include "Crypto.h"
+#include "Random.h"
+#include "Volumes.h"
+
+#include "Apidrvr.h"
+#include "Dlgcode.h"
+#include "Language.h"
+#include "Progress.h"
+#include "Resource.h"
+
+#include "InitDataArea.h"
+
+int FormatWriteBufferSize = 1024 * 1024;
+static uint32 FormatSectorSize = 0;
+
+void SetFormatSectorSize(uint32 sector_size)
+{
+ FormatSectorSize = sector_size;
+}
+
+int FormatNoFs (HWND hwndDlg, unsigned __int64 startSector, __int64 num_sectors, void * dev, PCRYPTO_INFO cryptoInfo, BOOL quickFormat)
+{
+ int write_buf_cnt = 0;
+ char sector[TC_MAX_VOLUME_SECTOR_SIZE], *write_buf;
+ unsigned __int64 nSecNo = startSector;
+ int retVal = 0;
+ DWORD err;
+ char temporaryKey[MASTER_KEYDATA_SIZE];
+ char originalK2[MASTER_KEYDATA_SIZE];
+
+ LARGE_INTEGER startOffset;
+ LARGE_INTEGER newOffset;
+
+ // Seek to start sector
+ startOffset.QuadPart = startSector * FormatSectorSize;
+ if (!SetFilePointerEx ((HANDLE) dev, startOffset, &newOffset, FILE_BEGIN)
+ || newOffset.QuadPart != startOffset.QuadPart)
+ {
+ return ERR_OS_ERROR;
+ }
+
+ write_buf = (char *)TCalloc (FormatWriteBufferSize);
+ if (!write_buf)
+ return ERR_OUTOFMEMORY;
+
+ VirtualLock (temporaryKey, sizeof (temporaryKey));
+ VirtualLock (originalK2, sizeof (originalK2));
+
+ memset (sector, 0, sizeof (sector));
+
+ // Remember the original secondary key (XTS mode) before generating a temporary one
+ memcpy (originalK2, cryptoInfo->k2, sizeof (cryptoInfo->k2));
+
+ /* Fill the rest of the data area with random data */
+
+ if(!quickFormat)
+ {
+ /* Generate a random temporary key set to be used for "dummy" encryption that will fill
+ the free disk space (data area) with random data. This is necessary for plausible
+ deniability of hidden volumes. */
+
+ // Temporary master key
+ if (!RandgetBytes (hwndDlg, temporaryKey, EAGetKeySize (cryptoInfo->ea), FALSE))
+ goto fail;
+
+ // Temporary secondary key (XTS mode)
+ if (!RandgetBytes (hwndDlg, cryptoInfo->k2, sizeof cryptoInfo->k2, FALSE))
+ goto fail;
+
+ retVal = EAInit (cryptoInfo->ea, temporaryKey, cryptoInfo->ks);
+ if (retVal != ERR_SUCCESS)
+ goto fail;
+
+ if (!EAInitMode (cryptoInfo))
+ {
+ retVal = ERR_MODE_INIT_FAILED;
+ goto fail;
+ }
+
+ while (num_sectors--)
+ {
+ if (WriteSector (dev, sector, write_buf, &write_buf_cnt, &nSecNo,
+ cryptoInfo) == FALSE)
+ goto fail;
+ }
+
+ if (!FlushFormatWriteBuffer (dev, write_buf, &write_buf_cnt, &nSecNo, cryptoInfo))
+ goto fail;
+ }
+ else
+ nSecNo = num_sectors;
+
+ UpdateProgressBar (nSecNo * FormatSectorSize);
+
+ // Restore the original secondary key (XTS mode) in case NTFS format fails and the user wants to try FAT immediately
+ memcpy (cryptoInfo->k2, originalK2, sizeof (cryptoInfo->k2));
+
+ // Reinitialize the encryption algorithm and mode in case NTFS format fails and the user wants to try FAT immediately
+ retVal = EAInit (cryptoInfo->ea, cryptoInfo->master_keydata, cryptoInfo->ks);
+ if (retVal != ERR_SUCCESS)
+ goto fail;
+ if (!EAInitMode (cryptoInfo))
+ {
+ retVal = ERR_MODE_INIT_FAILED;
+ goto fail;
+ }
+
+ burn (temporaryKey, sizeof(temporaryKey));
+ burn (originalK2, sizeof(originalK2));
+ VirtualUnlock (temporaryKey, sizeof (temporaryKey));
+ VirtualUnlock (originalK2, sizeof (originalK2));
+ TCfree (write_buf);
+
+ return 0;
+
+fail:
+ err = GetLastError();
+
+ burn (temporaryKey, sizeof(temporaryKey));
+ burn (originalK2, sizeof(originalK2));
+ VirtualUnlock (temporaryKey, sizeof (temporaryKey));
+ VirtualUnlock (originalK2, sizeof (originalK2));
+ TCfree (write_buf);
+
+ SetLastError (err);
+ return (retVal ? retVal : ERR_OS_ERROR);
+}
+
+
+BOOL WriteSector (void *dev, char *sector,
+ char *write_buf, int *write_buf_cnt,
+ __int64 *nSecNo, PCRYPTO_INFO cryptoInfo)
+{
+ static __int32 updateTime = 0;
+
+ (*nSecNo)++;
+
+ memcpy (write_buf + *write_buf_cnt, sector, FormatSectorSize);
+ (*write_buf_cnt) += FormatSectorSize;
+
+ if (*write_buf_cnt == FormatWriteBufferSize && !FlushFormatWriteBuffer (dev, write_buf, write_buf_cnt, nSecNo, cryptoInfo))
+ return FALSE;
+
+ if (GetTickCount () - updateTime > 25)
+ {
+ if (UpdateProgressBar (*nSecNo * FormatSectorSize))
+ return FALSE;
+
+ updateTime = GetTickCount ();
+ }
+
+ return TRUE;
+
+}
+
+
+static volatile BOOL WriteThreadRunning;
+static volatile BOOL WriteThreadExitRequested;
+static HANDLE WriteThreadHandle;
+
+static byte *WriteThreadBuffer;
+static HANDLE WriteBufferEmptyEvent;
+static HANDLE WriteBufferFullEvent;
+
+static volatile HANDLE WriteRequestHandle;
+static volatile int WriteRequestSize;
+static volatile DWORD WriteRequestResult;
+
+
+static void __cdecl FormatWriteThreadProc (void *arg)
+{
+ DWORD bytesWritten;
+
+ SetThreadPriority (GetCurrentThread(), THREAD_PRIORITY_HIGHEST);
+
+ while (!WriteThreadExitRequested)
+ {
+ if (WaitForSingleObject (WriteBufferFullEvent, INFINITE) == WAIT_FAILED)
+ {
+ handleWin32Error (NULL);
+ break;
+ }
+
+ if (WriteThreadExitRequested)
+ break;
+
+ if (!WriteFile (WriteRequestHandle, WriteThreadBuffer, WriteRequestSize, &bytesWritten, NULL))
+ WriteRequestResult = GetLastError();
+ else
+ WriteRequestResult = ERROR_SUCCESS;
+
+ if (!SetEvent (WriteBufferEmptyEvent))
+ {
+ handleWin32Error (NULL);
+ break;
+ }
+ }
+
+ WriteThreadRunning = FALSE;
+ _endthread();
+}
+
+
+BOOL StartFormatWriteThread ()
+{
+ DWORD sysErr;
+
+ WriteBufferEmptyEvent = NULL;
+ WriteBufferFullEvent = NULL;
+ WriteThreadBuffer = NULL;
+
+ WriteBufferEmptyEvent = CreateEvent (NULL, FALSE, TRUE, NULL);
+ if (!WriteBufferEmptyEvent)
+ goto err;
+
+ WriteBufferFullEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
+ if (!WriteBufferFullEvent)
+ goto err;
+
+ WriteThreadBuffer = TCalloc (FormatWriteBufferSize);
+ if (!WriteThreadBuffer)
+ {
+ SetLastError (ERROR_OUTOFMEMORY);
+ goto err;
+ }
+
+ WriteThreadExitRequested = FALSE;
+ WriteRequestResult = ERROR_SUCCESS;
+
+ WriteThreadHandle = (HANDLE) _beginthread (FormatWriteThreadProc, 0, NULL);
+ if ((uintptr_t) WriteThreadHandle == -1L)
+ goto err;
+
+ WriteThreadRunning = TRUE;
+ return TRUE;
+
+err:
+ sysErr = GetLastError();
+
+ if (WriteBufferEmptyEvent)
+ CloseHandle (WriteBufferEmptyEvent);
+ if (WriteBufferFullEvent)
+ CloseHandle (WriteBufferFullEvent);
+ if (WriteThreadBuffer)
+ TCfree (WriteThreadBuffer);
+
+ SetLastError (sysErr);
+ return FALSE;
+}
+
+
+void StopFormatWriteThread ()
+{
+ if (WriteThreadRunning)
+ {
+ WaitForSingleObject (WriteBufferEmptyEvent, INFINITE);
+
+ WriteThreadExitRequested = TRUE;
+ SetEvent (WriteBufferFullEvent);
+
+ WaitForSingleObject (WriteThreadHandle, INFINITE);
+ }
+
+ CloseHandle (WriteBufferEmptyEvent);
+ CloseHandle (WriteBufferFullEvent);
+ TCfree (WriteThreadBuffer);
+}
+
+
+BOOL FlushFormatWriteBuffer (void *dev, char *write_buf, int *write_buf_cnt, __int64 *nSecNo, PCRYPTO_INFO cryptoInfo)
+{
+ UINT64_STRUCT unitNo;
+ DWORD bytesWritten;
+
+ if (*write_buf_cnt == 0)
+ return TRUE;
+
+ unitNo.Value = (*nSecNo * FormatSectorSize - *write_buf_cnt) / ENCRYPTION_DATA_UNIT_SIZE;
+
+ EncryptDataUnits (write_buf, &unitNo, *write_buf_cnt / ENCRYPTION_DATA_UNIT_SIZE, cryptoInfo);
+
+ if (WriteThreadRunning)
+ {
+ if (WaitForSingleObject (WriteBufferEmptyEvent, INFINITE) == WAIT_FAILED)
+ return FALSE;
+
+ if (WriteRequestResult != ERROR_SUCCESS)
+ {
+ SetEvent (WriteBufferEmptyEvent);
+ SetLastError (WriteRequestResult);
+ return FALSE;
+ }
+
+ memcpy (WriteThreadBuffer, write_buf, *write_buf_cnt);
+ WriteRequestHandle = dev;
+ WriteRequestSize = *write_buf_cnt;
+
+ if (!SetEvent (WriteBufferFullEvent))
+ return FALSE;
+ }
+ else
+ {
+ if (!WriteFile ((HANDLE) dev, write_buf, *write_buf_cnt, &bytesWritten, NULL))
+ return FALSE;
+ }
+
+ *write_buf_cnt = 0;
+ return TRUE;
+}
diff --git a/src/ExpandVolume/InitDataArea.h b/src/ExpandVolume/InitDataArea.h
new file mode 100644
index 0000000..7b648e0
--- /dev/null
+++ b/src/ExpandVolume/InitDataArea.h
@@ -0,0 +1,44 @@
+/*
+
+Most of the source code contained in this file is taken from the source code of
+TrueCrypt 7.0a, which is governed by the TrueCrypt License 3.0 that can be found
+in the file 'License.txt' in the folder 'TrueCrypt-License'.
+
+Modifications and additions to the original source code (contained in this file)
+and all other portions of this file are Copyright (c) 2009-2010 by Kih-Oskh or
+Copyright (c) 2012-2013 Josef Schneider <josef@netpage.dk>
+
+-------------------------------------------------------------------------------
+
+Original legal notice of the TrueCrypt source:
+
+ Legal Notice: Some portions of the source code contained in this file were
+ derived from the source code of Encryption for the Masses 2.02a, which is
+ Copyright (c) 1998-2000 Paul Le Roux and which is governed by the 'License
+ Agreement for Encryption for the Masses'. Modifications and additions to
+ the original source code (contained in this file) and all other portions
+ of this file are Copyright (c) 2003-2010 TrueCrypt Developers Association
+ and are governed by the TrueCrypt License 3.0 the full text of which is
+ contained in the file License.txt included in TrueCrypt binary and source
+ code distribution packages. */
+
+#ifndef TC_HEADER_InitDataArea
+#define TC_HEADER_InitDataArea
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void SetFormatSectorSize (uint32 sector_size);
+int FormatNoFs (HWND hwndDlg, unsigned __int64 startSector, __int64 num_sectors, void *dev, PCRYPTO_INFO cryptoInfo, BOOL quickFormat);
+BOOL WriteSector ( void *dev , char *sector , char *write_buf , int *write_buf_cnt , __int64 *nSecNo , PCRYPTO_INFO cryptoInfo );
+BOOL FlushFormatWriteBuffer (void *dev, char *write_buf, int *write_buf_cnt, __int64 *nSecNo, PCRYPTO_INFO cryptoInfo);
+BOOL StartFormatWriteThread ();
+void StopFormatWriteThread ();
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // TC_HEADER_InitDataArea \ No newline at end of file
diff --git a/src/ExpandVolume/Logo_288dpi.bmp b/src/ExpandVolume/Logo_288dpi.bmp
new file mode 100644
index 0000000..d42da51
--- /dev/null
+++ b/src/ExpandVolume/Logo_288dpi.bmp
Binary files differ
diff --git a/src/ExpandVolume/Logo_96dpi.bmp b/src/ExpandVolume/Logo_96dpi.bmp
new file mode 100644
index 0000000..485923d
--- /dev/null
+++ b/src/ExpandVolume/Logo_96dpi.bmp
Binary files differ
diff --git a/src/ExpandVolume/VeraCryptExpander.manifest b/src/ExpandVolume/VeraCryptExpander.manifest
new file mode 100644
index 0000000..36c64bc
--- /dev/null
+++ b/src/ExpandVolume/VeraCryptExpander.manifest
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+ <v3:trustInfo xmlns:v3="urn:schemas-microsoft-com:asm.v3">
+ <v3:security>
+ <v3:requestedPrivileges>
+ <v3:requestedExecutionLevel level="requireAdministrator" />
+ </v3:requestedPrivileges>
+ </v3:security>
+ </v3:trustInfo>
+ <dependency>
+ <dependentAssembly>
+ <assemblyIdentity
+ type="win32"
+ name="Microsoft.Windows.Common-Controls"
+ version="6.0.0.0"
+ processorArchitecture="*"
+ publicKeyToken="6595b64144ccf1df"
+ language="*"
+ />
+ </dependentAssembly>
+ </dependency>
+</assembly>
diff --git a/src/ExpandVolume/WinMain.cpp b/src/ExpandVolume/WinMain.cpp
new file mode 100644
index 0000000..7940b3d
--- /dev/null
+++ b/src/ExpandVolume/WinMain.cpp
@@ -0,0 +1,971 @@
+/*
+
+Most of the source code contained in this file is taken from the source code of
+TrueCrypt 7.0a, which is governed by the TrueCrypt License 3.0 that can be found
+in the file 'License.txt' in the folder 'TrueCrypt-License'.
+
+Modifications and additions to the original source code (contained in this file)
+and all other portions of this file are Copyright (c) 2009-2010 by Kih-Oskh or
+Copyright (c) 2012-2013 Josef Schneider <josef@netpage.dk>
+
+
+Source code in this file is derived from 'Mount\Mount.c'
+
+-------------------------------------------------------------------------------
+
+Original legal notice of the TrueCrypt source:
+
+ Legal Notice: Some portions of the source code contained in this file were
+ derived from the source code of Encryption for the Masses 2.02a, which is
+ Copyright (c) 1998-2000 Paul Le Roux and which is governed by the 'License
+ Agreement for Encryption for the Masses'. Modifications and additions to
+ the original source code (contained in this file) and all other portions
+ of this file are Copyright (c) 2003-2009 TrueCrypt Developers Association
+ and are governed by the TrueCrypt License 3.0 the full text of which is
+ contained in the file License.txt included in TrueCrypt binary and source
+ code distribution packages.
+
+*/
+
+#include "Tcdefs.h"
+
+#include <time.h>
+#include <math.h>
+#include <dbt.h>
+#include <fcntl.h>
+#include <io.h>
+#include <sys/stat.h>
+#include <windowsx.h>
+
+#include "Apidrvr.h"
+#include "BootEncryption.h"
+#include "Cmdline.h"
+#include "Crypto.h"
+#include "Dlgcode.h"
+#include "Combo.h"
+#include "Keyfiles.h"
+#include "Language.h"
+#include "../Mount/MainCom.h"
+#include "../Mount/Mount.h"
+#include "Pkcs5.h"
+#include "Random.h"
+#include "Registry.h"
+#include "Resource.h"
+#include "Password.h"
+#include "Xml.h"
+#include "../Boot/Windows/BootCommon.h"
+#include "../Common/Dictionary.h"
+#include "../Common/Common.h"
+#include "../Common/Resource.h"
+#include "../Common/SecurityToken.h"
+#include "../Platform/Finally.h"
+#include "../Platform/ForEach.h"
+#include <Strsafe.h>
+
+#include "ExpandVolume.h"
+
+using namespace VeraCrypt;
+
+const char szExpandVolumeInfo[] =
+":: VeraCrypt Expander ::\n\nExpand a VeraCrypt volume on the fly without reformatting\n\n\n\
+All kind of volumes (container files, disks and partitions) formatted with \
+NTFS are supported. The only condition is that there must be enough free \
+space on the host drive or host device of the VeraCrypt volume.\n\n\
+Do not use this software to expand an outer volume containing a hidden \
+volume, because this destroys the hidden volume!\n\
+";
+
+enum timer_ids
+{
+ TIMER_ID_MAIN = 0xff,
+ TIMER_ID_KEYB_LAYOUT_GUARD
+};
+
+enum hidden_os_read_only_notif_mode
+{
+ TC_HIDDEN_OS_READ_ONLY_NOTIF_MODE_NONE = 0,
+ TC_HIDDEN_OS_READ_ONLY_NOTIF_MODE_COMPACT,
+ TC_HIDDEN_OS_READ_ONLY_NOTIF_MODE_DISABLED
+};
+
+#define TIMER_INTERVAL_MAIN 500
+#define TIMER_INTERVAL_KEYB_LAYOUT_GUARD 10
+
+namespace VeraCryptExpander
+{
+
+BOOL bExplore = FALSE; /* Display explorer window after mount */
+BOOL bBeep = FALSE; /* Donot beep after mount */
+char szFileName[TC_MAX_PATH+1]; /* Volume to mount */
+char szDriveLetter[3]; /* Drive Letter to mount */
+char commandLineDrive = 0;
+BOOL bCacheInDriver = FALSE; /* Cache any passwords we see */
+BOOL bCacheInDriverDefault = FALSE;
+BOOL bHistoryCmdLine = FALSE; /* History control is always disabled */
+BOOL bCloseDismountedWindows=TRUE; /* Close all open explorer windows of dismounted volume */
+BOOL bWipeCacheOnExit = FALSE; /* Wipe password from chace on exit */
+BOOL bWipeCacheOnAutoDismount = TRUE;
+BOOL bEnableBkgTask = FALSE;
+BOOL bCloseBkgTaskWhenNoVolumes = FALSE;
+BOOL bDismountOnLogOff = TRUE;
+BOOL bDismountOnScreenSaver = TRUE;
+BOOL bDismountOnPowerSaving = FALSE;
+BOOL bForceAutoDismount = TRUE;
+BOOL bForceMount = FALSE; /* Mount volume even if host file/device already in use */
+BOOL bForceUnmount = FALSE; /* Unmount volume even if it cannot be locked */
+BOOL bWipe = FALSE; /* Wipe driver passwords */
+BOOL bAuto = FALSE; /* Do everything without user input */
+BOOL bAutoMountDevices = FALSE; /* Auto-mount devices */
+BOOL bAutoMountFavorites = FALSE;
+BOOL bPlaySoundOnHotkeyMountDismount = TRUE;
+BOOL bDisplayMsgBoxOnHotkeyDismount = FALSE;
+BOOL bHibernationPreventionNotified = FALSE; /* TRUE if the user has been notified that hibernation was prevented (system encryption) during the session. */
+BOOL bHiddenSysLeakProtNotifiedDuringSession = FALSE; /* TRUE if the user has been notified during the session that unencrypted filesystems and non-hidden VeraCrypt volumes are mounted as read-only under hidden OS. */
+BOOL CloseSecurityTokenSessionsAfterMount = FALSE;
+
+BOOL MultipleMountOperationInProgress = FALSE;
+
+BOOL Quit = FALSE; /* Exit after processing command line */
+BOOL ComServerMode = FALSE;
+BOOL UsePreferences = TRUE;
+
+int HiddenSysLeakProtectionNotificationStatus = TC_HIDDEN_OS_READ_ONLY_NOTIF_MODE_NONE;
+int MaxVolumeIdleTime = -120;
+int nCurrentShowType = 0; /* current display mode, mount, unmount etc */
+int nSelectedDriveIndex = -1; /* Item number of selected drive */
+
+int cmdUnmountDrive = 0; /* Volume drive letter to unmount (-1 = all) */
+Password VolumePassword; /* Password used for mounting volumes */
+Password CmdVolumePassword; /* Password passed from command line */
+BOOL CmdVolumePasswordValid = FALSE;
+MountOptions mountOptions;
+MountOptions defaultMountOptions;
+KeyFile *FirstCmdKeyFile;
+
+HBITMAP hbmLogoBitmapRescaled = NULL;
+char OrigKeyboardLayout [8+1] = "00000409";
+BOOL bKeyboardLayoutChanged = FALSE; /* TRUE if the keyboard layout was changed to the standard US keyboard layout (from any other layout). */
+BOOL bKeybLayoutAltKeyWarningShown = FALSE; /* TRUE if the user has been informed that it is not possible to type characters by pressing keys while the right Alt key is held down. */
+
+static KeyFilesDlgParam hidVolProtKeyFilesParam;
+VOLUME_NOTIFICATIONS_LIST VolumeNotificationsList;
+
+static int bPrebootPasswordDlgMode = FALSE;
+
+static void localcleanup (void)
+{
+ // Wipe command line
+ char *c = GetCommandLineA ();
+ wchar_t *wc = GetCommandLineW ();
+ burn(c, strlen (c));
+ burn(wc, wcslen (wc) * sizeof (wchar_t));
+
+ /* Delete buffered bitmaps (if any) */
+ if (hbmLogoBitmapRescaled != NULL)
+ {
+ DeleteObject ((HGDIOBJ) hbmLogoBitmapRescaled);
+ hbmLogoBitmapRescaled = NULL;
+ }
+
+ /* These items should have already been cleared by the functions that used them, but we're going to
+ clear them for extra security. */
+ burn (&VolumePassword, sizeof (VolumePassword));
+ burn (&CmdVolumePassword, sizeof (CmdVolumePassword));
+ burn (&mountOptions, sizeof (mountOptions));
+ burn (&defaultMountOptions, sizeof (defaultMountOptions));
+ burn (&szFileName, sizeof(szFileName));
+
+ /* Cleanup common code resources */
+ cleanup ();
+
+ RandStop (TRUE);
+}
+
+
+void EndMainDlg (HWND hwndDlg)
+{
+ if (!bHistory)
+ {
+ SetWindowText (GetDlgItem (hwndDlg, IDC_VOLUME), "");
+ }
+
+ EndDialog (hwndDlg, 0);
+}
+
+BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ // dummy (referenced by PasswordDlgProc() )
+ return FALSE;
+}
+BOOL TCBootLoaderOnInactiveSysEncDrive (void)
+{
+ // dummy (referenced by Dlgcode.c)
+ return FALSE;
+}
+
+BOOL CheckSysEncMountWithoutPBA (const char *devicePath, BOOL quiet)
+{
+ // dummy (referenced by Dlgcode.c)
+ return FALSE;
+}
+
+static void InitMainDialog (HWND hwndDlg)
+{
+ /* Call the common dialog init code */
+ InitDialog (hwndDlg);
+ LocalizeDialog (hwndDlg, NULL);
+
+ SendMessage (GetDlgItem (hwndDlg, IDC_VOLUME), CB_LIMITTEXT, TC_MAX_PATH, 0);
+ SetWindowTextW (hwndDlg, lpszTitle);
+
+ SendMessage (GetDlgItem (hwndDlg, IDC_INFOEXPAND), WM_SETFONT, (WPARAM) hBoldFont, (LPARAM) TRUE);
+ SetWindowText (GetDlgItem (hwndDlg, IDC_INFOEXPAND), szExpandVolumeInfo);
+
+ // Resize the logo bitmap if the user has a non-default DPI
+ if (ScreenDPI != USER_DEFAULT_SCREEN_DPI
+ && hbmLogoBitmapRescaled == NULL) // If not re-called (e.g. after language pack change)
+ {
+ hbmLogoBitmapRescaled = RenderBitmap (MAKEINTRESOURCE (IDB_LOGO_288DPI),
+ GetDlgItem (hwndDlg, IDC_LOGO),
+ 0, 0, 0, 0, FALSE, TRUE);
+ }
+
+ EnableDisableButtons (hwndDlg);
+}
+
+void EnableDisableButtons (HWND hwndDlg)
+{
+ HWND hOKButton = GetDlgItem (hwndDlg, IDOK);
+ WORD x;
+
+ x = LOWORD (GetSelectedLong (GetDlgItem (hwndDlg, IDC_DRIVELIST)));
+
+ EnableWindow (hOKButton, TRUE);
+
+}
+
+BOOL VolumeSelected (HWND hwndDlg)
+{
+ return (GetWindowTextLength (GetDlgItem (hwndDlg, IDC_VOLUME)) > 0);
+}
+
+
+void LoadSettings (HWND hwndDlg)
+{
+ WipeAlgorithmId savedWipeAlgorithm = TC_WIPE_NONE;
+
+ LoadSysEncSettings (hwndDlg);
+
+ if (LoadNonSysInPlaceEncSettings (&savedWipeAlgorithm) != 0)
+ bInPlaceEncNonSysPending = TRUE;
+
+ // If the config file has already been loaded during this session
+ if (ConfigBuffer != NULL)
+ {
+ free (ConfigBuffer);
+ ConfigBuffer = NULL;
+ }
+
+ // Options
+ bExplore = ConfigReadInt ("OpenExplorerWindowAfterMount", FALSE);
+ bCloseDismountedWindows = ConfigReadInt ("CloseExplorerWindowsOnDismount", TRUE);
+
+ bHistory = ConfigReadInt ("SaveVolumeHistory", FALSE);
+
+ bCacheInDriverDefault = bCacheInDriver = ConfigReadInt ("CachePasswords", FALSE);
+ bWipeCacheOnExit = ConfigReadInt ("WipePasswordCacheOnExit", FALSE);
+ bWipeCacheOnAutoDismount = ConfigReadInt ("WipeCacheOnAutoDismount", TRUE);
+
+ bStartOnLogon = ConfigReadInt ("StartOnLogon", FALSE);
+ bMountDevicesOnLogon = ConfigReadInt ("MountDevicesOnLogon", FALSE);
+ bMountFavoritesOnLogon = ConfigReadInt ("MountFavoritesOnLogon", FALSE);
+
+ bEnableBkgTask = ConfigReadInt ("EnableBackgroundTask", TRUE);
+ bCloseBkgTaskWhenNoVolumes = ConfigReadInt ("CloseBackgroundTaskOnNoVolumes", FALSE);
+
+ bDismountOnLogOff = ConfigReadInt ("DismountOnLogOff", TRUE);
+ bDismountOnPowerSaving = ConfigReadInt ("DismountOnPowerSaving", FALSE);
+ bDismountOnScreenSaver = ConfigReadInt ("DismountOnScreenSaver", FALSE);
+ bForceAutoDismount = ConfigReadInt ("ForceAutoDismount", TRUE);
+ MaxVolumeIdleTime = ConfigReadInt ("MaxVolumeIdleTime", -60);
+
+ HiddenSectorDetectionStatus = ConfigReadInt ("HiddenSectorDetectionStatus", 0);
+
+ defaultKeyFilesParam.EnableKeyFiles = ConfigReadInt ("UseKeyfiles", FALSE);
+
+ bPreserveTimestamp = defaultMountOptions.PreserveTimestamp = ConfigReadInt ("PreserveTimestamps", TRUE);
+ defaultMountOptions.Removable = ConfigReadInt ("MountVolumesRemovable", FALSE);
+ defaultMountOptions.ReadOnly = ConfigReadInt ("MountVolumesReadOnly", FALSE);
+ defaultMountOptions.ProtectHiddenVolume = FALSE;
+ defaultMountOptions.PartitionInInactiveSysEncScope = FALSE;
+ defaultMountOptions.RecoveryMode = FALSE;
+ defaultMountOptions.UseBackupHeader = FALSE;
+
+ mountOptions = defaultMountOptions;
+
+ CloseSecurityTokenSessionsAfterMount = ConfigReadInt ("CloseSecurityTokenSessionsAfterMount", 0);
+
+ ConfigReadString ("SecurityTokenLibrary", "", SecurityTokenLibraryPath, sizeof (SecurityTokenLibraryPath) - 1);
+ if (SecurityTokenLibraryPath[0])
+ InitSecurityTokenLibrary(hwndDlg);
+
+ /* we don't load the history */
+}
+
+
+BOOL SelectItem (HWND hTree, char nLetter)
+{
+ int i;
+ LVITEM item;
+
+ for (i = 0; i < ListView_GetItemCount(hTree); i++)
+ {
+ memset(&item, 0, sizeof(LVITEM));
+ item.mask = LVIF_PARAM;
+ item.iItem = i;
+
+ if (ListView_GetItem (hTree, &item) == FALSE)
+ return FALSE;
+ else
+ {
+ if (HIWORD (item.lParam) == nLetter)
+ {
+ memset(&item, 0, sizeof(LVITEM));
+ item.state = LVIS_FOCUSED|LVIS_SELECTED;
+ item.stateMask = LVIS_FOCUSED|LVIS_SELECTED;
+ item.mask = LVIF_STATE;
+ item.iItem = i;
+ SendMessage(hTree, LVM_SETITEMSTATE, i, (LPARAM) &item);
+ return TRUE;
+ }
+ }
+ }
+
+ return TRUE;
+}
+
+
+
+LPARAM
+GetSelectedLong (HWND hTree)
+{
+ int hItem = ListView_GetSelectionMark (hTree);
+ LVITEM item;
+
+ if (nSelectedDriveIndex >= 0)
+ hItem = nSelectedDriveIndex;
+
+ memset(&item, 0, sizeof(LVITEM));
+ item.mask = LVIF_PARAM;
+ item.iItem = hItem;
+
+ if (ListView_GetItem (hTree, &item) == FALSE)
+ return MAKELONG (0xffff, 0xffff);
+ else
+ return item.lParam;
+}
+
+LPARAM
+GetItemLong (HWND hTree, int itemNo)
+{
+ LVITEM item;
+
+ memset(&item, 0, sizeof(LVITEM));
+ item.mask = LVIF_PARAM;
+ item.iItem = itemNo;
+
+ if (ListView_GetItem (hTree, &item) == FALSE)
+ return MAKELONG (0xffff, 0xffff);
+ else
+ return item.lParam;
+}
+
+static char PasswordDlgVolume[MAX_PATH + 1];
+static BOOL PasswordDialogDisableMountOptions;
+static char *PasswordDialogTitleStringId;
+
+/* Except in response to the WM_INITDIALOG message, the dialog box procedure
+ should return nonzero if it processes the message, and zero if it does
+ not. - see DialogProc */
+BOOL CALLBACK ExtcvPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ WORD lw = LOWORD (wParam);
+ static Password *szXPwd;
+ static int *pkcs5;
+ static BOOL* truecryptMode;
+
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ int i, nIndex;
+ szXPwd = ((PasswordDlgParam *) lParam) -> password;
+ pkcs5 = ((PasswordDlgParam *) lParam) -> pkcs5;
+ truecryptMode = ((PasswordDlgParam *) lParam) -> truecryptMode;
+ LocalizeDialog (hwndDlg, "IDD_PASSWORD_DLG");
+ DragAcceptFiles (hwndDlg, TRUE);
+
+ if (PasswordDialogTitleStringId)
+ {
+ SetWindowTextW (hwndDlg, GetString (PasswordDialogTitleStringId));
+ }
+ else if (strlen (PasswordDlgVolume) > 0)
+ {
+ wchar_t s[1024];
+ const int maxVisibleLen = 40;
+
+ if (strlen (PasswordDlgVolume) > maxVisibleLen)
+ {
+ string volStr = PasswordDlgVolume;
+ StringCbPrintfW (s, sizeof(s), GetString ("ENTER_PASSWORD_FOR"), ("..." + volStr.substr (volStr.size() - maxVisibleLen - 1)).c_str());
+ }
+ else
+ StringCbPrintfW (s, sizeof(s), GetString ("ENTER_PASSWORD_FOR"), PasswordDlgVolume);
+
+ SetWindowTextW (hwndDlg, s);
+ }
+
+ /* Populate the PRF algorithms list */
+ HWND hComboBox = GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID);
+ SendMessage (hComboBox, CB_RESETCONTENT, 0, 0);
+
+ nIndex = SendMessageW (hComboBox, CB_ADDSTRING, 0, (LPARAM) GetString ("AUTODETECTION"));
+ SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (LPARAM) 0);
+
+ for (i = FIRST_PRF_ID; i <= LAST_PRF_ID; i++)
+ {
+ nIndex = SendMessage (hComboBox, CB_ADDSTRING, 0, (LPARAM) get_pkcs5_prf_name(i));
+ SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (LPARAM) i);
+ }
+
+ /* make autodetection the default */
+ SendMessage (hComboBox, CB_SETCURSEL, 0, 0);
+
+ SendMessage (GetDlgItem (hwndDlg, IDC_PASSWORD), EM_LIMITTEXT, MAX_PASSWORD, 0);
+ SendMessage (GetDlgItem (hwndDlg, IDC_CACHE), BM_SETCHECK, bCacheInDriver ? BST_CHECKED:BST_UNCHECKED, 0);
+
+ SetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE, KeyFilesEnable);
+
+ mountOptions.PartitionInInactiveSysEncScope = bPrebootPasswordDlgMode;
+
+ if (bPrebootPasswordDlgMode)
+ {
+ SendMessage (hwndDlg, TC_APPMSG_PREBOOT_PASSWORD_MODE, 0, 0);
+ }
+
+ if (PasswordDialogDisableMountOptions)
+ {
+ EnableWindow (GetDlgItem (hwndDlg, IDC_CACHE), FALSE);
+ EnableWindow (GetDlgItem (hwndDlg, IDC_MOUNT_OPTIONS), FALSE);
+ }
+
+ /* No support for mounting TrueCrypt volumes */
+ SetCheckBox (hwndDlg, IDC_TRUECRYPT_MODE, FALSE);
+ EnableWindow (GetDlgItem (hwndDlg, IDC_TRUECRYPT_MODE), FALSE);
+
+ if (!SetForegroundWindow (hwndDlg) && (FavoriteMountOnArrivalInProgress))
+ {
+ SetWindowPos (hwndDlg, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
+
+ FLASHWINFO flash;
+ flash.cbSize = sizeof (flash);
+ flash.dwFlags = FLASHW_ALL | FLASHW_TIMERNOFG;
+ flash.dwTimeout = 0;
+ flash.hwnd = hwndDlg;
+ flash.uCount = 0;
+
+ FlashWindowEx (&flash);
+
+ SetWindowPos (hwndDlg, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
+ }
+ }
+ return 0;
+
+ case TC_APPMSG_PREBOOT_PASSWORD_MODE:
+ {
+ /* No support for mounting TrueCrypt system partition */
+ SetCheckBox (hwndDlg, IDC_TRUECRYPT_MODE, FALSE);
+ EnableWindow (GetDlgItem (hwndDlg, IDC_TRUECRYPT_MODE), FALSE);
+
+ /* Repopulate the PRF algorithms list with algorithms that support system encryption */
+ HWND hComboBox = GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID);
+ SendMessage (hComboBox, CB_RESETCONTENT, 0, 0);
+
+ int i, nIndex = SendMessageW (hComboBox, CB_ADDSTRING, 0, (LPARAM) GetString ("AUTODETECTION"));
+ SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (LPARAM) 0);
+
+ for (i = FIRST_PRF_ID; i <= LAST_PRF_ID; i++)
+ {
+ if (HashForSystemEncryption(i))
+ {
+ nIndex = SendMessage (hComboBox, CB_ADDSTRING, 0, (LPARAM) get_pkcs5_prf_name(i));
+ SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (LPARAM) i);
+ }
+ }
+
+ /* make autodetection the default */
+ SendMessage (hComboBox, CB_SETCURSEL, 0, 0);
+
+ ToBootPwdField (hwndDlg, IDC_PASSWORD);
+
+ // Attempt to wipe the password stored in the input field buffer
+ char tmp[MAX_PASSWORD+1];
+ memset (tmp, 'X', MAX_PASSWORD);
+ tmp [MAX_PASSWORD] = 0;
+ SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), tmp);
+ SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), "");
+
+ StringCbPrintfA (OrigKeyboardLayout, sizeof(OrigKeyboardLayout),"%08X", (DWORD) GetKeyboardLayout (NULL) & 0xFFFF);
+
+ DWORD keybLayout = (DWORD) LoadKeyboardLayout ("00000409", KLF_ACTIVATE);
+
+ if (keybLayout != 0x00000409 && keybLayout != 0x04090409)
+ {
+ Error ("CANT_CHANGE_KEYB_LAYOUT_FOR_SYS_ENCRYPTION", hwndDlg);
+ EndDialog (hwndDlg, IDCANCEL);
+ return 1;
+ }
+
+ if (SetTimer (hwndDlg, TIMER_ID_KEYB_LAYOUT_GUARD, TIMER_INTERVAL_KEYB_LAYOUT_GUARD, NULL) == 0)
+ {
+ Error ("CANNOT_SET_TIMER", hwndDlg);
+ EndDialog (hwndDlg, IDCANCEL);
+ return 1;
+ }
+
+ SetCheckBox (hwndDlg, IDC_SHOW_PASSWORD, FALSE);
+ EnableWindow (GetDlgItem (hwndDlg, IDC_SHOW_PASSWORD), FALSE);
+
+ SendMessage (GetDlgItem (hwndDlg, IDC_PASSWORD), EM_SETPASSWORDCHAR, '*', 0);
+ InvalidateRect (GetDlgItem (hwndDlg, IDC_PASSWORD), NULL, TRUE);
+
+ bPrebootPasswordDlgMode = TRUE;
+ }
+ return 1;
+
+ case WM_TIMER:
+ switch (wParam)
+ {
+ case TIMER_ID_KEYB_LAYOUT_GUARD:
+ if (bPrebootPasswordDlgMode)
+ {
+ DWORD keybLayout = (DWORD) GetKeyboardLayout (NULL);
+
+ if (keybLayout != 0x00000409 && keybLayout != 0x04090409)
+ {
+ // Keyboard layout is not standard US
+
+ // Attempt to wipe the password stored in the input field buffer
+ char tmp[MAX_PASSWORD+1];
+ memset (tmp, 'X', MAX_PASSWORD);
+ tmp [MAX_PASSWORD] = 0;
+ SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), tmp);
+ SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), "");
+
+ keybLayout = (DWORD) LoadKeyboardLayout ("00000409", KLF_ACTIVATE);
+
+ if (keybLayout != 0x00000409 && keybLayout != 0x04090409)
+ {
+ KillTimer (hwndDlg, TIMER_ID_KEYB_LAYOUT_GUARD);
+ Error ("CANT_CHANGE_KEYB_LAYOUT_FOR_SYS_ENCRYPTION", hwndDlg);
+ EndDialog (hwndDlg, IDCANCEL);
+ return 1;
+ }
+
+ wchar_t szTmp [4096];
+ StringCbCopyW (szTmp, sizeof(szTmp), GetString ("KEYB_LAYOUT_CHANGE_PREVENTED"));
+ StringCbCatW (szTmp, sizeof(szTmp), L"\n\n");
+ StringCbCatW (szTmp, sizeof(szTmp), GetString ("KEYB_LAYOUT_SYS_ENC_EXPLANATION"));
+ MessageBoxW (MainDlg, szTmp, lpszTitle, MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST);
+ }
+ }
+ return 1;
+ }
+ return 0;
+
+ case WM_COMMAND:
+
+ if (lw == IDC_MOUNT_OPTIONS)
+ {
+ DialogBoxParamW (hInst,
+ MAKEINTRESOURCEW (IDD_MOUNT_OPTIONS), hwndDlg,
+ (DLGPROC) MountOptionsDlgProc, (LPARAM) &mountOptions);
+
+ if (!bPrebootPasswordDlgMode && mountOptions.PartitionInInactiveSysEncScope)
+ SendMessage (hwndDlg, TC_APPMSG_PREBOOT_PASSWORD_MODE, 0, 0);
+
+ return 1;
+ }
+
+ if (lw == IDC_SHOW_PASSWORD)
+ {
+ SendMessage (GetDlgItem (hwndDlg, IDC_PASSWORD),
+ EM_SETPASSWORDCHAR,
+ GetCheckBox (hwndDlg, IDC_SHOW_PASSWORD) ? 0 : '*',
+ 0);
+ InvalidateRect (GetDlgItem (hwndDlg, IDC_PASSWORD), NULL, TRUE);
+ return 1;
+ }
+
+ if (lw == IDC_KEY_FILES)
+ {
+ KeyFilesDlgParam param;
+ param.EnableKeyFiles = KeyFilesEnable;
+ param.FirstKeyFile = FirstKeyFile;
+
+ if (IDOK == DialogBoxParamW (hInst,
+ MAKEINTRESOURCEW (IDD_KEYFILES), hwndDlg,
+ (DLGPROC) KeyFilesDlgProc, (LPARAM) &param))
+ {
+ KeyFilesEnable = param.EnableKeyFiles;
+ FirstKeyFile = param.FirstKeyFile;
+
+ SetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE, KeyFilesEnable);
+ }
+
+ return 1;
+ }
+
+ if (lw == IDC_KEYFILES_ENABLE)
+ {
+ KeyFilesEnable = GetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE);
+
+ return 1;
+ }
+
+ if (lw == IDCANCEL || lw == IDOK)
+ {
+ char tmp[MAX_PASSWORD+1];
+
+ if (lw == IDOK)
+ {
+ if (mountOptions.ProtectHiddenVolume && hidVolProtKeyFilesParam.EnableKeyFiles)
+ KeyFilesApply (hwndDlg, &mountOptions.ProtectedHidVolPassword, hidVolProtKeyFilesParam.FirstKeyFile);
+
+ GetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), (LPSTR) szXPwd->Text, MAX_PASSWORD + 1);
+ szXPwd->Length = strlen ((char *) szXPwd->Text);
+
+ bCacheInDriver = IsButtonChecked (GetDlgItem (hwndDlg, IDC_CACHE));
+ *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);
+ /* SHA-256 is not supported by TrueCrypt */
+ if ( (*truecryptMode)
+ && ((*pkcs5 == SHA256) || (mountOptions.ProtectHiddenVolume && mountOptions.ProtectedHidVolPkcs5Prf == SHA256))
+ )
+ {
+ Error ("ALGO_NOT_SUPPORTED_FOR_TRUECRYPT_MODE", hwndDlg);
+ return 1;
+ }
+ }
+
+ // Attempt to wipe password stored in the input field buffer
+ memset (tmp, 'X', MAX_PASSWORD);
+ tmp[MAX_PASSWORD] = 0;
+ SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), tmp);
+ SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD_PROT_HIDVOL), tmp);
+
+ if (hidVolProtKeyFilesParam.FirstKeyFile != NULL)
+ {
+ KeyFileRemoveAll (&hidVolProtKeyFilesParam.FirstKeyFile);
+ hidVolProtKeyFilesParam.EnableKeyFiles = FALSE;
+ }
+
+ if (bPrebootPasswordDlgMode)
+ {
+ KillTimer (hwndDlg, TIMER_ID_KEYB_LAYOUT_GUARD);
+
+ // Restore the original keyboard layout
+ if (LoadKeyboardLayout (OrigKeyboardLayout, KLF_ACTIVATE | KLF_SUBSTITUTE_OK) == NULL)
+ Warning ("CANNOT_RESTORE_KEYBOARD_LAYOUT", hwndDlg);
+ }
+
+ EndDialog (hwndDlg, lw);
+ return 1;
+ }
+ return 0;
+
+ case WM_CONTEXTMENU:
+ {
+ RECT buttonRect;
+ GetWindowRect (GetDlgItem (hwndDlg, IDC_KEY_FILES), &buttonRect);
+
+ if (LOWORD (lParam) >= buttonRect.left && LOWORD (lParam) <= buttonRect.right
+ && HIWORD (lParam) >= buttonRect.top && HIWORD (lParam) <= buttonRect.bottom)
+ {
+ // The "Keyfiles" button has been right-clicked
+
+ KeyFilesDlgParam param;
+ param.EnableKeyFiles = KeyFilesEnable;
+ param.FirstKeyFile = FirstKeyFile;
+
+ POINT popupPos;
+ popupPos.x = buttonRect.left + 2;
+ popupPos.y = buttonRect.top + 2;
+
+ if (KeyfilesPopupMenu (hwndDlg, popupPos, &param))
+ {
+ KeyFilesEnable = param.EnableKeyFiles;
+ FirstKeyFile = param.FirstKeyFile;
+ SetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE, KeyFilesEnable);
+ }
+ }
+ }
+ break;
+
+ case WM_DROPFILES:
+ {
+ HDROP hdrop = (HDROP) wParam;
+ int i = 0, count = DragQueryFile (hdrop, 0xFFFFFFFF, NULL, 0);
+
+ while (count-- > 0)
+ {
+ KeyFile *kf = (KeyFile *) malloc (sizeof (KeyFile));
+ if (kf)
+ {
+ DragQueryFile (hdrop, i++, kf->FileName, sizeof (kf->FileName));
+ FirstKeyFile = KeyFileAdd (FirstKeyFile, kf);
+ KeyFilesEnable = TRUE;
+ }
+ }
+
+ SetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE, KeyFilesEnable);
+ DragFinish (hdrop);
+ }
+ return 1;
+ }
+
+ return 0;
+}
+
+void SaveSettings (HWND hwndDlg)
+{
+ // dummy
+}
+
+int BackupVolumeHeader (HWND hwndDlg, BOOL bRequireConfirmation, char *lpszVolume)
+{
+ // dummy
+ return 0;
+}
+
+int RestoreVolumeHeader (HWND hwndDlg, char *lpszVolume)
+{
+ // dummy
+ return 0;
+}
+
+int ExtcvAskVolumePassword (HWND hwndDlg, Password *password, int *pkcs5, BOOL* truecryptMode, char *titleStringId, BOOL enableMountOptions)
+{
+ int result;
+ PasswordDlgParam dlgParam;
+
+ PasswordDialogTitleStringId = titleStringId;
+ PasswordDialogDisableMountOptions = !enableMountOptions;
+
+ dlgParam.password = password;
+ dlgParam.pkcs5 = pkcs5;
+ dlgParam.truecryptMode = truecryptMode;
+
+ result = DialogBoxParamW (hInst,
+ MAKEINTRESOURCEW (IDD_PASSWORD_DLG), hwndDlg,
+ (DLGPROC) ExtcvPasswordDlgProc, (LPARAM) &dlgParam);
+
+ if (result != IDOK)
+ {
+ password->Length = 0;
+ *pkcs5 = 0;
+ *truecryptMode = FALSE;
+ burn (&mountOptions.ProtectedHidVolPassword, sizeof (mountOptions.ProtectedHidVolPassword));
+ burn (&mountOptions.ProtectedHidVolPkcs5Prf, sizeof (mountOptions.ProtectedHidVolPkcs5Prf));
+ }
+
+ return result == IDOK;
+}
+
+// GUI actions
+
+static BOOL SelectContainer (HWND hwndDlg)
+{
+ if (BrowseFiles (hwndDlg, "OPEN_VOL_TITLE", szFileName, bHistory, FALSE, NULL) == FALSE)
+ return FALSE;
+
+ AddComboItem (GetDlgItem (hwndDlg, IDC_VOLUME), szFileName, bHistory);
+ VeraCryptExpander::EnableDisableButtons (hwndDlg);
+ SetFocus (GetDlgItem (hwndDlg, IDC_DRIVELIST));
+ return TRUE;
+}
+
+static BOOL SelectPartition (HWND hwndDlg)
+{
+ int nResult = DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_RAWDEVICES_DLG), hwndDlg,
+ (DLGPROC) RawDevicesDlgProc, (LPARAM) & szFileName[0]);
+ if (nResult == IDOK)
+ {
+ AddComboItem (GetDlgItem (hwndDlg, IDC_VOLUME), szFileName, bHistory);
+ VeraCryptExpander::EnableDisableButtons (hwndDlg);
+ SetFocus (GetDlgItem (hwndDlg, IDC_DRIVELIST));
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+/* Except in response to the WM_INITDIALOG and WM_ENDSESSION messages, the dialog box procedure
+ should return nonzero if it processes a message, and zero if it does not. */
+BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ static UINT taskBarCreatedMsg;
+ WORD lw = LOWORD (wParam);
+ WORD hw = HIWORD (wParam);
+
+ switch (uMsg)
+ {
+
+ case WM_INITDIALOG:
+ {
+ int exitCode = 0;
+
+ MainDlg = hwndDlg;
+
+ // Set critical default options in case UsePreferences is false
+ bPreserveTimestamp = defaultMountOptions.PreserveTimestamp = TRUE;
+
+ if (UsePreferences)
+ {
+ // General preferences
+ VeraCryptExpander::LoadSettings (hwndDlg);
+
+ // Keyfiles
+ LoadDefaultKeyFilesParam ();
+ RestoreDefaultKeyFilesParam ();
+ }
+
+ InitMainDialog (hwndDlg);
+
+ // Quit
+ if (Quit)
+ {
+ exit (exitCode);
+ }
+
+ Silent = FALSE;
+ }
+ return 0;
+
+ case WM_SYSCOMMAND:
+ if (lw == IDC_ABOUT)
+ {
+ DialogBoxW (hInst, MAKEINTRESOURCEW (IDD_ABOUT_DLG), hwndDlg, (DLGPROC) AboutDlgProc);
+ return 1;
+ }
+ return 0;
+
+ case WM_ENDSESSION:
+ VeraCryptExpander::EndMainDlg (hwndDlg);
+ localcleanup ();
+ return 0;
+
+ case WM_COMMAND:
+
+ if (lw == IDCANCEL || lw == IDC_EXIT)
+ {
+ VeraCryptExpander::EndMainDlg (hwndDlg);
+ return 1;
+ }
+
+ if ( lw == IDOK )
+ {
+ if (!VeraCryptExpander::VolumeSelected(hwndDlg))
+ {
+ Warning ("NO_VOLUME_SELECTED", hwndDlg);
+ }
+ else
+ {
+ char fileName[MAX_PATH];
+ GetWindowText (GetDlgItem (hwndDlg, IDC_VOLUME), fileName, sizeof (fileName));
+ ExpandVolumeWizard(hwndDlg, (char*)fileName);
+ }
+ return 1;
+ }
+
+ if (lw == IDM_ABOUT )
+ {
+ DialogBoxW (hInst, MAKEINTRESOURCEW (IDD_ABOUT_DLG), hwndDlg, (DLGPROC) AboutDlgProc);
+ return 1;
+ }
+
+ if (lw == IDM_HOMEPAGE )
+ {
+ ArrowWaitCursor ();
+ ShellExecute (NULL, "open", "https://veracrypt.codeplex.com", NULL, NULL, SW_SHOWNORMAL);
+ Sleep (200);
+ NormalCursor ();
+
+ return 1;
+ }
+
+ if (lw == IDC_SELECT_FILE)
+ {
+ SelectContainer (hwndDlg);
+ return 1;
+ }
+
+ if (lw == IDC_SELECT_DEVICE)
+ {
+ SelectPartition (hwndDlg);
+ return 1;
+ }
+
+ return 0;
+
+ case WM_CLOSE:
+ VeraCryptExpander::EndMainDlg (hwndDlg);
+ return 1;
+
+ default:
+ ;
+ }
+
+ return 0;
+}
+
+}
+
+
+int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, char *lpszCommandLine, int nCmdShow)
+{
+ int status;
+ atexit (VeraCryptExpander::localcleanup);
+ SetProcessShutdownParameters (0x100, 0);
+
+ VirtualLock (&VeraCryptExpander::VolumePassword, sizeof (VeraCryptExpander::VolumePassword));
+ VirtualLock (&VeraCryptExpander::CmdVolumePassword, sizeof (VeraCryptExpander::CmdVolumePassword));
+ VirtualLock (&VeraCryptExpander::mountOptions, sizeof (VeraCryptExpander::mountOptions));
+ VirtualLock (&VeraCryptExpander::defaultMountOptions, sizeof (VeraCryptExpander::defaultMountOptions));
+ VirtualLock (&VeraCryptExpander::szFileName, sizeof(VeraCryptExpander::szFileName));
+
+ InitCommonControls ();
+ InitApp (hInstance, lpszCommandLine);
+
+ /* application title */
+ lpszTitle = L"VeraCrypt Expander";
+
+ status = DriverAttach ();
+ if (status != 0)
+ {
+ if (status == ERR_OS_ERROR)
+ handleWin32Error (NULL);
+ else
+ handleError (NULL, status);
+
+ AbortProcess ("NODRIVER");
+ }
+
+ /* Create the main dialog box */
+ DialogBoxParamW (hInstance, MAKEINTRESOURCEW (IDD_MOUNT_DLG), NULL, (DLGPROC) VeraCryptExpander::MainDialogProc,
+ (LPARAM) lpszCommandLine);
+
+ /* Terminate */
+ return 0;
+}
diff --git a/src/ExpandVolume/resource.h b/src/ExpandVolume/resource.h
new file mode 100644
index 0000000..9e2a2d8
--- /dev/null
+++ b/src/ExpandVolume/resource.h
@@ -0,0 +1,143 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by ExpandVolume.rc
+//
+#define IDD_MOUNT_DLG 101
+#define IDD_PASSWORD_DLG 104
+#define IDR_MENU 106
+#define IDD_EXPAND_PROGRESS_DLG 106
+#define IDR_MOUNT_RSRC_HEADER 109
+#define IDS_UACSTRING 110
+#define IDB_LOGO_288DPI 111
+#define IDB_LOGO_96DPI 112
+#define IDD_SIZE_DIALOG 117
+#define IDC_BOX_HELP 1003
+#define IDC_CACHE 1005
+#define IDC_NO_HISTORY 1006
+#define IDC_DRIVELIST 1007
+#define IDC_SPACE_LEFT 1009
+#define IDC_KB 1011
+#define IDC_MB 1013
+#define IDC_PROGRESS_BAR 1014
+#define IDC_GB 1015
+#define IDC_EXPAND_VOLUME_OLDSIZE 1017
+#define IDC_EXPAND_VOLUME_NEWSIZE 1019
+#define IDC_EXPAND_VOLUME_NAME 1020
+#define IDC_EXPAND_VOLUME_INITSPACE 1021
+#define IDC_EXPAND_FILE_SYSTEM 1022
+#define IDC_RANDOM_BYTES 1023
+#define IDC_BYTESWRITTEN 1024
+#define IDC_WRITESPEED 1025
+#define IDC_MOUNT_OPTIONS 1026
+#define IDC_TIMEREMAIN 1027
+#define IDC_KEY_FILES 1030
+#define IDC_VOLUME 1033
+#define IDC_PASSWORD 1034
+#define IDC_SELECT_DEVICE 1036
+#define IDC_CREATE_VOLUME 1037
+#define IDC_VOLUME_TOOLS 1038
+#define IDC_SIZEBOX 1038
+#define IDC_WIPE_CACHE 1039
+#define IDC_MOUNTALL 1040
+#define IDC_SELECT_FILE 1042
+#define IDC_VOLUME_PROPERTIES 1044
+#define IDT_RANDOM_POOL 1047
+#define IDT_VOL_NAME 1047
+#define IDT_HEADER_KEY 1048
+#define IDT_CURRENT_SIZE 1048
+#define IDT_VOLUME 1049
+#define IDT_MASTER_KEY 1049
+#define IDT_NEW_SIZE 1049
+#define IDT_PASSWORD 1050
+#define IDT_DONE 1050
+#define IDT_SPEED 1051
+#define IDT_LEFT 1052
+#define IDT_INIT_SPACE 1053
+#define IDT_FILE_SYS 1054
+#define IDT_INIT_SPACE2 1055
+#define IDT_RANDOM_POOL2 1055
+#define IDC_EXIT 1060
+#define IDC_UNMOUNTALL 1063
+#define IDC_SHOW_PASSWORD 1094
+#define IDC_LOGO 1095
+#define IDC_SIZEDLG_TITLE 1111
+#define IDC_INIT_NEWSPACE 1112
+#define IDC_INFOEXPAND 1113
+#define IDC_EDIT1 1114
+#define IDC_BOX_STATUS 1114
+#define IDC_TRUECRYPT_MODE 1140
+#define IDM_HELP 40001
+#define IDM_ABOUT 40002
+#define IDM_UNMOUNT_VOLUME 40003
+#define IDM_CLEAR_HISTORY 40004
+#define IDM_FORUMS 40005
+#define IDM_BENCHMARK 40006
+#define IDM_TRAVELER 40007
+#define IDM_MOUNT_VOLUME_OPTIONS 40008
+#define IDM_FAQ 40009
+#define IDM_REFRESH_DRIVE_LETTERS 40010
+#define IDM_DEFAULT_KEYFILES 40011
+#define IDM_WEBSITE 40012
+#define IDM_MOUNTALL 40013
+#define IDM_UNMOUNTALL 40014
+#define IDM_MOUNT_VOLUME 40015
+#define IDM_CHANGE_PASSWORD 40016
+#define IDM_VOLUME_WIZARD 40017
+#define IDM_CREATE_VOLUME 40018
+#define IDM_WIPE_CACHE 40019
+#define IDM_PREFERENCES 40020
+#define IDM_LICENSE 40021
+#define IDM_SELECT_FILE 40022
+#define IDM_SELECT_DEVICE 40023
+#define IDM_VOLUME_PROPERTIES 40024
+#define IDM_LANGUAGE 40025
+#define IDM_MOUNT_FAVORITE_VOLUMES 40026
+#define IDM_SAVE_FAVORITE_VOLUMES 40027
+#define IDM_BACKUP_VOL_HEADER 40028
+#define IDM_RESTORE_VOL_HEADER 40029
+#define IDM_HOTKEY_SETTINGS 40030
+#define IDM_TC_DOWNLOADS 40031
+#define IDM_NEWS 40032
+#define IDM_BUGREPORT 40033
+#define IDM_CONTACT 40034
+#define IDM_VERSION_HISTORY 40035
+#define IDM_HOMEPAGE 40036
+#define IDM_TEST_VECTORS 40037
+#define IDM_ADD_REMOVE_VOL_KEYFILES 40038
+#define IDM_REMOVE_ALL_KEYFILES_FROM_VOL 40039
+#define IDM_GENERATE_KEYFILE 40040
+#define IDM_CHANGE_HEADER_KEY_DERIV_ALGO 40041
+#define IDM_KEYFILE_GENERATOR 40042
+#define IDM_SET_DEFAULT_KEYFILES 40043
+#define IDM_ONLINE_TUTORIAL 40044
+#define IDM_ONLINE_HELP 40045
+#define IDM_DONATIONS 40046
+#define IDM_CHANGE_SYS_HEADER_KEY_DERIV_ALGO 40047
+#define IDM_CHANGE_SYS_PASSWORD 40048
+#define IDM_CREATE_RESCUE_DISK 40049
+#define IDM_PERMANENTLY_DECRYPT_SYS 40050
+#define IDM_VERIFY_RESCUE_DISK 40051
+#define IDM_SYSTEM_ENCRYPTION_STATUS 40052
+#define IDM_ENCRYPT_SYSTEM_DEVICE 40053
+#define IDM_SYSENC_RESUME 40054
+#define IDM_MOUNT_SYSENC_PART_WITHOUT_PBA 40055
+#define IDM_CREATE_HIDDEN_OS 40056
+#define IDM_TOKEN_PREFERENCES 40057
+#define IDM_CLOSE_ALL_TOKEN_SESSIONS 40058
+#define IDM_SYS_ENC_SETTINGS 40059
+#define IDM_SYSENC_SETTINGS 40060
+#define IDM_RESUME_INTERRUPTED_PROC 40061
+#define IDM_MANAGE_TOKEN_KEYFILES 40062
+#define ID_HOMEPAGE 40063
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NO_MFC 1
+#define _APS_NEXT_RESOURCE_VALUE 120
+#define _APS_NEXT_COMMAND_VALUE 40064
+#define _APS_NEXT_CONTROL_VALUE 1116
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c
index f9692c1..7d8e084 100644
--- a/src/Mount/Mount.c
+++ b/src/Mount/Mount.c
@@ -4696,7 +4696,7 @@ static void ResumeInterruptedNonSysInplaceEncProcess (void)
LaunchVolCreationWizard (MainDlg, "/zinplace");
}
-static BOOL SelectContainer (HWND hwndDlg)
+BOOL SelectContainer (HWND hwndDlg)
{
if (BrowseFiles (hwndDlg, "OPEN_VOL_TITLE", szFileName, bHistory, FALSE, NULL) == FALSE)
return FALSE;
@@ -4707,7 +4707,7 @@ static BOOL SelectContainer (HWND hwndDlg)
return TRUE;
}
-static BOOL SelectPartition (HWND hwndDlg)
+BOOL SelectPartition (HWND hwndDlg)
{
int nResult = DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_RAWDEVICES_DLG), hwndDlg,
(DLGPROC) RawDevicesDlgProc, (LPARAM) & szFileName[0]);
@@ -7335,7 +7335,7 @@ static BOOL StartSystemFavoritesService ()
return result;
}
-
+#ifndef VCEXPANDER
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, char *lpszCommandLine, int nCmdShow)
{
int argc;
@@ -7392,6 +7392,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, char *lpszComm
/* Terminate */
return 0;
}
+#endif
BOOL TaskBarIconAdd (HWND hwnd)
diff --git a/src/Signing/sign.bat b/src/Signing/sign.bat
index 14e1348..b0aa1ac 100644
--- a/src/Signing/sign.bat
+++ b/src/Signing/sign.bat
@@ -5,6 +5,7 @@ signtool sign /v /a /n IDRIX /ac thawte_Primary_MS_Cross_Cert.cer /t http://time
signtool sign /v /a /n IDRIX /ac Thawt_CodeSigning_CA.crt /t http://timestamp.verisign.com/scripts/timestamp.dll "..\Release\Setup Files\VeraCrypt.exe"
signtool sign /v /a /n IDRIX /ac Thawt_CodeSigning_CA.crt /t http://timestamp.verisign.com/scripts/timestamp.dll "..\Release\Setup Files\VeraCrypt Format.exe"
+signtool sign /v /a /n IDRIX /ac Thawt_CodeSigning_CA.crt /t http://timestamp.verisign.com/scripts/timestamp.dll "..\Release\Setup Files\VeraCryptExpander.exe"
cd "..\Release\Setup Files\"
diff --git a/src/VeraCrypt.sln b/src/VeraCrypt.sln
index 25c7d3b..720517c 100644
--- a/src/VeraCrypt.sln
+++ b/src/VeraCrypt.sln
@@ -25,12 +25,15 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Setup", "Setup\Setup.vcproj
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Boot", "Boot\Windows\Boot.vcproj", "{8B7F059F-E4C7-4E11-88F5-EE8B8433072E}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VeraCyptExpander", "ExpandVolume\ExpandVolume.vcproj", "{9715FF1D-599B-4BBC-AD96-BEF6E08FF827}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
All Debug|Win32 = All Debug|Win32
All|Win32 = All|Win32
Boot Loader|Win32 = Boot Loader|Win32
Boot|Win32 = Boot|Win32
+ Debug|Win32 = Debug|Win32
Driver Debug|Win32 = Driver Debug|Win32
Driver x64 Debug|Win32 = Driver x64 Debug|Win32
Driver x64|Win32 = Driver x64|Win32
@@ -41,6 +44,7 @@ Global
Format|Win32 = Format|Win32
Mount Debug|Win32 = Mount Debug|Win32
Mount|Win32 = Mount|Win32
+ Release|Win32 = Release|Win32
Setup Debug|Win32 = Setup Debug|Win32
Setup|Win32 = Setup|Win32
EndGlobalSection
@@ -51,6 +55,8 @@ Global
{993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.All|Win32.Build.0 = Release|Win32
{993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Boot Loader|Win32.ActiveCfg = Release|Win32
{993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Boot|Win32.ActiveCfg = Release|Win32
+ {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Debug|Win32.ActiveCfg = Debug|Win32
+ {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Debug|Win32.Build.0 = Debug|Win32
{993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Driver Debug|Win32.ActiveCfg = Debug|Win32
{993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Driver x64 Debug|Win32.ActiveCfg = Debug|Win32
{993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Driver x64|Win32.ActiveCfg = Release|Win32
@@ -65,6 +71,8 @@ Global
{993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Mount Debug|Win32.Build.0 = Debug|Win32
{993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Mount|Win32.ActiveCfg = Release|Win32
{993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Mount|Win32.Build.0 = Release|Win32
+ {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Release|Win32.ActiveCfg = Release|Win32
+ {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Release|Win32.Build.0 = Release|Win32
{993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Setup Debug|Win32.ActiveCfg = Debug|Win32
{993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Setup|Win32.ActiveCfg = Release|Win32
{EF5EF444-18D0-40D7-8DFA-775EC4448602}.All Debug|Win32.ActiveCfg = Debug|Win32
@@ -73,6 +81,8 @@ Global
{EF5EF444-18D0-40D7-8DFA-775EC4448602}.All|Win32.Build.0 = Release|Win32
{EF5EF444-18D0-40D7-8DFA-775EC4448602}.Boot Loader|Win32.ActiveCfg = Release|Win32
{EF5EF444-18D0-40D7-8DFA-775EC4448602}.Boot|Win32.ActiveCfg = Release|Win32
+ {EF5EF444-18D0-40D7-8DFA-775EC4448602}.Debug|Win32.ActiveCfg = Debug|Win32
+ {EF5EF444-18D0-40D7-8DFA-775EC4448602}.Debug|Win32.Build.0 = Debug|Win32
{EF5EF444-18D0-40D7-8DFA-775EC4448602}.Driver Debug|Win32.ActiveCfg = Debug|Win32
{EF5EF444-18D0-40D7-8DFA-775EC4448602}.Driver Debug|Win32.Build.0 = Debug|Win32
{EF5EF444-18D0-40D7-8DFA-775EC4448602}.Driver x64 Debug|Win32.ActiveCfg = Debug x64|Win32
@@ -89,6 +99,8 @@ Global
{EF5EF444-18D0-40D7-8DFA-775EC4448602}.Format|Win32.ActiveCfg = Release|Win32
{EF5EF444-18D0-40D7-8DFA-775EC4448602}.Mount Debug|Win32.ActiveCfg = Debug|Win32
{EF5EF444-18D0-40D7-8DFA-775EC4448602}.Mount|Win32.ActiveCfg = Release|Win32
+ {EF5EF444-18D0-40D7-8DFA-775EC4448602}.Release|Win32.ActiveCfg = Release|Win32
+ {EF5EF444-18D0-40D7-8DFA-775EC4448602}.Release|Win32.Build.0 = Release|Win32
{EF5EF444-18D0-40D7-8DFA-775EC4448602}.Setup Debug|Win32.ActiveCfg = Debug|Win32
{EF5EF444-18D0-40D7-8DFA-775EC4448602}.Setup|Win32.ActiveCfg = Release|Win32
{9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.All Debug|Win32.ActiveCfg = Debug|Win32
@@ -97,6 +109,8 @@ Global
{9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.All|Win32.Build.0 = Release|Win32
{9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Boot Loader|Win32.ActiveCfg = Release|Win32
{9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Boot|Win32.ActiveCfg = Release|Win32
+ {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Debug|Win32.ActiveCfg = Debug|Win32
+ {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Debug|Win32.Build.0 = Debug|Win32
{9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Driver Debug|Win32.ActiveCfg = Debug|Win32
{9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Driver x64 Debug|Win32.ActiveCfg = Debug|Win32
{9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Driver x64|Win32.ActiveCfg = Release|Win32
@@ -109,6 +123,8 @@ Global
{9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Format|Win32.Build.0 = Release|Win32
{9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Mount Debug|Win32.ActiveCfg = Debug|Win32
{9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Mount|Win32.ActiveCfg = Release|Win32
+ {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Release|Win32.ActiveCfg = Release|Win32
+ {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Release|Win32.Build.0 = Release|Win32
{9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Setup Debug|Win32.ActiveCfg = Debug|Win32
{9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Setup|Win32.ActiveCfg = Release|Win32
{E4C40F94-E7F9-4981-86E4-186B46F993F3}.All Debug|Win32.ActiveCfg = Debug|Win32
@@ -117,6 +133,8 @@ Global
{E4C40F94-E7F9-4981-86E4-186B46F993F3}.All|Win32.Build.0 = Release|Win32
{E4C40F94-E7F9-4981-86E4-186B46F993F3}.Boot Loader|Win32.ActiveCfg = Release|Win32
{E4C40F94-E7F9-4981-86E4-186B46F993F3}.Boot|Win32.ActiveCfg = Release|Win32
+ {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Debug|Win32.ActiveCfg = Debug|Win32
+ {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Debug|Win32.Build.0 = Debug|Win32
{E4C40F94-E7F9-4981-86E4-186B46F993F3}.Driver Debug|Win32.ActiveCfg = Debug|Win32
{E4C40F94-E7F9-4981-86E4-186B46F993F3}.Driver x64 Debug|Win32.ActiveCfg = Debug|Win32
{E4C40F94-E7F9-4981-86E4-186B46F993F3}.Driver x64|Win32.ActiveCfg = Release|Win32
@@ -129,6 +147,8 @@ Global
{E4C40F94-E7F9-4981-86E4-186B46F993F3}.Mount Debug|Win32.Build.0 = Debug|Win32
{E4C40F94-E7F9-4981-86E4-186B46F993F3}.Mount|Win32.ActiveCfg = Release|Win32
{E4C40F94-E7F9-4981-86E4-186B46F993F3}.Mount|Win32.Build.0 = Release|Win32
+ {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Release|Win32.ActiveCfg = Release|Win32
+ {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Release|Win32.Build.0 = Release|Win32
{E4C40F94-E7F9-4981-86E4-186B46F993F3}.Setup Debug|Win32.ActiveCfg = Debug|Win32
{E4C40F94-E7F9-4981-86E4-186B46F993F3}.Setup|Win32.ActiveCfg = Release|Win32
{DF5F654D-BD44-4E31-B92E-B68074DC37A8}.All Debug|Win32.ActiveCfg = Debug|Win32
@@ -137,6 +157,8 @@ Global
{DF5F654D-BD44-4E31-B92E-B68074DC37A8}.All|Win32.Build.0 = Release|Win32
{DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Boot Loader|Win32.ActiveCfg = Release|Win32
{DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Boot|Win32.ActiveCfg = Release|Win32
+ {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Debug|Win32.ActiveCfg = Debug|Win32
+ {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Debug|Win32.Build.0 = Debug|Win32
{DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver Debug|Win32.ActiveCfg = Debug|Win32
{DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver x64 Debug|Win32.ActiveCfg = Debug|Win32
{DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver x64|Win32.ActiveCfg = Release|Win32
@@ -147,6 +169,8 @@ Global
{DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Format|Win32.ActiveCfg = Release|Win32
{DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Mount Debug|Win32.ActiveCfg = Debug|Win32
{DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Mount|Win32.ActiveCfg = Release|Win32
+ {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Release|Win32.ActiveCfg = Release|Win32
+ {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Release|Win32.Build.0 = Release|Win32
{DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Setup Debug|Win32.ActiveCfg = Debug|Win32
{DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Setup Debug|Win32.Build.0 = Debug|Win32
{DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Setup|Win32.ActiveCfg = Release|Win32
@@ -159,6 +183,8 @@ Global
{8B7F059F-E4C7-4E11-88F5-EE8B8433072E}.Boot Loader|Win32.Build.0 = Release Loader|Win32
{8B7F059F-E4C7-4E11-88F5-EE8B8433072E}.Boot|Win32.ActiveCfg = Release|Win32
{8B7F059F-E4C7-4E11-88F5-EE8B8433072E}.Boot|Win32.Build.0 = Release|Win32
+ {8B7F059F-E4C7-4E11-88F5-EE8B8433072E}.Debug|Win32.ActiveCfg = Release Loader|Win32
+ {8B7F059F-E4C7-4E11-88F5-EE8B8433072E}.Debug|Win32.Build.0 = Release Loader|Win32
{8B7F059F-E4C7-4E11-88F5-EE8B8433072E}.Driver Debug|Win32.ActiveCfg = Release|Win32
{8B7F059F-E4C7-4E11-88F5-EE8B8433072E}.Driver x64 Debug|Win32.ActiveCfg = Release|Win32
{8B7F059F-E4C7-4E11-88F5-EE8B8433072E}.Driver x64|Win32.ActiveCfg = Release|Win32
@@ -169,8 +195,46 @@ Global
{8B7F059F-E4C7-4E11-88F5-EE8B8433072E}.Format|Win32.ActiveCfg = Release|Win32
{8B7F059F-E4C7-4E11-88F5-EE8B8433072E}.Mount Debug|Win32.ActiveCfg = Release|Win32
{8B7F059F-E4C7-4E11-88F5-EE8B8433072E}.Mount|Win32.ActiveCfg = Release|Win32
+ {8B7F059F-E4C7-4E11-88F5-EE8B8433072E}.Release|Win32.ActiveCfg = Release|Win32
+ {8B7F059F-E4C7-4E11-88F5-EE8B8433072E}.Release|Win32.Build.0 = Release|Win32
{8B7F059F-E4C7-4E11-88F5-EE8B8433072E}.Setup Debug|Win32.ActiveCfg = Release|Win32
{8B7F059F-E4C7-4E11-88F5-EE8B8433072E}.Setup|Win32.ActiveCfg = Release|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.All Debug|Win32.ActiveCfg = Debug|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.All Debug|Win32.Build.0 = Debug|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.All|Win32.ActiveCfg = Release|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.All|Win32.Build.0 = Release|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Boot Loader|Win32.ActiveCfg = Release|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Boot Loader|Win32.Build.0 = Release|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Boot|Win32.ActiveCfg = Release|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Boot|Win32.Build.0 = Release|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Debug|Win32.ActiveCfg = Debug|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Debug|Win32.Build.0 = Debug|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Driver Debug|Win32.ActiveCfg = Debug|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Driver Debug|Win32.Build.0 = Debug|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Driver x64 Debug|Win32.ActiveCfg = Debug|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Driver x64 Debug|Win32.Build.0 = Debug|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Driver x64|Win32.ActiveCfg = Debug|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Driver x64|Win32.Build.0 = Debug|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Driver x86 Debug|Win32.ActiveCfg = Debug|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Driver x86 Debug|Win32.Build.0 = Debug|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Driver x86|Win32.ActiveCfg = Debug|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Driver x86|Win32.Build.0 = Debug|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Driver|Win32.ActiveCfg = Debug|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Driver|Win32.Build.0 = Debug|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Format Debug|Win32.ActiveCfg = Debug|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Format Debug|Win32.Build.0 = Debug|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Format|Win32.ActiveCfg = Release|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Format|Win32.Build.0 = Release|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Mount Debug|Win32.ActiveCfg = Debug|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Mount Debug|Win32.Build.0 = Debug|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Mount|Win32.ActiveCfg = Release|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Mount|Win32.Build.0 = Release|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Release|Win32.ActiveCfg = Release|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Release|Win32.Build.0 = Release|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Setup Debug|Win32.ActiveCfg = Debug|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Setup Debug|Win32.Build.0 = Debug|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Setup|Win32.ActiveCfg = Release|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Setup|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE