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