2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * Entry Point for win32k.sys
24 #undef WIN32_LEAN_AND_MEAN
25 #define WIN32_NO_STATUS
27 #define NTOS_MODE_KERNEL
29 #include <ddk/winddi.h>
31 #include <win32k/win32k.h>
33 #include <include/winsta.h>
34 #include <include/class.h>
35 #include <include/window.h>
36 #include <include/menu.h>
37 #include <include/object.h>
38 #include <include/input.h>
39 #include <include/timer.h>
40 #include <include/text.h>
43 #include <win32k/debug1.h>
45 extern SSDT Win32kSSDT[];
46 extern SSPT Win32kSSPT[];
47 extern ULONG Win32kNumberOfSysCalls;
49 PEPROCESS Win32kDeviceProcess;
53 Win32kProcessCallback (struct _EPROCESS *Process,
56 PW32PROCESS Win32Process;
60 DbgPrint ("Win32kProcessCallback() called\n");
63 Win32Process = Process->Win32Process;
67 DbgPrint (" Create process\n");
70 InitializeListHead(&Win32Process->ClassListHead);
71 ExInitializeFastMutex(&Win32Process->ClassListLock);
73 InitializeListHead(&Win32Process->MenuListHead);
74 ExInitializeFastMutex(&Win32Process->MenuListLock);
76 Win32Process->WindowStation = NULL;
77 if (Process->Win32WindowStation != NULL)
80 ValidateWindowStationHandle(Process->Win32WindowStation,
83 &Win32Process->WindowStation);
84 if (!NT_SUCCESS(Status))
86 DbgPrint("Win32K: Failed to reference a window station for "
94 DbgPrint (" Destroy process\n");
95 DbgPrint (" IRQ level: %lu\n", KeGetCurrentIrql ());
98 IntCleanupMenus(Process, Win32Process);
100 CleanupForProcess(Process, Process->UniqueProcessId);
103 return STATUS_SUCCESS;
108 Win32kThreadCallback (struct _ETHREAD *Thread,
111 struct _EPROCESS *Process;
112 PW32THREAD Win32Thread;
116 DbgPrint ("Win32kThreadCallback() called\n");
119 Process = Thread->ThreadsProcess;
120 Win32Thread = Thread->Win32Thread;
124 DbgPrint (" Create thread\n");
127 Win32Thread->MessageQueue = MsqCreateMessageQueue();
128 InitializeListHead(&Win32Thread->WindowListHead);
129 ExInitializeFastMutex(&Win32Thread->WindowListLock);
131 /* By default threads get assigned their process's desktop. */
132 Win32Thread->Desktop = NULL;
133 if (Process->Win32Desktop != NULL)
135 Status = ObReferenceObjectByHandle(Process->Win32Desktop,
139 (PVOID*)&Win32Thread->Desktop,
141 if (!NT_SUCCESS(Status))
143 DbgPrint("Win32K: Failed to reference a desktop for thread.\n");
150 DbgPrint (" Destroy thread\n");
153 RemoveTimersThread(Thread->Cid.UniqueThread);
154 DestroyThreadWindows(Thread);
157 return STATUS_SUCCESS;
162 * This definition doesn't work
164 // WINBOOL STDCALL DllMain(VOID)
168 IN PDRIVER_OBJECT DriverObject,
169 IN PUNICODE_STRING RegistryPath)
174 IntInitializeWinLock();
177 * Register user mode call interface
178 * (system service table index = 1)
180 Result = KeAddSystemServiceTable (Win32kSSDT,
182 Win32kNumberOfSysCalls,
187 DbgPrint("Adding system services failed!\n");
188 return STATUS_UNSUCCESSFUL;
192 * Register our per-process and per-thread structures.
194 PsEstablishWin32Callouts (Win32kProcessCallback,
195 Win32kThreadCallback,
201 WinPosSetupInternalPos();
203 Status = InitWindowStationImpl();
204 if (!NT_SUCCESS(Status))
206 DbgPrint("Failed to initialize window station implementation!\n");
207 return STATUS_UNSUCCESSFUL;
210 Status = InitClassImpl();
211 if (!NT_SUCCESS(Status))
213 DbgPrint("Failed to initialize window class implementation!\n");
214 return STATUS_UNSUCCESSFUL;
217 Status = InitWindowImpl();
218 if (!NT_SUCCESS(Status))
220 DbgPrint("Failed to initialize window implementation!\n");
221 return STATUS_UNSUCCESSFUL;
224 Status = InitMenuImpl();
225 if (!NT_SUCCESS(Status))
227 DbgPrint("Failed to initialize menu implementation!\n");
228 return STATUS_UNSUCCESSFUL;
231 Status = InitInputImpl();
232 if (!NT_SUCCESS(Status))
234 DbgPrint("Failed to initialize input implementation.\n");
238 Status = MsqInitializeImpl();
239 if (!NT_SUCCESS(Status))
241 DbgPrint("Failed to initialize message queue implementation.\n");
245 Status = InitTimerImpl();
246 if (!NT_SUCCESS(Status))
248 DbgPrint("Failed to initialize timer implementation.\n");
252 return STATUS_SUCCESS;
258 Win32kInitialize (VOID)
260 DPRINT("in Win32kInitialize\n");
262 Win32kDeviceProcess = PsGetCurrentProcess();
264 InitGdiObjectHandleTable ();
266 // Initialize FreeType library
267 if(!InitFontSupport()) return FALSE;
269 // Create stock objects, ie. precreated objects commonly used by win32 applications
270 CreateStockObjects();