mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
Fix NtOpenThreadToken() and NtSetInformationThread().
svn path=/trunk/; revision=8791
This commit is contained in:
parent
d037d068ff
commit
c89688b59d
2 changed files with 134 additions and 96 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $Id: create.c,v 1.71 2004/03/14 18:12:07 ekohl Exp $
|
||||
/* $Id: create.c,v 1.72 2004/03/19 12:45:07 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -183,10 +183,10 @@ NtImpersonateThread(IN HANDLE ThreadHandle,
|
|||
IN HANDLE ThreadToImpersonateHandle,
|
||||
IN PSECURITY_QUALITY_OF_SERVICE SecurityQualityOfService)
|
||||
{
|
||||
SECURITY_CLIENT_CONTEXT ClientContext;
|
||||
PETHREAD Thread;
|
||||
PETHREAD ThreadToImpersonate;
|
||||
NTSTATUS Status;
|
||||
SECURITY_CLIENT_CONTEXT ClientContext;
|
||||
|
||||
Status = ObReferenceObjectByHandle (ThreadHandle,
|
||||
0,
|
||||
|
@ -196,7 +196,7 @@ NtImpersonateThread(IN HANDLE ThreadHandle,
|
|||
NULL);
|
||||
if (!NT_SUCCESS (Status))
|
||||
{
|
||||
return(Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = ObReferenceObjectByHandle (ThreadToImpersonateHandle,
|
||||
|
@ -208,7 +208,7 @@ NtImpersonateThread(IN HANDLE ThreadHandle,
|
|||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ObDereferenceObject (Thread);
|
||||
return(Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = SeCreateClientSecurity (ThreadToImpersonate,
|
||||
|
@ -217,17 +217,22 @@ NtImpersonateThread(IN HANDLE ThreadHandle,
|
|||
&ClientContext);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ObDereferenceObject(Thread);
|
||||
ObDereferenceObject (ThreadToImpersonate);
|
||||
return(Status);
|
||||
ObDereferenceObject (Thread);
|
||||
return Status;
|
||||
}
|
||||
|
||||
SeImpersonateClient(&ClientContext, Thread);
|
||||
SeImpersonateClient (&ClientContext,
|
||||
Thread);
|
||||
if (ClientContext.Token != NULL)
|
||||
{
|
||||
ObDereferenceObject (ClientContext.Token);
|
||||
}
|
||||
return(STATUS_SUCCESS);
|
||||
|
||||
ObDereferenceObject (ThreadToImpersonate);
|
||||
ObDereferenceObject (Thread);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
@ -237,10 +242,9 @@ NtOpenThreadToken (IN HANDLE ThreadHandle,
|
|||
IN BOOLEAN OpenAsSelf,
|
||||
OUT PHANDLE TokenHandle)
|
||||
{
|
||||
#if 0
|
||||
PACCESS_TOKEN Token;
|
||||
PETHREAD Thread;
|
||||
NTSTATUS Status;
|
||||
PACCESS_TOKEN Token;
|
||||
|
||||
Status = ObReferenceObjectByHandle (ThreadHandle,
|
||||
0,
|
||||
|
@ -253,12 +257,38 @@ NtOpenThreadToken (IN HANDLE ThreadHandle,
|
|||
return(Status);
|
||||
}
|
||||
|
||||
Token = PsReferencePrimaryToken(Thread->ThreadsProcess);
|
||||
SepCreateImpersonationTokenDacl(Token);
|
||||
#endif
|
||||
if (OpenAsSelf)
|
||||
{
|
||||
if (Thread->ActiveImpersonationInfo == FALSE)
|
||||
{
|
||||
ObDereferenceObject (Thread);
|
||||
return STATUS_NO_TOKEN;
|
||||
}
|
||||
|
||||
Token = Thread->ImpersonationInfo->Token;
|
||||
}
|
||||
else
|
||||
{
|
||||
Token = Thread->ThreadsProcess->Token;
|
||||
}
|
||||
|
||||
if (Token == NULL)
|
||||
{
|
||||
ObDereferenceObject (Thread);
|
||||
return STATUS_NO_TOKEN;
|
||||
}
|
||||
|
||||
Status = ObCreateHandle (PsGetCurrentProcess(),
|
||||
Token,
|
||||
DesiredAccess,
|
||||
FALSE,
|
||||
TokenHandle);
|
||||
|
||||
ObDereferenceObject (Thread);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: tinfo.c,v 1.24 2003/12/30 18:52:05 fireball Exp $
|
||||
/* $Id: tinfo.c,v 1.25 2004/03/19 12:45:07 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -23,10 +23,10 @@
|
|||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
NTSTATUS STDCALL
|
||||
NtSetInformationThread(HANDLE ThreadHandle,
|
||||
THREADINFOCLASS ThreadInformationClass,
|
||||
PVOID ThreadInformation,
|
||||
ULONG ThreadInformationLength)
|
||||
NtSetInformationThread (IN HANDLE ThreadHandle,
|
||||
IN THREADINFOCLASS ThreadInformationClass,
|
||||
IN PVOID ThreadInformation,
|
||||
IN ULONG ThreadInformationLength)
|
||||
{
|
||||
PETHREAD Thread;
|
||||
NTSTATUS Status;
|
||||
|
@ -77,6 +77,7 @@ NtSetInformationThread(HANDLE ThreadHandle,
|
|||
case ThreadBasePriority:
|
||||
{
|
||||
LONG Increment;
|
||||
|
||||
if (ThreadInformationLength != sizeof(LONG))
|
||||
{
|
||||
Status = STATUS_INFO_LENGTH_MISMATCH;
|
||||
|
@ -106,7 +107,8 @@ NtSetInformationThread(HANDLE ThreadHandle,
|
|||
break;
|
||||
}
|
||||
TokenHandle = *((PHANDLE)ThreadInformation);
|
||||
Status = PsAssignImpersonationToken(Thread, TokenHandle);
|
||||
Status = PsAssignImpersonationToken (Thread,
|
||||
TokenHandle);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -199,7 +201,9 @@ NtSetInformationThread(HANDLE ThreadHandle,
|
|||
default:
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
ObDereferenceObject (Thread);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -364,11 +368,14 @@ NtQueryInformationThread (IN HANDLE ThreadHandle,
|
|||
return(Status);
|
||||
}
|
||||
|
||||
VOID KeSetPreviousMode(ULONG Mode)
|
||||
|
||||
VOID
|
||||
KeSetPreviousMode (ULONG Mode)
|
||||
{
|
||||
PsGetCurrentThread()->Tcb.PreviousMode = (UCHAR)Mode;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
|
@ -378,6 +385,7 @@ KeGetPreviousMode (VOID)
|
|||
return (ULONG)PsGetCurrentThread()->Tcb.PreviousMode;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue