From 0e4f1ecee33db0353dc845ee02b339f9c4ab7c22 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Fri, 23 Jun 2023 00:32:24 +0200 Subject: Windows: Make SetPrivilege return error if AdjustTokenPrivileges cannot adjust privileges --- src/Common/Dlgcode.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/Common') diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c index 76748fe5..e1170d84 100644 --- a/src/Common/Dlgcode.c +++ b/src/Common/Dlgcode.c @@ -13976,8 +13976,11 @@ BOOL SetPrivilege(LPTSTR szPrivilegeName, BOOL bEnable) tkp.Privileges[0].Attributes = bEnable? SE_PRIVILEGE_ENABLED : SE_PRIVILEGE_REMOVED; bRet = AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, NULL, NULL); - if (!bRet) - dwLastError = GetLastError (); + dwLastError = GetLastError (); + if ( ERROR_SUCCESS != dwLastError) + { + bRet = FALSE; + } } else dwLastError = GetLastError (); -- cgit v1.2.3