Windows: Make Travel Disk contains 32-bit and arm64 binaries when VeraCrypt installed using MSI

This commit is contained in:
Mounir IDRASSI 2022-02-09 22:37:22 +01:00
parent 2da115ffb4
commit 302dc37fb9
No known key found for this signature in database
GPG Key ID: 02C30AE90FAE4A6F
12 changed files with 1412 additions and 1033 deletions

30
src/COMReg/COMReg.cpp Normal file
View File

@ -0,0 +1,30 @@
#include "Tcdefs.h"
#include <windows.h>
#include "SelfExtract.h"
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
wchar_t SetupFilesDir[TC_MAX_PATH];
wchar_t *s;
UNREFERENCED_PARAMETER(hInstance);
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(nCmdShow);
if (lpCmdLine[0] == L'/' && lpCmdLine[1] == L'p')
{
MessageBox(NULL, L"",L"",0);
SelfExtractStartupInit();
GetModuleFileName (NULL, SetupFilesDir, ARRAYSIZE (SetupFilesDir));
s = wcsrchr (SetupFilesDir, L'\\');
if (s)
s[1] = 0;
/* Create self-extracting package */
MakeSelfExtractingPackage (NULL, SetupFilesDir, TRUE);
}
return 0;
}

100
src/COMReg/COMReg.rc Normal file
View File

@ -0,0 +1,100 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,25,8,1
PRODUCTVERSION 1,25,8,1
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "IDRIX"
VALUE "FileDescription", "VeraCrypt COMReg"
VALUE "FileVersion", "1.25"
VALUE "LegalTrademarks", "VeraCrypt"
VALUE "OriginalFilename", "VeraCrypt COMReg.exe"
VALUE "ProductName", "VeraCrypt"
VALUE "ProductVersion", "1.25"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
/////////////////////////////////////////////////////////////////////////////
//
// REGISTRY
//
IDR_COMREG REGISTRY "..\Setup\ComSetup.rgs"
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_COMREG ICON "..\Setup\Setup.ico"
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"#include ""..\\\\common\\\\resource.h""\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////

119
src/COMReg/COMReg.vcxproj Normal file
View File

@ -0,0 +1,119 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{C8914211-32AC-4F48-ACD9-8212E8DE53F3}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>COMReg</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<TargetName>VeraCryptCOMRegBase</TargetName>
<OutDir>Debug\</OutDir>
<IntDir>Debug\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<TargetName>VeraCryptCOMRegBase</TargetName>
<OutDir>Release\</OutDir>
<IntDir>Release\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;VC_COMREG;_DEBUG;_WINDOWS;HAVE_CONFIG_H;ZIP_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<AdditionalIncludeDirectories>..\Setup;..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>..\Common\Debug\Zip.lib;..\Crypto\Debug\crypto.lib;..\Common\Debug\lzma.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>copy Debug\VeraCryptCOMRegBase.exe "..\Debug\Setup Files\VeraCryptCOMRegBase.exe"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;VC_COMREG;NDEBUG;_WINDOWS;HAVE_CONFIG_H;ZIP_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalIncludeDirectories>..\Setup;..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>false</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>..\Common\Release\Zip.lib;..\Crypto\Release\crypto.lib;..\Common\Release\lzma.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>copy Release\VeraCryptCOMRegBase.exe "..\Release\Setup Files\VeraCryptCOMRegBase.exe"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\Common\Crc.c" />
<ClCompile Include="..\Common\Dlgcode.c">
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsCpp</CompileAs>
</ClCompile>
<ClCompile Include="..\Setup\SelfExtract.c">
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Default</CompileAs>
</ClCompile>
<ClCompile Include="COMReg.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="COMReg.rc" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\Common\Crc.h" />
<ClInclude Include="..\Common\Dlgcode.h" />
<ClInclude Include="..\Setup\SelfExtract.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common\Lzma.vcxproj">
<Project>{b896fe1f-6bf3-4f75-9148-f841829073d9}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{453a6bf1-2afd-4016-8b8f-e3821a6c8ab5}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Common">
<UniqueIdentifier>{efcd999c-3973-4bd6-af14-0583669e6722}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="COMReg.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\Setup\SelfExtract.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\Common\Dlgcode.c">
<Filter>Source Files\Common</Filter>
</ClCompile>
<ClCompile Include="..\Common\Crc.c">
<Filter>Source Files\Common</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="COMReg.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\Setup\SelfExtract.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\Common\Dlgcode.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\Common\Crc.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerCommand>$(TargetPath)</LocalDebuggerCommand>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>

18
src/COMReg/Resource.h Normal file
View File

@ -0,0 +1,18 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by COMReg.rc
//
#define IDR_COMREG 10
#define IDI_COMREG 11
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 12
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -4790,15 +4790,101 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
else
{
int fileNo = 0;
BOOL bMsiX64Case = FALSE;
// get file from the Setup binary after checking its signature and its version
StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\VeraCrypt COMReg.exe", appDir); // MSI installation case
if (FileExists(srcPath))
{
// we copy only our binaries since we don't have those of the other platforms
bMsiX64Case = TRUE;
}
else
StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\VeraCrypt Setup.exe", appDir); // EXE installation case
FreeAllFileBuffers ();
if (!VerifyPackageIntegrity (srcPath) || !SelfExtractInMemory (srcPath, TRUE) || (!bMsiX64Case && (Decompressed_Files_Count != NBR_COMPRESSED_FILES)))
{
MessageBoxW (hwndDlg, GetString ("DIST_PACKAGE_CORRUPTED"), lpszTitle, MB_ICONEXCLAMATION);
goto stop;
}
for (fileNo = 0; fileNo < Decompressed_Files_Count; 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-arm64.exe") == 0)
{
StringCbPrintfW(dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCrypt-arm64.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 (wcscmp(fileName, L"veracrypt-arm64.sys") == 0)
{
StringCbPrintfW(dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\veracrypt-arm64.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 (copyWizard && (wcscmp(fileName, L"VeraCrypt Format-arm64.exe") == 0))
{
StringCbPrintfW(dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCrypt Format-arm64.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 if (copyExpander && (wcscmp(fileName, L"VeraCryptExpander-arm64.exe") == 0))
{
StringCbPrintfW(dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCryptExpander-arm64.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 (bMsiX64Case)
{
// Main app
StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\VeraCrypt.exe", appDir);
StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCrypt.exe", dstDir);
StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCrypt-x64.exe", dstDir);
if (!VerifyModuleSignature (srcPath))
{
Error ("DIST_PACKAGE_CORRUPTED", hwndDlg);
@ -4814,7 +4900,7 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
if (copyWizard)
{
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 Format-x64.exe", dstDir);
if (!VerifyModuleSignature (srcPath))
{
Error ("DIST_PACKAGE_CORRUPTED", hwndDlg);
@ -4831,7 +4917,7 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
if (copyExpander)
{
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-x64.exe", dstDir);
if (!VerifyModuleSignature (srcPath))
{
Error ("DIST_PACKAGE_CORRUPTED", hwndDlg);
@ -4846,7 +4932,7 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
// Driver
StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\veracrypt.sys", appDir);
StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\veracrypt.sys", dstDir);
StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\veracrypt-x64.sys", dstDir);
if (!VerifyModuleSignature (srcPath))
{
Error ("DIST_PACKAGE_CORRUPTED", hwndDlg);
@ -4858,90 +4944,6 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
goto stop;
}
}
else
{
StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\VeraCrypt Setup.exe", appDir); // EXE installation case
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-arm64.exe") == 0)
{
StringCbPrintfW(dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCrypt-arm64.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 (wcscmp(fileName, L"veracrypt-arm64.sys") == 0)
{
StringCbPrintfW(dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\veracrypt-arm64.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 (copyWizard && (wcscmp(fileName, L"VeraCrypt Format-arm64.exe") == 0))
{
StringCbPrintfW(dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCrypt Format-arm64.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 if (copyExpander && (wcscmp(fileName, L"VeraCryptExpander-arm64.exe") == 0))
{
StringCbPrintfW(dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\VeraCryptExpander-arm64.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)

View File

@ -32,8 +32,12 @@
#ifdef PORTABLE
#define OutputPackageFile L"VeraCrypt Portable " _T(VERSION_STRING) _T(VERSION_STRING_SUFFIX)L".exe"
#else
#ifdef VC_COMREG
#define OutputPackageFile L"VeraCrypt COMReg.exe"
#else
#define OutputPackageFile L"VeraCrypt Setup " _T(VERSION_STRING) _T(VERSION_STRING_SUFFIX) L".exe"
#endif
#endif
#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)
@ -41,6 +45,7 @@
unsigned char MagEndMarker [sizeof (MAG_END_MARKER_OBFUSCATED)];
wchar_t DestExtractPath [TC_MAX_PATH];
DECOMPRESSED_FILE Decompressed_Files [NBR_COMPRESSED_FILES];
int Decompressed_Files_Count = 0;
volatile char *PipeWriteBuf = NULL;
volatile HANDLE hChildStdinWrite = INVALID_HANDLE_VALUE;
@ -119,7 +124,7 @@ static void WipeSignatureAreas (char *buffer)
}
BOOL MakeSelfExtractingPackage (HWND hwndDlg, wchar_t *szDestDir)
BOOL MakeSelfExtractingPackage (HWND hwndDlg, wchar_t *szDestDir, BOOL bSkipX64)
{
int i, x;
wchar_t inputFile [TC_MAX_PATH];
@ -163,6 +168,17 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, wchar_t *szDestDir)
for (i = 0; i < sizeof (szCompressedFiles) / sizeof (szCompressedFiles[0]); i++)
{
if (bSkipX64 && wcsstr(szCompressedFiles[i], L"-x64"))
continue;
#ifdef VC_COMREG
if ( wcsstr(szCompressedFiles[i], L".zip") || wcsstr(szCompressedFiles[i], L".inf")
|| wcsstr(szCompressedFiles[i], L".cat") || wcsstr(szCompressedFiles[i], L".txt")
|| wcsstr(szCompressedFiles[i], L"LICENSE") || wcsstr(szCompressedFiles[i], L"NOTICE")
)
continue;
#endif
StringCbPrintfW (szTmpFilePath, sizeof(szTmpFilePath), L"%s%s", szDestDir, szCompressedFiles[i]);
if (!FileExists (szTmpFilePath))
@ -215,6 +231,17 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, wchar_t *szDestDir)
DWORD tmpFileSize;
unsigned char *tmpBuffer;
if (bSkipX64 && wcsstr(szCompressedFiles[i], L"-x64"))
continue;
#ifdef VC_COMREG
if ( wcsstr(szCompressedFiles[i], L".zip") || wcsstr(szCompressedFiles[i], L".inf")
|| wcsstr(szCompressedFiles[i], L".cat") || wcsstr(szCompressedFiles[i], L".txt")
|| wcsstr(szCompressedFiles[i], L"LICENSE") || wcsstr(szCompressedFiles[i], L"NOTICE")
)
continue;
#endif
StringCbPrintfW (szTmpFilePath, sizeof(szTmpFilePath), L"%s%s", szDestDir, szCompressedFiles[i]);
tmpBuffer = LoadFile (szTmpFilePath, &tmpFileSize);
@ -485,6 +512,8 @@ void FreeAllFileBuffers (void)
Decompressed_Files[fileNo].fileLength = 0;
Decompressed_Files[fileNo].crc = 0;
}
Decompressed_Files_Count = 0;
}
@ -492,7 +521,7 @@ 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 (wchar_t *path)
BOOL SelfExtractInMemory (wchar_t *path, BOOL bSkipCountCheck)
{
int filePos = 0, fileNo = 0;
int fileDataEndPos = 0;
@ -548,7 +577,7 @@ BOOL SelfExtractInMemory (wchar_t *path)
Error ("DIST_PACKAGE_CORRUPTED", NULL);
}
decompressedDataLen = uncompressedLen + 524288; // + 512K reserve
decompressedDataLen = uncompressedLen;
DecompressedData = malloc (decompressedDataLen);
if (DecompressedData == NULL)
{
@ -607,12 +636,14 @@ BOOL SelfExtractInMemory (wchar_t *path)
fileNo++;
}
if (fileNo < NBR_COMPRESSED_FILES)
if (!bSkipCountCheck && (fileNo < NBR_COMPRESSED_FILES))
{
Error ("DIST_PACKAGE_CORRUPTED", NULL);
goto sem_end;
}
Decompressed_Files_Count = fileNo;
free (compressedData);
return TRUE;
@ -635,7 +666,7 @@ void __cdecl ExtractAllFilesThread (void *hwndDlg)
GetModuleFileName (NULL, packageFile, ARRAYSIZE (packageFile));
if (!(bSuccess = SelfExtractInMemory (packageFile)))
if (!(bSuccess = SelfExtractInMemory (packageFile, FALSE)))
goto eaf_end;
if (mkfulldir (DestExtractPath, TRUE) != 0)

View File

@ -27,11 +27,12 @@ typedef struct
} DECOMPRESSED_FILE;
extern DECOMPRESSED_FILE Decompressed_Files [NBR_COMPRESSED_FILES];
extern int Decompressed_Files_Count;
void SelfExtractStartupInit (void);
BOOL SelfExtractInMemory (wchar_t *path);
BOOL SelfExtractInMemory (wchar_t *path, BOOL bSkipCountCheck);
void __cdecl ExtractAllFilesThread (void *hwndDlg);
BOOL MakeSelfExtractingPackage (HWND hwndDlg, wchar_t *szDestDir);
BOOL MakeSelfExtractingPackage (HWND hwndDlg, wchar_t *szDestDir, BOOL bSkipX64);
BOOL VerifyPackageIntegrity (const wchar_t *path);
BOOL VerifySelfPackageIntegrity (void);
BOOL IsSelfExtractingPackage (void);

View File

@ -787,7 +787,7 @@ BOOL DoFilesInstall (HWND hwndDlg, wchar_t *szDestDir)
GetModuleFileName (NULL, szTmp, ARRAYSIZE (szTmp));
if (!SelfExtractInMemory (szTmp))
if (!SelfExtractInMemory (szTmp, FALSE))
return FALSE;
}
@ -2779,7 +2779,7 @@ int WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, wchar_t *lpsz
{
/* Create self-extracting package */
MakeSelfExtractingPackage (NULL, SetupFilesDir);
MakeSelfExtractingPackage (NULL, SetupFilesDir, FALSE);
}
else
{

View File

@ -10,7 +10,7 @@ call "..\..\doc\chm\create_chm.bat"
cd %SIGNINGPATH%
rem sign using SHA-256
signtool sign /v /sha1 88c1ff4b7469ea3915bd8e7635a7567d34f43202 /ac GlobalSign_SHA256_EV_CodeSigning_CA.cer /fd sha256 /tr http://timestamp.digicert.com /td SHA256 "..\Release\Setup Files\VeraCrypt.exe" "..\Release\Setup Files\VeraCrypt Format.exe" "..\Release\Setup Files\VeraCryptExpander.exe" "..\Release\Setup Files\VeraCrypt-x64.exe" "..\Release\Setup Files\VeraCrypt Format-x64.exe" "..\Release\Setup Files\VeraCryptExpander-x64.exe" "..\Release\Setup Files\VeraCrypt-arm64.exe" "..\Release\Setup Files\VeraCrypt Format-arm64.exe" "..\Release\Setup Files\VeraCryptExpander-arm64.exe" "..\Release\Setup Files\VeraCrypt COMReg.exe" "..\Release\Setup Files\VeraCryptSetup.dll"
signtool sign /v /sha1 88c1ff4b7469ea3915bd8e7635a7567d34f43202 /ac GlobalSign_SHA256_EV_CodeSigning_CA.cer /fd sha256 /tr http://timestamp.digicert.com /td SHA256 "..\Release\Setup Files\VeraCrypt.exe" "..\Release\Setup Files\VeraCrypt Format.exe" "..\Release\Setup Files\VeraCryptExpander.exe" "..\Release\Setup Files\VeraCrypt-x64.exe" "..\Release\Setup Files\VeraCrypt Format-x64.exe" "..\Release\Setup Files\VeraCryptExpander-x64.exe" "..\Release\Setup Files\VeraCrypt-arm64.exe" "..\Release\Setup Files\VeraCrypt Format-arm64.exe" "..\Release\Setup Files\VeraCryptExpander-arm64.exe" "..\Release\Setup Files\VeraCryptSetup.dll"
rem create setup and MSI
cd "..\Release\Setup Files\"
@ -38,6 +38,12 @@ del docs.zip
7z a -y docs.zip docs
"VeraCrypt Setup.exe" /p
"VeraCrypt Portable.exe" /p
VeraCryptCOMRegBase.exe /p
cd %SIGNINGPATH%
signtool sign /v /sha1 88c1ff4b7469ea3915bd8e7635a7567d34f43202 /ac GlobalSign_SHA256_EV_CodeSigning_CA.cer /fd sha256 /tr http://timestamp.digicert.com /td SHA256 "..\Release\Setup Files\VeraCrypt COMReg.exe"
cd "..\Release\Setup Files\"
call build_msi_x64.bat %VC_VERSION_NBRE%
del LICENSE
del License.txt