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)
14 HANDLE DllHandle
= NULL
;
15 // HANDLE BaseApiPort = NULL;
18 HANDLE ConSrvHeap
= NULL
; // Our own heap.
19 // HANDLE BaseSrvSharedHeap = NULL; // Shared heap with CSR. (CsrSrvSharedSectionHeap)
20 // PBASE_STATIC_SERVER_DATA BaseStaticServerData = NULL; // Data that we can share amongst processes. Initialized inside BaseSrvSharedHeap.
22 // Windows 2k3 tables, adapted from http://j00ru.vexillium.org/csrss_list/api_list.html#Windows_2k3
23 // plus a little bit of Windows 7. It is for testing purposes. After that I will add stubs.
24 // Some names are also deduced from the subsystems/win32/csrss/csrsrv/server.c ones.
25 PCSR_API_ROUTINE ConsoleServerApiDispatchTable
[ConsolepMaxApiNumber
] =
31 SrvWriteConsoleOutput
,
32 // SrvReadConsoleOutputString,
33 // SrvWriteConsoleOutputString,
34 // SrvFillConsoleOutput,
36 // SrvGetConsoleNumberOfFonts,
37 SrvGetConsoleNumberOfInputEvents
,
38 SrvGetConsoleScreenBufferInfo
,
39 SrvGetConsoleCursorInfo
,
40 // SrvGetConsoleMouseInfo,
41 // SrvGetConsoleFontInfo,
42 // SrvGetConsoleFontSize,
43 // SrvGetConsoleCurrentFont,
45 SrvSetConsoleActiveScreenBuffer
,
46 SrvFlushConsoleInputBuffer
,
47 // SrvGetLargestConsoleWindowSize,
48 SrvSetConsoleScreenBufferSize
,
49 // SrvSetConsoleCursorPosition,
50 SrvSetConsoleCursorInfo
,
51 // SrvSetConsoleWindowInfo,
52 SrvScrollConsoleScreenBuffer
,
53 // SrvSetConsoleTextAttribute,
59 // SrvGetHandleInformation,
60 // SrvSetHandleInformation,
62 SrvVerifyConsoleIoHandle
,
67 SrvCreateConsoleScreenBuffer
,
68 // SrvInvalidateBitMapRect,
69 // SrvVDMConsoleOperation,
71 // SrvShowConsoleCursor,
72 // SrvConsoleMenuControl,
73 // SrvSetConsolePalette,
74 // SrvSetConsoleDisplayMode,
75 // SrvRegisterConsoleVDM,
76 SrvGetConsoleHardwareState
,
77 SrvSetConsoleHardwareState
,
78 // SrvGetConsoleDisplayMode,
81 SrvGetConsoleAliasesLength
,
82 SrvGetConsoleAliasExesLength
,
84 SrvGetConsoleAliasExes
,
85 SrvExpungeConsoleCommandHistory
,
86 SrvSetConsoleNumberOfCommands
,
87 SrvGetConsoleCommandHistoryLength
,
88 SrvGetConsoleCommandHistory
,
89 // SrvSetConsoleCommandHistoryMode,
92 // SrvSetConsoleKeyShortcuts,
93 // SrvSetConsoleMenuClose,
94 // SrvConsoleNotifyLastClose,
95 SrvGenerateConsoleCtrlEvent
,
96 // SrvGetConsoleKeyboardLayoutName,
98 // SrvGetConsoleCharType,
99 // SrvSetConsoleLocalEUDC,
100 // SrvSetConsoleCursorMode,
101 // SrvGetConsoleCursorMode,
102 // SrvRegisterConsoleOS2,
103 // SrvSetConsoleOS2OemFormat,
104 // SrvGetConsoleNlsMode,
105 // SrvSetConsoleNlsMode,
106 // SrvRegisterConsoleIME,
107 // SrvUnregisterConsoleIME,
108 // SrvGetConsoleLangId,
110 SrvGetConsoleSelectionInfo
,
111 SrvGetConsoleProcessList
,
112 SrvGetConsoleHistory
,
116 BOOLEAN ConsoleServerApiServerValidTable
[ConsolepMaxApiNumber
] =
118 // FALSE, // SrvOpenConsole,
119 FALSE
, // SrvGetConsoleInput,
120 FALSE
, // SrvWriteConsoleInput,
121 FALSE
, // SrvReadConsoleOutput,
122 FALSE
, // SrvWriteConsoleOutput,
123 // FALSE, // SrvReadConsoleOutputString,
124 // FALSE, // SrvWriteConsoleOutputString,
125 // FALSE, // SrvFillConsoleOutput,
126 FALSE
, // SrvGetConsoleMode,
127 // FALSE, // SrvGetConsoleNumberOfFonts,
128 FALSE
, // SrvGetConsoleNumberOfInputEvents,
129 FALSE
, // SrvGetConsoleScreenBufferInfo,
130 FALSE
, // SrvGetConsoleCursorInfo,
131 // FALSE, // SrvGetConsoleMouseInfo,
132 // FALSE, // SrvGetConsoleFontInfo,
133 // FALSE, // SrvGetConsoleFontSize,
134 // FALSE, // SrvGetConsoleCurrentFont,
135 FALSE
, // SrvSetConsoleMode,
136 FALSE
, // SrvSetConsoleActiveScreenBuffer,
137 FALSE
, // SrvFlushConsoleInputBuffer,
138 // FALSE, // SrvGetLargestConsoleWindowSize,
139 FALSE
, // SrvSetConsoleScreenBufferSize,
140 // FALSE, // SrvSetConsoleCursorPosition,
141 FALSE
, // SrvSetConsoleCursorInfo,
142 // FALSE, // SrvSetConsoleWindowInfo,
143 FALSE
, // SrvScrollConsoleScreenBuffer,
144 // FALSE, // SrvSetConsoleTextAttribute,
145 // FALSE, // SrvSetConsoleFont,
146 FALSE
, // SrvSetConsoleIcon,
147 FALSE
, // SrvReadConsole,
148 FALSE
, // SrvWriteConsole,
149 FALSE
, // SrvDuplicateHandle,
150 // FALSE, // SrvGetHandleInformation,
151 // FALSE, // SrvSetHandleInformation,
152 FALSE
, // SrvCloseHandle,
153 FALSE
, // SrvVerifyConsoleIoHandle,
154 FALSE
, // SrvAllocConsole,
155 FALSE
, // SrvFreeConsole,
156 FALSE
, // SrvGetConsoleTitle,
157 FALSE
, // SrvSetConsoleTitle,
158 FALSE
, // SrvCreateConsoleScreenBuffer,
159 // FALSE, // SrvInvalidateBitMapRect,
160 // FALSE, // SrvVDMConsoleOperation,
161 FALSE
, // SrvSetConsoleCursor,
162 // FALSE, // SrvShowConsoleCursor,
163 // FALSE, // SrvConsoleMenuControl,
164 // FALSE, // SrvSetConsolePalette,
165 // FALSE, // SrvSetConsoleDisplayMode,
166 // FALSE, // SrvRegisterConsoleVDM,
167 FALSE
, // SrvGetConsoleHardwareState,
168 FALSE
, // SrvSetConsoleHardwareState,
169 // TRUE, // SrvGetConsoleDisplayMode,
170 FALSE
, // SrvAddConsoleAlias,
171 FALSE
, // SrvGetConsoleAlias,
172 FALSE
, // SrvGetConsoleAliasesLength,
173 FALSE
, // SrvGetConsoleAliasExesLength,
174 FALSE
, // SrvGetConsoleAliases,
175 FALSE
, // SrvGetConsoleAliasExes,
176 FALSE
, // SrvExpungeConsoleCommandHistory,
177 FALSE
, // SrvSetConsoleNumberOfCommands,
178 FALSE
, // SrvGetConsoleCommandHistoryLength,
179 FALSE
, // SrvGetConsoleCommandHistory,
180 // FALSE, // SrvSetConsoleCommandHistoryMode,
181 FALSE
, // SrvGetConsoleCP,
182 FALSE
, // SrvSetConsoleCP,
183 // FALSE, // SrvSetConsoleKeyShortcuts,
184 // FALSE, // SrvSetConsoleMenuClose,
185 // FALSE, // SrvConsoleNotifyLastClose,
186 FALSE
, // SrvGenerateConsoleCtrlEvent,
187 // FALSE, // SrvGetConsoleKeyboardLayoutName,
188 FALSE
, // SrvGetConsoleWindow,
189 // FALSE, // SrvGetConsoleCharType,
190 // FALSE, // SrvSetConsoleLocalEUDC,
191 // FALSE, // SrvSetConsoleCursorMode,
192 // FALSE, // SrvGetConsoleCursorMode,
193 // FALSE, // SrvRegisterConsoleOS2,
194 // FALSE, // SrvSetConsoleOS2OemFormat,
195 // FALSE, // SrvGetConsoleNlsMode,
196 // FALSE, // SrvSetConsoleNlsMode,
197 // FALSE, // SrvRegisterConsoleIME,
198 // FALSE, // SrvUnregisterConsoleIME,
199 // FALSE, // SrvGetConsoleLangId,
200 // FALSE, // SrvAttachConsole,
201 FALSE
, // SrvGetConsoleSelectionInfo,
202 FALSE
, // SrvGetConsoleProcessList,
203 FALSE
, // SrvGetConsoleHistory,
204 FALSE
, // SrvSetConsoleHistory
209 PCHAR ConsoleServerApiNameTable
[ConsolepMaxApiNumber
] =
215 "WriteConsoleOutput",
216 // "ReadConsoleOutputString",
217 // "WriteConsoleOutputString",
218 // "FillConsoleOutput",
220 // "GetConsoleNumberOfFonts",
221 "GetConsoleNumberOfInputEvents",
222 "GetConsoleScreenBufferInfo",
223 "GetConsoleCursorInfo",
224 // "GetConsoleMouseInfo",
225 // "GetConsoleFontInfo",
226 // "GetConsoleFontSize",
227 // "GetConsoleCurrentFont",
229 "SetConsoleActiveScreenBuffer",
230 "FlushConsoleInputBuffer",
231 // "GetLargestConsoleWindowSize",
232 "SetConsoleScreenBufferSize",
233 // "SetConsoleCursorPosition",
234 "SetConsoleCursorInfo",
235 // "SetConsoleWindowInfo",
236 "ScrollConsoleScreenBuffer",
237 // "SetConsoleTextAttribute",
243 // "GetHandleInformation",
244 // "SetHandleInformation",
246 "VerifyConsoleIoHandle",
251 "CreateConsoleScreenBuffer",
252 // "InvalidateBitMapRect",
253 // "VDMConsoleOperation",
255 // "ShowConsoleCursor",
256 // "ConsoleMenuControl",
257 // "SetConsolePalette",
258 // "SetConsoleDisplayMode",
259 // "RegisterConsoleVDM",
260 "GetConsoleHardwareState",
261 "SetConsoleHardwareState",
262 // "GetConsoleDisplayMode",
265 "GetConsoleAliasesLength",
266 "GetConsoleAliasExesLength",
268 "GetConsoleAliasExes",
269 "ExpungeConsoleCommandHistory",
270 "SetConsoleNumberOfCommands",
271 "GetConsoleCommandHistoryLength",
272 "GetConsoleCommandHistory",
273 // "SetConsoleCommandHistoryMode",
276 // "SetConsoleKeyShortcuts",
277 // "SetConsoleMenuClose",
278 // "ConsoleNotifyLastClose",
279 "GenerateConsoleCtrlEvent",
280 // "GetConsoleKeyboardLayoutName",
282 // "GetConsoleCharType",
283 // "SetConsoleLocalEUDC",
284 // "SetConsoleCursorMode",
285 // "GetConsoleCursorMode",
286 // "RegisterConsoleOS2",
287 // "SetConsoleOS2OemFormat",
288 // "GetConsoleNlsMode",
289 // "SetConsoleNlsMode",
290 // "RegisterConsoleIME",
291 // "UnregisterConsoleIME",
292 // "GetConsoleLangId",
294 "GetConsoleSelectionInfo",
295 "GetConsoleProcessList",
303 /* FUNCTIONS ******************************************************************/
306 VOID WINAPI ConsoleStaticServerThread(PVOID x)
308 // NTSTATUS Status = STATUS_SUCCESS;
309 PPORT_MESSAGE Request = (PPORT_MESSAGE)x;
310 PPORT_MESSAGE Reply = NULL;
311 ULONG MessageType = 0;
313 DPRINT("BASESRV: %s called\n", __FUNCTION__);
315 MessageType = Request->u2.s2.Type;
316 DPRINT("BASESRV: %s received a message (Type=%d)\n",
317 __FUNCTION__, MessageType);
322 /\* Status = *\/ NtReplyPort(BaseApiPort, Reply);
328 CSR_SERVER_DLL_INIT(ConServerDllInitialization
)
330 // NTSTATUS Status = STATUS_SUCCESS;
333 DPRINT("BASSRV: %s(%ld,...) called\n", __FUNCTION__, ArgumentCount);
335 BaseApiPort = CsrQueryApiPort ();
336 Status = CsrAddStaticServerThread(ConsoleStaticServerThread);
337 if (NT_SUCCESS(Status))
339 //TODO initialize the BASE server
341 return STATUS_SUCCESS;
344 /* Initialize memory */
345 ConSrvHeap
= RtlGetProcessHeap(); // Initialize our own heap.
346 // BaseSrvSharedHeap = LoadedServerDll->SharedSection; // Get the CSR shared heap.
347 // LoadedServerDll->SharedSection = BaseStaticServerData;
349 CsrInitConsoleSupport();
351 /* Setup the DLL Object */
352 LoadedServerDll
->ApiBase
= CONSRV_FIRST_API_NUMBER
;
353 LoadedServerDll
->HighestApiSupported
= ConsolepMaxApiNumber
;
354 LoadedServerDll
->DispatchTable
= ConsoleServerApiDispatchTable
;
355 LoadedServerDll
->ValidTable
= ConsoleServerApiServerValidTable
;
356 LoadedServerDll
->NameTable
= ConsoleServerApiNameTable
;
357 LoadedServerDll
->SizeOfProcessData
= 0;
358 LoadedServerDll
->ConnectCallback
= NULL
;
359 LoadedServerDll
->DisconnectCallback
= Win32CsrReleaseConsole
;
360 LoadedServerDll
->NewProcessCallback
= Win32CsrDuplicateHandleTable
;
361 // LoadedServerDll->HardErrorCallback = Win32CsrHardError;
364 return STATUS_SUCCESS
;
369 DllMain(IN HANDLE hDll
,
371 IN LPVOID lpReserved
)
373 UNREFERENCED_PARAMETER(dwReason
);
374 UNREFERENCED_PARAMETER(lpReserved
);
376 if (DLL_PROCESS_ATTACH
== dwReason
)