Author: dchapyshev
Date: Sun Feb 22 16:39:21 2009
New Revision: 39710
URL:
http://svn.reactos.org/svn/reactos?rev=39710&view=rev
Log:
- Add CheckTokenMembership to winbase.h
- Use CheckTokenMembership in IsUserAdmin
Modified:
trunk/reactos/dll/win32/setupapi/misc.c
trunk/reactos/include/psdk/winbase.h
Modified: trunk/reactos/dll/win32/setupapi/misc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/misc.c?…
==============================================================================
--- trunk/reactos/dll/win32/setupapi/misc.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/setupapi/misc.c [iso-8859-1] Sun Feb 22 16:39:21 2009
@@ -1694,62 +1694,22 @@
IsUserAdmin(VOID)
{
SID_IDENTIFIER_AUTHORITY Authority = {SECURITY_NT_AUTHORITY};
- HANDLE hToken;
- DWORD dwSize;
- PTOKEN_GROUPS lpGroups;
+ BOOL bResult = FALSE;
PSID lpSid;
- DWORD i;
- BOOL bResult = FALSE;
-
- if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken))
- {
- return FALSE;
- }
-
- if (!GetTokenInformation(hToken, TokenGroups, NULL, 0, &dwSize))
- {
- if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
- {
- CloseHandle(hToken);
- return FALSE;
- }
- }
-
- lpGroups = HeapAlloc(GetProcessHeap(), 0, dwSize);
- if (lpGroups == NULL)
- {
- CloseHandle(hToken);
- return FALSE;
- }
-
- if (!GetTokenInformation(hToken, TokenGroups, lpGroups, dwSize, &dwSize))
- {
- HeapFree(GetProcessHeap(), 0, lpGroups);
- CloseHandle(hToken);
- return FALSE;
- }
-
- CloseHandle(hToken);
if (!AllocateAndInitializeSid(&Authority, 2, SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0,
&lpSid))
{
- HeapFree(GetProcessHeap(), 0, lpGroups);
return FALSE;
}
- for (i = 0; i < lpGroups->GroupCount; i++)
- {
- if (EqualSid(lpSid, lpGroups->Groups[i].Sid))
- {
- bResult = TRUE;
- break;
- }
+ if (!CheckTokenMembership(NULL, lpSid, &bResult))
+ {
+ bResult = FALSE;
}
FreeSid(lpSid);
- HeapFree(GetProcessHeap(), 0, lpGroups);
return bResult;
}
Modified: trunk/reactos/include/psdk/winbase.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/winbase.h?rev…
==============================================================================
--- trunk/reactos/include/psdk/winbase.h [iso-8859-1] (original)
+++ trunk/reactos/include/psdk/winbase.h [iso-8859-1] Sun Feb 22 16:39:21 2009
@@ -1151,6 +1151,7 @@
BOOL WINAPI AdjustTokenGroups(HANDLE,BOOL,PTOKEN_GROUPS,DWORD,PTOKEN_GROUPS,PDWORD);
BOOL WINAPI
AdjustTokenPrivileges(HANDLE,BOOL,PTOKEN_PRIVILEGES,DWORD,PTOKEN_PRIVILEGES,PDWORD);
BOOL WINAPI
AllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY,BYTE,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,PSID*);
+BOOL WINAPI CheckTokenMembership(HANDLE,PSID,PBOOL);
BOOL WINAPI AllocateLocallyUniqueId(PLUID);
BOOL WINAPI AreAllAccessesGranted(DWORD,DWORD);
BOOL WINAPI AreAnyAccessesGranted(DWORD,DWORD);