2003-03-06 23:57:03 +00:00
|
|
|
/* $Id: guicheck.c,v 1.10 2003/03/06 23:57:03 gvg Exp $
|
2001-06-12 17:51:51 +00:00
|
|
|
*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
|
|
|
* PURPOSE: GUI state check
|
|
|
|
* FILE: subsys/win32k/ntuser/guicheck.c
|
|
|
|
* PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
|
|
|
|
* NOTES: The GuiCheck() function performs a few delayed operations:
|
|
|
|
* 1) A GUI process is assigned a window station
|
|
|
|
* 2) A message queue is created for a GUI thread before use
|
|
|
|
* 3) The system window classes are registered for a process
|
|
|
|
* REVISION HISTORY:
|
|
|
|
* 06-06-2001 CSH Created
|
|
|
|
*/
|
2002-01-13 22:52:08 +00:00
|
|
|
|
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
|
2002-09-08 10:23:54 +00:00
|
|
|
#include <ddk/ntddk.h>
|
|
|
|
#include <napi/teb.h>
|
2001-06-12 17:51:51 +00:00
|
|
|
#include <win32k/win32k.h>
|
|
|
|
#include <include/guicheck.h>
|
|
|
|
#include <include/msgqueue.h>
|
2002-01-27 01:11:24 +00:00
|
|
|
#include <include/object.h>
|
2002-09-08 10:23:54 +00:00
|
|
|
#include <napi/win32.h>
|
2002-07-04 19:56:38 +00:00
|
|
|
#include <include/winsta.h>
|
2001-06-12 17:51:51 +00:00
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
2002-09-17 23:43:29 +00:00
|
|
|
/* GLOBALS *******************************************************************/
|
|
|
|
|
|
|
|
static ULONG NrGuiApplicationsRunning = 0;
|
|
|
|
|
2002-01-13 22:52:08 +00:00
|
|
|
/* FUNCTIONS *****************************************************************/
|
2001-06-12 17:51:51 +00:00
|
|
|
|
|
|
|
VOID
|
2003-03-06 23:57:03 +00:00
|
|
|
W32kGraphicsCheck(BOOL Create)
|
2001-06-12 17:51:51 +00:00
|
|
|
{
|
2003-03-06 23:57:03 +00:00
|
|
|
if (Create)
|
2002-09-17 23:43:29 +00:00
|
|
|
{
|
2003-03-06 23:57:03 +00:00
|
|
|
if (0 == NrGuiApplicationsRunning)
|
|
|
|
{
|
|
|
|
W32kInitializeDesktopGraphics();
|
|
|
|
}
|
|
|
|
NrGuiApplicationsRunning++;
|
2002-09-17 23:43:29 +00:00
|
|
|
}
|
2003-03-06 23:57:03 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (0 < NrGuiApplicationsRunning)
|
|
|
|
{
|
|
|
|
NrGuiApplicationsRunning--;
|
|
|
|
}
|
|
|
|
if (0 == NrGuiApplicationsRunning)
|
|
|
|
{
|
|
|
|
W32kEndDesktopGraphics();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-09-17 23:43:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
W32kGuiCheck(VOID)
|
|
|
|
{
|
2002-01-27 01:11:24 +00:00
|
|
|
if (PsGetWin32Process() == NULL)
|
|
|
|
{
|
2002-07-04 19:56:38 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
|
2002-01-27 01:11:24 +00:00
|
|
|
PsCreateWin32Process(PsGetCurrentProcess());
|
|
|
|
|
|
|
|
InitializeListHead(&PsGetWin32Process()->ClassListHead);
|
2002-07-04 19:56:38 +00:00
|
|
|
ExInitializeFastMutex(&PsGetWin32Process()->ClassListLock);
|
|
|
|
|
|
|
|
Status =
|
|
|
|
ValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
|
|
|
|
UserMode,
|
|
|
|
GENERIC_ALL,
|
|
|
|
&PsGetWin32Process()->WindowStation);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DbgPrint("W32K: Failed to reference a window station for "
|
|
|
|
"process.\n");
|
|
|
|
}
|
2002-01-27 01:11:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (PsGetWin32Thread() == NULL)
|
|
|
|
{
|
2002-07-04 19:56:38 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
|
2002-01-27 01:11:24 +00:00
|
|
|
PsCreateWin32Thread(PsGetCurrentThread());
|
|
|
|
PsGetWin32Thread()->MessageQueue = MsqCreateMessageQueue();
|
2002-07-04 19:56:38 +00:00
|
|
|
InitializeListHead(&PsGetWin32Thread()->WindowListHead);
|
|
|
|
ExInitializeFastMutex(&PsGetWin32Thread()->WindowListLock);
|
|
|
|
|
|
|
|
/* By default threads get assigned their process's desktop. */
|
|
|
|
PsGetWin32Thread()->Desktop = NULL;
|
|
|
|
Status = ObReferenceObjectByHandle(PsGetCurrentProcess()->Win32Desktop,
|
|
|
|
GENERIC_ALL,
|
|
|
|
ExDesktopObjectType,
|
|
|
|
UserMode,
|
2002-07-17 21:04:57 +00:00
|
|
|
(PVOID*)&PsGetWin32Thread()->Desktop,
|
2002-07-04 19:56:38 +00:00
|
|
|
NULL);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DbgPrint("W32K: Failed to reference a desktop for thread.\n");
|
|
|
|
}
|
2002-01-27 01:11:24 +00:00
|
|
|
}
|
2001-06-12 17:51:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|