mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-12 03:18:26 -06:00
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.
This commit is contained in:
@@ -765,6 +765,9 @@ BOOL DoFilesInstall (HWND hwndDlg, wchar_t *szDestDir)
|
||||
BOOL bOK = TRUE;
|
||||
int i, x, fileNo;
|
||||
wchar_t curFileName [TC_MAX_PATH] = {0};
|
||||
#ifndef PORTABLE
|
||||
PRIVILEGE_STATE originalPrivileges = { 0 };
|
||||
#endif
|
||||
|
||||
if (!bUninstall && !bDevm)
|
||||
{
|
||||
@@ -783,6 +786,10 @@ 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;
|
||||
@@ -1114,10 +1121,19 @@ err:
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user