mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-11 11:08:02 -06:00
Windows: on 64-bit Windows, more System favorite service from SysWoW64 to System32 since now all binaries are native 64-bit on 64-bit machines.
This commit is contained in:
@@ -1960,33 +1960,29 @@ namespace VeraCrypt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SETUP
|
void BootEncryption::RegisterSystemFavoritesService (BOOL registerService, BOOL noFileHandling)
|
||||||
|
|
||||||
void BootEncryption::RegisterSystemFavoritesService (BOOL registerService)
|
|
||||||
{
|
{
|
||||||
if (!IsAdmin() && IsUacSupported())
|
|
||||||
{
|
|
||||||
Elevator::RegisterSystemFavoritesService (registerService);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SC_HANDLE scm = OpenSCManager (NULL, NULL, SC_MANAGER_ALL_ACCESS);
|
SC_HANDLE scm = OpenSCManager (NULL, NULL, SC_MANAGER_ALL_ACCESS);
|
||||||
throw_sys_if (!scm);
|
throw_sys_if (!scm);
|
||||||
|
|
||||||
string servicePath = GetServiceConfigPath (TC_APP_NAME ".exe");
|
string servicePath = GetServiceConfigPath (TC_APP_NAME ".exe", false);
|
||||||
|
string serviceLegacyPath = GetServiceConfigPath (TC_APP_NAME ".exe", true);
|
||||||
|
|
||||||
if (registerService)
|
if (registerService)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
RegisterSystemFavoritesService (FALSE);
|
RegisterSystemFavoritesService (FALSE, noFileHandling);
|
||||||
}
|
}
|
||||||
catch (...) { }
|
catch (...) { }
|
||||||
|
|
||||||
char appPath[TC_MAX_PATH];
|
if (!noFileHandling)
|
||||||
throw_sys_if (!GetModuleFileName (NULL, appPath, sizeof (appPath)));
|
{
|
||||||
|
char appPath[TC_MAX_PATH];
|
||||||
|
throw_sys_if (!GetModuleFileName (NULL, appPath, sizeof (appPath)));
|
||||||
|
|
||||||
throw_sys_if (!CopyFile (appPath, servicePath.c_str(), FALSE));
|
throw_sys_if (!CopyFile (appPath, servicePath.c_str(), FALSE));
|
||||||
|
}
|
||||||
|
|
||||||
SC_HANDLE service = CreateService (scm,
|
SC_HANDLE service = CreateService (scm,
|
||||||
TC_SYSTEM_FAVORITES_SERVICE_NAME,
|
TC_SYSTEM_FAVORITES_SERVICE_NAME,
|
||||||
@@ -2021,7 +2017,7 @@ namespace VeraCrypt
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
RegisterSystemFavoritesService (false);
|
RegisterSystemFavoritesService (FALSE, noFileHandling);
|
||||||
}
|
}
|
||||||
catch (...) { }
|
catch (...) { }
|
||||||
|
|
||||||
@@ -2041,10 +2037,43 @@ namespace VeraCrypt
|
|||||||
throw_sys_if (!DeleteService (service));
|
throw_sys_if (!DeleteService (service));
|
||||||
CloseServiceHandle (service);
|
CloseServiceHandle (service);
|
||||||
|
|
||||||
DeleteFile (servicePath.c_str());
|
if (!noFileHandling)
|
||||||
|
{
|
||||||
|
DeleteFile (servicePath.c_str());
|
||||||
|
if (serviceLegacyPath != servicePath)
|
||||||
|
DeleteFile (serviceLegacyPath.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BootEncryption::SetDriverConfigurationFlag (uint32 flag, bool state)
|
||||||
|
{
|
||||||
|
DWORD configMap = ReadDriverConfigurationFlags();
|
||||||
|
|
||||||
|
if (state)
|
||||||
|
configMap |= flag;
|
||||||
|
else
|
||||||
|
configMap &= ~flag;
|
||||||
|
#ifdef SETUP
|
||||||
|
WriteLocalMachineRegistryDword ("SYSTEM\\CurrentControlSet\\Services\\veracrypt", TC_DRIVER_CONFIG_REG_VALUE_NAME, configMap);
|
||||||
|
#else
|
||||||
|
WriteLocalMachineRegistryDwordValue ("SYSTEM\\CurrentControlSet\\Services\\veracrypt", TC_DRIVER_CONFIG_REG_VALUE_NAME, configMap);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef SETUP
|
||||||
|
|
||||||
|
void BootEncryption::RegisterSystemFavoritesService (BOOL registerService)
|
||||||
|
{
|
||||||
|
if (!IsAdmin() && IsUacSupported())
|
||||||
|
{
|
||||||
|
Elevator::RegisterSystemFavoritesService (registerService);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RegisterSystemFavoritesService (registerService, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
void BootEncryption::CheckRequirements ()
|
void BootEncryption::CheckRequirements ()
|
||||||
{
|
{
|
||||||
if (nCurrentOS == WIN_2000)
|
if (nCurrentOS == WIN_2000)
|
||||||
@@ -2531,18 +2560,6 @@ namespace VeraCrypt
|
|||||||
throw_sys_if (!WriteLocalMachineRegistryDword (keyPath, valueName, value));
|
throw_sys_if (!WriteLocalMachineRegistryDword (keyPath, valueName, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BootEncryption::SetDriverConfigurationFlag (uint32 flag, bool state)
|
|
||||||
{
|
|
||||||
DWORD configMap = ReadDriverConfigurationFlags();
|
|
||||||
|
|
||||||
if (state)
|
|
||||||
configMap |= flag;
|
|
||||||
else
|
|
||||||
configMap &= ~flag;
|
|
||||||
|
|
||||||
WriteLocalMachineRegistryDwordValue ("SYSTEM\\CurrentControlSet\\Services\\veracrypt", TC_DRIVER_CONFIG_REG_VALUE_NAME, configMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BootEncryption::StartDecryption (BOOL discardUnreadableEncryptedSectors)
|
void BootEncryption::StartDecryption (BOOL discardUnreadableEncryptedSectors)
|
||||||
{
|
{
|
||||||
BootEncryptionStatus encStatus = GetStatus();
|
BootEncryptionStatus encStatus = GetStatus();
|
||||||
|
|||||||
@@ -177,6 +177,7 @@ namespace VeraCrypt
|
|||||||
void RegisterBootDriver (bool hiddenSystem);
|
void RegisterBootDriver (bool hiddenSystem);
|
||||||
void RegisterFilterDriver (bool registerDriver, FilterType filterType);
|
void RegisterFilterDriver (bool registerDriver, FilterType filterType);
|
||||||
void RegisterSystemFavoritesService (BOOL registerService);
|
void RegisterSystemFavoritesService (BOOL registerService);
|
||||||
|
void RegisterSystemFavoritesService (BOOL registerService, BOOL noFileHandling);
|
||||||
void RenameDeprecatedSystemLoaderBackup ();
|
void RenameDeprecatedSystemLoaderBackup ();
|
||||||
bool RestartComputer (void);
|
bool RestartComputer (void);
|
||||||
void InitialSecurityChecksForHiddenOS ();
|
void InitialSecurityChecksForHiddenOS ();
|
||||||
|
|||||||
@@ -8264,11 +8264,11 @@ char *GetProgramConfigPath (char *fileName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string GetServiceConfigPath (const char *fileName)
|
std::string GetServiceConfigPath (const char *fileName, bool useLegacy)
|
||||||
{
|
{
|
||||||
char sysPath[TC_MAX_PATH];
|
char sysPath[TC_MAX_PATH];
|
||||||
|
|
||||||
if (Is64BitOs())
|
if (Is64BitOs() && useLegacy)
|
||||||
{
|
{
|
||||||
typedef UINT (WINAPI *GetSystemWow64Directory_t) (LPTSTR lpBuffer, UINT uSize);
|
typedef UINT (WINAPI *GetSystemWow64Directory_t) (LPTSTR lpBuffer, UINT uSize);
|
||||||
|
|
||||||
|
|||||||
@@ -546,7 +546,7 @@ std::string ToUpperCase (const std::string &str);
|
|||||||
std::wstring GetWrongPasswordErrorMessage (HWND hwndDlg);
|
std::wstring GetWrongPasswordErrorMessage (HWND hwndDlg);
|
||||||
std::string GetWindowsEdition ();
|
std::string GetWindowsEdition ();
|
||||||
std::string FitPathInGfxWidth (HWND hwnd, HFONT hFont, LONG width, const std::string &path);
|
std::string FitPathInGfxWidth (HWND hwnd, HFONT hFont, LONG width, const std::string &path);
|
||||||
std::string GetServiceConfigPath (const char *fileName);
|
std::string GetServiceConfigPath (const char *fileName, bool useLegacy);
|
||||||
std::string VolumeGuidPathToDevicePath (std::string volumeGuidPath);
|
std::string VolumeGuidPathToDevicePath (std::string volumeGuidPath);
|
||||||
std::string HarddiskVolumePathToPartitionPath (const std::string &harddiskVolumePath);
|
std::string HarddiskVolumePathToPartitionPath (const std::string &harddiskVolumePath);
|
||||||
std::string FindLatestFileOrDirectory (const std::string &directory, const char *namePattern, bool findDirectory, bool findFile);
|
std::string FindLatestFileOrDirectory (const std::string &directory, const char *namePattern, bool findDirectory, bool findFile);
|
||||||
|
|||||||
@@ -503,7 +503,7 @@ namespace VeraCrypt
|
|||||||
void LoadFavoriteVolumes (vector <FavoriteVolume> &favorites, bool systemFavorites, bool noUacElevation)
|
void LoadFavoriteVolumes (vector <FavoriteVolume> &favorites, bool systemFavorites, bool noUacElevation)
|
||||||
{
|
{
|
||||||
favorites.clear();
|
favorites.clear();
|
||||||
string favoritesFilePath = systemFavorites ? GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES) : GetConfigPath (TC_APPD_FILENAME_FAVORITE_VOLUMES);
|
string favoritesFilePath = systemFavorites ? GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES, false) : GetConfigPath (TC_APPD_FILENAME_FAVORITE_VOLUMES);
|
||||||
|
|
||||||
if (systemFavorites && !IsAdmin() && !noUacElevation)
|
if (systemFavorites && !IsAdmin() && !noUacElevation)
|
||||||
{
|
{
|
||||||
@@ -512,7 +512,7 @@ namespace VeraCrypt
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
BootEncryption bootEnc (MainDlg);
|
BootEncryption bootEnc (MainDlg);
|
||||||
bootEnc.CopyFileAdmin (GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES).c_str(), favoritesFilePath.c_str());
|
bootEnc.CopyFileAdmin (GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES, false).c_str(), favoritesFilePath.c_str());
|
||||||
}
|
}
|
||||||
catch (SystemException &e)
|
catch (SystemException &e)
|
||||||
{
|
{
|
||||||
@@ -737,7 +737,7 @@ namespace VeraCrypt
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
bootEnc.DeleteFileAdmin (GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES).c_str());
|
bootEnc.DeleteFileAdmin (GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES, false).c_str());
|
||||||
}
|
}
|
||||||
catch (UserAbort&) { return false; }
|
catch (UserAbort&) { return false; }
|
||||||
catch (...) { }
|
catch (...) { }
|
||||||
@@ -746,7 +746,7 @@ namespace VeraCrypt
|
|||||||
{
|
{
|
||||||
if (cnt != 0)
|
if (cnt != 0)
|
||||||
{
|
{
|
||||||
bootEnc.CopyFileAdmin (GetConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES), GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES).c_str());
|
bootEnc.CopyFileAdmin (GetConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES), GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES, false).c_str());
|
||||||
|
|
||||||
if (!(ReadDriverConfigurationFlags() & TC_DRIVER_CONFIG_CACHE_BOOT_PASSWORD_FOR_SYS_FAVORITES))
|
if (!(ReadDriverConfigurationFlags() & TC_DRIVER_CONFIG_CACHE_BOOT_PASSWORD_FOR_SYS_FAVORITES))
|
||||||
Info ("SYS_FAVORITE_VOLUMES_SAVED", hwndDlg);
|
Info ("SYS_FAVORITE_VOLUMES_SAVED", hwndDlg);
|
||||||
@@ -764,7 +764,7 @@ namespace VeraCrypt
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
bootEnc.DeleteFileAdmin (GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES).c_str());
|
bootEnc.DeleteFileAdmin (GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES, false).c_str());
|
||||||
}
|
}
|
||||||
catch (...) { }
|
catch (...) { }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -769,12 +769,51 @@ BOOL DoFilesInstall (HWND hwndDlg, char *szDestDir)
|
|||||||
|
|
||||||
if (bResult && strcmp (szFiles[i], "AVeraCrypt.exe") == 0)
|
if (bResult && strcmp (szFiles[i], "AVeraCrypt.exe") == 0)
|
||||||
{
|
{
|
||||||
string servicePath = GetServiceConfigPath (TC_APP_NAME ".exe");
|
if (Is64BitOs ())
|
||||||
|
EnableWow64FsRedirection (FALSE);
|
||||||
|
|
||||||
|
string servicePath = GetServiceConfigPath (TC_APP_NAME ".exe", false);
|
||||||
|
string serviceLegacyPath = GetServiceConfigPath (TC_APP_NAME ".exe", true);
|
||||||
|
|
||||||
if (FileExists (servicePath.c_str()))
|
if (FileExists (servicePath.c_str()))
|
||||||
{
|
{
|
||||||
CopyMessage (hwndDlg, (char *) servicePath.c_str());
|
CopyMessage (hwndDlg, (char *) servicePath.c_str());
|
||||||
bResult = CopyFile (szTmp, servicePath.c_str(), FALSE);
|
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());
|
||||||
|
|
||||||
|
CopyMessage (hwndDlg, (char *) servicePath.c_str());
|
||||||
|
bResult = CopyFile (szTmp, servicePath.c_str(), FALSE);
|
||||||
|
|
||||||
|
if (bResult && FileExists (favoritesLegacyFile.c_str()))
|
||||||
|
{
|
||||||
|
// 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)
|
||||||
|
{
|
||||||
|
BootEncObj.RegisterSystemFavoritesService (TRUE, TRUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (...) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Is64BitOs ())
|
||||||
|
EnableWow64FsRedirection (TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user