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)
15 HANDLE DllHandle
= NULL
;
16 // HANDLE BaseApiPort = NULL;
19 HANDLE ConSrvHeap
= NULL
; // Our own heap.
20 // HANDLE BaseSrvSharedHeap = NULL; // Shared heap with CSR. (CsrSrvSharedSectionHeap)
21 // PBASE_STATIC_SERVER_DATA BaseStaticServerData = NULL; // Data that we can share amongst processes. Initialized inside BaseSrvSharedHeap.
23 // Windows 2k3 tables, adapted from http://j00ru.vexillium.org/csrss_list/api_list.html#Windows_2k3
24 // plus a little bit of Windows 7. It is for testing purposes. After that I will add stubs.
25 // Some names are also deduced from the subsystems/win32/csrss/csrsrv/server.c ones.
26 PCSR_API_ROUTINE ConsoleServerApiDispatchTable
[ConsolepMaxApiNumber
] =
32 SrvWriteConsoleOutput
,
33 // SrvReadConsoleOutputString,
34 // SrvWriteConsoleOutputString,
35 // SrvFillConsoleOutput,
37 // SrvGetConsoleNumberOfFonts,
38 SrvGetConsoleNumberOfInputEvents
,
39 SrvGetConsoleScreenBufferInfo
,
40 SrvGetConsoleCursorInfo
,
41 // SrvGetConsoleMouseInfo,
42 // SrvGetConsoleFontInfo,
43 // SrvGetConsoleFontSize,
44 // SrvGetConsoleCurrentFont,
46 SrvSetConsoleActiveScreenBuffer
,
47 SrvFlushConsoleInputBuffer
,
48 // SrvGetLargestConsoleWindowSize,
49 SrvSetConsoleScreenBufferSize
,
50 // SrvSetConsoleCursorPosition,
51 SrvSetConsoleCursorInfo
,
52 // SrvSetConsoleWindowInfo,
53 SrvScrollConsoleScreenBuffer
,
54 // SrvSetConsoleTextAttribute,
60 // SrvGetHandleInformation,
61 // SrvSetHandleInformation,
63 SrvVerifyConsoleIoHandle
,
68 SrvCreateConsoleScreenBuffer
,
69 // SrvInvalidateBitMapRect,
70 // SrvVDMConsoleOperation,
72 // SrvShowConsoleCursor,
73 // SrvConsoleMenuControl,
74 // SrvSetConsolePalette,
75 // SrvSetConsoleDisplayMode,
76 // SrvRegisterConsoleVDM,
77 SrvGetConsoleHardwareState
,
78 SrvSetConsoleHardwareState
,
79 // SrvGetConsoleDisplayMode,
82 SrvGetConsoleAliasesLength
,
83 SrvGetConsoleAliasExesLength
,
85 SrvGetConsoleAliasExes
,
86 SrvExpungeConsoleCommandHistory
,
87 SrvSetConsoleNumberOfCommands
,
88 SrvGetConsoleCommandHistoryLength
,
89 SrvGetConsoleCommandHistory
,
90 // SrvSetConsoleCommandHistoryMode,
93 // SrvSetConsoleKeyShortcuts,
94 // SrvSetConsoleMenuClose,
95 // SrvConsoleNotifyLastClose,
96 SrvGenerateConsoleCtrlEvent
,
97 // SrvGetConsoleKeyboardLayoutName,
99 // SrvGetConsoleCharType,
100 // SrvSetConsoleLocalEUDC,
101 // SrvSetConsoleCursorMode,
102 // SrvGetConsoleCursorMode,
103 // SrvRegisterConsoleOS2,
104 // SrvSetConsoleOS2OemFormat,
105 // SrvGetConsoleNlsMode,
106 // SrvSetConsoleNlsMode,
107 // SrvRegisterConsoleIME,
108 // SrvUnregisterConsoleIME,
109 // SrvGetConsoleLangId,
111 SrvGetConsoleSelectionInfo
,
112 SrvGetConsoleProcessList
,
113 SrvGetConsoleHistory
,
117 BOOLEAN ConsoleServerApiServerValidTable
[ConsolepMaxApiNumber
] =
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
210 PCHAR ConsoleServerApiNameTable
[ConsolepMaxApiNumber
] =
216 "WriteConsoleOutput",
217 // "ReadConsoleOutputString",
218 // "WriteConsoleOutputString",
219 // "FillConsoleOutput",
221 // "GetConsoleNumberOfFonts",
222 "GetConsoleNumberOfInputEvents",
223 "GetConsoleScreenBufferInfo",
224 "GetConsoleCursorInfo",
225 // "GetConsoleMouseInfo",
226 // "GetConsoleFontInfo",
227 // "GetConsoleFontSize",
228 // "GetConsoleCurrentFont",
230 "SetConsoleActiveScreenBuffer",
231 "FlushConsoleInputBuffer",
232 // "GetLargestConsoleWindowSize",
233 "SetConsoleScreenBufferSize",
234 // "SetConsoleCursorPosition",
235 "SetConsoleCursorInfo",
236 // "SetConsoleWindowInfo",
237 "ScrollConsoleScreenBuffer",
238 // "SetConsoleTextAttribute",
244 // "GetHandleInformation",
245 // "SetHandleInformation",
247 "VerifyConsoleIoHandle",
252 "CreateConsoleScreenBuffer",
253 // "InvalidateBitMapRect",
254 // "VDMConsoleOperation",
256 // "ShowConsoleCursor",
257 // "ConsoleMenuControl",
258 // "SetConsolePalette",
259 // "SetConsoleDisplayMode",
260 // "RegisterConsoleVDM",
261 "GetConsoleHardwareState",
262 "SetConsoleHardwareState",
263 // "GetConsoleDisplayMode",
266 "GetConsoleAliasesLength",
267 "GetConsoleAliasExesLength",
269 "GetConsoleAliasExes",
270 "ExpungeConsoleCommandHistory",
271 "SetConsoleNumberOfCommands",
272 "GetConsoleCommandHistoryLength",
273 "GetConsoleCommandHistory",
274 // "SetConsoleCommandHistoryMode",
277 // "SetConsoleKeyShortcuts",
278 // "SetConsoleMenuClose",
279 // "ConsoleNotifyLastClose",
280 "GenerateConsoleCtrlEvent",
281 // "GetConsoleKeyboardLayoutName",
283 // "GetConsoleCharType",
284 // "SetConsoleLocalEUDC",
285 // "SetConsoleCursorMode",
286 // "GetConsoleCursorMode",
287 // "RegisterConsoleOS2",
288 // "SetConsoleOS2OemFormat",
289 // "GetConsoleNlsMode",
290 // "SetConsoleNlsMode",
291 // "RegisterConsoleIME",
292 // "UnregisterConsoleIME",
293 // "GetConsoleLangId",
295 "GetConsoleSelectionInfo",
296 "GetConsoleProcessList",
304 /* FUNCTIONS ******************************************************************/
307 VOID WINAPI ConsoleStaticServerThread(PVOID x)
309 // NTSTATUS Status = STATUS_SUCCESS;
310 PPORT_MESSAGE Request = (PPORT_MESSAGE)x;
311 PPORT_MESSAGE Reply = NULL;
312 ULONG MessageType = 0;
314 DPRINT("BASESRV: %s called\n", __FUNCTION__);
316 MessageType = Request->u2.s2.Type;
317 DPRINT("BASESRV: %s received a message (Type=%d)\n",
318 __FUNCTION__, MessageType);
323 /\* Status = *\/ NtReplyPort(BaseApiPort, Reply);
329 CSR_SERVER_DLL_INIT(ConServerDllInitialization
)
332 NTSTATUS Status = STATUS_SUCCESS;
334 DPRINT("BASSRV: %s(%ld,...) called\n", __FUNCTION__, ArgumentCount);
336 // Get the listening port from csrsrv.dll
337 BaseApiPort = CsrQueryApiPort();
338 if (BaseApiPort == NULL) return STATUS_UNSUCCESSFUL;
340 // Register our message dispatcher
341 Status = CsrAddStaticServerThread(ConsoleStaticServerThread);
342 if (NT_SUCCESS(Status))
344 //TODO initialize the BASE server
346 return STATUS_SUCCESS;
349 /* Initialize memory */
350 ConSrvHeap
= RtlGetProcessHeap(); // Initialize our own heap.
351 // BaseSrvSharedHeap = LoadedServerDll->SharedSection; // Get the CSR shared heap.
352 // LoadedServerDll->SharedSection = BaseStaticServerData;
354 CsrInitConsoleSupport();
356 /* Setup the DLL Object */
357 LoadedServerDll
->ApiBase
= CONSRV_FIRST_API_NUMBER
;
358 LoadedServerDll
->HighestApiSupported
= ConsolepMaxApiNumber
;
359 LoadedServerDll
->DispatchTable
= ConsoleServerApiDispatchTable
;
360 LoadedServerDll
->ValidTable
= ConsoleServerApiServerValidTable
;
361 LoadedServerDll
->NameTable
= ConsoleServerApiNameTable
;
362 LoadedServerDll
->SizeOfProcessData
= 0;
363 LoadedServerDll
->ConnectCallback
= NULL
;
364 LoadedServerDll
->DisconnectCallback
= Win32CsrReleaseConsole
;
365 LoadedServerDll
->NewProcessCallback
= Win32CsrDuplicateHandleTable
;
366 // LoadedServerDll->HardErrorCallback = Win32CsrHardError;
369 return STATUS_SUCCESS
;
374 DllMain(IN HANDLE hDll
,
376 IN LPVOID lpReserved
)
378 UNREFERENCED_PARAMETER(dwReason
);
379 UNREFERENCED_PARAMETER(lpReserved
);
381 if (DLL_PROCESS_ATTACH
== dwReason
)