ReactOS  0.4.13-dev-247-g0f29b3f
conio_winsrv.h
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS Console Server DLL
4  * FILE: win32ss/user/winsrv/consrv/include/conio_winsrv.h
5  * PURPOSE: Public Console I/O Interface - Offers wrap-up structures
6  * over the console objects exposed by the console driver.
7  * PROGRAMMERS: Gé van Geldorp
8  * Jeffrey Morlan
9  * Hermes Belusca-Maito (hermes.belusca@sfr.fr)
10  */
11 
12 #pragma once
13 
14 #include "rect.h"
15 
16 // This is ALMOST a HACK!!!!!!!
17 // Helpers for code refactoring
18 #ifdef USE_NEW_CONSOLE_WAY
19 
20 #define _CONSRV_CONSOLE _WINSRV_CONSOLE
21 #define CONSRV_CONSOLE WINSRV_CONSOLE
22 #define PCONSRV_CONSOLE PWINSRV_CONSOLE
23 
24 #else
25 
26 #define _CONSRV_CONSOLE _CONSOLE
27 #define CONSRV_CONSOLE CONSOLE
28 #define PCONSRV_CONSOLE PCONSOLE
29 
30 #endif
31 
32 #define CSR_DEFAULT_CURSOR_SIZE 25
33 
34 /* VGA character cell */
35 typedef struct _CHAR_CELL
36 {
37  CHAR Char;
40 C_ASSERT(sizeof(CHAR_CELL) == 2);
41 
42 // HACK!!
43 struct _WINSRV_CONSOLE;
44 /* HACK: */ typedef struct _WINSRV_CONSOLE *PWINSRV_CONSOLE;
45 #ifdef USE_NEW_CONSOLE_WAY
46 #include "conio.h"
47 #endif
48 
49 typedef struct _FRONTEND FRONTEND, *PFRONTEND;
50 
51 typedef struct _FRONTEND_VTBL
52 {
53  // NTSTATUS (NTAPI *UnloadFrontEnd)(IN OUT PFRONTEND This);
54 
55  /*
56  * Internal interface (functions called by the console server only)
57  */
58  NTSTATUS (NTAPI *InitFrontEnd)(IN OUT PFRONTEND This,
60  VOID (NTAPI *DeinitFrontEnd)(IN OUT PFRONTEND This);
61 
62  /* Interface used for both text-mode and graphics screen buffers */
65  /* Interface used only for text-mode screen buffers */
66  VOID (NTAPI *WriteStream)(IN OUT PFRONTEND This,
71  PWCHAR Buffer,
72  UINT Length);
73  VOID (NTAPI *RingBell)(IN OUT PFRONTEND This);
74  BOOL (NTAPI *SetCursorInfo)(IN OUT PFRONTEND This,
76  BOOL (NTAPI *SetScreenInfo)(IN OUT PFRONTEND This,
80  VOID (NTAPI *ResizeTerminal)(IN OUT PFRONTEND This);
82  VOID (NTAPI *ReleaseScreenBuffer)(IN OUT PFRONTEND This,
84  VOID (NTAPI *RefreshInternalInfo)(IN OUT PFRONTEND This);
85 
86  /*
87  * External interface (functions corresponding to the Console API)
88  */
89  VOID (NTAPI *ChangeTitle)(IN OUT PFRONTEND This);
90  BOOL (NTAPI *ChangeIcon)(IN OUT PFRONTEND This,
93  HWND (NTAPI *GetConsoleWindowHandle)(IN OUT PFRONTEND This);
96  BOOL (NTAPI *GetSelectionInfo)(IN OUT PFRONTEND This,
98  BOOL (NTAPI *SetPalette)(IN OUT PFRONTEND This,
99  HPALETTE PaletteHandle,
101  ULONG (NTAPI *GetDisplayMode)(IN OUT PFRONTEND This);
102  BOOL (NTAPI *SetDisplayMode)(IN OUT PFRONTEND This,
104  INT (NTAPI *ShowMouseCursor)(IN OUT PFRONTEND This,
106  BOOL (NTAPI *SetMouseCursor)(IN OUT PFRONTEND This,
108  HMENU (NTAPI *MenuControl)(IN OUT PFRONTEND This,
110  UINT CmdIdHigh);
111  BOOL (NTAPI *SetMenuClose)(IN OUT PFRONTEND This,
114 
115 struct _FRONTEND
116 {
117  PFRONTEND_VTBL Vtbl; /* Virtual table */
118  NTSTATUS (NTAPI *UnloadFrontEnd)(IN OUT PFRONTEND This);
119 
120  struct _CONSRV_CONSOLE* Console; /* Console to which the frontend is attached to */
121  PVOID Context; /* Private context */
122  PVOID Context2; /* Private context */
123 };
124 
125 /* PauseFlags values (internal only) */
126 #define PAUSED_FROM_KEYBOARD 0x1
127 #define PAUSED_FROM_SCROLLBAR 0x2
128 #define PAUSED_FROM_SELECTION 0x4
129 
130 typedef struct _WINSRV_CONSOLE
131 {
132 /******************************* Console Set-up *******************************/
133  /* This **MUST** be FIRST!! */
134 #ifdef USE_NEW_CONSOLE_WAY
135  CONSOLE;
136  // CONSOLE Console;
137  // // PCONSOLE Console;
138 #endif
139 
140  // 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 */
141  // CRITICAL_SECTION Lock;
142  // CONSOLE_STATE State; /* State of the console */
143 
144  HANDLE InitEvents[MAX_INIT_EVENTS]; /* Initialization events */
145 
146  FRONTEND FrontEndIFace; /* Frontend-specific interface */
147 
148 /******************************* Process support ******************************/
149  LIST_ENTRY ProcessList; /* List of processes owning the console. The first one is the so-called "Console Leader Process" */
150  PCONSOLE_PROCESS_DATA NotifiedLastCloseProcess; /* Pointer to the unique process that needs to be notified when the console leader process is killed */
151  BOOLEAN NotifyLastClose; /* TRUE if the console should send a control event when the console leader process is killed */
152  BOOLEAN HasFocus; /* TRUE if the console has focus (is in the foreground) */
153 
154 /******************************* Pausing support ******************************/
156  LIST_ENTRY ReadWaitQueue; /* List head for the queue of unique input buffer read wait blocks */
157  LIST_ENTRY WriteWaitQueue; /* List head for the queue of current screen-buffer write wait blocks */
158 
159 /**************************** Aliases and Histories ***************************/
162  ULONG HistoryBufferSize; /* Size for newly created history buffers */
163  ULONG NumberOfHistoryBuffers; /* Maximum number of history buffers allowed */
164  BOOLEAN HistoryNoDup; /* Remove old duplicate history entries */
165 
166 /**************************** Input Line Discipline ***************************/
167  PWCHAR LineBuffer; /* Current line being input, in line buffered mode */
168  ULONG LineMaxSize; /* Maximum size of line in characters (including CR+LF) */
169  ULONG LineSize; /* Current size of line */
170  ULONG LinePos; /* Current position within line */
171  BOOLEAN LineComplete; /* User pressed enter, ready to send back to client */
173  BOOLEAN LineInsertToggle; /* Replace character over cursor instead of inserting */
174  ULONG LineWakeupMask; /* Bitmap of which control characters will end line input */
175 
178 
179 /************************ Virtual DOS Machine support *************************/
180  COORD VDMBufferSize; /* Real size of the VDM buffer, in units of ??? */
181  HANDLE VDMBufferSection; /* Handle to the memory shared section for the VDM buffer */
182  PVOID VDMBuffer; /* Our VDM buffer */
183  PVOID ClientVDMBuffer; /* A copy of the client view of our VDM buffer */
184  HANDLE VDMClientProcess; /* Handle to the client process who opened the buffer, to unmap the view */
185 
189 
190 /****************************** Other properties ******************************/
191  LIST_ENTRY PopupWindows; /* List of popup windows */
192  UNICODE_STRING OriginalTitle; /* Original title of console, the one defined when the console leader is launched; it never changes. Always NULL-terminated */
193  UNICODE_STRING Title; /* Title of console. Always NULL-terminated */
194  COLORREF Colors[16]; /* Colour palette */
195 
196 } WINSRV_CONSOLE; // , *PWINSRV_CONSOLE;
197 
198 /* console.c */
201 
204 NTSTATUS
206  IN PCONSOLE_PROCESS_DATA ProcessData);
209  IN ULONG ProcessGroupId,
210  IN ULONG CtrlEvent);
211 VOID
213  IN BOOLEAN SetForeground);
216  IN BOOLEAN SetForeground);
217 
218 /* coninput.c */
221  DWORD Scale);
222 
223 NTSTATUS
225  PINPUT_RECORD InputEvent);
226 
227 /* conoutput.c */
229 NTSTATUS ConioResizeBuffer(PCONSOLE /*PCONSRV_CONSOLE*/ Console,
231  COORD Size);
232 
233 /* terminal.c */
235 
236 /* EOF */
#define IN
Definition: typedefs.h:38
PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y)
Definition: text.c:140
static HICON
Definition: imagelist.c:84
DWORD ConioEffectiveCursorSize(PCONSRV_CONSOLE Console, DWORD Scale)
Definition: input.c:190
UNICODE_STRING OriginalTitle
Definition: conio_winsrv.h:192
BOOLEAN LineComplete
Definition: conio_winsrv.h:171
struct _CHAR_CELL * PCHAR_CELL
HDESK(NTAPI *GetThreadConsoleDesktop)(IN OUT PFRONTEND This)
SMALL_RECT SHORT SHORT UINT PWCHAR UINT Length
Definition: conio_winsrv.h:67
BOOLEAN HistoryNoDup
Definition: conio_winsrv.h:164
#define Y(I)
HWND(NTAPI *GetConsoleWindowHandle)(IN OUT PFRONTEND This)
BOOLEAN LineInsertToggle
Definition: conio_winsrv.h:173
struct _ALIAS_HEADER * Aliases
Definition: conio_winsrv.h:160
NTSTATUS(NTAPI *InitFrontEnd)(IN OUT PFRONTEND This
char CHAR
Definition: xmlstorage.h:175
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
BOOLEAN NotifyLastClose
Definition: conio_winsrv.h:151
HMENU(NTAPI *MenuControl)(IN OUT PFRONTEND This
SMALL_RECT SHORT SHORT CursorStartY
Definition: conio_winsrv.h:67
LONG NTSTATUS
Definition: precomp.h:26
PCONSOLE_SCREEN_BUFFER ScreenBuffer
Definition: conio_winsrv.h:75
ULONG NumberOfHistoryBuffers
Definition: conio_winsrv.h:163
#define _CONSRV_CONSOLE
Definition: conio_winsrv.h:26
HPALETTE UINT PaletteUsage
Definition: conio_winsrv.h:99
struct _CHAR_CELL CHAR_CELL
HCURSOR CursorHandle
Definition: conio_winsrv.h:107
uint16_t * PWCHAR
Definition: typedefs.h:54
HICON HCURSOR
Definition: windef.h:284
NTSTATUS NTAPI ConSrvConsoleProcessCtrlEvent(IN PCONSRV_CONSOLE Console, IN ULONG ProcessGroupId, IN ULONG CtrlEvent)
Definition: console.c:906
LIST_ENTRY HistoryBuffers
Definition: conio_winsrv.h:161
struct _FRONTEND * PFRONTEND
Definition: conio_winsrv.h:49
#define CONSOLE
Definition: scanf.c:101
PVOID Context2
Definition: conio_winsrv.h:122
struct _CONSRV_CONSOLE * Console
Definition: conio_winsrv.h:120
IN struct _CONSRV_CONSOLE * Console
Definition: conio_winsrv.h:59
BYTE Attributes
Definition: svga.h:393
struct _FRONTEND_VTBL FRONTEND_VTBL
static VOID DrawRegion(PGUI_CONSOLE_DATA GuiData, SMALL_RECT *Region)
Definition: guiterm.c:76
LIST_ENTRY ProcessList
Definition: conio_winsrv.h:149
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
PCONSOLE_PROCESS_DATA NTAPI ConSrvGetConsoleLeaderProcess(IN PCONSRV_CONSOLE Console)
Definition: console.c:867
struct _WINSRV_CONSOLE WINSRV_CONSOLE
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
unsigned int BOOL
Definition: ntddk_ex.h:94
short SHORT
Definition: pedump.c:59
VOID ConioUnpause(PCONSRV_CONSOLE Console, UINT Flags)
Definition: console.c:250
ULONG HistoryBufferSize
Definition: conio_winsrv.h:162
HANDLE EndHardwareEvent
Definition: conio_winsrv.h:187
NTSTATUS ConioProcessInputEvent(PCONSRV_CONSOLE Console, PINPUT_RECORD InputEvent)
Definition: coninput.c:195
NTSTATUS(NTAPI *UnloadFrontEnd)(IN OUT PFRONTEND This)
unsigned char BOOLEAN
PVOID Context
Definition: conio_winsrv.h:121
FRONTEND FrontEndIFace
Definition: conio_winsrv.h:146
SMALL_RECT * Region
Definition: conio_winsrv.h:64
NTSTATUS ConSrvConsoleCtrlEvent(IN ULONG CtrlEvent, IN PCONSOLE_PROCESS_DATA ProcessData)
Definition: console.c:860
C_ASSERT(sizeof(CHAR_CELL)==2)
NTSTATUS ConioResizeBuffer(PCONSOLE Console, PTEXTMODE_SCREEN_BUFFER ScreenBuffer, COORD Size)
Definition: text.c:257
CHAR Char
Definition: svga.h:392
LIST_ENTRY ReadWaitQueue
Definition: conio_winsrv.h:156
VOID ConSrvSetProcessFocus(IN PCSR_PROCESS CsrProcess, IN BOOLEAN SetForeground)
Definition: console.c:944
DWORD COLORREF
Definition: windef.h:285
Colors
Definition: ansiprsr.h:4
BOOLEAN InsertMode
Definition: conio_winsrv.h:176
PCONSOLE_SELECTION_INFO pSelectionInfo
Definition: conio_winsrv.h:97
COORD WINAPI DECLSPEC_HOTPATCH GetLargestConsoleWindowSize(HANDLE hConsoleOutput)
Definition: console.c:1675
unsigned long DWORD
Definition: ntddk_ex.h:95
VOID ConioDrawConsole(PCONSRV_CONSOLE Console)
Definition: terminal.c:663
PFRONTEND_VTBL Vtbl
Definition: conio_winsrv.h:117
HANDLE VDMBufferSection
Definition: conio_winsrv.h:181
unsigned char BYTE
Definition: mem.h:68
VOID NTAPI ConioProcessKey(PCONSRV_CONSOLE Console, MSG *msg)
Definition: input.c:57
VOID(NTAPI *DeinitFrontEnd)(IN OUT PFRONTEND This)
Definition: typedefs.h:117
ULONG(NTAPI *GetDisplayMode)(IN OUT PFRONTEND This)
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
HANDLE InitEvents[MAX_INIT_EVENTS]
Definition: conio_winsrv.h:144
#define PCONSRV_CONSOLE
Definition: conio_winsrv.h:28
Definition: bl.h:1338
static VOID SetActiveScreenBuffer(HANDLE ScreenBuffer)
Definition: video.c:439
HANDLE StartHardwareEvent
Definition: conio_winsrv.h:186
UNICODE_STRING Title
Definition: conio_winsrv.h:193
HPALETTE PaletteHandle
Definition: conio_winsrv.h:99
HANDLE ErrorHardwareEvent
Definition: conio_winsrv.h:188
UINT UINT CmdIdHigh
Definition: conio_winsrv.h:109
BOOL(NTAPI *SetCursorInfo)(IN OUT PFRONTEND This
HANDLE VDMClientProcess
Definition: conio_winsrv.h:184
SMALL_RECT SHORT SHORT UINT ScrolledLines
Definition: conio_winsrv.h:67
unsigned int UINT
Definition: ndis.h:50
struct _FRONTEND_VTBL * PFRONTEND_VTBL
CConsole Console
#define msg(x)
Definition: auth_time.c:54
HANDLE ScreenBuffer
Definition: notevil.c:37
#define OUT
Definition: typedefs.h:39
PCONSOLE_SCREEN_BUFFER SHORT SHORT OldCursorY
Definition: conio_winsrv.h:77
IN PCONSOLE_SCREEN_BUFFER ScreenBuffer
Definition: conio_winsrv.h:83
unsigned int ULONG
Definition: retypes.h:1
BOOLEAN LineUpPressed
Definition: conio_winsrv.h:172
NTSTATUS NTAPI ConSrvSetConsoleProcessFocus(IN PCONSRV_CONSOLE Console, IN BOOLEAN SetForeground)
Definition: console.c:957
SMALL_RECT SHORT SHORT UINT PWCHAR Buffer
Definition: conio_winsrv.h:67
PCONSOLE_SCREEN_BUFFER SHORT OldCursorX
Definition: conio_winsrv.h:77
SMALL_RECT SHORT CursorStartX
Definition: conio_winsrv.h:67
INT(NTAPI *ShowMouseCursor)(IN OUT PFRONTEND This
NTSTATUS NTAPI GetThreadConsoleDesktop(IN ULONG_PTR ThreadId, OUT HDESK *ConsoleDesktop)
Definition: frontendctl.c:281
LIST_ENTRY WriteWaitQueue
Definition: conio_winsrv.h:157
VOID ConioPause(PCONSRV_CONSOLE Console, UINT Flags)
Definition: console.c:243
struct _WINSRV_CONSOLE * PWINSRV_CONSOLE
Definition: conio_winsrv.h:44
PCONSOLE_PROCESS_DATA NotifiedLastCloseProcess
Definition: conio_winsrv.h:150
LIST_ENTRY PopupWindows
Definition: conio_winsrv.h:191