1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-12 03:18:26 -06:00

Windows: Add checks that the System Favorites service is running. Warn user if he enabled option to clear RAM encryption keys and the service is stopped.

This commit is contained in:
Mounir IDRASSI
2019-10-20 16:33:34 +02:00
parent 7c020c23ce
commit cca08e1ed5
6 changed files with 80 additions and 4 deletions

View File

@@ -4628,6 +4628,16 @@ namespace VeraCrypt
if (registerService)
{
// check if service already exists.
// If yes then start it immediatly after reinstalling it
bool bAlreadyExists = false;
SC_HANDLE service = OpenService (scm, TC_SYSTEM_FAVORITES_SERVICE_NAME, GENERIC_READ);
if (service)
{
bAlreadyExists = true;
CloseServiceHandle (service);
}
try
{
RegisterSystemFavoritesService (FALSE, noFileHandling);
@@ -4650,7 +4660,7 @@ namespace VeraCrypt
throw_sys_if (!CopyFile (appPath, servicePath.c_str(), FALSE));
}
SC_HANDLE service = CreateService (scm,
service = CreateService (scm,
TC_SYSTEM_FAVORITES_SERVICE_NAME,
_T(TC_APP_NAME) L" System Favorites",
SERVICE_ALL_ACCESS,
@@ -4670,6 +4680,10 @@ namespace VeraCrypt
description.lpDescription = L"Mounts VeraCrypt system favorite volumes.";
ChangeServiceConfig2 (service, SERVICE_CONFIG_DESCRIPTION, &description);
// start the service immediatly if it already existed before
if (bAlreadyExists)
StartService (service, 0, NULL);
CloseServiceHandle (service);
try
@@ -4711,6 +4725,30 @@ namespace VeraCrypt
}
}
bool BootEncryption::IsSystemFavoritesServiceRunning ()
{
bool bRet = false;
SC_HANDLE scm = OpenSCManager (NULL, NULL, SC_MANAGER_CONNECT);
if (scm)
{
SC_HANDLE service = OpenService(scm, TC_SYSTEM_FAVORITES_SERVICE_NAME, GENERIC_READ);
if (service)
{
SERVICE_STATUS status;
if (QueryServiceStatus(service, &status))
{
bRet = (status.dwCurrentState == SERVICE_RUNNING);
}
CloseServiceHandle(service);
}
CloseServiceHandle (scm);
}
return bRet;
}
void BootEncryption::UpdateSystemFavoritesService ()
{
SC_HANDLE scm = OpenSCManager (NULL, NULL, SC_MANAGER_ALL_ACCESS);

View File

@@ -287,6 +287,7 @@ namespace VeraCrypt
void RegisterFilterDriver (bool registerDriver, FilterType filterType);
void RegisterSystemFavoritesService (BOOL registerService);
void RegisterSystemFavoritesService (BOOL registerService, BOOL noFileHandling);
bool IsSystemFavoritesServiceRunning ();
void UpdateSystemFavoritesService ();
void RenameDeprecatedSystemLoaderBackup ();
bool RestartComputer (BOOL bShutdown = FALSE);

View File

@@ -11142,7 +11142,7 @@ void InconsistencyResolved (char *techInfo)
}
void ReportUnexpectedState (char *techInfo)
void ReportUnexpectedState (const char *techInfo)
{
wchar_t finalMsg[8024];

View File

@@ -473,7 +473,7 @@ BOOL CALLBACK CloseTCWindowsEnum( HWND hwnd, LPARAM lParam);
BOOL CALLBACK FindTCWindowEnum (HWND hwnd, LPARAM lParam);
BYTE *MapResource (wchar_t *resourceType, int resourceId, PDWORD size);
void InconsistencyResolved (char *msg);
void ReportUnexpectedState (char *techInfo);
void ReportUnexpectedState (const char *techInfo);
BOOL SelectMultipleFiles (HWND hwndDlg, const char *stringId, wchar_t *lpszFileName, size_t cbFileName, BOOL keepHistory);
BOOL SelectMultipleFilesNext (wchar_t *lpszFileName, size_t cbFileName);
void OpenOnlineHelp ();