mirror of
https://github.com/reactos/reactos.git
synced 2025-01-05 22:12:46 +00:00
implemented IsTokenRestricted(), inspired by a patch to winehq by James Hawkins
svn path=/trunk/; revision=15958
This commit is contained in:
parent
a50fde81ae
commit
f6e5d12f4c
2 changed files with 68 additions and 1 deletions
|
@ -319,7 +319,7 @@ InitiateSystemShutdownA@20
|
||||||
InitiateSystemShutdownW@20
|
InitiateSystemShutdownW@20
|
||||||
;InstallApplication
|
;InstallApplication
|
||||||
IsTextUnicode@12=NTDLL.RtlIsTextUnicode
|
IsTextUnicode@12=NTDLL.RtlIsTextUnicode
|
||||||
;IsTokenRestricted
|
IsTokenRestricted@4
|
||||||
;IsTokenUntrusted
|
;IsTokenUntrusted
|
||||||
IsValidAcl@4
|
IsValidAcl@4
|
||||||
IsValidSecurityDescriptor@4
|
IsValidSecurityDescriptor@4
|
||||||
|
|
|
@ -401,4 +401,71 @@ ByeBye:
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL STDCALL
|
||||||
|
IsTokenRestricted(HANDLE TokenHandle)
|
||||||
|
{
|
||||||
|
ULONG RetLength;
|
||||||
|
PTOKEN_GROUPS lpGroups;
|
||||||
|
NTSTATUS Status;
|
||||||
|
BOOL Ret = FALSE;
|
||||||
|
|
||||||
|
/* determine the required buffer size and allocate enough memory to read the
|
||||||
|
list of restricted SIDs */
|
||||||
|
|
||||||
|
Status = NtQueryInformationToken(TokenHandle,
|
||||||
|
TokenRestrictedSids,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
&RetLength);
|
||||||
|
if (Status != STATUS_BUFFER_TOO_SMALL)
|
||||||
|
{
|
||||||
|
SetLastError(RtlNtStatusToDosError(Status));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
AllocAndReadRestrictedSids:
|
||||||
|
lpGroups = (PTOKEN_GROUPS)HeapAlloc(GetProcessHeap(),
|
||||||
|
0,
|
||||||
|
RetLength);
|
||||||
|
if (lpGroups == NULL)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_OUTOFMEMORY);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* actually read the list of the restricted SIDs */
|
||||||
|
|
||||||
|
Status = NtQueryInformationToken(TokenHandle,
|
||||||
|
TokenRestrictedSids,
|
||||||
|
lpGroups,
|
||||||
|
RetLength,
|
||||||
|
&RetLength);
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
Ret = (lpGroups->GroupCount != 0);
|
||||||
|
}
|
||||||
|
else if (Status == STATUS_BUFFER_TOO_SMALL)
|
||||||
|
{
|
||||||
|
/* looks like the token was modified in the meanwhile, let's just try again */
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(),
|
||||||
|
0,
|
||||||
|
lpGroups);
|
||||||
|
|
||||||
|
goto AllocAndReadRestrictedSids;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetLastError(RtlNtStatusToDosError(Status));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free allocated memory */
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(),
|
||||||
|
0,
|
||||||
|
lpGroups);
|
||||||
|
|
||||||
|
return Ret;
|
||||||
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
Loading…
Reference in a new issue