VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Setup
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2015-11-25 00:41:37 (GMT)
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2015-11-26 00:44:52 (GMT)
commit90bd57fe40e66fc829ecb01482d32d604b0df19c (patch)
tree6d6de0d9a31c82d0598f68c2d160cb9e565bd5ea /src/Setup
parentec7d96fcb733021c214b414a1ba2841039733dd2 (diff)
downloadVeraCrypt-90bd57fe40e66fc829ecb01482d32d604b0df19c.zip
VeraCrypt-90bd57fe40e66fc829ecb01482d32d604b0df19c.tar.gz
Windows: Full UNICODE rewrite and implement support for UNICODE passwords.
Diffstat (limited to 'src/Setup')
-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
10 files changed, 632 insertions, 688 deletions
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);
+ StringCbCopyW (DestExtractPath, sizeof(DestExtractPath), WizardDestExtractPath);
InitProgressBar ();
@@ -406,9 +407,9 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
EnableWindow (GetDlgItem (hwndDlg, IDC_BROWSE), FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDC_ALL_USERS), FALSE);
- char path[MAX_PATH];
+ wchar_t path[MAX_PATH];
SHGetSpecialFolderPath (hwndDlg, path, CSIDL_COMMON_PROGRAMS, 0);
- bForAllUsers = (_access ((string (path) + "\\" TC_APP_NAME).c_str(), 0) == 0);
+ bForAllUsers = (_waccess ((wstring (path) + L"\\" _T(TC_APP_NAME)).c_str(), 0) == 0);
}
// System Restore
@@ -456,10 +457,10 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
InitProgressBar ();
- if (WizardDestInstallPath [strlen(WizardDestInstallPath)-1] != '\\')
- StringCbCatA (WizardDestInstallPath, sizeof(WizardDestInstallPath), "\\");
+ if (WizardDestInstallPath [wcslen(WizardDestInstallPath)-1] != L'\\')
+ StringCbCatW (WizardDestInstallPath, sizeof(WizardDestInstallPath), L"\\");
- StringCbCopyA (InstallationPath, sizeof(InstallationPath), WizardDestInstallPath);
+ StringCbCopyW (InstallationPath, sizeof(InstallationPath), WizardDestInstallPath);
WaitCursor ();
@@ -627,9 +628,9 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
case IDC_BROWSE:
if (BrowseDirectories (hwndDlg, "SELECT_DEST_DIR", WizardDestExtractPath))
{
- if (WizardDestExtractPath [strlen(WizardDestExtractPath)-1] != '\\')
+ if (WizardDestExtractPath [wcslen(WizardDestExtractPath)-1] != L'\\')
{
- StringCbCatA (WizardDestExtractPath, sizeof(WizardDestExtractPath), "\\");
+ StringCbCatW (WizardDestExtractPath, sizeof(WizardDestExtractPath), L"\\");
}
SetDlgItemText (hwndDlg, IDC_DESTINATION, WizardDestExtractPath);
}
@@ -648,9 +649,9 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
case IDC_BROWSE:
if (BrowseDirectories (hwndDlg, "SELECT_DEST_DIR", WizardDestInstallPath))
{
- if (WizardDestInstallPath [strlen(WizardDestInstallPath)-1] != '\\')
+ if (WizardDestInstallPath [wcslen(WizardDestInstallPath)-1] != L'\\')
{
- StringCbCatA (WizardDestInstallPath, sizeof(WizardDestInstallPath), "\\");
+ StringCbCatW (WizardDestInstallPath, sizeof(WizardDestInstallPath), L"\\");
}
SetDlgItemText (hwndDlg, IDC_DESTINATION, WizardDestInstallPath);
}
@@ -803,7 +804,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
{
RECT rec;
- GetModuleFileName (NULL, SelfFile, sizeof (SelfFile));
+ GetModuleFileName (NULL, SelfFile, ARRAYSIZE (SelfFile));
MainDlg = hwndDlg;
@@ -829,7 +830,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
SendMessage (GetDlgItem (hwndDlg, IDC_BOX_TITLE), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
- SetWindowText (hwndDlg, "VeraCrypt Setup " VERSION_STRING);
+ SetWindowText (hwndDlg, L"VeraCrypt Setup " _T(VERSION_STRING));
DonColorSchemeId = GetDonVal (2, 9);
@@ -899,7 +900,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
HKEY hkey;
- if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Updates\\Windows 2000\\SP5\\Update Rollup 1", 0, KEY_READ, &hkey) != ERROR_SUCCESS)
+ if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Updates\\Windows 2000\\SP5\\Update Rollup 1", 0, KEY_READ, &hkey) != ERROR_SUCCESS)
{
ErrorDirect (L"VeraCrypt requires Update Rollup 1 for Windows 2000 SP4 to be installed.\n\nFor more information, see http://support.microsoft.com/kb/891861", hwndDlg);
AbortProcessSilent ();
@@ -928,14 +929,14 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
else if (nCurPageNo == EXTRACTION_OPTIONS_PAGE)
{
- GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestExtractPath, sizeof (WizardDestExtractPath));
+ GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestExtractPath, ARRAYSIZE (WizardDestExtractPath));
bStartExtraction = TRUE;
}
else if (nCurPageNo == INSTALL_OPTIONS_PAGE)
{
- GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestInstallPath, sizeof (WizardDestInstallPath));
+ GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestInstallPath, ARRAYSIZE (WizardDestInstallPath));
bStartInstall = TRUE;
}
@@ -975,13 +976,13 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
else if (nCurPageNo == EXTRACTION_OPTIONS_PAGE)
{
- GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestExtractPath, sizeof (WizardDestExtractPath));
+ GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestExtractPath, ARRAYSIZE (WizardDestExtractPath));
nCurPageNo = WIZARD_MODE_PAGE + 1;
}
else if (nCurPageNo == INSTALL_OPTIONS_PAGE)
{
- GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestInstallPath, sizeof (WizardDestInstallPath));
+ GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestInstallPath, ARRAYSIZE (WizardDestInstallPath));
}
LoadPage (hwndDlg, --nCurPageNo);
@@ -1156,7 +1157,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (bOpenContainingFolder && bExtractOnly && bExtractionSuccessful)
{
- ShellExecute (NULL, "open", WizardDestExtractPath, NULL, NULL, SW_SHOWNORMAL);
+ ShellExecute (NULL, L"open", WizardDestExtractPath, NULL, NULL, SW_SHOWNORMAL);
}
else
{