[CONSRV]
[reactos.git] / include / reactos / subsys / win / conmsg.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Client/Server Runtime SubSystem
4 * FILE: include/reactos/subsys/win/conmsg.h
5 * PURPOSE: Public definitions for communication
6 * between Console API Clients and Servers
7 * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca@sfr.fr)
8 */
9
10 #ifndef _CONMSG_H
11 #define _CONMSG_H
12
13 #pragma once
14
15 #define CONSRV_SERVERDLL_INDEX 2
16 #define CONSRV_FIRST_API_NUMBER 512
17
18 // Windows 2k3 tables, adapted from http://j00ru.vexillium.org/csrss_list/api_list.html#Windows_2k3
19 // plus a little bit of Windows 7. It is for testing purposes. After that I will add stubs.
20 // Some names are also deduced from the subsystems/win32/csrss/csrsrv/server.c ones.
21 typedef enum _CONSRV_API_NUMBER
22 {
23 ConsolepOpenConsole = CONSRV_FIRST_API_NUMBER,
24 ConsolepGetConsoleInput,
25 ConsolepWriteConsoleInput,
26 ConsolepReadConsoleOutput,
27 ConsolepWriteConsoleOutput,
28 ConsolepReadConsoleOutputString,
29 ConsolepWriteConsoleOutputString,
30 ConsolepFillConsoleOutput,
31 ConsolepGetMode,
32 // ConsolepGetNumberOfFonts,
33 ConsolepGetNumberOfInputEvents,
34 ConsolepGetScreenBufferInfo,
35 ConsolepGetCursorInfo,
36 // ConsolepGetMouseInfo,
37 // ConsolepGetFontInfo,
38 // ConsolepGetFontSize,
39 // ConsolepGetCurrentFont,
40 ConsolepSetMode,
41 ConsolepSetActiveScreenBuffer,
42 ConsolepFlushInputBuffer,
43 // ConsolepGetLargestWindowSize,
44 ConsolepSetScreenBufferSize,
45 ConsolepSetCursorPosition,
46 ConsolepSetCursorInfo,
47 // ConsolepSetWindowInfo,
48 ConsolepScrollScreenBuffer,
49 ConsolepSetTextAttribute,
50 // ConsolepSetFont,
51 ConsolepSetIcon,
52 ConsolepReadConsole,
53 ConsolepWriteConsole,
54 ConsolepDuplicateHandle,
55 // ConsolepGetHandleInformation,
56 // ConsolepSetHandleInformation,
57 ConsolepCloseHandle,
58 ConsolepVerifyIoHandle,
59 ConsolepAlloc,
60 ConsolepFree,
61 ConsolepGetTitle,
62 ConsolepSetTitle,
63 ConsolepCreateScreenBuffer,
64 // ConsolepInvalidateBitMapRect,
65 // ConsolepVDMOperation,
66 // ConsolepSetCursor,
67 // ConsolepShowCursor,
68 // ConsolepMenuControl,
69 // ConsolepSetPalette,
70 // ConsolepSetDisplayMode,
71 // ConsolepRegisterVDM,
72 ConsolepGetHardwareState,
73 ConsolepSetHardwareState,
74 // ConsolepGetDisplayMode,
75 ConsolepAddAlias,
76 ConsolepGetAlias,
77 ConsolepGetAliasesLength,
78 ConsolepGetAliasExesLength,
79 ConsolepGetAliases,
80 ConsolepGetAliasExes,
81 ConsolepExpungeCommandHistory,
82 ConsolepSetNumberOfCommands,
83 ConsolepGetCommandHistoryLength,
84 ConsolepGetCommandHistory,
85 // ConsolepSetCommandHistoryMode,
86 ConsolepGetCP,
87 ConsolepSetCP,
88 // ConsolepSetKeyShortcuts,
89 // ConsolepSetMenuClose,
90 // ConsolepNotifyLastClose,
91 ConsolepGenerateCtrlEvent,
92 // ConsolepGetKeyboardLayoutName,
93 ConsolepGetConsoleWindow,
94 // ConsolepCharType,
95 // ConsolepSetLocalEUDC,
96 // ConsolepSetCursorMode,
97 // ConsolepGetCursorMode,
98 // ConsolepRegisterOS2,
99 // ConsolepSetOS2OemFormat,
100 // ConsolepGetNlsMode,
101 // ConsolepSetNlsMode,
102 // ConsolepRegisterConsoleIME,
103 // ConsolepUnregisterConsoleIME,
104 // ConsolepGetLangId,
105 // ConsolepAttach,
106 ConsolepGetSelectionInfo,
107 ConsolepGetProcessList,
108 ConsolepGetHistory,
109 ConsolepSetHistory,
110
111 ConsolepMaxApiNumber
112 } CONSRV_API_NUMBER, *PCONSRV_API_NUMBER;
113
114
115 typedef struct _CONSOLE_CONNECTION_INFO
116 {
117 ULONG Dummy;
118 } CONSOLE_CONNECTION_INFO, *PCONSOLE_CONNECTION_INFO;
119
120
121 #define CONSOLE_INPUT_MODE_VALID 0x0f
122 #define CONSOLE_OUTPUT_MODE_VALID 0x03
123
124
125 typedef struct
126 {
127 USHORT nMaxIds;
128 ULONG nProcessIdsTotal;
129 PDWORD pProcessIds;
130 } CSRSS_GET_PROCESS_LIST, *PCSRSS_GET_PROCESS_LIST;
131
132 typedef struct
133 {
134 HANDLE ConsoleHandle;
135 BOOL Unicode;
136 ULONG NrCharactersToWrite;
137 ULONG NrCharactersWritten;
138
139 ULONG BufferSize;
140 PVOID Buffer;
141 } CSRSS_WRITE_CONSOLE, *PCSRSS_WRITE_CONSOLE;
142
143 typedef struct
144 {
145 HANDLE ConsoleHandle;
146 BOOL Unicode;
147 WORD NrCharactersToRead;
148 WORD NrCharactersRead;
149
150 UNICODE_STRING ExeName;
151 DWORD CtrlWakeupMask;
152 DWORD ControlKeyState;
153
154 ULONG BufferSize;
155 PVOID Buffer;
156 } CSRSS_READ_CONSOLE, *PCSRSS_READ_CONSOLE;
157
158 typedef struct
159 {
160 LPTHREAD_START_ROUTINE CtrlDispatcher;
161 BOOL ConsoleNeeded;
162 INT ShowCmd;
163 HANDLE Console;
164 HANDLE InputHandle;
165 HANDLE OutputHandle;
166 } CSRSS_ALLOC_CONSOLE, *PCSRSS_ALLOC_CONSOLE;
167
168 typedef struct
169 {
170 ULONG Dummy;
171 } CSRSS_FREE_CONSOLE, *PCSRSS_FREE_CONSOLE;
172
173 typedef struct
174 {
175 HANDLE ConsoleHandle;
176 CONSOLE_SCREEN_BUFFER_INFO Info;
177 } CSRSS_SCREEN_BUFFER_INFO, *PCSRSS_SCREEN_BUFFER_INFO;
178
179 typedef struct
180 {
181 HANDLE ConsoleHandle;
182 COORD Position;
183 } CSRSS_SET_CURSOR_POSITION, *PCSRSS_SET_CURSOR_POSITION;
184
185 typedef struct
186 {
187 HANDLE ConsoleHandle;
188 CONSOLE_CURSOR_INFO Info;
189 } CSRSS_CURSOR_INFO, *PCSRSS_CURSOR_INFO;
190
191 typedef struct
192 {
193 HANDLE ConsoleHandle;
194 WORD Attrib;
195 } CSRSS_SET_ATTRIB, *PCSRSS_SET_ATTRIB;
196
197 typedef struct
198 {
199 HANDLE ConsoleHandle;
200 DWORD ConsoleMode;
201 } CSRSS_CONSOLE_MODE, *PCSRSS_CONSOLE_MODE;
202
203 typedef struct
204 {
205 DWORD Access;
206 DWORD ShareMode;
207 BOOL Inheritable;
208 HANDLE OutputHandle; /* handle to newly created screen buffer */
209 } CSRSS_CREATE_SCREEN_BUFFER, *PCSRSS_CREATE_SCREEN_BUFFER;
210
211 typedef struct
212 {
213 HANDLE OutputHandle; /* handle to screen buffer to switch to */
214 } CSRSS_SET_SCREEN_BUFFER, *PCSRSS_SET_SCREEN_BUFFER;
215
216 typedef struct
217 {
218 DWORD Length;
219 PWCHAR Title;
220 } CSRSS_CONSOLE_TITLE, *PCSRSS_CONSOLE_TITLE;
221
222 typedef struct
223 {
224 HANDLE ConsoleHandle;
225 BOOL Unicode;
226 COORD BufferSize;
227 COORD BufferCoord;
228 SMALL_RECT WriteRegion;
229 CHAR_INFO* CharInfo;
230 } CSRSS_WRITE_CONSOLE_OUTPUT, *PCSRSS_WRITE_CONSOLE_OUTPUT;
231
232 typedef struct
233 {
234 HANDLE ConsoleInput;
235 } CSRSS_FLUSH_INPUT_BUFFER, *PCSRSS_FLUSH_INPUT_BUFFER;
236
237 typedef struct
238 {
239 HANDLE ConsoleHandle;
240 BOOL Unicode;
241 SMALL_RECT ScrollRectangle;
242 BOOL UseClipRectangle;
243 SMALL_RECT ClipRectangle;
244 COORD DestinationOrigin;
245 CHAR_INFO Fill;
246 } CSRSS_SCROLL_CONSOLE_SCREEN_BUFFER, *PCSRSS_SCROLL_CONSOLE_SCREEN_BUFFER;
247
248
249 /*
250 * An attribute or a character are instances of the same entity, namely
251 * a "code" (what would be called an (ANSI) escape sequence). Therefore
252 * encode them inside the same structure.
253 */
254 typedef enum _CODE_TYPE
255 {
256 CODE_ASCII = 0x01,
257 CODE_UNICODE = 0x02,
258 CODE_ATTRIBUTE = 0x03
259 } CODE_TYPE;
260
261 typedef struct
262 {
263 HANDLE ConsoleHandle;
264
265 DWORD NumCodesToRead;
266 COORD ReadCoord;
267 COORD EndCoord;
268
269 DWORD CodesRead;
270
271 CODE_TYPE CodeType;
272 union
273 {
274 PVOID pCode;
275 PCHAR AsciiChar;
276 PWCHAR UnicodeChar;
277 PWORD Attribute;
278 } pCode; // Either a pointer to a character or to an attribute.
279 } CSRSS_READ_CONSOLE_OUTPUT_CODE, *PCSRSS_READ_CONSOLE_OUTPUT_CODE;
280
281 typedef struct
282 {
283 HANDLE ConsoleHandle;
284 USHORT CodeType;
285
286 ULONG BufferSize;
287 WORD Length;
288 COORD Coord;
289 COORD EndCoord;
290
291 ULONG NrCharactersWritten;
292
293 union
294 {
295 // PVOID String;
296 PVOID pCode;
297 PCHAR AsciiChar;
298 PWCHAR UnicodeChar;
299 PWORD Attribute;
300 } pCode; // Either a pointer to a character or to an attribute.
301 } CSRSS_WRITE_CONSOLE_OUTPUT_CODE, *PCSRSS_WRITE_CONSOLE_OUTPUT_CODE;
302
303 typedef struct
304 {
305 HANDLE ConsoleHandle;
306
307 CODE_TYPE CodeType;
308 union
309 {
310 CHAR AsciiChar;
311 WCHAR UnicodeChar;
312 WORD Attribute;
313 } Code; // Either a character or an attribute.
314
315 COORD Coord;
316 ULONG Length;
317
318 ULONG NrCharactersWritten; // FIXME: Only for chars, is it removable ?
319 } CSRSS_FILL_OUTPUT, *PCSRSS_FILL_OUTPUT;
320
321 typedef struct
322 {
323 HANDLE ConsoleHandle;
324 BOOL Unicode;
325 BOOL bRead; // TRUE --> Read ; FALSE --> Peek
326
327 ULONG InputsRead;
328
329 ULONG Length;
330 PINPUT_RECORD InputRecord;
331 } CSRSS_GET_CONSOLE_INPUT, *PCSRSS_GET_CONSOLE_INPUT;
332
333 typedef struct
334 {
335 HANDLE ConsoleHandle;
336 BOOL Unicode;
337 COORD BufferSize;
338 COORD BufferCoord;
339 SMALL_RECT ReadRegion;
340 CHAR_INFO* CharInfo;
341 } CSRSS_READ_CONSOLE_OUTPUT, *PCSRSS_READ_CONSOLE_OUTPUT;
342
343 typedef struct
344 {
345 HANDLE ConsoleHandle;
346 BOOL Unicode;
347 DWORD Length;
348 INPUT_RECORD* InputRecord;
349 } CSRSS_WRITE_CONSOLE_INPUT, *PCSRSS_WRITE_CONSOLE_INPUT;
350
351 typedef struct
352 {
353 HANDLE Handle;
354 } CSRSS_CLOSE_HANDLE, *PCSRSS_CLOSE_HANDLE;
355
356 typedef struct
357 {
358 HANDLE Handle;
359 } CSRSS_VERIFY_HANDLE, *PCSRSS_VERIFY_HANDLE;
360
361 typedef struct
362 {
363 HANDLE Handle;
364 DWORD Access;
365 BOOL Inheritable;
366 DWORD Options;
367 } CSRSS_DUPLICATE_HANDLE, *PCSRSS_DUPLICATE_HANDLE;
368
369 /*
370 * Type of handles.
371 */
372 typedef enum _CONSOLE_HANDLE_TYPE
373 {
374 HANDLE_INPUT = 0x01,
375 HANDLE_OUTPUT = 0x02
376 } CONSOLE_HANDLE_TYPE;
377
378 typedef struct
379 {
380 HANDLE Handle;
381 CONSOLE_HANDLE_TYPE HandleType;
382 DWORD Access;
383 BOOL Inheritable;
384 DWORD ShareMode;
385 } CSRSS_OPEN_CONSOLE, *PCSRSS_OPEN_CONSOLE;
386
387 typedef struct
388 {
389 HANDLE InputWaitHandle;
390 } CSRSS_GET_INPUT_WAIT_HANDLE, *PCSRSS_GET_INPUT_WAIT_HANDLE;
391
392
393 /*
394 * Console hardware states.
395 */
396 #define CONSOLE_HARDWARE_STATE_GDI_MANAGED 0
397 #define CONSOLE_HARDWARE_STATE_DIRECT 1
398
399 typedef struct
400 {
401 HANDLE ConsoleHandle;
402 DWORD State;
403 } CSRSS_CONSOLE_HW_STATE, *PCSRSS_CONSOLE_HW_STATE;
404
405 typedef struct
406 {
407 HWND WindowHandle;
408 } CSRSS_GET_CONSOLE_WINDOW, *PCSRSS_GET_CONSOLE_WINDOW;
409
410 typedef struct
411 {
412 HICON WindowIcon;
413 } CSRSS_SET_CONSOLE_ICON, *PCSRSS_SET_CONSOLE_ICON;
414
415
416
417
418
419
420
421
422
423 typedef struct
424 {
425 ULONG SourceLength;
426 ULONG TargetLength; // Also used for storing the number of bytes written.
427 ULONG ExeLength;
428 LPWSTR Source;
429 LPWSTR Target;
430 LPWSTR Exe;
431 } CSRSS_CONSOLE_ALIAS, *PCSRSS_CONSOLE_ALIAS;
432
433 typedef struct
434 {
435 DWORD ExeLength;
436 DWORD AliasesBufferLength;
437 LPWSTR ExeName;
438 LPWSTR AliasesBuffer;
439 } CSRSS_GET_ALL_CONSOLE_ALIASES, *PCSRSS_GET_ALL_CONSOLE_ALIASES;
440
441 typedef struct
442 {
443 DWORD Length;
444 DWORD ExeLength;
445 LPWSTR ExeName;
446 } CSRSS_GET_ALL_CONSOLE_ALIASES_LENGTH, *PCSRSS_GET_ALL_CONSOLE_ALIASES_LENGTH;
447
448 typedef struct
449 {
450 DWORD Length;
451 LPWSTR ExeNames;
452 } CSRSS_GET_CONSOLE_ALIASES_EXES, *PCSRSS_GET_CONSOLE_ALIASES_EXES;
453
454 typedef struct
455 {
456 DWORD Length;
457 } CSRSS_GET_CONSOLE_ALIASES_EXES_LENGTH, *PCSRSS_GET_CONSOLE_ALIASES_EXES_LENGTH;
458
459
460
461
462
463
464 typedef struct
465 {
466 UNICODE_STRING ExeName;
467 PWCHAR History;
468 DWORD Length;
469 } CSRSS_GET_COMMAND_HISTORY, *PCSRSS_GET_COMMAND_HISTORY;
470
471 typedef struct
472 {
473 UNICODE_STRING ExeName;
474 DWORD Length;
475 } CSRSS_GET_COMMAND_HISTORY_LENGTH, *PCSRSS_GET_COMMAND_HISTORY_LENGTH;
476
477 typedef struct
478 {
479 UNICODE_STRING ExeName;
480 } CSRSS_EXPUNGE_COMMAND_HISTORY, *PCSRSS_EXPUNGE_COMMAND_HISTORY;
481
482 typedef struct
483 {
484 UNICODE_STRING ExeName;
485 DWORD NumCommands;
486 } CSRSS_SET_HISTORY_NUMBER_COMMANDS, *PCSRSS_SET_HISTORY_NUMBER_COMMANDS;
487
488 typedef struct
489 {
490 UINT HistoryBufferSize;
491 UINT NumberOfHistoryBuffers;
492 DWORD dwFlags;
493 } CSRSS_HISTORY_INFO, *PCSRSS_HISTORY_INFO;
494
495
496
497
498
499
500
501
502
503
504 typedef struct
505 {
506 DWORD Event;
507 DWORD ProcessGroup;
508 } CSRSS_GENERATE_CTRL_EVENT, *PCSRSS_GENERATE_CTRL_EVENT;
509
510 typedef struct
511 {
512 HANDLE ConsoleHandle;
513 DWORD NumInputEvents;
514 } CSRSS_GET_NUM_INPUT_EVENTS, *PCSRSS_GET_NUM_INPUT_EVENTS;
515
516 typedef struct
517 {
518 HANDLE OutputHandle;
519 COORD Size;
520 } CSRSS_SET_SCREEN_BUFFER_SIZE, *PCSRSS_SET_SCREEN_BUFFER_SIZE;
521
522 typedef struct
523 {
524 CONSOLE_SELECTION_INFO Info;
525 } CSRSS_GET_CONSOLE_SELECTION_INFO, *PCSRSS_GET_CONSOLE_SELECTION_INFO;
526
527 typedef struct
528 {
529 BOOL InputCP; // TRUE : Input Code Page ; FALSE : Output Code Page
530 UINT CodePage;
531 } CSRSS_CONSOLE_CP, *PCSRSS_CONSOLE_CP;
532
533 typedef struct _CONSOLE_API_MESSAGE
534 {
535 PORT_MESSAGE Header;
536
537 PCSR_CAPTURE_BUFFER CsrCaptureData;
538 CSR_API_NUMBER ApiNumber;
539 ULONG Status; // ReturnValue; // NTSTATUS Status
540 ULONG Reserved;
541 union
542 {
543 CSRSS_ALLOC_CONSOLE AllocConsoleRequest;
544 CSRSS_FREE_CONSOLE FreeConsoleRequest;
545
546 /* Handles */
547 CSRSS_OPEN_CONSOLE OpenConsoleRequest;
548 CSRSS_CLOSE_HANDLE CloseHandleRequest;
549 CSRSS_VERIFY_HANDLE VerifyHandleRequest;
550 CSRSS_DUPLICATE_HANDLE DuplicateHandleRequest;
551 CSRSS_GET_INPUT_WAIT_HANDLE GetConsoleInputWaitHandle;
552
553 /* Cursor */
554 CSRSS_CURSOR_INFO CursorInfoRequest;
555 CSRSS_SET_CURSOR_POSITION SetCursorPositionRequest;
556
557 /* Screen buffer */
558 CSRSS_CREATE_SCREEN_BUFFER CreateScreenBufferRequest;
559 CSRSS_SET_SCREEN_BUFFER SetScreenBufferRequest;
560 CSRSS_SCREEN_BUFFER_INFO ScreenBufferInfoRequest;
561 CSRSS_SET_SCREEN_BUFFER_SIZE SetScreenBufferSize;
562 CSRSS_SCROLL_CONSOLE_SCREEN_BUFFER ScrollConsoleScreenBufferRequest;
563
564 CSRSS_GET_CONSOLE_SELECTION_INFO GetConsoleSelectionInfo;
565 CSRSS_FLUSH_INPUT_BUFFER FlushInputBufferRequest;
566
567 /* Console mode */
568 CSRSS_CONSOLE_MODE ConsoleModeRequest;
569 CSRSS_CONSOLE_HW_STATE ConsoleHardwareStateRequest;
570
571 /* Console window */
572 CSRSS_CONSOLE_TITLE TitleRequest;
573 CSRSS_GET_CONSOLE_WINDOW GetConsoleWindowRequest;
574 CSRSS_SET_CONSOLE_ICON SetConsoleIconRequest;
575
576 /* Read */
577 CSRSS_READ_CONSOLE ReadConsoleRequest; // SrvReadConsole / ReadConsole
578 CSRSS_GET_CONSOLE_INPUT GetConsoleInputRequest; // SrvGetConsoleInput / PeekConsoleInput & ReadConsoleInput
579 CSRSS_READ_CONSOLE_OUTPUT ReadConsoleOutputRequest; // SrvReadConsoleOutput / ReadConsoleOutput
580 CSRSS_READ_CONSOLE_OUTPUT_CODE ReadConsoleOutputCodeRequest; // SrvReadConsoleOutputString / ReadConsoleOutputAttribute & ReadConsoleOutputCharacter
581
582 /* Write */
583 CSRSS_WRITE_CONSOLE WriteConsoleRequest; // SrvWriteConsole / WriteConsole
584 CSRSS_WRITE_CONSOLE_INPUT WriteConsoleInputRequest;
585 CSRSS_WRITE_CONSOLE_OUTPUT WriteConsoleOutputRequest;
586 CSRSS_WRITE_CONSOLE_OUTPUT_CODE WriteConsoleOutputCodeRequest;
587
588 CSRSS_FILL_OUTPUT FillOutputRequest;
589 CSRSS_SET_ATTRIB SetAttribRequest;
590
591 /* Aliases */
592 CSRSS_CONSOLE_ALIAS ConsoleAlias;
593 CSRSS_GET_ALL_CONSOLE_ALIASES GetAllConsoleAliases;
594 CSRSS_GET_ALL_CONSOLE_ALIASES_LENGTH GetAllConsoleAliasesLength;
595 CSRSS_GET_CONSOLE_ALIASES_EXES GetConsoleAliasesExes;
596 CSRSS_GET_CONSOLE_ALIASES_EXES_LENGTH GetConsoleAliasesExesLength;
597
598 /* History */
599 CSRSS_GET_COMMAND_HISTORY GetCommandHistory;
600 CSRSS_GET_COMMAND_HISTORY_LENGTH GetCommandHistoryLength;
601 CSRSS_EXPUNGE_COMMAND_HISTORY ExpungeCommandHistory;
602 CSRSS_SET_HISTORY_NUMBER_COMMANDS SetHistoryNumberCommands;
603 CSRSS_HISTORY_INFO HistoryInfoRequest;
604
605 CSRSS_GENERATE_CTRL_EVENT GenerateCtrlEvent;
606 CSRSS_GET_NUM_INPUT_EVENTS GetNumInputEventsRequest;
607
608 /* Input and Output Code Pages */
609 CSRSS_CONSOLE_CP ConsoleCPRequest;
610
611 CSRSS_GET_PROCESS_LIST GetProcessListRequest;
612 } Data;
613 } CONSOLE_API_MESSAGE, *PCONSOLE_API_MESSAGE;
614
615 // Check that a CONSOLE_API_MESSAGE can hold in a CSR_API_MESSAGE.
616 CHECK_API_MSG_SIZE(CONSOLE_API_MESSAGE);
617
618 #endif // _CONMSG_H
619
620 /* EOF */