[VIDEOPRT/WINSERV] Move mapping the BIOS memory from winsrv to videoprt, where it...
[reactos.git] / reactos / win32ss / user / winsrv / usersrv / init.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS User API Server DLL
4 * FILE: win32ss/user/winsrv/usersrv/init.c
5 * PURPOSE: Initialization
6 * PROGRAMMERS: Dmitry Philippov (shedon@mail.ru)
7 * Hermes Belusca-Maito (hermes.belusca@sfr.fr)
8 */
9
10 /* INCLUDES *******************************************************************/
11
12 #include "usersrv.h"
13 #include "api.h"
14
15 #define NDEBUG
16 #include <debug.h>
17
18 /* GLOBALS ********************************************************************/
19
20 HINSTANCE UserServerDllInstance = NULL;
21
22 /* Memory */
23 HANDLE UserServerHeap = NULL; // Our own heap.
24
25 // Windows Server 2003 table from http://j00ru.vexillium.org/csrss_list/api_list.html#Windows_2k3
26 PCSR_API_ROUTINE UserServerApiDispatchTable[UserpMaxApiNumber - USERSRV_FIRST_API_NUMBER] =
27 {
28 SrvExitWindowsEx,
29 SrvEndTask,
30 SrvLogon,
31 SrvRegisterServicesProcess, // Not present in Win7
32 SrvActivateDebugger,
33 SrvGetThreadConsoleDesktop, // Not present in Win7
34 SrvDeviceEvent,
35 SrvRegisterLogonProcess, // Not present in Win7
36 SrvCreateSystemThreads,
37 SrvRecordShutdownReason,
38 // SrvCancelShutdown, // Added in Vista
39 // SrvConsoleHandleOperation, // Added in Win7
40 // SrvGetSetShutdownBlockReason, // Added in Vista
41 };
42
43 BOOLEAN UserServerApiServerValidTable[UserpMaxApiNumber - USERSRV_FIRST_API_NUMBER] =
44 {
45 FALSE, // SrvExitWindowsEx
46 FALSE, // SrvEndTask
47 FALSE, // SrvLogon
48 FALSE, // SrvRegisterServicesProcess
49 FALSE, // SrvActivateDebugger
50 TRUE, // SrvGetThreadConsoleDesktop
51 FALSE, // SrvDeviceEvent
52 FALSE, // SrvRegisterLogonProcess
53 FALSE, // SrvCreateSystemThreads
54 FALSE, // SrvRecordShutdownReason
55 // FALSE, // SrvCancelShutdown
56 // FALSE, // SrvConsoleHandleOperation
57 // FALSE, // SrvGetSetShutdownBlockReason
58 };
59
60 /*
61 * On Windows Server 2003, CSR Servers contain
62 * the API Names Table only in Debug Builds.
63 */
64 #ifdef CSR_DBG
65 PCHAR UserServerApiNameTable[UserpMaxApiNumber - USERSRV_FIRST_API_NUMBER] =
66 {
67 "SrvExitWindowsEx",
68 "SrvEndTask",
69 "SrvLogon",
70 "SrvRegisterServicesProcess",
71 "SrvActivateDebugger",
72 "SrvGetThreadConsoleDesktop",
73 "SrvDeviceEvent",
74 "SrvRegisterLogonProcess",
75 "SrvCreateSystemThreads",
76 "SrvRecordShutdownReason",
77 // "SrvCancelShutdown",
78 // "SrvConsoleHandleOperation",
79 // "SrvGetSetShutdownBlockReason",
80 };
81 #endif
82
83 /* FUNCTIONS ******************************************************************/
84
85 // PUSER_SOUND_SENTRY. Used in basesrv.dll
86 BOOL WINAPI _UserSoundSentry(VOID)
87 {
88 // TODO: Do something.
89 return TRUE;
90 }
91
92 // From win32ss/user/win32csr/dllmain.c
93 VOID
94 WINAPI
95 PrivateCsrssManualGuiCheck(LONG Check)
96 {
97 NtUserCallOneParam(Check, ONEPARAM_ROUTINE_CSRSS_GUICHECK);
98 }
99
100 ULONG
101 NTAPI
102 CreateSystemThreads(PVOID pParam)
103 {
104 NtUserCallOneParam((DWORD)pParam, ONEPARAM_ROUTINE_CREATESYSTEMTHREADS);
105 DPRINT1("This thread should not terminate!\n");
106 return 0;
107 }
108
109 CSR_API(SrvCreateSystemThreads)
110 {
111 DPRINT1("%s not yet implemented\n", __FUNCTION__);
112 return STATUS_NOT_IMPLEMENTED;
113 }
114
115 CSR_API(SrvActivateDebugger)
116 {
117 DPRINT1("%s not yet implemented\n", __FUNCTION__);
118 return STATUS_NOT_IMPLEMENTED;
119 }
120
121 CSR_API(SrvGetThreadConsoleDesktop)
122 {
123 DPRINT1("%s not yet implemented\n", __FUNCTION__);
124 return STATUS_NOT_IMPLEMENTED;
125 }
126
127 CSR_API(SrvDeviceEvent)
128 {
129 DPRINT1("%s not yet implemented\n", __FUNCTION__);
130 return STATUS_NOT_IMPLEMENTED;
131 }
132
133 CSR_SERVER_DLL_INIT(UserServerDllInitialization)
134 {
135 /*** From win32csr... ***/
136 HANDLE ServerThread;
137 CLIENT_ID ClientId;
138 NTSTATUS Status;
139 UINT i;
140 /*** END - From win32csr... ***/
141
142 /* Initialize the memory */
143 UserServerHeap = RtlGetProcessHeap();
144
145 /* Initialize the video */
146 NtUserInitialize(0, NULL, NULL); //
147 PrivateCsrssManualGuiCheck(0);
148
149 /* Setup the DLL Object */
150 LoadedServerDll->ApiBase = USERSRV_FIRST_API_NUMBER;
151 LoadedServerDll->HighestApiSupported = UserpMaxApiNumber;
152 LoadedServerDll->DispatchTable = UserServerApiDispatchTable;
153 LoadedServerDll->ValidTable = UserServerApiServerValidTable;
154 #ifdef CSR_DBG
155 LoadedServerDll->NameTable = UserServerApiNameTable;
156 #endif
157 LoadedServerDll->SizeOfProcessData = 0;
158 LoadedServerDll->ConnectCallback = NULL;
159 LoadedServerDll->DisconnectCallback = NULL;
160 LoadedServerDll->HardErrorCallback = UserServerHardError;
161 LoadedServerDll->ShutdownProcessCallback = NULL;
162
163 UserServerDllInstance = LoadedServerDll->ServerHandle;
164
165 /*** From win32csr... See r54125 ***/
166 /* Start the Raw Input Thread and the Desktop Thread */
167 for (i = 0; i < 2; ++i)
168 {
169 Status = RtlCreateUserThread(NtCurrentProcess(),
170 NULL, TRUE, 0, 0, 0,
171 CreateSystemThreads,
172 (PVOID)i, &ServerThread, &ClientId);
173 if (NT_SUCCESS(Status))
174 {
175 NtResumeThread(ServerThread, NULL);
176 NtClose(ServerThread);
177 }
178 else
179 DPRINT1("Cannot start Raw Input Thread!\n");
180 }
181 /*** END - From win32csr... ***/
182
183 /* All done */
184 return STATUS_SUCCESS;
185 }
186
187 /* EOF */