WIN32K code cleanup.
[reactos.git] / reactos / subsys / win32k / main / dllmain.c
1 /*
2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
4 *
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.
9 *
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.
14 *
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.
18 */
19 /* $Id: dllmain.c,v 1.35 2003/05/18 17:16:17 ea Exp $
20 *
21 * Entry Point for win32k.sys
22 */
23
24 #undef WIN32_LEAN_AND_MEAN
25 #define WIN32_NO_STATUS
26 #include <windows.h>
27 #include <ddk/ntddk.h>
28 #include <ddk/winddi.h>
29 #include <ddk/service.h>
30
31 #include <napi/win32.h>
32 #include <win32k/win32k.h>
33
34 #include <include/winsta.h>
35 #include <include/class.h>
36 #include <include/window.h>
37 #include <include/object.h>
38 #include <include/input.h>
39 #include <include/timer.h>
40 #include <include/text.h>
41
42 #define NDEBUG
43 #include <win32k/debug1.h>
44
45 extern SSDT Win32kSSDT[];
46 extern SSPT Win32kSSPT[];
47 extern ULONG Win32kNumberOfSysCalls;
48
49 /*
50 * This definition doesn't work
51 */
52 // WINBOOL STDCALL DllMain(VOID)
53 NTSTATUS
54 STDCALL
55 DllMain (
56 IN PDRIVER_OBJECT DriverObject,
57 IN PUNICODE_STRING RegistryPath)
58 {
59 NTSTATUS Status;
60 BOOLEAN Result;
61
62 /*
63 * Register user mode call interface
64 * (system service table index = 1)
65 */
66 Result = KeAddSystemServiceTable (Win32kSSDT, NULL,
67 Win32kNumberOfSysCalls, Win32kSSPT, 1);
68 if (Result == FALSE)
69 {
70 DbgPrint("Adding system services failed!\n");
71 return STATUS_UNSUCCESSFUL;
72 }
73
74 /*
75 * Register our per-process and per-thread structures.
76 */
77 PsEstablishWin32Callouts(0, 0, 0, 0, sizeof(W32THREAD), sizeof(W32PROCESS));
78
79 WinPosSetupInternalPos();
80
81 Status = InitWindowStationImpl();
82 if (!NT_SUCCESS(Status))
83 {
84 DbgPrint("Failed to initialize window station implementation!\n");
85 return STATUS_UNSUCCESSFUL;
86 }
87
88 Status = InitClassImpl();
89 if (!NT_SUCCESS(Status))
90 {
91 DbgPrint("Failed to initialize window class implementation!\n");
92 return STATUS_UNSUCCESSFUL;
93 }
94
95 Status = InitWindowImpl();
96 if (!NT_SUCCESS(Status))
97 {
98 DbgPrint("Failed to initialize window implementation!\n");
99 return STATUS_UNSUCCESSFUL;
100 }
101
102 Status = InitInputImpl();
103 if (!NT_SUCCESS(Status))
104 {
105 DbgPrint("Failed to initialize input implementation.\n");
106 return(Status);
107 }
108
109 Status = MsqInitializeImpl();
110 if (!NT_SUCCESS(Status))
111 {
112 DbgPrint("Failed to initialize message queue implementation.\n");
113 return(Status);
114 }
115
116 Status = InitTimerImpl();
117 if (!NT_SUCCESS(Status))
118 {
119 DbgPrint("Failed to initialize timer implementation.\n");
120 return(Status);
121 }
122
123 return STATUS_SUCCESS;
124 }
125
126 PEPROCESS W32kDeviceProcess;
127
128 BOOLEAN
129 STDCALL
130 W32kInitialize (VOID)
131 {
132 DPRINT("in W32kInitialize\n");
133
134 W32kDeviceProcess = PsGetCurrentProcess();
135
136 InitGdiObjectHandleTable ();
137
138 // Create surface used to draw the internal font onto
139 #ifdef TODO
140 CreateCellCharSurface();
141 #endif
142
143 // Initialize FreeType library
144 if(!InitFontSupport()) return FALSE;
145
146 // Create stock objects, ie. precreated objects commonly used by win32 applications
147 CreateStockObjects();
148
149 return TRUE;
150 }
151
152 /* EOF */