setupapi: Move IsUserAdmin to shell32.IsUserAnAdmin.
This commit is contained in:
parent
fb98499063
commit
ed1b527dd9
|
@ -30,6 +30,7 @@
|
|||
#include "lzexpand.h"
|
||||
#include "softpub.h"
|
||||
#include "mscat.h"
|
||||
#include "shlobj.h"
|
||||
|
||||
#include "wine/unicode.h"
|
||||
#include "wine/debug.h"
|
||||
|
@ -197,67 +198,8 @@ LONG WINAPI QueryRegistryValue(HKEY hKey,
|
|||
*/
|
||||
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;
|
||||
|
||||
TRACE("\n");
|
||||
|
||||
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 = MyMalloc(dwSize);
|
||||
if (lpGroups == NULL)
|
||||
{
|
||||
CloseHandle(hToken);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!GetTokenInformation(hToken, TokenGroups, lpGroups, dwSize, &dwSize))
|
||||
{
|
||||
MyFree(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))
|
||||
{
|
||||
MyFree(lpGroups);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (i = 0; i < lpGroups->GroupCount; i++)
|
||||
{
|
||||
if (EqualSid(lpSid, lpGroups->Groups[i].Sid))
|
||||
{
|
||||
bResult = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
FreeSid(lpSid);
|
||||
MyFree(lpGroups);
|
||||
|
||||
return bResult;
|
||||
return IsUserAnAdmin();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -251,7 +251,7 @@
|
|||
654 stdcall @(long long) shell32_654 # ReadCabinetState@8
|
||||
|
||||
660 stdcall -noname FileIconInit(long)
|
||||
680 stdcall -noname IsUserAdmin()
|
||||
680 stdcall -noname IsUserAnAdmin()
|
||||
|
||||
704 stdcall -noname GUIDFromStringW(wstr ptr)
|
||||
|
||||
|
|
|
@ -1279,13 +1279,79 @@ BOOL WINAPI FileIconInit(BOOL bFullInit)
|
|||
{ FIXME("(%s)\n", bFullInit ? "true" : "false");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* IsUserAdmin [SHELL32.680] NT 4.0
|
||||
* IsUserAnAdmin [SHELL32.680] NT 4.0
|
||||
*
|
||||
* Checks whether the current user is a member of the Administrators group.
|
||||
*
|
||||
* PARAMS
|
||||
* None
|
||||
*
|
||||
* RETURNS
|
||||
* Success: TRUE
|
||||
* Failure: FALSE
|
||||
*/
|
||||
HRESULT WINAPI IsUserAdmin(void)
|
||||
{ FIXME("stub\n");
|
||||
return TRUE;
|
||||
BOOL WINAPI IsUserAnAdmin(VOID)
|
||||
{
|
||||
SID_IDENTIFIER_AUTHORITY Authority = {SECURITY_NT_AUTHORITY};
|
||||
HANDLE hToken;
|
||||
DWORD dwSize;
|
||||
PTOKEN_GROUPS lpGroups;
|
||||
PSID lpSid;
|
||||
DWORD i;
|
||||
BOOL bResult = FALSE;
|
||||
|
||||
TRACE("\n");
|
||||
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;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
|
|
|
@ -77,6 +77,7 @@ VOID WINAPI SHUpdateImageW(LPCWSTR,INT,UINT,INT);
|
|||
#define SHUpdateImage WINELIB_NAME_AW(SHUpdateImage)
|
||||
int WINAPI RestartDialog(HWND,LPCWSTR,DWORD);
|
||||
int WINAPI RestartDialogEx(HWND,LPCWSTR,DWORD,DWORD);
|
||||
BOOL WINAPI IsUserAnAdmin(void);
|
||||
|
||||
#define SHFMT_ERROR 0xFFFFFFFFL /* Error on last format, drive may be formattable */
|
||||
#define SHFMT_CANCEL 0xFFFFFFFEL /* Last format was cancelled */
|
||||
|
|
Loading…
Reference in New Issue