From 4519bb494e7c88890aa0022d4aaabffb0b6d8faf Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Mon, 16 Apr 2018 23:48:54 +0200 Subject: Windows: implement compatibility for Windows 10 major updates using ReflectDrivers mechanism whose support started from Windows 10 version 1607. --- src/Setup/ComSetup.cpp | 12 ++++---- src/Setup/Setup.c | 76 ++++++-------------------------------------------- src/Setup/Setup.h | 5 ++++ 3 files changed, 19 insertions(+), 74 deletions(-) (limited to 'src/Setup') diff --git a/src/Setup/ComSetup.cpp b/src/Setup/ComSetup.cpp index 8d59a3f7..64078076 100644 --- a/src/Setup/ComSetup.cpp +++ b/src/Setup/ComSetup.cpp @@ -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 #include @@ -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]; diff --git a/src/Setup/Setup.c b/src/Setup/Setup.c index f6ea93fe..46583c46 100644 --- a/src/Setup/Setup.c +++ b/src/Setup/Setup.c @@ -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"\\"); - } } diff --git a/src/Setup/Setup.h b/src/Setup/Setup.h index 12b4159f..ada20fb9 100644 --- a/src/Setup/Setup.h +++ b/src/Setup/Setup.h @@ -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" -- cgit v1.2.3