diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2024-11-25 00:05:50 +0100 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2024-11-25 00:05:50 +0100 |
commit | 0c5fcf2286c912e087e6c3c5a25464fcfc107c89 (patch) | |
tree | 21315173722e02a2f312a8f34be5b130f4f1d4e5 /src/Setup/Setup.c | |
parent | 8ad9e7d769057d622d447ba4122bc499a70bd238 (diff) | |
download | VeraCrypt-0c5fcf2286c912e087e6c3c5a25464fcfc107c89.tar.gz VeraCrypt-0c5fcf2286c912e087e6c3c5a25464fcfc107c89.zip |
Windows Setup: Fix "Access Denied" issue during VeraCrypt update after a Windows upgrade
During a Windows upgrade, ownership of veracrypt.sys is set to TrustedInstaller, preventing VeraCrypt from accessing the file during an update.
This commit resolves the issue by temporarily taking ownership of the file to rename it, allowing the new file to be copied. The setup process now obtains additional privileges for this operation, which are properly dropped once the file copying is complete.
Diffstat (limited to 'src/Setup/Setup.c')
-rw-r--r-- | src/Setup/Setup.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/Setup/Setup.c b/src/Setup/Setup.c index 0a66dccd..ed236616 100644 --- a/src/Setup/Setup.c +++ b/src/Setup/Setup.c @@ -764,8 +764,11 @@ BOOL DoFilesInstall (HWND hwndDlg, wchar_t *szDestDir) wchar_t szTmp[TC_MAX_PATH]; BOOL bOK = TRUE; int i, x, fileNo; wchar_t curFileName [TC_MAX_PATH] = {0}; +#ifndef PORTABLE + PRIVILEGE_STATE originalPrivileges = { 0 }; +#endif if (!bUninstall && !bDevm) { // Self-extract all files to memory @@ -782,8 +785,12 @@ BOOL DoFilesInstall (HWND hwndDlg, wchar_t *szDestDir) if (szDestDir[x - 1] != L'\\') StringCbCatW (szDestDir, MAX_PATH, L"\\"); +#ifndef PORTABLE + EnableRequiredSetupPrivileges(&originalPrivileges); +#endif + for (i = 0; i < sizeof (szFiles) / sizeof (szFiles[0]); i++) { BOOL bResult, zipFile = FALSE; wchar_t szDir[TC_MAX_PATH]; @@ -1113,12 +1120,21 @@ err: StringCbPrintfW (szTmp2, sizeof(szTmp2), GetString ("UNINSTALL_OF_FAILED"), szTmp, pszDesc); if (lpMsgBuf) LocalFree (lpMsgBuf); - if (!Silent && MessageBoxW (hwndDlg, szTmp2, lpszTitle, MB_YESNO | MB_ICONHAND) != IDYES) + if (!Silent && MessageBoxW(hwndDlg, szTmp2, lpszTitle, MB_YESNO | MB_ICONHAND) != IDYES) + { +#ifndef PORTABLE + RestorePrivilegeState(&originalPrivileges); +#endif return FALSE; + } } } + +#ifndef PORTABLE + RestorePrivilegeState(&originalPrivileges); +#endif if (bUninstall == FALSE) { WIN32_FIND_DATA f; |