VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2015-07-13 21:13:28 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2015-07-13 23:35:23 +0200
commit7d6cd0c92d30ebb2dd0ec24744d18524538457b9 (patch)
treeb57976794415f2bf9f5e0cad3b81cdf6bec10b61
parent103018b367108b2ffce9a4b7f91f3c07cd41c492 (diff)
downloadVeraCrypt-7d6cd0c92d30ebb2dd0ec24744d18524538457b9.tar.gz
VeraCrypt-7d6cd0c92d30ebb2dd0ec24744d18524538457b9.zip
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.
-rw-r--r--src/Common/BootEncryption.cpp73
-rw-r--r--src/Common/BootEncryption.h1
-rw-r--r--src/Common/Dlgcode.c4
-rw-r--r--src/Common/Dlgcode.h2
-rw-r--r--src/Mount/Favorites.cpp10
-rw-r--r--src/Setup/Setup.c41
6 files changed, 94 insertions, 37 deletions
diff --git a/src/Common/BootEncryption.cpp b/src/Common/BootEncryption.cpp
index 2964e04d..a83db22d 100644
--- a/src/Common/BootEncryption.cpp
+++ b/src/Common/BootEncryption.cpp
@@ -1959,35 +1959,31 @@ namespace VeraCrypt
throw ParameterIncorrect (SRC_POS);
}
}
-#ifndef SETUP
-
- void BootEncryption::RegisterSystemFavoritesService (BOOL registerService)
+ void BootEncryption::RegisterSystemFavoritesService (BOOL registerService, BOOL noFileHandling)
{
- if (!IsAdmin() && IsUacSupported())
- {
- Elevator::RegisterSystemFavoritesService (registerService);
- return;
- }
-
SC_HANDLE scm = OpenSCManager (NULL, NULL, SC_MANAGER_ALL_ACCESS);
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)
{
try
{
- RegisterSystemFavoritesService (FALSE);
+ RegisterSystemFavoritesService (FALSE, noFileHandling);
}
catch (...) { }
- char appPath[TC_MAX_PATH];
- throw_sys_if (!GetModuleFileName (NULL, appPath, sizeof (appPath)));
+ if (!noFileHandling)
+ {
+ 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,
TC_SYSTEM_FAVORITES_SERVICE_NAME,
TC_APP_NAME " System Favorites",
@@ -2020,9 +2016,9 @@ namespace VeraCrypt
catch (...)
{
try
{
- RegisterSystemFavoritesService (false);
+ RegisterSystemFavoritesService (FALSE, noFileHandling);
}
catch (...) { }
throw;
@@ -2040,12 +2036,45 @@ namespace VeraCrypt
throw_sys_if (!DeleteService (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 ()
{
if (nCurrentOS == WIN_2000)
throw ErrorException ("SYS_ENCRYPTION_UNSUPPORTED_ON_CURRENT_OS", SRC_POS);
@@ -2530,20 +2559,8 @@ namespace VeraCrypt
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)
{
BootEncryptionStatus encStatus = GetStatus();
diff --git a/src/Common/BootEncryption.h b/src/Common/BootEncryption.h
index 745c343b..6ac42cd3 100644
--- a/src/Common/BootEncryption.h
+++ b/src/Common/BootEncryption.h
@@ -176,8 +176,9 @@ namespace VeraCrypt
uint32 ReadDriverConfigurationFlags ();
void RegisterBootDriver (bool hiddenSystem);
void RegisterFilterDriver (bool registerDriver, FilterType filterType);
void RegisterSystemFavoritesService (BOOL registerService);
+ void RegisterSystemFavoritesService (BOOL registerService, BOOL noFileHandling);
void RenameDeprecatedSystemLoaderBackup ();
bool RestartComputer (void);
void InitialSecurityChecksForHiddenOS ();
void RestrictPagingFilesToSystemPartition ();
diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c
index 2742317f..9625973b 100644
--- a/src/Common/Dlgcode.c
+++ b/src/Common/Dlgcode.c
@@ -8263,13 +8263,13 @@ char *GetProgramConfigPath (char *fileName)
return path;
}
-std::string GetServiceConfigPath (const char *fileName)
+std::string GetServiceConfigPath (const char *fileName, bool useLegacy)
{
char sysPath[TC_MAX_PATH];
- if (Is64BitOs())
+ if (Is64BitOs() && useLegacy)
{
typedef UINT (WINAPI *GetSystemWow64Directory_t) (LPTSTR lpBuffer, UINT uSize);
GetSystemWow64Directory_t getSystemWow64Directory = (GetSystemWow64Directory_t) GetProcAddress (GetModuleHandle ("kernel32"), "GetSystemWow64DirectoryA");
diff --git a/src/Common/Dlgcode.h b/src/Common/Dlgcode.h
index 18e581f5..5954ccf9 100644
--- a/src/Common/Dlgcode.h
+++ b/src/Common/Dlgcode.h
@@ -545,9 +545,9 @@ std::vector <HostDevice> GetAvailableHostDevices (bool noDeviceProperties = fals
std::string ToUpperCase (const std::string &str);
std::wstring GetWrongPasswordErrorMessage (HWND hwndDlg);
std::string GetWindowsEdition ();
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 HarddiskVolumePathToPartitionPath (const std::string &harddiskVolumePath);
std::string FindLatestFileOrDirectory (const std::string &directory, const char *namePattern, bool findDirectory, bool findFile);
std::string GetUserFriendlyVersionString (int version);
diff --git a/src/Mount/Favorites.cpp b/src/Mount/Favorites.cpp
index 1e8226d8..c04b15bd 100644
--- a/src/Mount/Favorites.cpp
+++ b/src/Mount/Favorites.cpp
@@ -502,18 +502,18 @@ namespace VeraCrypt
void LoadFavoriteVolumes (vector <FavoriteVolume> &favorites, bool systemFavorites, bool noUacElevation)
{
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)
{
favoritesFilePath = GetConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES);
try
{
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)
{
if (e.ErrorCode == ERROR_FILE_NOT_FOUND)
@@ -736,18 +736,18 @@ namespace VeraCrypt
finally_do ({ remove (GetConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES)); });
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 (...) { }
try
{
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))
Info ("SYS_FAVORITE_VOLUMES_SAVED", hwndDlg);
}
@@ -763,9 +763,9 @@ namespace VeraCrypt
if (systemFavorites)
{
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 (...) { }
}
else
diff --git a/src/Setup/Setup.c b/src/Setup/Setup.c
index a5a30189..ce52fe3a 100644
--- a/src/Setup/Setup.c
+++ b/src/Setup/Setup.c
@@ -768,14 +768,53 @@ BOOL DoFilesInstall (HWND hwndDlg, char *szDestDir)
}
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()))
{
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());
+
+ 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);
}
}
}
else