- Store the initial desktop handle and use it evey time a new thread is created.

svn path=/trunk/; revision=51483
This commit is contained in:
Giannis Adamopoulos 2011-04-28 20:33:16 +00:00
parent f80c0cc156
commit 16afe3648f

View file

@ -154,6 +154,13 @@ Win32kProcessCallback(struct _EPROCESS *Process,
LogonProcess = NULL;
}
/* Close the startup desktop */
ASSERT(Win32Process->rpdeskStartup);
ASSERT(Win32Process->hdeskStartup);
ObDereferenceObject(Win32Process->rpdeskStartup);
ZwClose(Win32Process->hdeskStartup);
/* Close the current window station */
UserSetProcessWindowStation(NULL);
/* Destroy GDI pools */
@ -211,6 +218,7 @@ Win32kThreadCallback(struct _ETHREAD *Thread,
HDESK hDesk = NULL;
NTSTATUS Status;
PUNICODE_STRING DesktopPath;
PDESKTOP pdesk;
PRTL_USER_PROCESS_PARAMETERS ProcessParams = (Process->Peb ? Process->Peb->ProcessParameters : NULL);
DPRINT("Creating W32 thread TID:%d at IRQ level: %lu\n", Thread->Cid.UniqueThread, KeGetCurrentIrql());
@ -223,6 +231,22 @@ Win32kThreadCallback(struct _ETHREAD *Thread,
InitializeListHead(&Win32Thread->aphkStart[i]);
}
Win32Thread->TIF_flags &= ~TIF_INCLEANUP;
co_IntDestroyCaret(Win32Thread);
Win32Thread->ppi = PsGetCurrentProcessWin32Process();
Win32Thread->ptiSibling = Win32Thread->ppi->ptiList;
Win32Thread->ppi->ptiList = Win32Thread;
Win32Thread->ppi->cThreads++;
if (Win32Thread->rpdesk && !Win32Thread->pDeskInfo)
{
Win32Thread->pDeskInfo = Win32Thread->rpdesk->pDeskInfo;
}
Win32Thread->MessageQueue = MsqCreateMessageQueue(Thread);
Win32Thread->KeyboardLayout = W32kGetDefaultKeyLayout();
/* HAAAAAAAACK! This should go to Win32kProcessCallback */
if(Win32Thread->ppi->hdeskStartup == NULL)
{
/*
* inherit the thread desktop and process window station (if not yet inherited) from the process startup
* info structure. See documentation of CreateProcess()
@ -244,9 +268,16 @@ Win32kThreadCallback(struct _ETHREAD *Thread,
if (hDesk != NULL)
{
if (!IntSetThreadDesktop(hDesk, FALSE))
/* Validate the new desktop. */
Status = IntValidateDesktopHandle(hDesk,
UserMode,
0,
&pdesk);
if(NT_SUCCESS(Status))
{
DPRINT1("Unable to set thread desktop\n");
Win32Thread->ppi->hdeskStartup = hDesk;
Win32Thread->ppi->rpdeskStartup = pdesk;
}
}
}
@ -254,18 +285,16 @@ Win32kThreadCallback(struct _ETHREAD *Thread,
{
DPRINT1("No Desktop handle for this Thread!\n");
}
Win32Thread->TIF_flags &= ~TIF_INCLEANUP;
co_IntDestroyCaret(Win32Thread);
Win32Thread->ppi = PsGetCurrentProcessWin32Process();
Win32Thread->ptiSibling = Win32Thread->ppi->ptiList;
Win32Thread->ppi->ptiList = Win32Thread;
Win32Thread->ppi->cThreads++;
if (Win32Thread->rpdesk && !Win32Thread->pDeskInfo)
{
Win32Thread->pDeskInfo = Win32Thread->rpdesk->pDeskInfo;
}
Win32Thread->MessageQueue = MsqCreateMessageQueue(Thread);
Win32Thread->KeyboardLayout = W32kGetDefaultKeyLayout();
if (Win32Thread->ppi->hdeskStartup != NULL)
{
if (!IntSetThreadDesktop(Win32Thread->ppi->hdeskStartup, FALSE))
{
DPRINT1("Unable to set thread desktop\n");
}
}
pTeb = NtCurrentTeb();
if (pTeb)
{ /* Attempt to startup client support which should have been initialized in IntSetThreadDesktop. */