VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Common/Apidrvr.h4
-rw-r--r--src/Common/BaseCom.cpp11
-rw-r--r--src/Common/BootEncryption.cpp229
-rw-r--r--src/Common/BootEncryption.h44
-rw-r--r--src/Common/Cmdline.c58
-rw-r--r--src/Common/Cmdline.h12
-rw-r--r--src/Common/Combo.c37
-rw-r--r--src/Common/Combo.h2
-rw-r--r--src/Common/Crypto.c84
-rw-r--r--src/Common/Crypto.h28
-rw-r--r--src/Common/Dlgcode.c1464
-rw-r--r--src/Common/Dlgcode.h195
-rw-r--r--src/Common/Exception.h10
-rw-r--r--src/Common/Format.c27
-rw-r--r--src/Common/Format.h2
-rw-r--r--src/Common/Keyfiles.c41
-rw-r--r--src/Common/Keyfiles.h6
-rw-r--r--src/Common/Language.c8
-rw-r--r--src/Common/Language.xml74
-rw-r--r--src/Common/Password.c38
-rw-r--r--src/Common/Password.h2
-rw-r--r--src/Common/Pkcs5.c12
-rw-r--r--src/Common/Pkcs5.h12
-rw-r--r--src/Common/Random.c20
-rw-r--r--src/Common/Registry.c74
-rw-r--r--src/Common/Registry.h35
-rw-r--r--src/Common/SecurityToken.cpp8
-rw-r--r--src/Common/SecurityToken.h4
-rw-r--r--src/Common/Tcdefs.h3
-rw-r--r--src/Common/Tests.c36
-rw-r--r--src/Common/Xml.c53
-rw-r--r--src/Common/Xml.h3
-rw-r--r--src/Crypto/Crypto.vcproj84
-rw-r--r--src/Driver/DriveFilter.c10
-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
-rw-r--r--src/Format/Format.vcproj188
-rw-r--r--src/Format/InPlace.c66
-rw-r--r--src/Format/InPlace.h8
-rw-r--r--src/Format/Tcformat.cbin633378 -> 633870 bytes
-rw-r--r--src/Format/Tcformat.h6
-rw-r--r--src/Mount/Favorites.cpp92
-rw-r--r--src/Mount/Favorites.h8
-rw-r--r--src/Mount/MainCom.cpp63
-rw-r--r--src/Mount/MainCom.h6
-rw-r--r--src/Mount/Mount.c1030
-rw-r--r--src/Mount/Mount.h12
-rw-r--r--src/Mount/Mount.vcproj184
-rw-r--r--src/Setup/ComSetup.cpp14
-rw-r--r--src/Setup/ComSetup.h4
-rw-r--r--src/Setup/Dir.c74
-rw-r--r--src/Setup/Dir.h4
-rw-r--r--src/Setup/SelfExtract.c180
-rw-r--r--src/Setup/SelfExtract.h8
-rw-r--r--src/Setup/Setup.c717
-rw-r--r--src/Setup/Setup.h248
-rw-r--r--src/Setup/Setup.vcproj8
-rw-r--r--src/Setup/Wizard.c63
61 files changed, 3027 insertions, 3026 deletions
diff --git a/src/Common/Apidrvr.h b/src/Common/Apidrvr.h
index 3f74176..5ba6c88 100644
--- a/src/Common/Apidrvr.h
+++ b/src/Common/Apidrvr.h
@@ -311,11 +311,7 @@ typedef struct
#pragma pack (pop)
-#ifdef TC_WINDOWS_DRIVER
#define DRIVER_STR WIDE
-#else
-#define DRIVER_STR
-#endif
#define TC_UNIQUE_ID_PREFIX "VeraCryptVolume"
#define TC_MOUNT_PREFIX L"\\Device\\VeraCryptVolume"
diff --git a/src/Common/BaseCom.cpp b/src/Common/BaseCom.cpp
index 74d4432..a3bc42f 100644
--- a/src/Common/BaseCom.cpp
+++ b/src/Common/BaseCom.cpp
@@ -128,16 +128,9 @@ BOOL BaseCom::IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly)
DWORD BaseCom::ReadWriteFile (BOOL write, BOOL device, BSTR filePath, BSTR *bufferBstr, unsigned __int64 offset, unsigned __int32 size, DWORD *sizeDone)
{
- USES_CONVERSION;
- CW2A szFilePathA(filePath);
- if (!szFilePathA.m_psz)
- {
- return ERROR_NOT_ENOUGH_MEMORY;
- }
-
try
{
- auto_ptr <File> file (device ? new Device (string (szFilePathA.m_psz), !write) : new File (string (szFilePathA.m_psz), !write));
+ auto_ptr <File> file (device ? new Device (filePath, !write) : new File (filePath, !write));
file->CheckOpened (SRC_POS);
file->SeekAt (offset);
@@ -246,7 +239,7 @@ DWORD BaseCom::SetDriverServiceStartType (DWORD startType)
DWORD BaseCom::WriteLocalMachineRegistryDwordValue (BSTR keyPath, BSTR valueName, DWORD value)
{
- if (!::WriteLocalMachineRegistryDwordW (keyPath, valueName, value))
+ if (!::WriteLocalMachineRegistryDword (keyPath, valueName, value))
return GetLastError();
return ERROR_SUCCESS;
diff --git a/src/Common/BootEncryption.cpp b/src/Common/BootEncryption.cpp
index 8b8c122..9edc89e 100644
--- a/src/Common/BootEncryption.cpp
+++ b/src/Common/BootEncryption.cpp
@@ -76,17 +76,17 @@ namespace VeraCrypt
}
}
- static void CopyFile (const string &sourceFile, const string &destinationFile)
+ static void CopyFile (const wstring &sourceFile, const wstring &destinationFile)
{
Elevate();
DWORD result;
CComBSTR sourceFileBstr, destinationFileBstr;
- BSTR bstr = A2WBSTR(sourceFile.c_str());
+ BSTR bstr = W2BSTR(sourceFile.c_str());
if (bstr)
{
sourceFileBstr.Attach (bstr);
- bstr = A2WBSTR(destinationFile.c_str());
+ bstr = W2BSTR(destinationFile.c_str());
if (bstr)
{
destinationFileBstr.Attach (bstr);
@@ -109,12 +109,12 @@ namespace VeraCrypt
}
}
- static void DeleteFile (const string &file)
+ static void DeleteFile (const wstring &file)
{
Elevate();
CComBSTR fileBstr;
DWORD result;
- BSTR bstr = A2WBSTR(file.c_str());
+ BSTR bstr = W2BSTR(file.c_str());
if (bstr)
{
fileBstr.Attach (bstr);
@@ -132,7 +132,7 @@ namespace VeraCrypt
}
}
- static void ReadWriteFile (BOOL write, BOOL device, const string &filePath, byte *buffer, uint64 offset, uint32 size, DWORD *sizeDone)
+ static void ReadWriteFile (BOOL write, BOOL device, const wstring &filePath, byte *buffer, uint64 offset, uint32 size, DWORD *sizeDone)
{
Elevate();
@@ -140,7 +140,7 @@ namespace VeraCrypt
CComBSTR bufferBstr, fileBstr;
if (bufferBstr.AppendBytes ((const char *) buffer, size) != S_OK)
throw ParameterIncorrect (SRC_POS);
- BSTR bstr = A2WBSTR(filePath.c_str());
+ BSTR bstr = W2BSTR(filePath.c_str());
if (bstr)
{
fileBstr.Attach (bstr);
@@ -168,17 +168,17 @@ namespace VeraCrypt
return ElevatedComInstance->IsPagingFileActive (checkNonWindowsPartitionsOnly);
}
- static void WriteLocalMachineRegistryDwordValue (char *keyPath, char *valueName, DWORD value)
+ static void WriteLocalMachineRegistryDwordValue (wchar_t *keyPath, wchar_t *valueName, DWORD value)
{
Elevate();
DWORD result;
CComBSTR keyPathBstr, valueNameBstr;
- BSTR bstr = A2WBSTR(keyPath);
+ BSTR bstr = W2BSTR(keyPath);
if (bstr)
{
keyPathBstr.Attach (bstr);
- bstr = A2WBSTR(valueName);
+ bstr = W2BSTR(valueName);
if (bstr)
{
valueNameBstr.Attach (bstr);
@@ -289,7 +289,7 @@ namespace VeraCrypt
public:
static void AddReference () { }
static void CallDriver (DWORD ioctl, void *input, DWORD inputSize, void *output, DWORD outputSize) { throw ParameterIncorrect (SRC_POS); }
- static void ReadWriteFile (BOOL write, BOOL device, const string &filePath, byte *buffer, uint64 offset, uint32 size, DWORD *sizeDone) { throw ParameterIncorrect (SRC_POS); }
+ static void ReadWriteFile (BOOL write, BOOL device, const wstring &filePath, byte *buffer, uint64 offset, uint32 size, DWORD *sizeDone) { throw ParameterIncorrect (SRC_POS); }
static void RegisterFilterDriver (bool registerDriver, BootEncryption::FilterType filterType) { throw ParameterIncorrect (SRC_POS); }
static void Release () { }
static void SetDriverServiceStartType (DWORD startType) { throw ParameterIncorrect (SRC_POS); }
@@ -298,7 +298,7 @@ namespace VeraCrypt
#endif // SETUP
- File::File (string path, bool readOnly, bool create) : Elevated (false), FileOpen (false), LastError(0)
+ File::File (wstring path, bool readOnly, bool create) : Elevated (false), FileOpen (false), LastError(0)
{
Handle = CreateFile (path.c_str(),
readOnly ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE,
@@ -417,18 +417,18 @@ namespace VeraCrypt
}
}
- void Show (HWND parent, const string &str)
+ void Show (HWND parent, const wstring &str)
{
MessageBox (parent, str.c_str(), NULL, 0);
}
- Device::Device (string path, bool readOnly)
+ Device::Device (wstring path, bool readOnly)
{
FileOpen = false;
Elevated = false;
- Handle = CreateFile ((string ("\\\\.\\") + path).c_str(),
+ Handle = CreateFile ((wstring (L"\\\\.\\") + path).c_str(),
readOnly ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
FILE_FLAG_RANDOM_ACCESS | FILE_FLAG_WRITE_THROUGH, NULL);
@@ -616,7 +616,7 @@ namespace VeraCrypt
DWORD BootEncryption::GetDriverServiceStartType ()
{
DWORD startType;
- throw_sys_if (!ReadLocalMachineRegistryDword ("SYSTEM\\CurrentControlSet\\Services\\veracrypt", "Start", &startType));
+ throw_sys_if (!ReadLocalMachineRegistryDword (L"SYSTEM\\CurrentControlSet\\Services\\veracrypt", L"Start", &startType));
return startType;
}
@@ -645,42 +645,42 @@ namespace VeraCrypt
finally_do_arg (SC_HANDLE, serviceManager, { CloseServiceHandle (finally_arg); });
- SC_HANDLE service = OpenService (serviceManager, "veracrypt", SERVICE_CHANGE_CONFIG);
+ SC_HANDLE service = OpenService (serviceManager, L"veracrypt", SERVICE_CHANGE_CONFIG);
throw_sys_if (!service);
finally_do_arg (SC_HANDLE, service, { CloseServiceHandle (finally_arg); });
// Windows versions preceding Vista can be installed on FAT filesystem which does not
// support long filenames during boot. Convert the driver path to short form if required.
- string driverPath;
+ wstring driverPath;
if (startOnBoot && !IsOSAtLeast (WIN_VISTA))
{
- char pathBuf[MAX_PATH];
- char filesystem[128];
+ wchar_t pathBuf[MAX_PATH];
+ wchar_t filesystem[128];
- string path (GetWindowsDirectory());
- path += "\\drivers\\veracrypt.sys";
+ wstring path (GetWindowsDirectory());
+ path += L"\\drivers\\veracrypt.sys";
- if (GetVolumePathName (path.c_str(), pathBuf, sizeof (pathBuf))
- && GetVolumeInformation (pathBuf, NULL, 0, NULL, NULL, NULL, filesystem, sizeof(filesystem))
- && memcmp (filesystem, "FAT", 3) == 0)
+ if (GetVolumePathName (path.c_str(), pathBuf, ARRAYSIZE (pathBuf))
+ && GetVolumeInformation (pathBuf, NULL, 0, NULL, NULL, NULL, filesystem, ARRAYSIZE(filesystem))
+ && wmemcmp (filesystem, L"FAT", 3) == 0)
{
- throw_sys_if (GetShortPathName (path.c_str(), pathBuf, sizeof (pathBuf)) == 0);
+ throw_sys_if (GetShortPathName (path.c_str(), pathBuf, ARRAYSIZE (pathBuf)) == 0);
// Convert absolute path to relative to the Windows directory
driverPath = pathBuf;
- driverPath = driverPath.substr (driverPath.rfind ("\\", driverPath.rfind ("\\", driverPath.rfind ("\\") - 1) - 1) + 1);
+ driverPath = driverPath.substr (driverPath.rfind (L"\\", driverPath.rfind (L"\\", driverPath.rfind (L"\\") - 1) - 1) + 1);
}
}
throw_sys_if (!ChangeServiceConfig (service, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE,
startOnBoot ? SERVICE_ERROR_SEVERE : SERVICE_ERROR_NORMAL,
driverPath.empty() ? NULL : driverPath.c_str(),
- startOnBoot ? "Filter" : NULL,
+ startOnBoot ? L"Filter" : NULL,
NULL, NULL, NULL, NULL, NULL));
// ChangeServiceConfig() rejects SERVICE_BOOT_START with ERROR_INVALID_PARAMETER
- throw_sys_if (!WriteLocalMachineRegistryDword ("SYSTEM\\CurrentControlSet\\Services\\veracrypt", "Start", startType));
+ throw_sys_if (!WriteLocalMachineRegistryDword (L"SYSTEM\\CurrentControlSet\\Services\\veracrypt", L"Start", startType));
}
@@ -692,7 +692,7 @@ namespace VeraCrypt
GetSystemDriveConfiguration();
ProbeRealDriveSizeRequest request;
- StringCbPrintfW (request.DeviceName, sizeof (request.DeviceName), L"%hs", DriveConfig.DrivePartition.DevicePath.c_str());
+ StringCbCopyW (request.DeviceName, sizeof (request.DeviceName), DriveConfig.DrivePartition.DevicePath.c_str());
CallDriver (TC_IOCTL_PROBE_REAL_DRIVE_SIZE, &request, sizeof (request), &request, sizeof (request));
DriveConfig.DrivePartition.Info.PartitionLength = request.RealDriveSize;
@@ -717,11 +717,11 @@ namespace VeraCrypt
for (int partNumber = 0; partNumber < 64; ++partNumber)
{
- stringstream partPath;
- partPath << "\\Device\\Harddisk" << driveNumber << "\\Partition" << partNumber;
+ wstringstream partPath;
+ partPath << L"\\Device\\Harddisk" << driveNumber << L"\\Partition" << partNumber;
DISK_PARTITION_INFO_STRUCT diskPartInfo = {0};
- StringCbPrintfW (diskPartInfo.deviceName, sizeof (diskPartInfo.deviceName), L"%hs", partPath.str().c_str());
+ StringCbCopyW (diskPartInfo.deviceName, sizeof (diskPartInfo.deviceName), partPath.str().c_str());
try
{
@@ -748,19 +748,17 @@ namespace VeraCrypt
part.IsGPT = diskPartInfo.IsGPT;
// Mount point
- wstringstream ws;
- ws << partPath.str().c_str();
- int driveNumber = GetDiskDeviceDriveLetter ((wchar_t *) ws.str().c_str());
+ int driveNumber = GetDiskDeviceDriveLetter ((wchar_t *) partPath.str().c_str());
if (driveNumber >= 0)
{
- part.MountPoint += (char) (driveNumber + 'A');
- part.MountPoint += ":";
+ part.MountPoint += (wchar_t) (driveNumber + L'A');
+ part.MountPoint += L":";
}
// Volume ID
wchar_t volumePath[TC_MAX_PATH];
- if (ResolveSymbolicLink ((wchar_t *) ws.str().c_str(), volumePath, sizeof(volumePath)))
+ if (ResolveSymbolicLink ((wchar_t *) partPath.str().c_str(), volumePath, sizeof(volumePath)))
{
wchar_t volumeName[TC_MAX_PATH];
HANDLE fh = FindFirstVolumeW (volumeName, array_capacity (volumeName));
@@ -794,32 +792,32 @@ namespace VeraCrypt
DISK_GEOMETRY BootEncryption::GetDriveGeometry (int driveNumber)
{
- stringstream devName;
- devName << "\\Device\\Harddisk" << driveNumber << "\\Partition0";
+ wstringstream devName;
+ devName << L"\\Device\\Harddisk" << driveNumber << L"\\Partition0";
DISK_GEOMETRY geometry;
- throw_sys_if (!::GetDriveGeometry ((char *) devName.str().c_str(), &geometry));
+ throw_sys_if (!::GetDriveGeometry (devName.str().c_str(), &geometry));
return geometry;
}
- string BootEncryption::GetWindowsDirectory ()
+ wstring BootEncryption::GetWindowsDirectory ()
{
- char buf[MAX_PATH];
- throw_sys_if (GetSystemDirectory (buf, sizeof (buf)) == 0);
+ wchar_t buf[MAX_PATH];
+ throw_sys_if (GetSystemDirectory (buf, ARRAYSIZE (buf)) == 0);
- return string (buf);
+ return wstring (buf);
}
- string BootEncryption::GetTempPath ()
+ wstring BootEncryption::GetTempPath ()
{
- char tempPath[MAX_PATH];
- DWORD tempLen = ::GetTempPath (sizeof (tempPath), tempPath);
- if (tempLen == 0 || tempLen > sizeof (tempPath))
+ wchar_t tempPath[MAX_PATH];
+ DWORD tempLen = ::GetTempPath (ARRAYSIZE (tempPath), tempPath);
+ if (tempLen == 0 || tempLen > ARRAYSIZE (tempPath))
throw ParameterIncorrect (SRC_POS);
- return string (tempPath);
+ return wstring (tempPath);
}
@@ -838,7 +836,7 @@ namespace VeraCrypt
}
// Note that this does not require admin rights (it just requires the driver to be running)
- bool BootEncryption::IsBootLoaderOnDrive (char *devicePath)
+ bool BootEncryption::IsBootLoaderOnDrive (wchar_t *devicePath)
{
try
{
@@ -846,8 +844,7 @@ namespace VeraCrypt
memset (&openTestStruct, 0, sizeof (openTestStruct));
DWORD dwResult;
- StringCbCopyA ((char *) &openTestStruct.wszFileName[0], sizeof(openTestStruct.wszFileName),devicePath);
- ToUNICODE ((char *) &openTestStruct.wszFileName[0], sizeof(openTestStruct.wszFileName));
+ StringCbCopyW (&openTestStruct.wszFileName[0], sizeof(openTestStruct.wszFileName),devicePath);
openTestStruct.bDetectTCBootLoader = TRUE;
@@ -949,7 +946,7 @@ namespace VeraCrypt
bool BootEncryption::SystemDriveIsDynamic ()
{
GetSystemDriveConfigurationRequest request;
- StringCbPrintfW (request.DevicePath, sizeof (request.DevicePath), L"%hs", GetSystemDriveConfiguration().DeviceKernelPath.c_str());
+ StringCbCopyW (request.DevicePath, sizeof (request.DevicePath), GetSystemDriveConfiguration().DeviceKernelPath.c_str());
CallDriver (TC_IOCTL_GET_SYSTEM_DRIVE_CONFIG, &request, sizeof (request), &request, sizeof (request));
return request.DriveIsDynamic ? true : false;
@@ -963,7 +960,7 @@ namespace VeraCrypt
SystemDriveConfiguration config;
- string winDir = GetWindowsDirectory();
+ wstring winDir = GetWindowsDirectory();
// Scan all drives
for (int driveNumber = 0; driveNumber < 32; ++driveNumber)
@@ -977,7 +974,7 @@ namespace VeraCrypt
foreach (const Partition &part, partitions)
{
if (!part.MountPoint.empty()
- && (_access ((part.MountPoint + "\\bootmgr").c_str(), 0) == 0 || _access ((part.MountPoint + "\\ntldr").c_str(), 0) == 0))
+ && (_waccess ((part.MountPoint + L"\\bootmgr").c_str(), 0) == 0 || _waccess ((part.MountPoint + L"\\ntldr").c_str(), 0) == 0))
{
config.SystemLoaderPresent = true;
}
@@ -1006,12 +1003,12 @@ namespace VeraCrypt
{
config.DriveNumber = driveNumber;
- stringstream ss;
- ss << "PhysicalDrive" << driveNumber;
+ wstringstream ss;
+ ss << L"PhysicalDrive" << driveNumber;
config.DevicePath = ss.str();
- stringstream kernelPath;
- kernelPath << "\\Device\\Harddisk" << driveNumber << "\\Partition0";
+ wstringstream kernelPath;
+ kernelPath << L"\\Device\\Harddisk" << driveNumber << L"\\Partition0";
config.DeviceKernelPath = kernelPath.str();
config.DrivePartition = partitions.front();
@@ -1187,7 +1184,7 @@ namespace VeraCrypt
// Boot sector
DWORD size;
- byte *bootSecResourceImg = MapResource ("BIN", bootSectorId, &size);
+ byte *bootSecResourceImg = MapResource (L"BIN", bootSectorId, &size);
if (!bootSecResourceImg || size != TC_SECTOR_SIZE_BIOS)
throw ParameterIncorrect (SRC_POS);
@@ -1215,14 +1212,14 @@ namespace VeraCrypt
}
// Decompressor
- byte *decompressor = MapResource ("BIN", IDR_BOOT_LOADER_DECOMPRESSOR, &size);
+ byte *decompressor = MapResource (L"BIN", IDR_BOOT_LOADER_DECOMPRESSOR, &size);
if (!decompressor || size > TC_BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS)
throw ParameterIncorrect (SRC_POS);
memcpy (buffer + TC_SECTOR_SIZE_BIOS, decompressor, size);
// Compressed boot loader
- byte *bootLoader = MapResource ("BIN", bootLoaderId, &size);
+ byte *bootLoader = MapResource (L"BIN", bootLoaderId, &size);
if (!bootLoader || size > TC_MAX_BOOT_LOADER_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS)
throw ParameterIncorrect (SRC_POS);
@@ -1254,7 +1251,7 @@ namespace VeraCrypt
throw ParameterIncorrect (SRC_POS);
GetSystemDriveConfigurationRequest request;
- StringCbPrintfW (request.DevicePath, sizeof (request.DevicePath), L"%hs", GetSystemDriveConfiguration().DeviceKernelPath.c_str());
+ StringCbCopyW (request.DevicePath, sizeof (request.DevicePath), GetSystemDriveConfiguration().DeviceKernelPath.c_str());
try
{
@@ -1584,35 +1581,35 @@ namespace VeraCrypt
}
#endif
- string BootEncryption::GetSystemLoaderBackupPath ()
+ wstring BootEncryption::GetSystemLoaderBackupPath ()
{
- char pathBuf[MAX_PATH];
+ WCHAR pathBuf[MAX_PATH];
throw_sys_if (!SUCCEEDED (SHGetFolderPath (NULL, CSIDL_COMMON_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, pathBuf)));
- string path = string (pathBuf) + "\\" TC_APP_NAME;
+ wstring path = wstring (pathBuf) + L"\\" _T(TC_APP_NAME);
CreateDirectory (path.c_str(), NULL);
- return path + '\\' + TC_SYS_BOOT_LOADER_BACKUP_NAME;
+ return path + L'\\' + TC_SYS_BOOT_LOADER_BACKUP_NAME;
}
void BootEncryption::RenameDeprecatedSystemLoaderBackup ()
{
- char pathBuf[MAX_PATH];
+ WCHAR pathBuf[MAX_PATH];
if (SUCCEEDED (SHGetFolderPath (NULL, CSIDL_COMMON_APPDATA, NULL, 0, pathBuf)))
{
- string path = string (pathBuf) + "\\" TC_APP_NAME + '\\' + TC_SYS_BOOT_LOADER_BACKUP_NAME_LEGACY;
+ wstring path = wstring (pathBuf) + L"\\" _T(TC_APP_NAME) + L'\\' + TC_SYS_BOOT_LOADER_BACKUP_NAME_LEGACY;
if (FileExists (path.c_str()) && !FileExists (GetSystemLoaderBackupPath().c_str()))
- throw_sys_if (rename (path.c_str(), GetSystemLoaderBackupPath().c_str()) != 0);
+ throw_sys_if (_wrename (path.c_str(), GetSystemLoaderBackupPath().c_str()) != 0);
}
}
#ifndef SETUP
- void BootEncryption::CreateRescueIsoImage (bool initialSetup, const string &isoImagePath)
+ void BootEncryption::CreateRescueIsoImage (bool initialSetup, const wstring &isoImagePath)
{
BootEncryptionStatus encStatus = GetStatus();
if (encStatus.SetupInProgress)
@@ -1764,12 +1761,12 @@ namespace VeraCrypt
if (!RescueIsoImage)
throw ParameterIncorrect (SRC_POS);
- for (char drive = 'Z'; drive >= 'C'; --drive)
+ for (WCHAR drive = L'Z'; drive >= L'C'; --drive)
{
try
{
- char rootPath[4] = { drive, ':', '\\', 0};
- UINT driveType = GetDriveTypeA (rootPath);
+ WCHAR rootPath[4] = { drive, L':', L'\\', 0};
+ UINT driveType = GetDriveType (rootPath);
// check that it is a CD/DVD drive or a removable media in case a bootable
// USB key was created from the rescue disk ISO file
if ((DRIVE_CDROM == driveType) || (DRIVE_REMOVABLE == driveType))
@@ -1795,7 +1792,7 @@ namespace VeraCrypt
return false;
}
- bool BootEncryption::VerifyRescueDiskIsoImage (const char* imageFile)
+ bool BootEncryption::VerifyRescueDiskIsoImage (const wchar_t* imageFile)
{
if (!RescueIsoImage)
throw ParameterIncorrect (SRC_POS);
@@ -1967,7 +1964,7 @@ namespace VeraCrypt
filter = "veracrypt.sys";
filterReg = "DumpFilters";
- SetLastError (RegOpenKeyEx (HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\CrashControl", 0, KEY_READ | KEY_WRITE, &regKey));
+ SetLastError (RegOpenKeyEx (HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\CrashControl", 0, KEY_READ | KEY_WRITE, &regKey));
throw_sys_if (GetLastError() != ERROR_SUCCESS);
break;
@@ -1989,18 +1986,18 @@ namespace VeraCrypt
// SetupInstallFromInfSection() does not support prepending of values so we have to modify the registry directly
StringCbCopyA ((char *) regKeyBuf, sizeof(regKeyBuf), filter.c_str());
- if (RegQueryValueEx (regKey, filterReg.c_str(), NULL, NULL, regKeyBuf + strSize, &size) != ERROR_SUCCESS)
+ if (RegQueryValueExA (regKey, filterReg.c_str(), NULL, NULL, regKeyBuf + strSize, &size) != ERROR_SUCCESS)
size = 1;
- SetLastError (RegSetValueEx (regKey, filterReg.c_str(), 0, REG_MULTI_SZ, regKeyBuf, (DWORD) strSize + size));
+ SetLastError (RegSetValueExA (regKey, filterReg.c_str(), 0, REG_MULTI_SZ, regKeyBuf, (DWORD) strSize + size));
throw_sys_if (GetLastError() != ERROR_SUCCESS);
}
else
{
- string infFileName = GetTempPath() + "\\veracrypt_driver_setup.inf";
+ wstring infFileName = GetTempPath() + L"\\veracrypt_driver_setup.inf";
File infFile (infFileName, false, true);
- finally_do_arg (string, infFileName, { DeleteFile (finally_arg.c_str()); });
+ finally_do_arg (wstring, infFileName, { DeleteFile (finally_arg.c_str()); });
string infTxt = "[veracrypt]\r\n"
+ string (registerFilter ? "Add" : "Del") + "Reg=veracrypt_reg\r\n\r\n"
@@ -2014,7 +2011,7 @@ namespace VeraCrypt
throw_sys_if (hInf == INVALID_HANDLE_VALUE);
finally_do_arg (HINF, hInf, { SetupCloseInfFile (finally_arg); });
- throw_sys_if (!SetupInstallFromInfSection (ParentWindow, hInf, "veracrypt", SPINST_REGISTRY, regKey, NULL, 0, NULL, NULL, NULL, NULL));
+ throw_sys_if (!SetupInstallFromInfSection (ParentWindow, hInf, L"veracrypt", SPINST_REGISTRY, regKey, NULL, 0, NULL, NULL, NULL, NULL));
}
}
@@ -2052,8 +2049,8 @@ namespace VeraCrypt
throw_sys_if (!scm);
finally_do_arg (SC_HANDLE, scm, { CloseServiceHandle (finally_arg); });
- string servicePath = GetServiceConfigPath (TC_APP_NAME ".exe", false);
- string serviceLegacyPath = GetServiceConfigPath (TC_APP_NAME ".exe", true);
+ wstring servicePath = GetServiceConfigPath (_T(TC_APP_NAME) L".exe", false);
+ wstring serviceLegacyPath = GetServiceConfigPath (_T(TC_APP_NAME) L".exe", true);
if (registerService)
{
@@ -2065,20 +2062,20 @@ namespace VeraCrypt
if (!noFileHandling)
{
- char appPath[TC_MAX_PATH];
- throw_sys_if (!GetModuleFileName (NULL, appPath, sizeof (appPath)));
+ wchar_t appPath[TC_MAX_PATH];
+ throw_sys_if (!GetModuleFileName (NULL, appPath, ARRAYSIZE (appPath)));
throw_sys_if (!CopyFile (appPath, servicePath.c_str(), FALSE));
}
SC_HANDLE service = CreateService (scm,
TC_SYSTEM_FAVORITES_SERVICE_NAME,
- TC_APP_NAME " System Favorites",
+ _T(TC_APP_NAME) L" System Favorites",
SERVICE_ALL_ACCESS,
SERVICE_WIN32_OWN_PROCESS,
SERVICE_AUTO_START,
SERVICE_ERROR_NORMAL,
- (string ("\"") + servicePath + "\" " TC_SYSTEM_FAVORITES_SERVICE_CMDLINE_OPTION).c_str(),
+ (wstring (L"\"") + servicePath + L"\" " TC_SYSTEM_FAVORITES_SERVICE_CMDLINE_OPTION).c_str(),
TC_SYSTEM_FAVORITES_SERVICE_LOAD_ORDER_GROUP,
NULL,
NULL,
@@ -2088,15 +2085,15 @@ namespace VeraCrypt
throw_sys_if (!service);
SERVICE_DESCRIPTION description;
- description.lpDescription = "Mounts VeraCrypt system favorite volumes.";
+ description.lpDescription = L"Mounts VeraCrypt system favorite volumes.";
ChangeServiceConfig2 (service, SERVICE_CONFIG_DESCRIPTION, &description);
CloseServiceHandle (service);
try
{
- WriteLocalMachineRegistryString ("SYSTEM\\CurrentControlSet\\Control\\SafeBoot\\Minimal\\" TC_SYSTEM_FAVORITES_SERVICE_NAME, NULL, "Service", FALSE);
- WriteLocalMachineRegistryString ("SYSTEM\\CurrentControlSet\\Control\\SafeBoot\\Network\\" TC_SYSTEM_FAVORITES_SERVICE_NAME, NULL, "Service", FALSE);
+ WriteLocalMachineRegistryString (L"SYSTEM\\CurrentControlSet\\Control\\SafeBoot\\Minimal\\" TC_SYSTEM_FAVORITES_SERVICE_NAME, NULL, L"Service", FALSE);
+ WriteLocalMachineRegistryString (L"SYSTEM\\CurrentControlSet\\Control\\SafeBoot\\Network\\" TC_SYSTEM_FAVORITES_SERVICE_NAME, NULL, L"Service", FALSE);
SetDriverConfigurationFlag (TC_DRIVER_CONFIG_CACHE_BOOT_PASSWORD_FOR_SYS_FAVORITES, true);
}
@@ -2115,8 +2112,8 @@ namespace VeraCrypt
{
SetDriverConfigurationFlag (TC_DRIVER_CONFIG_CACHE_BOOT_PASSWORD_FOR_SYS_FAVORITES, false);
- DeleteLocalMachineRegistryKey ("SYSTEM\\CurrentControlSet\\Control\\SafeBoot\\Minimal", TC_SYSTEM_FAVORITES_SERVICE_NAME);
- DeleteLocalMachineRegistryKey ("SYSTEM\\CurrentControlSet\\Control\\SafeBoot\\Network", TC_SYSTEM_FAVORITES_SERVICE_NAME);
+ DeleteLocalMachineRegistryKey (L"SYSTEM\\CurrentControlSet\\Control\\SafeBoot\\Minimal", TC_SYSTEM_FAVORITES_SERVICE_NAME);
+ DeleteLocalMachineRegistryKey (L"SYSTEM\\CurrentControlSet\\Control\\SafeBoot\\Network", TC_SYSTEM_FAVORITES_SERVICE_NAME);
SC_HANDLE service = OpenService (scm, TC_SYSTEM_FAVORITES_SERVICE_NAME, SERVICE_ALL_ACCESS);
throw_sys_if (!service);
@@ -2140,7 +2137,7 @@ namespace VeraCrypt
finally_do_arg (SC_HANDLE, scm, { CloseServiceHandle (finally_arg); });
- string servicePath = GetServiceConfigPath (TC_APP_NAME ".exe", false);
+ wstring servicePath = GetServiceConfigPath (_T(TC_APP_NAME) L".exe", false);
// check if service exists
SC_HANDLE service = OpenService (scm, TC_SYSTEM_FAVORITES_SERVICE_NAME, SERVICE_ALL_ACCESS);
@@ -2151,13 +2148,13 @@ namespace VeraCrypt
SERVICE_WIN32_OWN_PROCESS,
SERVICE_AUTO_START,
SERVICE_ERROR_NORMAL,
- (string ("\"") + servicePath + "\" " TC_SYSTEM_FAVORITES_SERVICE_CMDLINE_OPTION).c_str(),
+ (wstring (L"\"") + servicePath + L"\" " TC_SYSTEM_FAVORITES_SERVICE_CMDLINE_OPTION).c_str(),
TC_SYSTEM_FAVORITES_SERVICE_LOAD_ORDER_GROUP,
NULL,
NULL,
NULL,
NULL,
- TC_APP_NAME " System Favorites"));
+ _T(TC_APP_NAME) L" System Favorites"));
}
else
@@ -2175,9 +2172,9 @@ namespace VeraCrypt
else
configMap &= ~flag;
#ifdef SETUP
- WriteLocalMachineRegistryDword ("SYSTEM\\CurrentControlSet\\Services\\veracrypt", TC_DRIVER_CONFIG_REG_VALUE_NAME, configMap);
+ WriteLocalMachineRegistryDword (L"SYSTEM\\CurrentControlSet\\Services\\veracrypt", TC_DRIVER_CONFIG_REG_VALUE_NAME, configMap);
#else
- WriteLocalMachineRegistryDwordValue ("SYSTEM\\CurrentControlSet\\Services\\veracrypt", TC_DRIVER_CONFIG_REG_VALUE_NAME, configMap);
+ WriteLocalMachineRegistryDwordValue (L"SYSTEM\\CurrentControlSet\\Services\\veracrypt", TC_DRIVER_CONFIG_REG_VALUE_NAME, configMap);
#endif
}
@@ -2260,20 +2257,20 @@ namespace VeraCrypt
void BootEncryption::InitialSecurityChecksForHiddenOS ()
{
- char windowsDrive = (char) toupper (GetWindowsDirectory()[0]);
+ wchar_t windowsDrive = (wchar_t) towupper (GetWindowsDirectory()[0]);
// Paging files
bool pagingFilesOk = !IsPagingFileActive (TRUE);
- char pagingFileRegData[65536];
+ wchar_t pagingFileRegData[65536];
DWORD pagingFileRegDataSize = sizeof (pagingFileRegData);
- if (ReadLocalMachineRegistryMultiString ("System\\CurrentControlSet\\Control\\Session Manager\\Memory Management", "PagingFiles", pagingFileRegData, &pagingFileRegDataSize)
- && pagingFileRegDataSize > 4)
+ if (ReadLocalMachineRegistryMultiString (L"System\\CurrentControlSet\\Control\\Session Manager\\Memory Management", L"PagingFiles", pagingFileRegData, &pagingFileRegDataSize)
+ && pagingFileRegDataSize > 8)
{
- for (size_t i = 1; i < pagingFileRegDataSize - 2; ++i)
+ for (size_t i = 1; i < pagingFileRegDataSize/2 - 2; ++i)
{
- if (memcmp (pagingFileRegData + i, ":\\", 2) == 0 && toupper (pagingFileRegData[i - 1]) != windowsDrive)
+ if (wmemcmp (pagingFileRegData + i, L":\\", 2) == 0 && towupper (pagingFileRegData[i - 1]) != windowsDrive)
{
pagingFilesOk = false;
break;
@@ -2299,15 +2296,15 @@ namespace VeraCrypt
}
// User profile
- char *configPath = GetConfigPath ("dummy");
- if (configPath && toupper (configPath[0]) != windowsDrive)
+ wchar_t *configPath = GetConfigPath (L"dummy");
+ if (configPath && towupper (configPath[0]) != windowsDrive)
{
throw ErrorException (wstring (GetString ("USER_PROFILE_NOT_ON_SYS_PARTITION"))
+ GetString ("LEAKS_OUTSIDE_SYSPART_UNIVERSAL_EXPLANATION"), SRC_POS);
}
// Temporary files
- if (toupper (GetTempPath()[0]) != windowsDrive)
+ if (towupper (GetTempPath()[0]) != windowsDrive)
{
throw ErrorException (wstring (GetString ("TEMP_NOT_ON_SYS_PARTITION"))
+ GetString ("LEAKS_OUTSIDE_SYSPART_UNIVERSAL_EXPLANATION"), SRC_POS);
@@ -2602,7 +2599,7 @@ namespace VeraCrypt
}
- void BootEncryption::PrepareInstallation (bool systemPartitionOnly, Password &password, int ea, int mode, int pkcs5, int pim, const string &rescueIsoImagePath)
+ void BootEncryption::PrepareInstallation (bool systemPartitionOnly, Password &password, int ea, int mode, int pkcs5, int pim, const wstring &rescueIsoImagePath)
{
BootEncryptionStatus encStatus = GetStatus();
if (encStatus.DriveMounted)
@@ -2671,14 +2668,14 @@ namespace VeraCrypt
void BootEncryption::RestrictPagingFilesToSystemPartition ()
{
- char pagingFiles[128];
- StringCbCopyA (pagingFiles, sizeof(pagingFiles), "X:\\pagefile.sys 0 0");
+ wchar_t pagingFiles[128] = {0};
+ StringCbCopyW (pagingFiles, sizeof(pagingFiles), L"X:\\pagefile.sys 0 0");
pagingFiles[0] = GetWindowsDirectory()[0];
- throw_sys_if (!WriteLocalMachineRegistryMultiString ("System\\CurrentControlSet\\Control\\Session Manager\\Memory Management", "PagingFiles", pagingFiles, (DWORD) strlen (pagingFiles) + 2));
+ throw_sys_if (!WriteLocalMachineRegistryMultiString (L"System\\CurrentControlSet\\Control\\Session Manager\\Memory Management", L"PagingFiles", pagingFiles, (DWORD) (wcslen (pagingFiles) + 2) * sizeof (wchar_t)));
}
- void BootEncryption::WriteLocalMachineRegistryDwordValue (char *keyPath, char *valueName, DWORD value)
+ void BootEncryption::WriteLocalMachineRegistryDwordValue (wchar_t *keyPath, wchar_t *valueName, DWORD value)
{
if (!IsAdmin() && IsUacSupported())
{
@@ -2722,7 +2719,7 @@ namespace VeraCrypt
CallDriver (TC_IOCTL_BOOT_ENCRYPTION_SETUP, &request, sizeof (request), NULL, 0);
}
- void BootEncryption::CopyFileAdmin (const string &sourceFile, const string &destinationFile)
+ void BootEncryption::CopyFileAdmin (const wstring &sourceFile, const wstring &destinationFile)
{
if (!IsAdmin())
{
@@ -2738,7 +2735,7 @@ namespace VeraCrypt
throw_sys_if (!::CopyFile (sourceFile.c_str(), destinationFile.c_str(), FALSE));
}
- void BootEncryption::DeleteFileAdmin (const string &file)
+ void BootEncryption::DeleteFileAdmin (const wstring &file)
{
if (!IsAdmin() && IsUacSupported())
Elevator::DeleteFile (file);
@@ -2752,7 +2749,7 @@ namespace VeraCrypt
{
DWORD configMap;
- if (!ReadLocalMachineRegistryDword ("SYSTEM\\CurrentControlSet\\Services\\veracrypt", TC_DRIVER_CONFIG_REG_VALUE_NAME, &configMap))
+ if (!ReadLocalMachineRegistryDword (L"SYSTEM\\CurrentControlSet\\Services\\veracrypt", TC_DRIVER_CONFIG_REG_VALUE_NAME, &configMap))
configMap = 0;
return configMap;
diff --git a/src/Common/BootEncryption.h b/src/Common/BootEncryption.h
index c3eb336..ae2d85e 100644
--- a/src/Common/BootEncryption.h
+++ b/src/Common/BootEncryption.h
@@ -27,7 +27,7 @@ namespace VeraCrypt
{
public:
File () : Elevated (false), FileOpen (false), FilePointerPosition(0), Handle(INVALID_HANDLE_VALUE), IsDevice(false), LastError(0) { }
- File (string path,bool readOnly = false, bool create = false);
+ File (wstring path,bool readOnly = false, bool create = false);
virtual ~File () { Close(); }
void CheckOpened (const char* srcPos) { if (!FileOpen) { SetLastError (LastError); throw SystemException (srcPos);} }
@@ -42,7 +42,7 @@ namespace VeraCrypt
uint64 FilePointerPosition;
HANDLE Handle;
bool IsDevice;
- string Path;
+ wstring Path;
DWORD LastError;
};
@@ -50,7 +50,7 @@ namespace VeraCrypt
class Device : public File
{
public:
- Device (string path,bool readOnly = false);
+ Device (wstring path,bool readOnly = false);
virtual ~Device () {}
};
@@ -77,9 +77,9 @@ namespace VeraCrypt
struct Partition
{
- string DevicePath;
+ wstring DevicePath;
PARTITION_INFORMATION Info;
- string MountPoint;
+ wstring MountPoint;
size_t Number;
BOOL IsGPT;
wstring VolumeNameId;
@@ -119,8 +119,8 @@ namespace VeraCrypt
struct SystemDriveConfiguration
{
- string DeviceKernelPath;
- string DevicePath;
+ wstring DeviceKernelPath;
+ wstring DevicePath;
int DriveNumber;
Partition DrivePartition;
bool ExtraBootPartitionPresent;
@@ -154,19 +154,19 @@ namespace VeraCrypt
void CheckEncryptionSetupResult ();
void CheckRequirements ();
void CheckRequirementsHiddenOS ();
- void CopyFileAdmin (const string &sourceFile, const string &destinationFile);
- void CreateRescueIsoImage (bool initialSetup, const string &isoImagePath);
+ void CopyFileAdmin (const wstring &sourceFile, const wstring &destinationFile);
+ void CreateRescueIsoImage (bool initialSetup, const wstring &isoImagePath);
void Deinstall (bool displayWaitDialog = false);
- void DeleteFileAdmin (const string &file);
+ void DeleteFileAdmin (const wstring &file);
DecoySystemWipeStatus GetDecoyOSWipeStatus ();
DWORD GetDriverServiceStartType ();
unsigned int GetHiddenOSCreationPhase ();
uint16 GetInstalledBootLoaderVersion ();
void GetInstalledBootLoaderFingerprint (byte fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE]);
Partition GetPartitionForHiddenOS ();
- bool IsBootLoaderOnDrive (char *devicePath);
+ bool IsBootLoaderOnDrive (wchar_t *devicePath);
BootEncryptionStatus GetStatus ();
- string GetTempPath ();
+ wstring GetTempPath ();
void GetVolumeProperties (VOLUME_PROPERTIES_STRUCT *properties);
SystemDriveConfiguration GetSystemDriveConfiguration ();
void Install (bool hiddenSystem);
@@ -178,7 +178,7 @@ namespace VeraCrypt
bool IsHiddenSystemRunning ();
bool IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly);
void PrepareHiddenOSCreation (int ea, int mode, int pkcs5);
- void PrepareInstallation (bool systemPartitionOnly, Password &password, int ea, int mode, int pkcs5, int pim, const string &rescueIsoImagePath);
+ void PrepareInstallation (bool systemPartitionOnly, Password &password, int ea, int mode, int pkcs5, int pim, const wstring &rescueIsoImagePath);
void ProbeRealSystemDriveSize ();
void ReadBootSectorConfig (byte *config, size_t bufLength, byte *userConfig = nullptr, string *customUserMessage = nullptr, uint16 *bootLoaderVersion = nullptr);
uint32 ReadDriverConfigurationFlags ();
@@ -203,12 +203,12 @@ namespace VeraCrypt
bool SystemPartitionCoversWholeDrive ();
bool SystemDriveIsDynamic ();
bool VerifyRescueDisk ();
- bool VerifyRescueDiskIsoImage (const char* imageFile);
+ bool VerifyRescueDiskIsoImage (const wchar_t* imageFile);
void WipeHiddenOSCreationConfig ();
void WriteBootDriveSector (uint64 offset, byte *data);
void WriteBootSectorConfig (const byte newConfig[]);
void WriteBootSectorUserConfig (byte userConfig, const string &customUserMessage);
- void WriteLocalMachineRegistryDwordValue (char *keyPath, char *valueName, DWORD value);
+ void WriteLocalMachineRegistryDwordValue (wchar_t *keyPath, wchar_t *valueName, DWORD value);
protected:
static const uint32 RescueIsoImageSize = 1835008; // Size of ISO9660 image with bootable emulated 1.44MB floppy disk image
@@ -216,12 +216,12 @@ namespace VeraCrypt
void BackupSystemLoader ();
void CreateBootLoaderInMemory (byte *buffer, size_t bufferSize, bool rescueDisk, bool hiddenOSCreation = false);
void CreateVolumeHeader (uint64 volumeSize, uint64 encryptedAreaStart, Password *password, int ea, int mode, int pkcs5, int pim);
- string GetSystemLoaderBackupPath ();
+ wstring GetSystemLoaderBackupPath ();
uint32 GetChecksum (byte *data, size_t size);
DISK_GEOMETRY GetDriveGeometry (int driveNumber);
PartitionList GetDrivePartitions (int driveNumber);
wstring GetRemarksOnHiddenOS ();
- string GetWindowsDirectory ();
+ wstring GetWindowsDirectory ();
void RegisterFilter (bool registerFilter, FilterType filterType, const GUID *deviceClassGuid = nullptr);
void RestoreSystemLoader ();
void InstallVolumeHeader ();
@@ -246,11 +246,11 @@ namespace VeraCrypt
#define MIN_HIDDENOS_DECOY_PARTITION_SIZE_RATIO_NTFS 2.1
#define MIN_HIDDENOS_DECOY_PARTITION_SIZE_RATIO_FAT 1.05
-#define TC_SYS_BOOT_LOADER_BACKUP_NAME "Original System Loader"
-#define TC_SYS_BOOT_LOADER_BACKUP_NAME_LEGACY "Original System Loader.bak" // Deprecated to prevent removal by some "cleaners"
+#define TC_SYS_BOOT_LOADER_BACKUP_NAME L"Original System Loader"
+#define TC_SYS_BOOT_LOADER_BACKUP_NAME_LEGACY L"Original System Loader.bak" // Deprecated to prevent removal by some "cleaners"
-#define TC_SYSTEM_FAVORITES_SERVICE_NAME TC_APP_NAME "SystemFavorites"
-#define TC_SYSTEM_FAVORITES_SERVICE_LOAD_ORDER_GROUP "Event Log"
-#define TC_SYSTEM_FAVORITES_SERVICE_CMDLINE_OPTION "/systemFavoritesService"
+#define TC_SYSTEM_FAVORITES_SERVICE_NAME _T(TC_APP_NAME) L"SystemFavorites"
+#define TC_SYSTEM_FAVORITES_SERVICE_LOAD_ORDER_GROUP L"Event Log"
+#define TC_SYSTEM_FAVORITES_SERVICE_CMDLINE_OPTION L"/systemFavoritesService"
#endif // TC_HEADER_Common_BootEncryption
diff --git a/src/Common/Cmdline.c b/src/Common/Cmdline.c
index 4fca2db..f3609f9 100644
--- a/src/Common/Cmdline.c
+++ b/src/Common/Cmdline.c
@@ -40,8 +40,8 @@ BOOL CALLBACK CommandHelpDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
{
case WM_INITDIALOG:
{
- char * tmp = err_malloc(8192);
- char tmp2[MAX_PATH * 2];
+ wchar_t * tmp = err_malloc(8192 * sizeof (wchar_t));
+ wchar_t tmp2[MAX_PATH * 2];
argumentspec *as;
int i;
@@ -51,29 +51,29 @@ BOOL CALLBACK CommandHelpDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
*tmp = 0;
- StringCbCopyA (tmp, 8192, "VeraCrypt " VERSION_STRING);
+ StringCchCopyW (tmp, 8192, L"VeraCrypt " _T(VERSION_STRING));
#ifdef _WIN64
- StringCbCatA (tmp, 8192, " (64-bit)");
+ StringCchCatW (tmp, 8192, L" (64-bit)");
#else
- StringCbCatA (tmp, 8192, " (32-bit)");
+ StringCchCatW (tmp, 8192, L" (32-bit)");
#endif
#if (defined(_DEBUG) || defined(DEBUG))
- StringCbCatA (tmp, 8192, " (debug)");
+ StringCchCatW (tmp, 8192, L" (debug)");
#endif
- StringCbCatA (tmp, 8192, "\n\nCommand line options:\n\n");
+ StringCchCatW (tmp, 8192, L"\n\nCommand line options:\n\n");
for (i = 0; i < as->arg_cnt; i ++)
{
if (!as->args[i].Internal)
{
- StringCchPrintf(tmp2, MAX_PATH * 2, "%s\t%s\n", as->args[i].short_name, as->args[i].long_name);
- StringCchCat(tmp, 8192, tmp2);
+ StringCchPrintfW(tmp2, MAX_PATH * 2, L"%s\t%s\n", as->args[i].short_name, as->args[i].long_name);
+ StringCchCatW(tmp, 8192, tmp2);
}
}
- StringCbCatA (tmp, 8192, "\nExamples:\n\nMount a volume as X:\tveracrypt.exe /q /v volume.hc /l X\nDismount a volume X:\tveracrypt.exe /q /d X");
+ StringCchCatW (tmp, 8192, L"\nExamples:\n\nMount a volume as X:\tveracrypt.exe /q /v volume.hc /l X\nDismount a volume X:\tveracrypt.exe /q /d X");
- SetWindowText (GetDlgItem (hwndDlg, IDC_COMMANDHELP_TEXT), (char*) tmp);
+ SetWindowTextW (GetDlgItem (hwndDlg, IDC_COMMANDHELP_TEXT), tmp);
TCfree(tmp);
return 1;
@@ -90,7 +90,7 @@ BOOL CALLBACK CommandHelpDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
return 0;
}
-int Win32CommandLine (char *lpszCommandLine, char ***lpszArgs)
+int Win32CommandLine (wchar_t ***lpszArgs)
{
int argumentCount;
int i;
@@ -109,30 +109,16 @@ int Win32CommandLine (char *lpszCommandLine, char ***lpszArgs)
return 0;
}
- *lpszArgs = malloc (sizeof (char *) * argumentCount);
+ *lpszArgs = malloc (sizeof (wchar_t *) * argumentCount);
if (!*lpszArgs)
AbortProcess ("OUTOFMEMORY");
for (i = 0; i < argumentCount; ++i)
{
- size_t argLen = wcslen (arguments[i + 1]);
-
- char *arg = malloc (argLen + 1);
+ wchar_t *arg = _wcsdup (arguments[i + 1]);
if (!arg)
AbortProcess ("OUTOFMEMORY");
- if (argLen > 0)
- {
- int len = WideCharToMultiByte (CP_ACP, 0, arguments[i + 1], -1, arg, (int) argLen + 1, NULL, NULL);
- if (len == 0)
- {
- handleWin32Error (NULL, SRC_POS);
- AbortProcessSilent();
- }
- }
- else
- arg[0] = 0;
-
(*lpszArgs)[i] = arg;
}
@@ -140,21 +126,21 @@ int Win32CommandLine (char *lpszCommandLine, char ***lpszArgs)
return argumentCount;
}
-int GetArgSepPosOffset (char *lpszArgument)
+int GetArgSepPosOffset (wchar_t *lpszArgument)
{
- if (lpszArgument[0] == '/')
+ if (lpszArgument[0] == L'/')
return 1;
return 0;
}
-int GetArgumentID (argumentspec *as, char *lpszArgument)
+int GetArgumentID (argumentspec *as, wchar_t *lpszArgument)
{
int i;
for (i = 0; i < as->arg_cnt; i++)
{
- if (_stricmp (as->args[i].long_name, lpszArgument) == 0)
+ if (_wcsicmp (as->args[i].long_name, lpszArgument) == 0)
{
return as->args[i].Id;
}
@@ -165,7 +151,7 @@ int GetArgumentID (argumentspec *as, char *lpszArgument)
if (as->args[i].short_name[0] == 0)
continue;
- if (_stricmp (as->args[i].short_name, lpszArgument) == 0)
+ if (_wcsicmp (as->args[i].short_name, lpszArgument) == 0)
{
return as->args[i].Id;
}
@@ -175,8 +161,8 @@ int GetArgumentID (argumentspec *as, char *lpszArgument)
return -1;
}
-int GetArgumentValue (char **lpszCommandLineArgs, int *nArgIdx,
- int nNoCommandLineArgs, char *lpszValue, int nValueSize)
+int GetArgumentValue (wchar_t **lpszCommandLineArgs, int *nArgIdx,
+ int nNoCommandLineArgs, wchar_t *lpszValue, int nValueSize)
{
*lpszValue = 0;
@@ -187,7 +173,7 @@ int GetArgumentValue (char **lpszCommandLineArgs, int *nArgIdx,
{
/* Handles the case of space between parameter code
and value */
- StringCbCopyA (lpszValue, nValueSize, lpszCommandLineArgs[*nArgIdx + 1]);
+ StringCbCopyW (lpszValue, nValueSize, lpszCommandLineArgs[*nArgIdx + 1]);
lpszValue[nValueSize - 1] = 0;
(*nArgIdx)++;
return HAS_ARGUMENT;
diff --git a/src/Common/Cmdline.h b/src/Common/Cmdline.h
index a46a7c3..8f2c055 100644
--- a/src/Common/Cmdline.h
+++ b/src/Common/Cmdline.h
@@ -21,8 +21,8 @@ extern "C" {
typedef struct argument_t
{
int Id;
- char long_name[32];
- char short_name[8];
+ wchar_t long_name[32];
+ wchar_t short_name[8];
BOOL Internal;
} argument;
@@ -33,10 +33,10 @@ typedef struct argumentspec_t
} argumentspec;
BOOL CALLBACK CommandHelpDlgProc ( HWND hwndDlg , UINT msg , WPARAM wParam , LPARAM lParam );
-int Win32CommandLine ( char *lpszCommandLine , char ***lpszArgs );
-int GetArgSepPosOffset ( char *lpszArgument );
-int GetArgumentID ( argumentspec *as , char *lpszArgument );
-int GetArgumentValue ( char **lpszCommandLineArgs , int *nArgIdx , int nNoCommandLineArgs , char *lpszValue , int nValueSize );
+int Win32CommandLine ( wchar_t ***lpszArgs );
+int GetArgSepPosOffset ( wchar_t *lpszArgument );
+int GetArgumentID ( argumentspec *as , wchar_t *lpszArgument );
+int GetArgumentValue ( wchar_t **lpszCommandLineArgs , int *nArgIdx , int nNoCommandLineArgs , wchar_t *lpszValue , int nValueSize );
#ifdef __cplusplus
}
diff --git a/src/Common/Combo.c b/src/Common/Combo.c
index 89e8315..e5759bb 100644
--- a/src/Common/Combo.c
+++ b/src/Common/Combo.c
@@ -20,7 +20,7 @@
#define SIZEOF_MRU_LIST 20
-void AddComboItem (HWND hComboBox, char *lpszFileName, BOOL saveHistory)
+void AddComboItem (HWND hComboBox, const wchar_t *lpszFileName, BOOL saveHistory)
{
LPARAM nIndex;
@@ -53,19 +53,19 @@ void AddComboItem (HWND hComboBox, char *lpszFileName, BOOL saveHistory)
LPARAM MoveEditToCombo (HWND hComboBox, BOOL saveHistory)
{
- char szTmp[TC_MAX_PATH] = {0};
+ wchar_t szTmp[TC_MAX_PATH] = {0};
if (!saveHistory)
{
- GetWindowText (hComboBox, szTmp, sizeof (szTmp));
+ GetWindowText (hComboBox, szTmp, ARRAYSIZE (szTmp));
SendMessage (hComboBox, CB_RESETCONTENT, 0, 0);
SetWindowText (hComboBox, szTmp);
return 0;
}
- GetWindowText (hComboBox, szTmp, sizeof (szTmp));
+ GetWindowText (hComboBox, szTmp, ARRAYSIZE (szTmp));
- if (strlen (szTmp) > 0)
+ if (wcslen (szTmp) > 0)
{
LPARAM nIndex = SendMessage (hComboBox, CB_FINDSTRINGEXACT, (WPARAM) - 1,
(LPARAM) & szTmp[0]);
@@ -169,19 +169,22 @@ void LoadCombo (HWND hComboBox, BOOL bEnabled, BOOL bOnlyCheckModified, BOOL *pb
i = 0;
while (xml = XmlFindElement (xml, "volume"))
{
- char szTmp[MAX_PATH] = { 0 };
+ wchar_t szTmp[MAX_PATH] = { 0 };
+ wchar_t wszVolume[MAX_PATH] = {0};
if (i < count)
{
- if (SendMessage (hComboBox, CB_GETLBTEXTLEN, nComboIdx[i], 0) < sizeof (szTmp))
+ if (SendMessage (hComboBox, CB_GETLBTEXTLEN, nComboIdx[i], 0) < ARRAYSIZE (szTmp))
SendMessage (hComboBox, CB_GETLBTEXT, nComboIdx[i], (LPARAM) & szTmp[0]);
}
XmlGetNodeText (xml, volume, sizeof (volume));
+ if (0 == MultiByteToWideChar (CP_UTF8, 0, volume, -1, wszVolume, MAX_PATH))
+ wszVolume [0] = 0;
if (!bOnlyCheckModified)
- AddComboItem (hComboBox, volume, TRUE);
+ AddComboItem (hComboBox, wszVolume, TRUE);
- if (pbModified && strcmp (volume, szTmp))
+ if (pbModified && wcscmp (wszVolume, szTmp))
*pbModified = TRUE;
xml++;
@@ -208,11 +211,11 @@ void DumpCombo (HWND hComboBox, int bClear)
return;
}
- f = fopen (GetConfigPath (TC_APPD_FILENAME_HISTORY), "w");
+ f = _wfopen (GetConfigPath (TC_APPD_FILENAME_HISTORY), L"w,ccs=UTF-8");
if (f == NULL) return;
XmlWriteHeader (f);
- fputs ("\n\t<history>", f);
+ fputws (L"\n\t<history>", f);
/* combo list part:- get mru items */
for (i = 0; i < SIZEOF_MRU_LIST; i++)
@@ -221,21 +224,21 @@ void DumpCombo (HWND hComboBox, int bClear)
/* combo list part:- write out mru items */
for (i = 0; i < SIZEOF_MRU_LIST; i++)
{
- char szTmp[MAX_PATH] = { 0 };
+ wchar_t szTmp[MAX_PATH] = { 0 };
- if (SendMessage (hComboBox, CB_GETLBTEXTLEN, nComboIdx[i], 0) < sizeof (szTmp))
+ if (SendMessage (hComboBox, CB_GETLBTEXTLEN, nComboIdx[i], 0) < ARRAYSIZE (szTmp))
SendMessage (hComboBox, CB_GETLBTEXT, nComboIdx[i], (LPARAM) & szTmp[0]);
if (szTmp[0] != 0)
{
- char q[MAX_PATH * 2] = { 0 };
- XmlQuoteText (szTmp, q, sizeof (q));
+ wchar_t q[MAX_PATH * 2] = { 0 };
+ XmlQuoteTextW (szTmp, q, sizeof (q));
- fprintf (f, "\n\t\t<volume>%s</volume>", q);
+ fwprintf (f, L"\n\t\t<volume>%s</volume>", q);
}
}
- fputs ("\n\t</history>", f);
+ fputws (L"\n\t</history>", f);
XmlWriteFooter (f);
fclose (f);
}
diff --git a/src/Common/Combo.h b/src/Common/Combo.h
index 9bd67a9..f4889fc 100644
--- a/src/Common/Combo.h
+++ b/src/Common/Combo.h
@@ -15,7 +15,7 @@
extern "C" {
#endif
-void AddComboItem (HWND hComboBox, char *lpszFileName, BOOL saveHistory);
+void AddComboItem (HWND hComboBox, const wchar_t *lpszFileName, BOOL saveHistory);
LPARAM MoveEditToCombo (HWND hComboBox, BOOL saveHistory);
int GetOrderComboIdx ( HWND hComboBox , int *nIdxList , int nElems );
LPARAM UpdateComboOrder ( HWND hComboBox );
diff --git a/src/Common/Crypto.c b/src/Common/Crypto.c
index ead091d..e7a40a3 100644
--- a/src/Common/Crypto.c
+++ b/src/Common/Crypto.c
@@ -44,9 +44,15 @@ static Cipher Ciphers[] =
{
// Block Size Key Size Key Schedule Size
// ID Name (Bytes) (Bytes) (Bytes)
+#ifdef TC_WINDOWS_BOOT
{ AES, "AES", 16, 32, AES_KS },
{ SERPENT, "Serpent", 16, 32, 140*4 },
{ TWOFISH, "Twofish", 16, 32, TWOFISH_KS },
+#else
+ { AES, L"AES", 16, 32, AES_KS },
+ { SERPENT, L"Serpent", 16, 32, 140*4 },
+ { TWOFISH, L"Twofish", 16, 32, TWOFISH_KS },
+#endif
{ 0, 0, 0, 0, 0 }
};
@@ -88,18 +94,17 @@ static EncryptionAlgorithm EncryptionAlgorithms[] =
};
-
+#ifndef TC_WINDOWS_BOOT
// Hash algorithms
static Hash Hashes[] =
{ // ID Name Deprecated System Encryption
-#ifndef TC_WINDOWS_BOOT
- { SHA512, "SHA-512", FALSE, FALSE },
- { WHIRLPOOL, "Whirlpool", FALSE, FALSE },
-#endif
- { SHA256, "SHA-256", FALSE, TRUE },
- { RIPEMD160, "RIPEMD-160", TRUE, TRUE },
+ { SHA512, L"SHA-512", FALSE, FALSE },
+ { WHIRLPOOL, L"Whirlpool", FALSE, FALSE },
+ { SHA256, L"SHA-256", FALSE, TRUE },
+ { RIPEMD160, L"RIPEMD-160", TRUE, TRUE },
{ 0, 0, 0 }
};
+#endif
/* Return values: 0 = success, ERR_CIPHER_INIT_FAILURE (fatal), ERR_CIPHER_INIT_WEAK_KEY (non-fatal) */
int CipherInit (int cipher, unsigned char *key, unsigned __int8 *ks)
@@ -279,17 +284,12 @@ Cipher *CipherGet (int id)
}
#ifndef TC_WINDOWS_BOOT
-const
-#endif
-char *CipherGetName (int cipherId)
+const wchar_t *CipherGetName (int cipherId)
{
-#ifdef TC_WINDOWS_BOOT
- return CipherGet (cipherId) -> Name;
-#else
Cipher* pCipher = CipherGet (cipherId);
- return pCipher? pCipher -> Name : "";
-#endif
+ return pCipher? pCipher -> Name : L"";
}
+#endif
int CipherGetBlockSize (int cipherId)
{
@@ -410,19 +410,19 @@ BOOL EAInitMode (PCRYPTO_INFO ci)
return TRUE;
}
-static void EAGetDisplayName(char *buf, int ea, int i)
+static void EAGetDisplayName(wchar_t *buf, int ea, int i)
{
- strcpy (buf, CipherGetName (i));
+ wcscpy (buf, CipherGetName (i));
if (i = EAGetPreviousCipher(ea, i))
{
- strcat (buf, "(");
- EAGetDisplayName (&buf[strlen(buf)], ea, i);
- strcat (buf, ")");
+ wcscat (buf, L"(");
+ EAGetDisplayName (&buf[wcslen(buf)], ea, i);
+ wcscat (buf, L")");
}
}
// Returns name of EA, cascaded cipher names are separated by hyphens
-char *EAGetName (char *buf, int ea, int guiDisplay)
+wchar_t *EAGetName (wchar_t *buf, int ea, int guiDisplay)
{
if (guiDisplay)
{
@@ -431,27 +431,27 @@ char *EAGetName (char *buf, int ea, int guiDisplay)
else
{
int i = EAGetLastCipher(ea);
- strcpy (buf, (i != 0) ? CipherGetName (i) : "?");
+ wcscpy (buf, (i != 0) ? CipherGetName (i) : L"?");
while (i = EAGetPreviousCipher(ea, i))
{
- strcat (buf, "-");
- strcat (buf, CipherGetName (i));
+ wcscat (buf, L"-");
+ wcscat (buf, CipherGetName (i));
}
}
return buf;
}
-int EAGetByName (char *name)
+int EAGetByName (wchar_t *name)
{
int ea = EAGetFirst ();
- char n[128];
+ wchar_t n[128];
do
{
EAGetName (n, ea, 1);
- if (_stricmp (n, name) == 0)
+ if (_wcsicmp (n, name) == 0)
return ea;
}
while (ea = EAGetNext (ea));
@@ -499,16 +499,16 @@ int EAGetNextMode (int ea, int previousModeId)
#ifndef TC_WINDOWS_BOOT
// Returns the name of the mode of operation of the whole EA
-char *EAGetModeName (int ea, int mode, BOOL capitalLetters)
+wchar_t *EAGetModeName (int ea, int mode, BOOL capitalLetters)
{
switch (mode)
{
case XTS:
- return "XTS";
+ return L"XTS";
}
- return "[unknown]";
+ return L"[unknown]";
}
#endif // TC_WINDOWS_BOOT
@@ -635,7 +635,7 @@ BOOL EAIsModeSupported (int ea, int testedMode)
return FALSE;
}
-
+#ifndef TC_WINDOWS_BOOT
Hash *HashGet (int id)
{
int i;
@@ -647,37 +647,29 @@ Hash *HashGet (int id)
}
-int HashGetIdByName (char *name)
+int HashGetIdByName (wchar_t *name)
{
int i;
for (i = 0; Hashes[i].Id != 0; i++)
- if (strcmp (Hashes[i].Name, name) == 0)
+ if (wcscmp (Hashes[i].Name, name) == 0)
return Hashes[i].Id;
return 0;
}
-#ifndef TC_WINDOWS_BOOT
-const
-#endif
-char *HashGetName (int hashId)
+const wchar_t *HashGetName (int hashId)
{
-#ifdef TC_WINDOWS_BOOT
- return HashGet(hashId) -> Name;
-#else
Hash* pHash = HashGet(hashId);
- return pHash? pHash -> Name : "";
-#endif
+ return pHash? pHash -> Name : L"";
}
-#ifndef TC_WINDOWS_BOOT
-void HashGetName2 (char *buf, int hashId)
+void HashGetName2 (wchar_t *buf, int hashId)
{
Hash* pHash = HashGet(hashId);
if (pHash)
- strcpy(buf, pHash -> Name);
+ wcscpy(buf, pHash -> Name);
else
- buf[0] = '\0';
+ buf[0] = L'\0';
}
BOOL HashIsDeprecated (int hashId)
diff --git a/src/Common/Crypto.h b/src/Common/Crypto.h
index 073616c..5153976 100644
--- a/src/Common/Crypto.h
+++ b/src/Common/Crypto.h
@@ -112,7 +112,11 @@ enum
typedef struct
{
int Id; // Cipher ID
+#ifdef TC_WINDOWS_BOOT
char *Name; // Name
+#else
+ wchar_t *Name; // Name
+#endif
int BlockSize; // Block size (bytes)
int KeySize; // Key size (bytes)
int KeyScheduleSize; // Scheduled key size (bytes)
@@ -125,13 +129,15 @@ typedef struct
int FormatEnabled;
} EncryptionAlgorithm;
+#ifndef TC_WINDOWS_BOOT
typedef struct
{
int Id; // Hash ID
- char *Name; // Name
+ wchar_t *Name; // Name
BOOL Deprecated;
BOOL SystemEncryption; // Available for system encryption
} Hash;
+#endif
// Maxium length of scheduled key
#if !defined (TC_WINDOWS_BOOT) || defined (TC_WINDOWS_BOOT_AES)
@@ -276,9 +282,8 @@ int CipherGetKeyScheduleSize (int cipher);
BOOL CipherSupportsIntraDataUnitParallelization (int cipher);
#ifndef TC_WINDOWS_BOOT
-const
+const wchar_t * CipherGetName (int cipher);
#endif
-char * CipherGetName (int cipher);
int CipherInit (int cipher, unsigned char *key, unsigned char *ks);
#ifndef TC_WINDOWS_BOOT_SINGLE_CIPHER_MODE
@@ -297,12 +302,16 @@ void DecipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount);
int EAGetFirst ();
int EAGetCount (void);
int EAGetNext (int previousEA);
-char * EAGetName (char *buf, int ea, int guiDisplay);
-int EAGetByName (char *name);
+#ifndef TC_WINDOWS_BOOT
+wchar_t * EAGetName (wchar_t *buf, int ea, int guiDisplay);
+int EAGetByName (wchar_t *name);
+#endif
int EAGetKeySize (int ea);
int EAGetFirstMode (int ea);
int EAGetNextMode (int ea, int previousModeId);
-char * EAGetModeName (int ea, int mode, BOOL capitalLetters);
+#ifndef TC_WINDOWS_BOOT
+wchar_t * EAGetModeName (int ea, int mode, BOOL capitalLetters);
+#endif
int EAGetKeyScheduleSize (int ea);
int EAGetLargestKey ();
int EAGetLargestKeyForMode (int mode);
@@ -317,13 +326,10 @@ BOOL EAIsModeSupported (int ea, int testedMode);
#ifndef TC_WINDOWS_BOOT
-const
-#endif
-char *HashGetName (int hash_algo_id);
+const wchar_t *HashGetName (int hash_algo_id);
-#ifndef TC_WINDOWS_BOOT
Hash *HashGet (int id);
-void HashGetName2 (char *buf, int hashId);
+void HashGetName2 (wchar_t *buf, int hashId);
BOOL HashIsDeprecated (int hashId);
BOOL HashForSystemEncryption (int hashId);
int GetMaxPkcs5OutSize (void);
diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c
index 65801be..48dc1dd 100644
--- a/src/Common/Dlgcode.c
+++ b/src/Common/Dlgcode.c
@@ -72,9 +72,9 @@ using namespace VeraCrypt;
LONG DriverVersion;
char *LastDialogId;
-char szHelpFile[TC_MAX_PATH];
-char szHelpFile2[TC_MAX_PATH];
-char SecurityTokenLibraryPath[TC_MAX_PATH];
+wchar_t szHelpFile[TC_MAX_PATH];
+wchar_t szHelpFile2[TC_MAX_PATH];
+wchar_t SecurityTokenLibraryPath[TC_MAX_PATH];
HFONT hFixedDigitFont = NULL;
HFONT hBoldFont = NULL;
@@ -170,9 +170,9 @@ BOOL bSysPartitionSelected = FALSE; /* TRUE if the user selected the system par
BOOL bSysDriveSelected = FALSE; /* TRUE if the user selected the system drive via the Select Device dialog */
/* To populate these arrays, call GetSysDevicePaths(). If they contain valid paths, bCachedSysDevicePathsValid is TRUE. */
-char SysPartitionDevicePath [TC_MAX_PATH];
-char SysDriveDevicePath [TC_MAX_PATH];
-string ExtraBootPartitionDevicePath;
+wchar_t SysPartitionDevicePath [TC_MAX_PATH];
+wchar_t SysDriveDevicePath [TC_MAX_PATH];
+wstring ExtraBootPartitionDevicePath;
char bCachedSysDevicePathsValid = FALSE;
BOOL bHyperLinkBeingTracked = FALSE;
@@ -219,7 +219,7 @@ enum
typedef struct
{
int id;
- char name[100];
+ wchar_t name[100];
unsigned __int64 encSpeed;
unsigned __int64 decSpeed;
unsigned __int64 meanBytesPerSec;
@@ -321,23 +321,23 @@ void cleanup ()
}
-void LowerCaseCopy (char *lpszDest, const char *lpszSource)
+void LowerCaseCopy (wchar_t *lpszDest, const wchar_t *lpszSource)
{
- size_t i = strlen (lpszSource) + 1;
+ size_t i = wcslen (lpszSource) + 1;
lpszDest[i - 1] = 0;
while (--i > 0)
{
- lpszDest[i - 1] = (char) tolower (lpszSource[i - 1]);
+ lpszDest[i - 1] = (wchar_t) towlower (lpszSource[i - 1]);
}
}
-void UpperCaseCopy (char *lpszDest, size_t cbDest, const char *lpszSource)
+void UpperCaseCopy (wchar_t *lpszDest, size_t cbDest, const wchar_t *lpszSource)
{
if (lpszDest && cbDest)
{
- size_t i = strlen (lpszSource);
+ size_t i = wcslen (lpszSource);
if (i >= cbDest)
i = cbDest - 1;
@@ -345,7 +345,7 @@ void UpperCaseCopy (char *lpszDest, size_t cbDest, const char *lpszSource)
i++;
while (--i > 0)
{
- lpszDest[i - 1] = (char) toupper (lpszSource[i - 1]);
+ lpszDest[i - 1] = (wchar_t) towupper (lpszSource[i - 1]);
}
}
}
@@ -362,16 +362,27 @@ std::string ToUpperCase (const std::string &str)
return u;
}
-size_t TrimWhiteSpace(char *str)
+std::wstring ToUpperCase (const std::wstring &str)
{
- char *end, *ptr = str;
+ wstring u;
+ foreach (wchar_t c, str)
+ {
+ u += (wchar_t) towupper (c);
+ }
+
+ return u;
+}
+
+size_t TrimWhiteSpace(wchar_t *str)
+{
+ wchar_t *end, *ptr = str;
size_t out_size;
if(!str || *str == 0)
return 0;
// Trim leading space
- while(isspace(*ptr)) ptr++;
+ while(iswspace(*ptr)) ptr++;
if(*ptr == 0) // All spaces?
{
@@ -380,32 +391,32 @@ size_t TrimWhiteSpace(char *str)
}
// Trim trailing space
- end = str + strlen(str) - 1;
- while(end > ptr && isspace(*end)) end--;
+ end = str + wcslen(str) - 1;
+ while(end > ptr && iswspace(*end)) end--;
end++;
// Set output size to trimmed string length
out_size = (end - ptr);
// Copy trimmed string and add null terminator
- memmove(str, ptr, out_size);
+ wmemmove(str, ptr, out_size);
str[out_size] = 0;
return out_size;
}
// check the validity of a file name
-BOOL IsValidFileName(const char* str)
+BOOL IsValidFileName(const wchar_t* str)
{
- static char invalidChars[9] = {'<', '>', ':', '"', '/', '\\', '|', '?', '*'};
- char c;
+ static wchar_t invalidChars[9] = {L'<', L'>', L':', L'"', L'/', L'\\', L'|', L'?', L'*'};
+ wchar_t c;
int i;
BOOL bNotDotOnly = FALSE;
while ((c = *str))
{
- if (c != '.')
+ if (c != L'.')
bNotDotOnly = TRUE;
- for (i= 0; i < sizeof(invalidChars); i++)
+ for (i= 0; i < ARRAYSIZE(invalidChars); i++)
if (c == invalidChars[i])
return FALSE;
str++;
@@ -414,38 +425,38 @@ BOOL IsValidFileName(const char* str)
return bNotDotOnly;
}
-BOOL IsVolumeDeviceHosted (const char *lpszDiskFile)
+BOOL IsVolumeDeviceHosted (const wchar_t *lpszDiskFile)
{
- return strstr (lpszDiskFile, "\\Device\\") == lpszDiskFile
- || strstr (lpszDiskFile, "\\DEVICE\\") == lpszDiskFile;
+ return wcsstr (lpszDiskFile, L"\\Device\\") == lpszDiskFile
+ || wcsstr (lpszDiskFile, L"\\DEVICE\\") == lpszDiskFile;
}
-void CreateFullVolumePath (char *lpszDiskFile, size_t cbDiskFile, const char *lpszFileName, BOOL * bDevice)
+void CreateFullVolumePath (wchar_t *lpszDiskFile, size_t cbDiskFile, const wchar_t *lpszFileName, BOOL * bDevice)
{
UpperCaseCopy (lpszDiskFile, cbDiskFile, lpszFileName);
*bDevice = FALSE;
- if (memcmp (lpszDiskFile, "\\DEVICE", sizeof (char) * 7) == 0)
+ if (wmemcmp (lpszDiskFile, L"\\DEVICE", 7) == 0)
{
*bDevice = TRUE;
}
- StringCbCopyA (lpszDiskFile, cbDiskFile, lpszFileName);
+ StringCbCopyW (lpszDiskFile, cbDiskFile, lpszFileName);
#if _DEBUG
- OutputDebugString ("CreateFullVolumePath: ");
+ OutputDebugString (L"CreateFullVolumePath: ");
OutputDebugString (lpszDiskFile);
- OutputDebugString ("\n");
+ OutputDebugString (L"\n");
#endif
}
-int FakeDosNameForDevice (const char *lpszDiskFile , char *lpszDosDevice , size_t cbDosDevice, char *lpszCFDevice , size_t cbCFDevice, BOOL bNameOnly)
+int FakeDosNameForDevice (const wchar_t *lpszDiskFile , wchar_t *lpszDosDevice , size_t cbDosDevice, wchar_t *lpszCFDevice , size_t cbCFDevice, BOOL bNameOnly)
{
BOOL bDosLinkCreated = TRUE;
- StringCbPrintfA (lpszDosDevice, cbDosDevice,"veracrypt%lu", GetCurrentProcessId ());
+ StringCbPrintfW (lpszDosDevice, cbDosDevice,L"veracrypt%lu", GetCurrentProcessId ());
if (bNameOnly == FALSE)
bDosLinkCreated = DefineDosDevice (DDD_RAW_TARGET_PATH, lpszDosDevice, lpszDiskFile);
@@ -453,12 +464,12 @@ int FakeDosNameForDevice (const char *lpszDiskFile , char *lpszDosDevice , size_
if (bDosLinkCreated == FALSE)
return ERR_OS_ERROR;
else
- StringCbPrintfA (lpszCFDevice, cbCFDevice,"\\\\.\\%s", lpszDosDevice);
+ StringCbPrintfW (lpszCFDevice, cbCFDevice,L"\\\\.\\%s", lpszDosDevice);
return 0;
}
-int RemoveFakeDosName (char *lpszDiskFile, char *lpszDosDevice)
+int RemoveFakeDosName (wchar_t *lpszDiskFile, wchar_t *lpszDosDevice)
{
BOOL bDosLinkRemoved = DefineDosDevice (DDD_RAW_TARGET_PATH | DDD_EXACT_MATCH_ON_REMOVE |
DDD_REMOVE_DEFINITION, lpszDosDevice, lpszDiskFile);
@@ -700,9 +711,9 @@ int GetTextGfxHeight (HWND hwndDlgItem, const wchar_t *text, HFONT hFont)
}
-std::string FitPathInGfxWidth (HWND hwnd, HFONT hFont, LONG width, const std::string &path)
+std::wstring FitPathInGfxWidth (HWND hwnd, HFONT hFont, LONG width, const std::wstring &path)
{
- string newPath;
+ wstring newPath;
RECT rect;
rect.left = 0;
@@ -713,8 +724,8 @@ std::string FitPathInGfxWidth (HWND hwnd, HFONT hFont, LONG width, const std::st
HDC hdc = GetDC (hwnd);
SelectObject (hdc, (HGDIOBJ) hFont);
- char pathBuf[TC_MAX_PATH];
- strcpy_s (pathBuf, sizeof (pathBuf), path.c_str());
+ wchar_t pathBuf[TC_MAX_PATH];
+ StringCbCopyW (pathBuf, sizeof (pathBuf), path.c_str());
if (DrawText (hdc, pathBuf, (int) path.size(), &rect, DT_CALCRECT | DT_MODIFYSTRING | DT_PATH_ELLIPSIS | DT_SINGLELINE) != 0)
newPath = pathBuf;
@@ -964,13 +975,13 @@ BOOL CALLBACK AboutDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam
{
case WM_INITDIALOG:
{
- char szTmp[100];
+ wchar_t szTmp[100];
RECT rec;
LocalizeDialog (hwndDlg, "IDD_ABOUT_DLG");
// Hyperlink
- SetWindowText (GetDlgItem (hwndDlg, IDC_HOMEPAGE), "www.idrix.fr");
+ SetWindowText (GetDlgItem (hwndDlg, IDC_HOMEPAGE), L"www.idrix.fr");
ToHyperlink (hwndDlg, IDC_HOMEPAGE);
// Logo area background (must not keep aspect ratio; must retain Windows-imposed distortion)
@@ -990,14 +1001,14 @@ BOOL CALLBACK AboutDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam
// Version
SendMessage (GetDlgItem (hwndDlg, IDT_ABOUT_VERSION), WM_SETFONT, (WPARAM) hUserBoldFont, 0);
- StringCbPrintfA (szTmp, sizeof(szTmp), "VeraCrypt %s", VERSION_STRING);
+ StringCbPrintfW (szTmp, sizeof(szTmp), L"VeraCrypt %s", _T(VERSION_STRING));
#ifdef _WIN64
- StringCbCatA (szTmp, sizeof(szTmp), " (64-bit)");
+ StringCbCatW (szTmp, sizeof(szTmp), L" (64-bit)");
#else
- StringCbCatA (szTmp, sizeof(szTmp), " (32-bit)");
+ StringCbCatW (szTmp, sizeof(szTmp), L" (32-bit)");
#endif
#if (defined(_DEBUG) || defined(DEBUG))
- StringCbCatA (szTmp, sizeof(szTmp), " (debug)");
+ StringCbCatW (szTmp, sizeof(szTmp), L" (debug)");
#endif
SetDlgItemText (hwndDlg, IDT_ABOUT_VERSION, szTmp);
SetDlgItemText (hwndDlg, IDT_ABOUT_RELEASE, TC_STR_RELEASED_BY);
@@ -1010,19 +1021,19 @@ BOOL CALLBACK AboutDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam
case WM_APP:
SetWindowText (GetDlgItem (hwndDlg, IDC_ABOUT_CREDITS),
- "Based on TrueCrypt 7.1a, freely available at http://www.truecrypt.org/ .\r\n\r\n"
+ L"Based on TrueCrypt 7.1a, freely available at http://www.truecrypt.org/ .\r\n\r\n"
- "Portions of this software:\r\n"
- "Copyright \xA9 2013-2015 IDRIX. All rights reserved.\r\n"
- "Copyright \xA9 2003-2012 TrueCrypt Developers Association. All Rights Reserved.\r\n"
- "Copyright \xA9 1998-2000 Paul Le Roux. All Rights Reserved.\r\n"
- "Copyright \xA9 1998-2008 Brian Gladman. All Rights Reserved.\r\n"
- "Copyright \xA9 2002-2004 Mark Adler. All Rights Reserved.\r\n\r\n"
+ L"Portions of this software:\r\n"
+ L"Copyright \xA9 2013-2015 IDRIX. All rights reserved.\r\n"
+ L"Copyright \xA9 2003-2012 TrueCrypt Developers Association. All Rights Reserved.\r\n"
+ L"Copyright \xA9 1998-2000 Paul Le Roux. All Rights Reserved.\r\n"
+ L"Copyright \xA9 1998-2008 Brian Gladman. All Rights Reserved.\r\n"
+ L"Copyright \xA9 2002-2004 Mark Adler. All Rights Reserved.\r\n\r\n"
- "This software as a whole:\r\n"
- "Copyright \xA9 2013-2015 IDRIX. All rights reserved.\r\n\r\n"
+ L"This software as a whole:\r\n"
+ L"Copyright \xA9 2013-2015 IDRIX. All rights reserved.\r\n\r\n"
- "An IDRIX Release");
+ L"An IDRIX Release");
return 1;
@@ -1137,7 +1148,7 @@ void CheckButton (HWND hButton)
}
-void LeftPadString (char *szTmp, int len, int targetLen, char filler)
+void LeftPadString (wchar_t *szTmp, int len, int targetLen, wchar_t filler)
{
int i;
@@ -1147,62 +1158,10 @@ void LeftPadString (char *szTmp, int len, int targetLen, char filler)
for (i = targetLen-1; i >= (targetLen-len); i--)
szTmp [i] = szTmp [i-(targetLen-len)];
- memset (szTmp, filler, targetLen-len);
+ wmemset (szTmp, filler, targetLen-len);
szTmp [targetLen] = 0;
}
-
-/*****************************************************************************
- ToSBCS: converts a unicode string to Single Byte Character String (SBCS).
- ***************************************************************************/
-
-void ToSBCS (LPWSTR lpszText, size_t cbSize)
-{
- if (lpszText)
- {
- int j = (int) wcslen (lpszText);
- if (j == 0)
- {
- *((char *) lpszText) = 0;
- return;
- }
- else
- {
- char *lpszNewText = (char *) err_malloc (j + 1);
- j = WideCharToMultiByte (CP_ACP, 0L, lpszText, -1, lpszNewText, j + 1, NULL, NULL);
- if (j > 0)
- StringCbCopyA ((char *) lpszText, cbSize, lpszNewText);
- else
- *((char *) lpszText) = 0;
- free (lpszNewText);
- }
- }
-}
-
-/*****************************************************************************
- ToUNICODE: converts a SBCS string to a UNICODE string.
- ***************************************************************************/
-
-void ToUNICODE (char *lpszText, size_t cbSize)
-{
- int j = (int) strlen (lpszText);
- if (j == 0)
- {
- StringCbCopyW ((LPWSTR) lpszText, cbSize, (LPWSTR) WIDE (""));
- return;
- }
- else
- {
- LPWSTR lpszNewText = (LPWSTR) err_malloc ((j + 1) * 2);
- j = MultiByteToWideChar (CP_ACP, 0L, lpszText, -1, lpszNewText, j + 1);
- if (j > 0)
- StringCbCopyW ((LPWSTR) lpszText, cbSize, lpszNewText);
- else
- StringCbCopyW ((LPWSTR) lpszText, cbSize, (LPWSTR) WIDE (""));
- free (lpszNewText);
- }
-}
-
/* InitDialog - initialize the applications main dialog, this function should
be called only once in the dialogs WM_INITDIALOG message handler */
void InitDialog (HWND hwndDlg)
@@ -1333,7 +1292,7 @@ void InitDialog (HWND hwndDlg)
if (!aboutMenuAppended)
{
hMenu = GetSystemMenu (hwndDlg, FALSE);
- AppendMenu (hMenu, MF_SEPARATOR, 0, "");
+ AppendMenu (hMenu, MF_SEPARATOR, 0, L"");
AppendMenuW (hMenu, MF_ENABLED | MF_STRING, IDC_ABOUT, GetString ("ABOUTBOX"));
aboutMenuAppended = TRUE;
@@ -1354,7 +1313,7 @@ void ProcessPaintMessages (HWND hwnd, int maxMessagesToProcess)
}
-HDC CreateMemBitmap (HINSTANCE hInstance, HWND hwnd, char *resource)
+HDC CreateMemBitmap (HINSTANCE hInstance, HWND hwnd, wchar_t *resource)
{
HBITMAP picture = LoadBitmap (hInstance, resource);
HDC viewDC = GetDC (hwnd), dcMem;
@@ -1384,7 +1343,7 @@ deleted by calling DeleteObject() with the handle passed as the parameter.
Known Windows issues:
- For some reason, anti-aliasing is not applied if the source bitmap contains less than 16K pixels.
- Windows 2000 may produce slightly inaccurate colors even when source, buffer, and target are 24-bit true color. */
-HBITMAP RenderBitmap (char *resource, HWND hwndDest, int x, int y, int nWidth, int nHeight, BOOL bDirectRender, BOOL bKeepAspectRatio)
+HBITMAP RenderBitmap (wchar_t *resource, HWND hwndDest, int x, int y, int nWidth, int nHeight, BOOL bDirectRender, BOOL bKeepAspectRatio)
{
LRESULT lResult = 0;
@@ -1711,15 +1670,15 @@ wchar_t *GetWipeModeName (WipeAlgorithmId modeId)
}
}
-wchar_t *GetPathType (const char *path, BOOL bUpperCase, BOOL *bIsPartition)
+wchar_t *GetPathType (const wchar_t *path, BOOL bUpperCase, BOOL *bIsPartition)
{
- if (strstr (path, "Partition")
- && strstr (path, "Partition0") == NULL)
+ if (wcsstr (path, L"Partition")
+ && wcsstr (path, L"Partition0") == NULL)
{
*bIsPartition = TRUE;
return GetString (bUpperCase ? "PARTITION_UPPER_CASE" : "PARTITION_LOWER_CASE");
}
- else if (strstr (path, "HarddiskVolume"))
+ else if (wcsstr (path, L"HarddiskVolume"))
{
*bIsPartition = TRUE;
return GetString (bUpperCase ? "VOLUME_UPPER_CASE" : "VOLUME_LOWER_CASE");
@@ -2088,7 +2047,7 @@ BOOL IsTrueCryptInstallerRunning (void)
// Returns TRUE if the mutex is (or had been) successfully acquired (otherwise FALSE).
-BOOL TCCreateMutex (volatile HANDLE *hMutex, char *name)
+BOOL TCCreateMutex (volatile HANDLE *hMutex, wchar_t *name)
{
if (*hMutex != NULL)
return TRUE; // This instance already has the mutex
@@ -2128,7 +2087,7 @@ void TCCloseMutex (volatile HANDLE *hMutex)
// Returns TRUE if a process running on the system has the specified mutex (otherwise FALSE).
-BOOL MutexExistsOnSystem (char *name)
+BOOL MutexExistsOnSystem (wchar_t *name)
{
if (name[0] == 0)
return FALSE;
@@ -2156,7 +2115,7 @@ uint32 ReadDriverConfigurationFlags ()
{
DWORD configMap;
- if (!ReadLocalMachineRegistryDword ("SYSTEM\\CurrentControlSet\\Services\\veracrypt", TC_DRIVER_CONFIG_REG_VALUE_NAME, &configMap))
+ if (!ReadLocalMachineRegistryDword (L"SYSTEM\\CurrentControlSet\\Services\\veracrypt", TC_DRIVER_CONFIG_REG_VALUE_NAME, &configMap))
configMap = 0;
return configMap;
@@ -2167,7 +2126,7 @@ uint32 ReadEncryptionThreadPoolFreeCpuCountLimit ()
{
DWORD count;
- if (!ReadLocalMachineRegistryDword ("SYSTEM\\CurrentControlSet\\Services\\veracrypt", TC_ENCRYPTION_FREE_CPU_COUNT_REG_VALUE_NAME, &count))
+ if (!ReadLocalMachineRegistryDword (L"SYSTEM\\CurrentControlSet\\Services\\veracrypt", TC_ENCRYPTION_FREE_CPU_COUNT_REG_VALUE_NAME, &count))
count = 0;
return count;
@@ -2260,13 +2219,13 @@ int LoadNonSysInPlaceEncSettings (WipeAlgorithmId *wipeAlgorithm)
void RemoveNonSysInPlaceEncNotifications (void)
{
if (FileExists (GetConfigPath (TC_APPD_FILENAME_NONSYS_INPLACE_ENC)))
- remove (GetConfigPath (TC_APPD_FILENAME_NONSYS_INPLACE_ENC));
+ _wremove (GetConfigPath (TC_APPD_FILENAME_NONSYS_INPLACE_ENC));
if (FileExists (GetConfigPath (TC_APPD_FILENAME_NONSYS_INPLACE_ENC_WIPE)))
- remove (GetConfigPath (TC_APPD_FILENAME_NONSYS_INPLACE_ENC_WIPE));
+ _wremove (GetConfigPath (TC_APPD_FILENAME_NONSYS_INPLACE_ENC_WIPE));
if (!IsNonInstallMode () && SystemEncryptionStatus == SYSENC_STATUS_NONE)
- ManageStartupSeqWiz (TRUE, "");
+ ManageStartupSeqWiz (TRUE, L"");
}
@@ -2280,16 +2239,16 @@ void SavePostInstallTasksSettings (int command)
switch (command)
{
case TC_POST_INSTALL_CFG_REMOVE_ALL:
- remove (GetConfigPath (TC_APPD_FILENAME_POST_INSTALL_TASK_TUTORIAL));
- remove (GetConfigPath (TC_APPD_FILENAME_POST_INSTALL_TASK_RELEASE_NOTES));
+ _wremove (GetConfigPath (TC_APPD_FILENAME_POST_INSTALL_TASK_TUTORIAL));
+ _wremove (GetConfigPath (TC_APPD_FILENAME_POST_INSTALL_TASK_RELEASE_NOTES));
break;
case TC_POST_INSTALL_CFG_TUTORIAL:
- f = fopen (GetConfigPath (TC_APPD_FILENAME_POST_INSTALL_TASK_TUTORIAL), "w");
+ f = _wfopen (GetConfigPath (TC_APPD_FILENAME_POST_INSTALL_TASK_TUTORIAL), L"w");
break;
case TC_POST_INSTALL_CFG_RELEASE_NOTES:
- f = fopen (GetConfigPath (TC_APPD_FILENAME_POST_INSTALL_TASK_RELEASE_NOTES), "w");
+ f = _wfopen (GetConfigPath (TC_APPD_FILENAME_POST_INSTALL_TASK_RELEASE_NOTES), L"w");
break;
default:
@@ -2299,7 +2258,7 @@ void SavePostInstallTasksSettings (int command)
if (f == NULL)
return;
- if (fputs ("1", f) < 0)
+ if (fputws (L"1", f) < 0)
{
// Error
fclose (f);
@@ -2357,7 +2316,7 @@ void InitOSVersionInfo ()
OSVERSIONINFOEX osEx;
osEx.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
- GetVersionEx ((LPOSVERSIONINFOA) &osEx);
+ GetVersionEx ((LPOSVERSIONINFOW) &osEx);
if (osEx.wProductType == VER_NT_SERVER || osEx.wProductType == VER_NT_DOMAIN_CONTROLLER)
nCurrentOS = WIN_SERVER_2003;
@@ -2369,7 +2328,7 @@ void InitOSVersionInfo ()
OSVERSIONINFOEX osEx;
osEx.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
- GetVersionEx ((LPOSVERSIONINFOA) &osEx);
+ GetVersionEx ((LPOSVERSIONINFOW) &osEx);
if (osEx.wProductType == VER_NT_SERVER || osEx.wProductType == VER_NT_DOMAIN_CONTROLLER)
nCurrentOS = WIN_SERVER_2008;
@@ -2395,11 +2354,11 @@ void InitOSVersionInfo ()
/* InitApp - initialize the application, this function is called once in the
applications WinMain function, but before the main dialog has been created */
-void InitApp (HINSTANCE hInstance, char *lpszCommandLine)
+void InitApp (HINSTANCE hInstance, wchar_t *lpszCommandLine)
{
WNDCLASSW wc;
char langId[6];
- char dllPath[MAX_PATH];
+ wchar_t dllPath[MAX_PATH];
/* Save the instance handle for later */
hInst = hInstance;
@@ -2412,7 +2371,7 @@ void InitApp (HINSTANCE hInstance, char *lpszCommandLine)
#ifndef SETUP
// Application ID
typedef HRESULT (WINAPI *SetAppId_t) (PCWSTR appID);
- SetAppId_t setAppId = (SetAppId_t) GetProcAddress (GetModuleHandle ("shell32.dll"), "SetCurrentProcessExplicitAppUserModelID");
+ SetAppId_t setAppId = (SetAppId_t) GetProcAddress (GetModuleHandle (L"shell32.dll"), "SetCurrentProcessExplicitAppUserModelID");
if (setAppId)
setAppId (TC_APPLICATION_ID);
@@ -2446,11 +2405,11 @@ void InitApp (HINSTANCE hInstance, char *lpszCommandLine)
// A new instance of the application must be created with elevated privileges.
if (IsNonInstallMode () && !IsAdmin () && IsUacSupported ())
{
- char modPath[MAX_PATH], newCmdLine[4096];
+ wchar_t modPath[MAX_PATH], newCmdLine[4096];
WNDCLASSEXW wcex;
HWND hWnd;
- if (strstr (lpszCommandLine, "/q UAC ") == lpszCommandLine)
+ if (wcsstr (lpszCommandLine, L"/q UAC ") == lpszCommandLine)
{
Error ("UAC_INIT_ERROR", NULL);
exit (1);
@@ -2473,12 +2432,12 @@ void InitApp (HINSTANCE hInstance, char *lpszCommandLine)
SetLayeredWindowAttributes (hWnd, 0, 0, LWA_ALPHA);
ShowWindow (hWnd, SW_SHOWNORMAL);
- GetModuleFileName (NULL, modPath, sizeof (modPath));
+ GetModuleFileNameW (NULL, modPath, ARRAYSIZE (modPath));
- StringCbCopyA (newCmdLine, sizeof(newCmdLine), "/q UAC ");
- StringCbCatA (newCmdLine, sizeof (newCmdLine), lpszCommandLine);
+ StringCbCopyW (newCmdLine, sizeof(newCmdLine), L"/q UAC ");
+ StringCbCatW (newCmdLine, sizeof (newCmdLine), lpszCommandLine);
- if ((int)ShellExecute (hWnd, "runas", modPath, newCmdLine, NULL, SW_SHOWNORMAL) <= 32)
+ if ((int)ShellExecuteW (hWnd, L"runas", modPath, newCmdLine, NULL, SW_SHOWNORMAL) <= 32)
exit (1);
Sleep (2000);
@@ -2503,7 +2462,7 @@ void InitApp (HINSTANCE hInstance, char *lpszCommandLine)
// Service pack check & warnings about critical MS issues
osEx.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
- if (GetVersionEx ((LPOSVERSIONINFOA) &osEx) != 0)
+ if (GetVersionEx ((LPOSVERSIONINFOW) &osEx) != 0)
{
CurrentOSServicePack = osEx.wServicePackMajor;
switch (nCurrentOS)
@@ -2516,9 +2475,9 @@ void InitApp (HINSTANCE hInstance, char *lpszCommandLine)
DWORD val = 0, size = sizeof(val);
HKEY hkey;
- if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\Atapi\\Parameters", 0, KEY_READ, &hkey) == ERROR_SUCCESS)
+ if (RegOpenKeyExW (HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\Atapi\\Parameters", 0, KEY_READ, &hkey) == ERROR_SUCCESS)
{
- if (RegQueryValueEx (hkey, "EnableBigLba", 0, 0, (LPBYTE) &val, &size) != ERROR_SUCCESS
+ if (RegQueryValueExW (hkey, L"EnableBigLba", 0, 0, (LPBYTE) &val, &size) != ERROR_SUCCESS
|| val != 1)
{
Warning ("LARGE_IDE_WARNING_2K_REGISTRY", NULL);
@@ -2533,7 +2492,7 @@ void InitApp (HINSTANCE hInstance, char *lpszCommandLine)
{
HKEY k;
// PE environment does not report version of SP
- if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Control\\minint", 0, KEY_READ, &k) != ERROR_SUCCESS)
+ if (RegOpenKeyExW (HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\minint", 0, KEY_READ, &k) != ERROR_SUCCESS)
Warning ("LARGE_IDE_WARNING_XP", NULL);
else
RegCloseKey (k);
@@ -2581,9 +2540,9 @@ void InitApp (HINSTANCE hInstance, char *lpszCommandLine)
}
if (GetSystemDirectory(dllPath, MAX_PATH))
- StringCbCatA(dllPath, sizeof(dllPath), "\\Riched20.dll");
+ StringCbCatW(dllPath, sizeof(dllPath), L"\\Riched20.dll");
else
- StringCbCopyA(dllPath, sizeof(dllPath), "c:\\Windows\\System32\\Riched20.dll");
+ StringCbCopyW(dllPath, sizeof(dllPath), L"c:\\Windows\\System32\\Riched20.dll");
// Required for RichEdit text fields to work
if ((hRichEditDll = LoadLibrary(dllPath)) == NULL)
{
@@ -2623,13 +2582,13 @@ void FinalizeApp (void)
void InitHelpFileName (void)
{
- char *lpszTmp;
+ wchar_t *lpszTmp;
- GetModuleFileName (NULL, szHelpFile, sizeof (szHelpFile));
- lpszTmp = strrchr (szHelpFile, '\\');
+ GetModuleFileNameW (NULL, szHelpFile, ARRAYSIZE (szHelpFile));
+ lpszTmp = wcsrchr (szHelpFile, L'\\');
if (lpszTmp)
{
- char szTemp[TC_MAX_PATH];
+ wchar_t szTemp[TC_MAX_PATH];
++lpszTmp;
*lpszTmp = 0; // add null terminating character to prepare for append operations
@@ -2638,34 +2597,33 @@ void InitHelpFileName (void)
if (strcmp (GetPreferredLangId(), "en") == 0
|| strlen(GetPreferredLangId()) == 0)
{
- StringCbCatA (szHelpFile, sizeof(szHelpFile), "VeraCrypt User Guide.pdf");
+ StringCbCatW (szHelpFile, sizeof(szHelpFile), L"VeraCrypt User Guide.pdf");
}
else
{
- StringCbPrintfA (szTemp, sizeof(szTemp), "VeraCrypt User Guide.%s.pdf", GetPreferredLangId());
- StringCbCatA (szHelpFile, sizeof(szHelpFile), szTemp);
+ StringCbPrintfW (szTemp, sizeof(szTemp), L"VeraCrypt User Guide.%S.pdf", GetPreferredLangId());
+ StringCbCatW (szHelpFile, sizeof(szHelpFile), szTemp);
}
// Secondary file name (used when localized documentation is not found).
- GetModuleFileName (NULL, szHelpFile2, sizeof (szHelpFile2));
- lpszTmp = strrchr (szHelpFile2, '\\');
+ GetModuleFileNameW (NULL, szHelpFile2, ARRAYSIZE (szHelpFile2));
+ lpszTmp = wcsrchr (szHelpFile2, L'\\');
if (lpszTmp)
{
++lpszTmp;
*lpszTmp = 0;
- StringCbCatA (szHelpFile2, sizeof(szHelpFile2), "VeraCrypt User Guide.pdf");
+ StringCbCatW (szHelpFile2, sizeof(szHelpFile2), L"VeraCrypt User Guide.pdf");
}
}
}
-BOOL OpenDevice (const char *lpszPath, OPEN_TEST_STRUCT *driver, BOOL detectFilesystem)
+BOOL OpenDevice (const wchar_t *lpszPath, OPEN_TEST_STRUCT *driver, BOOL detectFilesystem)
{
DWORD dwResult;
BOOL bResult;
wchar_t wszFileName[TC_MAX_PATH];
- StringCbCopyA ((char *) &wszFileName[0], sizeof(wszFileName), lpszPath);
- ToUNICODE ((char *) &wszFileName[0], sizeof(wszFileName));
+ StringCbCopyW (wszFileName, sizeof(wszFileName), lpszPath);
memset (driver, 0, sizeof (OPEN_TEST_STRUCT));
memcpy (driver->wszFileName, wszFileName, sizeof (wszFileName));
@@ -2743,13 +2701,13 @@ executions complete very fast. Returns TRUE if successful (otherwise FALSE). */
BOOL GetSysDevicePaths (HWND hwndDlg)
{
if (!bCachedSysDevicePathsValid
- || strlen (SysPartitionDevicePath) <= 1
- || strlen (SysDriveDevicePath) <= 1)
+ || wcslen (SysPartitionDevicePath) <= 1
+ || wcslen (SysDriveDevicePath) <= 1)
{
foreach (const HostDevice &device, GetAvailableHostDevices (false, true))
{
if (device.ContainsSystem)
- strcpy_s (device.IsPartition ? SysPartitionDevicePath : SysDriveDevicePath, TC_MAX_PATH, device.Path.c_str());
+ StringCchCopyW (device.IsPartition ? SysPartitionDevicePath : SysDriveDevicePath, TC_MAX_PATH, device.Path.c_str());
}
if (IsOSAtLeast (WIN_7))
@@ -2777,8 +2735,8 @@ BOOL GetSysDevicePaths (HWND hwndDlg)
}
return (bCachedSysDevicePathsValid
- && strlen (SysPartitionDevicePath) > 1
- && strlen (SysDriveDevicePath) > 1);
+ && wcslen (SysPartitionDevicePath) > 1
+ && wcslen (SysDriveDevicePath) > 1);
}
/* Determines whether the device path is the path of the system partition or of the system drive (or neither).
@@ -2800,7 +2758,7 @@ Return codes:
3 - it is the extra boot partition path
0 - it's not the system partition/drive path
-1 - the result can't be determined, isn't reliable, or there was an error. */
-int IsSystemDevicePath (const char *path, HWND hwndDlg, BOOL bReliableRequired)
+int IsSystemDevicePath (const wchar_t *path, HWND hwndDlg, BOOL bReliableRequired)
{
if (!bCachedSysDevicePathsValid
&& bReliableRequired)
@@ -2809,15 +2767,15 @@ int IsSystemDevicePath (const char *path, HWND hwndDlg, BOOL bReliableRequired)
return -1;
}
- if (strlen (SysPartitionDevicePath) <= 1 || strlen (SysDriveDevicePath) <= 1)
+ if (wcslen (SysPartitionDevicePath) <= 1 || wcslen (SysDriveDevicePath) <= 1)
return -1;
if (!path)
return -1;
- if (strncmp (path, SysPartitionDevicePath, max (strlen(path), strlen(SysPartitionDevicePath))) == 0)
+ if (wcsncmp (path, SysPartitionDevicePath, max (wcslen(path), wcslen(SysPartitionDevicePath))) == 0)
return 1;
- else if (strncmp (path, SysDriveDevicePath, max (strlen(path), strlen(SysDriveDevicePath))) == 0)
+ else if (wcsncmp (path, SysDriveDevicePath, max (wcslen(path), wcslen(SysDriveDevicePath))) == 0)
return 2;
else if (ExtraBootPartitionDevicePath == path)
return 3;
@@ -2833,42 +2791,43 @@ Return codes:
0 - it isn't a non-system partition on the system drive
1 - it's a non-system partition on the system drive
-1 - the result can't be determined, isn't reliable, or there was an error. */
-int IsNonSysPartitionOnSysDrive (const char *path)
+int IsNonSysPartitionOnSysDrive (const wchar_t *path)
{
- char tmpPath [TC_MAX_PATH + 1];
+ wchar_t tmpPath [TC_MAX_PATH + 1];
int pos;
if (!GetSysDevicePaths (MainDlg))
return -1;
- if (strlen (SysPartitionDevicePath) <= 1 || strlen (SysDriveDevicePath) <= 1)
+ if (wcslen (SysPartitionDevicePath) <= 1 || wcslen (SysDriveDevicePath) <= 1)
return -1;
- if (strncmp (path, SysPartitionDevicePath, max (strlen(path), strlen(SysPartitionDevicePath))) == 0
- || strncmp (path, SysDriveDevicePath, max (strlen(path), strlen(SysDriveDevicePath))) == 0)
+ if (wcsncmp (path, SysPartitionDevicePath, max (wcslen(path), wcslen(SysPartitionDevicePath))) == 0
+ || wcsncmp (path, SysDriveDevicePath, max (wcslen(path), wcslen(SysDriveDevicePath))) == 0)
{
// It is the system partition/drive path (it isn't a non-system partition)
return 0;
}
memset (tmpPath, 0, sizeof (tmpPath));
- strncpy (tmpPath, path, sizeof (tmpPath) - 1);
+ wcsncpy (tmpPath, path, ARRAYSIZE (tmpPath) - 1);
- pos = (int) FindString (tmpPath, "Partition", (int) strlen (tmpPath), (int) strlen ("Partition"), 0);
+ pos = (int) FindString ((const char*) tmpPath, (const char*) L"Partition", (int) wcslen (tmpPath) * 2, (int) wcslen (L"Partition") * 2, 0);
if (pos < 0)
return -1;
+ pos /= 2;
pos += (int) strlen ("Partition");
- if (pos + 1 > sizeof (tmpPath) - 1)
+ if (pos + 1 > ARRAYSIZE (tmpPath) - 1)
return -1;
- tmpPath [pos] = '0';
+ tmpPath [pos] = L'0';
tmpPath [pos + 1] = 0;
- if (strncmp (tmpPath, SysDriveDevicePath, max (strlen(tmpPath), strlen(SysDriveDevicePath))) == 0)
+ if (wcsncmp (tmpPath, SysDriveDevicePath, max (wcslen(tmpPath), wcslen(SysDriveDevicePath))) == 0)
{
// It is a non-system partition on the system drive
return 1;
@@ -3004,19 +2963,19 @@ BOOL CALLBACK TextInfoDialogBoxDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, L
switch (nID)
{
case TC_TBXID_SYS_ENCRYPTION_PRETEST:
- PrintHardCopyTextUTF16 ((wchar_t *) GetSysEncryptionPretestInfo2String ().c_str(), "Pre-Boot Troubleshooting", GetSysEncryptionPretestInfo2String ().length () * 2);
+ PrintHardCopyTextUTF16 ((wchar_t *) GetSysEncryptionPretestInfo2String ().c_str(), L"Pre-Boot Troubleshooting", GetSysEncryptionPretestInfo2String ().length () * 2);
break;
case TC_TBXID_SYS_ENC_RESCUE_DISK:
- PrintHardCopyTextUTF16 ((wchar_t *) GetRescueDiskHelpString ().c_str(), "VeraCrypt Rescue Disk Help", GetRescueDiskHelpString ().length () * 2);
+ PrintHardCopyTextUTF16 ((wchar_t *) GetRescueDiskHelpString ().c_str(), L"VeraCrypt Rescue Disk Help", GetRescueDiskHelpString ().length () * 2);
break;
case TC_TBXID_DECOY_OS_INSTRUCTIONS:
- PrintHardCopyTextUTF16 ((wchar_t *) GetDecoyOsInstructionsString ().c_str(), "How to Create Decoy OS", GetDecoyOsInstructionsString ().length () * 2);
+ PrintHardCopyTextUTF16 ((wchar_t *) GetDecoyOsInstructionsString ().c_str(), L"How to Create Decoy OS", GetDecoyOsInstructionsString ().length () * 2);
break;
case TC_TBXID_EXTRA_BOOT_PARTITION_REMOVAL_INSTRUCTIONS:
- PrintHardCopyTextUTF16 (GetString ("EXTRA_BOOT_PARTITION_REMOVAL_INSTRUCTIONS"), "How to Remove Extra Boot Partition", wcslen (GetString ("EXTRA_BOOT_PARTITION_REMOVAL_INSTRUCTIONS")) * 2);
+ PrintHardCopyTextUTF16 (GetString ("EXTRA_BOOT_PARTITION_REMOVAL_INSTRUCTIONS"), L"How to Remove Extra Boot Partition", wcslen (GetString ("EXTRA_BOOT_PARTITION_REMOVAL_INSTRUCTIONS")) * 2);
break;
}
return 1;
@@ -3035,7 +2994,7 @@ BOOL CALLBACK TextInfoDialogBoxDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, L
r = GetLegalNotices ();
if (r != NULL)
{
- SetWindowText (GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT), r);
+ SetWindowTextA (GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT), r);
free (r);
}
break;
@@ -3080,7 +3039,7 @@ char * GetLegalNotices ()
char *buf = NULL;
if (resource == NULL)
- resource = (char *) MapResource ("Text", IDR_LICENSE, &size);
+ resource = (char *) MapResource (L"Text", IDR_LICENSE, &size);
if (resource != NULL)
{
@@ -3098,7 +3057,7 @@ char * GetLegalNotices ()
BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- static char *lpszFileName; // This is actually a pointer to a GLOBAL array
+ static wchar_t *lpszFileName; // This is actually a pointer to a GLOBAL array
static vector <HostDevice> devices;
static map <int, HostDevice> itemToDeviceMap;
@@ -3171,9 +3130,9 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
if (device.ContainsSystem)
{
if (device.IsPartition)
- strcpy_s (SysPartitionDevicePath, sizeof (SysPartitionDevicePath), device.Path.c_str());
+ StringCbCopyW (SysPartitionDevicePath, sizeof (SysPartitionDevicePath), device.Path.c_str());
else
- strcpy_s (SysDriveDevicePath, sizeof (SysDriveDevicePath), device.Path.c_str());
+ StringCbCopyW (SysDriveDevicePath, sizeof (SysDriveDevicePath), device.Path.c_str());
}
// Path
@@ -3184,13 +3143,13 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
if (line > 1)
{
- ListItemAdd (hList, item.iItem, "");
+ ListItemAdd (hList, item.iItem, L"");
item.iItem = line++;
}
if (device.Floppy || device.DynamicVolume)
{
- ListItemAdd (hList, item.iItem, (char *) device.Path.c_str());
+ ListItemAdd (hList, item.iItem, (wchar_t *) device.Path.c_str());
}
else
{
@@ -3203,12 +3162,12 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
if (!device.Partitions.empty())
StringCbCatW (s, sizeof(s), L":");
- ListItemAddW (hList, item.iItem, s);
+ ListItemAdd (hList, item.iItem, s);
}
}
else
{
- ListItemAdd (hList, item.iItem, (char *) device.Path.c_str());
+ ListItemAdd (hList, item.iItem, (wchar_t *) device.Path.c_str());
}
itemToDeviceMap[item.iItem] = device;
@@ -3218,23 +3177,23 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
{
wchar_t size[100] = { 0 };
GetSizeString (device.Size, size, sizeof(size));
- ListSubItemSetW (hList, item.iItem, 2, size);
+ ListSubItemSet (hList, item.iItem, 2, size);
}
// Mount point
if (!device.MountPoint.empty())
- ListSubItemSet (hList, item.iItem, 1, (char *) device.MountPoint.c_str());
+ ListSubItemSet (hList, item.iItem, 1, (wchar_t *) device.MountPoint.c_str());
// Label
if (!device.Name.empty())
- ListSubItemSetW (hList, item.iItem, 3, (wchar_t *) device.Name.c_str());
+ ListSubItemSet (hList, item.iItem, 3, (wchar_t *) device.Name.c_str());
#ifdef TCMOUNT
else
{
bool useInExplorer = false;
wstring favoriteLabel = GetFavoriteVolumeLabel (device.Path, useInExplorer);
if (!favoriteLabel.empty())
- ListSubItemSetW (hList, item.iItem, 3, (wchar_t *) favoriteLabel.c_str());
+ ListSubItemSet (hList, item.iItem, 3, (wchar_t *) favoriteLabel.c_str());
}
#endif
@@ -3298,7 +3257,7 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
return 1; // non-device line selected
const HostDevice selectedDevice = itemToDeviceMap[selectedItem];
- strcpy_s (lpszFileName, TC_MAX_PATH, selectedDevice.Path.c_str());
+ StringCchCopyW (lpszFileName, TC_MAX_PATH, selectedDevice.Path.c_str());
#ifdef VOLFORMAT
if (selectedDevice.ContainsSystem && selectedDevice.IsPartition)
@@ -3470,9 +3429,9 @@ BOOL DoDriverInstall (HWND hwndDlg)
StatusMessage (hwndDlg, "INSTALLING_DRIVER");
#endif
- hService = CreateService (hManager, "veracrypt", "veracrypt",
+ hService = CreateService (hManager, L"veracrypt", L"veracrypt",
SERVICE_ALL_ACCESS, SERVICE_KERNEL_DRIVER, SERVICE_SYSTEM_START, SERVICE_ERROR_NORMAL,
- "System32\\drivers\\veracrypt.sys",
+ L"System32\\drivers\\veracrypt.sys",
NULL, NULL, NULL, NULL, NULL);
if (hService == NULL)
@@ -3480,7 +3439,7 @@ BOOL DoDriverInstall (HWND hwndDlg)
else
CloseServiceHandle (hService);
- hService = OpenService (hManager, "veracrypt", SERVICE_ALL_ACCESS);
+ hService = OpenService (hManager, L"veracrypt", SERVICE_ALL_ACCESS);
if (hService == NULL)
goto error;
@@ -3519,25 +3478,25 @@ static int DriverLoad ()
HANDLE file;
WIN32_FIND_DATA find;
SC_HANDLE hManager, hService = NULL;
- char driverPath[TC_MAX_PATH*2];
+ wchar_t driverPath[TC_MAX_PATH*2];
BOOL res;
- char *tmp;
+ wchar_t *tmp;
DWORD startType;
- if (ReadLocalMachineRegistryDword ("SYSTEM\\CurrentControlSet\\Services\\veracrypt", "Start", &startType) && startType == SERVICE_BOOT_START)
+ if (ReadLocalMachineRegistryDword (L"SYSTEM\\CurrentControlSet\\Services\\veracrypt", L"Start", &startType) && startType == SERVICE_BOOT_START)
return ERR_PARAMETER_INCORRECT;
- GetModuleFileName (NULL, driverPath, sizeof (driverPath));
- tmp = strrchr (driverPath, '\\');
+ GetModuleFileName (NULL, driverPath, ARRAYSIZE (driverPath));
+ tmp = wcsrchr (driverPath, L'\\');
if (!tmp)
{
- driverPath[0] = '.';
+ driverPath[0] = L'.';
driverPath[1] = 0;
}
else
*tmp = 0;
- StringCbCatA (driverPath, sizeof(driverPath), !Is64BitOs () ? "\\veracrypt.sys" : "\\veracrypt-x64.sys");
+ StringCbCatW (driverPath, sizeof(driverPath), !Is64BitOs () ? L"\\veracrypt.sys" : L"\\veracrypt-x64.sys");
file = FindFirstFile (driverPath, &find);
@@ -3561,7 +3520,7 @@ static int DriverLoad ()
return ERR_OS_ERROR;
}
- hService = OpenService (hManager, "veracrypt", SERVICE_ALL_ACCESS);
+ hService = OpenService (hManager, L"veracrypt", SERVICE_ALL_ACCESS);
if (hService != NULL)
{
// Remove stale service (driver is not loaded but service exists)
@@ -3570,7 +3529,7 @@ static int DriverLoad ()
Sleep (500);
}
- hService = CreateService (hManager, "veracrypt", "veracrypt",
+ hService = CreateService (hManager, L"veracrypt", L"veracrypt",
SERVICE_ALL_ACCESS, SERVICE_KERNEL_DRIVER, SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL,
driverPath, NULL, NULL, NULL, NULL, NULL);
@@ -3647,7 +3606,7 @@ BOOL DriverUnload ()
if (hManager == NULL)
goto error;
- hService = OpenService (hManager, "veracrypt", SERVICE_ALL_ACCESS);
+ hService = OpenService (hManager, L"veracrypt", SERVICE_ALL_ACCESS);
if (hService == NULL)
goto error;
@@ -3821,30 +3780,29 @@ load:
void ResetCurrentDirectory ()
{
- char p[MAX_PATH];
+ wchar_t p[MAX_PATH];
if (!IsNonInstallMode () && SHGetFolderPath (NULL, CSIDL_PROFILE, NULL, 0, p) == ERROR_SUCCESS)
{
SetCurrentDirectory (p);
}
else
{
- GetModPath (p, sizeof (p));
+ GetModPath (p, ARRAYSIZE (p));
SetCurrentDirectory (p);
}
}
-BOOL BrowseFiles (HWND hwndDlg, char *stringId, char *lpszFileName, BOOL keepHistory, BOOL saveMode, wchar_t *browseFilter)
+BOOL BrowseFiles (HWND hwndDlg, char *stringId, wchar_t *lpszFileName, BOOL keepHistory, BOOL saveMode, wchar_t *browseFilter)
{
return BrowseFilesInDir (hwndDlg, stringId, NULL, lpszFileName, keepHistory, saveMode, browseFilter);
}
-BOOL BrowseFilesInDir (HWND hwndDlg, char *stringId, char *initialDir, char *lpszFileName, BOOL keepHistory, BOOL saveMode, wchar_t *browseFilter, const wchar_t *initialFileName, const wchar_t *defaultExtension)
+BOOL BrowseFilesInDir (HWND hwndDlg, char *stringId, wchar_t *initialDir, wchar_t *lpszFileName, BOOL keepHistory, BOOL saveMode, wchar_t *browseFilter, const wchar_t *initialFileName, const wchar_t *defaultExtension)
{
OPENFILENAMEW ofn;
wchar_t file[TC_MAX_PATH] = { 0 };
- wchar_t wInitialDir[TC_MAX_PATH] = { 0 };
wchar_t filter[1024];
BOOL status = FALSE;
@@ -3855,12 +3813,11 @@ BOOL BrowseFilesInDir (HWND hwndDlg, char *stringId, char *initialDir, char *lps
if (initialDir)
{
- swprintf_s (wInitialDir, sizeof (wInitialDir) / 2, L"%hs", initialDir);
- ofn.lpstrInitialDir = wInitialDir;
+ ofn.lpstrInitialDir = initialDir;
}
if (initialFileName)
- wcscpy_s (file, array_capacity (file), initialFileName);
+ StringCchCopyW (file, array_capacity (file), initialFileName);
ofn.lStructSize = sizeof (ofn);
ofn.hwndOwner = hwndDlg;
@@ -3897,7 +3854,7 @@ BOOL BrowseFilesInDir (HWND hwndDlg, char *stringId, char *initialDir, char *lps
SystemFileSelectorCallPending = FALSE;
- WideCharToMultiByte (CP_ACP, 0, file, -1, lpszFileName, MAX_PATH, NULL, NULL);
+ StringCchCopyW (lpszFileName, MAX_PATH, file);
if (!keepHistory)
CleanLastVisitedMRU ();
@@ -3913,13 +3870,12 @@ ret:
}
-static char SelectMultipleFilesPath[131072];
+static wchar_t SelectMultipleFilesPath[131072];
static int SelectMultipleFilesOffset;
-BOOL SelectMultipleFiles (HWND hwndDlg, const char *stringId, char *lpszFileName, size_t cbFileName,BOOL keepHistory)
+BOOL SelectMultipleFiles (HWND hwndDlg, const char *stringId, wchar_t *lpszFileName, size_t cbFileName,BOOL keepHistory)
{
OPENFILENAMEW ofn;
- wchar_t file[0xffff * 2] = { 0 }; // The size must not exceed 0xffff*2 due to a bug in Windows 2000 and XP SP1
wchar_t filter[1024];
BOOL status = FALSE;
@@ -3934,8 +3890,8 @@ BOOL SelectMultipleFiles (HWND hwndDlg, const char *stringId, char *lpszFileName
GetString ("ALL_FILES"), 0, 0, GetString ("TC_VOLUMES"), 0, 0, 0);
ofn.lpstrFilter = filter;
ofn.nFilterIndex = 1;
- ofn.lpstrFile = file;
- ofn.nMaxFile = sizeof (file) / sizeof (file[0]);
+ ofn.lpstrFile = SelectMultipleFilesPath;
+ ofn.nMaxFile = 0xffff * 2; // The size must not exceed 0xffff*2 due to a bug in Windows 2000 and XP SP1
ofn.lpstrTitle = GetString (stringId);
ofn.Flags = OFN_HIDEREADONLY
| OFN_EXPLORER
@@ -3954,24 +3910,15 @@ BOOL SelectMultipleFiles (HWND hwndDlg, const char *stringId, char *lpszFileName
SystemFileSelectorCallPending = FALSE;
- if (file[ofn.nFileOffset - 1] != 0)
+ if (SelectMultipleFilesPath[ofn.nFileOffset - 1] != 0)
{
// Single file selected
- WideCharToMultiByte (CP_ACP, 0, file, -1, lpszFileName, MAX_PATH, NULL, NULL);
+ StringCbCopyW (lpszFileName, cbFileName, SelectMultipleFilesPath);
SelectMultipleFilesOffset = 0;
}
else
{
// Multiple files selected
- int n;
- wchar_t *f = file;
- char *s = SelectMultipleFilesPath;
- while ((n = WideCharToMultiByte (CP_ACP, 0, f, -1, s, MAX_PATH, NULL, NULL)) > 1)
- {
- f += n;
- s += n;
- }
-
SelectMultipleFilesOffset = ofn.nFileOffset;
SelectMultipleFilesNext (lpszFileName, cbFileName);
}
@@ -3990,20 +3937,20 @@ ret:
}
-BOOL SelectMultipleFilesNext (char *lpszFileName, size_t cbFileName)
+BOOL SelectMultipleFilesNext (wchar_t *lpszFileName, size_t cbFileName)
{
if (SelectMultipleFilesOffset == 0)
return FALSE;
- StringCbCopyA (lpszFileName, cbFileName,SelectMultipleFilesPath);
+ StringCbCopyW (lpszFileName, cbFileName,SelectMultipleFilesPath);
lpszFileName[TC_MAX_PATH - 1] = 0;
- if (lpszFileName[strlen (lpszFileName) - 1] != '\\')
- StringCbCatA (lpszFileName, cbFileName,"\\");
+ if (lpszFileName[wcslen (lpszFileName) - 1] != L'\\')
+ StringCbCatW (lpszFileName, cbFileName,L"\\");
- StringCbCatA (lpszFileName, cbFileName,SelectMultipleFilesPath + SelectMultipleFilesOffset);
+ StringCbCatW (lpszFileName, cbFileName,SelectMultipleFilesPath + SelectMultipleFilesOffset);
- SelectMultipleFilesOffset += (int) strlen (SelectMultipleFilesPath + SelectMultipleFilesOffset) + 1;
+ SelectMultipleFilesOffset += (int) wcslen (SelectMultipleFilesPath + SelectMultipleFilesOffset) + 1;
if (SelectMultipleFilesPath[SelectMultipleFilesOffset] == 0)
SelectMultipleFilesOffset = 0;
@@ -4018,13 +3965,13 @@ static int CALLBACK BrowseCallbackProc(HWND hwnd,UINT uMsg,LPARAM lp, LPARAM pDa
{
/* WParam is TRUE since we are passing a path.
It would be FALSE if we were passing a pidl. */
- SendMessage (hwnd,BFFM_SETSELECTION,TRUE,(LPARAM)pData);
+ SendMessageW (hwnd,BFFM_SETSELECTION,TRUE,(LPARAM)pData);
break;
}
case BFFM_SELCHANGED:
{
- char szDir[TC_MAX_PATH];
+ wchar_t szDir[TC_MAX_PATH];
/* Set the status window to the currently selected path. */
if (SHGetPathFromIDList((LPITEMIDLIST) lp ,szDir))
@@ -4042,7 +3989,7 @@ static int CALLBACK BrowseCallbackProc(HWND hwnd,UINT uMsg,LPARAM lp, LPARAM pDa
}
-BOOL BrowseDirectories (HWND hwndDlg, char *lpszTitle, char *dirName)
+BOOL BrowseDirectories (HWND hwndDlg, char *lpszTitle, wchar_t *dirName)
{
BROWSEINFOW bi;
LPITEMIDLIST pidl;
@@ -4090,8 +4037,8 @@ std::wstring GetWrongPasswordErrorMessage (HWND hwndDlg)
StringCbCatW (szTmp, sizeof(szTmp), GetString ("PASSWORD_WRONG_CAPSLOCK_ON"));
#ifdef TCMOUNT
- char szDevicePath [TC_MAX_PATH+1] = {0};
- GetWindowText (GetDlgItem (MainDlg, IDC_VOLUME), szDevicePath, sizeof (szDevicePath));
+ wchar_t szDevicePath [TC_MAX_PATH+1] = {0};
+ GetWindowText (GetDlgItem (MainDlg, IDC_VOLUME), szDevicePath, ARRAYSIZE (szDevicePath));
if (TCBootLoaderOnInactiveSysEncDrive (szDevicePath))
{
@@ -4241,7 +4188,7 @@ void handleError (HWND hwndDlg, int code, const char* srcPos)
}
-BOOL CheckFileStreamWriteErrors (HWND hwndDlg, FILE *file, const char *fileName)
+BOOL CheckFileStreamWriteErrors (HWND hwndDlg, FILE *file, const wchar_t *fileName)
{
if (ferror (file))
{
@@ -4300,15 +4247,15 @@ void LocalizeDialog (HWND hwnd, char *stringId)
void OpenVolumeExplorerWindow (int driveNo)
{
- char dosName[5];
+ wchar_t dosName[5];
SHFILEINFO fInfo;
- StringCbPrintfA (dosName, sizeof(dosName), "%c:\\", (char) driveNo + 'A');
+ StringCbPrintfW (dosName, sizeof(dosName), L"%c:\\", (wchar_t) driveNo + L'A');
// Force explorer to discover the drive
SHGetFileInfo (dosName, 0, &fInfo, sizeof (fInfo), 0);
- ShellExecute (NULL, "open", dosName, NULL, NULL, SW_SHOWNORMAL);
+ ShellExecute (NULL, L"open", dosName, NULL, NULL, SW_SHOWNORMAL);
}
static BOOL explorerCloseSent;
@@ -4417,16 +4364,16 @@ BOOL UpdateDriveCustomLabel (int driveNo, wchar_t* effectiveLabel, BOOL bSetValu
return (ERROR_SUCCESS == lStatus)? TRUE : FALSE;
}
-string GetUserFriendlyVersionString (int version)
+wstring GetUserFriendlyVersionString (int version)
{
- char szTmp [64];
- StringCbPrintfA (szTmp, sizeof(szTmp), "%x", version);
+ wchar_t szTmp [64];
+ StringCbPrintfW (szTmp, sizeof(szTmp), L"%x", version);
- string versionString (szTmp);
+ wstring versionString (szTmp);
- versionString.insert (version > 0xfff ? 2 : 1,".");
+ versionString.insert (version > 0xfff ? 2 : 1,L".");
- if (versionString[versionString.length()-1] == '0')
+ if (versionString[versionString.length()-1] == L'0')
versionString.erase (versionString.length()-1, 1);
return (versionString);
@@ -4808,7 +4755,7 @@ static BOOL PerformBenchmark(HWND hBenchDlg, HWND hwndDlg)
benchmarkTable[benchmarkTotalItems].encSpeed = performanceCountEnd.QuadPart - performanceCountStart.QuadPart;
benchmarkTable[benchmarkTotalItems].id = thid;
- StringCbPrintfA (benchmarkTable[benchmarkTotalItems].name, sizeof(benchmarkTable[benchmarkTable[benchmarkTotalItems].name),"%s", get_pkcs5_prf_name (thid));
+ StringCbPrintfW (benchmarkTable[benchmarkTotalItems].name, sizeof(benchmarkTable[benchmarkTable[benchmarkTotalItems].name),L"%s", get_pkcs5_prf_name (thid));
benchmarkTotalItems++;
}
@@ -5113,7 +5060,7 @@ static BOOL CALLBACK RandomPoolEnrichementDlgProc (HWND hwndDlg, UINT msg, WPARA
WORD hw = HIWORD (wParam);
static unsigned char randPool [RNG_POOL_SIZE];
static unsigned char lastRandPool [RNG_POOL_SIZE];
- static char outputDispBuffer [RNG_POOL_SIZE * 3 + RANDPOOL_DISPLAY_ROWS + 2];
+ static wchar_t outputDispBuffer [RNG_POOL_SIZE * 3 + RANDPOOL_DISPLAY_ROWS + 2];
static BOOL bDisplayPoolContents = TRUE;
static BOOL bRandPoolDispAscii = FALSE;
int hash_algo = RandGetHashFunction();
@@ -5135,7 +5082,7 @@ static BOOL CALLBACK RandomPoolEnrichementDlgProc (HWND hwndDlg, UINT msg, WPARA
for (hid = FIRST_PRF_ID; hid <= LAST_PRF_ID; hid++)
{
if (!HashIsDeprecated (hid))
- AddComboPair (hComboBox, HashGetName(hid), hid);
+ AddComboPairW (hComboBox, HashGetName(hid), hid);
}
SelectAlgo (hComboBox, &hash_algo);
@@ -5148,7 +5095,7 @@ static BOOL CALLBACK RandomPoolEnrichementDlgProc (HWND hwndDlg, UINT msg, WPARA
case WM_TIMER:
{
- char tmp[4];
+ wchar_t tmp[4];
unsigned char tmpByte;
int col, row;
@@ -5166,10 +5113,10 @@ static BOOL CALLBACK RandomPoolEnrichementDlgProc (HWND hwndDlg, UINT msg, WPARA
{
tmpByte = randPool[row * RANDPOOL_DISPLAY_COLUMNS + col];
- StringCbPrintfA (tmp, sizeof(tmp), bRandPoolDispAscii ? ((tmpByte >= 32 && tmpByte < 255 && tmpByte != '&') ? " %c " : " . ") : "%02X ", tmpByte);
- StringCbCatA (outputDispBuffer, sizeof(outputDispBuffer), tmp);
+ StringCbPrintfW (tmp, sizeof(tmp), bRandPoolDispAscii ? ((tmpByte >= 32 && tmpByte < 255 && tmpByte != L'&') ? L" %c " : L" . ") : L"%02X ", tmpByte);
+ StringCbCatW (outputDispBuffer, sizeof(outputDispBuffer), tmp);
}
- StringCbCatA (outputDispBuffer, sizeof(outputDispBuffer), "\n");
+ StringCbCatW (outputDispBuffer, sizeof(outputDispBuffer), L"\n");
}
SetWindowText (GetDlgItem (hwndDlg, IDC_POOL_CONTENTS), outputDispBuffer);
@@ -5200,9 +5147,9 @@ static BOOL CALLBACK RandomPoolEnrichementDlgProc (HWND hwndDlg, UINT msg, WPARA
{
if (!(bDisplayPoolContents = GetCheckBox (hwndDlg, IDC_DISPLAY_POOL_CONTENTS)))
{
- char tmp[RNG_POOL_SIZE+1];
+ wchar_t tmp[RNG_POOL_SIZE+1];
- memset (tmp, ' ', sizeof(tmp));
+ wmemset (tmp, L' ', ARRAYSIZE(tmp));
tmp [RNG_POOL_SIZE] = 0;
SetWindowText (GetDlgItem (hwndDlg, IDC_POOL_CONTENTS), tmp);
}
@@ -5214,7 +5161,7 @@ static BOOL CALLBACK RandomPoolEnrichementDlgProc (HWND hwndDlg, UINT msg, WPARA
case WM_CLOSE:
{
- char tmp[RNG_POOL_SIZE+1];
+ wchar_t tmp[RNG_POOL_SIZE+1];
exit:
KillTimer (hwndDlg, 0xfd);
@@ -5223,7 +5170,7 @@ exit:
burn (outputDispBuffer, sizeof(outputDispBuffer));
// Attempt to wipe the pool contents in the GUI text area
- memset (tmp, ' ', RNG_POOL_SIZE);
+ wmemset (tmp, L' ', RNG_POOL_SIZE);
tmp [RNG_POOL_SIZE] = 0;
SetWindowText (GetDlgItem (hwndDlg, IDC_POOL_CONTENTS), tmp);
@@ -5261,7 +5208,7 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
WORD hw = HIWORD (wParam);
static unsigned char randPool [RNG_POOL_SIZE];
static unsigned char lastRandPool [RNG_POOL_SIZE];
- static char outputDispBuffer [RNG_POOL_SIZE * 3 + RANDPOOL_DISPLAY_ROWS + 2];
+ static wchar_t outputDispBuffer [RNG_POOL_SIZE * 3 + RANDPOOL_DISPLAY_ROWS + 2];
static BOOL bDisplayPoolContents = TRUE;
static BOOL bRandPoolDispAscii = FALSE;
int hash_algo = RandGetHashFunction();
@@ -5283,7 +5230,7 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
for (hid = FIRST_PRF_ID; hid <= LAST_PRF_ID; hid++)
{
if (!HashIsDeprecated (hid))
- AddComboPair (hComboBox, HashGetName(hid), hid);
+ AddComboPairW (hComboBox, HashGetName(hid), hid);
}
SelectAlgo (hComboBox, &hash_algo);
@@ -5300,10 +5247,10 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
SendMessage (GetDlgItem (hwndDlg, IDC_POOL_CONTENTS), WM_SETFONT, (WPARAM) hFixedDigitFont, (LPARAM) TRUE);
// 9-digit limit for the number of keyfiles (more than enough!)
SendMessage (GetDlgItem (hwndDlg, IDC_NUMBER_KEYFILES), EM_SETLIMITTEXT, (WPARAM) 9, 0);
- SetWindowText(GetDlgItem (hwndDlg, IDC_NUMBER_KEYFILES), "1");
+ SetWindowText(GetDlgItem (hwndDlg, IDC_NUMBER_KEYFILES), L"1");
// maximum keyfile size is 1048576, so limit the edit control to 7 characters
SendMessage (GetDlgItem (hwndDlg, IDC_KEYFILES_SIZE), EM_SETLIMITTEXT, (WPARAM) 7, 0);
- SetWindowText(GetDlgItem (hwndDlg, IDC_KEYFILES_SIZE), "64");
+ SetWindowText(GetDlgItem (hwndDlg, IDC_KEYFILES_SIZE), L"64");
// set the maximum length of the keyfile base name to (TC_MAX_PATH - 1)
SendMessage (GetDlgItem (hwndDlg, IDC_KEYFILES_BASE_NAME), EM_SETLIMITTEXT, (WPARAM) (TC_MAX_PATH - 1), 0);
return 1;
@@ -5311,7 +5258,7 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
case WM_TIMER:
{
- char tmp[4];
+ wchar_t tmp[4];
unsigned char tmpByte;
int col, row;
@@ -5329,10 +5276,10 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
{
tmpByte = randPool[row * RANDPOOL_DISPLAY_COLUMNS + col];
- StringCbPrintfA (tmp, sizeof(tmp), bRandPoolDispAscii ? ((tmpByte >= 32 && tmpByte < 255 && tmpByte != '&') ? " %c " : " . ") : "%02X ", tmpByte);
- StringCbCatA (outputDispBuffer, sizeof(outputDispBuffer), tmp);
+ StringCbPrintfW (tmp, sizeof(tmp), bRandPoolDispAscii ? ((tmpByte >= 32 && tmpByte < 255 && tmpByte != L'&') ? L" %c " : L" . ") : L"%02X ", tmpByte);
+ StringCbCatW (outputDispBuffer, sizeof(outputDispBuffer), tmp);
}
- StringCbCatA (outputDispBuffer, sizeof(outputDispBuffer), "\n");
+ StringCbCatW (outputDispBuffer, sizeof(outputDispBuffer), L"\n");
}
SetWindowText (GetDlgItem (hwndDlg, IDC_POOL_CONTENTS), outputDispBuffer);
@@ -5361,9 +5308,9 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
{
if (!(bDisplayPoolContents = GetCheckBox (hwndDlg, IDC_DISPLAY_POOL_CONTENTS)))
{
- char tmp[RNG_POOL_SIZE+1];
+ wchar_t tmp[RNG_POOL_SIZE+1];
- memset (tmp, ' ', sizeof(tmp));
+ wmemset (tmp, L' ', ARRAYSIZE(tmp));
tmp [RNG_POOL_SIZE] = 0;
SetWindowText (GetDlgItem (hwndDlg, IDC_POOL_CONTENTS), tmp);
}
@@ -5377,21 +5324,21 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
if (lw == IDC_GENERATE_AND_SAVE_KEYFILE)
{
- char szNumber[16] = {0};
- char szFileBaseName[TC_MAX_PATH];
- char szDirName[TC_MAX_PATH];
- char szFileName [2*TC_MAX_PATH + 16];
+ wchar_t szNumber[16] = {0};
+ wchar_t szFileBaseName[TC_MAX_PATH];
+ wchar_t szDirName[TC_MAX_PATH];
+ wchar_t szFileName [2*TC_MAX_PATH + 16];
unsigned char *keyfile = NULL;
int fhKeyfile = -1, status;
long keyfilesCount = 0, keyfilesSize = 0, i;
- char* fileExtensionPtr = 0;
- char szSuffix[32];
+ wchar_t* fileExtensionPtr = 0;
+ wchar_t szSuffix[32];
BOOL bRandomSize = GetCheckBox (hwndDlg, IDC_KEYFILES_RANDOM_SIZE);
- if (!GetWindowText(GetDlgItem (hwndDlg, IDC_NUMBER_KEYFILES), szNumber, sizeof(szNumber)))
+ if (!GetWindowText(GetDlgItem (hwndDlg, IDC_NUMBER_KEYFILES), szNumber, ARRAYSIZE(szNumber)))
szNumber[0] = 0;
- keyfilesCount = strtoul(szNumber, NULL, 0);
+ keyfilesCount = wcstoul(szNumber, NULL, 0);
if (keyfilesCount <= 0 || keyfilesCount == LONG_MAX)
{
Warning("KEYFILE_INCORRECT_NUMBER", hwndDlg);
@@ -5401,10 +5348,10 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
if (!bRandomSize)
{
- if (!GetWindowText(GetDlgItem (hwndDlg, IDC_KEYFILES_SIZE), szNumber, sizeof(szNumber)))
+ if (!GetWindowText(GetDlgItem (hwndDlg, IDC_KEYFILES_SIZE), szNumber, ARRAYSIZE(szNumber)))
szNumber[0] = 0;
- keyfilesSize = strtoul(szNumber, NULL, 0);
+ keyfilesSize = wcstoul(szNumber, NULL, 0);
if (keyfilesSize < 64 || keyfilesSize > 1024*1024)
{
Warning("KEYFILE_INCORRECT_SIZE", hwndDlg);
@@ -5431,14 +5378,14 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
return 1;
}
- fileExtensionPtr = strrchr(szFileBaseName, '.');
+ fileExtensionPtr = wcsrchr(szFileBaseName, L'.');
/* Select directory */
if (!BrowseDirectories (hwndDlg, "SELECT_KEYFILE_GENERATION_DIRECTORY", szDirName))
return 1;
- if (szDirName[strlen(szDirName) - 1] != '\\' && szDirName[strlen(szDirName) - 1] != '/')
- StringCbCat(szDirName, sizeof(szDirName), "\\");
+ if (szDirName[wcslen(szDirName) - 1] != L'\\' && szDirName[wcslen(szDirName) - 1] != L'/')
+ StringCbCat(szDirName, sizeof(szDirName), L"\\");
WaitCursor();
@@ -5446,15 +5393,15 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
for (i= 0; i < keyfilesCount; i++)
{
- StringCbCopy(szFileName, sizeof(szFileName), szDirName);
+ StringCbCopyW(szFileName, sizeof(szFileName), szDirName);
if (i > 0)
{
- StringCbPrintfA(szSuffix, sizeof(szSuffix), "_%d", i);
+ StringCbPrintfW(szSuffix, sizeof(szSuffix), L"_%d", i);
// Append the counter to the name
if (fileExtensionPtr)
{
- StringCbCatN(szFileName, sizeof(szFileName), szFileBaseName, (size_t) (fileExtensionPtr - szFileBaseName));
+ StringCchCatN(szFileName, ARRAYSIZE(szFileName), szFileBaseName, (size_t) (fileExtensionPtr - szFileBaseName));
StringCbCat(szFileName, sizeof(szFileName), szSuffix);
StringCbCat(szFileName, sizeof(szFileName), fileExtensionPtr);
}
@@ -5468,16 +5415,13 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
StringCbCat(szFileName, sizeof(szFileName), szFileBaseName);
// check if the file exists
- if ((fhKeyfile = _open(szFileName, _O_RDONLY|_O_BINARY, _S_IREAD|_S_IWRITE)) != -1)
+ if ((fhKeyfile = _wopen(szFileName, _O_RDONLY|_O_BINARY, _S_IREAD|_S_IWRITE)) != -1)
{
WCHAR s[4*TC_MAX_PATH] = {0};
- WCHAR wszFileName[3*TC_MAX_PATH] = {0};
_close (fhKeyfile);
- MultiByteToWideChar(CP_ACP, 0, szFileName, -1, wszFileName, sizeof(wszFileName) / sizeof(WCHAR));
-
- StringCbPrintfW (s, sizeof(s), GetString ("KEYFILE_ALREADY_EXISTS"), wszFileName);
+ StringCbPrintfW (s, sizeof(s), GetString ("KEYFILE_ALREADY_EXISTS"), szFileName);
status = AskWarnNoYesString (s, hwndDlg);
if (status == IDNO)
{
@@ -5488,7 +5432,7 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
}
/* Conceive the file */
- if ((fhKeyfile = _open(szFileName, _O_CREAT|_O_TRUNC|_O_WRONLY|_O_BINARY, _S_IREAD|_S_IWRITE)) == -1)
+ if ((fhKeyfile = _wopen(szFileName, _O_CREAT|_O_TRUNC|_O_WRONLY|_O_BINARY, _S_IREAD|_S_IWRITE)) == -1)
{
TCfree(keyfile);
NormalCursor();
@@ -5550,7 +5494,7 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
case WM_CLOSE:
{
- char tmp[RNG_POOL_SIZE+1];
+ wchar_t tmp[RNG_POOL_SIZE+1];
exit:
WaitCursor();
KillTimer (hwndDlg, 0xfd);
@@ -5565,7 +5509,7 @@ exit:
burn (outputDispBuffer, sizeof(outputDispBuffer));
// Attempt to wipe the pool contents in the GUI text area
- memset (tmp, ' ', RNG_POOL_SIZE);
+ wmemset (tmp, L' ', RNG_POOL_SIZE);
tmp [RNG_POOL_SIZE] = 0;
SetWindowText (GetDlgItem (hwndDlg, IDC_POOL_CONTENTS), tmp);
@@ -5597,7 +5541,7 @@ CipherTestDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
case WM_INITDIALOG:
{
int ea;
- char buf[100];
+ wchar_t buf[100];
LocalizeDialog (hwndDlg, "IDD_CIPHER_TEST_DLG");
@@ -5627,7 +5571,7 @@ CipherTestDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
for (ea = EAGetFirst (); ea != 0; ea = EAGetNext (ea))
{
if (EAGetCipherCount (ea) == 1 && EAIsFormatEnabled (ea))
- AddComboPair (GetDlgItem (hwndDlg, IDC_CIPHER), EAGetName (buf, ea, 1), EAGetFirstCipher (ea));
+ AddComboPairW (GetDlgItem (hwndDlg, IDC_CIPHER), EAGetName (buf, ea, 1), EAGetFirstCipher (ea));
}
ResetCipherTest(hwndDlg, idTestCipher);
@@ -5695,7 +5639,8 @@ CipherTestDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
if (lw == IDOK || lw == IDC_ENCRYPT || lw == IDC_DECRYPT)
{
- char key[128+1], inputtext[128+1], secondaryKey[64+1], dataUnitNo[16+1], szTmp[128+1];
+ char key[128+1], inputtext[128+1], secondaryKey[64+1], dataUnitNo[16+1];
+ wchar_t szTmp[128+1];
int ks, pt, n, tlen, blockNo = 0;
BOOL bEncrypt;
@@ -5710,7 +5655,7 @@ CipherTestDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
memset(key,0,sizeof(key));
memset(szTmp,0,sizeof(szTmp));
- n = GetWindowText(GetDlgItem(hwndDlg, IDC_KEY), szTmp, sizeof(szTmp));
+ n = GetWindowText(GetDlgItem(hwndDlg, IDC_KEY), szTmp, ARRAYSIZE(szTmp));
if (n != ks * 2)
{
Warning ("TEST_KEY_SIZE", hwndDlg);
@@ -5719,14 +5664,14 @@ CipherTestDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
for (n = 0; n < ks; n ++)
{
- char szTmp2[3], *ptr;
+ wchar_t szTmp2[3], *ptr;
long x;
szTmp2[2] = 0;
szTmp2[0] = szTmp[n * 2];
szTmp2[1] = szTmp[n * 2 + 1];
- x = strtol(szTmp2, &ptr, 16);
+ x = wcstol(szTmp2, &ptr, 16);
key[n] = (char) x;
}
@@ -5738,11 +5683,11 @@ CipherTestDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
if (bEncrypt)
{
- n = GetWindowText(GetDlgItem(hwndDlg, IDC_PLAINTEXT), szTmp, sizeof(szTmp));
+ n = GetWindowText(GetDlgItem(hwndDlg, IDC_PLAINTEXT), szTmp, ARRAYSIZE(szTmp));
}
else
{
- n = GetWindowText(GetDlgItem(hwndDlg, IDC_CIPHERTEXT), szTmp, sizeof(szTmp));
+ n = GetWindowText(GetDlgItem(hwndDlg, IDC_CIPHERTEXT), szTmp, ARRAYSIZE(szTmp));
}
if (n != pt * 2)
@@ -5761,14 +5706,14 @@ CipherTestDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
for (n = 0; n < pt; n ++)
{
- char szTmp2[3], *ptr;
+ wchar_t szTmp2[3], *ptr;
long x;
szTmp2[2] = 0;
szTmp2[0] = szTmp[n * 2];
szTmp2[1] = szTmp[n * 2 + 1];
- x = strtol(szTmp2, &ptr, 16);
+ x = wcstol(szTmp2, &ptr, 16);
inputtext[n] = (char) x;
}
@@ -5778,7 +5723,7 @@ CipherTestDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
// Secondary key
- if (GetWindowText(GetDlgItem(hwndDlg, IDC_SECONDARY_KEY), szTmp, sizeof(szTmp)) != 64)
+ if (GetWindowText(GetDlgItem(hwndDlg, IDC_SECONDARY_KEY), szTmp, ARRAYSIZE(szTmp)) != 64)
{
Warning ("TEST_INCORRECT_SECONDARY_KEY_SIZE", hwndDlg);
return 1;
@@ -5786,21 +5731,21 @@ CipherTestDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
for (n = 0; n < 64; n ++)
{
- char szTmp2[3], *ptr;
+ wchar_t szTmp2[3], *ptr;
long x;
szTmp2[2] = 0;
szTmp2[0] = szTmp[n * 2];
szTmp2[1] = szTmp[n * 2 + 1];
- x = strtol(szTmp2, &ptr, 16);
+ x = wcstol(szTmp2, &ptr, 16);
secondaryKey[n] = (char) x;
}
// Data unit number
- tlen = GetWindowText(GetDlgItem(hwndDlg, IDC_TEST_DATA_UNIT_NUMBER), szTmp, sizeof(szTmp));
+ tlen = GetWindowText(GetDlgItem(hwndDlg, IDC_TEST_DATA_UNIT_NUMBER), szTmp, ARRAYSIZE(szTmp));
if (tlen > 16 || tlen < 1)
{
@@ -5808,18 +5753,18 @@ CipherTestDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
return 1;
}
- LeftPadString (szTmp, tlen, 16, '0');
+ LeftPadString (szTmp, tlen, 16, L'0');
for (n = 0; n < 16; n ++)
{
- char szTmp2[3], *ptr;
+ wchar_t szTmp2[3], *ptr;
long x;
szTmp2[2] = 0;
szTmp2[0] = szTmp[n * 2];
szTmp2[1] = szTmp[n * 2 + 1];
- x = strtol(szTmp2, &ptr, 16);
+ x = wcstol(szTmp2, &ptr, 16);
dataUnitNo[n] = (char) x;
}
@@ -5898,9 +5843,9 @@ CipherTestDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
for (n = 0; n < pt; n ++)
{
- char szTmp2[3];
- StringCbPrintfA(szTmp2, sizeof(szTmp2), "%02x", (int)((unsigned char)tmp[n]));
- StringCbCatA(szTmp, sizeof(szTmp), szTmp2);
+ wchar_t szTmp2[3];
+ StringCbPrintfW(szTmp2, sizeof(szTmp2), L"%02x", (int)((unsigned char)tmp[n]));
+ StringCbCatW(szTmp, sizeof(szTmp), szTmp2);
}
if (bEncrypt)
@@ -5961,26 +5906,26 @@ ResetCipherTest(HWND hwndDlg, int idTestCipher)
SendMessage(GetDlgItem(hwndDlg, IDC_TEST_BLOCK_NUMBER), CB_SETCURSEL, 0, 0);
- SetWindowText(GetDlgItem(hwndDlg, IDC_SECONDARY_KEY), "0000000000000000000000000000000000000000000000000000000000000000");
- SetWindowText(GetDlgItem(hwndDlg, IDC_TEST_DATA_UNIT_NUMBER), "0");
+ SetWindowText(GetDlgItem(hwndDlg, IDC_SECONDARY_KEY), L"0000000000000000000000000000000000000000000000000000000000000000");
+ SetWindowText(GetDlgItem(hwndDlg, IDC_TEST_DATA_UNIT_NUMBER), L"0");
- SetWindowText(GetDlgItem(hwndDlg, IDC_PLAINTEXT), "0000000000000000");
- SetWindowText(GetDlgItem(hwndDlg, IDC_CIPHERTEXT), "0000000000000000");
+ SetWindowText(GetDlgItem(hwndDlg, IDC_PLAINTEXT), L"0000000000000000");
+ SetWindowText(GetDlgItem(hwndDlg, IDC_CIPHERTEXT), L"0000000000000000");
if (idTestCipher == AES || idTestCipher == SERPENT || idTestCipher == TWOFISH)
{
- ndx = (int) SendMessage (GetDlgItem(hwndDlg, IDC_KEY_SIZE), CB_ADDSTRING, 0,(LPARAM) "256");
+ ndx = (int) SendMessage (GetDlgItem(hwndDlg, IDC_KEY_SIZE), CB_ADDSTRING, 0,(LPARAM) L"256");
SendMessage(GetDlgItem(hwndDlg, IDC_KEY_SIZE), CB_SETITEMDATA, ndx,(LPARAM) 32);
SendMessage(GetDlgItem(hwndDlg, IDC_KEY_SIZE), CB_SETCURSEL, ndx,0);
SendMessage (GetDlgItem(hwndDlg, IDC_PLAINTEXT_SIZE), CB_RESETCONTENT, 0,0);
- ndx = (int) SendMessage (GetDlgItem(hwndDlg, IDC_PLAINTEXT_SIZE), CB_ADDSTRING, 0,(LPARAM) "128");
+ ndx = (int) SendMessage (GetDlgItem(hwndDlg, IDC_PLAINTEXT_SIZE), CB_ADDSTRING, 0,(LPARAM) L"128");
SendMessage(GetDlgItem(hwndDlg, IDC_PLAINTEXT_SIZE), CB_SETITEMDATA, ndx,(LPARAM) 16);
SendMessage(GetDlgItem(hwndDlg, IDC_PLAINTEXT_SIZE), CB_SETCURSEL, ndx,0);
- SetWindowText(GetDlgItem(hwndDlg, IDC_KEY), "0000000000000000000000000000000000000000000000000000000000000000");
- SetWindowText(GetDlgItem(hwndDlg, IDC_PLAINTEXT), "00000000000000000000000000000000");
- SetWindowText(GetDlgItem(hwndDlg, IDC_CIPHERTEXT), "00000000000000000000000000000000");
+ SetWindowText(GetDlgItem(hwndDlg, IDC_KEY), L"0000000000000000000000000000000000000000000000000000000000000000");
+ SetWindowText(GetDlgItem(hwndDlg, IDC_PLAINTEXT), L"00000000000000000000000000000000");
+ SetWindowText(GetDlgItem(hwndDlg, IDC_CIPHERTEXT), L"00000000000000000000000000000000");
}
}
@@ -6228,48 +6173,48 @@ BOOL CheckCapsLock (HWND hwnd, BOOL quiet)
// Checks whether the file extension is not used for executable files or similarly problematic, which often
// causes Windows and antivirus software to interfere with the container.
-BOOL CheckFileExtension (char *fileName)
+BOOL CheckFileExtension (wchar_t *fileName)
{
int i = 0;
- char *ext = strrchr (fileName, '.');
- static char *problemFileExt[] = {
+ wchar_t *ext = wcsrchr (fileName, L'.');
+ static wchar_t *problemFileExt[] = {
// These are protected by the Windows Resource Protection
- ".asa", ".asp", ".aspx", ".ax", ".bas", ".bat", ".bin", ".cer", ".chm", ".clb", ".cmd", ".cnt", ".cnv",
- ".com", ".cpl", ".cpx", ".crt", ".csh", ".dll", ".drv", ".dtd", ".exe", ".fxp", ".grp", ".h1s", ".hlp",
- ".hta", ".ime", ".inf", ".ins", ".isp", ".its", ".js", ".jse", ".ksh", ".lnk", ".mad", ".maf", ".mag",
- ".mam", ".man", ".maq", ".mar", ".mas", ".mat", ".mau", ".mav", ".maw", ".mda", ".mdb", ".mde", ".mdt",
- ".mdw", ".mdz", ".msc", ".msi", ".msp", ".mst", ".mui", ".nls", ".ocx", ".ops", ".pal", ".pcd", ".pif",
- ".prf", ".prg", ".pst", ".reg", ".scf", ".scr", ".sct", ".shb", ".shs", ".sys", ".tlb", ".tsp", ".url",
- ".vb", ".vbe", ".vbs", ".vsmacros", ".vss", ".vst", ".vsw", ".ws", ".wsc", ".wsf", ".wsh", ".xsd", ".xsl",
+ L".asa", L".asp", L".aspx", L".ax", L".bas", L".bat", L".bin", L".cer", L".chm", L".clb", L".cmd", L".cnt", L".cnv",
+ L".com", L".cpl", L".cpx", L".crt", L".csh", L".dll", L".drv", L".dtd", L".exe", L".fxp", L".grp", L".h1s", L".hlp",
+ L".hta", L".ime", L".inf", L".ins", L".isp", L".its", L".js", L".jse", L".ksh", L".lnk", L".mad", L".maf", L".mag",
+ L".mam", L".man", L".maq", L".mar", L".mas", L".mat", L".mau", L".mav", L".maw", L".mda", L".mdb", L".mde", L".mdt",
+ L".mdw", L".mdz", L".msc", L".msi", L".msp", L".mst", L".mui", L".nls", L".ocx", L".ops", L".pal", L".pcd", L".pif",
+ L".prf", L".prg", L".pst", L".reg", L".scf", L".scr", L".sct", L".shb", L".shs", L".sys", L".tlb", L".tsp", L".url",
+ L".vb", L".vbe", L".vbs", L".vsmacros", L".vss", L".vst", L".vsw", L".ws", L".wsc", L".wsf", L".wsh", L".xsd", L".xsl",
// These additional file extensions are usually watched by antivirus programs
- ".386", ".acm", ".ade", ".adp", ".ani", ".app", ".asd", ".asf", ".asx", ".awx", ".ax", ".boo", ".bz2", ".cdf",
- ".class", ".dhtm", ".dhtml",".dlo", ".emf", ".eml", ".flt", ".fot", ".gz", ".hlp", ".htm", ".html", ".ini",
- ".j2k", ".jar", ".jff", ".jif", ".jmh", ".jng", ".jp2", ".jpe", ".jpeg", ".jpg", ".lsp", ".mod", ".nws",
- ".obj", ".olb", ".osd", ".ov1", ".ov2", ".ov3", ".ovl", ".ovl", ".ovr", ".pdr", ".pgm", ".php", ".pkg",
- ".pl", ".png", ".pot", ".pps", ".ppt", ".ps1", ".ps1xml", ".psc1", ".rar", ".rpl", ".rtf", ".sbf", ".script", ".sh", ".sha", ".shtm",
- ".shtml", ".spl", ".swf", ".tar", ".tgz", ".tmp", ".ttf", ".vcs", ".vlm", ".vxd", ".vxo", ".wiz", ".wll", ".wmd",
- ".wmf", ".wms", ".wmz", ".wpc", ".wsc", ".wsh", ".wwk", ".xhtm", ".xhtml", ".xl", ".xml", ".zip", ".7z", 0};
+ L".386", L".acm", L".ade", L".adp", L".ani", L".app", L".asd", L".asf", L".asx", L".awx", L".ax", L".boo", L".bz2", L".cdf",
+ L".class", L".dhtm", L".dhtml",L".dlo", L".emf", L".eml", L".flt", L".fot", L".gz", L".hlp", L".htm", L".html", L".ini",
+ L".j2k", L".jar", L".jff", L".jif", L".jmh", L".jng", L".jp2", L".jpe", L".jpeg", L".jpg", L".lsp", L".mod", L".nws",
+ L".obj", L".olb", L".osd", L".ov1", L".ov2", L".ov3", L".ovl", L".ovl", L".ovr", L".pdr", L".pgm", L".php", L".pkg",
+ L".pl", L".png", L".pot", L".pps", L".ppt", L".ps1", L".ps1xml", L".psc1", L".rar", L".rpl", L".rtf", L".sbf", L".script", L".sh", L".sha", L".shtm",
+ L".shtml", L".spl", L".swf", L".tar", L".tgz", L".tmp", L".ttf", L".vcs", L".vlm", L".vxd", L".vxo", L".wiz", L".wll", L".wmd",
+ L".wmf", L".wms", L".wmz", L".wpc", L".wsc", L".wsh", L".wwk", L".xhtm", L".xhtml", L".xl", L".xml", L".zip", L".7z", 0};
if (!ext)
return FALSE;
while (problemFileExt[i])
{
- if (!_stricmp (ext, problemFileExt[i++]))
+ if (!_wcsicmp (ext, problemFileExt[i++]))
return TRUE;
}
return FALSE;
}
-void CorrectFileName (char* fileName)
+void CorrectFileName (wchar_t* fileName)
{
/* replace '/' by '\' */
- size_t i, len = strlen (fileName);
+ size_t i, len = wcslen (fileName);
for (i = 0; i < len; i++)
{
- if (fileName [i] == '/')
- fileName [i] = '\\';
+ if (fileName [i] == L'/')
+ fileName [i] = L'\\';
}
}
@@ -6327,7 +6272,7 @@ BOOL IsDriveAvailable (int driveNo)
}
-BOOL IsDeviceMounted (char *deviceName)
+BOOL IsDeviceMounted (wchar_t *deviceName)
{
BOOL bResult = FALSE;
DWORD dwResult;
@@ -6392,7 +6337,7 @@ int DriverUnmountVolume (HWND hwndDlg, int nDosDriveNo, BOOL forced)
wchar_t msg[4096];
VolumeNotificationsList.bHidVolDamagePrevReported [nDosDriveNo] = TRUE;
- StringCbPrintfW (msg, sizeof(msg), GetString ("DAMAGE_TO_HIDDEN_VOLUME_PREVENTED"), nDosDriveNo + 'A');
+ StringCbPrintfW (msg, sizeof(msg), GetString ("DAMAGE_TO_HIDDEN_VOLUME_PREVENTED"), nDosDriveNo + L'A');
SetForegroundWindow (hwndDlg);
MessageBoxW (hwndDlg, msg, lpszTitle, MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST);
}
@@ -6429,21 +6374,10 @@ void BroadcastDeviceChange (WPARAM message, int nDosDriveNo, DWORD driveMap)
{
if (driveMap & (1 << i))
{
- char root[] = { (char) i + 'A', ':', '\\', 0 };
+ wchar_t root[] = { (wchar_t) i + L'A', L':', L'\\', 0 };
SHChangeNotify (eventId, SHCNF_PATH, root, NULL);
- if (nCurrentOS == WIN_2000 && RemoteSession)
- {
- char target[32];
- StringCbPrintfA (target, sizeof(target), "%ls%c", TC_MOUNT_PREFIX, i + 'A');
- root[2] = 0;
-
- if (message == DBT_DEVICEARRIVAL)
- DefineDosDevice (DDD_RAW_TARGET_PATH, root, target);
- else if (message == DBT_DEVICEREMOVECOMPLETE)
- DefineDosDevice (DDD_RAW_TARGET_PATH| DDD_REMOVE_DEFINITION
- | DDD_EXACT_MATCH_ON_REMOVE, root, target);
- }
+
}
}
}
@@ -6516,7 +6450,7 @@ BOOL GetPhysicalDriveAlignment(UINT nDriveNumber, STORAGE_ACCESS_ALIGNMENT_DESCR
// implementation of the generic wait dialog mechanism
-static UINT g_wmWaitDlg = ::RegisterWindowMessage("VeraCryptWaitDlgMessage");
+static UINT g_wmWaitDlg = ::RegisterWindowMessage(L"VeraCryptWaitDlgMessage");
typedef struct
{
@@ -6700,7 +6634,7 @@ void CALLBACK MountWaitThreadProc(void* pArg, HWND )
int MountVolume (HWND hwndDlg,
int driveNo,
- char *volumePath,
+ wchar_t *volumePath,
Password *password,
int pkcs5,
int pim,
@@ -6714,7 +6648,7 @@ int MountVolume (HWND hwndDlg,
MOUNT_STRUCT mount;
DWORD dwResult, dwLastError = ERROR_SUCCESS;
BOOL bResult, bDevice;
- char root[MAX_PATH];
+ wchar_t root[MAX_PATH];
int favoriteMountOnArrivalRetryCount = 0;
#ifdef TCMOUNT
@@ -6785,33 +6719,33 @@ retry:
if (CurrentOSMajor == 5 && CurrentOSMinor == 0)
mount.bMountManager = FALSE;
- string path = volumePath;
- if (path.find ("\\\\?\\") == 0)
+ wstring path = volumePath;
+ if (path.find (L"\\\\?\\") == 0)
{
// Remove \\?\ prefix
path = path.substr (4);
- strcpy_s (volumePath, TC_MAX_PATH, path.c_str());
+ StringCchCopyW (volumePath, TC_MAX_PATH, path.c_str());
}
- if (path.find ("Volume{") == 0 && path.rfind ("}\\") == path.size() - 2)
+ if (path.find (L"Volume{") == 0 && path.rfind (L"}\\") == path.size() - 2)
{
- string resolvedPath = VolumeGuidPathToDevicePath (path);
+ wstring resolvedPath = VolumeGuidPathToDevicePath (path);
if (!resolvedPath.empty())
- strcpy_s (volumePath, TC_MAX_PATH, resolvedPath.c_str());
+ StringCchCopyW (volumePath, TC_MAX_PATH, resolvedPath.c_str());
}
- CreateFullVolumePath ((char *) mount.wszVolume, sizeof(mount.wszVolume), volumePath, &bDevice);
+ CreateFullVolumePath (mount.wszVolume, sizeof(mount.wszVolume), volumePath, &bDevice);
if (!bDevice)
{
// UNC path
- if (path.find ("\\\\") == 0)
+ if (path.find (L"\\\\") == 0)
{
- strcpy_s ((char *)mount.wszVolume, array_capacity (mount.wszVolume), ("UNC" + path.substr (1)).c_str());
+ StringCbCopyW (mount.wszVolume, sizeof (mount.wszVolume), (L"UNC" + path.substr (1)).c_str());
}
- if (GetVolumePathName (volumePath, root, sizeof (root) - 1))
+ if (GetVolumePathName (volumePath, root, ARRAYSIZE (root) - 1))
{
DWORD bps, flags, d;
if (GetDiskFreeSpace (root, &d, &bps, &d, &d))
@@ -6822,12 +6756,12 @@ retry:
if (IsOSAtLeast (WIN_VISTA))
{
- if ( (strlen(root) >= 2)
- && (root[1] == ':')
- && (toupper(root[0]) >= 'A' && toupper(root[0]) <= 'Z')
+ if ( (wcslen(root) >= 2)
+ && (root[1] == L':')
+ && (towupper(root[0]) >= L'A' && towupper(root[0]) <= L'Z')
)
{
- string drivePath = "\\\\.\\X:";
+ wstring drivePath = L"\\\\.\\X:";
HANDLE dev = INVALID_HANDLE_VALUE;
VOLUME_DISK_EXTENTS extents = {0};
DWORD dwResult = 0;
@@ -6858,8 +6792,6 @@ retry:
}
}
- ToUNICODE ((char *) mount.wszVolume, sizeof(mount.wszVolume));
-
if (mountOptions->PartitionInInactiveSysEncScope)
{
if (mount.wszVolume == NULL || swscanf_s ((const wchar_t *) mount.wszVolume,
@@ -6965,7 +6897,7 @@ retry:
{
int driveNo;
- if (sscanf (volumePath, "\\Device\\Harddisk%d\\Partition", &driveNo) == 1)
+ if (swscanf (volumePath, L"\\Device\\Harddisk%d\\Partition", &driveNo) == 1)
{
OPEN_TEST_STRUCT openTestStruct;
memset (&openTestStruct, 0, sizeof (openTestStruct));
@@ -7040,7 +6972,7 @@ retry:
if (mount.VolumeMountedReadOnlyAfterDeviceWriteProtected
&& !Silent
- && strstr (volumePath, "\\Device\\Harddisk") == volumePath)
+ && wcsstr (volumePath, L"\\Device\\Harddisk") == volumePath)
{
wchar_t msg[1024];
wchar_t mountPoint[] = { L'A' + (wchar_t) driveNo, L':', 0 };
@@ -7049,7 +6981,7 @@ retry:
WarningDirect (msg, hwndDlg);
if (CurrentOSMajor >= 6
- && strstr (volumePath, "\\Device\\HarddiskVolume") != volumePath
+ && wcsstr (volumePath, L"\\Device\\HarddiskVolume") != volumePath
&& AskNoYes ("ASK_REMOVE_DEVICE_WRITE_PROTECTION", hwndDlg) == IDYES)
{
RemoveDeviceWriteProtection (hwndDlg, volumePath);
@@ -7143,7 +7075,7 @@ retry:
if (IsOSAtLeast (WIN_7))
{
// Undo SHCNE_DRIVEREMOVED
- char root[] = { (char) nDosDriveNo + 'A', ':', '\\', 0 };
+ wchar_t root[] = { (wchar_t) nDosDriveNo + L'A', L':', L'\\', 0 };
SHChangeNotify (SHCNE_DRIVEADD, SHCNF_PATH, root, NULL);
}
@@ -7178,23 +7110,21 @@ BOOL IsPasswordCacheEmpty (void)
}
-BOOL IsMountedVolume (const char *volname)
+BOOL IsMountedVolume (const wchar_t *volname)
{
MOUNT_LIST_STRUCT mlist;
DWORD dwResult;
int i;
- char volume[TC_MAX_PATH*2+16];
+ wchar_t volume[TC_MAX_PATH*2+16];
- StringCbCopyA (volume, sizeof(volume), volname);
+ StringCbCopyW (volume, sizeof(volume), volname);
- if (strstr (volname, "\\Device\\") != volname)
- StringCbPrintfA(volume, sizeof(volume), "\\??\\%s", volname);
+ if (wcsstr (volname, L"\\Device\\") != volname)
+ StringCbPrintfW(volume, sizeof(volume), L"\\??\\%s", volname);
- string resolvedPath = VolumeGuidPathToDevicePath (volname);
+ wstring resolvedPath = VolumeGuidPathToDevicePath (volname);
if (!resolvedPath.empty())
- StringCbCopyA (volume, sizeof (volume), resolvedPath.c_str());
-
- ToUNICODE (volume, sizeof(volume));
+ StringCbCopyW (volume, sizeof (volume), resolvedPath.c_str());
memset (&mlist, 0, sizeof (mlist));
DeviceIoControl (hDriver, TC_IOCTL_GET_MOUNTED_VOLUMES, &mlist,
@@ -7202,33 +7132,31 @@ BOOL IsMountedVolume (const char *volname)
NULL);
for (i=0 ; i<26; i++)
- if (0 == _wcsicmp ((wchar_t *) mlist.wszVolume[i], (WCHAR *)volume))
+ if (0 == _wcsicmp ((wchar_t *) mlist.wszVolume[i], volume))
return TRUE;
return FALSE;
}
-int GetMountedVolumeDriveNo (char *volname)
+int GetMountedVolumeDriveNo (wchar_t *volname)
{
MOUNT_LIST_STRUCT mlist;
DWORD dwResult;
int i;
- char volume[TC_MAX_PATH*2+16];
+ wchar_t volume[TC_MAX_PATH*2+16];
if (volname == NULL)
return -1;
- StringCbCopyA (volume, sizeof(volume), volname);
+ StringCbCopyW (volume, sizeof(volume), volname);
- if (strstr (volname, "\\Device\\") != volname)
- StringCbPrintfA (volume, sizeof(volume), "\\??\\%s", volname);
+ if (wcsstr (volname, L"\\Device\\") != volname)
+ StringCbPrintfW (volume, sizeof(volume), L"\\??\\%s", volname);
- string resolvedPath = VolumeGuidPathToDevicePath (volname);
+ wstring resolvedPath = VolumeGuidPathToDevicePath (volname);
if (!resolvedPath.empty())
- StringCbCopyA (volume, sizeof (volume), resolvedPath.c_str());
-
- ToUNICODE (volume, sizeof(volume));
+ StringCbCopyW (volume, sizeof (volume), resolvedPath.c_str());
memset (&mlist, 0, sizeof (mlist));
DeviceIoControl (hDriver, TC_IOCTL_GET_MOUNTED_VOLUMES, &mlist,
@@ -7283,9 +7211,9 @@ BOOL IsUacSupported ()
if (!IsOSAtLeast (WIN_VISTA))
return FALSE;
- if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", 0, KEY_READ, &hkey) == ERROR_SUCCESS)
+ if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", 0, KEY_READ, &hkey) == ERROR_SUCCESS)
{
- if (RegQueryValueEx (hkey, "EnableLUA", 0, 0, (LPBYTE) &value, &size) != ERROR_SUCCESS)
+ if (RegQueryValueEx (hkey, L"EnableLUA", 0, 0, (LPBYTE) &value, &size) != ERROR_SUCCESS)
value = 1;
RegCloseKey (hkey);
@@ -7314,14 +7242,14 @@ BOOL ResolveSymbolicLink (const wchar_t *symLinkName, PWSTR targetName, size_t c
}
-BOOL GetPartitionInfo (const char *deviceName, PPARTITION_INFORMATION rpartInfo)
+BOOL GetPartitionInfo (const wchar_t *deviceName, PPARTITION_INFORMATION rpartInfo)
{
BOOL bResult;
DWORD dwResult;
DISK_PARTITION_INFO_STRUCT dpi;
memset (&dpi, 0, sizeof(dpi));
- StringCbPrintfW ((PWSTR) &dpi.deviceName, sizeof(dpi.deviceName), L"%hs", deviceName);
+ StringCbCopyW ((PWSTR) &dpi.deviceName, sizeof(dpi.deviceName), deviceName);
bResult = DeviceIoControl (hDriver, TC_IOCTL_GET_DRIVE_PARTITION_INFO, &dpi,
sizeof (dpi), &dpi, sizeof (dpi), &dwResult, NULL);
@@ -7331,25 +7259,25 @@ BOOL GetPartitionInfo (const char *deviceName, PPARTITION_INFORMATION rpartInfo)
}
-BOOL GetDeviceInfo (const char *deviceName, DISK_PARTITION_INFO_STRUCT *info)
+BOOL GetDeviceInfo (const wchar_t *deviceName, DISK_PARTITION_INFO_STRUCT *info)
{
DWORD dwResult;
memset (info, 0, sizeof(*info));
- StringCbPrintfW ((PWSTR) &info->deviceName, sizeof(info->deviceName), L"%hs", deviceName);
+ StringCbCopyW ((PWSTR) &info->deviceName, sizeof(info->deviceName), deviceName);
return DeviceIoControl (hDriver, TC_IOCTL_GET_DRIVE_PARTITION_INFO, info, sizeof (*info), info, sizeof (*info), &dwResult, NULL);
}
-BOOL GetDriveGeometry (const char *deviceName, PDISK_GEOMETRY diskGeometry)
+BOOL GetDriveGeometry (const wchar_t *deviceName, PDISK_GEOMETRY diskGeometry)
{
BOOL bResult;
DWORD dwResult;
DISK_GEOMETRY_STRUCT dg;
memset (&dg, 0, sizeof(dg));
- StringCbPrintfW ((PWSTR) &dg.deviceName, sizeof(dg.deviceName), L"%hs", deviceName);
+ StringCbCopyW ((PWSTR) &dg.deviceName, sizeof(dg.deviceName), deviceName);
bResult = DeviceIoControl (hDriver, TC_IOCTL_GET_DRIVE_GEOMETRY, &dg,
sizeof (dg), &dg, sizeof (dg), &dwResult, NULL);
@@ -7377,7 +7305,7 @@ int GetDiskDeviceDriveLetter (PWSTR deviceName)
for (i = 0; i < 26; i++)
{
- WCHAR drive[] = { (WCHAR) i + 'A', ':', 0 };
+ WCHAR drive[] = { (WCHAR) i + L'A', L':', 0 };
StringCchCopyW (link, MAX_PATH, L"\\DosDevices\\");
StringCchCatW (link, MAX_PATH, drive);
@@ -7396,7 +7324,7 @@ int GetDiskDeviceDriveLetter (PWSTR deviceName)
// WARNING: This function does NOT provide 100% reliable results -- do NOT use it for critical/dangerous operations!
// Return values: 0 - filesystem does not appear empty, 1 - filesystem appears empty, -1 - an error occurred
-int FileSystemAppearsEmpty (const char *devicePath)
+int FileSystemAppearsEmpty (const wchar_t *devicePath)
{
float percentFreeSpace = 0.0;
__int64 occupiedBytes = 0;
@@ -7420,20 +7348,19 @@ int FileSystemAppearsEmpty (const char *devicePath)
// is not NULL, size of occupied space (in bytes) is written to the pointed location. In addition, if the
// 'percent' pointer is not NULL, % of free space is stored in the pointed location. If there's an error,
// returns -1.
-__int64 GetStatsFreeSpaceOnPartition (const char *devicePath, float *percentFree, __int64 *occupiedBytes, BOOL silent)
+__int64 GetStatsFreeSpaceOnPartition (const wchar_t *devicePath, float *percentFree, __int64 *occupiedBytes, BOOL silent)
{
WCHAR devPath [MAX_PATH];
int driveLetterNo = -1;
- char szRootPath[4] = {0, ':', '\\', 0};
+ wchar_t szRootPath[4] = {0, L':', L'\\', 0};
ULARGE_INTEGER freeSpaceSize;
ULARGE_INTEGER totalNumberOfBytes;
ULARGE_INTEGER totalNumberOfFreeBytes;
- StringCbCopyA ((char *) devPath, sizeof(devPath), devicePath);
- ToUNICODE ((char *) devPath, sizeof(devPath));
+ StringCbCopyW (devPath, sizeof(devPath), devicePath);
driveLetterNo = GetDiskDeviceDriveLetter (devPath);
- szRootPath[0] = (char) driveLetterNo + 'A';
+ szRootPath[0] = (wchar_t) driveLetterNo + L'A';
if (!GetDiskFreeSpaceEx (szRootPath, &freeSpaceSize, &totalNumberOfBytes, &totalNumberOfFreeBytes))
@@ -7476,7 +7403,7 @@ __int64 GetStatsFreeSpaceOnPartition (const char *devicePath, float *percentFree
// Returns -1 if there's an error.
-__int64 GetDeviceSize (const char *devicePath)
+__int64 GetDeviceSize (const wchar_t *devicePath)
{
PARTITION_INFORMATION partitionInfo;
@@ -7487,7 +7414,7 @@ __int64 GetDeviceSize (const char *devicePath)
}
-HANDLE DismountDrive (char *devName, char *devicePath)
+HANDLE DismountDrive (wchar_t *devName, wchar_t *devicePath)
{
DWORD dwResult;
HANDLE hVolume;
@@ -7496,8 +7423,7 @@ HANDLE DismountDrive (char *devName, char *devicePath)
int driveLetterNo = -1;
WCHAR devPath [MAX_PATH];
- StringCbCopyA ((char *) devPath, sizeof(devPath), devicePath);
- ToUNICODE ((char *) devPath, sizeof(devPath));
+ StringCbCopyW (devPath, sizeof(devPath), devicePath);
driveLetterNo = GetDiskDeviceDriveLetter (devPath);
@@ -7563,32 +7489,32 @@ int64 FindString (const char *buf, const char *str, int64 bufLen, int64 strLen,
}
// Returns TRUE if the file or directory exists (both may be enclosed in quotation marks).
-BOOL FileExists (const char *filePathPtr)
+BOOL FileExists (const wchar_t *filePathPtr)
{
- char filePath [TC_MAX_PATH * 2 + 1];
+ wchar_t filePath [TC_MAX_PATH * 2 + 1];
// Strip quotation marks (if any)
- if (filePathPtr [0] == '"')
+ if (filePathPtr [0] == L'"')
{
- StringCbCopyA (filePath, sizeof(filePath), filePathPtr + 1);
+ StringCbCopyW (filePath, sizeof(filePath), filePathPtr + 1);
}
else
{
- StringCbCopyA (filePath, sizeof(filePath), filePathPtr);
+ StringCbCopyW (filePath, sizeof(filePath), filePathPtr);
}
// Strip quotation marks (if any)
- if (filePath [strlen (filePath) - 1] == '"')
- filePath [strlen (filePath) - 1] = 0;
+ if (filePath [wcslen (filePath) - 1] == L'"')
+ filePath [wcslen (filePath) - 1] = 0;
- return (_access (filePath, 0) != -1);
+ return (_waccess (filePath, 0) != -1);
}
// Searches the file from its end for the LAST occurrence of the string str.
// The string may contain zeroes, which do NOT terminate the string.
// If the string is found, its offset from the start of the file is returned.
// If the string isn't found or if any error occurs, -1 is returned.
-__int64 FindStringInFile (const char *filePath, const char* str, int strLen)
+__int64 FindStringInFile (const wchar_t *filePath, const char* str, int strLen)
{
int bufSize = 64 * BYTES_PER_KB;
char *buffer = (char *) err_malloc (bufSize);
@@ -7706,31 +7632,7 @@ BOOL TCCopyFileBase (HANDLE src, HANDLE dst)
return res != 0;
}
-BOOL TCCopyFile (char *sourceFileName, char *destinationFile)
-{
- HANDLE src, dst;
-
- src = CreateFile (sourceFileName,
- GENERIC_READ,
- FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
-
- if (src == INVALID_HANDLE_VALUE)
- return FALSE;
-
- dst = CreateFile (destinationFile,
- GENERIC_WRITE,
- 0, NULL, CREATE_ALWAYS, 0, NULL);
-
- if (dst == INVALID_HANDLE_VALUE)
- {
- CloseHandle (src);
- return FALSE;
- }
-
- return TCCopyFileBase (src, dst);
-}
-
-BOOL TCCopyFileW (wchar_t *sourceFileName, wchar_t *destinationFile)
+BOOL TCCopyFile (wchar_t *sourceFileName, wchar_t *destinationFile)
{
HANDLE src, dst;
@@ -7756,7 +7658,7 @@ BOOL TCCopyFileW (wchar_t *sourceFileName, wchar_t *destinationFile)
// If bAppend is TRUE, the buffer is appended to an existing file. If bAppend is FALSE, any existing file
// is replaced. If an error occurs, the incomplete file is deleted (provided that bAppend is FALSE).
-BOOL SaveBufferToFile (const char *inputBuffer, const char *destinationFile, DWORD inputLength, BOOL bAppend, BOOL bRenameIfFailed)
+BOOL SaveBufferToFile (const char *inputBuffer, const wchar_t *destinationFile, DWORD inputLength, BOOL bAppend, BOOL bRenameIfFailed)
{
HANDLE dst;
DWORD bytesWritten;
@@ -7770,9 +7672,9 @@ BOOL SaveBufferToFile (const char *inputBuffer, const char *destinationFile, DWO
dwLastError = GetLastError();
if (!bAppend && bRenameIfFailed && (dst == INVALID_HANDLE_VALUE) && (GetLastError () == ERROR_SHARING_VIOLATION))
{
- char renamedPath[TC_MAX_PATH + 1];
- StringCbCopyA (renamedPath, sizeof(renamedPath), destinationFile);
- StringCbCatA (renamedPath, sizeof(renamedPath), VC_FILENAME_RENAMED_SUFFIX);
+ wchar_t renamedPath[TC_MAX_PATH + 1];
+ StringCbCopyW (renamedPath, sizeof(renamedPath), destinationFile);
+ StringCbCatW (renamedPath, sizeof(renamedPath), VC_FILENAME_RENAMED_SUFFIX);
/* rename the locked file in order to be able to create a new one */
if (MoveFileEx (destinationFile, renamedPath, MOVEFILE_REPLACE_EXISTING))
@@ -7821,7 +7723,7 @@ BOOL SaveBufferToFile (const char *inputBuffer, const char *destinationFile, DWO
CloseHandle (dst);
if (!res && !bAppend)
- remove (destinationFile);
+ _wremove (destinationFile);
return res;
}
@@ -7844,62 +7746,62 @@ BOOL TCFlushFile (FILE *f)
// Prints a UTF-16 text (note that this involves a real printer, not a screen).
// textByteLen - length of the text in bytes
// title - printed as part of the page header and used as the filename for a temporary file
-BOOL PrintHardCopyTextUTF16 (wchar_t *text, char *title, size_t textByteLen)
+BOOL PrintHardCopyTextUTF16 (wchar_t *text, wchar_t *title, size_t textByteLen)
{
- char cl [MAX_PATH*3] = {"/p \""};
- char path [MAX_PATH * 2] = { 0 };
- char filename [MAX_PATH + 1] = { 0 };
+ wchar_t cl [MAX_PATH*3] = {L"/p \""};
+ wchar_t path [MAX_PATH * 2] = { 0 };
+ wchar_t filename [MAX_PATH + 1] = { 0 };
- StringCbCopyA (filename, sizeof(filename), title);
+ StringCbCopyW (filename, sizeof(filename), title);
//strcat (filename, ".txt");
- GetTempPath (sizeof (path), path);
+ GetTempPath (ARRAYSIZE (path), path);
if (!FileExists (path))
{
- StringCbCopyA (path, sizeof(path), GetConfigPath (filename));
+ StringCbCopyW (path, sizeof(path), GetConfigPath (filename));
- if (strlen(path) < 2)
+ if (wcslen(path) < 2)
return FALSE;
}
else
{
- StringCbCatA (path, sizeof(path), filename);
+ StringCbCatW (path, sizeof(path), filename);
}
// Write the Unicode signature
if (!SaveBufferToFile ("\xFF\xFE", path, 2, FALSE, FALSE))
{
- remove (path);
+ _wremove (path);
return FALSE;
}
// Write the actual text
if (!SaveBufferToFile ((char *) text, path, (DWORD) textByteLen, TRUE, FALSE))
{
- remove (path);
+ _wremove (path);
return FALSE;
}
- StringCbCatA (cl, sizeof(cl), path);
- StringCbCatA (cl, sizeof(cl), "\"");
+ StringCbCatW (cl, sizeof(cl), path);
+ StringCbCatW (cl, sizeof(cl), L"\"");
// Get the absolute path for notepad
if (GetWindowsDirectory(filename, MAX_PATH))
{
- if (filename[strlen (filename) - 1] != '\\')
- StringCbCatA (filename, sizeof(filename), "\\");
- StringCbCatA(filename, sizeof(filename), PRINT_TOOL);
+ if (filename[wcslen (filename) - 1] != L'\\')
+ StringCbCatW (filename, sizeof(filename), L"\\");
+ StringCbCatW(filename, sizeof(filename), PRINT_TOOL);
}
else
- StringCbCopyA(filename, sizeof(filename), "C:\\Windows\\" PRINT_TOOL);
+ StringCbCopyW(filename, sizeof(filename), L"C:\\Windows\\" PRINT_TOOL);
WaitCursor ();
- ShellExecute (NULL, "open", filename, cl, NULL, SW_HIDE);
+ ShellExecute (NULL, L"open", filename, cl, NULL, SW_HIDE);
Sleep (6000);
NormalCursor();
- remove (path);
+ _wremove (path);
return TRUE;
}
@@ -7937,13 +7839,13 @@ BOOL IsNonInstallMode ()
{
// The driver was not found in the system path
- char path[MAX_PATH * 2] = { 0 };
+ wchar_t path[MAX_PATH * 2] = { 0 };
// We can't use GetConfigPath() here because it would call us back (indirect recursion)
if (SUCCEEDED(SHGetFolderPath (NULL, CSIDL_APPDATA, NULL, 0, path)))
{
- StringCbCatA (path, MAX_PATH * 2, "\\VeraCrypt\\");
- StringCbCatA (path, MAX_PATH * 2, TC_APPD_FILENAME_SYSTEM_ENCRYPTION);
+ StringCbCatW (path, MAX_PATH * 2, L"\\VeraCrypt\\");
+ StringCbCatW (path, MAX_PATH * 2, TC_APPD_FILENAME_SYSTEM_ENCRYPTION);
if (FileExists (path))
{
@@ -7968,7 +7870,7 @@ BOOL IsNonInstallMode ()
// The following test may be unreliable in some cases (e.g. after the user selects restore "Last Known Good
// Configuration" from the Windows boot menu).
- if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\VeraCrypt", 0, KEY_READ | KEY_WOW64_32KEY, &hkey) == ERROR_SUCCESS)
+ if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\VeraCrypt", 0, KEY_READ | KEY_WOW64_32KEY, &hkey) == ERROR_SUCCESS)
{
RegCloseKey (hkey);
return FALSE;
@@ -8008,79 +7910,79 @@ void ManageStartupSeq (void)
{
if (!IsNonInstallMode ())
{
- char regk [64];
+ wchar_t regk [64];
GetStartupRegKeyName (regk, sizeof(regk));
if (bStartOnLogon || bMountDevicesOnLogon || bMountFavoritesOnLogon)
{
- char exe[MAX_PATH * 2] = { '"' };
+ wchar_t exe[MAX_PATH * 2] = { L'"' };
- GetModuleFileName (NULL, exe + 1, sizeof (exe) - 1);
+ GetModuleFileName (NULL, exe + 1, ARRAYSIZE (exe) - 1);
#ifdef VOLFORMAT
{
- char *tmp = NULL;
+ wchar_t *tmp = NULL;
- if (tmp = strrchr (exe, '\\'))
+ if (tmp = wcsrchr (exe, L'\\'))
{
*tmp = 0;
- StringCbCatA (exe, MAX_PATH * 2, "\\VeraCrypt.exe");
+ StringCbCatW (exe, MAX_PATH * 2, L"\\VeraCrypt.exe");
}
}
#endif
- StringCbCatA (exe, MAX_PATH * 2, "\" /q preferences /a logon");
+ StringCbCatW (exe, MAX_PATH * 2, L"\" /q preferences /a logon");
- if (bMountDevicesOnLogon) StringCbCatA (exe, MAX_PATH * 2, " /a devices");
- if (bMountFavoritesOnLogon) StringCbCatA (exe, MAX_PATH * 2, " /a favorites");
+ if (bMountDevicesOnLogon) StringCbCatW (exe, MAX_PATH * 2, L" /a devices");
+ if (bMountFavoritesOnLogon) StringCbCatW (exe, MAX_PATH * 2, L" /a favorites");
- WriteRegistryString (regk, "VeraCrypt", exe);
+ WriteRegistryString (regk, L"VeraCrypt", exe);
}
else
- DeleteRegistryValue (regk, "VeraCrypt");
+ DeleteRegistryValue (regk, L"VeraCrypt");
}
}
// Adds or removes the VeraCrypt Volume Creation Wizard to/from the system startup sequence
-void ManageStartupSeqWiz (BOOL bRemove, const char *arg)
+void ManageStartupSeqWiz (BOOL bRemove, const wchar_t *arg)
{
- char regk [64];
+ wchar_t regk [64];
GetStartupRegKeyName (regk, sizeof(regk));
if (!bRemove)
{
- size_t exeSize = (MAX_PATH * 2) + 3 + 20 + strlen (arg); // enough room for all concatenation operations
- char* exe = (char*) calloc(1, exeSize);
- exe[0] = '"';
+ size_t exeSize = (MAX_PATH * 2) + 3 + 20 + wcslen (arg); // enough room for all concatenation operations
+ wchar_t* exe = (wchar_t*) calloc(1, exeSize * sizeof (wchar_t));
+ exe[0] = L'"';
GetModuleFileName (NULL, exe + 1, (DWORD) (exeSize - 1));
#ifndef VOLFORMAT
{
- char *tmp = NULL;
+ wchar_t *tmp = NULL;
- if (tmp = strrchr (exe, '\\'))
+ if (tmp = wcsrchr (exe, L'\\'))
{
*tmp = 0;
- StringCbCatA (exe, exeSize, "\\VeraCrypt Format.exe");
+ StringCchCatW (exe, exeSize, L"\\VeraCrypt Format.exe");
}
}
#endif
- if (strlen (arg) > 0)
+ if (wcslen (arg) > 0)
{
- StringCbCatA (exe, exeSize, "\" ");
- StringCbCatA (exe, exeSize, arg);
+ StringCchCatW (exe, exeSize, L"\" ");
+ StringCchCatW (exe, exeSize, arg);
}
- WriteRegistryString (regk, "VeraCrypt Format", exe);
+ WriteRegistryString (regk, L"VeraCrypt Format", exe);
free(exe);
}
else
- DeleteRegistryValue (regk, "VeraCrypt Format");
+ DeleteRegistryValue (regk, L"VeraCrypt Format");
}
@@ -8091,19 +7993,19 @@ void CleanLastVisitedMRU (void)
WCHAR *strToMatch;
WCHAR strTmp[4096];
- char regPath[128];
- char key[64];
+ WCHAR regPath[128];
+ WCHAR key[64];
int id, len;
GetModuleFileNameW (NULL, exeFilename, sizeof (exeFilename) / sizeof(exeFilename[0]));
- strToMatch = wcsrchr (exeFilename, '\\') + 1;
+ strToMatch = wcsrchr (exeFilename, L'\\') + 1;
- StringCbPrintfA (regPath, sizeof(regPath), "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComDlg32\\LastVisited%sMRU", IsOSAtLeast (WIN_VISTA) ? "Pidl" : "");
+ StringCbPrintfW (regPath, sizeof(regPath), L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComDlg32\\LastVisited%sMRU", IsOSAtLeast (WIN_VISTA) ? L"Pidl" : L"");
- for (id = (IsOSAtLeast (WIN_VISTA) ? 0 : 'a'); id <= (IsOSAtLeast (WIN_VISTA) ? 1000 : 'z'); id++)
+ for (id = (IsOSAtLeast (WIN_VISTA) ? 0 : L'a'); id <= (IsOSAtLeast (WIN_VISTA) ? 1000 : L'z'); id++)
{
*strTmp = 0;
- StringCbPrintfA (key, sizeof(key), (IsOSAtLeast (WIN_VISTA) ? "%d" : "%c"), id);
+ StringCbPrintfW (key, sizeof(key), (IsOSAtLeast (WIN_VISTA) ? L"%d" : L"%c"), id);
if ((len = ReadRegistryBytes (regPath, key, (char *) strTmp, sizeof (strTmp))) > 0)
{
@@ -8125,7 +8027,7 @@ void CleanLastVisitedMRU (void)
int *pout = (int *)bufout;
int l;
- l = len = ReadRegistryBytes ("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComDlg32\\LastVisitedPidlMRU", "MRUListEx", buf, sizeof (buf));
+ l = len = ReadRegistryBytes (L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComDlg32\\LastVisitedPidlMRU", L"MRUListEx", buf, sizeof (buf));
while (l > 0)
{
l -= sizeof (int);
@@ -8139,14 +8041,14 @@ void CleanLastVisitedMRU (void)
*pout++ = *p++;
}
- WriteRegistryBytes ("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComDlg32\\LastVisitedPidlMRU", "MRUListEx", bufout, len);
+ WriteRegistryBytes (L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComDlg32\\LastVisitedPidlMRU", L"MRUListEx", bufout, len);
}
else
{
- char *p = buf;
- char *pout = bufout;
+ wchar_t *p = (wchar_t*) buf;
+ wchar_t *pout = (wchar_t*) bufout;
- ReadRegistryString ("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComDlg32\\LastVisitedMRU", "MRUList", "", buf, sizeof (buf));
+ ReadRegistryString (L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComDlg32\\LastVisitedMRU", L"MRUList", L"", (wchar_t*) buf, sizeof (buf));
while (*p)
{
if (*p == id)
@@ -8158,7 +8060,7 @@ void CleanLastVisitedMRU (void)
}
*pout++ = 0;
- WriteRegistryString ("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComDlg32\\LastVisitedMRU", "MRUList", bufout);
+ WriteRegistryString (L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComDlg32\\LastVisitedMRU", L"MRUList", (wchar_t*) bufout);
}
break;
@@ -8183,58 +8085,32 @@ void ClearHistory (HWND hwndDlgItem)
#endif // #ifndef SETUP
-LRESULT ListItemAdd (HWND list, int index, char *string)
+LRESULT ListItemAdd (HWND list, int index, const wchar_t *string)
{
LVITEM li;
memset (&li, 0, sizeof(li));
li.mask = LVIF_TEXT;
- li.pszText = string;
+ li.pszText = (wchar_t*) string;
li.iItem = index;
li.iSubItem = 0;
return ListView_InsertItem (list, &li);
}
-LRESULT ListItemAddW (HWND list, int index, wchar_t *string)
-{
- LVITEMW li;
- memset (&li, 0, sizeof(li));
-
- li.mask = LVIF_TEXT;
- li.pszText = string;
- li.iItem = index;
- li.iSubItem = 0;
- return SendMessageW (list, LVM_INSERTITEMW, 0, (LPARAM)(&li));
-}
-
-
-LRESULT ListSubItemSet (HWND list, int index, int subIndex, char *string)
+LRESULT ListSubItemSet (HWND list, int index, int subIndex, const wchar_t *string)
{
LVITEM li;
memset (&li, 0, sizeof(li));
li.mask = LVIF_TEXT;
- li.pszText = string;
+ li.pszText = (wchar_t*) string;
li.iItem = index;
li.iSubItem = subIndex;
return ListView_SetItem (list, &li);
}
-LRESULT ListSubItemSetW (HWND list, int index, int subIndex, wchar_t *string)
-{
- LVITEMW li;
- memset (&li, 0, sizeof(li));
-
- li.mask = LVIF_TEXT;
- li.pszText = string;
- li.iItem = index;
- li.iSubItem = subIndex;
- return SendMessageW (list, LVM_SETITEMW, 0, (LPARAM)(&li));
-}
-
-
BOOL GetMountList (MOUNT_LIST_STRUCT *list)
{
DWORD dwResult;
@@ -8263,7 +8139,7 @@ int GetDriverRefCount ()
// Loads a 32-bit integer from the file at the specified file offset. The saved value is assumed to have been
// processed by mputLong(). The result is stored in *result. Returns TRUE if successful (otherwise FALSE).
-BOOL LoadInt32 (char *filePath, unsigned __int32 *result, __int64 fileOffset)
+BOOL LoadInt32 (const wchar_t *filePath, unsigned __int32 *result, __int64 fileOffset)
{
DWORD bufSize = sizeof(__int32);
unsigned char *buffer = (unsigned char *) malloc (bufSize);
@@ -8307,7 +8183,7 @@ fsif_end:
// Loads a 16-bit integer from the file at the specified file offset. The saved value is assumed to have been
// processed by mputWord(). The result is stored in *result. Returns TRUE if successful (otherwise FALSE).
-BOOL LoadInt16 (char *filePath, int *result, __int64 fileOffset)
+BOOL LoadInt16 (const wchar_t *filePath, int *result, __int64 fileOffset)
{
DWORD bufSize = sizeof(__int16);
unsigned char *buffer = (unsigned char *) malloc (bufSize);
@@ -8350,7 +8226,7 @@ fsif_end:
}
// Returns NULL if there's any error. Although the buffer can contain binary data, it is always null-terminated.
-char *LoadFile (const char *fileName, DWORD *size)
+char *LoadFile (const wchar_t *fileName, DWORD *size)
{
char *buf;
DWORD fileSize = INVALID_FILE_SIZE;
@@ -8385,7 +8261,7 @@ char *LoadFile (const char *fileName, DWORD *size)
// Returns NULL if there's any error.
-char *LoadFileBlock (char *fileName, __int64 fileOffset, DWORD count)
+char *LoadFileBlock (const wchar_t *fileName, __int64 fileOffset, DWORD count)
{
char *buf;
DWORD bytesRead = 0;
@@ -8427,7 +8303,7 @@ char *LoadFileBlock (char *fileName, __int64 fileOffset, DWORD count)
// Returns -1 if there is an error, or the size of the file.
-__int64 GetFileSize64 (const char *path)
+__int64 GetFileSize64 (const wchar_t *path)
{
HANDLE h = CreateFile (path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
LARGE_INTEGER size;
@@ -8447,33 +8323,33 @@ __int64 GetFileSize64 (const char *path)
}
-char *GetModPath (char *path, int maxSize)
+wchar_t *GetModPath (wchar_t *path, int maxSize)
{
GetModuleFileName (NULL, path, maxSize);
- char* ptr = strrchr (path, '\\');
+ wchar_t* ptr = wcsrchr (path, L'\\');
if (ptr)
ptr[1] = 0;
return path;
}
-char *GetConfigPath (char *fileName)
+wchar_t *GetConfigPath (wchar_t *fileName)
{
- static char path[MAX_PATH * 2] = { 0 };
+ static wchar_t path[MAX_PATH * 2] = { 0 };
if (IsNonInstallMode ())
{
- GetModPath (path, sizeof (path));
- StringCbCatA (path, (MAX_PATH * 2), fileName);
+ GetModPath (path, ARRAYSIZE (path));
+ StringCchCatW (path, (MAX_PATH * 2), fileName);
return path;
}
if (SUCCEEDED(SHGetFolderPath (NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, path)))
{
- StringCbCatA (path, (MAX_PATH * 2), "\\VeraCrypt\\");
+ StringCchCatW (path, (MAX_PATH * 2), L"\\VeraCrypt\\");
CreateDirectory (path, NULL);
- StringCbCatA (path, (MAX_PATH * 2), fileName);
+ StringCchCatW (path, (MAX_PATH * 2), fileName);
}
else
path[0] = 0;
@@ -8482,15 +8358,15 @@ char *GetConfigPath (char *fileName)
}
-char *GetProgramConfigPath (char *fileName)
+wchar_t *GetProgramConfigPath (wchar_t *fileName)
{
- static char path[MAX_PATH * 2] = { 0 };
+ static wchar_t path[MAX_PATH * 2] = { 0 };
if (SUCCEEDED (SHGetFolderPath (NULL, CSIDL_COMMON_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, path)))
{
- StringCbCatA (path, (MAX_PATH * 2), "\\VeraCrypt\\");
+ StringCchCatW (path, (MAX_PATH * 2), L"\\VeraCrypt\\");
CreateDirectory (path, NULL);
- StringCbCatA (path, (MAX_PATH * 2), fileName);
+ StringCchCatW (path, (MAX_PATH * 2), fileName);
}
else
path[0] = 0;
@@ -8499,31 +8375,31 @@ char *GetProgramConfigPath (char *fileName)
}
-std::string GetServiceConfigPath (const char *fileName, bool useLegacy)
+std::wstring GetServiceConfigPath (const wchar_t *fileName, bool useLegacy)
{
- char sysPath[TC_MAX_PATH];
+ wchar_t sysPath[TC_MAX_PATH];
if (Is64BitOs() && useLegacy)
{
- typedef UINT (WINAPI *GetSystemWow64Directory_t) (LPTSTR lpBuffer, UINT uSize);
+ typedef UINT (WINAPI *GetSystemWow64Directory_t) (LPWSTR lpBuffer, UINT uSize);
- GetSystemWow64Directory_t getSystemWow64Directory = (GetSystemWow64Directory_t) GetProcAddress (GetModuleHandle ("kernel32"), "GetSystemWow64DirectoryA");
- getSystemWow64Directory (sysPath, sizeof (sysPath));
+ GetSystemWow64Directory_t getSystemWow64Directory = (GetSystemWow64Directory_t) GetProcAddress (GetModuleHandle (L"kernel32"), "GetSystemWow64DirectoryW");
+ getSystemWow64Directory (sysPath, ARRAYSIZE (sysPath));
}
else
- GetSystemDirectory (sysPath, sizeof (sysPath));
+ GetSystemDirectory (sysPath, ARRAYSIZE (sysPath));
- return string (sysPath) + "\\" + fileName;
+ return wstring (sysPath) + L"\\" + fileName;
}
// Returns 0 if an error occurs or the drive letter (as an upper-case char) of the system partition (e.g. 'C');
-char GetSystemDriveLetter (void)
+wchar_t GetSystemDriveLetter (void)
{
- char systemDir [MAX_PATH];
+ wchar_t systemDir [MAX_PATH];
- if (GetSystemDirectory (systemDir, sizeof (systemDir)))
- return (char) (toupper (systemDir [0]));
+ if (GetSystemDirectory (systemDir, ARRAYSIZE (systemDir)))
+ return (wchar_t) (towupper (systemDir [0]));
else
return 0;
}
@@ -8826,7 +8702,7 @@ BOOL ConfigWriteBegin ()
if (ConfigBuffer == NULL)
ConfigBuffer = LoadFile (GetConfigPath (TC_APPD_FILENAME_CONFIGURATION), &size);
- ConfigFileHandle = fopen (GetConfigPath (TC_APPD_FILENAME_CONFIGURATION), "w");
+ ConfigFileHandle = _wfopen (GetConfigPath (TC_APPD_FILENAME_CONFIGURATION), L"w,ccs=UTF-8");
if (ConfigFileHandle == NULL)
{
free (ConfigBuffer);
@@ -8834,7 +8710,7 @@ BOOL ConfigWriteBegin ()
return FALSE;
}
XmlWriteHeader (ConfigFileHandle);
- fputs ("\n\t<configuration>", ConfigFileHandle);
+ fputws (L"\n\t<configuration>", ConfigFileHandle);
return TRUE;
}
@@ -8853,11 +8729,11 @@ BOOL ConfigWriteEnd (HWND hwnd)
XmlGetAttributeText (xml, "key", key, sizeof (key));
XmlGetNodeText (xml, value, sizeof (value));
- fprintf (ConfigFileHandle, "\n\t\t<config key=\"%s\">%s</config>", key, value);
+ fwprintf (ConfigFileHandle, L"\n\t\t<config key=\"%hs\">%hs</config>", key, value);
xml++;
}
- fputs ("\n\t</configuration>", ConfigFileHandle);
+ fputws (L"\n\t</configuration>", ConfigFileHandle);
XmlWriteFooter (ConfigFileHandle);
TCFlushFile (ConfigFileHandle);
@@ -8892,11 +8768,29 @@ BOOL ConfigWriteString (char *configKey, char *configValue)
c[1] = '!';
}
- return 0 != fprintf (
- ConfigFileHandle, "\n\t\t<config key=\"%s\">%s</config>",
+ return 0 != fwprintf (
+ ConfigFileHandle, L"\n\t\t<config key=\"%hs\">%hs</config>",
configKey, configValue);
}
+BOOL ConfigWriteStringW (char *configKey, wchar_t *configValue)
+{
+ char *c;
+ if (ConfigFileHandle == NULL)
+ return FALSE;
+
+ // Mark previous config value as updated
+ if (ConfigBuffer != NULL)
+ {
+ c = XmlFindElementByAttributeValue (ConfigBuffer, "config", "key", configKey);
+ if (c != NULL)
+ c[1] = '!';
+ }
+
+ return 0 != fwprintf (
+ ConfigFileHandle, L"\n\t\t<config key=\"%hs\">%ls</config>",
+ configKey, configValue);
+}
BOOL ConfigWriteInt (char *configKey, int configValue)
{
@@ -8992,12 +8886,12 @@ void ConfigReadCompareString (char *configKey, char *defaultValue, char *str, in
void OpenPageHelp (HWND hwndDlg, int nPage)
{
- int r = (int)ShellExecute (NULL, "open", szHelpFile, NULL, NULL, SW_SHOWNORMAL);
+ int r = (int)ShellExecuteW (NULL, L"open", szHelpFile, NULL, NULL, SW_SHOWNORMAL);
if (r == ERROR_FILE_NOT_FOUND)
{
// Try the secondary help file
- r = (int)ShellExecute (NULL, "open", szHelpFile2, NULL, NULL, SW_SHOWNORMAL);
+ r = (int)ShellExecuteW (NULL, L"open", szHelpFile2, NULL, NULL, SW_SHOWNORMAL);
if (r == ERROR_FILE_NOT_FOUND)
{
@@ -9053,8 +8947,13 @@ BOOL LoadDefaultKeyFilesParam (void)
kf = (KeyFile *) malloc (sizeof (KeyFile));
if (kf)
{
- if (XmlGetNodeText (xml, kf->FileName, sizeof (kf->FileName)) != NULL)
+ char fileName [MAX_PATH + 1];
+ if (XmlGetNodeText (xml, fileName, sizeof (fileName)) != NULL)
+ {
+ std::wstring wszFileName = Utf8StringToWide(fileName);
+ StringCbCopyW (kf->FileName, sizeof (kf->FileName), wszFileName.c_str ());
defaultKeyFilesParam.FirstKeyFile = KeyFileAdd (defaultKeyFilesParam.FirstKeyFile, kf);
+ }
else
free (kf);
}
@@ -9087,7 +8986,7 @@ void Debug (char *format, ...)
StringCbVPrintfA (buf, sizeof (buf), format, val);
va_end(val);
- OutputDebugString (buf);
+ OutputDebugStringA (buf);
}
@@ -9100,7 +8999,7 @@ void DebugMsgBox (char *format, ...)
StringCbVPrintfA (buf, sizeof (buf), format, val);
va_end(val);
- MessageBox (MainDlg, buf, "VeraCrypt debug", 0);
+ MessageBoxA (MainDlg, buf, "VeraCrypt debug", 0);
}
@@ -9154,7 +9053,7 @@ BOOL Is64BitOs ()
if (valid)
return isWow64;
- fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress (GetModuleHandle("kernel32"), "IsWow64Process");
+ fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress (GetModuleHandle(L"kernel32"), "IsWow64Process");
if (fnIsWow64Process != NULL)
if (!fnIsWow64Process (GetCurrentProcess(), &isWow64))
@@ -9204,7 +9103,7 @@ BOOL IsHiddenOSRunning (void)
BOOL EnableWow64FsRedirection (BOOL enable)
{
typedef BOOLEAN (__stdcall *Wow64EnableWow64FsRedirection_t) (BOOL enable);
- Wow64EnableWow64FsRedirection_t wow64EnableWow64FsRedirection = (Wow64EnableWow64FsRedirection_t) GetProcAddress (GetModuleHandle ("kernel32"), "Wow64EnableWow64FsRedirection");
+ Wow64EnableWow64FsRedirection_t wow64EnableWow64FsRedirection = (Wow64EnableWow64FsRedirection_t) GetProcAddress (GetModuleHandle (L"kernel32"), "Wow64EnableWow64FsRedirection");
if (!wow64EnableWow64FsRedirection)
return FALSE;
@@ -9246,23 +9145,23 @@ BOOL RestartComputer (void)
}
-std::string GetWindowsEdition ()
+std::wstring GetWindowsEdition ()
{
- string osname = "win";
+ wstring osname = L"win";
- OSVERSIONINFOEXA osVer;
+ OSVERSIONINFOEXW osVer;
osVer.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEXA);
- GetVersionExA ((LPOSVERSIONINFOA) &osVer);
+ GetVersionExW ((LPOSVERSIONINFOW) &osVer);
BOOL home = (osVer.wSuiteMask & VER_SUITE_PERSONAL);
BOOL server = (osVer.wProductType == VER_NT_SERVER || osVer.wProductType == VER_NT_DOMAIN_CONTROLLER);
HKEY hkey;
- char productName[300] = {0};
+ wchar_t productName[300] = {0};
DWORD productNameSize = sizeof (productName);
- if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS)
+ if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS)
{
- if (RegQueryValueEx (hkey, "ProductName", 0, 0, (LPBYTE) &productName, &productNameSize) != ERROR_SUCCESS || productNameSize < 1)
+ if (RegQueryValueEx (hkey, L"ProductName", 0, 0, (LPBYTE) &productName, &productNameSize) != ERROR_SUCCESS || productNameSize < 1)
productName[0] = 0;
RegCloseKey (hkey);
@@ -9271,75 +9170,75 @@ std::string GetWindowsEdition ()
switch (nCurrentOS)
{
case WIN_2000:
- osname += "2000";
+ osname += L"2000";
break;
case WIN_XP:
case WIN_XP64:
- osname += "xp";
- osname += home ? "-home" : "-pro";
+ osname += L"xp";
+ osname += home ? L"-home" : L"-pro";
break;
case WIN_SERVER_2003:
- osname += "2003";
+ osname += L"2003";
break;
case WIN_VISTA:
- osname += "vista";
+ osname += L"vista";
break;
case WIN_SERVER_2008:
- osname += "2008";
+ osname += L"2008";
break;
case WIN_7:
- osname += "7";
+ osname += L"7";
break;
case WIN_SERVER_2008_R2:
- osname += "2008r2";
+ osname += L"2008r2";
break;
default:
- stringstream s;
- s << CurrentOSMajor << "." << CurrentOSMinor;
+ wstringstream s;
+ s << CurrentOSMajor << L"." << CurrentOSMinor;
osname += s.str();
break;
}
if (server)
- osname += "-server";
+ osname += L"-server";
if (IsOSAtLeast (WIN_VISTA))
{
if (home)
- osname += "-home";
- else if (strstr (productName, "Standard") != 0)
- osname += "-standard";
- else if (strstr (productName, "Professional") != 0)
- osname += "-pro";
- else if (strstr (productName, "Business") != 0)
- osname += "-business";
- else if (strstr (productName, "Enterprise") != 0)
- osname += "-enterprise";
- else if (strstr (productName, "Datacenter") != 0)
- osname += "-datacenter";
- else if (strstr (productName, "Ultimate") != 0)
- osname += "-ultimate";
+ osname += L"-home";
+ else if (wcsstr (productName, L"Standard") != 0)
+ osname += L"-standard";
+ else if (wcsstr (productName, L"Professional") != 0)
+ osname += L"-pro";
+ else if (wcsstr (productName, L"Business") != 0)
+ osname += L"-business";
+ else if (wcsstr (productName, L"Enterprise") != 0)
+ osname += L"-enterprise";
+ else if (wcsstr (productName, L"Datacenter") != 0)
+ osname += L"-datacenter";
+ else if (wcsstr (productName, L"Ultimate") != 0)
+ osname += L"-ultimate";
}
if (GetSystemMetrics (SM_STARTER))
- osname += "-starter";
- else if (strstr (productName, "Basic") != 0)
- osname += "-basic";
+ osname += L"-starter";
+ else if (wcsstr (productName, L"Basic") != 0)
+ osname += L"-basic";
if (Is64BitOs())
- osname += "-x64";
+ osname += L"-x64";
if (CurrentOSServicePack > 0)
{
- stringstream s;
- s << "-sp" << CurrentOSServicePack;
+ wstringstream s;
+ s << L"-sp" << CurrentOSServicePack;
osname += s.str();
}
@@ -9470,27 +9369,27 @@ void Applink (char *dest, BOOL bSendOS, char *extraOutput)
{
StringCbCopyA (url, sizeof (url),TC_APPLINK);
}
- ShellExecute (NULL, "open", url, NULL, NULL, SW_SHOWNORMAL);
+ ShellExecuteA (NULL, "open", url, NULL, NULL, SW_SHOWNORMAL);
Sleep (200);
NormalCursor ();
}
-char *RelativePath2Absolute (char *szFileName)
+wchar_t *RelativePath2Absolute (wchar_t *szFileName)
{
- if (szFileName[0] != '\\'
- && strchr (szFileName, ':') == 0
- && strstr (szFileName, "Volume{") != szFileName)
+ if (szFileName[0] != L'\\'
+ && wcschr (szFileName, L':') == 0
+ && wcsstr (szFileName, L"Volume{") != szFileName)
{
- char path[MAX_PATH*2];
+ wchar_t path[MAX_PATH*2];
GetCurrentDirectory (MAX_PATH, path);
- if (path[strlen (path) - 1] != '\\')
- StringCbCatA (path, (MAX_PATH * 2), "\\");
+ if (path[wcslen (path) - 1] != L'\\')
+ StringCbCatW (path, (MAX_PATH * 2), L"\\");
- StringCbCatA (path, (MAX_PATH * 2), szFileName);
- StringCbCopyA (szFileName, MAX_PATH + 1, path); // szFileName size is always at least (MAX_PATH + 1)
+ StringCbCatW (path, (MAX_PATH * 2), szFileName);
+ StringCbCopyW (szFileName, MAX_PATH + 1, path); // szFileName size is always at least (MAX_PATH + 1)
}
return szFileName;
@@ -9502,11 +9401,11 @@ void HandleDriveNotReadyError (HWND hwnd)
HKEY hkey = 0;
DWORD value = 0, size = sizeof (DWORD);
- if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\MountMgr",
+ if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\MountMgr",
0, KEY_READ, &hkey) != ERROR_SUCCESS)
return;
- if (RegQueryValueEx (hkey, "NoAutoMount", 0, 0, (LPBYTE) &value, &size) == ERROR_SUCCESS
+ if (RegQueryValueEx (hkey, L"NoAutoMount", 0, 0, (LPBYTE) &value, &size) == ERROR_SUCCESS
&& value != 0)
{
Warning ("SYS_AUTOMOUNT_DISABLED", hwnd);
@@ -9525,9 +9424,9 @@ BOOL CALLBACK CloseTCWindowsEnum (HWND hwnd, LPARAM lParam)
LONG_PTR userDataVal = GetWindowLongPtrW (hwnd, GWLP_USERDATA);
if ((userDataVal == (LONG_PTR) 'VERA') || (userDataVal == (LONG_PTR) 'TRUE')) // Prior to 1.0e, 'TRUE' was used for VeraCrypt dialogs
{
- char name[1024] = { 0 };
- GetWindowText (hwnd, name, sizeof (name) - 1);
- if (hwnd != MainDlg && strstr (name, "VeraCrypt"))
+ wchar_t name[1024] = { 0 };
+ GetWindowText (hwnd, name, ARRAYSIZE (name) - 1);
+ if (hwnd != MainDlg && wcsstr (name, L"VeraCrypt"))
{
PostMessage (hwnd, TC_APPMSG_CLOSE_BKG_TASK, 0, 0);
@@ -9548,9 +9447,9 @@ BOOL CALLBACK FindTCWindowEnum (HWND hwnd, LPARAM lParam)
LONG_PTR userDataVal = GetWindowLongPtrW (hwnd, GWLP_USERDATA);
if ((userDataVal == (LONG_PTR) 'VERA') || (userDataVal == (LONG_PTR) 'TRUE')) // Prior to 1.0e, 'TRUE' was used for VeraCrypt dialogs
{
- char name[32] = { 0 };
- GetWindowText (hwnd, name, sizeof (name) - 1);
- if (hwnd != MainDlg && strcmp (name, "VeraCrypt") == 0)
+ wchar_t name[32] = { 0 };
+ GetWindowText (hwnd, name, ARRAYSIZE (name) - 1);
+ if (hwnd != MainDlg && wcscmp (name, L"VeraCrypt") == 0)
{
if (lParam != 0)
*((HWND *)lParam) = hwnd;
@@ -9560,7 +9459,7 @@ BOOL CALLBACK FindTCWindowEnum (HWND hwnd, LPARAM lParam)
}
-BYTE *MapResource (char *resourceType, int resourceId, PDWORD size)
+BYTE *MapResource (wchar_t *resourceType, int resourceId, PDWORD size)
{
HGLOBAL hResL;
HRSRC hRes;
@@ -9595,12 +9494,12 @@ void ReportUnexpectedState (char *techInfo)
#ifndef SETUP
-int OpenVolume (OpenVolumeContext *context, const char *volumePath, Password *password, int pkcs5_prf, int pim, BOOL truecryptMode, BOOL write, BOOL preserveTimestamps, BOOL useBackupHeader)
+int OpenVolume (OpenVolumeContext *context, const wchar_t *volumePath, Password *password, int pkcs5_prf, int pim, BOOL truecryptMode, BOOL write, BOOL preserveTimestamps, BOOL useBackupHeader)
{
int status = ERR_PARAMETER_INCORRECT;
int volumeType;
- 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];
LARGE_INTEGER headerOffset;
DWORD dwResult;
@@ -9628,7 +9527,7 @@ int OpenVolume (OpenVolumeContext *context, const char *volumePath, Password *pa
}
}
else
- StringCbCopyA (szCFDevice, sizeof(szCFDevice), szDiskFile);
+ StringCbCopyW (szCFDevice, sizeof(szCFDevice), szDiskFile);
if (preserveTimestamps)
write = TRUE;
@@ -9837,29 +9736,29 @@ BOOL IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly)
{
// GlobalMemoryStatusEx() cannot be used to determine if a paging file is active
- char data[65536];
+ wchar_t data[65536];
DWORD size = sizeof (data);
if (IsPagingFileWildcardActive())
return TRUE;
- if (ReadLocalMachineRegistryMultiString ("System\\CurrentControlSet\\Control\\Session Manager\\Memory Management", "PagingFiles", data, &size)
- && size > 12 && !checkNonWindowsPartitionsOnly)
+ if (ReadLocalMachineRegistryMultiString (L"System\\CurrentControlSet\\Control\\Session Manager\\Memory Management", L"PagingFiles", data, &size)
+ && size > 24 && !checkNonWindowsPartitionsOnly)
return TRUE;
if (!IsAdmin())
AbortProcess ("UAC_INIT_ERROR");
- for (char drive = 'C'; drive <= 'Z'; ++drive)
+ for (wchar_t drive = L'C'; drive <= L'Z'; ++drive)
{
// Query geometry of the drive first to prevent "no medium" pop-ups
- string drivePath = "\\\\.\\X:";
+ wstring drivePath = L"\\\\.\\X:";
drivePath[4] = drive;
if (checkNonWindowsPartitionsOnly)
{
- char sysDir[MAX_PATH];
- if (GetSystemDirectory (sysDir, sizeof (sysDir)) != 0 && toupper (sysDir[0]) == drive)
+ wchar_t sysDir[MAX_PATH];
+ if (GetSystemDirectory (sysDir, ARRAYSIZE (sysDir)) != 0 && towupper (sysDir[0]) == drive)
continue;
}
@@ -9880,7 +9779,7 @@ BOOL IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly)
CloseHandle (handle);
// Test if a paging file exists and is locked by another process
- string path = "X:\\pagefile.sys";
+ wstring path = L"X:\\pagefile.sys";
path[0] = drive;
handle = CreateFile (path.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
@@ -9897,25 +9796,25 @@ BOOL IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly)
BOOL IsPagingFileWildcardActive ()
{
- char pagingFiles[65536];
+ wchar_t pagingFiles[65536];
DWORD size = sizeof (pagingFiles);
- char *mmKey = "System\\CurrentControlSet\\Control\\Session Manager\\Memory Management";
+ wchar_t *mmKey = L"System\\CurrentControlSet\\Control\\Session Manager\\Memory Management";
- if (!ReadLocalMachineRegistryString (mmKey, "PagingFiles", pagingFiles, &size))
+ if (!ReadLocalMachineRegistryString (mmKey, L"PagingFiles", pagingFiles, &size))
{
size = sizeof (pagingFiles);
- if (!ReadLocalMachineRegistryMultiString (mmKey, "PagingFiles", pagingFiles, &size))
+ if (!ReadLocalMachineRegistryMultiString (mmKey, L"PagingFiles", pagingFiles, &size))
size = 0;
}
- return size > 0 && strstr (pagingFiles, "?:\\") == pagingFiles;
+ return size > 0 && wcsstr (pagingFiles, L"?:\\") == pagingFiles;
}
BOOL DisablePagingFile ()
{
- char empty[] = { 0, 0 };
- return WriteLocalMachineRegistryMultiString ("System\\CurrentControlSet\\Control\\Session Manager\\Memory Management", "PagingFiles", empty, sizeof (empty));
+ wchar_t empty[] = { 0, 0 };
+ return WriteLocalMachineRegistryMultiString (L"System\\CurrentControlSet\\Control\\Session Manager\\Memory Management", L"PagingFiles", empty, sizeof (empty));
}
@@ -10035,8 +9934,8 @@ BOOL CALLBACK SecurityTokenPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wPara
}
// Attempt to wipe password stored in the input field buffer
- char tmp[SecurityToken::MaxPasswordLength+1];
- memset (tmp, 'X', SecurityToken::MaxPasswordLength);
+ wchar_t tmp[SecurityToken::MaxPasswordLength+1];
+ wmemset (tmp, 'X', SecurityToken::MaxPasswordLength);
tmp[SecurityToken::MaxPasswordLength] = 0;
SetWindowText (GetDlgItem (hwndDlg, IDC_TOKEN_PASSWORD), tmp);
@@ -10162,12 +10061,12 @@ static void SecurityTokenKeyfileDlgFillList (HWND hwndDlg, const vector <Securit
lvItem.mask = LVIF_TEXT;
lvItem.iItem = line++;
- stringstream s;
+ wstringstream s;
s << keyfile.SlotId;
- ListItemAdd (tokenListControl, lvItem.iItem, (char *) s.str().c_str());
- ListSubItemSetW (tokenListControl, lvItem.iItem, 1, (wchar_t *) keyfile.Token.Label.c_str());
- ListSubItemSetW (tokenListControl, lvItem.iItem, 2, (wchar_t *) keyfile.Id.c_str());
+ ListItemAdd (tokenListControl, lvItem.iItem, (wchar_t *) s.str().c_str());
+ ListSubItemSet (tokenListControl, lvItem.iItem, 1, (wchar_t *) keyfile.Token.Label.c_str());
+ ListSubItemSet (tokenListControl, lvItem.iItem, 2, (wchar_t *) keyfile.Id.c_str());
}
BOOL selected = (ListView_GetNextItem (GetDlgItem (hwndDlg, IDC_TOKEN_FILE_LIST), -1, LVIS_SELECTED) != -1);
@@ -10293,7 +10192,7 @@ BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam
case IDC_IMPORT_KEYFILE:
{
- char keyfilePath[TC_MAX_PATH];
+ wchar_t keyfilePath[TC_MAX_PATH];
if (BrowseFiles (hwndDlg, "SELECT_KEYFILE", keyfilePath, bHistory, FALSE, NULL))
{
@@ -10308,7 +10207,7 @@ BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam
if (keyfileSize != 0)
{
NewSecurityTokenKeyfileDlgProcParams newParams;
- newParams.Name = WideToUtf8String (SingleStringToWide (keyfilePath));
+ newParams.Name = WideToUtf8String (keyfilePath);
size_t lastBackSlash = newParams.Name.find_last_of ('\\');
if (lastBackSlash != string::npos)
@@ -10356,7 +10255,7 @@ BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam
{
foreach (const SecurityTokenKeyfile &keyfile, SecurityTokenKeyfileDlgGetSelected (hwndDlg, keyfiles))
{
- char keyfilePath[TC_MAX_PATH];
+ wchar_t keyfilePath[TC_MAX_PATH];
if (!BrowseFiles (hwndDlg, "OPEN_TITLE", keyfilePath, bHistory, TRUE, NULL))
break;
@@ -10489,10 +10388,10 @@ std::vector <HostDevice> GetAvailableHostDevices (bool noDeviceProperties, bool
{
for (int partNumber = 0; partNumber < MAX_HOST_PARTITION_NUMBER; partNumber++)
{
- stringstream strm;
- strm << "\\Device\\Harddisk" << devNumber << "\\Partition" << partNumber;
- string devPathStr (strm.str());
- const char *devPath = devPathStr.c_str();
+ wstringstream strm;
+ strm << L"\\Device\\Harddisk" << devNumber << L"\\Partition" << partNumber;
+ wstring devPathStr (strm.str());
+ const wchar_t *devPath = devPathStr.c_str();
OPEN_TEST_STRUCT openTest = {0};
if (!OpenDevice (devPath, &openTest, detectUnencryptedFilesystems && partNumber != 0))
@@ -10521,20 +10420,18 @@ std::vector <HostDevice> GetAvailableHostDevices (bool noDeviceProperties, bool
{
DISK_GEOMETRY geometry;
- wstringstream ws;
- ws << devPathStr.c_str();
- int driveNumber = GetDiskDeviceDriveLetter ((wchar_t *) ws.str().c_str());
+ int driveNumber = GetDiskDeviceDriveLetter ((wchar_t *) devPathStr.c_str());
if (driveNumber >= 0)
{
- device.MountPoint += (char) (driveNumber + 'A');
- device.MountPoint += ":";
+ device.MountPoint += (wchar_t) (driveNumber + L'A');
+ device.MountPoint += L":";
wchar_t name[64];
if (GetDriveLabel (driveNumber, name, sizeof (name)))
device.Name = name;
- if (GetSystemDriveLetter() == 'A' + driveNumber)
+ if (GetSystemDriveLetter() == L'A' + driveNumber)
device.ContainsSystem = true;
}
@@ -10584,10 +10481,10 @@ std::vector <HostDevice> GetAvailableHostDevices (bool noDeviceProperties, bool
{
for (int devNumber = 0; devNumber < 256; devNumber++)
{
- stringstream strm;
- strm << "\\Device\\HarddiskVolume" << devNumber;
- string devPathStr (strm.str());
- const char *devPath = devPathStr.c_str();
+ wstringstream strm;
+ strm << L"\\Device\\HarddiskVolume" << devNumber;
+ wstring devPathStr (strm.str());
+ const wchar_t *devPath = devPathStr.c_str();
OPEN_TEST_STRUCT openTest = {0};
if (!OpenDevice (devPath, &openTest, detectUnencryptedFilesystems))
@@ -10606,20 +10503,18 @@ std::vector <HostDevice> GetAvailableHostDevices (bool noDeviceProperties, bool
if (!noDeviceProperties)
{
- wstringstream ws;
- ws << devPathStr.c_str();
- int driveNumber = GetDiskDeviceDriveLetter ((wchar_t *) ws.str().c_str());
+ int driveNumber = GetDiskDeviceDriveLetter ((wchar_t *) devPathStr.c_str());
if (driveNumber >= 0)
{
- device.MountPoint += (char) (driveNumber + 'A');
- device.MountPoint += ":";
+ device.MountPoint += (wchar_t) (driveNumber + L'A');
+ device.MountPoint += L":";
wchar_t name[64];
if (GetDriveLabel (driveNumber, name, sizeof (name)))
device.Name = name;
- if (GetSystemDriveLetter() == 'A' + driveNumber)
+ if (GetSystemDriveLetter() == L'A' + driveNumber)
device.ContainsSystem = true;
}
}
@@ -10633,17 +10528,17 @@ std::vector <HostDevice> GetAvailableHostDevices (bool noDeviceProperties, bool
}
-BOOL FileHasReadOnlyAttribute (const char *path)
+BOOL FileHasReadOnlyAttribute (const wchar_t *path)
{
DWORD attributes = GetFileAttributes (path);
return attributes != INVALID_FILE_ATTRIBUTES && (attributes & FILE_ATTRIBUTE_READONLY) != 0;
}
-BOOL IsFileOnReadOnlyFilesystem (const char *path)
+BOOL IsFileOnReadOnlyFilesystem (const wchar_t *path)
{
- char root[MAX_PATH];
- if (!GetVolumePathName (path, root, sizeof (root)))
+ wchar_t root[MAX_PATH];
+ if (!GetVolumePathName (path, root, ARRAYSIZE (root)))
return FALSE;
DWORD flags, d;
@@ -10657,13 +10552,13 @@ BOOL IsFileOnReadOnlyFilesystem (const char *path)
void CheckFilesystem (HWND hwndDlg, int driveNo, BOOL fixErrors)
{
wchar_t msg[1024], param[1024], cmdPath[MAX_PATH];
- char driveRoot[] = { 'A' + (char) driveNo, ':', 0 };
+ wchar_t driveRoot[] = { L'A' + (wchar_t) driveNo, L':', 0 };
if (fixErrors && AskWarnYesNo ("FILESYS_REPAIR_CONFIRM_BACKUP", hwndDlg) == IDNO)
return;
StringCbPrintfW (msg, sizeof(msg), GetString (fixErrors ? "REPAIRING_FS" : "CHECKING_FS"), driveRoot);
- StringCbPrintfW (param, sizeof(param), fixErrors ? L"/C echo %s & chkdsk %hs /F /X & pause" : L"/C echo %s & chkdsk %hs & pause", msg, driveRoot);
+ StringCbPrintfW (param, sizeof(param), fixErrors ? L"/C echo %s & chkdsk %s /F /X & pause" : L"/C echo %s & chkdsk %s & pause", msg, driveRoot);
if (GetSystemDirectoryW(cmdPath, MAX_PATH))
{
@@ -10741,37 +10636,37 @@ int AskNonSysInPlaceEncryptionResume (HWND hwndDlg, BOOL *pbDecrypt)
#endif // !SETUP
-BOOL RemoveDeviceWriteProtection (HWND hwndDlg, char *devicePath)
+BOOL RemoveDeviceWriteProtection (HWND hwndDlg, wchar_t *devicePath)
{
int driveNumber;
int partitionNumber;
- char temp[MAX_PATH*2];
- char cmdBatch[MAX_PATH*2];
- char diskpartScript[MAX_PATH*2];
+ wchar_t temp[MAX_PATH*2];
+ wchar_t cmdBatch[MAX_PATH*2];
+ wchar_t diskpartScript[MAX_PATH*2];
- if (sscanf (devicePath, "\\Device\\Harddisk%d\\Partition%d", &driveNumber, &partitionNumber) != 2)
+ if (swscanf (devicePath, L"\\Device\\Harddisk%d\\Partition%d", &driveNumber, &partitionNumber) != 2)
return FALSE;
- if (GetTempPath (sizeof (temp), temp) == 0)
+ if (GetTempPath (ARRAYSIZE (temp), temp) == 0)
return FALSE;
- StringCbPrintfA (cmdBatch, sizeof (cmdBatch), "%s\\VeraCrypt_Write_Protection_Removal.cmd", temp);
- StringCbPrintfA (diskpartScript, sizeof (diskpartScript), "%s\\VeraCrypt_Write_Protection_Removal.diskpart", temp);
+ StringCbPrintfW (cmdBatch, sizeof (cmdBatch), L"%s\\VeraCrypt_Write_Protection_Removal.cmd", temp);
+ StringCbPrintfW (diskpartScript, sizeof (diskpartScript), L"%s\\VeraCrypt_Write_Protection_Removal.diskpart", temp);
- FILE *f = fopen (cmdBatch, "w");
+ FILE *f = _wfopen (cmdBatch, L"w");
if (!f)
{
handleWin32Error (hwndDlg, SRC_POS);
return FALSE;
}
- fprintf (f, "@diskpart /s \"%s\"\n@pause\n@del \"%s\" \"%s\"", diskpartScript, diskpartScript, cmdBatch);
+ fwprintf (f, L"@diskpart /s \"%s\"\n@pause\n@del \"%s\" \"%s\"", diskpartScript, diskpartScript, cmdBatch);
CheckFileStreamWriteErrors (hwndDlg, f, cmdBatch);
fclose (f);
- f = fopen (diskpartScript, "w");
+ f = _wfopen (diskpartScript, L"w");
if (!f)
{
handleWin32Error (hwndDlg, SRC_POS);
@@ -10779,17 +10674,17 @@ BOOL RemoveDeviceWriteProtection (HWND hwndDlg, char *devicePath)
return FALSE;
}
- fprintf (f, "select disk %d\nattributes disk clear readonly\n", driveNumber);
+ fwprintf (f, L"select disk %d\nattributes disk clear readonly\n", driveNumber);
if (partitionNumber != 0)
- fprintf (f, "select partition %d\nattributes volume clear readonly\n", partitionNumber);
+ fwprintf (f, L"select partition %d\nattributes volume clear readonly\n", partitionNumber);
- fprintf (f, "exit\n");
+ fwprintf (f, L"exit\n");
CheckFileStreamWriteErrors (hwndDlg, f, diskpartScript);
fclose (f);
- ShellExecute (NULL, (!IsAdmin() && IsUacSupported()) ? "runas" : "open", cmdBatch, NULL, NULL, SW_SHOW);
+ ShellExecute (NULL, (!IsAdmin() && IsUacSupported()) ? L"runas" : L"open", cmdBatch, NULL, NULL, SW_SHOW);
return TRUE;
}
@@ -10846,25 +10741,25 @@ BOOL DisableFileCompression (HANDLE file)
}
-BOOL VolumePathExists (const char *volumePath)
+BOOL VolumePathExists (const wchar_t *volumePath)
{
OPEN_TEST_STRUCT openTest = {0};
- char upperCasePath[TC_MAX_PATH + 1];
+ wchar_t upperCasePath[TC_MAX_PATH + 1];
UpperCaseCopy (upperCasePath, sizeof(upperCasePath), volumePath);
- if (strstr (upperCasePath, "\\DEVICE\\") == upperCasePath)
+ if (wcsstr (upperCasePath, L"\\DEVICE\\") == upperCasePath)
return OpenDevice (volumePath, &openTest, FALSE);
- string path = volumePath;
- if (path.find ("\\\\?\\Volume{") == 0 && path.rfind ("}\\") == path.size() - 2)
+ wstring path = volumePath;
+ if (path.find (L"\\\\?\\Volume{") == 0 && path.rfind (L"}\\") == path.size() - 2)
{
- char devicePath[TC_MAX_PATH];
+ wchar_t devicePath[TC_MAX_PATH];
if (QueryDosDevice (path.substr (4, path.size() - 5).c_str(), devicePath, TC_MAX_PATH) != 0)
return TRUE;
}
- if (_access (volumePath, 0) == 0)
+ if (_waccess (volumePath, 0) == 0)
return TRUE;
else
{
@@ -10879,7 +10774,7 @@ BOOL VolumePathExists (const char *volumePath)
BOOL IsWindowsIsoBurnerAvailable ()
{
- char path[MAX_PATH*2] = { 0 };
+ wchar_t path[MAX_PATH*2] = { 0 };
if (!IsOSAtLeast (WIN_7))
{
@@ -10888,7 +10783,7 @@ BOOL IsWindowsIsoBurnerAvailable ()
if (SUCCEEDED(SHGetFolderPath (NULL, CSIDL_SYSTEM, NULL, 0, path)))
{
- StringCbCatA (path, MAX_PATH*2, "\\" ISO_BURNER_TOOL);
+ StringCbCatW (path, MAX_PATH*2, L"\\" ISO_BURNER_TOOL);
return (FileExists (path));
}
@@ -10897,17 +10792,17 @@ BOOL IsWindowsIsoBurnerAvailable ()
}
-BOOL LaunchWindowsIsoBurner (HWND hwnd, const char *isoPath)
+BOOL LaunchWindowsIsoBurner (HWND hwnd, const wchar_t *isoPath)
{
- char path[MAX_PATH*2] = { 0 };
+ wchar_t path[MAX_PATH*2] = { 0 };
int r;
if (SUCCEEDED(SHGetFolderPath (NULL, CSIDL_SYSTEM, NULL, 0, path)))
- StringCbCatA (path, MAX_PATH*2, "\\" ISO_BURNER_TOOL);
+ StringCbCatW (path, MAX_PATH*2, L"\\" ISO_BURNER_TOOL);
else
- StringCbCopyA (path, MAX_PATH*2, "C:\\Windows\\System32\\" ISO_BURNER_TOOL);
+ StringCbCopyW (path, MAX_PATH*2, L"C:\\Windows\\System32\\" ISO_BURNER_TOOL);
- r = (int) ShellExecute (hwnd, "open", path, (string ("\"") + isoPath + "\"").c_str(), NULL, SW_SHOWNORMAL);
+ r = (int) ShellExecute (hwnd, L"open", path, (wstring (L"\"") + isoPath + L"\"").c_str(), NULL, SW_SHOWNORMAL);
if (r <= 32)
{
@@ -10921,53 +10816,51 @@ BOOL LaunchWindowsIsoBurner (HWND hwnd, const char *isoPath)
}
-std::string VolumeGuidPathToDevicePath (std::string volumeGuidPath)
+std::wstring VolumeGuidPathToDevicePath (std::wstring volumeGuidPath)
{
- if (volumeGuidPath.find ("\\\\?\\") == 0)
+ if (volumeGuidPath.find (L"\\\\?\\") == 0)
volumeGuidPath = volumeGuidPath.substr (4);
- if (volumeGuidPath.find ("Volume{") != 0 || volumeGuidPath.rfind ("}\\") != volumeGuidPath.size() - 2)
- return string();
+ if (volumeGuidPath.find (L"Volume{") != 0 || volumeGuidPath.rfind (L"}\\") != volumeGuidPath.size() - 2)
+ return wstring();
- char volDevPath[TC_MAX_PATH];
+ wchar_t volDevPath[TC_MAX_PATH];
if (QueryDosDevice (volumeGuidPath.substr (0, volumeGuidPath.size() - 1).c_str(), volDevPath, TC_MAX_PATH) == 0)
- return string();
+ return wstring();
- string partitionPath = HarddiskVolumePathToPartitionPath (volDevPath);
+ wstring partitionPath = HarddiskVolumePathToPartitionPath (volDevPath);
return partitionPath.empty() ? volDevPath : partitionPath;
}
-std::string HarddiskVolumePathToPartitionPath (const std::string &harddiskVolumePath)
+std::wstring HarddiskVolumePathToPartitionPath (const std::wstring &harddiskVolumePath)
{
- wstring volPath = SingleStringToWide (harddiskVolumePath);
-
for (int driveNumber = 0; driveNumber < MAX_HOST_DRIVE_NUMBER; driveNumber++)
{
for (int partNumber = 0; partNumber < MAX_HOST_PARTITION_NUMBER; partNumber++)
{
wchar_t partitionPath[TC_MAX_PATH];
- swprintf_s (partitionPath, ARRAYSIZE (partitionPath), L"\\Device\\Harddisk%d\\Partition%d", driveNumber, partNumber);
+ StringCchPrintfW (partitionPath, ARRAYSIZE (partitionPath), L"\\Device\\Harddisk%d\\Partition%d", driveNumber, partNumber);
wchar_t resolvedPath[TC_MAX_PATH];
if (ResolveSymbolicLink (partitionPath, resolvedPath, sizeof(resolvedPath)))
{
- if (volPath == resolvedPath)
- return WideToSingleString (partitionPath);
+ if (harddiskVolumePath == resolvedPath)
+ return partitionPath;
}
else if (partNumber == 0)
break;
}
}
- return string();
+ return wstring();
}
-BOOL IsApplicationInstalled (const char *appName, BOOL b32bitApp)
+BOOL IsApplicationInstalled (const wchar_t *appName, BOOL b32bitApp)
{
- const char *uninstallRegName = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
+ const wchar_t *uninstallRegName = L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
BOOL installed = FALSE;
HKEY unistallKey;
LONG res = RegOpenKeyEx (HKEY_LOCAL_MACHINE, uninstallRegName, 0, KEY_READ | b32bitApp? KEY_WOW64_32KEY: KEY_WOW64_64KEY, &unistallKey);
@@ -10977,19 +10870,19 @@ BOOL IsApplicationInstalled (const char *appName, BOOL b32bitApp)
return FALSE;
}
- char regName[1024];
+ wchar_t regName[1024];
DWORD regNameSize = sizeof (regName);
DWORD index = 0;
while (RegEnumKeyEx (unistallKey, index++, regName, &regNameSize, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
{
- if (strstr (regName, "{") == regName)
+ if (wcsstr (regName, L"{") == regName)
{
regNameSize = sizeof (regName);
- if (!ReadLocalMachineRegistryStringNonReflected ((string (uninstallRegName) + "\\" + regName).c_str(), "DisplayName", regName, &regNameSize, b32bitApp))
+ if (!ReadLocalMachineRegistryStringNonReflected ((wstring (uninstallRegName) + L"\\" + regName).c_str(), L"DisplayName", regName, &regNameSize, b32bitApp))
regName[0] = 0;
}
- if (_stricmp (regName, appName) == 0)
+ if (_wcsicmp (regName, appName) == 0)
{
installed = TRUE;
break;
@@ -11003,19 +10896,19 @@ BOOL IsApplicationInstalled (const char *appName, BOOL b32bitApp)
}
-std::string FindLatestFileOrDirectory (const std::string &directory, const char *namePattern, bool findDirectory, bool findFile)
+std::wstring FindLatestFileOrDirectory (const std::wstring &directory, const wchar_t *namePattern, bool findDirectory, bool findFile)
{
- string name;
+ wstring name;
ULARGE_INTEGER latestTime;
latestTime.QuadPart = 0;
WIN32_FIND_DATA findData;
- HANDLE find = FindFirstFile ((directory + "\\" + namePattern).c_str(), &findData);
+ HANDLE find = FindFirstFile ((directory + L"\\" + namePattern).c_str(), &findData);
if (find != INVALID_HANDLE_VALUE)
{
do
{
- if (strcmp (findData.cFileName, ".") == 0 || strcmp (findData.cFileName, "..") == 0)
+ if (wcscmp (findData.cFileName, L".") == 0 || wcscmp (findData.cFileName, L"..") == 0)
continue;
ULARGE_INTEGER writeTime;
@@ -11040,7 +10933,7 @@ std::string FindLatestFileOrDirectory (const std::string &directory, const char
if (name.empty())
return name;
- return string (directory) + "\\" + name;
+ return wstring (directory) + L"\\" + name;
}
int GetPim (HWND hwndDlg, UINT ctrlId)
@@ -11049,12 +10942,12 @@ int GetPim (HWND hwndDlg, UINT ctrlId)
HWND hCtrl = GetDlgItem (hwndDlg, ctrlId);
if (IsWindowEnabled (hCtrl) && IsWindowVisible (hCtrl))
{
- char szTmp[MAX_PIM + 1] = {0};
+ wchar_t szTmp[MAX_PIM + 1] = {0};
if (GetDlgItemText (hwndDlg, ctrlId, szTmp, MAX_PIM + 1) > 0)
{
- char* endPtr = NULL;
- pim = strtol(szTmp, &endPtr, 10);
- if (pim < 0 || endPtr == szTmp || !endPtr || *endPtr != '\0')
+ wchar_t* endPtr = NULL;
+ pim = wcstol(szTmp, &endPtr, 10);
+ if (pim < 0 || endPtr == szTmp || !endPtr || *endPtr != L'\0')
pim = 0;
}
}
@@ -11065,12 +10958,49 @@ void SetPim (HWND hwndDlg, UINT ctrlId, int pim)
{
if (pim > 0)
{
- char szTmp[MAX_PIM + 1];
- StringCbPrintfA (szTmp, sizeof(szTmp), "%d", pim);
+ wchar_t szTmp[MAX_PIM + 1];
+ StringCbPrintfW (szTmp, sizeof(szTmp), L"%d", pim);
SetDlgItemText (hwndDlg, ctrlId, szTmp);
}
else
- SetDlgItemText (hwndDlg, ctrlId, "");
+ SetDlgItemText (hwndDlg, ctrlId, L"");
+}
+
+BOOL GetPassword (HWND hwndDlg, UINT ctrlID, char* passValue, int bufSize, BOOL bShowError)
+{
+ wchar_t tmp [MAX_PASSWORD + 1];
+ int utf8Len;
+ BOOL bRet = FALSE;
+
+ GetWindowText (GetDlgItem (hwndDlg, ctrlID), tmp, ARRAYSIZE (tmp));
+ utf8Len = WideCharToMultiByte (CP_UTF8, 0, tmp, -1, passValue, bufSize, NULL, NULL);
+ burn (tmp, sizeof (tmp));
+ if (utf8Len > 0)
+ {
+ bRet = TRUE;
+ }
+ else
+ {
+ passValue [0] = 0;
+ if (bShowError)
+ {
+ SetFocus (GetDlgItem(hwndDlg, ctrlID));
+ if (GetLastError () == ERROR_INSUFFICIENT_BUFFER)
+ Error ("PASSWORD_UTF8_TOO_LONG", hwndDlg);
+ else
+ Error ("PASSWORD_UTF8_INVALID", hwndDlg);
+ }
+ }
+
+ return bRet;
+}
+
+void SetPassword (HWND hwndDlg, UINT ctrlID, char* passValue)
+{
+ wchar_t tmp [MAX_PASSWORD + 1] = {0};
+ MultiByteToWideChar (CP_UTF8, 0, passValue, -1, tmp, MAX_PASSWORD + 1);
+ SetWindowText ( GetDlgItem (hwndDlg, ctrlID), tmp);
+ burn (tmp, sizeof (tmp));
}
void HandleShowPasswordFieldAction (HWND hwndDlg, UINT checkBoxId, UINT edit1Id, UINT edit2Id)
diff --git a/src/Common/Dlgcode.h b/src/Common/Dlgcode.h
index a7f4aff..2b6aee1 100644
--- a/src/Common/Dlgcode.h
+++ b/src/Common/Dlgcode.h
@@ -48,10 +48,10 @@ enum
#define TC_APPLICATION_ID L"IDRIX.VeraCrypt"
-#define TC_MUTEX_NAME_SYSENC "Global\\VeraCrypt System Encryption Wizard"
-#define TC_MUTEX_NAME_NONSYS_INPLACE_ENC "Global\\VeraCrypt In-Place Encryption Wizard"
-#define TC_MUTEX_NAME_APP_SETUP "Global\\VeraCrypt Setup"
-#define TC_MUTEX_NAME_DRIVER_SETUP "Global\\VeraCrypt Driver Setup"
+#define TC_MUTEX_NAME_SYSENC L"Global\\VeraCrypt System Encryption Wizard"
+#define TC_MUTEX_NAME_NONSYS_INPLACE_ENC L"Global\\VeraCrypt In-Place Encryption Wizard"
+#define TC_MUTEX_NAME_APP_SETUP L"Global\\VeraCrypt Setup"
+#define TC_MUTEX_NAME_DRIVER_SETUP L"Global\\VeraCrypt Driver Setup"
#define IDC_ABOUT 0x7fff /* ID for AboutBox on system menu in wm_user range */
@@ -68,18 +68,18 @@ enum
#define MAX_MULTI_CHOICES 10 /* Maximum number of options for mutliple-choice dialog */
-#define TC_APPD_FILENAME_CONFIGURATION "Configuration.xml"
-#define TC_APPD_FILENAME_SYSTEM_ENCRYPTION "System Encryption.xml"
-#define TC_APPD_FILENAME_DEFAULT_KEYFILES "Default Keyfiles.xml"
-#define TC_APPD_FILENAME_HISTORY "History.xml"
-#define TC_APPD_FILENAME_FAVORITE_VOLUMES "Favorite Volumes.xml"
-#define TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES TC_APP_NAME " System Favorite Volumes.xml"
-#define TC_APPD_FILENAME_NONSYS_INPLACE_ENC "In-Place Encryption"
-#define TC_APPD_FILENAME_NONSYS_INPLACE_ENC_WIPE "In-Place Encryption Wipe Algo"
-#define TC_APPD_FILENAME_POST_INSTALL_TASK_TUTORIAL "Post-Install Task - Tutorial"
-#define TC_APPD_FILENAME_POST_INSTALL_TASK_RELEASE_NOTES "Post-Install Task - Release Notes"
+#define TC_APPD_FILENAME_CONFIGURATION L"Configuration.xml"
+#define TC_APPD_FILENAME_SYSTEM_ENCRYPTION L"System Encryption.xml"
+#define TC_APPD_FILENAME_DEFAULT_KEYFILES L"Default Keyfiles.xml"
+#define TC_APPD_FILENAME_HISTORY L"History.xml"
+#define TC_APPD_FILENAME_FAVORITE_VOLUMES L"Favorite Volumes.xml"
+#define TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES _T(TC_APP_NAME) L" System Favorite Volumes.xml"
+#define TC_APPD_FILENAME_NONSYS_INPLACE_ENC L"In-Place Encryption"
+#define TC_APPD_FILENAME_NONSYS_INPLACE_ENC_WIPE L"In-Place Encryption Wipe Algo"
+#define TC_APPD_FILENAME_POST_INSTALL_TASK_TUTORIAL L"Post-Install Task - Tutorial"
+#define TC_APPD_FILENAME_POST_INSTALL_TASK_RELEASE_NOTES L"Post-Install Task - Release Notes"
-#define VC_FILENAME_RENAMED_SUFFIX "_old"
+#define VC_FILENAME_RENAMED_SUFFIX L"_old"
#ifndef USER_DEFAULT_SCREEN_DPI
#define USER_DEFAULT_SCREEN_DPI 96
@@ -98,9 +98,9 @@ enum
extern char *LastDialogId;
extern char *ConfigBuffer;
-extern char szHelpFile[TC_MAX_PATH];
-extern char szHelpFile2[TC_MAX_PATH];
-extern char SecurityTokenLibraryPath[TC_MAX_PATH];
+extern wchar_t szHelpFile[TC_MAX_PATH];
+extern wchar_t szHelpFile2[TC_MAX_PATH];
+extern wchar_t SecurityTokenLibraryPath[TC_MAX_PATH];
extern HFONT hFixedDigitFont;
extern HFONT hBoldFont;
extern HFONT hTitleFont;
@@ -132,8 +132,8 @@ extern WipeAlgorithmId nWipeMode;
extern BOOL bSysPartitionSelected;
extern BOOL bSysDriveSelected;
-extern char SysPartitionDevicePath [TC_MAX_PATH];
-extern char SysDriveDevicePath [TC_MAX_PATH];
+extern wchar_t SysPartitionDevicePath [TC_MAX_PATH];
+extern wchar_t SysDriveDevicePath [TC_MAX_PATH];
extern char bCachedSysDevicePathsValid;
extern BOOL bHyperLinkBeingTracked;
@@ -226,15 +226,15 @@ typedef struct
#define ICON_HAND MB_ICONHAND
#define YES_NO MB_YESNO
-#define ISO_BURNER_TOOL "isoburn.exe"
-#define PRINT_TOOL "notepad.exe"
+#define ISO_BURNER_TOOL L"isoburn.exe"
+#define PRINT_TOOL L"notepad.exe"
void cleanup ( void );
-void LowerCaseCopy ( char *lpszDest , const char *lpszSource );
-void UpperCaseCopy ( char *lpszDest , size_t cbDest, const char *lpszSource );
-void CreateFullVolumePath ( char *lpszDiskFile , size_t cbDiskFile, const char *lpszFileName , BOOL *bDevice );
-int FakeDosNameForDevice ( const char *lpszDiskFile , char *lpszDosDevice , size_t cbDosDevice, char *lpszCFDevice , size_t cbCFDevice, BOOL bNameOnly );
-int RemoveFakeDosName ( char *lpszDiskFile , char *lpszDosDevice );
+void LowerCaseCopy ( wchar_t *lpszDest , const wchar_t *lpszSource );
+void UpperCaseCopy ( wchar_t *lpszDest , size_t cbDest, const wchar_t *lpszSource );
+void CreateFullVolumePath ( wchar_t *lpszDiskFile , size_t cbDiskFile, const wchar_t *lpszFileName , BOOL *bDevice );
+int FakeDosNameForDevice ( const wchar_t *lpszDiskFile , wchar_t *lpszDosDevice , size_t cbDosDevice, wchar_t *lpszCFDevice , size_t cbCFDevice, BOOL bNameOnly );
+int RemoveFakeDosName ( wchar_t *lpszDiskFile , wchar_t *lpszDosDevice );
void AbortProcessDirect ( wchar_t *abortMsg );
void AbortProcess ( char *stringId );
void AbortProcessSilent ( void );
@@ -251,13 +251,11 @@ void DisplayStaticModelessWaitDlg (HWND parent);
void CloseStaticModelessWaitDlg (void);
BOOL IsButtonChecked ( HWND hButton );
void CheckButton ( HWND hButton );
-void LeftPadString (char *szTmp, int len, int targetLen, char filler);
-void ToSBCS ( LPWSTR lpszText, size_t cbSize );
-void ToUNICODE ( char *lpszText , size_t cbSize);
+void LeftPadString (wchar_t *szTmp, int len, int targetLen, wchar_t filler);
void InitDialog ( HWND hwndDlg );
void ProcessPaintMessages (HWND hwnd, int maxMessagesToProcess);
-HDC CreateMemBitmap ( HINSTANCE hInstance , HWND hwnd , char *resource );
-HBITMAP RenderBitmap ( char *resource , HWND hwndDest , int x , int y , int nWidth , int nHeight , BOOL bDirectRender , BOOL bKeepAspectRatio);
+HDC CreateMemBitmap ( HINSTANCE hInstance , HWND hwnd , wchar_t *resource );
+HBITMAP RenderBitmap ( wchar_t *resource , HWND hwndDest , int x , int y , int nWidth , int nHeight , BOOL bDirectRender , BOOL bKeepAspectRatio);
LRESULT CALLBACK RedTick ( HWND hwnd , UINT uMsg , WPARAM wParam , LPARAM lParam );
BOOL RegisterRedTick ( HINSTANCE hInstance );
BOOL UnregisterRedTick ( HINSTANCE hInstance );
@@ -271,11 +269,11 @@ void AddComboPairW (HWND hComboBox, const wchar_t *lpszItem, int value);
void SelectAlgo ( HWND hComboBox , int *nCipher );
void PopulateWipeModeCombo (HWND hComboBox, BOOL bNA, BOOL bInPlaceEncryption, BOOL bHeaderWipe);
wchar_t *GetWipeModeName (WipeAlgorithmId modeId);
-wchar_t *GetPathType (const char *path, BOOL bUpperCase, BOOL *bIsPartition);
+wchar_t *GetPathType (const wchar_t *path, BOOL bUpperCase, BOOL *bIsPartition);
LRESULT CALLBACK CustomDlgProc ( HWND hwnd , UINT uMsg , WPARAM wParam , LPARAM lParam );
-BOOL TCCreateMutex (volatile HANDLE *hMutex, char *name);
+BOOL TCCreateMutex (volatile HANDLE *hMutex, wchar_t *name);
void TCCloseMutex (volatile HANDLE *hMutex);
-BOOL MutexExistsOnSystem (char *name);
+BOOL MutexExistsOnSystem (wchar_t *name);
BOOL CreateSysEncMutex (void);
BOOL InstanceHasSysEncMutex (void);
void CloseSysEncMutex (void);
@@ -297,15 +295,15 @@ void RemoveNonSysInPlaceEncNotifications (void);
void SavePostInstallTasksSettings (int command);
void DoPostInstallTasks (HWND hwndDlg);
void InitOSVersionInfo ();
-void InitApp ( HINSTANCE hInstance, char *lpszCommandLine );
+void InitApp ( HINSTANCE hInstance, wchar_t *lpszCommandLine );
void FinalizeApp (void);
void InitHelpFileName (void);
-BOOL OpenDevice (const char *lpszPath, OPEN_TEST_STRUCT *driver, BOOL detectFilesystem);
+BOOL OpenDevice (const wchar_t *lpszPath, OPEN_TEST_STRUCT *driver, BOOL detectFilesystem);
void NotifyDriverOfPortableMode (void);
int GetAvailableFixedDisks ( HWND hComboBox , char *lpszRootPath );
int GetAvailableRemovables ( HWND hComboBox , char *lpszRootPath );
-int IsSystemDevicePath (const char *path, HWND hwndDlg, BOOL bReliableRequired);
-int IsNonSysPartitionOnSysDrive (const char *path);
+int IsSystemDevicePath (const wchar_t *path, HWND hwndDlg, BOOL bReliableRequired);
+int IsNonSysPartitionOnSysDrive (const wchar_t *path);
BOOL CALLBACK RawDevicesDlgProc ( HWND hwndDlg , UINT msg , WPARAM wParam , LPARAM lParam );
INT_PTR TextInfoDialogBox (int nID);
BOOL CALLBACK TextInfoDialogBoxDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
@@ -318,50 +316,49 @@ int DriverAttach ( void );
BOOL CALLBACK CipherTestDialogProc ( HWND hwndDlg , UINT uMsg , WPARAM wParam , LPARAM lParam );
void ResetCipherTest ( HWND hwndDlg , int idTestCipher );
void ResetCurrentDirectory ();
-BOOL BrowseFiles (HWND hwndDlg, char *stringId, char *lpszFileName, BOOL keepHistory, BOOL saveMode, wchar_t *browseFilter);
-BOOL BrowseDirectories (HWND hWnd, char *lpszTitle, char *dirName);
+BOOL BrowseFiles (HWND hwndDlg, char *stringId, wchar_t *lpszFileName, BOOL keepHistory, BOOL saveMode, wchar_t *browseFilter);
+BOOL BrowseDirectories (HWND hWnd, char *lpszTitle, wchar_t *dirName);
void handleError ( HWND hwndDlg , int code, const char* srcPos );
-BOOL CheckFileStreamWriteErrors (HWND hwndDlg, FILE *file, const char *fileName);
+BOOL CheckFileStreamWriteErrors (HWND hwndDlg, FILE *file, const wchar_t *fileName);
void LocalizeDialog ( HWND hwnd, char *stringId );
void OpenVolumeExplorerWindow (int driveNo);
static BOOL CALLBACK CloseVolumeExplorerWindowsEnum( HWND hwnd, LPARAM driveNo);
BOOL CloseVolumeExplorerWindows (HWND hwnd, int driveNo);
BOOL UpdateDriveCustomLabel (int driveNo, wchar_t* effectiveLabel, BOOL bSetValue);
BOOL CheckCapsLock (HWND hwnd, BOOL quiet);
-BOOL CheckFileExtension (char *fileName);
-void CorrectFileName (char* fileName);
+BOOL CheckFileExtension (wchar_t *fileName);
+void CorrectFileName (wchar_t* fileName);
void IncreaseWrongPwdRetryCount (int count);
void ResetWrongPwdRetryCount (void);
BOOL WrongPwdRetryCountOverLimit (void);
int GetFirstAvailableDrive ();
int GetLastAvailableDrive ();
BOOL IsDriveAvailable (int driveNo);
-BOOL IsDeviceMounted (char *deviceName);
+BOOL IsDeviceMounted (wchar_t *deviceName);
int DriverUnmountVolume (HWND hwndDlg, int nDosDriveNo, BOOL forced);
void BroadcastDeviceChange (WPARAM message, int nDosDriveNo, DWORD driveMap);
-int MountVolume (HWND hwndDlg, int driveNo, char *volumePath, Password *password, int pkcs5, int pim, BOOL truecryptMode, BOOL cachePassword, BOOL sharedAccess, const MountOptions* const mountOptions, BOOL quiet, BOOL bReportWrongPassword);
+int MountVolume (HWND hwndDlg, int driveNo, wchar_t *volumePath, Password *password, int pkcs5, int pim, BOOL truecryptMode, BOOL cachePassword, BOOL sharedAccess, const MountOptions* const mountOptions, BOOL quiet, BOOL bReportWrongPassword);
BOOL UnmountVolume (HWND hwndDlg , int nDosDriveNo, BOOL forceUnmount);
BOOL UnmountVolumeAfterFormatExCall (HWND hwndDlg, int nDosDriveNo);
BOOL IsPasswordCacheEmpty (void);
-BOOL IsMountedVolume (const char *volname);
-int GetMountedVolumeDriveNo (char *volname);
+BOOL IsMountedVolume (const wchar_t *volname);
+int GetMountedVolumeDriveNo (wchar_t *volname);
BOOL IsAdmin (void);
BOOL IsBuiltInAdmin ();
BOOL IsUacSupported ();
BOOL ResolveSymbolicLink (const wchar_t *symLinkName, PWSTR targetName, size_t cbTargetName);
int GetDiskDeviceDriveLetter (PWSTR deviceName);
-int FileSystemAppearsEmpty (const char *devicePath);
-__int64 GetStatsFreeSpaceOnPartition (const char *devicePath, float *percent, __int64 *occupiedBytes, BOOL silent);
-__int64 GetDeviceSize (const char *devicePath);
-HANDLE DismountDrive (char *devName, char *devicePath);
+int FileSystemAppearsEmpty (const wchar_t *devicePath);
+__int64 GetStatsFreeSpaceOnPartition (const wchar_t *devicePath, float *percent, __int64 *occupiedBytes, BOOL silent);
+__int64 GetDeviceSize (const wchar_t *devicePath);
+HANDLE DismountDrive (wchar_t *devName, wchar_t *devicePath);
int64 FindString (const char *buf, const char *str, int64 bufLen, int64 strLen, int64 startOffset);
-BOOL FileExists (const char *filePathPtr);
-__int64 FindStringInFile (const char *filePath, const char *str, int strLen);
-BOOL TCCopyFile (char *sourceFileName, char *destinationFile);
-BOOL TCCopyFileW (wchar_t *sourceFileName, wchar_t *destinationFile);
-BOOL SaveBufferToFile (const char *inputBuffer, const char *destinationFile, DWORD inputLength, BOOL bAppend, BOOL bRenameIfFailed);
+BOOL FileExists (const wchar_t *filePathPtr);
+__int64 FindStringInFile (const wchar_t *filePath, const char *str, int strLen);
+BOOL TCCopyFile (wchar_t *sourceFileName, wchar_t *destinationFile);
+BOOL SaveBufferToFile (const char *inputBuffer, const wchar_t *destinationFile, DWORD inputLength, BOOL bAppend, BOOL bRenameIfFailed);
BOOL TCFlushFile (FILE *f);
-BOOL PrintHardCopyTextUTF16 (wchar_t *text, char *title, size_t byteLen);
+BOOL PrintHardCopyTextUTF16 (wchar_t *text, wchar_t *title, size_t byteLen);
void GetSpeedString (unsigned __int64 speed, wchar_t *str, size_t cbStr);
BOOL IsNonInstallMode ();
BOOL DriverUnload ();
@@ -369,25 +366,23 @@ LRESULT SetCheckBox (HWND hwndDlg, int dlgItem, BOOL state);
BOOL GetCheckBox (HWND hwndDlg, int dlgItem);
void SetListScrollHPos (HWND hList, int topMostVisibleItem);
void ManageStartupSeq (void);
-void ManageStartupSeqWiz (BOOL bRemove, const char *arg);
+void ManageStartupSeqWiz (BOOL bRemove, const wchar_t *arg);
void CleanLastVisitedMRU (void);
void ClearHistory (HWND hwndDlgItem);
-LRESULT ListItemAdd (HWND list, int index, char *string);
-LRESULT ListItemAddW (HWND list, int index, wchar_t *string);
-LRESULT ListSubItemSet (HWND list, int index, int subIndex, char *string);
-LRESULT ListSubItemSetW (HWND list, int index, int subIndex, wchar_t *string);
+LRESULT ListItemAdd (HWND list, int index, const wchar_t *string);
+LRESULT ListSubItemSet (HWND list, int index, int subIndex, const wchar_t *string);
BOOL GetMountList (MOUNT_LIST_STRUCT *list);
int GetDriverRefCount ();
void GetSizeString (unsigned __int64 size, wchar_t *str, size_t cbStr);
-__int64 GetFileSize64 (const char *path);
-BOOL LoadInt16 (char *filePath, int *result, __int64 fileOffset);
-BOOL LoadInt32 (char *filePath, unsigned __int32 *result, __int64 fileOffset);
-char *LoadFile (const char *fileName, DWORD *size);
-char *LoadFileBlock (char *fileName, __int64 fileOffset, DWORD count);
-char *GetModPath (char *path, int maxSize);
-char *GetConfigPath (char *fileName);
-char *GetProgramConfigPath (char *fileName);
-char GetSystemDriveLetter (void);
+__int64 GetFileSize64 (const wchar_t *path);
+BOOL LoadInt16 (const wchar_t *filePath, int *result, __int64 fileOffset);
+BOOL LoadInt32 (const wchar_t *filePath, unsigned __int32 *result, __int64 fileOffset);
+char *LoadFile (const wchar_t *fileName, DWORD *size);
+char *LoadFileBlock (const wchar_t *fileName, __int64 fileOffset, DWORD count);
+wchar_t *GetModPath (wchar_t *path, int maxSize);
+wchar_t *GetConfigPath (wchar_t *fileName);
+wchar_t *GetProgramConfigPath (wchar_t *fileName);
+wchar_t GetSystemDriveLetter (void);
void OpenPageHelp (HWND hwndDlg, int nPage);
void TaskBarIconDisplayBalloonTooltip (HWND hwnd, wchar_t *headline, wchar_t *text, BOOL warning);
void InfoBalloon (char *headingStringId, char *textStringId, HWND hwnd);
@@ -425,6 +420,7 @@ int AskMultiChoice (void *strings[], BOOL bBold, HWND hwnd);
BOOL ConfigWriteBegin ();
BOOL ConfigWriteEnd (HWND hwnd);
BOOL ConfigWriteString (char *configKey, char *configValue);
+BOOL ConfigWriteStringW (char *configKey, wchar_t *configValue);
BOOL ConfigWriteInt (char *configKey, int configValue);
int ConfigReadInt (char *configKey, int defaultValue);
char *ConfigReadString (char *configKey, char *defaultValue, char *str, int maxLen);
@@ -442,20 +438,20 @@ BOOL IsHiddenOSRunning (void);
BOOL EnableWow64FsRedirection (BOOL enable);
BOOL RestartComputer (void);
void Applink (char *dest, BOOL bSendOS, char *extraOutput);
-char *RelativePath2Absolute (char *szFileName);
+wchar_t *RelativePath2Absolute (wchar_t *szFileName);
void HandleDriveNotReadyError (HWND hwnd);
BOOL CALLBACK CloseTCWindowsEnum( HWND hwnd, LPARAM lParam);
BOOL CALLBACK FindTCWindowEnum (HWND hwnd, LPARAM lParam);
-BYTE *MapResource (char *resourceType, int resourceId, PDWORD size);
+BYTE *MapResource (wchar_t *resourceType, int resourceId, PDWORD size);
void InconsistencyResolved (char *msg);
void ReportUnexpectedState (char *techInfo);
-BOOL SelectMultipleFiles (HWND hwndDlg, const char *stringId, char *lpszFileName, size_t cbFileName, BOOL keepHistory);
-BOOL SelectMultipleFilesNext (char *lpszFileName, size_t cbFileName);
+BOOL SelectMultipleFiles (HWND hwndDlg, const char *stringId, wchar_t *lpszFileName, size_t cbFileName, BOOL keepHistory);
+BOOL SelectMultipleFilesNext (wchar_t *lpszFileName, size_t cbFileName);
void OpenOnlineHelp ();
-BOOL GetPartitionInfo (const char *deviceName, PPARTITION_INFORMATION rpartInfo);
-BOOL GetDeviceInfo (const char *deviceName, DISK_PARTITION_INFO_STRUCT *info);
-BOOL GetDriveGeometry (const char *deviceName, PDISK_GEOMETRY diskGeometry);
-BOOL IsVolumeDeviceHosted (const char *lpszDiskFile);
+BOOL GetPartitionInfo (const wchar_t *deviceName, PPARTITION_INFORMATION rpartInfo);
+BOOL GetDeviceInfo (const wchar_t *deviceName, DISK_PARTITION_INFO_STRUCT *info);
+BOOL GetDriveGeometry (const wchar_t *deviceName, PDISK_GEOMETRY diskGeometry);
+BOOL IsVolumeDeviceHosted (const wchar_t *lpszDiskFile);
int CompensateXDPI (int val);
int CompensateYDPI (int val);
int CompensateDPIFont (int val);
@@ -470,7 +466,7 @@ void AccommodateTextField (HWND hwndDlg, UINT ctrlId, BOOL bFirstUpdate, HFONT h
BOOL GetDriveLabel (int driveNo, wchar_t *label, int labelSize);
BOOL GetSysDevicePaths (HWND hwndDlg);
BOOL DoDriverInstall (HWND hwndDlg);
-int OpenVolume (OpenVolumeContext *context, const char *volumePath, Password *password, int pkcs5_prf, int pim, BOOL truecryptMode, BOOL write, BOOL preserveTimestamps, BOOL useBackupHeader);
+int OpenVolume (OpenVolumeContext *context, const wchar_t *volumePath, Password *password, int pkcs5_prf, int pim, BOOL truecryptMode, BOOL write, BOOL preserveTimestamps, BOOL useBackupHeader);
void CloseVolume (OpenVolumeContext *context);
int ReEncryptVolumeHeader (HWND hwndDlg, char *buffer, BOOL bBoot, CRYPTO_INFO *cryptoInfo, Password *password, int pim, BOOL wipeMode);
BOOL IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly);
@@ -479,20 +475,22 @@ BOOL DisablePagingFile ();
BOOL CALLBACK SecurityTokenPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL InitSecurityTokenLibrary (HWND hwndDlg);
-BOOL FileHasReadOnlyAttribute (const char *path);
-BOOL IsFileOnReadOnlyFilesystem (const char *path);
+BOOL FileHasReadOnlyAttribute (const wchar_t *path);
+BOOL IsFileOnReadOnlyFilesystem (const wchar_t *path);
void CheckFilesystem (HWND hwndDlg, int driveNo, BOOL fixErrors);
BOOL BufferContainsString (const byte *buffer, size_t bufferSize, const char *str);
int AskNonSysInPlaceEncryptionResume (HWND hwndDlg, BOOL* pbDecrypt);
-BOOL RemoveDeviceWriteProtection (HWND hwndDlg, char *devicePath);
+BOOL RemoveDeviceWriteProtection (HWND hwndDlg, wchar_t *devicePath);
void EnableElevatedCursorChange (HWND parent);
BOOL DisableFileCompression (HANDLE file);
-BOOL VolumePathExists (const char *volumePath);
+BOOL VolumePathExists (const wchar_t *volumePath);
BOOL IsWindowsIsoBurnerAvailable ();
-BOOL LaunchWindowsIsoBurner (HWND hwnd, const char *isoPath);
-BOOL IsApplicationInstalled (const char *appName);
+BOOL LaunchWindowsIsoBurner (HWND hwnd, const wchar_t *isoPath);
+BOOL IsApplicationInstalled (const wchar_t *appName);
int GetPim (HWND hwndDlg, UINT ctrlId);
void SetPim (HWND hwndDlg, UINT ctrlId, int pim);
+BOOL GetPassword (HWND hwndDlg, UINT ctrlID, char* passValue, int bufSize, BOOL bShowError);
+void SetPassword (HWND hwndDlg, UINT ctrlID, char* passValue);
void HandleShowPasswordFieldAction (HWND hwndDlg, UINT checkBoxId, UINT edit1Id, UINT edit2Id);
#ifdef __cplusplus
@@ -527,9 +525,9 @@ struct HostDevice
bool IsPartition;
bool IsVirtualPartition;
bool HasUnencryptedFilesystem;
- std::string MountPoint;
+ std::wstring MountPoint;
std::wstring Name;
- std::string Path;
+ std::wstring Path;
bool Removable;
uint64 Size;
uint32 SystemNumber;
@@ -540,10 +538,10 @@ struct HostDevice
struct RawDevicesDlgParam
{
std::vector <HostDevice> devices;
- char *pszFileName;
+ wchar_t *pszFileName;
};
-BOOL BrowseFilesInDir (HWND hwndDlg, char *stringId, char *initialDir, char *lpszFileName, BOOL keepHistory, BOOL saveMode, wchar_t *browseFilter, const wchar_t *initialFileName = NULL, const wchar_t *defaultExtension = NULL);
+BOOL BrowseFilesInDir (HWND hwndDlg, char *stringId, wchar_t *initialDir, wchar_t *lpszFileName, BOOL keepHistory, BOOL saveMode, wchar_t *browseFilter, const wchar_t *initialFileName = NULL, const wchar_t *defaultExtension = NULL);
std::wstring SingleStringToWide (const std::string &singleString);
std::wstring Utf8StringToWide (const std::string &utf8String);
std::string WideToSingleString (const std::wstring &wideString);
@@ -551,14 +549,15 @@ std::string WideToUtf8String (const std::wstring &wideString);
std::string StringToUpperCase (const std::string &str);
std::vector <HostDevice> GetAvailableHostDevices (bool noDeviceProperties = false, bool singleList = false, bool noFloppy = true, bool detectUnencryptedFilesystems = false);
std::string ToUpperCase (const std::string &str);
+std::wstring ToUpperCase (const std::wstring &str);
std::wstring GetWrongPasswordErrorMessage (HWND hwndDlg);
-std::string GetWindowsEdition ();
-std::string FitPathInGfxWidth (HWND hwnd, HFONT hFont, LONG width, const std::string &path);
-std::string GetServiceConfigPath (const char *fileName, bool useLegacy);
-std::string VolumeGuidPathToDevicePath (std::string volumeGuidPath);
-std::string HarddiskVolumePathToPartitionPath (const std::string &harddiskVolumePath);
-std::string FindLatestFileOrDirectory (const std::string &directory, const char *namePattern, bool findDirectory, bool findFile);
-std::string GetUserFriendlyVersionString (int version);
+std::wstring GetWindowsEdition ();
+std::wstring FitPathInGfxWidth (HWND hwnd, HFONT hFont, LONG width, const std::wstring &path);
+std::wstring GetServiceConfigPath (const wchar_t *fileName, bool useLegacy);
+std::wstring VolumeGuidPathToDevicePath (std::wstring volumeGuidPath);
+std::wstring HarddiskVolumePathToPartitionPath (const std::wstring &harddiskVolumePath);
+std::wstring FindLatestFileOrDirectory (const std::wstring &directory, const wchar_t *namePattern, bool findDirectory, bool findFile);
+std::wstring GetUserFriendlyVersionString (int version);
std::string IntToString (int val);
std::wstring IntToWideString (int val);
inline std::wstring AppendSrcPos (const wchar_t* msg, const char* srcPos)
diff --git a/src/Common/Exception.h b/src/Common/Exception.h
index d5958b2..cac6ddd 100644
--- a/src/Common/Exception.h
+++ b/src/Common/Exception.h
@@ -64,7 +64,7 @@ namespace VeraCrypt
void Show (HWND parent) const
{
string msgBody = "Parameter incorrect.\n\n\n(If you report a bug in connection with this, please include the following technical information in the bug report:\n" + string (SrcPos) + ")";
- MessageBox (parent, msgBody.c_str(), "VeraCrypt", MB_ICONERROR | MB_SETFOREGROUND);
+ MessageBoxA (parent, msgBody.c_str(), "VeraCrypt", MB_ICONERROR | MB_SETFOREGROUND);
}
const char *SrcPos;
@@ -77,9 +77,9 @@ namespace VeraCrypt
void Show (HWND parent) const
{
char szErrCode[16];
- StringCbPrintf (szErrCode, sizeof(szErrCode), "0x%.8X", LastError);
+ StringCbPrintfA (szErrCode, sizeof(szErrCode), "0x%.8X", LastError);
string msgBody = "The Random Generator initialization failed.\n\n\n(If you report a bug in connection with this, please include the following technical information in the bug report:\n" + string (SrcPos) + "\nLast Error = " + string (szErrCode) + ")";
- MessageBox (parent, msgBody.c_str(), "VeraCrypt", MB_ICONERROR | MB_SETFOREGROUND);
+ MessageBoxA (parent, msgBody.c_str(), "VeraCrypt", MB_ICONERROR | MB_SETFOREGROUND);
}
const char *SrcPos;
@@ -93,9 +93,9 @@ namespace VeraCrypt
void Show (HWND parent) const
{
char szErrCode[16];
- StringCbPrintf (szErrCode, sizeof(szErrCode), "0x%.8X", LastError);
+ StringCbPrintfA (szErrCode, sizeof(szErrCode), "0x%.8X", LastError);
string msgBody = "Windows Crypto API failed.\n\n\n(If you report a bug in connection with this, please include the following technical information in the bug report:\n" + string (SrcPos) + "\nLast Error = " + string (szErrCode) + ")";
- MessageBox (parent, msgBody.c_str(), "VeraCrypt", MB_ICONERROR | MB_SETFOREGROUND);
+ MessageBoxA (parent, msgBody.c_str(), "VeraCrypt", MB_ICONERROR | MB_SETFOREGROUND);
}
const char *SrcPos;
diff --git a/src/Common/Format.c b/src/Common/Format.c
index 3fede6d..4391627 100644
--- a/src/Common/Format.c
+++ b/src/Common/Format.c
@@ -92,8 +92,8 @@ int TCFormatVolume (volatile FORMAT_VOL_PARAMETERS *volParams)
FILETIME ftLastAccessTime;
BOOL bTimeStampValid = FALSE;
BOOL bInstantRetryOtherFilesys = FALSE;
- char dosDev[TC_MAX_PATH] = { 0 };
- char devName[MAX_PATH] = { 0 };
+ WCHAR dosDev[TC_MAX_PATH] = { 0 };
+ WCHAR devName[MAX_PATH] = { 0 };
int driveLetter = -1;
WCHAR deviceName[MAX_PATH];
uint64 dataOffset, dataAreaSize;
@@ -138,8 +138,7 @@ int TCFormatVolume (volatile FORMAT_VOL_PARAMETERS *volParams)
if (volParams->bDevice)
{
- StringCbCopyA ((char *)deviceName, sizeof(deviceName), volParams->volumePath);
- ToUNICODE ((char *)deviceName, sizeof(deviceName));
+ StringCbCopyW (deviceName, sizeof(deviceName), volParams->volumePath);
driveLetter = GetDiskDeviceDriveLetter (deviceName);
}
@@ -213,9 +212,9 @@ begin_format:
// to which no drive letter has been assigned under the system. This problem can be worked
// around by assigning a drive letter to the partition temporarily.
- char szDriveLetter[] = { 'A', ':', 0 };
- char rootPath[] = { 'A', ':', '\\', 0 };
- char uniqVolName[MAX_PATH+1] = { 0 };
+ wchar_t szDriveLetter[] = { L'A', L':', 0 };
+ wchar_t rootPath[] = { L'A', L':', L'\\', 0 };
+ wchar_t uniqVolName[MAX_PATH+1] = { 0 };
int tmpDriveLetter = -1;
BOOL bResult = FALSE;
@@ -223,8 +222,8 @@ begin_format:
if (tmpDriveLetter != -1)
{
- rootPath[0] += (char) tmpDriveLetter;
- szDriveLetter[0] += (char) tmpDriveLetter;
+ rootPath[0] += (wchar_t) tmpDriveLetter;
+ szDriveLetter[0] += (wchar_t) tmpDriveLetter;
if (DefineDosDevice (DDD_RAW_TARGET_PATH, szDriveLetter, volParams->volumePath))
{
@@ -863,25 +862,25 @@ BOOLEAN __stdcall FormatExCallback (int command, DWORD subCommand, PVOID paramet
BOOL FormatNtfs (int driveNo, int clusterSize)
{
- char dllPath[MAX_PATH] = {0};
- WCHAR dir[8] = { (WCHAR) driveNo + 'A', 0 };
+ wchar_t dllPath[MAX_PATH] = {0};
+ WCHAR dir[8] = { (WCHAR) driveNo + L'A', 0 };
PFORMATEX FormatEx;
HMODULE hModule;
int i;
if (GetSystemDirectory (dllPath, MAX_PATH))
{
- StringCbCatA(dllPath, sizeof(dllPath), "\\fmifs.dll");
+ StringCbCatW(dllPath, sizeof(dllPath), L"\\fmifs.dll");
}
else
- StringCbCopyA(dllPath, sizeof(dllPath), "C:\\Windows\\System32\\fmifs.dll");
+ StringCbCopyW(dllPath, sizeof(dllPath), L"C:\\Windows\\System32\\fmifs.dll");
hModule = LoadLibrary (dllPath);
if (hModule == NULL)
return FALSE;
- if (!(FormatEx = (PFORMATEX) GetProcAddress (GetModuleHandle ("fmifs.dll"), "FormatEx")))
+ if (!(FormatEx = (PFORMATEX) GetProcAddress (GetModuleHandle (L"fmifs.dll"), "FormatEx")))
{
FreeLibrary (hModule);
return FALSE;
diff --git a/src/Common/Format.h b/src/Common/Format.h
index 3c39bec..97eeabe 100644
--- a/src/Common/Format.h
+++ b/src/Common/Format.h
@@ -28,7 +28,7 @@ typedef struct
{
BOOL bDevice;
BOOL hiddenVol;
- char *volumePath;
+ wchar_t *volumePath;
unsigned __int64 size;
unsigned __int64 hiddenVolHostSize;
int ea;
diff --git a/src/Common/Keyfiles.c b/src/Common/Keyfiles.c
index 428821b..5cde6b3 100644
--- a/src/Common/Keyfiles.c
+++ b/src/Common/Keyfiles.c
@@ -112,7 +112,7 @@ KeyFile *KeyFileClone (KeyFile *keyFile)
clone = (KeyFile *) malloc (sizeof (KeyFile));
if (clone)
{
- StringCbCopyA (clone->FileName, sizeof(clone->FileName), keyFile->FileName);
+ StringCbCopyW (clone->FileName, sizeof(clone->FileName), keyFile->FileName);
clone->Next = NULL;
}
return clone;
@@ -170,7 +170,7 @@ static BOOL KeyFileProcess (unsigned __int8 *keyPool, KeyFile *keyFile)
CloseHandle (finally_arg);
});
- f = fopen (keyFile->FileName, "rb");
+ f = _wfopen (keyFile->FileName, L"rb");
if (f == NULL) return FALSE;
while ((bytesRead = fread (buffer, 1, sizeof (buffer), f)) > 0)
@@ -225,7 +225,7 @@ close:
}
-BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile, const char* volumeFileName)
+BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile, const wchar_t* volumeFileName)
{
BOOL status = TRUE;
KeyFile kfSubStruct;
@@ -234,8 +234,8 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile, con
static unsigned __int8 keyPool [KEYFILE_POOL_SIZE];
size_t i;
struct stat statStruct;
- char searchPath [TC_MAX_PATH*2];
- struct _finddata_t fBuf;
+ wchar_t searchPath [TC_MAX_PATH*2];
+ struct _wfinddata_t fBuf;
intptr_t searchHandle;
HiddenFilesPresentInKeyfilePath = FALSE;
@@ -250,11 +250,12 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile, con
// Determine whether it's a security token path
try
{
- if (SecurityToken::IsKeyfilePathValid (SingleStringToWide (kf->FileName)))
+ if (SecurityToken::IsKeyfilePathValid (kf->FileName))
{
// Apply security token keyfile
vector <byte> keyfileData;
- SecurityToken::GetKeyfileData (SecurityTokenKeyfile (SingleStringToWide (kf->FileName)), keyfileData);
+ SecurityTokenKeyfilePath secPath (kf->FileName);
+ SecurityToken::GetKeyfileData (SecurityTokenKeyfile (secPath), keyfileData);
if (keyfileData.empty())
{
@@ -296,7 +297,7 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile, con
}
// Determine whether it's a path or a file
- if (stat (kf->FileName, &statStruct) != 0)
+ if (_wstat (kf->FileName, &statStruct) != 0)
{
handleWin32Error (hwndDlg, SRC_POS);
Error ("ERR_PROCESS_KEYFILE", hwndDlg);
@@ -309,8 +310,8 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile, con
/* Find and process all keyfiles in the directory */
int keyfileCount = 0;
- StringCbPrintfA (searchPath, sizeof (searchPath), "%s\\*.*", kf->FileName);
- if ((searchHandle = _findfirst (searchPath, &fBuf)) == -1)
+ StringCbPrintfW (searchPath, sizeof (searchPath), L"%s\\*.*", kf->FileName);
+ if ((searchHandle = _wfindfirst (searchPath, &fBuf)) == -1)
{
handleWin32Error (hwndDlg, SRC_POS);
Error ("ERR_PROCESS_KEYFILE_PATH", hwndDlg);
@@ -322,13 +323,13 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile, con
{
WIN32_FILE_ATTRIBUTE_DATA fileAttributes;
- StringCbPrintfA (kfSub->FileName, sizeof(kfSub->FileName), "%s%c%s", kf->FileName,
- '\\',
+ StringCbPrintfW (kfSub->FileName, sizeof(kfSub->FileName), L"%s%c%s", kf->FileName,
+ L'\\',
fBuf.name
);
// Determine whether it's a path or a file
- if (stat (kfSub->FileName, &statStruct) != 0)
+ if (_wstat (kfSub->FileName, &statStruct) != 0)
{
handleWin32Error (hwndDlg, SRC_POS);
Error ("ERR_PROCESS_KEYFILE", hwndDlg);
@@ -342,7 +343,7 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile, con
}
// Skip hidden files
- if (GetFileAttributesEx (kfSub->FileName, GetFileExInfoStandard, &fileAttributes)
+ if (GetFileAttributesExW (kfSub->FileName, GetFileExInfoStandard, &fileAttributes)
&& (fileAttributes.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0)
{
HiddenFilesPresentInKeyfilePath = TRUE;
@@ -350,7 +351,7 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile, con
}
CorrectFileName (kfSub->FileName);
- if (volumeFileName && (_stricmp (volumeFileName, kfSub->FileName) == 0))
+ if (volumeFileName && (_wcsicmp (volumeFileName, kfSub->FileName) == 0))
{
// skip if it is the current container file name
continue;
@@ -366,14 +367,14 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile, con
status = FALSE;
}
- } while (_findnext (searchHandle, &fBuf) != -1);
+ } while (_wfindnext (searchHandle, &fBuf) != -1);
_findclose (searchHandle);
burn (&kfSubStruct, sizeof (kfSubStruct));
if (keyfileCount == 0)
{
- ErrorDirect ((wstring (GetString ("ERR_KEYFILE_PATH_EMPTY")) + L"\n\n" + SingleStringToWide (kf->FileName)).c_str(), hwndDlg);
+ ErrorDirect ((wstring (GetString ("ERR_KEYFILE_PATH_EMPTY")) + L"\n\n" + wstring (kf->FileName)).c_str(), hwndDlg);
status = FALSE;
}
}
@@ -499,7 +500,7 @@ BOOL CALLBACK KeyFilesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
do
{
CorrectFileName (kf->FileName);
- if (_stricmp (param->VolumeFileName, kf->FileName) == 0)
+ if (_wcsicmp (param->VolumeFileName, kf->FileName) == 0)
containerFileSkipped = true;
else
{
@@ -547,7 +548,7 @@ BOOL CALLBACK KeyFilesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
KeyFile *kf = (KeyFile *) malloc (sizeof (KeyFile));
if (kf)
{
- strcpy_s (kf->FileName, sizeof (kf->FileName), WideToSingleString (keyPath).c_str());
+ StringCbCopyW (kf->FileName, sizeof (kf->FileName), wstring(keyPath).c_str ());
param->FirstKeyFile = KeyFileAdd (param->FirstKeyFile, kf);
LoadKeyList (hwndDlg, param->FirstKeyFile);
@@ -741,7 +742,7 @@ BOOL KeyfilesPopupMenu (HWND hwndDlg, POINT popupPosition, KeyFilesDlgParam *par
KeyFile *kf = (KeyFile *) malloc (sizeof (KeyFile));
if (kf)
{
- strcpy_s (kf->FileName, sizeof (kf->FileName), WideToSingleString (keyPath).c_str());
+ StringCbCopyW (kf->FileName, sizeof (kf->FileName), wstring (keyPath).c_str());
param->FirstKeyFile = KeyFileAdd (param->FirstKeyFile, kf);
param->EnableKeyFiles = TRUE;
diff --git a/src/Common/Keyfiles.h b/src/Common/Keyfiles.h
index 8400ebc..dcdfdde 100644
--- a/src/Common/Keyfiles.h
+++ b/src/Common/Keyfiles.h
@@ -24,13 +24,13 @@ extern "C" {
typedef struct KeyFileStruct
{
- char FileName[MAX_PATH + 1];
+ wchar_t FileName[MAX_PATH + 1];
struct KeyFileStruct *Next;
} KeyFile;
typedef struct
{
- char VolumeFileName[MAX_PATH + 1];
+ wchar_t VolumeFileName[MAX_PATH + 1];
BOOL EnableKeyFiles;
KeyFile *FirstKeyFile;
} KeyFilesDlgParam;
@@ -39,7 +39,7 @@ KeyFile *KeyFileAdd (KeyFile *firstKeyFile, KeyFile *keyFile);
void KeyFileRemoveAll (KeyFile **firstKeyFile);
KeyFile *KeyFileClone (KeyFile *keyFile);
KeyFile *KeyFileCloneAll (KeyFile *firstKeyFile);
-BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFilem, const char* volumeFileName);
+BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFilem, const wchar_t* volumeFileName);
BOOL CALLBACK KeyFilesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL KeyfilesPopupMenu (HWND hwndDlg, POINT popupPosition, KeyFilesDlgParam *dialogParam);
diff --git a/src/Common/Language.c b/src/Common/Language.c
index dbad2d5..757f050 100644
--- a/src/Common/Language.c
+++ b/src/Common/Language.c
@@ -62,7 +62,7 @@ static char *MapFirstLanguageFile ()
if (LanguageResource == NULL)
{
DWORD size;
- LanguageResource = MapResource ("Xml", IDR_LANGUAGE, &size);
+ LanguageResource = MapResource (L"Xml", IDR_LANGUAGE, &size);
if (LanguageResource)
LanguageResourceSize = size;
}
@@ -287,7 +287,7 @@ BOOL LoadLanguageFile ()
case 't': *out++ = '\t'; break;
case 'n': *out++ = 13; *out++ = 10; break;
default:
- MessageBox (0, key, "VeraCrypt: Unknown '\\' escape sequence in string", MB_ICONERROR);
+ MessageBoxA (0, key, "VeraCrypt: Unknown '\\' escape sequence in string", MB_ICONERROR);
return FALSE;
}
}
@@ -301,7 +301,7 @@ BOOL LoadLanguageFile ()
len = MultiByteToWideChar (CP_UTF8, 0, attr, -1, wattr, sizeof (wattr) / sizeof(wattr[0]));
if (len == 0)
{
- MessageBox (0, key, "VeraCrypt: Error while decoding UTF-8 string", MB_ICONERROR);
+ MessageBoxA (0, key, "VeraCrypt: Error while decoding UTF-8 string", MB_ICONERROR);
return FALSE;
}
@@ -343,7 +343,7 @@ BOOL LoadLanguageFile ()
{
if (HeaderResource[i] == NULL)
{
- HeaderResource[i] = MapResource ("Header", headers[i], &size);
+ HeaderResource[i] = MapResource (L"Header", headers[i], &size);
if (HeaderResource[i])
HeaderResourceSize[i] = size;
}
diff --git a/src/Common/Language.xml b/src/Common/Language.xml
index 250bf3a..3c8fbfc 100644
--- a/src/Common/Language.xml
+++ b/src/Common/Language.xml
@@ -416,13 +416,13 @@
<string lang="en" key="CIPHER_TITLE">Encryption Options</string>
<string lang="en" key="CLEAN_WINMRU_FAILED">WARNING: Failed to clear the path of the last selected volume/keyfile (remembered by file selector)!</string>
<string lang="en" key="COMPRESSION_NOT_SUPPORTED">Error: The container has been compressed at the filesystem level. VeraCrypt does not support compressed containers (note that compression of encrypted data is ineffective and redundant).\n\nPlease disable compression for the container by following these steps:\n1) Right-click the container in Windows Explorer (not in VeraCrypt).\n2) Select 'Properties'.\n3) In the 'Properties' dialog box, click 'Advanced'.\n4) In the 'Advanced Attributes' dialog box, disable the option 'Compress contents to save disk space' and click 'OK'.\n5) In the 'Properties' dialog box, click 'OK'.</string>
- <string lang="en" key="CREATE_FAILED">Failed to create volume %hs</string>
- <string lang="en" key="DEVICE_FREE_BYTES">Size of %hs is %.2f bytes</string>
- <string lang="en" key="DEVICE_FREE_KB">Size of %hs is %.2f KB</string>
- <string lang="en" key="DEVICE_FREE_MB">Size of %hs is %.2f MB</string>
- <string lang="en" key="DEVICE_FREE_GB">Size of %hs is %.2f GB</string>
- <string lang="en" key="DEVICE_FREE_TB">Size of %hs is %.2f TB</string>
- <string lang="en" key="DEVICE_FREE_PB">Size of %hs is %.2f PB</string>
+ <string lang="en" key="CREATE_FAILED">Failed to create volume %s</string>
+ <string lang="en" key="DEVICE_FREE_BYTES">Size of %s is %.2f bytes</string>
+ <string lang="en" key="DEVICE_FREE_KB">Size of %s is %.2f KB</string>
+ <string lang="en" key="DEVICE_FREE_MB">Size of %s is %.2f MB</string>
+ <string lang="en" key="DEVICE_FREE_GB">Size of %s is %.2f GB</string>
+ <string lang="en" key="DEVICE_FREE_TB">Size of %s is %.2f TB</string>
+ <string lang="en" key="DEVICE_FREE_PB">Size of %s is %.2f PB</string>
<string lang="en" key="DEVICE_IN_USE_FORMAT">WARNING: The device/partition is in use by the operating system or applications. Formatting the device/partition might cause data corruption and system instability.\n\nContinue?</string>
<string lang="en" key="DEVICE_IN_USE_INPLACE_ENC">Warning: The partition is in use by the operating system or applications. You should close any applications that might be using the partition (including antivirus software).\n\nContinue?</string>
<string lang="en" key="FORMAT_CANT_DISMOUNT_FILESYS">Error: The device/partition contains a file system that could not be dismounted. The file system may be in use by the operating system. Formatting the device/partition would very likely cause data corruption and system instability.\n\nTo solve this issue, we recommend that you first delete the partition and then recreate it without formatting. To do so, follow these steps:\n1) Right-click the 'Computer' (or 'My Computer') icon in the 'Start Menu' and select 'Manage'. The 'Computer Management' window should appear.\n2) In the 'Computer Management' window, select 'Storage' > 'Disk Management'.\n3) Right-click the partition you want to encrypt and select either 'Delete Partition', or 'Delete Volume', or 'Delete Logical Drive'.\n4) Click 'Yes'. If Windows asks you to restart the computer, do so. Then repeat the steps 1 and 2 and continue from the step 5.\n5) Right-click the unallocated/free space area and select either 'New Partition', or 'New Simple Volume', or 'New Logical Drive'.\n6) The 'New Partition Wizard' or 'New Simple Volume Wizard' window should appear now; follow its instructions. On the wizard page entitled 'Format Partition', select either 'Do not format this partition' or 'Do not format this volume'. In the same wizard, click 'Next' and then 'Finish'.\n7) Note that the device path you have selected in VeraCrypt may be wrong now. Therefore, exit the VeraCrypt Volume Creation Wizard (if it is still running) and then start it again.\n8) Try encrypting the device/partition again.\n\nIf VeraCrypt repeatedly fails to encrypt the device/partition, you may want to consider creating a file container instead.</string>
@@ -441,12 +441,12 @@
<string lang="en" key="INPLACE_ENC_INVALID_PATH">Error: VeraCrypt can in-place encrypt only a partition, a dynamic volume, or an entire system drive. Please make sure the specified path is valid.</string>
<string lang="en" key="CANNOT_RESIZE_FILESYS">Error: Cannot shrink the filesystem (the filesystem needs to be shrunk to make space for the volume header and backup header).\n\nPossible causes and solutions:\n\n- Not enough free space on the volume. Please make sure no other application is writing to the filesystem.\n\n- Corrupted file system. Try to check it and fix any errors (right-click the corresponding drive letter in the 'Computer' list, then select Properties > Tools > 'Check Now', make sure the option 'Automatically fix file system errors' is enabled and click Start).\n\nIf the above steps do not help, please follow the below steps.</string>
<string lang="en" key="NOT_ENOUGH_FREE_FILESYS_SPACE_FOR_SHRINK">Error: There is not enough free space on the volume and so the filesystem cannot be shrunk (the filesystem needs to be shrunk to make space for the volume header and backup header).\n\nPlease delete any redundant files and empty the Recycle Bin so as to free at least 256 KB of space and then try again. Note that due to a Windows issue, the amount of free space reported by the Windows Explorer may be incorrect until the operating system is restarted. If restarting the system does not help, the file system may be corrupted. Try to check it and fix any errors (right-click the corresponding drive letter in the 'Computer' list, then select Properties > Tools > 'Check Now', make sure the option 'Automatically fix file system errors' is enabled and click Start).\n\nIf the above steps do not help, please follow the below steps.</string>
- <string lang="en" key="DISK_FREE_BYTES">Free space on drive %hs is %.2f bytes.</string>
- <string lang="en" key="DISK_FREE_KB">Free space on drive %hs is %.2f KB</string>
- <string lang="en" key="DISK_FREE_MB">Free space on drive %hs is %.2f MB</string>
- <string lang="en" key="DISK_FREE_GB">Free space on drive %hs is %.2f GB</string>
- <string lang="en" key="DISK_FREE_TB">Free space on drive %hs is %.2f TB</string>
- <string lang="en" key="DISK_FREE_PB">Free space on drive %hs is %.2f PB</string>
+ <string lang="en" key="DISK_FREE_BYTES">Free space on drive %s is %.2f bytes.</string>
+ <string lang="en" key="DISK_FREE_KB">Free space on drive %s is %.2f KB</string>
+ <string lang="en" key="DISK_FREE_MB">Free space on drive %s is %.2f MB</string>
+ <string lang="en" key="DISK_FREE_GB">Free space on drive %s is %.2f GB</string>
+ <string lang="en" key="DISK_FREE_TB">Free space on drive %s is %.2f TB</string>
+ <string lang="en" key="DISK_FREE_PB">Free space on drive %s is %.2f PB</string>
<string lang="en" key="DRIVELETTERS">Could not get available drive letters.</string>
<string lang="en" key="DRIVER_NOT_FOUND">Error: VeraCrypt driver not found.\n\nPlease copy the files 'veracrypt.sys' and 'veracrypt-x64.sys' to the directory where the main VeraCrypt application (VeraCrypt.exe) is located.</string>
<string lang="en" key="DRIVER_VERSION">Error: An incompatible version of the VeraCrypt driver is currently running.\n\nIf you are trying to run VeraCrypt in portable mode (i.e. without installing it) and a different version of VeraCrypt is already installed, you must uninstall it first (or upgrade it using the VeraCrypt installer). To uninstall it, follow these steps: On Windows Vista or later, select 'Start Menu' > Computer > 'Uninstall or change a program' > VeraCrypt > Uninstall; on Windows XP, select 'Start Menu' > Settings > 'Control Panel' > 'Add Or Remove Programs' > VeraCrypt > Remove.\n\nSimilarly, if you are trying to run VeraCrypt in portable mode (i.e. without installing it) and a different version of VeraCrypt is already running in portable mode, you must restart the system first and then run only this new version.</string>
@@ -598,12 +598,12 @@
<string lang="en" key="SELECT_PKCS11_MODULE">Select PKCS #11 Library</string>
<string lang="en" key="OUTOFMEMORY">Out of Memory</string>
<string lang="en" key="FORMAT_DEVICE_FOR_ADVANCED_ONLY">IMPORTANT: We strongly recommend that inexperienced users create a VeraCrypt file container on the selected device/partition, instead of attempting to encrypt the entire device/partition.\n\nWhen you create a VeraCrypt file container (as opposed to encrypting a device or partition) there is, for example, no risk of destroying a large number of files. Note that a VeraCrypt file container (even though it contains a virtual encrypted disk) is actually just like any normal file. For more information, see the chapter Beginner's Tutorial in the VeraCrypt User Guide.\n\nAre you sure you want to encrypt the entire device/partition?</string>
- <string lang="en" key="OVERWRITEPROMPT">WARNING: The file '%hs' already exists!\n\nIMPORTANT: VERACRYPT WILL NOT ENCRYPT THE FILE, BUT IT WILL DELETE IT. Are you sure you want to delete the file and replace it with a new VeraCrypt container?</string>
- <string lang="en" key="OVERWRITEPROMPT_DEVICE">CAUTION: ALL FILES CURRENTLY STORED ON THE SELECTED %s '%hs'%s WILL BE ERASED AND LOST (THEY WILL NOT BE ENCRYPTED)!\n\nAre you sure you want to proceed with format?</string>
- <string lang="en" key="NONSYS_INPLACE_ENC_CONFIRM">WARNING: You will not be able to mount the volume or access any files stored on it until it has been fully encrypted.\n\nAre you sure you want to start encrypting the selected %s '%hs'%s?</string>
- <string lang="en" key="NONSYS_INPLACE_DEC_CONFIRM">WARNING: You will not be able to mount the volume or access any files stored on it until it has been fully decrypted.\n\nAre you sure you want to start decrypting the selected %s '%hs'%s?</string>
+ <string lang="en" key="OVERWRITEPROMPT">WARNING: The file '%s' already exists!\n\nIMPORTANT: VERACRYPT WILL NOT ENCRYPT THE FILE, BUT IT WILL DELETE IT. Are you sure you want to delete the file and replace it with a new VeraCrypt container?</string>
+ <string lang="en" key="OVERWRITEPROMPT_DEVICE">CAUTION: ALL FILES CURRENTLY STORED ON THE SELECTED %s '%s'%s WILL BE ERASED AND LOST (THEY WILL NOT BE ENCRYPTED)!\n\nAre you sure you want to proceed with format?</string>
+ <string lang="en" key="NONSYS_INPLACE_ENC_CONFIRM">WARNING: You will not be able to mount the volume or access any files stored on it until it has been fully encrypted.\n\nAre you sure you want to start encrypting the selected %s '%s'%s?</string>
+ <string lang="en" key="NONSYS_INPLACE_DEC_CONFIRM">WARNING: You will not be able to mount the volume or access any files stored on it until it has been fully decrypted.\n\nAre you sure you want to start decrypting the selected %s '%s'%s?</string>
<string lang="en" key="NONSYS_INPLACE_ENC_CONFIRM_BACKUP">WARNING: Please note that if power supply is suddenly interrupted while encrypting/decrypting existing data in place, or when the operating system crashes due to a software error or hardware malfunction while VeraCrypt is encrypting/decrypting existing data in place, portions of the data will be corrupted or lost. Therefore, before you start encrypting/decrypting, please make sure that you have backup copies of the files you want to encrypt/decrypt.\n\nDo you have such a backup?</string>
- <string lang="en" key="OVERWRITEPROMPT_DEVICE_HIDDEN_OS_PARTITION">CAUTION: ANY FILES CURRENTLY STORED ON THE PARTITION '%hs'%s (I.E. ON THE FIRST PARTITION BEHIND THE SYSTEM PARTITION) WILL BE ERASED AND LOST (THEY WILL NOT BE ENCRYPTED)!\n\nAre you sure you want to proceed with format?</string>
+ <string lang="en" key="OVERWRITEPROMPT_DEVICE_HIDDEN_OS_PARTITION">CAUTION: ANY FILES CURRENTLY STORED ON THE PARTITION '%s'%s (I.E. ON THE FIRST PARTITION BEHIND THE SYSTEM PARTITION) WILL BE ERASED AND LOST (THEY WILL NOT BE ENCRYPTED)!\n\nAre you sure you want to proceed with format?</string>
<string lang="en" key="OVERWRITEPROMPT_DEVICE_SECOND_WARNING_LOTS_OF_DATA">WARNING: THE SELECTED PARTITION CONTAINS A LARGE AMOUNT OF DATA! Any files stored on the partition will be erased and lost (they will NOT be encrypted)!</string>
<string lang="en" key="ERASE_FILES_BY_CREATING_VOLUME">Erase any files stored on the partition by creating a VeraCrypt volume within it</string>
<string lang="en" key="PASSWORD">Password</string>
@@ -641,6 +641,8 @@
<string lang="en" key="PASSWORD_WRONG_AUTOMOUNT">Auto-mount failed due to one or more of the following:\n - Incorrect password.\n - Incorrect Volume PIM number.\n - Incorrect PRF (hash).\n - No valid volume found.</string>
<string lang="en" key="PASSWORD_OR_KEYFILE_WRONG_AUTOMOUNT">Auto-mount failed due to one or more of the following:\n - Incorrect keyfile(s).\n - Incorrect password.\n - Incorrect Volume PIM number.\n - Incorrect PRF (hash).\n - No valid volume found.</string>
<string lang="en" key="PASSWORD_WRONG_CAPSLOCK_ON">\n\nWarning: Caps Lock is on. This may cause you to enter your password incorrectly.</string>
+ <string lang="en" key="PASSWORD_UTF8_TOO_LONG">The entered password is too long: its UTF-8 representation exceeds 64 bytes.</string>
+ <string lang="en" key="PASSWORD_UTF8_INVALID">The entered password contains Unicode characters that couldn't be converted to UTF-8 representation.</string>
<string lang="en" key="PIM_CHANGE_WARNING">Remember Number to Mount Volume</string>
<string lang="en" key="PIM_HIDVOL_HOST_TITLE">Outer Volume PIM</string>
<string lang="en" key="PIM_HIDVOL_TITLE">Hidden Volume PIM</string>
@@ -663,7 +665,7 @@
<string lang="en" key="CANT_DECRYPT_PARTITION_ON_ENTIRELY_ENCRYPTED_SYS_DRIVE_UNSURE">Warning: As the drive contains the VeraCrypt Boot Loader, it may be an entirely encrypted system drive. If it is, please note that VeraCrypt cannot decrypt an individual partition on an entirely encrypted system drive (you can decrypt only the entire system drive). If that is the case, you will be able to continue now but you will receive the 'Incorrect password' error message later.</string>
<string lang="en" key="PREV">&lt; &amp;Back</string>
<string lang="en" key="RAWDEVICES">Unable to list raw devices installed on your system!</string>
- <string lang="en" key="READONLYPROMPT">The volume '%hs' exists, and is read-only. Are you sure you want to replace it?</string>
+ <string lang="en" key="READONLYPROMPT">The volume '%s' exists, and is read-only. Are you sure you want to replace it?</string>
<string lang="en" key="SELECT_DEST_DIR">Select destination directory</string>
<string lang="en" key="SELECT_KEYFILE">Select Keyfile</string>
<string lang="en" key="SELECT_KEYFILE_PATH">Select a keyfile search path. WARNING: Note that only the path will be remembered, not the filenames!</string>
@@ -687,13 +689,13 @@
<string lang="en" key="TEST_CIPHERTEXT_SIZE">The test ciphertext you have supplied is too long or short.</string>
<string lang="en" key="TEST_KEY_SIZE">The test key you have supplied is too long or short.</string>
<string lang="en" key="TEST_PLAINTEXT_SIZE">The test plaintext you have supplied is too long or short.</string>
- <string lang="en" key="TWO_LAYER_CASCADE_HELP">Two ciphers in a cascade operating in XTS mode. Each block is first encrypted with %hs (%d-bit key) and then with %hs (%d-bit key). Each cipher uses its own key. All keys are mutually independent.</string>
- <string lang="en" key="THREE_LAYER_CASCADE_HELP">Three ciphers in a cascade operating in XTS mode. Each block is first encrypted with %hs (%d-bit key), then with %hs (%d-bit key), and finally with %hs (%d-bit key). Each cipher uses its own key. All keys are mutually independent.</string>
+ <string lang="en" key="TWO_LAYER_CASCADE_HELP">Two ciphers in a cascade operating in XTS mode. Each block is first encrypted with %s (%d-bit key) and then with %s (%d-bit key). Each cipher uses its own key. All keys are mutually independent.</string>
+ <string lang="en" key="THREE_LAYER_CASCADE_HELP">Three ciphers in a cascade operating in XTS mode. Each block is first encrypted with %s (%d-bit key), then with %s (%d-bit key), and finally with %s (%d-bit key). Each cipher uses its own key. All keys are mutually independent.</string>
<string lang="en" key="AUTORUN_MAY_NOT_ALWAYS_WORK">Note that, depending on the operating system configuration, these auto-run and auto-mount features may work only when the traveler disk files are created on a non-writable CD/DVD-like medium. Also note that this is not a bug in VeraCrypt (it is a limitation of Windows).</string>
<string lang="en" key="TRAVELER_DISK_CREATED">VeraCrypt traveler disk has been successfully created.\n\nNote that you need administrator privileges to run VeraCrypt in portable mode. Also note that, after examining the registry file, it may be possible to tell that VeraCrypt was run on a Windows system even if it is run in portable mode.</string>
<string lang="en" key="TC_TRAVELER_DISK">VeraCrypt Traveler Disk</string>
<string lang="en" key="TWOFISH_HELP">Designed by Bruce Schneier, John Kelsey, Doug Whiting, David Wagner, Chris Hall, and Niels Ferguson. Published in 1998. 256-bit key, 128-bit block. Mode of operation is XTS. Twofish was one of the AES finalists.</string>
- <string lang="en" key="MORE_INFO_ABOUT">More information on %hs</string>
+ <string lang="en" key="MORE_INFO_ABOUT">More information on %s</string>
<string lang="en" key="UNKNOWN">Unknown</string>
<string lang="en" key="ERR_UNKNOWN">An unspecified or unknown error occurred (%d).</string>
<string lang="en" key="UNMOUNTALL_LOCK_FAILED">Some volumes contain files or folders being used by applications or system.\n\nForce dismount?</string>
@@ -858,7 +860,7 @@
<string lang="en" key="INSTALL_FAILED">Installation failed.</string>
<string lang="en" key="UNINSTALL_FAILED">Uninstallation failed.</string>
<string lang="en" key="DIST_PACKAGE_CORRUPTED">This distribution package is damaged. Please try downloading it again (preferably from the official VeraCrypt website at https://veracrypt.codeplex.com).</string>
- <string lang="en" key="CANNOT_WRITE_FILE_X">Cannot write file %hs</string>
+ <string lang="en" key="CANNOT_WRITE_FILE_X">Cannot write file %s</string>
<string lang="en" key="EXTRACTING_VERB">Extracting</string>
<string lang="en" key="CANNOT_READ_FROM_PACKAGE">Cannot read data from the package.</string>
<string lang="en" key="CANT_VERIFY_PACKAGE_INTEGRITY">Cannot verify the integrity of this distribution package.</string>
@@ -868,7 +870,7 @@
<string lang="en" key="SETUP_UPDATE_OK">VeraCrypt has been successfully updated.</string>
<string lang="en" key="UPGRADE_OK_REBOOT_REQUIRED">VeraCrypt has been successfully upgraded. However, before you can start using it, the computer must be restarted.\n\nDo you want to restart it now?</string>
<string lang="en" key="SYS_ENC_UPGRADE_FAILED">Failed to upgrade VeraCrypt!\n\nIMPORTANT: Before you shut down or restart the system, we strongly recommend that you use System Restore (Windows Start menu > All programs > Accessories > System Tools > System Restore) to restore your system to the restore point named 'VeraCrypt installation'. If System Restore is not available, you should try installing the original or the new version of VeraCrypt again before you shut down or restart the system.</string>
- <string lang="en" key="UNINSTALL_OK">VeraCrypt has been successfully uninstalled.\n\nClick 'Finish' to remove the VeraCrypt installer and the folder %hs. Note that the folder will not be removed if it contains any files that were not installed by the VeraCrypt installer or created by VeraCrypt.</string>
+ <string lang="en" key="UNINSTALL_OK">VeraCrypt has been successfully uninstalled.\n\nClick 'Finish' to remove the VeraCrypt installer and the folder %s. Note that the folder will not be removed if it contains any files that were not installed by the VeraCrypt installer or created by VeraCrypt.</string>
<string lang="en" key="REMOVING_REG">Removing VeraCrypt registry entries</string>
<string lang="en" key="ADDING_REG">Adding registry entry</string>
<string lang="en" key="REMOVING_APPDATA">Removing application-specific data</string>
@@ -879,10 +881,10 @@
<string lang="en" key="CREATING_SYS_RESTORE">Creating System Restore point</string>
<string lang="en" key="FAILED_SYS_RESTORE">Failed to create System Restore point!</string>
<string lang="en" key="INSTALLER_UPDATING_BOOT_LOADER">Updating boot loader</string>
- <string lang="en" key="INSTALL_OF_FAILED">Failed to install '%hs'. %hs\nDo you want to continue installing?</string>
- <string lang="en" key="UNINSTALL_OF_FAILED">Failed to uninstall '%hs'. %hs\nDo you want to continue uninstalling?</string>
+ <string lang="en" key="INSTALL_OF_FAILED">Failed to install '%s'. %s\nDo you want to continue installing?</string>
+ <string lang="en" key="UNINSTALL_OF_FAILED">Failed to uninstall '%s'. %s\nDo you want to continue uninstalling?</string>
<string lang="en" key="INSTALL_COMPLETED">Installation completed.</string>
- <string lang="en" key="CANT_CREATE_FOLDER">The folder '%hs' could not be created</string>
+ <string lang="en" key="CANT_CREATE_FOLDER">The folder '%s' could not be created</string>
<string lang="en" key="CLOSE_TC_FIRST">The VeraCrypt device driver cannot be unloaded.\n\nPlease close all open VeraCrypt windows first. If it does not help, please restart Windows and then try again.</string>
<string lang="en" key="DISMOUNT_ALL_FIRST">All VeraCrypt volumes must be dismounted before installing or uninstalling VeraCrypt.</string>
<string lang="en" key="UNINSTALL_OLD_VERSION_FIRST">An obsolete version of VeraCrypt is currently installed on this system. It needs to be uninstalled before you can install this new version of VeraCrypt.\n\nAs soon as you close this message box, the uninstaller of the old version will be launched. Note that no volume will be decrypted when you uninstall VeraCrypt. After you uninstall the old version of VeraCrypt, run the installer of the new version of VeraCrypt again.</string>
@@ -935,7 +937,7 @@
<string lang="en" key="FAVORITE_LABEL_DEVICE_PATH_ERR">The device displayed below is neither a partition nor a dynamic volume. Therefore, no label can be assigned to it.</string>
<string lang="en" key="FAVORITE_LABEL_PARTITION_TYPE_ERR">Please set the type of the partition displayed below to a type recognized by Windows (use the SETID command of the Windows 'diskpart' tool). Then remove the partition from favorites and add it again. This will enable VeraCrypt to assign a label to the partition.</string>
<string lang="en" key="SYSTEM_FAVORITE_NETWORK_PATH_ERR">Due to a Windows limitation, a container stored in a remote filesystem shared over a network cannot be mounted as a system favorite volume (however, it can be mounted as a non-system favorite volume when a user logs on).</string>
- <string lang="en" key="ENTER_PASSWORD_FOR">Enter password for %hs</string>
+ <string lang="en" key="ENTER_PASSWORD_FOR">Enter password for %s</string>
<string lang="en" key="ENTER_PASSWORD_FOR_LABEL">Enter password for '%s'</string>
<string lang="en" key="ENTER_NORMAL_VOL_PASSWORD">Enter password for the normal/outer volume</string>
<string lang="en" key="ENTER_HIDDEN_VOL_PASSWORD">Enter password for the hidden volume</string>
@@ -950,8 +952,8 @@
<string lang="en" key="VOL_HEADER_BACKED_UP">Volume header backup has been successfully created.\n\nIMPORTANT: Restoring the volume header using this backup will also restore the current volume password. Moreover, if keyfile(s) are/is necessary to mount the volume, the same keyfile(s) will be necessary to mount the volume again when the volume header is restored.\n\nWARNING: This volume header backup may be used to restore the header ONLY of this particular volume. If you use this header backup to restore a header of a different volume, you will be able to mount the volume, but you will NOT be able to decrypt any data stored in the volume (because you will change its master key).</string>
<string lang="en" key="VOL_HEADER_RESTORED">The volume header has been successfully restored.\n\nIMPORTANT: Please note that an old password may have been restored as well. Moreover, if keyfile(s) were/was necessary to mount the volume when the backup was created, the same keyfile(s) are now necessary to mount the volume again.</string>
<string lang="en" key="EXTERNAL_VOL_HEADER_BAK_FIRST_INFO">For security reasons, you will have to enter the correct password (and/or supply the correct keyfiles) for the volume.\n\nNote: If the volume contains a hidden volume, you will have to enter the correct password (and/or supply the correct keyfiles) for the outer volume first. Afterwards, if you choose to back up the header of the hidden volume, you will have to enter the correct password (and/or supply the correct keyfiles) for the hidden volume.</string>
- <string lang="en" key="CONFIRM_VOL_HEADER_BAK">Are you sure you want to create volume header backup for %hs?\n\nAfter you click Yes, you will prompted for a filename for the header backup.\n\nNote: Both the standard and the hidden volume headers will be re-encrypted using a new salt and stored in the backup file. If there is no hidden volume within this volume, the area reserved for the hidden volume header in the backup file will be filled with random data (to preserve plausible deniability). When restoring a volume header from the backup file, you will need to enter the correct password (and/or to supply the correct keyfiles) that was/were valid when the volume header backup was created. The password (and/or keyfiles) will also automatically determine the type of the volume header to restore, i.e. standard or hidden (note that VeraCrypt determines the type through the process of trial and error).</string>
- <string lang="en" key="CONFIRM_VOL_HEADER_RESTORE">Are you sure you want to restore volume header of %hs?\n\nWARNING: Restoring a volume header also restores the volume password that was valid when the backup was created. Moreover, if keyfile(s) were/was necessary to mount the volume when the backup was created, the same keyfile(s) will be necessary to mount the volume again after the volume header is restored.\n\nAfter you click Yes, you will select the header backup file.</string>
+ <string lang="en" key="CONFIRM_VOL_HEADER_BAK">Are you sure you want to create volume header backup for %s?\n\nAfter you click Yes, you will prompted for a filename for the header backup.\n\nNote: Both the standard and the hidden volume headers will be re-encrypted using a new salt and stored in the backup file. If there is no hidden volume within this volume, the area reserved for the hidden volume header in the backup file will be filled with random data (to preserve plausible deniability). When restoring a volume header from the backup file, you will need to enter the correct password (and/or to supply the correct keyfiles) that was/were valid when the volume header backup was created. The password (and/or keyfiles) will also automatically determine the type of the volume header to restore, i.e. standard or hidden (note that VeraCrypt determines the type through the process of trial and error).</string>
+ <string lang="en" key="CONFIRM_VOL_HEADER_RESTORE">Are you sure you want to restore volume header of %s?\n\nWARNING: Restoring a volume header also restores the volume password that was valid when the backup was created. Moreover, if keyfile(s) were/was necessary to mount the volume when the backup was created, the same keyfile(s) will be necessary to mount the volume again after the volume header is restored.\n\nAfter you click Yes, you will select the header backup file.</string>
<string lang="en" key="DOES_VOLUME_CONTAIN_HIDDEN">Does the volume contain a hidden volume?</string>
<string lang="en" key="VOLUME_CONTAINS_HIDDEN">The volume contains a hidden volume</string>
<string lang="en" key="VOLUME_DOES_NOT_CONTAIN_HIDDEN">The volume does not contain a hidden volume</string>
@@ -963,8 +965,8 @@
<string lang="en" key="BACKUP_HEADER_NOT_FOR_SYS_DEVICE">You are attempting to back up the header of the system partition/drive. This is not allowed. Backup/restore operations pertaining to the system partition/drive can be performed only using the VeraCrypt Rescue Disk.\n\nDo you want to create a VeraCrypt Rescue Disk?</string>
<string lang="en" key="RESTORE_HEADER_NOT_FOR_SYS_DEVICE">You are attempting to restore the header of a virtual VeraCrypt volume but you selected the system partition/drive. This is not allowed. Backup/restore operations pertaining to the system partition/drive can be performed only using the VeraCrypt Rescue Disk.\n\nDo you want to create a VeraCrypt Rescue Disk?</string>
<string lang="en" key="RESCUE_DISK_NON_WIZARD_CREATION_SELECT_PATH">After you click OK, you will select a filename for the new VeraCrypt Rescue Disk ISO image and the location where you wish to place it.</string>
- <string lang="en" key="RESCUE_DISK_NON_WIZARD_CREATION_BURN">The Rescue Disk image has been created and stored in this file:\n%hs\n\nNow you need to burn the Rescue Disk image to a CD or DVD.\n\nIMPORTANT: Note that the file must be written to the CD/DVD as an ISO disk image (not as an individual file). For information on how to do so, please refer to the documentation of your CD/DVD recording software.\n\nAfter you burn the Rescue Disk, select 'System' > 'Verify Rescue Disk' to verify that it has been correctly burned.</string>
- <string lang="en" key="RESCUE_DISK_NON_WIZARD_CREATION_WIN_ISOBURN">The Rescue Disk image has been created and stored in this file:\n%hs\n\nNow you need to burn the Rescue Disk image to a CD or DVD.\n\nDo you want to launch the Microsoft Windows Disc Image Burner now?\n\nNote: After you burn the Rescue Disk, select 'System' > 'Verify Rescue Disk' to verify that it has been correctly burned.</string>
+ <string lang="en" key="RESCUE_DISK_NON_WIZARD_CREATION_BURN">The Rescue Disk image has been created and stored in this file:\n%s\n\nNow you need to burn the Rescue Disk image to a CD or DVD.\n\nIMPORTANT: Note that the file must be written to the CD/DVD as an ISO disk image (not as an individual file). For information on how to do so, please refer to the documentation of your CD/DVD recording software.\n\nAfter you burn the Rescue Disk, select 'System' > 'Verify Rescue Disk' to verify that it has been correctly burned.</string>
+ <string lang="en" key="RESCUE_DISK_NON_WIZARD_CREATION_WIN_ISOBURN">The Rescue Disk image has been created and stored in this file:\n%s\n\nNow you need to burn the Rescue Disk image to a CD or DVD.\n\nDo you want to launch the Microsoft Windows Disc Image Burner now?\n\nNote: After you burn the Rescue Disk, select 'System' > 'Verify Rescue Disk' to verify that it has been correctly burned.</string>
<string lang="en" key="RESCUE_DISK_NON_WIZARD_CHECK_INSERT">Please insert your VeraCrypt Rescue Disk into your CD/DVD drive and click OK to verify it.</string>
<string lang="en" key="RESCUE_DISK_NON_WIZARD_CHECK_PASSED">The VeraCrypt Rescue Disk has been successfully verified.</string>
<string lang="en" key="RESCUE_DISK_NON_WIZARD_CHECK_FAILED">Cannot verify that the Rescue Disk has been correctly burned.\n\nIf you have burned the Rescue Disk, please eject and reinsert the CD/DVD; then try again. If this does not help, please try other CD/DVD recording software and/or medium.\n\nIf you attempted to verify a VeraCrypt Rescue Disk created for a different master key, password, salt, etc., please note that such Rescue Disk will always fail this verification. To create a new Rescue Disk fully compatible with your current configuration, select 'System' > 'Create Rescue Disk'.</string>
@@ -1059,8 +1061,8 @@
<string lang="en" key="NO_SYS_ENC_PROCESS_TO_RESUME">There is no interrupted process of encryption/decryption of the system partition/drive to resume.\n\nNote: If you want to resume an interrupted process of encryption/decryption of a non-system partition/volume, select 'Volumes' &gt; 'Resume Interrupted Process'.</string>
<string lang="en" key="HIDVOL_PROT_BKG_TASK_WARNING">WARNING: VeraCrypt Background Task is disabled. After you exit VeraCrypt, you will not be notified if damage to hidden volume is prevented.\n\nNote: You may shut down the Background Task anytime by right-clicking the VeraCrypt tray icon and selecting 'Exit'.\n\nEnable VeraCrypt Background Task?</string>
<string lang="en" key="LANG_PACK_VERSION">Language pack version: %s</string>
- <string lang="en" key="CHECKING_FS">Checking the file system on the VeraCrypt volume mounted as %hs...</string>
- <string lang="en" key="REPAIRING_FS">Attempting to repair the file system on the VeraCrypt volume mounted as %hs...</string>
+ <string lang="en" key="CHECKING_FS">Checking the file system on the VeraCrypt volume mounted as %s...</string>
+ <string lang="en" key="REPAIRING_FS">Attempting to repair the file system on the VeraCrypt volume mounted as %s...</string>
<string lang="en" key="WARN_64_BIT_BLOCK_CIPHER">Warning: This volume is encrypted with a legacy encryption algorithm.\n\nAll 64-bit-block encryption algorithms (e.g., Blowfish, CAST-128, or Triple DES) are deprecated. It will be possible to mount this volume using future versions of VeraCrypt. However, there will be no further enhancements to the implementations of these legacy encryption algorithms. We recommend that you create a new VeraCrypt volume encrypted with a 128-bit-block encryption algorithm (e.g., AES, Serpent, Twofish, etc.) and that you move all files from this volume to the new volume.</string>
<string lang="en" key="SYS_AUTOMOUNT_DISABLED">Your system is not configured to auto-mount new volumes. It may be impossible to mount device-hosted VeraCrypt volumes. Auto-mounting can be enabled by executing the following command and restarting the system.\n\nmountvol.exe /E</string>
<string lang="en" key="SYS_ASSIGN_DRIVE_LETTER">Please assign a drive letter to the partition/device before proceeding ('Control Panel' > 'System and Maintenance' > 'Administrative Tools' - 'Create and format hard disk partitions').\n\nNote that this is a requirement of the operating system.</string>
@@ -1116,8 +1118,8 @@
<string lang="en" key="KEYB_LAYOUT_SYS_ENC_EXPLANATION">Note: The password will need to be typed in the pre-boot environment (before Windows starts) where non-US Windows keyboard layouts are not available. Therefore, the password must always be typed using the standard US keyboard layout. However, it is important to note that you do NOT need a real US keyboard. VeraCrypt automatically ensures that you can safely type the password (right now and in the pre-boot environment) even if you do NOT have a real US keyboard.</string>
<string lang="en" key="RESCUE_DISK_INFO">Before you can encrypt the partition/drive, you must create a VeraCrypt Rescue Disk (VRD), which serves the following purposes:\n\n- If the VeraCrypt Boot Loader, master key, or other critical data gets damaged, the VRD allows you to restore it (note, however, that you will still have to enter the correct password then).\n\n- If Windows gets damaged and cannot start, the VRD allows you to permanently decrypt the partition/drive before Windows starts.\n\n- The VRD will contain a backup of the present content of the first drive track (which typically contains a system loader or boot manager) and will allow you to restore it if necessary.\n\nThe VeraCrypt Rescue Disk ISO image will be created in the location specified below.</string>
<string lang="en" key="RESCUE_DISK_WIN_ISOBURN_PRELAUNCH_NOTE">After you click OK, Microsoft Windows Disc Image Burner will be launched. Please use it to burn the VeraCrypt Rescue Disk ISO image to a CD or DVD.\n\nAfter you do so, return to the VeraCrypt Volume Creation Wizard and follow its instructions.</string>
- <string lang="en" key="RESCUE_DISK_BURN_INFO">The Rescue Disk image has been created and stored in this file:\n%hs\n\nNow you need to burn it to a CD or DVD.\n\n%lsAfter you burn the Rescue Disk, click Next to verify that it has been correctly burned.</string>
- <string lang="en" key="RESCUE_DISK_BURN_INFO_NO_CHECK">The Rescue Disk image has been created and stored in this file:\n%hs\n\nNow you should either burn the image to a CD/DVD or move it to a safe location for later use.\n\n%lsClick Next to continue.</string>
+ <string lang="en" key="RESCUE_DISK_BURN_INFO">The Rescue Disk image has been created and stored in this file:\n%s\n\nNow you need to burn it to a CD or DVD.\n\n%lsAfter you burn the Rescue Disk, click Next to verify that it has been correctly burned.</string>
+ <string lang="en" key="RESCUE_DISK_BURN_INFO_NO_CHECK">The Rescue Disk image has been created and stored in this file:\n%s\n\nNow you should either burn the image to a CD/DVD or move it to a safe location for later use.\n\n%lsClick Next to continue.</string>
<string lang="en" key="RESCUE_DISK_BURN_INFO_NONWIN_ISO_BURNER">IMPORTANT: Note that the file must be written to the CD/DVD as an ISO disk image (not as an individual file). For information on how to do so, please refer to the documentation of your CD/DVD recording software. If you do not have any CD/DVD recording software that can write the ISO disk image to a CD/DVD, click the link below to download such free software.\n\n</string>
<string lang="en" key="LAUNCH_WIN_ISOBURN">Launch Microsoft Windows Disc Image Burner</string>
<string lang="en" key="RESCUE_DISK_BURN_NO_CHECK_WARN">WARNING: If you already created a VeraCrypt Rescue Disk in the past, it cannot be reused for this system partition/drive because it was created for a different master key! Every time you encrypt a system partition/drive, you must create a new VeraCrypt Rescue Disk for it even if you use the same password.</string>
diff --git a/src/Common/Password.c b/src/Common/Password.c
index 8b44e7d..e22e71a 100644
--- a/src/Common/Password.c
+++ b/src/Common/Password.c
@@ -33,17 +33,25 @@ void VerifyPasswordAndUpdate (HWND hwndDlg, HWND hButton, HWND hPassword,
char *szVerify,
BOOL keyFilesEnabled)
{
- char szTmp1[MAX_PASSWORD + 1];
- char szTmp2[MAX_PASSWORD + 1];
+ wchar_t szTmp1[MAX_PASSWORD + 1];
+ wchar_t szTmp2[MAX_PASSWORD + 1];
+ char szTmp1Utf8[MAX_PASSWORD + 1];
+ char szTmp2Utf8[MAX_PASSWORD + 1];
int k = GetWindowTextLength (hPassword);
BOOL bEnable = FALSE;
+ int utf8Len1, utf8Len2;
UNREFERENCED_PARAMETER (hwndDlg); /* Remove warning */
GetWindowText (hPassword, szTmp1, sizeof (szTmp1));
GetWindowText (hVerify, szTmp2, sizeof (szTmp2));
- if (strcmp (szTmp1, szTmp2) != 0)
+ utf8Len1 = WideCharToMultiByte (CP_UTF8, 0, szTmp1, -1, szTmp1Utf8, MAX_PASSWORD + 1, NULL, NULL);
+ utf8Len2 = WideCharToMultiByte (CP_UTF8, 0, szTmp2, -1, szTmp2Utf8, MAX_PASSWORD + 1, NULL, NULL);
+
+ if (wcscmp (szTmp1, szTmp2) != 0)
+ bEnable = FALSE;
+ else if (utf8Len1 <= 0)
bEnable = FALSE;
else
{
@@ -54,13 +62,25 @@ void VerifyPasswordAndUpdate (HWND hwndDlg, HWND hButton, HWND hPassword,
}
if (szPassword != NULL)
- memcpy (szPassword, szTmp1, sizeof (szTmp1));
+ {
+ if (utf8Len1 > 0)
+ memcpy (szPassword, szTmp1Utf8, sizeof (szTmp1Utf8));
+ else
+ szPassword [0] = 0;
+ }
if (szVerify != NULL)
- memcpy (szVerify, szTmp2, sizeof (szTmp2));
+ {
+ if (utf8Len2 > 0)
+ memcpy (szVerify, szTmp2Utf8, sizeof (szTmp2Utf8));
+ else
+ szVerify [0] = 0;
+ }
burn (szTmp1, sizeof (szTmp1));
burn (szTmp2, sizeof (szTmp2));
+ burn (szTmp1Utf8, sizeof (szTmp1Utf8));
+ burn (szTmp2Utf8, sizeof (szTmp2Utf8));
EnableWindow (hButton, bEnable);
}
@@ -146,11 +166,11 @@ BOOL CheckPasswordLength (HWND hwndDlg, unsigned __int32 passwordLength, int pim
return TRUE;
}
-int ChangePwd (const char *lpszVolume, Password *oldPassword, int old_pkcs5, int old_pim, BOOL truecryptMode, Password *newPassword, int pkcs5, int pim, int wipePassCount, HWND hwndDlg)
+int ChangePwd (const wchar_t *lpszVolume, Password *oldPassword, int old_pkcs5, int old_pim, BOOL truecryptMode, Password *newPassword, int pkcs5, int pim, int wipePassCount, HWND hwndDlg)
{
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;
@@ -190,7 +210,7 @@ int ChangePwd (const char *lpszVolume, Password *oldPassword, int old_pkcs5, int
if (bDevice == FALSE)
{
- strcpy (szCFDevice, szDiskFile);
+ wcscpy (szCFDevice, szDiskFile);
}
else
{
diff --git a/src/Common/Password.h b/src/Common/Password.h
index 6523e88..5d8b79e 100644
--- a/src/Common/Password.h
+++ b/src/Common/Password.h
@@ -40,7 +40,7 @@ typedef struct
void VerifyPasswordAndUpdate ( HWND hwndDlg , HWND hButton , HWND hPassword , HWND hVerify , unsigned char *szPassword , char *szVerify, BOOL keyFilesEnabled );
BOOL CheckPasswordLength (HWND hwndDlg, unsigned __int32 passwordLength, int pim, BOOL bForBoot, BOOL bSkipPasswordWarning, BOOL bSkipPimWarning);
BOOL CheckPasswordCharEncoding (HWND hPassword, Password *ptrPw);
-int ChangePwd (const char *lpszVolume, Password *oldPassword, int old_pkcs5, int old_pim, BOOL truecryptMode, Password *newPassword, int pkcs5, int pim, int wipePassCount, HWND hwndDlg);
+int ChangePwd (const wchar_t *lpszVolume, Password *oldPassword, int old_pkcs5, int old_pim, BOOL truecryptMode, Password *newPassword, int pkcs5, int pim, int wipePassCount, HWND hwndDlg);
#endif // defined(_WIN32) && !defined(TC_WINDOWS_DRIVER)
diff --git a/src/Common/Pkcs5.c b/src/Common/Pkcs5.c
index e7859cc..d1bc602 100644
--- a/src/Common/Pkcs5.c
+++ b/src/Common/Pkcs5.c
@@ -736,24 +736,24 @@ void derive_key_whirlpool (char *pwd, int pwd_len, char *salt, int salt_len, uin
}
-char *get_pkcs5_prf_name (int pkcs5_prf_id)
+wchar_t *get_pkcs5_prf_name (int pkcs5_prf_id)
{
switch (pkcs5_prf_id)
{
case SHA512:
- return "HMAC-SHA-512";
+ return L"HMAC-SHA-512";
case SHA256:
- return "HMAC-SHA-256";
+ return L"HMAC-SHA-256";
case RIPEMD160:
- return "HMAC-RIPEMD-160";
+ return L"HMAC-RIPEMD-160";
case WHIRLPOOL:
- return "HMAC-Whirlpool";
+ return L"HMAC-Whirlpool";
default:
- return "(Unknown)";
+ return L"(Unknown)";
}
}
diff --git a/src/Common/Pkcs5.h b/src/Common/Pkcs5.h
index e9c9ee0..ab42a4b 100644
--- a/src/Common/Pkcs5.h
+++ b/src/Common/Pkcs5.h
@@ -20,24 +20,26 @@
extern "C"
{
#endif
+/* output written to input_digest which must be at lease 20 bytes long */
+void hmac_ripemd160 (char *key, int keylen, char *input_digest, int len);
+void derive_key_ripemd160 (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, char *dk, int dklen);
+
/* output written to d which must be at lease 32 bytes long */
void hmac_sha256 (char *k, int lk, char *d, int ld);
void derive_key_sha256 (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, char *dk, int dklen);
+#ifndef TC_WINDOWS_BOOT
/* output written to d which must be at lease 64 bytes long */
void hmac_sha512 (char *k, int lk, char *d, int ld);
void derive_key_sha512 (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, char *dk, int dklen);
-/* output written to input_digest which must be at lease 20 bytes long */
-void hmac_ripemd160 (char *key, int keylen, char *input_digest, int len);
-void derive_key_ripemd160 (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, char *dk, int dklen);
-
/* output written to d which must be at lease 64 bytes long */
void hmac_whirlpool (char *k, int lk, char *d, int ld);
void derive_key_whirlpool (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, char *dk, int dklen);
int get_pkcs5_iteration_count (int pkcs5_prf_id, int pim, BOOL truecryptMode, BOOL bBoot);
-char *get_pkcs5_prf_name (int pkcs5_prf_id);
+wchar_t *get_pkcs5_prf_name (int pkcs5_prf_id);
+#endif
#if defined(__cplusplus)
}
diff --git a/src/Common/Random.c b/src/Common/Random.c
index f3f9489..84c10e6 100644
--- a/src/Common/Random.c
+++ b/src/Common/Random.c
@@ -631,17 +631,17 @@ BOOL SlowPoll (void)
HKEY hKey;
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE,
- "SYSTEM\\CurrentControlSet\\Control\\ProductOptions",
+ L"SYSTEM\\CurrentControlSet\\Control\\ProductOptions",
0, KEY_READ, &hKey) == ERROR_SUCCESS)
{
- unsigned char szValue[32];
+ wchar_t szValue[32];
dwSize = sizeof (szValue);
isWorkstation = TRUE;
- status = RegQueryValueEx (hKey, "ProductType", 0, NULL,
- szValue, &dwSize);
+ status = RegQueryValueEx (hKey, L"ProductType", 0, NULL,
+ (LPBYTE) szValue, &dwSize);
- if (status == ERROR_SUCCESS && _stricmp ((char *) szValue, "WinNT"))
+ if (status == ERROR_SUCCESS && _wcsicmp (szValue, L"WinNT"))
/* Note: There are (at least) three cases for
ProductType: WinNT = NT Workstation,
ServerNT = NT Server, LanmanNT = NT Server
@@ -656,13 +656,13 @@ BOOL SlowPoll (void)
{
/* Obtain a handle to the module containing the Lan Manager
functions */
- char dllPath[MAX_PATH];
+ wchar_t dllPath[MAX_PATH];
if (GetSystemDirectory (dllPath, MAX_PATH))
{
- StringCbCatA(dllPath, sizeof(dllPath), "\\NETAPI32.DLL");
+ StringCbCatW(dllPath, sizeof(dllPath), L"\\NETAPI32.DLL");
}
else
- StringCbCopyA(dllPath, sizeof(dllPath), "C:\\Windows\\System32\\NETAPI32.DLL");
+ StringCbCopyW(dllPath, sizeof(dllPath), L"C:\\Windows\\System32\\NETAPI32.DLL");
hNetAPI32 = LoadLibrary (dllPath);
if (hNetAPI32 != NULL)
@@ -710,10 +710,10 @@ BOOL SlowPoll (void)
for (nDrive = 0;; nDrive++)
{
DISK_PERFORMANCE diskPerformance;
- char szDevice[24];
+ wchar_t szDevice[24];
/* Check whether we can access this device */
- StringCbPrintfA (szDevice, sizeof(szDevice), "\\\\.\\PhysicalDrive%d", nDrive);
+ StringCbPrintfW (szDevice, sizeof(szDevice), L"\\\\.\\PhysicalDrive%d", nDrive);
hDevice = CreateFile (szDevice, 0, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, 0, NULL);
if (hDevice == INVALID_HANDLE_VALUE)
diff --git a/src/Common/Registry.c b/src/Common/Registry.c
index 4216290..f66e4f0 100644
--- a/src/Common/Registry.c
+++ b/src/Common/Registry.c
@@ -14,7 +14,7 @@
#include "Registry.h"
#include <Strsafe.h>
-BOOL ReadLocalMachineRegistryDword (char *subKey, char *name, DWORD *value)
+BOOL ReadLocalMachineRegistryDword (wchar_t *subKey, wchar_t *name, DWORD *value)
{
HKEY hkey = 0;
DWORD size = sizeof (*value);
@@ -33,7 +33,7 @@ BOOL ReadLocalMachineRegistryDword (char *subKey, char *name, DWORD *value)
return type == REG_DWORD;
}
-BOOL ReadLocalMachineRegistryMultiString (char *subKey, char *name, char *value, DWORD *size)
+BOOL ReadLocalMachineRegistryMultiString (wchar_t *subKey, wchar_t *name, wchar_t *value, DWORD *size)
{
HKEY hkey = 0;
DWORD type;
@@ -51,7 +51,7 @@ BOOL ReadLocalMachineRegistryMultiString (char *subKey, char *name, char *value,
return type == REG_MULTI_SZ;
}
-BOOL ReadLocalMachineRegistryString (const char *subKey, char *name, char *str, DWORD *size)
+BOOL ReadLocalMachineRegistryString (const wchar_t *subKey, wchar_t *name, wchar_t *str, DWORD *size)
{
HKEY hkey = 0;
DWORD type;
@@ -69,7 +69,7 @@ BOOL ReadLocalMachineRegistryString (const char *subKey, char *name, char *str,
return type == REG_SZ;
}
-BOOL ReadLocalMachineRegistryStringNonReflected (const char *subKey, char *name, char *str, DWORD *size, BOOL b32bitApp)
+BOOL ReadLocalMachineRegistryStringNonReflected (const wchar_t *subKey, wchar_t *name, wchar_t *str, DWORD *size, BOOL b32bitApp)
{
HKEY hkey = 0;
DWORD type;
@@ -87,7 +87,7 @@ BOOL ReadLocalMachineRegistryStringNonReflected (const char *subKey, char *name,
return type == REG_SZ;
}
-int ReadRegistryInt (char *subKey, char *name, int defaultValue)
+int ReadRegistryInt (wchar_t *subKey, wchar_t *name, int defaultValue)
{
HKEY hkey = 0;
DWORD value, size = sizeof (DWORD);
@@ -103,27 +103,27 @@ int ReadRegistryInt (char *subKey, char *name, int defaultValue)
return value;
}
-char *ReadRegistryString (char *subKey, char *name, char *defaultValue, char *str, int maxLen)
+wchar_t *ReadRegistryString (wchar_t *subKey, wchar_t *name, wchar_t *defaultValue, wchar_t *str, int maxLen)
{
HKEY hkey = 0;
- char value[MAX_PATH*4];
+ wchar_t value[MAX_PATH*4];
DWORD size = sizeof (value);
- str[maxLen-1] = 0;
- StringCbCopyA (str, maxLen, defaultValue);
+ str[maxLen/2-1] = 0;
+ StringCbCopyW (str, maxLen, defaultValue);
ZeroMemory (value, sizeof value);
if (RegOpenKeyEx (HKEY_CURRENT_USER, subKey,
0, KEY_READ, &hkey) == ERROR_SUCCESS)
if (RegQueryValueEx (hkey, name, 0, 0, (LPBYTE) value, &size) == ERROR_SUCCESS)
- StringCbCopyA (str, maxLen,value);
+ StringCbCopyW (str, maxLen,value);
if (hkey)
RegCloseKey (hkey);
return str;
}
-DWORD ReadRegistryBytes (char *path, char *name, char *value, int maxLen)
+DWORD ReadRegistryBytes (wchar_t *path, wchar_t *name, char *value, int maxLen)
{
HKEY hkey = 0;
DWORD size = maxLen;
@@ -138,7 +138,7 @@ DWORD ReadRegistryBytes (char *path, char *name, char *value, int maxLen)
return success ? size : 0;
}
-void WriteRegistryInt (char *subKey, char *name, int value)
+void WriteRegistryInt (wchar_t *subKey, wchar_t *name, int value)
{
HKEY hkey = 0;
DWORD disp;
@@ -151,7 +151,7 @@ void WriteRegistryInt (char *subKey, char *name, int value)
RegCloseKey (hkey);
}
-BOOL WriteLocalMachineRegistryDword (char *subKey, char *name, DWORD value)
+BOOL WriteLocalMachineRegistryDword (wchar_t *subKey, wchar_t *name, DWORD value)
{
HKEY hkey = 0;
DWORD disp;
@@ -175,31 +175,7 @@ BOOL WriteLocalMachineRegistryDword (char *subKey, char *name, DWORD value)
return TRUE;
}
-BOOL WriteLocalMachineRegistryDwordW (WCHAR *subKey, WCHAR *name, DWORD value)
-{
- HKEY hkey = 0;
- DWORD disp;
- LONG status;
-
- if ((status = RegCreateKeyExW (HKEY_LOCAL_MACHINE, subKey,
- 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hkey, &disp)) != ERROR_SUCCESS)
- {
- SetLastError (status);
- return FALSE;
- }
-
- if ((status = RegSetValueExW (hkey, name, 0, REG_DWORD, (BYTE *) &value, sizeof value)) != ERROR_SUCCESS)
- {
- RegCloseKey (hkey);
- SetLastError (status);
- return FALSE;
- }
-
- RegCloseKey (hkey);
- return TRUE;
-}
-
-BOOL WriteLocalMachineRegistryMultiString (char *subKey, char *name, char *multiString, DWORD size)
+BOOL WriteLocalMachineRegistryMultiString (wchar_t *subKey, wchar_t *name, wchar_t *multiString, DWORD size)
{
HKEY hkey = 0;
DWORD disp;
@@ -223,7 +199,7 @@ BOOL WriteLocalMachineRegistryMultiString (char *subKey, char *name, char *multi
return TRUE;
}
-BOOL WriteLocalMachineRegistryString (char *subKey, char *name, char *str, BOOL expandable)
+BOOL WriteLocalMachineRegistryString (wchar_t *subKey, wchar_t *name, wchar_t *str, BOOL expandable)
{
HKEY hkey = 0;
DWORD disp;
@@ -236,7 +212,7 @@ BOOL WriteLocalMachineRegistryString (char *subKey, char *name, char *str, BOOL
return FALSE;
}
- if ((status = RegSetValueEx (hkey, name, 0, expandable ? REG_EXPAND_SZ : REG_SZ, (BYTE *) str, (DWORD) strlen (str) + 1)) != ERROR_SUCCESS)
+ if ((status = RegSetValueEx (hkey, name, 0, expandable ? REG_EXPAND_SZ : REG_SZ, (BYTE *) str, (DWORD) (wcslen (str) + 1) * sizeof (wchar_t))) != ERROR_SUCCESS)
{
RegCloseKey (hkey);
SetLastError (status);
@@ -247,7 +223,7 @@ BOOL WriteLocalMachineRegistryString (char *subKey, char *name, char *str, BOOL
return TRUE;
}
-void WriteRegistryString (char *subKey, char *name, char *str)
+void WriteRegistryString (wchar_t *subKey, wchar_t *name, wchar_t *str)
{
HKEY hkey = 0;
DWORD disp;
@@ -256,11 +232,11 @@ void WriteRegistryString (char *subKey, char *name, char *str)
0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hkey, &disp) != ERROR_SUCCESS)
return;
- RegSetValueEx (hkey, name, 0, REG_SZ, (BYTE *) str, (DWORD) strlen (str) + 1);
+ RegSetValueEx (hkey, name, 0, REG_SZ, (BYTE *) str, (DWORD) (wcslen (str) + 1) * sizeof (wchar_t));
RegCloseKey (hkey);
}
-BOOL WriteRegistryBytes (char *path, char *name, char *str, DWORD size)
+BOOL WriteRegistryBytes (wchar_t *path, wchar_t *name, char *str, DWORD size)
{
HKEY hkey = 0;
DWORD disp;
@@ -275,7 +251,7 @@ BOOL WriteRegistryBytes (char *path, char *name, char *str, DWORD size)
return res == ERROR_SUCCESS;
}
-BOOL DeleteLocalMachineRegistryKey (char *parentKey, char *subKeyToDelete)
+BOOL DeleteLocalMachineRegistryKey (wchar_t *parentKey, wchar_t *subKeyToDelete)
{
LONG status;
HKEY hkey = 0;
@@ -297,7 +273,7 @@ BOOL DeleteLocalMachineRegistryKey (char *parentKey, char *subKeyToDelete)
return TRUE;
}
-void DeleteRegistryValue (char *subKey, char *name)
+void DeleteRegistryValue (wchar_t *subKey, wchar_t *name)
{
HKEY hkey = 0;
@@ -309,16 +285,16 @@ void DeleteRegistryValue (char *subKey, char *name)
}
-void GetStartupRegKeyName (char *regk, size_t cbRegk)
+void GetStartupRegKeyName (wchar_t *regk, size_t cbRegk)
{
// The string is split in order to prevent some antivirus packages from falsely reporting
// VeraCrypt.exe to contain a possible Trojan horse because of this string (heuristic scan).
- StringCbPrintfA (regk, cbRegk,"%s%s", "Software\\Microsoft\\Windows\\Curren", "tVersion\\Run");
+ StringCbPrintfW (regk, cbRegk,L"%s%s", L"Software\\Microsoft\\Windows\\Curren", L"tVersion\\Run");
}
-void GetRestorePointRegKeyName (char *regk, size_t cbRegk)
+void GetRestorePointRegKeyName (wchar_t *regk, size_t cbRegk)
{
// The string is split in order to prevent some antivirus packages from falsely reporting
// VeraCrypt.exe to contain a possible Trojan horse because of this string (heuristic scan).
- StringCbPrintfA (regk, cbRegk,"%s%s%s%s", "Software\\Microsoft\\Windows", " NT\\Curren", "tVersion\\Sy", "stemRestore");
+ StringCbPrintfW (regk, cbRegk,L"%s%s%s%s", L"Software\\Microsoft\\Windows", L" NT\\Curren", L"tVersion\\Sy", L"stemRestore");
} \ No newline at end of file
diff --git a/src/Common/Registry.h b/src/Common/Registry.h
index 9939677..c485ac0 100644
--- a/src/Common/Registry.h
+++ b/src/Common/Registry.h
@@ -14,24 +14,23 @@
extern "C" {
#endif
-BOOL ReadLocalMachineRegistryDword (char *subKey, char *name, DWORD *value);
-BOOL ReadLocalMachineRegistryMultiString (char *subKey, char *name, char *value, DWORD *size);
-BOOL ReadLocalMachineRegistryString (const char *subKey, char *name, char *value, DWORD *size);
-BOOL ReadLocalMachineRegistryStringNonReflected (const char *subKey, char *name, char *str, DWORD *size, BOOL b32bitApp);
-int ReadRegistryInt (char *subKey, char *name, int defaultValue);
-char *ReadRegistryString (char *subKey, char *name, char *defaultValue, char *str, int maxLen);
-DWORD ReadRegistryBytes (char *path, char *name, char *value, int maxLen);
-void WriteRegistryInt (char *subKey, char *name, int value);
-BOOL WriteLocalMachineRegistryDword (char *subKey, char *name, DWORD value);
-BOOL WriteLocalMachineRegistryDwordW (WCHAR *subKey, WCHAR *name, DWORD value);
-BOOL WriteLocalMachineRegistryMultiString (char *subKey, char *name, char *multiString, DWORD size);
-BOOL WriteLocalMachineRegistryString (char *subKey, char *name, char *str, BOOL expandable);
-void WriteRegistryString (char *subKey, char *name, char *str);
-BOOL WriteRegistryBytes (char *path, char *name, char *str, DWORD size);
-BOOL DeleteLocalMachineRegistryKey (char *parentKey, char *subKeyToDelete);
-void DeleteRegistryValue (char *subKey, char *name);
-void GetStartupRegKeyName (char *regk, size_t cbRegk);
-void GetRestorePointRegKeyName (char *regk, size_t cbRegk);
+BOOL ReadLocalMachineRegistryDword (wchar_t *subKey, wchar_t *name, DWORD *value);
+BOOL ReadLocalMachineRegistryMultiString (wchar_t *subKey, wchar_t *name, wchar_t *value, DWORD *size);
+BOOL ReadLocalMachineRegistryString (const wchar_t *subKey, wchar_t *name, wchar_t *value, DWORD *size);
+BOOL ReadLocalMachineRegistryStringNonReflected (const wchar_t *subKey, wchar_t *name, wchar_t *str, DWORD *size, BOOL b32bitApp);
+int ReadRegistryInt (wchar_t *subKey, wchar_t *name, int defaultValue);
+wchar_t *ReadRegistryString (wchar_t *subKey, wchar_t *name, wchar_t *defaultValue, wchar_t *str, int maxLen);
+DWORD ReadRegistryBytes (wchar_t *path, wchar_t *name, char *value, int maxLen);
+void WriteRegistryInt (wchar_t *subKey, wchar_t *name, int value);
+BOOL WriteLocalMachineRegistryDword (wchar_t *subKey, wchar_t *name, DWORD value);
+BOOL WriteLocalMachineRegistryMultiString (wchar_t *subKey, wchar_t *name, wchar_t *multiString, DWORD size);
+BOOL WriteLocalMachineRegistryString (wchar_t *subKey, wchar_t *name, wchar_t *str, BOOL expandable);
+void WriteRegistryString (wchar_t *subKey, wchar_t *name, wchar_t *str);
+BOOL WriteRegistryBytes (wchar_t *path, wchar_t *name, char *str, DWORD size);
+BOOL DeleteLocalMachineRegistryKey (wchar_t *parentKey, wchar_t *subKeyToDelete);
+void DeleteRegistryValue (wchar_t *subKey, wchar_t *name);
+void GetStartupRegKeyName (wchar_t *regk, size_t cbRegk);
+void GetRestorePointRegKeyName (wchar_t *regk, size_t cbRegk);
#ifdef __cplusplus
}
diff --git a/src/Common/SecurityToken.cpp b/src/Common/SecurityToken.cpp
index 4d2e9c6..d7dacf5 100644
--- a/src/Common/SecurityToken.cpp
+++ b/src/Common/SecurityToken.cpp
@@ -47,7 +47,7 @@ namespace VeraCrypt
SlotId = slotId;
size_t keyIdPos = pathStr.find (L"/" TC_SECURITY_TOKEN_KEYFILE_URL_FILE L"/");
- if (keyIdPos == string::npos)
+ if (keyIdPos == wstring::npos)
throw InvalidSecurityTokenKeyfilePath();
Id = pathStr.substr (keyIdPos + wstring (L"/" TC_SECURITY_TOKEN_KEYFILE_URL_FILE L"/").size());
@@ -510,13 +510,17 @@ namespace VeraCrypt
}
}
+#ifdef TC_WINDOWS
+ void SecurityToken::InitLibrary (const wstring &pkcs11LibraryPath, auto_ptr <GetPinFunctor> pinCallback, auto_ptr <SendExceptionFunctor> warningCallback)
+#else
void SecurityToken::InitLibrary (const string &pkcs11LibraryPath, auto_ptr <GetPinFunctor> pinCallback, auto_ptr <SendExceptionFunctor> warningCallback)
+#endif
{
if (Initialized)
CloseLibrary();
#ifdef TC_WINDOWS
- Pkcs11LibraryHandle = LoadLibraryA (pkcs11LibraryPath.c_str());
+ Pkcs11LibraryHandle = LoadLibraryW (pkcs11LibraryPath.c_str());
#else
Pkcs11LibraryHandle = dlopen (pkcs11LibraryPath.c_str(), RTLD_NOW | RTLD_LOCAL);
#endif
diff --git a/src/Common/SecurityToken.h b/src/Common/SecurityToken.h
index ba680c4..53292c9 100644
--- a/src/Common/SecurityToken.h
+++ b/src/Common/SecurityToken.h
@@ -189,7 +189,11 @@ namespace VeraCrypt
static void GetKeyfileData (const SecurityTokenKeyfile &keyfile, vector <byte> &keyfileData);
static list <SecurityTokenInfo> GetAvailableTokens ();
static SecurityTokenInfo GetTokenInfo (CK_SLOT_ID slotId);
+#ifdef TC_WINDOWS
+ static void InitLibrary (const wstring &pkcs11LibraryPath, auto_ptr <GetPinFunctor> pinCallback, auto_ptr <SendExceptionFunctor> warningCallback);
+#else
static void InitLibrary (const string &pkcs11LibraryPath, auto_ptr <GetPinFunctor> pinCallback, auto_ptr <SendExceptionFunctor> warningCallback);
+#endif
static bool IsInitialized () { return Initialized; }
static bool IsKeyfilePathValid (const wstring &securityTokenKeyfilePath);
diff --git a/src/Common/Tcdefs.h b/src/Common/Tcdefs.h
index bef6bee..5725c13 100644
--- a/src/Common/Tcdefs.h
+++ b/src/Common/Tcdefs.h
@@ -175,6 +175,7 @@ typedef int BOOL;
#include <process.h> /* Process control */
#include <winioctl.h>
#include <stdio.h> /* For sprintf */
+#include <tchar.h>
#endif /* _WIN32 */
@@ -254,7 +255,7 @@ void EraseMemory (void *memory, int size);
#define TC_MAX_PATH 260 /* Includes the null terminator */
#endif
-#define TC_STR_RELEASED_BY "Released by IDRIX on " TC_STR_RELEASE_DATE
+#define TC_STR_RELEASED_BY L"Released by IDRIX on " TC_STR_RELEASE_DATE
#define MAX_URL_LENGTH 2084 /* Internet Explorer limit. Includes the terminating null character. */
diff --git a/src/Common/Tests.c b/src/Common/Tests.c
index ff536e2..3d1f6d8 100644
--- a/src/Common/Tests.c
+++ b/src/Common/Tests.c
@@ -265,7 +265,7 @@ BOOL XTSAesTest (PCRYPTO_INFO ci)
for (i = 0; i < XTS_TEST_COUNT; i++)
{
- ci->ea = EAGetByName ("AES");
+ ci->ea = EAGetByName (L"AES");
if (ci->ea == 0)
return FALSE;
@@ -476,7 +476,7 @@ BOOL TestSectorBufEncryption (PCRYPTO_INFO ci)
{
unsigned char buf [ENCRYPTION_DATA_UNIT_SIZE * 4];
unsigned int i;
- char name[64];
+ wchar_t name[64];
unsigned __int32 crc;
UINT64_STRUCT unitNo;
uint32 nbrUnits;
@@ -538,7 +538,7 @@ BOOL TestSectorBufEncryption (PCRYPTO_INFO ci)
crc = GetCrc32 (buf, sizeof (buf));
- if (strcmp (name, "AES") == 0)
+ if (wcscmp (name, L"AES") == 0)
{
// Verify the ciphertext of the "moving" data unit using the IEEE test vector #14
if (memcmp (XTS_vectors[XTS_TEST_COUNT-1].ciphertext,
@@ -573,7 +573,7 @@ BOOL TestSectorBufEncryption (PCRYPTO_INFO ci)
break;
}
}
- else if (strcmp (name, "Serpent") == 0)
+ else if (wcscmp (name, L"Serpent") == 0)
{
switch (testCase)
{
@@ -599,7 +599,7 @@ BOOL TestSectorBufEncryption (PCRYPTO_INFO ci)
break;
}
}
- else if (strcmp (name, "Twofish") == 0)
+ else if (wcscmp (name, L"Twofish") == 0)
{
switch (testCase)
{
@@ -625,7 +625,7 @@ BOOL TestSectorBufEncryption (PCRYPTO_INFO ci)
break;
}
}
- else if (strcmp (name, "AES-Twofish") == 0)
+ else if (wcscmp (name, L"AES-Twofish") == 0)
{
switch (testCase)
{
@@ -651,7 +651,7 @@ BOOL TestSectorBufEncryption (PCRYPTO_INFO ci)
break;
}
}
- else if (strcmp (name, "AES-Twofish-Serpent") == 0)
+ else if (wcscmp (name, L"AES-Twofish-Serpent") == 0)
{
switch (testCase)
{
@@ -677,7 +677,7 @@ BOOL TestSectorBufEncryption (PCRYPTO_INFO ci)
break;
}
}
- else if (strcmp (name, "Serpent-AES") == 0)
+ else if (wcscmp (name, L"Serpent-AES") == 0)
{
switch (testCase)
{
@@ -703,7 +703,7 @@ BOOL TestSectorBufEncryption (PCRYPTO_INFO ci)
break;
}
}
- else if (strcmp (name, "Serpent-Twofish-AES") == 0)
+ else if (wcscmp (name, L"Serpent-Twofish-AES") == 0)
{
switch (testCase)
{
@@ -729,7 +729,7 @@ BOOL TestSectorBufEncryption (PCRYPTO_INFO ci)
break;
}
}
- else if (strcmp (name, "Twofish-Serpent") == 0)
+ else if (wcscmp (name, L"Twofish-Serpent") == 0)
{
switch (testCase)
{
@@ -801,49 +801,49 @@ BOOL TestSectorBufEncryption (PCRYPTO_INFO ci)
crc = GetCrc32 (buf, sizeof (buf));
- if (strcmp (name, "AES") == 0)
+ if (wcscmp (name, L"AES") == 0)
{
if (crc != 0x33b91fab)
return FALSE;
nTestsPerformed++;
}
- else if (strcmp (name, "Serpent") == 0)
+ else if (wcscmp (name, L"Serpent") == 0)
{
if (crc != 0x3494d480)
return FALSE;
nTestsPerformed++;
}
- else if (strcmp (name, "Twofish") == 0)
+ else if (wcscmp (name, L"Twofish") == 0)
{
if (crc != 0xc4d65b46)
return FALSE;
nTestsPerformed++;
}
- else if (strcmp (name, "AES-Twofish") == 0)
+ else if (wcscmp (name, L"AES-Twofish") == 0)
{
if (crc != 0x14ce7385)
return FALSE;
nTestsPerformed++;
}
- else if (strcmp (name, "AES-Twofish-Serpent") == 0)
+ else if (wcscmp (name, L"AES-Twofish-Serpent") == 0)
{
if (crc != 0x0ec81bf7)
return FALSE;
nTestsPerformed++;
}
- else if (strcmp (name, "Serpent-AES") == 0)
+ else if (wcscmp (name, L"Serpent-AES") == 0)
{
if (crc != 0x42f919ad)
return FALSE;
nTestsPerformed++;
}
- else if (strcmp (name, "Serpent-Twofish-AES") == 0)
+ else if (wcscmp (name, L"Serpent-Twofish-AES") == 0)
{
if (crc != 0x208d5c58)
return FALSE;
nTestsPerformed++;
}
- else if (strcmp (name, "Twofish-Serpent") == 0)
+ else if (wcscmp (name, L"Twofish-Serpent") == 0)
{
if (crc != 0xbe78cec1)
return FALSE;
diff --git a/src/Common/Xml.c b/src/Common/Xml.c
index bd01460..7199451 100644
--- a/src/Common/Xml.c
+++ b/src/Common/Xml.c
@@ -210,26 +210,59 @@ char *XmlQuoteText (const char *textSrc, char *textDst, int textDstMaxSize)
return textDst;
}
-
-int XmlWriteHeader (FILE *file)
+wchar_t *XmlQuoteTextW (const wchar_t *textSrc, wchar_t *textDst, int textDstMaxSize)
{
- return fputs ("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<VeraCrypt>", file);
-}
+ wchar_t *textDstLast = textDst + textDstMaxSize - 1;
+ if (textDstMaxSize == 0)
+ return NULL;
-int XmlWriteHeaderW (FILE *file)
-{
- return fputws (L"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<VeraCrypt>", file);
+ while (*textSrc != 0 && textDst <= textDstLast)
+ {
+ wchar_t c = *textSrc++;
+ switch (c)
+ {
+ case L'&':
+ if (textDst + 6 > textDstLast)
+ return NULL;
+ wcscpy (textDst, L"&amp;");
+ textDst += 5;
+ continue;
+
+ case L'>':
+ if (textDst + 5 > textDstLast)
+ return NULL;
+ wcscpy (textDst, L"&gt;");
+ textDst += 4;
+ continue;
+
+ case L'<':
+ if (textDst + 5 > textDstLast)
+ return NULL;
+ wcscpy (textDst, L"&lt;");
+ textDst += 4;
+ continue;
+
+ default:
+ *textDst++ = c;
+ }
+ }
+
+ if (textDst > textDstLast)
+ return NULL;
+
+ *textDst = 0;
+ return textDst;
}
-int XmlWriteFooter (FILE *file)
+int XmlWriteHeader (FILE *file)
{
- return fputs ("\n</VeraCrypt>", file);
+ return fputws (L"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<VeraCrypt>", file);
}
-int XmlWriteFooterW (FILE *file)
+int XmlWriteFooter (FILE *file)
{
return fputws (L"\n</VeraCrypt>", file);
}
diff --git a/src/Common/Xml.h b/src/Common/Xml.h
index eef5015..02eb69b 100644
--- a/src/Common/Xml.h
+++ b/src/Common/Xml.h
@@ -19,11 +19,10 @@ char *XmlFindElement (char *xmlNode, char *nodeName);
char *XmlGetAttributeText (char *xmlNode, char *xmlAttrName, char *xmlAttrValue, int xmlAttrValueSize);
char *XmlGetNodeText (char *xmlNode, char *xmlText, int xmlTextSize);
int XmlWriteHeader (FILE *file);
-int XmlWriteHeaderW (FILE *file);
int XmlWriteFooter (FILE *file);
-int XmlWriteFooterW (FILE *file);
char *XmlFindElementByAttributeValue (char *xml, char *nodeName, char *attrName, char *attrValue);
char *XmlQuoteText (const char *textSrc, char *textDst, int textDstMaxSize);
+wchar_t *XmlQuoteTextW (const wchar_t *textSrc, wchar_t *textDst, int textDstMaxSize);
#ifdef __cplusplus
}
diff --git a/src/Crypto/Crypto.vcproj b/src/Crypto/Crypto.vcproj
index dfa99e0..b8340e4 100644
--- a/src/Crypto/Crypto.vcproj
+++ b/src/Crypto/Crypto.vcproj
@@ -25,7 +25,7 @@
IntermediateDirectory="Debug"
ConfigurationType="4"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- CharacterSet="2"
+ CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
@@ -86,12 +86,12 @@
/>
</Configuration>
<Configuration
- Name="Release|Win32"
- OutputDirectory="Release"
- IntermediateDirectory="Release"
+ Name="Debug|x64"
+ OutputDirectory="$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="4"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- CharacterSet="2"
+ CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
@@ -107,20 +107,20 @@
/>
<Tool
Name="VCMIDLTool"
+ TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
- Optimization="2"
+ Optimization="0"
AdditionalIncludeDirectories="&quot;$(ProjectDir)\..&quot;;&quot;$(ProjectDir)\..\Common&quot;"
- PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS"
- RuntimeLibrary="0"
- BufferSecurityCheck="true"
+ PreprocessorDefinitions="WIN32;DEBUG;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="0"
+ RuntimeLibrary="1"
+ BufferSecurityCheck="false"
UsePrecompiledHeader="0"
- AssemblerOutput="2"
- AssemblerListingLocation="$(IntDir)/"
WarningLevel="4"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="0"
+ DebugInformationFormat="3"
DisableSpecificWarnings="4100;4127;4201"
/>
<Tool
@@ -135,7 +135,6 @@
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)/Crypto.lib"
- AdditionalLibraryDirectories="$(TargetDir)"
/>
<Tool
Name="VCALinkTool"
@@ -154,12 +153,12 @@
/>
</Configuration>
<Configuration
- Name="Debug|x64"
- OutputDirectory="$(PlatformName)\$(ConfigurationName)"
- IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
ConfigurationType="4"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- CharacterSet="2"
+ CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
@@ -175,20 +174,20 @@
/>
<Tool
Name="VCMIDLTool"
- TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
- Optimization="0"
+ Optimization="2"
AdditionalIncludeDirectories="&quot;$(ProjectDir)\..&quot;;&quot;$(ProjectDir)\..\Common&quot;"
- PreprocessorDefinitions="WIN32;DEBUG;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS"
- MinimalRebuild="true"
- BasicRuntimeChecks="0"
- RuntimeLibrary="1"
- BufferSecurityCheck="false"
+ PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS"
+ RuntimeLibrary="0"
+ BufferSecurityCheck="true"
UsePrecompiledHeader="0"
+ AssemblerOutput="2"
+ AssemblerListingLocation="$(IntDir)/"
WarningLevel="4"
- DebugInformationFormat="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="0"
DisableSpecificWarnings="4100;4127;4201"
/>
<Tool
@@ -203,6 +202,7 @@
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)/Crypto.lib"
+ AdditionalLibraryDirectories="$(TargetDir)"
/>
<Tool
Name="VCALinkTool"
@@ -226,7 +226,7 @@
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="4"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- CharacterSet="2"
+ CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
@@ -311,20 +311,20 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Release|Win32"
+ Name="Debug|x64"
>
<Tool
Name="VCCustomBuildTool"
- CommandLine="echo $(InputFileName) &amp; nasm.exe -Xvc -f win32 -Ox --prefix _ -o &quot;$(TargetDir)\$(InputName).obj&quot; -l &quot;$(TargetDir)\$(InputName).lst&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
+ CommandLine="echo $(InputFileName) &amp; nasm.exe -Xvc -f win64 -Ox -g -o &quot;$(TargetDir)\$(InputName).obj&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
Outputs="$(TargetDir)\$(InputName).obj"
/>
</FileConfiguration>
<FileConfiguration
- Name="Debug|x64"
+ Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
- CommandLine="echo $(InputFileName) &amp; nasm.exe -Xvc -f win64 -Ox -g -o &quot;$(TargetDir)\$(InputName).obj&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
+ CommandLine="echo $(InputFileName) &amp; nasm.exe -Xvc -f win32 -Ox --prefix _ -o &quot;$(TargetDir)\$(InputName).obj&quot; -l &quot;$(TargetDir)\$(InputName).lst&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
Outputs="$(TargetDir)\$(InputName).obj"
/>
</FileConfiguration>
@@ -350,20 +350,20 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Release|Win32"
- ExcludedFromBuild="true"
+ Name="Debug|x64"
>
<Tool
Name="VCCustomBuildTool"
+ CommandLine="echo $(InputFileName) &amp; nasm.exe -Xvc -f win64 -Ox -o &quot;$(TargetDir)\$(InputName).obj&quot; -l &quot;$(TargetDir)\$(InputName).lst&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
+ Outputs="$(TargetDir)\$(InputName).obj"
/>
</FileConfiguration>
<FileConfiguration
- Name="Debug|x64"
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
- CommandLine="echo $(InputFileName) &amp; nasm.exe -Xvc -f win64 -Ox -o &quot;$(TargetDir)\$(InputName).obj&quot; -l &quot;$(TargetDir)\$(InputName).lst&quot; &quot;$(InputPath)&quot;"
- Outputs="$(TargetDir)\$(InputName).obj"
/>
</FileConfiguration>
<FileConfiguration
@@ -371,7 +371,7 @@
>
<Tool
Name="VCCustomBuildTool"
- CommandLine="echo $(InputFileName) &amp; nasm.exe -Xvc -f win64 -Ox -o &quot;$(TargetDir)\$(InputName).obj&quot; -l &quot;$(TargetDir)\$(InputName).lst&quot; &quot;$(InputPath)&quot;"
+ CommandLine="echo $(InputFileName) &amp; nasm.exe -Xvc -f win64 -Ox -o &quot;$(TargetDir)\$(InputName).obj&quot; -l &quot;$(TargetDir)\$(InputName).lst&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
Outputs="$(TargetDir)\$(InputName).obj"
/>
</FileConfiguration>
@@ -389,21 +389,21 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Release|Win32"
+ Name="Debug|x64"
+ ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
- CommandLine="echo $(InputFileName) &amp; nasm.exe -Xvc -f win32 -Ox --prefix _ -o &quot;$(TargetDir)\$(InputName).obj&quot; -l &quot;$(TargetDir)\$(InputName).lst&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
+ CommandLine="echo $(InputFileName) &amp; nasm.exe -Xvc -f win32 -Ox -g --prefix _ -o &quot;$(TargetDir)\$(InputName).obj&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
Outputs="$(TargetDir)\$(InputName).obj"
/>
</FileConfiguration>
<FileConfiguration
- Name="Debug|x64"
- ExcludedFromBuild="true"
+ Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
- CommandLine="echo $(InputFileName) &amp; nasm.exe -Xvc -f win32 -Ox -g --prefix _ -o &quot;$(TargetDir)\$(InputName).obj&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
+ CommandLine="echo $(InputFileName) &amp; nasm.exe -Xvc -f win32 -Ox --prefix _ -o &quot;$(TargetDir)\$(InputName).obj&quot; -l &quot;$(TargetDir)\$(InputName).lst&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
Outputs="$(TargetDir)\$(InputName).obj"
/>
</FileConfiguration>
diff --git a/src/Driver/DriveFilter.c b/src/Driver/DriveFilter.c
index 9fcf307..d5daf89 100644
--- a/src/Driver/DriveFilter.c
+++ b/src/Driver/DriveFilter.c
@@ -13,6 +13,7 @@
#include "TCdefs.h"
#include <ntddk.h>
#include <ntddvol.h>
+#include <Ntstrsafe.h>
#include "Cache.h"
#include "Crc.h"
#include "Crypto.h"
@@ -1812,9 +1813,14 @@ void GetBootEncryptionAlgorithmName (PIRP irp, PIO_STACK_LOCATION irpSp)
{
if (BootDriveFilterExtension && BootDriveFilterExtension->DriveMounted)
{
+ wchar_t BootEncryptionAlgorithmNameW[256];
+ wchar_t BootPrfAlgorithmNameW[256];
GetBootEncryptionAlgorithmNameRequest *request = (GetBootEncryptionAlgorithmNameRequest *) irp->AssociatedIrp.SystemBuffer;
- EAGetName (request->BootEncryptionAlgorithmName, BootDriveFilterExtension->Queue.CryptoInfo->ea, 0);
- HashGetName2 (request->BootPrfAlgorithmName, BootDriveFilterExtension->Queue.CryptoInfo->pkcs5);
+ EAGetName (BootEncryptionAlgorithmNameW, BootDriveFilterExtension->Queue.CryptoInfo->ea, 0);
+ HashGetName2 (BootPrfAlgorithmNameW, BootDriveFilterExtension->Queue.CryptoInfo->pkcs5);
+
+ RtlStringCbPrintfA (request->BootEncryptionAlgorithmName, sizeof (request->BootEncryptionAlgorithmName), "%S", BootEncryptionAlgorithmNameW);
+ RtlStringCbPrintfA (request->BootPrfAlgorithmName, sizeof (request->BootPrfAlgorithmName), "%S", BootPrfAlgorithmNameW);
irp->IoStatus.Information = sizeof (GetBootEncryptionAlgorithmNameRequest);
irp->IoStatus.Status = STATUS_SUCCESS;
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);
diff --git a/src/Format/Format.vcproj b/src/Format/Format.vcproj
index b5b6a4a..72adc4d 100644
--- a/src/Format/Format.vcproj
+++ b/src/Format/Format.vcproj
@@ -25,7 +25,7 @@
IntermediateDirectory="Debug"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- CharacterSet="2"
+ CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
@@ -105,12 +105,12 @@
/>
</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"
@@ -126,21 +126,21 @@
/>
<Tool
Name="VCMIDLTool"
+ TargetEnvironment="3"
TypeLibraryName="$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb"
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalOptions="/w34189"
- Optimization="2"
+ Optimization="0"
AdditionalIncludeDirectories="..\Common;..\Crypto;..\;..\PKCS11"
- PreprocessorDefinitions="VOLFORMAT;WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS"
- RuntimeLibrary="0"
+ PreprocessorDefinitions="VOLFORMAT;WIN32;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
BufferSecurityCheck="true"
UsePrecompiledHeader="0"
- AssemblerOutput="2"
- AssemblerListingLocation="$(IntDir)/"
WarningLevel="4"
- DebugInformationFormat="0"
+ DebugInformationFormat="3"
DisableSpecificWarnings="4057;4100;4127;4201;4204;4701;4706"
/>
<Tool
@@ -154,19 +154,17 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="comctl32.lib setupapi.lib ..\Crypto\Release\crypto.lib"
+ AdditionalDependencies="comctl32.lib setupapi.lib ..\Crypto\x64\Debug\crypto.lib"
OutputFile="$(OutDir)/VeraCryptFormat.exe"
- LinkIncremental="1"
+ LinkIncremental="2"
GenerateManifest="false"
IgnoreAllDefaultLibraries="false"
- GenerateDebugInformation="false"
- GenerateMapFile="true"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile="$(OutDir)/Format.pdb"
SubSystem="2"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="2"
- TargetMachine="1"
+ TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
@@ -189,16 +187,16 @@
/>
<Tool
Name="VCPostBuildEventTool"
- CommandLine="copy Release\VeraCryptFormat.exe &quot;..\Release\Setup Files\VeraCrypt Format.exe&quot;"
+ CommandLine="md &quot;..\Debug\Setup Files&quot; 2&gt;NUL:&#x0D;&#x0A;copy $(TargetPath) &quot;..\Debug\Setup Files\VeraCrypt Format-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"
@@ -214,21 +212,21 @@
/>
<Tool
Name="VCMIDLTool"
- TargetEnvironment="3"
TypeLibraryName="$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb"
/>
<Tool
Name="VCCLCompilerTool"
- Optimization="0"
+ AdditionalOptions="/w34189"
+ Optimization="2"
AdditionalIncludeDirectories="..\Common;..\Crypto;..\;..\PKCS11"
- PreprocessorDefinitions="VOLFORMAT;WIN32;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="1"
+ PreprocessorDefinitions="VOLFORMAT;WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS"
+ RuntimeLibrary="0"
BufferSecurityCheck="true"
UsePrecompiledHeader="0"
+ AssemblerOutput="2"
+ AssemblerListingLocation="$(IntDir)/"
WarningLevel="4"
- DebugInformationFormat="3"
+ DebugInformationFormat="0"
DisableSpecificWarnings="4057;4100;4127;4201;4204;4701;4706"
/>
<Tool
@@ -242,17 +240,19 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="comctl32.lib setupapi.lib ..\Crypto\x64\Debug\crypto.lib"
+ AdditionalDependencies="comctl32.lib setupapi.lib ..\Crypto\Release\crypto.lib"
OutputFile="$(OutDir)/VeraCryptFormat.exe"
- LinkIncremental="2"
+ LinkIncremental="1"
GenerateManifest="false"
IgnoreAllDefaultLibraries="false"
- GenerateDebugInformation="true"
- ProgramDatabaseFile="$(OutDir)/Format.pdb"
+ GenerateDebugInformation="false"
+ GenerateMapFile="true"
SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="2"
- TargetMachine="17"
+ TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
@@ -275,7 +275,7 @@
/>
<Tool
Name="VCPostBuildEventTool"
- CommandLine="md &quot;..\Debug\Setup Files&quot; 2&gt;NUL:&#x0D;&#x0A;copy $(TargetPath) &quot;..\Debug\Setup Files\VeraCrypt Format-x64.exe&quot; &gt;NUL:&#x0D;&#x0A;"
+ CommandLine="copy Release\VeraCryptFormat.exe &quot;..\Release\Setup Files\VeraCrypt Format.exe&quot;"
/>
</Configuration>
<Configuration
@@ -284,7 +284,7 @@
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- CharacterSet="2"
+ CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
@@ -396,7 +396,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Release|Win32"
+ Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
@@ -404,7 +404,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Debug|x64"
+ Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
@@ -432,7 +432,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Release|Win32"
+ Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
@@ -440,7 +440,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Debug|x64"
+ Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
@@ -495,7 +495,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Release|Win32"
+ Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
@@ -503,7 +503,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Debug|x64"
+ Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
@@ -531,7 +531,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Release|Win32"
+ Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
@@ -539,7 +539,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Debug|x64"
+ Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
@@ -587,7 +587,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Release|Win32"
+ Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
@@ -595,7 +595,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Debug|x64"
+ Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
@@ -751,11 +751,11 @@
>
</File>
<File
- RelativePath="..\Common\Resource.h"
+ RelativePath=".\resource.h"
>
</File>
<File
- RelativePath=".\resource.h"
+ RelativePath="..\Common\Resource.h"
>
</File>
<File
@@ -797,6 +797,38 @@
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
+ RelativePath="..\Boot\Windows\Release_Serpent_SHA2\BootSector.bin"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Rescue_Twofish_SHA2\BootSector.bin"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Rescue_Serpent_SHA2\BootSector.bin"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Rescue_AES_SHA2\BootSector.bin"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Rescue_SHA2\BootSector.bin"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Release_SHA2\BootSector.bin"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Release_AES_SHA2\BootSector.bin"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Release_Twofish_SHA2\BootSector.bin"
+ >
+ </File>
+ <File
RelativePath=".\Format.manifest"
>
</File>
@@ -810,6 +842,10 @@
>
</File>
<File
+ RelativePath="..\Common\VeraCrypt_mounted.ico"
+ >
+ </File>
+ <File
RelativePath="..\Common\VeraCrypt_Volume.ico"
>
</File>
@@ -821,35 +857,35 @@
Name="Common"
>
<File
- RelativePath="..\Boot\Windows\Rescue\BootLoader.com.gz"
+ RelativePath="..\Boot\Windows\Release_AES\BootLoader.com.gz"
>
</File>
<File
- RelativePath="..\Boot\Windows\Rescue_Twofish\BootLoader.com.gz"
+ RelativePath="..\Boot\Windows\Release\BootLoader.com.gz"
>
</File>
<File
- RelativePath="..\Boot\Windows\Release_Serpent\BootLoader.com.gz"
+ RelativePath="..\Boot\Windows\Release_Twofish\BootLoader.com.gz"
>
</File>
<File
- RelativePath="..\Boot\Windows\Release_AES\BootLoader.com.gz"
+ RelativePath="..\Boot\Windows\Rescue_Serpent\BootLoader.com.gz"
>
</File>
<File
- RelativePath="..\Boot\Windows\Release\BootLoader.com.gz"
+ RelativePath="..\Boot\Windows\Rescue_AES\BootLoader.com.gz"
>
</File>
<File
- RelativePath="..\Boot\Windows\Release_Twofish\BootLoader.com.gz"
+ RelativePath="..\Boot\Windows\Rescue\BootLoader.com.gz"
>
</File>
<File
- RelativePath="..\Boot\Windows\Rescue_Serpent\BootLoader.com.gz"
+ RelativePath="..\Boot\Windows\Rescue_Twofish\BootLoader.com.gz"
>
</File>
<File
- RelativePath="..\Boot\Windows\Rescue_AES\BootLoader.com.gz"
+ RelativePath="..\Boot\Windows\Release_Serpent\BootLoader.com.gz"
>
</File>
<File
@@ -896,7 +932,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Release|Win32"
+ Name="Debug|x64"
ExcludedFromBuild="true"
>
<Tool
@@ -904,7 +940,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Debug|x64"
+ Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
@@ -950,6 +986,38 @@
</File>
</Filter>
</Filter>
+ <File
+ RelativePath="..\Boot\Windows\Release_Serpent_SHA2\BootLoader.com.gz"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Release_Twofish_SHA2\BootLoader.com.gz"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Rescue_SHA2\BootLoader.com.gz"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Rescue_AES_SHA2\BootLoader.com.gz"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Rescue_Serpent_SHA2\BootLoader.com.gz"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Rescue_Twofish_SHA2\BootLoader.com.gz"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Release_SHA2\BootLoader.com.gz"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Release_AES_SHA2\BootLoader.com.gz"
+ >
+ </File>
</Files>
<Globals>
</Globals>
diff --git a/src/Format/InPlace.c b/src/Format/InPlace.c
index 8d229f4..041f42b 100644
--- a/src/Format/InPlace.c
+++ b/src/Format/InPlace.c
@@ -65,7 +65,7 @@ using namespace VeraCrypt;
// If the returned value is greater than 0, it is the desired volume size in NTFS sectors (not in bytes)
// after shrinking has been performed. If there's any error, returns -1.
-static __int64 NewFileSysSizeAfterShrink (HANDLE dev, const char *devicePath, int64 *totalClusterCount, DWORD *bytesPerCluster, BOOL silent)
+static __int64 NewFileSysSizeAfterShrink (HANDLE dev, const wchar_t *devicePath, int64 *totalClusterCount, DWORD *bytesPerCluster, BOOL silent)
{
NTFS_VOLUME_DATA_BUFFER ntfsVolData;
DWORD nBytesReturned;
@@ -115,17 +115,17 @@ static __int64 NewFileSysSizeAfterShrink (HANDLE dev, const char *devicePath, in
}
-BOOL CheckRequirementsForNonSysInPlaceEnc (HWND hwndDlg, const char *devicePath, BOOL silent)
+BOOL CheckRequirementsForNonSysInPlaceEnc (HWND hwndDlg, const wchar_t *devicePath, BOOL silent)
{
NTFS_VOLUME_DATA_BUFFER ntfsVolData;
DWORD nBytesReturned;
HANDLE dev;
- char szFileSysName [256];
+ WCHAR szFileSysName [256];
WCHAR devPath [MAX_PATH];
- char dosDev [TC_MAX_PATH] = {0};
- char devName [MAX_PATH] = {0};
+ WCHAR dosDev [TC_MAX_PATH] = {0};
+ WCHAR devName [MAX_PATH] = {0};
int driveLetterNo = -1;
- char szRootPath[4] = {0, ':', '\\', 0};
+ WCHAR szRootPath[4] = {0, L':', L'\\', 0};
__int64 deviceSize;
int partitionNumber = -1, driveNumber = -1;
@@ -146,8 +146,8 @@ BOOL CheckRequirementsForNonSysInPlaceEnc (HWND hwndDlg, const char *devicePath,
/* Volume type (must be a partition or a dynamic volume) */
- if (sscanf (devicePath, "\\Device\\HarddiskVolume%d", &partitionNumber) != 1
- && sscanf (devicePath, "\\Device\\Harddisk%d\\Partition%d", &driveNumber, &partitionNumber) != 2)
+ if (swscanf (devicePath, L"\\Device\\HarddiskVolume%d", &partitionNumber) != 1
+ && swscanf (devicePath, L"\\Device\\Harddisk%d\\Partition%d", &driveNumber, &partitionNumber) != 2)
{
if (!silent)
Error ("INPLACE_ENC_INVALID_PATH", hwndDlg);
@@ -181,13 +181,12 @@ BOOL CheckRequirementsForNonSysInPlaceEnc (HWND hwndDlg, const char *devicePath,
/* Access to the partition */
- StringCbCopyA ((char *) devPath, sizeof(devPath), devicePath);
- ToUNICODE ((char *) devPath, sizeof(devPath));
+ StringCbCopyW (devPath, sizeof(devPath), devicePath);
driveLetterNo = GetDiskDeviceDriveLetter (devPath);
if (driveLetterNo >= 0)
- szRootPath[0] = (char) driveLetterNo + 'A';
+ szRootPath[0] = (wchar_t) driveLetterNo + L'A';
if (FakeDosNameForDevice (devicePath, dosDev, sizeof(dosDev), devName, sizeof(devName),FALSE) != 0)
{
@@ -212,9 +211,9 @@ BOOL CheckRequirementsForNonSysInPlaceEnc (HWND hwndDlg, const char *devicePath,
/* File system type */
- GetVolumeInformation (szRootPath, NULL, 0, NULL, NULL, NULL, szFileSysName, sizeof(szFileSysName));
+ GetVolumeInformation (szRootPath, NULL, 0, NULL, NULL, NULL, szFileSysName, ARRAYSIZE (szFileSysName));
- if (strncmp (szFileSysName, "NTFS", 4))
+ if (wcsncmp (szFileSysName, L"NTFS", 4))
{
// The previous filesystem type detection method failed (or it's not NTFS) -- try an alternative method
@@ -328,15 +327,15 @@ BOOL CheckRequirementsForNonSysInPlaceEnc (HWND hwndDlg, const char *devicePath,
return TRUE;
}
-BOOL CheckRequirementsForNonSysInPlaceDec (HWND hwndDlg, const char *devicePath, BOOL silent)
+BOOL CheckRequirementsForNonSysInPlaceDec (HWND hwndDlg, const wchar_t *devicePath, BOOL silent)
{
int partitionNumber = -1, driveNumber = -1;
/* ---------- Checks that do not require admin rights ----------- */
/* Volume type (must be a partition or a dynamic volume) */
- if ((sscanf (devicePath, "\\Device\\HarddiskVolume%d", &partitionNumber) != 1
- && sscanf (devicePath, "\\Device\\Harddisk%d\\Partition%d", &driveNumber, &partitionNumber) != 2)
+ if ((swscanf (devicePath, L"\\Device\\HarddiskVolume%d", &partitionNumber) != 1
+ && swscanf (devicePath, L"\\Device\\Harddisk%d\\Partition%d", &driveNumber, &partitionNumber) != 2)
|| partitionNumber == 0)
{
if (!silent)
@@ -375,8 +374,8 @@ int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, vol
HANDLE dev = INVALID_HANDLE_VALUE;
DWORD dwError;
char *header;
- char dosDev[TC_MAX_PATH] = {0};
- char devName[MAX_PATH] = {0};
+ WCHAR dosDev[TC_MAX_PATH] = {0};
+ WCHAR devName[MAX_PATH] = {0};
int driveLetter = -1;
WCHAR deviceName[MAX_PATH];
uint64 dataAreaSize;
@@ -415,8 +414,7 @@ int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, vol
dataAreaSize = GetVolumeDataAreaSize (volParams->hiddenVol, deviceSize);
- StringCbCopyA ((char *)deviceName, sizeof(deviceName), volParams->volumePath);
- ToUNICODE ((char *)deviceName, sizeof(deviceName));
+ StringCbCopyW (deviceName, sizeof(deviceName), volParams->volumePath);
driveLetter = GetDiskDeviceDriveLetter (deviceName);
@@ -665,7 +663,7 @@ int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, vol
// Add the wizard to the system startup sequence if appropriate
if (!IsNonInstallMode ())
- ManageStartupSeqWiz (FALSE, "/prinplace");
+ ManageStartupSeqWiz (FALSE, L"/prinplace");
nStatus = ERR_SUCCESS;
@@ -714,8 +712,8 @@ int EncryptPartitionInPlaceResume (HANDLE dev,
byte *wipeBuffer = NULL;
byte wipeRandChars [TC_WIPE_RAND_CHAR_COUNT];
byte wipeRandCharsUpdate [TC_WIPE_RAND_CHAR_COUNT];
- char dosDev[TC_MAX_PATH] = {0};
- char devName[MAX_PATH] = {0};
+ WCHAR dosDev[TC_MAX_PATH] = {0};
+ WCHAR devName[MAX_PATH] = {0};
WCHAR deviceName[MAX_PATH];
int nStatus = ERR_SUCCESS;
__int64 deviceSize;
@@ -727,7 +725,7 @@ int EncryptPartitionInPlaceResume (HANDLE dev,
int sectorSize;
int i;
DWORD n;
- char *devicePath = volParams->volumePath;
+ WCHAR *devicePath = volParams->volumePath;
Password *password = volParams->password;
int pkcs5_prf = volParams->pkcs5;
int pim = volParams->pim;
@@ -781,8 +779,7 @@ int EncryptPartitionInPlaceResume (HANDLE dev,
if (dev == INVALID_HANDLE_VALUE)
{
- StringCbCopyA ((char *)deviceName, sizeof(deviceName), devicePath);
- ToUNICODE ((char *)deviceName, sizeof(deviceName));
+ StringCbCopyW (deviceName, sizeof(deviceName), devicePath);
if (FakeDosNameForDevice (devicePath, dosDev, sizeof(dosDev),devName, sizeof(devName),FALSE) != 0)
{
@@ -1188,8 +1185,8 @@ int DecryptPartitionInPlace (volatile FORMAT_VOL_PARAMETERS *volParams, volatile
UINT64_STRUCT unitNo;
char *buf = NULL;
byte *tmpSectorBuf = NULL;
- char dosDev[TC_MAX_PATH] = {0};
- char devName[MAX_PATH] = {0};
+ WCHAR dosDev[TC_MAX_PATH] = {0};
+ WCHAR devName[MAX_PATH] = {0};
WCHAR deviceName[MAX_PATH];
int nStatus = ERR_SUCCESS;
__int64 deviceSize;
@@ -1201,7 +1198,7 @@ int DecryptPartitionInPlace (volatile FORMAT_VOL_PARAMETERS *volParams, volatile
int sectorSize;
int i;
DWORD n;
- char *devicePath = volParams->volumePath;
+ WCHAR *devicePath = volParams->volumePath;
Password *password = volParams->password;
HWND hwndDlg = volParams->hwndDlg;
int pkcs5_prf = volParams->pkcs5;
@@ -1247,8 +1244,7 @@ int DecryptPartitionInPlace (volatile FORMAT_VOL_PARAMETERS *volParams, volatile
}
- StringCbCopyA ((char *)deviceName, sizeof(deviceName), devicePath);
- ToUNICODE ((char *)deviceName, sizeof(deviceName));
+ StringCbCopyW (deviceName, sizeof(deviceName), devicePath);
if (FakeDosNameForDevice (devicePath, dosDev, sizeof(dosDev), devName, sizeof(devName), FALSE) != 0)
{
@@ -1355,7 +1351,7 @@ int DecryptPartitionInPlace (volatile FORMAT_VOL_PARAMETERS *volParams, volatile
// Add the wizard to the system startup sequence if appropriate
if (!IsNonInstallMode ())
- ManageStartupSeqWiz (FALSE, "/prinplace");
+ ManageStartupSeqWiz (FALSE, L"/prinplace");
}
@@ -1769,7 +1765,7 @@ closing_seq:
}
-static HANDLE OpenPartitionVolume (HWND hwndDlg, const char *devName,
+static HANDLE OpenPartitionVolume (HWND hwndDlg, const wchar_t *devName,
BOOL bExclusiveRequired,
BOOL bSharedRequired,
BOOL bSharedRequiresConfirmation,
@@ -2015,7 +2011,7 @@ BOOL SaveNonSysInPlaceEncSettings (int delta, WipeAlgorithmId newWipeAlgorithm,
}
else if (FileExists (GetConfigPath (TC_APPD_FILENAME_NONSYS_INPLACE_ENC_WIPE)))
{
- remove (GetConfigPath (TC_APPD_FILENAME_NONSYS_INPLACE_ENC_WIPE));
+ _wremove (GetConfigPath (TC_APPD_FILENAME_NONSYS_INPLACE_ENC_WIPE));
}
}
@@ -2089,7 +2085,7 @@ closing_seq:
}
-static int OpenBackupHeader (HANDLE dev, const char *devicePath, Password *password, int pkcs5, int pim, PCRYPTO_INFO *retMasterCryptoInfo, CRYPTO_INFO *headerCryptoInfo, __int64 deviceSize)
+static int OpenBackupHeader (HANDLE dev, const wchar_t *devicePath, Password *password, int pkcs5, int pim, PCRYPTO_INFO *retMasterCryptoInfo, CRYPTO_INFO *headerCryptoInfo, __int64 deviceSize)
{
LARGE_INTEGER offset;
DWORD n;
diff --git a/src/Format/InPlace.h b/src/Format/InPlace.h
index 72e7ca2..049a883 100644
--- a/src/Format/InPlace.h
+++ b/src/Format/InPlace.h
@@ -29,8 +29,8 @@ enum nonsys_inplace_enc_status
NONSYS_INPLACE_ENC_STATUS_ERROR
};
-BOOL CheckRequirementsForNonSysInPlaceEnc (HWND hwndDlg, const char *devicePath, BOOL silent);
-BOOL CheckRequirementsForNonSysInPlaceDec (HWND hwndDlg, const char *devicePath, BOOL silent);
+BOOL CheckRequirementsForNonSysInPlaceEnc (HWND hwndDlg, const wchar_t *devicePath, BOOL silent);
+BOOL CheckRequirementsForNonSysInPlaceDec (HWND hwndDlg, const wchar_t *devicePath, BOOL silent);
int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, volatile HANDLE *outHandle, WipeAlgorithmId wipeAlgorithm);
int EncryptPartitionInPlaceResume (HANDLE dev, volatile FORMAT_VOL_PARAMETERS *volParams, WipeAlgorithmId wipeAlgorithm, volatile BOOL *bTryToCorrectReadErrors);
int DecryptPartitionInPlace (volatile FORMAT_VOL_PARAMETERS *volParams, volatile BOOL *DiscardUnreadableEncryptedSectors);
@@ -38,13 +38,13 @@ void ShowInPlaceEncErrMsgWAltSteps (HWND hwndDlg, char *iniStrId, BOOL bErr);
void SetNonSysInplaceEncUIStatus (int nonSysInplaceEncStatus);
int FastVolumeHeaderUpdate (HANDLE dev, CRYPTO_INFO *headerCryptoInfo, CRYPTO_INFO *masterCryptoInfo, __int64 deviceSize);
-static HANDLE OpenPartitionVolume (HWND hwndDlg, const char *devName, BOOL bExclusiveRequired, BOOL bSharedRequired, BOOL bSharedRequiresConfirmation, BOOL bShowAlternativeSteps, BOOL bSilent);
+static HANDLE OpenPartitionVolume (HWND hwndDlg, const wchar_t *devName, BOOL bExclusiveRequired, BOOL bSharedRequired, BOOL bSharedRequiresConfirmation, BOOL bShowAlternativeSteps, BOOL bSilent);
static int DismountFileSystem (HWND hwndDlg, HANDLE dev, int driveLetter, BOOL bForcedAllowed, BOOL bForcedRequiresConfirmation, BOOL bSilent);
static int ConcealNTFS (HANDLE dev);
BOOL SaveNonSysInPlaceEncSettings (int delta, WipeAlgorithmId wipeAlgorithm, BOOL bDecrypting);
static void ExportProgressStats (__int64 bytesDone, __int64 totalSize);
int ZeroUnreadableSectors (HANDLE dev, LARGE_INTEGER startOffset, int64 size, int sectorSize, uint64 *zeroedSectorCount);
-static int OpenBackupHeader (HANDLE dev, const char *devicePath, Password *password, int pkcs5, int pim, PCRYPTO_INFO *retCryptoInfo, CRYPTO_INFO *headerCryptoInfo, __int64 deviceSize);
+static int OpenBackupHeader (HANDLE dev, const wchar_t *devicePath, Password *password, int pkcs5, int pim, PCRYPTO_INFO *retCryptoInfo, CRYPTO_INFO *headerCryptoInfo, __int64 deviceSize);
BOOL MoveClustersBeforeThreshold (HANDLE volumeHandle, PWSTR volumeDevicePath, int64 clusterThreshold);
#ifdef __cplusplus
diff --git a/src/Format/Tcformat.c b/src/Format/Tcformat.c
index 3fb1aca..e33b1ec 100644
--- a/src/Format/Tcformat.c
+++ b/src/Format/Tcformat.c
Binary files differ
diff --git a/src/Format/Tcformat.h b/src/Format/Tcformat.h
index 5bf42fc..778daeb 100644
--- a/src/Format/Tcformat.h
+++ b/src/Format/Tcformat.h
@@ -39,7 +39,7 @@ static void VerifySizeAndUpdate ( HWND hwndDlg , BOOL bUpdate );
static void __cdecl sysEncDriveAnalysisThread (void *hwndDlgArg);
static void __cdecl volTransformThreadFunction ( void *hwndDlg );
static void LoadPage ( HWND hwndDlg , int nPageNo );
-__int64 PrintFreeSpace ( HWND hwndTextBox , char *lpszDrive , PLARGE_INTEGER lDiskFree );
+__int64 PrintFreeSpace ( HWND hwndTextBox , wchar_t *lpszDrive , PLARGE_INTEGER lDiskFree );
void DisplaySizingErrorText ( HWND hwndTextBox );
void EnableDisableFileNext ( HWND hComboBox , HWND hMainButton );
BOOL QueryFreeSpace ( HWND hwndDlg , HWND hwndTextBox , BOOL display );
@@ -49,7 +49,7 @@ void HandleOldAssignedDriveLetter (void);
void AddCipher ( HWND hComboBox , char *lpszCipher , int nCipher );
BOOL CALLBACK PageDialogProc ( HWND hwndDlg , UINT uMsg , WPARAM wParam , LPARAM lParam );
BOOL CALLBACK MainDialogProc ( HWND hwndDlg , UINT uMsg , WPARAM wParam , LPARAM lParam );
-void ExtractCommandLine ( HWND hwndDlg , char *lpszCommandLine );
+void ExtractCommandLine ( HWND hwndDlg , wchar_t *lpszCommandLine );
void DisplayRandPool (HWND hwndDlg, HWND hPoolDisplay, BOOL bShow);
void DisplayPortionsOfKeys (HWND headerKeyHandle, HWND masterKeyHandle, char *headerKeyStr, char *masterKeyStr, BOOL hideKeys);
int DetermineMaxHiddenVolSize (HWND hwndDlg);
@@ -70,7 +70,7 @@ static void NonSysInplaceEncPause (void);
static void NonSysInplaceEncResume (void);
void ShowNonSysInPlaceEncUIStatus (void);
void UpdateNonSysInPlaceEncControls (void);
-int MountHiddenVolHost ( HWND hwndDlg, char *volumePath, int *driveNo, Password *password, int pkcs5_prf, int pim, BOOL bReadOnly );
+int MountHiddenVolHost ( HWND hwndDlg, wchar_t *volumePath, int *driveNo, Password *password, int pkcs5_prf, int pim, BOOL bReadOnly );
int AnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSize, int *realClusterSize, __int64 *pnbrFreeClusters);
int ScanVolClusterBitmap ( HWND hwndDlg, int *driveNo, __int64 nbrClusters, __int64 *nbrFreeClusters);
static void WipeStart (void);
diff --git a/src/Mount/Favorites.cpp b/src/Mount/Favorites.cpp
index 5d56345..39318bc 100644
--- a/src/Mount/Favorites.cpp
+++ b/src/Mount/Favorites.cpp
@@ -48,11 +48,11 @@ namespace VeraCrypt
}
FavoriteVolume favorite;
- favorite.MountPoint = "X:\\";
- favorite.MountPoint[0] = (char) (prop.driveNo + 'A');
+ favorite.MountPoint = L"X:\\";
+ favorite.MountPoint[0] = (wchar_t) (prop.driveNo + L'A');
- favorite.Path = WideToSingleString ((wchar_t *) prop.wszVolume);
- if (favorite.Path.find ("\\??\\") == 0)
+ favorite.Path = prop.wszVolume;
+ if (favorite.Path.find (L"\\??\\") == 0)
favorite.Path = favorite.Path.substr (4);
if (wcslen (prop.wszLabel))
@@ -64,30 +64,30 @@ namespace VeraCrypt
if (IsVolumeDeviceHosted (favorite.Path.c_str()))
{
// Get GUID path
- string volumeDevPath = favorite.Path;
+ wstring volumeDevPath = favorite.Path;
wchar_t resolvedVolumeDevPath[TC_MAX_PATH];
- if (ResolveSymbolicLink (SingleStringToWide (volumeDevPath).c_str(), resolvedVolumeDevPath, sizeof(resolvedVolumeDevPath)))
- volumeDevPath = WideToSingleString (resolvedVolumeDevPath);
+ if (ResolveSymbolicLink (volumeDevPath.c_str(), resolvedVolumeDevPath, sizeof(resolvedVolumeDevPath)))
+ volumeDevPath = resolvedVolumeDevPath;
- char volumeName[TC_MAX_PATH];
- HANDLE find = FindFirstVolume (volumeName, sizeof (volumeName));
+ wchar_t volumeName[TC_MAX_PATH];
+ HANDLE find = FindFirstVolume (volumeName, ARRAYSIZE (volumeName));
if (find != INVALID_HANDLE_VALUE)
{
do
{
- char findVolumeDevPath[TC_MAX_PATH];
- string vn = volumeName;
+ wchar_t findVolumeDevPath[TC_MAX_PATH];
+ wstring vn = volumeName;
- if (QueryDosDevice (vn.substr (4, vn.size() - 5).c_str(), findVolumeDevPath, sizeof (findVolumeDevPath)) != 0
+ if (QueryDosDevice (vn.substr (4, vn.size() - 5).c_str(), findVolumeDevPath, ARRAYSIZE (findVolumeDevPath)) != 0
&& volumeDevPath == findVolumeDevPath)
{
favorite.VolumePathId = volumeName;
break;
}
- } while (FindNextVolume (find, volumeName, sizeof (volumeName)));
+ } while (FindNextVolume (find, volumeName, ARRAYSIZE (volumeName)));
FindVolumeClose (find);
}
@@ -101,9 +101,9 @@ namespace VeraCrypt
if (favorite.VolumePathId.empty()
&& IsVolumeDeviceHosted (favorite.Path.c_str())
- && favorite.Path.find ("\\\\?\\Volume{") != 0)
+ && favorite.Path.find (L"\\\\?\\Volume{") != 0)
{
- Warning (favorite.Path.find ("\\Partition0") == string::npos ? "FAVORITE_ADD_PARTITION_TYPE_WARNING" : "FAVORITE_ADD_DRIVE_DEV_WARNING", hwndDlg);
+ Warning (favorite.Path.find (L"\\Partition0") == wstring::npos ? "FAVORITE_ADD_PARTITION_TYPE_WARNING" : "FAVORITE_ADD_DRIVE_DEV_WARNING", hwndDlg);
}
return OrganizeFavoriteVolumes (hwndDlg, systemFavorites, favorite);
@@ -429,7 +429,7 @@ namespace VeraCrypt
if (FavoriteVolumes.empty())
return;
- AppendMenu (FavoriteVolumesMenu, MF_SEPARATOR, 0, "");
+ AppendMenu (FavoriteVolumesMenu, MF_SEPARATOR, 0, L"");
int i = 0;
foreach (const FavoriteVolume &favorite, FavoriteVolumes)
@@ -439,7 +439,7 @@ namespace VeraCrypt
if (favorite.DisconnectedDevice)
flags |= MF_GRAYED;
- wstring menuText = SingleStringToWide (favorite.Path);
+ wstring menuText = favorite.Path;
if (favorite.DisconnectedDevice)
menuText = favorite.Label.empty() ? wstring (L"(") + GetString ("FAVORITE_DISCONNECTED_DEV") + L")" : L"";
@@ -452,7 +452,7 @@ namespace VeraCrypt
}
AppendMenuW (FavoriteVolumesMenu, flags, TC_FAVORITE_MENU_CMD_ID_OFFSET + i++,
- (menuText + L"\t" + SingleStringToWide (favorite.MountPoint).substr (0, 2)).c_str());
+ (menuText + L"\t" + favorite.MountPoint.substr (0, 2)).c_str());
}
}
@@ -464,7 +464,7 @@ namespace VeraCrypt
int line = 0;
foreach (const FavoriteVolume favorite, favorites)
{
- ListItemAdd (favoriteListControl, line, (char *) favorite.MountPoint.substr (0, 2).c_str());
+ ListItemAdd (favoriteListControl, line, (wchar_t *) favorite.MountPoint.substr (0, 2).c_str());
FillListControlSubItems (favoriteListControl, line++, favorite);
}
}
@@ -472,16 +472,16 @@ namespace VeraCrypt
static void FillListControlSubItems (HWND FavoriteListControl, int line, const FavoriteVolume &favorite)
{
- ListSubItemSetW (FavoriteListControl, line, 1, (wchar_t *) favorite.Label.c_str());
+ ListSubItemSet (FavoriteListControl, line, 1, (wchar_t *) favorite.Label.c_str());
if (favorite.DisconnectedDevice)
- ListSubItemSetW (FavoriteListControl, line, 2, (wchar_t *) (wstring (L"(") + GetString ("FAVORITE_DISCONNECTED_DEV") + L")").c_str());
+ ListSubItemSet (FavoriteListControl, line, 2, (wchar_t *) (wstring (L"(") + GetString ("FAVORITE_DISCONNECTED_DEV") + L")").c_str());
else
- ListSubItemSet (FavoriteListControl, line, 2, (char *) favorite.Path.c_str());
+ ListSubItemSet (FavoriteListControl, line, 2, (wchar_t *) favorite.Path.c_str());
}
- wstring GetFavoriteVolumeLabel (const string &volumePath, bool& useInExplorer)
+ wstring GetFavoriteVolumeLabel (const wstring &volumePath, bool& useInExplorer)
{
foreach (const FavoriteVolume &favorite, FavoriteVolumes)
{
@@ -523,7 +523,7 @@ namespace VeraCrypt
void LoadFavoriteVolumes (vector <FavoriteVolume> &favorites, bool systemFavorites, bool noUacElevation)
{
favorites.clear();
- string favoritesFilePath = systemFavorites ? GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES, false) : GetConfigPath (TC_APPD_FILENAME_FAVORITE_VOLUMES);
+ wstring favoritesFilePath = systemFavorites ? GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES, false) : GetConfigPath (TC_APPD_FILENAME_FAVORITE_VOLUMES);
if (systemFavorites && !IsAdmin() && !noUacElevation)
{
@@ -560,10 +560,10 @@ namespace VeraCrypt
FavoriteVolume favorite;
XmlGetAttributeText (xml, "mountpoint", mountPoint, sizeof (mountPoint));
- favorite.MountPoint = mountPoint;
+ favorite.MountPoint = Utf8StringToWide (mountPoint);
XmlGetNodeText (xml, volume, sizeof (volume));
- favorite.Path = WideToSingleString (Utf8StringToWide (volume));
+ favorite.Path = Utf8StringToWide (volume);
char label[1024];
XmlGetAttributeText (xml, "label", label, sizeof (label));
@@ -612,9 +612,9 @@ namespace VeraCrypt
if (boolVal[0])
favorite.UseLabelInExplorer = (boolVal[0] == '1') && !favorite.ReadOnly;
- if (favorite.Path.find ("\\\\?\\Volume{") == 0 && favorite.Path.rfind ("}\\") == favorite.Path.size() - 2)
+ if (favorite.Path.find (L"\\\\?\\Volume{") == 0 && favorite.Path.rfind (L"}\\") == favorite.Path.size() - 2)
{
- string resolvedPath = VolumeGuidPathToDevicePath (favorite.Path);
+ wstring resolvedPath = VolumeGuidPathToDevicePath (favorite.Path);
if (!resolvedPath.empty())
{
favorite.DisconnectedDevice = false;
@@ -688,26 +688,26 @@ namespace VeraCrypt
FILE *f;
int cnt = 0;
- f = fopen (GetConfigPath (systemFavorites ? TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES : TC_APPD_FILENAME_FAVORITE_VOLUMES), "w,ccs=UTF-8");
+ f = _wfopen (GetConfigPath (systemFavorites ? TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES : TC_APPD_FILENAME_FAVORITE_VOLUMES), L"w,ccs=UTF-8");
if (f == NULL)
{
handleWin32Error (MainDlg, SRC_POS);
return false;
}
- XmlWriteHeaderW (f);
+ XmlWriteHeader (f);
fputws (L"\n\t<favorites>", f);
foreach (const FavoriteVolume &favorite, favorites)
{
- char tq[2048];
+ wchar_t tq[2048];
- if (systemFavorites && favorite.Path.find ("\\\\") == 0 && favorite.Path.find ("Volume{") == string::npos)
+ if (systemFavorites && favorite.Path.find (L"\\\\") == 0 && favorite.Path.find (L"Volume{") == wstring::npos)
Warning ("SYSTEM_FAVORITE_NETWORK_PATH_ERR", hwndDlg);
- XmlQuoteText (!favorite.VolumePathId.empty() ? favorite.VolumePathId.c_str() : favorite.Path.c_str(), tq, sizeof (tq));
+ XmlQuoteTextW (!favorite.VolumePathId.empty() ? favorite.VolumePathId.c_str() : favorite.Path.c_str(), tq, ARRAYSIZE (tq));
- wstring s = L"\n\t\t<volume mountpoint=\"" + SingleStringToWide (favorite.MountPoint) + L"\"";
+ wstring s = L"\n\t\t<volume mountpoint=\"" + favorite.MountPoint + L"\"";
if (!favorite.Label.empty())
s += L" label=\"" + favorite.Label + L"\"";
@@ -739,14 +739,14 @@ namespace VeraCrypt
if (favorite.UseLabelInExplorer && !favorite.ReadOnly)
s += L" useLabelInExplorer=\"1\"";
- s += L">" + SingleStringToWide (tq) + L"</volume>";
+ s += L">" + wstring (tq) + L"</volume>";
fwprintf (f, L"%ws", s.c_str());
cnt++;
}
fputws (L"\n\t</favorites>", f);
- XmlWriteFooterW (f);
+ XmlWriteFooter (f);
if (!CheckFileStreamWriteErrors (hwndDlg, f, systemFavorites ? TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES : TC_APPD_FILENAME_FAVORITE_VOLUMES))
{
@@ -760,7 +760,7 @@ namespace VeraCrypt
if (systemFavorites)
{
- finally_do ({ remove (GetConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES)); });
+ finally_do ({ _wremove (GetConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES)); });
try
{
@@ -796,7 +796,7 @@ namespace VeraCrypt
catch (...) { }
}
else
- remove (GetConfigPath (TC_APPD_FILENAME_FAVORITE_VOLUMES));
+ _wremove (GetConfigPath (TC_APPD_FILENAME_FAVORITE_VOLUMES));
}
return true;
@@ -807,12 +807,12 @@ namespace VeraCrypt
{
if (favorite.Pim > 0)
{
- char szTmp[MAX_PIM + 1];
- StringCbPrintfA (szTmp, sizeof(szTmp), "%d", favorite.Pim);
+ wchar_t szTmp[MAX_PIM + 1];
+ StringCbPrintfW (szTmp, sizeof(szTmp), L"%d", favorite.Pim);
SetDlgItemText (hwndDlg, IDC_PIM, szTmp);
}
else
- SetDlgItemText (hwndDlg, IDC_PIM, "");
+ SetDlgItemText (hwndDlg, IDC_PIM, L"");
SetDlgItemTextW (hwndDlg, IDC_FAVORITE_LABEL, favorite.Label.c_str());
SetCheckBox (hwndDlg, IDC_FAVORITE_USE_LABEL_IN_EXPLORER, favorite.UseLabelInExplorer);
SetCheckBox (hwndDlg, IDC_FAVORITE_MOUNT_ON_LOGON, favorite.MountOnLogOn);
@@ -886,24 +886,24 @@ namespace VeraCrypt
if (favorite.VolumePathId.empty()
&& IsVolumeDeviceHosted (favorite.Path.c_str())
- && favorite.Path.find ("\\\\?\\Volume{") != 0)
+ && favorite.Path.find (L"\\\\?\\Volume{") != 0)
{
- bool partition = (favorite.Path.find ("\\Partition0") == string::npos);
+ bool partition = (favorite.Path.find (L"\\Partition0") == wstring::npos);
if (!favorite.Label.empty())
{
- ErrorDirect ((GetString (partition ? "FAVORITE_LABEL_PARTITION_TYPE_ERR" : "FAVORITE_LABEL_DEVICE_PATH_ERR") + wstring (L"\n\n") + SingleStringToWide (favorite.Path)).c_str(), hwndDlg);
+ ErrorDirect ((GetString (partition ? "FAVORITE_LABEL_PARTITION_TYPE_ERR" : "FAVORITE_LABEL_DEVICE_PATH_ERR") + wstring (L"\n\n") + favorite.Path).c_str(), hwndDlg);
favorite.Label.clear();
}
if (favorite.MountOnArrival)
{
- ErrorDirect ((GetString (partition ? "FAVORITE_ARRIVAL_MOUNT_PARTITION_TYPE_ERR" : "FAVORITE_ARRIVAL_MOUNT_DEVICE_PATH_ERR") + wstring (L"\n\n") + SingleStringToWide (favorite.Path)).c_str(), hwndDlg);
+ ErrorDirect ((GetString (partition ? "FAVORITE_ARRIVAL_MOUNT_PARTITION_TYPE_ERR" : "FAVORITE_ARRIVAL_MOUNT_DEVICE_PATH_ERR") + wstring (L"\n\n") + favorite.Path).c_str(), hwndDlg);
favorite.MountOnArrival = false;
}
}
- if (favorite.MountOnArrival && favorite.Path.find ("\\\\") == 0 && favorite.Path.find ("Volume{") == string::npos)
+ if (favorite.MountOnArrival && favorite.Path.find (L"\\\\") == 0 && favorite.Path.find (L"Volume{") == wstring::npos)
{
Error ("FAVORITE_ARRIVAL_MOUNT_NETWORK_PATH_ERR", hwndDlg);
favorite.MountOnArrival = false;
diff --git a/src/Mount/Favorites.h b/src/Mount/Favorites.h
index f82037c..3114d16 100644
--- a/src/Mount/Favorites.h
+++ b/src/Mount/Favorites.h
@@ -34,9 +34,9 @@ namespace VeraCrypt
{
}
- string Path;
- string MountPoint;
- string VolumePathId;
+ wstring Path;
+ wstring MountPoint;
+ wstring VolumePathId;
wstring Label;
int Pim;
@@ -69,7 +69,7 @@ namespace VeraCrypt
static void FillFavoriteVolumesMenu ();
static void FillListControl (HWND favoriteListControl, vector <FavoriteVolume> &favorites);
static void FillListControlSubItems (HWND favoriteListControl, int line, const FavoriteVolume &favorite);
- wstring GetFavoriteVolumeLabel (const string &volumePath, bool& useInExplorer);
+ wstring GetFavoriteVolumeLabel (const wstring &volumePath, bool& useInExplorer);
void LoadFavoriteVolumes ();
void LoadFavoriteVolumes (vector <FavoriteVolume> &favorites, bool systemFavorites, bool noUacElevation = false);
static void OnFavoriteVolumesUpdated ();
diff --git a/src/Mount/MainCom.cpp b/src/Mount/MainCom.cpp
index c810e3e..79b6309 100644
--- a/src/Mount/MainCom.cpp
+++ b/src/Mount/MainCom.cpp
@@ -79,24 +79,14 @@ public:
virtual int STDMETHODCALLTYPE BackupVolumeHeader (LONG_PTR hwndDlg, BOOL bRequireConfirmation, BSTR lpszVolume)
{
- USES_CONVERSION;
- CW2A szVolumeA(lpszVolume);
MainDlg = (HWND) hwndDlg;
- if (szVolumeA.m_psz)
- return ::BackupVolumeHeader ((HWND) hwndDlg, bRequireConfirmation, szVolumeA.m_psz);
- else
- return ERR_OUTOFMEMORY;
+ return ::BackupVolumeHeader ((HWND) hwndDlg, bRequireConfirmation, lpszVolume);
}
virtual int STDMETHODCALLTYPE RestoreVolumeHeader (LONG_PTR hwndDlg, BSTR lpszVolume)
{
- USES_CONVERSION;
- CW2A szVolumeA(lpszVolume);
MainDlg = (HWND) hwndDlg;
- if (szVolumeA.m_psz)
- return ::RestoreVolumeHeader ((HWND) hwndDlg, szVolumeA.m_psz);
- else
- return ERR_OUTOFMEMORY;
+ return ::RestoreVolumeHeader ((HWND) hwndDlg, lpszVolume);
}
virtual DWORD STDMETHODCALLTYPE CallDriver (DWORD ioctl, BSTR input, BSTR *output)
@@ -106,13 +96,8 @@ public:
virtual int STDMETHODCALLTYPE ChangePassword (BSTR volumePath, Password *oldPassword, Password *newPassword, int pkcs5, int wipePassCount, LONG_PTR hWnd)
{
- USES_CONVERSION;
- CW2A volumePathA(volumePath);
MainDlg = (HWND) hWnd;
- if (volumePathA.m_psz)
- return ::ChangePwd (volumePathA.m_psz, oldPassword, 0, 0, FALSE, newPassword, pkcs5, 0, wipePassCount, (HWND) hWnd);
- else
- return ERR_OUTOFMEMORY;
+ return ::ChangePwd (volumePath, oldPassword, 0, 0, FALSE, newPassword, pkcs5, 0, wipePassCount, (HWND) hWnd);
}
virtual DWORD STDMETHODCALLTYPE CopyFile (BSTR sourceFile, BSTR destinationFile)
@@ -157,35 +142,20 @@ public:
virtual int STDMETHODCALLTYPE ChangePasswordEx (BSTR volumePath, Password *oldPassword, int old_pkcs5, Password *newPassword, int pkcs5, int wipePassCount, LONG_PTR hWnd)
{
- USES_CONVERSION;
- CW2A volumePathA(volumePath);
MainDlg = (HWND) hWnd;
- if (volumePathA.m_psz)
- return ::ChangePwd (volumePathA.m_psz, oldPassword, old_pkcs5, 0, FALSE, newPassword, pkcs5, 0, wipePassCount, (HWND) hWnd);
- else
- return ERR_OUTOFMEMORY;
+ return ::ChangePwd (volumePath, oldPassword, old_pkcs5, 0, FALSE, newPassword, pkcs5, 0, wipePassCount, (HWND) hWnd);
}
virtual int STDMETHODCALLTYPE ChangePasswordEx2 (BSTR volumePath, Password *oldPassword, int old_pkcs5, BOOL truecryptMode, Password *newPassword, int pkcs5, int wipePassCount, LONG_PTR hWnd)
{
- USES_CONVERSION;
- CW2A volumePathA(volumePath);
MainDlg = (HWND) hWnd;
- if (volumePathA.m_psz)
- return ::ChangePwd (volumePathA.m_psz, oldPassword, old_pkcs5, 0, truecryptMode, newPassword, pkcs5, 0, wipePassCount, (HWND) hWnd);
- else
- return ERR_OUTOFMEMORY;
+ return ::ChangePwd (volumePath, oldPassword, old_pkcs5, 0, truecryptMode, newPassword, pkcs5, 0, wipePassCount, (HWND) hWnd);
}
virtual int STDMETHODCALLTYPE ChangePasswordEx3 (BSTR volumePath, Password *oldPassword, int old_pkcs5, int old_pim, BOOL truecryptMode, Password *newPassword, int pkcs5, int pim, int wipePassCount, LONG_PTR hWnd)
{
- USES_CONVERSION;
- CW2A volumePathA(volumePath);
MainDlg = (HWND) hWnd;
- if (volumePathA.m_psz)
- return ::ChangePwd (volumePathA.m_psz, oldPassword, old_pkcs5, old_pim, truecryptMode, newPassword, pkcs5, pim, wipePassCount, (HWND) hWnd);
- else
- return ERR_OUTOFMEMORY;
+ return ::ChangePwd (volumePath, oldPassword, old_pkcs5, old_pim, truecryptMode, newPassword, pkcs5, pim, wipePassCount, (HWND) hWnd);
}
protected:
@@ -245,7 +215,7 @@ ITrueCryptMainCom *GetElevatedInstance (HWND parent)
}
-extern "C" int UacBackupVolumeHeader (HWND hwndDlg, BOOL bRequireConfirmation, char *lpszVolume)
+extern "C" int UacBackupVolumeHeader (HWND hwndDlg, BOOL bRequireConfirmation, wchar_t *lpszVolume)
{
CComPtr<ITrueCryptMainCom> tc;
int r;
@@ -255,7 +225,7 @@ extern "C" int UacBackupVolumeHeader (HWND hwndDlg, BOOL bRequireConfirmation, c
if (ComGetInstance (hwndDlg, &tc))
{
CComBSTR volumeBstr;
- BSTR bstr = A2WBSTR(lpszVolume);
+ BSTR bstr = W2BSTR(lpszVolume);
if (bstr)
{
volumeBstr.Attach (bstr);
@@ -273,7 +243,7 @@ extern "C" int UacBackupVolumeHeader (HWND hwndDlg, BOOL bRequireConfirmation, c
}
-extern "C" int UacRestoreVolumeHeader (HWND hwndDlg, char *lpszVolume)
+extern "C" int UacRestoreVolumeHeader (HWND hwndDlg, wchar_t *lpszVolume)
{
CComPtr<ITrueCryptMainCom> tc;
int r;
@@ -283,7 +253,7 @@ extern "C" int UacRestoreVolumeHeader (HWND hwndDlg, char *lpszVolume)
if (ComGetInstance (hwndDlg, &tc))
{
CComBSTR volumeBstr;
- BSTR bstr = A2WBSTR(lpszVolume);
+ BSTR bstr = W2BSTR(lpszVolume);
if (bstr)
{
volumeBstr.Attach (bstr);
@@ -301,7 +271,7 @@ extern "C" int UacRestoreVolumeHeader (HWND hwndDlg, char *lpszVolume)
}
-extern "C" int UacChangePwd (char *lpszVolume, Password *oldPassword, int old_pkcs5, int old_pim, BOOL truecryptMode, Password *newPassword, int pkcs5, int pim, int wipePassCount, HWND hwndDlg)
+extern "C" int UacChangePwd (wchar_t *lpszVolume, Password *oldPassword, int old_pkcs5, int old_pim, BOOL truecryptMode, Password *newPassword, int pkcs5, int pim, int wipePassCount, HWND hwndDlg)
{
CComPtr<ITrueCryptMainCom> tc;
int r;
@@ -311,16 +281,7 @@ extern "C" int UacChangePwd (char *lpszVolume, Password *oldPassword, int old_pk
if (ComGetInstance (hwndDlg, &tc))
{
WaitCursor ();
- CComBSTR volumeBstr;
- BSTR bstr = A2WBSTR(lpszVolume);
- if (bstr)
- {
- volumeBstr.Attach (bstr);
-
- r = tc->ChangePasswordEx3 (volumeBstr, oldPassword, old_pkcs5, old_pim, truecryptMode, newPassword, pkcs5, pim, wipePassCount, (LONG_PTR) hwndDlg);
- }
- else
- r = ERR_OUTOFMEMORY;
+ r = tc->ChangePasswordEx3 (lpszVolume, oldPassword, old_pkcs5, old_pim, truecryptMode, newPassword, pkcs5, pim, wipePassCount, (LONG_PTR) hwndDlg);
NormalCursor ();
}
else
diff --git a/src/Mount/MainCom.h b/src/Mount/MainCom.h
index befc884..a6c6c71 100644
--- a/src/Mount/MainCom.h
+++ b/src/Mount/MainCom.h
@@ -24,9 +24,9 @@ extern "C" {
#endif
BOOL ComServerMain ();
-int UacBackupVolumeHeader (HWND hwndDlg, BOOL bRequireConfirmation, char *lpszVolume);
-int UacRestoreVolumeHeader (HWND hwndDlg, char *lpszVolume);
-int UacChangePwd (char *lpszVolume, Password *oldPassword, int old_pkcs5, int old_pim, BOOL truecryptMode, Password *newPassword, int pkcs5, int pim, int wipePassCount, HWND hwndDlg);
+int UacBackupVolumeHeader (HWND hwndDlg, BOOL bRequireConfirmation, wchar_t *lpszVolume);
+int UacRestoreVolumeHeader (HWND hwndDlg, wchar_t *lpszVolume);
+int UacChangePwd (wchar_t *lpszVolume, Password *oldPassword, int old_pkcs5, int old_pim, BOOL truecryptMode, Password *newPassword, int pkcs5, int pim, int wipePassCount, HWND hwndDlg);
#ifdef __cplusplus
}
diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c
index c546b21..ccf384e 100644
--- a/src/Mount/Mount.c
+++ b/src/Mount/Mount.c
@@ -79,9 +79,9 @@ BootEncryptionStatus RecentBootEncStatus;
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 bCacheDuringMultipleMount = FALSE;
@@ -143,7 +143,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. */
@@ -170,11 +170,11 @@ static void RegisterWtsNotification(HWND hWnd)
{
if (!hWtsLib)
{
- char dllPath[MAX_PATH];
+ wchar_t dllPath[MAX_PATH];
if (GetSystemDirectory(dllPath, MAX_PATH))
- StringCbCatA(dllPath, sizeof(dllPath), "\\wtsapi32.dll");
+ StringCbCatW(dllPath, sizeof(dllPath), L"\\wtsapi32.dll");
else
- StringCbCopyA(dllPath, sizeof(dllPath), "c:\\Windows\\System32\\wtsapi32.dll");
+ StringCbCopyW(dllPath, sizeof(dllPath), L"c:\\Windows\\System32\\wtsapi32.dll");
hWtsLib = LoadLibrary(dllPath);
if (hWtsLib)
@@ -250,7 +250,7 @@ static void localcleanup (void)
void RefreshMainDlg (HWND hwndDlg)
{
- int drive = (char) (HIWORD (GetSelectedLong (GetDlgItem (hwndDlg, IDC_DRIVELIST))));
+ int drive = (wchar_t) (HIWORD (GetSelectedLong (GetDlgItem (hwndDlg, IDC_DRIVELIST))));
MoveEditToCombo (GetDlgItem (hwndDlg, IDC_VOLUME), bHistory);
LoadDriveLetters (hwndDlg, GetDlgItem (hwndDlg, IDC_DRIVELIST), drive);
@@ -272,7 +272,7 @@ void EndMainDlg (HWND hwndDlg)
if (!bHistory)
{
- SetWindowText (GetDlgItem (hwndDlg, IDC_VOLUME), "");
+ SetWindowText (GetDlgItem (hwndDlg, IDC_VOLUME), L"");
ClearHistory (GetDlgItem (hwndDlg, IDC_VOLUME));
}
@@ -436,7 +436,7 @@ BOOL VolumeSelected (HWND hwndDlg)
return (GetWindowTextLength (GetDlgItem (hwndDlg, IDC_VOLUME)) > 0);
}
-void GetVolumePath (HWND hwndDlg, LPSTR szPath, int nMaxCount)
+void GetVolumePath (HWND hwndDlg, LPWSTR szPath, int nMaxCount)
{
GetWindowText (GetDlgItem (hwndDlg, IDC_VOLUME), szPath, nMaxCount);
CorrectFileName (szPath);
@@ -460,7 +460,7 @@ BOOL ActiveSysEncDeviceSelected (void)
{
int retCode = 0;
- GetVolumePath (MainDlg, szFileName, sizeof (szFileName));
+ GetVolumePath (MainDlg, szFileName, ARRAYSIZE (szFileName));
retCode = IsSystemDevicePath (szFileName, MainDlg, FALSE);
@@ -483,18 +483,16 @@ BOOL ActiveSysEncDeviceSelected (void)
// ask the user and returns the volume path directly (no selection ambiguity).
// If driveNoPtr is not NULL, and the volume is mounted, its drive letter is returned in *driveNoPtr (if no valid drive
// letter is resolved, -1 is stored instead).
-static string ResolveAmbiguousSelection (HWND hwndDlg, int *driveNoPtr)
+static wstring ResolveAmbiguousSelection (HWND hwndDlg, int *driveNoPtr)
{
LPARAM selectedDrive = GetSelectedLong (GetDlgItem (MainDlg, IDC_DRIVELIST));
- char volPathInputField [TC_MAX_PATH];
- wchar_t volPathInputFieldW [TC_MAX_PATH];
+ wchar_t volPathInputField [TC_MAX_PATH];
wchar_t volPathDriveListW [TC_MAX_PATH];
- string volPathDriveListStr;
- wstring volPathDriveListWStr;
+ wstring volPathDriveListStr;
- string retPath;
+ wstring retPath;
VOLUME_PROPERTIES_STRUCT prop;
DWORD dwResult;
@@ -509,10 +507,10 @@ static string ResolveAmbiguousSelection (HWND hwndDlg, int *driveNoPtr)
if (VolumeSelected (MainDlg))
{
// volPathInputField will contain the volume path (if any) from the input field below the drive list
- GetVolumePath (MainDlg, volPathInputField, sizeof (volPathInputField));
+ GetVolumePath (MainDlg, volPathInputField, ARRAYSIZE (volPathInputField));
if (!ambig)
- retPath = (string) volPathInputField;
+ retPath = (wstring) volPathInputField;
}
if (LOWORD (selectedDrive) != TC_MLIST_ITEM_FREE && LOWORD (selectedDrive) != 0xffff && HIWORD (selectedDrive) != 0xffff)
@@ -522,19 +520,18 @@ static string ResolveAmbiguousSelection (HWND hwndDlg, int *driveNoPtr)
switch (LOWORD (selectedDrive))
{
case TC_MLIST_ITEM_NONSYS_VOL:
- prop.driveNo = HIWORD (selectedDrive) - 'A';
+ prop.driveNo = HIWORD (selectedDrive) - L'A';
if (!DeviceIoControl (hDriver, TC_IOCTL_GET_VOLUME_PROPERTIES, &prop, sizeof (prop), &prop, sizeof (prop), &dwResult, NULL) || dwResult == 0)
{
// The driver did not return any path for this drive letter (the volume may have been dismounted).
// Return whatever is in the input field below the drive list (even if empty)
- return ((string) volPathInputField);
+ return ((wstring) volPathInputField);
}
// volPathDriveListWStr will contain the volume path selected in the main drive list
- volPathDriveListWStr = (wstring) prop.wszVolume;
- volPathDriveListStr = WideToSingleString (volPathDriveListWStr);
+ volPathDriveListStr = (wstring) prop.wszVolume;
break;
case TC_MLIST_ITEM_SYS_PARTITION:
@@ -543,8 +540,7 @@ static string ResolveAmbiguousSelection (HWND hwndDlg, int *driveNoPtr)
if (bCachedSysDevicePathsValid)
{
- volPathDriveListStr = (string) SysPartitionDevicePath;
- volPathDriveListWStr = SingleStringToWide (volPathDriveListStr);
+ volPathDriveListStr = (wstring) SysPartitionDevicePath;
}
break;
@@ -555,8 +551,7 @@ static string ResolveAmbiguousSelection (HWND hwndDlg, int *driveNoPtr)
if (bCachedSysDevicePathsValid)
{
- volPathDriveListStr = (string) SysDriveDevicePath;
- volPathDriveListWStr = SingleStringToWide (volPathDriveListStr);
+ volPathDriveListStr = (wstring) SysDriveDevicePath;
}
break;
@@ -573,21 +568,16 @@ static string ResolveAmbiguousSelection (HWND hwndDlg, int *driveNoPtr)
{
/* We have two paths. Compare them and if they don't match, ask the user to select one of them. Otherwise, return the path without asking. */
- if (memcmp (volPathDriveListStr.c_str (), "\\??\\", 4) == 0)
+ if (wmemcmp (volPathDriveListStr.c_str (), L"\\??\\", 4) == 0)
{
// The volume path starts with "\\??\\" which is used for file-hosted containers. We're going to strip this prefix.
- volPathDriveListStr = (string) (volPathDriveListStr.c_str () + 4);
- volPathDriveListWStr = SingleStringToWide (volPathDriveListStr);
+ volPathDriveListStr = (wstring) (volPathDriveListStr.c_str () + 4);
}
- StringCbCopyW (volPathDriveListW, sizeof(volPathDriveListW), SingleStringToWide (volPathDriveListStr).c_str ());
+ StringCbCopyW (volPathDriveListW, sizeof(volPathDriveListW), volPathDriveListStr.c_str ());
- ToSBCS (volPathDriveListW, sizeof(volPathDriveListW));
- StringCbCopyA ((char *) volPathInputFieldW, sizeof(volPathInputFieldW), volPathInputField);
- ToUNICODE ((char *) volPathInputFieldW, sizeof(volPathInputFieldW));
-
- if (strcmp (((memcmp ((char *) volPathDriveListW, "\\??\\", 4) == 0) ? (char *) volPathDriveListW + 4 : (char *) volPathDriveListW), volPathInputField) != 0)
+ if (wcscmp (((wmemcmp (volPathDriveListW, L"\\??\\", 4) == 0) ? volPathDriveListW + 4 : volPathDriveListW), volPathInputField) != 0)
{
// The path selected in the input field is different from the path to the volume selected
// in the drive lettter list. We have to resolve possible ambiguity.
@@ -595,13 +585,13 @@ static string ResolveAmbiguousSelection (HWND hwndDlg, int *driveNoPtr)
wchar_t *tmp[] = {L"", L"", L"", L"", L"", 0};
const int maxVolPathLen = 80;
- if (volPathDriveListWStr.length () > maxVolPathLen)
+ if (volPathDriveListStr.length () > maxVolPathLen)
{
// Ellipsis (path too long)
- volPathDriveListWStr = wstring (L"...") + volPathDriveListWStr.substr (volPathDriveListWStr.length () - maxVolPathLen, maxVolPathLen);
+ volPathDriveListStr = wstring (L"...") + volPathDriveListStr.substr (volPathDriveListStr.length () - maxVolPathLen, maxVolPathLen);
}
- wstring volPathInputFieldWStr (volPathInputFieldW);
+ wstring volPathInputFieldWStr (volPathInputField);
if (volPathInputFieldWStr.length () > maxVolPathLen)
{
@@ -610,7 +600,7 @@ static string ResolveAmbiguousSelection (HWND hwndDlg, int *driveNoPtr)
}
tmp[1] = GetString ("AMBIGUOUS_VOL_SELECTION");
- tmp[2] = (wchar_t *) volPathDriveListWStr.c_str();
+ tmp[2] = (wchar_t *) volPathDriveListStr.c_str();
tmp[3] = (wchar_t *) volPathInputFieldWStr.c_str();
tmp[4] = GetString ("IDCANCEL");
@@ -621,32 +611,32 @@ static string ResolveAmbiguousSelection (HWND hwndDlg, int *driveNoPtr)
break;
case 2:
- retPath = (string) volPathInputField;
+ retPath = (wstring) volPathInputField;
break;
default:
if (driveNoPtr != NULL)
*driveNoPtr = -1;
- return string ("");
+ return wstring (L"");
}
}
else
{
// Both selected paths are the same
- retPath = (string) volPathInputField;
+ retPath = (wstring) volPathInputField;
}
}
if (driveNoPtr != NULL)
- *driveNoPtr = GetMountedVolumeDriveNo ((char *) retPath.c_str ());
+ *driveNoPtr = GetMountedVolumeDriveNo ((wchar_t *) retPath.c_str ());
- if (memcmp (retPath.c_str (), "\\??\\", 4) == 0)
+ if (wmemcmp (retPath.c_str (), L"\\??\\", 4) == 0)
{
// The selected volume path starts with "\\??\\" which is used for file-hosted containers. We're going to strip this prefix.
- retPath = (string) (retPath.c_str () + 4);
+ retPath = (wstring) (retPath.c_str () + 4);
}
return retPath;
@@ -733,7 +723,11 @@ void LoadSettingsAndCheckModified (HWND hwndDlg, BOOL bOnlyCheckModified, BOOL*
// Drive letter - command line arg overrides registry
if (!bOnlyCheckModified && bHistory && szDriveLetter[0] == 0)
- ConfigReadString ("LastSelectedDrive", "", szDriveLetter, sizeof (szDriveLetter));
+ {
+ char szTmp[3] = {0};
+ ConfigReadString ("LastSelectedDrive", "", szTmp, sizeof (szTmp));
+ MultiByteToWideChar (CP_UTF8, 0, szTmp, -1, szDriveLetter, ARRAYSIZE (szDriveLetter));
+ }
if (bHistory && pbSettingsModified)
{
// only check for last drive modification if history enabled
@@ -741,14 +735,21 @@ void LoadSettingsAndCheckModified (HWND hwndDlg, BOOL bOnlyCheckModified, BOOL*
LPARAM lLetter;
lLetter = GetSelectedLong (GetDlgItem (hwndDlg, IDC_DRIVELIST));
if (LOWORD (lLetter) != 0xffff)
- StringCbPrintfA (szTmp, sizeof(szTmp), "%c:", (char) HIWORD (lLetter));
+ StringCbPrintfA (szTmp, sizeof(szTmp), "%lc:", (wchar_t) HIWORD (lLetter));
ConfigReadCompareString ("LastSelectedDrive", "", szTmp, sizeof (szTmp), bOnlyCheckModified, pbSettingsModified);
}
- ConfigReadCompareString ("SecurityTokenLibrary", "", SecurityTokenLibraryPath, sizeof (SecurityTokenLibraryPath) - 1, bOnlyCheckModified, pbSettingsModified);
- if (!bOnlyCheckModified && SecurityTokenLibraryPath[0])
- InitSecurityTokenLibrary(hwndDlg);
+ {
+ char szTmp[MAX_PATH];
+ WideCharToMultiByte (CP_UTF8, 0, SecurityTokenLibraryPath, -1, szTmp, MAX_PATH, NULL, NULL);
+ ConfigReadCompareString ("SecurityTokenLibrary", "", szTmp, sizeof (szTmp) - 1, bOnlyCheckModified, pbSettingsModified);
+ MultiByteToWideChar (CP_UTF8, 0, szTmp, -1, SecurityTokenLibraryPath, ARRAYSIZE (SecurityTokenLibraryPath));
+ if (!bOnlyCheckModified && SecurityTokenLibraryPath[0])
+ {
+ InitSecurityTokenLibrary(hwndDlg);
+ }
+ }
// Hotkeys
ConfigReadCompareInt ("PlaySoundOnHotkeyMountDismount", TRUE, &bPlaySoundOnSuccessfulHkDismount, bOnlyCheckModified, pbSettingsModified);
@@ -877,7 +878,7 @@ void SaveSettings (HWND hwndDlg)
// Drive Letter
lLetter = GetSelectedLong (GetDlgItem (hwndDlg, IDC_DRIVELIST));
if (LOWORD (lLetter) != 0xffff)
- StringCbPrintfA (szTmp, sizeof(szTmp), "%c:", (char) HIWORD (lLetter));
+ StringCbPrintfA (szTmp, sizeof(szTmp), "%lc:", (wchar_t) HIWORD (lLetter));
ConfigWriteString ("LastSelectedDrive", szTmp);
}
@@ -909,7 +910,7 @@ void SaveSettings (HWND hwndDlg)
ConfigWriteString ("Language", GetPreferredLangId ());
// PKCS#11 Library Path
- ConfigWriteString ("SecurityTokenLibrary", SecurityTokenLibraryPath[0] ? SecurityTokenLibraryPath : "");
+ ConfigWriteStringW ("SecurityTokenLibrary", SecurityTokenLibraryPath[0] ? SecurityTokenLibraryPath : L"");
// Mount Options
ConfigWriteInt ("DefaultPRF", DefaultVolumePkcs5);
@@ -1088,19 +1089,19 @@ static void PopulateSysEncContextMenu (HMENU popup, BOOL bToolsOnly)
AppendMenuW (popup, MF_STRING, IDM_PERMANENTLY_DECRYPT_SYS, GetString ("PERMANENTLY_DECRYPT"));
AppendMenuW (popup, MF_STRING, IDM_ENCRYPT_SYSTEM_DEVICE, GetString ("ENCRYPT"));
- AppendMenu (popup, MF_SEPARATOR, 0, "");
+ AppendMenu (popup, MF_SEPARATOR, 0, L"");
}
}
AppendMenuW (popup, MF_STRING, IDM_CHANGE_SYS_PASSWORD, GetString ("IDM_CHANGE_SYS_PASSWORD"));
// AppendMenuW (popup, MF_STRING, IDM_CHANGE_SYS_HEADER_KEY_DERIV_ALGO, GetString ("IDM_CHANGE_SYS_HEADER_KEY_DERIV_ALGO"));
- AppendMenu (popup, MF_SEPARATOR, 0, "");
+ AppendMenu (popup, MF_SEPARATOR, 0, L"");
AppendMenuW (popup, MF_STRING, IDM_SYS_ENC_SETTINGS, GetString ("IDM_SYS_ENC_SETTINGS"));
if (!IsHiddenOSRunning())
{
- AppendMenu (popup, MF_SEPARATOR, 0, "");
+ AppendMenu (popup, MF_SEPARATOR, 0, L"");
AppendMenuW (popup, MF_STRING, IDM_CREATE_RESCUE_DISK, GetString ("IDM_CREATE_RESCUE_DISK"));
AppendMenuW (popup, MF_STRING, IDM_VERIFY_RESCUE_DISK, GetString ("IDM_VERIFY_RESCUE_DISK"));
AppendMenuW (popup, MF_STRING, IDM_VERIFY_RESCUE_DISK_ISO, GetString ("IDM_VERIFY_RESCUE_DISK_ISO"));
@@ -1110,10 +1111,10 @@ static void PopulateSysEncContextMenu (HMENU popup, BOOL bToolsOnly)
{
if (SysDriveOrPartitionFullyEncrypted (FALSE) && !IsHiddenOSRunning())
{
- AppendMenu (popup, MF_SEPARATOR, 0, "");
+ AppendMenu (popup, MF_SEPARATOR, 0, L"");
AppendMenuW (popup, MF_STRING, IDM_PERMANENTLY_DECRYPT_SYS, GetString ("PERMANENTLY_DECRYPT"));
}
- AppendMenu (popup, MF_SEPARATOR, 0, "");
+ AppendMenu (popup, MF_SEPARATOR, 0, L"");
AppendMenuW (popup, MF_STRING, IDM_VOLUME_PROPERTIES, GetString ("IDPM_PROPERTIES"));
}
}
@@ -1123,15 +1124,15 @@ static void PopulateSysEncContextMenu (HMENU popup, BOOL bToolsOnly)
// mounting a partition (as a regular volume) that is within key scope of system encryption.
// Returns TRUE if the partition can be mounted as a partition within key scope of inactive system encryption.
// If devicePath is empty, the currently selected partition in the GUI is checked.
-BOOL CheckSysEncMountWithoutPBA (HWND hwndDlg, const char *devicePath, BOOL quiet)
+BOOL CheckSysEncMountWithoutPBA (HWND hwndDlg, const wchar_t *devicePath, BOOL quiet)
{
BOOL tmpbDevice;
- char szDevicePath [TC_MAX_PATH+1];
- char szDiskFile [TC_MAX_PATH+1];
+ wchar_t szDevicePath [TC_MAX_PATH+1];
+ wchar_t szDiskFile [TC_MAX_PATH+1];
- if (strlen (devicePath) < 2)
+ if (wcslen (devicePath) < 2)
{
- GetVolumePath (MainDlg, szDevicePath, sizeof (szDevicePath));
+ GetVolumePath (MainDlg, szDevicePath, ARRAYSIZE (szDevicePath));
CreateFullVolumePath (szDiskFile, sizeof(szDiskFile), szDevicePath, &tmpbDevice);
if (!tmpbDevice)
@@ -1151,12 +1152,12 @@ BOOL CheckSysEncMountWithoutPBA (HWND hwndDlg, const char *devicePath, BOOL quie
}
}
else
- StringCbCopyA (szDevicePath, sizeof(szDevicePath), devicePath);
+ StringCbCopyW (szDevicePath, sizeof(szDevicePath), devicePath);
- char *partionPortion = strrchr (szDevicePath, '\\');
+ wchar_t *partionPortion = wcsrchr (szDevicePath, L'\\');
if (!partionPortion
- || !_stricmp (partionPortion, "\\Partition0"))
+ || !_wcsicmp (partionPortion, L"\\Partition0"))
{
// Only partitions are supported (not whole drives)
if (!quiet)
@@ -1173,9 +1174,9 @@ BOOL CheckSysEncMountWithoutPBA (HWND hwndDlg, const char *devicePath, BOOL quie
{
int retCode = 0;
int driveNo;
- char parentDrivePath [TC_MAX_PATH+1];
+ wchar_t parentDrivePath [TC_MAX_PATH+1];
- if (sscanf (szDevicePath, "\\Device\\Harddisk%d\\Partition", &driveNo) != 1)
+ if (swscanf (szDevicePath, L"\\Device\\Harddisk%d\\Partition", &driveNo) != 1)
{
if (!quiet)
Error ("INVALID_PATH", hwndDlg);
@@ -1183,9 +1184,9 @@ BOOL CheckSysEncMountWithoutPBA (HWND hwndDlg, const char *devicePath, BOOL quie
return FALSE;
}
- StringCbPrintfA (parentDrivePath,
+ StringCbPrintfW (parentDrivePath,
sizeof (parentDrivePath),
- "\\Device\\Harddisk%d\\Partition0",
+ L"\\Device\\Harddisk%d\\Partition0",
driveNo);
WaitCursor ();
@@ -1224,23 +1225,23 @@ BOOL CheckSysEncMountWithoutPBA (HWND hwndDlg, const char *devicePath, BOOL quie
// Returns TRUE if the host drive of the specified partition contains a portion of the TrueCrypt Boot Loader
// and if the drive is not within key scope of active system encryption (e.g. the system drive of the running OS).
// If bPrebootPasswordDlgMode is TRUE, this function returns FALSE (because the check would be redundant).
-BOOL TCBootLoaderOnInactiveSysEncDrive (char *szDevicePath)
+BOOL TCBootLoaderOnInactiveSysEncDrive (wchar_t *szDevicePath)
{
try
{
int driveNo;
- char parentDrivePath [TC_MAX_PATH+1];
+ wchar_t parentDrivePath [TC_MAX_PATH+1];
if (bPrebootPasswordDlgMode)
return FALSE;
- if (sscanf (szDevicePath, "\\Device\\Harddisk%d\\Partition", &driveNo) != 1)
+ if (swscanf (szDevicePath, L"\\Device\\Harddisk%d\\Partition", &driveNo) != 1)
return FALSE;
- StringCbPrintfA (parentDrivePath,
+ StringCbPrintfW (parentDrivePath,
sizeof (parentDrivePath),
- "\\Device\\Harddisk%d\\Partition0",
+ L"\\Device\\Harddisk%d\\Partition0",
driveNo);
BootEncStatus = BootEncObj->GetStatus();
@@ -1262,13 +1263,13 @@ BOOL TCBootLoaderOnInactiveSysEncDrive (char *szDevicePath)
}
-BOOL SelectItem (HWND hTree, char nLetter)
+BOOL SelectItem (HWND hTree, wchar_t nLetter)
{
if (nLetter == 0)
{
// The caller specified an invalid drive letter (typically because it is unknown).
// Find out which drive letter is currently selected in the list and use it.
- nLetter = (char) (HIWORD (GetSelectedLong (hTree)));
+ nLetter = (wchar_t) (HIWORD (GetSelectedLong (hTree)));
}
int i;
@@ -1301,48 +1302,48 @@ BOOL SelectItem (HWND hTree, char nLetter)
}
-static void LaunchVolCreationWizard (HWND hwndDlg, const char *arg)
+static void LaunchVolCreationWizard (HWND hwndDlg, const wchar_t *arg)
{
- char t[TC_MAX_PATH + 1024] = {'"',0};
- char *tmp;
+ wchar_t t[TC_MAX_PATH + 1024] = {L'"',0};
+ wchar_t *tmp;
- GetModuleFileName (NULL, t+1, sizeof(t)-1);
+ GetModuleFileName (NULL, t+1, ARRAYSIZE(t)-1);
- tmp = strrchr (t, '\\');
+ tmp = wcsrchr (t, L'\\');
if (tmp)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
- char formatExeName[64];
- char* suffix = NULL;
+ wchar_t formatExeName[64];
+ wchar_t* suffix = NULL;
ZeroMemory (&si, sizeof (si));
- StringCbCopyA (formatExeName, sizeof (formatExeName), "\\VeraCrypt Format");
+ StringCbCopyW (formatExeName, sizeof (formatExeName), L"\\VeraCrypt Format");
// check if there is a suffix in VeraCrypt file name
// in order to use the same for "VeraCrypt Format"
- suffix = strrchr (tmp + 1, '-');
+ suffix = wcsrchr (tmp + 1, L'-');
if (suffix)
{
- StringCbCatA (formatExeName, sizeof (formatExeName), suffix);
- StringCbCatA (formatExeName, sizeof (formatExeName), "\"");
+ StringCbCatW (formatExeName, sizeof (formatExeName), suffix);
+ StringCbCatW (formatExeName, sizeof (formatExeName), L"\"");
}
else
- StringCbCatA (formatExeName, sizeof (formatExeName), ".exe\"");
+ StringCbCatW (formatExeName, sizeof (formatExeName), L".exe\"");
*tmp = 0;
- StringCbCatA (t, sizeof(t), formatExeName);
+ StringCbCatW (t, sizeof(t), formatExeName);
if (!FileExists(t))
Error ("VOL_CREATION_WIZARD_NOT_FOUND", hwndDlg); // Display a user-friendly error message and advise what to do
- if (strlen (arg) > 0)
+ if (wcslen (arg) > 0)
{
- StringCbCatA (t, sizeof(t), " ");
- StringCbCatA (t, sizeof(t), arg);
+ StringCbCatW (t, sizeof(t), L" ");
+ StringCbCatW (t, sizeof(t), arg);
}
- if (!CreateProcess (NULL, (LPSTR) t, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi))
+ if (!CreateProcess (NULL, (LPWSTR) t, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi))
{
handleWin32Error (hwndDlg, SRC_POS);
}
@@ -1356,36 +1357,36 @@ static void LaunchVolCreationWizard (HWND hwndDlg, const char *arg)
static void LaunchVolExpander (HWND hwndDlg)
{
- char t[TC_MAX_PATH + TC_MAX_PATH] = {'"',0};
- char *tmp;
+ wchar_t t[TC_MAX_PATH + TC_MAX_PATH] = {L'"',0};
+ wchar_t *tmp;
- GetModuleFileName (NULL, t+1, sizeof(t)-1);
+ GetModuleFileName (NULL, t+1, ARRAYSIZE(t)-1);
- tmp = strrchr (t, '\\');
+ tmp = wcsrchr (t, L'\\');
if (tmp)
{
- char expanderExeName[64];
- char* suffix = NULL;
+ wchar_t expanderExeName[64];
+ wchar_t* suffix = NULL;
- StringCbCopyA (expanderExeName, sizeof (expanderExeName), "\\VeraCryptExpander");
+ StringCbCopyW (expanderExeName, sizeof (expanderExeName), L"\\VeraCryptExpander");
// check if there is a suffix in VeraCrypt file name
// in order to use the same for "VeraCrypt Format"
- suffix = strrchr (tmp + 1, '-');
+ suffix = wcsrchr (tmp + 1, L'-');
if (suffix)
{
- StringCbCatA (expanderExeName, sizeof (expanderExeName), suffix);
- StringCbCatA (expanderExeName, sizeof (expanderExeName), "\"");
+ StringCbCatW (expanderExeName, sizeof (expanderExeName), suffix);
+ StringCbCatW (expanderExeName, sizeof (expanderExeName), L"\"");
}
else
- StringCbCatA (expanderExeName, sizeof (expanderExeName), ".exe\"");
+ StringCbCatW (expanderExeName, sizeof (expanderExeName), L".exe\"");
*tmp = 0;
- StringCbCatA (t, sizeof(t), expanderExeName);
+ StringCbCatW (t, sizeof(t), expanderExeName);
if (!FileExists(t))
Error ("VOL_EXPANDER_NOT_FOUND", hwndDlg); // Display a user-friendly error message and advise what to do
- else if (((int)ShellExecuteA (NULL, (!IsAdmin() && IsUacSupported()) ? "runas" : "open", t, NULL, NULL, SW_SHOW)) <= 32)
+ else if (((int)ShellExecuteW (NULL, (!IsAdmin() && IsUacSupported()) ? L"runas" : L"open", t, NULL, NULL, SW_SHOW)) <= 32)
{
handleWin32Error (hwndDlg, SRC_POS);
}
@@ -1400,19 +1401,19 @@ void LoadDriveLetters (HWND hwndDlg, HWND hTree, int drive)
// Remember the top-most visible item
int lastTopMostVisibleItem = ListView_GetTopIndex (hTree);
- char *szDriveLetters[]=
- {"A:", "B:", "C:", "D:",
- "E:", "F:", "G:", "H:", "I:", "J:", "K:",
- "L:", "M:", "N:", "O:", "P:", "Q:", "R:",
- "S:", "T:", "U:", "V:", "W:", "X:", "Y:",
- "Z:"};
+ wchar_t *szDriveLetters[]=
+ {L"A:", L"B:", L"C:", L"D:",
+ L"E:", L"F:", L"G:", L"H:", L"I:", L"J:", L"K:",
+ L"L:", L"M:", L"N:", L"O:", L"P:", L"Q:", L"R:",
+ L"S:", L"T:", L"U:", L"V:", L"W:", L"X:", L"Y:",
+ L"Z:"};
DWORD dwResult;
BOOL bResult;
DWORD dwUsedDrives;
MOUNT_LIST_STRUCT driver;
VOLUME_PROPERTIES_STRUCT propSysEnc;
- char sysDriveLetter = 0;
+ wchar_t sysDriveLetter = 0;
BOOL bSysEnc = FALSE;
BOOL bWholeSysDriveEncryption = FALSE;
@@ -1478,7 +1479,7 @@ void LoadDriveLetters (HWND hwndDlg, HWND hTree, int drive)
}
{
- char szTmp[1024];
+ wchar_t szTmp[1024];
wchar_t szTmpW[1024];
memset(&listItem, 0, sizeof(listItem));
@@ -1488,7 +1489,7 @@ void LoadDriveLetters (HWND hwndDlg, HWND hTree, int drive)
listItem.iItem = item++;
listItem.pszText = szTmp;
- szTmp[0] = ' ';
+ szTmp[0] = L' ';
szTmp[1] = 0;
listItem.lParam = MAKELONG (TC_MLIST_ITEM_SYS_DRIVE, ENC_SYSDRIVE_PSEUDO_DRIVE_LETTER);
@@ -1537,16 +1538,16 @@ void LoadDriveLetters (HWND hwndDlg, HWND hTree, int drive)
}
}
- ListSubItemSetW (hTree, listItem.iItem, 1, szTmpW);
+ ListSubItemSet (hTree, listItem.iItem, 1, szTmpW);
GetSizeString (GetSysEncDeviceSize(TRUE), szTmpW, sizeof(szTmpW));
- ListSubItemSetW (hTree, listItem.iItem, 2, szTmpW);
+ ListSubItemSet (hTree, listItem.iItem, 2, szTmpW);
EAGetName (szTmp, propSysEnc.ea, 1);
listItem.iSubItem = 3;
ListView_SetItem (hTree, &listItem);
- ListSubItemSetW (hTree, listItem.iItem, 4, GetString (IsHiddenOSRunning() ? "HIDDEN" : "SYSTEM_VOLUME_TYPE_ADJECTIVE"));
+ ListSubItemSet (hTree, listItem.iItem, 4, GetString (IsHiddenOSRunning() ? "HIDDEN" : "SYSTEM_VOLUME_TYPE_ADJECTIVE"));
}
}
@@ -1556,7 +1557,7 @@ void LoadDriveLetters (HWND hwndDlg, HWND hTree, int drive)
{
int curDrive = 0;
- BOOL bSysEncPartition = (bSysEnc && !bWholeSysDriveEncryption && sysDriveLetter == *((char *) szDriveLetters[i]));
+ BOOL bSysEncPartition = (bSysEnc && !bWholeSysDriveEncryption && sysDriveLetter == *((wchar_t *) szDriveLetters[i]));
if (drive > 0)
{
@@ -1571,7 +1572,7 @@ void LoadDriveLetters (HWND hwndDlg, HWND hTree, int drive)
if (driver.ulMountedDrives & (1 << i)
|| bSysEncPartition)
{
- char szTmp[1024];
+ wchar_t szTmp[1024];
wchar_t szTmpW[1024];
wchar_t *ws;
@@ -1586,7 +1587,7 @@ void LoadDriveLetters (HWND hwndDlg, HWND hTree, int drive)
listItem.lParam = MAKELONG (
bSysEncPartition ? TC_MLIST_ITEM_SYS_PARTITION : TC_MLIST_ITEM_NONSYS_VOL,
- i + 'A');
+ i + L'A');
listItem.pszText = szDriveLetters[i];
@@ -1637,14 +1638,13 @@ void LoadDriveLetters (HWND hwndDlg, HWND hTree, int drive)
}
}
- ListSubItemSetW (hTree, listItem.iItem, 1, szTmpW);
+ ListSubItemSet (hTree, listItem.iItem, 1, szTmpW);
}
else
{
- ToSBCS (driver.wszVolume[i], sizeof(driver.wszVolume[i]));
- char *path = (char *) driver.wszVolume[i];
+ wchar_t *path = driver.wszVolume[i];
- if (memcmp (path, "\\??\\", 4) == 0)
+ if (wmemcmp (path, L"\\??\\", 4) == 0)
path += 4;
listItem.iSubItem = 1;
@@ -1655,13 +1655,13 @@ void LoadDriveLetters (HWND hwndDlg, HWND hTree, int drive)
if (label.empty())
label = GetFavoriteVolumeLabel (path, useInExplorer);
if (!label.empty())
- ListSubItemSetW (hTree, listItem.iItem, 1, (wchar_t *) label.c_str());
+ ListSubItemSet (hTree, listItem.iItem, 1, (wchar_t *) label.c_str());
else
- ListSubItemSet (hTree, listItem.iItem, 1, (char *) FitPathInGfxWidth (hTree, hUserFont, ListView_GetColumnWidth (hTree, 1) - GetTextGfxWidth (hTree, L"___", hUserFont), path).c_str());
+ ListSubItemSet (hTree, listItem.iItem, 1, (wchar_t *) FitPathInGfxWidth (hTree, hUserFont, ListView_GetColumnWidth (hTree, 1) - GetTextGfxWidth (hTree, L"___", hUserFont), path).c_str());
}
GetSizeString (bSysEncPartition ? GetSysEncDeviceSize(TRUE) : driver.diskLength[i], szTmpW, sizeof(szTmpW));
- ListSubItemSetW (hTree, listItem.iItem, 2, szTmpW);
+ ListSubItemSet (hTree, listItem.iItem, 2, szTmpW);
EAGetName (szTmp, bSysEncPartition ? propSysEnc.ea : driver.ea[i], 1);
listItem.iSubItem = 3;
@@ -1671,7 +1671,7 @@ void LoadDriveLetters (HWND hwndDlg, HWND hTree, int drive)
{
ws = GetString (IsHiddenOSRunning() ? "HIDDEN" : "SYSTEM_VOLUME_TYPE_ADJECTIVE");
VolumeNotificationsList.bHidVolDamagePrevReported[i] = FALSE;
- ListSubItemSetW (hTree, listItem.iItem, 4, ws);
+ ListSubItemSet (hTree, listItem.iItem, 4, ws);
}
else
{
@@ -1696,10 +1696,10 @@ void LoadDriveLetters (HWND hwndDlg, HWND hTree, int drive)
if (driver.truecryptMode[i])
{
StringCbPrintfW (szTmpW, sizeof(szTmpW), L"TrueCrypt-%s", ws);
- ListSubItemSetW (hTree, listItem.iItem, 4, szTmpW);
+ ListSubItemSet (hTree, listItem.iItem, 4, szTmpW);
}
else
- ListSubItemSetW (hTree, listItem.iItem, 4, ws);
+ ListSubItemSet (hTree, listItem.iItem, 4, ws);
if (driver.volumeType[i] == PROP_VOL_TYPE_OUTER_VOL_WRITE_PREVENTED) // Normal/outer volume (hidden volume protected AND write denied)
{
@@ -1708,7 +1708,7 @@ void LoadDriveLetters (HWND hwndDlg, HWND hTree, int drive)
wchar_t szTmp[4096];
VolumeNotificationsList.bHidVolDamagePrevReported[i] = TRUE;
- StringCbPrintfW (szTmp, sizeof(szTmp), GetString ("DAMAGE_TO_HIDDEN_VOLUME_PREVENTED"), i+'A');
+ StringCbPrintfW (szTmp, sizeof(szTmp), GetString ("DAMAGE_TO_HIDDEN_VOLUME_PREVENTED"), i+L'A');
SetForegroundWindow (GetParent(hTree));
MessageBoxW (GetParent(hTree), szTmp, lpszTitle, MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST);
}
@@ -1745,7 +1745,7 @@ void LoadDriveLetters (HWND hwndDlg, HWND hTree, int drive)
ListView_SetItem (hTree, &listItem);
listItem.mask=LVIF_TEXT;
- listItem.pszText = "";
+ listItem.pszText = L"";
listItem.iSubItem = 1;
ListView_SetItem (hTree, &listItem);
listItem.iSubItem = 2;
@@ -1771,9 +1771,12 @@ static void PasswordChangeEnable (HWND hwndDlg, int button, int passwordId, BOOL
char password[MAX_PASSWORD + 1];
char newPassword[MAX_PASSWORD + 1];
char newVerify[MAX_PASSWORD + 1];
+ wchar_t tmp[MAX_PASSWORD + 1];
BOOL bEnable = TRUE;
+ int passwordUtf8Len, newPasswordUtf8Len, newVerifyUtf8Len;
- GetWindowText (GetDlgItem (hwndDlg, passwordId), password, sizeof (password));
+ GetWindowText (GetDlgItem (hwndDlg, passwordId), tmp, ARRAYSIZE (tmp));
+ passwordUtf8Len = WideCharToMultiByte (CP_UTF8, 0, tmp, -1, password, sizeof (password), NULL, NULL);
if (pwdChangeDlgMode == PCDM_CHANGE_PKCS5_PRF)
newKeyFilesEnabled = keyFilesEnabled;
@@ -1785,23 +1788,29 @@ static void PasswordChangeEnable (HWND hwndDlg, int button, int passwordId, BOOL
case PCDM_CHANGE_PKCS5_PRF:
memcpy (newPassword, password, sizeof (newPassword));
memcpy (newVerify, password, sizeof (newVerify));
+ newPasswordUtf8Len = passwordUtf8Len;
+ newVerifyUtf8Len = passwordUtf8Len;
break;
default:
- GetWindowText (GetDlgItem (hwndDlg, newPasswordId), newPassword, sizeof (newPassword));
- GetWindowText (GetDlgItem (hwndDlg, newVerifyId), newVerify, sizeof (newVerify));
+ GetWindowText (GetDlgItem (hwndDlg, newPasswordId), tmp, ARRAYSIZE (tmp));
+ newPasswordUtf8Len = WideCharToMultiByte (CP_UTF8, 0, tmp, -1, newPassword, sizeof (newPassword), NULL, NULL);
+ GetWindowText (GetDlgItem (hwndDlg, newVerifyId), tmp, ARRAYSIZE (tmp));
+ newVerifyUtf8Len = WideCharToMultiByte (CP_UTF8, 0, tmp, -1, newVerify, sizeof (newVerify), NULL, NULL);
+
}
- if (!keyFilesEnabled && strlen (password) < MIN_PASSWORD)
+ if (passwordUtf8Len <= 0 || (!keyFilesEnabled && ((passwordUtf8Len - 1) < MIN_PASSWORD)))
bEnable = FALSE;
else if (strcmp (newPassword, newVerify) != 0)
bEnable = FALSE;
- else if (!newKeyFilesEnabled && strlen (newPassword) < MIN_PASSWORD)
+ else if ((newPasswordUtf8Len <= 0) || (!newKeyFilesEnabled && ((newPasswordUtf8Len - 1) < MIN_PASSWORD)))
bEnable = FALSE;
burn (password, sizeof (password));
burn (newPassword, sizeof (newPassword));
burn (newVerify, sizeof (newVerify));
+ burn (tmp, sizeof (tmp));
EnableWindow (GetDlgItem (hwndDlg, button), bEnable);
}
@@ -1871,7 +1880,7 @@ void CALLBACK ChangePwdWaitThreadProc(void* pArg, HWND hwndDlg)
typedef struct
{
BOOL bRequireConfirmation;
- char *lpszVolume;
+ wchar_t *lpszVolume;
int* iResult;
} BackupHeaderThreadParam;
@@ -1889,7 +1898,7 @@ void CALLBACK BackupHeaderWaitThreadProc(void* pArg, HWND hwndDlg)
typedef struct
{
- char *lpszVolume;
+ wchar_t *lpszVolume;
int* iResult;
} RestoreHeaderThreadParam;
@@ -1945,7 +1954,7 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
/* we are in the case of a volume. Store its name to use it in the key file dialog
* this will help avoid using the current container file as a key file
*/
- StringCbCopyA (newKeyFilesParam.VolumeFileName, sizeof (newKeyFilesParam.VolumeFileName), szFileName);
+ StringCbCopyW (newKeyFilesParam.VolumeFileName, sizeof (newKeyFilesParam.VolumeFileName), szFileName);
}
SetWindowTextW (hwndDlg, GetString ("IDD_PASSWORDCHANGE_DLG"));
@@ -2091,7 +2100,7 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
if ((DWORD) GetKeyboardLayout (NULL) != 0x00000409 && (DWORD) GetKeyboardLayout (NULL) != 0x04090409)
{
- DWORD keybLayout = (DWORD) LoadKeyboardLayout ("00000409", KLF_ACTIVATE);
+ DWORD keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE);
if (keybLayout != 0x00000409 && keybLayout != 0x04090409)
{
@@ -2144,18 +2153,18 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
// Keyboard layout is not standard US
// Attempt to wipe passwords stored in the input field buffers
- 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_OLD_PASSWORD), tmp);
SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), tmp);
SetWindowText (GetDlgItem (hwndDlg, IDC_VERIFY), tmp);
- SetWindowText (GetDlgItem (hwndDlg, IDC_OLD_PASSWORD), "");
- SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), "");
- SetWindowText (GetDlgItem (hwndDlg, IDC_VERIFY), "");
+ SetWindowText (GetDlgItem (hwndDlg, IDC_OLD_PASSWORD), L"");
+ SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), L"");
+ SetWindowText (GetDlgItem (hwndDlg, IDC_VERIFY), L"");
- keybLayout = (DWORD) LoadKeyboardLayout ("00000409", KLF_ACTIVATE);
+ keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE);
if (keybLayout != 0x00000409 && keybLayout != 0x04090409)
{
@@ -2213,8 +2222,8 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
if (lw == IDCANCEL)
{
// Attempt to wipe passwords stored in the input field buffers
- 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_OLD_PASSWORD), tmp);
@@ -2235,7 +2244,7 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
if ((lw == IDC_OLD_PIM) && IsWindowEnabled (GetDlgItem (hwndDlg, IDC_PIM)))
{
- char tmp[MAX_PIM+1] = {0};
+ wchar_t tmp[MAX_PIM+1] = {0};
GetDlgItemText (hwndDlg, IDC_OLD_PIM, tmp, MAX_PIM + 1);
SetDlgItemText (hwndDlg, IDC_PIM, tmp);
}
@@ -2453,7 +2462,7 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
return 1;
}
- if (!CheckPasswordCharEncoding (GetDlgItem (hwndDlg, IDC_PASSWORD), NULL))
+ if (bSysEncPwdChangeDlgMode && !CheckPasswordCharEncoding (GetDlgItem (hwndDlg, IDC_PASSWORD), NULL))
{
Error ("UNSUPPORTED_CHARS_IN_PWD", hwndDlg);
return 1;
@@ -2477,10 +2486,14 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
return 1;
}
- GetVolumePath (hParent, szFileName, sizeof (szFileName));
+ GetVolumePath (hParent, szFileName, ARRAYSIZE (szFileName));
- GetWindowText (GetDlgItem (hwndDlg, IDC_OLD_PASSWORD), (LPSTR) oldPassword.Text, sizeof (oldPassword.Text));
- oldPassword.Length = (unsigned __int32) strlen ((char *) oldPassword.Text);
+ if (GetPassword (hwndDlg, IDC_OLD_PASSWORD, (LPSTR) oldPassword.Text, sizeof (oldPassword.Text), TRUE))
+ oldPassword.Length = (unsigned __int32) strlen ((char *) oldPassword.Text);
+ else
+ {
+ return 1;
+ }
switch (pwdChangeDlgMode)
{
@@ -2493,8 +2506,10 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
break;
default:
- GetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), (LPSTR) newPassword.Text, sizeof (newPassword.Text));
- newPassword.Length = (unsigned __int32) strlen ((char *) newPassword.Text);
+ if (GetPassword (hwndDlg, IDC_PASSWORD, (LPSTR) newPassword.Text, sizeof (newPassword.Text), TRUE))
+ newPassword.Length = (unsigned __int32) strlen ((char *) newPassword.Text);
+ else
+ return 1;
}
WaitCursor ();
@@ -2544,8 +2559,8 @@ err:
if (nStatus == 0)
{
// Attempt to wipe passwords stored in the input field buffers
- 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_OLD_PASSWORD), tmp);
@@ -2569,7 +2584,7 @@ err:
return 0;
}
-static char PasswordDlgVolume[MAX_PATH + 1];
+static wchar_t PasswordDlgVolume[MAX_PATH + 1];
static BOOL PasswordDialogDisableMountOptions;
static char *PasswordDialogTitleStringId;
@@ -2600,7 +2615,7 @@ BOOL CALLBACK PasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
{
SetWindowTextW (hwndDlg, GetString (PasswordDialogTitleStringId));
}
- else if (strlen (PasswordDlgVolume) > 0)
+ else if (wcslen (PasswordDlgVolume) > 0)
{
wchar_t s[1024];
RECT rect;
@@ -2616,7 +2631,7 @@ BOOL CALLBACK PasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
}
else
{
- StringCbPrintfW (s, sizeof(s), GetString ("ENTER_PASSWORD_FOR"), "___");
+ StringCbPrintfW (s, sizeof(s), GetString ("ENTER_PASSWORD_FOR"), L"___");
StringCbPrintfW (s, sizeof(s), GetString ("ENTER_PASSWORD_FOR"), FitPathInGfxWidth (hwndDlg, WindowTitleBarFont, rect.right - rect.left - GetTextGfxWidth (hwndDlg, s, WindowTitleBarFont), PasswordDlgVolume).c_str());
}
@@ -2724,15 +2739,15 @@ BOOL CALLBACK PasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
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)
{
@@ -2779,13 +2794,13 @@ BOOL CALLBACK PasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
// 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)
{
@@ -2878,15 +2893,17 @@ BOOL CALLBACK PasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
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, strlen (PasswordDlgVolume) > 0 ? PasswordDlgVolume : NULL);
+ KeyFilesApply (hwndDlg, &mountOptions.ProtectedHidVolPassword, hidVolProtKeyFilesParam.FirstKeyFile, wcslen (PasswordDlgVolume) > 0 ? PasswordDlgVolume : NULL);
- GetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), (LPSTR) szXPwd->Text, MAX_PASSWORD + 1);
- szXPwd->Length = (unsigned __int32) strlen ((char *) szXPwd->Text);
+ if (GetPassword (hwndDlg, IDC_PASSWORD, (LPSTR) szXPwd->Text, MAX_PASSWORD + 1, TRUE))
+ szXPwd->Length = (unsigned __int32) 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);
@@ -2913,7 +2930,7 @@ BOOL CALLBACK PasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
}
// 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);
@@ -3305,7 +3322,13 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
SendDlgItemMessage (hwndDlg, IDC_PIM, EM_LIMITTEXT, MAX_PIM, 0);
if (mountOptions->ProtectedHidVolPassword.Length > 0)
- SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD_PROT_HIDVOL), (LPSTR) mountOptions->ProtectedHidVolPassword.Text);
+ {
+ wchar_t szTmp[MAX_PASSWORD + 1];
+ if (0 == MultiByteToWideChar (CP_UTF8, 0, (LPSTR) mountOptions->ProtectedHidVolPassword.Text, -1, szTmp, MAX_PASSWORD + 1))
+ szTmp [0] = 0;
+ SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD_PROT_HIDVOL), szTmp);
+ burn (szTmp, sizeof (szTmp));
+ }
SetPim (hwndDlg, IDC_PIM, mountOptions->ProtectedHidVolPim);
@@ -3388,10 +3411,10 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
if (lw == IDCANCEL)
{
- char tmp[MAX_PASSWORD+1];
+ wchar_t tmp[MAX_PASSWORD+1];
// Cleanup
- memset (tmp, 'X', MAX_PASSWORD);
+ wmemset (tmp, L'X', MAX_PASSWORD);
tmp[MAX_PASSWORD] = 0;
SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD_PROT_HIDVOL), tmp);
@@ -3401,7 +3424,7 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
if (lw == IDOK)
{
- char tmp[MAX_PASSWORD+1];
+ wchar_t tmp[MAX_PASSWORD+1];
mountOptions->ReadOnly = IsButtonChecked (GetDlgItem (hwndDlg, IDC_MOUNT_READONLY));
mountOptions->Removable = IsButtonChecked (GetDlgItem (hwndDlg, IDC_MOUNT_REMOVABLE));
@@ -3413,9 +3436,9 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
if (mountOptions->ProtectHiddenVolume)
{
- GetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD_PROT_HIDVOL),
- (LPSTR) mountOptions->ProtectedHidVolPassword.Text,
- sizeof (mountOptions->ProtectedHidVolPassword.Text));
+ GetPassword (hwndDlg, IDC_PASSWORD_PROT_HIDVOL,
+ (LPSTR) mountOptions->ProtectedHidVolPassword.Text, MAX_PASSWORD + 1,
+ FALSE);
mountOptions->ProtectedHidVolPassword.Length = (unsigned __int32) strlen ((char *) mountOptions->ProtectedHidVolPassword.Text);
@@ -3426,7 +3449,7 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
}
// Cleanup
- memset (tmp, 'X', MAX_PASSWORD);
+ wmemset (tmp, L'X', MAX_PASSWORD);
tmp[MAX_PASSWORD] = 0;
SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD_PROT_HIDVOL), tmp);
@@ -3551,7 +3574,7 @@ BOOL CALLBACK VolumePropertiesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
LVCOLUMNW lvCol;
HWND list = GetDlgItem (hwndDlg, IDC_VOLUME_PROPERTIES_LIST);
- char szTmp[1024];
+ wchar_t szTmp[1024];
wchar_t sw[1024];
wchar_t *s;
@@ -3620,7 +3643,7 @@ BOOL CALLBACK VolumePropertiesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
SendMessage (list,LVM_INSERTCOLUMNW,0,(LPARAM)&lvCol);
memset (&prop, 0, sizeof(prop));
- prop.driveNo = HIWORD (GetSelectedLong (GetDlgItem (GetParent(hwndDlg), IDC_DRIVELIST))) - 'A';
+ prop.driveNo = HIWORD (GetSelectedLong (GetDlgItem (GetParent(hwndDlg), IDC_DRIVELIST))) - L'A';
if (bSysEnc)
{
@@ -3645,21 +3668,21 @@ BOOL CALLBACK VolumePropertiesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
}
// Location
- ListItemAddW (list, i, GetString ("LOCATION"));
+ ListItemAdd (list, i, GetString ("LOCATION"));
if (bSysEnc)
- ListSubItemSetW (list, i++, 1, GetString (bSysEncWholeDrive ? "SYSTEM_DRIVE" : IsHiddenOSRunning() ? "HIDDEN_SYSTEM_PARTITION" : "SYSTEM_PARTITION"));
+ ListSubItemSet (list, i++, 1, GetString (bSysEncWholeDrive ? "SYSTEM_DRIVE" : IsHiddenOSRunning() ? "HIDDEN_SYSTEM_PARTITION" : "SYSTEM_PARTITION"));
else
- ListSubItemSetW (list, i++, 1, (wchar_t *) (prop.wszVolume[1] != L'?' ? prop.wszVolume : prop.wszVolume + 4));
+ ListSubItemSet (list, i++, 1, (wchar_t *) (prop.wszVolume[1] != L'?' ? prop.wszVolume : prop.wszVolume + 4));
// Size
- ListItemAddW (list, i, GetString ("SIZE"));
+ ListItemAdd (list, i, GetString ("SIZE"));
StringCbPrintfW (sw, sizeof(sw), L"%I64u %s", prop.diskLength, GetString ("BYTES"));
- ListSubItemSetW (list, i++, 1, sw);
+ ListSubItemSet (list, i++, 1, sw);
// Type
- ListItemAddW (list, i, GetString ("TYPE"));
+ ListItemAdd (list, i, GetString ("TYPE"));
if (bSysEnc)
- ListSubItemSetW (list, i++, 1, GetString (IsHiddenOSRunning() ? "TYPE_HIDDEN_SYSTEM_ADJECTIVE" : "SYSTEM_VOLUME_TYPE_ADJECTIVE"));
+ ListSubItemSet (list, i++, 1, GetString (IsHiddenOSRunning() ? "TYPE_HIDDEN_SYSTEM_ADJECTIVE" : "SYSTEM_VOLUME_TYPE_ADJECTIVE"));
else
{
bool truecryptMode = prop.pkcs5Iterations == get_pkcs5_iteration_count(prop.pkcs5, 0, TRUE, prop.partitionInInactiveSysEncScope);
@@ -3669,26 +3692,26 @@ BOOL CALLBACK VolumePropertiesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
if (truecryptMode)
{
StringCbPrintfW (sw, sizeof(sw), L"TrueCrypt - %s", s);
- ListSubItemSetW (list, i++, 1, sw);
+ ListSubItemSet (list, i++, 1, sw);
}
else
- ListSubItemSetW (list, i++, 1, s);
+ ListSubItemSet (list, i++, 1, s);
}
if (!bSysEnc)
{
// Write protection
- ListItemAddW (list, i, GetString ("READ_ONLY"));
+ ListItemAdd (list, i, GetString ("READ_ONLY"));
if (prop.readOnly || prop.hiddenVolProtection == HIDVOL_PROT_STATUS_ACTION_TAKEN)
s = GetString ("UISTR_YES");
else
s = GetString ("UISTR_NO");
- ListSubItemSetW (list, i++, 1, s);
+ ListSubItemSet (list, i++, 1, s);
// Hidden Volume Protection
- ListItemAddW (list, i, GetString ("HIDDEN_VOL_PROTECTION"));
+ ListItemAdd (list, i, GetString ("HIDDEN_VOL_PROTECTION"));
if (prop.hiddenVolume)
s = GetString ("NOT_APPLICABLE_OR_NOT_AVAILABLE");
else if (prop.hiddenVolProtection == HIDVOL_PROT_STATUS_NONE)
@@ -3698,15 +3721,15 @@ BOOL CALLBACK VolumePropertiesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
else if (prop.hiddenVolProtection == HIDVOL_PROT_STATUS_ACTION_TAKEN)
s = GetString ("HID_VOL_DAMAGE_PREVENTED");
- ListSubItemSetW (list, i++, 1, s);
+ ListSubItemSet (list, i++, 1, s);
}
// Encryption algorithm
- ListItemAddW (list, i, GetString ("ENCRYPTION_ALGORITHM"));
+ ListItemAdd (list, i, GetString ("ENCRYPTION_ALGORITHM"));
if (prop.ea == 0 || prop.ea > EAGetCount ())
{
- ListSubItemSet (list, i, 1, "?");
+ ListSubItemSet (list, i, 1, L"?");
return 1;
}
@@ -3715,48 +3738,48 @@ BOOL CALLBACK VolumePropertiesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
// Key size(s)
{
- char name[128];
+ wchar_t name[128];
int size = EAGetKeySize (prop.ea);
EAGetName (name, prop.ea, 1);
// Primary key
- ListItemAddW (list, i, GetString ("KEY_SIZE"));
+ ListItemAdd (list, i, GetString ("KEY_SIZE"));
StringCbPrintfW (sw, sizeof(sw), L"%d %s", size * 8, GetString ("BITS"));
- ListSubItemSetW (list, i++, 1, sw);
+ ListSubItemSet (list, i++, 1, sw);
- if (strcmp (EAGetModeName (prop.ea, prop.mode, TRUE), "XTS") == 0)
+ if (wcscmp (EAGetModeName (prop.ea, prop.mode, TRUE), L"XTS") == 0)
{
// Secondary key (XTS)
- ListItemAddW (list, i, GetString ("SECONDARY_KEY_SIZE_XTS"));
- ListSubItemSetW (list, i++, 1, sw);
+ ListItemAdd (list, i, GetString ("SECONDARY_KEY_SIZE_XTS"));
+ ListSubItemSet (list, i++, 1, sw);
}
}
// Block size
- ListItemAddW (list, i, GetString ("BLOCK_SIZE"));
+ ListItemAdd (list, i, GetString ("BLOCK_SIZE"));
StringCbPrintfW (sw, sizeof(sw), L"%d ", CipherGetBlockSize (EAGetFirstCipher(prop.ea))*8);
StringCbCatW (sw, sizeof(sw), GetString ("BITS"));
- ListSubItemSetW (list, i++, 1, sw);
+ ListSubItemSet (list, i++, 1, sw);
// Mode
- ListItemAddW (list, i, GetString ("MODE_OF_OPERATION"));
+ ListItemAdd (list, i, GetString ("MODE_OF_OPERATION"));
ListSubItemSet (list, i++, 1, EAGetModeName (prop.ea, prop.mode, TRUE));
// PKCS 5 PRF
- ListItemAddW (list, i, GetString ("PKCS5_PRF"));
+ ListItemAdd (list, i, GetString ("PKCS5_PRF"));
if (prop.volumePim == 0)
ListSubItemSet (list, i++, 1, get_pkcs5_prf_name (prop.pkcs5));
else
{
- StringCbPrintfA (szTmp, sizeof(szTmp), "%s (Dynamic)", get_pkcs5_prf_name (prop.pkcs5));
+ StringCbPrintfW (szTmp, sizeof(szTmp), L"%s (Dynamic)", get_pkcs5_prf_name (prop.pkcs5));
ListSubItemSet (list, i++, 1, szTmp);
}
#if 0
// PCKS 5 iterations
- ListItemAddW (list, i, GetString ("PKCS5_ITERATIONS"));
+ ListItemAdd (list, i, GetString ("PKCS5_ITERATIONS"));
sprintf (szTmp, "%d", prop.pkcs5Iterations);
ListSubItemSet (list, i++, 1, szTmp);
#endif
@@ -3772,17 +3795,17 @@ BOOL CALLBACK VolumePropertiesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
memset (date, 0, sizeof (date));
// Volume date
- ListItemAddW (list, i, GetString ("VOLUME_CREATE_DATE"));
+ ListItemAdd (list, i, GetString ("VOLUME_CREATE_DATE"));
*(unsigned __int64 *)(&ft) = prop.volumeCreationTime;
FileTimeToSystemTime (&ft, &st);
GetDateFormatW (LOCALE_USER_DEFAULT, 0, &st, 0, sw, sizeof (sw)/2);
swprintf (date, L"%s ", sw);
GetTimeFormatW (LOCALE_USER_DEFAULT, 0, &st, 0, sw, sizeof (sw)/2);
wcscat (date, sw);
- ListSubItemSetW (list, i++, 1, date);
+ ListSubItemSet (list, i++, 1, date);
// Header date
- ListItemAddW (list, i, GetString ("VOLUME_HEADER_DATE"));
+ ListItemAdd (list, i, GetString ("VOLUME_HEADER_DATE"));
*(unsigned __int64 *)(&ft) = prop.headerCreationTime;
FileTimeToSystemTime (&ft, &st);
GetDateFormatW (LOCALE_USER_DEFAULT, 0, &st, 0, sw, sizeof (sw)/2);
@@ -3798,44 +3821,44 @@ BOOL CALLBACK VolumePropertiesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
ft64.LowPart = ft.dwLowDateTime;
swprintf (date + wcslen (date), GetString ("VOLUME_HEADER_DAYS")
, (curFt64.QuadPart - ft64.QuadPart)/(24LL*3600*10000000));
- ListSubItemSetW (list, i++, 1, date);
+ ListSubItemSet (list, i++, 1, date);
}
#endif // 0
if (!bSysEnc || IsHiddenOSRunning())
{
// Volume format version
- ListItemAddW (list, i, GetString ("VOLUME_FORMAT_VERSION"));
- StringCbPrintfA (szTmp, sizeof(szTmp), "%d", prop.volFormatVersion);
+ ListItemAdd (list, i, GetString ("VOLUME_FORMAT_VERSION"));
+ StringCbPrintfW (szTmp, sizeof(szTmp), L"%d", prop.volFormatVersion);
ListSubItemSet (list, i++, 1, szTmp);
// Backup header
- ListItemAddW (list, i, GetString ("BACKUP_HEADER"));
- ListSubItemSetW (list, i++, 1, GetString (prop.volFormatVersion > 1 ? "UISTR_YES" : "UISTR_NO"));
+ ListItemAdd (list, i, GetString ("BACKUP_HEADER"));
+ ListSubItemSet (list, i++, 1, GetString (prop.volFormatVersion > 1 ? "UISTR_YES" : "UISTR_NO"));
}
// Total data read
- ListItemAddW (list, i, GetString ("TOTAL_DATA_READ"));
+ ListItemAdd (list, i, GetString ("TOTAL_DATA_READ"));
GetSizeString (prop.totalBytesRead, sw, sizeof(sw));
- ListSubItemSetW (list, i++, 1, sw);
+ ListSubItemSet (list, i++, 1, sw);
// Total data written
- ListItemAddW (list, i, GetString ("TOTAL_DATA_WRITTEN"));
+ ListItemAdd (list, i, GetString ("TOTAL_DATA_WRITTEN"));
GetSizeString (prop.totalBytesWritten, sw, sizeof(sw));
- ListSubItemSetW (list, i++, 1, sw);
+ ListSubItemSet (list, i++, 1, sw);
if (bSysEnc)
{
// TrueCrypt Boot Loader version
- ListItemAddW (list, i, GetString ("VC_BOOT_LOADER_VERSION"));
- ListSubItemSet (list, i++, 1, (char *) GetUserFriendlyVersionString (BootEncStatus.BootLoaderVersion).c_str());
+ ListItemAdd (list, i, GetString ("VC_BOOT_LOADER_VERSION"));
+ ListSubItemSet (list, i++, 1, GetUserFriendlyVersionString (BootEncStatus.BootLoaderVersion).c_str());
// Encrypted portion
- ListItemAddW (list, i, GetString ("ENCRYPTED_PORTION"));
+ ListItemAdd (list, i, GetString ("ENCRYPTED_PORTION"));
if (GetSysEncDeviceEncryptedPartSize (FALSE) == GetSysEncDeviceSize (FALSE))
- ListSubItemSetW (list, i++, 1, GetString ("ENCRYPTED_PORTION_FULLY_ENCRYPTED"));
+ ListSubItemSet (list, i++, 1, GetString ("ENCRYPTED_PORTION_FULLY_ENCRYPTED"));
else if (GetSysEncDeviceEncryptedPartSize (FALSE) <= 1)
- ListSubItemSetW (list, i++, 1, GetString ("ENCRYPTED_PORTION_NOT_ENCRYPTED"));
+ ListSubItemSet (list, i++, 1, GetString ("ENCRYPTED_PORTION_NOT_ENCRYPTED"));
else
{
@@ -3844,7 +3867,7 @@ BOOL CALLBACK VolumePropertiesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
GetString ("PROCESSED_PORTION_X_PERCENT"),
(double) GetSysEncDeviceEncryptedPartSize (FALSE) / (double) GetSysEncDeviceSize (FALSE) * 100.0);
- ListSubItemSetW (list, i++, 1, sw);
+ ListSubItemSet (list, i++, 1, sw);
}
}
@@ -3957,21 +3980,21 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
if (lw == IDC_BROWSE_FILES)
{
- char dstDir[MAX_PATH];
- char volName[MAX_PATH] = { 0 };
+ wchar_t dstDir[MAX_PATH];
+ wchar_t volName[MAX_PATH] = { 0 };
- GetDlgItemText (hwndDlg, IDC_DIRECTORY, dstDir, sizeof dstDir);
+ GetDlgItemText (hwndDlg, IDC_DIRECTORY, dstDir, ARRAYSIZE (dstDir));
if (BrowseFilesInDir (hwndDlg, "OPEN_TITLE", dstDir, volName, bHistory, FALSE, NULL))
- SetDlgItemText (hwndDlg, IDC_VOLUME_NAME, strchr (volName, '\\') + 1);
+ SetDlgItemText (hwndDlg, IDC_VOLUME_NAME, wcschr (volName, L'\\') + 1);
return 1;
}
if (lw == IDC_BROWSE_DIRS)
{
- char dstPath[MAX_PATH * 2];
- GetDlgItemText (hwndDlg, IDC_DIRECTORY, dstPath, sizeof dstPath);
+ wchar_t dstPath[MAX_PATH * 2];
+ GetDlgItemText (hwndDlg, IDC_DIRECTORY, dstPath, ARRAYSIZE (dstPath));
if (BrowseDirectories (hwndDlg, "SELECT_DEST_DIR", dstPath))
SetDlgItemText (hwndDlg, IDC_DIRECTORY, dstPath);
@@ -4052,7 +4075,7 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
else
StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\VeraCrypt.exe", appDir);
StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCrypt.exe", dstDir);
- if (!TCCopyFileW (srcPath, dstPath))
+ if (!TCCopyFile (srcPath, dstPath))
{
handleWin32Error (hwndDlg, SRC_POS);
goto stop;
@@ -4064,7 +4087,7 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
else
StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\VeraCrypt-x64.exe", appDir);
StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCrypt-x64.exe", dstDir);
- if (!TCCopyFileW (srcPath, dstPath))
+ if (!TCCopyFile (srcPath, dstPath))
{
handleWin32Error (hwndDlg, SRC_POS);
goto stop;
@@ -4079,7 +4102,7 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
else
StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\VeraCrypt Format.exe", appDir);
StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCrypt Format.exe", dstDir);
- if (!TCCopyFileW (srcPath, dstPath))
+ if (!TCCopyFile (srcPath, dstPath))
{
handleWin32Error (hwndDlg, SRC_POS);
goto stop;
@@ -4091,7 +4114,7 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
else
StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\VeraCrypt Format-x64.exe", appDir);
StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCrypt Format-x64.exe", dstDir);
- if (!TCCopyFileW (srcPath, dstPath))
+ if (!TCCopyFile (srcPath, dstPath))
{
handleWin32Error (hwndDlg, SRC_POS);
goto stop;
@@ -4107,7 +4130,7 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
else
StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\VeraCryptExpander.exe", appDir);
StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCryptExpander.exe", dstDir);
- if (!TCCopyFileW (srcPath, dstPath))
+ if (!TCCopyFile (srcPath, dstPath))
{
handleWin32Error (hwndDlg, SRC_POS);
goto stop;
@@ -4119,7 +4142,7 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
else
StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\VeraCryptExpander-x64.exe", appDir);
StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCryptExpander-x64.exe", dstDir);
- if (!TCCopyFileW (srcPath, dstPath))
+ if (!TCCopyFile (srcPath, dstPath))
{
handleWin32Error (hwndDlg, SRC_POS);
goto stop;
@@ -4129,7 +4152,7 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
// Driver
StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\veracrypt.sys", appDir);
StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\veracrypt.sys", dstDir);
- if (!TCCopyFileW (srcPath, dstPath))
+ if (!TCCopyFile (srcPath, dstPath))
{
handleWin32Error (hwndDlg, SRC_POS);
goto stop;
@@ -4138,7 +4161,7 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
// Driver x64
StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\veracrypt-x64.sys", appDir);
StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\veracrypt-x64.sys", dstDir);
- if (!TCCopyFileW (srcPath, dstPath))
+ if (!TCCopyFile (srcPath, dstPath))
{
handleWin32Error (hwndDlg, SRC_POS);
goto stop;
@@ -4149,7 +4172,7 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
// Language pack
StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\Language.%hs.xml", appDir, GetPreferredLangId ());
StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\Language.%hs.xml", dstDir, GetPreferredLangId ());
- TCCopyFileW (srcPath, dstPath);
+ TCCopyFile (srcPath, dstPath);
}
// AutoRun
@@ -4182,8 +4205,7 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
fwprintf (af, L"shell\\start=%s\nshell\\start\\command=VeraCrypt\\VeraCrypt.exe\n", GetString ("IDC_PREF_LOGON_START"));
fwprintf (af, L"shell\\dismount=%s\nshell\\dismount\\command=VeraCrypt\\VeraCrypt.exe /q /d\n", GetString ("DISMOUNT_ALL_TC_VOLUMES"));
- ToSBCS (dstPath, sizeof (dstPath));
- CheckFileStreamWriteErrors (hwndDlg, af, (char*) dstPath);
+ CheckFileStreamWriteErrors (hwndDlg, af, dstPath);
fclose (af);
}
MessageBoxW (hwndDlg, GetString ("TRAVELER_DISK_CREATED"), lpszTitle, MB_ICONINFORMATION);
@@ -4356,10 +4378,10 @@ static int AskVolumePassword (HWND hwndDlg, Password *password, int *pkcs5, int
// GUI actions
-static BOOL Mount (HWND hwndDlg, int nDosDriveNo, char *szFileName, int pim)
+static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szFileName, int pim)
{
BOOL status = FALSE;
- char fileName[MAX_PATH];
+ wchar_t fileName[MAX_PATH];
int mounted = 0, EffectiveVolumePkcs5 = CmdVolumePkcs5;
BOOL EffectiveVolumeTrueCryptMode = CmdVolumeTrueCryptMode;
int EffectiveVolumePim = (pim < 0)? CmdVolumePim : pim;
@@ -4378,7 +4400,7 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, char *szFileName, int pim)
bPrebootPasswordDlgMode = mountOptions.PartitionInInactiveSysEncScope;
if (nDosDriveNo == 0)
- nDosDriveNo = HIWORD (GetSelectedLong (GetDlgItem (MainDlg, IDC_DRIVELIST))) - 'A';
+ nDosDriveNo = HIWORD (GetSelectedLong (GetDlgItem (MainDlg, IDC_DRIVELIST))) - L'A';
if (!MultipleMountOperationInProgress)
{
@@ -4390,11 +4412,11 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, char *szFileName, int pim)
if (szFileName == NULL)
{
- GetVolumePath (hwndDlg, fileName, sizeof (fileName));
+ GetVolumePath (hwndDlg, fileName, ARRAYSIZE (fileName));
szFileName = fileName;
}
- if (strlen(szFileName) == 0)
+ if (wcslen(szFileName) == 0)
{
status = FALSE;
goto ret;
@@ -4480,7 +4502,7 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, char *szFileName, int pim)
int GuiPkcs5 = EffectiveVolumePkcs5;
BOOL GuiTrueCryptMode = EffectiveVolumeTrueCryptMode;
int GuiPim = EffectiveVolumePim;
- StringCbCopyA (PasswordDlgVolume, sizeof(PasswordDlgVolume), szFileName);
+ StringCbCopyW (PasswordDlgVolume, sizeof(PasswordDlgVolume), szFileName);
if (!AskVolumePassword (hwndDlg, &VolumePassword, &GuiPkcs5, &GuiPim, &GuiTrueCryptMode, NULL, TRUE))
goto ret;
@@ -4503,10 +4525,6 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, char *szFileName, int pim)
mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &VolumePassword, VolumePkcs5, VolumePim, VolumeTrueCryptMode, bCacheInDriver, bForceMount, &mountOptions, Silent, !Silent);
NormalCursor ();
- // Check for legacy non-ASCII passwords
- if (mounted > 0 && !KeyFilesEnable && !CheckPasswordCharEncoding (NULL, &VolumePassword))
- Warning ("UNSUPPORTED_CHARS_IN_PWD_RECOM", hwndDlg);
-
// Check for problematic file extensions (exe, dll, sys)
if (mounted > 0 && CheckFileExtension (szFileName))
Warning ("EXE_FILE_EXTENSION_MOUNT_WARNING", hwndDlg);
@@ -4576,7 +4594,7 @@ static BOOL Dismount (HWND hwndDlg, int nDosDriveNo)
WaitCursor ();
if (nDosDriveNo == -2)
- nDosDriveNo = (char) (HIWORD (GetSelectedLong (GetDlgItem (hwndDlg, IDC_DRIVELIST))) - 'A');
+ nDosDriveNo = (char) (HIWORD (GetSelectedLong (GetDlgItem (hwndDlg, IDC_DRIVELIST))) - L'A');
if (bCloseDismountedWindows)
{
@@ -4666,7 +4684,7 @@ void CALLBACK DismountAllThreadProc(void* pArg, HWND hwndDlg)
VolumeNotificationsList.bHidVolDamagePrevReported [punmount->nDosDriveNo] = TRUE;
- StringCbPrintfW (msg, sizeof(msg), GetString ("DAMAGE_TO_HIDDEN_VOLUME_PREVENTED"), punmount->nDosDriveNo + 'A');
+ StringCbPrintfW (msg, sizeof(msg), GetString ("DAMAGE_TO_HIDDEN_VOLUME_PREVENTED"), punmount->nDosDriveNo + L'A');
SetForegroundWindow (hwndDlg);
MessageBoxW (hwndDlg, msg, lpszTitle, MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST);
@@ -4788,7 +4806,7 @@ retry:
{
if (mountList.ulMountedDrives & (1 << i))
{
- char root[] = { (char) i + 'A', ':', '\\', 0 };
+ wchar_t root[] = { (wchar_t) i + L'A', L':', L'\\', 0 };
SHChangeNotify (SHCNE_DRIVEADD, SHCNF_PATH, root, NULL);
}
}
@@ -4887,8 +4905,8 @@ static BOOL MountAllDevicesThreadCode (HWND hwndDlg, BOOL bPasswordPrompt)
foreach (const HostDevice &device, partitions)
{
- char szFileName[TC_MAX_PATH];
- strcpy_s (szFileName, sizeof (szFileName), device.Path.c_str());
+ wchar_t szFileName[TC_MAX_PATH];
+ StringCbCopyW (szFileName, sizeof (szFileName), device.Path.c_str());
BOOL mounted = IsMountedVolume (szFileName);
// Skip other partitions of the disk if partition0 (whole disk) is mounted
@@ -4912,7 +4930,7 @@ static BOOL MountAllDevicesThreadCode (HWND hwndDlg, BOOL bPasswordPrompt)
selDrive++;
continue;
}
- nDosDriveNo = HIWORD(GetItemLong (driveList, selDrive)) - 'A';
+ nDosDriveNo = HIWORD(GetItemLong (driveList, selDrive)) - L'A';
break;
}
@@ -5023,13 +5041,6 @@ static BOOL MountAllDevicesThreadCode (HWND hwndDlg, BOOL bPasswordPrompt)
Info ("HIDVOL_PROT_WARN_AFTER_MOUNT", hwndDlg);
}
- // Check for legacy non-ASCII passwords
- if (!KeyFilesEnable
- && !FirstCmdKeyFile
- && mountedVolCount > 0
- && !CheckPasswordCharEncoding (NULL, &VolumePassword))
- Warning ("UNSUPPORTED_CHARS_IN_PWD_RECOM", hwndDlg);
-
if (status && CloseSecurityTokenSessionsAfterMount)
SecurityToken::CloseAllSessions();
@@ -5087,7 +5098,7 @@ static void ChangePassword (HWND hwndDlg)
INT_PTR result;
int newPimValue = -1;
- GetVolumePath (hwndDlg, szFileName, sizeof (szFileName));
+ GetVolumePath (hwndDlg, szFileName, ARRAYSIZE (szFileName));
if (IsMountedVolume (szFileName))
{
Warning (pwdChangeDlgMode == PCDM_CHANGE_PKCS5_PRF ? "MOUNTED_NO_PKCS5_PRF_CHANGE" : "MOUNTED_NOPWCHANGE", hwndDlg);
@@ -5192,7 +5203,7 @@ static void ChangeSysEncPassword (HWND hwndDlg, BOOL bOnlyChangeKDF)
if (CreateSysEncMutex ()) // If no instance of the wizard is currently taking care of system encryption
{
- StringCbPrintfA (OrigKeyboardLayout, sizeof(OrigKeyboardLayout), "%08X", (DWORD) GetKeyboardLayout (NULL) & 0xFFFF);
+ StringCbPrintfW (OrigKeyboardLayout, sizeof(OrigKeyboardLayout), L"%08X", (DWORD) GetKeyboardLayout (NULL) & 0xFFFF);
bSysEncPwdChangeDlgMode = TRUE;
@@ -5275,7 +5286,7 @@ static void EncryptSystemDevice (HWND hwndDlg)
if (!MutexExistsOnSystem (TC_MUTEX_NAME_SYSENC)) // If no instance of the wizard is currently taking care of system encryption
{
- LaunchVolCreationWizard (hwndDlg, "/sysenc");
+ LaunchVolCreationWizard (hwndDlg, L"/sysenc");
}
else
Warning ("SYSTEM_ENCRYPTION_IN_PROGRESS_ELSEWHERE", hwndDlg);
@@ -5289,7 +5300,7 @@ static void EncryptSystemDevice (HWND hwndDlg)
if (!MutexExistsOnSystem (TC_MUTEX_NAME_SYSENC)) // If no instance of the wizard is currently taking care of system encryption
{
- LaunchVolCreationWizard (hwndDlg, "/sysenc");
+ LaunchVolCreationWizard (hwndDlg, L"/sysenc");
}
else
Warning ("SYSTEM_ENCRYPTION_IN_PROGRESS_ELSEWHERE", hwndDlg);
@@ -5369,7 +5380,7 @@ static void DecryptSystemDevice (HWND hwndDlg)
}
CloseSysEncMutex ();
- LaunchVolCreationWizard (hwndDlg, "/dsysenc");
+ LaunchVolCreationWizard (hwndDlg, L"/dsysenc");
}
else
Warning ("SYSTEM_ENCRYPTION_IN_PROGRESS_ELSEWHERE", hwndDlg);
@@ -5384,12 +5395,12 @@ static void CreateHiddenOS (HWND hwndDlg)
// such information, but will exit (displaying only an error meessage).
Info("HIDDEN_OS_PREINFO", hwndDlg);
- LaunchVolCreationWizard (hwndDlg, "/isysenc");
+ LaunchVolCreationWizard (hwndDlg, L"/isysenc");
}
static void DecryptNonSysDevice (HWND hwndDlg, BOOL bResolveAmbiguousSelection, BOOL bUseDriveListSel)
{
- string scPath;
+ wstring scPath;
if (bResolveAmbiguousSelection)
{
@@ -5413,7 +5424,7 @@ static void DecryptNonSysDevice (HWND hwndDlg, BOOL bResolveAmbiguousSelection,
DWORD bytesReturned;
memset (&prop, 0, sizeof (prop));
- prop.driveNo = (char) HIWORD (lLetter) - 'A';
+ prop.driveNo = (wchar_t) HIWORD (lLetter) - L'A';
if (!DeviceIoControl (hDriver, TC_IOCTL_GET_VOLUME_PROPERTIES, &prop, sizeof (prop), &prop, sizeof (prop), &bytesReturned, NULL))
{
@@ -5421,7 +5432,7 @@ static void DecryptNonSysDevice (HWND hwndDlg, BOOL bResolveAmbiguousSelection,
return;
}
- scPath = WideToSingleString ((wchar_t *) prop.wszVolume);
+ scPath = prop.wszVolume;
}
else
return;
@@ -5430,9 +5441,9 @@ static void DecryptNonSysDevice (HWND hwndDlg, BOOL bResolveAmbiguousSelection,
{
// Decrypt volume specified in the input field below the main drive list
- char volPath [TC_MAX_PATH];
+ wchar_t volPath [TC_MAX_PATH];
- GetVolumePath (MainDlg, volPath, sizeof (volPath));
+ GetVolumePath (MainDlg, volPath, ARRAYSIZE (volPath));
scPath = volPath;
}
@@ -5445,7 +5456,7 @@ static void DecryptNonSysDevice (HWND hwndDlg, BOOL bResolveAmbiguousSelection,
WaitCursor();
- switch (IsSystemDevicePath ((char *) scPath.c_str (), MainDlg, TRUE))
+ switch (IsSystemDevicePath (scPath.c_str (), MainDlg, TRUE))
{
case 1:
case 2:
@@ -5472,7 +5483,7 @@ static void DecryptNonSysDevice (HWND hwndDlg, BOOL bResolveAmbiguousSelection,
return;
}
}
- else if (TCBootLoaderOnInactiveSysEncDrive ((char *) scPath.c_str ()))
+ else if (TCBootLoaderOnInactiveSysEncDrive ((wchar_t *) scPath.c_str ()))
{
// The system drive MAY be entirely encrypted (external access without PBA) and the potentially encrypted OS is not running
@@ -5489,13 +5500,13 @@ static void DecryptNonSysDevice (HWND hwndDlg, BOOL bResolveAmbiguousSelection,
NormalCursor ();
- if (AskNoYesString ((wstring (GetString ("CONFIRM_DECRYPT_NON_SYS_DEVICE")) + L"\n\n" + SingleStringToWide (scPath)).c_str(), hwndDlg) == IDNO)
+ if (AskNoYesString ((wstring (GetString ("CONFIRM_DECRYPT_NON_SYS_DEVICE")) + L"\n\n" + scPath).c_str(), hwndDlg) == IDNO)
return;
if (AskWarnNoYes ("CONFIRM_DECRYPT_NON_SYS_DEVICE_CAUTION", hwndDlg) == IDNO)
return;
- LaunchVolCreationWizard (hwndDlg, (string ("/inplacedec \"") + scPath + "\"").c_str ());
+ LaunchVolCreationWizard (hwndDlg, (wstring (L"/inplacedec \"") + scPath + L"\"").c_str ());
}
// Blindly attempts (without any checks) to instruct the wizard to resume whatever system encryption process
@@ -5504,7 +5515,7 @@ static void ResumeInterruptedSysEncProcess (HWND hwndDlg)
{
if (!MutexExistsOnSystem (TC_MUTEX_NAME_SYSENC)) // If no instance of the wizard is currently taking care of system encryption
{
- LaunchVolCreationWizard (MainDlg, "/csysenc");
+ LaunchVolCreationWizard (MainDlg, L"/csysenc");
}
else
Warning ("SYSTEM_ENCRYPTION_IN_PROGRESS_ELSEWHERE", hwndDlg);
@@ -5548,7 +5559,7 @@ void CreateRescueDisk (HWND hwndDlg)
try
{
wchar_t szTmp [8096];
- char szRescueDiskISO [TC_MAX_PATH+1];
+ wchar_t szRescueDiskISO [TC_MAX_PATH+1];
if (AskOkCancel ("RESCUE_DISK_NON_WIZARD_CREATION_SELECT_PATH", hwndDlg) != IDOK)
{
@@ -5556,7 +5567,7 @@ void CreateRescueDisk (HWND hwndDlg)
return;
}
- char initialDir[MAX_PATH];
+ wchar_t initialDir[MAX_PATH];
SHGetFolderPath (NULL, CSIDL_MYDOCUMENTS, NULL, 0, initialDir);
if (!BrowseFilesInDir (hwndDlg, "OPEN_TITLE", initialDir, szRescueDiskISO, FALSE, TRUE, NULL, L"VeraCrypt Rescue Disk.iso", L"iso"))
@@ -5631,13 +5642,13 @@ static void VerifyRescueDisk (HWND hwndDlg, bool checkIsoFile)
}
// Create a temporary up-to-date rescue disk image in RAM (with it the CD/DVD content will be compared)
- BootEncObj->CreateRescueIsoImage (false, "");
+ BootEncObj->CreateRescueIsoImage (false, L"");
if (checkIsoFile)
{
- char szRescueDiskISO [TC_MAX_PATH+1];
- char initialDir[MAX_PATH];
+ wchar_t szRescueDiskISO [TC_MAX_PATH+1];
+ wchar_t initialDir[MAX_PATH];
SHGetFolderPath (NULL, CSIDL_MYDOCUMENTS, NULL, 0, initialDir);
if (!BrowseFilesInDir (hwndDlg, "OPEN_TITLE", initialDir, szRescueDiskISO, FALSE, FALSE, NULL, L"VeraCrypt Rescue Disk.iso", L"iso"))
@@ -5725,7 +5736,7 @@ static void ResumeInterruptedNonSysInplaceEncProcess (BOOL bDecrypt)
// IMPORTANT: This function must not check any config files! Otherwise, if a config file was lost or corrupt,
// the user would not be able resume encryption and the data on the volume would be inaccessible.
- LaunchVolCreationWizard (MainDlg, bDecrypt? "/resumeinplacedec" : "/zinplace");
+ LaunchVolCreationWizard (MainDlg, bDecrypt? L"/resumeinplacedec" : L"/zinplace");
}
BOOL SelectContainer (HWND hwndDlg)
@@ -5809,16 +5820,16 @@ static BOOL CheckMountList (HWND hwndDlg, BOOL bForceTaskBarUpdate)
if (LastKnownLogicalDrives != GetLogicalDrives()
|| memcmp (&LastKnownMountList, &current, sizeof (current)) != 0)
{
- char selDrive;
+ wchar_t selDrive;
WaitCursor ();
LastKnownMountList = current;
- selDrive = (char) HIWORD (GetSelectedLong (GetDlgItem (MainDlg, IDC_DRIVELIST)));
+ selDrive = (wchar_t) HIWORD (GetSelectedLong (GetDlgItem (MainDlg, IDC_DRIVELIST)));
LoadDriveLetters (hwndDlg, GetDlgItem (MainDlg, IDC_DRIVELIST), 0);
NormalCursor ();
- if (selDrive != -1 && (current.ulMountedDrives & (1 << (selDrive - 'A'))) == 0 && !IsDriveAvailable (selDrive - 'A'))
+ if (selDrive != -1 && (current.ulMountedDrives & (1 << (selDrive - L'A'))) == 0 && !IsDriveAvailable (selDrive - L'A'))
{
nSelectedDriveIndex = -1;
return FALSE;
@@ -5841,7 +5852,7 @@ static BOOL CheckMountList (HWND hwndDlg, BOOL bForceTaskBarUpdate)
{
/* System encryption status change */
- char selDrive;
+ wchar_t selDrive;
int driveLetterToRefresh;
if (RecentBootEncStatus.DriveMounted == newBootEncStatus.DriveMounted) // If an icon (and whole new line) for a system device isn't to be added/removed
@@ -5864,12 +5875,12 @@ static BOOL CheckMountList (HWND hwndDlg, BOOL bForceTaskBarUpdate)
driveLetterToRefresh = 0;
}
- selDrive = (char) HIWORD (GetSelectedLong (GetDlgItem (MainDlg, IDC_DRIVELIST)));
+ selDrive = (wchar_t) HIWORD (GetSelectedLong (GetDlgItem (MainDlg, IDC_DRIVELIST)));
LoadDriveLetters (hwndDlg, GetDlgItem (MainDlg, IDC_DRIVELIST), driveLetterToRefresh);
RecentBootEncStatus = newBootEncStatus;
- if (selDrive != -1 && (current.ulMountedDrives & (1 << (selDrive - 'A'))) == 0 && !IsDriveAvailable (selDrive - 'A'))
+ if (selDrive != -1 && (current.ulMountedDrives & (1 << (selDrive - L'A'))) == 0 && !IsDriveAvailable (selDrive - L'A'))
{
nSelectedDriveIndex = -1;
}
@@ -5995,7 +6006,7 @@ void DisplayDriveListContextMenu (HWND hwndDlg, LPARAM lParam)
// No mounted volume at this drive letter
AppendMenuW (popup, MF_STRING, IDM_MOUNT_VOLUME, GetString ("IDM_MOUNT_VOLUME"));
- AppendMenu (popup, MF_SEPARATOR, 0, "");
+ AppendMenu (popup, MF_SEPARATOR, 0, L"");
AppendMenuW (popup, MF_STRING, IDPM_SELECT_FILE_AND_MOUNT, GetString ("SELECT_FILE_AND_MOUNT"));
AppendMenuW (popup, MF_STRING, IDPM_SELECT_DEVICE_AND_MOUNT, GetString ("SELECT_DEVICE_AND_MOUNT"));
break;
@@ -6006,15 +6017,15 @@ void DisplayDriveListContextMenu (HWND hwndDlg, LPARAM lParam)
AppendMenuW (popup, MF_STRING, IDM_UNMOUNT_VOLUME, GetString ("DISMOUNT"));
AppendMenuW (popup, MF_STRING, IDPM_OPEN_VOLUME, GetString ("OPEN"));
- AppendMenu (popup, MF_SEPARATOR, 0, "");
+ AppendMenu (popup, MF_SEPARATOR, 0, L"");
AppendMenuW (popup, MF_STRING, IDPM_CHECK_FILESYS, GetString ("IDPM_CHECK_FILESYS"));
AppendMenuW (popup, MF_STRING, IDPM_REPAIR_FILESYS, GetString ("IDPM_REPAIR_FILESYS"));
- AppendMenu (popup, MF_SEPARATOR, 0, "");
+ AppendMenu (popup, MF_SEPARATOR, 0, L"");
AppendMenuW (popup, MF_STRING, IDPM_ADD_TO_FAVORITES, GetString ("IDPM_ADD_TO_FAVORITES"));
AppendMenuW (popup, MF_STRING, IDPM_ADD_TO_SYSTEM_FAVORITES, GetString ("IDPM_ADD_TO_SYSTEM_FAVORITES"));
- AppendMenu (popup, MF_SEPARATOR, 0, "");
+ AppendMenu (popup, MF_SEPARATOR, 0, L"");
AppendMenuW (popup, MF_STRING, IDM_DECRYPT_NONSYS_VOL, GetString ("IDM_DECRYPT_NONSYS_VOL"));
- AppendMenu (popup, MF_SEPARATOR, 0, "");
+ AppendMenu (popup, MF_SEPARATOR, 0, L"");
AppendMenuW (popup, MF_STRING, IDM_VOLUME_PROPERTIES, GetString ("IDPM_PROPERTIES"));
break;
@@ -6071,7 +6082,7 @@ void DisplayDriveListContextMenu (HWND hwndDlg, LPARAM lParam)
LPARAM lLetter = GetSelectedLong (hList);
if (LOWORD (lLetter) != 0xffff)
- CheckFilesystem (hwndDlg, (char) HIWORD (lLetter) - 'A', menuItem == IDPM_REPAIR_FILESYS);
+ CheckFilesystem (hwndDlg, (wchar_t) HIWORD (lLetter) - L'A', menuItem == IDPM_REPAIR_FILESYS);
}
break;
@@ -6095,7 +6106,7 @@ void DisplayDriveListContextMenu (HWND hwndDlg, LPARAM lParam)
state = GetItemLong (hList, nSelectedDriveIndex );
WaitCursor ();
- OpenVolumeExplorerWindow (HIWORD(state) - 'A');
+ OpenVolumeExplorerWindow (HIWORD(state) - L'A');
NormalCursor ();
}
break;
@@ -6127,7 +6138,7 @@ void DisplayDriveListContextMenu (HWND hwndDlg, LPARAM lParam)
LPARAM selectedDrive = GetSelectedLong (hList);
if (LOWORD (selectedDrive) == TC_MLIST_ITEM_NONSYS_VOL)
- AddMountedVolumeToFavorites (hwndDlg, HIWORD (selectedDrive) - 'A', menuItem == IDPM_ADD_TO_SYSTEM_FAVORITES);
+ AddMountedVolumeToFavorites (hwndDlg, HIWORD (selectedDrive) - L'A', menuItem == IDPM_ADD_TO_SYSTEM_FAVORITES);
}
break;
@@ -6167,7 +6178,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
ResetWrongPwdRetryCount ();
- ExtractCommandLine (hwndDlg, (char *) lParam);
+ ExtractCommandLine (hwndDlg, (wchar_t *) lParam);
try
{
@@ -6237,7 +6248,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
{
// No drive letter specified on command line
if (commandLineDrive == 0)
- szDriveLetter[0] = (char) GetFirstAvailableDrive () + 'A';
+ szDriveLetter[0] = (wchar_t) GetFirstAvailableDrive () + L'A';
if (bAutoMountDevices)
{
@@ -6289,7 +6300,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
EffectiveVolumeTrueCryptMode = DefaultVolumeTrueCryptMode;
// Cached password
- mounted = MountVolume (hwndDlg, szDriveLetter[0] - 'A', szFileName, NULL, EffectiveVolumePkcs5, CmdVolumePim, EffectiveVolumeTrueCryptMode, bCacheInDriver, bForceMount, &mountOptions, Silent, FALSE);
+ mounted = MountVolume (hwndDlg, szDriveLetter[0] - L'A', szFileName, NULL, EffectiveVolumePkcs5, CmdVolumePim, EffectiveVolumeTrueCryptMode, bCacheInDriver, bForceMount, &mountOptions, Silent, FALSE);
// Command line password or keyfiles
if (!mounted && (CmdVolumePassword.Length != 0 || (FirstCmdKeyFile && (CmdVolumePasswordValid || bEffectiveTryEmptyPasswordWhenKeyfileUsed))))
@@ -6299,7 +6310,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (FirstCmdKeyFile)
KeyFilesApply (hwndDlg, &CmdVolumePassword, FirstCmdKeyFile, szFileName);
- mounted = MountVolume (hwndDlg, szDriveLetter[0] - 'A',
+ mounted = MountVolume (hwndDlg, szDriveLetter[0] - L'A',
szFileName, &CmdVolumePassword, EffectiveVolumePkcs5, CmdVolumePim, EffectiveVolumeTrueCryptMode, bCacheInDriver, bForceMount,
&mountOptions, Silent, reportBadPasswd);
@@ -6320,7 +6331,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
BOOL GuiTrueCryptMode = EffectiveVolumeTrueCryptMode;
VolumePassword.Length = 0;
- StringCbCopyA (PasswordDlgVolume, sizeof(PasswordDlgVolume),szFileName);
+ StringCbCopyW (PasswordDlgVolume, sizeof(PasswordDlgVolume),szFileName);
if (!AskVolumePassword (hwndDlg, &VolumePassword, &GuiPkcs5, &GuiPim, &GuiTrueCryptMode, NULL, TRUE))
break;
else
@@ -6338,7 +6349,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (KeyFilesEnable && FirstKeyFile)
KeyFilesApply (hwndDlg, &VolumePassword, FirstKeyFile, szFileName);
- mounted = MountVolume (hwndDlg, szDriveLetter[0] - 'A', szFileName, &VolumePassword, VolumePkcs5, VolumePim, VolumeTrueCryptMode, bCacheInDriver, bForceMount, &mountOptions, FALSE, TRUE);
+ mounted = MountVolume (hwndDlg, szDriveLetter[0] - L'A', szFileName, &VolumePassword, VolumePkcs5, VolumePim, VolumeTrueCryptMode, bCacheInDriver, bForceMount, &mountOptions, FALSE, TRUE);
burn (&VolumePassword, sizeof (VolumePassword));
burn (&VolumePkcs5, sizeof (VolumePkcs5));
@@ -6363,7 +6374,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
MessageBeep (0xFFFFFFFF);
if (bExplore)
- OpenVolumeExplorerWindow (szDriveLetter[0] - 'A');
+ OpenVolumeExplorerWindow (szDriveLetter[0] - L'A');
RefreshMainDlg(hwndDlg);
@@ -6473,7 +6484,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
COPYDATASTRUCT cd;
memcpy (&cd.dwData, WM_COPY_SET_VOLUME_NAME, 4);
cd.lpData = szFileName;
- cd.cbData = (DWORD) strlen (szFileName) + 1;
+ cd.cbData = (DWORD) ((wcslen (szFileName) + 1) * sizeof (wchar_t));
SendMessage (h, WM_COPYDATA, (WPARAM)hwndDlg, (LPARAM)&cd);
}
@@ -6500,7 +6511,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
GetMountList (&LastKnownMountList);
SetTimer (hwndDlg, TIMER_ID_MAIN, TIMER_INTERVAL_MAIN, NULL);
- taskBarCreatedMsg = RegisterWindowMessage ("TaskbarCreated");
+ taskBarCreatedMsg = RegisterWindowMessage (L"TaskbarCreated");
SetFocus (GetDlgItem (hwndDlg, IDC_DRIVELIST));
@@ -6521,7 +6532,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
// to resume the encryption/decryption process.
- LaunchVolCreationWizard (hwndDlg, "/csysenc");
+ LaunchVolCreationWizard (hwndDlg, L"/csysenc");
}
}
}
@@ -6717,15 +6728,15 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (IsMountedVolume (favorite.Path.c_str()))
continue;
- char volDevPath[TC_MAX_PATH];
+ wchar_t volDevPath[TC_MAX_PATH];
if (QueryDosDevice (favorite.VolumePathId.substr (4, favorite.VolumePathId.size() - 5).c_str(), volDevPath, TC_MAX_PATH) == 0)
continue;
favorite.DisconnectedDevice = false;
}
- else if (favorite.Path.find ("\\\\?\\Volume{") == 0)
+ else if (favorite.Path.find (L"\\\\?\\Volume{") == 0)
{
- string resolvedPath = VolumeGuidPathToDevicePath (favorite.Path);
+ wstring resolvedPath = VolumeGuidPathToDevicePath (favorite.Path);
if (resolvedPath.empty())
continue;
@@ -6781,7 +6792,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
continue;
}
- char volDevPath[TC_MAX_PATH];
+ wchar_t volDevPath[TC_MAX_PATH];
if (favorite->VolumePathId.size() > 5
&& QueryDosDevice (favorite->VolumePathId.substr (4, favorite->VolumePathId.size() - 5).c_str(), volDevPath, TC_MAX_PATH) != 0)
{
@@ -6833,7 +6844,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (MainWindowHidden)
{
AppendMenuW (popup, MF_STRING, IDM_SHOW_HIDE, GetString ("SHOW_TC"));
- AppendMenu (popup, MF_SEPARATOR, 0, "");
+ AppendMenu (popup, MF_SEPARATOR, 0, L"");
}
else if (bEnableBkgTask
&& (!(LastKnownMountList.ulMountedDrives == 0
@@ -6842,12 +6853,12 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
&& GetDriverRefCount () < 2)))
{
AppendMenuW (popup, MF_STRING, IDM_SHOW_HIDE, GetString ("HIDE_TC"));
- AppendMenu (popup, MF_SEPARATOR, 0, "");
+ AppendMenu (popup, MF_SEPARATOR, 0, L"");
}
AppendMenuW (popup, MF_STRING, IDM_MOUNTALL, GetString ("IDC_MOUNTALL"));
AppendMenuW (popup, MF_STRING, IDM_MOUNT_FAVORITE_VOLUMES, GetString ("IDM_MOUNT_FAVORITE_VOLUMES"));
AppendMenuW (popup, MF_STRING, IDM_UNMOUNTALL, GetString ("IDC_UNMOUNTALL"));
- AppendMenu (popup, MF_SEPARATOR, 0, "");
+ AppendMenu (popup, MF_SEPARATOR, 0, L"");
for (n = 0; n < 2; n++)
{
@@ -6864,7 +6875,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
bool useInExplorer = false;
wstring label = (wchar_t *) LastKnownMountList.wszLabel[i];
if (label.empty())
- label = GetFavoriteVolumeLabel (WideToSingleString (vol), useInExplorer);
+ label = GetFavoriteVolumeLabel (vol, useInExplorer);
StringCbPrintfW (s, sizeof(s), L"%s %c: (%s)",
GetString (n==0 ? "OPEN" : "DISMOUNT"),
@@ -6874,14 +6885,14 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
}
}
if (LastKnownMountList.ulMountedDrives != 0)
- AppendMenu (popup, MF_SEPARATOR, 0, "");
+ AppendMenu (popup, MF_SEPARATOR, 0, L"");
}
AppendMenuW (popup, MF_STRING, IDM_HELP, GetString ("MENU_HELP"));
AppendMenuW (popup, MF_STRING, IDM_HOMEPAGE_SYSTRAY, GetString ("HOMEPAGE"));
AppendMenuW (popup, MF_STRING, IDM_PREFERENCES, GetString ("IDM_PREFERENCES"));
AppendMenuW (popup, MF_STRING, IDM_ABOUT, GetString ("IDM_ABOUT"));
- AppendMenu (popup, MF_SEPARATOR, 0, "");
+ AppendMenu (popup, MF_SEPARATOR, 0, L"");
AppendMenuW (popup, MF_STRING, IDCANCEL, GetString ("EXIT"));
GetCursorPos (&pos);
@@ -7010,18 +7021,15 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (LastKnownMountList.ulMountedDrives & (1 << m))
{
wchar_t *vol = (wchar_t *) LastKnownMountList.wszVolume[m];
- char volp[MAX_PATH];
if (wcsstr (vol, L"\\??\\") == vol)
vol += 4;
- StringCbPrintfA (volp, sizeof(volp), "%ls", vol);
-
- if (IsVolumeDeviceHosted (volp))
+ if (IsVolumeDeviceHosted (vol))
{
OPEN_TEST_STRUCT ots = {0};
- if (!OpenDevice (volp, &ots, FALSE))
+ if (!OpenDevice (vol, &ots, FALSE))
{
UnmountVolume (hwndDlg, m, TRUE);
WarningBalloon ("HOST_DEVICE_REMOVAL_DISMOUNT_WARN_TITLE", "HOST_DEVICE_REMOVAL_DISMOUNT_WARN", hwndDlg);
@@ -7069,7 +7077,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
{
// Open explorer window for mounted volume
WaitCursor ();
- OpenVolumeExplorerWindow (HIWORD(state) - 'A');
+ OpenVolumeExplorerWindow (HIWORD(state) - L'A');
NormalCursor ();
}
else if (LOWORD (GetSelectedLong (GetDlgItem (hwndDlg, IDC_DRIVELIST))) == TC_MLIST_ITEM_FREE)
@@ -7095,8 +7103,8 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (mountOptions.ProtectHiddenVolume && hidVolProtKeyFilesParam.EnableKeyFiles)
{
- char selectedVolume [TC_MAX_PATH + 1];
- GetVolumePath (hwndDlg, selectedVolume, sizeof (selectedVolume));
+ wchar_t selectedVolume [TC_MAX_PATH + 1];
+ GetVolumePath (hwndDlg, selectedVolume, ARRAYSIZE (selectedVolume));
KeyFilesApply (hwndDlg, &mountOptions.ProtectedHidVolPassword, hidVolProtKeyFilesParam.FirstKeyFile, selectedVolume);
}
}
@@ -7241,7 +7249,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
break;
case IDM_MOUNT_SYSENC_PART_WITHOUT_PBA:
- if (CheckSysEncMountWithoutPBA (hwndDlg, "", FALSE))
+ if (CheckSysEncMountWithoutPBA (hwndDlg, L"", FALSE))
{
mountOptions = defaultMountOptions;
mountOptions.PartitionInInactiveSysEncScope = TRUE;
@@ -7258,7 +7266,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
/* Volume Tools popup menu */
int menuItem;
- char volPath[TC_MAX_PATH]; /* Volume to mount */
+ wchar_t volPath[TC_MAX_PATH]; /* Volume to mount */
HMENU popup = CreatePopupMenu ();
RECT rect;
@@ -7270,10 +7278,10 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
{
AppendMenuW (popup, MF_STRING, IDM_CHANGE_PASSWORD, GetString ("IDM_CHANGE_PASSWORD"));
AppendMenuW (popup, MF_STRING, IDM_CHANGE_HEADER_KEY_DERIV_ALGO, GetString ("IDM_CHANGE_HEADER_KEY_DERIV_ALGO"));
- AppendMenu (popup, MF_SEPARATOR, 0, "");
+ AppendMenu (popup, MF_SEPARATOR, 0, L"");
AppendMenuW (popup, MF_STRING, IDM_ADD_REMOVE_VOL_KEYFILES, GetString ("IDM_ADD_REMOVE_VOL_KEYFILES"));
AppendMenuW (popup, MF_STRING, IDM_REMOVE_ALL_KEYFILES_FROM_VOL, GetString ("IDM_REMOVE_ALL_KEYFILES_FROM_VOL"));
- AppendMenu (popup, MF_SEPARATOR, 0, "");
+ AppendMenu (popup, MF_SEPARATOR, 0, L"");
AppendMenuW (popup, MF_STRING, IDM_DECRYPT_NONSYS_VOL, GetString ("IDM_DECRYPT_NONSYS_VOL"));
AppendMenu (popup, MF_SEPARATOR, 0, NULL);
AppendMenuW (popup, MF_STRING, IDM_BACKUP_VOL_HEADER, GetString ("IDM_BACKUP_VOL_HEADER"));
@@ -7360,7 +7368,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
}
else
{
- GetVolumePath (hwndDlg, volPath, sizeof (volPath));
+ GetVolumePath (hwndDlg, volPath, ARRAYSIZE (volPath));
WaitCursor ();
@@ -7478,7 +7486,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (lw == IDC_CREATE_VOLUME || lw == IDM_CREATE_VOLUME || lw == IDM_VOLUME_WIZARD)
{
- LaunchVolCreationWizard (hwndDlg, "");
+ LaunchVolCreationWizard (hwndDlg, L"");
return 1;
}
@@ -7655,11 +7663,10 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
{
LPARAM selectedDrive = GetSelectedLong (GetDlgItem (hwndDlg, IDC_DRIVELIST));
- char volPathLower[TC_MAX_PATH];
- wchar_t volPathLowerW[TC_MAX_PATH];
+ wchar_t volPathLower[TC_MAX_PATH];
// volPathLower will contain the volume path (if any) from the input field below the drive list
- GetVolumePath (hwndDlg, volPathLower, sizeof (volPathLower));
+ GetVolumePath (hwndDlg, volPathLower, ARRAYSIZE (volPathLower));
if (LOWORD (selectedDrive) != TC_MLIST_ITEM_NONSYS_VOL
&& !(VolumeSelected (hwndDlg) && IsMountedVolume (volPathLower)))
@@ -7687,7 +7694,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
DWORD dwResult;
memset (&prop, 0, sizeof(prop));
- prop.driveNo = HIWORD (selectedDrive) - 'A';
+ prop.driveNo = HIWORD (selectedDrive) - L'A';
if (!DeviceIoControl (hDriver, TC_IOCTL_GET_VOLUME_PROPERTIES, &prop, sizeof (prop), &prop, sizeof (prop), &dwResult, NULL) || dwResult == 0)
{
@@ -7698,11 +7705,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
// volPathHigher will contain the volume path selected in the main drive list
wstring volPathHigher (prop.wszVolume);
- ToSBCS (prop.wszVolume, sizeof(prop.wszVolume));
- StringCbCopyA ((char *) volPathLowerW, sizeof(volPathLowerW), volPathLower);
- ToUNICODE ((char *) volPathLowerW, sizeof(volPathLowerW));
-
- if (strcmp (((memcmp ((char *) prop.wszVolume, "\\??\\", 4) == 0) ? (char *) prop.wszVolume + 4 : (char *) prop.wszVolume), volPathLower) != 0)
+ if (wcscmp (((wmemcmp (prop.wszVolume, L"\\??\\", 4) == 0) ? (wchar_t *) prop.wszVolume + 4 : prop.wszVolume), volPathLower) != 0)
{
// The path selected in the input field is different from the path to the volume selected
// in the drive lettter list. We have to resolve possible ambiguity.
@@ -7715,7 +7718,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
volPathHigher = wstring (L"...") + volPathHigher.substr (volPathHigher.length () - maxVolPathLen, maxVolPathLen);
}
- wstring volPathLowerWStr (volPathLowerW);
+ wstring volPathLowerWStr (volPathLower);
if (volPathLowerWStr.length () > maxVolPathLen)
{
@@ -7730,7 +7733,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
switch (AskMultiChoice ((void **) tmp, FALSE, hwndDlg))
{
case 1:
- driveNo = HIWORD (selectedDrive) - 'A';
+ driveNo = HIWORD (selectedDrive) - L'A';
break;
case 2:
@@ -7743,13 +7746,13 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
}
else
{
- driveNo = HIWORD (selectedDrive) - 'A';
+ driveNo = HIWORD (selectedDrive) - L'A';
}
}
}
else
{
- driveNo = HIWORD (selectedDrive) - 'A';
+ driveNo = HIWORD (selectedDrive) - L'A';
}
AddMountedVolumeToFavorites (hwndDlg, driveNo, lw == IDM_ADD_VOLUME_TO_SYSTEM_FAVORITES);
@@ -7803,9 +7806,9 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
}
else
{
- char volPath[TC_MAX_PATH]; /* Volume to mount */
+ wchar_t volPath[TC_MAX_PATH]; /* Volume to mount */
- GetVolumePath (hwndDlg, volPath, sizeof (volPath));
+ GetVolumePath (hwndDlg, volPath, ARRAYSIZE (volPath));
WaitCursor ();
@@ -7830,9 +7833,9 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
}
else
{
- char volPath[TC_MAX_PATH]; /* Volume to mount */
+ wchar_t volPath[TC_MAX_PATH]; /* Volume to mount */
- GetVolumePath (hwndDlg, volPath, sizeof (volPath));
+ GetVolumePath (hwndDlg, volPath, ARRAYSIZE (volPath));
WaitCursor ();
@@ -7891,7 +7894,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (nSelectedDriveIndex >= 0)
{
SelectItem (GetDlgItem (hwndDlg, IDC_DRIVELIST),
- (char) HIWORD (GetItemLong (GetDlgItem (hwndDlg, IDC_DRIVELIST), nSelectedDriveIndex)));
+ (wchar_t) HIWORD (GetItemLong (GetDlgItem (hwndDlg, IDC_DRIVELIST), nSelectedDriveIndex)));
}
NormalCursor ();
@@ -7969,7 +7972,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (IsMountedVolume (FavoriteVolumes[favoriteIndex].Path.c_str()))
{
WaitCursor();
- OpenVolumeExplorerWindow (GetMountedVolumeDriveNo ((char *) FavoriteVolumes[favoriteIndex].Path.c_str()));
+ OpenVolumeExplorerWindow (GetMountedVolumeDriveNo ((wchar_t*) FavoriteVolumes[favoriteIndex].Path.c_str()));
NormalCursor();
}
else
@@ -8018,8 +8021,8 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
{
if (cd->cbData > 0)
{
- ((char *) cd->lpData)[cd->cbData - 1] = 0;
- AddComboItem (GetDlgItem (hwndDlg, IDC_VOLUME), (char *)cd->lpData, bHistory);
+ ((wchar_t *) cd->lpData)[(cd->cbData / sizeof (wchar_t)) - 1] = 0;
+ AddComboItem (GetDlgItem (hwndDlg, IDC_VOLUME), (wchar_t *)cd->lpData, bHistory);
}
EnableDisableButtons (hwndDlg);
@@ -8060,23 +8063,23 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
return 0;
}
-void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
+void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine)
{
- char **lpszCommandLineArgs = NULL; /* Array of command line arguments */
+ wchar_t **lpszCommandLineArgs = NULL; /* Array of command line arguments */
int nNoCommandLineArgs; /* The number of arguments in the array */
- char tmpPath[MAX_PATH * 2];
+ wchar_t tmpPath[MAX_PATH * 2];
/* Defaults */
mountOptions.PreserveTimestamp = TRUE;
- if (_stricmp (lpszCommandLine, "-Embedding") == 0)
+ if (_wcsicmp (lpszCommandLine, L"-Embedding") == 0)
{
ComServerMode = TRUE;
return;
}
/* Extract command line arguments */
- NoCmdLineArgs = nNoCommandLineArgs = Win32CommandLine (lpszCommandLine, &lpszCommandLineArgs);
+ NoCmdLineArgs = nNoCommandLineArgs = Win32CommandLine (&lpszCommandLineArgs);
if (nNoCommandLineArgs > 0)
{
@@ -8111,27 +8114,27 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
argument args[]=
{
- { OptionAuto, "/auto", "/a", FALSE },
- { OptionBeep, "/beep", "/b", FALSE },
- { OptionCache, "/cache", "/c", FALSE },
- { CommandDismount, "/dismount", "/d", FALSE },
- { OptionExplore, "/explore", "/e", FALSE },
- { OptionForce, "/force", "/f", FALSE },
- { OptionPkcs5, "/hash", NULL , FALSE },
- { CommandHelp, "/help", "/?", FALSE },
- { OptionHistory, "/history", "/h", FALSE },
- { OptionKeyfile, "/keyfile", "/k", FALSE },
- { OptionLetter, "/letter", "/l", FALSE },
- { OptionMountOption, "/mountoption", "/m", FALSE },
- { OptionPassword, "/password", "/p", FALSE },
- { OptionPim, "/pim", NULL, FALSE },
- { OptionQuit, "/quit", "/q", FALSE },
- { OptionSilent, "/silent", "/s", FALSE },
- { OptionTokenLib, "/tokenlib", NULL, FALSE },
- { OptionTrueCryptMode, "/truecrypt", "/tc", FALSE },
- { OptionVolume, "/volume", "/v", FALSE },
- { CommandWipeCache, "/wipecache", "/w", FALSE },
- { OptionTryEmptyPassword, "/tryemptypass", NULL, FALSE },
+ { OptionAuto, L"/auto", L"/a", FALSE },
+ { OptionBeep, L"/beep", L"/b", FALSE },
+ { OptionCache, L"/cache", L"/c", FALSE },
+ { CommandDismount, L"/dismount", L"/d", FALSE },
+ { OptionExplore, L"/explore", L"/e", FALSE },
+ { OptionForce, L"/force", L"/f", FALSE },
+ { OptionPkcs5, L"/hash", NULL , FALSE },
+ { CommandHelp, L"/help", L"/?", FALSE },
+ { OptionHistory, L"/history", L"/h", FALSE },
+ { OptionKeyfile, L"/keyfile", L"/k", FALSE },
+ { OptionLetter, L"/letter", L"/l", FALSE },
+ { OptionMountOption, L"/mountoption", L"/m", FALSE },
+ { OptionPassword, L"/password", L"/p", FALSE },
+ { OptionPim, L"/pim", NULL, FALSE },
+ { OptionQuit, L"/quit", L"/q", FALSE },
+ { OptionSilent, L"/silent", L"/s", FALSE },
+ { OptionTokenLib, L"/tokenlib", NULL, FALSE },
+ { OptionTrueCryptMode, L"/truecrypt", L"/tc", FALSE },
+ { OptionVolume, L"/volume", L"/v", FALSE },
+ { CommandWipeCache, L"/wipecache", L"/w", FALSE },
+ { OptionTryEmptyPassword, L"/tryemptypass", NULL, FALSE },
};
argumentspec as;
@@ -8143,17 +8146,17 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
{
case OptionAuto:
{
- char szTmp[32] = {0};
+ wchar_t szTmp[32] = {0};
bAuto = TRUE;
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs,
&i, nNoCommandLineArgs, szTmp, sizeof (szTmp)))
{
- if (!_stricmp (szTmp, "devices"))
+ if (!_wcsicmp (szTmp, L"devices"))
bAutoMountDevices = TRUE;
- else if (!_stricmp (szTmp, "favorites"))
+ else if (!_wcsicmp (szTmp, L"favorites"))
bAutoMountFavorites = TRUE;
- else if (!_stricmp (szTmp, "logon"))
+ else if (!_wcsicmp (szTmp, L"logon"))
LogOn = TRUE;
else
AbortProcess ("COMMAND_LINE_ERROR");
@@ -8167,16 +8170,16 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
case OptionTryEmptyPassword:
{
- char szTmp[16] = {0};
+ wchar_t szTmp[16] = {0};
bCmdTryEmptyPasswordWhenKeyfileUsed = TRUE;
bCmdTryEmptyPasswordWhenKeyfileUsedValid = TRUE;
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs,
szTmp, sizeof (szTmp)))
{
- if (!_stricmp(szTmp,"n") || !_stricmp(szTmp,"no"))
+ if (!_wcsicmp(szTmp,L"n") || !_wcsicmp(szTmp,L"no"))
bCmdTryEmptyPasswordWhenKeyfileUsed = FALSE;
- else if (!_stricmp(szTmp,"y") || !_stricmp(szTmp,"yes"))
+ else if (!_wcsicmp(szTmp,L"y") || !_wcsicmp(szTmp,L"yes"))
bCmdTryEmptyPasswordWhenKeyfileUsed = TRUE;
else
AbortProcess ("COMMAND_LINE_ERROR");
@@ -8186,17 +8189,17 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
case OptionCache:
{
- char szTmp[16] = {0};
+ wchar_t szTmp[16] = {0};
bCacheInDriver = TRUE;
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs,
szTmp, sizeof (szTmp)))
{
- if (!_stricmp(szTmp,"n") || !_stricmp(szTmp,"no"))
+ if (!_wcsicmp(szTmp,L"n") || !_wcsicmp(szTmp,L"no"))
bCacheInDriver = FALSE;
- else if (!_stricmp(szTmp,"y") || !_stricmp(szTmp,"yes"))
+ else if (!_wcsicmp(szTmp,L"y") || !_wcsicmp(szTmp,L"yes"))
bCacheInDriver = TRUE;
- else if (!_stricmp(szTmp,"f") || !_stricmp(szTmp,"favorites"))
+ else if (!_wcsicmp(szTmp,L"f") || !_wcsicmp(szTmp,L"favorites"))
{
bCacheInDriver = FALSE;
bCmdCacheDuringMultipleMount = TRUE;
@@ -8212,12 +8215,12 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs,
szDriveLetter, sizeof (szDriveLetter)))
{
- if ( (strlen(szDriveLetter) == 1)
- || (strlen(szDriveLetter) == 2 && szDriveLetter[1] == ':')
+ if ( (wcslen(szDriveLetter) == 1)
+ || (wcslen(szDriveLetter) == 2 && szDriveLetter[1] == L':')
)
{
- cmdUnmountDrive = toupper(szDriveLetter[0]) - 'A';
- if ((cmdUnmountDrive < 0) || (cmdUnmountDrive > ('Z' - 'A')))
+ cmdUnmountDrive = towupper(szDriveLetter[0]) - L'A';
+ if ((cmdUnmountDrive < 0) || (cmdUnmountDrive > (L'Z' - L'A')))
AbortProcess ("BAD_DRIVE_LETTER");
}
else
@@ -8247,7 +8250,7 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
kf = (KeyFile *) malloc (sizeof (KeyFile));
if (kf)
{
- StringCbCopyA (kf->FileName, sizeof(kf->FileName), tmpPath);
+ StringCbCopyW (kf->FileName, sizeof(kf->FileName), tmpPath);
FirstCmdKeyFile = KeyFileAdd (FirstCmdKeyFile, kf);
}
}
@@ -8260,13 +8263,13 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs,
szDriveLetter, sizeof (szDriveLetter)))
{
- if ( (strlen(szDriveLetter) == 1)
- || (strlen(szDriveLetter) == 2 && szDriveLetter[1] == ':')
+ if ( (wcslen(szDriveLetter) == 1)
+ || (wcslen(szDriveLetter) == 2 && szDriveLetter[1] == L':')
)
{
- commandLineDrive = *szDriveLetter = (char) toupper (*szDriveLetter);
+ commandLineDrive = *szDriveLetter = (wchar_t) towupper (*szDriveLetter);
- if (commandLineDrive < 'A' || commandLineDrive > 'Z')
+ if (commandLineDrive < L'A' || commandLineDrive > L'Z')
AbortProcess ("BAD_DRIVE_LETTER");
}
else
@@ -8279,15 +8282,15 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
case OptionHistory:
{
- char szTmp[8] = {0};
+ wchar_t szTmp[8] = {0};
bHistory = bHistoryCmdLine = TRUE;
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs,
szTmp, sizeof (szTmp)))
{
- if (!_stricmp(szTmp,"n") || !_stricmp(szTmp,"no"))
+ if (!_wcsicmp(szTmp,L"n") || !_wcsicmp(szTmp,L"no"))
bHistory = FALSE;
- else if (!_stricmp(szTmp,"y") || !_stricmp(szTmp,"yes"))
+ else if (!_wcsicmp(szTmp,L"y") || !_wcsicmp(szTmp,L"yes"))
bHistory = TRUE;
else
AbortProcess ("COMMAND_LINE_ERROR");
@@ -8297,32 +8300,31 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
case OptionMountOption:
{
- char szTmp[64] = {0};
+ wchar_t szTmp[64] = {0};
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs,
&i, nNoCommandLineArgs, szTmp, sizeof (szTmp)))
{
- if (!_stricmp (szTmp, "ro") || !_stricmp (szTmp, "readonly"))
+ if (!_wcsicmp (szTmp, L"ro") || !_wcsicmp (szTmp, L"readonly"))
mountOptions.ReadOnly = TRUE;
- else if (!_stricmp (szTmp, "rm") || !_stricmp (szTmp, "removable"))
+ else if (!_wcsicmp (szTmp, L"rm") || !_wcsicmp (szTmp, L"removable"))
mountOptions.Removable = TRUE;
- else if (!_stricmp (szTmp, "ts") || !_stricmp (szTmp, "timestamp"))
+ else if (!_wcsicmp (szTmp, L"ts") || !_wcsicmp (szTmp, L"timestamp"))
mountOptions.PreserveTimestamp = FALSE;
- else if (!_stricmp (szTmp, "sm") || !_stricmp (szTmp, "system"))
+ else if (!_wcsicmp (szTmp, L"sm") || !_wcsicmp (szTmp, L"system"))
mountOptions.PartitionInInactiveSysEncScope = bPrebootPasswordDlgMode = TRUE;
- else if (!_stricmp (szTmp, "bk") || !_stricmp (szTmp, "headerbak"))
+ else if (!_wcsicmp (szTmp, L"bk") || !_wcsicmp (szTmp, L"headerbak"))
mountOptions.UseBackupHeader = TRUE;
- else if (!_stricmp (szTmp, "recovery"))
+ else if (!_wcsicmp (szTmp, L"recovery"))
mountOptions.RecoveryMode = TRUE;
- else if ((strlen(szTmp) > 6) && (strlen(szTmp) <= 38) && !_strnicmp (szTmp, "label=", 6))
+ else if ((wcslen(szTmp) > 6) && (wcslen(szTmp) <= 38) && !_wcsnicmp (szTmp, L"label=", 6))
{
// get the label
- memmove (szTmp, &szTmp[6], (strlen(szTmp) - 6) + 1);
- MultiByteToWideChar (CP_ACP, 0, szTmp, -1, mountOptions.Label, sizeof (mountOptions.Label) / sizeof(wchar_t));
+ StringCbCopyW (mountOptions.Label, sizeof (mountOptions.Label), &szTmp[6]);
}
else
AbortProcess ("COMMAND_LINE_ERROR");
@@ -8336,14 +8338,24 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
break;
case OptionPassword:
- if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs,
- (char *) CmdVolumePassword.Text, sizeof (CmdVolumePassword.Text)))
{
- CmdVolumePassword.Length = (unsigned __int32) strlen ((char *) CmdVolumePassword.Text);
- CmdVolumePasswordValid = TRUE;
+ wchar_t szTmp[MAX_PASSWORD + 1];
+ if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs,
+ szTmp, sizeof (szTmp)))
+ {
+ int iLen = WideCharToMultiByte (CP_UTF8, 0, szTmp, -1, (char*) CmdVolumePassword.Text, MAX_PASSWORD + 1, NULL, NULL);
+ burn (szTmp, sizeof (szTmp));
+ if (iLen > 0)
+ {
+ CmdVolumePassword.Length = (unsigned __int32) (iLen - 1);
+ CmdVolumePasswordValid = TRUE;
+ }
+ else
+ AbortProcess ("COMMAND_LINE_ERROR");
+ }
+ else
+ AbortProcess ("COMMAND_LINE_ERROR");
}
- else
- AbortProcess ("COMMAND_LINE_ERROR");
break;
case OptionVolume:
@@ -8360,22 +8372,22 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
case OptionQuit:
{
- char szTmp[32] = {0};
+ wchar_t szTmp[32] = {0};
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs,
&i, nNoCommandLineArgs, szTmp, sizeof (szTmp)))
{
- if (!_stricmp (szTmp, "UAC")) // Used to indicate non-install elevation
+ if (!_wcsicmp (szTmp, L"UAC")) // Used to indicate non-install elevation
break;
- else if (!_stricmp (szTmp, "preferences"))
+ else if (!_wcsicmp (szTmp, L"preferences"))
{
Quit = TRUE;
UsePreferences = TRUE;
break;
}
- else if (!_stricmp (szTmp, "background"))
+ else if (!_wcsicmp (szTmp, L"background"))
bEnableBkgTask = TRUE;
else
@@ -8411,17 +8423,17 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
case OptionPkcs5:
{
- char szTmp[32] = {0};
+ wchar_t szTmp[32] = {0};
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs,
&i, nNoCommandLineArgs, szTmp, sizeof (szTmp)))
{
- if (_stricmp(szTmp, "sha512") == 0 || _stricmp(szTmp, "sha-512") == 0)
+ if (_wcsicmp(szTmp, L"sha512") == 0 || _wcsicmp(szTmp, L"sha-512") == 0)
CmdVolumePkcs5 = SHA512;
- else if (_stricmp(szTmp, "whirlpool") == 0)
+ else if (_wcsicmp(szTmp, L"whirlpool") == 0)
CmdVolumePkcs5 = WHIRLPOOL;
- else if (_stricmp(szTmp, "sha256") == 0 || _stricmp(szTmp, "sha-256") == 0)
+ else if (_wcsicmp(szTmp, L"sha256") == 0 || _wcsicmp(szTmp, L"sha-256") == 0)
CmdVolumePkcs5 = SHA256;
- else if (_stricmp(szTmp, "ripemd160") == 0 || _stricmp(szTmp, "ripemd-160") == 0)
+ else if (_wcsicmp(szTmp, L"ripemd160") == 0 || _wcsicmp(szTmp, L"ripemd-160") == 0)
CmdVolumePkcs5 = RIPEMD160;
else
{
@@ -8437,13 +8449,13 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
case OptionPim:
{
- char szTmp[32] = {0};
+ wchar_t szTmp[32] = {0};
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs,
&i, nNoCommandLineArgs, szTmp, sizeof (szTmp)))
{
- char* endPtr = NULL;
- CmdVolumePim = (int) strtol(szTmp, &endPtr, 0);
- if (CmdVolumePim < 0 || endPtr == szTmp || *endPtr != '\0')
+ wchar_t* endPtr = NULL;
+ CmdVolumePim = (int) wcstol(szTmp, &endPtr, 0);
+ if (CmdVolumePim < 0 || endPtr == szTmp || *endPtr != L'\0')
{
CmdVolumePim = 0;
AbortProcess ("COMMAND_LINE_ERROR");
@@ -8464,7 +8476,7 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
{
if (nNoCommandLineArgs == 1)
{
- strcpy_s (szFileName, array_capacity (szFileName), lpszCommandLineArgs[i]);
+ StringCbCopyW (szFileName, array_capacity (szFileName), lpszCommandLineArgs[i]);
RelativePath2Absolute (szFileName);
CmdLineVolumeSpecified = TRUE;
@@ -8491,7 +8503,7 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
static SERVICE_STATUS SystemFavoritesServiceStatus;
static SERVICE_STATUS_HANDLE SystemFavoritesServiceStatusHandle;
-static void SystemFavoritesServiceLogMessage (const string &errorMessage, WORD wType)
+static void SystemFavoritesServiceLogMessage (const wstring &errorMessage, WORD wType)
{
HANDLE eventSource = RegisterEventSource (NULL, TC_SYSTEM_FAVORITES_SERVICE_NAME);
@@ -8504,17 +8516,17 @@ static void SystemFavoritesServiceLogMessage (const string &errorMessage, WORD w
}
}
-static void SystemFavoritesServiceLogError (const string &errorMessage)
+static void SystemFavoritesServiceLogError (const wstring &errorMessage)
{
SystemFavoritesServiceLogMessage (errorMessage, EVENTLOG_ERROR_TYPE);
}
-static void SystemFavoritesServiceLogWarning (const string &warningMessage)
+static void SystemFavoritesServiceLogWarning (const wstring &warningMessage)
{
SystemFavoritesServiceLogMessage (warningMessage, EVENTLOG_WARNING_TYPE);
}
-static void SystemFavoritesServiceLogInfo (const string &infoMessage)
+static void SystemFavoritesServiceLogInfo (const wstring &infoMessage)
{
SystemFavoritesServiceLogMessage (infoMessage, EVENTLOG_INFORMATION_TYPE);
}
@@ -8551,7 +8563,7 @@ static VOID WINAPI SystemFavoritesServiceMain (DWORD argc, LPTSTR *argv)
SystemFavoritesServiceSetStatus (SERVICE_START_PENDING, 120000);
- SystemFavoritesServiceLogInfo (string ("Starting System Favorites mounting process"));
+ SystemFavoritesServiceLogInfo (wstring (L"Starting System Favorites mounting process"));
try
{
@@ -8561,11 +8573,11 @@ static VOID WINAPI SystemFavoritesServiceMain (DWORD argc, LPTSTR *argv)
if (status)
{
- SystemFavoritesServiceLogInfo (string ("System Favorites mounting process finished"));
+ SystemFavoritesServiceLogInfo (wstring (L"System Favorites mounting process finished"));
}
else
{
- SystemFavoritesServiceLogError (string ("System Favorites mounting process failed."));
+ SystemFavoritesServiceLogError (wstring (L"System Favorites mounting process failed."));
}
SystemFavoritesServiceSetStatus (SERVICE_RUNNING);
@@ -8600,12 +8612,12 @@ static BOOL StartSystemFavoritesService ()
}
#ifndef VCEXPANDER
-int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, char *lpszCommandLine, int nCmdShow)
+int WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, wchar_t *lpszCommandLine, int nCmdShow)
{
int argc;
LPWSTR *argv = CommandLineToArgvW (GetCommandLineW(), &argc);
- if (argv && argc == 2 && SingleStringToWide (TC_SYSTEM_FAVORITES_SERVICE_CMDLINE_OPTION) == argv[1])
+ if (argv && argc == 2 && wstring (TC_SYSTEM_FAVORITES_SERVICE_CMDLINE_OPTION) == argv[1])
return StartSystemFavoritesService() ? 0 : 1;
int status;
@@ -8669,7 +8681,7 @@ BOOL TaskBarIconAdd (HWND hwnd)
// Only one icon may be created
if (TaskBarIconMutex != NULL) return TRUE;
- TaskBarIconMutex = CreateMutex (NULL, TRUE, "VeraCryptTaskBarIcon");
+ TaskBarIconMutex = CreateMutex (NULL, TRUE, L"VeraCryptTaskBarIcon");
if (TaskBarIconMutex == NULL || GetLastError () == ERROR_ALREADY_EXISTS)
{
if (TaskBarIconMutex != NULL)
@@ -8827,7 +8839,7 @@ static BOOL MountFavoriteVolumeBase (HWND hwnd, const FavoriteVolume &favorite,
{
BOOL status = TRUE;
int drive;
- drive = toupper (favorite.MountPoint[0]) - 'A';
+ drive = towupper (favorite.MountPoint[0]) - L'A';
mountOptions.ReadOnly = favorite.ReadOnly || userForcedReadOnly;
mountOptions.Removable = favorite.Removable;
@@ -8851,15 +8863,15 @@ static BOOL MountFavoriteVolumeBase (HWND hwnd, const FavoriteVolume &favorite,
{
MountVolumesAsSystemFavorite = systemFavorites;
- string mountPoint = (char) (drive + 'A') + string (":\\");
- char prevVolumeAtMountPoint[MAX_PATH] = { 0 };
+ wstring mountPoint = (wchar_t) (drive + L'A') + wstring (L":\\");
+ wchar_t prevVolumeAtMountPoint[MAX_PATH] = { 0 };
if (systemFavorites)
{
// Partitions of new drives are assigned free drive letters by Windows on boot. Make sure this does not prevent system favorite volumes
// from being mounted. Each partition (using the same drive letter as a system favorite volume) is assigned another free drive letter.
- if (GetVolumeNameForVolumeMountPoint (mountPoint.c_str(), prevVolumeAtMountPoint, sizeof (prevVolumeAtMountPoint)))
+ if (GetVolumeNameForVolumeMountPoint (mountPoint.c_str(), prevVolumeAtMountPoint, ARRAYSIZE (prevVolumeAtMountPoint)))
DeleteVolumeMountPoint (mountPoint.c_str());
else
prevVolumeAtMountPoint[0] = 0;
@@ -8893,9 +8905,9 @@ static BOOL MountFavoriteVolumeBase (HWND hwnd, const FavoriteVolume &favorite,
BOOL prevReadOnly = mountOptions.ReadOnly;
if (ServiceMode)
- SystemFavoritesServiceLogInfo (string ("Mounting system favorite \"") + favorite.Path + "\"");
+ SystemFavoritesServiceLogInfo (wstring (L"Mounting system favorite \"") + favorite.Path + L"\"");
- status = Mount (hwnd, drive, (char *) favorite.Path.c_str(), favorite.Pim);
+ status = Mount (hwnd, drive, (wchar_t *) favorite.Path.c_str(), favorite.Pim);
if (ServiceMode)
{
@@ -8905,11 +8917,11 @@ static BOOL MountFavoriteVolumeBase (HWND hwnd, const FavoriteVolume &favorite,
if (status)
{
- SystemFavoritesServiceLogInfo (string ("Favorite \"") + favorite.Path + string ("\" mounted successfully as ") + (char) (drive + 'A') + ":");
+ SystemFavoritesServiceLogInfo (wstring (L"Favorite \"") + favorite.Path + wstring (L"\" mounted successfully as ") + (wchar_t) (drive + L'A') + L":");
}
else
{
- SystemFavoritesServiceLogError (string ("Favorite \"") + favorite.Path + "\" failed to mount");
+ SystemFavoritesServiceLogError (wstring (L"Favorite \"") + favorite.Path + L"\" failed to mount");
}
}
@@ -8926,7 +8938,7 @@ skipMount:
int freeDrive = GetFirstAvailableDrive();
if (freeDrive != -1)
{
- mountPoint[0] = (char) (freeDrive + 'A');
+ mountPoint[0] = (wchar_t) (freeDrive + L'A');
SetVolumeMountPoint (mountPoint.c_str(), prevVolumeAtMountPoint);
}
}
@@ -8943,14 +8955,14 @@ skipMount:
DWORD bytesOut;
DeviceIoControl (hDriver, TC_IOCTL_SET_SYSTEM_FAVORITE_VOLUME_DIRTY, NULL, 0, NULL, 0, &bytesOut, NULL);
- SystemFavoritesServiceLogError (string ("The filesystem of the volume mounted as ") + (char) (drive + 'A') + ": was not cleanly dismounted and needs to be checked for errors.");
+ SystemFavoritesServiceLogError (wstring (L"The filesystem of the volume mounted as ") + (wchar_t) (drive + L'A') + L": was not cleanly dismounted and needs to be checked for errors.");
}
}
else if (!systemFavorites && !favoriteVolumeToMount.Path.empty())
Error ("DRIVE_LETTER_UNAVAILABLE", MainDlg);
else if (ServiceMode && systemFavorites)
{
- SystemFavoritesServiceLogError (string ("The drive letter ") + (char) (drive + 'A') + string (" used by favorite \"") + favorite.Path + "\" is already taken.\nThis system favorite will not be mounted");
+ SystemFavoritesServiceLogError (wstring (L"The drive letter ") + (wchar_t) (drive + L'A') + wstring (L" used by favorite \"") + favorite.Path + L"\" is already taken.\nThis system favorite will not be mounted");
}
return status;
@@ -8982,20 +8994,20 @@ BOOL MountFavoriteVolumes (HWND hwnd, BOOL systemFavorites, BOOL logOnMount, BOO
try
{
if (ServiceMode)
- SystemFavoritesServiceLogInfo (string ("Reading System Favorites XML file"));
+ SystemFavoritesServiceLogInfo (wstring (L"Reading System Favorites XML file"));
LoadFavoriteVolumes (favorites, true);
if (ServiceMode)
{
- char szTmp[32];
- StringCbPrintf (szTmp, sizeof(szTmp), "%d", (int) favorites.size());
- SystemFavoritesServiceLogInfo (string ("Loaded %d favorites from the file") + szTmp);
+ wchar_t szTmp[32];
+ StringCbPrintf (szTmp, sizeof(szTmp), L"%d", (int) favorites.size());
+ SystemFavoritesServiceLogInfo (wstring (L"Loaded ") + szTmp + wstring (L" favorites from the file"));
}
}
catch (...)
{
if (ServiceMode)
- SystemFavoritesServiceLogError (string ("An error occured while reading System Favorites XML file"));
+ SystemFavoritesServiceLogError (wstring (L"An error occured while reading System Favorites XML file"));
return false;
}
}
@@ -9009,7 +9021,7 @@ BOOL MountFavoriteVolumes (HWND hwnd, BOOL systemFavorites, BOOL logOnMount, BOO
if (ServiceMode && systemFavorites && favorite.DisconnectedDevice)
{
skippedSystemFavorites.push_back (favorite);
- SystemFavoritesServiceLogWarning (string ("Favorite \"") + favorite.Path + "\" is disconnected. It will be ignored.");
+ SystemFavoritesServiceLogWarning (wstring (L"Favorite \"") + favorite.Path + L"\" is disconnected. It will be ignored.");
}
if (favorite.DisconnectedDevice
@@ -9034,7 +9046,7 @@ BOOL MountFavoriteVolumes (HWND hwnd, BOOL systemFavorites, BOOL logOnMount, BOO
{
Sleep (5000);
- SystemFavoritesServiceLogInfo (string ("Trying to mount skipped system favorites"));
+ SystemFavoritesServiceLogInfo (wstring (L"Trying to mount skipped system favorites"));
// Update the service status to avoid being killed
SystemFavoritesServiceStatus.dwCheckPoint++;
@@ -9046,7 +9058,7 @@ BOOL MountFavoriteVolumes (HWND hwnd, BOOL systemFavorites, BOOL logOnMount, BOO
if (favorite->DisconnectedDevice)
{
// check if the favorite is here and get its path
- string resolvedPath = VolumeGuidPathToDevicePath (favorite->Path);
+ wstring resolvedPath = VolumeGuidPathToDevicePath (favorite->Path);
if (!resolvedPath.empty())
{
favorite->DisconnectedDevice = false;
@@ -9056,7 +9068,7 @@ BOOL MountFavoriteVolumes (HWND hwnd, BOOL systemFavorites, BOOL logOnMount, BOO
remainingFavorites--;
// favorite OK.
- SystemFavoritesServiceLogInfo (string ("Favorite \"") + favorite->VolumePathId + "\" is connected. Performing mount.");
+ SystemFavoritesServiceLogInfo (wstring (L"Favorite \"") + favorite->VolumePathId + L"\" is connected. Performing mount.");
status = MountFavoriteVolumeBase (hwnd, *favorite, lastbExplore, userForcedReadOnly, systemFavorites, logOnMount, hotKeyMount, favoriteVolumeToMount);
if (!status)
@@ -9066,12 +9078,12 @@ BOOL MountFavoriteVolumes (HWND hwnd, BOOL systemFavorites, BOOL logOnMount, BOO
}
if (remainingFavorites == 0)
- SystemFavoritesServiceLogInfo (string ("All skipped system favorites have been processed"));
+ SystemFavoritesServiceLogInfo (wstring (L"All skipped system favorites have been processed"));
else
{
- char szTmp[32];
- StringCbPrintfA (szTmp, sizeof(szTmp), "%d", (int) remainingFavorites);
- SystemFavoritesServiceLogWarning (string ("Number of unprocessed system favorites is ") + szTmp);
+ wchar_t szTmp[32];
+ StringCbPrintfW (szTmp, sizeof(szTmp), L"%d", (int) remainingFavorites);
+ SystemFavoritesServiceLogWarning (wstring (L"Number of unprocessed system favorites is ") + szTmp);
}
}
}
@@ -9115,14 +9127,14 @@ static void SaveDefaultKeyFilesParam (HWND hwnd)
if (defaultKeyFilesParam.FirstKeyFile == NULL)
{
/* No keyfiles selected */
- remove (GetConfigPath (TC_APPD_FILENAME_DEFAULT_KEYFILES));
+ _wremove (GetConfigPath (TC_APPD_FILENAME_DEFAULT_KEYFILES));
}
else
{
FILE *f;
KeyFile *kf = FirstKeyFile;
- f = fopen (GetConfigPath (TC_APPD_FILENAME_DEFAULT_KEYFILES), "w");
+ f = _wfopen (GetConfigPath (TC_APPD_FILENAME_DEFAULT_KEYFILES), L"w,ccs=UTF-8");
if (f == NULL)
{
handleWin32Error (MainDlg, SRC_POS);
@@ -9131,19 +9143,19 @@ static void SaveDefaultKeyFilesParam (HWND hwnd)
XmlWriteHeader (f);
- fputs ("\n\t<defaultkeyfiles>", f);
+ fputws (L"\n\t<defaultkeyfiles>", f);
while (kf != NULL)
{
- char q[TC_MAX_PATH * 2];
+ wchar_t q[TC_MAX_PATH * 2];
- XmlQuoteText (kf->FileName, q, sizeof (q));
- fprintf (f, "\n\t\t<keyfile>%s</keyfile>", q);
+ XmlQuoteTextW (kf->FileName, q, ARRAYSIZE (q));
+ fwprintf (f, L"\n\t\t<keyfile>%s</keyfile>", q);
kf = kf->Next;
}
- fputs ("\n\t</defaultkeyfiles>", f);
+ fputws (L"\n\t</defaultkeyfiles>", f);
XmlWriteFooter (f);
@@ -9280,7 +9292,7 @@ void ChangeMainWindowVisibility ()
}
-int BackupVolumeHeader (HWND hwndDlg, BOOL bRequireConfirmation, const char *lpszVolume)
+int BackupVolumeHeader (HWND hwndDlg, BOOL bRequireConfirmation, const wchar_t *lpszVolume)
{
int nStatus = ERR_OS_ERROR;
wchar_t szTmp[4096];
@@ -9428,7 +9440,7 @@ noHidden:
goto ret;
/* Conceive the backup file */
- if ((fBackup = _open(szFileName, _O_CREAT|_O_TRUNC|_O_WRONLY|_O_BINARY, _S_IREAD|_S_IWRITE)) == -1)
+ if ((fBackup = _wopen(szFileName, _O_CREAT|_O_TRUNC|_O_WRONLY|_O_BINARY, _S_IREAD|_S_IWRITE)) == -1)
{
nStatus = ERR_OS_ERROR;
goto error;
@@ -9538,12 +9550,12 @@ error:
}
-int RestoreVolumeHeader (HWND hwndDlg, const char *lpszVolume)
+int RestoreVolumeHeader (HWND hwndDlg, const wchar_t *lpszVolume)
{
int nDosLinkCreated = -1, nStatus = ERR_OS_ERROR;
- char szDiskFile[TC_MAX_PATH], szCFDevice[TC_MAX_PATH];
- char szFileName[TC_MAX_PATH];
- char szDosDevice[TC_MAX_PATH];
+ wchar_t szDiskFile[TC_MAX_PATH], szCFDevice[TC_MAX_PATH];
+ wchar_t szFileName[TC_MAX_PATH];
+ wchar_t szDosDevice[TC_MAX_PATH];
void *dev = INVALID_HANDLE_VALUE;
DWORD dwError;
BOOL bDevice;
@@ -9636,7 +9648,7 @@ int RestoreVolumeHeader (HWND hwndDlg, const char *lpszVolume)
{
int GuiPkcs5 = ((EffectiveVolumePkcs5 > 0) && (VolumePkcs5 == 0))? EffectiveVolumePkcs5 : VolumePkcs5;
int GuiPim = ((EffectiveVolumePim > 0) && (VolumePim <= 0))? EffectiveVolumePim : VolumePim;
- StringCbCopyA (PasswordDlgVolume, sizeof(PasswordDlgVolume), lpszVolume);
+ StringCbCopyW (PasswordDlgVolume, sizeof(PasswordDlgVolume), lpszVolume);
if (!AskVolumePassword (hwndDlg, &VolumePassword, &GuiPkcs5, &GuiPim, &VolumeTrueCryptMode, NULL, FALSE))
{
nStatus = ERR_SUCCESS;
@@ -9733,7 +9745,7 @@ int RestoreVolumeHeader (HWND hwndDlg, const char *lpszVolume)
CreateFullVolumePath (szDiskFile, sizeof(szDiskFile), lpszVolume, &bDevice);
if (bDevice == FALSE)
- StringCbCopyA (szCFDevice, sizeof(szCFDevice), szDiskFile);
+ StringCbCopyW (szCFDevice, sizeof(szCFDevice), szDiskFile);
else
{
nDosLinkCreated = FakeDosNameForDevice (szDiskFile, szDosDevice, sizeof(szDosDevice),szCFDevice, sizeof(szCFDevice),FALSE);
@@ -10112,7 +10124,7 @@ static BOOL CALLBACK PerformanceSettingsDlgProc (HWND hwndDlg, UINT msg, WPARAM
if (ReadEncryptionThreadPoolFreeCpuCountLimit() != cpuFreeCount)
{
- BootEncObj->WriteLocalMachineRegistryDwordValue ("SYSTEM\\CurrentControlSet\\Services\\veracrypt", TC_ENCRYPTION_FREE_CPU_COUNT_REG_VALUE_NAME, cpuFreeCount);
+ BootEncObj->WriteLocalMachineRegistryDwordValue (L"SYSTEM\\CurrentControlSet\\Services\\veracrypt", TC_ENCRYPTION_FREE_CPU_COUNT_REG_VALUE_NAME, cpuFreeCount);
Warning ("SETTING_REQUIRES_REBOOT", hwndDlg);
}
@@ -10194,8 +10206,8 @@ static BOOL CALLBACK SecurityTokenPreferencesDlgProc (HWND hwndDlg, UINT msg, WP
case IDOK:
{
- char securityTokenLibraryPath[MAX_PATH];
- GetDlgItemText (hwndDlg, IDC_PKCS11_MODULE, securityTokenLibraryPath, sizeof (securityTokenLibraryPath));
+ wchar_t securityTokenLibraryPath[MAX_PATH];
+ GetDlgItemText (hwndDlg, IDC_PKCS11_MODULE, securityTokenLibraryPath, ARRAYSIZE (securityTokenLibraryPath));
if (securityTokenLibraryPath[0] == 0)
{
@@ -10209,13 +10221,13 @@ static BOOL CALLBACK SecurityTokenPreferencesDlgProc (HWND hwndDlg, UINT msg, WP
}
else
{
- char prevSecurityTokenLibraryPath[MAX_PATH];
- StringCbCopyA (prevSecurityTokenLibraryPath, sizeof(prevSecurityTokenLibraryPath), SecurityTokenLibraryPath);
- StringCbCopyA (SecurityTokenLibraryPath, sizeof(SecurityTokenLibraryPath), securityTokenLibraryPath);
+ wchar_t prevSecurityTokenLibraryPath[MAX_PATH];
+ StringCbCopyW (prevSecurityTokenLibraryPath, sizeof(prevSecurityTokenLibraryPath), SecurityTokenLibraryPath);
+ StringCbCopyW (SecurityTokenLibraryPath, sizeof(SecurityTokenLibraryPath), securityTokenLibraryPath);
if (!InitSecurityTokenLibrary(hwndDlg))
{
- StringCbCopyA (SecurityTokenLibraryPath, sizeof(SecurityTokenLibraryPath), prevSecurityTokenLibraryPath);
+ StringCbCopyW (SecurityTokenLibraryPath, sizeof(SecurityTokenLibraryPath), prevSecurityTokenLibraryPath);
return 1;
}
}
@@ -10232,17 +10244,17 @@ static BOOL CALLBACK SecurityTokenPreferencesDlgProc (HWND hwndDlg, UINT msg, WP
case IDC_AUTO_DETECT_PKCS11_MODULE:
{
- char systemDir[MAX_PATH];
- GetSystemDirectory (systemDir, sizeof (systemDir));
+ wchar_t systemDir[MAX_PATH];
+ GetSystemDirectory (systemDir, ARRAYSIZE (systemDir));
WIN32_FIND_DATA findData;
bool found = false;
WaitCursor();
- HANDLE find = FindFirstFile ((string (systemDir) + "\\*.dll").c_str(), &findData);
+ HANDLE find = FindFirstFile ((wstring (systemDir) + L"\\*.dll").c_str(), &findData);
while (!found && find != INVALID_HANDLE_VALUE)
{
- string dllPathname = string (systemDir) + "\\" + findData.cFileName;
+ wstring dllPathname = wstring (systemDir) + L"\\" + findData.cFileName;
DWORD fileSize;
char *file = LoadFile (dllPathname.c_str(), &fileSize);
@@ -10295,14 +10307,14 @@ static BOOL CALLBACK SecurityTokenPreferencesDlgProc (HWND hwndDlg, UINT msg, WP
case IDC_SELECT_PKCS11_MODULE:
{
- char securityTokenLibraryPath[MAX_PATH];
- char systemDir[MAX_PATH];
+ wchar_t securityTokenLibraryPath[MAX_PATH];
+ wchar_t systemDir[MAX_PATH];
wchar_t browseFilter[1024];
Info ("SELECT_PKCS11_MODULE_HELP", hwndDlg);
StringCbPrintfW (browseFilter, sizeof(browseFilter), L"%ls (*.dll)%c*.dll%c%c", GetString ("DLL_FILES"), 0, 0, 0);
- GetSystemDirectory (systemDir, sizeof (systemDir));
+ GetSystemDirectory (systemDir, ARRAYSIZE (systemDir));
if (BrowseFilesInDir (hwndDlg, "SELECT_PKCS11_MODULE", systemDir, securityTokenLibraryPath, TRUE, FALSE, browseFilter))
SetDlgItemText (hwndDlg, IDC_PKCS11_MODULE, securityTokenLibraryPath);
@@ -10426,7 +10438,7 @@ static BOOL CALLBACK BootLoaderPreferencesDlgProc (HWND hwndDlg, UINT msg, WPARA
Warning ("BOOT_LOADER_VERSION_INCORRECT_PREFERENCES", hwndDlg);
SendMessage (GetDlgItem (hwndDlg, IDC_CUSTOM_BOOT_LOADER_MESSAGE), EM_LIMITTEXT, TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH, 0);
- SetDlgItemText (hwndDlg, IDC_CUSTOM_BOOT_LOADER_MESSAGE, customUserMessage.c_str());
+ SetDlgItemTextA (hwndDlg, IDC_CUSTOM_BOOT_LOADER_MESSAGE, customUserMessage.c_str());
CheckDlgButton (hwndDlg, IDC_DISABLE_BOOT_LOADER_OUTPUT, (userConfig & TC_BOOT_USER_CFG_FLAG_SILENT_MODE) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton (hwndDlg, IDC_ALLOW_ESC_PBA_BYPASS, (userConfig & TC_BOOT_USER_CFG_FLAG_DISABLE_ESC) ? BST_UNCHECKED : BST_CHECKED);
@@ -10461,7 +10473,7 @@ static BOOL CALLBACK BootLoaderPreferencesDlgProc (HWND hwndDlg, UINT msg, WPARA
}
char customUserMessage[TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH + 1];
- GetDlgItemText (hwndDlg, IDC_CUSTOM_BOOT_LOADER_MESSAGE, customUserMessage, sizeof (customUserMessage));
+ GetDlgItemTextA (hwndDlg, IDC_CUSTOM_BOOT_LOADER_MESSAGE, customUserMessage, sizeof (customUserMessage));
byte userConfig;
try
@@ -10550,8 +10562,8 @@ void MountSelectedVolume (HWND hwndDlg, BOOL mountWithOptions)
if (mountOptions.ProtectHiddenVolume && hidVolProtKeyFilesParam.EnableKeyFiles)
{
- char selectedVolume [TC_MAX_PATH + 1];
- GetVolumePath (hwndDlg, selectedVolume, sizeof (selectedVolume));
+ wchar_t selectedVolume [TC_MAX_PATH + 1];
+ GetVolumePath (hwndDlg, selectedVolume, ARRAYSIZE (selectedVolume));
KeyFilesApply (hwndDlg, &mountOptions.ProtectedHidVolPassword, hidVolProtKeyFilesParam.FirstKeyFile, selectedVolume);
}
}
diff --git a/src/Mount/Mount.h b/src/Mount/Mount.h
index 1b32ae8..e01690c 100644
--- a/src/Mount/Mount.h
+++ b/src/Mount/Mount.h
@@ -73,7 +73,7 @@ void EnableDisableButtons ( HWND hwndDlg );
BOOL VolumeSelected (HWND hwndDlg );
void LoadSettings ( HWND hwndDlg );
void SaveSettings ( HWND hwndDlg );
-BOOL SelectItem ( HWND hTree , char nLetter );
+BOOL SelectItem ( HWND hTree , wchar_t nLetter );
void LoadDriveLetters ( HWND hwndDlg, HWND hTree, int drive );
BOOL CALLBACK PasswordChangeDlgProc ( HWND hwndDlg , UINT msg , WPARAM wParam , LPARAM lParam );
BOOL CALLBACK PasswordDlgProc ( HWND hwndDlg , UINT msg , WPARAM wParam , LPARAM lParam );
@@ -83,7 +83,7 @@ LPARAM GetSelectedLong ( HWND hTree );
LPARAM GetItemLong ( HWND hTree, int itemNo );
BOOL CALLBACK CommandHelpDlgProc ( HWND hwndDlg , UINT msg , WPARAM wParam , LPARAM lParam );
BOOL CALLBACK MainDialogProc ( HWND hwndDlg , UINT uMsg , WPARAM wParam , LPARAM lParam );
-void ExtractCommandLine ( HWND hwndDlg , char *lpszCommandLine );
+void ExtractCommandLine ( HWND hwndDlg , wchar_t *lpszCommandLine );
static void WipeCache (HWND hwndDlg, BOOL silent);
void OpenVolumeExplorerWindow (int driveNo);
BOOL TaskBarIconAdd (HWND hwnd);
@@ -101,11 +101,11 @@ int GetModeOfOperationByDriveNo (int nDosDriveNo);
void ChangeMainWindowVisibility ();
void LaunchVolCreationWizard (HWND hwndDlg);
BOOL WholeSysDriveEncryption (BOOL bSilent);
-BOOL CheckSysEncMountWithoutPBA (HWND hwndDlg, const char *devicePath, BOOL quiet);
-BOOL TCBootLoaderOnInactiveSysEncDrive (char *szDevicePath);
+BOOL CheckSysEncMountWithoutPBA (HWND hwndDlg, const wchar_t *devicePath, BOOL quiet);
+BOOL TCBootLoaderOnInactiveSysEncDrive (wchar_t *szDevicePath);
void CreateRescueDisk (HWND hwndDlg);
-int BackupVolumeHeader (HWND hwndDlg, BOOL bRequireConfirmation, const char *lpszVolume);
-int RestoreVolumeHeader (HWND hwndDlg, const char *lpszVolume);
+int BackupVolumeHeader (HWND hwndDlg, BOOL bRequireConfirmation, const wchar_t *lpszVolume);
+int RestoreVolumeHeader (HWND hwndDlg, const wchar_t *lpszVolume);
void SecurityTokenPreferencesDialog (HWND hwndDlg);
static BOOL CALLBACK PerformanceSettingsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
static BOOL CALLBACK BootLoaderPreferencesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
diff --git a/src/Mount/Mount.vcproj b/src/Mount/Mount.vcproj
index 1f8e6a6..58a199b 100644
--- a/src/Mount/Mount.vcproj
+++ b/src/Mount/Mount.vcproj
@@ -25,7 +25,7 @@
IntermediateDirectory="Debug"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- CharacterSet="2"
+ CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
@@ -111,12 +111,12 @@
/>
</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"
@@ -133,22 +133,26 @@
<Tool
Name="VCMIDLTool"
AdditionalIncludeDirectories=""
+ TargetEnvironment="3"
TypeLibraryName="$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb"
OutputDirectory=""
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalOptions="/w34189"
- Optimization="2"
+ Optimization="0"
AdditionalIncludeDirectories="..\Common;..\Crypto;..\;..\PKCS11"
- PreprocessorDefinitions="TCMOUNT;WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS"
- RuntimeLibrary="0"
+ PreprocessorDefinitions="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="4"
- DebugInformationFormat="0"
+ DebugInformationFormat="3"
DisableSpecificWarnings="4057;4100;4127;4201;4701;4706"
/>
<Tool
@@ -162,19 +166,17 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="comctl32.lib setupapi.lib version.lib ..\Crypto\Release\crypto.lib"
+ AdditionalDependencies="comctl32.lib setupapi.lib version.lib ..\Crypto\x64\Debug\crypto.lib"
OutputFile="$(OutDir)/VeraCrypt.exe"
- LinkIncremental="1"
+ LinkIncremental="2"
GenerateManifest="false"
IgnoreAllDefaultLibraries="false"
- GenerateDebugInformation="false"
- GenerateMapFile="true"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile="$(OutDir)/Mount.pdb"
SubSystem="2"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="2"
- TargetMachine="1"
+ TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
@@ -197,16 +199,16 @@
/>
<Tool
Name="VCPostBuildEventTool"
- CommandLine="copy Release\VeraCrypt.exe &quot;..\Release\Setup Files&quot;"
+ CommandLine="md &quot;..\Debug\Setup Files&quot; 2&gt;NUL:&#x0D;&#x0A;copy $(TargetPath) &quot;..\Debug\Setup Files\VeraCrypt-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"
@@ -223,26 +225,22 @@
<Tool
Name="VCMIDLTool"
AdditionalIncludeDirectories=""
- TargetEnvironment="3"
TypeLibraryName="$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb"
OutputDirectory=""
/>
<Tool
Name="VCCLCompilerTool"
- Optimization="0"
+ AdditionalOptions="/w34189"
+ Optimization="2"
AdditionalIncludeDirectories="..\Common;..\Crypto;..\;..\PKCS11"
- PreprocessorDefinitions="TCMOUNT;WIN32;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS"
- MinimalRebuild="true"
- ExceptionHandling="1"
- BasicRuntimeChecks="3"
- RuntimeLibrary="1"
+ PreprocessorDefinitions="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="4"
- DebugInformationFormat="3"
+ DebugInformationFormat="0"
DisableSpecificWarnings="4057;4100;4127;4201;4701;4706"
/>
<Tool
@@ -256,17 +254,19 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="comctl32.lib setupapi.lib version.lib ..\Crypto\x64\Debug\crypto.lib"
+ AdditionalDependencies="comctl32.lib setupapi.lib version.lib ..\Crypto\Release\crypto.lib"
OutputFile="$(OutDir)/VeraCrypt.exe"
- LinkIncremental="2"
+ LinkIncremental="1"
GenerateManifest="false"
IgnoreAllDefaultLibraries="false"
- GenerateDebugInformation="true"
- ProgramDatabaseFile="$(OutDir)/Mount.pdb"
+ GenerateDebugInformation="false"
+ GenerateMapFile="true"
SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="2"
- TargetMachine="17"
+ TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
@@ -289,7 +289,7 @@
/>
<Tool
Name="VCPostBuildEventTool"
- CommandLine="md &quot;..\Debug\Setup Files&quot; 2&gt;NUL:&#x0D;&#x0A;copy $(TargetPath) &quot;..\Debug\Setup Files\VeraCrypt-x64.exe&quot; &gt;NUL:&#x0D;&#x0A;"
+ CommandLine="copy Release\VeraCrypt.exe &quot;..\Release\Setup Files&quot;"
/>
</Configuration>
<Configuration
@@ -298,7 +298,7 @@
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- CharacterSet="2"
+ CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
@@ -420,7 +420,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Release|Win32"
+ Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
@@ -428,7 +428,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Debug|x64"
+ Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
@@ -483,7 +483,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Release|Win32"
+ Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
@@ -491,7 +491,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Debug|x64"
+ Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
@@ -519,7 +519,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Release|Win32"
+ Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
@@ -527,7 +527,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Debug|x64"
+ Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
@@ -567,7 +567,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Release|Win32"
+ Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
@@ -575,7 +575,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Debug|x64"
+ Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
@@ -777,6 +777,38 @@
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
+ RelativePath="..\Boot\Windows\Rescue_Serpent_SHA2\BootSector.bin"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Rescue_AES_SHA2\BootSector.bin"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Rescue_SHA2\BootSector.bin"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Release_Twofish_SHA2\BootSector.bin"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Release_Serpent_SHA2\BootSector.bin"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Release_AES_SHA2\BootSector.bin"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Release_SHA2\BootSector.bin"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Rescue_Twofish_SHA2\BootSector.bin"
+ >
+ </File>
+ <File
RelativePath=".\Drive_icon_96dpi.bmp"
>
</File>
@@ -824,35 +856,35 @@
Name="Common"
>
<File
- RelativePath="..\Boot\Windows\Release\BootLoader.com.gz"
+ RelativePath="..\Boot\Windows\Rescue_Twofish\BootLoader.com.gz"
>
</File>
<File
- RelativePath="..\Boot\Windows\Release_Twofish\BootLoader.com.gz"
+ RelativePath="..\Boot\Windows\Release_Serpent\BootLoader.com.gz"
>
</File>
<File
- RelativePath="..\Boot\Windows\Rescue_Serpent\BootLoader.com.gz"
+ RelativePath="..\Boot\Windows\Release_AES\BootLoader.com.gz"
>
</File>
<File
- RelativePath="..\Boot\Windows\Rescue_AES\BootLoader.com.gz"
+ RelativePath="..\Boot\Windows\Release\BootLoader.com.gz"
>
</File>
<File
- RelativePath="..\Boot\Windows\Rescue\BootLoader.com.gz"
+ RelativePath="..\Boot\Windows\Release_Twofish\BootLoader.com.gz"
>
</File>
<File
- RelativePath="..\Boot\Windows\Rescue_Twofish\BootLoader.com.gz"
+ RelativePath="..\Boot\Windows\Rescue_Serpent\BootLoader.com.gz"
>
</File>
<File
- RelativePath="..\Boot\Windows\Release_Serpent\BootLoader.com.gz"
+ RelativePath="..\Boot\Windows\Rescue_AES\BootLoader.com.gz"
>
</File>
<File
- RelativePath="..\Boot\Windows\Release_AES\BootLoader.com.gz"
+ RelativePath="..\Boot\Windows\Rescue\BootLoader.com.gz"
>
</File>
<File
@@ -899,7 +931,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Release|Win32"
+ Name="Debug|x64"
ExcludedFromBuild="true"
>
<Tool
@@ -907,7 +939,7 @@
/>
</FileConfiguration>
<FileConfiguration
- Name="Debug|x64"
+ Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
@@ -953,6 +985,38 @@
</File>
</Filter>
</Filter>
+ <File
+ RelativePath="..\Boot\Windows\Rescue_AES_SHA2\BootLoader.com.gz"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Rescue_Serpent_SHA2\BootLoader.com.gz"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Rescue_Twofish_SHA2\BootLoader.com.gz"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Release_SHA2\BootLoader.com.gz"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Release_AES_SHA2\BootLoader.com.gz"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Release_Serpent_SHA2\BootLoader.com.gz"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Release_Twofish_SHA2\BootLoader.com.gz"
+ >
+ </File>
+ <File
+ RelativePath="..\Boot\Windows\Rescue_SHA2\BootLoader.com.gz"
+ >
+ </File>
</Files>
<Globals>
</Globals>
diff --git a/src/Setup/ComSetup.cpp b/src/Setup/ComSetup.cpp
index 96bf42b..3a3687d 100644
--- a/src/Setup/ComSetup.cpp
+++ b/src/Setup/ComSetup.cpp
@@ -27,14 +27,14 @@
#include "../Format/FormatCom_i.c"
-extern "C" BOOL RegisterComServers (char *modulePath)
+extern "C" BOOL RegisterComServers (wchar_t *modulePath)
{
BOOL ret = TRUE;
wchar_t mainModule[1024], formatModule[1024];
CComPtr<ITypeLib> tl, tl2;
- wsprintfW (mainModule, L"%hsVeraCrypt.exe", modulePath);
- wsprintfW (formatModule, L"%hsVeraCrypt Format.exe", modulePath);
+ wsprintfW (mainModule, L"%sVeraCrypt.exe", modulePath);
+ wsprintfW (formatModule, L"%sVeraCrypt Format.exe", modulePath);
UnRegisterTypeLib (LIBID_TrueCryptMainCom, TC_MAIN_COM_VERSION_MAJOR, TC_MAIN_COM_VERSION_MINOR, 0, SYS_WIN32);
UnRegisterTypeLib (LIBID_TrueCryptFormatCom, TC_FORMAT_COM_VERSION_MAJOR, TC_FORMAT_COM_VERSION_MINOR, 0, SYS_WIN32);
@@ -58,7 +58,7 @@ extern "C" BOOL RegisterComServers (char *modulePath)
|| !SUCCEEDED (r = LoadTypeLib (formatModule, &tl2))
|| !SUCCEEDED (r = RegisterTypeLib (tl2, formatModule, 0)))
{
- MessageBox (MainDlg, _com_error (r).ErrorMessage(), TC_APP_NAME, MB_ICONERROR);
+ MessageBox (MainDlg, _com_error (r).ErrorMessage(), _T(TC_APP_NAME), MB_ICONERROR);
ret = FALSE;
}
@@ -67,7 +67,7 @@ extern "C" BOOL RegisterComServers (char *modulePath)
}
-extern "C" BOOL UnregisterComServers (char *modulePath)
+extern "C" BOOL UnregisterComServers (wchar_t *modulePath)
{
BOOL ret;
@@ -85,10 +85,10 @@ extern "C" BOOL UnregisterComServers (char *modulePath)
CRegObject ro;
ro.FinalConstruct ();
- wsprintfW (module, L"%hsVeraCrypt.exe", modulePath);
+ wsprintfW (module, L"%sVeraCrypt.exe", modulePath);
ro.AddReplacement (L"MAIN_MODULE", module);
- wsprintfW (module, L"%hsVeraCrypt Format.exe", modulePath);
+ wsprintfW (module, L"%sVeraCrypt Format.exe", modulePath);
ro.AddReplacement (L"FORMAT_MODULE", module);
wchar_t setupModule[MAX_PATH];
diff --git a/src/Setup/ComSetup.h b/src/Setup/ComSetup.h
index 0c1f4d2..c0928c8 100644
--- a/src/Setup/ComSetup.h
+++ b/src/Setup/ComSetup.h
@@ -14,8 +14,8 @@
extern "C" {
#endif
-BOOL RegisterComServers (char *modulePath);
-BOOL UnregisterComServers (char *modulePath);
+BOOL RegisterComServers (wchar_t *modulePath);
+BOOL UnregisterComServers (wchar_t *modulePath);
#ifdef __cplusplus
}
diff --git a/src/Setup/Dir.c b/src/Setup/Dir.c
index 2733d5c..07ababa 100644
--- a/src/Setup/Dir.c
+++ b/src/Setup/Dir.c
@@ -25,33 +25,33 @@
/* create full directory tree. returns 0 for success, -1 if failure */
int
-mkfulldir (char *oriPath, BOOL bCheckonly)
+mkfulldir (wchar_t *oriPath, BOOL bCheckonly)
{
struct _stat st;
- char *uniq_file;
- char path [TC_MAX_PATH];
+ wchar_t *uniq_file;
+ wchar_t path [TC_MAX_PATH];
- StringCbCopyA (path, TC_MAX_PATH, oriPath);
+ StringCbCopyW (path, TC_MAX_PATH, oriPath);
- if (strlen (path) == 3 && path[1] == ':')
+ if (wcslen (path) == 3 && path[1] == L':')
goto is_root; /* keep final slash in root if present */
/* strip final forward or backslash if we have one! */
- uniq_file = strrchr (path, '\\');
- if (uniq_file && uniq_file[1] == '\0')
- uniq_file[0] = '\0';
+ uniq_file = wcsrchr (path, L'\\');
+ if (uniq_file && uniq_file[1] == L'\0')
+ uniq_file[0] = L'\0';
else
{
- uniq_file = strrchr (path, '/');
- if (uniq_file && uniq_file[1] == '\0')
- uniq_file[0] = '\0';
+ uniq_file = wcsrchr (path, L'/');
+ if (uniq_file && uniq_file[1] == L'\0')
+ uniq_file[0] = L'\0';
}
is_root:
if (bCheckonly)
- return _stat (path, &st);
+ return _wstat (path, &st);
- if (_stat (path, &st))
+ if (_wstat (path, &st))
return mkfulldir_internal (path);
else
return 0;
@@ -59,52 +59,52 @@ mkfulldir (char *oriPath, BOOL bCheckonly)
int
-mkfulldir_internal (char *path)
+mkfulldir_internal (wchar_t *path)
{
- char *token;
+ wchar_t *token;
struct _stat st;
- static char tokpath[_MAX_PATH];
- static char trail[_MAX_PATH];
+ static wchar_t tokpath[_MAX_PATH];
+ static wchar_t trail[_MAX_PATH];
- StringCbCopyA (tokpath, _MAX_PATH, path);
- trail[0] = '\0';
+ StringCbCopyW (tokpath, _MAX_PATH, path);
+ trail[0] = L'\0';
- token = strtok (tokpath, "\\/");
+ token = wcstok (tokpath, L"\\/");
- if (tokpath[0] == '\\' && tokpath[1] == '\\')
+ if (tokpath[0] == L'\\' && tokpath[1] == L'\\')
{ /* unc */
trail[0] = tokpath[0];
trail[1] = tokpath[1];
- trail[2] = '\0';
+ trail[2] = L'\0';
if (token)
{
- StringCbCatA (trail, _MAX_PATH, token);
- StringCbCatA (trail, _MAX_PATH, "\\");
- token = strtok (NULL, "\\/");
+ StringCbCatW (trail, _MAX_PATH, token);
+ StringCbCatW (trail, _MAX_PATH, L"\\");
+ token = wcstok (NULL, L"\\/");
if (token)
{ /* get share name */
- StringCbCatA (trail, _MAX_PATH, token);
- StringCbCatA (trail, _MAX_PATH, "\\");
+ StringCbCatW (trail, _MAX_PATH, token);
+ StringCbCatW (trail, _MAX_PATH, L"\\");
}
- token = strtok (NULL, "\\/");
+ token = wcstok (NULL, L"\\/");
}
}
- if (tokpath[1] == ':')
+ if (tokpath[1] == L':')
{ /* drive letter */
- StringCbCatA (trail, _MAX_PATH, tokpath);
- StringCbCatA (trail, _MAX_PATH, "\\");
- token = strtok (NULL, "\\/");
+ StringCbCatW (trail, _MAX_PATH, tokpath);
+ StringCbCatW (trail, _MAX_PATH, L"\\");
+ token = wcstok (NULL, L"\\/");
}
while (token != NULL)
{
int x;
- StringCbCatA (trail, _MAX_PATH, token);
- x = _mkdir (trail);
- StringCbCatA (trail, _MAX_PATH, "\\");
- token = strtok (NULL, "\\/");
+ StringCbCatW (trail, _MAX_PATH, token);
+ x = _wmkdir (trail);
+ StringCbCatW (trail, _MAX_PATH, L"\\");
+ token = wcstok (NULL, L"\\/");
}
- return _stat (path, &st);
+ return _wstat (path, &st);
}
diff --git a/src/Setup/Dir.h b/src/Setup/Dir.h
index 1e4177b..2f518f7 100644
--- a/src/Setup/Dir.h
+++ b/src/Setup/Dir.h
@@ -15,8 +15,8 @@
extern "C" {
#endif
-int mkfulldir ( char *path , BOOL bCheckonly );
-int mkfulldir_internal ( char *path );
+int mkfulldir ( wchar_t *path , BOOL bCheckonly );
+int mkfulldir_internal ( wchar_t *path );
#ifdef __cplusplus
}
diff --git a/src/Setup/SelfExtract.c b/src/Setup/SelfExtract.c
index 7cb07b4..8486ef9 100644
--- a/src/Setup/SelfExtract.c
+++ b/src/Setup/SelfExtract.c
@@ -22,20 +22,21 @@
#include "Dir.h"
#include "Language.h"
#include "Resource.h"
+#include <tchar.h>
#include <Strsafe.h>
#ifndef SRC_POS
#define SRC_POS (__FUNCTION__ ":" TC_TO_STRING(__LINE__))
#endif
-#define OutputPackageFile "VeraCrypt Setup " VERSION_STRING ".exe"
+#define OutputPackageFile L"VeraCrypt Setup " _T(VERSION_STRING) L".exe"
#define MAG_START_MARKER "TCINSTRT"
#define MAG_END_MARKER_OBFUSCATED "T/C/I/N/S/C/R/C"
#define PIPE_BUFFER_LEN (4 * BYTES_PER_KB)
unsigned char MagEndMarker [sizeof (MAG_END_MARKER_OBFUSCATED)];
-char DestExtractPath [TC_MAX_PATH];
+wchar_t DestExtractPath [TC_MAX_PATH];
DECOMPRESSED_FILE Decompressed_Files [NBR_COMPRESSED_FILES];
volatile char *PipeWriteBuf = NULL;
@@ -64,21 +65,21 @@ static void DeobfuscateMagEndMarker (void)
}
-static void PkgError (char *msg)
+static void PkgError (wchar_t *msg)
{
- MessageBox (NULL, msg, "VeraCrypt", MB_ICONERROR | MB_SETFOREGROUND | MB_TOPMOST);
+ MessageBox (NULL, msg, L"VeraCrypt", MB_ICONERROR | MB_SETFOREGROUND | MB_TOPMOST);
}
-static void PkgWarning (char *msg)
+static void PkgWarning (wchar_t *msg)
{
- MessageBox (NULL, msg, "VeraCrypt", MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST);
+ MessageBox (NULL, msg, L"VeraCrypt", MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST);
}
-static void PkgInfo (char *msg)
+static void PkgInfo (wchar_t *msg)
{
- MessageBox (NULL, msg, "VeraCrypt", MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TOPMOST);
+ MessageBox (NULL, msg, L"VeraCrypt", MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TOPMOST);
}
@@ -96,7 +97,7 @@ static void __cdecl PipeWriteThread (void *len)
if (PipeWriteBuf == NULL || (HANDLE) hChildStdinWrite == INVALID_HANDLE_VALUE)
{
- PkgError ("Failed sending data to the STDIN pipe");
+ PkgError (L"Failed sending data to the STDIN pipe");
return;
}
@@ -109,7 +110,7 @@ static void __cdecl PipeWriteThread (void *len)
|| bytesSent == 0
|| bytesSent != sendBufSize)
{
- PkgError ("Failed sending data to the STDIN pipe");
+ PkgError (L"Failed sending data to the STDIN pipe");
return;
}
@@ -121,7 +122,7 @@ static void __cdecl PipeWriteThread (void *len)
if (!CloseHandle (hChildStdinWrite))
{
- PkgError ("Cannot close pipe");
+ PkgError (L"Cannot close pipe");
return;
}
}
@@ -140,6 +141,7 @@ static int CompressBuffer (char *out, char *in, int len)
char pipeBuffer [PIPE_BUFFER_LEN];
int res_len = 0;
BOOL bGzipHeaderRead = FALSE;
+ wchar_t szGzipCmd[64];
ZeroMemory (&startupInfo, sizeof (startupInfo));
ZeroMemory (&procInfo, sizeof (procInfo));
@@ -151,14 +153,14 @@ static int CompressBuffer (char *out, char *in, int len)
if (!CreatePipe (&hChildStdoutRead, &hChildStdoutWrite, &securityAttrib, 0))
{
- PkgError ("Cannot create STDOUT pipe.");
+ PkgError (L"Cannot create STDOUT pipe.");
return 0;
}
SetHandleInformation (hChildStdoutRead, HANDLE_FLAG_INHERIT, 0);
if (!CreatePipe (&hChildStdinRead, &((HANDLE) hChildStdinWrite), &securityAttrib, 0))
{
- PkgError ("Cannot create STDIN pipe.");
+ PkgError (L"Cannot create STDIN pipe.");
CloseHandle(hChildStdoutWrite);
CloseHandle(hChildStdoutRead);
return 0;
@@ -174,9 +176,10 @@ static int CompressBuffer (char *out, char *in, int len)
startupInfo.hStdError = hChildStdoutWrite;
startupInfo.dwFlags |= STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
- if (!CreateProcess (NULL, "gzip --best", NULL, NULL, TRUE, 0, NULL, NULL, &startupInfo, &procInfo))
+ StringCbCopyW (szGzipCmd, sizeof (szGzipCmd), L"gzip --best");
+ if (!CreateProcess (NULL, szGzipCmd, NULL, NULL, TRUE, 0, NULL, NULL, &startupInfo, &procInfo))
{
- PkgError ("Error: Cannot run gzip.\n\nBefore you can create a self-extracting VeraCrypt package, you need to have the open-source 'gzip' compression tool placed in any directory in the search path for executable files (for example, in 'C:\\Windows\\').\n\nNote: gzip can be freely downloaded e.g. from www.gzip.org");
+ PkgError (L"Error: Cannot run gzip.\n\nBefore you can create a self-extracting VeraCrypt package, you need to have the open-source 'gzip' compression tool placed in any directory in the search path for executable files (for example, in 'C:\\Windows\\').\n\nNote: gzip can be freely downloaded e.g. from www.gzip.org");
CloseHandle(hChildStdoutWrite);
CloseHandle(hChildStdoutRead);
CloseHandle(hChildStdinRead);
@@ -193,7 +196,7 @@ static int CompressBuffer (char *out, char *in, int len)
if (!CloseHandle (hChildStdoutWrite))
{
- PkgError ("Cannot close STDOUT write");
+ PkgError (L"Cannot close STDOUT write");
CloseHandle(hChildStdoutRead);
CloseHandle(hChildStdinRead);
return 0;
@@ -231,37 +234,37 @@ static void WipeSignatureAreas (char *buffer)
}
-BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
+BOOL MakeSelfExtractingPackage (HWND hwndDlg, wchar_t *szDestDir)
{
int i, x;
- unsigned char inputFile [TC_MAX_PATH];
- unsigned char outputFile [TC_MAX_PATH];
- unsigned char szTmpFilePath [TC_MAX_PATH];
+ wchar_t inputFile [TC_MAX_PATH];
+ wchar_t outputFile [TC_MAX_PATH];
+ wchar_t szTmpFilePath [TC_MAX_PATH];
unsigned char szTmp32bit [4] = {0};
unsigned char *szTmp32bitPtr = szTmp32bit;
unsigned char *buffer = NULL, *compressedBuffer = NULL;
unsigned char *bufIndex = NULL;
- char tmpStr [2048];
+ wchar_t tmpStr [2048];
int bufLen = 0, compressedDataLen = 0, uncompressedDataLen = 0;
- x = strlen (szDestDir);
+ x = wcslen (szDestDir);
if (x < 2)
goto err;
- if (szDestDir[x - 1] != '\\')
- StringCbCatA (szDestDir, MAX_PATH, "\\");
+ if (szDestDir[x - 1] != L'\\')
+ StringCbCatW (szDestDir, MAX_PATH, L"\\");
- GetModuleFileName (NULL, inputFile, sizeof (inputFile));
+ GetModuleFileName (NULL, inputFile, ARRAYSIZE (inputFile));
- StringCbCopyA (outputFile, sizeof(outputFile), szDestDir);
- StringCbCatA (outputFile, sizeof(outputFile), OutputPackageFile);
+ StringCbCopyW (outputFile, sizeof(outputFile), szDestDir);
+ StringCbCatW (outputFile, sizeof(outputFile), OutputPackageFile);
// Clone 'VeraCrypt Setup.exe' to create the base of the new self-extracting archive
if (!TCCopyFile (inputFile, outputFile))
{
handleWin32Error (hwndDlg, SRC_POS);
- PkgError ("Cannot copy 'VeraCrypt Setup.exe' to the package");
+ PkgError (L"Cannot copy 'VeraCrypt Setup.exe' to the package");
goto err;
}
@@ -271,15 +274,15 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
for (i = 0; i < sizeof (szCompressedFiles) / sizeof (szCompressedFiles[0]); i++)
{
- StringCbPrintfA (szTmpFilePath, sizeof(szTmpFilePath), "%s%s", szDestDir, szCompressedFiles[i]);
+ StringCbPrintfW (szTmpFilePath, sizeof(szTmpFilePath), L"%s%s", szDestDir, szCompressedFiles[i]);
if (!FileExists (szTmpFilePath))
{
- char tmpstr [1000];
+ wchar_t tmpstr [1000];
- StringCbPrintfA (tmpstr, sizeof(tmpstr), "File not found:\n\n'%s'", szTmpFilePath);
- if (remove (outputFile))
- StringCbCatA (tmpstr, sizeof(tmpstr), "\nFailed also to delete package file");
+ StringCbPrintfW (tmpstr, sizeof(tmpstr), L"File not found:\n\n'%s'", szTmpFilePath);
+ if (_wremove (outputFile))
+ StringCbCatW (tmpstr, sizeof(tmpstr), L"\nFailed also to delete package file");
PkgError (tmpstr);
goto err;
}
@@ -287,7 +290,7 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
bufLen += (int) GetFileSize64 (szTmpFilePath);
bufLen += 2; // 16-bit filename length
- bufLen += strlen(szCompressedFiles[i]); // Filename
+ bufLen += (wcslen(szCompressedFiles[i]) * sizeof (wchar_t)); // Filename
bufLen += 4; // CRC-32
bufLen += 4; // 32-bit file length
}
@@ -295,11 +298,11 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
buffer = malloc (bufLen + 524288); // + 512K reserve
if (buffer == NULL)
{
- PkgError ("Cannot allocate memory for uncompressed data");
- if (remove (outputFile))
- PkgError ("Cannot allocate memory for uncompressed data.\nFailed also to delete package file");
+ PkgError (L"Cannot allocate memory for uncompressed data");
+ if (_wremove (outputFile))
+ PkgError (L"Cannot allocate memory for uncompressed data.\nFailed also to delete package file");
else
- PkgError ("Cannot allocate memory for uncompressed data");
+ PkgError (L"Cannot allocate memory for uncompressed data");
goto err;
}
@@ -307,10 +310,10 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
// Write the start marker
if (!SaveBufferToFile (MAG_START_MARKER, outputFile, strlen (MAG_START_MARKER), TRUE, FALSE))
{
- if (remove (outputFile))
- PkgError ("Cannot write the start marker\nFailed also to delete package file");
+ if (_wremove (outputFile))
+ PkgError (L"Cannot write the start marker\nFailed also to delete package file");
else
- PkgError ("Cannot write the start marker");
+ PkgError (L"Cannot write the start marker");
goto err;
}
@@ -323,28 +326,27 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
DWORD tmpFileSize;
unsigned char *tmpBuffer;
- StringCbPrintfA (szTmpFilePath, sizeof(szTmpFilePath), "%s%s", szDestDir, szCompressedFiles[i]);
+ StringCbPrintfW (szTmpFilePath, sizeof(szTmpFilePath), L"%s%s", szDestDir, szCompressedFiles[i]);
tmpBuffer = LoadFile (szTmpFilePath, &tmpFileSize);
if (tmpBuffer == NULL)
{
- char tmpstr [1000];
+ wchar_t tmpstr [1000];
- free (tmpBuffer);
- StringCbPrintfA (tmpstr, sizeof(tmpstr), "Cannot load file \n'%s'", szTmpFilePath);
- if (remove (outputFile))
- StringCbCatA (tmpstr, sizeof(tmpstr), "\nFailed also to delete package file");
+ StringCbPrintfW (tmpstr, sizeof(tmpstr), L"Cannot load file \n'%s'", szTmpFilePath);
+ if (_wremove (outputFile))
+ StringCbCatW (tmpstr, sizeof(tmpstr), L"\nFailed also to delete package file");
PkgError (tmpstr);
goto err;
}
// Copy the filename length to the main buffer
- mputWord (bufIndex, (WORD) strlen(szCompressedFiles[i]));
+ mputWord (bufIndex, (WORD) wcslen(szCompressedFiles[i]));
// Copy the filename to the main buffer
- memcpy (bufIndex, szCompressedFiles[i], strlen(szCompressedFiles[i]));
- bufIndex += strlen(szCompressedFiles[i]);
+ wmemcpy ((wchar_t*)bufIndex, szCompressedFiles[i], wcslen(szCompressedFiles[i]));
+ bufIndex += (wcslen(szCompressedFiles[i]) * sizeof (wchar_t));
// Compute CRC-32 hash of the uncompressed file and copy it to the main buffer
mputLong (bufIndex, GetCrc32 (tmpBuffer, tmpFileSize));
@@ -367,10 +369,10 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
mputLong (szTmp32bitPtr, (unsigned __int32) uncompressedDataLen);
if (!SaveBufferToFile (szTmp32bit, outputFile, sizeof (szTmp32bit), TRUE, FALSE))
{
- if (remove (outputFile))
- PkgError ("Cannot write the total size of the uncompressed data.\nFailed also to delete package file");
+ if (_wremove (outputFile))
+ PkgError (L"Cannot write the total size of the uncompressed data.\nFailed also to delete package file");
else
- PkgError ("Cannot write the total size of the uncompressed data");
+ PkgError (L"Cannot write the total size of the uncompressed data");
goto err;
}
@@ -379,20 +381,20 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
compressedBuffer = malloc (uncompressedDataLen + 524288); // + 512K reserve
if (compressedBuffer == NULL)
{
- if (remove (outputFile))
- PkgError ("Cannot allocate memory for compressed data.\nFailed also to delete package file");
+ if (_wremove (outputFile))
+ PkgError (L"Cannot allocate memory for compressed data.\nFailed also to delete package file");
else
- PkgError ("Cannot allocate memory for compressed data");
+ PkgError (L"Cannot allocate memory for compressed data");
goto err;
}
compressedDataLen = CompressBuffer (compressedBuffer, buffer, uncompressedDataLen);
if (compressedDataLen <= 0)
{
- if (remove (outputFile))
- PkgError ("Failed to compress the data.\nFailed also to delete package file");
+ if (_wremove (outputFile))
+ PkgError (L"Failed to compress the data.\nFailed also to delete package file");
else
- PkgError ("Failed to compress the data");
+ PkgError (L"Failed to compress the data");
goto err;
}
@@ -404,30 +406,30 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
mputLong (szTmp32bitPtr, (unsigned __int32) compressedDataLen);
if (!SaveBufferToFile (szTmp32bit, outputFile, sizeof (szTmp32bit), TRUE, FALSE))
{
- if (remove (outputFile))
- PkgError ("Cannot write the total size of the compressed data.\nFailed also to delete package file");
+ if (_wremove (outputFile))
+ PkgError (L"Cannot write the total size of the compressed data.\nFailed also to delete package file");
else
- PkgError ("Cannot write the total size of the compressed data");
+ PkgError (L"Cannot write the total size of the compressed data");
goto err;
}
// Write the compressed data
if (!SaveBufferToFile (compressedBuffer, outputFile, compressedDataLen, TRUE, FALSE))
{
- if (remove (outputFile))
- PkgError ("Cannot write compressed data to the package.\nFailed also to delete package file");
+ if (_wremove (outputFile))
+ PkgError (L"Cannot write compressed data to the package.\nFailed also to delete package file");
else
- PkgError ("Cannot write compressed data to the package");
+ PkgError (L"Cannot write compressed data to the package");
goto err;
}
// Write the end marker
if (!SaveBufferToFile (MagEndMarker, outputFile, strlen (MagEndMarker), TRUE, FALSE))
{
- if (remove (outputFile))
- PkgError ("Cannot write the end marker.\nFailed also to delete package file");
+ if (_wremove (outputFile))
+ PkgError (L"Cannot write the end marker.\nFailed also to delete package file");
else
- PkgError ("Cannot write the end marker");
+ PkgError (L"Cannot write the end marker");
goto err;
}
@@ -444,10 +446,10 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
if (tmpBuffer == NULL)
{
handleWin32Error (hwndDlg, SRC_POS);
- if (remove (outputFile))
- PkgError ("Cannot load the package to compute CRC.\nFailed also to delete package file");
+ if (_wremove (outputFile))
+ PkgError (L"Cannot load the package to compute CRC.\nFailed also to delete package file");
else
- PkgError ("Cannot load the package to compute CRC");
+ PkgError (L"Cannot load the package to compute CRC");
goto err;
}
@@ -460,15 +462,15 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
if (!SaveBufferToFile (szTmp32bit, outputFile, sizeof (szTmp32bit), TRUE, FALSE))
{
- if (remove (outputFile))
- PkgError ("Cannot write the total size of the compressed data.\nFailed also to delete package file");
+ if (_wremove (outputFile))
+ PkgError (L"Cannot write the total size of the compressed data.\nFailed also to delete package file");
else
- PkgError ("Cannot write the total size of the compressed data");
+ PkgError (L"Cannot write the total size of the compressed data");
goto err;
}
}
- StringCbPrintfA (tmpStr, sizeof(tmpStr), "Self-extracting package successfully created (%s)", outputFile);
+ StringCbPrintfW (tmpStr, sizeof(tmpStr), L"Self-extracting package successfully created (%s)", outputFile);
PkgInfo (tmpStr);
return TRUE;
@@ -490,9 +492,9 @@ BOOL VerifyPackageIntegrity (void)
unsigned __int32 crc = 0;
unsigned char *tmpBuffer;
int tmpFileSize;
- char path [TC_MAX_PATH];
+ wchar_t path [TC_MAX_PATH];
- GetModuleFileName (NULL, path, sizeof (path));
+ GetModuleFileName (NULL, path, ARRAYSIZE (path));
fileDataEndPos = (int) FindStringInFile (path, MagEndMarker, strlen (MagEndMarker));
if (fileDataEndPos < 0)
@@ -545,9 +547,9 @@ BOOL VerifyPackageIntegrity (void)
// Determines whether we are a self-extracting package
BOOL IsSelfExtractingPackage (void)
{
- char path [TC_MAX_PATH];
+ wchar_t path [TC_MAX_PATH];
- GetModuleFileName (NULL, path, sizeof (path));
+ GetModuleFileName (NULL, path, ARRAYSIZE (path));
return (FindStringInFile (path, MagEndMarker, strlen (MagEndMarker)) != -1);
}
@@ -578,7 +580,7 @@ static void FreeAllFileBuffers (void)
// Creates a table of pointers to buffers containing the following objects for each file:
// filename size, filename (not null-terminated!), file size, file CRC-32, uncompressed file contents.
// For details, see the definition of the DECOMPRESSED_FILE structure.
-BOOL SelfExtractInMemory (char *path)
+BOOL SelfExtractInMemory (wchar_t *path)
{
int filePos = 0, fileNo = 0;
int fileDataEndPos = 0;
@@ -667,8 +669,8 @@ BOOL SelfExtractInMemory (char *path)
Decompressed_Files[fileNo].fileNameLength = mgetWord (bufPos);
// Filename
- Decompressed_Files[fileNo].fileName = bufPos;
- bufPos += Decompressed_Files[fileNo].fileNameLength;
+ Decompressed_Files[fileNo].fileName = (wchar_t*) bufPos;
+ bufPos += (Decompressed_Files[fileNo].fileNameLength * sizeof (wchar_t));
// CRC-32 of the file
Decompressed_Files[fileNo].crc = mgetLong (bufPos);
@@ -711,13 +713,13 @@ void __cdecl ExtractAllFilesThread (void *hwndDlg)
{
int fileNo;
BOOL bSuccess = FALSE;
- char packageFile [TC_MAX_PATH];
+ wchar_t packageFile [TC_MAX_PATH];
InvalidateRect (GetDlgItem (GetParent (hwndDlg), IDD_INSTL_DLG), NULL, TRUE);
ClearLogWindow (hwndDlg);
- GetModuleFileName (NULL, packageFile, sizeof (packageFile));
+ GetModuleFileName (NULL, packageFile, ARRAYSIZE (packageFile));
if (!(bSuccess = SelfExtractInMemory (packageFile)))
goto eaf_end;
@@ -738,13 +740,13 @@ void __cdecl ExtractAllFilesThread (void *hwndDlg)
for (fileNo = 0; fileNo < NBR_COMPRESSED_FILES; fileNo++)
{
- char fileName [TC_MAX_PATH] = {0};
- char filePath [TC_MAX_PATH] = {0};
+ wchar_t fileName [TC_MAX_PATH] = {0};
+ wchar_t filePath [TC_MAX_PATH] = {0};
// Filename
- StringCbCopyNA (fileName, sizeof(fileName), Decompressed_Files[fileNo].fileName, Decompressed_Files[fileNo].fileNameLength);
- StringCbCopyA (filePath, sizeof(filePath), DestExtractPath);
- StringCbCatA (filePath, sizeof(filePath), fileName);
+ StringCchCopyNW (fileName, ARRAYSIZE(fileName), Decompressed_Files[fileNo].fileName, Decompressed_Files[fileNo].fileNameLength);
+ StringCbCopyW (filePath, sizeof(filePath), DestExtractPath);
+ StringCbCatW (filePath, sizeof(filePath), fileName);
StatusMessageParam (hwndDlg, "EXTRACTING_VERB", filePath);
diff --git a/src/Setup/SelfExtract.h b/src/Setup/SelfExtract.h
index b1269c9..76d81f2 100644
--- a/src/Setup/SelfExtract.h
+++ b/src/Setup/SelfExtract.h
@@ -19,7 +19,7 @@ extern "C" {
typedef struct
{
// WARNING: file name is NOT null-terminated (use fileNameLength).
- unsigned char *fileName;
+ wchar_t *fileName;
int fileNameLength;
uint32 crc;
__int32 fileLength;
@@ -29,14 +29,14 @@ typedef struct
extern DECOMPRESSED_FILE Decompressed_Files [NBR_COMPRESSED_FILES];
void SelfExtractStartupInit (void);
-BOOL SelfExtractInMemory (char *path);
+BOOL SelfExtractInMemory (wchar_t *path);
void __cdecl ExtractAllFilesThread (void *hwndDlg);
-BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir);
+BOOL MakeSelfExtractingPackage (HWND hwndDlg, wchar_t *szDestDir);
BOOL VerifyPackageIntegrity (void);
BOOL IsSelfExtractingPackage (void);
static void DeobfuscateMagEndMarker (void);
-extern char DestExtractPath [TC_MAX_PATH];
+extern wchar_t DestExtractPath [TC_MAX_PATH];
#ifdef __cplusplus
}
diff --git a/src/Setup/Setup.c b/src/Setup/Setup.c
index 1b2042b..fd6d891 100644
--- a/src/Setup/Setup.c
+++ b/src/Setup/Setup.c
@@ -18,6 +18,7 @@
#include <propvarutil.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <tchar.h>
#include "Apidrvr.h"
#include "BootEncryption.h"
@@ -48,9 +49,9 @@ using namespace VeraCrypt;
#include <Strsafe.h>
-char InstallationPath[TC_MAX_PATH];
-char SetupFilesDir[TC_MAX_PATH];
-char UninstallBatch[MAX_PATH];
+wchar_t InstallationPath[TC_MAX_PATH];
+wchar_t SetupFilesDir[TC_MAX_PATH];
+wchar_t UninstallBatch[MAX_PATH];
BOOL bUninstall = FALSE;
BOOL bRestartRequired = FALSE;
@@ -88,40 +89,40 @@ void localcleanup (void)
CloseAppSetupMutex ();
}
-BOOL StatDeleteFile (char *lpszFile, BOOL bCheckForOldFile)
+BOOL StatDeleteFile (wchar_t *lpszFile, BOOL bCheckForOldFile)
{
struct __stat64 st;
if (bCheckForOldFile)
{
- char szOldPath[MAX_PATH + 1];
- StringCbCopyA (szOldPath, sizeof(szOldPath), lpszFile);
- StringCbCatA (szOldPath, sizeof(szOldPath), VC_FILENAME_RENAMED_SUFFIX);
+ wchar_t szOldPath[MAX_PATH + 1];
+ StringCbCopyW (szOldPath, sizeof(szOldPath), lpszFile);
+ StringCbCatW (szOldPath, sizeof(szOldPath), VC_FILENAME_RENAMED_SUFFIX);
- if (_stat64 (szOldPath, &st) == 0)
+ if (_wstat64 (szOldPath, &st) == 0)
DeleteFile (szOldPath);
}
- if (_stat64 (lpszFile, &st) == 0)
+ if (_wstat64 (lpszFile, &st) == 0)
return DeleteFile (lpszFile);
else
return TRUE;
}
-BOOL StatRemoveDirectory (char *lpszDir)
+BOOL StatRemoveDirectory (wchar_t *lpszDir)
{
struct __stat64 st;
- if (_stat64 (lpszDir, &st) == 0)
+ if (_wstat64 (lpszDir, &st) == 0)
{
BOOL bStatus = RemoveDirectory (lpszDir);
if (!bStatus)
{
/* force removal of the non empty directory */
- char szOpPath[TC_MAX_PATH + 1] = {0};
- SHFILEOPSTRUCTA op;
+ wchar_t szOpPath[TC_MAX_PATH + 1] = {0};
+ SHFILEOPSTRUCTW op;
- StringCbCopyA(szOpPath, sizeof(szOpPath)-1, lpszDir);
+ StringCchCopyW(szOpPath, ARRAYSIZE(szOpPath)-1, lpszDir);
ZeroMemory(&op, sizeof(op));
op.wFunc = FO_DELETE;
op.pFrom = szOpPath;
@@ -149,14 +150,14 @@ static void RecursiveSetOwner (HKEY hKey, PSECURITY_DESCRIPTOR pSD)
)
{
dwMaxNameLen++;
- char* szNameValue = new char[dwMaxNameLen];
+ wchar_t* szNameValue = new wchar_t[dwMaxNameLen];
while (true)
{
dwNameLen = dwMaxNameLen;
- status = RegEnumKeyExA (hKey, dwIndex++, szNameValue, &dwNameLen, NULL, NULL, NULL, NULL);
+ status = RegEnumKeyExW (hKey, dwIndex++, szNameValue, &dwNameLen, NULL, NULL, NULL, NULL);
if (status == ERROR_SUCCESS)
{
- status = RegOpenKeyExA (hKey, szNameValue, 0, WRITE_OWNER | KEY_READ , &hSubKey);
+ status = RegOpenKeyExW (hKey, szNameValue, 0, WRITE_OWNER | KEY_READ , &hSubKey);
if (ERROR_SUCCESS == status)
{
RecursiveSetOwner (hSubKey, pSD);
@@ -173,31 +174,31 @@ static void RecursiveSetOwner (HKEY hKey, PSECURITY_DESCRIPTOR pSD)
}
/* Recursively set the given DACL security descriptor to the key and its subkeys */
-static void RecursiveSetDACL (HKEY hKey, const char* SubKeyName, PSECURITY_DESCRIPTOR pSD)
+static void RecursiveSetDACL (HKEY hKey, const wchar_t* SubKeyName, PSECURITY_DESCRIPTOR pSD)
{
HKEY hSubKey;
DWORD dwIndex = 0, dwMaxNameLen = 0, dwNameLen = 0, numberSubKeys = 0;
- LSTATUS status = RegOpenKeyExA(hKey, SubKeyName, 0, WRITE_DAC | KEY_READ /*| ACCESS_SYSTEM_SECURITY*/, &hSubKey);
+ LSTATUS status = RegOpenKeyExW(hKey, SubKeyName, 0, WRITE_DAC | KEY_READ /*| ACCESS_SYSTEM_SECURITY*/, &hSubKey);
if (status == ERROR_SUCCESS)
{
status = RegSetKeySecurity (hSubKey, DACL_SECURITY_INFORMATION, pSD);
if (status == ERROR_SUCCESS)
{
RegCloseKey(hSubKey);
- status = RegOpenKeyExA(hKey, SubKeyName, 0, WRITE_DAC | KEY_READ , &hSubKey);
+ status = RegOpenKeyExW(hKey, SubKeyName, 0, WRITE_DAC | KEY_READ , &hSubKey);
}
if ( (ERROR_SUCCESS == status)
- && (ERROR_SUCCESS == RegQueryInfoKeyA(hSubKey, NULL, NULL, NULL, &numberSubKeys, &dwMaxNameLen, NULL, NULL, NULL, NULL, NULL, NULL))
+ && (ERROR_SUCCESS == RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, &numberSubKeys, &dwMaxNameLen, NULL, NULL, NULL, NULL, NULL, NULL))
&& (numberSubKeys >= 1)
)
{
dwMaxNameLen++;
- char* szNameValue = new char[dwMaxNameLen];
+ wchar_t* szNameValue = new wchar_t[dwMaxNameLen];
while (true)
{
dwNameLen = dwMaxNameLen;
- status = RegEnumKeyExA (hSubKey, dwIndex++, szNameValue, &dwNameLen, NULL, NULL, NULL, NULL);
+ status = RegEnumKeyExW (hSubKey, dwIndex++, szNameValue, &dwNameLen, NULL, NULL, NULL, NULL);
if (status == ERROR_SUCCESS)
{
RecursiveSetDACL (hSubKey, szNameValue, pSD);
@@ -211,7 +212,7 @@ static void RecursiveSetDACL (HKEY hKey, const char* SubKeyName, PSECURITY_DESCR
}
/* Correct the key permissions to allow its deletion */
-static void AllowKeyAccess(HKEY Key,const char* SubKeyName)
+static void AllowKeyAccess(HKEY Key,const wchar_t* SubKeyName)
{
LSTATUS RegResult;
HKEY SvcKey = NULL;
@@ -220,7 +221,7 @@ static void AllowKeyAccess(HKEY Key,const char* SubKeyName)
PTOKEN_USER pTokenUser = NULL;
std::string sNewSD;
- RegResult = RegOpenKeyExA(Key, SubKeyName, 0, WRITE_OWNER | KEY_READ, &SvcKey);
+ RegResult = RegOpenKeyExW(Key, SubKeyName, 0, WRITE_OWNER | KEY_READ, &SvcKey);
if (RegResult==ERROR_SUCCESS)
{
if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &Token))
@@ -282,13 +283,13 @@ static void AllowKeyAccess(HKEY Key,const char* SubKeyName)
CloseHandle(Token);
}
-void SearchAndDeleteRegistrySubString (HKEY hKey, const char *subKey, const char *str, BOOL bEnumSubKeys, const char* enumMatchSubStr)
+void SearchAndDeleteRegistrySubString (HKEY hKey, const wchar_t *subKey, const wchar_t *str, BOOL bEnumSubKeys, const wchar_t* enumMatchSubStr)
{
HKEY hSubKey = 0;
LSTATUS status = 0;
DWORD dwIndex = 0, dwType, dwValueNameLen, dwDataLen;
- std::list<std::string> subKeysList;
- size_t subStringLength = str? strlen(str) : 0;
+ std::list<std::wstring> subKeysList;
+ size_t subStringLength = str? wcslen(str) : 0;
if (bEnumSubKeys)
{
@@ -296,20 +297,20 @@ void SearchAndDeleteRegistrySubString (HKEY hKey, const char *subKey, const char
if (ERROR_SUCCESS == RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, &dwMaxNameLen, NULL, NULL, NULL, NULL, NULL, NULL))
{
dwMaxNameLen++;
- char* szNameValue = new char[dwMaxNameLen];
+ wchar_t* szNameValue = new wchar_t[dwMaxNameLen];
dwIndex = 0;
while (true)
{
dwValueNameLen = dwMaxNameLen;
- status = RegEnumKeyExA (hKey, dwIndex++, szNameValue, &dwValueNameLen, NULL, NULL, NULL, NULL);
+ status = RegEnumKeyExW (hKey, dwIndex++, szNameValue, &dwValueNameLen, NULL, NULL, NULL, NULL);
if (status == ERROR_SUCCESS)
{
- if (enumMatchSubStr && !strstr(szNameValue, enumMatchSubStr))
+ if (enumMatchSubStr && !wcsstr(szNameValue, enumMatchSubStr))
continue;
- std::string entryName = szNameValue;
- entryName += "\\";
+ std::wstring entryName = szNameValue;
+ entryName += L"\\";
entryName += subKey;
- entryName += "\\";
+ entryName += L"\\";
subKeysList.push_back(entryName);
}
else
@@ -323,42 +324,42 @@ void SearchAndDeleteRegistrySubString (HKEY hKey, const char *subKey, const char
subKeysList.push_back(subKey);
}
- for (std::list<std::string>::iterator ItSubKey = subKeysList.begin(); ItSubKey != subKeysList.end(); ItSubKey++)
+ for (std::list<std::wstring>::iterator ItSubKey = subKeysList.begin(); ItSubKey != subKeysList.end(); ItSubKey++)
{
// if the string to search for is empty, delete the sub key, otherwise, look for matching value and delete them
if (subStringLength == 0)
{
- if (ERROR_ACCESS_DENIED == SHDeleteKeyA (hKey, ItSubKey->c_str()))
+ if (ERROR_ACCESS_DENIED == SHDeleteKeyW (hKey, ItSubKey->c_str()))
{
// grant permission to delete
AllowKeyAccess (hKey, ItSubKey->c_str());
// try again
- SHDeleteKeyA (hKey, ItSubKey->c_str());
+ SHDeleteKeyW (hKey, ItSubKey->c_str());
}
}
else
{
- if (RegOpenKeyExA (hKey, ItSubKey->c_str(), 0, KEY_ALL_ACCESS, &hSubKey) == ERROR_SUCCESS)
+ if (RegOpenKeyExW (hKey, ItSubKey->c_str(), 0, KEY_ALL_ACCESS, &hSubKey) == ERROR_SUCCESS)
{
DWORD dwMaxNameLen = 0, dwMaxDataLen = 0;
if (ERROR_SUCCESS == RegQueryInfoKey(hSubKey, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &dwMaxNameLen, &dwMaxDataLen, NULL, NULL))
{
dwMaxNameLen++;
- char* szNameValue = new char[dwMaxNameLen];
+ wchar_t* szNameValue = new wchar_t[dwMaxNameLen];
LPBYTE pbData = new BYTE[dwMaxDataLen];
- std::list<std::string> foundEntries;
+ std::list<std::wstring> foundEntries;
dwIndex = 0;
do
{
dwValueNameLen = dwMaxNameLen;
dwDataLen = dwMaxDataLen;
- status = RegEnumValueA(hSubKey, dwIndex++, szNameValue, &dwValueNameLen, NULL, &dwType, pbData, &dwDataLen);
+ status = RegEnumValueW(hSubKey, dwIndex++, szNameValue, &dwValueNameLen, NULL, &dwType, pbData, &dwDataLen);
if (status == ERROR_SUCCESS)
{
- if ( (strlen(szNameValue) >= subStringLength && strstr(szNameValue, str))
- || (dwType == REG_SZ && strlen((char*) pbData) >= subStringLength && strstr((char*) pbData, str))
+ if ( (wcslen(szNameValue) >= subStringLength && wcsstr(szNameValue, str))
+ || (dwType == REG_SZ && wcslen((wchar_t*) pbData) >= subStringLength && wcsstr((wchar_t*) pbData, str))
)
{
foundEntries.push_back(szNameValue);
@@ -370,10 +371,10 @@ void SearchAndDeleteRegistrySubString (HKEY hKey, const char *subKey, const char
// delete the entries
if (!foundEntries.empty())
{
- for (std::list<std::string>::iterator It = foundEntries.begin();
+ for (std::list<std::wstring>::iterator It = foundEntries.begin();
It != foundEntries.end(); It++)
{
- RegDeleteValueA (hSubKey, It->c_str());
+ RegDeleteValueW (hSubKey, It->c_str());
}
}
@@ -426,8 +427,8 @@ BOOL SetPrivilege(LPTSTR szPrivilegeName, BOOL bEnable)
return bStatus;
}
-HRESULT CreateLink (char *lpszPathObj, char *lpszArguments,
- char *lpszPathLink, const char* iconFile, int iconIndex)
+HRESULT CreateLink (wchar_t *lpszPathObj, wchar_t *lpszArguments,
+ wchar_t *lpszPathLink, const wchar_t* iconFile, int iconIndex)
{
HRESULT hres;
IShellLink *psl;
@@ -449,7 +450,7 @@ HRESULT CreateLink (char *lpszPathObj, char *lpszArguments,
}
// Application ID
- if (strstr (lpszPathObj, TC_APP_NAME ".exe"))
+ if (_tcsstr (lpszPathObj, _T(TC_APP_NAME) _T(".exe")))
{
IPropertyStore *propStore;
@@ -475,14 +476,8 @@ HRESULT CreateLink (char *lpszPathObj, char *lpszArguments,
if (SUCCEEDED (hres))
{
- wchar_t wsz[TC_MAX_PATH];
-
- /* Ensure that the string is ANSI. */
- MultiByteToWideChar (CP_ACP, 0, lpszPathLink, -1,
- wsz, sizeof(wsz) / sizeof(wsz[0]));
-
/* Save the link by calling IPersistFile::Save. */
- hres = ppf->Save (wsz, TRUE);
+ hres = ppf->Save (lpszPathLink, TRUE);
ppf->Release ();
}
psl->Release ();
@@ -495,13 +490,13 @@ BOOL IsSystemRestoreEnabled ()
BOOL bEnabled = FALSE;
HKEY hKey;
DWORD dwValue = 0, cbValue = sizeof (DWORD);
- char szRegPath[MAX_PATH];
+ wchar_t szRegPath[MAX_PATH];
GetRestorePointRegKeyName (szRegPath, sizeof (szRegPath));
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, szRegPath, 0, KEY_READ | KEY_WOW64_64KEY, &hKey) == ERROR_SUCCESS)
{
if (IsOSAtLeast (WIN_VISTA))
{
- if ( (ERROR_SUCCESS == RegQueryValueEx (hKey, "RPSessionInterval", NULL, NULL, (LPBYTE) &dwValue, &cbValue))
+ if ( (ERROR_SUCCESS == RegQueryValueEx (hKey, L"RPSessionInterval", NULL, NULL, (LPBYTE) &dwValue, &cbValue))
&& (dwValue == 1)
)
{
@@ -510,7 +505,7 @@ BOOL IsSystemRestoreEnabled ()
}
else
{
- if ( (ERROR_SUCCESS == RegQueryValueEx (hKey, "DisableSR", NULL, NULL, (LPBYTE) &dwValue, &cbValue))
+ if ( (ERROR_SUCCESS == RegQueryValueEx (hKey, L"DisableSR", NULL, NULL, (LPBYTE) &dwValue, &cbValue))
&& (dwValue == 0)
)
{
@@ -525,7 +520,7 @@ BOOL IsSystemRestoreEnabled ()
return bEnabled;
}
-void GetProgramPath (HWND hwndDlg, char *path)
+void GetProgramPath (HWND hwndDlg, wchar_t *path)
{
ITEMIDLIST *i;
HRESULT res;
@@ -549,14 +544,14 @@ void StatusMessage (HWND hwndDlg, char *stringId)
SendDlgItemMessage (hwndDlg, IDC_LOG_WINDOW, LB_GETCOUNT, 0, 0) - 1, 0);
}
-void StatusMessageParam (HWND hwndDlg, char *stringId, char *param)
+void StatusMessageParam (HWND hwndDlg, char *stringId, wchar_t *param)
{
wchar_t szTmp[1024];
if (Rollback)
return;
- StringCbPrintfW (szTmp, sizeof(szTmp), L"%s %hs", GetString (stringId), param);
+ StringCbPrintfW (szTmp, sizeof(szTmp), L"%s %s", GetString (stringId), param);
SendMessageW (GetDlgItem (hwndDlg, IDC_LOG_WINDOW), LB_ADDSTRING, 0, (LPARAM) szTmp);
SendDlgItemMessage (hwndDlg, IDC_LOG_WINDOW, LB_SETTOPINDEX,
@@ -568,23 +563,23 @@ void ClearLogWindow (HWND hwndDlg)
SendMessage (GetDlgItem (hwndDlg, IDC_LOG_WINDOW), LB_RESETCONTENT, 0, 0);
}
-void RegMessage (HWND hwndDlg, char *txt)
+void RegMessage (HWND hwndDlg, wchar_t *txt)
{
StatusMessageParam (hwndDlg, "ADDING_REG", txt);
}
-void CopyMessage (HWND hwndDlg, char *txt)
+void CopyMessage (HWND hwndDlg, wchar_t *txt)
{
StatusMessageParam (hwndDlg, "INSTALLING", txt);
}
-void RemoveMessage (HWND hwndDlg, char *txt)
+void RemoveMessage (HWND hwndDlg, wchar_t *txt)
{
if (!Rollback)
StatusMessageParam (hwndDlg, "REMOVING", txt);
}
-void IconMessage (HWND hwndDlg, char *txt)
+void IconMessage (HWND hwndDlg, wchar_t *txt)
{
StatusMessageParam (hwndDlg, "ADDING_ICON", txt);
}
@@ -623,7 +618,7 @@ void DetermineUpgradeDowngradeStatus (BOOL bCloseDriverHandle, LONG *driverVersi
}
-static BOOL IsFileInUse (const string &filePath)
+static BOOL IsFileInUse (const wstring &filePath)
{
HANDLE useTestHandle = CreateFile (filePath.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
@@ -636,38 +631,38 @@ static BOOL IsFileInUse (const string &filePath)
}
-BOOL DoFilesInstall (HWND hwndDlg, char *szDestDir)
+BOOL DoFilesInstall (HWND hwndDlg, wchar_t *szDestDir)
{
/* WARNING: Note that, despite its name, this function is used during UNinstallation as well. */
- char szTmp[TC_MAX_PATH];
+ wchar_t szTmp[TC_MAX_PATH];
BOOL bOK = TRUE;
int i, x, fileNo;
- char curFileName [TC_MAX_PATH] = {0};
+ wchar_t curFileName [TC_MAX_PATH] = {0};
if (!bUninstall && !bDevm)
{
// Self-extract all files to memory
- GetModuleFileName (NULL, szTmp, sizeof (szTmp));
+ GetModuleFileName (NULL, szTmp, ARRAYSIZE (szTmp));
if (!SelfExtractInMemory (szTmp))
return FALSE;
}
- x = strlen (szDestDir);
+ x = wcslen (szDestDir);
if (x < 2)
return FALSE;
- if (szDestDir[x - 1] != '\\')
- StringCbCatA (szDestDir, MAX_PATH, "\\");
+ if (szDestDir[x - 1] != L'\\')
+ StringCbCatW (szDestDir, MAX_PATH, L"\\");
for (i = 0; i < sizeof (szFiles) / sizeof (szFiles[0]); i++)
{
BOOL bResult;
- char szDir[TC_MAX_PATH];
+ wchar_t szDir[TC_MAX_PATH];
- if (strstr (szFiles[i], "VeraCrypt Setup") != 0)
+ if (wcsstr (szFiles[i], L"VeraCrypt Setup") != 0)
{
if (bUninstall)
continue; // Prevent 'access denied' error
@@ -677,36 +672,36 @@ BOOL DoFilesInstall (HWND hwndDlg, char *szDestDir)
}
// skip files that don't apply to the current architecture
- if ( (Is64BitOs () && (strcmp (szFiles[i], "AVeraCrypt-x64.exe") == 0))
- || (Is64BitOs () && (strcmp (szFiles[i], "AVeraCryptExpander-x64.exe") == 0))
- || (Is64BitOs () && (strcmp (szFiles[i], "AVeraCrypt Format-x64.exe") == 0))
- || (!Is64BitOs () && (strcmp (szFiles[i], "AVeraCrypt-x86.exe") == 0))
- || (!Is64BitOs () && (strcmp (szFiles[i], "AVeraCryptExpander-x86.exe") == 0))
- || (!Is64BitOs () && (strcmp (szFiles[i], "AVeraCrypt Format-x86.exe") == 0))
+ if ( (Is64BitOs () && (wcscmp (szFiles[i], L"AVeraCrypt-x64.exe") == 0))
+ || (Is64BitOs () && (wcscmp (szFiles[i], L"AVeraCryptExpander-x64.exe") == 0))
+ || (Is64BitOs () && (wcscmp (szFiles[i], L"AVeraCrypt Format-x64.exe") == 0))
+ || (!Is64BitOs () && (wcscmp (szFiles[i], L"AVeraCrypt-x86.exe") == 0))
+ || (!Is64BitOs () && (wcscmp (szFiles[i], L"AVeraCryptExpander-x86.exe") == 0))
+ || (!Is64BitOs () && (wcscmp (szFiles[i], L"AVeraCrypt Format-x86.exe") == 0))
)
{
continue;
}
- if (*szFiles[i] == 'A')
- StringCbCopyA (szDir, sizeof(szDir), szDestDir);
- else if (*szFiles[i] == 'D')
+ if (*szFiles[i] == L'A')
+ StringCbCopyW (szDir, sizeof(szDir), szDestDir);
+ else if (*szFiles[i] == L'D')
{
- GetSystemDirectory (szDir, sizeof (szDir));
+ GetSystemDirectory (szDir, ARRAYSIZE (szDir));
- x = strlen (szDir);
- if (szDir[x - 1] != '\\')
- StringCbCatA (szDir, sizeof(szDir), "\\");
+ x = wcslen (szDir);
+ if (szDir[x - 1] != L'\\')
+ StringCbCatW (szDir, sizeof(szDir), L"\\");
- StringCbCatA (szDir, sizeof(szDir), "Drivers\\");
+ StringCbCatW (szDir, sizeof(szDir), L"Drivers\\");
}
- else if (*szFiles[i] == 'W')
+ else if (*szFiles[i] == L'W')
GetWindowsDirectory (szDir, sizeof (szDir));
- if (*szFiles[i] == 'I')
+ if (*szFiles[i] == L'I')
continue;
- StringCbPrintfA (szTmp, sizeof(szTmp), "%s%s", szDir, szFiles[i] + 1);
+ StringCbPrintfW (szTmp, sizeof(szTmp), L"%s%s", szDir, szFiles[i] + 1);
if (bUninstall == FALSE)
CopyMessage (hwndDlg, szTmp);
@@ -717,63 +712,63 @@ BOOL DoFilesInstall (HWND hwndDlg, char *szDestDir)
{
SetCurrentDirectory (SetupFilesDir);
- if (strstr (szFiles[i], "VeraCrypt Setup") != 0)
+ if (wcsstr (szFiles[i], L"VeraCrypt Setup") != 0)
{
// Copy ourselves (the distribution package) to the destination location as 'VeraCrypt Setup.exe'
- char mp[MAX_PATH];
+ wchar_t mp[MAX_PATH];
- GetModuleFileName (NULL, mp, sizeof (mp));
+ GetModuleFileName (NULL, mp, ARRAYSIZE (mp));
bResult = TCCopyFile (mp, szTmp);
}
else
{
BOOL driver64 = FALSE;
- StringCbCopyNA (curFileName, sizeof(curFileName), szFiles[i] + 1, strlen (szFiles[i]) - 1);
- curFileName [strlen (szFiles[i]) - 1] = 0;
+ StringCchCopyNW (curFileName, ARRAYSIZE(curFileName), szFiles[i] + 1, wcslen (szFiles[i]) - 1);
+ curFileName [wcslen (szFiles[i]) - 1] = 0;
if (Is64BitOs ()
- && strcmp (szFiles[i], "Dveracrypt.sys") == 0)
+ && wcscmp (szFiles[i], L"Dveracrypt.sys") == 0)
{
driver64 = TRUE;
- StringCbCopyNA (curFileName, sizeof(curFileName), FILENAME_64BIT_DRIVER, sizeof (FILENAME_64BIT_DRIVER));
+ StringCbCopyNW (curFileName, sizeof(curFileName), FILENAME_64BIT_DRIVER, sizeof (FILENAME_64BIT_DRIVER));
}
if (Is64BitOs ()
- && strcmp (szFiles[i], "AVeraCrypt.exe") == 0)
+ && wcscmp (szFiles[i], L"AVeraCrypt.exe") == 0)
{
- StringCbCopyNA (curFileName, sizeof(curFileName), "VeraCrypt-x64.exe", sizeof ("VeraCrypt-x64.exe"));
+ StringCbCopyNW (curFileName, sizeof(curFileName), L"VeraCrypt-x64.exe", sizeof (L"VeraCrypt-x64.exe"));
}
if (Is64BitOs ()
- && strcmp (szFiles[i], "AVeraCrypt-x86.exe") == 0)
+ && wcscmp (szFiles[i], L"AVeraCrypt-x86.exe") == 0)
{
- StringCbCopyNA (curFileName, sizeof(curFileName), "VeraCrypt.exe", sizeof ("VeraCrypt.exe"));
+ StringCbCopyNW (curFileName, sizeof(curFileName), L"VeraCrypt.exe", sizeof (L"VeraCrypt.exe"));
}
if (Is64BitOs ()
- && strcmp (szFiles[i], "AVeraCryptExpander.exe") == 0)
+ && wcscmp (szFiles[i], L"AVeraCryptExpander.exe") == 0)
{
- StringCbCopyNA (curFileName, sizeof(curFileName), "VeraCryptExpander-x64.exe", sizeof ("VeraCryptExpander-x64.exe"));
+ StringCbCopyNW (curFileName, sizeof(curFileName), L"VeraCryptExpander-x64.exe", sizeof (L"VeraCryptExpander-x64.exe"));
}
if (Is64BitOs ()
- && strcmp (szFiles[i], "AVeraCryptExpander-x86.exe") == 0)
+ && wcscmp (szFiles[i], L"AVeraCryptExpander-x86.exe") == 0)
{
- StringCbCopyNA (curFileName, sizeof(curFileName), "VeraCryptExpander.exe", sizeof ("VeraCryptExpander.exe"));
+ StringCbCopyNW (curFileName, sizeof(curFileName), L"VeraCryptExpander.exe", sizeof (L"VeraCryptExpander.exe"));
}
if (Is64BitOs ()
- && strcmp (szFiles[i], "AVeraCrypt Format.exe") == 0)
+ && wcscmp (szFiles[i], L"AVeraCrypt Format.exe") == 0)
{
- StringCbCopyNA (curFileName, sizeof(curFileName), "VeraCrypt Format-x64.exe", sizeof ("VeraCrypt Format-x64.exe"));
+ StringCbCopyNW (curFileName, sizeof(curFileName), L"VeraCrypt Format-x64.exe", sizeof (L"VeraCrypt Format-x64.exe"));
}
if (Is64BitOs ()
- && strcmp (szFiles[i], "AVeraCrypt Format-x86.exe") == 0)
+ && wcscmp (szFiles[i], L"AVeraCrypt Format-x86.exe") == 0)
{
- StringCbCopyNA (curFileName, sizeof(curFileName), "VeraCrypt Format.exe", sizeof ("VeraCrypt Format.exe"));
+ StringCbCopyNW (curFileName, sizeof(curFileName), L"VeraCrypt Format.exe", sizeof (L"VeraCrypt Format.exe"));
}
if (!bDevm)
@@ -785,10 +780,10 @@ BOOL DoFilesInstall (HWND hwndDlg, char *szDestDir)
{
// Write the file (stored in memory) directly to the destination location
// (there will be no temporary files).
- if (memcmp (
+ if (wmemcmp (
curFileName,
Decompressed_Files[fileNo].fileName,
- min (strlen (curFileName), (size_t) Decompressed_Files[fileNo].fileNameLength)) == 0)
+ min (wcslen (curFileName), (size_t) Decompressed_Files[fileNo].fileNameLength)) == 0)
{
// Dump filter driver cannot be installed to SysWOW64 directory
if (driver64 && !EnableWow64FsRedirection (FALSE))
@@ -834,21 +829,21 @@ BOOL DoFilesInstall (HWND hwndDlg, char *szDestDir)
EnableWow64FsRedirection (TRUE);
}
- if (bResult && strcmp (szFiles[i], "AVeraCrypt.exe") == 0)
+ if (bResult && wcscmp (szFiles[i], L"AVeraCrypt.exe") == 0)
{
if (Is64BitOs ())
EnableWow64FsRedirection (FALSE);
- string servicePath = GetServiceConfigPath (TC_APP_NAME ".exe", false);
- string serviceLegacyPath = GetServiceConfigPath (TC_APP_NAME ".exe", true);
- string favoritesFile = GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES, false);
- string favoritesLegacyFile = GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES, true);
+ wstring servicePath = GetServiceConfigPath (_T(TC_APP_NAME) L".exe", false);
+ wstring serviceLegacyPath = GetServiceConfigPath (_T(TC_APP_NAME) L".exe", true);
+ wstring favoritesFile = GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES, false);
+ wstring favoritesLegacyFile = GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES, true);
if ( FileExists (servicePath.c_str())
|| (Is64BitOs () && FileExists (serviceLegacyPath.c_str()))
)
{
- CopyMessage (hwndDlg, (char *) servicePath.c_str());
+ CopyMessage (hwndDlg, (wchar_t *) servicePath.c_str());
bResult = CopyFile (szTmp, servicePath.c_str(), FALSE);
}
@@ -880,13 +875,13 @@ BOOL DoFilesInstall (HWND hwndDlg, char *szDestDir)
// delete files from legacy path
if (FileExists (favoritesLegacyFile.c_str()))
{
- RemoveMessage (hwndDlg, (char *) favoritesLegacyFile.c_str());
+ RemoveMessage (hwndDlg, (wchar_t *) favoritesLegacyFile.c_str());
DeleteFile (favoritesLegacyFile.c_str());
}
if (FileExists (serviceLegacyPath.c_str()))
{
- RemoveMessage (hwndDlg, (char *) serviceLegacyPath.c_str());
+ RemoveMessage (hwndDlg, (wchar_t *) serviceLegacyPath.c_str());
DeleteFile (serviceLegacyPath.c_str());
}
@@ -898,26 +893,26 @@ BOOL DoFilesInstall (HWND hwndDlg, char *szDestDir)
else
{
bResult = StatDeleteFile (szTmp, TRUE);
- if (bResult && strcmp (szFiles[i], "AVeraCrypt.exe") == 0)
+ if (bResult && wcscmp (szFiles[i], L"AVeraCrypt.exe") == 0)
{
if (Is64BitOs ())
EnableWow64FsRedirection (FALSE);
- string servicePath = GetServiceConfigPath (TC_APP_NAME ".exe", false);
- string serviceLegacyPath = GetServiceConfigPath (TC_APP_NAME ".exe", true);
- string favoritesFile = GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES, false);
- string favoritesLegacyFile = GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES, true);
+ wstring servicePath = GetServiceConfigPath (_T(TC_APP_NAME) L".exe", false);
+ wstring serviceLegacyPath = GetServiceConfigPath (_T(TC_APP_NAME) L".exe", true);
+ wstring favoritesFile = GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES, false);
+ wstring favoritesLegacyFile = GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES, true);
// delete all files related to system favorites service
if (FileExists (favoritesFile.c_str()))
{
- RemoveMessage (hwndDlg, (char *) favoritesFile.c_str());
+ RemoveMessage (hwndDlg, (wchar_t *) favoritesFile.c_str());
DeleteFile (favoritesFile.c_str());
}
if (FileExists (servicePath.c_str()))
{
- RemoveMessage (hwndDlg, (char *) servicePath.c_str());
+ RemoveMessage (hwndDlg, (wchar_t *) servicePath.c_str());
DeleteFile (servicePath.c_str());
}
@@ -925,13 +920,13 @@ BOOL DoFilesInstall (HWND hwndDlg, char *szDestDir)
{
if (FileExists (favoritesLegacyFile.c_str()))
{
- RemoveMessage (hwndDlg, (char *) favoritesLegacyFile.c_str());
+ RemoveMessage (hwndDlg, (wchar_t *) favoritesLegacyFile.c_str());
DeleteFile (favoritesLegacyFile.c_str());
}
if (FileExists (serviceLegacyPath.c_str()))
{
- RemoveMessage (hwndDlg, (char *) serviceLegacyPath.c_str());
+ RemoveMessage (hwndDlg, (wchar_t *) serviceLegacyPath.c_str());
DeleteFile (serviceLegacyPath.c_str());
}
@@ -952,7 +947,7 @@ err:
NULL,
dwError,
MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
- (char *) &lpMsgBuf,
+ (wchar_t *) &lpMsgBuf,
0,
NULL
);
@@ -977,24 +972,24 @@ err:
HANDLE h;
SetCurrentDirectory (SetupFilesDir);
- h = FindFirstFile ("Language.*.xml", &f);
+ h = FindFirstFile (L"Language.*.xml", &f);
if (h != INVALID_HANDLE_VALUE)
{
- char d[MAX_PATH*2];
- StringCbPrintfA (d, sizeof(d), "%s%s", szDestDir, f.cFileName);
+ wchar_t d[MAX_PATH*2];
+ StringCbPrintfW (d, sizeof(d), L"%s%s", szDestDir, f.cFileName);
CopyMessage (hwndDlg, d);
TCCopyFile (f.cFileName, d);
FindClose (h);
}
SetCurrentDirectory (SetupFilesDir);
- SetCurrentDirectory ("Setup files");
- h = FindFirstFile ("VeraCrypt User Guide.*.pdf", &f);
+ SetCurrentDirectory (L"Setup files");
+ h = FindFirstFile (L"VeraCrypt User Guide.*.pdf", &f);
if (h != INVALID_HANDLE_VALUE)
{
- char d[MAX_PATH*2];
- StringCbPrintfA (d, sizeof(d), "%s%s", szDestDir, f.cFileName);
+ wchar_t d[MAX_PATH*2];
+ StringCbPrintfW (d, sizeof(d), L"%s%s", szDestDir, f.cFileName);
CopyMessage (hwndDlg, d);
TCCopyFile (f.cFileName, d);
FindClose (h);
@@ -1005,10 +1000,10 @@ err:
return bOK;
}
-BOOL DoRegInstall (HWND hwndDlg, char *szDestDir, BOOL bInstallType)
+BOOL DoRegInstall (HWND hwndDlg, wchar_t *szDestDir, BOOL bInstallType)
{
- char szDir[TC_MAX_PATH], *key;
- char szTmp[TC_MAX_PATH*4];
+ wchar_t szDir[TC_MAX_PATH], *key;
+ wchar_t szTmp[TC_MAX_PATH*4];
HKEY hkey = 0;
BOOL bSlash, bOK = FALSE;
DWORD dw;
@@ -1016,14 +1011,14 @@ BOOL DoRegInstall (HWND hwndDlg, char *szDestDir, BOOL bInstallType)
if (SystemEncryptionUpdate)
{
- if (RegCreateKeyEx (HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\VeraCrypt",
+ if (RegCreateKeyEx (HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\VeraCrypt",
0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE | KEY_WOW64_32KEY, NULL, &hkey, &dw) == ERROR_SUCCESS)
{
- StringCbCopyA (szTmp, sizeof(szTmp), VERSION_STRING);
- RegSetValueEx (hkey, "DisplayVersion", 0, REG_SZ, (BYTE *) szTmp, strlen (szTmp) + 1);
+ StringCbCopyW (szTmp, sizeof(szTmp), _T(VERSION_STRING));
+ RegSetValueEx (hkey, L"DisplayVersion", 0, REG_SZ, (BYTE *) szTmp, (wcslen (szTmp) + 1) * sizeof (wchar_t));
- StringCbCopyA (szTmp, sizeof(szTmp), TC_HOMEPAGE);
- RegSetValueEx (hkey, "URLInfoAbout", 0, REG_SZ, (BYTE *) szTmp, strlen (szTmp) + 1);
+ StringCbCopyW (szTmp, sizeof(szTmp), _T(TC_HOMEPAGE));
+ RegSetValueEx (hkey, L"URLInfoAbout", 0, REG_SZ, (BYTE *) szTmp, (wcslen (szTmp) + 1) * sizeof (wchar_t));
RegCloseKey (hkey);
}
@@ -1031,71 +1026,71 @@ BOOL DoRegInstall (HWND hwndDlg, char *szDestDir, BOOL bInstallType)
return TRUE;
}
- StringCbCopyA (szDir, sizeof(szDir), szDestDir);
- x = strlen (szDestDir);
- if (szDestDir[x - 1] == '\\')
+ StringCbCopyW (szDir, sizeof(szDir), szDestDir);
+ x = wcslen (szDestDir);
+ if (szDestDir[x - 1] == L'\\')
bSlash = TRUE;
else
bSlash = FALSE;
if (bSlash == FALSE)
- StringCbCatA (szDir, sizeof(szDir), "\\");
+ StringCbCatW (szDir, sizeof(szDir), L"\\");
if (bInstallType)
{
- key = "Software\\Classes\\VeraCryptVolume";
+ key = L"Software\\Classes\\VeraCryptVolume";
RegMessage (hwndDlg, key);
if (RegCreateKeyEx (HKEY_LOCAL_MACHINE,
key,
0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hkey, &dw) != ERROR_SUCCESS)
goto error;
- StringCbCopyA (szTmp, sizeof(szTmp), "VeraCrypt Volume");
- if (RegSetValueEx (hkey, "", 0, REG_SZ, (BYTE *) szTmp, strlen (szTmp) + 1) != ERROR_SUCCESS)
+ StringCbCopyW (szTmp, sizeof(szTmp), L"VeraCrypt Volume");
+ if (RegSetValueEx (hkey, L"", 0, REG_SZ, (BYTE *) szTmp, (wcslen (szTmp) + 1) * sizeof (wchar_t)) != ERROR_SUCCESS)
goto error;
- StringCbPrintfA (szTmp, sizeof(szTmp), "%ws", TC_APPLICATION_ID);
- if (RegSetValueEx (hkey, "AppUserModelID", 0, REG_SZ, (BYTE *) szTmp, strlen (szTmp) + 1) != ERROR_SUCCESS)
+ StringCbPrintfW (szTmp, sizeof(szTmp), L"%ws", TC_APPLICATION_ID);
+ if (RegSetValueEx (hkey, L"AppUserModelID", 0, REG_SZ, (BYTE *) szTmp, (wcslen (szTmp) + 1) * sizeof (wchar_t)) != ERROR_SUCCESS)
goto error;
RegCloseKey (hkey);
hkey = 0;
- key = "Software\\Classes\\VeraCryptVolume\\DefaultIcon";
+ key = L"Software\\Classes\\VeraCryptVolume\\DefaultIcon";
RegMessage (hwndDlg, key);
if (RegCreateKeyEx (HKEY_LOCAL_MACHINE,
key,
0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hkey, &dw) != ERROR_SUCCESS)
goto error;
- StringCbPrintfA (szTmp, sizeof(szTmp), "%sVeraCrypt.exe,1", szDir);
- if (RegSetValueEx (hkey, "", 0, REG_SZ, (BYTE *) szTmp, strlen (szTmp) + 1) != ERROR_SUCCESS)
+ StringCbPrintfW (szTmp, sizeof(szTmp), L"%sVeraCrypt.exe,1", szDir);
+ if (RegSetValueEx (hkey, L"", 0, REG_SZ, (BYTE *) szTmp, (wcslen (szTmp) + 1) * sizeof (wchar_t)) != ERROR_SUCCESS)
goto error;
RegCloseKey (hkey);
hkey = 0;
- key = "Software\\Classes\\VeraCryptVolume\\Shell\\open\\command";
+ key = L"Software\\Classes\\VeraCryptVolume\\Shell\\open\\command";
RegMessage (hwndDlg, key);
if (RegCreateKeyEx (HKEY_LOCAL_MACHINE,
key,
0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hkey, &dw) != ERROR_SUCCESS)
goto error;
- StringCbPrintfA (szTmp, sizeof(szTmp), "\"%sVeraCrypt.exe\" /v \"%%1\"", szDir );
- if (RegSetValueEx (hkey, "", 0, REG_SZ, (BYTE *) szTmp, strlen (szTmp) + 1) != ERROR_SUCCESS)
+ StringCbPrintfW (szTmp, sizeof(szTmp), L"\"%sVeraCrypt.exe\" /v \"%%1\"", szDir );
+ if (RegSetValueEx (hkey, L"", 0, REG_SZ, (BYTE *) szTmp, (wcslen (szTmp) + 1) * sizeof (wchar_t)) != ERROR_SUCCESS)
goto error;
RegCloseKey (hkey);
hkey = 0;
- key = "Software\\Classes\\.hc";
+ key = L"Software\\Classes\\.hc";
BOOL typeClassChanged = TRUE;
- char typeClass[256];
+ wchar_t typeClass[256];
DWORD typeClassSize = sizeof (typeClass);
- if (ReadLocalMachineRegistryString (key, "", typeClass, &typeClassSize) && typeClassSize > 0 && strcmp (typeClass, "VeraCryptVolume") == 0)
+ if (ReadLocalMachineRegistryString (key, L"", typeClass, &typeClassSize) && typeClassSize > 0 && wcscmp (typeClass, L"VeraCryptVolume") == 0)
typeClassChanged = FALSE;
RegMessage (hwndDlg, key);
@@ -1104,8 +1099,8 @@ BOOL DoRegInstall (HWND hwndDlg, char *szDestDir, BOOL bInstallType)
0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hkey, &dw) != ERROR_SUCCESS)
goto error;
- StringCbCopyA (szTmp, sizeof(szTmp), "VeraCryptVolume");
- if (RegSetValueEx (hkey, "", 0, REG_SZ, (BYTE *) szTmp, strlen (szTmp) + 1) != ERROR_SUCCESS)
+ StringCbCopyW (szTmp, sizeof(szTmp), L"VeraCryptVolume");
+ if (RegSetValueEx (hkey, L"", 0, REG_SZ, (BYTE *) szTmp, (wcslen (szTmp) + 1) * sizeof (wchar_t)) != ERROR_SUCCESS)
goto error;
RegCloseKey (hkey);
@@ -1115,7 +1110,7 @@ BOOL DoRegInstall (HWND hwndDlg, char *szDestDir, BOOL bInstallType)
SHChangeNotify (SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
}
- key = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\VeraCrypt";
+ key = L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\VeraCrypt";
RegMessage (hwndDlg, key);
if (RegCreateKeyEx (HKEY_LOCAL_MACHINE,
key,
@@ -1123,32 +1118,32 @@ BOOL DoRegInstall (HWND hwndDlg, char *szDestDir, BOOL bInstallType)
goto error;
/* IMPORTANT: IF YOU CHANGE THIS IN ANY WAY, REVISE AND UPDATE SetInstallationPath() ACCORDINGLY! */
- StringCbPrintfA (szTmp, sizeof(szTmp), "\"%sVeraCrypt Setup.exe\" /u", szDir);
- if (RegSetValueEx (hkey, "UninstallString", 0, REG_SZ, (BYTE *) szTmp, strlen (szTmp) + 1) != ERROR_SUCCESS)
+ StringCbPrintfW (szTmp, sizeof(szTmp), L"\"%sVeraCrypt Setup.exe\" /u", szDir);
+ if (RegSetValueEx (hkey, L"UninstallString", 0, REG_SZ, (BYTE *) szTmp, (wcslen (szTmp) + 1) * sizeof (wchar_t)) != ERROR_SUCCESS)
goto error;
- StringCbPrintfA (szTmp, sizeof(szTmp), "\"%sVeraCrypt Setup.exe\" /c", szDir);
- if (RegSetValueEx (hkey, "ModifyPath", 0, REG_SZ, (BYTE *) szTmp, strlen (szTmp) + 1) != ERROR_SUCCESS)
+ StringCbPrintfW (szTmp, sizeof(szTmp), L"\"%sVeraCrypt Setup.exe\" /c", szDir);
+ if (RegSetValueEx (hkey, L"ModifyPath", 0, REG_SZ, (BYTE *) szTmp, (wcslen (szTmp) + 1) * sizeof (wchar_t)) != ERROR_SUCCESS)
goto error;
- StringCbPrintfA (szTmp, sizeof(szTmp), "\"%sVeraCrypt Setup.exe\"", szDir);
- if (RegSetValueEx (hkey, "DisplayIcon", 0, REG_SZ, (BYTE *) szTmp, strlen (szTmp) + 1) != ERROR_SUCCESS)
+ StringCbPrintfW (szTmp, sizeof(szTmp), L"\"%sVeraCrypt Setup.exe\"", szDir);
+ if (RegSetValueEx (hkey, L"DisplayIcon", 0, REG_SZ, (BYTE *) szTmp, (wcslen (szTmp) + 1) * sizeof (wchar_t)) != ERROR_SUCCESS)
goto error;
- StringCbCopyA (szTmp, sizeof(szTmp), VERSION_STRING);
- if (RegSetValueEx (hkey, "DisplayVersion", 0, REG_SZ, (BYTE *) szTmp, strlen (szTmp) + 1) != ERROR_SUCCESS)
+ StringCbCopyW (szTmp, sizeof(szTmp), _T(VERSION_STRING));
+ if (RegSetValueEx (hkey, L"DisplayVersion", 0, REG_SZ, (BYTE *) szTmp, (wcslen (szTmp) + 1) * sizeof (wchar_t)) != ERROR_SUCCESS)
goto error;
- StringCbCopyA (szTmp, sizeof(szTmp), "VeraCrypt");
- if (RegSetValueEx (hkey, "DisplayName", 0, REG_SZ, (BYTE *) szTmp, strlen (szTmp) + 1) != ERROR_SUCCESS)
+ StringCbCopyW (szTmp, sizeof(szTmp), L"VeraCrypt");
+ if (RegSetValueEx (hkey, L"DisplayName", 0, REG_SZ, (BYTE *) szTmp, (wcslen (szTmp) + 1) * sizeof (wchar_t)) != ERROR_SUCCESS)
goto error;
- StringCbCopyA (szTmp, sizeof(szTmp), "IDRIX");
- if (RegSetValueEx (hkey, "Publisher", 0, REG_SZ, (BYTE *) szTmp, strlen (szTmp) + 1) != ERROR_SUCCESS)
+ StringCbCopyW (szTmp, sizeof(szTmp), L"IDRIX");
+ if (RegSetValueEx (hkey, L"Publisher", 0, REG_SZ, (BYTE *) szTmp, (wcslen (szTmp) + 1) * sizeof (wchar_t)) != ERROR_SUCCESS)
goto error;
- StringCbCopyA (szTmp, sizeof(szTmp), TC_HOMEPAGE);
- if (RegSetValueEx (hkey, "URLInfoAbout", 0, REG_SZ, (BYTE *) szTmp, strlen (szTmp) + 1) != ERROR_SUCCESS)
+ StringCbCopyW (szTmp, sizeof(szTmp), _T(TC_HOMEPAGE));
+ if (RegSetValueEx (hkey, L"URLInfoAbout", 0, REG_SZ, (BYTE *) szTmp, (wcslen (szTmp) + 1) * sizeof (wchar_t)) != ERROR_SUCCESS)
goto error;
bOK = TRUE;
@@ -1178,42 +1173,42 @@ error:
BOOL DoApplicationDataUninstall (HWND hwndDlg)
{
- char path[MAX_PATH];
- char path2[MAX_PATH];
+ wchar_t path[MAX_PATH];
+ wchar_t path2[MAX_PATH];
BOOL bOK = TRUE;
StatusMessage (hwndDlg, "REMOVING_APPDATA");
SHGetFolderPath (NULL, CSIDL_APPDATA, NULL, 0, path);
- StringCbCatA (path, sizeof(path), "\\VeraCrypt\\");
+ StringCbCatW (path, sizeof(path), L"\\VeraCrypt\\");
// Delete favorite volumes file
- StringCbPrintfA (path2, sizeof(path2), "%s%s", path, TC_APPD_FILENAME_FAVORITE_VOLUMES);
+ StringCbPrintfW (path2, sizeof(path2), L"%s%s", path, TC_APPD_FILENAME_FAVORITE_VOLUMES);
RemoveMessage (hwndDlg, path2);
StatDeleteFile (path2, FALSE);
// Delete keyfile defaults
- StringCbPrintfA (path2, sizeof(path2), "%s%s", path, TC_APPD_FILENAME_DEFAULT_KEYFILES);
+ StringCbPrintfW (path2, sizeof(path2), L"%s%s", path, TC_APPD_FILENAME_DEFAULT_KEYFILES);
RemoveMessage (hwndDlg, path2);
StatDeleteFile (path2, FALSE);
// Delete history file
- StringCbPrintfA (path2, sizeof(path2), "%s%s", path, TC_APPD_FILENAME_HISTORY);
+ StringCbPrintfW (path2, sizeof(path2), L"%s%s", path, TC_APPD_FILENAME_HISTORY);
RemoveMessage (hwndDlg, path2);
StatDeleteFile (path2, FALSE);
// Delete configuration file
- StringCbPrintfA (path2, sizeof(path2), "%s%s", path, TC_APPD_FILENAME_CONFIGURATION);
+ StringCbPrintfW (path2, sizeof(path2), L"%s%s", path, TC_APPD_FILENAME_CONFIGURATION);
RemoveMessage (hwndDlg, path2);
StatDeleteFile (path2, FALSE);
// Delete system encryption configuration file
- StringCbPrintfA (path2, sizeof(path2), "%s%s", path, TC_APPD_FILENAME_SYSTEM_ENCRYPTION);
+ StringCbPrintfW (path2, sizeof(path2), L"%s%s", path, TC_APPD_FILENAME_SYSTEM_ENCRYPTION);
RemoveMessage (hwndDlg, path2);
StatDeleteFile (path2, FALSE);
SHGetFolderPath (NULL, CSIDL_APPDATA, NULL, 0, path);
- StringCbCatA (path, sizeof(path), "\\VeraCrypt");
+ StringCbCatW (path, sizeof(path), L"\\VeraCrypt");
RemoveMessage (hwndDlg, path);
if (!StatRemoveDirectory (path))
{
@@ -1224,10 +1219,10 @@ BOOL DoApplicationDataUninstall (HWND hwndDlg)
// remove VeraCrypt under common appdata
if (SUCCEEDED (SHGetFolderPath (NULL, CSIDL_COMMON_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, path)))
{
- StringCbCatA (path, sizeof(path), "\\VeraCrypt");
+ StringCbCatW (path, sizeof(path), L"\\VeraCrypt");
// Delete original bootloader
- StringCbPrintfA (path2, sizeof(path2), "%s\\%s", path, TC_SYS_BOOT_LOADER_BACKUP_NAME);
+ StringCbPrintfW (path2, sizeof(path2), L"%s\\%s", path, TC_SYS_BOOT_LOADER_BACKUP_NAME);
RemoveMessage (hwndDlg, path2);
StatDeleteFile (path2, FALSE);
@@ -1242,13 +1237,13 @@ BOOL DoApplicationDataUninstall (HWND hwndDlg)
BOOL DoRegUninstall (HWND hwndDlg, BOOL bRemoveDeprecated)
{
- char regk [64];
- typedef LSTATUS (WINAPI *RegDeleteKeyExAFn) (HKEY hKey,LPCSTR lpSubKey,REGSAM samDesired,WORD Reserved);
- RegDeleteKeyExAFn RegDeleteKeyExAPtr = NULL;
- HMODULE hAdvapiDll = LoadLibrary ("Advapi32.dll");
+ wchar_t regk [64];
+ typedef LSTATUS (WINAPI *RegDeleteKeyExWFn) (HKEY hKey,LPCWSTR lpSubKey,REGSAM samDesired,WORD Reserved);
+ RegDeleteKeyExWFn RegDeleteKeyExWPtr = NULL;
+ HMODULE hAdvapiDll = LoadLibrary (L"Advapi32.dll");
if (hAdvapiDll)
{
- RegDeleteKeyExAPtr = (RegDeleteKeyExAFn) GetProcAddress(hAdvapiDll, "RegDeleteKeyExA");
+ RegDeleteKeyExWPtr = (RegDeleteKeyExWFn) GetProcAddress(hAdvapiDll, "RegDeleteKeyExW");
}
// Unregister COM servers
@@ -1261,45 +1256,45 @@ BOOL DoRegUninstall (HWND hwndDlg, BOOL bRemoveDeprecated)
if (!bRemoveDeprecated)
StatusMessage (hwndDlg, "REMOVING_REG");
- if (RegDeleteKeyExAPtr)
+ if (RegDeleteKeyExWPtr)
{
- RegDeleteKeyExAPtr (HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\VeraCrypt", KEY_WOW64_32KEY, 0);
- RegDeleteKeyExAPtr (HKEY_CURRENT_USER, "Software\\VeraCrypt", KEY_WOW64_32KEY, 0);
+ RegDeleteKeyExWPtr (HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\VeraCrypt", KEY_WOW64_32KEY, 0);
+ RegDeleteKeyExWPtr (HKEY_CURRENT_USER, L"Software\\VeraCrypt", KEY_WOW64_32KEY, 0);
}
else
{
- RegDeleteKey (HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\VeraCrypt");
- RegDeleteKey (HKEY_LOCAL_MACHINE, "Software\\VeraCrypt");
+ RegDeleteKey (HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\VeraCrypt");
+ RegDeleteKey (HKEY_LOCAL_MACHINE, L"Software\\VeraCrypt");
}
- RegDeleteKey (HKEY_LOCAL_MACHINE, "Software\\Classes\\VeraCryptVolume\\Shell\\open\\command");
- RegDeleteKey (HKEY_LOCAL_MACHINE, "Software\\Classes\\VeraCryptVolume\\Shell\\open");
- RegDeleteKey (HKEY_LOCAL_MACHINE, "Software\\Classes\\VeraCryptVolume\\Shell");
- RegDeleteKey (HKEY_LOCAL_MACHINE, "Software\\Classes\\VeraCryptVolume\\DefaultIcon");
- RegDeleteKey (HKEY_LOCAL_MACHINE, "Software\\Classes\\VeraCryptVolume");
+ RegDeleteKey (HKEY_LOCAL_MACHINE, L"Software\\Classes\\VeraCryptVolume\\Shell\\open\\command");
+ RegDeleteKey (HKEY_LOCAL_MACHINE, L"Software\\Classes\\VeraCryptVolume\\Shell\\open");
+ RegDeleteKey (HKEY_LOCAL_MACHINE, L"Software\\Classes\\VeraCryptVolume\\Shell");
+ RegDeleteKey (HKEY_LOCAL_MACHINE, L"Software\\Classes\\VeraCryptVolume\\DefaultIcon");
+ RegDeleteKey (HKEY_LOCAL_MACHINE, L"Software\\Classes\\VeraCryptVolume");
if (!bRemoveDeprecated)
{
HKEY hKey;
GetStartupRegKeyName (regk, sizeof(regk));
- DeleteRegistryValue (regk, "VeraCrypt");
+ DeleteRegistryValue (regk, L"VeraCrypt");
- SHDeleteKey (HKEY_LOCAL_MACHINE, "Software\\Classes\\.hc");
+ SHDeleteKey (HKEY_LOCAL_MACHINE, L"Software\\Classes\\.hc");
// enable the SE_TAKE_OWNERSHIP_NAME privilege for this operation
SetPrivilege (SE_TAKE_OWNERSHIP_NAME, TRUE);
// clean MuiCache list from VeraCrypt entries
- SearchAndDeleteRegistrySubString (HKEY_CLASSES_ROOT, "Local Settings\\Software\\Microsoft\\Windows\\Shell\\MuiCache", "VeraCrypt", FALSE, NULL);
+ SearchAndDeleteRegistrySubString (HKEY_CLASSES_ROOT, L"Local Settings\\Software\\Microsoft\\Windows\\Shell\\MuiCache", L"VeraCrypt", FALSE, NULL);
// clean other VeraCrypt entries from all users
- SearchAndDeleteRegistrySubString (HKEY_USERS, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\.hc", NULL, TRUE, NULL);
- SearchAndDeleteRegistrySubString (HKEY_USERS, "Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Compatibility Assistant\\Persisted", "VeraCrypt", TRUE, NULL);
- SearchAndDeleteRegistrySubString (HKEY_USERS, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StartPage\\NewShortcuts", "VeraCrypt", TRUE, NULL);
+ SearchAndDeleteRegistrySubString (HKEY_USERS, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\.hc", NULL, TRUE, NULL);
+ SearchAndDeleteRegistrySubString (HKEY_USERS, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Compatibility Assistant\\Persisted", L"VeraCrypt", TRUE, NULL);
+ SearchAndDeleteRegistrySubString (HKEY_USERS, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StartPage\\NewShortcuts", L"VeraCrypt", TRUE, NULL);
- if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SYSTEM", 0, KEY_ALL_ACCESS | WRITE_DAC | WRITE_OWNER, &hKey) == ERROR_SUCCESS)
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SYSTEM", 0, KEY_ALL_ACCESS | WRITE_DAC | WRITE_OWNER, &hKey) == ERROR_SUCCESS)
{
- SearchAndDeleteRegistrySubString (hKey, "Enum\\Root\\LEGACY_VERACRYPT", NULL, TRUE, "ControlSet");
- SearchAndDeleteRegistrySubString (hKey, "services\\veracrypt", NULL, TRUE, "ControlSet");
+ SearchAndDeleteRegistrySubString (hKey, L"Enum\\Root\\LEGACY_VERACRYPT", NULL, TRUE, L"ControlSet");
+ SearchAndDeleteRegistrySubString (hKey, L"services\\veracrypt", NULL, TRUE, L"ControlSet");
RegCloseKey(hKey);
}
@@ -1316,7 +1311,7 @@ BOOL DoRegUninstall (HWND hwndDlg, BOOL bRemoveDeprecated)
}
-BOOL DoServiceUninstall (HWND hwndDlg, char *lpszService)
+BOOL DoServiceUninstall (HWND hwndDlg, wchar_t *lpszService)
{
SC_HANDLE hManager, hService = NULL;
BOOL bOK = FALSE, bRet;
@@ -1336,7 +1331,7 @@ retry:
if (hService == NULL)
goto error;
- if (strcmp ("veracrypt", lpszService) == 0)
+ if (wcscmp (L"veracrypt", lpszService) == 0)
{
try
{
@@ -1397,7 +1392,7 @@ retry:
try_delete:
- if (strcmp ("veracrypt", lpszService) == 0)
+ if (wcscmp (L"veracrypt", lpszService) == 0)
StatusMessage (hwndDlg, "REMOVING_DRIVER");
else
StatusMessageParam (hwndDlg, "REMOVING", lpszService);
@@ -1651,10 +1646,10 @@ BOOL UpgradeBootLoader (HWND hwndDlg)
}
-BOOL DoShortcutsUninstall (HWND hwndDlg, char *szDestDir)
+BOOL DoShortcutsUninstall (HWND hwndDlg, wchar_t *szDestDir)
{
- char szLinkDir[TC_MAX_PATH];
- char szTmp2[TC_MAX_PATH];
+ wchar_t szLinkDir[TC_MAX_PATH];
+ wchar_t szTmp2[TC_MAX_PATH];
BOOL bSlash, bOK = FALSE;
HRESULT hOle;
int x;
@@ -1664,54 +1659,54 @@ BOOL DoShortcutsUninstall (HWND hwndDlg, char *szDestDir)
// User start menu
SHGetSpecialFolderPath (hwndDlg, szLinkDir, CSIDL_PROGRAMS, 0);
- x = strlen (szLinkDir);
- if (szLinkDir[x - 1] == '\\')
+ x = wcslen (szLinkDir);
+ if (szLinkDir[x - 1] == L'\\')
bSlash = TRUE;
else
bSlash = FALSE;
if (bSlash == FALSE)
- StringCbCatA (szLinkDir, sizeof(szLinkDir), "\\");
+ StringCbCatW (szLinkDir, sizeof(szLinkDir), L"\\");
- StringCbCatA (szLinkDir, sizeof(szLinkDir), "VeraCrypt");
+ StringCbCatW (szLinkDir, sizeof(szLinkDir), L"VeraCrypt");
// Global start menu
{
struct _stat st;
- char path[TC_MAX_PATH];
+ wchar_t path[TC_MAX_PATH];
SHGetSpecialFolderPath (hwndDlg, path, CSIDL_COMMON_PROGRAMS, 0);
- StringCbCatA (path, sizeof(path), "\\VeraCrypt");
+ StringCbCatW (path, sizeof(path), L"\\VeraCrypt");
- if (_stat (path, &st) == 0)
+ if (_wstat (path, &st) == 0)
{
- StringCbCopyA (szLinkDir, sizeof(szLinkDir), path);
+ StringCbCopyW (szLinkDir, sizeof(szLinkDir), path);
allUsers = TRUE;
}
}
// Start menu entries
- StringCbPrintfA (szTmp2, sizeof(szTmp2), "%s%s", szLinkDir, "\\VeraCrypt.lnk");
+ StringCbPrintfW (szTmp2, sizeof(szTmp2), L"%s%s", szLinkDir, L"\\VeraCrypt.lnk");
RemoveMessage (hwndDlg, szTmp2);
if (StatDeleteFile (szTmp2, FALSE) == FALSE)
goto error;
- StringCbPrintfA (szTmp2, sizeof(szTmp2), "%s%s", szLinkDir, "\\VeraCryptExpander.lnk");
+ StringCbPrintfW (szTmp2, sizeof(szTmp2), L"%s%s", szLinkDir, L"\\VeraCryptExpander.lnk");
RemoveMessage (hwndDlg, szTmp2);
if (StatDeleteFile (szTmp2, FALSE) == FALSE)
goto error;
- StringCbPrintfA (szTmp2, sizeof(szTmp2), "%s%s", szLinkDir, "\\VeraCrypt Website.url");
+ StringCbPrintfW (szTmp2, sizeof(szTmp2), L"%s%s", szLinkDir, L"\\VeraCrypt Website.url");
RemoveMessage (hwndDlg, szTmp2);
if (StatDeleteFile (szTmp2, FALSE) == FALSE)
goto error;
- StringCbPrintfA (szTmp2, sizeof(szTmp2), "%s%s", szLinkDir, "\\Uninstall VeraCrypt.lnk");
+ StringCbPrintfW (szTmp2, sizeof(szTmp2), L"%s%s", szLinkDir, L"\\Uninstall VeraCrypt.lnk");
RemoveMessage (hwndDlg, szTmp2);
if (StatDeleteFile (szTmp2, FALSE) == FALSE)
goto error;
- StringCbPrintfA (szTmp2, sizeof(szTmp2), "%s%s", szLinkDir, "\\VeraCrypt User's Guide.lnk");
+ StringCbPrintfW (szTmp2, sizeof(szTmp2), L"%s%s", szLinkDir, L"\\VeraCrypt User's Guide.lnk");
DeleteFile (szTmp2);
// Start menu group
@@ -1726,7 +1721,7 @@ BOOL DoShortcutsUninstall (HWND hwndDlg, char *szDestDir)
else
SHGetSpecialFolderPath (hwndDlg, szLinkDir, CSIDL_DESKTOPDIRECTORY, 0);
- StringCbPrintfA (szTmp2, sizeof(szTmp2), "%s%s", szLinkDir, "\\VeraCrypt.lnk");
+ StringCbPrintfW (szTmp2, sizeof(szTmp2), L"%s%s", szLinkDir, L"\\VeraCrypt.lnk");
RemoveMessage (hwndDlg, szTmp2);
if (StatDeleteFile (szTmp2, FALSE) == FALSE)
@@ -1740,10 +1735,10 @@ error:
return bOK;
}
-BOOL DoShortcutsInstall (HWND hwndDlg, char *szDestDir, BOOL bProgGroup, BOOL bDesktopIcon)
+BOOL DoShortcutsInstall (HWND hwndDlg, wchar_t *szDestDir, BOOL bProgGroup, BOOL bDesktopIcon)
{
- char szLinkDir[TC_MAX_PATH], szDir[TC_MAX_PATH];
- char szTmp[TC_MAX_PATH], szTmp2[TC_MAX_PATH], szTmp3[TC_MAX_PATH];
+ wchar_t szLinkDir[TC_MAX_PATH], szDir[TC_MAX_PATH];
+ wchar_t szTmp[TC_MAX_PATH], szTmp2[TC_MAX_PATH], szTmp3[TC_MAX_PATH];
BOOL bSlash, bOK = FALSE;
HRESULT hOle;
int x;
@@ -1755,26 +1750,26 @@ BOOL DoShortcutsInstall (HWND hwndDlg, char *szDestDir, BOOL bProgGroup, BOOL bD
GetProgramPath (hwndDlg, szLinkDir);
- x = strlen (szLinkDir);
- if (szLinkDir[x - 1] == '\\')
+ x = wcslen (szLinkDir);
+ if (szLinkDir[x - 1] == L'\\')
bSlash = TRUE;
else
bSlash = FALSE;
if (bSlash == FALSE)
- StringCbCatA (szLinkDir, sizeof(szLinkDir), "\\");
+ StringCbCatW (szLinkDir, sizeof(szLinkDir), L"\\");
- StringCbCatA (szLinkDir, sizeof(szLinkDir), "VeraCrypt");
+ StringCbCatW (szLinkDir, sizeof(szLinkDir), L"VeraCrypt");
- StringCbCopyA (szDir, sizeof(szDir), szDestDir);
- x = strlen (szDestDir);
- if (szDestDir[x - 1] == '\\')
+ StringCbCopyW (szDir, sizeof(szDir), szDestDir);
+ x = wcslen (szDestDir);
+ if (szDestDir[x - 1] == L'\\')
bSlash = TRUE;
else
bSlash = FALSE;
if (bSlash == FALSE)
- StringCbCatA (szDir, sizeof(szDir), "\\");
+ StringCbCatW (szDir, sizeof(szDir), L"\\");
if (bProgGroup)
{
@@ -1793,23 +1788,23 @@ BOOL DoShortcutsInstall (HWND hwndDlg, char *szDestDir, BOOL bProgGroup, BOOL bD
}
}
- StringCbPrintfA (szTmp, sizeof(szTmp), "%s%s", szDir, "VeraCrypt.exe");
- StringCbPrintfA (szTmp2, sizeof(szTmp2), "%s%s", szLinkDir, "\\VeraCrypt.lnk");
+ StringCbPrintfW (szTmp, sizeof(szTmp), L"%s%s", szDir, L"VeraCrypt.exe");
+ StringCbPrintfW (szTmp2, sizeof(szTmp2), L"%s%s", szLinkDir, L"\\VeraCrypt.lnk");
IconMessage (hwndDlg, szTmp2);
- if (CreateLink (szTmp, "", szTmp2, NULL, -1) != S_OK)
+ if (CreateLink (szTmp, L"", szTmp2, NULL, -1) != S_OK)
goto error;
- StringCbPrintfA (szTmp, sizeof(szTmp), "%s%s", szDir, "VeraCryptExpander.exe");
- StringCbPrintfA (szTmp2, sizeof(szTmp2), "%s%s", szLinkDir, "\\VeraCryptExpander.lnk");
+ StringCbPrintfW (szTmp, sizeof(szTmp), L"%s%s", szDir, L"VeraCryptExpander.exe");
+ StringCbPrintfW (szTmp2, sizeof(szTmp2), L"%s%s", szLinkDir, L"\\VeraCryptExpander.lnk");
IconMessage (hwndDlg, szTmp2);
- if (CreateLink (szTmp, "", szTmp2, NULL, -1) != S_OK)
+ if (CreateLink (szTmp, L"", szTmp2, NULL, -1) != S_OK)
goto error;
- StringCbPrintfA (szTmp2, sizeof(szTmp2), "%s%s", szLinkDir, "\\VeraCrypt Website.url");
+ StringCbPrintfW (szTmp2, sizeof(szTmp2), L"%s%s", szLinkDir, L"\\VeraCrypt Website.url");
IconMessage (hwndDlg, szTmp2);
- f = fopen (szTmp2, "w");
+ f = _wfopen (szTmp2, L"w");
if (f)
{
fprintf (f, "[InternetShortcut]\nURL=%s\n", TC_APPLINK);
@@ -1820,46 +1815,46 @@ BOOL DoShortcutsInstall (HWND hwndDlg, char *szDestDir, BOOL bProgGroup, BOOL bD
else
goto error;
- StringCbPrintfA (szTmp, sizeof(szTmp), "%s%s", szDir, "VeraCrypt Setup.exe");
- StringCbPrintfA (szTmp2, sizeof(szTmp2), "%s%s", szLinkDir, "\\Uninstall VeraCrypt.lnk");
- if (GetSystemDirectoryA (szTmp3, sizeof(szTmp3)))
+ StringCbPrintfW (szTmp, sizeof(szTmp), L"%s%s", szDir, L"VeraCrypt Setup.exe");
+ StringCbPrintfW (szTmp2, sizeof(szTmp2), L"%s%s", szLinkDir, L"\\Uninstall VeraCrypt.lnk");
+ if (GetSystemDirectory (szTmp3, ARRAYSIZE(szTmp3)))
{
- StringCbCatA (szTmp3, sizeof(szTmp3), "\\control.exe");
+ StringCbCatW (szTmp3, sizeof(szTmp3), L"\\control.exe");
}
else
- StringCbCopyA(szTmp3, sizeof(szTmp3), "C:\\Windows\\System32\\control.exe");
+ StringCbCopyW(szTmp3, sizeof(szTmp3), L"C:\\Windows\\System32\\control.exe");
IconMessage (hwndDlg, szTmp2);
- if (CreateLink (szTmp3, "appwiz.cpl", szTmp2, szTmp, 0) != S_OK)
+ if (CreateLink (szTmp3, L"appwiz.cpl", szTmp2, szTmp, 0) != S_OK)
goto error;
- StringCbPrintfA (szTmp2, sizeof(szTmp2), "%s%s", szLinkDir, "\\VeraCrypt User's Guide.lnk");
+ StringCbPrintfW (szTmp2, sizeof(szTmp2), L"%s%s", szLinkDir, L"\\VeraCrypt User's Guide.lnk");
DeleteFile (szTmp2);
}
if (bDesktopIcon)
{
- StringCbCopyA (szDir, sizeof(szDir), szDestDir);
- x = strlen (szDestDir);
- if (szDestDir[x - 1] == '\\')
+ StringCbCopyW (szDir, sizeof(szDir), szDestDir);
+ x = wcslen (szDestDir);
+ if (szDestDir[x - 1] == L'\\')
bSlash = TRUE;
else
bSlash = FALSE;
if (bSlash == FALSE)
- StringCbCatA (szDir, sizeof(szDir), "\\");
+ StringCbCatW (szDir, sizeof(szDir), L"\\");
if (bForAllUsers)
SHGetSpecialFolderPath (hwndDlg, szLinkDir, CSIDL_COMMON_DESKTOPDIRECTORY, 0);
else
SHGetSpecialFolderPath (hwndDlg, szLinkDir, CSIDL_DESKTOPDIRECTORY, 0);
- StringCbPrintfA (szTmp, sizeof(szTmp), "%s%s", szDir, "VeraCrypt.exe");
- StringCbPrintfA (szTmp2, sizeof(szTmp2), "%s%s", szLinkDir, "\\VeraCrypt.lnk");
+ StringCbPrintfW (szTmp, sizeof(szTmp), L"%s%s", szDir, L"VeraCrypt.exe");
+ StringCbPrintfW (szTmp2, sizeof(szTmp2), L"%s%s", szLinkDir, L"\\VeraCrypt.lnk");
IconMessage (hwndDlg, szTmp2);
- if (CreateLink (szTmp, "", szTmp2, NULL, -1) != S_OK)
+ if (CreateLink (szTmp, L"", szTmp2, NULL, -1) != S_OK)
goto error;
}
@@ -1915,7 +1910,7 @@ static void SetSystemRestorePoint (HWND hwndDlg, BOOL finalize)
if (!SystemRestoreDll) return;
- _SRSetRestorePoint = (BOOL (__stdcall *)(PRESTOREPOINTINFO, PSTATEMGRSTATUS))GetProcAddress (SystemRestoreDll,"SRSetRestorePointA");
+ _SRSetRestorePoint = (BOOL (__stdcall *)(PRESTOREPOINTINFO, PSTATEMGRSTATUS))GetProcAddress (SystemRestoreDll,"SRSetRestorePointW");
if (_SRSetRestorePoint == 0)
{
FreeLibrary (SystemRestoreDll);
@@ -1930,7 +1925,7 @@ static void SetSystemRestorePoint (HWND hwndDlg, BOOL finalize)
RestPtInfo.dwEventType = BEGIN_SYSTEM_CHANGE;
RestPtInfo.dwRestorePtType = bUninstall ? APPLICATION_UNINSTALL : APPLICATION_INSTALL | DEVICE_DRIVER_INSTALL;
RestPtInfo.llSequenceNumber = 0;
- StringCbCopyA (RestPtInfo.szDescription, sizeof(RestPtInfo.szDescription), bUninstall ? "VeraCrypt uninstallation" : "VeraCrypt installation");
+ StringCbCopyW (RestPtInfo.szDescription, sizeof(RestPtInfo.szDescription), bUninstall ? L"VeraCrypt uninstallation" : L"VeraCrypt installation");
if(!_SRSetRestorePoint (&RestPtInfo, &SMgrStatus))
{
@@ -1976,7 +1971,7 @@ void DoUninstall (void *arg)
if (!Rollback && bSystemRestore && !bTempSkipSysRestore)
SetSystemRestorePoint (hwndDlg, FALSE);
- if (DoServiceUninstall (hwndDlg, "veracrypt") == FALSE)
+ if (DoServiceUninstall (hwndDlg, L"veracrypt") == FALSE)
{
bOK = FALSE;
}
@@ -1998,30 +1993,30 @@ void DoUninstall (void *arg)
}
else
{
- char temp[MAX_PATH];
+ wchar_t temp[MAX_PATH];
FILE *f;
// Deprecated service
- DoServiceUninstall (hwndDlg, "VeraCryptService");
+ DoServiceUninstall (hwndDlg, L"VeraCryptService");
- GetTempPath (sizeof (temp), temp);
- StringCbPrintfA (UninstallBatch, sizeof (UninstallBatch), "%sVeraCrypt-Uninstall.bat", temp);
+ GetTempPath (ARRAYSIZE (temp), temp);
+ StringCbPrintfW (UninstallBatch, sizeof (UninstallBatch), L"%sVeraCrypt-Uninstall.bat", temp);
- UninstallBatch [sizeof(UninstallBatch)-1] = 0;
+ UninstallBatch [ARRAYSIZE(UninstallBatch)-1] = 0;
// Create uninstall batch
- f = fopen (UninstallBatch, "w");
+ f = _wfopen (UninstallBatch, L"w");
if (!f)
bOK = FALSE;
else
{
- fprintf (f,":loop\n"
- "del \"%s%s\"\n"
- "if exist \"%s%s\" goto loop\n"
- "rmdir \"%s\"\n"
- "del \"%s\"",
- InstallationPath, "VeraCrypt Setup.exe",
- InstallationPath, "VeraCrypt Setup.exe",
+ fwprintf (f,L":loop\n"
+ L"del \"%s%s\"\n"
+ L"if exist \"%s%s\" goto loop\n"
+ L"rmdir \"%s\"\n"
+ L"del \"%s\"",
+ InstallationPath, L"VeraCrypt Setup.exe",
+ InstallationPath, L"VeraCrypt Setup.exe",
InstallationPath,
UninstallBatch
);
@@ -2053,7 +2048,7 @@ void DoInstall (void *arg)
{
HWND hwndDlg = (HWND) arg;
BOOL bOK = TRUE;
- char path[MAX_PATH];
+ wchar_t path[MAX_PATH];
BootEncryption bootEnc (hwndDlg);
@@ -2087,16 +2082,16 @@ void DoInstall (void *arg)
}
if (bUpgrade
- && (IsFileInUse (string (InstallationPath) + '\\' + TC_APP_NAME ".exe")
- || IsFileInUse (string (InstallationPath) + '\\' + TC_APP_NAME "-x86.exe")
- || IsFileInUse (string (InstallationPath) + '\\' + TC_APP_NAME "-x64.exe")
- || IsFileInUse (string (InstallationPath) + '\\' + TC_APP_NAME " Format.exe")
- || IsFileInUse (string (InstallationPath) + '\\' + TC_APP_NAME " Format-x86.exe")
- || IsFileInUse (string (InstallationPath) + '\\' + TC_APP_NAME " Format-x64.exe")
- || IsFileInUse (string (InstallationPath) + '\\' + TC_APP_NAME "Expander.exe")
- || IsFileInUse (string (InstallationPath) + '\\' + TC_APP_NAME "Expander-x86.exe")
- || IsFileInUse (string (InstallationPath) + '\\' + TC_APP_NAME "Expander-x64.exe")
- || IsFileInUse (string (InstallationPath) + '\\' + TC_APP_NAME " Setup.exe")
+ && (IsFileInUse (wstring (InstallationPath) + L'\\' + _T(TC_APP_NAME) L".exe")
+ || IsFileInUse (wstring (InstallationPath) + L'\\' + _T(TC_APP_NAME) L"-x86.exe")
+ || IsFileInUse (wstring (InstallationPath) + L'\\' + _T(TC_APP_NAME) L"-x64.exe")
+ || IsFileInUse (wstring (InstallationPath) + L'\\' + _T(TC_APP_NAME) L" Format.exe")
+ || IsFileInUse (wstring (InstallationPath) + L'\\' + _T(TC_APP_NAME) L" Format-x86.exe")
+ || IsFileInUse (wstring (InstallationPath) + L'\\' + _T(TC_APP_NAME) L" Format-x64.exe")
+ || IsFileInUse (wstring (InstallationPath) + L'\\' + _T(TC_APP_NAME) L"Expander.exe")
+ || IsFileInUse (wstring (InstallationPath) + L'\\' + _T(TC_APP_NAME) L"Expander-x86.exe")
+ || IsFileInUse (wstring (InstallationPath) + L'\\' + _T(TC_APP_NAME) L"Expander-x64.exe")
+ || IsFileInUse (wstring (InstallationPath) + L'\\' + _T(TC_APP_NAME) L" Setup.exe")
)
)
{
@@ -2128,7 +2123,7 @@ void DoInstall (void *arg)
UpdateProgressBarProc(50);
// Remove deprecated
- DoServiceUninstall (hwndDlg, "VeraCryptService");
+ DoServiceUninstall (hwndDlg, L"VeraCryptService");
UpdateProgressBarProc(55);
@@ -2137,11 +2132,11 @@ void DoInstall (void *arg)
UpdateProgressBarProc(61);
- GetWindowsDirectory (path, sizeof (path));
- StringCbCatA (path, sizeof (path), "\\VeraCrypt Setup.exe");
+ GetWindowsDirectory (path, ARRAYSIZE (path));
+ StringCbCatW (path, sizeof (path), L"\\VeraCrypt Setup.exe");
DeleteFile (path);
- if (UpdateProgressBarProc(63) && UnloadDriver && DoServiceUninstall (hwndDlg, "veracrypt") == FALSE)
+ if (UpdateProgressBarProc(63) && UnloadDriver && DoServiceUninstall (hwndDlg, L"veracrypt") == FALSE)
{
bOK = FALSE;
}
@@ -2254,89 +2249,37 @@ void SetInstallationPath (HWND hwndDlg)
{
HKEY hkey;
BOOL bInstallPathDetermined = FALSE;
- char path[MAX_PATH+20];
+ wchar_t path[MAX_PATH+20];
ITEMIDLIST *itemList;
memset (InstallationPath, 0, sizeof (InstallationPath));
// Determine if VeraCrypt is already installed and try to determine its "Program Files" location
- if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\VeraCrypt", 0, KEY_READ | KEY_WOW64_32KEY, &hkey) == ERROR_SUCCESS)
+ if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\VeraCrypt", 0, KEY_READ | KEY_WOW64_32KEY, &hkey) == ERROR_SUCCESS)
{
- /* Default 'UninstallString' registry strings written by past versions of VeraCrypt:
+ /* Default 'UninstallString' registry strings written by VeraCrypt:
------------------------------------------------------------------------------------
- 1.0 C:\WINDOWS\VeraCrypt Setup.exe /u [optional]
- 1.0a C:\WINDOWS\VeraCrypt Setup.exe /u [optional]
- 2.0 C:\WINDOWS\VeraCrypt Setup.exe /u [optional]
- 2.1 C:\WINDOWS\VeraCrypt Setup.exe /u [optional]
- 2.1a C:\WINDOWS\VeraCrypt Setup.exe /u [optional]
- 3.0 C:\WINDOWS\VeraCrypt Setup.exe /u [optional]
- 3.0a C:\WINDOWS\VeraCrypt Setup.exe /u [optional]
- 3.1 The UninstallString was NEVER written (fortunately, 3.1a replaced 3.1 after 2 weeks)
- 3.1a C:\WINDOWS\VeraCrypt Setup.exe /u
- 4.0 C:\WINDOWS\VeraCrypt Setup.exe /u C:\Program Files\VeraCrypt
- 4.1 C:\WINDOWS\VeraCrypt Setup.exe /u C:\Program Files\VeraCrypt
- 4.2 C:\WINDOWS\VeraCrypt Setup.exe /u C:\Program Files\VeraCrypt
- 4.2a C:\WINDOWS\VeraCrypt Setup.exe /u C:\Program Files\VeraCrypt
- 4.3 "C:\Program Files\VeraCrypt\VeraCrypt Setup.exe" /u C:\Program Files\VeraCrypt\
- 4.3a "C:\Program Files\VeraCrypt\VeraCrypt Setup.exe" /u C:\Program Files\VeraCrypt\
5.0+ "C:\Program Files\VeraCrypt\VeraCrypt Setup.exe" /u
-
- Note: In versions 1.0-3.0a the user was able to choose whether to install the uninstaller.
- The default was to install it. If it wasn't installed, there was no UninstallString.
*/
- char rv[MAX_PATH*4];
+ wchar_t rv[MAX_PATH*4];
DWORD size = sizeof (rv);
- if (RegQueryValueEx (hkey, "UninstallString", 0, 0, (LPBYTE) &rv, &size) == ERROR_SUCCESS && strrchr (rv, '/'))
+ if (RegQueryValueEx (hkey, L"UninstallString", 0, 0, (LPBYTE) &rv, &size) == ERROR_SUCCESS && wcsrchr (rv, L'/'))
{
size_t len = 0;
// Cut and paste the location (path) where VeraCrypt is installed to InstallationPath
- if (rv[0] == '"')
+ if (rv[0] == L'"')
{
- // 4.3 or later
-
- len = strrchr (rv, '/') - rv - 2;
- StringCbCopyNA (InstallationPath, sizeof(InstallationPath), rv + 1, len);
+ len = wcsrchr (rv, L'/') - rv - 2;
+ StringCchCopyNW (InstallationPath, ARRAYSIZE(InstallationPath), rv + 1, len);
InstallationPath [len] = 0;
bInstallPathDetermined = TRUE;
- if (InstallationPath [strlen (InstallationPath) - 1] != '\\')
- {
- len = strrchr (InstallationPath, '\\') - InstallationPath;
- InstallationPath [len] = 0;
- }
- }
- else
- {
- // 1.0-4.2a (except 3.1)
-
- len = strrchr (rv, '/') - rv;
- if (rv[len+2] == ' ')
- {
- // 4.0-4.2a
-
- StringCbCopyNA (InstallationPath, sizeof(InstallationPath), rv + len + 3, strlen (rv) - len - 3);
- InstallationPath [strlen (rv) - len - 3] = 0;
- bInstallPathDetermined = TRUE;
- }
- else
+ if (InstallationPath [wcslen (InstallationPath) - 1] != L'\\')
{
- // 1.0-3.1a (except 3.1)
-
- // We know that VeraCrypt is installed but don't know where. It's not safe to continue installing
- // over the old version.
-
- Error ("UNINSTALL_OLD_VERSION_FIRST", hwndDlg);
-
- len = strrchr (rv, '/') - rv - 1;
- StringCbCopyNA (InstallationPath, sizeof(InstallationPath), rv, len); // Path and filename of the uninstaller
+ len = wcsrchr (InstallationPath, L'\\') - InstallationPath;
InstallationPath [len] = 0;
- bInstallPathDetermined = FALSE;
-
- ShellExecute (NULL, "open", InstallationPath, "/u", NULL, SW_SHOWNORMAL);
- RegCloseKey (hkey);
- exit (1);
}
}
@@ -2346,11 +2289,11 @@ void SetInstallationPath (HWND hwndDlg)
if (bInstallPathDetermined)
{
- char mp[MAX_PATH];
+ wchar_t mp[MAX_PATH];
// Determine whether we were launched from the folder where VeraCrypt is installed
- GetModuleFileName (NULL, mp, sizeof (mp));
- if (strncmp (InstallationPath, mp, min (strlen(InstallationPath), strlen(mp))) == 0)
+ GetModuleFileName (NULL, mp, ARRAYSIZE (mp));
+ if (wcsncmp (InstallationPath, mp, min (wcslen(InstallationPath), wcslen(mp))) == 0)
{
// We were launched from the folder where VeraCrypt is installed
@@ -2369,24 +2312,24 @@ void SetInstallationPath (HWND hwndDlg)
if (Is64BitOs())
{
// Use a unified default installation path (registry redirection of %ProgramFiles% does not work if the installation path is user-selectable)
- string s = path;
- size_t p = s.find (" (x86)");
- if (p != string::npos)
+ wstring s = path;
+ size_t p = s.find (L" (x86)");
+ if (p != wstring::npos)
{
s = s.substr (0, p);
- if (_access (s.c_str(), 0) != -1)
- StringCbCopyA (path, sizeof (path), s.c_str());
+ if (_waccess (s.c_str(), 0) != -1)
+ StringCbCopyW (path, sizeof (path), s.c_str());
}
}
- StringCbCatA (path, sizeof(path), "\\VeraCrypt\\");
- StringCbCopyA (InstallationPath, sizeof(InstallationPath), path);
+ StringCbCatW (path, sizeof(path), L"\\VeraCrypt\\");
+ StringCbCopyW (InstallationPath, sizeof(InstallationPath), path);
}
// Make sure the path ends with a backslash
- if (InstallationPath [strlen (InstallationPath) - 1] != '\\')
+ if (InstallationPath [wcslen (InstallationPath) - 1] != L'\\')
{
- StringCbCatA (InstallationPath, sizeof(InstallationPath), "\\");
+ StringCbCatW (InstallationPath, sizeof(InstallationPath), L"\\");
}
}
@@ -2487,7 +2430,7 @@ BOOL CALLBACK UninstallDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
}
-int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, char *lpszCommandLine, int nCmdShow)
+int WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, wchar_t *lpszCommandLine, int nCmdShow)
{
atexit (localcleanup);
@@ -2509,36 +2452,36 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, char *lpszComm
/* Setup directory */
{
- char *s;
- GetModuleFileName (NULL, SetupFilesDir, sizeof (SetupFilesDir));
- s = strrchr (SetupFilesDir, '\\');
+ wchar_t *s;
+ GetModuleFileName (NULL, SetupFilesDir, ARRAYSIZE (SetupFilesDir));
+ s = wcsrchr (SetupFilesDir, L'\\');
if (s)
s[1] = 0;
}
/* Parse command line arguments */
- if (lpszCommandLine[0] == '/')
+ if (lpszCommandLine[0] == L'/')
{
- if (lpszCommandLine[1] == 'u')
+ if (lpszCommandLine[1] == L'u')
{
// Uninstall: /u
bUninstall = TRUE;
}
- else if (lpszCommandLine[1] == 'c')
+ else if (lpszCommandLine[1] == L'c')
{
// Change: /c
bChangeMode = TRUE;
}
- else if (lpszCommandLine[1] == 'p')
+ else if (lpszCommandLine[1] == L'p')
{
// Create self-extracting package: /p
bMakePackage = TRUE;
}
- else if (lpszCommandLine[1] == 'd')
+ else if (lpszCommandLine[1] == L'd')
{
// Dev mode: /d
bDevm = TRUE;
@@ -2568,7 +2511,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, char *lpszComm
}
else if (!bDevm)
{
- MessageBox (NULL, "Error: This installer file does not contain any compressed files.\n\nTo create a self-extracting installation package (with embedded compressed files), run:\n\"VeraCrypt Setup.exe\" /p", "VeraCrypt", MB_ICONERROR | MB_SETFOREGROUND | MB_TOPMOST);
+ MessageBox (NULL, L"Error: This installer file does not contain any compressed files.\n\nTo create a self-extracting installation package (with embedded compressed files), run:\n\"VeraCrypt Setup.exe\" /p", L"VeraCrypt", MB_ICONERROR | MB_SETFOREGROUND | MB_TOPMOST);
FinalizeApp ();
exit (1);
}
@@ -2598,13 +2541,13 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, char *lpszComm
// System Restore
if (IsSystemRestoreEnabled ())
{
- char dllPath[MAX_PATH];
+ wchar_t dllPath[MAX_PATH];
if (GetSystemDirectory (dllPath, MAX_PATH))
{
- StringCbCatA(dllPath, sizeof(dllPath), "\\srclient.dll");
+ StringCbCatW(dllPath, sizeof(dllPath), L"\\srclient.dll");
}
else
- StringCbCopyA(dllPath, sizeof(dllPath), "C:\\Windows\\System32\\srclient.dll");
+ StringCbCopyW(dllPath, sizeof(dllPath), L"C:\\Windows\\System32\\srclient.dll");
SystemRestoreDll = LoadLibrary (dllPath);
}
else
diff --git a/src/Setup/Setup.h b/src/Setup/Setup.h
index 99a6061..5327190 100644
--- a/src/Setup/Setup.h
+++ b/src/Setup/Setup.h
@@ -19,146 +19,144 @@ extern "C" {
#endif
// Specifies what files to install, where (determined by the prefix), and in what order
-static char *szFiles[]=
+static wchar_t *szFiles[]=
{
- "AVeraCrypt User Guide.pdf",
- "ALicense.txt",
- "ALICENSE",
- "ANOTICE",
- "AVeraCrypt.exe",
- "AVeraCryptExpander.exe",
- "AVeraCrypt Format.exe",
- "AVeraCrypt-x86.exe",
- "AVeraCryptExpander-x86.exe",
- "AVeraCrypt Format-x86.exe",
- "AVeraCrypt-x64.exe",
- "AVeraCryptExpander-x64.exe",
- "AVeraCrypt Format-x64.exe",
- "Averacrypt.sys",
- "Averacrypt-x64.sys",
- "Dveracrypt.sys",
- "AVeraCrypt Setup.exe",
- "ALanguage.ar.xml",
- "ALanguage.be.xml",
- "ALanguage.bg.xml",
- "ALanguage.ca.xml",
- "ALanguage.cs.xml",
- "ALanguage.da.xml",
- "ALanguage.de.xml",
- "ALanguage.el.xml",
- "ALanguage.es.xml",
- "ALanguage.et.xml",
- "ALanguage.eu.xml",
- "ALanguage.fa.xml",
- "ALanguage.fi.xml",
- "ALanguage.fr.xml",
- "ALanguage.hu.xml",
- "ALanguage.id.xml",
- "ALanguage.it.xml",
- "ALanguage.ja.xml",
- "ALanguage.ka.xml",
- "ALanguage.ko.xml",
- "ALanguage.lv.xml",
- "ALanguage.my.xml",
- "ALanguage.nl.xml",
- "ALanguage.nn.xml",
- "ALanguage.pl.xml",
- "ALanguage.pt-br.xml",
- "ALanguage.ru.xml",
- "ALanguage.sk.xml",
- "ALanguage.sl.xml",
- "ALanguage.sv.xml",
- "ALanguage.tr.xml",
- "ALanguage.uk.xml",
- "ALanguage.uz.xml",
- "ALanguage.vi.xml",
- "ALanguage.zh-cn.xml",
- "ALanguage.zh-hk.xml",
- "ALanguage.zh-tw.xml"
+ L"AVeraCrypt User Guide.pdf",
+ L"ALicense.txt",
+ L"ALICENSE",
+ L"ANOTICE",
+ L"AVeraCrypt.exe",
+ L"AVeraCryptExpander.exe",
+ L"AVeraCrypt Format.exe",
+ L"AVeraCrypt-x86.exe",
+ L"AVeraCryptExpander-x86.exe",
+ L"AVeraCrypt Format-x86.exe",
+ L"AVeraCrypt-x64.exe",
+ L"AVeraCryptExpander-x64.exe",
+ L"AVeraCrypt Format-x64.exe",
+ L"Averacrypt.sys",
+ L"Averacrypt-x64.sys",
+ L"Dveracrypt.sys",
+ L"AVeraCrypt Setup.exe",
+ L"ALanguage.ar.xml",
+ L"ALanguage.be.xml",
+ L"ALanguage.bg.xml",
+ L"ALanguage.ca.xml",
+ L"ALanguage.cs.xml",
+ L"ALanguage.da.xml",
+ L"ALanguage.de.xml",
+ L"ALanguage.el.xml",
+ L"ALanguage.es.xml",
+ L"ALanguage.et.xml",
+ L"ALanguage.eu.xml",
+ L"ALanguage.fa.xml",
+ L"ALanguage.fi.xml",
+ L"ALanguage.fr.xml",
+ L"ALanguage.hu.xml",
+ L"ALanguage.id.xml",
+ L"ALanguage.it.xml",
+ L"ALanguage.ja.xml",
+ L"ALanguage.ka.xml",
+ L"ALanguage.ko.xml",
+ L"ALanguage.lv.xml",
+ L"ALanguage.my.xml",
+ L"ALanguage.nl.xml",
+ L"ALanguage.nn.xml",
+ L"ALanguage.pl.xml",
+ L"ALanguage.pt-br.xml",
+ L"ALanguage.ru.xml",
+ L"ALanguage.sk.xml",
+ L"ALanguage.sl.xml",
+ L"ALanguage.sv.xml",
+ L"ALanguage.tr.xml",
+ L"ALanguage.uk.xml",
+ L"ALanguage.uz.xml",
+ L"ALanguage.vi.xml",
+ L"ALanguage.zh-cn.xml",
+ L"ALanguage.zh-hk.xml",
+ L"ALanguage.zh-tw.xml"
};
// Specifies what files are included in self-extracting packages (no other files will be packaged or extracted).
-static char *szCompressedFiles[]=
+static wchar_t *szCompressedFiles[]=
{
- "VeraCrypt User Guide.pdf",
- "License.txt",
- "LICENSE",
- "NOTICE",
- "VeraCrypt.exe",
- "VeraCryptExpander.exe",
- "VeraCrypt Format.exe",
- "VeraCrypt-x64.exe",
- "VeraCryptExpander-x64.exe",
- "VeraCrypt Format-x64.exe",
- "veracrypt.sys",
- "veracrypt-x64.sys",
- "Language.ar.xml",
- "Language.be.xml",
- "Language.bg.xml",
- "Language.ca.xml",
- "Language.cs.xml",
- "Language.da.xml",
- "Language.de.xml",
- "Language.el.xml",
- "Language.es.xml",
- "Language.et.xml",
- "Language.eu.xml",
- "Language.fa.xml",
- "Language.fi.xml",
- "Language.fr.xml",
- "Language.hu.xml",
- "Language.id.xml",
- "Language.it.xml",
- "Language.ja.xml",
- "Language.ka.xml",
- "Language.ko.xml",
- "Language.lv.xml",
- "Language.my.xml",
- "Language.nl.xml",
- "Language.nn.xml",
- "Language.pl.xml",
- "Language.pt-br.xml",
- "Language.ru.xml",
- "Language.sk.xml",
- "Language.sl.xml",
- "Language.sv.xml",
- "Language.tr.xml",
- "Language.uk.xml",
- "Language.uz.xml",
- "Language.vi.xml",
- "Language.zh-cn.xml",
- "Language.zh-hk.xml",
- "Language.zh-tw.xml"
+ L"VeraCrypt User Guide.pdf",
+ L"License.txt",
+ L"LICENSE",
+ L"NOTICE",
+ L"VeraCrypt.exe",
+ L"VeraCryptExpander.exe",
+ L"VeraCrypt Format.exe",
+ L"VeraCrypt-x64.exe",
+ L"VeraCryptExpander-x64.exe",
+ L"VeraCrypt Format-x64.exe",
+ L"veracrypt.sys",
+ L"veracrypt-x64.sys",
+ L"Language.ar.xml",
+ L"Language.be.xml",
+ L"Language.bg.xml",
+ L"Language.ca.xml",
+ L"Language.cs.xml",
+ L"Language.da.xml",
+ L"Language.de.xml",
+ L"Language.el.xml",
+ L"Language.es.xml",
+ L"Language.et.xml",
+ L"Language.eu.xml",
+ L"Language.fa.xml",
+ L"Language.fi.xml",
+ L"Language.fr.xml",
+ L"Language.hu.xml",
+ L"Language.id.xml",
+ L"Language.it.xml",
+ L"Language.ja.xml",
+ L"Language.ka.xml",
+ L"Language.ko.xml",
+ L"Language.lv.xml",
+ L"Language.my.xml",
+ L"Language.nl.xml",
+ L"Language.nn.xml",
+ L"Language.pl.xml",
+ L"Language.pt-br.xml",
+ L"Language.ru.xml",
+ L"Language.sk.xml",
+ L"Language.sl.xml",
+ L"Language.sv.xml",
+ L"Language.tr.xml",
+ L"Language.uk.xml",
+ L"Language.uz.xml",
+ L"Language.vi.xml",
+ L"Language.zh-cn.xml",
+ L"Language.zh-hk.xml",
+ L"Language.zh-tw.xml"
};
-#define FILENAME_64BIT_DRIVER "veracrypt-x64.sys"
+#define FILENAME_64BIT_DRIVER L"veracrypt-x64.sys"
#define NBR_COMPRESSED_FILES (sizeof(szCompressedFiles) / sizeof(szCompressedFiles[0]))
void localcleanup (void);
-BOOL StatDeleteFile ( char *lpszFile, BOOL bCheckForOldFile );
-BOOL StatRemoveDirectory ( char *lpszDir );
-HRESULT CreateLink ( char *lpszPathObj , char *lpszArguments , char *lpszPathLink );
-void GetProgramPath ( HWND hwndDlg , char *path );
+BOOL StatDeleteFile ( wchar_t *lpszFile, BOOL bCheckForOldFile );
+BOOL StatRemoveDirectory ( wchar_t *lpszDir );
+HRESULT CreateLink ( wchar_t *lpszPathObj , wchar_t *lpszArguments , wchar_t *lpszPathLink );
+void GetProgramPath ( HWND hwndDlg , wchar_t *path );
void StatusMessage (HWND hwndDlg, char *stringId);
-void StatusMessageParam (HWND hwndDlg, char *stringId, char *param);
+void StatusMessageParam (HWND hwndDlg, char *stringId, wchar_t *param);
void ClearLogWindow (HWND hwndDlg);
-void StatusMessage ( HWND hwndDlg , char *stringId );
-void StatusMessageParam ( HWND hwndDlg , char *stringId , char *param );
-void RegMessage ( HWND hwndDlg , char *txt );
-void RegRemoveMessage (HWND hwndDlg, char *txt);
-void CopyMessage ( HWND hwndDlg , char *txt );
-void RemoveMessage ( HWND hwndDlg , char *txt );
-void IconMessage ( HWND hwndDlg , char *txt );
+void RegMessage ( HWND hwndDlg , wchar_t *txt );
+void RegRemoveMessage (HWND hwndDlg, wchar_t *txt);
+void CopyMessage ( HWND hwndDlg , wchar_t *txt );
+void RemoveMessage ( HWND hwndDlg , wchar_t *txt );
+void IconMessage ( HWND hwndDlg , wchar_t *txt );
static int CALLBACK BrowseCallbackProc ( HWND hwnd , UINT uMsg , LPARAM lp , LPARAM pData );
void LoadLicense ( HWND hwndDlg );
void DetermineUpgradeDowngradeStatus (BOOL bCloseDriverHandle, LONG *driverVersionPtr);
-BOOL DoFilesInstall ( HWND hwndDlg , char *szDestDir );
-BOOL DoRegInstall ( HWND hwndDlg , char *szDestDir , BOOL bInstallType );
+BOOL DoFilesInstall ( HWND hwndDlg , wchar_t *szDestDir );
+BOOL DoRegInstall ( HWND hwndDlg , wchar_t *szDestDir , BOOL bInstallType );
BOOL DoRegUninstall (HWND hwndDlg, BOOL bRemoveDeprecated);
-BOOL DoServiceUninstall ( HWND hwndDlg , char *lpszService );
+BOOL DoServiceUninstall ( HWND hwndDlg , wchar_t *lpszService );
BOOL DoDriverUnload ( HWND hwndDlg );
-BOOL DoShortcutsInstall ( HWND hwndDlg , char *szDestDir , BOOL bProgGroup, BOOL bDesktopIcon );
-BOOL DoShortcutsUninstall (HWND hwndDlg, char *szDestDir);
+BOOL DoShortcutsInstall ( HWND hwndDlg , wchar_t *szDestDir , BOOL bProgGroup, BOOL bDesktopIcon );
+BOOL DoShortcutsUninstall (HWND hwndDlg, wchar_t *szDestDir);
void OutcomePrompt ( HWND hwndDlg , BOOL bOK );
void DoUninstall ( void *hwndDlg );
void DoInstall ( void *hwndDlg );
@@ -182,8 +180,8 @@ extern BOOL bDesktopIconStatusDetermined;
extern BOOL SystemEncryptionUpdate;
extern BOOL bRestartRequired;
extern HMODULE volatile SystemRestoreDll;
-extern char InstallationPath[TC_MAX_PATH];
-extern char SetupFilesDir[TC_MAX_PATH];
+extern wchar_t InstallationPath[TC_MAX_PATH];
+extern wchar_t SetupFilesDir[TC_MAX_PATH];
#ifdef __cplusplus
}
diff --git a/src/Setup/Setup.vcproj b/src/Setup/Setup.vcproj
index d44c3ed..8e70aa6 100644
--- a/src/Setup/Setup.vcproj
+++ b/src/Setup/Setup.vcproj
@@ -22,7 +22,7 @@
IntermediateDirectory="Debug"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- CharacterSet="2"
+ CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
@@ -108,7 +108,7 @@
IntermediateDirectory="Release"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- CharacterSet="2"
+ CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
@@ -374,11 +374,11 @@
>
</File>
<File
- RelativePath=".\Resource.h"
+ RelativePath="..\Common\Resource.h"
>
</File>
<File
- RelativePath="..\Common\Resource.h"
+ RelativePath=".\Resource.h"
>
</File>
<File
diff --git a/src/Setup/Wizard.c b/src/Setup/Wizard.c
index 92c7516..602625d 100644
--- a/src/Setup/Wizard.c
+++ b/src/Setup/Wizard.c
@@ -23,6 +23,7 @@
#include "Common/Resource.h"
#include "Resource.h"
#include "Setup.h"
+#include <tchar.h>
#include <Strsafe.h>
using namespace std;
@@ -40,9 +41,9 @@ enum wizard_pages
HWND hCurPage = NULL; /* Handle to current wizard page */
int nCurPageNo = -1; /* The current wizard page */
-char WizardDestInstallPath [TC_MAX_PATH];
-char WizardDestExtractPath [TC_MAX_PATH];
-char SelfFile [TC_MAX_PATH];
+wchar_t WizardDestInstallPath [TC_MAX_PATH];
+wchar_t WizardDestExtractPath [TC_MAX_PATH];
+wchar_t SelfFile [TC_MAX_PATH];
HBITMAP hbmWizardBitmapRescaled = NULL;
@@ -92,12 +93,12 @@ void localcleanupwiz (void)
static void InitWizardDestInstallPath (void)
{
- if (strlen (WizardDestInstallPath) < 2)
+ if (wcslen (WizardDestInstallPath) < 2)
{
- StringCbCopyA (WizardDestInstallPath, sizeof(WizardDestInstallPath), InstallationPath);
- if (WizardDestInstallPath [strlen (WizardDestInstallPath) - 1] != '\\')
+ StringCbCopyW (WizardDestInstallPath, sizeof(WizardDestInstallPath), InstallationPath);
+ if (WizardDestInstallPath [wcslen (WizardDestInstallPath) - 1] != L'\\')
{
- StringCbCatA (WizardDestInstallPath, sizeof(WizardDestInstallPath), "\\");
+ StringCbCatW (WizardDestInstallPath, sizeof(WizardDestInstallPath), L"\\");
}
}
}
@@ -228,7 +229,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
licenseText = GetLegalNotices ();
if (licenseText != NULL)
{
- SetWindowText (GetDlgItem (hwndDlg, IDC_LICENSE_TEXT), licenseText);
+ SetWindowTextA (GetDlgItem (hwndDlg, IDC_LICENSE_TEXT), licenseText);
free (licenseText);
}
else
@@ -308,10 +309,10 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
case EXTRACTION_OPTIONS_PAGE:
- if (strlen(WizardDestExtractPath) < 2)
+ if (wcslen(WizardDestExtractPath) < 2)
{
- StringCbCopyA (WizardDestExtractPath, sizeof(WizardDestExtractPath), SetupFilesDir);
- StringCbCatNA (WizardDestExtractPath, sizeof(WizardDestExtractPath), "VeraCrypt\\", sizeof (WizardDestExtractPath) - strlen (WizardDestExtractPath) - 1);
+ StringCbCopyW (WizardDestExtractPath, sizeof(WizardDestExtractPath), SetupFilesDir);
+ StringCbCatNW (WizardDestExtractPath, sizeof(WizardDestExtractPath), L"VeraCrypt\\", ARRAYSIZE (WizardDestExtractPath) - wcslen (WizardDestExtractPath) - 1);
}
SendMessage (GetDlgItem (hwndDlg, IDC_DESTINATION), EM_LIMITTEXT, TC_MAX_PATH - 1, 0);
@@ -353,10 +354,10 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), FALSE);
EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), FALSE);
- if (WizardDestExtractPath [strlen(WizardDestExtractPath)-1] != '\\')
- StringCbCatA (WizardDestExtractPath, sizeof(WizardDestExtractPath), "\\");
+ if (WizardDestExtractPath [wcslen(WizardDestExtractPath)-1] != L'\\')
+ StringCbCatW (WizardDestExtractPath, sizeof(WizardDestExtractPath), L"\\");
- StringCbCopyA (DestExtractPath, sizeof(DestExtractPath), WizardDestExtractPath);
+ Stri