1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-11 11:08:02 -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:
Mounir IDRASSI
2024-11-25 00:05:50 +01:00
parent 8ad9e7d769
commit 0c5fcf2286
3 changed files with 256 additions and 2 deletions

View File

@@ -598,6 +598,27 @@ DWORD FastResizeFile (const wchar_t* filePath, __int64 fileSize);
void GetAppRandomSeed (unsigned char* pbRandSeed, size_t cbRandSeed);
#endif
BOOL IsInternetConnected();
#if defined(SETUP) && !defined (PORTABLE)
typedef struct _SECURITY_INFO_BACKUP {
PSID pOrigOwner;
PSID pOrigGroup;
PACL pOrigDacl;
PACL pOrigSacl;
} SECURITY_INFO_BACKUP, * PSECURITY_INFO_BACKUP;
typedef struct _PRIVILEGE_STATE {
BOOL takeOwnership;
BOOL backup;
BOOL restore;
} PRIVILEGE_STATE, * PPRIVILEGE_STATE;
BOOL RestoreSecurityInfo(const wchar_t* filePath, PSECURITY_INFO_BACKUP pBackup);
void FreeSecurityBackup(PSECURITY_INFO_BACKUP pBackup);
BOOL SaveCurrentPrivilegeState(PPRIVILEGE_STATE state);
BOOL RestorePrivilegeState(const PPRIVILEGE_STATE state);
BOOL EnableRequiredSetupPrivileges(PPRIVILEGE_STATE currentState);
BOOL ModifyFileSecurityPermissions(const wchar_t* filePath, PSECURITY_INFO_BACKUP pBackup);
#endif
#ifdef __cplusplus
}