VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Setup
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2018-04-16 00:32:27 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2018-04-23 16:59:28 +0200
commit2dc39a7c7e085d77a5b3505b15fd00111a6fff5e (patch)
treed49daa73ab4a8094ca689497c881ed27ea9b1242 /src/Setup
parent0a737c8c87fded05a74cad5232c9c973b3037d61 (diff)
downloadVeraCrypt-2dc39a7c7e085d77a5b3505b15fd00111a6fff5e.tar.gz
VeraCrypt-2dc39a7c7e085d77a5b3505b15fd00111a6fff5e.zip
Windows: simplify installer logic by copying only binaries for the current architecture.
Diffstat (limited to 'src/Setup')
-rw-r--r--src/Setup/Portable.vcxproj4
-rw-r--r--src/Setup/SelfExtract.c25
-rw-r--r--src/Setup/SelfExtract.h6
-rw-r--r--src/Setup/Setup.c38
-rw-r--r--src/Setup/Setup.h19
-rw-r--r--src/Setup/Setup.vcxproj4
6 files changed, 42 insertions, 54 deletions
diff --git a/src/Setup/Portable.vcxproj b/src/Setup/Portable.vcxproj
index 78f48197..06c2e45a 100644
--- a/src/Setup/Portable.vcxproj
+++ b/src/Setup/Portable.vcxproj
@@ -69,7 +69,7 @@
</ClCompile>
<Link>
<AdditionalOptions>/NODEFAULTLIB:LIBCMTD %(AdditionalOptions)</AdditionalOptions>
- <AdditionalDependencies>libcmtd.lib;atlsd.lib;mpr.lib;..\Common\Debug\Zip.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>libcmtd.lib;atlsd.lib;mpr.lib;..\Common\Debug\Zip.lib;..\Crypto\Debug\crypto.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)VeraCryptPortable.exe</OutputFile>
<UACExecutionLevel>AsInvoker</UACExecutionLevel>
<DelayLoadDLLs>user32.dll;gdi32.dll;advapi32.dll;shell32.dll;ole32.dll;mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
@@ -107,7 +107,7 @@ copy PortableDebug\VeraCryptPortable.exe "..\Debug\Setup Files\VeraCrypt Portabl
</ClCompile>
<Link>
<AdditionalOptions>/IGNORE:4089 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalDependencies>mpr.lib;..\Common\Release\Zip.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>mpr.lib;..\Common\Release\Zip.lib;..\Crypto\Release\crypto.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)VeraCryptPortable.exe</OutputFile>
<UACExecutionLevel>AsInvoker</UACExecutionLevel>
<DelayLoadDLLs>user32.dll;gdi32.dll;advapi32.dll;shell32.dll;ole32.dll;mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
diff --git a/src/Setup/SelfExtract.c b/src/Setup/SelfExtract.c
index 7b3fb4fe..2a3a8b29 100644
--- a/src/Setup/SelfExtract.c
+++ b/src/Setup/SelfExtract.c
@@ -34,8 +34,8 @@
#else
#define OutputPackageFile L"VeraCrypt Setup " _T(VERSION_STRING) L".exe"
#endif
-#define MAG_START_MARKER "TCINSTRT"
-#define MAG_END_MARKER_OBFUSCATED "T/C/I/N/S/C/R/C"
+#define MAG_START_MARKER "VCINSTRT"
+#define MAG_END_MARKER_OBFUSCATED "V/C/I/N/S/C/R/C"
#define PIPE_BUFFER_LEN (4 * BYTES_PER_KB)
unsigned char MagEndMarker [sizeof (MAG_END_MARKER_OBFUSCATED)];
@@ -57,7 +57,7 @@ void SelfExtractStartupInit (void)
// The end marker must be included in the self-extracting exe only once, not twice (used e.g.
// by IsSelfExtractingPackage()) and that's why MAG_END_MARKER_OBFUSCATED is obfuscated and
// needs to be deobfuscated using this function at startup.
-static void DeobfuscateMagEndMarker (void)
+void DeobfuscateMagEndMarker (void)
{
int i;
@@ -385,16 +385,21 @@ err:
// Verifies the CRC-32 of the whole self-extracting package (except the digital signature areas, if present)
-BOOL VerifyPackageIntegrity (void)
+BOOL VerifySelfPackageIntegrity ()
+{
+ wchar_t path [TC_MAX_PATH];
+
+ GetModuleFileName (NULL, path, ARRAYSIZE (path));
+ return VerifyPackageIntegrity (path);
+}
+
+BOOL VerifyPackageIntegrity (const wchar_t *path)
{
int fileDataEndPos = 0;
int fileDataStartPos = 0;
unsigned __int32 crc = 0;
unsigned char *tmpBuffer;
int tmpFileSize;
- wchar_t path [TC_MAX_PATH];
-
- GetModuleFileName (NULL, path, ARRAYSIZE (path));
#ifdef NDEBUG
// verify Authenticode digital signature of the exe file
@@ -464,7 +469,7 @@ BOOL IsSelfExtractingPackage (void)
}
-static void FreeAllFileBuffers (void)
+void FreeAllFileBuffers (void)
{
int fileNo;
@@ -619,7 +624,7 @@ sem_end:
return FALSE;
}
-
+#ifdef SETUP
void __cdecl ExtractAllFilesThread (void *hwndDlg)
{
int fileNo;
@@ -704,4 +709,4 @@ eaf_end:
else
PostMessage (MainDlg, TC_APPMSG_EXTRACTION_FAILURE, 0, 0);
}
-
+#endif
diff --git a/src/Setup/SelfExtract.h b/src/Setup/SelfExtract.h
index 020b1441..ed4b6655 100644
--- a/src/Setup/SelfExtract.h
+++ b/src/Setup/SelfExtract.h
@@ -32,9 +32,11 @@ void SelfExtractStartupInit (void);
BOOL SelfExtractInMemory (wchar_t *path);
void __cdecl ExtractAllFilesThread (void *hwndDlg);
BOOL MakeSelfExtractingPackage (HWND hwndDlg, wchar_t *szDestDir);
-BOOL VerifyPackageIntegrity (void);
+BOOL VerifyPackageIntegrity (const wchar_t *path);
+BOOL VerifySelfPackageIntegrity (void);
BOOL IsSelfExtractingPackage (void);
-static void DeobfuscateMagEndMarker (void);
+void FreeAllFileBuffers (void);
+void DeobfuscateMagEndMarker (void);
extern wchar_t DestExtractPath [TC_MAX_PATH];
diff --git a/src/Setup/Setup.c b/src/Setup/Setup.c
index cedd9f61..5f2cea19 100644
--- a/src/Setup/Setup.c
+++ b/src/Setup/Setup.c
@@ -685,18 +685,6 @@ BOOL DoFilesInstall (HWND hwndDlg, wchar_t *szDestDir)
continue; // Destination = target
}
- // skip files that don't apply to the current architecture
- 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] == L'A') || (*szFiles[i] == L'X'))
StringCbCopyW (szDir, sizeof(szDir), szDestDir);
else if (*szFiles[i] == L'D')
@@ -766,35 +754,17 @@ BOOL DoFilesInstall (HWND hwndDlg, wchar_t *szDestDir)
}
if (Is64BitOs ()
- && wcscmp (szFiles[i], L"AVeraCrypt-x86.exe") == 0)
- {
- StringCbCopyNW (curFileName, sizeof(curFileName), L"VeraCrypt.exe", sizeof (L"VeraCrypt.exe"));
- }
-
- if (Is64BitOs ()
&& wcscmp (szFiles[i], L"AVeraCryptExpander.exe") == 0)
{
StringCbCopyNW (curFileName, sizeof(curFileName), L"VeraCryptExpander-x64.exe", sizeof (L"VeraCryptExpander-x64.exe"));
}
if (Is64BitOs ()
- && wcscmp (szFiles[i], L"AVeraCryptExpander-x86.exe") == 0)
- {
- StringCbCopyNW (curFileName, sizeof(curFileName), L"VeraCryptExpander.exe", sizeof (L"VeraCryptExpander.exe"));
- }
-
- if (Is64BitOs ()
&& wcscmp (szFiles[i], L"AVeraCrypt Format.exe") == 0)
{
StringCbCopyNW (curFileName, sizeof(curFileName), L"VeraCrypt Format-x64.exe", sizeof (L"VeraCrypt Format-x64.exe"));
}
- if (Is64BitOs ()
- && wcscmp (szFiles[i], L"AVeraCrypt Format-x86.exe") == 0)
- {
- StringCbCopyNW (curFileName, sizeof(curFileName), L"VeraCrypt Format.exe", sizeof (L"VeraCrypt Format.exe"));
- }
-
if (!bDevm)
{
bResult = FALSE;
@@ -1052,6 +1022,12 @@ err:
FindClose (h);
}
+ // remvove legacy files that are not needed anymore
+ for (i = 0; i < sizeof (szLegacyFiles) / sizeof (szLegacyFiles[0]); i++)
+ {
+ StatDeleteFile (szLegacyFiles [i], TRUE);
+ }
+
SetCurrentDirectory (SetupFilesDir);
}
@@ -2586,7 +2562,7 @@ int WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, wchar_t *lpsz
{
if (IsSelfExtractingPackage())
{
- if (!VerifyPackageIntegrity())
+ if (!VerifySelfPackageIntegrity())
{
// Package corrupted
exit (1);
diff --git a/src/Setup/Setup.h b/src/Setup/Setup.h
index b29ad14a..12b4159f 100644
--- a/src/Setup/Setup.h
+++ b/src/Setup/Setup.h
@@ -27,14 +27,7 @@ static wchar_t *szFiles[]=
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"XLanguages.zip",
@@ -59,6 +52,18 @@ static wchar_t *szCompressedFiles[]=
L"docs.zip"
};
+// Specifies what legacy files to remove during install
+static wchar_t *szLegacyFiles[]=
+{
+ L"VeraCrypt-x86.exe",
+ L"VeraCryptExpander-x86.exe",
+ L"VeraCrypt Format-x86.exe",
+ L"VeraCrypt-x64.exe",
+ L"VeraCryptExpander-x64.exe",
+ L"VeraCrypt Format-x64.exe",
+ L"veracrypt-x64.sys",
+};
+
#define FILENAME_64BIT_DRIVER L"veracrypt-x64.sys"
#define NBR_COMPRESSED_FILES (sizeof(szCompressedFiles) / sizeof(szCompressedFiles[0]))
diff --git a/src/Setup/Setup.vcxproj b/src/Setup/Setup.vcxproj
index c4c1aad0..932cb051 100644
--- a/src/Setup/Setup.vcxproj
+++ b/src/Setup/Setup.vcxproj
@@ -69,7 +69,7 @@
</ClCompile>
<Link>
<AdditionalOptions>/NODEFAULTLIB:LIBCMTD %(AdditionalOptions)</AdditionalOptions>
- <AdditionalDependencies>libcmtd.lib;atlsd.lib;mpr.lib;..\Common\Debug\Zip.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>libcmtd.lib;atlsd.lib;mpr.lib;..\Common\Debug\Zip.lib;..\Crypto\Debug\crypto.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)VeraCryptSetup.exe</OutputFile>
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
<DelayLoadDLLs>user32.dll;gdi32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
@@ -107,7 +107,7 @@ copy Debug\VeraCryptSetup.exe "..\Debug\Setup Files\VeraCrypt Setup.exe" &gt;NUL
</ClCompile>
<Link>
<AdditionalOptions>/IGNORE:4089 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalDependencies>mpr.lib;..\Common\Release\Zip.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>mpr.lib;..\Common\Release\Zip.lib;..\Crypto\Release\crypto.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)VeraCryptSetup.exe</OutputFile>
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
<DelayLoadDLLs>user32.dll;gdi32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs>