[ros-diffs] [dchapyshev] 39709: - Don't direct call IsUserAnAdmin (setupapi in Windows not linked with shell32) - Implement IsUserAdmin in setupapi (based on shell32 implementation) - Implement pSetupIsUserAdmin

dchapyshev at svn.reactos.org dchapyshev at svn.reactos.org
Sun Feb 22 13:49:19 CET 2009


Author: dchapyshev
Date: Sun Feb 22 15:49:18 2009
New Revision: 39709

URL: http://svn.reactos.org/svn/reactos?rev=39709&view=rev
Log:
- Don't direct call IsUserAnAdmin (setupapi in Windows not linked with shell32)
- Implement IsUserAdmin in setupapi (based on shell32 implementation)
- Implement pSetupIsUserAdmin

Modified:
    trunk/reactos/dll/win32/setupapi/cfgmgr.c
    trunk/reactos/dll/win32/setupapi/misc.c
    trunk/reactos/dll/win32/setupapi/setupapi.spec

Modified: trunk/reactos/dll/win32/setupapi/cfgmgr.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/cfgmgr.c?rev=39709&r1=39708&r2=39709&view=diff
==============================================================================
--- trunk/reactos/dll/win32/setupapi/cfgmgr.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/setupapi/cfgmgr.c [iso-8859-1] Sun Feb 22 15:49:18 2009
@@ -153,7 +153,7 @@
     if (!PnpGetLocalHandles(&BindingHandle, NULL))
         return CR_FAILURE;
 
-    bAdmin = IsUserAnAdmin();
+    bAdmin = IsUserAdmin();
 
     for (i = 0; i < 30; i++)
     {
@@ -209,7 +209,7 @@
     FIXME("%p %p %lu %lx %p\n",
           plcLogConf, dnDevInst, Priority, ulFlags, hMachine);
 
-    if (!IsUserAnAdmin())
+    if (!IsUserAdmin())
         return CR_ACCESS_DENIED;
 
     if (plcLogConf == NULL)
@@ -336,7 +336,7 @@
 
     TRACE("%p %s %lx %p\n", dnDevInst, debugstr_w(pszID), ulFlags, hMachine);
 
-    if (!IsUserAnAdmin())
+    if (!IsUserAdmin())
         return CR_ACCESS_DENIED;
 
     if (dnDevInst == 0)
@@ -543,7 +543,7 @@
     FIXME("%p %s %p %lx %p\n",
           pdnDevInst, debugstr_w(pDeviceID), dnParent, ulFlags, hMachine);
 
-    if (!IsUserAnAdmin())
+    if (!IsUserAdmin())
         return CR_ACCESS_DENIED;
 
     if (pdnDevInst == NULL)
@@ -713,7 +713,7 @@
 
     FIXME("%p %lx %p\n", dnDevInst, ulFlags, hMachine);
 
-    if (!IsUserAnAdmin())
+    if (!IsUserAdmin())
         return CR_ACCESS_DENIED;
 
     if (dnDevInst == 0)
@@ -812,7 +812,7 @@
 
     FIXME("%p %lx %p\n", dnDevInst, ulFlags, hMachine);
 
-    if (!IsUserAnAdmin())
+    if (!IsUserAdmin())
         return CR_ACCESS_DENIED;
 
     if (dnDevInst == 0)
@@ -1079,7 +1079,7 @@
 
     TRACE("%lx %lx %lx\n", lcLogConfToBeFreed, ulFlags, hMachine);
 
-    if (!IsUserAnAdmin())
+    if (!IsUserAdmin())
         return CR_ACCESS_DENIED;
 
     pLogConfInfo = (PLOG_CONF_INFO)lcLogConfToBeFreed;
@@ -3008,7 +3008,7 @@
     FIXME("%lx %lx %lx %lx\n",
           dnFromDevInst, dnToDevInst, ulFlags, hMachine);
 
-    if (!IsUserAnAdmin())
+    if (!IsUserAdmin())
         return CR_ACCESS_DENIED;
 
     if (dnFromDevInst == 0 || dnToDevInst == 0)
@@ -3385,7 +3385,7 @@
 
     TRACE("%lx %lx\n", ulFlags, hMachine);
 
-    if (!IsUserAnAdmin())
+    if (!IsUserAdmin())
         return CR_ACCESS_DENIED;
 
     if (ulFlags & ~CM_DETECT_BITS)
@@ -3903,7 +3903,7 @@
 
     FIXME("%lx %lx %lx\n", dnDevInst, ulFlags, hMachine);
 
-    if (!IsUserAnAdmin())
+    if (!IsUserAdmin())
         return CR_ACCESS_DENIED;
 
     if (dnDevInst == 0)

Modified: trunk/reactos/dll/win32/setupapi/misc.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/misc.c?rev=39709&r1=39708&r2=39709&view=diff
==============================================================================
--- trunk/reactos/dll/win32/setupapi/misc.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/setupapi/misc.c [iso-8859-1] Sun Feb 22 15:49:18 2009
@@ -1685,3 +1685,71 @@
 {
     return IsEqualGUID(lpGUID, &GUID_NULL);
 }
+
+/*
+ * implemented
+ */
+BOOL
+WINAPI
+IsUserAdmin(VOID)
+{
+    SID_IDENTIFIER_AUTHORITY Authority = {SECURITY_NT_AUTHORITY};
+    HANDLE hToken;
+    DWORD dwSize;
+    PTOKEN_GROUPS lpGroups;
+    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;
+        }
+    }
+
+    FreeSid(lpSid);
+    HeapFree(GetProcessHeap(), 0, lpGroups);
+
+    return bResult;
+}

Modified: trunk/reactos/dll/win32/setupapi/setupapi.spec
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/setupapi.spec?rev=39709&r1=39708&r2=39709&view=diff
==============================================================================
--- trunk/reactos/dll/win32/setupapi/setupapi.spec [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/setupapi/setupapi.spec [iso-8859-1] Sun Feb 22 15:49:18 2009
@@ -213,7 +213,7 @@
 @ stdcall InstallHinfSection(long long str long) InstallHinfSectionA
 @ stdcall InstallHinfSectionA(long long str long)
 @ stdcall InstallHinfSectionW(long long wstr long)
-@ stdcall IsUserAdmin() shell32.IsUserAnAdmin
+@ stdcall IsUserAdmin()
 @ stdcall MyFree(ptr)
 @ stdcall MyMalloc(long)
 @ stdcall MyRealloc(ptr long)
@@ -566,7 +566,7 @@
 @ stub pSetupInstallStopEx
 @ stdcall pSetupIsGuidNull(ptr)
 @ stub pSetupIsLocalSystem
-@ stub pSetupIsUserAdmin
+@ stdcall pSetupIsUserAdmin() IsUserAdmin
 @ stub pSetupMakeSurePathExists
 @ stub pSetupMalloc
 @ stub pSetupModifyGlobalFlags



More information about the Ros-diffs mailing list