[KERNEL32]
[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
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 // HANDLE UnpauseEvent;
139
140 ULONG BufferSize;
141 PVOID Buffer;
142 } CSRSS_WRITE_CONSOLE, *PCSRSS_WRITE_CONSOLE;
143
144 typedef struct
145 {
146 HANDLE ConsoleHandle;
147 BOOL Unicode;
148 WORD NrCharactersToRead;
149 WORD NrCharactersRead;
150
151 UNICODE_STRING ExeName;
152 DWORD CtrlWakeupMask;
153 DWORD ControlKeyState;
154
155 ULONG BufferSize;
156 PVOID Buffer;
157 } CSRSS_READ_CONSOLE, *PCSRSS_READ_CONSOLE;
158
159 typedef struct
160 {
161 LPTHREAD_START_ROUTINE CtrlDispatcher;
162 BOOL ConsoleNeeded;
163 INT ShowCmd;
164 HANDLE Console;
165 HANDLE InputHandle;
166 HANDLE OutputHandle;
167 } CSRSS_ALLOC_CONSOLE, *PCSRSS_ALLOC_CONSOLE;
168
169 typedef struct
170 {
171 ULONG Dummy;
172 } CSRSS_FREE_CONSOLE, *PCSRSS_FREE_CONSOLE;
173
174 typedef struct
175 {
176 HANDLE ConsoleHandle;
177 CONSOLE_SCREEN_BUFFER_INFO Info;
178 } CSRSS_SCREEN_BUFFER_INFO, *PCSRSS_SCREEN_BUFFER_INFO;
179
180 typedef struct
181 {
182 HANDLE ConsoleHandle;
183 COORD Position;
184 } CSRSS_SET_CURSOR_POSITION, *PCSRSS_SET_CURSOR_POSITION;
185
186 typedef struct
187 {
188 HANDLE ConsoleHandle;
189 CONSOLE_CURSOR_INFO Info;
190 } CSRSS_CURSOR_INFO, *PCSRSS_CURSOR_INFO;
191
192 typedef struct
193 {
194 HANDLE ConsoleHandle;
195 WORD Attrib;
196 } CSRSS_SET_ATTRIB, *PCSRSS_SET_ATTRIB;
197
198 typedef struct
199 {
200 HANDLE ConsoleHandle;
201 DWORD ConsoleMode;
202 } CSRSS_CONSOLE_MODE, *PCSRSS_CONSOLE_MODE;
203
204 typedef struct
205 {
206 DWORD Access;
207 DWORD ShareMode;
208 BOOL Inheritable;
209 HANDLE OutputHandle; /* handle to newly created screen buffer */
210 } CSRSS_CREATE_SCREEN_BUFFER, *PCSRSS_CREATE_SCREEN_BUFFER;
211
212 typedef struct
213 {
214 HANDLE OutputHandle; /* handle to screen buffer to switch to */
215 } CSRSS_SET_SCREEN_BUFFER, *PCSRSS_SET_SCREEN_BUFFER;
216
217 typedef struct
218 {
219 DWORD Length;
220 PWCHAR Title;
221 } CSRSS_CONSOLE_TITLE, *PCSRSS_CONSOLE_TITLE;
222
223 typedef struct
224 {
225 HANDLE ConsoleHandle;
226 BOOL Unicode;
227 COORD BufferSize;
228 COORD BufferCoord;
229 SMALL_RECT WriteRegion;
230 CHAR_INFO* CharInfo;
231 } CSRSS_WRITE_CONSOLE_OUTPUT, *PCSRSS_WRITE_CONSOLE_OUTPUT;
232
233 typedef struct
234 {
235 HANDLE ConsoleInput;
236 } CSRSS_FLUSH_INPUT_BUFFER, *PCSRSS_FLUSH_INPUT_BUFFER;
237
238 typedef struct
239 {
240 HANDLE ConsoleHandle;
241 BOOL Unicode;
242 SMALL_RECT ScrollRectangle;
243 BOOL UseClipRectangle;
244 SMALL_RECT ClipRectangle;
245 COORD DestinationOrigin;
246 CHAR_INFO Fill;
247 } CSRSS_SCROLL_CONSOLE_SCREEN_BUFFER, *PCSRSS_SCROLL_CONSOLE_SCREEN_BUFFER;
248
249
250 /*
251 * An attribute or a character are instances of the same entity, namely
252 * a "code" (what would be called an (ANSI) escape sequence). Therefore
253 * encode them inside the same structure.
254 */
255 typedef enum _CODE_TYPE
256 {
257 CODE_ASCII = 0x01,
258 CODE_UNICODE = 0x02,
259 CODE_ATTRIBUTE = 0x03
260 } CODE_TYPE;
261
262 typedef struct
263 {
264 HANDLE ConsoleHandle;
265
266 DWORD NumCodesToRead;
267 COORD ReadCoord;
268 COORD EndCoord;
269
270 DWORD CodesRead;
271
272 CODE_TYPE CodeType;
273 union
274 {
275 PVOID pCode;
276 PCHAR AsciiChar;
277 PWCHAR UnicodeChar;
278 PWORD Attribute;
279 } pCode; // Either a pointer to a character or to an attribute.
280 } CSRSS_READ_CONSOLE_OUTPUT_CODE, *PCSRSS_READ_CONSOLE_OUTPUT_CODE;
281
282 typedef struct
283 {
284 HANDLE ConsoleHandle;
285 USHORT CodeType;
286
287 ULONG BufferSize;
288 WORD Length;
289 COORD Coord;
290 COORD EndCoord;
291
292 ULONG NrCharactersWritten;
293
294 union
295 {
296 // PVOID String;
297 PVOID pCode;
298 PCHAR AsciiChar;
299 PWCHAR UnicodeChar;
300 PWORD Attribute;
301 } pCode; // Either a pointer to a character or to an attribute.
302 } CSRSS_WRITE_CONSOLE_OUTPUT_CODE, *PCSRSS_WRITE_CONSOLE_OUTPUT_CODE;
303
304 typedef struct
305 {
306 HANDLE ConsoleHandle;
307
308 CODE_TYPE CodeType;
309 union
310 {
311 CHAR AsciiChar;
312 WCHAR UnicodeChar;
313 WORD Attribute;
314 } Code; // Either a character or an attribute.
315
316 COORD Coord;
317 ULONG Length;
318
319 ULONG NrCharactersWritten; // FIXME: Only for chars, is it removable ?
320 } CSRSS_FILL_OUTPUT, *PCSRSS_FILL_OUTPUT;
321
322 typedef struct
323 {
324 HANDLE ConsoleHandle;
325 BOOL Unicode;
326 BOOL bRead; // TRUE --> Read ; FALSE --> Peek
327
328 ULONG InputsRead;
329
330 ULONG Length;
331 PINPUT_RECORD InputRecord;
332 } CSRSS_GET_CONSOLE_INPUT, *PCSRSS_GET_CONSOLE_INPUT;
333
334 typedef struct
335 {
336 HANDLE ConsoleHandle;
337 BOOL Unicode;
338 COORD BufferSize;
339 COORD BufferCoord;
340 SMALL_RECT ReadRegion;
341 CHAR_INFO* CharInfo;
342 } CSRSS_READ_CONSOLE_OUTPUT, *PCSRSS_READ_CONSOLE_OUTPUT;
343
344 typedef struct
345 {
346 HANDLE ConsoleHandle;
347 BOOL Unicode;
348 DWORD Length;
349 INPUT_RECORD* InputRecord;
350 } CSRSS_WRITE_CONSOLE_INPUT, *PCSRSS_WRITE_CONSOLE_INPUT;
351
352 typedef struct
353 {
354 HANDLE Handle;
355 } CSRSS_CLOSE_HANDLE, *PCSRSS_CLOSE_HANDLE;
356
357 typedef struct
358 {
359 HANDLE Handle;
360 } CSRSS_VERIFY_HANDLE, *PCSRSS_VERIFY_HANDLE;
361
362 typedef struct
363 {
364 HANDLE Handle;
365 DWORD Access;
366 BOOL Inheritable;
367 DWORD Options;
368 } CSRSS_DUPLICATE_HANDLE, *PCSRSS_DUPLICATE_HANDLE;
369
370 /*
371 * Type of handles.
372 */
373 typedef enum _HANDLE_TYPE
374 {
375 HANDLE_INPUT = 0x01,
376 HANDLE_OUTPUT = 0x02
377 } HANDLE_TYPE;
378
379 typedef struct
380 {
381 HANDLE Handle;
382 HANDLE_TYPE HandleType;
383 DWORD Access;
384 BOOL Inheritable;
385 DWORD ShareMode;
386 } CSRSS_OPEN_CONSOLE, *PCSRSS_OPEN_CONSOLE;
387
388 typedef struct
389 {
390 HANDLE InputWaitHandle;
391 } CSRSS_GET_INPUT_WAIT_HANDLE, *PCSRSS_GET_INPUT_WAIT_HANDLE;
392
393
394 /*
395 * Console hardware states.
396 */
397 #define CONSOLE_HARDWARE_STATE_GDI_MANAGED 0
398 #define CONSOLE_HARDWARE_STATE_DIRECT 1
399
400 typedef struct
401 {
402 HANDLE ConsoleHandle;
403 DWORD State;
404 } CSRSS_CONSOLE_HW_STATE, *PCSRSS_CONSOLE_HW_STATE;
405
406 typedef struct
407 {
408 HWND WindowHandle;
409 } CSRSS_GET_CONSOLE_WINDOW, *PCSRSS_GET_CONSOLE_WINDOW;
410
411 typedef struct
412 {
413 HICON WindowIcon;
414 } CSRSS_SET_CONSOLE_ICON, *PCSRSS_SET_CONSOLE_ICON;
415
416
417
418
419
420
421
422
423
424 typedef struct
425 {
426 ULONG SourceLength;
427 ULONG TargetLength; // Also used for storing the number of bytes written.
428 ULONG ExeLength;
429 LPWSTR Source;
430 LPWSTR Target;
431 LPWSTR Exe;
432 } CSRSS_CONSOLE_ALIAS, *PCSRSS_CONSOLE_ALIAS;
433
434 typedef struct
435 {
436 DWORD ExeLength;
437 DWORD AliasesBufferLength;
438 LPWSTR ExeName;
439 LPWSTR AliasesBuffer;
440 } CSRSS_GET_ALL_CONSOLE_ALIASES, *PCSRSS_GET_ALL_CONSOLE_ALIASES;
441
442 typedef struct
443 {
444 DWORD Length;
445 DWORD ExeLength;
446 LPWSTR ExeName;
447 } CSRSS_GET_ALL_CONSOLE_ALIASES_LENGTH, *PCSRSS_GET_ALL_CONSOLE_ALIASES_LENGTH;
448
449 typedef struct
450 {
451 DWORD Length;
452 LPWSTR ExeNames;
453 } CSRSS_GET_CONSOLE_ALIASES_EXES, *PCSRSS_GET_CONSOLE_ALIASES_EXES;
454
455 typedef struct
456 {
457 DWORD Length;
458 } CSRSS_GET_CONSOLE_ALIASES_EXES_LENGTH, *PCSRSS_GET_CONSOLE_ALIASES_EXES_LENGTH;
459
460
461
462
463
464
465 typedef struct
466 {
467 UNICODE_STRING ExeName;
468 PWCHAR History;
469 DWORD Length;
470 } CSRSS_GET_COMMAND_HISTORY, *PCSRSS_GET_COMMAND_HISTORY;
471
472 typedef struct
473 {
474 UNICODE_STRING ExeName;
475 DWORD Length;
476 } CSRSS_GET_COMMAND_HISTORY_LENGTH, *PCSRSS_GET_COMMAND_HISTORY_LENGTH;
477
478 typedef struct
479 {
480 UNICODE_STRING ExeName;
481 } CSRSS_EXPUNGE_COMMAND_HISTORY, *PCSRSS_EXPUNGE_COMMAND_HISTORY;
482
483 typedef struct
484 {
485 UNICODE_STRING ExeName;
486 DWORD NumCommands;
487 } CSRSS_SET_HISTORY_NUMBER_COMMANDS, *PCSRSS_SET_HISTORY_NUMBER_COMMANDS;
488
489 typedef struct
490 {
491 UINT HistoryBufferSize;
492 UINT NumberOfHistoryBuffers;
493 DWORD dwFlags;
494 } CSRSS_HISTORY_INFO, *PCSRSS_HISTORY_INFO;
495
496
497
498
499
500
501
502
503
504
505 typedef struct
506 {
507 DWORD Event;
508 DWORD ProcessGroup;
509 } CSRSS_GENERATE_CTRL_EVENT, *PCSRSS_GENERATE_CTRL_EVENT;
510
511 typedef struct
512 {
513 HANDLE ConsoleHandle;
514 DWORD NumInputEvents;
515 } CSRSS_GET_NUM_INPUT_EVENTS, *PCSRSS_GET_NUM_INPUT_EVENTS;
516
517 typedef struct
518 {
519 HANDLE OutputHandle;
520 COORD Size;
521 } CSRSS_SET_SCREEN_BUFFER_SIZE, *PCSRSS_SET_SCREEN_BUFFER_SIZE;
522
523 typedef struct
524 {
525 CONSOLE_SELECTION_INFO Info;
526 } CSRSS_GET_CONSOLE_SELECTION_INFO, *PCSRSS_GET_CONSOLE_SELECTION_INFO;
527
528 typedef struct
529 {
530 BOOL InputCP; // TRUE : Input Code Page ; FALSE : Output Code Page
531 UINT CodePage;
532 } CSRSS_CONSOLE_CP, *PCSRSS_CONSOLE_CP;
533
534 typedef struct _CONSOLE_API_MESSAGE
535 {
536 PORT_MESSAGE Header;
537
538 PCSR_CAPTURE_BUFFER CsrCaptureData;
539 CSR_API_NUMBER ApiNumber;
540 ULONG Status; // ReturnValue; // NTSTATUS Status
541 ULONG Reserved;
542 union
543 {
544 CSRSS_ALLOC_CONSOLE AllocConsoleRequest;
545 CSRSS_FREE_CONSOLE FreeConsoleRequest;
546
547 /* Handles */
548 CSRSS_OPEN_CONSOLE OpenConsoleRequest;
549 CSRSS_CLOSE_HANDLE CloseHandleRequest;
550 CSRSS_VERIFY_HANDLE VerifyHandleRequest;
551 CSRSS_DUPLICATE_HANDLE DuplicateHandleRequest;
552 CSRSS_GET_INPUT_WAIT_HANDLE GetConsoleInputWaitHandle;
553
554 /* Cursor */
555 CSRSS_CURSOR_INFO CursorInfoRequest;
556 CSRSS_SET_CURSOR_POSITION SetCursorPositionRequest;
557
558 /* Screen buffer */
559 CSRSS_CREATE_SCREEN_BUFFER CreateScreenBufferRequest;
560 CSRSS_SET_SCREEN_BUFFER SetScreenBufferRequest;
561 CSRSS_SCREEN_BUFFER_INFO ScreenBufferInfoRequest;
562 CSRSS_SET_SCREEN_BUFFER_SIZE SetScreenBufferSize;
563 CSRSS_SCROLL_CONSOLE_SCREEN_BUFFER ScrollConsoleScreenBufferRequest;
564
565 CSRSS_GET_CONSOLE_SELECTION_INFO GetConsoleSelectionInfo;
566 CSRSS_FLUSH_INPUT_BUFFER FlushInputBufferRequest;
567
568 /* Console mode */
569 CSRSS_CONSOLE_MODE ConsoleModeRequest;
570 CSRSS_CONSOLE_HW_STATE ConsoleHardwareStateRequest;
571
572 /* Console window */
573 CSRSS_CONSOLE_TITLE TitleRequest;
574 CSRSS_GET_CONSOLE_WINDOW GetConsoleWindowRequest;
575 CSRSS_SET_CONSOLE_ICON SetConsoleIconRequest;
576
577 /* Read */
578 CSRSS_READ_CONSOLE ReadConsoleRequest; // SrvReadConsole / ReadConsole
579 CSRSS_GET_CONSOLE_INPUT GetConsoleInputRequest; // SrvGetConsoleInput / PeekConsoleInput & ReadConsoleInput
580 CSRSS_READ_CONSOLE_OUTPUT ReadConsoleOutputRequest; // SrvReadConsoleOutput / ReadConsoleOutput
581 CSRSS_READ_CONSOLE_OUTPUT_CODE ReadConsoleOutputCodeRequest; // SrvReadConsoleOutputString / ReadConsoleOutputAttribute & ReadConsoleOutputCharacter
582
583 /* Write */
584 CSRSS_WRITE_CONSOLE WriteConsoleRequest; // SrvWriteConsole / WriteConsole
585 CSRSS_WRITE_CONSOLE_INPUT WriteConsoleInputRequest;
586 CSRSS_WRITE_CONSOLE_OUTPUT WriteConsoleOutputRequest;
587 CSRSS_WRITE_CONSOLE_OUTPUT_CODE WriteConsoleOutputCodeRequest;
588
589 CSRSS_FILL_OUTPUT FillOutputRequest;
590 CSRSS_SET_ATTRIB SetAttribRequest;
591
592 /* Aliases */
593 CSRSS_CONSOLE_ALIAS ConsoleAlias;
594 CSRSS_GET_ALL_CONSOLE_ALIASES GetAllConsoleAliases;
595 CSRSS_GET_ALL_CONSOLE_ALIASES_LENGTH GetAllConsoleAliasesLength;
596 CSRSS_GET_CONSOLE_ALIASES_EXES GetConsoleAliasesExes;
597 CSRSS_GET_CONSOLE_ALIASES_EXES_LENGTH GetConsoleAliasesExesLength;
598
599 /* History */
600 CSRSS_GET_COMMAND_HISTORY GetCommandHistory;
601 CSRSS_GET_COMMAND_HISTORY_LENGTH GetCommandHistoryLength;
602 CSRSS_EXPUNGE_COMMAND_HISTORY ExpungeCommandHistory;
603 CSRSS_SET_HISTORY_NUMBER_COMMANDS SetHistoryNumberCommands;
604 CSRSS_HISTORY_INFO HistoryInfoRequest;
605
606 CSRSS_GENERATE_CTRL_EVENT GenerateCtrlEvent;
607 CSRSS_GET_NUM_INPUT_EVENTS GetNumInputEventsRequest;
608
609 /* Input and Output Code Pages */
610 CSRSS_CONSOLE_CP ConsoleCPRequest;
611
612 CSRSS_GET_PROCESS_LIST GetProcessListRequest;
613 } Data;
614 } CONSOLE_API_MESSAGE, *PCONSOLE_API_MESSAGE;
615
616 // Check that a CONSOLE_API_MESSAGE can hold in a CSR_API_MESSAGE.
617 CHECK_API_MSG_SIZE(CONSOLE_API_MESSAGE);
618
619 #endif // _CONMSG_H
620
621 /* EOF */