diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c
index 179ea217..2e0b507a 100644
--- a/src/Common/Dlgcode.c
+++ b/src/Common/Dlgcode.c
@@ -9523,8 +9523,11 @@ BOOL PrintHardCopyTextUTF16 (wchar_t *text, wchar_t *title, size_t textByteLen)
BOOL IsNonInstallMode ()
{
- HKEY hkey;
+ HKEY hkey, hkeybis;
DWORD dw;
+ WCHAR szBuffer[512];
+ DWORD dwBufferSize = sizeof(szBuffer);
+ std::wstring msiProductGUID;
if (bPortableModeConfirmed)
return TRUE;
@@ -9582,6 +9585,29 @@ BOOL IsNonInstallMode ()
CloseHandle (hDriverTmp);
}
+ // The following test checks whether the MSI is installed, which means we're not in portable mode.
+ // The ProductGUID is read from registry.
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\VeraCrypt_MSI", 0, KEY_QUERY_VALUE | KEY_WOW64_32KEY, &hkey) == ERROR_SUCCESS ||
+ RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\VeraCrypt_MSI", 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS)
+ {
+ if (ERROR_SUCCESS == RegQueryValueExW(hkey, L"ProductGuid", 0, NULL, (LPBYTE)szBuffer, &dwBufferSize))
+ {
+ msiProductGUID = szBuffer;
+
+ std::wstring regKey = L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\";
+ regKey += msiProductGUID;
+
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, regKey.c_str(), 0, KEY_READ | KEY_WOW64_32KEY, &hkeybis) == ERROR_SUCCESS ||
+ RegOpenKeyEx(HKEY_LOCAL_MACHINE, regKey.c_str(), 0, KEY_READ, &hkeybis) == ERROR_SUCCESS)
+ {
+ RegCloseKey(hkeybis);
+ return FALSE;
+ }
+ }
+
+ RegCloseKey(hkey);
+ }
+
// The following test may be unreliable in some cases (e.g. after the user selects restore "Last Known Good
// Configuration" from the Windows boot menu).
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\VeraCrypt", 0, KEY_READ | KEY_WOW64_32KEY, &hkey) == ERROR_SUCCESS)
@@ -11335,12 +11361,21 @@ BYTE *MapResource (wchar_t *resourceType, int resourceId, PDWORD size)
{
HGLOBAL hResL;
HRSRC hRes;
+ HINSTANCE hResInst = NULL;
- hRes = FindResource (NULL, MAKEINTRESOURCE(resourceId), resourceType);
- hResL = LoadResource (NULL, hRes);
+#ifdef SETUP_DLL
+ // In case we're being called from the SetupDLL project, FindResource()
+ // and LoadResource() with NULL will fail since we're in a DLL. We need
+ // to call them with the HINSTANCE of the DLL instead, which we set in
+ // Setup.c of SetupDLL, DllMain() function.
+ hResInst = hInst;
+#endif
+
+ hRes = FindResource (hResInst, MAKEINTRESOURCE(resourceId), resourceType);
+ hResL = LoadResource (hResInst, hRes);
if (size != NULL)
- *size = SizeofResource (NULL, hRes);
+ *size = SizeofResource (hResInst, hRes);
return (BYTE *) LockResource (hResL);
}
diff --git a/src/Release/Setup Files/Custom_InstallDir.wxs b/src/Release/Setup Files/Custom_InstallDir.wxs
new file mode 100644
index 00000000..3c9563fd
--- /dev/null
+++ b/src/Release/Setup Files/Custom_InstallDir.wxs
@@ -0,0 +1,83 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+ "1"]]>
+
+ 1
+
+ NOT Installed
+ Installed AND PATCH
+
+ 1
+
+ 1
+ LicenseAccepted = "1"
+
+ 1
+ 1
+ NOT WIXUI_DONTVALIDATEPATH
+ "1"]]>
+ WIXUI_DONTVALIDATEPATH OR WIXUI_INSTALLDIR_VALID="1"
+ 1
+ 1
+
+ NOT Installed
+ Installed AND NOT PATCH
+ Installed AND PATCH
+
+ 1
+
+ 1
+ 1
+ 1
+
+
+
+
+
+
+
diff --git a/src/Release/Setup Files/Custom_InstallDirDlg.wxs b/src/Release/Setup Files/Custom_InstallDirDlg.wxs
new file mode 100644
index 00000000..1893801b
--- /dev/null
+++ b/src/Release/Setup Files/Custom_InstallDirDlg.wxs
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Release/Setup Files/Product64.wxs b/src/Release/Setup Files/Product64.wxs
new file mode 100644
index 00000000..7bd7388b
--- /dev/null
+++ b/src/Release/Setup Files/Product64.wxs
@@ -0,0 +1,1709 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 602)
+ ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ INSTALLDESKTOPSHORTCUT
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ INSTALLSTARTMENUSHORTCUT
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ REGISTERVCFILEEXT
+
+
+
+
+
+
+
+
+
+
+
+ REGISTERVCFILEEXT
+
+
+
+
+
+
+
+
+
+
+ REGISTERVCFILEEXT
+
+
+
+
+
+
+
+
+
+
+ REGISTERVCFILEEXT
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ REINSTALL OR UPGRADINGPRODUCTCODE OR REMOVE~="ALL"
+
+
+
+
+
+
+ "YES" AND NOT Installed ]]>
+
+
+ REINSTALL OR UPGRADINGPRODUCTCODE OR REMOVE~="ALL"
+
+
+
+
+ (NOT Installed AND NOT REMOVE) OR REINSTALL
+
+
+ (NOT Installed AND NOT REMOVE) OR REINSTALL
+
+
+ (NOT Installed AND NOT REMOVE) OR REINSTALL
+
+
+ (NOT Installed AND NOT REMOVE) OR REINSTALL
+
+
+
+
+ REMOVE~="ALL" AND NOT UPGRADINGPRODUCTCODE
+
+
+ REMOVE~="ALL" AND NOT UPGRADINGPRODUCTCODE
+
+
+ REMOVE~="ALL" AND NOT UPGRADINGPRODUCTCODE
+
+
+ REMOVE~="ALL" AND NOT UPGRADINGPRODUCTCODE
+
+
+ (NOT Installed AND NOT REMOVE) OR REINSTALL OR (REMOVE~="ALL" AND NOT UPGRADINGPRODUCTCODE)
+
+
+
+
+
+ ISREBOOTREQUIRED = "1"
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Release/Setup Files/Strings-en.wxl b/src/Release/Setup Files/Strings-en.wxl
new file mode 100644
index 00000000..48946057
--- /dev/null
+++ b/src/Release/Setup Files/Strings-en.wxl
@@ -0,0 +1,24 @@
+
+
+ 1033
+ A newer version is already installed
+ This 32-bit installer can only run on at least Windows Vista
+ This is a 32-bit installer that cannot be run under 64-bit Windows
+ This is a 64-bit installer that cannot be run under 32-bit Windows
+
+ Choose which options to enable then click Next to proceed.
+
+ Install for all users
+ Add VeraCrypt icon to desktop
+
+ Associate the .hc file extension with VeraCrypt
+
+ Please close all open VeraCrypt windows first.
+
+ Please accept the license agreement by passing ACCEPTLICENSE=YES during installation.
+
+ VeraCrypt
+ VeraCrypt Expander
+ VeraCrypt Website
+
+
\ No newline at end of file
diff --git a/src/Release/Setup Files/build_msi_x64.bat b/src/Release/Setup Files/build_msi_x64.bat
new file mode 100644
index 00000000..476625b0
--- /dev/null
+++ b/src/Release/Setup Files/build_msi_x64.bat
@@ -0,0 +1,178 @@
+::------------------------------------
+::Define search paths here for Wix ToolSet and SDK (and SignTool optionnally)
+::------------------------------------
+
+@set SEARCH_WIX_PATH=C:\Program Files (x86)\WiX Toolset v3.11\bin
+
+@set SEARCH_VC_DIR_PLATFORMSDK_1=C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x86
+@set SEARCH_VC_DIR_PLATFORMSDK_2=C:\Program Files (x86)\Windows Kits\10\bin\x86
+@set SEARCH_VC_DIR_PLATFORMSDK_3=C:\Program Files\Microsoft Platform SDK\bin
+@set SEARCH_VC_DIR_PLATFORMSDK_4=C:\Program Files (x86)\Windows Kits\8.1\bin\x86
+@set SEARCH_VC_DIR_PLATFORMSDK_5=C:\Program Files (x86)\Windows Kits\8.0\bin\x86
+@set SEARCH_VC_DIR_PLATFORMSDK_6=C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\bin
+
+::end of search paths
+
+set MSI_BUILDPATH=%~dp0
+cd %MSI_BUILDPATH%
+
+::------------------------------------
+:: Look for msitran.exe and msidb.exe
+::------------------------------------
+
+@echo [INFO] Define default value for VC_DIR_PLATFORMSDK if not defined yet
+@echo [INFO] Input VC_DIR_PLATFORMSDK=%VC_DIR_PLATFORMSDK%
+@set FILE_TO_FIND="msitran.exe" "msidb.exe"
+@echo [INFO] Looking for files: %FILE_TO_FIND%
+
+@set FILE_NOT_FOUND=
+@for %%i in (%FILE_TO_FIND%) do @if not exist "%VC_DIR_PLATFORMSDK%\%%~i" set FILE_NOT_FOUND=%%~i
+@if "%FILE_NOT_FOUND%"=="" goto found_mssdk
+@echo Not found in "%VC_DIR_PLATFORMSDK%"
+
+@set VC_DIR_PLATFORMSDK=%SEARCH_VC_DIR_PLATFORMSDK_1%
+@set FILE_NOT_FOUND=
+@for %%i in (%FILE_TO_FIND%) do @if not exist "%VC_DIR_PLATFORMSDK%\%%~i" set FILE_NOT_FOUND=%%~i
+@if "%FILE_NOT_FOUND%"=="" goto found_mssdk
+@echo Not found in "%VC_DIR_PLATFORMSDK%"
+
+@set VC_DIR_PLATFORMSDK=%SEARCH_VC_DIR_PLATFORMSDK_2%
+@set FILE_NOT_FOUND=
+@for %%i in (%FILE_TO_FIND%) do @if not exist "%VC_DIR_PLATFORMSDK%\%%~i" set FILE_NOT_FOUND=%%~i
+@if "%FILE_NOT_FOUND%"=="" goto found_mssdk
+@echo Not found in "%VC_DIR_PLATFORMSDK%"
+
+@set VC_DIR_PLATFORMSDK=%SEARCH_VC_DIR_PLATFORMSDK_3%
+@set FILE_NOT_FOUND=
+@for %%i in (%FILE_TO_FIND%) do @if not exist "%VC_DIR_PLATFORMSDK%\%%~i" set FILE_NOT_FOUND=%%~i
+@if "%FILE_NOT_FOUND%"=="" goto found_mssdk
+@echo Not found in "%VC_DIR_PLATFORMSDK%"
+
+@rem paths for Windows 8 SDK are slightly different
+@set FILE_TO_FIND="msitran.exe" "msidb.exe"
+
+@set VC_DIR_PLATFORMSDK=%SEARCH_VC_DIR_PLATFORMSDK_4%
+@set FILE_NOT_FOUND=
+@for %%i in (%FILE_TO_FIND%) do @if not exist "%VC_DIR_PLATFORMSDK%\%%~i" set FILE_NOT_FOUND=%%~i
+@if "%FILE_NOT_FOUND%"=="" goto found_mssdk
+@echo Not found in "%VC_DIR_PLATFORMSDK%"
+
+@set VC_DIR_PLATFORMSDK=%SEARCH_VC_DIR_PLATFORMSDK_5%
+@set FILE_NOT_FOUND=
+@for %%i in (%FILE_TO_FIND%) do @if not exist "%VC_DIR_PLATFORMSDK%\%%~i" set FILE_NOT_FOUND=%%~i
+@if "%FILE_NOT_FOUND%"=="" goto found_mssdk
+@echo Not found in "%VC_DIR_PLATFORMSDK%"
+
+@set VC_DIR_PLATFORMSDK=%SEARCH_VC_DIR_PLATFORMSDK_6%
+@set FILE_NOT_FOUND=
+@for %%i in (%FILE_TO_FIND%) do @if not exist "%VC_DIR_PLATFORMSDK%\%%~i" set FILE_NOT_FOUND=%%~i
+@if "%FILE_NOT_FOUND%"=="" goto found_mssdk
+@echo Not found in "%VC_DIR_PLATFORMSDK%"
+
+@echo [ERROR] MS Platform SDK 2008, Windows SDK v7.1, or Windows SDK 8.0/8.1/10 could not be found
+@echo If the path is not any of the above,
+@echo please define VC_DIR_PLATFORMSDK environment variable.
+@exit /B 1
+
+:found_mssdk
+@echo Found in "%VC_DIR_PLATFORMSDK%"
+
+::------------------------------------
+:: Look for candle.exe (and light.exe obviously)
+::------------------------------------
+
+@echo [INFO] Check if WiX is installed
+@echo [INFO] Default value for VC_DIR_WIX is set to %WIX%
+@set VC_DIR_WIX=%WIX%
+@set FILE_TO_FIND="candle.exe"
+@echo [INFO] Looking for files: %FILE_TO_FIND%
+
+@set FILE_NOT_FOUND=
+@for %%i in (%FILE_TO_FIND%) do @if not exist "%VC_DIR_WIX%\%%~i" set FILE_NOT_FOUND=%%~i
+@if "%FILE_NOT_FOUND%"=="" goto found_wix
+@echo Not found in "%VC_DIR_WIX%"
+
+@set VC_DIR_WIX=%SEARCH_WIX_PATH%
+@set FILE_NOT_FOUND=
+@for %%i in (%FILE_TO_FIND%) do @if not exist "%VC_DIR_WIX%\%%~i" set FILE_NOT_FOUND=%%~i
+@if "%FILE_NOT_FOUND%"=="" goto found_wix
+@echo Not found in "%VC_DIR_WIX%"
+
+@echo [ERROR] WiX could not be found
+@echo Please install Wix3
+@exit /B 1
+
+:found_wix
+@echo Found in "%VC_DIR_WIX%"
+
+::------------------------------------
+:: Create a MSI installer for each language
+:: We make use of -sice:ICE09 to silence ICE09 warnings generated because we install non-permanent elements to 'SystemFolder'
+::------------------------------------
+@echo [INFO] Creating msi 64-bit installers
+
+@echo [INFO] Making the en-us version in %cd%\out\64\en-us\
+"%VC_DIR_WIX%\candle.exe" -dLang=en -arch x64 -ext WixUIExtension -ext WiXUtilExtension Product64.wxs -out out\64\en-us\Product.wixobj
+@if NOT "%ERRORLEVEL%" == "0" goto msi_failed
+"%VC_DIR_WIX%\candle.exe" -dLang=en -arch x64 -ext WixUIExtension -ext WiXUtilExtension Custom_InstallDir.wxs -out out\64\en-us\Custom_InstallDir.wixobj
+@if NOT "%ERRORLEVEL%" == "0" goto msi_failed
+"%VC_DIR_WIX%\candle.exe" -dLang=en -arch x64 -ext WixUIExtension -ext WiXUtilExtension Custom_InstallDirDlg.wxs -out out\64\en-us\Custom_InstallDirDlg.wixobj
+@if NOT "%ERRORLEVEL%" == "0" goto msi_failed
+"%VC_DIR_WIX%\Light.exe" -ext WixUIExtension -ext WiXUtilExtension -cultures:en-us -loc Strings-en.wxl out\64\en-us\Product.wixobj out\64\en-us\Custom_InstallDirDlg.wixobj out\64\en-us\Custom_InstallDir.wixobj -out out\64\en-us\VeraCrypt_%1_Setup_en-us.msi -pdbout out\64\en-us\VeraCrypt_%1_Setup_en-us.wixpdb -sice:ICE09
+@if NOT "%ERRORLEVEL%" == "0" goto msi_failed
+
+::------------------------------------
+:: Join the language specific MSIs together
+::------------------------------------
+@echo [INFO] Joining msi 64-bit installers into 1 64-bit installer
+
+@set OUT_PATH=%cd%\out\64\
+@echo [INFO] OUT_PATH=%OUT_PATH%
+
+@set MSI_FILE_IN=VeraCrypt_%1_Setup
+@set MSI_FILE_OUT=VeraCrypt_%1_Setup_x64
+
+:: Check if all the MSI files were built
+@set LANG=en-us
+@IF NOT EXIST "%OUT_PATH%\%LANG%\%MSI_FILE_IN%_%LANG%.msi" goto NOT_%LANG%
+
+:: Take all the MSI files and process
+@set LANG=en-us
+@copy /Y "%OUT_PATH%\%LANG%\%MSI_FILE_IN%_%LANG%.msi" "%OUT_PATH%\%MSI_FILE_OUT%.msi"
+
+::------------------------------------
+:: Add all available LCIDs
+::------------------------------------
+"%VC_DIR_PLATFORMSDK%\MsiInfo.Exe" "%OUT_PATH%\%MSI_FILE_OUT%.msi" /p x64;1033
+@if NOT "%ERRORLEVEL%" == "0" goto comb_msi_failed
+
+::------------------------------------
+:: Copy to bin and remove out
+::------------------------------------
+mkdir bin
+@copy /Y "%OUT_PATH%\%MSI_FILE_OUT%.msi" "%cd%\bin\%MSI_FILE_OUT%.msi"
+@set LANG=en-us
+@copy /Y "%OUT_PATH%\%LANG%\%MSI_FILE_IN%_%LANG%.msi" "%cd%\bin\%MSI_FILE_IN%_x64_%LANG%.msi"
+@rmdir /S /Q "%cd%\out"
+
+goto END
+
+:msi_failed
+@echo [ERR ] failed to create the MSI
+@exit /B 1
+
+:comb_msi_failed
+@echo [ERR ] failed to combine the language specific MSI's
+@exit /B 1
+
+:NOT_en-us
+@echo [ERR ] Missing file '%OUT_PATH%\%LANG%\%MSI_FILE_IN%_%LANG%.msi'
+@exit /B 1
+
+:NOT_lv-lv
+@echo [ERR ] Missing file '%OUT_PATH%\%LANG%\%MSI_FILE_IN%_%LANG%.msi'
+@exit /B 1
+
+@echo [INFO] Done creating multi-lang msi installers
+:END
+@echo end
\ No newline at end of file
diff --git a/src/Setup/Setup.vcxproj b/src/Setup/Setup.vcxproj
index 922d3018..30c7e167 100644
--- a/src/Setup/Setup.vcxproj
+++ b/src/Setup/Setup.vcxproj
@@ -104,6 +104,7 @@
md "..\Debug\Setup Files" 2>NUL:
copy Debug\VeraCryptSetup.exe "..\Debug\Setup Files\VeraCrypt Setup.exe" >NUL:
+copy Debug\VeraCryptSetup.exe "..\Debug\Setup Files\VeraCrypt COMReg.exe" >NUL:
@@ -142,7 +143,7 @@ copy Debug\VeraCryptSetup.exe "..\Debug\Setup Files\VeraCrypt Setup.exe" >NUL
Setup.manifest;%(AdditionalManifestFiles)
- copy Release\VeraCryptSetup.exe "..\Release\Setup Files\VeraCrypt Setup.exe"
+ copy Release\VeraCryptSetup.exe "..\Release\Setup Files\VeraCrypt Setup.exe" && copy Release\VeraCryptSetup.exe "..\Release\Setup Files\VeraCrypt COMReg.exe"
diff --git a/src/SetupDLL/ComSetup.cpp b/src/SetupDLL/ComSetup.cpp
new file mode 100644
index 00000000..07c3360a
--- /dev/null
+++ b/src/SetupDLL/ComSetup.cpp
@@ -0,0 +1,114 @@
+/*
+ Derived from source code of TrueCrypt 7.1a, which is
+ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
+ by the TrueCrypt License 3.0.
+
+ Modifications and additions to the original source code (contained in this file)
+ and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and are governed by the Apache License 2.0 the full text of which is
+ contained in the file License.txt included in VeraCrypt binary and source
+ code distribution packages.
+*/
+
+#define TC_MAIN_COM_VERSION_MAJOR 2
+#define TC_MAIN_COM_VERSION_MINOR 11
+
+#define TC_FORMAT_COM_VERSION_MAJOR 2
+#define TC_FORMAT_COM_VERSION_MINOR 9
+
+#include
+#include
+#include
+#include
+#include "ComSetup.h"
+#include "Dlgcode.h"
+#include "Resource.h"
+#include "../Mount/MainCom_i.c"
+#include "../Format/FormatCom_i.c"
+
+/*
+ * Same as RegisterComServers() in Setup project, but
+ * instead of using GetModuleFileNameW() to get this
+ * DLL's path as setupModule which will not work because
+ * the DLL is embedded in the binary of the MSI,
+ * we ship the empty version of 'VeraCrypt Setup.exe'
+ * as 'VeraCrypt COMReg.exe' and use it.
+ */
+extern "C" BOOL RegisterComServers (wchar_t *modulePath)
+{
+ BOOL ret = TRUE;
+ wchar_t mainModule[1024], formatModule[1024], setupModule[1024];
+ CComPtr tl, tl2;
+
+ wsprintfW (mainModule, L"%sVeraCrypt.exe", modulePath);
+ wsprintfW (formatModule, L"%sVeraCrypt Format.exe", modulePath);
+ wsprintfW (setupModule, L"%sVeraCrypt COMReg.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);
+ // unregister older versions that may still exist
+ for (WORD i = 7; i >= 1; i--)
+ UnRegisterTypeLib (LIBID_TrueCryptMainCom, TC_MAIN_COM_VERSION_MAJOR, TC_MAIN_COM_VERSION_MINOR-i, 0, SYS_WIN32);
+ for (WORD i = 5; i >= 1; i--)
+ UnRegisterTypeLib (LIBID_TrueCryptFormatCom, TC_FORMAT_COM_VERSION_MAJOR, TC_FORMAT_COM_VERSION_MINOR-i, 0, SYS_WIN32);
+
+ CRegObject ro;
+ HRESULT r;
+
+ if (!SUCCEEDED (r = ro.FinalConstruct ())
+ || !SUCCEEDED (r = ro.AddReplacement (L"MAIN_MODULE", mainModule))
+ || !SUCCEEDED (r = ro.AddReplacement (L"FORMAT_MODULE", formatModule))
+ || !SUCCEEDED (r = ro.ResourceRegister (setupModule, IDR_COMREG, L"REGISTRY"))
+ || !SUCCEEDED (r = LoadTypeLib (mainModule, &tl))
+ || !SUCCEEDED (r = RegisterTypeLib (tl, mainModule, 0))
+ || !SUCCEEDED (r = LoadTypeLib (formatModule, &tl2))
+ || !SUCCEEDED (r = RegisterTypeLib (tl2, formatModule, 0)))
+ {
+ MessageBox (MainDlg, _com_error (r).ErrorMessage(), _T(TC_APP_NAME), MB_ICONERROR);
+ ret = FALSE;
+ }
+
+ ro.FinalRelease ();
+ return ret;
+}
+
+/*
+ * Same as UnregisterComServers() in Setup project, but
+ * instead of using GetModuleFileNameW() to get this
+ * DLL's path as setupModule which will not work because
+ * the DLL is embedded in the binary of the MSI,
+ * we ship the empty version of 'VeraCrypt Setup.exe'
+ * as 'VeraCrypt COMReg.exe' and use it.
+ */
+extern "C" BOOL UnregisterComServers (wchar_t *modulePath)
+{
+ BOOL ret;
+
+ if (UnRegisterTypeLib (LIBID_TrueCryptMainCom, TC_MAIN_COM_VERSION_MAJOR, TC_MAIN_COM_VERSION_MINOR, 0, SYS_WIN32) != S_OK)
+ return FALSE;
+ if (UnRegisterTypeLib (LIBID_TrueCryptFormatCom, TC_FORMAT_COM_VERSION_MAJOR, TC_FORMAT_COM_VERSION_MINOR, 0, SYS_WIN32) != S_OK)
+ return FALSE;
+
+ // unregister older versions that may still exist
+ for (WORD i = 7; i >= 1; i--)
+ UnRegisterTypeLib (LIBID_TrueCryptMainCom, TC_MAIN_COM_VERSION_MAJOR, TC_MAIN_COM_VERSION_MINOR-i, 0, SYS_WIN32);
+ for (WORD i = 5; i >= 1; i--)
+ UnRegisterTypeLib (LIBID_TrueCryptFormatCom, TC_FORMAT_COM_VERSION_MAJOR, TC_FORMAT_COM_VERSION_MINOR-i, 0, SYS_WIN32);
+
+ wchar_t module[1024];
+ HRESULT r;
+ CRegObject ro;
+ ro.FinalConstruct ();
+
+ wsprintfW (module, L"%sVeraCrypt.exe", modulePath);
+ ro.AddReplacement (L"MAIN_MODULE", module);
+
+ wsprintfW (module, L"%sVeraCrypt Format.exe", modulePath);
+ ro.AddReplacement (L"FORMAT_MODULE", module);
+
+ wsprintfW (module, L"%sVeraCrypt COMReg.exe", modulePath);
+ ret = SUCCEEDED(r = ro.ResourceUnregister (module, IDR_COMREG, L"REGISTRY"));
+
+ ro.FinalRelease ();
+ return ret;
+}
diff --git a/src/SetupDLL/ComSetup.h b/src/SetupDLL/ComSetup.h
new file mode 100644
index 00000000..85d0f249
--- /dev/null
+++ b/src/SetupDLL/ComSetup.h
@@ -0,0 +1,22 @@
+/*
+ Derived from source code of TrueCrypt 7.1a, which is
+ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
+ by the TrueCrypt License 3.0.
+
+ Modifications and additions to the original source code (contained in this file)
+ and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and are governed by the Apache License 2.0 the full text of which is
+ contained in the file License.txt included in VeraCrypt binary and source
+ code distribution packages.
+*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+BOOL RegisterComServers (wchar_t *modulePath);
+BOOL UnregisterComServers (wchar_t *modulePath);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/SetupDLL/ComSetup.rgs b/src/SetupDLL/ComSetup.rgs
new file mode 100644
index 00000000..b8201c10
--- /dev/null
+++ b/src/SetupDLL/ComSetup.rgs
@@ -0,0 +1,92 @@
+HKCR
+{
+ ForceRemove VeraCrypt.1 = s 'VeraCrypt class'
+ {
+ CLSID = s '{FE8B3B95-C80C-41f7-830F-FBA271C26F7E}'
+ }
+
+ ForceRemove VeraCrypt = s 'VeraCrypt class'
+ {
+ CLSID = s '{FE8B3B95-C80C-41f7-830F-FBA271C26F7E}'
+ CurVer = s 'VeraCrypt.1'
+ }
+
+ NoRemove CLSID
+ {
+ ForceRemove {FE8B3B95-C80C-41f7-830F-FBA271C26F7E} = s 'VeraCrypt class'
+ {
+ ProgID = s 'VeraCrypt.1'
+ VersionIndependentProgID = s 'VeraCrypt'
+ LocalServer32 = s '"%MAIN_MODULE%"'
+
+ TypeLib = s '{9ACF6176-5FC4-4690-A025-B3306A50EB6A}'
+
+ Elevation
+ {
+ val Enabled = d 1
+ val IconReference = s '@%MAIN_MODULE%,-501'
+ }
+
+ val AppId = s '{FE8B3B95-C80C-41f7-830F-FBA271C26F7E}'
+ val LocalizedString = s '@%MAIN_MODULE%,-110'
+ }
+ }
+
+ NoRemove AppId
+ {
+ ForceRemove {FE8B3B95-C80C-41f7-830F-FBA271C26F7E} = s 'VeraCrypt class'
+ {
+ val AccessPermission = b 010004803000000040000000000000001400000002001c000100000000001400070000000101000000000005040000000102000000000005200000002002000001020000000000052000000020020000
+ }
+
+ ForceRemove VeraCrypt.exe
+ {
+ val AppId = s '{FE8B3B95-C80C-41f7-830F-FBA271C26F7E}'
+ }
+ }
+
+ ForceRemove VeraCryptFormat.1 = s 'VeraCryptFormat class'
+ {
+ CLSID = s '{A96D3797-9F31-49f4-A0CE-9657392CF789}'
+ }
+
+ ForceRemove VeraCryptFormat = s 'VeraCryptFormat class'
+ {
+ CLSID = s '{A96D3797-9F31-49f4-A0CE-9657392CF789}'
+ CurVer = s 'VeraCryptFormat.1'
+ }
+
+ NoRemove CLSID
+ {
+ ForceRemove {A96D3797-9F31-49f4-A0CE-9657392CF789} = s 'VeraCryptFormat class'
+ {
+ ProgID = s 'VeraCryptFormat.1'
+ VersionIndependentProgID = s 'VeraCryptFormat'
+ LocalServer32 = s '"%FORMAT_MODULE%"'
+
+ TypeLib = s '{56327DDA-F1A7-4e13-B128-520D129BDEF6}'
+
+ Elevation
+ {
+ val Enabled = d 1
+ val IconReference = s '@%FORMAT_MODULE%,-501'
+ }
+
+ val AppId = s '{A96D3797-9F31-49f4-A0CE-9657392CF789}'
+ val LocalizedString = s '@%FORMAT_MODULE%,-112'
+ }
+ }
+
+ NoRemove AppId
+ {
+ ForceRemove {A96D3797-9F31-49f4-A0CE-9657392CF789} = s 'VeraCryptFormat class'
+ {
+ val AccessPermission = b 010004803000000040000000000000001400000002001c000100000000001400070000000101000000000005040000000102000000000005200000002002000001020000000000052000000020020000
+ }
+
+ ForceRemove 'VeraCrypt Format.exe'
+ {
+ val AppId = s '{A96D3797-9F31-49f4-A0CE-9657392CF789}'
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/SetupDLL/Dir.c b/src/SetupDLL/Dir.c
new file mode 100644
index 00000000..2d4feecd
--- /dev/null
+++ b/src/SetupDLL/Dir.c
@@ -0,0 +1,110 @@
+/*
+ Legal Notice: Some portions of the source code contained in this file were
+ derived from the source code of TrueCrypt 7.1a, which is
+ Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
+ governed by the TrueCrypt License 3.0, also from the source code of
+ Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
+ and which is governed by the 'License Agreement for Encryption for the Masses'
+ Modifications and additions to the original source code (contained in this file)
+ and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and are governed by the Apache License 2.0 the full text of which is
+ contained in the file License.txt included in VeraCrypt binary and source
+ code distribution packages. */
+
+#include "Tcdefs.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "Dir.h"
+
+/* create full directory tree. returns 0 for success, -1 if failure */
+int
+mkfulldir (wchar_t *oriPath, BOOL bCheckonly)
+{
+ struct _stat st;
+ wchar_t *uniq_file;
+ wchar_t path [TC_MAX_PATH];
+
+ StringCbCopyW (path, TC_MAX_PATH, oriPath);
+
+ 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 = wcsrchr (path, L'\\');
+ if (uniq_file && uniq_file[1] == L'\0')
+ uniq_file[0] = L'\0';
+ else
+ {
+ uniq_file = wcsrchr (path, L'/');
+ if (uniq_file && uniq_file[1] == L'\0')
+ uniq_file[0] = L'\0';
+ }
+
+ is_root:
+ if (bCheckonly)
+ return _wstat (path, &st);
+
+ if (_wstat (path, &st))
+ return mkfulldir_internal (path);
+ else
+ return 0;
+}
+
+
+int
+mkfulldir_internal (wchar_t *path)
+{
+ wchar_t *token;
+ struct _stat st;
+ static wchar_t tokpath[_MAX_PATH];
+ static wchar_t trail[_MAX_PATH];
+
+ StringCbCopyW (tokpath, _MAX_PATH, path);
+ trail[0] = L'\0';
+
+ token = wcstok (tokpath, L"\\/");
+
+ if (tokpath[0] == L'\\' && tokpath[1] == L'\\')
+ { /* unc */
+ trail[0] = tokpath[0];
+ trail[1] = tokpath[1];
+ trail[2] = L'\0';
+ if (token)
+ {
+ StringCbCatW (trail, _MAX_PATH, token);
+ StringCbCatW (trail, _MAX_PATH, L"\\");
+ token = wcstok (NULL, L"\\/");
+ if (token)
+ { /* get share name */
+ StringCbCatW (trail, _MAX_PATH, token);
+ StringCbCatW (trail, _MAX_PATH, L"\\");
+ }
+ token = wcstok (NULL, L"\\/");
+ }
+ }
+
+ if (tokpath[1] == L':')
+ { /* drive letter */
+ StringCbCatW (trail, _MAX_PATH, tokpath);
+ StringCbCatW (trail, _MAX_PATH, L"\\");
+ token = wcstok (NULL, L"\\/");
+ }
+
+ while (token != NULL)
+ {
+ int x;
+ StringCbCatW (trail, _MAX_PATH, token);
+ x = _wmkdir (trail);
+ StringCbCatW (trail, _MAX_PATH, L"\\");
+ token = wcstok (NULL, L"\\/");
+ }
+
+ return _wstat (path, &st);
+}
diff --git a/src/SetupDLL/Dir.h b/src/SetupDLL/Dir.h
new file mode 100644
index 00000000..fb9dfc6b
--- /dev/null
+++ b/src/SetupDLL/Dir.h
@@ -0,0 +1,23 @@
+/*
+ Legal Notice: Some portions of the source code contained in this file were
+ derived from the source code of TrueCrypt 7.1a, which is
+ Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
+ governed by the TrueCrypt License 3.0, also from the source code of
+ Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
+ and which is governed by the 'License Agreement for Encryption for the Masses'
+ Modifications and additions to the original source code (contained in this file)
+ and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and are governed by the Apache License 2.0 the full text of which is
+ contained in the file License.txt included in VeraCrypt binary and source
+ code distribution packages. */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int mkfulldir ( wchar_t *path , BOOL bCheckonly );
+int mkfulldir_internal ( wchar_t *path );
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/SetupDLL/Portable.manifest b/src/SetupDLL/Portable.manifest
new file mode 100644
index 00000000..5d4cb896
--- /dev/null
+++ b/src/SetupDLL/Portable.manifest
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/SetupDLL/Portable.rc b/src/SetupDLL/Portable.rc
new file mode 100644
index 00000000..6ffc03c7
--- /dev/null
+++ b/src/SetupDLL/Portable.rc
@@ -0,0 +1,291 @@
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "winres.h"
+#include "..\\common\\resource.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (United States) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1,24,25,0
+ PRODUCTVERSION 1,24,25,0
+ 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 Portable"
+ VALUE "FileVersion", "1.24-Update9"
+ VALUE "LegalTrademarks", "VeraCrypt"
+ VALUE "OriginalFilename", "VeraCrypt Portable.exe"
+ VALUE "ProductName", "VeraCrypt"
+ VALUE "ProductVersion", "1.24-Update9"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// HEADER
+//
+
+IDR_SETUP_RSRC_HEADER HEADER "resource.h"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+/////////////////////////////////////////////////////////////////////////////
+//
+// LANGUAGES
+//
+
+IDR_LANG_AR LANGUAGES "..\\..\\Translations\\Language.ar.xml"
+IDR_LANG_CS LANGUAGES "..\\..\\Translations\\Language.cs.xml"
+IDR_LANG_DE LANGUAGES "..\\..\\Translations\\Language.de.xml"
+IDR_LANG_ES LANGUAGES "..\\..\\Translations\\Language.es.xml"
+IDR_LANG_FR LANGUAGES "..\\..\\Translations\\Language.fr.xml"
+IDR_LANG_IT LANGUAGES "..\\..\\Translations\\Language.it.xml"
+IDR_LANG_JA LANGUAGES "..\\..\\Translations\\Language.ja.xml"
+IDR_LANG_NL LANGUAGES "..\\..\\Translations\\Language.nl.xml"
+IDR_LANG_PL LANGUAGES "..\\..\\Translations\\Language.pl.xml"
+IDR_LANG_RO LANGUAGES "..\\..\\Translations\\Language.ro.xml"
+IDR_LANG_RU LANGUAGES "..\\..\\Translations\\Language.ru.xml"
+IDR_LANG_VI LANGUAGES "..\\..\\Translations\\Language.vi.xml"
+IDR_LANG_ZHCN LANGUAGES "..\\..\\Translations\\Language.zh-cn.xml"
+IDR_LANG_ZHHK LANGUAGES "..\\..\\Translations\\Language.zh-hk.xml"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_INFO_PAGE_DLG DIALOGEX 0, 0, 217, 156
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ LTEXT "",IDC_BOX_HELP,0,10,217,146
+END
+
+IDD_INTRO_PAGE_DLG DIALOGEX 0, 0, 346, 152
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ CONTROL "",IDC_LICENSE_TEXT,"RichEdit20W",WS_BORDER | WS_VSCROLL | WS_TABSTOP | 0x2804,0,23,345,108
+ CONTROL "",IDC_AGREE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,2,137,126,10
+ LTEXT "",IDC_BOX_HELP,0,0,346,22
+END
+
+IDD_INSTL_DLG DIALOGEX 0, 0, 374, 231
+STYLE DS_SETFONT | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "VeraCrypt Portable Wizard"
+CLASS "VeraCryptCustomDlg"
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ PUSHBUTTON "&Help",IDHELP,150,211,50,14
+ PUSHBUTTON "",IDC_PREV,209,211,50,14
+ DEFPUSHBUTTON "",IDC_NEXT,259,211,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,317,211,50,14
+ LTEXT "",IDC_BOX_TITLE,11,5,324,12,0,WS_EX_TRANSPARENT
+ CONTROL 107,IDC_BITMAP_SETUP_WIZARD,"Static",SS_BITMAP | SS_NOTIFY,139,3,228,30
+ CONTROL 109,IDC_SETUP_WIZARD_BKG,"Static",SS_BITMAP,0,0,11,10
+ CONTROL "",IDC_SETUP_WIZARD_GFX_AREA,"Static",SS_GRAYRECT | NOT WS_VISIBLE,0,0,378,36,WS_EX_TRANSPARENT | WS_EX_STATICEDGE
+ CONTROL "",IDC_HR_BOTTOM,"Static",SS_ETCHEDHORZ,67,204,306,1,WS_EX_STATICEDGE
+ CONTROL "",IDC_HR,"Static",SS_ETCHEDHORZ,0,35,399,1,WS_EX_STATICEDGE
+ LTEXT "VeraCrypt Portable",IDC_STATIC,4,200,62,8,WS_DISABLED
+ LTEXT "",IDC_BOX_INFO,18,18,317,13,0,WS_EX_TRANSPARENT
+ LTEXT "",IDC_MAIN_CONTENT_CANVAS,0,36,374,164
+ LTEXT "",IDC_POS_BOX,14,42,346,155,0,WS_EX_TRANSPARENT
+END
+
+IDD_EXTRACTION_OPTIONS_PAGE_DLG DIALOGEX 0, 0, 346, 152
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ PUSHBUTTON "Bro&wse...",IDC_BROWSE,277,32,62,14
+ EDITTEXT IDC_DESTINATION,6,33,264,12,ES_AUTOHSCROLL
+ LTEXT "Please select or type the location where you want to place the extracted files:",IDT_EXTRACT_DESTINATION,6,15,333,17
+ CONTROL "&Open the destination location when finished",IDC_OPEN_CONTAINING_FOLDER,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,91,318,16
+ LTEXT "",IDC_BOX_HELP,6,56,333,32
+END
+
+IDD_PROGRESS_PAGE_DLG DIALOGEX 0, 0, 346, 152
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ LISTBOX IDC_LOG_WINDOW,0,1,345,131,LBS_NOINTEGRALHEIGHT | LBS_DISABLENOSCROLL | LBS_NOSEL | WS_VSCROLL
+ CONTROL "",IDC_PROGRESS_BAR,"msctls_progress32",PBS_SMOOTH | WS_BORDER,0,139,345,12
+END
+
+IDD_DONATIONS_PAGE_DLG DIALOGEX 0, 0, 346, 152
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+EXSTYLE WS_EX_TRANSPARENT
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ PUSHBUTTON "Donate now...",IDC_DONATE,124,94,96,14
+END
+
+IDD_INSTALL_LANGUAGE DIALOGEX 0, 0, 213, 87
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "VeraCrypt Setup Wizard"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ DEFPUSHBUTTON "OK",IDOK,102,66,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,156,66,50,14
+ ICON 501,IDC_STATIC,10,10,32,32
+ LTEXT "Select the language to use during the installation:",IDC_SELECT_LANGUAGE_LABEL,42,13,157,26
+ COMBOBOX IDC_LANGUAGES_LIST,42,44,164,155,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+END
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_SETUP ICON "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
+
+3 TEXTINCLUDE
+BEGIN
+ "#include ""..\\\\common\\\\common.rc""\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_INFO_PAGE_DLG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 210
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 149
+ END
+
+ IDD_INTRO_PAGE_DLG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 339
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 145
+ END
+
+ IDD_INSTL_DLG, DIALOG
+ BEGIN
+ END
+
+ IDD_EXTRACTION_OPTIONS_PAGE_DLG, DIALOG
+ BEGIN
+ RIGHTMARGIN, 343
+ BOTTOMMARGIN, 147
+ END
+
+ IDD_PROGRESS_PAGE_DLG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 339
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 145
+ END
+
+ IDD_DONATIONS_PAGE_DLG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 339
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 147
+ END
+
+ IDD_INSTALL_LANGUAGE, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 206
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 80
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Bitmap
+//
+
+IDB_SETUP_WIZARD BITMAP "VeraCrypt_setup.bmp"
+IDB_SETUP_WIZARD_BKG BITMAP "VeraCrypt_setup_background.bmp"
+#endif // English (United States) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+#include "..\\common\\common.rc"
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/src/SetupDLL/Portable.vcxproj b/src/SetupDLL/Portable.vcxproj
new file mode 100644
index 00000000..e864515b
--- /dev/null
+++ b/src/SetupDLL/Portable.vcxproj
@@ -0,0 +1,281 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ ReleaseCustomEFI
+ Win32
+
+
+ Release
+ Win32
+
+
+
+ {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}
+ Portable
+ Win32Proj
+
+
+
+ Application
+ Unicode
+ Windows7.1SDK
+
+
+ Application
+ Unicode
+ Windows7.1SDK
+
+
+ Application
+ Unicode
+ Windows7.1SDK
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <_ProjectFileVersion>10.0.40219.1
+ PortableDebug\
+ PortableDebug\
+ true
+ true
+ true
+ PortableRelease\
+ PortableRelease\
+ PortableRelease\
+ PortableRelease\
+ false
+ false
+ true
+ true
+ VeraCryptPortable
+ VeraCryptPortable
+ VeraCryptPortable
+
+
+
+ Disabled
+ ..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;%(AdditionalIncludeDirectories)
+ SETUP;PORTABLE;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;_ATL_NO_DEFAULT_LIBS;%(PreprocessorDefinitions)
+ true
+ EnableFastChecks
+ MultiThreadedDebug
+ true
+
+
+ Level4
+ EditAndContinue
+ 4057;4100;4127;4201;4505;4701;4706;4131;%(DisableSpecificWarnings)
+
+
+ /NODEFAULTLIB:LIBCMTD %(AdditionalOptions)
+ libcmtd.lib;atlsd.lib;mpr.lib;..\Common\Debug\Zip.lib;..\Crypto\Debug\crypto.lib;%(AdditionalDependencies)
+ $(OutDir)VeraCryptPortable.exe
+ AsInvoker
+ user32.dll;gdi32.dll;advapi32.dll;shell32.dll;ole32.dll;mpr.dll;%(DelayLoadDLLs)
+ true
+ $(OutDir)Portable.pdb
+ Windows
+ false
+ true
+ MachineX86
+
+
+ Portable.manifest;%(AdditionalManifestFiles)
+
+
+ md "..\Debug\Setup Files" 2>NUL:
+copy PortableDebug\VeraCryptPortable.exe "..\Debug\Setup Files\VeraCrypt Portable.exe" >NUL:
+
+
+
+
+
+ /w34189 %(AdditionalOptions)
+ MaxSpeed
+ ..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;%(AdditionalIncludeDirectories)
+ SETUP;PORTABLE;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;_ATL_NO_DEFAULT_LIBS;%(PreprocessorDefinitions)
+ MultiThreaded
+ true
+
+
+ All
+ $(IntDir)
+ Level4
+ ProgramDatabase
+ 4057;4100;4127;4201;4505;4701;4706;4131;%(DisableSpecificWarnings)
+
+
+ /IGNORE:4089 %(AdditionalOptions)
+ mpr.lib;..\Common\Release\Zip.lib;..\Crypto\Release\crypto.lib;%(AdditionalDependencies)
+ $(OutDir)VeraCryptPortable.exe
+ AsInvoker
+ user32.dll;gdi32.dll;advapi32.dll;shell32.dll;ole32.dll;mpr.dll;%(DelayLoadDLLs)
+ true
+ true
+ Windows
+ true
+ true
+ true
+ true
+ MachineX86
+
+
+ Portable.manifest;%(AdditionalManifestFiles)
+
+
+ copy PortableRelease\VeraCryptPortable.exe "..\Release\Setup Files\VeraCrypt Portable.exe"
+
+
+
+
+ /w34189 %(AdditionalOptions)
+ MaxSpeed
+ ..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;%(AdditionalIncludeDirectories)
+ SETUP;PORTABLE;VC_EFI_CUSTOM_MODE;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;_ATL_NO_DEFAULT_LIBS;%(PreprocessorDefinitions)
+ MultiThreaded
+ true
+
+
+ All
+ $(IntDir)
+ Level4
+ ProgramDatabase
+ 4057;4100;4127;4201;4505;4701;4706;4131;%(DisableSpecificWarnings)
+
+
+ /IGNORE:4089 %(AdditionalOptions)
+ mpr.lib;..\Common\Release\Zip.lib;..\Crypto\Release\crypto.lib;%(AdditionalDependencies)
+ $(OutDir)VeraCryptPortable.exe
+ AsInvoker
+ user32.dll;gdi32.dll;advapi32.dll;shell32.dll;ole32.dll;mpr.dll;%(DelayLoadDLLs)
+ true
+ true
+ Windows
+ true
+ true
+ true
+ true
+ MachineX86
+
+
+ Portable.manifest;%(AdditionalManifestFiles)
+
+
+ copy PortableRelease\VeraCryptPortable.exe "..\Release\Setup Files\VeraCrypt Portable.exe"
+
+
+ VC_EFI_CUSTOM_MODE;%(PreprocessorDefinitions)
+
+
+
+
+
+
+ CompileAsCpp
+ CompileAsCpp
+ CompileAsCpp
+
+
+ CompileAsCpp
+ CompileAsCpp
+ CompileAsCpp
+
+
+
+
+
+ CompileAsCpp
+ CompileAsCpp
+ CompileAsCpp
+
+
+ CompileAsCpp
+ CompileAsCpp
+ CompileAsCpp
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ true
+
+
+
+
+
+ {8b7f059f-e4c7-4e11-88f5-ee8b8433072e}
+ false
+
+
+ {9715ff1d-599b-4bbc-ad96-bef6e08ff827}
+ false
+
+
+ {9dc1abe2-d18b-48fb-81d2-8c50adc57bcf}
+ false
+
+
+ {e4c40f94-e7f9-4981-86e4-186b46f993f3}
+ false
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/SetupDLL/Portable.vcxproj.filters b/src/SetupDLL/Portable.vcxproj.filters
new file mode 100644
index 00000000..855ecc00
--- /dev/null
+++ b/src/SetupDLL/Portable.vcxproj.filters
@@ -0,0 +1,154 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {876C2050-1694-4F32-AF5D-491C6A43A799}
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hpp;hxx;hm;inl;inc;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx
+
+
+ {17370B4B-2D76-41A9-9828-015FB30054F6}
+
+
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files\Common
+
+
+ Source Files\Common
+
+
+ Source Files\Common
+
+
+ Source Files\Common
+
+
+ Source Files\Common
+
+
+ Source Files\Common
+
+
+ Source Files
+
+
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files\Common
+
+
+ Resource Files\Common
+
+
+ Resource Files\Common
+
+
+ Resource Files\Common
+
+
+ Resource Files\Common
+
+
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+
+
+
+
+
+ Resource Files\Common
+
+
+ Resource Files
+
+
+
\ No newline at end of file
diff --git a/src/SetupDLL/Portable.vcxproj.user b/src/SetupDLL/Portable.vcxproj.user
new file mode 100644
index 00000000..ace9a86a
--- /dev/null
+++ b/src/SetupDLL/Portable.vcxproj.user
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/src/SetupDLL/Resource.h b/src/SetupDLL/Resource.h
new file mode 100644
index 00000000..8882d67b
--- /dev/null
+++ b/src/SetupDLL/Resource.h
@@ -0,0 +1,81 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by Setup.rc
+//
+#define IDR_COMREG 10
+#define IDR_LANG_AR 20
+#define IDR_LANG_CS 21
+#define IDR_LANG_DE 22
+#define IDR_LANG_ES 23
+#define IDR_LANG_FR 24
+#define IDR_LANG_IT 25
+#define IDR_LANG_JA 26
+#define IDR_LANG_NL 27
+#define IDR_LANG_PL 28
+#define IDR_LANG_RO 29
+#define IDR_LANG_RU 30
+#define IDR_LANG_VI 31
+#define IDR_LANG_ZHCN 32
+#define IDR_LANG_ZHHK 33
+#define IDD_INSTALL 101
+#define IDD_INSTALL_OPTIONS_PAGE_DLG 102
+#define IDD_UNINSTALL 103
+#define IDI_SETUP 104
+#define IDR_SETUP_RSRC_HEADER 105
+#define IDD_EXTRACTION_OPTIONS_PAGE_DLG 106
+#define IDB_SETUP_WIZARD 107
+#define IDD_INTRO_PAGE_DLG 108
+#define IDB_SETUP_WIZARD_BKG 109
+#define IDD_INFO_PAGE_DLG 110
+#define IDD_INSTL_DLG 111
+#define IDD_WIZARD_MODE_PAGE_DLG 112
+#define IDD_PROGRESS_PAGE_DLG 113
+#define IDD_DONATIONS_PAGE_DLG 114
+#define IDD_INSTALL_LANGUAGE 115
+#define IDC_DESTINATION 1000
+#define IDC_BOX_TITLE 1001
+#define IDC_BROWSE 1002
+#define IDC_BOX_INFO 1003
+#define IDC_LICENSE 1004
+#define IDC_BOX_HELP 1005
+#define IDC_LICENSE_TEXT 1006
+#define IDC_BOX_HELP2 1007
+#define IDC_FILE_TYPE 1008
+#define IDT_UNINSTALL_DIR 1009
+#define IDC_PROG_GROUP 1010
+#define IDC_SYSTEM_RESTORE 1011
+#define IDC_DESKTOP_ICON 1012
+#define IDC_ALL_USERS 1013
+#define IDT_INSTALL_DESTINATION 1014
+#define IDC_UNINSTALL 1015
+#define IDC_PROGRESS_BAR 1016
+#define IDC_LOG_WINDOW 1017
+#define IDC_SETUP_WIZARD_BKG 1018
+#define IDC_SETUP_WIZARD_GFX_AREA 1019
+#define IDC_HR 1020
+#define IDC_OPEN_CONTAINING_FOLDER 1021
+#define IDC_AGREE 1022
+#define IDC_HR_BOTTOM 1023
+#define IDC_WIZARD_MODE_INSTALL 1024
+#define IDC_WIZARD_MODE_EXTRACT_ONLY 1025
+#define IDC_NEXT 1026
+#define IDC_PREV 1027
+#define IDT_EXTRACT_DESTINATION 1028
+#define IDC_POS_BOX 1029
+#define IDC_BITMAP_SETUP_WIZARD 1030
+#define IDC_MAIN_CONTENT_CANVAS 1031
+#define IDC_DONATE 1032
+#define IDC_LANGUAGES_LIST 1033
+#define IDC_SELECT_LANGUAGE_LABEL 1034
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NO_MFC 1
+#define _APS_NEXT_RESOURCE_VALUE 116
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1035
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/src/SetupDLL/Setup.c b/src/SetupDLL/Setup.c
new file mode 100644
index 00000000..14bdefd4
--- /dev/null
+++ b/src/SetupDLL/Setup.c
@@ -0,0 +1,3620 @@
+/*
+ Legal Notice: Some portions of the source code contained in this file were
+ derived from the source code of TrueCrypt 7.1a, which is
+ Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
+ governed by the TrueCrypt License 3.0, also from the source code of
+ Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
+ and which is governed by the 'License Agreement for Encryption for the Masses'
+ Modifications and additions to the original source code (contained in this file)
+ and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and are governed by the Apache License 2.0 the full text of which is
+ contained in the file License.txt included in VeraCrypt binary and source
+ code distribution packages. */
+
+#include "Tcdefs.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "Apidrvr.h"
+#include "BootEncryption.h"
+#include "Boot/Windows/BootCommon.h"
+#include "Combo.h"
+#include "ComSetup.h"
+#include "Dlgcode.h"
+#include "Language.h"
+#include "Registry.h"
+#include "Resource.h"
+
+#include "Dir.h"
+#include "Setup.h"
+
+#include "../Common/Resource.h"
+
+#pragma comment(lib, "Shlwapi.lib")
+
+using namespace VeraCrypt;
+
+#pragma warning( disable : 4201 )
+#pragma warning( disable : 4115 )
+
+#include
+
+#pragma warning( default : 4201 )
+#pragma warning( default : 4115 )
+
+#include
+
+#include
+#include
+#include
+
+#include
+#if !defined(va_copy)
+#define va_copy(d, s) ((d) = (s))
+#endif
+
+typedef enum
+{
+ MSI_INFO_LEVEL = 0,
+ MSI_WARNING_LEVEL,
+ MSI_ERROR_LEVEL
+} eMSILogLevel;
+
+#define WAIT_PERIOD 3
+
+extern HMODULE hRichEditDll;
+extern HMODULE hComctl32Dll;
+extern HMODULE hSetupDll;
+extern HMODULE hShlwapiDll;
+extern HMODULE hProfApiDll;
+extern HMODULE hUsp10Dll;
+extern HMODULE hCryptSpDll;
+extern HMODULE hUXThemeDll;
+extern HMODULE hUserenvDll;
+extern HMODULE hRsaenhDll;
+extern HMODULE himm32dll;
+extern HMODULE hMSCTFdll;
+extern HMODULE hfltlibdll;
+extern HMODULE hframedyndll;
+extern HMODULE hpsapidll;
+extern HMODULE hsecur32dll;
+extern HMODULE hnetapi32dll;
+extern HMODULE hauthzdll;
+extern HMODULE hxmllitedll;
+extern HMODULE hmprdll;
+extern HMODULE hsppdll;
+extern HMODULE vssapidll;
+extern HMODULE hvsstracedll;
+extern HMODULE hcfgmgr32dll;
+extern HMODULE hdevobjdll;
+extern HMODULE hpowrprofdll;
+extern HMODULE hsspiclidll;
+extern HMODULE hcryptbasedll;
+extern HMODULE hdwmapidll;
+extern HMODULE hmsasn1dll;
+extern HMODULE hcrypt32dll;
+extern HMODULE hbcryptdll;
+extern HMODULE hbcryptprimitivesdll;
+extern HMODULE hMsls31;
+extern HMODULE hntmartadll;
+extern HMODULE hwinscarddll;
+extern HMODULE hmsvcrtdll;
+extern HMODULE hWinTrustLib;
+extern HMODULE hAdvapi32Dll;
+
+#define FREE_DLL(h) if (h) { FreeLibrary (h); h = NULL;}
+
+#ifndef BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE
+#define BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE 0x00000001
+#endif
+
+#ifndef BASE_SEARCH_PATH_PERMANENT
+#define BASE_SEARCH_PATH_PERMANENT 0x00008000
+#endif
+
+#ifndef LOAD_LIBRARY_SEARCH_SYSTEM32
+#define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800
+#endif
+
+typedef BOOL (WINAPI *SetDllDirectoryPtr)(LPCWSTR lpPathName);
+typedef BOOL (WINAPI *SetSearchPathModePtr)(DWORD Flags);
+typedef BOOL (WINAPI *SetDefaultDllDirectoriesPtr)(DWORD DirectoryFlags);
+
+typedef void (WINAPI *InitCommonControlsPtr)(void);
+typedef HIMAGELIST (WINAPI *ImageList_CreatePtr)(int cx, int cy, UINT flags, int cInitial, int cGrow);
+typedef int (WINAPI *ImageList_AddPtr)(HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask);
+
+typedef VOID (WINAPI *SetupCloseInfFilePtr)(HINF InfHandle);
+typedef HKEY (WINAPI *SetupDiOpenClassRegKeyPtr)(CONST GUID *ClassGuid,REGSAM samDesired);
+typedef BOOL (WINAPI *SetupInstallFromInfSectionWPtr)(HWND,HINF,PCWSTR,UINT,HKEY,PCWSTR,UINT,PSP_FILE_CALLBACK_W,PVOID,HDEVINFO,PSP_DEVINFO_DATA);
+typedef HINF (WINAPI *SetupOpenInfFileWPtr)(PCWSTR FileName,PCWSTR InfClass,DWORD InfStyle,PUINT ErrorLine);
+
+typedef LSTATUS (STDAPICALLTYPE *SHDeleteKeyWPtr)(HKEY hkey, LPCWSTR pszSubKey);
+
+typedef HRESULT (STDAPICALLTYPE *SHStrDupWPtr)(LPCWSTR psz, LPWSTR *ppwsz);
+
+// ChangeWindowMessageFilter
+typedef BOOL (WINAPI *ChangeWindowMessageFilterPtr) (UINT, DWORD);
+
+typedef BOOL (WINAPI *CreateProcessWithTokenWFn)(
+ __in HANDLE hToken,
+ __in DWORD dwLogonFlags,
+ __in_opt LPCWSTR lpApplicationName,
+ __inout_opt LPWSTR lpCommandLine,
+ __in DWORD dwCreationFlags,
+ __in_opt LPVOID lpEnvironment,
+ __in_opt LPCWSTR lpCurrentDirectory,
+ __in LPSTARTUPINFOW lpStartupInfo,
+ __out LPPROCESS_INFORMATION lpProcessInformation
+ );
+
+extern SetDllDirectoryPtr SetDllDirectoryFn;
+extern SetSearchPathModePtr SetSearchPathModeFn;
+extern SetDefaultDllDirectoriesPtr SetDefaultDllDirectoriesFn;
+
+extern ImageList_CreatePtr ImageList_CreateFn;
+extern ImageList_AddPtr ImageList_AddFn;
+
+extern SetupCloseInfFilePtr SetupCloseInfFileFn;
+extern SetupDiOpenClassRegKeyPtr SetupDiOpenClassRegKeyFn;
+extern SetupInstallFromInfSectionWPtr SetupInstallFromInfSectionWFn;
+extern SetupOpenInfFileWPtr SetupOpenInfFileWFn;
+extern SHDeleteKeyWPtr SHDeleteKeyWFn;
+extern SHStrDupWPtr SHStrDupWFn;
+extern ChangeWindowMessageFilterPtr ChangeWindowMessageFilterFn;
+extern CreateProcessWithTokenWFn CreateProcessWithTokenWPtr;
+
+wchar_t InstallationPath[TC_MAX_PATH];
+
+BOOL bUninstall = FALSE;
+BOOL bDowngrade = FALSE;
+BOOL bUninstallInProgress = FALSE;
+BOOL PortableMode = FALSE;
+BOOL UnloadDriver = TRUE;
+
+BOOL Rollback = FALSE;
+BOOL bReinstallMode = FALSE;
+BOOL bUpgrade = FALSE;
+BOOL bPossiblyFirstTimeInstall = FALSE;
+BOOL bDevm = FALSE;
+BOOL SystemEncryptionUpdate = FALSE;
+BOOL bRestartRequired = FALSE;
+BOOL bDisableSwapFiles = FALSE;
+BOOL bSystemRestore = TRUE;
+HMODULE volatile SystemRestoreDll = 0;
+
+BOOL bPromptFastStartup = FALSE;
+BOOL bPromptReleaseNotes = FALSE;
+BOOL bPromptTutorial = FALSE;
+BOOL bUpdateRescueDisk = FALSE;
+BOOL bRepairMode = FALSE;
+BOOL bUserSetLanguage = FALSE;
+
+/*
+BOOL bMakePackage = FALSE;
+BOOL bDone = FALSE;
+
+BOOL bForAllUsers = TRUE;
+BOOL bRegisterFileExt = TRUE;
+BOOL bAddToStartMenu = TRUE;
+BOOL bDesktopIcon = TRUE;
+BOOL bDesktopIconStatusDetermined = FALSE;
+
+*/
+
+/* **************************************************************************** */
+
+/* Defined in this file, but a little bit late */
+BOOL IsSystemRestoreEnabled ();
+
+/*
+ * Same as in Setup.c
+ */
+BOOL ForceCopyFile (LPCWSTR szSrcFile, LPCWSTR szDestFile)
+{
+ BOOL bRet = CopyFileW (szSrcFile, szDestFile, FALSE);
+ if (!bRet)
+ {
+ wstring renamedPath = szDestFile;
+ renamedPath += VC_FILENAME_RENAMED_SUFFIX;
+
+ /* rename the locked file in order to be able to create a new one */
+ if (MoveFileExW (szDestFile, renamedPath.c_str(), MOVEFILE_REPLACE_EXISTING))
+ {
+ bRet = CopyFileW (szSrcFile, szDestFile, FALSE);
+ if (bRet)
+ {
+ /* delete the renamed file when the machine reboots */
+ MoveFileEx (renamedPath.c_str(), NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
+ }
+ else
+ {
+ /* restore the original file name */
+ MoveFileEx (renamedPath.c_str(), szDestFile, MOVEFILE_REPLACE_EXISTING);
+ }
+ }
+ }
+
+ return bRet;
+}
+
+/*
+ * Same as in Setup.c
+ */
+BOOL ForceDeleteFile (LPCWSTR szFileName)
+{
+ if (!DeleteFile (szFileName))
+ {
+ /* delete the renamed file when the machine reboots */
+ return MoveFileEx (szFileName, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
+ }
+ else
+ return TRUE;
+}
+
+/*
+ * Same as in Setup.c
+ */
+BOOL StatDeleteFile (wchar_t *lpszFile, BOOL bCheckForOldFile)
+{
+ struct __stat64 st;
+
+ if (bCheckForOldFile)
+ {
+ wchar_t szOldPath[MAX_PATH + 1];
+ StringCbCopyW (szOldPath, sizeof(szOldPath), lpszFile);
+ StringCbCatW (szOldPath, sizeof(szOldPath), VC_FILENAME_RENAMED_SUFFIX);
+
+ if (_wstat64 (szOldPath, &st) == 0)
+ {
+ ForceDeleteFile (szOldPath);
+ }
+ }
+
+ if (_wstat64 (lpszFile, &st) == 0)
+ return ForceDeleteFile (lpszFile);
+ else
+ return TRUE;
+}
+
+/*
+ * Same as in Setup.c
+ */
+BOOL StatRemoveDirectory (wchar_t *lpszDir)
+{
+ struct __stat64 st;
+
+ if (_wstat64 (lpszDir, &st) == 0)
+ {
+ return DeleteDirectory (lpszDir);
+ }
+ else
+ return TRUE;
+}
+
+/*
+ * Same as in Setup.c
+ */
+void StatusMessage (HWND hwndDlg, char *stringId)
+{
+ if (Rollback)
+ return;
+
+ SendMessageW (GetDlgItem (hwndDlg, IDC_LOG_WINDOW), LB_ADDSTRING, 0, (LPARAM) GetString (stringId));
+
+ SendDlgItemMessage (hwndDlg, IDC_LOG_WINDOW, LB_SETTOPINDEX,
+ SendDlgItemMessage (hwndDlg, IDC_LOG_WINDOW, LB_GETCOUNT, 0, 0) - 1, 0);
+}
+
+/*
+ * Same as in Setup.c
+ */
+void DetermineUpgradeDowngradeStatus (BOOL bCloseDriverHandle, LONG *driverVersionPtr)
+{
+ LONG driverVersion = VERSION_NUM;
+ int status = 0;
+
+ if (hDriver == INVALID_HANDLE_VALUE)
+ status = DriverAttach();
+
+ if ((status == 0) && (hDriver != INVALID_HANDLE_VALUE))
+ {
+ DWORD dwResult;
+ BOOL bResult = DeviceIoControl (hDriver, TC_IOCTL_GET_DRIVER_VERSION, NULL, 0, &driverVersion, sizeof (driverVersion), &dwResult, NULL);
+
+ if (!bResult)
+ bResult = DeviceIoControl (hDriver, TC_IOCTL_LEGACY_GET_DRIVER_VERSION, NULL, 0, &driverVersion, sizeof (driverVersion), &dwResult, NULL);
+
+
+ bUpgrade = (bResult && driverVersion <= VERSION_NUM);
+ bDowngrade = (bResult && driverVersion > VERSION_NUM);
+ bReinstallMode = (bResult && driverVersion == VERSION_NUM);
+
+ PortableMode = DeviceIoControl (hDriver, TC_IOCTL_GET_PORTABLE_MODE_STATUS, NULL, 0, NULL, 0, &dwResult, NULL);
+
+ if (bCloseDriverHandle)
+ {
+ CloseHandle (hDriver);
+ hDriver = INVALID_HANDLE_VALUE;
+ }
+ }
+
+ *driverVersionPtr = driverVersion;
+}
+
+/*
+ * Same as in Setup.c
+ */
+BOOL IsSystemRestoreEnabled ()
+{
+ BOOL bEnabled = FALSE;
+ HKEY hKey;
+ DWORD dwValue = 0, cbValue = sizeof (DWORD);
+ 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, L"RPSessionInterval", NULL, NULL, (LPBYTE) &dwValue, &cbValue))
+ && (dwValue == 1)
+ )
+ {
+ bEnabled = TRUE;
+ }
+ }
+ else
+ {
+ if ( (ERROR_SUCCESS == RegQueryValueEx (hKey, L"DisableSR", NULL, NULL, (LPBYTE) &dwValue, &cbValue))
+ && (dwValue == 0)
+ )
+ {
+ bEnabled = TRUE;
+ }
+ }
+
+
+ RegCloseKey (hKey);
+ }
+
+ return bEnabled;
+}
+
+/*
+ * Same as in Setup.c
+ */
+static void RecursiveSetOwner (HKEY hKey, PSECURITY_DESCRIPTOR pSD)
+{
+ LSTATUS status = 0;
+ DWORD dwIndex = 0, dwMaxNameLen = 0, dwNameLen = 0, numberSubKeys = 0;
+ HKEY hSubKey;
+
+ if ( (ERROR_SUCCESS == status) && (ERROR_SUCCESS == RegQueryInfoKey(hKey, NULL, NULL, NULL, &numberSubKeys, &dwMaxNameLen, NULL, NULL, NULL, NULL, NULL, NULL))
+ && (numberSubKeys >= 1)
+ )
+ {
+ dwMaxNameLen++;
+ wchar_t* szNameValue = new wchar_t[dwMaxNameLen];
+ while (true)
+ {
+ dwNameLen = dwMaxNameLen;
+ status = RegEnumKeyExW (hKey, dwIndex++, szNameValue, &dwNameLen, NULL, NULL, NULL, NULL);
+ if (status == ERROR_SUCCESS)
+ {
+ status = RegOpenKeyExW (hKey, szNameValue, 0, WRITE_OWNER | KEY_READ , &hSubKey);
+ if (ERROR_SUCCESS == status)
+ {
+ RecursiveSetOwner (hSubKey, pSD);
+ RegCloseKey(hSubKey);
+ }
+ }
+ else
+ break;
+ }
+ delete [] szNameValue;
+ }
+
+ RegSetKeySecurity (hKey, OWNER_SECURITY_INFORMATION, pSD);
+}
+
+/*
+ * Same as in Setup.c
+ */
+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 = 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 = RegOpenKeyExW(hKey, SubKeyName, 0, WRITE_DAC | KEY_READ , &hSubKey);
+ }
+
+ if ( (ERROR_SUCCESS == status)
+ && (ERROR_SUCCESS == RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, &numberSubKeys, &dwMaxNameLen, NULL, NULL, NULL, NULL, NULL, NULL))
+ && (numberSubKeys >= 1)
+ )
+ {
+ dwMaxNameLen++;
+ wchar_t* szNameValue = new wchar_t[dwMaxNameLen];
+ while (true)
+ {
+ dwNameLen = dwMaxNameLen;
+ status = RegEnumKeyExW (hSubKey, dwIndex++, szNameValue, &dwNameLen, NULL, NULL, NULL, NULL);
+ if (status == ERROR_SUCCESS)
+ {
+ RecursiveSetDACL (hSubKey, szNameValue, pSD);
+ }
+ else
+ break;
+ }
+ delete [] szNameValue;
+ }
+ }
+}
+
+/*
+ * Same as in Setup.c
+ */
+static void AllowKeyAccess(HKEY Key,const wchar_t* SubKeyName)
+{
+ LSTATUS RegResult;
+ HKEY SvcKey = NULL;
+ DWORD dwLength = 0;
+ HANDLE Token = NULL;
+ PTOKEN_USER pTokenUser = NULL;
+ std::string sNewSD;
+
+ RegResult = RegOpenKeyExW(Key, SubKeyName, 0, WRITE_OWNER | KEY_READ, &SvcKey);
+ if (RegResult==ERROR_SUCCESS)
+ {
+ if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &Token))
+ {
+ if (!GetTokenInformation(Token, TokenUser, pTokenUser, 0, &dwLength))
+ {
+ if (GetLastError() ==ERROR_INSUFFICIENT_BUFFER)
+ {
+ pTokenUser = (PTOKEN_USER) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwLength);
+ if (pTokenUser)
+ {
+ if (GetTokenInformation(Token, TokenUser, pTokenUser, dwLength, &dwLength))
+ {
+ SECURITY_DESCRIPTOR SecDesc;
+ if ( InitializeSecurityDescriptor(&SecDesc, SECURITY_DESCRIPTOR_REVISION)
+ && SetSecurityDescriptorDacl(&SecDesc, TRUE, NULL, FALSE) // NULL DACL: full access to everyone
+ && SetSecurityDescriptorOwner(&SecDesc, pTokenUser->User.Sid, FALSE)
+ )
+ {
+ RecursiveSetOwner(SvcKey, &SecDesc);
+ }
+ }
+
+ }
+ }
+ }
+ }
+ RegCloseKey(SvcKey);
+ }
+
+ if (pTokenUser)
+ {
+ PSID pSid = pTokenUser->User.Sid;
+ DWORD dwAclSize = sizeof(ACL) + sizeof(ACCESS_ALLOWED_ACE) + ::GetLengthSid(pSid) - sizeof(DWORD);
+ PACL pDacl = (PACL) new BYTE[dwAclSize];
+ if (pDacl)
+ {
+ if (TRUE == ::InitializeAcl(pDacl, dwAclSize, ACL_REVISION))
+ {
+ if (TRUE == AddAccessAllowedAceEx(pDacl, ACL_REVISION, CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE, WRITE_DAC | KEY_ALL_ACCESS, pSid))
+ {
+ SECURITY_DESCRIPTOR SecDesc;
+ if (TRUE == ::InitializeSecurityDescriptor(&SecDesc, SECURITY_DESCRIPTOR_REVISION))
+ {
+ if (TRUE == ::SetSecurityDescriptorDacl(&SecDesc, TRUE, pDacl, FALSE))
+ {
+ RecursiveSetDACL (Key, SubKeyName, &SecDesc);
+ }
+ }
+ }
+ }
+ delete [] pDacl;
+ }
+ }
+
+ if (pTokenUser)
+ HeapFree(GetProcessHeap(), 0, pTokenUser);
+ if (Token)
+ CloseHandle(Token);
+}
+
+/*
+ * Same as in Setup.c
+ */
+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 subKeysList;
+ size_t subStringLength = str? wcslen(str) : 0;
+
+ if (bEnumSubKeys)
+ {
+ DWORD dwMaxNameLen = 0;
+ if (ERROR_SUCCESS == RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, &dwMaxNameLen, NULL, NULL, NULL, NULL, NULL, NULL))
+ {
+ dwMaxNameLen++;
+ wchar_t* szNameValue = new wchar_t[dwMaxNameLen];
+ dwIndex = 0;
+ while (true)
+ {
+ dwValueNameLen = dwMaxNameLen;
+ status = RegEnumKeyExW (hKey, dwIndex++, szNameValue, &dwValueNameLen, NULL, NULL, NULL, NULL);
+ if (status == ERROR_SUCCESS)
+ {
+ if (enumMatchSubStr && !wcsstr(szNameValue, enumMatchSubStr))
+ continue;
+ std::wstring entryName = szNameValue;
+ entryName += L"\\";
+ entryName += subKey;
+ entryName += L"\\";
+ subKeysList.push_back(entryName);
+ }
+ else
+ break;
+ }
+ delete [] szNameValue;
+ }
+ }
+ else
+ {
+ subKeysList.push_back(subKey);
+ }
+
+ for (std::list::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 == DeleteRegistryKey (hKey, ItSubKey->c_str()))
+ {
+ // grant permission to delete
+ AllowKeyAccess (hKey, ItSubKey->c_str());
+
+ // try again
+ DeleteRegistryKey (hKey, ItSubKey->c_str());
+ }
+ }
+ else
+ {
+ 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++;
+ wchar_t* szNameValue = new wchar_t[dwMaxNameLen];
+ LPBYTE pbData = new BYTE[dwMaxDataLen];
+
+ std::list foundEntries;
+ dwIndex = 0;
+ do
+ {
+ dwValueNameLen = dwMaxNameLen;
+ dwDataLen = dwMaxDataLen;
+ status = RegEnumValueW(hSubKey, dwIndex++, szNameValue, &dwValueNameLen, NULL, &dwType, pbData, &dwDataLen);
+ if (status == ERROR_SUCCESS)
+ {
+ if ( (wcslen(szNameValue) >= subStringLength && wcsstr(szNameValue, str))
+ || (dwType == REG_SZ && wcslen((wchar_t*) pbData) >= subStringLength && wcsstr((wchar_t*) pbData, str))
+ )
+ {
+ foundEntries.push_back(szNameValue);
+ }
+ }
+ } while ((status == ERROR_SUCCESS) || (status == ERROR_MORE_DATA)); // we ignore ERROR_MORE_DATA errors since
+ // we are sure to use the correct sizes
+
+ // delete the entries
+ if (!foundEntries.empty())
+ {
+ for (std::list::iterator It = foundEntries.begin();
+ It != foundEntries.end(); It++)
+ {
+ RegDeleteValueW (hSubKey, It->c_str());
+ }
+ }
+
+ delete [] szNameValue;
+ delete [] pbData;
+ }
+
+
+ RegCloseKey (hSubKey);
+ }
+ }
+ }
+}
+
+/* **************************************************************************** */
+
+// Adds a line to the log file of the installer.
+void MSILog(MSIHANDLE hInstall, eMSILogLevel level, const wchar_t* zcFormat, ...)
+{
+ std::wstring wszMessage;
+
+ // initialize use of the variable argument array
+ va_list vaArgs;
+ va_start(vaArgs, zcFormat);
+
+ // reliably acquire the size
+ // from a copy of the variable argument array
+ // and a functionally reliable call to mock the formatting
+ va_list vaArgsCopy;
+ va_copy(vaArgsCopy, vaArgs);
+ const int iLen = vswprintf(NULL, 0, zcFormat, vaArgsCopy);
+ va_end(vaArgsCopy);
+
+ // return a formatted string without risking memory mismanagement
+ // and without assuming any compiler or platform specific behavior
+ std::vector zc(iLen + 1);
+ vswprintf(zc.data(), zc.size(), zcFormat, vaArgs);
+ va_end(vaArgs);
+
+ wszMessage.assign(zc.data(), iLen);
+
+#ifdef TEST_HARNESS
+ if (!hInstall)
+ {
+ MessageBox(NULL, pszMessage, wszMessage.c_str(), 0);
+ return;
+ }
+#endif
+
+ PMSIHANDLE hRecord = MsiCreateRecord(1);
+ // field 0 is the template
+ MsiRecordSetString(hRecord, 0, (level == MSI_INFO_LEVEL) ? L"VeraCryptCustomAction_INFO: [1]" : ((level == MSI_WARNING_LEVEL) ? L"VeraCryptCustomAction_WARNING: [1]" : L"VeraCryptCustomAction_ERROR: [1]"));
+ // field 1, to be placed in [1] placeholder
+ MsiRecordSetString(hRecord, 1, wszMessage.c_str());
+ // send message to running installer
+ MsiProcessMessage(hInstall, INSTALLMESSAGE_INFO, hRecord);
+}
+
+// Adds a line to the log file of the installer and shows a popup.
+// Since MsiProcessMessage() takes the UILEVEL into account,
+// this won't cause a deadlock in case of a silent install.
+void MSILogAndShow(MSIHANDLE hInstall, eMSILogLevel level, const wchar_t* zcFormat, ...)
+{
+ std::wstring wszMessage;
+
+ // initialize use of the variable argument array
+ va_list vaArgs;
+ va_start(vaArgs, zcFormat);
+
+ // reliably acquire the size
+ // from a copy of the variable argument array
+ // and a functionally reliable call to mock the formatting
+ va_list vaArgsCopy;
+ va_copy(vaArgsCopy, vaArgs);
+ const int iLen = vswprintf(NULL, 0, zcFormat, vaArgsCopy);
+ va_end(vaArgsCopy);
+
+ // return a formatted string without risking memory mismanagement
+ // and without assuming any compiler or platform specific behavior
+ std::vector zc(iLen + 1);
+ vswprintf(zc.data(), zc.size(), zcFormat, vaArgs);
+ va_end(vaArgs);
+
+ wszMessage.assign(zc.data(), iLen);
+
+#ifdef TEST_HARNESS
+ if (!hInstall)
+ {
+ MessageBox(NULL, pszMessage, wszMessage.c_str(), 0);
+ return;
+ }
+#endif
+
+ PMSIHANDLE hRecord0 = MsiCreateRecord(1);
+ // field 0 is the template
+ MsiRecordSetString(hRecord0, 0, (level == MSI_INFO_LEVEL) ? L"VeraCryptCustomAction_INFO: [1]" : ((level == MSI_WARNING_LEVEL) ? L"VeraCryptCustomAction_WARNING: [1]" : L"VeraCryptCustomAction_ERROR: [1]"));
+ // field 1, to be placed in [1] placeholder
+ MsiRecordSetString(hRecord0, 1, wszMessage.c_str());
+ // send message to running installer
+ MsiProcessMessage(hInstall, INSTALLMESSAGE_INFO, hRecord0);
+
+ PMSIHANDLE hRecord1 = MsiCreateRecord(0);
+ MsiRecordSetString(hRecord1, 0, wszMessage.c_str());
+ if (level == MSI_INFO_LEVEL)
+ MsiProcessMessage(hInstall, INSTALLMESSAGE(INSTALLMESSAGE_INFO + MB_OK), hRecord1);
+ else if (level == MSI_WARNING_LEVEL)
+ MsiProcessMessage(hInstall, INSTALLMESSAGE(INSTALLMESSAGE_WARNING + MB_OK), hRecord1);
+ else
+ MsiProcessMessage(hInstall, INSTALLMESSAGE(INSTALLMESSAGE_ERROR + MB_OK), hRecord1);
+}
+
+/* **************************************************************************** */
+
+/*
+ * Defined in Dlgcode.c.
+ */
+extern void ExceptionHandlerThread (void *threadArg);
+extern LONG __stdcall ExceptionHandler (EXCEPTION_POINTERS *ep);
+extern void InvalidParameterHandler (const wchar_t *expression, const wchar_t *function, const wchar_t *file, unsigned int line, uintptr_t reserved);
+extern BOOL SystemFileSelectorCallPending;
+extern DWORD SystemFileSelectorCallerThreadId;
+
+/* **************************************************************************** */
+
+/*
+ * Same as in Dlgcode.c, Applink() , but
+ * removed unnecessary code.
+ */
+void Applink_Dll (MSIHANDLE hInstaller, const char *dest)
+{
+ wchar_t url [MAX_URL_LENGTH] = {0};
+ wchar_t page[TC_MAX_PATH] = {0};
+ wchar_t installDir[TC_MAX_PATH] = {0};
+ BOOL buildUrl = TRUE;
+ int r;
+
+ StringCbCopyW (installDir, sizeof (installDir), InstallationPath);
+
+ if (strcmp(dest, "donate") == 0)
+ {
+ StringCbCopyW (page, sizeof (page),L"Donation.html");
+ }
+ else if (strcmp(dest, "main") == 0)
+ {
+ StringCbCopyW (url, sizeof (url), TC_HOMEPAGE);
+ buildUrl = FALSE;
+ }
+ else if (strcmp(dest,"localizations") == 0)
+ {
+ StringCbCopyW (page, sizeof (page),L"Language%20Packs.html");
+ }
+ else if (strcmp(dest, "beginnerstutorial") == 0 || strcmp(dest,"tutorial") == 0)
+ {
+ StringCbCopyW (page, sizeof (page),L"Beginner%27s%20Tutorial.html");
+ }
+ else if (strcmp(dest, "releasenotes") == 0 || strcmp(dest, "history") == 0)
+ {
+ StringCbCopyW (page, sizeof (page),L"Release%20Notes.html");
+ }
+ else if (strcmp(dest, "hwacceleration") == 0)
+ {
+ StringCbCopyW (page, sizeof (page),L"Hardware%20Acceleration.html");
+ }
+ else if (strcmp(dest, "parallelization") == 0)
+ {
+ StringCbCopyW (page, sizeof (page),L"Parallelization.html");
+ }
+ else if (strcmp(dest, "help") == 0)
+ {
+ StringCbCopyW (page, sizeof (page),L"Documentation.html");
+ }
+ else if (strcmp(dest, "onlinehelp") == 0)
+ {
+ StringCbCopyW (url, sizeof (url),L"https://www.veracrypt.fr/en/Documentation.html");
+ buildUrl = FALSE;
+ }
+ else if (strcmp(dest, "keyfiles") == 0)
+ {
+ StringCbCopyW (page, sizeof (page),L"Keyfiles.html");
+ }
+ else if (strcmp(dest, "introcontainer") == 0)
+ {
+ StringCbCopyW (page, sizeof (page),L"Creating%20New%20Volumes.html");
+ }
+ else if (strcmp(dest, "introsysenc") == 0)
+ {
+ StringCbCopyW (page, sizeof (page),L"System%20Encryption.html");
+ }
+ else if (strcmp(dest, "hiddensysenc") == 0)
+ {
+ StringCbCopyW (page, sizeof (page),L"VeraCrypt%20Hidden%20Operating%20System.html");
+ }
+ else if (strcmp(dest, "sysencprogressinfo") == 0)
+ {
+ StringCbCopyW (page, sizeof (page),L"System%20Encryption.html");
+ }
+ else if (strcmp(dest, "hiddenvolume") == 0)
+ {
+ StringCbCopyW (page, sizeof (page),L"Hidden%20Volume.html");
+ }
+ else if (strcmp(dest, "aes") == 0)
+ {
+ StringCbCopyW (page, sizeof (page),L"AES.html");
+ }
+ else if (strcmp(dest, "serpent") == 0)
+ {
+ StringCbCopyW (page, sizeof (page),L"Serpent.html");
+ }
+ else if (strcmp(dest, "twofish") == 0)
+ {
+ StringCbCopyW (page, sizeof (page),L"Twofish.html");
+ }
+ else if (strcmp(dest, "kuznyechik") == 0)
+ {
+ StringCbCopyW (page, sizeof (page),L"Kuznyechik.html");
+ }
+ else if (strcmp(dest, "camellia") == 0)
+ {
+ StringCbCopyW (page, sizeof (page),L"Camellia.html");
+ }
+ else if (strcmp(dest, "cascades") == 0)
+ {
+ StringCbCopyW (page, sizeof (page),L"Cascades.html");
+ }
+ else if (strcmp(dest, "hashalgorithms") == 0)
+ {
+ StringCbCopyW (page, sizeof (page),L"Hash%20Algorithms.html");
+ }
+ else if (strcmp(dest, "isoburning") == 0)
+ {
+ StringCbCopyW (url, sizeof (url),L"https://cdburnerxp.se/en/home");
+ buildUrl = FALSE;
+ }
+ else if (strcmp(dest, "sysfavorites") == 0)
+ {
+ StringCbCopyW (page, sizeof (page),L"System%20Favorite%20Volumes.html");
+ }
+ else if (strcmp(dest, "favorites") == 0)
+ {
+ StringCbCopyW (page, sizeof (page),L"Favorite%20Volumes.html");
+ }
+ else if (strcmp(dest, "hiddenvolprotection") == 0)
+ {
+ StringCbCopyW (page, sizeof (page),L"Protection%20of%20Hidden%20Volumes.html");
+ }
+ else if (strcmp(dest, "faq") == 0)
+ {
+ StringCbCopyW (page, sizeof (page),L"FAQ.html");
+ }
+ else if (strcmp(dest, "downloads") == 0)
+ {
+ StringCbCopyW (page, sizeof (page),L"Downloads.html");
+ }
+ else if (strcmp(dest, "news") == 0)
+ {
+ StringCbCopyW (page, sizeof (page),L"News.html");
+ }
+ else if (strcmp(dest, "contact") == 0)
+ {
+ StringCbCopyW (page, sizeof (page),L"Contact.html");
+ }
+ else if (strcmp(dest, "pim") == 0)
+ {
+ StringCbCopyW (page, sizeof (page),L"Personal%20Iterations%20Multiplier%20%28PIM%29.html");
+ }
+ else
+ {
+ StringCbCopyW (url, sizeof (url),TC_APPLINK);
+ buildUrl = FALSE;
+ }
+
+ if (buildUrl)
+ {
+ StringCbPrintfW (url, sizeof (url), L"file:///%sdocs/html/en/%s", installDir, page);
+ CorrectURL (url);
+ }
+
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"Applink_Dll: url(%s)", url);
+
+ if (IsAdmin ())
+ {
+ // TODO: FileExists always returns FALSE
+ // This is due to the fact that waccess does not like url encoded as 'file:///%sdocs/html/en/%s'.
+ // It fails with '0x0000007B: The filename, directory name, or volume label syntax is incorrect.'.
+ if (buildUrl && !FileExists (url))
+ {
+ // fallbacl to online resources
+ StringCbPrintfW (url, sizeof (url), L"https://www.veracrypt.fr/en/%s", page);
+ SafeOpenURL (url);
+ }
+ else
+ {
+ SafeOpenURL (url);
+ }
+ }
+ else
+ {
+ r = (int) ShellExecuteW (NULL, L"open", url, NULL, NULL, SW_SHOWNORMAL);
+
+ if (((r == ERROR_FILE_NOT_FOUND) || (r == ERROR_PATH_NOT_FOUND)) && buildUrl)
+ {
+ // fallbacl to online resources
+ StringCbPrintfW (url, sizeof (url), L"https://www.veracrypt.fr/en/%s", page);
+ ShellExecuteW (NULL, L"open", url, NULL, NULL, SW_SHOWNORMAL);
+ }
+ }
+}
+
+/*
+ * Same as in Dlgcode.c, CheckCapsLock(), but
+ * replaced MessageBoxW() with MSILogAndShow().
+ */
+BOOL CheckCapsLock_Dll (MSIHANDLE hInstaller, BOOL quiet)
+{
+ if ((GetKeyState(VK_CAPITAL) & 1) != 0)
+ {
+ MSILogAndShow(hInstaller, MSI_WARNING_LEVEL, GetString ("CAPSLOCK_ON"));
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/*
+ * Same as in Dlgcode.c, GetWrongPasswordErrorMessage(), but
+ * replaced CheckCapsLock() with CheckCapsLock_Dll().
+ */
+std::wstring GetWrongPasswordErrorMessage_Dll (MSIHANDLE hInstaller)
+{
+ WCHAR szTmp[8192];
+
+ StringCbPrintfW (szTmp, sizeof(szTmp), GetString (KeyFilesEnable ? "PASSWORD_OR_KEYFILE_WRONG" : "PASSWORD_WRONG"));
+ if (CheckCapsLock_Dll (hInstaller, TRUE))
+ StringCbCatW (szTmp, sizeof(szTmp), GetString ("PASSWORD_WRONG_CAPSLOCK_ON"));
+
+ wstring msg = szTmp;
+ return msg;
+}
+
+/*
+ * Same as in Dlgcode.c, HandleDriveNotReadyError(), but
+ * replaced Warning() with MSILogAndShow().
+ */
+void HandleDriveNotReadyError_Dll (MSIHANDLE hInstaller)
+{
+ HKEY hkey = 0;
+ DWORD value = 0, size = sizeof (DWORD);
+
+ if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\MountMgr",
+ 0, KEY_READ, &hkey) != ERROR_SUCCESS)
+ return;
+
+ if (RegQueryValueEx (hkey, L"NoAutoMount", 0, 0, (LPBYTE) &value, &size) == ERROR_SUCCESS
+ && value != 0)
+ {
+ MSILogAndShow (hInstaller, MSI_WARNING_LEVEL, GetString("SYS_AUTOMOUNT_DISABLED"));
+ }
+ else if (nCurrentOS == WIN_VISTA && CurrentOSServicePack < 1)
+ MSILogAndShow (hInstaller, MSI_WARNING_LEVEL, GetString("SYS_ASSIGN_DRIVE_LETTER"));
+ else
+ MSILogAndShow (hInstaller, MSI_WARNING_LEVEL, GetString("DEVICE_NOT_READY_ERROR"));
+
+ RegCloseKey (hkey);
+}
+
+/*
+ * Same as in Dlgcode.c, handleWin32Error(), but
+ * replaced ErrorDirect(), Error() and MessageBoxW with MSILogAndShow(),
+ * replaced HandleDriveNotReadyError() with HandleDriveNotReadyError_Dll().
+ */
+DWORD handleWin32Error_Dll (MSIHANDLE hInstaller, const char* srcPos)
+{
+ PWSTR lpMsgBuf;
+ DWORD dwError = GetLastError ();
+ wchar_t szErrorValue[32];
+ wchar_t* pszDesc;
+
+ if (dwError == 0 || dwError == ERROR_INVALID_WINDOW_HANDLE)
+ return dwError;
+
+ // Access denied
+ if (dwError == ERROR_ACCESS_DENIED && !IsAdmin ())
+ {
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, AppendSrcPos (GetString ("ERR_ACCESS_DENIED"), srcPos).c_str ());
+ SetLastError (dwError); // Preserve the original error code
+ return dwError;
+ }
+
+ FormatMessageW (
+ FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ dwError,
+ MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
+ (PWSTR) &lpMsgBuf,
+ 0,
+ NULL
+ );
+
+ if (lpMsgBuf)
+ pszDesc = (wchar_t*) lpMsgBuf;
+ else
+ {
+ StringCchPrintfW (szErrorValue, ARRAYSIZE (szErrorValue), L"Error 0x%.8X", dwError);
+ pszDesc = szErrorValue;
+ }
+
+ MSILogAndShow (hInstaller, MSI_INFO_LEVEL, AppendSrcPos (pszDesc, srcPos).c_str ());
+ if (lpMsgBuf) LocalFree (lpMsgBuf);
+
+ // User-friendly hardware error explanation
+ if (IsDiskError (dwError))
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, GetString("ERR_HARDWARE_ERROR"));
+
+ // Device not ready
+ if (dwError == ERROR_NOT_READY)
+ HandleDriveNotReadyError_Dll(hInstaller);
+
+ SetLastError (dwError); // Preserve the original error code
+
+ return dwError;
+}
+
+/*
+ * Same as in Dlgcode.c, handleError(), but
+ * replaced ErrorDirect(), Error() and MessageBoxW with MSILogAndShow(),
+ * replaced handleWin32Error() with handleWin32Error_Dll().
+ */
+void handleError_Dll (MSIHANDLE hInstaller, int code, const char* srcPos)
+{
+ WCHAR szTmp[4096];
+
+ switch (code & 0x0000FFFF)
+ {
+ case ERR_OS_ERROR:
+ handleWin32Error_Dll (hInstaller, srcPos);
+ break;
+ case ERR_OUTOFMEMORY:
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, AppendSrcPos (GetString ("OUTOFMEMORY"), srcPos).c_str());
+ break;
+
+ case ERR_PASSWORD_WRONG:
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, AppendSrcPos (GetWrongPasswordErrorMessage_Dll (hInstaller).c_str(), srcPos).c_str());
+ break;
+
+ case ERR_DRIVE_NOT_FOUND:
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, AppendSrcPos (GetString ("NOT_FOUND"), srcPos).c_str());
+ break;
+ case ERR_FILES_OPEN:
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, AppendSrcPos (GetString ("OPENFILES_DRIVER"), srcPos).c_str());
+ break;
+ case ERR_FILES_OPEN_LOCK:
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, AppendSrcPos (GetString ("OPENFILES_LOCK"), srcPos).c_str());
+ break;
+ case ERR_VOL_SIZE_WRONG:
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, AppendSrcPos (GetString ("VOL_SIZE_WRONG"), srcPos).c_str());
+ break;
+ case ERR_COMPRESSION_NOT_SUPPORTED:
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, AppendSrcPos (GetString ("COMPRESSION_NOT_SUPPORTED"), srcPos).c_str());
+ break;
+ case ERR_PASSWORD_CHANGE_VOL_TYPE:
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, AppendSrcPos (GetString ("WRONG_VOL_TYPE"), srcPos).c_str());
+ break;
+ case ERR_VOL_SEEKING:
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, AppendSrcPos (GetString ("VOL_SEEKING"), srcPos).c_str());
+ break;
+ case ERR_CIPHER_INIT_FAILURE:
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, AppendSrcPos (GetString ("ERR_CIPHER_INIT_FAILURE"), srcPos).c_str());
+ break;
+ case ERR_CIPHER_INIT_WEAK_KEY:
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, AppendSrcPos (GetString ("ERR_CIPHER_INIT_WEAK_KEY"), srcPos).c_str());
+ break;
+ case ERR_VOL_ALREADY_MOUNTED:
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, AppendSrcPos (GetString ("VOL_ALREADY_MOUNTED"), srcPos).c_str());
+ break;
+ case ERR_FILE_OPEN_FAILED:
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, AppendSrcPos (GetString ("FILE_OPEN_FAILED"), srcPos).c_str());
+ break;
+ case ERR_VOL_MOUNT_FAILED:
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, AppendSrcPos (GetString ("VOL_MOUNT_FAILED"), srcPos).c_str());
+ break;
+ case ERR_NO_FREE_DRIVES:
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, AppendSrcPos (GetString ("NO_FREE_DRIVES"), srcPos).c_str());
+ break;
+ case ERR_ACCESS_DENIED:
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, AppendSrcPos (GetString ("ACCESS_DENIED"), srcPos).c_str());
+ break;
+
+ case ERR_DRIVER_VERSION:
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, GetString("DRIVER_VERSION"));
+ break;
+
+ case ERR_NEW_VERSION_REQUIRED:
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, AppendSrcPos (GetString ("NEW_VERSION_REQUIRED"), srcPos).c_str());
+ break;
+
+ case ERR_SELF_TESTS_FAILED:
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, GetString("ERR_SELF_TESTS_FAILED"));
+ break;
+
+ case ERR_VOL_FORMAT_BAD:
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, GetString ("ERR_VOL_FORMAT_BAD"));
+ break;
+
+ case ERR_ENCRYPTION_NOT_COMPLETED:
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, GetString ("ERR_ENCRYPTION_NOT_COMPLETED"));
+ break;
+
+ case ERR_NONSYS_INPLACE_ENC_INCOMPLETE:
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, GetString ("ERR_NONSYS_INPLACE_ENC_INCOMPLETE"));
+ break;
+
+ case ERR_SYS_HIDVOL_HEAD_REENC_MODE_WRONG:
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, GetString ("ERR_SYS_HIDVOL_HEAD_REENC_MODE_WRONG"));
+ break;
+
+ case ERR_PARAMETER_INCORRECT:
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, GetString ("ERR_PARAMETER_INCORRECT"));
+ break;
+
+ case ERR_USER_ABORT:
+ case ERR_DONT_REPORT:
+ // A non-error
+ break;
+
+ case ERR_UNSUPPORTED_TRUECRYPT_FORMAT:
+ StringCbPrintfW (szTmp, sizeof(szTmp), GetString ("UNSUPPORTED_TRUECRYPT_FORMAT"), (code >> 24), (code >> 16) & 0x000000FF);
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, AppendSrcPos (szTmp, srcPos).c_str());
+ break;
+
+ default:
+ StringCbPrintfW (szTmp, sizeof(szTmp), GetString ("ERR_UNKNOWN"), code);
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, AppendSrcPos (szTmp, srcPos).c_str());
+ }
+}
+
+/*
+ * Same as in Dlgcode.c, LoadSystemDll() , but
+ * replaced AbortProcess() with MSILogAndShow() + return,
+ */
+static void LoadSystemDll_Dll (MSIHANDLE hInstaller, LPCTSTR szModuleName, HMODULE *pHandle, BOOL bIgnoreError, const char* srcPos)
+{
+ wchar_t dllPath[MAX_PATH];
+
+ /* Load dll explictely from System32 to avoid Dll hijacking attacks*/
+ if (!GetSystemDirectory(dllPath, MAX_PATH))
+ StringCbCopyW(dllPath, sizeof(dllPath), L"C:\\Windows\\System32");
+
+ StringCbCatW(dllPath, sizeof(dllPath), L"\\");
+ StringCbCatW(dllPath, sizeof(dllPath), szModuleName);
+
+ if (((*pHandle = LoadLibrary(dllPath)) == NULL) && !bIgnoreError)
+ {
+ // This error is fatal
+ handleWin32Error_Dll (hInstaller, srcPos);
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, GetString ("INIT_DLL"));
+ }
+}
+
+/*
+ * Same as in Dlgcode.c, handleWin32Error(), but
+ * replaced AbortProcess() with MSILogAndShow() + return,
+ */
+BOOL IsPagingFileActive_Dll (MSIHANDLE hInstaller, BOOL checkNonWindowsPartitionsOnly)
+{
+ // GlobalMemoryStatusEx() cannot be used to determine if a paging file is active
+
+ wchar_t data[65536];
+ DWORD size = sizeof (data);
+
+ if (IsPagingFileWildcardActive())
+ return TRUE;
+
+ if (ReadLocalMachineRegistryMultiString (L"System\\CurrentControlSet\\Control\\Session Manager\\Memory Management", L"PagingFiles", data, &size)
+ && size > 24 && !checkNonWindowsPartitionsOnly)
+ return TRUE;
+
+ if (!IsAdmin())
+ {
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, GetString("UAC_INIT_ERROR"));
+ return FALSE;
+ }
+
+ for (wchar_t drive = L'C'; drive <= L'Z'; ++drive)
+ {
+ // Query geometry of the drive first to prevent "no medium" pop-ups
+ wstring drivePath = L"\\\\.\\X:";
+ drivePath[4] = drive;
+
+ if (checkNonWindowsPartitionsOnly)
+ {
+ wchar_t sysDir[MAX_PATH];
+ if (GetSystemDirectory (sysDir, ARRAYSIZE (sysDir)) != 0 && towupper (sysDir[0]) == drive)
+ continue;
+ }
+
+ HANDLE handle = CreateFile (drivePath.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
+
+ if (handle == INVALID_HANDLE_VALUE)
+ continue;
+
+ BYTE dgBuffer[256];
+ DWORD dwResult;
+
+ if (!DeviceIoControl (handle, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, dgBuffer, sizeof (dgBuffer), &dwResult, NULL)
+ && !DeviceIoControl (handle, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, dgBuffer, sizeof (dgBuffer), &dwResult, NULL))
+ {
+ CloseHandle (handle);
+ continue;
+ }
+
+ CloseHandle (handle);
+
+ // Test if a paging file exists and is locked by another process
+ wstring path = L"X:\\pagefile.sys";
+ path[0] = drive;
+
+ handle = CreateFile (path.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
+
+ if (handle != INVALID_HANDLE_VALUE)
+ CloseHandle (handle);
+ else if (GetLastError() == ERROR_SHARING_VIOLATION)
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/*
+ * Same as in Dlgcode.c, DoDriverInstall(), but
+ * replaced StatusMessage() with MSILog().
+ */
+BOOL DoDriverInstall_Dll (MSIHANDLE hInstaller)
+{
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"Begin DoDriverInstall_Dll");
+
+ SC_HANDLE hManager, hService = NULL;
+ BOOL bOK = FALSE, bRet;
+
+#ifdef SETUP
+ if (SystemEncryptionUpdate)
+ {
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"SystemEncryptionUpdate == TRUE");
+ bOK = TRUE;
+ goto end;
+ }
+#endif
+
+ hManager = OpenSCManager (NULL, NULL, SC_MANAGER_ALL_ACCESS);
+ if (hManager == NULL)
+ goto error;
+
+#ifdef SETUP
+ MSILog (hInstaller, MSI_INFO_LEVEL, GetString("INSTALLING_DRIVER"));
+#endif
+
+ hService = CreateService (hManager, L"veracrypt", L"veracrypt",
+ SERVICE_ALL_ACCESS, SERVICE_KERNEL_DRIVER, SERVICE_SYSTEM_START, SERVICE_ERROR_NORMAL,
+ L"System32\\drivers\\veracrypt.sys",
+ NULL, NULL, NULL, NULL, NULL);
+
+ if (hService == NULL)
+ goto error;
+ else
+ CloseServiceHandle (hService);
+
+ hService = OpenService (hManager, L"veracrypt", SERVICE_ALL_ACCESS);
+ if (hService == NULL)
+ goto error;
+
+#ifdef SETUP
+ MSILog (hInstaller, MSI_INFO_LEVEL, GetString("STARTING_DRIVER"));
+#endif
+
+ bRet = StartService (hService, 0, NULL);
+ if (bRet == FALSE)
+ goto error;
+
+ bOK = TRUE;
+
+error:
+ if (bOK == FALSE && GetLastError () != ERROR_SERVICE_ALREADY_RUNNING)
+ {
+ handleWin32Error_Dll (hInstaller, SRC_POS);
+ MSILogAndShow(hInstaller, MSI_ERROR_LEVEL, GetString("DRIVER_INSTALL_FAILED"));
+ }
+ else
+ bOK = TRUE;
+
+ if (hService != NULL)
+ CloseServiceHandle (hService);
+
+ if (hManager != NULL)
+ CloseServiceHandle (hManager);
+
+end:
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"End DoDriverInstall_Dll");
+ return bOK;
+}
+
+/* **************************************************************************** */
+
+/*
+ * Same as in Setup.c, StartStopService(), but
+ * replaced StatusMessage() with MSILog().
+ */
+BOOL StartStopService_Dll (MSIHANDLE hInstaller, wchar_t *lpszService, BOOL bStart, DWORD argc, LPCWSTR* argv)
+{
+ SC_HANDLE hManager, hService = NULL;
+ BOOL bOK = FALSE, bRet;
+ SERVICE_STATUS status = {0};
+ int x;
+ DWORD dwExpectedState = bStart? SERVICE_RUNNING : SERVICE_STOPPED;
+
+ hManager = OpenSCManager (NULL, NULL, SC_MANAGER_ALL_ACCESS);
+ if (hManager == NULL)
+ goto error;
+
+ hService = OpenService (hManager, lpszService, SERVICE_ALL_ACCESS);
+ if (hService == NULL)
+ goto error;
+
+ if (bStart)
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"STARTING %s", lpszService);
+ else
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"STOPPING %s", lpszService);
+
+ if (bStart)
+ {
+ if (!StartService (hService, argc, argv) && (GetLastError () != ERROR_SERVICE_ALREADY_RUNNING))
+ goto error;
+ }
+ else
+ ControlService (hService, SERVICE_CONTROL_STOP, &status);
+
+ for (x = 0; x < WAIT_PERIOD; x++)
+ {
+ bRet = QueryServiceStatus (hService, &status);
+ if (bRet != TRUE)
+ goto error;
+
+ if (status.dwCurrentState == dwExpectedState)
+ break;
+
+ Sleep (1000);
+ }
+
+ bRet = QueryServiceStatus (hService, &status);
+ if (bRet != TRUE)
+ goto error;
+
+ if (status.dwCurrentState != dwExpectedState)
+ goto error;
+
+ bOK = TRUE;
+
+error:
+
+ if (bOK == FALSE && GetLastError () == ERROR_SERVICE_DOES_NOT_EXIST)
+ {
+ bOK = TRUE;
+ }
+
+ if (hService != NULL)
+ CloseServiceHandle (hService);
+
+ if (hManager != NULL)
+ CloseServiceHandle (hManager);
+
+ return bOK;
+}
+
+/*
+ * Same as in Setup.c, SetSystemRestorePoint(), but
+ * replaced StatusMessage() with MSILog().
+ */
+static void SetSystemRestorePoint_Dll (MSIHANDLE hInstaller, BOOL finalize)
+{
+ static RESTOREPOINTINFO RestPtInfo;
+ static STATEMGRSTATUS SMgrStatus;
+ static BOOL failed = FALSE;
+ static BOOL (__stdcall *_SRSetRestorePoint)(PRESTOREPOINTINFO, PSTATEMGRSTATUS);
+
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"Begin SetSystemRestorePoint_Dll");
+
+ if (!SystemRestoreDll)
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"SystemRestoreDll NULL");
+ goto end;
+ }
+
+ _SRSetRestorePoint = (BOOL (__stdcall *)(PRESTOREPOINTINFO, PSTATEMGRSTATUS))GetProcAddress (SystemRestoreDll,"SRSetRestorePointW");
+ if (_SRSetRestorePoint == 0)
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"_SRSetRestorePoint NULL");
+ FreeLibrary (SystemRestoreDll);
+ SystemRestoreDll = 0;
+ goto end;
+ }
+
+ if (!finalize)
+ {
+ MSILog (hInstaller, MSI_INFO_LEVEL, GetString("CREATING_SYS_RESTORE"));
+
+ RestPtInfo.dwEventType = BEGIN_SYSTEM_CHANGE;
+ RestPtInfo.dwRestorePtType = bUninstall ? APPLICATION_UNINSTALL : APPLICATION_INSTALL | DEVICE_DRIVER_INSTALL;
+ RestPtInfo.llSequenceNumber = 0;
+ StringCbCopyW (RestPtInfo.szDescription, sizeof(RestPtInfo.szDescription), bUninstall ? L"VeraCrypt uninstallation" : L"VeraCrypt installation");
+
+ if(!_SRSetRestorePoint (&RestPtInfo, &SMgrStatus))
+ {
+ MSILog (hInstaller, MSI_ERROR_LEVEL, GetString("FAILED_SYS_RESTORE"));
+ failed = TRUE;
+ }
+ }
+ else if (!failed)
+ {
+ RestPtInfo.dwEventType = END_SYSTEM_CHANGE;
+ RestPtInfo.llSequenceNumber = SMgrStatus.llSequenceNumber;
+
+ if(!_SRSetRestorePoint(&RestPtInfo, &SMgrStatus))
+ {
+ MSILog (hInstaller, MSI_ERROR_LEVEL, GetString("FAILED_SYS_RESTORE"));
+ }
+ }
+
+end:
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"End SetSystemRestorePoint_Dll");
+}
+
+/*
+ * Same as in Setup.c, DoDriverUnload(), but
+ * replaced AbortProcess() and AbortProcessSilent() with MSILogAndShow() + return,
+ * replaced Error(), MessageBoxW() with MSILogAndShow(),
+ * replaced StatusMessage() with MSILog(),
+ * replaced handleWin32Error() with handleWin32Error_Dll().
+ */
+BOOL DoDriverUnload_Dll (MSIHANDLE hInstaller, HWND hwnd)
+{
+ BOOL bOK = TRUE;
+ int status = 0;
+
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"Begin DoDriverUnload_Dll");
+
+ status = DriverAttach ();
+ if (status != 0)
+ {
+ if (status == ERR_OS_ERROR && GetLastError () != ERROR_FILE_NOT_FOUND)
+ {
+ handleWin32Error_Dll (hInstaller, SRC_POS);
+ MSILogAndShow(hInstaller, MSI_ERROR_LEVEL, GetString("NODRIVER"));
+ bOK = FALSE;
+ goto end;
+ }
+
+ if (status != ERR_OS_ERROR)
+ {
+ handleError_Dll (hInstaller, status, SRC_POS);
+ MSILogAndShow(hInstaller, MSI_ERROR_LEVEL, GetString("NODRIVER"));
+ bOK = FALSE;
+ goto end;
+ }
+ }
+
+ if (hDriver != INVALID_HANDLE_VALUE)
+ {
+ MOUNT_LIST_STRUCT driver;
+ LONG driverVersion = VERSION_NUM;
+ int refCount;
+ DWORD dwResult;
+ BOOL bResult;
+
+ // Try to determine if it's upgrade (and not reinstall, downgrade, or first-time install).
+ DetermineUpgradeDowngradeStatus (FALSE, &driverVersion);
+
+ // Test for encrypted boot drive
+ try
+ {
+ BootEncryption bootEnc (hwnd);
+ if (bootEnc.GetDriverServiceStartType() == SERVICE_BOOT_START)
+ {
+ try
+ {
+ // Check hidden OS update consistency
+ if (IsHiddenOSRunning())
+ {
+ if (bootEnc.GetInstalledBootLoaderVersion() != VERSION_NUM)
+ {
+ if (AskWarnNoYes ("UPDATE_TC_IN_DECOY_OS_FIRST", hwnd) == IDNO)
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"User denied request");
+ bOK = FALSE;
+ goto end;
+ }
+ }
+ }
+ }
+ catch (...) { }
+
+ if (bUninstallInProgress && !bootEnc.GetStatus().DriveMounted)
+ {
+ try { bootEnc.RegisterFilterDriver (false, BootEncryption::DriveFilter); } catch (...) { }
+ try { bootEnc.RegisterFilterDriver (false, BootEncryption::VolumeFilter); } catch (...) { }
+ try { bootEnc.RegisterFilterDriver (false, BootEncryption::DumpFilter); } catch (...) { }
+ bootEnc.SetDriverServiceStartType (SERVICE_SYSTEM_START);
+ }
+ else if (bUninstallInProgress || bDowngrade)
+ {
+ MSILogAndShow(hInstaller, MSI_ERROR_LEVEL, (bDowngrade ? GetString("SETUP_FAILED_BOOT_DRIVE_ENCRYPTED_DOWNGRADE") : GetString("SETUP_FAILED_BOOT_DRIVE_ENCRYPTED")));
+ bOK = FALSE;
+ goto end;
+ }
+ else
+ {
+ if (CurrentOSMajor == 6 && CurrentOSMinor == 0 && CurrentOSServicePack < 1)
+ {
+ MSILogAndShow(hInstaller, MSI_ERROR_LEVEL, GetString("SYS_ENCRYPTION_UPGRADE_UNSUPPORTED_ON_VISTA_SP0"));
+ bOK = FALSE;
+ goto end;
+ }
+
+ SystemEncryptionUpdate = TRUE;
+ PortableMode = FALSE;
+ }
+ }
+ }
+ catch (...) { }
+
+ if (!bUninstall
+ && (bUpgrade || SystemEncryptionUpdate)
+ && (!bDevm || SystemEncryptionUpdate))
+ {
+ UnloadDriver = FALSE;
+ }
+
+ if (PortableMode && !SystemEncryptionUpdate)
+ UnloadDriver = TRUE;
+
+ if (UnloadDriver)
+ {
+ int volumesMounted = 0;
+
+ // Check mounted volumes
+ bResult = DeviceIoControl (hDriver, TC_IOCTL_IS_ANY_VOLUME_MOUNTED, NULL, 0, &volumesMounted, sizeof (volumesMounted), &dwResult, NULL);
+
+ if (!bResult)
+ {
+ bResult = DeviceIoControl (hDriver, TC_IOCTL_LEGACY_GET_MOUNTED_VOLUMES, NULL, 0, &driver, sizeof (driver), &dwResult, NULL);
+ if (bResult)
+ volumesMounted = driver.ulMountedDrives;
+ }
+
+ if (bResult)
+ {
+ if (volumesMounted != 0)
+ {
+ bOK = FALSE;
+ MSILogAndShow(hInstaller, MSI_WARNING_LEVEL, GetString ("DISMOUNT_ALL_FIRST"));
+ }
+ }
+ else
+ {
+ bOK = FALSE;
+ handleWin32Error_Dll (hInstaller, SRC_POS);
+ }
+ }
+
+ // Try to close all open TC windows
+ if (bOK)
+ {
+ BOOL TCWindowClosed = FALSE;
+
+ EnumWindows (CloseTCWindowsEnum, (LPARAM) &TCWindowClosed);
+
+ if (TCWindowClosed)
+ Sleep (2000);
+ }
+
+ // Test for any applications attached to driver
+ if (!bUpgrade)
+ {
+ bResult = DeviceIoControl (hDriver, TC_IOCTL_GET_DEVICE_REFCOUNT, &refCount, sizeof (refCount), &refCount,
+ sizeof (refCount), &dwResult, NULL);
+
+ if (bOK && bResult && refCount > 1)
+ {
+ MSILogAndShow(hInstaller, MSI_WARNING_LEVEL, GetString ("CLOSE_TC_FIRST"));
+ bOK = FALSE;
+ }
+ }
+
+ if (!bOK || UnloadDriver)
+ {
+ CloseHandle (hDriver);
+ hDriver = INVALID_HANDLE_VALUE;
+ }
+ }
+ else
+ {
+ // Note that the driver may have already been unloaded during this session (e.g. retry after an error, etc.) so it is not
+ // guaranteed that the user is installing VeraCrypt for the first time now (we also cannot know if the user has already
+ // installed and used VeraCrypt on another system before).
+ bPossiblyFirstTimeInstall = TRUE;
+ }
+
+end:
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"End DoDriverUnload_Dll");
+ return bOK;
+}
+
+/*
+ * Same as in Setup.c, DoServiceUninstall(), but
+ * replaced AbortProcess() and AbortProcessSilent() with MSILogAndShow() + return,
+ * replaced Error(), MessageBoxW() with MSILogAndShow(),
+ * replaced StatusMessage() with MSILog(),
+ * replaced handleWin32Error() with handleWin32Error_Dll().
+ */
+BOOL DoServiceUninstall_Dll (MSIHANDLE hInstaller, HWND hwndDlg, wchar_t *lpszService)
+{
+ SC_HANDLE hManager, hService = NULL;
+ BOOL bOK = FALSE, bRet;
+ SERVICE_STATUS status;
+ BOOL firstTry = TRUE;
+ int x;
+
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"Begin DoServiceUninstall_Dll");
+
+ memset (&status, 0, sizeof (status)); /* Keep VC6 quiet */
+
+retry:
+
+ hManager = OpenSCManager (NULL, NULL, SC_MANAGER_ALL_ACCESS);
+ if (hManager == NULL)
+ goto error;
+
+ hService = OpenService (hManager, lpszService, SERVICE_ALL_ACCESS);
+ if (hService == NULL)
+ goto error;
+
+ if (wcscmp (L"veracrypt", lpszService) == 0)
+ {
+ try
+ {
+ BootEncryption bootEnc (hwndDlg);
+ if (bootEnc.GetDriverServiceStartType() == SERVICE_BOOT_START)
+ {
+ try { bootEnc.RegisterFilterDriver (false, BootEncryption::DriveFilter); } catch (...) { }
+ try { bootEnc.RegisterFilterDriver (false, BootEncryption::VolumeFilter); } catch (...) { }
+ try { bootEnc.RegisterFilterDriver (false, BootEncryption::DumpFilter); } catch (...) { }
+ }
+ }
+ catch (...) { }
+
+ MSILog (hInstaller, MSI_INFO_LEVEL, GetString("STOPPING_DRIVER"));
+ }
+ else
+ MSILog (hInstaller, MSI_INFO_LEVEL, L"STOPPING %s", lpszService);
+
+ for (x = 0; x < WAIT_PERIOD; x++)
+ {
+ bRet = QueryServiceStatus (hService, &status);
+ if (bRet != TRUE)
+ goto error;
+
+ if (status.dwCurrentState != SERVICE_START_PENDING &&
+ status.dwCurrentState != SERVICE_STOP_PENDING &&
+ status.dwCurrentState != SERVICE_CONTINUE_PENDING)
+ break;
+
+ Sleep (1000);
+ }
+
+ if (status.dwCurrentState != SERVICE_STOPPED)
+ {
+ bRet = ControlService (hService, SERVICE_CONTROL_STOP, &status);
+ if (bRet == FALSE)
+ goto try_delete;
+
+ for (x = 0; x < WAIT_PERIOD; x++)
+ {
+ bRet = QueryServiceStatus (hService, &status);
+ if (bRet != TRUE)
+ goto error;
+
+ if (status.dwCurrentState != SERVICE_START_PENDING &&
+ status.dwCurrentState != SERVICE_STOP_PENDING &&
+ status.dwCurrentState != SERVICE_CONTINUE_PENDING)
+ break;
+
+ Sleep (1000);
+ }
+
+ if (status.dwCurrentState != SERVICE_STOPPED && status.dwCurrentState != SERVICE_STOP_PENDING)
+ goto error;
+ }
+
+try_delete:
+
+ if (wcscmp (L"veracrypt", lpszService) == 0)
+ MSILog (hInstaller, MSI_INFO_LEVEL, GetString("REMOVING_DRIVER"));
+ else
+ MSILog (hInstaller, MSI_INFO_LEVEL, L"REMOVING %s", lpszService);
+
+ if (hService != NULL)
+ {
+ CloseServiceHandle (hService);
+ hService = NULL;
+ }
+
+ if (hManager != NULL)
+ {
+ CloseServiceHandle (hManager);
+ hManager = NULL;
+ }
+
+ hManager = OpenSCManager (NULL, NULL, SC_MANAGER_ALL_ACCESS);
+ if (hManager == NULL)
+ goto error;
+
+ hService = OpenService (hManager, lpszService, SERVICE_ALL_ACCESS);
+ if (hService == NULL)
+ goto error;
+
+ bRet = DeleteService (hService);
+ if (bRet == FALSE)
+ {
+ if (firstTry && GetLastError () == ERROR_SERVICE_MARKED_FOR_DELETE)
+ {
+ // Second try for an eventual no-install driver instance
+ CloseServiceHandle (hService);
+ CloseServiceHandle (hManager);
+ hService = NULL;
+ hManager = NULL;
+
+ Sleep(1000);
+ firstTry = FALSE;
+ goto retry;
+ }
+
+ goto error;
+ }
+
+ bOK = TRUE;
+
+error:
+
+ if (bOK == FALSE && GetLastError ()!= ERROR_SERVICE_DOES_NOT_EXIST)
+ {
+ handleWin32Error_Dll (hInstaller, SRC_POS);
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, GetString("DRIVER_UINSTALL_FAILED"));
+ }
+ else
+ bOK = TRUE;
+
+ if (hService != NULL)
+ CloseServiceHandle (hService);
+
+ if (hManager != NULL)
+ CloseServiceHandle (hManager);
+
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"End DoServiceUninstall_Dll");
+ return bOK;
+}
+
+/*
+ * Same as in Setup.c, DoRegUninstall(), but
+ * replaced StatusMessage() with MSILog(),
+ * removed unnecessary code that is done by MSI.
+ */
+BOOL DoRegUninstall_Dll (MSIHANDLE hInstaller, BOOL bRemoveDeprecated)
+{
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"Begin DoRegUninstall_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)
+ {
+ RegDeleteKeyExWPtr = (RegDeleteKeyExWFn) GetProcAddress(hAdvapiDll, "RegDeleteKeyExW");
+ }
+
+ // Unregister COM servers
+ if (!bRemoveDeprecated && IsOSAtLeast (WIN_VISTA))
+ {
+ if (!UnregisterComServers (InstallationPath))
+ MSILog (hInstaller, MSI_ERROR_LEVEL, GetString("COM_DEREG_FAILED"));
+ }
+
+ if (!bRemoveDeprecated)
+ MSILog (hInstaller, MSI_INFO_LEVEL, GetString("REMOVING_REG"));
+
+ /* The following is done by MSI, so we skip it */
+ /*
+ if (RegDeleteKeyExWPtr)
+ {
+ 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, L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\VeraCrypt");
+ RegDeleteKey (HKEY_LOCAL_MACHINE, L"Software\\VeraCrypt");
+ }
+ 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, L"VeraCrypt");
+
+ // The following is done by MSI, so we skip it
+ // DeleteRegistryKey (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, L"Local Settings\\Software\\Microsoft\\Windows\\Shell\\MuiCache", L"VeraCrypt", FALSE, NULL);
+
+ // clean other VeraCrypt entries from all users
+ 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, L"SYSTEM", 0, KEY_ALL_ACCESS | WRITE_DAC | WRITE_OWNER, &hKey) == ERROR_SUCCESS)
+ {
+ SearchAndDeleteRegistrySubString (hKey, L"Enum\\Root\\LEGACY_VERACRYPT", NULL, TRUE, L"ControlSet");
+ SearchAndDeleteRegistrySubString (hKey, L"services\\veracrypt", NULL, TRUE, L"ControlSet");
+ RegCloseKey(hKey);
+ }
+
+ // disable the SE_TAKE_OWNERSHIP_NAME privilege for this operation
+ SetPrivilege (SE_TAKE_OWNERSHIP_NAME, FALSE);
+
+ // The following is done by MSI, so we skip it
+ //SHChangeNotify (SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
+ }
+
+ if (hAdvapiDll)
+ FreeLibrary (hAdvapiDll);
+
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"End DoRegUninstall_Dll");
+ return TRUE;
+}
+
+/*
+ * Same as in Setup.c, UpgradeBootLoader(), but
+ * replaced StatusMessage() with MSILog().
+ */
+BOOL UpgradeBootLoader_Dll (MSIHANDLE hInstaller, HWND hwndDlg)
+{
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"Begin UpgradeBootLoader_Dll");
+
+ BOOL bOK = FALSE;
+
+ if (!SystemEncryptionUpdate)
+ {
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"SystemEncryptionUpdate == FALSE");
+ bOK = TRUE;
+ goto end;
+ }
+
+ try
+ {
+ BootEncryption bootEnc (hwndDlg);
+ uint64 bootLoaderVersion = bootEnc.GetInstalledBootLoaderVersion();
+ if ((bootLoaderVersion < VERSION_NUM) || (bReinstallMode && (bootLoaderVersion == VERSION_NUM)))
+ {
+ MSILog (hInstaller, MSI_INFO_LEVEL, GetString("INSTALLER_UPDATING_BOOT_LOADER"));
+
+ bootEnc.InstallBootLoader (true);
+
+ if (bootEnc.GetInstalledBootLoaderVersion() <= TC_RESCUE_DISK_UPGRADE_NOTICE_MAX_VERSION)
+ {
+ bUpdateRescueDisk = TRUE;
+ MSILog (hInstaller, MSI_INFO_LEVEL, GetString(IsHiddenOSRunning() ? "BOOT_LOADER_UPGRADE_OK_HIDDEN_OS" : "BOOT_LOADER_UPGRADE_OK"));
+ }
+ }
+ bOK = TRUE;
+ goto end;
+ }
+ catch (Exception &e)
+ {
+ e.Show (hwndDlg);
+ }
+ catch (...) { }
+
+ MSILog (hInstaller, MSI_ERROR_LEVEL, GetString("BOOT_LOADER_UPGRADE_FAILED"));
+
+end:
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"End UpgradeBootLoader_Dll");
+ return bOK;
+}
+
+/*
+ * Same as Setup.c, function DoApplicationDataUninstall(), but
+ * replaced StatusMessage() and RemoveMessage() with MSILog().
+ */
+BOOL DoApplicationDataUninstall_Dll (MSIHANDLE hInstaller)
+{
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"Begin DoApplicationDataUninstall");
+
+ wchar_t path[MAX_PATH];
+ wchar_t path2[MAX_PATH];
+ BOOL bOK = TRUE;
+
+ MSILog(hInstaller, MSI_INFO_LEVEL, GetString("REMOVING_APPDATA"));
+
+ SHGetFolderPath (NULL, CSIDL_APPDATA, NULL, 0, path);
+ StringCbCatW (path, sizeof(path), L"\\VeraCrypt\\");
+
+ // Delete favorite volumes file
+ StringCbPrintfW (path2, sizeof(path2), L"%s%s", path, TC_APPD_FILENAME_FAVORITE_VOLUMES);
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"REMOVING %s", path2);
+ StatDeleteFile (path2, FALSE);
+
+ // Delete keyfile defaults
+ StringCbPrintfW (path2, sizeof(path2), L"%s%s", path, TC_APPD_FILENAME_DEFAULT_KEYFILES);
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"REMOVING %s", path2);
+ StatDeleteFile (path2, FALSE);
+
+ // Delete history file
+ StringCbPrintfW (path2, sizeof(path2), L"%s%s", path, TC_APPD_FILENAME_HISTORY);
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"REMOVING %s", path2);
+ StatDeleteFile (path2, FALSE);
+
+ // Delete configuration file
+ StringCbPrintfW (path2, sizeof(path2), L"%s%s", path, TC_APPD_FILENAME_CONFIGURATION);
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"REMOVING %s", path2);
+ StatDeleteFile (path2, FALSE);
+
+ // Delete system encryption configuration file
+ StringCbPrintfW (path2, sizeof(path2), L"%s%s", path, TC_APPD_FILENAME_SYSTEM_ENCRYPTION);
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"REMOVING %s", path2);
+ StatDeleteFile (path2, FALSE);
+
+ SHGetFolderPath (NULL, CSIDL_APPDATA, NULL, 0, path);
+ StringCbCatW (path, sizeof(path), L"\\VeraCrypt");
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"REMOVING %s", path);
+ if (!StatRemoveDirectory (path))
+ {
+ handleWin32Error_Dll (hInstaller, SRC_POS);
+ bOK = FALSE;
+ }
+
+ // remove VeraCrypt under common appdata
+ if (SUCCEEDED (SHGetFolderPath (NULL, CSIDL_COMMON_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, path)))
+ {
+ StringCbCatW (path, sizeof(path), L"\\VeraCrypt");
+
+ // Delete original bootloader
+ StringCbPrintfW (path2, sizeof(path2), L"%s\\%s", path, TC_SYS_BOOT_LOADER_BACKUP_NAME);
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"REMOVING %s", path2);
+ StatDeleteFile (path2, FALSE);
+
+ // remove VeraCrypt folder
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"REMOVING %s", path);
+ StatRemoveDirectory (path);
+ }
+
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"End DoApplicationDataUninstall");
+ return bOK;
+}
+
+/*
+ * Same as Setup.c, function DoUninstall(), but
+ * removed uninstall of files and registry as it will be
+ * done by MSI.
+ */
+BOOL DoUninstall_Dll (MSIHANDLE hInstaller, HWND hwndDlg)
+{
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"Begin DoUninstall_Dll");
+
+ BOOL bOK = TRUE;
+ BOOL bTempSkipSysRestore = FALSE;
+
+ if (DoDriverUnload_Dll (hInstaller, hwndDlg) == FALSE)
+ {
+ bOK = FALSE;
+ bTempSkipSysRestore = TRUE; // Volumes are possibly mounted; defer System Restore point creation for this uninstall attempt.
+ }
+ else
+ {
+ if (!Rollback && bSystemRestore && !bTempSkipSysRestore)
+ SetSystemRestorePoint_Dll (hInstaller, FALSE);
+
+ if (DoServiceUninstall_Dll (hInstaller, hwndDlg, L"veracrypt") == FALSE)
+ {
+ bOK = FALSE;
+ }
+ else if (DoRegUninstall_Dll (hInstaller, FALSE) == FALSE)
+ {
+ bOK = FALSE;
+ }
+ /* Following skipped because done by MSI */
+ /*
+ else if (DoFilesInstall ((HWND) hwndDlg, InstallationPath) == FALSE)
+ {
+ bOK = FALSE;
+ }
+ else if (DoShortcutsUninstall (hwndDlg, InstallationPath) == FALSE)
+ {
+ bOK = FALSE;
+ }
+ */
+ else if (!DoApplicationDataUninstall_Dll (hInstaller))
+ {
+ bOK = FALSE;
+ }
+ else
+ {
+ // Deprecated service
+ DoServiceUninstall_Dll (hInstaller, hwndDlg, L"VeraCryptService");
+ }
+ }
+
+ if (Rollback)
+ goto end;
+
+ if (bSystemRestore && !bTempSkipSysRestore)
+ SetSystemRestorePoint_Dll (hInstaller, TRUE);
+
+ if (!bOK)
+ bUninstallInProgress = FALSE;
+
+end:
+
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"End DoUninstall_Dll");
+ return bOK;
+}
+
+/*
+ * Same as Setup.c, function InitApp(), but
+ * replaced unnecessary calls,
+ * forced english as language,
+ * replaced LoadLanguageFile() with LoadLanguageFromResource() to be able to set bForceSilent.
+ */
+BOOL InitDll (MSIHANDLE hInstaller)
+{
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"Begin InitDll");
+
+ BOOL bOK = TRUE;
+ InitCommonControlsPtr InitCommonControlsFn = NULL;
+
+ /* remove current directory from dll search path */
+ SetDllDirectoryFn = (SetDllDirectoryPtr) GetProcAddress (GetModuleHandle(L"kernel32.dll"), "SetDllDirectoryW");
+ SetSearchPathModeFn = (SetSearchPathModePtr) GetProcAddress (GetModuleHandle(L"kernel32.dll"), "SetSearchPathMode");
+ SetDefaultDllDirectoriesFn = (SetDefaultDllDirectoriesPtr) GetProcAddress (GetModuleHandle(L"kernel32.dll"), "SetDefaultDllDirectories");
+ if (SetDllDirectoryFn)
+ SetDllDirectoryFn (L"");
+ if (SetSearchPathModeFn)
+ SetSearchPathModeFn (BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE | BASE_SEARCH_PATH_PERMANENT);
+ if (SetDefaultDllDirectoriesFn)
+ SetDefaultDllDirectoriesFn (LOAD_LIBRARY_SEARCH_SYSTEM32);
+
+ InitOSVersionInfo();
+ InitGlobalLocks ();
+
+ LoadSystemDll_Dll (hInstaller, L"msvcrt.dll", &hmsvcrtdll, TRUE, SRC_POS);
+ LoadSystemDll_Dll (hInstaller, L"ntmarta.dll", &hntmartadll, TRUE, SRC_POS);
+ LoadSystemDll_Dll (hInstaller, L"MPR.DLL", &hmprdll, TRUE, SRC_POS);
+ if (IsOSAtLeast (WIN_7))
+ {
+ LoadSystemDll_Dll (hInstaller, L"ProfApi.DLL", &hProfApiDll, TRUE, SRC_POS);
+ LoadSystemDll_Dll (hInstaller, L"cryptbase.dll", &hcryptbasedll, TRUE, SRC_POS);
+ LoadSystemDll_Dll (hInstaller, L"sspicli.dll", &hsspiclidll, TRUE, SRC_POS);
+ }
+ LoadSystemDll_Dll (hInstaller, L"psapi.dll", &hpsapidll, TRUE, SRC_POS);
+ LoadSystemDll_Dll (hInstaller, L"secur32.dll", &hsecur32dll, TRUE, SRC_POS);
+ LoadSystemDll_Dll (hInstaller, L"msasn1.dll", &hmsasn1dll, TRUE, SRC_POS);
+ LoadSystemDll_Dll (hInstaller, L"Usp10.DLL", &hUsp10Dll, TRUE, SRC_POS);
+ if (IsOSAtLeast (WIN_7))
+ LoadSystemDll_Dll (hInstaller, L"dwmapi.dll", &hdwmapidll, TRUE, SRC_POS);
+ LoadSystemDll_Dll (hInstaller, L"UXTheme.dll", &hUXThemeDll, TRUE, SRC_POS);
+
+ LoadSystemDll_Dll (hInstaller, L"msls31.dll", &hMsls31, TRUE, SRC_POS);
+ LoadSystemDll_Dll (hInstaller, L"SETUPAPI.DLL", &hSetupDll, FALSE, SRC_POS);
+ LoadSystemDll_Dll (hInstaller, L"SHLWAPI.DLL", &hShlwapiDll, FALSE, SRC_POS);
+
+ LoadSystemDll_Dll (hInstaller, L"userenv.dll", &hUserenvDll, TRUE, SRC_POS);
+ LoadSystemDll_Dll (hInstaller, L"rsaenh.dll", &hRsaenhDll, TRUE, SRC_POS);
+
+ if (nCurrentOS < WIN_7)
+ {
+ if (nCurrentOS == WIN_XP)
+ {
+ LoadSystemDll_Dll (hInstaller, L"imm32.dll", &himm32dll, TRUE, SRC_POS);
+ LoadSystemDll_Dll (hInstaller, L"MSCTF.dll", &hMSCTFdll, TRUE, SRC_POS);
+ LoadSystemDll_Dll (hInstaller, L"fltlib.dll", &hfltlibdll, TRUE, SRC_POS);
+ LoadSystemDll_Dll (hInstaller, L"wbem\\framedyn.dll", &hframedyndll, TRUE, SRC_POS);
+ }
+
+ if (IsOSAtLeast (WIN_VISTA))
+ {
+ LoadSystemDll_Dll (hInstaller, L"netapi32.dll", &hnetapi32dll, TRUE, SRC_POS);
+ LoadSystemDll_Dll (hInstaller, L"authz.dll", &hauthzdll, TRUE, SRC_POS);
+ LoadSystemDll_Dll (hInstaller, L"xmllite.dll", &hxmllitedll, TRUE, SRC_POS);
+ }
+ }
+
+ if (IsOSAtLeast (WIN_VISTA))
+ {
+ LoadSystemDll_Dll (hInstaller, L"atl.dll", &hsppdll, TRUE, SRC_POS);
+ LoadSystemDll_Dll (hInstaller, L"vsstrace.dll", &hvsstracedll, TRUE, SRC_POS);
+ LoadSystemDll_Dll (hInstaller, L"vssapi.dll", &vssapidll, TRUE, SRC_POS);
+ LoadSystemDll_Dll (hInstaller, L"spp.dll", &hsppdll, TRUE, SRC_POS);
+ }
+
+ LoadSystemDll_Dll (hInstaller, L"crypt32.dll", &hcrypt32dll, TRUE, SRC_POS);
+
+ if (IsOSAtLeast (WIN_7))
+ {
+ LoadSystemDll_Dll (hInstaller, L"CryptSP.dll", &hCryptSpDll, TRUE, SRC_POS);
+
+ LoadSystemDll_Dll (hInstaller, L"cfgmgr32.dll", &hcfgmgr32dll, TRUE, SRC_POS);
+ LoadSystemDll_Dll (hInstaller, L"devobj.dll", &hdevobjdll, TRUE, SRC_POS);
+ LoadSystemDll_Dll (hInstaller, L"powrprof.dll", &hpowrprofdll, TRUE, SRC_POS);
+
+ LoadSystemDll_Dll (hInstaller, L"bcrypt.dll", &hbcryptdll, TRUE, SRC_POS);
+ LoadSystemDll_Dll (hInstaller, L"bcryptprimitives.dll", &hbcryptprimitivesdll, TRUE, SRC_POS);
+ }
+
+ LoadSystemDll_Dll (hInstaller, L"COMCTL32.DLL", &hComctl32Dll, FALSE, SRC_POS);
+
+ // call InitCommonControls function
+ InitCommonControlsFn = (InitCommonControlsPtr) GetProcAddress (hComctl32Dll, "InitCommonControls");
+ ImageList_AddFn = (ImageList_AddPtr) GetProcAddress (hComctl32Dll, "ImageList_Add");
+ ImageList_CreateFn = (ImageList_CreatePtr) GetProcAddress (hComctl32Dll, "ImageList_Create");
+
+ if (InitCommonControlsFn && ImageList_AddFn && ImageList_CreateFn)
+ {
+ InitCommonControlsFn();
+ }
+ else
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, GetString("INIT_DLL"));
+ bOK = FALSE;
+ goto end;
+ }
+
+ LoadSystemDll_Dll (hInstaller, L"Riched20.dll", &hRichEditDll, FALSE, SRC_POS);
+ LoadSystemDll_Dll (hInstaller, L"Advapi32.dll", &hAdvapi32Dll, FALSE, SRC_POS);
+
+ // Get SetupAPI functions pointers
+ SetupCloseInfFileFn = (SetupCloseInfFilePtr) GetProcAddress (hSetupDll, "SetupCloseInfFile");
+ SetupDiOpenClassRegKeyFn = (SetupDiOpenClassRegKeyPtr) GetProcAddress (hSetupDll, "SetupDiOpenClassRegKey");
+ SetupInstallFromInfSectionWFn = (SetupInstallFromInfSectionWPtr) GetProcAddress (hSetupDll, "SetupInstallFromInfSectionW");
+ SetupOpenInfFileWFn = (SetupOpenInfFileWPtr) GetProcAddress (hSetupDll, "SetupOpenInfFileW");
+
+ if (!SetupCloseInfFileFn || !SetupDiOpenClassRegKeyFn || !SetupInstallFromInfSectionWFn || !SetupOpenInfFileWFn)
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, GetString("INIT_DLL"));
+ bOK = FALSE;
+ goto end;
+ }
+
+ // Get SHDeleteKeyW function pointer
+ SHDeleteKeyWFn = (SHDeleteKeyWPtr) GetProcAddress (hShlwapiDll, "SHDeleteKeyW");
+ SHStrDupWFn = (SHStrDupWPtr) GetProcAddress (hShlwapiDll, "SHStrDupW");
+ if (!SHDeleteKeyWFn || !SHStrDupWFn)
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, GetString("INIT_DLL"));
+ bOK = FALSE;
+ goto end;
+ }
+
+ if (IsOSAtLeast (WIN_VISTA))
+ {
+ /* Get ChangeWindowMessageFilter used to enable some messages bypasss UIPI (User Interface Privilege Isolation) */
+ ChangeWindowMessageFilterFn = (ChangeWindowMessageFilterPtr) GetProcAddress (GetModuleHandle (L"user32.dll"), "ChangeWindowMessageFilter");
+ }
+
+ // Get CreateProcessWithTokenW function pointer
+ CreateProcessWithTokenWPtr = (CreateProcessWithTokenWFn) GetProcAddress(hAdvapi32Dll, "CreateProcessWithTokenW");
+
+ SetErrorMode (SetErrorMode (0) | SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
+ CoInitialize (NULL);
+
+ // Force language to english to read strings from the default Language.xml embedded in the DLL.
+ SetPreferredLangId ("en");
+ bUserSetLanguage = TRUE;
+ LoadLanguageFromResource (0, FALSE, TRUE);
+
+ SetUnhandledExceptionFilter (ExceptionHandler);
+ _set_invalid_parameter_handler (InvalidParameterHandler);
+ RemoteSession = GetSystemMetrics (SM_REMOTESESSION) != 0;
+
+end:
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"End InitDll");
+ return bOK;
+}
+
+/* **************************************************************************** */
+
+/*
+ * Same as Setup.c, function wWinMain(), but
+ * replaced unnecessary calls.
+ * This should be called at the beginning of each operation (install, uninstall...),
+ * before atexit(VC_CustomAction_Cleanup()) call.
+ */
+BOOL VC_CustomAction_Init(MSIHANDLE hInstaller, const wchar_t* szInstallDir)
+{
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"Begin VC_CustomAction_Init");
+
+ BOOL bOK = TRUE;
+
+ if (!InitDll(hInstaller))
+ {
+ bOK = FALSE;
+ goto end;
+ }
+
+ // System Restore
+ if (IsSystemRestoreEnabled ())
+ {
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"System Restore is enabled");
+
+ wchar_t dllPath[MAX_PATH];
+ if (GetSystemDirectory (dllPath, MAX_PATH))
+ {
+ StringCbCatW(dllPath, sizeof(dllPath), L"\\srclient.dll");
+ }
+ else
+ StringCbCopyW(dllPath, sizeof(dllPath), L"C:\\Windows\\System32\\srclient.dll");
+ SystemRestoreDll = LoadLibrary (dllPath);
+ }
+ else
+ {
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"System Restore is not enabled");
+ SystemRestoreDll = 0;
+ }
+
+ // Set InstallationPath
+ wcsncpy(InstallationPath, szInstallDir, min(wcslen(szInstallDir), ARRAYSIZE(InstallationPath)));
+
+end:
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"End VC_CustomAction_Init");
+ return bOK;
+}
+
+/*
+ * Same as Setup.c, function localcleanup(), but
+ * replaced unnecessary calls.
+ * This should be called at the beginning of each operation (install, uninstall...),
+ * as an argument to atexit() before VC_CustomAction_Init() call.
+ */
+void VC_CustomAction_Cleanup ()
+{
+ //MSILog(hInstaller, MSI_INFO_LEVEL, L"Begin VC_CustomAction_Cleanup");
+
+ /* Cleanup the GDI fonts */
+ if (hFixedFont != NULL)
+ DeleteObject (hFixedFont);
+ if (hFixedDigitFont != NULL)
+ DeleteObject (hFixedDigitFont);
+ if (hBoldFont != NULL)
+ DeleteObject (hBoldFont);
+ if (hTitleFont != NULL)
+ DeleteObject (hTitleFont);
+ if (hUserFont != NULL)
+ DeleteObject (hUserFont);
+ if (hUserUnderlineFont != NULL)
+ DeleteObject (hUserUnderlineFont);
+ if (hUserBoldFont != NULL)
+ DeleteObject (hUserBoldFont);
+
+ /* Close the device driver handle */
+ if (hDriver != INVALID_HANDLE_VALUE)
+ {
+ // Unload driver mode if possible (non-install mode)
+ if (IsNonInstallMode ())
+ {
+ // If a dismount was forced in the lifetime of the driver, Windows may later prevent it to be loaded again from
+ // the same path. Therefore, the driver will not be unloaded even though it was loaded in non-install mode.
+ int driverUnloadDisabled;
+ DWORD dwResult;
+
+ if (!DeviceIoControl (hDriver, TC_IOCTL_IS_DRIVER_UNLOAD_DISABLED, NULL, 0, &driverUnloadDisabled, sizeof (driverUnloadDisabled), &dwResult, NULL))
+ driverUnloadDisabled = 0;
+
+ if (!driverUnloadDisabled)
+ DriverUnload ();
+ else
+ {
+ CloseHandle (hDriver);
+ hDriver = INVALID_HANDLE_VALUE;
+ }
+ }
+ else
+ {
+ CloseHandle (hDriver);
+ hDriver = INVALID_HANDLE_VALUE;
+ }
+ }
+
+ CoUninitialize ();
+
+ CloseSysEncMutex ();
+
+ FinalizeGlobalLocks ();
+
+ FREE_DLL (hRichEditDll);
+ FREE_DLL (hComctl32Dll);
+ FREE_DLL (hSetupDll);
+ FREE_DLL (hShlwapiDll);
+ FREE_DLL (hProfApiDll);
+ FREE_DLL (hUsp10Dll);
+ FREE_DLL (hCryptSpDll);
+ FREE_DLL (hUXThemeDll);
+ FREE_DLL (hUserenvDll);
+ FREE_DLL (hRsaenhDll);
+ FREE_DLL (himm32dll);
+ FREE_DLL (hMSCTFdll);
+ FREE_DLL (hfltlibdll);
+ FREE_DLL (hframedyndll);
+ FREE_DLL (hpsapidll);
+ FREE_DLL (hsecur32dll);
+ FREE_DLL (hnetapi32dll);
+ FREE_DLL (hauthzdll);
+ FREE_DLL (hxmllitedll);
+ FREE_DLL (hmprdll);
+ FREE_DLL (hsppdll);
+ FREE_DLL (vssapidll);
+ FREE_DLL (hvsstracedll);
+ FREE_DLL (hCryptSpDll);
+ FREE_DLL (hcfgmgr32dll);
+ FREE_DLL (hdevobjdll);
+ FREE_DLL (hpowrprofdll);
+ FREE_DLL (hsspiclidll);
+ FREE_DLL (hcryptbasedll);
+ FREE_DLL (hdwmapidll);
+ FREE_DLL (hmsasn1dll);
+ FREE_DLL (hcrypt32dll);
+ FREE_DLL (hbcryptdll);
+ FREE_DLL (hbcryptprimitivesdll);
+ FREE_DLL (hMsls31);
+ FREE_DLL (hntmartadll);
+ FREE_DLL (hwinscarddll);
+ FREE_DLL (hmsvcrtdll);
+ FREE_DLL (hAdvapi32Dll);
+
+ //MSILog(hInstaller, MSI_INFO_LEVEL, L"End VC_CustomAction_Cleanup");
+}
+
+void Tokenize(const wchar_t* szInput, std::vector& szTokens)
+{
+ std::wstringstream check(szInput);
+ std::wstring intermediate;
+ while(std::getline(check, intermediate, L'?'))
+ {
+ szTokens.push_back(intermediate);
+ }
+}
+
+/*
+ * Same as Setup.c, function DoInstall(), but
+ * without the actual installation, it only prepares the system
+ * before the installation (before DoFilesInstall).
+ * It runs as a Deferred CA.
+ */
+EXTERN_C UINT STDAPICALLTYPE VC_CustomAction_PreInstall(MSIHANDLE hInstaller)
+{
+ HWND hwndDlg = NULL;
+ std::wstring szValueBuf = L"";
+ DWORD cchValueBuf = 0;
+ UINT uiStat = 0;
+ HKEY hkey = 0;
+ DWORD dw = 0;
+ BootEncryption bootEnc(NULL);
+ std::wstring szInstallDir = L"";
+ UINT uiRet = ERROR_INSTALL_FAILURE;
+ BOOL bOK = TRUE;
+
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"Begin VC_CustomAction_PreInstall");
+
+ // Get UILevel to see whether we're being installed silently or not.
+ // Also get INSTALLDIR to see where we're being installed.
+ // Since this is a Deferred CA, they are to be setup in its CustomActionData.
+ uiStat = MsiGetProperty(hInstaller, TEXT("CustomActionData"), (LPWSTR)TEXT(""), &cchValueBuf);
+ if (ERROR_MORE_DATA == uiStat)
+ {
+ ++cchValueBuf; // add 1 for null termination
+ szValueBuf.resize(cchValueBuf);
+ uiStat = MsiGetProperty(hInstaller, TEXT("CustomActionData"), &szValueBuf[0], &cchValueBuf);
+ if ((ERROR_SUCCESS == uiStat))
+ {
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"VC_CustomAction_PreInstall: CustomActionData = '%s'", szValueBuf.c_str());
+
+ std::vector szTokens;
+ Tokenize(szValueBuf.c_str(), szTokens);
+
+ for (size_t i = 0; i < szTokens.size(); i++)
+ {
+ std::wstring szToken = szTokens[i];
+
+ if (wcsncmp(szToken.c_str(), L"UILEVEL=", wcslen(L"UILEVEL=")) == 0)
+ {
+ size_t index0 = szToken.find_first_of(L"=");
+ if (index0 != std::wstring::npos)
+ {
+ std::wstring uiLevel = szToken.substr(index0 + 1);
+ Silent = (stoi(uiLevel) <= 3);
+
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"VC_CustomAction_PreInstall: UILEVEL = '%s', bSilent = '%d'", uiLevel.c_str(), Silent);
+ }
+ }
+ else if (wcsncmp(szToken.c_str(), L"INSTALLDIR=", wcslen(L"INSTALLDIR=")) == 0)
+ {
+ size_t index0 = szToken.find_first_of(L"=");
+ if (index0 != std::wstring::npos)
+ {
+ szInstallDir = szToken.substr(index0 + 1);
+
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"VC_CustomAction_PreInstall: INSTALLDIR = '%s'", szInstallDir.c_str());
+ }
+ }
+ else if (wcsncmp(szToken.c_str(), L"REINSTALL=", wcslen(L"REINSTALL=")) == 0)
+ {
+ size_t index0 = szToken.find_first_of(L"=");
+ if (index0 != std::wstring::npos)
+ {
+ std::wstring szReinstall = szToken.substr(index0 + 1);
+ bRepairMode = (wcslen(szReinstall.c_str()) != 0);
+
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"VC_CustomAction_PreInstall: REINSTALL = '%s', bRepairMode = '%s'", szReinstall.c_str(), bRepairMode ? L"TRUE" : L"FALSE");
+ }
+ }
+ }
+ }
+ }
+
+ // Get this MSI Installer HWND.
+ // There cannot be 2 MSIs or more running at the same time, so we're sure we'll get ours.
+ // This is only possible in case of non silent install.
+ hwndDlg = FindWindow(L"MsiDialogCloseClass", NULL);
+ if (!hwndDlg && !Silent)
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PreInstall: MsiDialogCloseClass not found");
+ goto end;
+ }
+
+ /* Start actual work */
+
+ if (!VC_CustomAction_Init(hInstaller, szInstallDir.c_str()))
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PreInstall: VC_CustomAction_Init() failed");
+ goto end;
+ }
+ atexit(VC_CustomAction_Cleanup);
+
+ bootEnc.SetParentWindow(hwndDlg);
+
+ if (DoDriverUnload_Dll (hInstaller, hwndDlg) == FALSE)
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PreInstall: DoDriverUnload_Dll() failed");
+ goto end;
+ }
+
+ if (bSystemRestore)
+ {
+ SetSystemRestorePoint_Dll (hInstaller, FALSE);
+ }
+
+ if (bDisableSwapFiles && IsPagingFileActive_Dll (hInstaller, FALSE))
+ {
+ if (!DisablePagingFile())
+ {
+ handleWin32Error_Dll (hInstaller, SRC_POS);
+ MSILogAndShow(hInstaller, MSI_ERROR_LEVEL, GetString("FAILED_TO_DISABLE_PAGING_FILES"));
+ }
+ else
+ {
+ bRestartRequired = TRUE;
+ }
+ }
+
+ // Remove deprecated
+ DoServiceUninstall_Dll (hInstaller, hwndDlg, L"VeraCryptService");
+
+ if (!SystemEncryptionUpdate)
+ DoRegUninstall_Dll (hInstaller, TRUE);
+
+ if (UnloadDriver && DoServiceUninstall_Dll(hInstaller, hwndDlg, L"veracrypt") == FALSE)
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PreInstall: DoServiceUninstall_Dll(veracrypt) failed");
+ bOK = FALSE;
+ }
+
+ // uiRet = MsiSetProperty(hInstaller, TEXT("ISREBOOTREQUIRED"), TEXT("1"));
+ // Cannot do this because this is a Deferred CA (we need Deferred so that it runs with admin privileges).
+ // MsiGetProperty and MsiSetProperty properties cannot be used for deferred InstallScript custom actions,
+ // which do not have access to the active .msi database and do not recognize any Windows Installer properties.
+ // They can access only the information that has been written into the execution script (CustomActionData).
+ // Therefore, we set the values in RegKeys that are volatile.
+ if (bOK)
+ {
+ if (RegCreateKeyEx (HKEY_LOCAL_MACHINE, L"Software\\.VeraCrypt\\Values", 0, NULL, REG_OPTION_VOLATILE, KEY_WRITE, NULL, &hkey, &dw) == ERROR_SUCCESS)
+ {
+ RegSetValueEx (hkey, L"Silent", 0, REG_DWORD, (const BYTE*)(&Silent), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bUninstall", 0, REG_DWORD, (const BYTE*)(&bUninstall), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bDowngrade", 0, REG_DWORD, (const BYTE*)(&bDowngrade), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bUninstallInProgress", 0, REG_DWORD, (const BYTE*)(&bUninstallInProgress), sizeof(BOOL));
+ RegSetValueEx (hkey, L"PortableMode", 0, REG_DWORD, (const BYTE*)(&PortableMode), sizeof(BOOL));
+ RegSetValueEx (hkey, L"UnloadDriver", 0, REG_DWORD, (const BYTE*)(&UnloadDriver), sizeof(BOOL));
+
+ RegSetValueEx (hkey, L"Rollback", 0, REG_DWORD, (const BYTE*)(&Rollback), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bReinstallMode", 0, REG_DWORD, (const BYTE*)(&bReinstallMode), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bUpgrade", 0, REG_DWORD, (const BYTE*)(&bUpgrade), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bPossiblyFirstTimeInstall", 0, REG_DWORD, (const BYTE*)(&bPossiblyFirstTimeInstall), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bDevm", 0, REG_DWORD, (const BYTE*)(&bDevm), sizeof(BOOL));
+ RegSetValueEx (hkey, L"SystemEncryptionUpdate", 0, REG_DWORD, (const BYTE*)(&SystemEncryptionUpdate), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bRestartRequired", 0, REG_DWORD, (const BYTE*)(&bRestartRequired), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bDisableSwapFiles", 0, REG_DWORD, (const BYTE*)(&bDisableSwapFiles), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bSystemRestore", 0, REG_DWORD, (const BYTE*)(&bSystemRestore), sizeof(BOOL));
+
+ RegSetValueEx (hkey, L"bPromptFastStartup", 0, REG_DWORD, (const BYTE*)(&bPromptFastStartup), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bPromptReleaseNotes", 0, REG_DWORD, (const BYTE*)(&bPromptReleaseNotes), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bPromptTutorial", 0, REG_DWORD, (const BYTE*)(&bPromptTutorial), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bUpdateRescueDisk", 0, REG_DWORD, (const BYTE*)(&bUpdateRescueDisk), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bRepairMode", 0, REG_DWORD, (const BYTE*)(&bRepairMode), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bUserSetLanguage", 0, REG_DWORD, (const BYTE*)(&bUserSetLanguage), sizeof(BOOL));
+
+ RegCloseKey (hkey);
+
+ uiRet = ERROR_SUCCESS;
+ }
+ else
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"End VC_CustomAction_PreInstall: Could not write to registry");
+ }
+ }
+
+end:
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"End VC_CustomAction_PreInstall");
+ return uiRet;
+}
+
+/*
+ * Same as Setup.c, function DoInstall(), but
+ * without the actual installation, it only performs
+ * post install operations (after DoRegInstall and last parts
+ * of DoFilesInstall / DoRegInstall).
+ * It also does the Fast Startup check, shows Release Notes and
+ * Beginner's Tutorial if needed and sets regkey accordingly.
+ * It runs as a Deferred CA.
+ */
+EXTERN_C UINT STDAPICALLTYPE VC_CustomAction_PostInstall(MSIHANDLE hInstaller)
+{
+ HWND hwndDlg = NULL;
+ std::wstring szValueBuf = L"";
+ DWORD cchValueBuf = 0;
+ UINT uiStat = 0;
+ HKEY hkey = 0;
+ DWORD dw = 0;
+ BootEncryption bootEnc(NULL);
+ std::wstring szInstallDir = L"";
+ UINT uiRet = ERROR_INSTALL_FAILURE;
+ BOOL bOK = TRUE;
+ WCHAR szCurrentDir[MAX_PATH];
+
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"Begin VC_CustomAction_PostInstall");
+
+ // Get INSTALLDIR to see where we're being installed.
+ uiStat = MsiGetProperty(hInstaller, TEXT("CustomActionData"), (LPWSTR)TEXT(""), &cchValueBuf);
+ if (ERROR_MORE_DATA == uiStat)
+ {
+ ++cchValueBuf; // add 1 for null termination
+ szValueBuf.resize(cchValueBuf);
+ uiStat = MsiGetProperty(hInstaller, TEXT("CustomActionData"), &szValueBuf[0], &cchValueBuf);
+ if ((ERROR_SUCCESS == uiStat))
+ {
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"VC_CustomAction_PostInstall: CustomActionData = '%s'", szValueBuf.c_str());
+ if (wcsncmp(szValueBuf.c_str(), L"INSTALLDIR=", wcslen(L"INSTALLDIR=")) == 0)
+ {
+ size_t index0 = szValueBuf.find_first_of(L"=");
+ if (index0 != std::wstring::npos)
+ {
+ szInstallDir = szValueBuf.substr(index0 + 1);
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"VC_CustomAction_PostInstall: INSTALLDIR = '%s'", szInstallDir.c_str());
+ }
+ }
+ }
+ }
+
+ // Read RegKeys previously setup by PreInstall
+ if (RegOpenKeyExW (HKEY_LOCAL_MACHINE, L"Software\\.VeraCrypt\\Values", 0, KEY_READ, &hkey) == ERROR_SUCCESS)
+ {
+ DWORD cbValue = sizeof(DWORD);
+ DWORD dwValue = 0;
+
+ RegQueryValueEx (hkey, L"Silent", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ Silent = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bUninstall", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bUninstall = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bDowngrade", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bDowngrade = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bUninstallInProgress", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bUninstallInProgress = (dwValue == 1);
+ RegQueryValueEx (hkey, L"PortableMode", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ PortableMode = (dwValue == 1);
+ RegQueryValueEx (hkey, L"UnloadDriver", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ UnloadDriver = (dwValue == 1);
+
+ RegQueryValueEx (hkey, L"Rollback", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ Rollback = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bReinstallMode", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bReinstallMode = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bUpgrade", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bUpgrade = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bPossiblyFirstTimeInstall", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bPossiblyFirstTimeInstall = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bDevm", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bDevm = (dwValue == 1);
+ RegQueryValueEx (hkey, L"SystemEncryptionUpdate", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ SystemEncryptionUpdate = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bRestartRequired", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bRestartRequired = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bDisableSwapFiles", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bDisableSwapFiles = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bSystemRestore", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bSystemRestore = (dwValue == 1);
+
+ RegQueryValueEx (hkey, L"bPromptFastStartup", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bPromptFastStartup = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bPromptReleaseNotes", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bPromptReleaseNotes = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bPromptTutorial", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bPromptTutorial = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bUpdateRescueDisk", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bUpdateRescueDisk = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bRepairMode", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bRepairMode = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bUserSetLanguage", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bUserSetLanguage = (dwValue == 1);
+
+ RegCloseKey (hkey);
+ }
+ else
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"End VC_CustomAction_PostInstall: Could not read from registry");
+ goto end;
+ }
+
+ // Get this MSI Installer HWND.
+ // There cannot be 2 MSIs or more running at the same time, so we're sure we'll get ours.
+ // This is only possible in case of non silent install.
+ hwndDlg = FindWindow(L"MsiDialogCloseClass", NULL);
+ if (!hwndDlg && !Silent)
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PostInstall: MsiDialogCloseClass not found");
+ goto end;
+ }
+
+ /* Start actual work */
+
+ if (!VC_CustomAction_Init(hInstaller, szInstallDir.c_str()))
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PostInstall: VC_CustomAction_Init() failed");
+ goto end;
+ }
+ atexit(VC_CustomAction_Cleanup);
+ bootEnc.SetParentWindow(hwndDlg);
+
+ // Last part of DoFilesInstall()
+ {
+ BOOL bResult = FALSE;
+ WIN32_FIND_DATA f;
+ HANDLE h;
+ wchar_t szTmp[TC_MAX_PATH];
+
+ StringCbPrintfW (szTmp, sizeof(szTmp), L"%s%s", szInstallDir.c_str(), L"VeraCrypt.exe");
+
+ if (Is64BitOs ())
+ EnableWow64FsRedirection (FALSE);
+
+ 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 (Is64BitOs ()
+ && FileExists (favoritesLegacyFile.c_str())
+ && !FileExists (favoritesFile.c_str()))
+ {
+ // copy the favorites XML file to the native system directory
+ bResult = CopyFile (favoritesLegacyFile.c_str(), favoritesFile.c_str(), FALSE);
+ }
+ else
+ {
+ bResult = TRUE;
+ }
+
+ if (bResult)
+ {
+ // Update the path of the service
+ BootEncryption BootEncObj (hwndDlg);
+
+ try
+ {
+ if (BootEncObj.GetDriverServiceStartType() == SERVICE_BOOT_START)
+ {
+ uint32 driverFlags = ReadDriverConfigurationFlags ();
+ uint32 serviceFlags = BootEncObj.ReadServiceConfigurationFlags ();
+
+ BootEncObj.UpdateSystemFavoritesService ();
+
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PostInstall: INSTALLING %s", servicePath.c_str());
+
+ // Tell the service not to update loader on stop
+ BootEncObj.SetServiceConfigurationFlag (VC_SYSTEM_FAVORITES_SERVICE_CONFIG_DONT_UPDATE_LOADER, true);
+
+ if (StartStopService_Dll (hInstaller, TC_SYSTEM_FAVORITES_SERVICE_NAME, FALSE, 0, NULL))
+ {
+ // we tell the service not to load system favorites on startup
+ LPCWSTR szArgs[2] = { TC_SYSTEM_FAVORITES_SERVICE_NAME, VC_SYSTEM_FAVORITES_SERVICE_ARG_SKIP_MOUNT};
+ if (!CopyFile (szTmp, servicePath.c_str(), FALSE))
+ ForceCopyFile (szTmp, servicePath.c_str());
+
+ StartStopService_Dll (hInstaller, TC_SYSTEM_FAVORITES_SERVICE_NAME, TRUE, 2, szArgs);
+ }
+ else
+ ForceCopyFile (szTmp, servicePath.c_str());
+
+ BootEncObj.SetDriverConfigurationFlag (driverFlags, true);
+
+ // remove the service flag if it was set originally
+ if (!(serviceFlags & VC_SYSTEM_FAVORITES_SERVICE_CONFIG_DONT_UPDATE_LOADER))
+ BootEncObj.SetServiceConfigurationFlag (VC_SYSTEM_FAVORITES_SERVICE_CONFIG_DONT_UPDATE_LOADER, false);
+ }
+ }
+ catch (...) {}
+ }
+
+ if (Is64BitOs ())
+ {
+ // delete files from legacy path
+ if (FileExists (favoritesLegacyFile.c_str()))
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PostInstall: REMOVING %s", favoritesLegacyFile.c_str());
+ ForceDeleteFile (favoritesLegacyFile.c_str());
+ }
+
+ if (FileExists (serviceLegacyPath.c_str()))
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PostInstall: REMOVING %s", serviceLegacyPath.c_str());
+ ForceDeleteFile (serviceLegacyPath.c_str());
+ }
+
+ EnableWow64FsRedirection (TRUE);
+ }
+
+ if (bResult == FALSE)
+ {
+ LPVOID lpMsgBuf;
+ DWORD dwError = GetLastError ();
+ wchar_t szTmp2[700];
+ wchar_t szErrorValue[16];
+ wchar_t* pszDesc;
+
+ FormatMessage (
+ FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ dwError,
+ MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
+ (wchar_t *) &lpMsgBuf,
+ 0,
+ NULL
+ );
+
+ if (lpMsgBuf)
+ pszDesc = (wchar_t*) lpMsgBuf;
+ else
+ {
+ StringCbPrintfW (szErrorValue, sizeof (szErrorValue), L"0x%.8X", dwError);
+ pszDesc = szErrorValue;
+ }
+
+ if (bUninstall == FALSE)
+ StringCbPrintfW (szTmp2, sizeof(szTmp2), GetString ("INSTALL_OF_FAILED"), szTmp, pszDesc);
+ else
+ StringCbPrintfW (szTmp2, sizeof(szTmp2), GetString ("UNINSTALL_OF_FAILED"), szTmp, pszDesc);
+
+ if (lpMsgBuf) LocalFree (lpMsgBuf);
+
+ if (!Silent && MessageBoxW (hwndDlg, szTmp2, lpszTitle, MB_YESNO | MB_ICONHAND) != IDYES)
+ goto end;
+ }
+
+ if (bUninstall == FALSE)
+ {
+ GetCurrentDirectory (MAX_PATH, szCurrentDir); // Save current dir since it will be changed
+ SetCurrentDirectory (szInstallDir.c_str());
+
+ // remove PDF from previous version if any
+ h = FindFirstFile (L"VeraCrypt User Guide*.pdf", &f);
+
+ if (h != INVALID_HANDLE_VALUE)
+ {
+ do
+ {
+ StatDeleteFile (f.cFileName, TRUE);
+ }
+ while (FindNextFile(h, &f) != 0);
+
+ FindClose (h);
+ }
+
+ // remove language XML files from previous version if any
+ h = FindFirstFile (L"Language*.xml", &f);
+
+ if (h != INVALID_HANDLE_VALUE)
+ {
+ do
+ {
+ StatDeleteFile (f.cFileName, TRUE);
+ }
+ while (FindNextFile(h, &f) != 0);
+
+ FindClose (h);
+ }
+
+ // remvove legacy files that are not needed anymore
+ for (int i = 0; i < sizeof (szLegacyFiles) / sizeof (szLegacyFiles[0]); i++)
+ {
+ StatDeleteFile (szLegacyFiles [i], TRUE);
+ }
+
+ SetCurrentDirectory(szCurrentDir);
+ }
+ }
+
+ // Last part of DoRegInstall()
+ {
+ // Register COM servers for UAC
+ if (IsOSAtLeast (WIN_VISTA))
+ {
+ if (!RegisterComServers ((wchar_t*)szInstallDir.c_str()))
+ {
+ MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, GetString("COM_REG_FAILED"));
+ goto end;
+ }
+ }
+ }
+
+ if (UnloadDriver && DoDriverInstall_Dll(hInstaller) == FALSE)
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PostInstall: DoDriverInstall_Dll() failed");
+ bOK = FALSE;
+ }
+ else if (SystemEncryptionUpdate && UpgradeBootLoader_Dll(hInstaller, hwndDlg) == FALSE)
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PostInstall: UpgradeBootLoader_Dll() failed");
+ bOK = FALSE;
+ }
+
+ // Shortcuts are installed by MSI, so we skip that.
+
+ if (!UnloadDriver)
+ bRestartRequired = TRUE;
+
+ try
+ {
+ bootEnc.RenameDeprecatedSystemLoaderBackup();
+ }
+ catch (...) { }
+
+ if (bSystemRestore)
+ SetSystemRestorePoint_Dll (hInstaller, TRUE);
+
+ if (bOK)
+ {
+ MSILog(hInstaller, MSI_INFO_LEVEL, GetString("INSTALL_COMPLETED"));
+ }
+ else
+ {
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"Post install failed");
+ if (!SystemEncryptionUpdate)
+ {
+ bUninstall = TRUE;
+ Rollback = TRUE;
+ Silent = TRUE;
+
+ DoUninstall_Dll (hInstaller, hwndDlg);
+
+ bUninstall = FALSE;
+ Rollback = FALSE;
+ Silent = FALSE;
+
+ MSILog(hInstaller, MSI_INFO_LEVEL, GetString("ROLLBACK"));
+ }
+ else
+ {
+ MSILog(hInstaller, MSI_WARNING_LEVEL, GetString("SYS_ENC_UPGRADE_FAILED"));
+ }
+ }
+
+ if (bOK && !bUninstall && !bDowngrade && !bRepairMode && !bDevm)
+ {
+ BOOL bHibernateEnabled = FALSE, bHiberbootEnabled = FALSE;
+ if (GetHibernateStatus (bHibernateEnabled, bHiberbootEnabled))
+ {
+ if (bHiberbootEnabled)
+ {
+ bPromptFastStartup = TRUE;
+ }
+ }
+
+ if (!IsHiddenOSRunning()) // A hidden OS user should not see the post-install notes twice (on decoy OS and then on hidden OS).
+ {
+ if (bRestartRequired || SystemEncryptionUpdate)
+ {
+ // Restart required
+
+ if (bUpgrade)
+ {
+ SavePostInstallTasksSettings (TC_POST_INSTALL_CFG_RELEASE_NOTES);
+ if (bUpdateRescueDisk)
+ {
+ SavePostInstallTasksSettings (TC_POST_INSTALL_CFG_RESCUE_DISK);
+ }
+ }
+ else if (bPossiblyFirstTimeInstall)
+ {
+ SavePostInstallTasksSettings (TC_POST_INSTALL_CFG_TUTORIAL);
+ }
+ }
+ else
+ {
+ // No restart will be required
+
+ if (bUpgrade)
+ {
+ bPromptReleaseNotes = TRUE;
+ }
+ else if (bPossiblyFirstTimeInstall)
+ {
+ bPromptTutorial = TRUE;
+ }
+ }
+ }
+ }
+
+ if (bOK)
+ {
+ // This is part of MainDialogProc, WM_CLOSE, after PostMessage (MainDlg, bOK ? TC_APPMSG_INSTALL_SUCCESS : TC_APPMSG_INSTALL_FAILURE, 0, 0);
+
+ /* if user selected a language, use for GUI in the next run */
+ if (bUserSetLanguage)
+ {
+ WCHAR langId[6];
+ MultiByteToWideChar (CP_ACP, 0, GetPreferredLangId(), -1, langId, ARRAYSIZE (langId));
+ WriteRegistryString (L"Software\\VeraCrypt", L"SetupUILanguage", langId);
+ }
+
+ if (bPromptFastStartup && AskWarnYesNo ("CONFIRM_DISABLE_FAST_STARTUP", hwndDlg) == IDYES)
+ {
+ WriteLocalMachineRegistryDword (L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Power", L"HiberbootEnabled", 0);
+ bRestartRequired = TRUE;
+ }
+ bPromptFastStartup = FALSE;
+
+ if (bPromptReleaseNotes && AskYesNo ("AFTER_UPGRADE_RELEASE_NOTES", hwndDlg) == IDYES)
+ {
+ Applink_Dll (hInstaller, "releasenotes");
+ }
+ bPromptReleaseNotes = FALSE;
+
+ if (bPromptTutorial && AskYesNo ("AFTER_INSTALL_TUTORIAL", hwndDlg) == IDYES)
+ {
+ Applink_Dll (hInstaller, "beginnerstutorial");
+ }
+ bPromptTutorial = FALSE;
+
+ if (RegCreateKeyEx (HKEY_LOCAL_MACHINE, L"Software\\.VeraCrypt\\Values", 0, NULL, REG_OPTION_VOLATILE, KEY_WRITE, NULL, &hkey, &dw) == ERROR_SUCCESS)
+ {
+ RegSetValueEx (hkey, L"Silent", 0, REG_DWORD, (const BYTE*)(&Silent), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bUninstall", 0, REG_DWORD, (const BYTE*)(&bUninstall), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bDowngrade", 0, REG_DWORD, (const BYTE*)(&bDowngrade), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bUninstallInProgress", 0, REG_DWORD, (const BYTE*)(&bUninstallInProgress), sizeof(BOOL));
+ RegSetValueEx (hkey, L"PortableMode", 0, REG_DWORD, (const BYTE*)(&PortableMode), sizeof(BOOL));
+ RegSetValueEx (hkey, L"UnloadDriver", 0, REG_DWORD, (const BYTE*)(&UnloadDriver), sizeof(BOOL));
+
+ RegSetValueEx (hkey, L"Rollback", 0, REG_DWORD, (const BYTE*)(&Rollback), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bReinstallMode", 0, REG_DWORD, (const BYTE*)(&bReinstallMode), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bUpgrade", 0, REG_DWORD, (const BYTE*)(&bUpgrade), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bPossiblyFirstTimeInstall", 0, REG_DWORD, (const BYTE*)(&bPossiblyFirstTimeInstall), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bDevm", 0, REG_DWORD, (const BYTE*)(&bDevm), sizeof(BOOL));
+ RegSetValueEx (hkey, L"SystemEncryptionUpdate", 0, REG_DWORD, (const BYTE*)(&SystemEncryptionUpdate), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bRestartRequired", 0, REG_DWORD, (const BYTE*)(&bRestartRequired), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bDisableSwapFiles", 0, REG_DWORD, (const BYTE*)(&bDisableSwapFiles), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bSystemRestore", 0, REG_DWORD, (const BYTE*)(&bSystemRestore), sizeof(BOOL));
+
+ RegSetValueEx (hkey, L"bPromptFastStartup", 0, REG_DWORD, (const BYTE*)(&bPromptFastStartup), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bPromptReleaseNotes", 0, REG_DWORD, (const BYTE*)(&bPromptReleaseNotes), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bPromptTutorial", 0, REG_DWORD, (const BYTE*)(&bPromptTutorial), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bUpdateRescueDisk", 0, REG_DWORD, (const BYTE*)(&bUpdateRescueDisk), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bRepairMode", 0, REG_DWORD, (const BYTE*)(&bRepairMode), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bUserSetLanguage", 0, REG_DWORD, (const BYTE*)(&bUserSetLanguage), sizeof(BOOL));
+
+ RegCloseKey (hkey);
+
+ uiRet = ERROR_SUCCESS;
+ }
+ else
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"End VC_CustomAction_PostInstall: Could not write to registry");
+ }
+ }
+end:
+
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"End VC_CustomAction_PostInstall");
+ return uiRet;
+}
+
+/*
+ * Same as Setup.c, function DoUninstall(), but
+ * without the actual uninstall, it only prepares the system
+ * before the uninstall (before DoFilesInstall).
+ * It runs as a Deferred CA.
+ */
+EXTERN_C UINT STDAPICALLTYPE VC_CustomAction_PreUninstall(MSIHANDLE hInstaller)
+{
+ HWND hwndDlg = NULL;
+ std::wstring szValueBuf = L"";
+ DWORD cchValueBuf = 0;
+ UINT uiStat = 0;
+ HKEY hkey = 0;
+ DWORD dw = 0;
+ BootEncryption bootEnc(NULL);
+ std::wstring szInstallDir = L"";
+ UINT uiRet = ERROR_INSTALL_FAILURE;
+ BOOL bTempSkipSysRestore = FALSE;
+ BOOL bOK = TRUE;
+
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"Begin VC_CustomAction_PreUninstall");
+
+ // Get UILevel to see whether we're being installed silently or not.
+ // Also get INSTALLDIR to see where we're being installed.
+ // Since this is a Deferred CA, they are to be setup in its CustomActionData.
+ uiStat = MsiGetProperty(hInstaller, TEXT("CustomActionData"), (LPWSTR)TEXT(""), &cchValueBuf);
+ if (ERROR_MORE_DATA == uiStat)
+ {
+ ++cchValueBuf; // add 1 for null termination
+ szValueBuf.resize(cchValueBuf);
+ uiStat = MsiGetProperty(hInstaller, TEXT("CustomActionData"), &szValueBuf[0], &cchValueBuf);
+ if ((ERROR_SUCCESS == uiStat))
+ {
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"VC_CustomAction_PreUninstall: CustomActionData = '%s'", szValueBuf.c_str());
+
+ std::vector szTokens;
+ Tokenize(szValueBuf.c_str(), szTokens);
+
+ for (size_t i = 0; i < szTokens.size(); i++)
+ {
+ std::wstring szToken = szTokens[i];
+
+ if (wcsncmp(szToken.c_str(), L"UILEVEL=", wcslen(L"UILEVEL=")) == 0)
+ {
+ size_t index0 = szToken.find_first_of(L"=");
+ if (index0 != std::wstring::npos)
+ {
+ std::wstring uiLevel = szToken.substr(index0 + 1);
+ Silent = (stoi(uiLevel) <= 3);
+
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"VC_CustomAction_PreInstall: UILEVEL = '%s', bSilent = '%d'", uiLevel.c_str(), Silent);
+ }
+ }
+ else if (wcsncmp(szToken.c_str(), L"INSTALLDIR=", wcslen(L"INSTALLDIR=")) == 0)
+ {
+ size_t index0 = szToken.find_first_of(L"=");
+ if (index0 != std::wstring::npos)
+ {
+ szInstallDir = szToken.substr(index0 + 1);
+
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"VC_CustomAction_PreInstall: INSTALLDIR = '%s'", szInstallDir.c_str());
+ }
+ }
+ else if (wcsncmp(szToken.c_str(), L"REINSTALL=", wcslen(L"REINSTALL=")) == 0)
+ {
+ size_t index0 = szToken.find_first_of(L"=");
+ if (index0 != std::wstring::npos)
+ {
+ std::wstring szReinstall = szToken.substr(index0 + 1);
+ bRepairMode = (wcslen(szReinstall.c_str()) != 0);
+
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"VC_CustomAction_PreInstall: REINSTALL = '%s', bRepairMode = '%s'", szReinstall.c_str(), bRepairMode ? L"TRUE" : L"FALSE");
+ }
+ }
+ }
+ }
+ }
+
+ // Get this MSI Installer HWND.
+ // There cannot be 2 MSIs or more running at the same time, so we're sure we'll get ours.
+ // This is only possible in case of non silent install.
+ hwndDlg = FindWindow(L"MsiDialogCloseClass", NULL);
+ if (!hwndDlg && !Silent)
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PreUninstall: MsiDialogCloseClass not found");
+ goto end;
+ }
+
+ /* Start actual work */
+
+ bUninstall = TRUE;
+ if (!VC_CustomAction_Init(hInstaller, szInstallDir.c_str()))
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PreUninstall: VC_CustomAction_Init() failed");
+ goto end;
+ }
+ atexit(VC_CustomAction_Cleanup);
+ bootEnc.SetParentWindow(hwndDlg);
+
+ if (DoDriverUnload_Dll(hInstaller, hwndDlg) == FALSE)
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PreUninstall: DoDriverUnload_Dll() failed");
+ bOK = FALSE;
+ bTempSkipSysRestore = TRUE; // Volumes are possibly mounted; defer System Restore point creation for this uninstall attempt.
+ }
+ else
+ {
+ if (!Rollback && bSystemRestore && !bTempSkipSysRestore)
+ SetSystemRestorePoint_Dll (hInstaller, FALSE);
+
+ if (DoServiceUninstall_Dll (hInstaller, hwndDlg, L"veracrypt") == FALSE)
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PreUninstall: DoServiceUninstall_Dll(veracrypt) failed");
+ bOK = FALSE;
+ }
+ // DoRegUninstall_Dll removes regkeys that are not linked to MSI
+ // We need to do this in PreUninstall instead of in PostUninstall so that UnregisterComServers works,
+ // because in PostUninstall the "VeraCrypt COMReg.exe" is removed and UnregisterComServers will fail.
+ else if (DoRegUninstall_Dll (hInstaller, FALSE) == FALSE)
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PreUninstall: DoRegUninstall_Dll() failed");
+ bOK = FALSE;
+ }
+ }
+
+ if (bOK)
+ {
+ // uiRet = MsiSetProperty(hInstaller, TEXT("ISREBOOTREQUIRED"), TEXT("1"));
+ // Cannot do this because this is a Deferred CA (we need Deferred so that it runs with admin privileges).
+ // MsiGetProperty and MsiSetProperty properties cannot be used for deferred InstallScript custom actions,
+ // which do not have access to the active .msi database and do not recognize any Windows Installer properties.
+ // They can access only the information that has been written into the execution script (CustomActionData).
+ // Therefore, we set the values in RegKeys that are volatile.
+ if (RegCreateKeyEx (HKEY_LOCAL_MACHINE, L"Software\\.VeraCrypt\\Values", 0, NULL, REG_OPTION_VOLATILE, KEY_WRITE, NULL, &hkey, &dw) == ERROR_SUCCESS)
+ {
+ RegSetValueEx (hkey, L"Silent", 0, REG_DWORD, (const BYTE*)(&Silent), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bUninstall", 0, REG_DWORD, (const BYTE*)(&bUninstall), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bDowngrade", 0, REG_DWORD, (const BYTE*)(&bDowngrade), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bUninstallInProgress", 0, REG_DWORD, (const BYTE*)(&bUninstallInProgress), sizeof(BOOL));
+ RegSetValueEx (hkey, L"PortableMode", 0, REG_DWORD, (const BYTE*)(&PortableMode), sizeof(BOOL));
+ RegSetValueEx (hkey, L"UnloadDriver", 0, REG_DWORD, (const BYTE*)(&UnloadDriver), sizeof(BOOL));
+
+ RegSetValueEx (hkey, L"Rollback", 0, REG_DWORD, (const BYTE*)(&Rollback), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bReinstallMode", 0, REG_DWORD, (const BYTE*)(&bReinstallMode), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bUpgrade", 0, REG_DWORD, (const BYTE*)(&bUpgrade), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bPossiblyFirstTimeInstall", 0, REG_DWORD, (const BYTE*)(&bPossiblyFirstTimeInstall), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bDevm", 0, REG_DWORD, (const BYTE*)(&bDevm), sizeof(BOOL));
+ RegSetValueEx (hkey, L"SystemEncryptionUpdate", 0, REG_DWORD, (const BYTE*)(&SystemEncryptionUpdate), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bRestartRequired", 0, REG_DWORD, (const BYTE*)(&bRestartRequired), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bDisableSwapFiles", 0, REG_DWORD, (const BYTE*)(&bDisableSwapFiles), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bSystemRestore", 0, REG_DWORD, (const BYTE*)(&bSystemRestore), sizeof(BOOL));
+
+ RegSetValueEx (hkey, L"bPromptFastStartup", 0, REG_DWORD, (const BYTE*)(&bPromptFastStartup), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bPromptReleaseNotes", 0, REG_DWORD, (const BYTE*)(&bPromptReleaseNotes), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bPromptTutorial", 0, REG_DWORD, (const BYTE*)(&bPromptTutorial), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bUpdateRescueDisk", 0, REG_DWORD, (const BYTE*)(&bUpdateRescueDisk), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bRepairMode", 0, REG_DWORD, (const BYTE*)(&bRepairMode), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bUserSetLanguage", 0, REG_DWORD, (const BYTE*)(&bUserSetLanguage), sizeof(BOOL));
+
+ RegCloseKey (hkey);
+
+ uiRet = ERROR_SUCCESS;
+ }
+ else
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"End VC_CustomAction_PreUninstall: Could not write to registry");
+ }
+ }
+
+end:
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"End VC_CustomAction_PreUninstall");
+ return uiRet;
+}
+
+/*
+ * Same as Setup.c, function DoUninstall(), but
+ * without the actual installation, it only performs
+ * post install operations (after DoFilesInstall and last parts
+ * of DoFilesInstall / DoRegUninstall).
+ * It also sets regkey accordingly.
+ * It runs as a Deferred CA.
+ */
+EXTERN_C UINT STDAPICALLTYPE VC_CustomAction_PostUninstall(MSIHANDLE hInstaller)
+{
+ HWND hwndDlg = NULL;
+ std::wstring szValueBuf = L"";
+ DWORD cchValueBuf = 0;
+ UINT uiStat = 0;
+ HKEY hkey = 0;
+ DWORD dw = 0;
+ BootEncryption bootEnc(NULL);
+ std::wstring szInstallDir = L"";
+ UINT uiRet = ERROR_INSTALL_FAILURE;
+ BOOL bTempSkipSysRestore = FALSE;
+ BOOL bOK = TRUE;
+
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"Begin VC_CustomAction_PostUninstall");
+
+ // Get INSTALLDIR to see where we're being installed.
+ uiStat = MsiGetProperty(hInstaller, TEXT("CustomActionData"), (LPWSTR)TEXT(""), &cchValueBuf);
+ if (ERROR_MORE_DATA == uiStat)
+ {
+ ++cchValueBuf; // add 1 for null termination
+ szValueBuf.resize(cchValueBuf);
+ uiStat = MsiGetProperty(hInstaller, TEXT("CustomActionData"), &szValueBuf[0], &cchValueBuf);
+ if ((ERROR_SUCCESS == uiStat))
+ {
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"VC_CustomAction_PostUninstall: CustomActionData = '%s'", szValueBuf.c_str());
+ if (wcsncmp(szValueBuf.c_str(), L"INSTALLDIR=", wcslen(L"INSTALLDIR=")) == 0)
+ {
+ size_t index0 = szValueBuf.find_first_of(L"=");
+ if (index0 != std::wstring::npos)
+ {
+ szInstallDir = szValueBuf.substr(index0 + 1);
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"VC_CustomAction_PostUninstall: INSTALLDIR = '%s'", szInstallDir.c_str());
+ }
+ }
+ }
+ }
+
+ // Read RegKeys previously setup by PreInstall
+ if (RegOpenKeyExW (HKEY_LOCAL_MACHINE, L"Software\\.VeraCrypt\\Values", 0, KEY_READ, &hkey) == ERROR_SUCCESS)
+ {
+ DWORD cbValue = sizeof(DWORD);
+ DWORD dwValue = 0;
+
+ RegQueryValueEx (hkey, L"Silent", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ Silent = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bUninstall", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bUninstall = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bDowngrade", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bDowngrade = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bUninstallInProgress", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bUninstallInProgress = (dwValue == 1);
+ RegQueryValueEx (hkey, L"PortableMode", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ PortableMode = (dwValue == 1);
+ RegQueryValueEx (hkey, L"UnloadDriver", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ UnloadDriver = (dwValue == 1);
+
+ RegQueryValueEx (hkey, L"Rollback", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ Rollback = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bReinstallMode", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bReinstallMode = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bUpgrade", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bUpgrade = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bPossiblyFirstTimeInstall", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bPossiblyFirstTimeInstall = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bDevm", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bDevm = (dwValue == 1);
+ RegQueryValueEx (hkey, L"SystemEncryptionUpdate", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ SystemEncryptionUpdate = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bRestartRequired", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bRestartRequired = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bDisableSwapFiles", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bDisableSwapFiles = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bSystemRestore", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bSystemRestore = (dwValue == 1);
+
+ RegQueryValueEx (hkey, L"bPromptFastStartup", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bPromptFastStartup = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bPromptReleaseNotes", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bPromptReleaseNotes = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bPromptTutorial", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bPromptTutorial = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bUpdateRescueDisk", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bUpdateRescueDisk = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bRepairMode", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bRepairMode = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bUserSetLanguage", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bUserSetLanguage = (dwValue == 1);
+
+ RegCloseKey (hkey);
+ }
+ else
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"End VC_CustomAction_PostUninstall: Could not read from registry");
+ goto end;
+ }
+
+ // Get this MSI Installer HWND.
+ // There cannot be 2 MSIs or more running at the same time, so we're sure we'll get ours.
+ // This is only possible in case of non silent install.
+ hwndDlg = FindWindow(L"MsiDialogCloseClass", NULL);
+ if (!hwndDlg && !Silent)
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PostUninstall: MsiDialogCloseClass not found");
+ goto end;
+ }
+
+ /* Start actual work */
+
+ bUninstall = TRUE;
+ if (!VC_CustomAction_Init(hInstaller, szInstallDir.c_str()))
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PostUninstall: VC_CustomAction_Init() failed");
+ goto end;
+ }
+ atexit(VC_CustomAction_Cleanup);
+ bootEnc.SetParentWindow(hwndDlg);
+
+ if (!DoApplicationDataUninstall_Dll (hInstaller))
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PostUninstall: DoApplicationDataUninstall_Dll() failed");
+ bOK = FALSE;
+ }
+ else
+ {
+ // Deprecated service
+ DoServiceUninstall_Dll (hInstaller, hwndDlg, L"VeraCryptService");
+ }
+
+ // Last part of DoFilesInstall()
+ {
+ if (Is64BitOs ())
+ EnableWow64FsRedirection (FALSE);
+
+ 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()))
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PostUninstall: REMOVING %s", favoritesFile.c_str());
+ ForceDeleteFile (favoritesFile.c_str());
+ }
+
+ if (FileExists (servicePath.c_str()))
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PostUninstall: REMOVING %s", servicePath.c_str());
+ ForceDeleteFile (servicePath.c_str());
+ }
+
+ if (Is64BitOs ())
+ {
+ if (FileExists (favoritesLegacyFile.c_str()))
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PostUninstall: REMOVING %s", favoritesLegacyFile.c_str());
+ ForceDeleteFile (favoritesLegacyFile.c_str());
+ }
+
+ if (FileExists (serviceLegacyPath.c_str()))
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PostUninstall: REMOVING %s", serviceLegacyPath.c_str());
+ ForceDeleteFile (serviceLegacyPath.c_str());
+ }
+
+ EnableWow64FsRedirection (TRUE);
+ }
+ }
+
+ if (bSystemRestore && !bTempSkipSysRestore)
+ SetSystemRestorePoint_Dll (hInstaller, TRUE);
+
+ if (bOK)
+ {
+ // uiRet = MsiSetProperty(hInstaller, TEXT("ISREBOOTREQUIRED"), TEXT("1"));
+ // Cannot do this because this is a Deferred CA (we need Deferred so that it runs with admin privileges).
+ // MsiGetProperty and MsiSetProperty properties cannot be used for deferred InstallScript custom actions,
+ // which do not have access to the active .msi database and do not recognize any Windows Installer properties.
+ // They can access only the information that has been written into the execution script (CustomActionData).
+ // Therefore, we set the values in RegKeys that are volatile.
+ if (RegCreateKeyEx (HKEY_LOCAL_MACHINE, L"Software\\.VeraCrypt\\Values", 0, NULL, REG_OPTION_VOLATILE, KEY_WRITE, NULL, &hkey, &dw) == ERROR_SUCCESS)
+ {
+ RegSetValueEx (hkey, L"Silent", 0, REG_DWORD, (const BYTE*)(&Silent), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bUninstall", 0, REG_DWORD, (const BYTE*)(&bUninstall), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bDowngrade", 0, REG_DWORD, (const BYTE*)(&bDowngrade), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bUninstallInProgress", 0, REG_DWORD, (const BYTE*)(&bUninstallInProgress), sizeof(BOOL));
+ RegSetValueEx (hkey, L"PortableMode", 0, REG_DWORD, (const BYTE*)(&PortableMode), sizeof(BOOL));
+ RegSetValueEx (hkey, L"UnloadDriver", 0, REG_DWORD, (const BYTE*)(&UnloadDriver), sizeof(BOOL));
+
+ RegSetValueEx (hkey, L"Rollback", 0, REG_DWORD, (const BYTE*)(&Rollback), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bReinstallMode", 0, REG_DWORD, (const BYTE*)(&bReinstallMode), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bUpgrade", 0, REG_DWORD, (const BYTE*)(&bUpgrade), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bPossiblyFirstTimeInstall", 0, REG_DWORD, (const BYTE*)(&bPossiblyFirstTimeInstall), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bDevm", 0, REG_DWORD, (const BYTE*)(&bDevm), sizeof(BOOL));
+ RegSetValueEx (hkey, L"SystemEncryptionUpdate", 0, REG_DWORD, (const BYTE*)(&SystemEncryptionUpdate), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bRestartRequired", 0, REG_DWORD, (const BYTE*)(&bRestartRequired), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bDisableSwapFiles", 0, REG_DWORD, (const BYTE*)(&bDisableSwapFiles), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bSystemRestore", 0, REG_DWORD, (const BYTE*)(&bSystemRestore), sizeof(BOOL));
+
+ RegSetValueEx (hkey, L"bPromptFastStartup", 0, REG_DWORD, (const BYTE*)(&bPromptFastStartup), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bPromptReleaseNotes", 0, REG_DWORD, (const BYTE*)(&bPromptReleaseNotes), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bPromptTutorial", 0, REG_DWORD, (const BYTE*)(&bPromptTutorial), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bUpdateRescueDisk", 0, REG_DWORD, (const BYTE*)(&bUpdateRescueDisk), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bRepairMode", 0, REG_DWORD, (const BYTE*)(&bRepairMode), sizeof(BOOL));
+ RegSetValueEx (hkey, L"bUserSetLanguage", 0, REG_DWORD, (const BYTE*)(&bUserSetLanguage), sizeof(BOOL));
+
+ RegCloseKey (hkey);
+
+ uiRet = ERROR_SUCCESS;
+ }
+ else
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"End VC_CustomAction_PostUninstall: Could not write to registry");
+ }
+ }
+ else
+ bUninstallInProgress = FALSE;
+
+end:
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"End VC_CustomAction_PostUninstall");
+ return uiRet;
+}
+
+/* Runs as a Commit CA : therefore, we can get / set properties that are defined in WiX.
+ * It sets ISREBOOTREQUIRED Wix Property accordingly and refreshes extensions list
+ * if REGISTERVCFILEEXT is set.
+ */
+EXTERN_C UINT STDAPICALLTYPE VC_CustomAction_DoChecks(MSIHANDLE hInstaller)
+{
+ HWND hwndDlg = NULL;
+ std::wstring szValueBuf = L"";
+ DWORD cchValueBuf = 0;
+ UINT uiStat = 0;
+ HKEY hkey = 0;
+ DWORD dw = 0;
+ std::wstring szInstallDir = L"";
+ BOOL bRefreshExts = FALSE;
+ UINT uiRet = ERROR_INSTALL_FAILURE;
+
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"Begin VC_CustomAction_DoChecks");
+
+ // Get WIXUI_INSTALLDIR to see where we're being installed
+ uiStat = MsiGetProperty(hInstaller, TEXT("APPLICATIONROOTFOLDER"), (LPWSTR)TEXT(""), &cchValueBuf);
+ if (ERROR_MORE_DATA == uiStat)
+ {
+ ++cchValueBuf; // add 1 for null termination
+ szValueBuf.resize(cchValueBuf);
+ uiStat = MsiGetProperty(hInstaller, TEXT("APPLICATIONROOTFOLDER"), &szValueBuf[0], &cchValueBuf);
+ if ((ERROR_SUCCESS == uiStat))
+ {
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"VC_CustomAction_DoChecks: APPLICATIONROOTFOLDER = '%s'", szValueBuf.c_str());
+ szInstallDir = szValueBuf;
+ }
+ }
+
+ // Get REGISTERVCFILEEXT to see whether we should refresh extensions list.
+ szValueBuf.clear();
+ cchValueBuf = 0;
+ uiStat = MsiGetProperty(hInstaller, TEXT("REGISTERVCFILEEXT"), (LPWSTR)TEXT(""), &cchValueBuf);
+ if (ERROR_MORE_DATA == uiStat)
+ {
+ ++cchValueBuf; // add 1 for null termination
+ szValueBuf.resize(cchValueBuf);
+ uiStat = MsiGetProperty(hInstaller, TEXT("REGISTERVCFILEEXT"), &szValueBuf[0], &cchValueBuf);
+ if ((ERROR_SUCCESS == uiStat))
+ {
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"VC_CustomAction_DoChecks: REGISTERVCFILEEXT = '%s'", szValueBuf.c_str());
+ bRefreshExts = (szValueBuf[0] == L'1');
+ }
+ }
+
+ // Read RegKeys previously setup by Pre/Post-Install
+ if (RegOpenKeyExW (HKEY_LOCAL_MACHINE, L"Software\\.VeraCrypt\\Values", 0, KEY_READ, &hkey) == ERROR_SUCCESS)
+ {
+ DWORD cbValue = sizeof(DWORD);
+ DWORD dwValue = 0;
+
+ RegQueryValueEx (hkey, L"Silent", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ Silent = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bUninstall", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bUninstall = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bDowngrade", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bDowngrade = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bUninstallInProgress", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bUninstallInProgress = (dwValue == 1);
+ RegQueryValueEx (hkey, L"PortableMode", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ PortableMode = (dwValue == 1);
+ RegQueryValueEx (hkey, L"UnloadDriver", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ UnloadDriver = (dwValue == 1);
+
+ RegQueryValueEx (hkey, L"Rollback", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ Rollback = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bReinstallMode", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bReinstallMode = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bUpgrade", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bUpgrade = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bPossiblyFirstTimeInstall", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bPossiblyFirstTimeInstall = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bDevm", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bDevm = (dwValue == 1);
+ RegQueryValueEx (hkey, L"SystemEncryptionUpdate", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ SystemEncryptionUpdate = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bRestartRequired", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bRestartRequired = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bDisableSwapFiles", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bDisableSwapFiles = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bSystemRestore", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bSystemRestore = (dwValue == 1);
+
+ RegQueryValueEx (hkey, L"bPromptFastStartup", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bPromptFastStartup = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bPromptReleaseNotes", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bPromptReleaseNotes = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bPromptTutorial", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bPromptTutorial = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bUpdateRescueDisk", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bUpdateRescueDisk = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bRepairMode", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bRepairMode = (dwValue == 1);
+ RegQueryValueEx (hkey, L"bUserSetLanguage", NULL, NULL, (LPBYTE) &dwValue, &cbValue);
+ bUserSetLanguage = (dwValue == 1);
+
+ RegCloseKey (hkey);
+ }
+ else
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"End VC_CustomAction_DoChecks: Could not read from registry");
+ goto end;
+ }
+
+ // Get this MSI Installer HWND.
+ // There cannot be 2 MSIs or more running at the same time, so we're sure we'll get ours.
+ // This is only possible in case of non silent install.
+ hwndDlg = FindWindow(L"MsiDialogCloseClass", NULL);
+ if (!hwndDlg && !Silent)
+ {
+ MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_DoChecks: MsiDialogCloseClass not found");
+ goto end;
+ }
+
+ /* Start actual work */
+
+ if (bRefreshExts)
+ {
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"VC_CustomAction_DoChecks: Will refresh file extensions");
+ SHChangeNotify (SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
+ }
+
+ // Check if reboot was required by the pre/post-install and set Wix property ISREBOOTREQUIRED accordingly.
+ if (bRestartRequired)
+ {
+ uiRet = MsiSetProperty(hInstaller, L"ISREBOOTREQUIRED", L"1");
+ }
+ else
+ {
+ uiRet = ERROR_SUCCESS;
+ }
+
+ // Remove volatile regkeys
+ SHDeleteKey(HKEY_LOCAL_MACHINE, L"Software\\.VeraCrypt");
+
+end:
+ MSILog(hInstaller, MSI_INFO_LEVEL, L"End VC_CustomAction_DoChecks");
+ return uiRet;
+}
+
+BOOL
+WINAPI
+DllMain(
+ HMODULE hInstDLL,
+ DWORD dwReason,
+ LPVOID lpvReserved)
+{
+ UNREFERENCED_PARAMETER(lpvReserved);
+
+ /* Save the instance handle for later,
+ * especially for loading embedded Language.xml file
+ * in Dlgcode.c, MapResource() function.
+ */
+ hInst = hInstDLL;
+
+ return TRUE;
+}
\ No newline at end of file
diff --git a/src/SetupDLL/Setup.h b/src/SetupDLL/Setup.h
new file mode 100644
index 00000000..e38dd75a
--- /dev/null
+++ b/src/SetupDLL/Setup.h
@@ -0,0 +1,137 @@
+/*
+ Legal Notice: Some portions of the source code contained in this file were
+ derived from the source code of TrueCrypt 7.1a, which is
+ Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
+ governed by the TrueCrypt License 3.0, also from the source code of
+ Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
+ and which is governed by the 'License Agreement for Encryption for the Masses'
+ Modifications and additions to the original source code (contained in this file)
+ and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and are governed by the Apache License 2.0 the full text of which is
+ contained in the file License.txt included in VeraCrypt binary and source
+ code distribution packages. */
+
+#ifndef SETUP_H
+#define SETUP_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Specifies what files to install, where (determined by the prefix), and in what order
+static wchar_t *szFiles[]=
+{
+ L"ALicense.txt",
+ L"ALICENSE",
+ L"ANOTICE",
+ L"AVeraCrypt.exe",
+ L"AVeraCryptExpander.exe",
+ L"AVeraCrypt Format.exe",
+ L"Averacrypt.inf",
+ L"Averacrypt.cat",
+ L"Averacrypt.sys",
+ L"Dveracrypt.sys",
+ L"AVeraCrypt Setup.exe",
+ L"XLanguages.zip",
+ L"Xdocs.zip",
+};
+
+// Specifies what files are included in self-extracting packages (no other files will be packaged or extracted).
+static wchar_t *szCompressedFiles[]=
+{
+ 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-arm64.exe",
+ L"VeraCryptExpander-arm64.exe",
+ L"VeraCrypt Format-arm64.exe",
+ L"veracrypt.inf",
+ L"veracrypt.cat",
+ L"veracrypt.sys",
+ L"veracrypt-x64.cat",
+ L"veracrypt-x64.sys",
+ L"veracrypt-arm64.cat",
+ L"veracrypt-arm64.sys",
+ L"Languages.zip",
+ 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]))
+
+void localcleanup (void);
+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, const wchar_t *param);
+void ClearLogWindow (HWND hwndDlg);
+void RegMessage ( HWND hwndDlg , const wchar_t *txt );
+void RegRemoveMessage (HWND hwndDlg, const wchar_t *txt);
+void _cdecl CopyMessage ( HWND hwndDlg , const wchar_t *txt );
+void RemoveMessage ( HWND hwndDlg , const wchar_t *txt );
+void IconMessage ( HWND hwndDlg , const 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 , wchar_t *szDestDir );
+BOOL DoRegInstall ( HWND hwndDlg , wchar_t *szDestDir , BOOL bInstallType );
+BOOL DoRegUninstall (HWND hwndDlg, BOOL bRemoveDeprecated);
+BOOL DoServiceUninstall ( HWND hwndDlg , wchar_t *lpszService );
+BOOL DoDriverUnload ( HWND hwndDlg );
+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 );
+void SetInstallationPath (HWND hwndDlg);
+BOOL UpgradeBootLoader (HWND hwndDlg);
+BOOL CALLBACK InstallDlgProc ( HWND hwndDlg , UINT msg , WPARAM wParam , LPARAM lParam );
+#ifdef VC_EFI_CUSTOM_MODE
+BOOL CheckSecureBootCompatibility (HWND hWnd);
+#endif
+
+extern BOOL bDevm;
+extern BOOL Rollback;
+extern BOOL bUpgrade;
+extern BOOL bUpdateRescueDisk;
+extern BOOL bPossiblyFirstTimeInstall;
+extern BOOL bRepairMode;
+extern BOOL bReinstallMode;
+extern BOOL bSystemRestore;
+extern BOOL bDisableSwapFiles;
+extern BOOL bForAllUsers;
+extern BOOL bRegisterFileExt;
+extern BOOL bAddToStartMenu;
+extern BOOL bDesktopIcon;
+extern BOOL bDesktopIconStatusDetermined;
+extern BOOL SystemEncryptionUpdate;
+extern BOOL bRestartRequired;
+extern HMODULE volatile SystemRestoreDll;
+extern wchar_t InstallationPath[TC_MAX_PATH];
+extern wchar_t SetupFilesDir[TC_MAX_PATH];
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // #ifndef SETUP_H
diff --git a/src/SetupDLL/Setup.ico b/src/SetupDLL/Setup.ico
new file mode 100644
index 00000000..8fd81cd3
Binary files /dev/null and b/src/SetupDLL/Setup.ico differ
diff --git a/src/SetupDLL/Setup.manifest b/src/SetupDLL/Setup.manifest
new file mode 100644
index 00000000..afd4c1c0
--- /dev/null
+++ b/src/SetupDLL/Setup.manifest
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/SetupDLL/Setup.rc b/src/SetupDLL/Setup.rc
new file mode 100644
index 00000000..6e1a5312
--- /dev/null
+++ b/src/SetupDLL/Setup.rc
@@ -0,0 +1,367 @@
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "winres.h"
+#include "..\\common\\resource.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,24,25,0
+ PRODUCTVERSION 1,24,25,0
+ 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", "VeraCryptSetup"
+ VALUE "FileVersion", "1.24-Update9"
+ VALUE "LegalTrademarks", "VeraCrypt"
+ VALUE "OriginalFilename", "VeraCryptSetup.dll"
+ VALUE "ProductName", "VeraCrypt"
+ VALUE "ProductVersion", "1.24-Update9"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// HEADER
+//
+
+IDR_SETUP_RSRC_HEADER HEADER "resource.h"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// REGISTRY
+//
+
+IDR_COMREG REGISTRY "ComSetup.rgs"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// LANGUAGES
+//
+
+IDR_LANG_AR LANGUAGES "..\\..\\Translations\\Language.ar.xml"
+IDR_LANG_CS LANGUAGES "..\\..\\Translations\\Language.cs.xml"
+IDR_LANG_DE LANGUAGES "..\\..\\Translations\\Language.de.xml"
+IDR_LANG_ES LANGUAGES "..\\..\\Translations\\Language.es.xml"
+IDR_LANG_FR LANGUAGES "..\\..\\Translations\\Language.fr.xml"
+IDR_LANG_IT LANGUAGES "..\\..\\Translations\\Language.it.xml"
+IDR_LANG_JA LANGUAGES "..\\..\\Translations\\Language.ja.xml"
+IDR_LANG_NL LANGUAGES "..\\..\\Translations\\Language.nl.xml"
+IDR_LANG_PL LANGUAGES "..\\..\\Translations\\Language.pl.xml"
+IDR_LANG_RO LANGUAGES "..\\..\\Translations\\Language.ro.xml"
+IDR_LANG_RU LANGUAGES "..\\..\\Translations\\Language.ru.xml"
+IDR_LANG_VI LANGUAGES "..\\..\\Translations\\Language.vi.xml"
+IDR_LANG_ZHCN LANGUAGES "..\\..\\Translations\\Language.zh-cn.xml"
+IDR_LANG_ZHHK LANGUAGES "..\\..\\Translations\\Language.zh-hk.xml"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_UNINSTALL DIALOGEX 0, 0, 349, 234
+STYLE DS_SETFONT | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Uninstall VeraCrypt"
+CLASS "VeraCryptCustomDlg"
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ LTEXT "Click Uninstall to remove VeraCrypt from this system.",IDT_UNINSTALL_DIR,8,8,334,8
+ LISTBOX IDC_LOG_WINDOW,7,21,335,179,LBS_NOINTEGRALHEIGHT | LBS_NOSEL | WS_VSCROLL
+ DEFPUSHBUTTON "&Uninstall",IDC_UNINSTALL,236,213,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,292,213,50,14
+ CONTROL "Create System &Restore point",IDC_SYSTEM_RESTORE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,215,194,10
+ CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,2,206,347,1,WS_EX_STATICEDGE
+ CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,1,1,348,1,WS_EX_STATICEDGE
+END
+
+IDD_INSTALL_OPTIONS_PAGE_DLG DIALOGEX 0, 0, 346, 152
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ EDITTEXT IDC_DESTINATION,11,41,260,13,ES_AUTOHSCROLL
+ PUSHBUTTON "Bro&wse...",IDC_BROWSE,278,40,59,14
+ CONTROL "Install &for all users",IDC_ALL_USERS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,77,168,11
+ CONTROL "Associate the .hc file &extension with VeraCrypt",IDC_FILE_TYPE,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,113,232,11
+ CONTROL "Add VeraCrypt to &Start menu",IDC_PROG_GROUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,89,168,11
+ CONTROL "Create System &Restore point",IDC_SYSTEM_RESTORE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,125,194,11
+ CONTROL "Add VeraCrypt icon to &desktop",IDC_DESKTOP_ICON,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,101,168,11
+ LTEXT "Please select or type the location where you want to install the VeraCrypt program files. If the specified folder does not exist, it will be automatically created.",IDT_INSTALL_DESTINATION,11,14,319,25
+END
+
+IDD_INFO_PAGE_DLG DIALOGEX 0, 0, 217, 156
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ LTEXT "",IDC_BOX_HELP,0,10,217,146
+END
+
+IDD_INTRO_PAGE_DLG DIALOGEX 0, 0, 346, 152
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ CONTROL "",IDC_LICENSE_TEXT,"RichEdit20W",ES_MULTILINE | ES_READONLY | ES_NUMBER | WS_BORDER | WS_VSCROLL | WS_TABSTOP,0,23,345,108
+ CONTROL "",IDC_AGREE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,2,137,126,10
+ LTEXT "",IDC_BOX_HELP,0,0,346,22
+END
+
+IDD_INSTL_DLG DIALOGEX 0, 0, 374, 231
+STYLE DS_SETFONT | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "VeraCrypt Setup Wizard"
+CLASS "VeraCryptCustomDlg"
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ PUSHBUTTON "&Help",IDHELP,150,211,50,14
+ PUSHBUTTON "",IDC_PREV,209,211,50,14
+ DEFPUSHBUTTON "",IDC_NEXT,259,211,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,317,211,50,14
+ LTEXT "",IDC_BOX_TITLE,11,5,324,12,0,WS_EX_TRANSPARENT
+ CONTROL 107,IDC_BITMAP_SETUP_WIZARD,"Static",SS_BITMAP | SS_NOTIFY,139,3,228,30
+ CONTROL 109,IDC_SETUP_WIZARD_BKG,"Static",SS_BITMAP,0,0,11,10
+ CONTROL "",IDC_SETUP_WIZARD_GFX_AREA,"Static",SS_GRAYRECT | NOT WS_VISIBLE,0,0,378,36,WS_EX_TRANSPARENT | WS_EX_STATICEDGE
+ CONTROL "",IDC_HR_BOTTOM,"Static",SS_ETCHEDHORZ,67,204,306,1,WS_EX_STATICEDGE
+ CONTROL "",IDC_HR,"Static",SS_ETCHEDHORZ,0,35,399,1,WS_EX_STATICEDGE
+ LTEXT "VeraCrypt Installer",IDC_STATIC,4,200,62,8,WS_DISABLED
+ LTEXT "",IDC_BOX_INFO,18,18,317,13,0,WS_EX_TRANSPARENT
+ LTEXT "",IDC_MAIN_CONTENT_CANVAS,0,36,374,164
+ LTEXT "",IDC_POS_BOX,14,42,346,155,0,WS_EX_TRANSPARENT
+END
+
+IDD_EXTRACTION_OPTIONS_PAGE_DLG DIALOGEX 0, 0, 346, 152
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ PUSHBUTTON "Bro&wse...",IDC_BROWSE,277,32,62,14
+ EDITTEXT IDC_DESTINATION,6,33,264,12,ES_AUTOHSCROLL
+ LTEXT "Please select or type the location where you want to place the extracted files:",IDT_EXTRACT_DESTINATION,6,15,333,17
+ CONTROL "&Open the destination location when finished",IDC_OPEN_CONTAINING_FOLDER,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,91,318,16
+ LTEXT "",IDC_BOX_HELP,6,56,333,32
+END
+
+IDD_WIZARD_MODE_PAGE_DLG DIALOGEX 0, 0, 346, 152
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ CONTROL "&Install",IDC_WIZARD_MODE_INSTALL,"Button",BS_AUTORADIOBUTTON,6,14,232,10
+ CONTROL "&Extract",IDC_WIZARD_MODE_EXTRACT_ONLY,"Button",BS_AUTORADIOBUTTON,6,60,232,10
+ LTEXT "",IDC_BOX_HELP,42,77,286,64
+ LTEXT "",IDC_BOX_HELP2,42,30,286,29
+END
+
+IDD_PROGRESS_PAGE_DLG DIALOGEX 0, 0, 346, 152
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ LISTBOX IDC_LOG_WINDOW,0,1,345,131,LBS_NOINTEGRALHEIGHT | LBS_DISABLENOSCROLL | LBS_NOSEL | WS_VSCROLL
+ CONTROL "",IDC_PROGRESS_BAR,"msctls_progress32",PBS_SMOOTH | WS_BORDER,0,139,345,12
+END
+
+IDD_DONATIONS_PAGE_DLG DIALOGEX 0, 0, 346, 152
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+EXSTYLE WS_EX_TRANSPARENT
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ PUSHBUTTON "Donate now...",IDC_DONATE,124,94,96,14
+END
+
+IDD_INSTALL_LANGUAGE DIALOGEX 0, 0, 214, 75
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "VeraCrypt Setup Wizard"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ DEFPUSHBUTTON "OK",IDOK,102,54,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,157,54,50,14
+ ICON IDI_SETUP,IDC_STATIC,10,10,32,32
+ LTEXT "Select the language to use during the installation:",IDC_SELECT_LANGUAGE_LABEL,42,13,158,17
+ COMBOBOX IDC_LANGUAGES_LIST,42,36,164,155,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_SETUP ICON "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
+
+3 TEXTINCLUDE
+BEGIN
+ "#include ""..\\\\common\\\\common.rc""\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_UNINSTALL, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 342
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 229
+ END
+
+ IDD_INSTALL_OPTIONS_PAGE_DLG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 339
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 147
+ END
+
+ IDD_INFO_PAGE_DLG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 210
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 149
+ END
+
+ IDD_INTRO_PAGE_DLG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 339
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 145
+ END
+
+ IDD_INSTL_DLG, DIALOG
+ BEGIN
+ RIGHTMARGIN, 367
+ TOPMARGIN, 1
+ BOTTOMMARGIN, 229
+ HORZGUIDE, 196
+ END
+
+ IDD_EXTRACTION_OPTIONS_PAGE_DLG, DIALOG
+ BEGIN
+ RIGHTMARGIN, 343
+ BOTTOMMARGIN, 147
+ END
+
+ IDD_WIZARD_MODE_PAGE_DLG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 339
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 145
+ END
+
+ IDD_PROGRESS_PAGE_DLG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 339
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 145
+ END
+
+ IDD_DONATIONS_PAGE_DLG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 339
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 147
+ END
+
+ IDD_INSTALL_LANGUAGE, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 207
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 68
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Bitmap
+//
+
+IDB_SETUP_WIZARD BITMAP "VeraCrypt_setup.bmp"
+IDB_SETUP_WIZARD_BKG BITMAP "VeraCrypt_setup_background.bmp"
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+#include "..\\common\\common.rc"
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/src/SetupDLL/Setup.vcxproj.filters b/src/SetupDLL/Setup.vcxproj.filters
new file mode 100644
index 00000000..d747363f
--- /dev/null
+++ b/src/SetupDLL/Setup.vcxproj.filters
@@ -0,0 +1,162 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {6073052c-2d95-47a0-95d8-5960d4c1d1c0}
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hpp;hxx;hm;inl;inc;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx
+
+
+ {a540fb0a-850b-4cb9-85f9-ade0112ebb50}
+
+
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files\Common
+
+
+ Source Files\Common
+
+
+ Source Files\Common
+
+
+ Source Files\Common
+
+
+ Source Files\Common
+
+
+ Source Files\Common
+
+
+ Source Files
+
+
+
+
+ Source Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files\Common
+
+
+ Resource Files\Common
+
+
+ Resource Files\Common
+
+
+ Resource Files\Common
+
+
+ Resource Files\Common
+
+
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+
+
+ Resource Files
+
+
+
+
+ Resource Files
+
+
+ Resource Files\Common
+
+
+
\ No newline at end of file
diff --git a/src/SetupDLL/Setup.vcxproj.user b/src/SetupDLL/Setup.vcxproj.user
new file mode 100644
index 00000000..ace9a86a
--- /dev/null
+++ b/src/SetupDLL/Setup.vcxproj.user
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/src/SetupDLL/SetupDLL.def b/src/SetupDLL/SetupDLL.def
new file mode 100644
index 00000000..8a54fa06
--- /dev/null
+++ b/src/SetupDLL/SetupDLL.def
@@ -0,0 +1,7 @@
+LIBRARY VERACRYPTSETUP
+EXPORTS
+ VC_CustomAction_PreInstall
+ VC_CustomAction_PostInstall
+ VC_CustomAction_PreUninstall
+ VC_CustomAction_PostUninstall
+ VC_CustomAction_DoChecks
\ No newline at end of file
diff --git a/src/SetupDLL/SetupDLL.vcproj b/src/SetupDLL/SetupDLL.vcproj
new file mode 100644
index 00000000..a1a6a81f
--- /dev/null
+++ b/src/SetupDLL/SetupDLL.vcproj
@@ -0,0 +1,484 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/SetupDLL/SetupDLL.vcxproj b/src/SetupDLL/SetupDLL.vcxproj
new file mode 100644
index 00000000..374ad866
--- /dev/null
+++ b/src/SetupDLL/SetupDLL.vcxproj
@@ -0,0 +1,279 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ ReleaseCustomEFI
+ Win32
+
+
+ Release
+ Win32
+
+
+
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}
+ Setup
+ Win32Proj
+ SetupDLL
+
+
+
+ DynamicLibrary
+ Unicode
+ Windows7.1SDK
+
+
+ DynamicLibrary
+ Unicode
+ Windows7.1SDK
+
+
+ DynamicLibrary
+ Unicode
+ Windows7.1SDK
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <_ProjectFileVersion>10.0.40219.1
+ Debug\
+ Debug\
+ true
+ true
+ true
+ Release\
+ Release\
+ Release\
+ Release\
+ false
+ false
+ true
+ true
+ VeraCryptSetup
+ VeraCryptSetup
+ VeraCryptSetup
+
+
+
+ Disabled
+ ..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;%(AdditionalIncludeDirectories)
+ SETUP;SETUP_DLL;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;_ATL_NO_DEFAULT_LIBS;%(PreprocessorDefinitions)
+ true
+ EnableFastChecks
+ MultiThreadedDebug
+ true
+
+
+ Level4
+ EditAndContinue
+ 4057;4100;4127;4201;4505;4701;4706;4131;%(DisableSpecificWarnings)
+
+
+ /NODEFAULTLIB:LIBCMTD %(AdditionalOptions)
+ msi.lib;libcmtd.lib;atlsd.lib;mpr.lib;..\Common\Debug\Zip.lib;..\Crypto\Debug\crypto.lib;%(AdditionalDependencies)
+ $(OutDir)VeraCryptSetup.dll
+ RequireAdministrator
+ user32.dll;gdi32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;mpr.dll;%(DelayLoadDLLs)
+ true
+ $(OutDir)Setup.pdb
+ Windows
+ false
+ true
+ MachineX86
+ SetupDLL.def
+
+
+ Setup.manifest;%(AdditionalManifestFiles)
+
+
+ md "..\Debug\Setup Files" 2>NUL:
+copy Debug\VeraCryptSetup.dll "..\Debug\Setup Files\VeraCryptSetup.dll" >NUL:
+
+
+
+
+
+ /w34189 %(AdditionalOptions)
+ MaxSpeed
+ ..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;%(AdditionalIncludeDirectories)
+ SETUP;SETUP_DLL;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;_ATL_NO_DEFAULT_LIBS;%(PreprocessorDefinitions)
+ MultiThreaded
+ true
+
+
+ All
+ $(IntDir)
+ Level4
+ ProgramDatabase
+ 4995;4057;4100;4127;4201;4505;4701;4706;4131;%(DisableSpecificWarnings)
+
+
+ /IGNORE:4089 %(AdditionalOptions)
+ msi.lib;mpr.lib;..\Common\Release\Zip.lib;..\Crypto\Release\crypto.lib;%(AdditionalDependencies)
+ $(OutDir)VeraCryptSetup.dll
+ RequireAdministrator
+ user32.dll;gdi32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;mpr.dll;%(DelayLoadDLLs)
+ true
+ true
+ Windows
+ true
+ true
+ true
+ true
+ MachineX86
+ SetupDLL.def
+
+
+ Setup.manifest;%(AdditionalManifestFiles)
+
+
+ copy Release\VeraCryptSetup.dll "..\Release\Setup Files\VeraCryptSetup.dll"
+
+
+
+
+ /w34189 %(AdditionalOptions)
+ MaxSpeed
+ ..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;%(AdditionalIncludeDirectories)
+ SETUP;VC_EFI_CUSTOM_MODE;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;_ATL_NO_DEFAULT_LIBS;%(PreprocessorDefinitions)
+ MultiThreaded
+ true
+
+
+ All
+ $(IntDir)
+ Level4
+ ProgramDatabase
+ 4057;4100;4127;4201;4505;4701;4706;4131;%(DisableSpecificWarnings)
+
+
+ /IGNORE:4089 %(AdditionalOptions)
+ msi.lib;mpr.lib;..\Common\Release\Zip.lib;..\Crypto\Release\crypto.lib;%(AdditionalDependencies)
+ $(OutDir)VeraCryptSetup.exe
+ RequireAdministrator
+ user32.dll;gdi32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;mpr.dll;%(DelayLoadDLLs)
+ true
+ true
+ Windows
+ true
+ true
+ true
+ true
+ MachineX86
+
+
+ Setup.manifest;%(AdditionalManifestFiles)
+
+
+ copy Release\VeraCryptSetup.dll "..\Release\Setup Files\VeraCryptSetup.dll"
+
+
+ VC_EFI_CUSTOM_MODE;%(PreprocessorDefinitions)
+
+
+
+
+
+
+ CompileAsCpp
+ CompileAsCpp
+ CompileAsCpp
+
+
+
+
+
+ CompileAsCpp
+ CompileAsCpp
+ CompileAsCpp
+
+
+ CompileAsCpp
+ CompileAsCpp
+ CompileAsCpp
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ true
+
+
+
+
+ {8b7f059f-e4c7-4e11-88f5-ee8b8433072e}
+ false
+
+
+ {9715ff1d-599b-4bbc-ad96-bef6e08ff827}
+ false
+
+
+ {9dc1abe2-d18b-48fb-81d2-8c50adc57bcf}
+ false
+
+
+ {e4c40f94-e7f9-4981-86e4-186b46f993f3}
+ false
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/SetupDLL/SetupDLL.vcxproj.filters b/src/SetupDLL/SetupDLL.vcxproj.filters
new file mode 100644
index 00000000..e0429539
--- /dev/null
+++ b/src/SetupDLL/SetupDLL.vcxproj.filters
@@ -0,0 +1,150 @@
+
+
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files\Common
+
+
+ Source Files\Common
+
+
+ Source Files\Common
+
+
+ Source Files\Common
+
+
+ Source Files\Common
+
+
+ Source Files\Common
+
+
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+
+
+ Resource Files
+
+
+ Resource Files\Common
+
+
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files
+
+
+ Resource Files\Common
+
+
+ Resource Files\Common
+
+
+ Resource Files\Common
+
+
+ Resource Files\Common
+
+
+ Resource Files\Common
+
+
+ Source Files
+
+
+ Source Files
+
+
+
+
+ {abfa03d7-3de7-4832-b36d-5b45cd0fc304}
+
+
+ {d912b4b9-7f5e-4063-8af7-4d544dde2233}
+
+
+ {5a0efac0-b028-4388-a278-1fe6dc479d79}
+
+
+ {3cb669f1-3949-43f4-a1e5-3b5d0fd75f76}
+
+
+ {92f9499e-670d-464b-9edf-c1a2c56fb813}
+
+
+
+
+ Resource Files
+
+
+
\ No newline at end of file
diff --git a/src/SetupDLL/SetupDLL.vcxproj.user b/src/SetupDLL/SetupDLL.vcxproj.user
new file mode 100644
index 00000000..ace9a86a
--- /dev/null
+++ b/src/SetupDLL/SetupDLL.vcxproj.user
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/src/SetupDLL/VeraCrypt_setup.bmp b/src/SetupDLL/VeraCrypt_setup.bmp
new file mode 100644
index 00000000..b99619e3
Binary files /dev/null and b/src/SetupDLL/VeraCrypt_setup.bmp differ
diff --git a/src/SetupDLL/VeraCrypt_setup_background.bmp b/src/SetupDLL/VeraCrypt_setup_background.bmp
new file mode 100644
index 00000000..85397e80
Binary files /dev/null and b/src/SetupDLL/VeraCrypt_setup_background.bmp differ
diff --git a/src/Signing/sign-sha256.bat b/src/Signing/sign-sha256.bat
index 99cad96d..7902e66c 100644
--- a/src/Signing/sign-sha256.bat
+++ b/src/Signing/sign-sha256.bat
@@ -1,6 +1,7 @@
PATH=%PATH%;%WSDK81%\bin\x86;C:\Program Files\7-Zip;C:\Program Files (x86)\7-Zip
set VC_VERSION=1.24-Update9
+set VC_VERSION_NBRE=1.24.25
set SIGNINGPATH=%~dp0
cd %SIGNINGPATH%
@@ -9,47 +10,51 @@ call "..\..\doc\chm\create_chm.bat"
cd %SIGNINGPATH%
rem sign using SHA-1
-signtool sign /v /sha1 85aa2e55cfb9c38fe474c58b38e9521450cd9306 /ac DigiCert_Assured_ID_MS_Cross_Cert.crt /fd sha1 /t http://timestamp.verisign.com/scripts/timestamp.dll "..\Release\Setup Files\veracrypt.sys" "..\Release\Setup Files\veracrypt-x64.sys"
+signtool sign /v /sha1 85aa2e55cfb9c38fe474c58b38e9521450cd9306 /ac DigiCert_Assured_ID_MS_Cross_Cert.crt /fd sha1 /t http://timestamp.digicert.com "..\Release\Setup Files\veracrypt.sys" "..\Release\Setup Files\veracrypt-x64.sys"
timeout /t 10
rem sign using SHA-256
signtool sign /v /sha1 04141E4EA6D9343CEC994F6C099DC09BDD8937C9 /ac GlobalSign_R3Cross.cer /as /fd sha256 /tr http://rfc3161timestamp.globalsign.com/advanced /td SHA256 "..\Release\Setup Files\veracrypt.sys" "..\Release\Setup Files\veracrypt-x64.sys"
signtool sign /v /sha1 04141E4EA6D9343CEC994F6C099DC09BDD8937C9 /ac GlobalSign_R3Cross.cer /fd sha256 /tr http://rfc3161timestamp.globalsign.com/advanced /td SHA256 "..\Release\Setup Files\veracrypt-arm64.sys"
-signtool sign /v /sha1 04141E4EA6D9343CEC994F6C099DC09BDD8937C9 /ac GlobalSign_SHA256_EV_CodeSigning_CA.cer /fd sha256 /tr http://rfc3161timestamp.globalsign.com/advanced /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"
-
+signtool sign /v /sha1 04141E4EA6D9343CEC994F6C099DC09BDD8937C9 /ac GlobalSign_SHA256_EV_CodeSigning_CA.cer /fd sha256 /tr http://rfc3161timestamp.globalsign.com/advanced /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"
+rem create setup and MSI
cd "..\Release\Setup Files\"
-
copy ..\..\LICENSE .
copy ..\..\License.txt .
copy ..\..\NOTICE .
-
+copy ..\..\Resources\Texts\License.rtf .
+copy ..\..\Common\VeraCrypt.ico .
+copy ..\..\Setup\VeraCrypt_setup_background.bmp .
+copy ..\..\Setup\VeraCrypt_setup.bmp .
+copy ..\..\Setup\Setup.ico .
del *.xml
rmdir /S /Q Languages
mkdir Languages
copy /V /Y ..\..\..\Translations\*.xml Languages\.
del Languages.zip
7z a -y Languages.zip Languages
-
rmdir /S /Q docs
mkdir docs\html\en
mkdir docs\EFI-DCS
copy /V /Y ..\..\..\doc\html\* docs\html\en\.
copy "..\..\..\doc\chm\VeraCrypt User Guide.chm" docs\.
copy "..\..\..\doc\EFI-DCS\*.pdf" docs\EFI-DCS\.
-
del docs.zip
7z a -y docs.zip docs
-
"VeraCrypt Setup.exe" /p
"VeraCrypt Portable.exe" /p
-
+call build_msi_x64.bat %VC_VERSION_NBRE%
del LICENSE
del License.txt
del NOTICE
+del License.rtf
+del VeraCrypt.ico
+del VeraCrypt_setup_background.bmp
+del VeraCrypt_setup.bmp
+del Setup.ico
del "VeraCrypt User Guide.chm"
-
del Languages.zip
del docs.zip
rmdir /S /Q Languages
@@ -58,6 +63,6 @@ rmdir /S /Q docs
cd %SIGNINGPATH%
rem sign using SHA-256
-signtool sign /v /sha1 04141E4EA6D9343CEC994F6C099DC09BDD8937C9 /ac GlobalSign_SHA256_EV_CodeSigning_CA.cer /fd sha256 /tr http://rfc3161timestamp.globalsign.com/advanced /td SHA256 "..\Release\Setup Files\VeraCrypt Setup %VC_VERSION%.exe" "..\Release\Setup Files\VeraCrypt Portable %VC_VERSION%.exe"
+signtool sign /v /sha1 04141E4EA6D9343CEC994F6C099DC09BDD8937C9 /ac GlobalSign_SHA256_EV_CodeSigning_CA.cer /fd sha256 /tr http://rfc3161timestamp.globalsign.com/advanced /td SHA256 "..\Release\Setup Files\VeraCrypt Setup %VC_VERSION%.exe" "..\Release\Setup Files\VeraCrypt Portable %VC_VERSION%.exe" "..\Release\Setup Files\bin\VeraCrypt_%VC_VERSION_NBRE%_Setup_x64.msi" "..\Release\Setup Files\bin\VeraCrypt_%VC_VERSION_NBRE%_Setup_x64_en-us.msi"
pause
diff --git a/src/Signing/sign.bat b/src/Signing/sign.bat
index f4efacdd..15dca15d 100644
--- a/src/Signing/sign.bat
+++ b/src/Signing/sign.bat
@@ -1,6 +1,7 @@
PATH=%PATH%;%WSDK81%\bin\x86;C:\Program Files\7-Zip;C:\Program Files (x86)\7-Zip
set VC_VERSION=1.24-Update9
+set VC_VERSION_NBRE=1.24.25
set SIGNINGPATH=%~dp0
cd %SIGNINGPATH%
@@ -9,47 +10,51 @@ call "..\..\doc\chm\create_chm.bat"
cd %SIGNINGPATH%
rem sign using SHA-1
-signtool sign /v /sha1 85aa2e55cfb9c38fe474c58b38e9521450cd9306 /ac DigiCert_Assured_ID_MS_Cross_Cert.crt /fd sha1 /t http://timestamp.verisign.com/scripts/timestamp.dll "..\Release\Setup Files\veracrypt.sys" "..\Release\Setup Files\veracrypt-x64.sys"
-signtool sign /v /sha1 85aa2e55cfb9c38fe474c58b38e9521450cd9306 /ac DigiCert_Assured_ID_Code_Signing_CA.cer /fd sha1 /t http://timestamp.verisign.com/scripts/timestamp.dll "..\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"
+signtool sign /v /sha1 85aa2e55cfb9c38fe474c58b38e9521450cd9306 /ac DigiCert_Assured_ID_MS_Cross_Cert.crt /fd sha1 /t http://timestamp.digicert.com "..\Release\Setup Files\veracrypt.sys" "..\Release\Setup Files\veracrypt-x64.sys"
+signtool sign /v /sha1 85aa2e55cfb9c38fe474c58b38e9521450cd9306 /ac DigiCert_Assured_ID_Code_Signing_CA.cer /fd sha1 /t http://timestamp.digicert.com "..\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 COMReg.exe"
timeout /t 10
rem sign using SHA-256
signtool sign /v /sha1 04141E4EA6D9343CEC994F6C099DC09BDD8937C9 /ac GlobalSign_R3Cross.cer /as /fd sha256 /tr http://rfc3161timestamp.globalsign.com/advanced /td SHA256 "..\Release\Setup Files\veracrypt.sys" "..\Release\Setup Files\veracrypt-x64.sys"
-signtool sign /v /sha1 04141E4EA6D9343CEC994F6C099DC09BDD8937C9 /ac GlobalSign_SHA256_EV_CodeSigning_CA.cer /as /fd sha256 /tr http://rfc3161timestamp.globalsign.com/advanced /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"
-
+signtool sign /v /sha1 04141E4EA6D9343CEC994F6C099DC09BDD8937C9 /ac GlobalSign_SHA256_EV_CodeSigning_CA.cer /as /fd sha256 /tr http://rfc3161timestamp.globalsign.com/advanced /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 COMReg.exe"
+rem create setup and MSI
cd "..\Release\Setup Files\"
-
copy ..\..\LICENSE .
copy ..\..\License.txt .
copy ..\..\NOTICE .
-
+copy ..\..\Resources\Texts\License.rtf .
+copy ..\..\Common\VeraCrypt.ico .
+copy ..\..\Setup\VeraCrypt_setup_background.bmp .
+copy ..\..\Setup\VeraCrypt_setup.bmp .
+copy ..\..\Setup\Setup.ico .
del *.xml
rmdir /S /Q Languages
mkdir Languages
copy /V /Y ..\..\..\Translations\*.xml Languages\.
del Languages.zip
7z a -y Languages.zip Languages
-
rmdir /S /Q docs
mkdir docs\html\en
mkdir docs\EFI-DCS
copy /V /Y ..\..\..\doc\html\* docs\html\en\.
copy "..\..\..\doc\chm\VeraCrypt User Guide.chm" docs\.
copy "..\..\..\doc\EFI-DCS\*.pdf" docs\EFI-DCS\.
-
del docs.zip
7z a -y docs.zip docs
-
"VeraCrypt Setup.exe" /p
"VeraCrypt Portable.exe" /p
-
+call build_msi_x64.bat %VC_VERSION_NBRE%
del LICENSE
del License.txt
del NOTICE
+del License.rtf
+del VeraCrypt.ico
+del VeraCrypt_setup_background.bmp
+del VeraCrypt_setup.bmp
+del Setup.ico
del "VeraCrypt User Guide.chm"
-
del Languages.zip
del docs.zip
rmdir /S /Q Languages
@@ -57,13 +62,18 @@ rmdir /S /Q docs
cd %SIGNINGPATH%
+rem Can't dual-sign MSI files when using signtool (only jsign / osslsigncode can do that)
+
rem sign using SHA-1
-signtool sign /v /sha1 85aa2e55cfb9c38fe474c58b38e9521450cd9306 /ac DigiCert_Assured_ID_Code_Signing_CA.cer /fd sha1 /t http://timestamp.verisign.com/scripts/timestamp.dll "..\Release\Setup Files\VeraCrypt Setup %VC_VERSION%.exe" "..\Release\Setup Files\VeraCrypt Portable %VC_VERSION%.exe"
+signtool sign /v /sha1 85aa2e55cfb9c38fe474c58b38e9521450cd9306 /ac DigiCert_Assured_ID_Code_Signing_CA.cer /fd sha1 /t http://timestamp.digicert.com "..\Release\Setup Files\VeraCrypt Setup %VC_VERSION%.exe" "..\Release\Setup Files\VeraCrypt Portable %VC_VERSION%.exe"
timeout /t 10
-rem sign using SHA-256
-signtool sign /v /sha1 04141E4EA6D9343CEC994F6C099DC09BDD8937C9 /ac GlobalSign_SHA256_EV_CodeSigning_CA.cer /as /fd sha256 /tr http://rfc3161timestamp.globalsign.com/advanced /td SHA256 "..\Release\Setup Files\VeraCrypt Setup %VC_VERSION%.exe" "..\Release\Setup Files\VeraCrypt Portable %VC_VERSION%.exe"
+rem dual sign Setup using SHA-256
+signtool sign /v /sha1 04141E4EA6D9343CEC994F6C099DC09BDD8937C9 /ac GlobalSign_SHA256_EV_CodeSigning_CA.cer /as /fd sha256 /tr http://rfc3161timestamp.globalsign.com/advanced /td SHA256 "..\Release\Setup Files\VeraCrypt Setup %VC_VERSION%.exe" "..\Release\Setup Files\VeraCrypt Portable %VC_VERSION%.exe" "..\Release\Setup Files\bin\VeraCrypt_%VC_VERSION_NBRE%_Setup_x64.msi" "..\Release\Setup Files\bin\VeraCrypt_%VC_VERSION_NBRE%_Setup_x64_en-us.msi"
+
+rem single sign MSI using SHA-256
+signtool sign /v /sha1 04141E4EA6D9343CEC994F6C099DC09BDD8937C9 /ac GlobalSign_SHA256_EV_CodeSigning_CA.cer /fd sha256 /tr http://rfc3161timestamp.globalsign.com/advanced /td SHA256 "..\Release\Setup Files\bin\VeraCrypt_%VC_VERSION_NBRE%_Setup_x64.msi" "..\Release\Setup Files\bin\VeraCrypt_%VC_VERSION_NBRE%_Setup_x64_en-us.msi"
move "..\Release\Setup Files\VeraCrypt Setup %VC_VERSION%.exe" "..\Release\Setup Files\VeraCrypt Legacy Setup %VC_VERSION%.exe"
move "..\Release\Setup Files\VeraCrypt Portable %VC_VERSION%.exe" "..\Release\Setup Files\VeraCrypt Legacy Portable %VC_VERSION%.exe"
diff --git a/src/Signing/sign_test.bat b/src/Signing/sign_test.bat
index 858e545f..9e4b2e87 100644
--- a/src/Signing/sign_test.bat
+++ b/src/Signing/sign_test.bat
@@ -1,5 +1,6 @@
PATH=%PATH%;%WSDK81%\bin\x86;C:\Program Files\7-Zip;C:\Program Files (x86)\7-Zip
set VC_VERSION=1.24-Update9
+set VC_VERSION_NBRE=1.24.25
set PFXNAME=TestCertificate\idrix_codeSign.pfx
set PFXPASSWORD=idrix
set PFXCA=TestCertificate\idrix_TestRootCA.crt
@@ -15,43 +16,48 @@ call "..\..\doc\chm\create_chm.bat"
cd %SIGNINGPATH%
rem sign using SHA-1
-signtool sign /v /a /f %PFXNAME% /p %PFXPASSWORD% /ac %PFXCA% /fd sha1 /t http://timestamp.verisign.com/scripts/timestamp.dll "..\Release\Setup Files\veracrypt.sys" "..\Release\Setup Files\veracrypt-x64.sys" "..\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"
+signtool sign /v /a /f %PFXNAME% /p %PFXPASSWORD% /ac %PFXCA% /fd sha1 /t http://timestamp.digicert.com "..\Release\Setup Files\veracrypt.sys" "..\Release\Setup Files\veracrypt-x64.sys" "..\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 COMReg.exe"
timeout /t 10
rem sign using SHA-256
-signtool sign /v /a /f %SHA256PFXNAME% /p %SHA256PFXPASSWORD% /ac %SHA256PFXCA% /as /fd sha256 /tr http://rfc3161timestamp.globalsign.com/advanced /td SHA256 "..\Release\Setup Files\veracrypt.sys" "..\Release\Setup Files\veracrypt-x64.sys" "..\Release\Setup Files\veracrypt-arm64.sys" "..\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"
+signtool sign /v /a /f %SHA256PFXNAME% /p %SHA256PFXPASSWORD% /ac %SHA256PFXCA% /as /fd sha256 /tr http://rfc3161timestamp.globalsign.com/advanced /td SHA256 "..\Release\Setup Files\veracrypt.sys" "..\Release\Setup Files\veracrypt-x64.sys" "..\Release\Setup Files\veracrypt-arm64.sys" "..\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"
+rem create setup and MSI
cd "..\Release\Setup Files\"
-
copy ..\..\LICENSE .
copy ..\..\License.txt .
copy ..\..\NOTICE .
-
+copy ..\..\Resources\Texts\License.rtf .
+copy ..\..\Common\VeraCrypt.ico .
+copy ..\..\Setup\VeraCrypt_setup_background.bmp .
+copy ..\..\Setup\VeraCrypt_setup.bmp .
+copy ..\..\Setup\Setup.ico .
del *.xml
rmdir /S /Q Languages
mkdir Languages
copy /V /Y ..\..\..\Translations\*.xml Languages\.
del Languages.zip
7z a -y Languages.zip Languages
-
rmdir /S /Q docs
mkdir docs\html\en
mkdir docs\EFI-DCS
copy /V /Y ..\..\..\doc\html\* docs\html\en\.
copy "..\..\..\doc\chm\VeraCrypt User Guide.chm" docs\.
copy "..\..\..\doc\EFI-DCS\*.pdf" docs\EFI-DCS\.
-
del docs.zip
7z a -y docs.zip docs
-
"VeraCrypt Setup.exe" /p
-
+call build_msi_x64.bat %VC_VERSION_NBRE%
del LICENSE
del License.txt
del NOTICE
+del License.rtf
+del VeraCrypt.ico
+del VeraCrypt_setup_background.bmp
+del VeraCrypt_setup.bmp
+del Setup.ico
del "VeraCrypt User Guide.chm"
-
del Languages.zip
del docs.zip
rmdir /S /Q Languages
@@ -59,12 +65,17 @@ rmdir /S /Q docs
cd %SIGNINGPATH%
+rem Can't dual-sign MSI files when using signtool (only jsign / osslsigncode can do that)
+
rem sign using SHA-1
-signtool sign /v /a /f %PFXNAME% /p %PFXPASSWORD% /ac %PFXCA% /fd sha1 /t http://timestamp.verisign.com/scripts/timestamp.dll "..\Release\Setup Files\VeraCrypt Setup %VC_VERSION%.exe"
+signtool sign /v /a /f %PFXNAME% /p %PFXPASSWORD% /ac %PFXCA% /fd sha1 /t http://timestamp.digicert.com "..\Release\Setup Files\VeraCrypt Setup %VC_VERSION%.exe"
timeout /t 10
-rem sign using SHA-256
+rem dual-sign Setup using SHA-256
signtool sign /v /a /f %SHA256PFXNAME% /p %SHA256PFXPASSWORD% /ac %SHA256PFXCA% /as /fd sha256 /tr http://rfc3161timestamp.globalsign.com/advanced /td SHA256 "..\Release\Setup Files\VeraCrypt Setup %VC_VERSION%.exe"
+rem single sign MSI using SHA-256
+signtool sign /v /a /f %SHA256PFXNAME% /p %SHA256PFXPASSWORD% /ac %SHA256PFXCA% /fd sha256 /tr http://rfc3161timestamp.globalsign.com/advanced /td SHA256 "..\Release\Setup Files\bin\VeraCrypt_%VC_VERSION_NBRE%_Setup_x64.msi" "..\Release\Setup Files\bin\VeraCrypt_%VC_VERSION_NBRE%_Setup_x64_en-us.msi"
+
pause
\ No newline at end of file
diff --git a/src/Signing/sign_test_debug.bat b/src/Signing/sign_test_debug.bat
index 9cf8e562..4b5e33ac 100644
--- a/src/Signing/sign_test_debug.bat
+++ b/src/Signing/sign_test_debug.bat
@@ -1,5 +1,6 @@
PATH=%PATH%;%WSDK81%\bin\x86;C:\Program Files\7-Zip;C:\Program Files (x86)\7-Zip
set VC_VERSION=1.24-Update9
+set VC_VERSION_NBRE=1.24.25
set PFXNAME=TestCertificate\idrix_codeSign.pfx
set PFXPASSWORD=idrix
set PFXCA=TestCertificate\idrix_TestRootCA.crt
@@ -15,26 +16,29 @@ call "..\..\doc\chm\create_chm.bat"
cd %SIGNINGPATH%
rem sign using SHA-1
-signtool sign /v /a /f %PFXNAME% /p %PFXPASSWORD% /ac %PFXCA% /fd sha1 /t http://timestamp.verisign.com/scripts/timestamp.dll "..\Debug\Setup Files\veracrypt.sys" "..\Debug\Setup Files\veracrypt-x64.sys" "..\Debug\Setup Files\VeraCrypt.exe" "..\Debug\Setup Files\VeraCrypt Format.exe" "..\Debug\Setup Files\VeraCryptExpander.exe" "..\Debug\Setup Files\VeraCrypt-x64.exe" "..\Debug\Setup Files\VeraCrypt Format-x64.exe" "..\Debug\Setup Files\VeraCryptExpander-x64.exe"
+signtool sign /v /a /f %PFXNAME% /p %PFXPASSWORD% /ac %PFXCA% /fd sha1 /t http://timestamp.digicert.com "..\Debug\Setup Files\veracrypt.sys" "..\Debug\Setup Files\veracrypt-x64.sys" "..\Debug\Setup Files\VeraCrypt.exe" "..\Debug\Setup Files\VeraCrypt Format.exe" "..\Debug\Setup Files\VeraCryptExpander.exe" "..\Debug\Setup Files\VeraCrypt-x64.exe" "..\Debug\Setup Files\VeraCrypt Format-x64.exe" "..\Debug\Setup Files\VeraCryptExpander-x64.exe" "..\Debug\Setup Files\VeraCrypt COMReg.exe"
timeout /t 10
rem sign using SHA-256
-signtool sign /v /a /f %SHA256PFXNAME% /p %SHA256PFXPASSWORD% /ac %SHA256PFXCA% /as /fd sha256 /tr http://rfc3161timestamp.globalsign.com/advanced /td SHA256 "..\Debug\Setup Files\veracrypt.sys" "..\Debug\Setup Files\veracrypt-x64.sys" "..\Debug\Setup Files\veracrypt-arm64.sys" "..\Debug\Setup Files\VeraCrypt.exe" "..\Debug\Setup Files\VeraCrypt Format.exe" "..\Debug\Setup Files\VeraCryptExpander.exe" "..\Debug\Setup Files\VeraCrypt-x64.exe" "..\Debug\Setup Files\VeraCrypt Format-x64.exe" "..\Debug\Setup Files\VeraCryptExpander-x64.exe" "..\Debug\Setup Files\VeraCrypt-arm64.exe" "..\Debug\Setup Files\VeraCrypt Format-arm64.exe" "..\Debug\Setup Files\VeraCryptExpander-arm64.exe"
+signtool sign /v /a /f %SHA256PFXNAME% /p %SHA256PFXPASSWORD% /ac %SHA256PFXCA% /as /fd sha256 /tr http://rfc3161timestamp.globalsign.com/advanced /td SHA256 "..\Debug\Setup Files\veracrypt.sys" "..\Debug\Setup Files\veracrypt-x64.sys" "..\Debug\Setup Files\veracrypt-arm64.sys" "..\Debug\Setup Files\VeraCrypt.exe" "..\Debug\Setup Files\VeraCrypt Format.exe" "..\Debug\Setup Files\VeraCryptExpander.exe" "..\Debug\Setup Files\VeraCrypt-x64.exe" "..\Debug\Setup Files\VeraCrypt Format-x64.exe" "..\Debug\Setup Files\VeraCryptExpander-x64.exe" "..\Debug\Setup Files\VeraCrypt-arm64.exe" "..\Debug\Setup Files\VeraCrypt Format-arm64.exe" "..\Debug\Setup Files\VeraCryptExpander-arm64.exe" "..\Debug\Setup Files\VeraCrypt COMReg.exe"
+rem create setup and MSI
cd "..\Debug\Setup Files\"
-
copy ..\..\LICENSE .
copy ..\..\License.txt .
copy ..\..\NOTICE .
-
+copy ..\..\Resources\Texts\License.rtf .
+copy ..\..\Common\VeraCrypt.ico .
+copy ..\..\Setup\VeraCrypt_setup_background.bmp .
+copy ..\..\Setup\VeraCrypt_setup.bmp .
+copy ..\..\Setup\Setup.ico .
del *.xml
rmdir /S /Q Languages
mkdir Languages
copy /V /Y ..\..\..\Translations\*.xml Languages\.
del Languages.zip
7z a -y Languages.zip Languages
-
rmdir /S /Q docs
mkdir docs\html\en
mkdir docs\EFI-DCS
@@ -43,17 +47,19 @@ copy "..\..\..\doc\chm\VeraCrypt User Guide.chm" docs\.
copy "..\..\..\doc\EFI-DCS\*.pdf" docs\EFI-DCS\.
copy "..\..\Release\Setup Files\*.cat" .
copy "..\..\Release\Setup Files\veracrypt.inf" .
-
del docs.zip
7z a -y docs.zip docs
-
"VeraCrypt Setup.exe" /p
-
+call build_msi_x64.bat %VC_VERSION_NBRE%
del LICENSE
del License.txt
del NOTICE
+del License.rtf
+del VeraCrypt.ico
+del VeraCrypt_setup_background.bmp
+del VeraCrypt_setup.bmp
+del Setup.ico
del "VeraCrypt User Guide.chm"
-
del Languages.zip
del docs.zip
rmdir /S /Q Languages
@@ -61,12 +67,17 @@ rmdir /S /Q docs
cd %SIGNINGPATH%
+rem Can't dual-sign MSI files when using signtool (only jsign / osslsigncode can do that)
+
rem sign using SHA-1
-signtool sign /v /a /f %PFXNAME% /p %PFXPASSWORD% /ac %PFXCA% /fd sha1 /t http://timestamp.verisign.com/scripts/timestamp.dll "..\Debug\Setup Files\VeraCrypt Setup %VC_VERSION%.exe"
+signtool sign /v /a /f %PFXNAME% /p %PFXPASSWORD% /ac %PFXCA% /fd sha1 /t http://timestamp.digicert.com "..\Debug\Setup Files\VeraCrypt Setup %VC_VERSION%.exe"
timeout /t 10
-rem sign using SHA-256
+rem dual-sign Setup using SHA-256
signtool sign /v /a /f %SHA256PFXNAME% /p %SHA256PFXPASSWORD% /ac %SHA256PFXCA% /as /fd sha256 /tr http://rfc3161timestamp.globalsign.com/advanced /td SHA256 "..\Debug\Setup Files\VeraCrypt Setup %VC_VERSION%.exe"
+rem single sign MSI using SHA-256
+signtool sign /v /a /f %SHA256PFXNAME% /p %SHA256PFXPASSWORD% /ac %SHA256PFXCA% /fd sha256 /tr http://rfc3161timestamp.globalsign.com/advanced /td SHA256 "..\Debug\Setup Files\bin\VeraCrypt_%VC_VERSION_NBRE%_Setup_x64.msi" "..\Debug\Setup Files\bin\VeraCrypt_%VC_VERSION_NBRE%_Setup_x64_en-us.msi"
+
pause
\ No newline at end of file
diff --git a/src/VeraCrypt.sln b/src/VeraCrypt.sln
index 6f373bcd..c7a31445 100644
--- a/src/VeraCrypt.sln
+++ b/src/VeraCrypt.sln
@@ -33,6 +33,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Portable", "Setup\Portable.
{6316EE71-0210-4CA4-BCC7-CFB7A3C090FC} = {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}
EndProjectSection
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SetupDLL", "SetupDLL\SetupDLL.vcxproj", "{ADD324E2-ADC8-402E-87EB-03E4E26B1B49}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
All CustomEFI|Win32 = All CustomEFI|Win32
@@ -73,6 +75,8 @@ Global
Portable|x64 = Portable|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
+ ReleaseCustomEFI|Win32 = ReleaseCustomEFI|Win32
+ ReleaseCustomEFI|x64 = ReleaseCustomEFI|x64
Setup Debug|Win32 = Setup Debug|Win32
Setup Debug|x64 = Setup Debug|x64
Setup|Win32 = Setup|Win32
@@ -145,6 +149,9 @@ Global
{993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Release|Win32.Build.0 = Release|Win32
{993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Release|x64.ActiveCfg = Release|x64
{993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Release|x64.Build.0 = Release|x64
+ {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.ReleaseCustomEFI|Win32.ActiveCfg = Release|x64
+ {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.ReleaseCustomEFI|x64.ActiveCfg = Release|x64
+ {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.ReleaseCustomEFI|x64.Build.0 = Release|x64
{993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Setup Debug|Win32.ActiveCfg = Debug|Win32
{993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Setup Debug|x64.ActiveCfg = Debug|x64
{993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Setup Debug|x64.Build.0 = Debug|x64
@@ -200,6 +207,9 @@ Global
{EF5EF444-18D0-40D7-8DFA-775EC4448602}.Release|Win32.ActiveCfg = Release|Win32
{EF5EF444-18D0-40D7-8DFA-775EC4448602}.Release|Win32.Build.0 = Release|Win32
{EF5EF444-18D0-40D7-8DFA-775EC4448602}.Release|x64.ActiveCfg = Release|Win32
+ {EF5EF444-18D0-40D7-8DFA-775EC4448602}.ReleaseCustomEFI|Win32.ActiveCfg = Release|Win32
+ {EF5EF444-18D0-40D7-8DFA-775EC4448602}.ReleaseCustomEFI|Win32.Build.0 = Release|Win32
+ {EF5EF444-18D0-40D7-8DFA-775EC4448602}.ReleaseCustomEFI|x64.ActiveCfg = Release|Win32
{EF5EF444-18D0-40D7-8DFA-775EC4448602}.Setup Debug|Win32.ActiveCfg = Debug|Win32
{EF5EF444-18D0-40D7-8DFA-775EC4448602}.Setup Debug|x64.ActiveCfg = Debug|Win32
{EF5EF444-18D0-40D7-8DFA-775EC4448602}.Setup|Win32.ActiveCfg = Release|Win32
@@ -268,6 +278,10 @@ Global
{9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Release|Win32.Build.0 = Release|Win32
{9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Release|x64.ActiveCfg = Release|x64
{9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Release|x64.Build.0 = Release|x64
+ {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.ReleaseCustomEFI|Win32.ActiveCfg = ReleaseCustomEFI|Win32
+ {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.ReleaseCustomEFI|Win32.Build.0 = ReleaseCustomEFI|Win32
+ {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.ReleaseCustomEFI|x64.ActiveCfg = ReleaseCustomEFI|x64
+ {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.ReleaseCustomEFI|x64.Build.0 = ReleaseCustomEFI|x64
{9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Setup Debug|Win32.ActiveCfg = Debug|Win32
{9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Setup Debug|x64.ActiveCfg = Debug|x64
{9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Setup Debug|x64.Build.0 = Debug|x64
@@ -338,6 +352,10 @@ Global
{E4C40F94-E7F9-4981-86E4-186B46F993F3}.Release|Win32.Build.0 = Release|Win32
{E4C40F94-E7F9-4981-86E4-186B46F993F3}.Release|x64.ActiveCfg = Release|x64
{E4C40F94-E7F9-4981-86E4-186B46F993F3}.Release|x64.Build.0 = Release|x64
+ {E4C40F94-E7F9-4981-86E4-186B46F993F3}.ReleaseCustomEFI|Win32.ActiveCfg = ReleaseCustomEFI|Win32
+ {E4C40F94-E7F9-4981-86E4-186B46F993F3}.ReleaseCustomEFI|Win32.Build.0 = ReleaseCustomEFI|Win32
+ {E4C40F94-E7F9-4981-86E4-186B46F993F3}.ReleaseCustomEFI|x64.ActiveCfg = ReleaseCustomEFI|x64
+ {E4C40F94-E7F9-4981-86E4-186B46F993F3}.ReleaseCustomEFI|x64.Build.0 = ReleaseCustomEFI|x64
{E4C40F94-E7F9-4981-86E4-186B46F993F3}.Setup Debug|Win32.ActiveCfg = Debug|Win32
{E4C40F94-E7F9-4981-86E4-186B46F993F3}.Setup Debug|x64.ActiveCfg = Debug|x64
{E4C40F94-E7F9-4981-86E4-186B46F993F3}.Setup Debug|x64.Build.0 = Debug|x64
@@ -389,6 +407,9 @@ Global
{DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Release|Win32.ActiveCfg = Release|Win32
{DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Release|Win32.Build.0 = Release|Win32
{DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Release|x64.ActiveCfg = Release|Win32
+ {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.ReleaseCustomEFI|Win32.ActiveCfg = ReleaseCustomEFI|Win32
+ {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.ReleaseCustomEFI|Win32.Build.0 = ReleaseCustomEFI|Win32
+ {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.ReleaseCustomEFI|x64.ActiveCfg = ReleaseCustomEFI|Win32
{DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Setup Debug|Win32.ActiveCfg = Debug|Win32
{DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Setup Debug|Win32.Build.0 = Debug|Win32
{DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Setup Debug|x64.ActiveCfg = Debug|Win32
@@ -440,6 +461,9 @@ Global
{8B7F059F-E4C7-4E11-88F5-EE8B8433072E}.Release|Win32.ActiveCfg = Release|Win32
{8B7F059F-E4C7-4E11-88F5-EE8B8433072E}.Release|Win32.Build.0 = Release|Win32
{8B7F059F-E4C7-4E11-88F5-EE8B8433072E}.Release|x64.ActiveCfg = Release|Win32
+ {8B7F059F-E4C7-4E11-88F5-EE8B8433072E}.ReleaseCustomEFI|Win32.ActiveCfg = Release|Win32
+ {8B7F059F-E4C7-4E11-88F5-EE8B8433072E}.ReleaseCustomEFI|Win32.Build.0 = Release|Win32
+ {8B7F059F-E4C7-4E11-88F5-EE8B8433072E}.ReleaseCustomEFI|x64.ActiveCfg = Release|Win32
{8B7F059F-E4C7-4E11-88F5-EE8B8433072E}.Setup Debug|Win32.ActiveCfg = Release|Win32
{8B7F059F-E4C7-4E11-88F5-EE8B8433072E}.Setup Debug|x64.ActiveCfg = Release Loader|Win32
{8B7F059F-E4C7-4E11-88F5-EE8B8433072E}.Setup|Win32.ActiveCfg = Release|Win32
@@ -518,6 +542,10 @@ Global
{9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Release|Win32.Build.0 = Release|Win32
{9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Release|x64.ActiveCfg = Release|x64
{9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Release|x64.Build.0 = Release|x64
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.ReleaseCustomEFI|Win32.ActiveCfg = ReleaseCustomEFI|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.ReleaseCustomEFI|Win32.Build.0 = ReleaseCustomEFI|Win32
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.ReleaseCustomEFI|x64.ActiveCfg = ReleaseCustomEFI|x64
+ {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.ReleaseCustomEFI|x64.Build.0 = ReleaseCustomEFI|x64
{9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Setup Debug|Win32.ActiveCfg = Debug|Win32
{9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Setup Debug|Win32.Build.0 = Debug|Win32
{9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Setup Debug|x64.ActiveCfg = Debug|x64
@@ -585,6 +613,9 @@ Global
{6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Release|Win32.ActiveCfg = Release|Win32
{6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Release|Win32.Build.0 = Release|Win32
{6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Release|x64.ActiveCfg = Release|Win32
+ {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.ReleaseCustomEFI|Win32.ActiveCfg = Release|x64
+ {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.ReleaseCustomEFI|x64.ActiveCfg = Release|x64
+ {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.ReleaseCustomEFI|x64.Build.0 = Release|x64
{6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Setup Debug|Win32.ActiveCfg = Debug|Win32
{6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Setup Debug|Win32.Build.0 = Debug|Win32
{6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Setup Debug|x64.ActiveCfg = Debug|Win32
@@ -648,12 +679,81 @@ Global
{60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Release|Win32.ActiveCfg = Release|Win32
{60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Release|Win32.Build.0 = Release|Win32
{60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Release|x64.ActiveCfg = Release|Win32
+ {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.ReleaseCustomEFI|Win32.ActiveCfg = ReleaseCustomEFI|Win32
+ {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.ReleaseCustomEFI|Win32.Build.0 = ReleaseCustomEFI|Win32
+ {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.ReleaseCustomEFI|x64.ActiveCfg = ReleaseCustomEFI|Win32
{60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Setup Debug|Win32.ActiveCfg = Debug|Win32
{60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Setup Debug|Win32.Build.0 = Debug|Win32
{60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Setup Debug|x64.ActiveCfg = Debug|Win32
{60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Setup|Win32.ActiveCfg = Release|Win32
{60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Setup|Win32.Build.0 = Release|Win32
{60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Setup|x64.ActiveCfg = Release|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.All CustomEFI|Win32.ActiveCfg = Release|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.All CustomEFI|Win32.Build.0 = Release|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.All CustomEFI|x64.ActiveCfg = Release|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.All Debug|Win32.ActiveCfg = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.All Debug|Win32.Build.0 = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.All Debug|x64.ActiveCfg = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.All|Win32.ActiveCfg = Release|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.All|Win32.Build.0 = Release|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.All|x64.ActiveCfg = Release|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Boot Loader|Win32.ActiveCfg = Release|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Boot Loader|Win32.Build.0 = Release|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Boot Loader|x64.ActiveCfg = Release|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Boot|Win32.ActiveCfg = Release|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Boot|Win32.Build.0 = Release|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Boot|x64.ActiveCfg = Release|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Debug|Win32.ActiveCfg = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Debug|Win32.Build.0 = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Debug|x64.ActiveCfg = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver Debug|Win32.ActiveCfg = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver Debug|Win32.Build.0 = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver Debug|x64.ActiveCfg = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x64 Debug|Win32.ActiveCfg = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x64 Debug|Win32.Build.0 = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x64 Debug|x64.ActiveCfg = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x64|Win32.ActiveCfg = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x64|Win32.Build.0 = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x64|x64.ActiveCfg = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x86 Debug|Win32.ActiveCfg = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x86 Debug|Win32.Build.0 = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x86 Debug|x64.ActiveCfg = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x86|Win32.ActiveCfg = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x86|Win32.Build.0 = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x86|x64.ActiveCfg = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver|Win32.ActiveCfg = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver|Win32.Build.0 = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver|x64.ActiveCfg = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Format Debug|Win32.ActiveCfg = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Format Debug|Win32.Build.0 = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Format Debug|x64.ActiveCfg = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Format|Win32.ActiveCfg = Release|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Format|Win32.Build.0 = Release|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Format|x64.ActiveCfg = Release|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Mount Debug|Win32.ActiveCfg = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Mount Debug|Win32.Build.0 = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Mount Debug|x64.ActiveCfg = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Mount|Win32.ActiveCfg = Release|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Mount|Win32.Build.0 = Release|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Mount|x64.ActiveCfg = Release|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Portable Debug|Win32.ActiveCfg = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Portable Debug|Win32.Build.0 = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Portable Debug|x64.ActiveCfg = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Portable|Win32.ActiveCfg = Release|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Portable|Win32.Build.0 = Release|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Portable|x64.ActiveCfg = Release|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Release|Win32.ActiveCfg = Release|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Release|Win32.Build.0 = Release|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Release|x64.ActiveCfg = Release|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.ReleaseCustomEFI|Win32.ActiveCfg = ReleaseCustomEFI|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.ReleaseCustomEFI|Win32.Build.0 = ReleaseCustomEFI|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.ReleaseCustomEFI|x64.ActiveCfg = ReleaseCustomEFI|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Setup Debug|Win32.ActiveCfg = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Setup Debug|Win32.Build.0 = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Setup Debug|x64.ActiveCfg = Debug|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Setup|Win32.ActiveCfg = Release|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Setup|Win32.Build.0 = Release|Win32
+ {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Setup|x64.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE