[CSRSRV]
[reactos.git] / win32ss / user / consrv / init.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Console Server DLL
4 * FILE: win32ss/user/consrv/init.c
5 * PURPOSE: Initialization
6 * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca@sfr.fr)
7 */
8
9 /* INCLUDES *******************************************************************/
10
11 #include "consrv.h"
12 #include "conio.h"
13
14 #define NDEBUG
15 #include <debug.h>
16
17 /* GLOBALS ********************************************************************/
18
19 HINSTANCE ConSrvDllInstance = NULL;
20
21 /* Memory */
22 HANDLE ConSrvHeap = NULL; // Our own heap.
23
24 // Windows Server 2003 table from http://j00ru.vexillium.org/csrss_list/api_list.html#Windows_2k3
25 // plus a little bit of Windows 7.
26 PCSR_API_ROUTINE ConsoleServerApiDispatchTable[ConsolepMaxApiNumber - CONSRV_FIRST_API_NUMBER] =
27 {
28 SrvOpenConsole,
29 SrvGetConsoleInput,
30 SrvWriteConsoleInput,
31 SrvReadConsoleOutput,
32 SrvWriteConsoleOutput,
33 SrvReadConsoleOutputString,
34 SrvWriteConsoleOutputString,
35 SrvFillConsoleOutput,
36 SrvGetConsoleMode,
37 // SrvGetConsoleNumberOfFonts,
38 SrvGetConsoleNumberOfInputEvents,
39 SrvGetConsoleScreenBufferInfo,
40 SrvGetConsoleCursorInfo,
41 // SrvGetConsoleMouseInfo,
42 // SrvGetConsoleFontInfo,
43 // SrvGetConsoleFontSize,
44 // SrvGetConsoleCurrentFont,
45 SrvSetConsoleMode,
46 SrvSetConsoleActiveScreenBuffer,
47 SrvFlushConsoleInputBuffer,
48 // SrvGetLargestConsoleWindowSize,
49 SrvSetConsoleScreenBufferSize,
50 SrvSetConsoleCursorPosition,
51 SrvSetConsoleCursorInfo,
52 // SrvSetConsoleWindowInfo,
53 SrvScrollConsoleScreenBuffer,
54 SrvSetConsoleTextAttribute,
55 // SrvSetConsoleFont,
56 SrvSetConsoleIcon,
57 SrvReadConsole,
58 SrvWriteConsole,
59 SrvDuplicateHandle,
60 // SrvGetHandleInformation,
61 // SrvSetHandleInformation,
62 SrvCloseHandle,
63 SrvVerifyConsoleIoHandle,
64 SrvAllocConsole,
65 SrvFreeConsole,
66 SrvGetConsoleTitle,
67 SrvSetConsoleTitle,
68 SrvCreateConsoleScreenBuffer,
69 // SrvInvalidateBitMapRect,
70 // SrvVDMConsoleOperation,
71 // SrvSetConsoleCursor,
72 // SrvShowConsoleCursor,
73 // SrvConsoleMenuControl,
74 // SrvSetConsolePalette,
75 // SrvSetConsoleDisplayMode,
76 // SrvRegisterConsoleVDM,
77 SrvGetConsoleHardwareState,
78 SrvSetConsoleHardwareState,
79 // SrvGetConsoleDisplayMode,
80 SrvAddConsoleAlias,
81 SrvGetConsoleAlias,
82 SrvGetConsoleAliasesLength,
83 SrvGetConsoleAliasExesLength,
84 SrvGetConsoleAliases,
85 SrvGetConsoleAliasExes,
86 SrvExpungeConsoleCommandHistory,
87 SrvSetConsoleNumberOfCommands,
88 SrvGetConsoleCommandHistoryLength,
89 SrvGetConsoleCommandHistory,
90 // SrvSetConsoleCommandHistoryMode,
91 SrvGetConsoleCP,
92 SrvSetConsoleCP,
93 // SrvSetConsoleKeyShortcuts,
94 // SrvSetConsoleMenuClose,
95 // SrvConsoleNotifyLastClose,
96 SrvGenerateConsoleCtrlEvent,
97 // SrvGetConsoleKeyboardLayoutName,
98 SrvGetConsoleWindow,
99 // SrvGetConsoleCharType,
100 // SrvSetConsoleLocalEUDC,
101 // SrvSetConsoleCursorMode,
102 // SrvGetConsoleCursorMode,
103 // SrvRegisterConsoleOS2,
104 // SrvSetConsoleOS2OemFormat,
105 // SrvGetConsoleNlsMode,
106 // SrvSetConsoleNlsMode,
107 // SrvRegisterConsoleIME,
108 // SrvUnregisterConsoleIME,
109 // SrvGetConsoleLangId,
110 SrvAttachConsole,
111 SrvGetConsoleSelectionInfo,
112 SrvGetConsoleProcessList,
113 SrvGetConsoleHistory,
114 SrvSetConsoleHistory,
115 };
116
117 BOOLEAN ConsoleServerApiServerValidTable[ConsolepMaxApiNumber - CONSRV_FIRST_API_NUMBER] =
118 {
119 FALSE, // SrvOpenConsole,
120 FALSE, // SrvGetConsoleInput,
121 FALSE, // SrvWriteConsoleInput,
122 FALSE, // SrvReadConsoleOutput,
123 FALSE, // SrvWriteConsoleOutput,
124 FALSE, // SrvReadConsoleOutputString,
125 FALSE, // SrvWriteConsoleOutputString,
126 FALSE, // SrvFillConsoleOutput,
127 FALSE, // SrvGetConsoleMode,
128 // FALSE, // SrvGetConsoleNumberOfFonts,
129 FALSE, // SrvGetConsoleNumberOfInputEvents,
130 FALSE, // SrvGetConsoleScreenBufferInfo,
131 FALSE, // SrvGetConsoleCursorInfo,
132 // FALSE, // SrvGetConsoleMouseInfo,
133 // FALSE, // SrvGetConsoleFontInfo,
134 // FALSE, // SrvGetConsoleFontSize,
135 // FALSE, // SrvGetConsoleCurrentFont,
136 FALSE, // SrvSetConsoleMode,
137 FALSE, // SrvSetConsoleActiveScreenBuffer,
138 FALSE, // SrvFlushConsoleInputBuffer,
139 // FALSE, // SrvGetLargestConsoleWindowSize,
140 FALSE, // SrvSetConsoleScreenBufferSize,
141 FALSE, // SrvSetConsoleCursorPosition,
142 FALSE, // SrvSetConsoleCursorInfo,
143 // FALSE, // SrvSetConsoleWindowInfo,
144 FALSE, // SrvScrollConsoleScreenBuffer,
145 FALSE, // SrvSetConsoleTextAttribute,
146 // FALSE, // SrvSetConsoleFont,
147 FALSE, // SrvSetConsoleIcon,
148 FALSE, // SrvReadConsole,
149 FALSE, // SrvWriteConsole,
150 FALSE, // SrvDuplicateHandle,
151 // FALSE, // SrvGetHandleInformation,
152 // FALSE, // SrvSetHandleInformation,
153 FALSE, // SrvCloseHandle,
154 FALSE, // SrvVerifyConsoleIoHandle,
155 FALSE, // SrvAllocConsole,
156 FALSE, // SrvFreeConsole,
157 FALSE, // SrvGetConsoleTitle,
158 FALSE, // SrvSetConsoleTitle,
159 FALSE, // SrvCreateConsoleScreenBuffer,
160 // FALSE, // SrvInvalidateBitMapRect,
161 // FALSE, // SrvVDMConsoleOperation,
162 // FALSE, // SrvSetConsoleCursor,
163 // FALSE, // SrvShowConsoleCursor,
164 // FALSE, // SrvConsoleMenuControl,
165 // FALSE, // SrvSetConsolePalette,
166 // FALSE, // SrvSetConsoleDisplayMode,
167 // FALSE, // SrvRegisterConsoleVDM,
168 FALSE, // SrvGetConsoleHardwareState,
169 FALSE, // SrvSetConsoleHardwareState,
170 // TRUE, // SrvGetConsoleDisplayMode,
171 FALSE, // SrvAddConsoleAlias,
172 FALSE, // SrvGetConsoleAlias,
173 FALSE, // SrvGetConsoleAliasesLength,
174 FALSE, // SrvGetConsoleAliasExesLength,
175 FALSE, // SrvGetConsoleAliases,
176 FALSE, // SrvGetConsoleAliasExes,
177 FALSE, // SrvExpungeConsoleCommandHistory,
178 FALSE, // SrvSetConsoleNumberOfCommands,
179 FALSE, // SrvGetConsoleCommandHistoryLength,
180 FALSE, // SrvGetConsoleCommandHistory,
181 // FALSE, // SrvSetConsoleCommandHistoryMode,
182 FALSE, // SrvGetConsoleCP,
183 FALSE, // SrvSetConsoleCP,
184 // FALSE, // SrvSetConsoleKeyShortcuts,
185 // FALSE, // SrvSetConsoleMenuClose,
186 // FALSE, // SrvConsoleNotifyLastClose,
187 FALSE, // SrvGenerateConsoleCtrlEvent,
188 // FALSE, // SrvGetConsoleKeyboardLayoutName,
189 FALSE, // SrvGetConsoleWindow,
190 // FALSE, // SrvGetConsoleCharType,
191 // FALSE, // SrvSetConsoleLocalEUDC,
192 // FALSE, // SrvSetConsoleCursorMode,
193 // FALSE, // SrvGetConsoleCursorMode,
194 // FALSE, // SrvRegisterConsoleOS2,
195 // FALSE, // SrvSetConsoleOS2OemFormat,
196 // FALSE, // SrvGetConsoleNlsMode,
197 // FALSE, // SrvSetConsoleNlsMode,
198 // FALSE, // SrvRegisterConsoleIME,
199 // FALSE, // SrvUnregisterConsoleIME,
200 // FALSE, // SrvGetConsoleLangId,
201 FALSE, // SrvAttachConsole,
202 FALSE, // SrvGetConsoleSelectionInfo,
203 FALSE, // SrvGetConsoleProcessList,
204 FALSE, // SrvGetConsoleHistory,
205 FALSE, // SrvSetConsoleHistory
206 };
207
208 PCHAR ConsoleServerApiNameTable[ConsolepMaxApiNumber - CONSRV_FIRST_API_NUMBER] =
209 {
210 "OpenConsole",
211 "GetConsoleInput",
212 "WriteConsoleInput",
213 "ReadConsoleOutput",
214 "WriteConsoleOutput",
215 "ReadConsoleOutputString",
216 "WriteConsoleOutputString",
217 "FillConsoleOutput",
218 "GetConsoleMode",
219 // "GetConsoleNumberOfFonts",
220 "GetConsoleNumberOfInputEvents",
221 "GetConsoleScreenBufferInfo",
222 "GetConsoleCursorInfo",
223 // "GetConsoleMouseInfo",
224 // "GetConsoleFontInfo",
225 // "GetConsoleFontSize",
226 // "GetConsoleCurrentFont",
227 "SetConsoleMode",
228 "SetConsoleActiveScreenBuffer",
229 "FlushConsoleInputBuffer",
230 // "GetLargestConsoleWindowSize",
231 "SetConsoleScreenBufferSize",
232 "SetConsoleCursorPosition",
233 "SetConsoleCursorInfo",
234 // "SetConsoleWindowInfo",
235 "ScrollConsoleScreenBuffer",
236 "SetConsoleTextAttribute",
237 // "SetConsoleFont",
238 "SetConsoleIcon",
239 "ReadConsole",
240 "WriteConsole",
241 "DuplicateHandle",
242 // "GetHandleInformation",
243 // "SetHandleInformation",
244 "CloseHandle",
245 "VerifyConsoleIoHandle",
246 "AllocConsole",
247 "FreeConsole",
248 "GetConsoleTitle",
249 "SetConsoleTitle",
250 "CreateConsoleScreenBuffer",
251 // "InvalidateBitMapRect",
252 // "VDMConsoleOperation",
253 // "SetConsoleCursor",
254 // "ShowConsoleCursor",
255 // "ConsoleMenuControl",
256 // "SetConsolePalette",
257 // "SetConsoleDisplayMode",
258 // "RegisterConsoleVDM",
259 "GetConsoleHardwareState",
260 "SetConsoleHardwareState",
261 // "GetConsoleDisplayMode",
262 "AddConsoleAlias",
263 "GetConsoleAlias",
264 "GetConsoleAliasesLength",
265 "GetConsoleAliasExesLength",
266 "GetConsoleAliases",
267 "GetConsoleAliasExes",
268 "ExpungeConsoleCommandHistory",
269 "SetConsoleNumberOfCommands",
270 "GetConsoleCommandHistoryLength",
271 "GetConsoleCommandHistory",
272 // "SetConsoleCommandHistoryMode",
273 "GetConsoleCP",
274 "SetConsoleCP",
275 // "SetConsoleKeyShortcuts",
276 // "SetConsoleMenuClose",
277 // "ConsoleNotifyLastClose",
278 "GenerateConsoleCtrlEvent",
279 // "GetConsoleKeyboardLayoutName",
280 "GetConsoleWindow",
281 // "GetConsoleCharType",
282 // "SetConsoleLocalEUDC",
283 // "SetConsoleCursorMode",
284 // "GetConsoleCursorMode",
285 // "RegisterConsoleOS2",
286 // "SetConsoleOS2OemFormat",
287 // "GetConsoleNlsMode",
288 // "SetConsoleNlsMode",
289 // "RegisterConsoleIME",
290 // "UnregisterConsoleIME",
291 // "GetConsoleLangId",
292 "AttachConsole",
293 "GetConsoleSelectionInfo",
294 "GetConsoleProcessList",
295 "GetConsoleHistory",
296 "SetConsoleHistory",
297 };
298
299
300 /* FUNCTIONS ******************************************************************/
301
302 CSR_SERVER_DLL_INIT(ConServerDllInitialization)
303 {
304 /* Initialize the memory */
305 ConSrvHeap = RtlGetProcessHeap();
306
307 ConSrvInitConsoleSupport();
308
309 /* Setup the DLL Object */
310 LoadedServerDll->ApiBase = CONSRV_FIRST_API_NUMBER;
311 LoadedServerDll->HighestApiSupported = ConsolepMaxApiNumber;
312 LoadedServerDll->DispatchTable = ConsoleServerApiDispatchTable;
313 LoadedServerDll->ValidTable = ConsoleServerApiServerValidTable;
314 LoadedServerDll->NameTable = ConsoleServerApiNameTable;
315 LoadedServerDll->SizeOfProcessData = sizeof(CONSOLE_PROCESS_DATA);
316 LoadedServerDll->ConnectCallback = ConSrvConnect;
317 LoadedServerDll->DisconnectCallback = ConSrvDisconnect;
318 LoadedServerDll->NewProcessCallback = ConSrvNewProcess;
319 // LoadedServerDll->HardErrorCallback = ConSrvHardError;
320 LoadedServerDll->ShutdownProcessCallback = NULL;
321
322 ConSrvDllInstance = LoadedServerDll->ServerHandle;
323
324 /* All done */
325 return STATUS_SUCCESS;
326 }
327
328 BOOL
329 WINAPI
330 DllMain(IN HINSTANCE hInstanceDll,
331 IN DWORD dwReason,
332 IN LPVOID lpReserved)
333 {
334 UNREFERENCED_PARAMETER(hInstanceDll);
335 UNREFERENCED_PARAMETER(dwReason);
336 UNREFERENCED_PARAMETER(lpReserved);
337 return TRUE;
338 }
339
340 /* EOF */