Windows: Fix bug in disabling of Windows privileges, they were completely removed instead

This started to cause issues after latest changes to disable privileges when they are no more needed.
Because of the bug, the privileges could not be enabled again because they were wrongly removed.
This commit is contained in:
Mounir IDRASSI 2024-09-02 14:08:26 +02:00
parent f024653450
commit 0970a98c84
No known key found for this signature in database
GPG Key ID: FC1B00364B3FE937

View File

@ -13706,11 +13706,11 @@ BOOL SetPrivilege(LPTSTR szPrivilegeName, BOOL bEnable)
&tkp.Privileges[0].Luid))
{
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Attributes = bEnable? SE_PRIVILEGE_ENABLED : SE_PRIVILEGE_REMOVED;
tkp.Privileges[0].Attributes = bEnable? SE_PRIVILEGE_ENABLED : 0;
bRet = AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, NULL, NULL);
dwLastError = GetLastError ();
if ( ERROR_SUCCESS != dwLastError)
if (bRet && (ERROR_NOT_ALL_ASSIGNED == dwLastError))
{
bRet = FALSE;
}