2006-11-08 11:47:44 +00:00
|
|
|
/*
|
|
|
|
* ReactOS W32 Subsystem
|
|
|
|
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*
|
|
|
|
* $Id: painting.c 16320 2005-06-29 07:09:25Z navaraf $
|
|
|
|
*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
|
|
|
* PURPOSE: ntuser init. and main funcs.
|
|
|
|
* FILE: subsys/win32k/ntuser/ntuser.c
|
|
|
|
* REVISION HISTORY:
|
|
|
|
* 16 July 2005 Created (hardon)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
|
|
|
|
#include <w32k.h>
|
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
2007-02-28 13:21:48 +00:00
|
|
|
ERESOURCE UserLock;
|
2009-07-01 17:19:16 +00:00
|
|
|
ATOM AtomMessage; // Window Message atom.
|
2009-06-25 02:43:38 +00:00
|
|
|
BOOL gbInitialized;
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
InitSysParams();
|
2006-11-08 11:47:44 +00:00
|
|
|
|
|
|
|
/* FUNCTIONS **********************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
NTSTATUS FASTCALL InitUserImpl(VOID)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
2007-02-28 13:21:48 +00:00
|
|
|
ExInitializeResourceLite(&UserLock);
|
2006-11-08 11:47:44 +00:00
|
|
|
|
2008-02-13 00:46:23 +00:00
|
|
|
if (!UserCreateHandleTable())
|
2006-11-08 11:47:44 +00:00
|
|
|
{
|
|
|
|
DPRINT1("Failed creating handle table\n");
|
|
|
|
return STATUS_INSUFFICIENT_RESOURCES;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = InitSessionImpl();
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT1("Error init session impl.\n");
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2008-06-10 21:09:31 +00:00
|
|
|
if (!gpsi)
|
|
|
|
{
|
|
|
|
gpsi = UserHeapAlloc(sizeof(SERVERINFO));
|
|
|
|
if (gpsi)
|
|
|
|
{
|
|
|
|
RtlZeroMemory(gpsi, sizeof(SERVERINFO));
|
2008-06-12 09:35:24 +00:00
|
|
|
DPRINT("Global Server Data -> %x\n", gpsi);
|
2008-06-10 21:09:31 +00:00
|
|
|
}
|
|
|
|
}
|
2009-06-25 02:43:38 +00:00
|
|
|
|
|
|
|
InitSysParams();
|
|
|
|
|
2006-11-08 11:47:44 +00:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2009-06-25 02:43:38 +00:00
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
UserInitialize(
|
|
|
|
HANDLE hPowerRequestEvent,
|
|
|
|
HANDLE hMediaRequestEvent)
|
|
|
|
{
|
|
|
|
// Set W32PF_Flags |= (W32PF_READSCREENACCESSGRANTED | W32PF_IOWINSTA)
|
|
|
|
// Create Object Directory,,, Looks like create workstation. "\\Windows\\WindowStations"
|
|
|
|
// Create Event for Diconnect Desktop.
|
|
|
|
// Initialize Video.
|
|
|
|
// {
|
|
|
|
// DrvInitConsole.
|
|
|
|
// DrvChangeDisplaySettings.
|
|
|
|
// Update Shared Device Caps.
|
|
|
|
// Initialize User Screen.
|
|
|
|
// }
|
|
|
|
// Create ThreadInfo for this Thread!
|
|
|
|
// Set Global SERVERINFO Error flags.
|
|
|
|
// Load Resources.
|
|
|
|
|
|
|
|
NtUserUpdatePerUserSystemParameters(0, TRUE);
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Called from win32csr.
|
|
|
|
*/
|
|
|
|
NTSTATUS
|
|
|
|
APIENTRY
|
|
|
|
NtUserInitialize(
|
|
|
|
DWORD dwWinVersion,
|
|
|
|
HANDLE hPowerRequestEvent,
|
|
|
|
HANDLE hMediaRequestEvent)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
DPRINT1("Enter NtUserInitialize(%lx, %p, %p)\n",
|
|
|
|
dwWinVersion, hPowerRequestEvent, hMediaRequestEvent);
|
|
|
|
|
|
|
|
/* Check the Windows version */
|
|
|
|
if (dwWinVersion != 0)
|
|
|
|
{
|
|
|
|
return STATUS_UNSUCCESSFUL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Acquire exclusive lock */
|
|
|
|
UserEnterExclusive();
|
|
|
|
|
|
|
|
/* Check if we are already initialized */
|
|
|
|
if (gbInitialized)
|
|
|
|
{
|
|
|
|
UserLeave();
|
|
|
|
return STATUS_UNSUCCESSFUL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialize Power Request List.
|
|
|
|
// Initialize Media Change.
|
|
|
|
// InitializeGreCSRSS();
|
|
|
|
// {
|
|
|
|
// Startup DxGraphics.
|
|
|
|
// calls ** IntGdiGetLanguageID() and sets it **.
|
|
|
|
// Enables Fonts drivers, Initialize Font table & Stock Fonts.
|
|
|
|
// }
|
|
|
|
|
|
|
|
/* Initialize USER */
|
|
|
|
Status = UserInitialize(hPowerRequestEvent, hMediaRequestEvent);
|
|
|
|
|
|
|
|
/* Set us as initialized */
|
|
|
|
gbInitialized = TRUE;
|
|
|
|
|
|
|
|
/* Return */
|
|
|
|
UserLeave();
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-11-08 11:47:44 +00:00
|
|
|
/*
|
|
|
|
RETURN
|
|
|
|
True if current thread owns the lock (possibly shared)
|
|
|
|
*/
|
|
|
|
BOOL FASTCALL UserIsEntered()
|
|
|
|
{
|
2007-10-19 23:21:45 +00:00
|
|
|
return ExIsResourceAcquiredExclusiveLite(&UserLock)
|
2007-02-28 13:21:48 +00:00
|
|
|
|| ExIsResourceAcquiredSharedLite(&UserLock);
|
2006-11-08 11:47:44 +00:00
|
|
|
}
|
|
|
|
|
2007-02-28 13:21:48 +00:00
|
|
|
BOOL FASTCALL UserIsEnteredExclusive()
|
|
|
|
{
|
|
|
|
return ExIsResourceAcquiredExclusiveLite(&UserLock);
|
|
|
|
}
|
2006-11-08 11:47:44 +00:00
|
|
|
|
2007-02-28 13:21:48 +00:00
|
|
|
VOID FASTCALL CleanupUserImpl(VOID)
|
2006-11-08 11:47:44 +00:00
|
|
|
{
|
2007-02-28 13:21:48 +00:00
|
|
|
ExDeleteResourceLite(&UserLock);
|
2006-11-08 11:47:44 +00:00
|
|
|
}
|
|
|
|
|
2007-02-28 13:21:48 +00:00
|
|
|
VOID FASTCALL UserEnterShared(VOID)
|
2006-11-08 11:47:44 +00:00
|
|
|
{
|
2007-03-08 19:45:32 +00:00
|
|
|
KeEnterCriticalRegion();
|
2007-02-28 13:21:48 +00:00
|
|
|
ExAcquireResourceSharedLite(&UserLock, TRUE);
|
2006-11-08 11:47:44 +00:00
|
|
|
}
|
|
|
|
|
2007-02-28 13:21:48 +00:00
|
|
|
VOID FASTCALL UserEnterExclusive(VOID)
|
2006-11-08 11:47:44 +00:00
|
|
|
{
|
2007-03-08 19:45:32 +00:00
|
|
|
KeEnterCriticalRegion();
|
2007-02-28 13:21:48 +00:00
|
|
|
ExAcquireResourceExclusiveLite(&UserLock, TRUE);
|
2006-11-08 11:47:44 +00:00
|
|
|
}
|
|
|
|
|
2007-02-28 13:21:48 +00:00
|
|
|
VOID FASTCALL UserLeave(VOID)
|
2006-11-08 11:47:44 +00:00
|
|
|
{
|
2007-02-28 13:21:48 +00:00
|
|
|
ExReleaseResourceLite(&UserLock);
|
2007-03-08 19:45:32 +00:00
|
|
|
KeLeaveCriticalRegion();
|
2006-11-08 11:47:44 +00:00
|
|
|
}
|