VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Common/BootEncryption.cpp34
-rw-r--r--src/Common/BootEncryption.h1
-rw-r--r--src/Setup/Setup.c115
3 files changed, 126 insertions, 24 deletions
diff --git a/src/Common/BootEncryption.cpp b/src/Common/BootEncryption.cpp
index 064d1f8d..02affc89 100644
--- a/src/Common/BootEncryption.cpp
+++ b/src/Common/BootEncryption.cpp
@@ -2017,6 +2017,7 @@ namespace VeraCrypt
{
SC_HANDLE scm = OpenSCManager (NULL, NULL, SC_MANAGER_ALL_ACCESS);
throw_sys_if (!scm);
+ finally_do_arg (SC_HANDLE, scm, { CloseServiceHandle (finally_arg); });
string servicePath = GetServiceConfigPath (TC_APP_NAME ".exe", false);
string serviceLegacyPath = GetServiceConfigPath (TC_APP_NAME ".exe", true);
@@ -2099,6 +2100,39 @@ namespace VeraCrypt
}
}
+ void BootEncryption::UpdateSystemFavoritesService ()
+ {
+ SC_HANDLE scm = OpenSCManager (NULL, NULL, SC_MANAGER_ALL_ACCESS);
+ throw_sys_if (!scm);
+
+ finally_do_arg (SC_HANDLE, scm, { CloseServiceHandle (finally_arg); });
+
+ string servicePath = GetServiceConfigPath (TC_APP_NAME ".exe", false);
+
+ // check if service exists
+ SC_HANDLE service = OpenService (scm, TC_SYSTEM_FAVORITES_SERVICE_NAME, SERVICE_ALL_ACCESS);
+ if (service)
+ {
+ // ensure that its parameters are correct
+ throw_sys_if (!ChangeServiceConfig (service,
+ SERVICE_WIN32_OWN_PROCESS,
+ SERVICE_AUTO_START,
+ SERVICE_ERROR_NORMAL,
+ (string ("\"") + servicePath + "\" " TC_SYSTEM_FAVORITES_SERVICE_CMDLINE_OPTION).c_str(),
+ TC_SYSTEM_FAVORITES_SERVICE_LOAD_ORDER_GROUP,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ TC_APP_NAME " System Favorites"));
+
+ }
+ else
+ {
+ RegisterSystemFavoritesService (TRUE, TRUE);
+ }
+ }
+
void BootEncryption::SetDriverConfigurationFlag (uint32 flag, bool state)
{
DWORD configMap = ReadDriverConfigurationFlags();
diff --git a/src/Common/BootEncryption.h b/src/Common/BootEncryption.h
index b1c5e7c1..561e1723 100644
--- a/src/Common/BootEncryption.h
+++ b/src/Common/BootEncryption.h
@@ -186,6 +186,7 @@ namespace VeraCrypt
void RegisterFilterDriver (bool registerDriver, FilterType filterType);
void RegisterSystemFavoritesService (BOOL registerService);
void RegisterSystemFavoritesService (BOOL registerService, BOOL noFileHandling);
+ void UpdateSystemFavoritesService ();
void RenameDeprecatedSystemLoaderBackup ();
bool RestartComputer (void);
void InitialSecurityChecksForHiddenOS ();
diff --git a/src/Setup/Setup.c b/src/Setup/Setup.c
index 3a7751f8..98b94b08 100644
--- a/src/Setup/Setup.c
+++ b/src/Setup/Setup.c
@@ -776,52 +776,103 @@ BOOL DoFilesInstall (HWND hwndDlg, char *szDestDir)
string servicePath = GetServiceConfigPath (TC_APP_NAME ".exe", false);
string serviceLegacyPath = GetServiceConfigPath (TC_APP_NAME ".exe", true);
+ string favoritesFile = GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES, false);
+ string favoritesLegacyFile = GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES, true);
- if (FileExists (servicePath.c_str()))
+ if ( FileExists (servicePath.c_str())
+ || (Is64BitOs () && FileExists (serviceLegacyPath.c_str()))
+ )
{
CopyMessage (hwndDlg, (char *) servicePath.c_str());
bResult = CopyFile (szTmp, servicePath.c_str(), FALSE);
}
- else if (Is64BitOs () && FileExists (serviceLegacyPath.c_str()))
- {
- string favoritesFile = GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES, false);
- string favoritesLegacyFile = GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES, true);
- // delete files from legacy path
- RemoveMessage (hwndDlg, (char *) serviceLegacyPath.c_str());
- DeleteFile (serviceLegacyPath.c_str());
+ if (bResult && 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);
+ }
- CopyMessage (hwndDlg, (char *) servicePath.c_str());
- bResult = CopyFile (szTmp, servicePath.c_str(), FALSE);
+ if (bResult && Is64BitOs () && FileExists (favoritesFile.c_str()) && FileExists (servicePath.c_str()))
+ {
+ // Update the path of the service
+ BootEncryption BootEncObj (hwndDlg);
- if (bResult && FileExists (favoritesLegacyFile.c_str()))
+ try
{
- // copy the favorites XML file to the native system directory
- bResult = CopyFile (favoritesLegacyFile.c_str(), favoritesFile.c_str(), FALSE);
- if (bResult)
- DeleteFile (favoritesLegacyFile.c_str());
-
- BootEncryption BootEncObj (hwndDlg);
-
- try
+ if (BootEncObj.GetStatus().DriveMounted)
{
- if (BootEncObj.GetStatus().DriveMounted)
- {
- BootEncObj.RegisterSystemFavoritesService (TRUE, TRUE);
- }
+ BootEncObj.UpdateSystemFavoritesService ();
}
- catch (...) {}
}
+ catch (...) {}
}
if (Is64BitOs ())
+ {
+ // delete files from legacy path
+ if (FileExists (favoritesLegacyFile.c_str()))
+ {
+ RemoveMessage (hwndDlg, (char *) favoritesLegacyFile.c_str());
+ DeleteFile (favoritesLegacyFile.c_str());
+ }
+
+ if (FileExists (serviceLegacyPath.c_str()))
+ {
+ RemoveMessage (hwndDlg, (char *) serviceLegacyPath.c_str());
+ DeleteFile (serviceLegacyPath.c_str());
+ }
+
EnableWow64FsRedirection (TRUE);
+ }
}
}
}
else
{
bResult = StatDeleteFile (szTmp, TRUE);
+ if (bResult && strcmp (szFiles[i], "AVeraCrypt.exe") == 0)
+ {
+ if (Is64BitOs ())
+ EnableWow64FsRedirection (FALSE);
+
+ string servicePath = GetServiceConfigPath (TC_APP_NAME ".exe", false);
+ string serviceLegacyPath = GetServiceConfigPath (TC_APP_NAME ".exe", true);
+ string favoritesFile = GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES, false);
+ string favoritesLegacyFile = GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES, true);
+
+ // delete all files related to system favorites service
+ if (FileExists (favoritesFile.c_str()))
+ {
+ RemoveMessage (hwndDlg, (char *) favoritesFile.c_str());
+ DeleteFile (favoritesFile.c_str());
+ }
+
+ if (FileExists (servicePath.c_str()))
+ {
+ RemoveMessage (hwndDlg, (char *) servicePath.c_str());
+ DeleteFile (servicePath.c_str());
+ }
+
+ if (Is64BitOs ())
+ {
+ if (FileExists (favoritesLegacyFile.c_str()))
+ {
+ RemoveMessage (hwndDlg, (char *) favoritesLegacyFile.c_str());
+ DeleteFile (favoritesLegacyFile.c_str());
+ }
+
+ if (FileExists (serviceLegacyPath.c_str()))
+ {
+ RemoveMessage (hwndDlg, (char *) serviceLegacyPath.c_str());
+ DeleteFile (serviceLegacyPath.c_str());
+ }
+
+ EnableWow64FsRedirection (TRUE);
+ }
+ }
}
err:
@@ -1105,6 +1156,22 @@ BOOL DoApplicationDataUninstall (HWND hwndDlg)
bOK = FALSE;
}
+ // remove VeraCrypt under common appdata
+ if (SUCCEEDED (SHGetFolderPath (NULL, CSIDL_COMMON_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, path)))
+ {
+ StringCbCatA (path, sizeof(path), "\\VeraCrypt");
+
+ // Delete original bootloader
+ StringCbPrintfA (path2, sizeof(path2), "%s\\%s", path, TC_SYS_BOOT_LOADER_BACKUP_NAME);
+ RemoveMessage (hwndDlg, path2);
+ StatDeleteFile (path2, FALSE);
+
+ // remove VeraCrypt folder
+ RemoveMessage (hwndDlg, path);
+ StatRemoveDirectory (path);
+ }
+
+
return bOK;
}