VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/ExpandVolume
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2015-11-25 00:41:37 (GMT)
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2015-11-26 00:44:52 (GMT)
commit90bd57fe40e66fc829ecb01482d32d604b0df19c (patch)
tree6d6de0d9a31c82d0598f68c2d160cb9e565bd5ea /src/ExpandVolume
parentec7d96fcb733021c214b414a1ba2841039733dd2 (diff)
downloadVeraCrypt-90bd57fe40e66fc829ecb01482d32d604b0df19c.zip
VeraCrypt-90bd57fe40e66fc829ecb01482d32d604b0df19c.tar.gz
Windows: Full UNICODE rewrite and implement support for UNICODE passwords.
Diffstat (limited to 'src/ExpandVolume')
-rw-r--r--src/ExpandVolume/DlgExpandVolume.cpp64
-rw-r--r--src/ExpandVolume/ExpandVolume.c60
-rw-r--r--src/ExpandVolume/ExpandVolume.h14
-rw-r--r--src/ExpandVolume/ExpandVolume.vcproj118
-rw-r--r--src/ExpandVolume/WinMain.cpp84
5 files changed, 174 insertions, 166 deletions
diff --git a/src/ExpandVolume/DlgExpandVolume.cpp b/src/ExpandVolume/DlgExpandVolume.cpp
index 21d1f83..67c76c6 100644
--- a/src/ExpandVolume/DlgExpandVolume.cpp
+++ b/src/ExpandVolume/DlgExpandVolume.cpp
@@ -50,7 +50,7 @@
#define TIMER_INTERVAL_RANDVIEW 50
// see definition of enum EV_FileSystem
-const char * szFileSystemStr[3] = {"RAW","FAT","NTFS"};
+const wchar_t * szFileSystemStr[3] = {L"RAW",L"FAT",L"NTFS"};
// prototypes for internal functions
BOOL CALLBACK ExpandVolSizeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
@@ -59,15 +59,15 @@ BOOL CALLBACK ExpandVolProgressDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, L
namespace VeraCryptExpander
{
/* defined in WinMain.c, referenced by ExpandVolumeWizard() */
-int ExtcvAskVolumePassword (HWND hwndDlg, const char* fileName, Password *password, int *pkcs5, int *pim, BOOL* truecryptMode, char *titleStringId, BOOL enableMountOptions);
+int ExtcvAskVolumePassword (HWND hwndDlg, const wchar_t* fileName, Password *password, int *pkcs5, int *pim, BOOL* truecryptMode, char *titleStringId, BOOL enableMountOptions);
}
-int GetSpaceString(char *dest, size_t maxlen, uint64 size, BOOL bDevice)
+int GetSpaceString(wchar_t *dest, size_t cbDest, uint64 size, BOOL bDevice)
{
- const char * szFmtBytes = "%.0lf %s";
- const char * szFmtOther = "%.2lf %s";
- const char * SuffixStr[] = {"Byte", "kB", "MB", "GB", "TB"};
+ const wchar_t * szFmtBytes = L"%.0lf %s";
+ const wchar_t * szFmtOther = L"%.2lf %s";
+ const wchar_t * SuffixStr[] = {L"Byte", L"KB", L"MB", L"GB", L"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;
@@ -77,15 +77,15 @@ int GetSpaceString(char *dest, size_t maxlen, uint64 size, BOOL bDevice)
--i;
if (bDevice) {
- char szTemp[512];
+ wchar_t szTemp[512];
- if (sprintf_s(szTemp, sizeof(szTemp),i?szFmtOther:szFmtBytes, size/(double)Muliplier[i], SuffixStr[i]) < 0 )
+ if (StringCbPrintfW(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 StringCbPrintfW(dest, cbDest, L"%I64u sectors (%s)", size/SECTOR_SIZE_MSG , szTemp);
}
- return sprintf_s(dest, maxlen,i?szFmtOther:szFmtBytes, size/(double)Muliplier[i], SuffixStr[i]);
+ return StringCbPrintfW(dest, cbDest,i?szFmtOther:szFmtBytes, size/(double)Muliplier[i], SuffixStr[i]);
}
void SetCurrentVolSize(HWND hwndDlg, uint64 size)
@@ -94,14 +94,14 @@ void SetCurrentVolSize(HWND hwndDlg, uint64 size)
const int IdRadioBtn[] = {IDC_KB, IDC_MB, IDC_GB, IDC_TB};
const int nMaxSuffix = sizeof(Muliplier)/sizeof(uint64) - 1;
int i;
- char szTemp[256];
+ wchar_t szTemp[256];
for (i=1; i<=nMaxSuffix && size>Muliplier[i]; i++) ;
--i;
SendDlgItemMessage (hwndDlg, IdRadioBtn[i], BM_SETCHECK, BST_CHECKED, 0);
- StringCbPrintfA(szTemp,sizeof(szTemp),"%I64u",size/Muliplier[i]);
+ StringCbPrintfW(szTemp,sizeof(szTemp),L"%I64u",size/Muliplier[i]);
SetWindowText (GetDlgItem (hwndDlg, IDC_SIZEBOX), szTemp);
}
@@ -127,7 +127,7 @@ BOOL CALLBACK ExpandVolSizeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
{
case WM_INITDIALOG:
{
- char szTemp[4096];
+ wchar_t szTemp[4096];
pVolExpandParam = (EXPAND_VOL_THREAD_PARAMS*)lParam;
@@ -159,11 +159,11 @@ BOOL CALLBACK ExpandVolSizeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
}
else
{
- char szHostFreeStr[256];
+ wchar_t szHostFreeStr[256];
- SetWindowText (GetDlgItem (hwndDlg, IDT_NEW_SIZE), "");
+ SetWindowText (GetDlgItem (hwndDlg, IDT_NEW_SIZE), L"");
GetSpaceString(szHostFreeStr,sizeof(szHostFreeStr),pVolExpandParam->hostSizeFree,FALSE);
- StringCbPrintfA (szTemp,sizeof(szTemp),"%s available on host drive", szHostFreeStr);
+ StringCbPrintfW (szTemp,sizeof(szTemp),L"%s available on host drive", szHostFreeStr);
}
SetWindowText (GetDlgItem (hwndDlg, IDC_EXPAND_VOLUME_NEWSIZE), szTemp);
@@ -171,13 +171,13 @@ BOOL CALLBACK ExpandVolSizeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
// set help text
if (pVolExpandParam->bIsDevice)
{
- StringCbPrintfA (szTemp,sizeof(szTemp),"This is a device-based VeraCrypt volume.\n\nThe new volume size will be choosen automatically as the size of the host device.");
+ StringCbPrintfW (szTemp,sizeof(szTemp),L"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)
- StringCbCatA(szTemp,sizeof(szTemp)," Note: filling the new space with random data is not supported for legacy volumes.");
+ StringCbCatW(szTemp,sizeof(szTemp),L" Note: filling the new space with random data is not supported for legacy volumes.");
}
else
{
- StringCbPrintfA (szTemp, sizeof(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);
+ StringCbPrintfW (szTemp, sizeof(szTemp),L"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);
@@ -194,13 +194,13 @@ BOOL CALLBACK ExpandVolSizeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
if (lw == IDOK)
{
- char szTemp[4096];
+ wchar_t 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);
+ GetWindowText (GetDlgItem (hwndDlg, IDC_SIZEBOX), szTemp, ARRAYSIZE (szTemp));
+ pVolExpandParam->newSize = _wtoi64(szTemp) * GetSizeBoxMultiplier(hwndDlg);
}
EndDialog (hwndDlg, lw);
@@ -247,7 +247,7 @@ BOOL CALLBACK ExpandVolProgressDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, L
{
case WM_INITDIALOG:
{
- char szOldHostSize[512], szNewHostSize[512];
+ wchar_t szOldHostSize[512], szNewHostSize[512];
pProgressDlgParam = (EXPAND_VOL_THREAD_PARAMS*)lParam;
bVolTransformStarted = FALSE;
@@ -263,7 +263,7 @@ BOOL CALLBACK ExpandVolProgressDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, L
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");
+ SetWindowText (GetDlgItem (hwndDlg, IDC_EXPAND_VOLUME_INITSPACE), pProgressDlgParam->bInitFreeSpace?L"Yes":L"No");
SendMessage (GetDlgItem (hwndDlg, IDC_BOX_STATUS), WM_SETFONT, (WPARAM) hBoldFont, (LPARAM) TRUE);
@@ -275,11 +275,11 @@ BOOL CALLBACK ExpandVolProgressDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, L
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.");
+ SetDlgItemText(hwndDlg, IDC_BOX_STATUS, L"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.");
+ SetDlgItemText(hwndDlg, IDC_BOX_STATUS, L"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);
@@ -303,7 +303,7 @@ BOOL CALLBACK ExpandVolProgressDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, L
AddProgressDlgStatus (hwndDlg, "Finished. Volume successfully expanded.");
}
- SetWindowText (GetDlgItem (hwndDlg, IDOK), "Exit");
+ SetWindowText (GetDlgItem (hwndDlg, IDOK), L"Exit");
EnableWindow (GetDlgItem (hwndDlg, IDOK), TRUE);
EnableWindow (GetDlgItem (hwndDlg, IDCANCEL), FALSE);
}
@@ -316,14 +316,14 @@ BOOL CALLBACK ExpandVolProgressDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, L
case TIMER_ID_RANDVIEW:
{
unsigned char tmp[16] = {0};
- char szRndPool[64] = {0};
+ wchar_t szRndPool[64] = {0};
if (!showRandPool)
return 1;
RandpeekBytes (hwndDlg, tmp, sizeof (tmp));
- StringCbPrintfA (szRndPool, sizeof(szRndPool), "%08X%08X%08X%08X",
+ StringCbPrintfW (szRndPool, sizeof(szRndPool), L"%08X%08X%08X%08X",
*((DWORD*) (tmp + 12)), *((DWORD*) (tmp + 8)), *((DWORD*) (tmp + 4)), *((DWORD*) (tmp)));
SetWindowText (GetDlgItem (hwndDlg, IDC_RANDOM_BYTES), szRndPool);
@@ -391,7 +391,7 @@ BOOL CALLBACK ExpandVolProgressDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, L
typedef struct
{
OpenVolumeContext *context;
- const char *volumePath;
+ const wchar_t *volumePath;
Password *password;
int pkcs5_prf;
int pim;
@@ -428,7 +428,7 @@ void CALLBACK OpenVolumeWaitThreadProc(void* pArg, HWND hwndDlg)
none
*/
-void ExpandVolumeWizard (HWND hwndDlg, char *lpszVolume)
+void ExpandVolumeWizard (HWND hwndDlg, wchar_t *lpszVolume)
{
int nStatus = ERR_OS_ERROR;
wchar_t szTmp[4096];
@@ -439,7 +439,7 @@ void ExpandVolumeWizard (HWND hwndDlg, char *lpszVolume)
DWORD dwError;
int driveNo;
enum EV_FileSystem volFSType;
- char rootPath[] = "A:\\";
+ wchar_t rootPath[] = L"A:\\";
switch (IsSystemDevicePath (lpszVolume, hwndDlg, TRUE))
{
diff --git a/src/ExpandVolume/ExpandVolume.c b/src/ExpandVolume/ExpandVolume.c
index b978be4..e263e1f 100644
--- a/src/ExpandVolume/ExpandVolume.c
+++ b/src/ExpandVolume/ExpandVolume.c
@@ -56,8 +56,8 @@ 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 );
+static int UpdateVolumeHeaderHostSize (wchar_t *lpszVolume, Password *pVolumePassword, HWND hwndDlg, uint64 newHostSize, uint64 *pDataSize, BOOL initFreeSpace);
+static int FsctlExtendVolume(wchar_t * szVolume, LONGLONG nTotalSectors );
/*
@@ -84,7 +84,7 @@ static int FsctlExtendVolume(char * szVolume, LONGLONG nTotalSectors );
int with Truecrypt error code (ERR_SUCCESS on success)
*/
-int MountVolTemp (HWND hwndDlg, char *volumePath, int *driveNo, Password *password, int pkcs5, int pim)
+int MountVolTemp (HWND hwndDlg, wchar_t *volumePath, int *driveNo, Password *password, int pkcs5, int pim)
{
MountOptions mountOptions;
ZeroMemory (&mountOptions, sizeof (mountOptions));
@@ -133,7 +133,7 @@ int MountVolTemp (HWND hwndDlg, char *volumePath, int *driveNo, Password *passwo
Remarks: only supported by NTFS and RAW file systems
*/
-static int FsctlExtendVolume(char * szVolume, LONGLONG nTotalSectors )
+static int FsctlExtendVolume(wchar_t * szVolume, LONGLONG nTotalSectors )
{
HANDLE hDevice; // handle to the volume to be extended
BOOL bResult; // results flag
@@ -176,21 +176,21 @@ error:
}
-BOOL GetFileSystemType(const char *szFileName, enum EV_FileSystem *pFS)
+BOOL GetFileSystemType(const wchar_t *szFileName, enum EV_FileSystem *pFS)
{
- char szFS[256];
- char root[MAX_PATH];
+ wchar_t szFS[256];
+ wchar_t root[MAX_PATH];
*pFS = EV_FS_TYPE_RAW;
- if (!GetVolumePathName (szFileName, root, sizeof (root)))
+ if (!GetVolumePathName (szFileName, root, ARRAYSIZE (root)))
return FALSE;
- if ( GetVolumeInformation (root, NULL, 0, NULL, NULL, NULL, szFS, sizeof(szFS)) )
+ if ( GetVolumeInformation (root, NULL, 0, NULL, NULL, NULL, szFS, ARRAYSIZE(szFS)) )
{
- if (!strncmp (szFS, "NTFS", 4))
+ if (!wcsncmp (szFS, L"NTFS", 4))
*pFS = EV_FS_TYPE_NTFS;
- else if (!strncmp (szFS, "FAT", 3)) // FAT16, FAT32
+ else if (!wcsncmp (szFS, L"FAT", 3)) // FAT16, FAT32
*pFS = EV_FS_TYPE_FAT;
else
*pFS = EV_FS_TYPE_RAW;
@@ -227,10 +227,10 @@ BOOL GetFileSystemType(const char *szFileName, enum EV_FileSystem *pFS)
int with TrueCrypt error code (ERR_SUCCESS on success)
*/
-int QueryVolumeInfo (HWND hwndDlg, const char *lpszVolume, uint64 * pHostSizeFree, uint64 * pSizeLimitFS )
+int QueryVolumeInfo (HWND hwndDlg, const wchar_t *lpszVolume, uint64 * pHostSizeFree, uint64 * pSizeLimitFS )
{
int nStatus = ERR_OS_ERROR;
- char szDiskFile[TC_MAX_PATH], root[MAX_PATH];
+ wchar_t szDiskFile[TC_MAX_PATH], root[MAX_PATH];
BOOL bDevice;
enum EV_FileSystem fs;
@@ -244,7 +244,7 @@ int QueryVolumeInfo (HWND hwndDlg, const char *lpszVolume, uint64 * pHostSizeFre
return ERR_SUCCESS;
}
- if (!GetVolumePathName (szDiskFile, root, sizeof (root)))
+ if (!GetVolumePathName (szDiskFile, root, ARRAYSIZE (root)))
{
nStatus = ERR_OS_ERROR;
goto error;
@@ -286,26 +286,26 @@ error:
return nStatus;
}
-BOOL GetNtfsNumberOfSectors(char * rootPath, uint64 * pNumberOfSectors, DWORD *pBytesPerSector)
+BOOL GetNtfsNumberOfSectors(wchar_t * rootPath, uint64 * pNumberOfSectors, DWORD *pBytesPerSector)
{
HANDLE hDevice;
BOOL bResult;
DWORD nbytes, dwError;
size_t len;
NTFS_VOLUME_DATA_BUFFER ntfsvdb;
- char szVolumeGUID[128];
+ wchar_t szVolumeGUID[128];
// get volume name
- if (!GetVolumeNameForVolumeMountPoint(rootPath,szVolumeGUID,sizeof(szVolumeGUID)))
+ if (!GetVolumeNameForVolumeMountPoint(rootPath,szVolumeGUID,ARRAYSIZE(szVolumeGUID)))
{
return FALSE;
}
// strip trailing backslash from volume GUID (otherwise it means root dir)
- len = strlen(szVolumeGUID);
+ len = wcslen(szVolumeGUID);
if (len>0)
--len;
- if (szVolumeGUID[len]=='\\')
+ if (szVolumeGUID[len]==L'\\')
szVolumeGUID[len]=0;
hDevice = CreateFile(szVolumeGUID,
@@ -371,11 +371,11 @@ uint64 GetVolumeSizeByDataAreaSize (uint64 dataAreaSize, BOOL legacyVolume)
}
-int ExtendFileSystem (HWND hwndDlg , char *lpszVolume, Password *pVolumePassword, int VolumePkcs5, int VolumePim, uint64 newDataAreaSize)
+int ExtendFileSystem (HWND hwndDlg , wchar_t *lpszVolume, Password *pVolumePassword, int VolumePkcs5, int VolumePim, uint64 newDataAreaSize)
{
- char szVolumeGUID[128];
+ wchar_t szVolumeGUID[128];
int driveNo = -1;
- char rootPath[] = "A:\\";
+ wchar_t rootPath[] = L"A:\\";
enum EV_FileSystem fs;
DWORD dwError;
int nStatus = ERR_SUCCESS;
@@ -415,7 +415,7 @@ int ExtendFileSystem (HWND hwndDlg , char *lpszVolume, Password *pVolumePassword
}
// Get volume GUID
- if (!GetVolumeNameForVolumeMountPoint(rootPath,szVolumeGUID,sizeof(szVolumeGUID)))
+ if (!GetVolumeNameForVolumeMountPoint(rootPath,szVolumeGUID,ARRAYSIZE(szVolumeGUID)))
{
nStatus = ERR_OS_ERROR;
goto error;
@@ -423,9 +423,9 @@ int ExtendFileSystem (HWND hwndDlg , char *lpszVolume, Password *pVolumePassword
else
{
// strip trailing backslash from volume GUID (otherwise it means root dir)
- size_t len = strlen(szVolumeGUID);
+ size_t len = wcslen(szVolumeGUID);
if (len>0) --len;
- if (szVolumeGUID[len]=='\\') szVolumeGUID[len]=0;
+ if (szVolumeGUID[len]==L'\\') szVolumeGUID[len]=0;
}
// Get Sector Size
@@ -486,11 +486,11 @@ error:
Remarks: a lot of code is from TrueCrypt 'Common\Password.c' :: ChangePwd()
*/
-static int ExpandVolume (HWND hwndDlg, char *lpszVolume, Password *pVolumePassword, int VolumePkcs5, int VolumePim, uint64 newHostSize, BOOL initFreeSpace)
+static int ExpandVolume (HWND hwndDlg, wchar_t *lpszVolume, Password *pVolumePassword, int VolumePkcs5, int VolumePim, uint64 newHostSize, BOOL initFreeSpace)
{
int nDosLinkCreated = 1, nStatus = ERR_OS_ERROR;
- char szDiskFile[TC_MAX_PATH], szCFDevice[TC_MAX_PATH];
- char szDosDevice[TC_MAX_PATH];
+ wchar_t szDiskFile[TC_MAX_PATH], szCFDevice[TC_MAX_PATH];
+ wchar_t szDosDevice[TC_MAX_PATH];
char buffer[TC_VOLUME_HEADER_EFFECTIVE_SIZE];
PCRYPTO_INFO cryptoInfo = NULL, ci = NULL;
void *dev = INVALID_HANDLE_VALUE;
@@ -515,7 +515,7 @@ static int ExpandVolume (HWND hwndDlg, char *lpszVolume, Password *pVolumePasswo
if (bDevice == FALSE)
{
- strcpy (szCFDevice, szDiskFile);
+ wcscpy (szCFDevice, szDiskFile);
}
else
{
@@ -969,7 +969,7 @@ void __cdecl volTransformThreadFunction (void *pExpandDlgParam)
EXPAND_VOL_THREAD_PARAMS *pParam=(EXPAND_VOL_THREAD_PARAMS *)pExpandDlgParam;
HWND hwndDlg = (HWND) pParam->hwndDlg;
- nStatus = ExpandVolume (hwndDlg, (char*)pParam->szVolumeName, pParam->pVolumePassword,
+ nStatus = ExpandVolume (hwndDlg, (wchar_t*)pParam->szVolumeName, pParam->pVolumePassword,
pParam->VolumePkcs5, pParam->VolumePim, pParam->newSize, pParam->bInitFreeSpace );
if (nStatus!=ERR_SUCCESS && nStatus!=ERR_USER_ABORT)
diff --git a/src/ExpandVolume/ExpandVolume.h b/src/ExpandVolume/ExpandVolume.h
index 3dc213f..6f3e962 100644
--- a/src/ExpandVolume/ExpandVolume.h
+++ b/src/ExpandVolume/ExpandVolume.h
@@ -27,14 +27,14 @@ enum EV_FileSystem
EV_FS_TYPE_NTFS = 2,
};
-extern const char * szFileSystemStr[3];
+extern const wchar_t * szFileSystemStr[3];
typedef struct
{
uint64 oldSize;
uint64 newSize;
uint64 hostSizeFree;
- const char *szVolumeName;
+ const wchar_t *szVolumeName;
enum EV_FileSystem FileSystem;
BOOL bIsDevice;
BOOL bIsLegacy;
@@ -56,10 +56,10 @@ extern volatile BOOL bVolTransformThreadCancel; /* TRUE if the user cancels/paus
/* 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, int pim);
-BOOL GetFileSystemType(const char *szFileName, enum EV_FileSystem *pFS);
-BOOL GetNtfsNumberOfSectors(char *rootPath, uint64 *pNumberOfSectors, DWORD *pBytesPerSector);
+int QueryVolumeInfo (HWND hwndDlg, const wchar_t *lpszVolume, uint64 * pHostSizeFree, uint64 * pSizeLimitFS );
+int MountVolTemp (HWND hwndDlg, wchar_t *volumePath, int *driveNo, Password *password, int pkcs5, int pim);
+BOOL GetFileSystemType(const wchar_t *szFileName, enum EV_FileSystem *pFS);
+BOOL GetNtfsNumberOfSectors(wchar_t *rootPath, uint64 *pNumberOfSectors, DWORD *pBytesPerSector);
void __cdecl volTransformThreadFunction (void *hwndDlgArg);
/* defined in DlgExpandVolume.cpp */
@@ -71,7 +71,7 @@ void SetProgressDlgStatus(HWND hwndDlg, const char* szText);
#endif
/* defined in DlgExpandVolume.cpp */
-void ExpandVolumeWizard (HWND hwndDlg, char *lpszVolume);
+void ExpandVolumeWizard (HWND hwndDlg, wchar_t *lpszVolume);
#endif /* TC_HEADER_ExpandVolume */ \ No newline at end of file
diff --git a/src/ExpandVolume/ExpandVolume.vcproj b/src/ExpandVolume/ExpandVolume.vcproj
index b7401e5..897a34a 100644
--- a/src/ExpandVolume/ExpandVolume.vcproj
+++ b/src/ExpandVolume/ExpandVolume.vcproj
@@ -25,7 +25,7 @@
IntermediateDirectory="Debug"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- CharacterSet="2"
+ CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
@@ -112,18 +112,19 @@
/>
</Configuration>
<Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release"
+ Name="Debug|x64"
+ OutputDirectory="$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- CharacterSet="2"
+ CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
+ CommandLine=""
/>
<Tool
Name="VCXMLDataGeneratorTool"
@@ -134,22 +135,26 @@
<Tool
Name="VCMIDLTool"
AdditionalIncludeDirectories=""
- TypeLibraryName="$(SolutionDir)/Mount/$(ProjectName).tlb"
+ TargetEnvironment="3"
+ TypeLibraryName="$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb"
OutputDirectory=""
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalOptions="/w34189"
- Optimization="2"
+ Optimization="0"
AdditionalIncludeDirectories="..\Common;..\Crypto;..\;..\pkcs11"
- PreprocessorDefinitions="VCEXPANDER;TCMOUNT;WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS"
- RuntimeLibrary="0"
+ 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"
- AssemblerOutput="2"
- AssemblerListingLocation="$(IntDir)/"
+ BrowseInformation="0"
+ BrowseInformationFile=""
WarningLevel="3"
- DebugInformationFormat="0"
+ DebugInformationFormat="3"
DisableSpecificWarnings="4311"
/>
<Tool
@@ -163,19 +168,17 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="comctl32.lib setupapi.lib version.lib ..\Crypto\Release\crypto.lib"
+ AdditionalDependencies="version.lib comctl32.lib setupapi.lib ..\Crypto\x64\Debug\crypto.lib"
OutputFile="$(OutDir)/VeraCryptExpander.exe"
- LinkIncremental="1"
+ LinkIncremental="2"
GenerateManifest="false"
IgnoreAllDefaultLibraries="false"
- GenerateDebugInformation="false"
- GenerateMapFile="true"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile="$(OutDir)/ExpandVolume.pdb"
SubSystem="2"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="2"
- TargetMachine="1"
+ TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
@@ -198,23 +201,22 @@
/>
<Tool
Name="VCPostBuildEventTool"
- CommandLine="copy Release\VeraCryptExpander.exe &quot;..\Release\Setup Files\&quot;"
+ CommandLine="md &quot;..\Debug\Setup Files&quot; 2&gt;NUL:&#x0D;&#x0A;copy $(TargetPath) &quot;..\Debug\Setup Files\VeraCryptExpander-x64.exe&quot; &gt;NUL:&#x0D;&#x0A;"
/>
</Configuration>
<Configuration
- Name="Debug|x64"
- OutputDirectory="$(PlatformName)\$(ConfigurationName)"
- IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- CharacterSet="2"
+ CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
- CommandLine=""
/>
<Tool
Name="VCXMLDataGeneratorTool"
@@ -225,26 +227,22 @@
<Tool
Name="VCMIDLTool"
AdditionalIncludeDirectories=""
- TargetEnvironment="3"
- TypeLibraryName="$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb"
+ TypeLibraryName="$(SolutionDir)/Mount/$(ProjectName).tlb"
OutputDirectory=""
/>
<Tool
Name="VCCLCompilerTool"
- Optimization="0"
+ AdditionalOptions="/w34189"
+ Optimization="2"
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"
+ PreprocessorDefinitions="VCEXPANDER;TCMOUNT;WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS"
+ RuntimeLibrary="0"
BufferSecurityCheck="true"
- EnableFunctionLevelLinking="false"
UsePrecompiledHeader="0"
- BrowseInformation="0"
- BrowseInformationFile=""
+ AssemblerOutput="2"
+ AssemblerListingLocation="$(IntDir)/"
WarningLevel="3"
- DebugInformationFormat="3"
+ DebugInformationFormat="0"
DisableSpecificWarnings="4311"
/>
<Tool
@@ -258,17 +256,19 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="version.lib comctl32.lib setupapi.lib ..\Crypto\x64\Debug\crypto.lib"
+ AdditionalDependencies="comctl32.lib setupapi.lib version.lib ..\Crypto\Release\crypto.lib"
OutputFile="$(OutDir)/VeraCryptExpander.exe"
- LinkIncremental="2"
+ LinkIncremental="1"
GenerateManifest="false"
IgnoreAllDefaultLibraries="false"
- GenerateDebugInformation="true"
- ProgramDatabaseFile="$(OutDir)/ExpandVolume.pdb"
+ GenerateDebugInformation="false"
+ GenerateMapFile="true"
SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="2"
- TargetMachine="17"
+ TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
@@ -291,7 +291,7 @@
/>
<Tool
Name="VCPostBuildEventTool"
- CommandLine="md &quot;..\Debug\Setup Files&quot; 2&gt;NUL:&#x0D;&#x0A;copy $(TargetPath) &quot;..\Debug\Setup Files\VeraCryptExpander-x64.exe&quot; &gt;NUL:&#x0D;&#x0A;"
+ CommandLine="copy Release\VeraCryptExpander.exe &quot;..\Release\Setup Files\&quot;"
/>
</Configuration>
<Configuration
@@ -300,7 +300,7 @@
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- CharacterSet="2"
+ CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
@@ -422,7 +422,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Release|Win32"
+ Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
@@ -430,7 +430,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Debug|x64"
+ Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
@@ -485,7 +485,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Release|Win32"
+ Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
@@ -493,7 +493,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Debug|x64"
+ Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
@@ -521,7 +521,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Release|Win32"
+ Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
@@ -529,7 +529,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Debug|x64"
+ Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
@@ -569,7 +569,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Release|Win32"
+ Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
@@ -577,7 +577,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Debug|x64"
+ Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
@@ -674,7 +674,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Release|Win32"
+ Name="Debug|x64"
>
<Tool
Name="VCMIDLTool"
@@ -683,7 +683,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Debug|x64"
+ Name="Release|Win32"
>
<Tool
Name="VCMIDLTool"
@@ -713,7 +713,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Release|Win32"
+ Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
@@ -721,7 +721,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Debug|x64"
+ Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
@@ -937,7 +937,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Release|Win32"
+ Name="Debug|x64"
ExcludedFromBuild="true"
>
<Tool
@@ -945,7 +945,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Debug|x64"
+ Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
diff --git a/src/ExpandVolume/WinMain.cpp b/src/ExpandVolume/WinMain.cpp
index 502977c..7b3d77e 100644
--- a/src/ExpandVolume/WinMain.cpp
+++ b/src/ExpandVolume/WinMain.cpp
@@ -53,8 +53,8 @@
using namespace VeraCrypt;
-const char szExpandVolumeInfo[] =
-":: VeraCrypt Expander ::\n\nExpand a VeraCrypt volume on the fly without reformatting\n\n\n\
+const wchar_t szExpandVolumeInfo[] =
+L":: 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\
@@ -83,9 +83,9 @@ 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;
+wchar_t szFileName[TC_MAX_PATH+1]; /* Volume to mount */
+wchar_t szDriveLetter[3]; /* Drive Letter to mount */
+wchar_t commandLineDrive = 0;
BOOL bCacheInDriver = FALSE; /* Cache any passwords we see */
BOOL bCacheInDriverDefault = FALSE;
BOOL bHistoryCmdLine = FALSE; /* History control is always disabled */
@@ -130,7 +130,7 @@ MountOptions defaultMountOptions;
KeyFile *FirstCmdKeyFile;
HBITMAP hbmLogoBitmapRescaled = NULL;
-char OrigKeyboardLayout [8+1] = "00000409";
+wchar_t OrigKeyboardLayout [8+1] = L"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. */
@@ -173,7 +173,7 @@ void EndMainDlg (HWND hwndDlg)
{
if (!bHistory)
{
- SetWindowText (GetDlgItem (hwndDlg, IDC_VOLUME), "");
+ SetWindowText (GetDlgItem (hwndDlg, IDC_VOLUME), L"");
}
EndDialog (hwndDlg, 0);
@@ -292,15 +292,21 @@ void LoadSettings (HWND hwndDlg)
CloseSecurityTokenSessionsAfterMount = ConfigReadInt ("CloseSecurityTokenSessionsAfterMount", 0);
- ConfigReadString ("SecurityTokenLibrary", "", SecurityTokenLibraryPath, sizeof (SecurityTokenLibraryPath) - 1);
- if (SecurityTokenLibraryPath[0])
- InitSecurityTokenLibrary(hwndDlg);
+ {
+ char szTmp[TC_MAX_PATH] = {0};
+ WideCharToMultiByte (CP_UTF8, 0, SecurityTokenLibraryPath, -1, szTmp, sizeof (szTmp), NULL, NULL);
+ ConfigReadString ("SecurityTokenLibrary", "", szTmp, sizeof (szTmp) - 1);
+ MultiByteToWideChar (CP_UTF8, 0, szTmp, -1, SecurityTokenLibraryPath, ARRAYSIZE (SecurityTokenLibraryPath));
+
+ if (SecurityTokenLibraryPath[0])
+ InitSecurityTokenLibrary(hwndDlg);
+ }
/* we don't load the history */
}
-BOOL SelectItem (HWND hTree, char nLetter)
+BOOL SelectItem (HWND hTree, wchar_t nLetter)
{
int i;
LVITEM item;
@@ -367,7 +373,7 @@ GetItemLong (HWND hTree, int itemNo)
return item.lParam;
}
-static char PasswordDlgVolume[MAX_PATH + 1] = {0};
+static wchar_t PasswordDlgVolume[MAX_PATH + 1] = {0};
static BOOL PasswordDialogDisableMountOptions;
static char *PasswordDialogTitleStringId;
@@ -398,15 +404,15 @@ BOOL CALLBACK ExtcvPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
{
SetWindowTextW (hwndDlg, GetString (PasswordDialogTitleStringId));
}
- else if (strlen (PasswordDlgVolume) > 0)
+ else if (wcslen (PasswordDlgVolume) > 0)
{
wchar_t s[1024];
const int maxVisibleLen = 40;
- if (strlen (PasswordDlgVolume) > maxVisibleLen)
+ if (wcslen (PasswordDlgVolume) > maxVisibleLen)
{
- string volStr = PasswordDlgVolume;
- StringCbPrintfW (s, sizeof(s), GetString ("ENTER_PASSWORD_FOR"), ("..." + volStr.substr (volStr.size() - maxVisibleLen - 1)).c_str());
+ wstring volStr = PasswordDlgVolume;
+ StringCbPrintfW (s, sizeof(s), GetString ("ENTER_PASSWORD_FOR"), (L"..." + volStr.substr (volStr.size() - maxVisibleLen - 1)).c_str());
}
else
StringCbPrintfW (s, sizeof(s), GetString ("ENTER_PASSWORD_FOR"), PasswordDlgVolume);
@@ -510,15 +516,15 @@ BOOL CALLBACK ExtcvPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
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);
+ wchar_t tmp[MAX_PASSWORD+1];
+ wmemset (tmp, L'X', MAX_PASSWORD);
tmp [MAX_PASSWORD] = 0;
SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), tmp);
- SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), "");
+ SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), L"");
- StringCbPrintfA (OrigKeyboardLayout, sizeof(OrigKeyboardLayout),"%08X", (DWORD) GetKeyboardLayout (NULL) & 0xFFFF);
+ StringCbPrintfW (OrigKeyboardLayout, sizeof(OrigKeyboardLayout),L"%08X", (DWORD) GetKeyboardLayout (NULL) & 0xFFFF);
- DWORD keybLayout = (DWORD) LoadKeyboardLayout ("00000409", KLF_ACTIVATE);
+ DWORD keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE);
if (keybLayout != 0x00000409 && keybLayout != 0x04090409)
{
@@ -565,13 +571,13 @@ BOOL CALLBACK ExtcvPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
// 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);
+ wchar_t tmp[MAX_PASSWORD+1];
+ wmemset (tmp, L'X', MAX_PASSWORD);
tmp [MAX_PASSWORD] = 0;
SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), tmp);
- SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), "");
+ SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), L"");
- keybLayout = (DWORD) LoadKeyboardLayout ("00000409", KLF_ACTIVATE);
+ keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE);
if (keybLayout != 0x00000409 && keybLayout != 0x04090409)
{
@@ -651,15 +657,17 @@ BOOL CALLBACK ExtcvPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
if (lw == IDCANCEL || lw == IDOK)
{
- char tmp[MAX_PASSWORD+1];
-
+ wchar_t tmp[MAX_PASSWORD+1];
+
if (lw == IDOK)
{
if (mountOptions.ProtectHiddenVolume && hidVolProtKeyFilesParam.EnableKeyFiles)
KeyFilesApply (hwndDlg, &mountOptions.ProtectedHidVolPassword, hidVolProtKeyFilesParam.FirstKeyFile, PasswordDlgVolume);
- GetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), (LPSTR) szXPwd->Text, MAX_PASSWORD + 1);
- szXPwd->Length = strlen ((char *) szXPwd->Text);
+ if (GetPassword (hwndDlg, IDC_PASSWORD, (LPSTR) szXPwd->Text, MAX_PASSWORD + 1, TRUE))
+ szXPwd->Length = strlen ((char *) szXPwd->Text);
+ else
+ return 1;
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);
@@ -686,10 +694,10 @@ BOOL CALLBACK ExtcvPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
}
// Attempt to wipe password stored in the input field buffer
- memset (tmp, 'X', MAX_PASSWORD);
+ wmemset (tmp, L'X', MAX_PASSWORD);
tmp[MAX_PASSWORD] = 0;
SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), tmp);
- SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD_PROT_HIDVOL), tmp);
+ SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD_PROT_HIDVOL), tmp);
if (hidVolProtKeyFilesParam.FirstKeyFile != NULL)
{
@@ -781,7 +789,7 @@ int RestoreVolumeHeader (HWND hwndDlg, char *lpszVolume)
return 0;
}
-int ExtcvAskVolumePassword (HWND hwndDlg, const char* fileName, Password *password, int *pkcs5, int *pim, BOOL* truecryptMode, char *titleStringId, BOOL enableMountOptions)
+int ExtcvAskVolumePassword (HWND hwndDlg, const wchar_t* fileName, Password *password, int *pkcs5, int *pim, BOOL* truecryptMode, char *titleStringId, BOOL enableMountOptions)
{
int result;
PasswordDlgParam dlgParam;
@@ -794,7 +802,7 @@ int ExtcvAskVolumePassword (HWND hwndDlg, const char* fileName, Password *passwo
dlgParam.pim = pim;
dlgParam.truecryptMode = truecryptMode;
- StringCbCopyA (PasswordDlgVolume, sizeof(PasswordDlgVolume), fileName);
+ StringCbCopyW (PasswordDlgVolume, sizeof(PasswordDlgVolume), fileName);
result = DialogBoxParamW (hInst,
MAKEINTRESOURCEW (IDD_PASSWORD_DLG), hwndDlg,
@@ -914,9 +922,9 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
}
else
{
- char fileName[MAX_PATH];
- GetWindowText (GetDlgItem (hwndDlg, IDC_VOLUME), fileName, sizeof (fileName));
- ExpandVolumeWizard(hwndDlg, (char*)fileName);
+ wchar_t fileName[MAX_PATH];
+ GetWindowText (GetDlgItem (hwndDlg, IDC_VOLUME), fileName, ARRAYSIZE (fileName));
+ ExpandVolumeWizard(hwndDlg, fileName);
}
return 1;
}
@@ -930,7 +938,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (lw == IDM_HOMEPAGE )
{
ArrowWaitCursor ();
- ShellExecute (NULL, "open", "https://veracrypt.codeplex.com", NULL, NULL, SW_SHOWNORMAL);
+ ShellExecute (NULL, L"open", L"https://veracrypt.codeplex.com", NULL, NULL, SW_SHOWNORMAL);
Sleep (200);
NormalCursor ();
@@ -965,7 +973,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
}
-int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, char *lpszCommandLine, int nCmdShow)
+int WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, wchar_t *lpszCommandLine, int nCmdShow)
{
int status;
atexit (VeraCryptExpander::localcleanup);