Windows: implement compatibility for Windows 10 major updates using ReflectDrivers mechanism whose support started from Windows 10 version 1607.
This commit is contained in:
parent
cce74aaee0
commit
4519bb494e
|
@ -429,5 +429,29 @@ DWORD BaseCom::WriteEfiBootSectorUserConfig (DWORD userConfig, BSTR customUserMe
|
|||
return ERROR_EXCEPTION_IN_SERVICE;
|
||||
}
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
DWORD BaseCom::UpdateSetupConfigFile (BOOL bForInstall)
|
||||
{
|
||||
try
|
||||
{
|
||||
BootEncryption bootEnc (NULL);
|
||||
bootEnc.UpdateSetupConfigFile (bForInstall? true : false);
|
||||
}
|
||||
catch (SystemException &)
|
||||
{
|
||||
return GetLastError();
|
||||
}
|
||||
catch (Exception &e)
|
||||
{
|
||||
e.Show (NULL);
|
||||
return ERROR_EXCEPTION_IN_SERVICE;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return ERROR_EXCEPTION_IN_SERVICE;
|
||||
}
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
|
@ -117,6 +117,7 @@ public:
|
|||
static DWORD RestoreEfiSystemLoader ();
|
||||
static DWORD GetEfiBootDeviceNumber (BSTR* pSdn);
|
||||
static DWORD WriteEfiBootSectorUserConfig (DWORD userConfig, BSTR customUserMessage, int pim, int hashAlg);
|
||||
static DWORD UpdateSetupConfigFile (BOOL bForInstall);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -396,6 +396,18 @@ namespace VeraCrypt
|
|||
}
|
||||
}
|
||||
|
||||
static void UpdateSetupConfigFile (bool bForInstall)
|
||||
{
|
||||
Elevate();
|
||||
|
||||
DWORD result = ElevatedComInstance->UpdateSetupConfigFile (bForInstall ? TRUE : FALSE);
|
||||
if (result != ERROR_SUCCESS)
|
||||
{
|
||||
SetLastError (result);
|
||||
throw SystemException(SRC_POS);
|
||||
}
|
||||
}
|
||||
|
||||
static void Release ()
|
||||
{
|
||||
if (--ReferenceCount == 0 && ElevatedComInstance)
|
||||
|
@ -470,6 +482,7 @@ namespace VeraCrypt
|
|||
static void RestoreEfiSystemLoader () { throw ParameterIncorrect (SRC_POS); }
|
||||
static void GetEfiBootDeviceNumber (PSTORAGE_DEVICE_NUMBER pSdn) { throw ParameterIncorrect (SRC_POS); }
|
||||
static void WriteEfiBootSectorUserConfig (byte userConfig, const string &customUserMessage, int pim, int hashAlg) { throw ParameterIncorrect (SRC_POS); }
|
||||
static void UpdateSetupConfigFile (bool bForInstall) { throw ParameterIncorrect (SRC_POS); }
|
||||
};
|
||||
|
||||
#endif // SETUP
|
||||
|
@ -2685,6 +2698,27 @@ namespace VeraCrypt
|
|||
return conf.Save (path.c_str(), hwndDlg);
|
||||
}
|
||||
|
||||
void BootEncryption::UpdateSetupConfigFile (bool bForInstall)
|
||||
{
|
||||
// starting from Windows 10 1607 (Build 14393), ReflectDrivers in Setupconfig.ini is supported
|
||||
if (IsOSVersionAtLeast (WIN_10, 0) && CurrentOSBuildNumber >= 14393)
|
||||
{
|
||||
wchar_t szInstallPath [TC_MAX_PATH];
|
||||
wchar_t szSetupconfigLocation [TC_MAX_PATH + 20];
|
||||
|
||||
if (bForInstall)
|
||||
GetInstallationPath (NULL, szInstallPath, ARRAYSIZE (szInstallPath), NULL);
|
||||
if (GetSetupconfigLocation (szSetupconfigLocation, ARRAYSIZE (szSetupconfigLocation)))
|
||||
{
|
||||
::CreateDirectoryW (szSetupconfigLocation, NULL);
|
||||
|
||||
StringCchCatW (szSetupconfigLocation, ARRAYSIZE (szSetupconfigLocation), L"SetupConfig.ini");
|
||||
|
||||
WritePrivateProfileStringW (L"SetupConfig", L"ReflectDrivers", bForInstall? szInstallPath : NULL, szSetupconfigLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BootEncryption::InstallBootLoader (bool preserveUserConfig, bool hiddenOSCreation, int pim, int hashAlg)
|
||||
{
|
||||
Device device (GetSystemDriveConfiguration().DevicePath);
|
||||
|
@ -2851,6 +2885,15 @@ namespace VeraCrypt
|
|||
device.SeekAt (TC_SECTOR_SIZE_BIOS);
|
||||
device.Write (bootLoaderBuf + TC_SECTOR_SIZE_BIOS, sizeof (bootLoaderBuf) - TC_SECTOR_SIZE_BIOS);
|
||||
}
|
||||
|
||||
if (!IsAdmin() && IsUacSupported())
|
||||
{
|
||||
Elevator::UpdateSetupConfigFile (true);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateSetupConfigFile (true);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef SETUP
|
||||
|
@ -3786,6 +3829,22 @@ namespace VeraCrypt
|
|||
device.SeekAt (0);
|
||||
device.Write (bootLoaderBuf, sizeof (bootLoaderBuf));
|
||||
}
|
||||
|
||||
// starting from Windows 10 1607 (Build 14393), ReflectDrivers in Setupconfig.ini is supported
|
||||
if (IsOSVersionAtLeast (WIN_10, 0) && CurrentOSBuildNumber >= 14393)
|
||||
{
|
||||
wchar_t szSetupconfigLocation [TC_MAX_PATH + 20];
|
||||
|
||||
if (GetSetupconfigLocation (szSetupconfigLocation, ARRAYSIZE (szSetupconfigLocation)))
|
||||
{
|
||||
StringCchCatW (szSetupconfigLocation, ARRAYSIZE (szSetupconfigLocation), L"SetupConfig.ini");
|
||||
|
||||
if (FileExists (szSetupconfigLocation))
|
||||
{
|
||||
WritePrivateProfileStringW (L"SetupConfig", L"ReflectDrivers", NULL, szSetupconfigLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SETUP
|
||||
|
|
|
@ -310,7 +310,7 @@ namespace VeraCrypt
|
|||
void GetEfiBootDeviceNumber (PSTORAGE_DEVICE_NUMBER pSdn);
|
||||
void BackupSystemLoader ();
|
||||
void RestoreSystemLoader ();
|
||||
|
||||
void UpdateSetupConfigFile (bool bForInstall);
|
||||
protected:
|
||||
static const uint32 RescueIsoImageSize = 1835008; // Size of ISO9660 image with bootable emulated 1.44MB floppy disk image
|
||||
|
||||
|
|
|
@ -147,6 +147,7 @@ OSVersionEnum nCurrentOS = WIN_UNKNOWN;
|
|||
int CurrentOSMajor = 0;
|
||||
int CurrentOSMinor = 0;
|
||||
int CurrentOSServicePack = 0;
|
||||
int CurrentOSBuildNumber = 0;
|
||||
BOOL RemoteSession = FALSE;
|
||||
BOOL UacElevated = FALSE;
|
||||
|
||||
|
@ -344,6 +345,13 @@ static unsigned char gpbSha1CodeSignCertFingerprint[64] = {
|
|||
0x40, 0xCE, 0x17, 0x6C
|
||||
};
|
||||
|
||||
typedef HRESULT (WINAPI *SHGETKNOWNFOLDERPATH) (
|
||||
_In_ REFKNOWNFOLDERID rfid,
|
||||
_In_ DWORD dwFlags,
|
||||
_In_opt_ HANDLE hToken,
|
||||
_Out_ PWSTR *ppszPath
|
||||
);
|
||||
|
||||
/* Windows dialog class */
|
||||
#define WINDOWS_DIALOG_CLASS L"#32770"
|
||||
|
||||
|
@ -2663,6 +2671,7 @@ void InitOSVersionInfo ()
|
|||
CurrentOSMajor = os.dwMajorVersion;
|
||||
CurrentOSMinor = os.dwMinorVersion;
|
||||
CurrentOSServicePack = os.wServicePackMajor;
|
||||
CurrentOSBuildNumber = os.dwBuildNumber;
|
||||
|
||||
if (os.dwPlatformId == VER_PLATFORM_WIN32_NT && CurrentOSMajor == 5 && CurrentOSMinor == 0)
|
||||
nCurrentOS = WIN_2000;
|
||||
|
@ -13520,3 +13529,119 @@ BOOL VerifyModuleSignature (const wchar_t* path)
|
|||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
void GetInstallationPath (HWND hwndDlg, wchar_t* szInstallPath, DWORD cchSize, BOOL* pbInstallPathDetermined)
|
||||
{
|
||||
HKEY hkey;
|
||||
BOOL bInstallPathDetermined = FALSE;
|
||||
wchar_t path[MAX_PATH+20];
|
||||
ITEMIDLIST *itemList;
|
||||
|
||||
memset (szInstallPath, 0, cchSize * sizeof (wchar_t));
|
||||
|
||||
// Determine if VeraCrypt is already installed and try to determine its "Program Files" location
|
||||
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\VeraCrypt", 0, KEY_READ | KEY_WOW64_32KEY, &hkey) == ERROR_SUCCESS)
|
||||
{
|
||||
/* Default 'UninstallString' registry strings written by VeraCrypt:
|
||||
------------------------------------------------------------------------------------
|
||||
5.0+ "C:\Program Files\VeraCrypt\VeraCrypt Setup.exe" /u
|
||||
*/
|
||||
|
||||
wchar_t rv[MAX_PATH*4];
|
||||
DWORD size = sizeof (rv);
|
||||
if (RegQueryValueEx (hkey, L"UninstallString", 0, 0, (LPBYTE) &rv, &size) == ERROR_SUCCESS && wcsrchr (rv, L'/'))
|
||||
{
|
||||
size_t len = 0;
|
||||
|
||||
// Cut and paste the location (path) where VeraCrypt is installed to InstallationPath
|
||||
if (rv[0] == L'"')
|
||||
{
|
||||
len = wcsrchr (rv, L'/') - rv - 2;
|
||||
StringCchCopyNW (szInstallPath, cchSize, rv + 1, len);
|
||||
szInstallPath [len] = 0;
|
||||
bInstallPathDetermined = TRUE;
|
||||
|
||||
if (szInstallPath [wcslen (szInstallPath) - 1] != L'\\')
|
||||
{
|
||||
len = wcsrchr (szInstallPath, L'\\') - szInstallPath;
|
||||
szInstallPath [len] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
RegCloseKey (hkey);
|
||||
}
|
||||
|
||||
if (!bInstallPathDetermined)
|
||||
{
|
||||
/* VeraCrypt is not installed or it wasn't possible to determine where it is installed. */
|
||||
|
||||
// Default "Program Files" path.
|
||||
SHGetSpecialFolderLocation (hwndDlg, CSIDL_PROGRAM_FILES, &itemList);
|
||||
SHGetPathFromIDList (itemList, path);
|
||||
|
||||
if (Is64BitOs())
|
||||
{
|
||||
// Use a unified default installation path (registry redirection of %ProgramFiles% does not work if the installation path is user-selectable)
|
||||
wstring s = path;
|
||||
size_t p = s.find (L" (x86)");
|
||||
if (p != wstring::npos)
|
||||
{
|
||||
s = s.substr (0, p);
|
||||
if (_waccess (s.c_str(), 0) != -1)
|
||||
StringCbCopyW (path, sizeof (path), s.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
StringCbCatW (path, sizeof(path), L"\\VeraCrypt\\");
|
||||
StringCbCopyW (szInstallPath, cchSize, path);
|
||||
}
|
||||
|
||||
// Make sure the path ends with a backslash
|
||||
if (szInstallPath [wcslen (szInstallPath) - 1] != L'\\')
|
||||
{
|
||||
StringCbCatW (szInstallPath, cchSize, L"\\");
|
||||
}
|
||||
|
||||
if (pbInstallPathDetermined)
|
||||
*pbInstallPathDetermined = bInstallPathDetermined;
|
||||
}
|
||||
|
||||
BOOL GetSetupconfigLocation (wchar_t* path, DWORD cchSize)
|
||||
{
|
||||
wchar_t szShell32Path[MAX_PATH] = {0};
|
||||
HMODULE hShell32 = NULL;
|
||||
BOOL bResult = FALSE;
|
||||
|
||||
path[0] = 0;
|
||||
|
||||
if (GetSystemDirectory(szShell32Path, MAX_PATH))
|
||||
StringCchCatW (szShell32Path, MAX_PATH, L"\\Shell32.dll");
|
||||
else
|
||||
StringCchCopyW (szShell32Path, MAX_PATH, L"C:\\Windows\\System32\\Shell32.dll");
|
||||
|
||||
hShell32 = LoadLibrary (szShell32Path);
|
||||
if (hShell32)
|
||||
{
|
||||
SHGETKNOWNFOLDERPATH SHGetKnownFolderPathFn = (SHGETKNOWNFOLDERPATH) GetProcAddress (hShell32, "SHGetKnownFolderPath");
|
||||
if (SHGetKnownFolderPathFn)
|
||||
{
|
||||
wchar_t* pszUsersPath = NULL;
|
||||
if (S_OK == SHGetKnownFolderPathFn (FOLDERID_UserProfiles, 0, NULL, &pszUsersPath))
|
||||
{
|
||||
StringCchPrintfW (path, cchSize, L"%s\\Default\\AppData\\Local\\Microsoft\\Windows\\WSUS\\", pszUsersPath);
|
||||
CoTaskMemFree (pszUsersPath);
|
||||
bResult = TRUE;
|
||||
}
|
||||
}
|
||||
FreeLibrary (hShell32);
|
||||
}
|
||||
|
||||
if (!bResult && CurrentOSMajor >= 10)
|
||||
{
|
||||
StringCchPrintfW (path, cchSize, L"%c:\\Users\\Default\\AppData\\Local\\Microsoft\\Windows\\WSUS\\", szShell32Path[0]);
|
||||
bResult = TRUE;
|
||||
}
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
|
|
@ -135,6 +135,7 @@ extern OSVersionEnum nCurrentOS;
|
|||
extern int CurrentOSMajor;
|
||||
extern int CurrentOSMinor;
|
||||
extern int CurrentOSServicePack;
|
||||
extern int CurrentOSBuildNumber;
|
||||
extern BOOL RemoteSession;
|
||||
extern HANDLE hDriver;
|
||||
extern HINSTANCE hInst;
|
||||
|
@ -529,6 +530,8 @@ BOOL RaisePrivileges(void);
|
|||
BOOL DeleteDirectory (const wchar_t* szDirName);
|
||||
INT_PTR SecureDesktopDialogBoxParam (HINSTANCE, LPCWSTR, HWND, DLGPROC, LPARAM);
|
||||
BOOL VerifyModuleSignature (const wchar_t* path);
|
||||
void GetInstallationPath (HWND hwndDlg, wchar_t* szInstallPath, DWORD cchSize, BOOL* pbInstallPathDetermined);
|
||||
BOOL GetSetupconfigLocation (wchar_t* path, DWORD cchSize);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
|
|
|
@ -172,6 +172,11 @@ public:
|
|||
return BaseCom::WriteEfiBootSectorUserConfig (userConfig, customUserMessage,pim, hashAlg);
|
||||
}
|
||||
|
||||
virtual DWORD STDMETHODCALLTYPE UpdateSetupConfigFile (BOOL bForInstall)
|
||||
{
|
||||
return BaseCom::UpdateSetupConfigFile (bForInstall);
|
||||
}
|
||||
|
||||
protected:
|
||||
DWORD MessageThreadId;
|
||||
LONG RefCount;
|
||||
|
|
|
@ -16,7 +16,7 @@ import "..\Common\Password.h";
|
|||
[
|
||||
uuid(56327DDA-F1A7-4e13-B128-520D129BDEF6),
|
||||
helpstring("VeraCrypt Format UAC Support Library"),
|
||||
version(2.7) // Update ComSetup.cpp when changing version number
|
||||
version(2.8) // Update ComSetup.cpp when changing version number
|
||||
]
|
||||
library TrueCryptFormatCom
|
||||
{
|
||||
|
@ -47,6 +47,7 @@ library TrueCryptFormatCom
|
|||
DWORD RestoreEfiSystemLoader ();
|
||||
DWORD GetEfiBootDeviceNumber (BSTR* pSdn);
|
||||
DWORD WriteEfiBootSectorUserConfig (DWORD userConfig, BSTR customUserMessage, int pim, int hashAlg);
|
||||
DWORD UpdateSetupConfigFile (BOOL bForInstall);
|
||||
};
|
||||
|
||||
[
|
||||
|
|
|
@ -193,6 +193,11 @@ public:
|
|||
return BaseCom::WriteEfiBootSectorUserConfig (userConfig, customUserMessage,pim, hashAlg);
|
||||
}
|
||||
|
||||
virtual DWORD STDMETHODCALLTYPE UpdateSetupConfigFile (BOOL bForInstall)
|
||||
{
|
||||
return BaseCom::UpdateSetupConfigFile (bForInstall);
|
||||
}
|
||||
|
||||
protected:
|
||||
DWORD MessageThreadId;
|
||||
LONG RefCount;
|
||||
|
|
|
@ -16,7 +16,7 @@ import "..\Common\Password.h";
|
|||
[
|
||||
uuid(9ACF6176-5FC4-4690-A025-B3306A50EB6A),
|
||||
helpstring("VeraCrypt Main UAC Support Library"),
|
||||
version(2.9) // Update ComSetup.cpp when changing version number
|
||||
version(2.10) // Update ComSetup.cpp when changing version number
|
||||
]
|
||||
library TrueCryptMainCom
|
||||
{
|
||||
|
@ -51,6 +51,7 @@ library TrueCryptMainCom
|
|||
DWORD RestoreEfiSystemLoader ();
|
||||
DWORD GetEfiBootDeviceNumber (BSTR* pSdn);
|
||||
DWORD WriteEfiBootSectorUserConfig (DWORD userConfig, BSTR customUserMessage, int pim, int hashAlg);
|
||||
DWORD UpdateSetupConfigFile (BOOL bForInstall);
|
||||
};
|
||||
|
||||
[
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,80 @@
|
|||
;;;
|
||||
;;; VeraCrypt
|
||||
;;;
|
||||
;;;
|
||||
;;; Copyright (c) 2018, IDRIX
|
||||
;;;
|
||||
|
||||
[Version]
|
||||
signature = "$Windows NT$"
|
||||
Class = "Encryption" ;This is determined by the work this filter driver does
|
||||
ClassGuid = {a0a701c0-a511-42ff-aa6c-06dc0395576f} ;This value is determined by the Class
|
||||
Provider = %ProviderString%
|
||||
DriverVer = 04/14/2018,1.23.0.0
|
||||
CatalogFile = veracrypt.cat
|
||||
|
||||
|
||||
[DestinationDirs]
|
||||
DefaultDestDir = 12
|
||||
MiniFilter.DriverFiles = 12 ;%windir%\system32\drivers
|
||||
|
||||
;;
|
||||
;; Default install sections
|
||||
;;
|
||||
|
||||
[DefaultInstall]
|
||||
OptionDesc = %ServiceDescription%
|
||||
CopyFiles = MiniFilter.DriverFiles
|
||||
|
||||
[DefaultInstall.Services]
|
||||
AddService = %ServiceName%,,MiniFilter.Service
|
||||
|
||||
;;
|
||||
;; Default uninstall sections
|
||||
;;
|
||||
|
||||
[DefaultUninstall]
|
||||
DelFiles = MiniFilter.DriverFiles
|
||||
|
||||
[DefaultUninstall.Services]
|
||||
DelService = veracrypt,0x200 ;Ensure service is stopped before deleting
|
||||
|
||||
;
|
||||
; Services Section
|
||||
;
|
||||
|
||||
[MiniFilter.Service]
|
||||
DisplayName = %ServiceName%
|
||||
Description = %ServiceDescription%
|
||||
ServiceBinary = %12%\%DriverName%.sys ;%windir%\system32\drivers\
|
||||
Dependencies = "FltMgr"
|
||||
ServiceType = 2 ;SERVICE_FILE_SYSTEM_DRIVER
|
||||
;StartType = 0 ;SERVICE_BOOT_START
|
||||
StartType = 3 ;SERVICE_DEMAND_START
|
||||
ErrorControl = 1 ;SERVICE_ERROR_NORMAL
|
||||
LoadOrderGroup = "FSFilter Encryption"
|
||||
|
||||
;
|
||||
; Copy Files
|
||||
;
|
||||
|
||||
[MiniFilter.DriverFiles]
|
||||
%DriverName%.sys
|
||||
|
||||
[SourceDisksFiles]
|
||||
veracrypt.sys = 1,,
|
||||
|
||||
[SourceDisksNames]
|
||||
1 = %DiskId1%,,,
|
||||
|
||||
;;
|
||||
;; String Section
|
||||
;;
|
||||
|
||||
[Strings]
|
||||
ProviderString = "IDRIX"
|
||||
ServiceDescription = "veracrypt"
|
||||
ServiceName = "veracrypt"
|
||||
DriverName = "veracrypt"
|
||||
DiskId1 = "VeraCrypt Device Installation Disk"
|
||||
|
Binary file not shown.
Binary file not shown.
|
@ -11,10 +11,10 @@
|
|||
*/
|
||||
|
||||
#define TC_MAIN_COM_VERSION_MAJOR 2
|
||||
#define TC_MAIN_COM_VERSION_MINOR 9
|
||||
#define TC_MAIN_COM_VERSION_MINOR 10
|
||||
|
||||
#define TC_FORMAT_COM_VERSION_MAJOR 2
|
||||
#define TC_FORMAT_COM_VERSION_MINOR 7
|
||||
#define TC_FORMAT_COM_VERSION_MINOR 8
|
||||
|
||||
#include <atlbase.h>
|
||||
#include <comdef.h>
|
||||
|
@ -39,9 +39,9 @@ extern "C" BOOL RegisterComServers (wchar_t *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 = 5; i >= 1; i--)
|
||||
for (WORD i = 6; i >= 1; i--)
|
||||
UnRegisterTypeLib (LIBID_TrueCryptMainCom, TC_MAIN_COM_VERSION_MAJOR, TC_MAIN_COM_VERSION_MINOR-i, 0, SYS_WIN32);
|
||||
for (WORD i = 3; i >= 1; i--)
|
||||
for (WORD i = 4; i >= 1; i--)
|
||||
UnRegisterTypeLib (LIBID_TrueCryptFormatCom, TC_FORMAT_COM_VERSION_MAJOR, TC_FORMAT_COM_VERSION_MINOR-i, 0, SYS_WIN32);
|
||||
|
||||
wchar_t setupModule[MAX_PATH];
|
||||
|
@ -78,9 +78,9 @@ extern "C" BOOL UnregisterComServers (wchar_t *modulePath)
|
|||
return FALSE;
|
||||
|
||||
// unregister older versions that may still exist
|
||||
for (WORD i = 5; i >= 1; i--)
|
||||
for (WORD i = 6; i >= 1; i--)
|
||||
UnRegisterTypeLib (LIBID_TrueCryptMainCom, TC_MAIN_COM_VERSION_MAJOR, TC_MAIN_COM_VERSION_MINOR-i, 0, SYS_WIN32);
|
||||
for (WORD i = 3; i >= 1; i--)
|
||||
for (WORD i = 4; i >= 1; i--)
|
||||
UnRegisterTypeLib (LIBID_TrueCryptFormatCom, TC_FORMAT_COM_VERSION_MAJOR, TC_FORMAT_COM_VERSION_MINOR-i, 0, SYS_WIN32);
|
||||
|
||||
wchar_t module[1024];
|
||||
|
|
|
@ -747,6 +747,12 @@ BOOL DoFilesInstall (HWND hwndDlg, wchar_t *szDestDir)
|
|||
StringCbCopyNW (curFileName, sizeof(curFileName), FILENAME_64BIT_DRIVER, sizeof (FILENAME_64BIT_DRIVER));
|
||||
}
|
||||
|
||||
if (Is64BitOs ()
|
||||
&& wcscmp (szFiles[i], L"Averacrypt.cat") == 0)
|
||||
{
|
||||
StringCbCopyNW (curFileName, sizeof(curFileName), L"veracrypt-x64.cat", sizeof (L"veracrypt-x64.cat"));
|
||||
}
|
||||
|
||||
if (Is64BitOs ()
|
||||
&& wcscmp (szFiles[i], L"AVeraCrypt.exe") == 0)
|
||||
{
|
||||
|
@ -2289,45 +2295,9 @@ void DoInstall (void *arg)
|
|||
|
||||
void SetInstallationPath (HWND hwndDlg)
|
||||
{
|
||||
HKEY hkey;
|
||||
BOOL bInstallPathDetermined = FALSE;
|
||||
wchar_t path[MAX_PATH+20];
|
||||
ITEMIDLIST *itemList;
|
||||
|
||||
memset (InstallationPath, 0, sizeof (InstallationPath));
|
||||
|
||||
// Determine if VeraCrypt is already installed and try to determine its "Program Files" location
|
||||
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\VeraCrypt", 0, KEY_READ | KEY_WOW64_32KEY, &hkey) == ERROR_SUCCESS)
|
||||
{
|
||||
/* Default 'UninstallString' registry strings written by VeraCrypt:
|
||||
------------------------------------------------------------------------------------
|
||||
5.0+ "C:\Program Files\VeraCrypt\VeraCrypt Setup.exe" /u
|
||||
*/
|
||||
|
||||
wchar_t rv[MAX_PATH*4];
|
||||
DWORD size = sizeof (rv);
|
||||
if (RegQueryValueEx (hkey, L"UninstallString", 0, 0, (LPBYTE) &rv, &size) == ERROR_SUCCESS && wcsrchr (rv, L'/'))
|
||||
{
|
||||
size_t len = 0;
|
||||
|
||||
// Cut and paste the location (path) where VeraCrypt is installed to InstallationPath
|
||||
if (rv[0] == L'"')
|
||||
{
|
||||
len = wcsrchr (rv, L'/') - rv - 2;
|
||||
StringCchCopyNW (InstallationPath, ARRAYSIZE(InstallationPath), rv + 1, len);
|
||||
InstallationPath [len] = 0;
|
||||
bInstallPathDetermined = TRUE;
|
||||
|
||||
if (InstallationPath [wcslen (InstallationPath) - 1] != L'\\')
|
||||
{
|
||||
len = wcsrchr (InstallationPath, L'\\') - InstallationPath;
|
||||
InstallationPath [len] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
RegCloseKey (hkey);
|
||||
}
|
||||
|
||||
GetInstallationPath (hwndDlg, InstallationPath, ARRAYSIZE (InstallationPath), &bInstallPathDetermined);
|
||||
|
||||
if (bInstallPathDetermined)
|
||||
{
|
||||
|
@ -2343,36 +2313,6 @@ void SetInstallationPath (HWND hwndDlg)
|
|||
bChangeMode = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* VeraCrypt is not installed or it wasn't possible to determine where it is installed. */
|
||||
|
||||
// Default "Program Files" path.
|
||||
SHGetSpecialFolderLocation (hwndDlg, CSIDL_PROGRAM_FILES, &itemList);
|
||||
SHGetPathFromIDList (itemList, path);
|
||||
|
||||
if (Is64BitOs())
|
||||
{
|
||||
// Use a unified default installation path (registry redirection of %ProgramFiles% does not work if the installation path is user-selectable)
|
||||
wstring s = path;
|
||||
size_t p = s.find (L" (x86)");
|
||||
if (p != wstring::npos)
|
||||
{
|
||||
s = s.substr (0, p);
|
||||
if (_waccess (s.c_str(), 0) != -1)
|
||||
StringCbCopyW (path, sizeof (path), s.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
StringCbCatW (path, sizeof(path), L"\\VeraCrypt\\");
|
||||
StringCbCopyW (InstallationPath, sizeof(InstallationPath), path);
|
||||
}
|
||||
|
||||
// Make sure the path ends with a backslash
|
||||
if (InstallationPath [wcslen (InstallationPath) - 1] != L'\\')
|
||||
{
|
||||
StringCbCatW (InstallationPath, sizeof(InstallationPath), L"\\");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@ static wchar_t *szFiles[]=
|
|||
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",
|
||||
|
@ -46,7 +48,10 @@ static wchar_t *szCompressedFiles[]=
|
|||
L"VeraCrypt-x64.exe",
|
||||
L"VeraCryptExpander-x64.exe",
|
||||
L"VeraCrypt Format-x64.exe",
|
||||
L"veracrypt.inf",
|
||||
L"veracrypt.cat",
|
||||
L"veracrypt.sys",
|
||||
L"veracrypt-x64.cat",
|
||||
L"veracrypt-x64.sys",
|
||||
L"Languages.zip",
|
||||
L"docs.zip"
|
||||
|
|
Loading…
Reference in New Issue