2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Console Server DLL
4 * FILE: consrv/include/conio_winsrv.h
5 * PURPOSE: Public Console I/O Interface
6 * PROGRAMMERS: Gé van Geldorp
8 * Hermes Belusca-Maito (hermes.belusca@sfr.fr)
15 // This is ALMOST a HACK!!!!!!!
16 // Helpers for code refactoring
17 #define _CONSRV_CONSOLE _CONSOLE
18 #define CONSRV_CONSOLE CONSOLE
19 #define PCONSRV_CONSOLE PCONSOLE
21 // #define _CONSRV_CONSOLE _WINSRV_CONSOLE
22 // #define CONSRV_CONSOLE WINSRV_CONSOLE
23 // #define PCONSRV_CONSOLE PWINSRV_CONSOLE
26 #define CSR_DEFAULT_CURSOR_SIZE 25
28 /* VGA character cell */
29 typedef struct _CHAR_CELL
33 } CHAR_CELL
, *PCHAR_CELL
;
34 C_ASSERT(sizeof(CHAR_CELL
) == 2);
37 typedef struct _FRONTEND FRONTEND
, *PFRONTEND
;
38 /* HACK: */ typedef struct _CONSOLE_INFO
*PCONSOLE_INFO
;
39 typedef struct _FRONTEND_VTBL
41 // NTSTATUS (NTAPI *UnloadFrontEnd)(IN OUT PFRONTEND This);
44 * Internal interface (functions called by the console server only)
46 NTSTATUS (NTAPI
*InitFrontEnd
)(IN OUT PFRONTEND This
,
47 IN
struct _CONSRV_CONSOLE
* Console
);
48 VOID (NTAPI
*DeinitFrontEnd
)(IN OUT PFRONTEND This
);
50 /* Interface used for both text-mode and graphics screen buffers */
51 VOID (NTAPI
*DrawRegion
)(IN OUT PFRONTEND This
,
53 /* Interface used only for text-mode screen buffers */
54 VOID (NTAPI
*WriteStream
)(IN OUT PFRONTEND This
,
61 BOOL (NTAPI
*SetCursorInfo
)(IN OUT PFRONTEND This
,
62 PCONSOLE_SCREEN_BUFFER ScreenBuffer
);
63 BOOL (NTAPI
*SetScreenInfo
)(IN OUT PFRONTEND This
,
64 PCONSOLE_SCREEN_BUFFER ScreenBuffer
,
67 VOID (NTAPI
*ResizeTerminal
)(IN OUT PFRONTEND This
);
68 VOID (NTAPI
*SetActiveScreenBuffer
)(IN OUT PFRONTEND This
);
69 VOID (NTAPI
*ReleaseScreenBuffer
)(IN OUT PFRONTEND This
,
70 IN PCONSOLE_SCREEN_BUFFER ScreenBuffer
);
71 VOID (NTAPI
*RefreshInternalInfo
)(IN OUT PFRONTEND This
);
74 * External interface (functions corresponding to the Console API)
76 VOID (NTAPI
*ChangeTitle
)(IN OUT PFRONTEND This
);
77 BOOL (NTAPI
*ChangeIcon
)(IN OUT PFRONTEND This
,
79 HWND (NTAPI
*GetConsoleWindowHandle
)(IN OUT PFRONTEND This
);
80 VOID (NTAPI
*GetLargestConsoleWindowSize
)(IN OUT PFRONTEND This
,
82 BOOL (NTAPI
*GetSelectionInfo
)(IN OUT PFRONTEND This
,
83 PCONSOLE_SELECTION_INFO pSelectionInfo
);
84 BOOL (NTAPI
*SetPalette
)(IN OUT PFRONTEND This
,
85 HPALETTE PaletteHandle
,
87 ULONG (NTAPI
*GetDisplayMode
)(IN OUT PFRONTEND This
);
88 BOOL (NTAPI
*SetDisplayMode
)(IN OUT PFRONTEND This
,
90 INT (NTAPI
*ShowMouseCursor
)(IN OUT PFRONTEND This
,
92 BOOL (NTAPI
*SetMouseCursor
)(IN OUT PFRONTEND This
,
93 HCURSOR CursorHandle
);
94 HMENU (NTAPI
*MenuControl
)(IN OUT PFRONTEND This
,
97 BOOL (NTAPI
*SetMenuClose
)(IN OUT PFRONTEND This
,
99 } FRONTEND_VTBL
, *PFRONTEND_VTBL
;
103 PFRONTEND_VTBL Vtbl
; /* Virtual table */
104 NTSTATUS (NTAPI
*UnloadFrontEnd
)(IN OUT PFRONTEND This
);
106 struct _CONSRV_CONSOLE
* Console
; /* Console to which the frontend is attached to */
107 PVOID Data
; /* Private data */
108 PVOID OldData
; /* Reserved */
111 /* PauseFlags values (internal only) */
112 #define PAUSED_FROM_KEYBOARD 0x1
113 #define PAUSED_FROM_SCROLLBAR 0x2
114 #define PAUSED_FROM_SELECTION 0x4
116 typedef struct _WINSRV_CONSOLE
118 /******************************* Console Set-up *******************************/
119 /* This **MUST** be FIRST!! */
123 // LONG ReferenceCount; /* Is incremented each time a handle to something in the console (a screen-buffer or the input buffer of this console) gets referenced */
124 // CRITICAL_SECTION Lock;
125 // CONSOLE_STATE State; /* State of the console */
127 FRONTEND FrontEndIFace
; /* Frontend-specific interface */
129 /******************************* Process support ******************************/
130 LIST_ENTRY ProcessList
; /* List of processes owning the console. The first one is the so-called "Console Leader Process" */
131 PCONSOLE_PROCESS_DATA NotifiedLastCloseProcess
; /* Pointer to the unique process that needs to be notified when the console leader process is killed */
132 BOOLEAN NotifyLastClose
; /* TRUE if the console should send a control event when the console leader process is killed */
134 /******************************* Pausing support ******************************/
136 LIST_ENTRY ReadWaitQueue
; /* List head for the queue of unique input buffer read wait blocks */
137 LIST_ENTRY WriteWaitQueue
; /* List head for the queue of current screen-buffer write wait blocks */
139 /**************************** Aliases and Histories ***************************/
140 struct _ALIAS_HEADER
*Aliases
;
141 LIST_ENTRY HistoryBuffers
;
142 ULONG HistoryBufferSize
; /* Size for newly created history buffers */
143 ULONG NumberOfHistoryBuffers
; /* Maximum number of history buffers allowed */
144 BOOLEAN HistoryNoDup
; /* Remove old duplicate history entries */
146 /**************************** Input Line Discipline ***************************/
147 PWCHAR LineBuffer
; /* Current line being input, in line buffered mode */
148 ULONG LineMaxSize
; /* Maximum size of line in characters (including CR+LF) */
149 ULONG LineSize
; /* Current size of line */
150 ULONG LinePos
; /* Current position within line */
151 BOOLEAN LineComplete
; /* User pressed enter, ready to send back to client */
152 BOOLEAN LineUpPressed
;
153 BOOLEAN LineInsertToggle
; /* Replace character over cursor instead of inserting */
154 ULONG LineWakeupMask
; /* Bitmap of which control characters will end line input */
159 /************************ Virtual DOS Machine support *************************/
160 COORD VDMBufferSize
; /* Real size of the VDM buffer, in units of ??? */
161 HANDLE VDMBufferSection
; /* Handle to the memory shared section for the VDM buffer */
162 PVOID VDMBuffer
; /* Our VDM buffer */
163 PVOID ClientVDMBuffer
; /* A copy of the client view of our VDM buffer */
164 HANDLE VDMClientProcess
; /* Handle to the client process who opened the buffer, to unmap the view */
166 HANDLE StartHardwareEvent
;
167 HANDLE EndHardwareEvent
;
168 HANDLE ErrorHardwareEvent
;
170 /****************************** Other properties ******************************/
171 COLORREF Colors
[16]; /* Colour palette */
173 } WINSRV_CONSOLE
, *PWINSRV_CONSOLE
;
176 VOID
ConioPause(PCONSRV_CONSOLE Console
, UINT Flags
);
177 VOID
ConioUnpause(PCONSRV_CONSOLE Console
, UINT Flags
);
179 PCONSOLE_PROCESS_DATA NTAPI
180 ConSrvGetConsoleLeaderProcess(IN PCONSRV_CONSOLE Console
);
182 ConSrvConsoleCtrlEvent(IN ULONG CtrlEvent
,
183 IN PCONSOLE_PROCESS_DATA ProcessData
);
185 ConSrvConsoleProcessCtrlEvent(IN PCONSRV_CONSOLE Console
,
186 IN ULONG ProcessGroupId
,
190 VOID NTAPI
ConioProcessKey(PCONSRV_CONSOLE Console
, MSG
* msg
);
191 DWORD
ConioEffectiveCursorSize(PCONSRV_CONSOLE Console
,
195 ConioAddInputEvents(PCONSRV_CONSOLE Console
,
196 PINPUT_RECORD InputRecords
,
197 ULONG NumEventsToWrite
,
198 PULONG NumEventsWritten
,
199 BOOLEAN AppendToEnd
);
201 ConioProcessInputEvent(PCONSRV_CONSOLE Console
,
202 PINPUT_RECORD InputEvent
);
208 * "The lpMultiByteStr and lpWideCharStr pointers must not be the same.
209 * If they are the same, the function fails, and GetLastError returns
210 * ERROR_INVALID_PARAMETER."
212 #define ConsoleUnicodeCharToAnsiChar(Console, dChar, sWChar) \
213 ASSERT((ULONG_PTR)dChar != (ULONG_PTR)sWChar); \
214 WideCharToMultiByte((Console)->OutputCodePage, 0, (sWChar), 1, (dChar), 1, NULL, NULL)
216 #define ConsoleAnsiCharToUnicodeChar(Console, dWChar, sChar) \
217 ASSERT((ULONG_PTR)dWChar != (ULONG_PTR)sChar); \
218 MultiByteToWideChar((Console)->OutputCodePage, 0, (sChar), 1, (dWChar), 1)
220 PCHAR_INFO
ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff
, ULONG X
, ULONG Y
);
221 VOID
ConioDrawConsole(PCONSRV_CONSOLE Console
);
222 NTSTATUS
ConioResizeBuffer(PCONSRV_CONSOLE Console
,
223 PTEXTMODE_SCREEN_BUFFER ScreenBuffer
,