xref: /reactos/sdk/include/reactos/subsys/win/conmsg.h (revision 8b948ff0)
1 /*
2  * COPYRIGHT:       See COPYING in the top level directory
3  * PROJECT:         ReactOS Console Server DLL
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 Server 2003 table from http://j00ru.vexillium.org/csrss_list/api_list.html#Windows_2k3
19 typedef enum _CONSRV_API_NUMBER
20 {
21     ConsolepOpenConsole = CONSRV_FIRST_API_NUMBER,
22     ConsolepGetConsoleInput,
23     ConsolepWriteConsoleInput,
24     ConsolepReadConsoleOutput,
25     ConsolepWriteConsoleOutput,
26     ConsolepReadConsoleOutputString,
27     ConsolepWriteConsoleOutputString,
28     ConsolepFillConsoleOutput,
29     ConsolepGetMode,
30     ConsolepGetNumberOfFonts,
31     ConsolepGetNumberOfInputEvents,
32     ConsolepGetScreenBufferInfo,
33     ConsolepGetCursorInfo,
34     ConsolepGetMouseInfo,
35     ConsolepGetFontInfo,
36     ConsolepGetFontSize,
37     ConsolepGetCurrentFont,
38     ConsolepSetMode,
39     ConsolepSetActiveScreenBuffer,
40     ConsolepFlushInputBuffer,
41     ConsolepGetLargestWindowSize,
42     ConsolepSetScreenBufferSize,
43     ConsolepSetCursorPosition,
44     ConsolepSetCursorInfo,
45     ConsolepSetWindowInfo,
46     ConsolepScrollScreenBuffer,
47     ConsolepSetTextAttribute,
48     ConsolepSetFont,
49     ConsolepSetIcon,
50     ConsolepReadConsole,
51     ConsolepWriteConsole,
52     ConsolepDuplicateHandle,
53     ConsolepGetHandleInformation,
54     ConsolepSetHandleInformation,
55     ConsolepCloseHandle,
56     ConsolepVerifyIoHandle,
57     ConsolepAlloc,                          // Not present in Win7
58     ConsolepFree,                           // Not present in Win7
59     ConsolepGetTitle,
60     ConsolepSetTitle,
61     ConsolepCreateScreenBuffer,
62     ConsolepInvalidateBitMapRect,
63     ConsolepVDMOperation,
64     ConsolepSetCursor,
65     ConsolepShowCursor,
66     ConsolepMenuControl,
67     ConsolepSetPalette,
68     ConsolepSetDisplayMode,
69     ConsolepRegisterVDM,
70     ConsolepGetHardwareState,
71     ConsolepSetHardwareState,
72     ConsolepGetDisplayMode,
73     ConsolepAddAlias,
74     ConsolepGetAlias,
75     ConsolepGetAliasesLength,
76     ConsolepGetAliasExesLength,
77     ConsolepGetAliases,
78     ConsolepGetAliasExes,
79     ConsolepExpungeCommandHistory,
80     ConsolepSetNumberOfCommands,
81     ConsolepGetCommandHistoryLength,
82     ConsolepGetCommandHistory,
83     ConsolepSetCommandHistoryMode,          // Not present in Vista+
84     ConsolepGetCP,
85     ConsolepSetCP,
86     ConsolepSetKeyShortcuts,
87     ConsolepSetMenuClose,
88     ConsolepNotifyLastClose,
89     ConsolepGenerateCtrlEvent,
90     ConsolepGetKeyboardLayoutName,
91     ConsolepGetConsoleWindow,
92     ConsolepCharType,
93     ConsolepSetLocalEUDC,
94     ConsolepSetCursorMode,
95     ConsolepGetCursorMode,
96     ConsolepRegisterOS2,
97     ConsolepSetOS2OemFormat,
98     ConsolepGetNlsMode,
99     ConsolepSetNlsMode,
100     ConsolepRegisterConsoleIME,             // Not present in Win7
101     ConsolepUnregisterConsoleIME,           // Not present in Win7
102     // ConsolepQueryConsoleIME,                // Added only in Vista and Win2k8, not present in Win7
103     ConsolepGetLangId,
104     ConsolepAttach,                         // Not present in Win7
105     ConsolepGetSelectionInfo,
106     ConsolepGetProcessList,
107 
108     ConsolepGetHistory,                     // Added in Vista+
109     ConsolepSetHistory,                     // Added in Vista+
110     // ConsolepSetCurrentFont,                 // Added in Vista+
111     // ConsolepSetScreenBufferInfo,            // Added in Vista+
112     // ConsolepClientConnect,                  // Added in Win7
113 
114     ConsolepMaxApiNumber
115 } CONSRV_API_NUMBER, *PCONSRV_API_NUMBER;
116 
117 //
118 // See http://msdn.microsoft.com/en-us/library/windows/desktop/bb773359(v=vs.85).aspx
119 //
120 typedef struct _CONSOLE_PROPERTIES
121 {
122     INT   IconIndex;
123     HICON hIcon;
124     HICON hIconSm;
125     DWORD dwHotKey;
126     DWORD dwStartupFlags;
127 
128     // NT_CONSOLE_PROPS
129     WORD wFillAttribute;
130     WORD wPopupFillAttribute;
131 
132     //
133     // Not on MSDN, but show up in binary
134     //
135     WORD wShowWindow;
136     WORD wUnknown;
137 
138     COORD dwScreenBufferSize;
139     COORD dwWindowSize;
140     COORD dwWindowOrigin;
141     DWORD nFont;
142     DWORD nInputBufferSize;
143     COORD dwFontSize;
144     UINT  uFontFamily;
145     UINT  uFontWeight;
146     WCHAR FaceName[LF_FACESIZE];
147     UINT  uCursorSize;
148     BOOL  bFullScreen;
149     BOOL  bQuickEdit;
150     BOOL  bInsertMode;
151     BOOL  bAutoPosition;
152     UINT  uHistoryBufferSize;
153     UINT  uNumberOfHistoryBuffers;
154     BOOL  bHistoryNoDup;
155     COLORREF ColorTable[16];
156 
157     // NT_FE_CONSOLE_PROPS
158     UINT uCodePage;
159 } CONSOLE_PROPERTIES;
160 
161 enum
162 {
163     INIT_SUCCESS, // STATUS_WAIT_0
164     INIT_FAILURE, // STATUS_WAIT_1
165     MAX_INIT_EVENTS
166 };
167 
168 typedef struct _CONSOLE_START_INFO
169 {
170     HANDLE ConsoleHandle;
171     HANDLE InputWaitHandle;
172     HANDLE InputHandle;
173     HANDLE OutputHandle;
174     HANDLE ErrorHandle;
175     HANDLE InitEvents[MAX_INIT_EVENTS];
176 
177     CONSOLE_PROPERTIES;
178 } CONSOLE_START_INFO, *PCONSOLE_START_INFO;
179 
180 #if defined(_M_IX86)
181 C_ASSERT(sizeof(CONSOLE_START_INFO) == 0xFC);
182 #endif
183 
184 typedef struct _CONSRV_API_CONNECTINFO
185 {
186     CONSOLE_START_INFO ConsoleStartInfo;
187 
188     BOOLEAN IsConsoleApp;
189     BOOLEAN IsWindowVisible;
190 
191     // USHORT Padding;
192 
193     LPTHREAD_START_ROUTINE CtrlRoutine;
194     LPTHREAD_START_ROUTINE PropRoutine;
195     LPTHREAD_START_ROUTINE ImeRoutine;
196 
197     ULONG  TitleLength;
198     WCHAR  ConsoleTitle[MAX_PATH + 1];  // Console title or full path to the startup shortcut
199     ULONG  DesktopLength;
200     PWCHAR Desktop;                     // Contrary to the case of CONSOLE_ALLOCCONSOLE, the
201                                         // desktop string is allocated in the process' heap,
202                                         // and CSR will read it via NtReadVirtualMemory.
203     ULONG  AppNameLength;
204     WCHAR  AppName[128];                // Full path of the launched app
205     ULONG  CurDirLength;
206     WCHAR  CurDir[MAX_PATH + 1];
207 } CONSRV_API_CONNECTINFO, *PCONSRV_API_CONNECTINFO;
208 
209 #if defined(_M_IX86)
210 C_ASSERT(sizeof(CONSRV_API_CONNECTINFO) == 0x638);
211 #endif
212 
213 typedef struct _CONSOLE_GETPROCESSLIST
214 {
215     HANDLE ConsoleHandle;
216     ULONG  ProcessCount;
217     PDWORD ProcessIdsList;
218 } CONSOLE_GETPROCESSLIST, *PCONSOLE_GETPROCESSLIST;
219 
220 typedef struct _CONSOLE_GENERATECTRLEVENT
221 {
222     HANDLE ConsoleHandle;
223     ULONG  CtrlEvent;
224     ULONG  ProcessGroupId;
225 } CONSOLE_GENERATECTRLEVENT, *PCONSOLE_GENERATECTRLEVENT;
226 
227 typedef struct _CONSOLE_NOTIFYLASTCLOSE
228 {
229     HANDLE ConsoleHandle;
230 } CONSOLE_NOTIFYLASTCLOSE, *PCONSOLE_NOTIFYLASTCLOSE;
231 
232 
233 
234 typedef struct _CONSOLE_WRITECONSOLE
235 {
236     HANDLE ConsoleHandle;
237     HANDLE OutputHandle;
238 
239     CHAR  StaticBuffer[80];
240     PVOID Buffer; // BufPtr
241     ULONG NumBytes;
242 
243     // On Windows, the client never uses this member
244     ULONG Reserved1;
245 
246     BOOLEAN UsingStaticBuffer;
247     BOOLEAN Unicode;
248 
249     // On Windows, the client never uses this member
250     CHAR Reserved2[6];
251 } CONSOLE_WRITECONSOLE, *PCONSOLE_WRITECONSOLE;
252 
253 typedef struct _CONSOLE_READCONSOLE
254 {
255     HANDLE ConsoleHandle;
256     HANDLE InputHandle;
257 
258     USHORT ExeLength;
259 
260     CHAR  StaticBuffer[80];
261     PVOID Buffer; // BufPtr
262     ULONG NumBytes;
263 
264     ULONG CaptureBufferSize;
265 
266     ULONG   InitialNumBytes;
267     ULONG   CtrlWakeupMask;
268     ULONG   ControlKeyState;
269     BOOLEAN Unicode;
270 } CONSOLE_READCONSOLE, *PCONSOLE_READCONSOLE;
271 
272 typedef struct _CONSOLE_ALLOCCONSOLE
273 {
274     PCONSOLE_START_INFO ConsoleStartInfo;
275 
276     ULONG  TitleLength;
277     PWCHAR ConsoleTitle;    // Console title or full path to the startup shortcut
278     ULONG  DesktopLength;
279     PWCHAR Desktop;
280     ULONG  AppNameLength;
281     PWCHAR AppName;         // Full path of the launched app
282     ULONG  CurDirLength;
283     PWCHAR CurDir;
284 
285     LPTHREAD_START_ROUTINE CtrlRoutine;
286     LPTHREAD_START_ROUTINE PropRoutine;
287 } CONSOLE_ALLOCCONSOLE, *PCONSOLE_ALLOCCONSOLE;
288 
289 typedef struct _CONSOLE_ATTACHCONSOLE
290 {
291     /*
292      * If ProcessId == ATTACH_PARENT_PROCESS == -1, then attach
293      * the current process to its parent process console.
294      */
295     ULONG ProcessId;
296 
297     PCONSOLE_START_INFO ConsoleStartInfo;
298 
299     LPTHREAD_START_ROUTINE CtrlRoutine;
300     LPTHREAD_START_ROUTINE PropRoutine;
301 } CONSOLE_ATTACHCONSOLE, *PCONSOLE_ATTACHCONSOLE;
302 
303 typedef struct _CONSOLE_FREECONSOLE
304 {
305     HANDLE ConsoleHandle;
306 } CONSOLE_FREECONSOLE, *PCONSOLE_FREECONSOLE;
307 
308 typedef struct _CONSOLE_GETSCREENBUFFERINFO
309 {
310     HANDLE ConsoleHandle;
311     HANDLE OutputHandle;
312     COORD  ScreenBufferSize;
313     COORD  CursorPosition;
314     COORD  ViewOrigin;
315     WORD   Attributes;
316     COORD  ViewSize;
317     COORD  MaximumViewSize;
318 } CONSOLE_GETSCREENBUFFERINFO, *PCONSOLE_GETSCREENBUFFERINFO;
319 
320 typedef struct _CONSOLE_SETCURSORPOSITION
321 {
322     HANDLE ConsoleHandle;
323     HANDLE OutputHandle;
324     COORD  Position;
325 } CONSOLE_SETCURSORPOSITION, *PCONSOLE_SETCURSORPOSITION;
326 
327 typedef struct _CONSOLE_SHOWCURSOR
328 {
329     HANDLE ConsoleHandle;
330     HANDLE OutputHandle;
331     BOOL   Show;
332     INT    RefCount;
333 } CONSOLE_SHOWCURSOR, *PCONSOLE_SHOWCURSOR;
334 
335 typedef struct _CONSOLE_SETCURSOR
336 {
337     HANDLE  ConsoleHandle;
338     HANDLE  OutputHandle;
339     HCURSOR CursorHandle;
340 } CONSOLE_SETCURSOR, *PCONSOLE_SETCURSOR;
341 
342 typedef struct _CONSOLE_GETSETCURSORINFO
343 {
344     HANDLE ConsoleHandle;
345     HANDLE OutputHandle;
346     CONSOLE_CURSOR_INFO Info;
347 /*
348     ULONG   Size;
349     BOOLEAN Visible;
350 */
351 } CONSOLE_GETSETCURSORINFO, *PCONSOLE_GETSETCURSORINFO;
352 
353 typedef struct _CONSOLE_GETMOUSEINFO
354 {
355     HANDLE ConsoleHandle;
356     ULONG  NumButtons;
357 } CONSOLE_GETMOUSEINFO, *PCONSOLE_GETMOUSEINFO;
358 
359 typedef struct _CONSOLE_SETTEXTATTRIB
360 {
361     HANDLE ConsoleHandle;
362     HANDLE OutputHandle;
363     WORD   Attributes;
364 } CONSOLE_SETTEXTATTRIB, *PCONSOLE_SETTEXTATTRIB;
365 
366 typedef struct _CONSOLE_GETSETCONSOLEMODE
367 {
368     HANDLE ConsoleHandle;
369     HANDLE Handle;
370     ULONG  Mode;
371 } CONSOLE_GETSETCONSOLEMODE, *PCONSOLE_GETSETCONSOLEMODE;
372 
373 typedef struct _CONSOLE_GETDISPLAYMODE
374 {
375     HANDLE ConsoleHandle;
376     ULONG  DisplayMode; // ModeFlags
377 } CONSOLE_GETDISPLAYMODE, *PCONSOLE_GETDISPLAYMODE;
378 
379 typedef struct _CONSOLE_SETDISPLAYMODE
380 {
381     HANDLE ConsoleHandle;
382     HANDLE OutputHandle;
383     ULONG  DisplayMode; // ModeFlags
384     COORD  NewSBDim;
385     HANDLE EventHandle;
386 } CONSOLE_SETDISPLAYMODE, *PCONSOLE_SETDISPLAYMODE;
387 
388 /*
389  * Console hardware states.
390  */
391 #define CONSOLE_HARDWARE_STATE_GDI_MANAGED 0
392 #define CONSOLE_HARDWARE_STATE_DIRECT      1
393 
394 typedef struct _CONSOLE_GETSETHWSTATE
395 {
396     HANDLE ConsoleHandle;
397     HANDLE OutputHandle;
398     ULONG  Flags;
399     ULONG  State;
400 } CONSOLE_GETSETHWSTATE, *PCONSOLE_GETSETHWSTATE;
401 
402 
403 typedef struct _CONSOLE_GETNUMFONTS
404 {
405     HANDLE ConsoleHandle;
406     ULONG  NumFonts;
407 } CONSOLE_GETNUMFONTS, *PCONSOLE_GETNUMFONTS;
408 
409 typedef struct _CONSOLE_GETFONTINFO
410 {
411     HANDLE  ConsoleHandle;
412     HANDLE  OutputHandle;
413     BOOLEAN MaximumWindow;
414     PCONSOLE_FONT_INFO FontInfo;
415     ULONG   NumFonts;
416 } CONSOLE_GETFONTINFO, *PCONSOLE_GETFONTINFO;
417 
418 typedef struct _CONSOLE_GETFONTSIZE
419 {
420     HANDLE ConsoleHandle;
421     HANDLE OutputHandle;
422     ULONG  FontIndex;
423     COORD  FontSize;
424 } CONSOLE_GETFONTSIZE, *PCONSOLE_GETFONTSIZE;
425 
426 typedef struct _CONSOLE_GETCURRENTFONT
427 {
428     HANDLE  ConsoleHandle;
429     HANDLE  OutputHandle;
430     BOOLEAN MaximumWindow;
431     ULONG   FontIndex;
432     COORD   FontSize;
433 } CONSOLE_GETCURRENTFONT, *PCONSOLE_GETCURRENTFONT;
434 
435 typedef struct _CONSOLE_SETFONT
436 {
437     HANDLE ConsoleHandle;
438     HANDLE OutputHandle;
439     ULONG  FontIndex;
440 } CONSOLE_SETFONT, *PCONSOLE_SETFONT;
441 
442 
443 
444 typedef struct _CONSOLE_CREATESCREENBUFFER
445 {
446     HANDLE ConsoleHandle;
447     ULONG  DesiredAccess; // ACCESS_MASK
448     BOOL   InheritHandle;
449     ULONG  ShareMode;
450     /* Type of the screen buffer: CONSOLE_TEXTMODE_BUFFER or CONSOLE_GRAPHICS_BUFFER */
451     ULONG  ScreenBufferType;
452     /*
453      * This structure holds the initialization information
454      * for graphics screen buffers.
455      */
456     CONSOLE_GRAPHICS_BUFFER_INFO GraphicsBufferInfo;
457     HANDLE hMutex;
458     PVOID  lpBitMap;
459     HANDLE OutputHandle;     /* Handle to newly created screen buffer */
460 } CONSOLE_CREATESCREENBUFFER, *PCONSOLE_CREATESCREENBUFFER;
461 
462 typedef struct _CONSOLE_SETACTIVESCREENBUFFER
463 {
464     HANDLE ConsoleHandle;
465     HANDLE OutputHandle;  /* Handle to screen buffer to switch to */
466 } CONSOLE_SETACTIVESCREENBUFFER, *PCONSOLE_SETACTIVESCREENBUFFER;
467 
468 typedef struct _CONSOLE_INVALIDATEDIBITS
469 {
470     HANDLE ConsoleHandle;
471     HANDLE OutputHandle;
472     SMALL_RECT Region;
473 } CONSOLE_INVALIDATEDIBITS, *PCONSOLE_INVALIDATEDIBITS;
474 
475 typedef struct _CONSOLE_SETPALETTE
476 {
477     HANDLE   ConsoleHandle;
478     HANDLE   OutputHandle;
479     HPALETTE PaletteHandle;
480     UINT     Usage;
481 } CONSOLE_SETPALETTE, *PCONSOLE_SETPALETTE;
482 
483 typedef struct _CONSOLE_GETSETCONSOLETITLE
484 {
485     HANDLE  ConsoleHandle;
486     ULONG   Length;
487     PVOID   Title;
488     BOOLEAN Unicode;
489 } CONSOLE_GETSETCONSOLETITLE, *PCONSOLE_GETSETCONSOLETITLE;
490 
491 typedef struct _CONSOLE_FLUSHINPUTBUFFER
492 {
493     HANDLE ConsoleHandle;
494     HANDLE InputHandle;
495 } CONSOLE_FLUSHINPUTBUFFER, *PCONSOLE_FLUSHINPUTBUFFER;
496 
497 typedef struct _CONSOLE_SCROLLSCREENBUFFER
498 {
499     HANDLE     ConsoleHandle;
500     HANDLE     OutputHandle;
501     SMALL_RECT ScrollRectangle;
502     SMALL_RECT ClipRectangle;
503     BOOL       UseClipRectangle;
504     COORD      DestinationOrigin;
505     CHAR_INFO  Fill;
506     BOOLEAN    Unicode;
507 } CONSOLE_SCROLLSCREENBUFFER, *PCONSOLE_SCROLLSCREENBUFFER;
508 
509 
510 /*
511  * An attribute or a character are instances of the same entity, namely
512  * a "code" (what would be called an (ANSI) escape sequence). Therefore
513  * encode them inside the same structure.
514  */
515 typedef enum _CODE_TYPE
516 {
517     CODE_ASCII      = 0x01,
518     CODE_UNICODE    = 0x02,
519     CODE_ATTRIBUTE  = 0x03
520 } CODE_TYPE;
521 
522 typedef union _CODE_ELEMENT
523 {
524     CHAR  AsciiChar;
525     WCHAR UnicodeChar;
526     WORD  Attribute;
527 } CODE_ELEMENT;
528 
529 typedef struct _CONSOLE_OUTPUTCODE
530 {
531     HANDLE ConsoleHandle;
532     HANDLE OutputHandle;
533     COORD  Coord;
534 
535     CODE_TYPE CodeType;
536     CHAR      CodeStaticBuffer[80]; // == 40 * sizeof(CODE_ELEMENT)
537     PVOID     pCode; // Either a pointer to a character or to an attribute.
538     // union
539     // {
540         // PVOID  pCode;
541         // PCHAR  AsciiChar;
542         // PWCHAR UnicodeChar;
543         // PWORD  Attribute;
544     // } pCode;    // Either a pointer to a character or to an attribute.
545 
546     ULONG NumCodes;
547 } CONSOLE_READOUTPUTCODE , *PCONSOLE_READOUTPUTCODE,
548   CONSOLE_WRITEOUTPUTCODE, *PCONSOLE_WRITEOUTPUTCODE;
549 
550 typedef struct _CONSOLE_FILLOUTPUTCODE
551 {
552     HANDLE ConsoleHandle;
553     HANDLE OutputHandle;
554     COORD  WriteCoord;
555 
556     CODE_TYPE    CodeType;
557     CODE_ELEMENT Code; // Either a character or an attribute.
558 
559     ULONG NumCodes;
560 } CONSOLE_FILLOUTPUTCODE, *PCONSOLE_FILLOUTPUTCODE;
561 
562 typedef struct _CONSOLE_GETINPUT
563 {
564     HANDLE        ConsoleHandle;
565     HANDLE        InputHandle;
566     INPUT_RECORD  RecordStaticBuffer[5];
567     PINPUT_RECORD RecordBufPtr;
568     ULONG         NumRecords;
569     WORD          Flags;
570     BOOLEAN       Unicode;
571 } CONSOLE_GETINPUT, *PCONSOLE_GETINPUT;
572 
573 typedef struct _CONSOLE_WRITEINPUT
574 {
575     HANDLE        ConsoleHandle;
576     HANDLE        InputHandle;
577     INPUT_RECORD  RecordStaticBuffer[5];
578     PINPUT_RECORD RecordBufPtr;
579     ULONG         NumRecords;
580     BOOLEAN       Unicode;
581     BOOLEAN       AppendToEnd;
582 } CONSOLE_WRITEINPUT, *PCONSOLE_WRITEINPUT;
583 
584 typedef struct _CONSOLE_READOUTPUT
585 {
586     HANDLE ConsoleHandle;
587     HANDLE OutputHandle;
588 
589     CHAR_INFO  StaticBuffer;
590     PCHAR_INFO CharInfo;
591 
592     SMALL_RECT ReadRegion;
593     BOOLEAN Unicode;
594 } CONSOLE_READOUTPUT, *PCONSOLE_READOUTPUT;
595 
596 typedef struct _CONSOLE_WRITEOUTPUT
597 {
598     HANDLE ConsoleHandle;
599     HANDLE OutputHandle;
600 
601     CHAR_INFO  StaticBuffer;
602     PCHAR_INFO CharInfo;
603 
604     SMALL_RECT WriteRegion;
605     BOOLEAN Unicode;
606 
607     /*
608      * If we are going to write too large (>= 64 kB, size of the CSR heap)
609      * data buffers, we allocate a heap buffer in the process' memory, and
610      * CSR will read it via NtReadVirtualMemory.
611      */
612     BOOLEAN UseVirtualMemory;
613 } CONSOLE_WRITEOUTPUT, *PCONSOLE_WRITEOUTPUT;
614 
615 typedef struct _CONSOLE_GETNUMINPUTEVENTS
616 {
617     HANDLE ConsoleHandle;
618     HANDLE InputHandle;
619     ULONG  NumberOfEvents;
620 } CONSOLE_GETNUMINPUTEVENTS, *PCONSOLE_GETNUMINPUTEVENTS;
621 
622 
623 
624 typedef struct _CONSOLE_CLOSEHANDLE
625 {
626     HANDLE ConsoleHandle;
627     HANDLE Handle;
628 } CONSOLE_CLOSEHANDLE, *PCONSOLE_CLOSEHANDLE;
629 
630 typedef struct _CONSOLE_VERIFYHANDLE
631 {
632     BOOL   IsValid;
633     HANDLE ConsoleHandle;
634     HANDLE Handle;
635 } CONSOLE_VERIFYHANDLE, *PCONSOLE_VERIFYHANDLE;
636 
637 typedef struct _CONSOLE_DUPLICATEHANDLE
638 {
639     HANDLE  ConsoleHandle;
640     HANDLE  SourceHandle;
641     ULONG   DesiredAccess; // ACCESS_MASK
642     BOOLEAN InheritHandle;
643     ULONG   Options;
644     HANDLE  TargetHandle;
645 } CONSOLE_DUPLICATEHANDLE, *PCONSOLE_DUPLICATEHANDLE;
646 
647 typedef struct _CONSOLE_GETHANDLEINFO
648 {
649     HANDLE ConsoleHandle;
650     HANDLE Handle;
651     ULONG  Flags;
652 } CONSOLE_GETHANDLEINFO, *PCONSOLE_GETHANDLEINFO;
653 
654 typedef struct _CONSOLE_SETHANDLEINFO
655 {
656     HANDLE ConsoleHandle;
657     HANDLE Handle;
658     ULONG  Mask;
659     ULONG  Flags;
660 } CONSOLE_SETHANDLEINFO, *PCONSOLE_SETHANDLEINFO;
661 
662 /*
663  * Type of handles.
664  */
665 typedef enum _CONSOLE_HANDLE_TYPE
666 {
667     HANDLE_INPUT    = 0x01,
668     HANDLE_OUTPUT   = 0x02
669 } CONSOLE_HANDLE_TYPE;
670 
671 typedef struct _CONSOLE_OPENCONSOLE
672 {
673     HANDLE ConsoleHandle;
674     CONSOLE_HANDLE_TYPE HandleType;
675     ULONG  DesiredAccess; // ACCESS_MASK
676     BOOL   InheritHandle;
677     ULONG  ShareMode;
678     HANDLE Handle;
679 } CONSOLE_OPENCONSOLE, *PCONSOLE_OPENCONSOLE;
680 
681 
682 
683 typedef struct _CONSOLE_GETLARGESTWINDOWSIZE
684 {
685     HANDLE ConsoleHandle;
686     HANDLE OutputHandle;
687     COORD  Size;
688 } CONSOLE_GETLARGESTWINDOWSIZE, *PCONSOLE_GETLARGESTWINDOWSIZE;
689 
690 typedef struct _CONSOLE_MENUCONTROL
691 {
692     HANDLE ConsoleHandle;
693     HANDLE OutputHandle;
694     ULONG  CmdIdLow;
695     ULONG  CmdIdHigh;
696     HMENU  MenuHandle;
697 } CONSOLE_MENUCONTROL, *PCONSOLE_MENUCONTROL;
698 
699 typedef struct _CONSOLE_SETMENUCLOSE
700 {
701     HANDLE ConsoleHandle;
702     BOOL   Enable;
703 } CONSOLE_SETMENUCLOSE, *PCONSOLE_SETMENUCLOSE;
704 
705 typedef struct _CONSOLE_SETWINDOWINFO
706 {
707     HANDLE ConsoleHandle;
708     HANDLE OutputHandle;
709     BOOL   Absolute;
710     SMALL_RECT WindowRect; // New console window position in the screen-buffer frame (Absolute == TRUE)
711                            // or in the old window position frame (Absolute == FALSE).
712 } CONSOLE_SETWINDOWINFO, *PCONSOLE_SETWINDOWINFO;
713 
714 typedef struct _CONSOLE_GETWINDOW
715 {
716     HANDLE ConsoleHandle;
717     HWND   WindowHandle;
718 } CONSOLE_GETWINDOW, *PCONSOLE_GETWINDOW;
719 
720 typedef struct _CONSOLE_SETICON
721 {
722     HANDLE ConsoleHandle;
723     HICON  IconHandle;
724 } CONSOLE_SETICON, *PCONSOLE_SETICON;
725 
726 
727 
728 typedef struct _CONSOLE_ADDGETALIAS
729 {
730     HANDLE  ConsoleHandle;
731     USHORT  SourceLength;
732     USHORT  TargetLength; // Also used for storing the number of bytes written.
733     USHORT  ExeLength;
734     PVOID   Source;
735     PVOID   Target;
736     PVOID   ExeName;
737     BOOLEAN Unicode;
738     BOOLEAN Unicode2;
739 } CONSOLE_ADDGETALIAS, *PCONSOLE_ADDGETALIAS;
740 
741 typedef struct _CONSOLE_GETALLALIASES
742 {
743     HANDLE  ConsoleHandle;
744     USHORT  ExeLength;
745     PVOID   ExeName;
746     BOOLEAN Unicode;
747     BOOLEAN Unicode2;
748     ULONG   AliasesBufferLength;
749     PVOID   AliasesBuffer;
750 } CONSOLE_GETALLALIASES, *PCONSOLE_GETALLALIASES;
751 
752 typedef struct _CONSOLE_GETALLALIASESLENGTH
753 {
754     HANDLE  ConsoleHandle;
755     USHORT  ExeLength;
756     PVOID   ExeName;
757     ULONG   Length;
758     BOOLEAN Unicode;
759     BOOLEAN Unicode2;
760 } CONSOLE_GETALLALIASESLENGTH, *PCONSOLE_GETALLALIASESLENGTH;
761 
762 typedef struct _CONSOLE_GETALIASESEXES
763 {
764     HANDLE  ConsoleHandle;
765     ULONG   Length ; // ExeLength; // ExesLength
766     PVOID   ExeNames;
767     BOOLEAN Unicode;
768 } CONSOLE_GETALIASESEXES, *PCONSOLE_GETALIASESEXES;
769 
770 typedef struct _CONSOLE_GETALIASESEXESLENGTH
771 {
772     HANDLE  ConsoleHandle;
773     ULONG   Length;
774     BOOLEAN Unicode;
775 } CONSOLE_GETALIASESEXESLENGTH, *PCONSOLE_GETALIASESEXESLENGTH;
776 
777 
778 
779 typedef struct _CONSOLE_GETCOMMANDHISTORY
780 {
781     HANDLE  ConsoleHandle;
782     ULONG   HistoryLength;
783     PVOID   History;
784     USHORT  ExeLength;
785     PVOID   ExeName;
786     BOOLEAN Unicode;
787     BOOLEAN Unicode2;
788 } CONSOLE_GETCOMMANDHISTORY, *PCONSOLE_GETCOMMANDHISTORY;
789 
790 typedef struct _CONSOLE_GETCOMMANDHISTORYLENGTH
791 {
792     HANDLE  ConsoleHandle;
793     ULONG   HistoryLength;
794     USHORT  ExeLength;
795     PVOID   ExeName;
796     BOOLEAN Unicode;
797     BOOLEAN Unicode2;
798 } CONSOLE_GETCOMMANDHISTORYLENGTH, *PCONSOLE_GETCOMMANDHISTORYLENGTH;
799 
800 typedef struct _CONSOLE_EXPUNGECOMMANDHISTORY
801 {
802     HANDLE  ConsoleHandle;
803     USHORT  ExeLength;
804     PVOID   ExeName;
805     BOOLEAN Unicode;
806     BOOLEAN Unicode2;
807 } CONSOLE_EXPUNGECOMMANDHISTORY, *PCONSOLE_EXPUNGECOMMANDHISTORY;
808 
809 typedef struct _CONSOLE_GETSETHISTORYINFO
810 {
811     UINT HistoryBufferSize;
812     UINT NumberOfHistoryBuffers;
813     ULONG dwFlags;
814 } CONSOLE_GETSETHISTORYINFO, *PCONSOLE_GETSETHISTORYINFO;
815 
816 typedef struct _CONSOLE_SETHISTORYNUMBERCOMMANDS
817 {
818     HANDLE  ConsoleHandle;
819     ULONG   NumCommands;
820     USHORT  ExeLength;
821     PVOID   ExeName;
822     BOOLEAN Unicode;
823     BOOLEAN Unicode2;
824 } CONSOLE_SETHISTORYNUMBERCOMMANDS, *PCONSOLE_SETHISTORYNUMBERCOMMANDS;
825 
826 typedef struct _CONSOLE_SETHISTORYMODE
827 {
828     HANDLE ConsoleHandle;
829     ULONG  Mode;
830 } CONSOLE_SETHISTORYMODE, *PCONSOLE_SETHISTORYMODE;
831 
832 
833 
834 typedef struct _CONSOLE_SETSCREENBUFFERSIZE
835 {
836     HANDLE ConsoleHandle;
837     HANDLE OutputHandle;
838     COORD  Size;
839 } CONSOLE_SETSCREENBUFFERSIZE, *PCONSOLE_SETSCREENBUFFERSIZE;
840 
841 typedef struct _CONSOLE_GETSELECTIONINFO
842 {
843     HANDLE ConsoleHandle;
844     CONSOLE_SELECTION_INFO Info;
845 } CONSOLE_GETSELECTIONINFO, *PCONSOLE_GETSELECTIONINFO;
846 
847 typedef struct _CONSOLE_GETINPUTOUTPUTCP
848 {
849     HANDLE ConsoleHandle;
850     UINT   CodePage;
851     BOOL   OutputCP;    // TRUE : Output Code Page ; FALSE : Input Code Page
852 } CONSOLE_GETINPUTOUTPUTCP, *PCONSOLE_GETINPUTOUTPUTCP;
853 
854 typedef struct _CONSOLE_SETINPUTOUTPUTCP
855 {
856     HANDLE ConsoleHandle;
857     UINT   CodePage;
858     BOOL   OutputCP;    // TRUE : Output Code Page ; FALSE : Input Code Page
859     HANDLE EventHandle;
860 } CONSOLE_SETINPUTOUTPUTCP, *PCONSOLE_SETINPUTOUTPUTCP;
861 
862 typedef struct _CONSOLE_GETLANGID
863 {
864     HANDLE ConsoleHandle;
865     LANGID LangId;
866 } CONSOLE_GETLANGID, *PCONSOLE_GETLANGID;
867 
868 typedef struct _CONSOLE_GETKBDLAYOUTNAME
869 {
870     HANDLE ConsoleHandle;
871     CHAR   LayoutBuffer[KL_NAMELENGTH * sizeof(WCHAR)]; // Can hold up to 9 wchars
872     BOOL   Ansi;
873 } CONSOLE_GETKBDLAYOUTNAME, *PCONSOLE_GETKBDLAYOUTNAME;
874 
875 typedef struct _CONSOLE_REGISTERVDM
876 {
877     HANDLE ConsoleHandle;
878     ULONG  RegisterFlags;
879     HANDLE StartHardwareEvent;
880     HANDLE EndHardwareEvent;
881     HANDLE ErrorHardwareEvent;
882 
883     /* Unused member */
884     ULONG  UnusedVar;
885 
886     ULONG  VideoStateLength;
887     PVOID  VideoState;  // PVIDEO_HARDWARE_STATE_HEADER
888 
889     /* Unused members */
890     PVOID  UnusedBuffer;
891     ULONG  UnusedBufferLength;
892 
893     COORD  VDMBufferSize;
894     PVOID  VDMBuffer;
895 } CONSOLE_REGISTERVDM, *PCONSOLE_REGISTERVDM;
896 
897 typedef struct _CONSOLE_REGISTERCONSOLEIME
898 {
899     HANDLE ConsoleHandle;
900     HWND hWnd;
901     DWORD dwThreadId;
902     DWORD cbDesktop;
903     LPWSTR pDesktop;
904     DWORD dwAttachToThreadId;
905 } CONSOLE_REGISTERCONSOLEIME, *PCONSOLE_REGISTERCONSOLEIME;
906 
907 typedef struct _CONSOLE_UNREGISTERCONSOLEIME
908 {
909     HANDLE ConsoleHandle;
910     DWORD dwThreadId;
911 } CONSOLE_UNREGISTERCONSOLEIME, *PCONSOLE_UNREGISTERCONSOLEIME;
912 
913 typedef struct _CONSOLE_API_MESSAGE
914 {
915     PORT_MESSAGE Header;
916 
917     PCSR_CAPTURE_BUFFER CsrCaptureData;
918     CSR_API_NUMBER ApiNumber;
919     NTSTATUS Status;
920     ULONG Reserved;
921     union
922     {
923         /* Console initialization and uninitialization */
924         CONSOLE_ALLOCCONSOLE AllocConsoleRequest;
925         CONSOLE_ATTACHCONSOLE AttachConsoleRequest;
926         CONSOLE_FREECONSOLE FreeConsoleRequest;
927 
928         /* Processes */
929         CONSOLE_GETPROCESSLIST GetProcessListRequest;
930         CONSOLE_GENERATECTRLEVENT GenerateCtrlEventRequest;
931         CONSOLE_NOTIFYLASTCLOSE NotifyLastCloseRequest;
932 
933         /* Handles */
934         CONSOLE_OPENCONSOLE OpenConsoleRequest;
935         CONSOLE_CLOSEHANDLE CloseHandleRequest;
936         CONSOLE_VERIFYHANDLE VerifyHandleRequest;
937         CONSOLE_DUPLICATEHANDLE DuplicateHandleRequest;
938         CONSOLE_GETHANDLEINFO GetHandleInfoRequest;
939         CONSOLE_SETHANDLEINFO SetHandleInfoRequest;
940 
941         /* Cursor & Mouse */
942         CONSOLE_SHOWCURSOR ShowCursorRequest;
943         CONSOLE_SETCURSOR SetCursorRequest;
944         CONSOLE_GETSETCURSORINFO CursorInfoRequest;
945         CONSOLE_SETCURSORPOSITION SetCursorPositionRequest;
946         CONSOLE_GETMOUSEINFO GetMouseInfoRequest;
947 
948         /* Screen-buffer */
949         CONSOLE_CREATESCREENBUFFER CreateScreenBufferRequest;
950         CONSOLE_SETACTIVESCREENBUFFER SetScreenBufferRequest;
951         CONSOLE_GETSCREENBUFFERINFO ScreenBufferInfoRequest;
952         CONSOLE_SETSCREENBUFFERSIZE SetScreenBufferSizeRequest;
953         CONSOLE_SCROLLSCREENBUFFER ScrollScreenBufferRequest;
954 
955         CONSOLE_GETSELECTIONINFO GetSelectionInfoRequest;
956         CONSOLE_FLUSHINPUTBUFFER FlushInputBufferRequest;
957 
958         /* Console mode */
959         CONSOLE_GETSETCONSOLEMODE ConsoleModeRequest;
960         CONSOLE_GETDISPLAYMODE GetDisplayModeRequest;
961         CONSOLE_SETDISPLAYMODE SetDisplayModeRequest;
962         CONSOLE_GETSETHWSTATE HardwareStateRequest;
963 
964         /* Console fonts */
965         CONSOLE_GETNUMFONTS GetNumFontsRequest;
966         CONSOLE_GETFONTINFO GetFontInfoRequest;
967         CONSOLE_GETFONTSIZE GetFontSizeRequest;
968         CONSOLE_GETCURRENTFONT GetCurrentFontRequest;
969         CONSOLE_SETFONT SetFontRequest;
970 
971         /* Console window */
972         CONSOLE_INVALIDATEDIBITS InvalidateDIBitsRequest;
973         CONSOLE_SETPALETTE SetPaletteRequest;
974         CONSOLE_GETSETCONSOLETITLE TitleRequest;
975         CONSOLE_GETLARGESTWINDOWSIZE GetLargestWindowSizeRequest;
976         CONSOLE_MENUCONTROL MenuControlRequest;
977         CONSOLE_SETMENUCLOSE SetMenuCloseRequest;
978         CONSOLE_SETWINDOWINFO SetWindowInfoRequest;
979         CONSOLE_GETWINDOW GetWindowRequest;
980         CONSOLE_SETICON SetIconRequest;
981 
982         /* Read */
983         CONSOLE_READCONSOLE ReadConsoleRequest;         // SrvReadConsole / ReadConsole
984         CONSOLE_GETINPUT GetInputRequest;               // SrvGetConsoleInput / PeekConsoleInput & ReadConsoleInput
985         CONSOLE_READOUTPUT ReadOutputRequest;           // SrvReadConsoleOutput / ReadConsoleOutput
986         CONSOLE_READOUTPUTCODE ReadOutputCodeRequest;   // SrvReadConsoleOutputString / ReadConsoleOutputAttribute & ReadConsoleOutputCharacter
987         CONSOLE_GETNUMINPUTEVENTS GetNumInputEventsRequest;
988 
989         /* Write */
990         CONSOLE_WRITECONSOLE WriteConsoleRequest;       // SrvWriteConsole / WriteConsole
991         CONSOLE_WRITEINPUT WriteInputRequest;
992         CONSOLE_WRITEOUTPUT WriteOutputRequest;
993         CONSOLE_WRITEOUTPUTCODE WriteOutputCodeRequest;
994 
995         CONSOLE_FILLOUTPUTCODE FillOutputRequest;
996         CONSOLE_SETTEXTATTRIB SetTextAttribRequest;
997 
998         /* Aliases */
999         CONSOLE_ADDGETALIAS ConsoleAliasRequest;
1000         CONSOLE_GETALLALIASES GetAllAliasesRequest;
1001         CONSOLE_GETALLALIASESLENGTH GetAllAliasesLengthRequest;
1002         CONSOLE_GETALIASESEXES GetAliasesExesRequest;
1003         CONSOLE_GETALIASESEXESLENGTH GetAliasesExesLengthRequest;
1004 
1005         /* History */
1006         CONSOLE_GETCOMMANDHISTORY GetCommandHistoryRequest;
1007         CONSOLE_GETCOMMANDHISTORYLENGTH GetCommandHistoryLengthRequest;
1008         CONSOLE_EXPUNGECOMMANDHISTORY ExpungeCommandHistoryRequest;
1009         CONSOLE_GETSETHISTORYINFO HistoryInfoRequest;
1010         CONSOLE_SETHISTORYNUMBERCOMMANDS SetHistoryNumberCommandsRequest;
1011         CONSOLE_SETHISTORYMODE SetHistoryModeRequest;
1012 
1013         /* Input and Output Code Pages; keyboard */
1014         CONSOLE_GETINPUTOUTPUTCP GetConsoleCPRequest;
1015         CONSOLE_SETINPUTOUTPUTCP SetConsoleCPRequest;
1016         CONSOLE_GETLANGID LangIdRequest;
1017         CONSOLE_GETKBDLAYOUTNAME GetKbdLayoutNameRequest;
1018 
1019         /* Virtual DOS Machine */
1020         CONSOLE_REGISTERVDM RegisterVDMRequest;
1021 
1022         /* Console IME */
1023         CONSOLE_REGISTERCONSOLEIME RegisterConsoleIME;
1024         CONSOLE_UNREGISTERCONSOLEIME UnregisterConsoleIME;
1025     } Data;
1026 } CONSOLE_API_MESSAGE, *PCONSOLE_API_MESSAGE;
1027 
1028 // Check that a CONSOLE_API_MESSAGE can hold in a CSR_API_MESSAGE.
1029 CHECK_API_MSG_SIZE(CONSOLE_API_MESSAGE);
1030 
1031 #endif // _CONMSG_H
1032 
1033 /* EOF */
1034