reactos/reactos/subsys/win32k/main/dllmain.c

261 lines
5.6 KiB
C
Raw Normal View History

/*
* 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: dllmain.c,v 1.39 2003/06/20 16:25:13 ekohl Exp $
*
* Entry Point for win32k.sys
*/
#undef WIN32_LEAN_AND_MEAN
#define WIN32_NO_STATUS
#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>
#include <ddk/winddi.h>
#include <win32k/win32k.h>
#include <include/winsta.h>
#include <include/class.h>
#include <include/window.h>
#include <include/object.h>
#include <include/input.h>
#include <include/timer.h>
#include <include/text.h>
#define NDEBUG
#include <win32k/debug1.h>
2002-07-04 David Welch <welch@computer2.darkstar.org> * subsys/win32k/include/callback.h: Fixed callback argument definitions. * subsys/win32k/ntuser/winpos.c: Implemented some more of the windows sizing/moving code. * subsys/win32k/ntuser/painting.c: Implemented some more of the window painting code. * subsys/win32k/objects/coord.c: Implemented LPtoDP and DPtoLP. * subsys/win32k/objects/region.c: Added stubs for some more region functions. 2002-07-04 David Welch <welch@computer2.darkstar.org> * ntoskrnl/ps/process.c (NtCreateProcess): Duplicate the process desktop handle as well. 2002-07-04 David Welch <welch@computer2.darkstar.org> * ntoskrnl/se/token.c: Don't call the ZwXXX variant of system calls when in system context. 2002-07-04 David Welch <welch@computer2.darkstar.org> * ntoskrnl/Makefile: Added file with MDA output code. * ntoskrnl/kd/kdebug.c: Recognize MDA as a destination for debug output. 2002-07-04 David Welch <welch@computer2.darkstar.org> * lib/user32/windows/defwnd.c: Implemented some more of the default window handler. 2002-07-04 David Welch <welch@computer2.darkstar.org> * lib/user32/misc/stubs.c: Removed some stubs to seperate files. 2002-07-04 David Welch <welch@computer2.darkstar.org> * lib/user32/user32.def: Export ScreenToClient otherwise we get problems when code in user32 tries to call it. 2002-07-04 David Welch <welch@computer2.darkstar.org> * include/win32k/region.h: Added prototypes for some missing region functions. 2002-07-04 David Welch <welch@computer2.darkstar.org> * include/win32k/ntuser.h: Added prototypes for some missing NtUserXXX functions. 2002-07-04 David Welch <welch@computer2.darkstar.org> * include/user32/wininternal.h: Added some constants for private GetDCEx styles that WINE needs. 2002-07-04 David Welch <welch@computer2.darkstar.org> * include/user32/callback.h: Fixed callbacks for messages with parameters. 2002-07-04 David Welch <welch@computer2.darkstar.org> * include/napi/win32.h (W32THREAD): Added pointer to the thread's desktop. * include/napi/win32.h (W32PROCESS): Removed handle table, added a pointer to the process's window station. * subsys/win32k/ntuser/guicheck.c (W32kGuiCheck): Reference a process's window station on the first win32k system call. Reference a thread's desktop on the first win32k system call. 2002-07-04 David Welch <welch@computer2.darkstar.org> * include/messages.h: Added some missing WM_XXX constants. 2002-07-04 David Welch <welch@computer2.darkstar.org> * drivers/dd/ide/makefile: Compiling with debugging messages needs libgcc to be linked in. 2002-07-04 David Welch <welch@computer2.darkstar.org> * iface/addsys/genw32k.c: Generate a variable with the number of system calls. * iface/native/genntdll.c: Generate a proper stack frame for the user system call stubs. * ntoskrnl/ke/i386/syscall.S: Generate a proper stack frame for the handler for system calls. 2002-07-04 David Welch <welch@computer2.darkstar.org> * Makefile: Build the GUI startup application. * subsys/system/gstart/gstart.c: Application to start up the GUI. svn path=/trunk/; revision=3179
2002-07-04 19:56:38 +00:00
extern SSDT Win32kSSDT[];
extern SSPT Win32kSSPT[];
extern ULONG Win32kNumberOfSysCalls;
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;
}
/*
* This definition doesn't work
*/
// WINBOOL STDCALL DllMain(VOID)
NTSTATUS
STDCALL
DllMain (
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath)
{
NTSTATUS Status;
BOOLEAN Result;
/*
* Register user mode call interface
* (system service table index = 1)
*/
Result = KeAddSystemServiceTable (Win32kSSDT,
NULL,
Win32kNumberOfSysCalls,
Win32kSSPT,
1);
if (Result == FALSE)
{
DbgPrint("Adding system services failed!\n");
return STATUS_UNSUCCESSFUL;
}
/*
* Register our per-process and per-thread structures.
*/
PsEstablishWin32Callouts (W32kProcessCallback,
W32kThreadCallback,
0,
0,
sizeof(W32THREAD),
sizeof(W32PROCESS));
WinPosSetupInternalPos();
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;
}
Status = InitInputImpl();
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);
}
Status = InitTimerImpl();
if (!NT_SUCCESS(Status))
{
DbgPrint("Failed to initialize timer implementation.\n");
return(Status);
}
return STATUS_SUCCESS;
}
BOOLEAN
STDCALL
W32kInitialize (VOID)
{
DPRINT("in W32kInitialize\n");
W32kDeviceProcess = PsGetCurrentProcess();
InitGdiObjectHandleTable ();
// Initialize FreeType library
if(!InitFontSupport()) return FALSE;
// Create stock objects, ie. precreated objects commonly used by win32 applications
CreateStockObjects();
return TRUE;
}
/* EOF */