2003-05-18 17:16:18 +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.
|
|
|
|
*/
|
2003-06-20 16:26:53 +00:00
|
|
|
/* $Id: dllmain.c,v 1.39 2003/06/20 16:25:13 ekohl Exp $
|
2002-07-13 21:37:27 +00:00
|
|
|
*
|
1999-05-22 23:55:56 +00:00
|
|
|
* Entry Point for win32k.sys
|
|
|
|
*/
|
1999-05-20 01:31:05 +00:00
|
|
|
|
1999-07-12 23:26:57 +00:00
|
|
|
#undef WIN32_LEAN_AND_MEAN
|
1999-11-20 21:51:19 +00:00
|
|
|
#define WIN32_NO_STATUS
|
1999-05-22 23:55:56 +00:00
|
|
|
#include <windows.h>
|
2003-06-07 Casper S. Hornstrup <chorns@users.sourceforge.net>
Changes for compiling with w32api
* include/ddk/service.h: Move ...
* include/ntos/service.h: ... here.
* include/ddk/kdfuncs.h: Move ...
* include/ntos/kdfuncs.h: ... here.
* include/ntos/halfuncs.h: New file.
* ntoskrnl/include/internal/hal/hal.h,
ntoskrnl/include/internal/hal/bus.h,
ntoskrnl/include/internal/hal/mps.h: Remove.
* hal/halx86/include/hal.h: Remove disabled code.
* include/ntos.h: Include ntos/service.h, ntos/halfuncs.h, and
ntos/kdfuncs.h.
* include/ddk/fstypes.h (FILE_LOCK_TOC): Move ...
* include/ntos/file.h: ... here.
* include/ddk/halfuncs.h (HalAllProcessorsStarted,
HalBeginSystemInterrupt, HalDisableSystemInterrupt,
HalEnableSystemInterrupt, HalEndSystemInterrupt,
HalInitializeProcessor, HalInitSystem, HalReportResourceUsage): Move to
include/ntos/halfuncs.h.
* include/ddk/iofuncs.h (IoAssignDriveLetters): Ditto.
* include/ddk/kefuncs.h (KeInitializeApc): Match w32api prototype.
(KeRaiseIrqlToSynchLevel): Move to include/ntos/halfuncs.h.
* include/ddk/ketypes.h (KAPC_ENVIRONMENT): Move to include/ntos/types.h.
(KDEVICE_QUEUE, KDEVICE_QUEUE_ENTRY): Match w32api prototype.
(KINTERRUPT): Move to include/ntos/zwtypes.h.
* include/ddk/mmtypes.h (PAGE_ROUND_UP, PAGE_ROUND_DOWN): Move ...
* include/ntos/mm.h: ... here.
* include/ddk/ntddk.h: Don't include ddk/kdfuncs.h.
* include/ddk/pstypes.h (PKTHREAD, PRKTHREAD): Add.
(PsInitialSystemProcess, PsProcessType, PsThreadType): Move ...
include/ntos/ps.h: ... here.
* lib/ntdll/rtl/i386/exception.c (SehpContinue): New.
* ntoskrnl/rtl/i386/exception.c (SehpContinue): Ditto.
* ntoskrnl/include/internal/ke.h: Include <ddk/ntifs.h>.
* ntoskrnl/include/internal/ntoskrnl.h: Include internal/ke.h.
* ntoskrnl/ex/napi.c: Use new structure SSDT_ENTRY.
* ntoskrnl/ke/apc.c (KeInitializeApc): Match w32api prototype.
* ntoskrnl/ke/kqueue.c: Use fields of new structures KDEVICE_QUEUE
and KDEVICE_QUEUE_ENTRY.
svn path=/trunk/; revision=4861
2003-06-07 10:14:40 +00:00
|
|
|
#define NTOS_MODE_KERNEL
|
|
|
|
#include <ntos.h>
|
1999-07-12 23:26:57 +00:00
|
|
|
#include <ddk/winddi.h>
|
2002-09-08 10:23:54 +00:00
|
|
|
|
1999-07-22 16:21:53 +00:00
|
|
|
#include <win32k/win32k.h>
|
1999-05-27 23:08:26 +00:00
|
|
|
|
2001-06-12 17:51:51 +00:00
|
|
|
#include <include/winsta.h>
|
|
|
|
#include <include/class.h>
|
|
|
|
#include <include/window.h>
|
2003-05-18 17:16:18 +00:00
|
|
|
#include <include/object.h>
|
|
|
|
#include <include/input.h>
|
|
|
|
#include <include/timer.h>
|
|
|
|
#include <include/text.h>
|
2001-06-12 17:51:51 +00:00
|
|
|
|
2003-03-11 00:21:41 +00:00
|
|
|
#define NDEBUG
|
2002-07-13 21:37:27 +00:00
|
|
|
#include <win32k/debug1.h>
|
|
|
|
|
2002-07-04 19:56:38 +00:00
|
|
|
extern SSDT Win32kSSDT[];
|
|
|
|
extern SSPT Win32kSSPT[];
|
|
|
|
extern ULONG Win32kNumberOfSysCalls;
|
1999-07-12 23:26:57 +00:00
|
|
|
|
2003-06-20 16:26:53 +00:00
|
|
|
PEPROCESS W32kDeviceProcess;
|
|
|
|
|
|
|
|
|
|
|
|
NTSTATUS STDCALL
|
|
|
|
W32kProcessCallback (struct _EPROCESS *Process,
|
|
|
|
BOOLEAN Create)
|
|
|
|
{
|
|
|
|
PW32PROCESS Win32Process;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
DbgPrint ("W32kProcessCallback() called\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
Win32Process = Process->Win32Process;
|
|
|
|
if (Create)
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
DbgPrint (" Create process\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
InitializeListHead(&Win32Process->ClassListHead);
|
|
|
|
ExInitializeFastMutex(&Win32Process->ClassListLock);
|
|
|
|
|
|
|
|
Win32Process->WindowStation = NULL;
|
|
|
|
if (Process->Win32WindowStation != NULL)
|
|
|
|
{
|
|
|
|
Status =
|
|
|
|
ValidateWindowStationHandle(Process->Win32WindowStation,
|
|
|
|
UserMode,
|
|
|
|
GENERIC_ALL,
|
|
|
|
&Win32Process->WindowStation);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DbgPrint("W32K: Failed to reference a window station for "
|
|
|
|
"process.\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
DbgPrint (" Destroy process\n");
|
|
|
|
DbgPrint (" IRQ level: %lu\n", KeGetCurrentIrql ());
|
|
|
|
#endif
|
|
|
|
|
|
|
|
CleanupForProcess(Process, Process->UniqueProcessId);
|
|
|
|
}
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NTSTATUS STDCALL
|
|
|
|
W32kThreadCallback (struct _ETHREAD *Thread,
|
|
|
|
BOOLEAN Create)
|
|
|
|
{
|
|
|
|
struct _EPROCESS *Process;
|
|
|
|
PW32THREAD Win32Thread;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
DbgPrint ("W32kThreadCallback() called\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
Process = Thread->ThreadsProcess;
|
|
|
|
Win32Thread = Thread->Win32Thread;
|
|
|
|
if (Create)
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
DbgPrint (" Create thread\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
Win32Thread->MessageQueue = MsqCreateMessageQueue();
|
|
|
|
InitializeListHead(&Win32Thread->WindowListHead);
|
|
|
|
ExInitializeFastMutex(&Win32Thread->WindowListLock);
|
|
|
|
|
|
|
|
/* By default threads get assigned their process's desktop. */
|
|
|
|
Win32Thread->Desktop = NULL;
|
|
|
|
if (Process->Win32Desktop != NULL)
|
|
|
|
{
|
|
|
|
Status = ObReferenceObjectByHandle(Process->Win32Desktop,
|
|
|
|
GENERIC_ALL,
|
|
|
|
ExDesktopObjectType,
|
|
|
|
UserMode,
|
|
|
|
(PVOID*)&Win32Thread->Desktop,
|
|
|
|
NULL);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DbgPrint("W32K: Failed to reference a desktop for thread.\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
DbgPrint (" Destroy thread\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
RemoveTimersThread(Thread->Cid.UniqueThread);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-02 08:55:45 +00:00
|
|
|
/*
|
|
|
|
* This definition doesn't work
|
|
|
|
*/
|
|
|
|
// WINBOOL STDCALL DllMain(VOID)
|
2000-02-20 22:52:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
STDCALL
|
|
|
|
DllMain (
|
2001-03-31 15:35:08 +00:00
|
|
|
IN PDRIVER_OBJECT DriverObject,
|
|
|
|
IN PUNICODE_STRING RegistryPath)
|
1999-07-12 23:26:57 +00:00
|
|
|
{
|
2001-06-12 17:51:51 +00:00
|
|
|
NTSTATUS Status;
|
2001-03-31 15:35:08 +00:00
|
|
|
BOOLEAN Result;
|
2000-02-21 22:44:37 +00:00
|
|
|
|
2001-03-31 15:35:08 +00:00
|
|
|
/*
|
|
|
|
* Register user mode call interface
|
|
|
|
* (system service table index = 1)
|
|
|
|
*/
|
2003-06-20 16:26:53 +00:00
|
|
|
Result = KeAddSystemServiceTable (Win32kSSDT,
|
|
|
|
NULL,
|
|
|
|
Win32kNumberOfSysCalls,
|
|
|
|
Win32kSSPT,
|
|
|
|
1);
|
2001-03-31 15:35:08 +00:00
|
|
|
if (Result == FALSE)
|
2003-06-20 16:26:53 +00:00
|
|
|
{
|
|
|
|
DbgPrint("Adding system services failed!\n");
|
|
|
|
return STATUS_UNSUCCESSFUL;
|
|
|
|
}
|
1999-05-27 23:08:26 +00:00
|
|
|
|
2002-01-27 01:11:24 +00:00
|
|
|
/*
|
|
|
|
* Register our per-process and per-thread structures.
|
|
|
|
*/
|
2003-06-20 16:26:53 +00:00
|
|
|
PsEstablishWin32Callouts (W32kProcessCallback,
|
|
|
|
W32kThreadCallback,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
sizeof(W32THREAD),
|
|
|
|
sizeof(W32PROCESS));
|
2002-01-27 01:11:24 +00:00
|
|
|
|
2002-09-17 23:43:29 +00:00
|
|
|
WinPosSetupInternalPos();
|
|
|
|
|
2001-06-12 17:51:51 +00:00
|
|
|
Status = InitWindowStationImpl();
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DbgPrint("Failed to initialize window station implementation!\n");
|
|
|
|
return STATUS_UNSUCCESSFUL;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = InitClassImpl();
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DbgPrint("Failed to initialize window class implementation!\n");
|
|
|
|
return STATUS_UNSUCCESSFUL;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = InitWindowImpl();
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DbgPrint("Failed to initialize window implementation!\n");
|
|
|
|
return STATUS_UNSUCCESSFUL;
|
|
|
|
}
|
|
|
|
|
2002-01-27 01:11:24 +00:00
|
|
|
Status = InitInputImpl();
|
2002-01-13 22:52:08 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DbgPrint("Failed to initialize input implementation.\n");
|
|
|
|
return(Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = MsqInitializeImpl();
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DbgPrint("Failed to initialize message queue implementation.\n");
|
|
|
|
return(Status);
|
|
|
|
}
|
|
|
|
|
2003-04-02 23:19:28 +00:00
|
|
|
Status = InitTimerImpl();
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DbgPrint("Failed to initialize timer implementation.\n");
|
|
|
|
return(Status);
|
|
|
|
}
|
|
|
|
|
2001-03-31 15:35:08 +00:00
|
|
|
return STATUS_SUCCESS;
|
2000-02-21 22:44:37 +00:00
|
|
|
}
|
2000-02-20 22:52:50 +00:00
|
|
|
|
2000-02-22 20:53:11 +00:00
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
STDCALL
|
|
|
|
W32kInitialize (VOID)
|
|
|
|
{
|
2002-07-13 21:37:27 +00:00
|
|
|
DPRINT("in W32kInitialize\n");
|
2003-03-11 00:21:41 +00:00
|
|
|
|
|
|
|
W32kDeviceProcess = PsGetCurrentProcess();
|
|
|
|
|
2001-11-02 06:10:11 +00:00
|
|
|
InitGdiObjectHandleTable ();
|
|
|
|
|
2001-03-31 15:35:08 +00:00
|
|
|
// Initialize FreeType library
|
|
|
|
if(!InitFontSupport()) return FALSE;
|
|
|
|
|
2003-03-28 16:20:51 +00:00
|
|
|
// Create stock objects, ie. precreated objects commonly used by win32 applications
|
|
|
|
CreateStockObjects();
|
|
|
|
|
2001-03-31 15:35:08 +00:00
|
|
|
return TRUE;
|
2000-02-22 20:53:11 +00:00
|
|
|
}
|
|
|
|
|
2000-02-20 22:52:50 +00:00
|
|
|
/* EOF */
|