VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2018-04-16 00:36:59 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2018-04-23 16:59:29 +0200
commitf5cb9d1f2eec08649c9b78d389f4e904cd371165 (patch)
tree8cedc124421d41b49925360db0e0b6b1b560c8af
parent2dc39a7c7e085d77a5b3505b15fd00111a6fff5e (diff)
downloadVeraCrypt-f5cb9d1f2eec08649c9b78d389f4e904cd371165.tar.gz
VeraCrypt-f5cb9d1f2eec08649c9b78d389f4e904cd371165.zip
Windows: modify travel disk creation to get binaries from within setup exe files instead of copying existing binaries. This is needed since now we only install binaries of the current architecture.
-rw-r--r--src/ExpandVolume/ExpandVolume.vcxproj1
-rw-r--r--src/ExpandVolume/ExpandVolume.vcxproj.filters6
-rw-r--r--src/Mount/Mount.c232
-rw-r--r--src/Mount/Mount.vcxproj1
-rw-r--r--src/Mount/Mount.vcxproj.filters6
5 files changed, 159 insertions, 87 deletions
diff --git a/src/ExpandVolume/ExpandVolume.vcxproj b/src/ExpandVolume/ExpandVolume.vcxproj
index 38a3f976..0db64c99 100644
--- a/src/ExpandVolume/ExpandVolume.vcxproj
+++ b/src/ExpandVolume/ExpandVolume.vcxproj
@@ -313,6 +313,7 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCryptExpander-x64.exe" &gt;NUL:
</ProjectReference>
</ItemGroup>
<ItemGroup>
+ <ClCompile Include="..\Setup\SelfExtract.c" />
<ClCompile Include="DlgExpandVolume.cpp" />
<ClCompile Include="ExpandVolume.c" />
<ClCompile Include="InitDataArea.c" />
diff --git a/src/ExpandVolume/ExpandVolume.vcxproj.filters b/src/ExpandVolume/ExpandVolume.vcxproj.filters
index c84fd9d8..007757ff 100644
--- a/src/ExpandVolume/ExpandVolume.vcxproj.filters
+++ b/src/ExpandVolume/ExpandVolume.vcxproj.filters
@@ -22,6 +22,9 @@
<Filter Include="Resource Files\Common">
<UniqueIdentifier>{ece6c790-f488-400d-b92d-64f73ce9f990}</UniqueIdentifier>
</Filter>
+ <Filter Include="Source Files\Setup">
+ <UniqueIdentifier>{922a1924-e0f2-4829-8ed2-eb783e03e8a5}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="DlgExpandVolume.cpp">
@@ -120,6 +123,9 @@
<ClCompile Include="..\Mount\Mount.c">
<Filter>Source Files\Mount</Filter>
</ClCompile>
+ <ClCompile Include="..\Setup\SelfExtract.c">
+ <Filter>Source Files\Setup</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\Common\Wipe.h">
diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c
index 3f508d14..bbf956f0 100644
--- a/src/Mount/Mount.c
+++ b/src/Mount/Mount.c
@@ -48,6 +48,7 @@
#include "../Common/SecurityToken.h"
#include "../Platform/Finally.h"
#include "../Platform/ForEach.h"
+#include "../Setup/SelfExtract.h"
#include <Strsafe.h>
@@ -4429,49 +4430,11 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
goto stop;
}
- // Main app 32-bit
- if (Is64BitOs () && !IsNonInstallMode ())
- StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\VeraCrypt-x86.exe", appDir);
- else
- StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\VeraCrypt.exe", appDir);
- StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCrypt.exe", dstDir);
- if (!VerifyModuleSignature (srcPath))
+ if (IsNonInstallMode ())
{
- Error ("DIST_PACKAGE_CORRUPTED", hwndDlg);
- goto stop;
- }
- else if (!TCCopyFile (srcPath, dstPath))
- {
- handleWin32Error (hwndDlg, SRC_POS);
- goto stop;
- }
-
- // Main app 64-bit
- if (Is64BitOs () && !IsNonInstallMode ())
+ // Main app 32-bit
StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\VeraCrypt.exe", appDir);
- else
- StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\VeraCrypt-x64.exe", appDir);
- StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCrypt-x64.exe", dstDir);
- if (!VerifyModuleSignature (srcPath))
- {
- Error ("DIST_PACKAGE_CORRUPTED", hwndDlg);
- goto stop;
- }
- else if (!TCCopyFile (srcPath, dstPath))
- {
- handleWin32Error (hwndDlg, SRC_POS);
- goto stop;
- }
-
- // Wizard
- if (copyWizard)
- {
- // Wizard 32-bit
- if (Is64BitOs () && !IsNonInstallMode ())
- StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\VeraCrypt Format-x86.exe", appDir);
- else
- StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\VeraCrypt Format.exe", appDir);
- StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCrypt Format.exe", dstDir);
+ StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCrypt.exe", dstDir);
if (!VerifyModuleSignature (srcPath))
{
Error ("DIST_PACKAGE_CORRUPTED", hwndDlg);
@@ -4483,12 +4446,9 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
goto stop;
}
- // Wizard 64-bit
- if (Is64BitOs () && !IsNonInstallMode ())
- StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\VeraCrypt Format.exe", appDir);
- else
- StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\VeraCrypt Format-x64.exe", appDir);
- StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCrypt Format-x64.exe", dstDir);
+ // Main app 64-bit
+ StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\VeraCrypt-x64.exe", appDir);
+ StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCrypt-x64.exe", dstDir);
if (!VerifyModuleSignature (srcPath))
{
Error ("DIST_PACKAGE_CORRUPTED", hwndDlg);
@@ -4499,17 +4459,74 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
handleWin32Error (hwndDlg, SRC_POS);
goto stop;
}
- }
- // Expander
- if (copyExpander)
- {
- // Expander 32-bit
- if (Is64BitOs () && !IsNonInstallMode ())
- StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\VeraCryptExpander-x86.exe", appDir);
- else
+ // Wizard
+ if (copyWizard)
+ {
+ // Wizard 32-bit
+ StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\VeraCrypt Format.exe", appDir);
+ StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCrypt Format.exe", dstDir);
+ if (!VerifyModuleSignature (srcPath))
+ {
+ Error ("DIST_PACKAGE_CORRUPTED", hwndDlg);
+ goto stop;
+ }
+ else if (!TCCopyFile (srcPath, dstPath))
+ {
+ handleWin32Error (hwndDlg, SRC_POS);
+ goto stop;
+ }
+
+ // Wizard 64-bit
+ StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\VeraCrypt Format-x64.exe", appDir);
+ StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCrypt Format-x64.exe", dstDir);
+ if (!VerifyModuleSignature (srcPath))
+ {
+ Error ("DIST_PACKAGE_CORRUPTED", hwndDlg);
+ goto stop;
+ }
+ else if (!TCCopyFile (srcPath, dstPath))
+ {
+ handleWin32Error (hwndDlg, SRC_POS);
+ goto stop;
+ }
+ }
+
+ // Expander
+ if (copyExpander)
+ {
+ // Expander 32-bit
StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\VeraCryptExpander.exe", appDir);
- StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCryptExpander.exe", dstDir);
+ StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCryptExpander.exe", dstDir);
+ if (!VerifyModuleSignature (srcPath))
+ {
+ Error ("DIST_PACKAGE_CORRUPTED", hwndDlg);
+ goto stop;
+ }
+ else if (!TCCopyFile (srcPath, dstPath))
+ {
+ handleWin32Error (hwndDlg, SRC_POS);
+ goto stop;
+ }
+
+ // Expander 64-bit
+ StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\VeraCryptExpander-x64.exe", appDir);
+ StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCryptExpander-x64.exe", dstDir);
+ if (!VerifyModuleSignature (srcPath))
+ {
+ Error ("DIST_PACKAGE_CORRUPTED", hwndDlg);
+ goto stop;
+ }
+ else if (!TCCopyFile (srcPath, dstPath))
+ {
+ handleWin32Error (hwndDlg, SRC_POS);
+ goto stop;
+ }
+ }
+
+ // Driver
+ StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\veracrypt.sys", appDir);
+ StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\veracrypt.sys", dstDir);
if (!VerifyModuleSignature (srcPath))
{
Error ("DIST_PACKAGE_CORRUPTED", hwndDlg);
@@ -4521,12 +4538,9 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
goto stop;
}
- // Expander 64-bit
- if (Is64BitOs () && !IsNonInstallMode ())
- StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\VeraCryptExpander.exe", appDir);
- else
- StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\VeraCryptExpander-x64.exe", appDir);
- StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCryptExpander-x64.exe", dstDir);
+ // Driver x64
+ StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\veracrypt-x64.sys", appDir);
+ StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\veracrypt-x64.sys", dstDir);
if (!VerifyModuleSignature (srcPath))
{
Error ("DIST_PACKAGE_CORRUPTED", hwndDlg);
@@ -4538,33 +4552,75 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
goto stop;
}
}
-
- // Driver
- StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\veracrypt.sys", appDir);
- StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\veracrypt.sys", dstDir);
- if (!VerifyModuleSignature (srcPath))
- {
- Error ("DIST_PACKAGE_CORRUPTED", hwndDlg);
- goto stop;
- }
- else if (!TCCopyFile (srcPath, dstPath))
+ else
{
- handleWin32Error (hwndDlg, SRC_POS);
- goto stop;
- }
+ int fileNo = 0;
+ // get file from the Setup binary after checking its signature and its version
+ StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\VeraCrypt Setup.exe", appDir);
- // Driver x64
- StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\veracrypt-x64.sys", appDir);
- StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\veracrypt-x64.sys", dstDir);
- if (!VerifyModuleSignature (srcPath))
- {
- Error ("DIST_PACKAGE_CORRUPTED", hwndDlg);
- goto stop;
- }
- else if (!TCCopyFile (srcPath, dstPath))
- {
- handleWin32Error (hwndDlg, SRC_POS);
- goto stop;
+ FreeAllFileBuffers ();
+
+ if (!VerifyPackageIntegrity (srcPath) || !SelfExtractInMemory (srcPath))
+ {
+ MessageBoxW (hwndDlg, GetString ("DIST_PACKAGE_CORRUPTED"), lpszTitle, MB_ICONEXCLAMATION);
+ goto stop;
+ }
+
+ for (fileNo = 0; fileNo < NBR_COMPRESSED_FILES; fileNo++)
+ {
+ wchar_t fileName [TC_MAX_PATH] = {0};
+
+ // Filename
+ StringCchCopyNW (fileName, ARRAYSIZE(fileName), Decompressed_Files[fileNo].fileName, Decompressed_Files[fileNo].fileNameLength);
+
+ if (wcscmp (fileName, L"VeraCrypt.exe") == 0)
+ {
+ StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCrypt.exe", dstDir);
+ }
+ else if (wcscmp (fileName, L"VeraCrypt-x64.exe") == 0)
+ {
+ StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCrypt-x64.exe", dstDir);
+ }
+ else if (wcscmp (fileName, L"veracrypt.sys") == 0)
+ {
+ StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\veracrypt.sys", dstDir);
+ }
+ else if (wcscmp (fileName, L"veracrypt-x64.sys") == 0)
+ {
+ StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\veracrypt-x64.sys", dstDir);
+ }
+ else if (copyWizard && (wcscmp (fileName, L"VeraCrypt Format.exe") == 0))
+ {
+ StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCrypt Format.exe", dstDir);
+ }
+ else if (copyWizard && (wcscmp (fileName, L"VeraCrypt Format-x64.exe") == 0))
+ {
+ StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCrypt Format-x64.exe", dstDir);
+ }
+ else if (copyExpander && (wcscmp (fileName, L"VeraCryptExpander.exe") == 0))
+ {
+ StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCryptExpander.exe", dstDir);
+ }
+ else if (copyExpander && (wcscmp (fileName, L"VeraCryptExpander-x64.exe") == 0))
+ {
+ StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCryptExpander-x64.exe", dstDir);
+ }
+ else
+ continue;
+
+ if (!SaveBufferToFile (
+ (char *) Decompressed_Files[fileNo].fileContent,
+ dstPath,
+ Decompressed_Files[fileNo].fileLength,
+ FALSE, FALSE))
+ {
+ wchar_t szTmp[512];
+
+ StringCbPrintfW (szTmp, sizeof (szTmp), GetString ("CANNOT_WRITE_FILE_X"), dstPath);
+ MessageBoxW (hwndDlg, szTmp, lpszTitle, MB_ICONERROR | MB_SETFOREGROUND | MB_TOPMOST);
+ goto stop;
+ }
+ }
}
if (strcmp (GetPreferredLangId (), "en") != 0)
@@ -4617,6 +4673,7 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
MessageBoxW (hwndDlg, GetString ("TRAVELER_DISK_CREATED"), lpszTitle, MB_ICONINFORMATION);
stop:
+ FreeAllFileBuffers ();
NormalCursor ();
return 1;
}
@@ -9329,6 +9386,7 @@ int WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, wchar_t *lpsz
int status;
atexit (localcleanup);
SetProcessShutdownParameters (0x100, 0);
+ DeobfuscateMagEndMarker ();
VirtualLock (&VolumePassword, sizeof (VolumePassword));
VirtualLock (&CmdVolumePassword, sizeof (CmdVolumePassword));
diff --git a/src/Mount/Mount.vcxproj b/src/Mount/Mount.vcxproj
index c5df7a00..d4af0464 100644
--- a/src/Mount/Mount.vcxproj
+++ b/src/Mount/Mount.vcxproj
@@ -278,6 +278,7 @@ copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt-x64.exe" &gt;NUL:
</ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
+ <ClCompile Include="..\Setup\SelfExtract.c" />
<ClCompile Include="Favorites.cpp" />
<ClCompile Include="Hotkeys.c" />
<ClCompile Include="MainCom.cpp" />
diff --git a/src/Mount/Mount.vcxproj.filters b/src/Mount/Mount.vcxproj.filters
index b29330c4..e1dfd652 100644
--- a/src/Mount/Mount.vcxproj.filters
+++ b/src/Mount/Mount.vcxproj.filters
@@ -19,6 +19,9 @@
<Filter Include="Resource Files\Common">
<UniqueIdentifier>{f805ede6-c210-4210-95ce-e33edb12bc27}</UniqueIdentifier>
</Filter>
+ <Filter Include="Source Files\Setup">
+ <UniqueIdentifier>{3bd21420-974d-4264-8daa-807c240fbed7}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Favorites.cpp">
@@ -102,6 +105,9 @@
<ClCompile Include="..\Common\Xts.c">
<Filter>Source Files\Common</Filter>
</ClCompile>
+ <ClCompile Include="..\Setup\SelfExtract.c">
+ <Filter>Source Files\Setup</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<Midl Include="MainCom.idl">