reactos/ntoskrnl/ps
diff -u -r1.71 -r1.72
--- create.c 14 Mar 2004 18:12:07 -0000 1.71
+++ create.c 19 Mar 2004 12:45:07 -0000 1.72
@@ -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
@@ -58,7 +58,7 @@
PACCESS_TOKEN Token;
SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
NTSTATUS Status;
-
+
if (TokenHandle != NULL)
{
Status = ObReferenceObjectByHandle(TokenHandle,
@@ -78,7 +78,7 @@
Token = NULL;
ImpersonationLevel = 0;
}
-
+
PsImpersonateClient(Thread,
Token,
0,
@@ -183,51 +183,56 @@
IN HANDLE ThreadToImpersonateHandle,
IN PSECURITY_QUALITY_OF_SERVICE SecurityQualityOfService)
{
- PETHREAD Thread;
- PETHREAD ThreadToImpersonate;
- NTSTATUS Status;
- SECURITY_CLIENT_CONTEXT ClientContext;
-
- Status = ObReferenceObjectByHandle(ThreadHandle,
+ SECURITY_CLIENT_CONTEXT ClientContext;
+ PETHREAD Thread;
+ PETHREAD ThreadToImpersonate;
+ NTSTATUS Status;
+
+ Status = ObReferenceObjectByHandle (ThreadHandle,
0,
PsThreadType,
UserMode,
(PVOID*)&Thread,
NULL);
- if (!NT_SUCCESS(Status))
- {
- return(Status);
- }
-
- Status = ObReferenceObjectByHandle(ThreadToImpersonateHandle,
+ if (!NT_SUCCESS (Status))
+ {
+ return Status;
+ }
+
+ Status = ObReferenceObjectByHandle (ThreadToImpersonateHandle,
0,
PsThreadType,
UserMode,
(PVOID*)&ThreadToImpersonate,
NULL);
- if (!NT_SUCCESS(Status))
- {
- ObDereferenceObject(Thread);
- return(Status);
- }
-
- Status = SeCreateClientSecurity(ThreadToImpersonate,
+ if (!NT_SUCCESS(Status))
+ {
+ ObDereferenceObject (Thread);
+ return Status;
+ }
+
+ Status = SeCreateClientSecurity (ThreadToImpersonate,
SecurityQualityOfService,
0,
&ClientContext);
- if (!NT_SUCCESS(Status))
- {
- ObDereferenceObject(Thread);
- ObDereferenceObject(ThreadToImpersonate);
- return(Status);
- }
-
- SeImpersonateClient(&ClientContext, Thread);
- if (ClientContext.Token != NULL)
- {
- ObDereferenceObject(ClientContext.Token);
+ if (!NT_SUCCESS(Status))
+ {
+ ObDereferenceObject (ThreadToImpersonate);
+ ObDereferenceObject (Thread);
+ return Status;
}
- return(STATUS_SUCCESS);
+
+ SeImpersonateClient (&ClientContext,
+ Thread);
+ if (ClientContext.Token != NULL)
+ {
+ ObDereferenceObject (ClientContext.Token);
+ }
+
+ ObDereferenceObject (ThreadToImpersonate);
+ ObDereferenceObject (Thread);
+
+ return STATUS_SUCCESS;
}
@@ -237,12 +242,11 @@
IN BOOLEAN OpenAsSelf,
OUT PHANDLE TokenHandle)
{
-#if 0
- PETHREAD Thread;
- NTSTATUS Status;
- PACCESS_TOKEN Token;
-
- Status = ObReferenceObjectByHandle(ThreadHandle,
+ PACCESS_TOKEN Token;
+ PETHREAD Thread;
+ NTSTATUS Status;
+
+ Status = ObReferenceObjectByHandle (ThreadHandle,
0,
PsThreadType,
UserMode,
@@ -252,11 +256,37 @@
{
return(Status);
}
-
- Token = PsReferencePrimaryToken(Thread->ThreadsProcess);
- SepCreateImpersonationTokenDacl(Token);
-#endif
- return STATUS_NO_TOKEN;
+
+ 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;
}
reactos/ntoskrnl/ps
diff -u -r1.24 -r1.25
--- tinfo.c 30 Dec 2003 18:52:05 -0000 1.24
+++ tinfo.c 19 Mar 2004 12:45:07 -0000 1.25
@@ -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
@@ -22,28 +22,28 @@
/* FUNCTIONS *****************************************************************/
-NTSTATUS STDCALL
-NtSetInformationThread(HANDLE ThreadHandle,
- THREADINFOCLASS ThreadInformationClass,
- PVOID ThreadInformation,
- ULONG ThreadInformationLength)
+NTSTATUS STDCALL
+NtSetInformationThread (IN HANDLE ThreadHandle,
+ IN THREADINFOCLASS ThreadInformationClass,
+ IN PVOID ThreadInformation,
+ IN ULONG ThreadInformationLength)
{
- PETHREAD Thread;
- NTSTATUS Status;
-
- Status = ObReferenceObjectByHandle(ThreadHandle,
+ PETHREAD Thread;
+ NTSTATUS Status;
+
+ Status = ObReferenceObjectByHandle (ThreadHandle,
THREAD_SET_INFORMATION,
PsThreadType,
- ExGetPreviousMode(),
+ ExGetPreviousMode (),
(PVOID*)&Thread,
NULL);
if (!NT_SUCCESS(Status))
{
return Status;
}
-
- switch (ThreadInformationClass)
- {
+
+ switch (ThreadInformationClass)
+ {
case ThreadBasicInformation:
/* Can only be queried */
Status = STATUS_INVALID_INFO_CLASS;
@@ -57,7 +57,7 @@
case ThreadPriority:
{
KPRIORITY Priority;
-
+
if (ThreadInformationLength != sizeof(KPRIORITY))
{
Status = STATUS_INFO_LENGTH_MISMATCH;
@@ -77,17 +77,18 @@
case ThreadBasePriority:
{
LONG Increment;
+
if (ThreadInformationLength != sizeof(LONG))
{
Status = STATUS_INFO_LENGTH_MISMATCH;
break;
}
- Status = MmCopyFromCaller(&Increment,
- ThreadInformation,
- sizeof(ULONG));
- if (NT_SUCCESS(Status))
- {
- KeSetBasePriorityThread (&Thread->Tcb, Increment);
+ Status = MmCopyFromCaller(&Increment,
+ ThreadInformation,
+ sizeof(ULONG));
+ if (NT_SUCCESS(Status))
+ {
+ KeSetBasePriorityThread (&Thread->Tcb, Increment);
}
}
break;
@@ -106,7 +107,8 @@
break;
}
TokenHandle = *((PHANDLE)ThreadInformation);
- Status = PsAssignImpersonationToken(Thread, TokenHandle);
+ Status = PsAssignImpersonationToken (Thread,
+ TokenHandle);
break;
}
@@ -158,49 +160,51 @@
Thread->u2.Win32StartAddress = (PVOID)*((PULONG)ThreadInformation);
Status = STATUS_SUCCESS;
break;
-
+
case ThreadZeroTlsCell:
{
Status = STATUS_NOT_IMPLEMENTED;
break;
}
-
+
case ThreadPerformanceCount:
/* Can only be queried */
Status = STATUS_INVALID_INFO_CLASS;
break;
-
+
case ThreadAmILastThread:
/* Can only be queried */
Status = STATUS_INVALID_INFO_CLASS;
break;
-
- case ThreadIdealProcessor:
- Status = STATUS_NOT_IMPLEMENTED;
- break;
-
- case ThreadPriorityBoost:
- Status = STATUS_NOT_IMPLEMENTED;
- break;
-
- case ThreadSetTlsArrayAddress:
- Status = STATUS_NOT_IMPLEMENTED;
- break;
- case ThreadIsIoPending:
- /* Can only be queried */
- Status = STATUS_INVALID_INFO_CLASS;
- break;
+ case ThreadIdealProcessor:
+ Status = STATUS_NOT_IMPLEMENTED;
+ break;
- case ThreadHideFromDebugger:
- Status = STATUS_NOT_IMPLEMENTED;
- break;
+ case ThreadPriorityBoost:
+ Status = STATUS_NOT_IMPLEMENTED;
+ break;
+
+ case ThreadSetTlsArrayAddress:
+ Status = STATUS_NOT_IMPLEMENTED;
+ break;
+
+ case ThreadIsIoPending:
+ /* Can only be queried */
+ Status = STATUS_INVALID_INFO_CLASS;
+ break;
+
+ case ThreadHideFromDebugger:
+ Status = STATUS_NOT_IMPLEMENTED;
+ break;
default:
Status = STATUS_UNSUCCESSFUL;
- }
- ObDereferenceObject(Thread);
- return Status;
+ }
+
+ ObDereferenceObject (Thread);
+
+ return Status;
}
@@ -364,27 +368,31 @@
return(Status);
}
-VOID KeSetPreviousMode(ULONG Mode)
+
+VOID
+KeSetPreviousMode (ULONG Mode)
{
- PsGetCurrentThread()->Tcb.PreviousMode = (UCHAR)Mode;
+ PsGetCurrentThread()->Tcb.PreviousMode = (UCHAR)Mode;
}
+
/*
* @implemented
*/
ULONG STDCALL
KeGetPreviousMode (VOID)
{
- return (ULONG)PsGetCurrentThread()->Tcb.PreviousMode;
+ return (ULONG)PsGetCurrentThread()->Tcb.PreviousMode;
}
+
/*
* @implemented
*/
KPROCESSOR_MODE STDCALL
ExGetPreviousMode (VOID)
{
- return (KPROCESSOR_MODE)PsGetCurrentThread()->Tcb.PreviousMode;
+ return (KPROCESSOR_MODE)PsGetCurrentThread()->Tcb.PreviousMode;
}
/* EOF */