- Remove some debug prints that are not needed anymore

- NtCurrentTeb now returns the TEB instead of the KCPR, so re-enable the codepath that set the CurrentLocale and IdealProcessor in the TEB from the KTHREAD.

svn path=/trunk/; revision=23067
This commit is contained in:
Alex Ionescu 2006-07-15 20:10:13 +00:00
parent 1af6dae1c1
commit 78874d1548
2 changed files with 15 additions and 48 deletions

View file

@ -9,10 +9,9 @@
/* /*
* Alex FIXMEs: * Alex FIXMEs:
* - CRITICAL: NtCurrentTeb returns KPCR.
* - MAJOR: Use Process Rundown * - MAJOR: Use Process Rundown
* - MAJOR: Use Process Pushlock Locks * - MAJOR: Use Process Pushlock Locks
* - MAJOR: Implement Safe Referencing (See PsGetNextProcess/Thread). * - MAJOR: Use Safe Referencing in PsGetNextProcess/Thread.
* - MAJOR: Use Guarded Mutex instead of Fast Mutex for Active Process Locks. * - MAJOR: Use Guarded Mutex instead of Fast Mutex for Active Process Locks.
* - Generate process cookie for user-more thread. * - Generate process cookie for user-more thread.
* - Add security calls where necessary. * - Add security calls where necessary.
@ -56,15 +55,14 @@ PspUserThreadStartup(PKSTART_ROUTINE StartRoutine,
if (Thread->DeadThread) if (Thread->DeadThread)
{ {
/* Remember that we're dead */ /* Remember that we're dead */
DPRINT1("This thread is already dead\n");
DeadThread = TRUE; DeadThread = TRUE;
} }
else else
{ {
/* Get the Locale ID and save Preferred Proc */ /* Get the Locale ID and save Preferred Proc */
Teb = NtCurrentTeb(); /* FIXME: This returns KPCR!!! */ Teb = NtCurrentTeb();
//Teb->CurrentLocale = MmGetSessionLocaleId(); Teb->CurrentLocale = MmGetSessionLocaleId();
//Teb->IdealProcessor = Thread->Tcb.IdealProcessor; Teb->IdealProcessor = Thread->Tcb.IdealProcessor;
} }
/* Check if this is a system thread, or if we're hiding */ /* Check if this is a system thread, or if we're hiding */
@ -191,11 +189,7 @@ PspCreateThread(OUT PHANDLE ThreadHandle,
} }
/* Check for success */ /* Check for success */
if(!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status)) return Status;
{
DPRINT1("Invalid Process Handle, or no handle given\n");
return Status;
}
/* Also make sure that User-Mode isn't trying to create a system thread */ /* Also make sure that User-Mode isn't trying to create a system thread */
if ((PreviousMode != KernelMode) && (Process == PsInitialSystemProcess)) if ((PreviousMode != KernelMode) && (Process == PsInitialSystemProcess))
@ -217,7 +211,6 @@ PspCreateThread(OUT PHANDLE ThreadHandle,
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
/* We failed; dereference the process and exit */ /* We failed; dereference the process and exit */
DPRINT1("Failed to Create Thread Object\n");
ObDereferenceObject(Process); ObDereferenceObject(Process);
return Status; return Status;
} }
@ -236,7 +229,6 @@ PspCreateThread(OUT PHANDLE ThreadHandle,
if (!Thread->Cid.UniqueThread) if (!Thread->Cid.UniqueThread)
{ {
/* We couldn't create the CID, dereference everything and fail */ /* We couldn't create the CID, dereference everything and fail */
DPRINT1("Failed to create Thread Handle (CID)\n");
ObDereferenceObject(Process); ObDereferenceObject(Process);
ObDereferenceObject(Thread); ObDereferenceObject(Thread);
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
@ -628,11 +620,7 @@ NtCreateThread(OUT PHANDLE ThreadHandle,
if(KeGetPreviousMode() != KernelMode) if(KeGetPreviousMode() != KernelMode)
{ {
/* Make sure that we got a context */ /* Make sure that we got a context */
if (!ThreadContext) if (!ThreadContext) return STATUS_INVALID_PARAMETER;
{
DPRINT1("No context for User-Mode Thread!!\n");
return STATUS_INVALID_PARAMETER;
}
/* Protect checks */ /* Protect checks */
_SEH_TRY _SEH_TRY
@ -761,9 +749,8 @@ NtOpenThread(OUT PHANDLE ThreadHandle,
DesiredAccess, DesiredAccess,
NULL, NULL,
&hThread); &hThread);
if (!NT_SUCCESS(Status)) DPRINT1("Could not open object by name\n"); }
} else if (ClientId)
else if (ClientId != NULL)
{ {
/* Open by Thread ID */ /* Open by Thread ID */
if (ClientId->UniqueProcess) if (ClientId->UniqueProcess)
@ -780,11 +767,8 @@ NtOpenThread(OUT PHANDLE ThreadHandle,
&Thread); &Thread);
} }
if(!NT_SUCCESS(Status)) /* Fail if we didn't find anything */
{ if(!NT_SUCCESS(Status)) return Status;
DPRINT1("Failure to find Thread\n");
return Status;
}
/* Open the Thread Object */ /* Open the Thread Object */
Status = ObOpenObjectByPointer(Thread, Status = ObOpenObjectByPointer(Thread,
@ -794,10 +778,6 @@ NtOpenThread(OUT PHANDLE ThreadHandle,
PsThreadType, PsThreadType,
PreviousMode, PreviousMode,
&hThread); &hThread);
if(!NT_SUCCESS(Status))
{
DPRINT1("Failure to open Thread\n");
}
/* Dereference the thread */ /* Dereference the thread */
ObDereferenceObject(Thread); ObDereferenceObject(Thread);
@ -809,7 +789,7 @@ NtOpenThread(OUT PHANDLE ThreadHandle,
} }
/* Check for success */ /* Check for success */
if(NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
/* Protect against bad user-mode pointers */ /* Protect against bad user-mode pointers */
_SEH_TRY _SEH_TRY

View file

@ -72,23 +72,15 @@ PsConvertToGuiThread(VOID)
PAGED_CODE(); PAGED_CODE();
/* Validate the previous mode */ /* Validate the previous mode */
if (KeGetPreviousMode() == KernelMode) if (KeGetPreviousMode() == KernelMode) return STATUS_INVALID_PARAMETER;
{
DPRINT1("Danger: win32k call being made in kernel-mode?!\n");
return STATUS_INVALID_PARAMETER;
}
/* Make sure win32k is here */ /* Make sure win32k is here */
if (!PspW32ProcessCallout) if (!PspW32ProcessCallout) return STATUS_ACCESS_DENIED;
{
DPRINT1("Danger: Win32K call attempted but Win32k not ready!\n");
return STATUS_ACCESS_DENIED;
}
/* Make sure it's not already win32 */ /* Make sure it's not already win32 */
if (Thread->Tcb.ServiceTable != KeServiceDescriptorTable) if (Thread->Tcb.ServiceTable != KeServiceDescriptorTable)
{ {
DPRINT1("Danger: Thread is already a win32 thread. Limit bypassed?\n"); /* We're already a win32 thread */
return STATUS_ALREADY_WIN32; return STATUS_ALREADY_WIN32;
} }
@ -123,11 +115,7 @@ PsConvertToGuiThread(VOID)
{ {
/* Now tell win32k about us */ /* Now tell win32k about us */
Status = PspW32ProcessCallout(Process, TRUE); Status = PspW32ProcessCallout(Process, TRUE);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status)) return Status;
{
DPRINT1("Danger: Win32k wasn't happy about us!\n");
return Status;
}
} }
/* Set the new service table */ /* Set the new service table */
@ -139,7 +127,6 @@ PsConvertToGuiThread(VOID)
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
/* Revert our table */ /* Revert our table */
DPRINT1("Danger: Win32k wasn't happy about us!\n");
Thread->Tcb.ServiceTable = KeServiceDescriptorTable; Thread->Tcb.ServiceTable = KeServiceDescriptorTable;
} }