[WIN32K:NTUSER] Add an extra optional "Process" parameter to the GetProcessLuid() function to be used alternatively in place of "Thread" to retrieve the LUID.

This commit is contained in:
Hermès Bélusca-Maïto 2018-06-16 19:44:27 +02:00
parent d77c493213
commit 2345d63ce3
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
3 changed files with 30 additions and 15 deletions

View file

@ -766,30 +766,44 @@ GetW32ThreadInfo(VOID)
NTSTATUS
GetProcessLuid(
IN PETHREAD Thread OPTIONAL,
IN PEPROCESS Process OPTIONAL,
OUT PLUID Luid)
{
NTSTATUS Status;
PACCESS_TOKEN Token;
PACCESS_TOKEN Token = NULL;
SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
BOOLEAN CopyOnOpen, EffectiveOnly;
if (Thread == NULL)
if (Thread && Process)
return STATUS_INVALID_PARAMETER;
/* If nothing has been specified, use the current thread */
if (!Thread && !Process)
Thread = PsGetCurrentThread();
/* Use a thread token */
Token = PsReferenceImpersonationToken(Thread,
&CopyOnOpen,
&EffectiveOnly,
&ImpersonationLevel);
if (Token == NULL)
if (Thread)
{
/* We don't have a thread token, use a process token */
Token = PsReferencePrimaryToken(PsGetThreadProcess(Thread));
/* Use a thread token */
ASSERT(!Process);
Token = PsReferenceImpersonationToken(Thread,
&CopyOnOpen,
&EffectiveOnly,
&ImpersonationLevel);
/* If no token, fail */
if (Token == NULL)
/* If we don't have a thread token, use a process token */
if (!Token)
Process = PsGetThreadProcess(Thread);
}
if (!Token && Process)
{
/* Use a process token */
Token = PsReferencePrimaryToken(Process);
/* If we don't have a token, fail */
if (!Token)
return STATUS_NO_TOKEN;
}
ASSERT(Token);
/* Query the LUID */
Status = SeQueryAuthenticationIdToken(Token, Luid);

View file

@ -181,7 +181,7 @@ UserInitiateShutdown(IN PETHREAD Thread,
TRACE("UserInitiateShutdown\n");
/* Get the caller's LUID */
Status = GetProcessLuid(Thread, &CallerLuid);
Status = GetProcessLuid(Thread, NULL, &CallerLuid);
if (!NT_SUCCESS(Status))
{
ERR("UserInitiateShutdown: GetProcessLuid failed\n");
@ -302,10 +302,10 @@ UserEndShutdown(IN PETHREAD Thread,
*/
//STUB;
Status = GetProcessLuid(Thread, &CallerLuid);
Status = GetProcessLuid(Thread, NULL, &CallerLuid);
if (!NT_SUCCESS(Status))
{
ERR("GetProcessLuid failed\n");
ERR("UserEndShutdown: GetProcessLuid failed\n");
return Status;
}

View file

@ -108,6 +108,7 @@ HBRUSH FASTCALL GetControlColor(PWND,PWND,HDC,UINT);
NTSTATUS
GetProcessLuid(
IN PETHREAD Thread OPTIONAL,
IN PEPROCESS Process OPTIONAL,
OUT PLUID Luid);
/*************** MESSAGE.C ***************/