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 #define CSR_DEFAULT_CURSOR_SIZE 25 17 18 /* VGA character cell */ 19 typedef struct _CHAR_CELL 20 { 21 CHAR Char; 22 BYTE Attributes; 23 } CHAR_CELL, *PCHAR_CELL; 24 C_ASSERT(sizeof(CHAR_CELL) == 2); 25 26 // #include "conio.h" 27 28 typedef struct _FRONTEND FRONTEND, *PFRONTEND; 29 30 struct _CONSRV_CONSOLE; 31 32 typedef struct _FRONTEND_VTBL 33 { 34 // NTSTATUS (NTAPI *UnloadFrontEnd)(IN OUT PFRONTEND This); 35 36 /* 37 * Internal interface (functions called by the console server only) 38 */ 39 NTSTATUS (NTAPI *InitFrontEnd)(IN OUT PFRONTEND This, 40 IN struct _CONSRV_CONSOLE* Console); 41 VOID (NTAPI *DeinitFrontEnd)(IN OUT PFRONTEND This); 42 43 /* Interface used for both text-mode and graphics screen buffers */ 44 VOID (NTAPI *DrawRegion)(IN OUT PFRONTEND This, 45 SMALL_RECT* Region); 46 /* Interface used only for text-mode screen buffers */ 47 VOID (NTAPI *WriteStream)(IN OUT PFRONTEND This, 48 SMALL_RECT* Region, 49 SHORT CursorStartX, 50 SHORT CursorStartY, 51 UINT ScrolledLines, 52 PWCHAR Buffer, 53 UINT Length); 54 VOID (NTAPI *RingBell)(IN OUT PFRONTEND This); 55 BOOL (NTAPI *SetCursorInfo)(IN OUT PFRONTEND This, 56 PCONSOLE_SCREEN_BUFFER ScreenBuffer); 57 BOOL (NTAPI *SetScreenInfo)(IN OUT PFRONTEND This, 58 PCONSOLE_SCREEN_BUFFER ScreenBuffer, 59 SHORT OldCursorX, 60 SHORT OldCursorY); 61 VOID (NTAPI *ResizeTerminal)(IN OUT PFRONTEND This); 62 VOID (NTAPI *SetActiveScreenBuffer)(IN OUT PFRONTEND This); 63 VOID (NTAPI *ReleaseScreenBuffer)(IN OUT PFRONTEND This, 64 IN PCONSOLE_SCREEN_BUFFER ScreenBuffer); 65 VOID (NTAPI *RefreshInternalInfo)(IN OUT PFRONTEND This); 66 67 /* 68 * External interface (functions corresponding to the Console API) 69 */ 70 VOID (NTAPI *ChangeTitle)(IN OUT PFRONTEND This); 71 BOOL (NTAPI *ChangeIcon)(IN OUT PFRONTEND This, 72 HICON IconHandle); 73 HDESK (NTAPI *GetThreadConsoleDesktop)(IN OUT PFRONTEND This); 74 HWND (NTAPI *GetConsoleWindowHandle)(IN OUT PFRONTEND This); 75 VOID (NTAPI *GetLargestConsoleWindowSize)(IN OUT PFRONTEND This, 76 PCOORD pSize); 77 BOOL (NTAPI *GetSelectionInfo)(IN OUT PFRONTEND This, 78 PCONSOLE_SELECTION_INFO pSelectionInfo); 79 BOOL (NTAPI *SetPalette)(IN OUT PFRONTEND This, 80 HPALETTE PaletteHandle, 81 UINT PaletteUsage); 82 BOOL (NTAPI *SetCodePage)(IN OUT PFRONTEND This, 83 UINT CodePage); 84 ULONG (NTAPI *GetDisplayMode)(IN OUT PFRONTEND This); 85 BOOL (NTAPI *SetDisplayMode)(IN OUT PFRONTEND This, 86 ULONG NewMode); 87 INT (NTAPI *ShowMouseCursor)(IN OUT PFRONTEND This, 88 BOOL Show); 89 BOOL (NTAPI *SetMouseCursor)(IN OUT PFRONTEND This, 90 HCURSOR CursorHandle); 91 HMENU (NTAPI *MenuControl)(IN OUT PFRONTEND This, 92 UINT CmdIdLow, 93 UINT CmdIdHigh); 94 BOOL (NTAPI *SetMenuClose)(IN OUT PFRONTEND This, 95 BOOL Enable); 96 } FRONTEND_VTBL, *PFRONTEND_VTBL; 97 98 struct _FRONTEND 99 { 100 PFRONTEND_VTBL Vtbl; /* Virtual table */ 101 NTSTATUS (NTAPI *UnloadFrontEnd)(IN OUT PFRONTEND This); 102 103 struct _CONSRV_CONSOLE* Console; /* Console to which the frontend is attached to */ 104 PVOID Context; /* Private context */ 105 PVOID Context2; /* Private context */ 106 }; 107 108 /* PauseFlags values (internal only) */ 109 #define PAUSED_FROM_KEYBOARD 0x1 110 #define PAUSED_FROM_SCROLLBAR 0x2 111 #define PAUSED_FROM_SELECTION 0x4 112 113 typedef struct _CONSRV_CONSOLE 114 { 115 /******************************* Console Set-up *******************************/ 116 /* This **MUST** be FIRST!! */ 117 CONSOLE; 118 // CONSOLE Console; 119 // // PCONSOLE Console; 120 121 // 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 */ 122 // CRITICAL_SECTION Lock; 123 // CONSOLE_STATE State; /* State of the console */ 124 125 // ULONG ConsoleID; /* The ID of the console */ 126 // LIST_ENTRY ListEntry; /* Entry in the list of consoles */ 127 128 HANDLE InitEvents[MAX_INIT_EVENTS]; /* Initialization events */ 129 130 FRONTEND FrontEndIFace; /* Frontend-specific interface */ 131 132 /******************************* Process support ******************************/ 133 LIST_ENTRY ProcessList; /* List of processes owning the console. The first one is the so-called "Console Leader Process" */ 134 PCONSOLE_PROCESS_DATA NotifiedLastCloseProcess; /* Pointer to the unique process that needs to be notified when the console leader process is killed */ 135 BOOLEAN NotifyLastClose; /* TRUE if the console should send a control event when the console leader process is killed */ 136 BOOLEAN HasFocus; /* TRUE if the console has focus (is in the foreground) */ 137 138 /******************************* Pausing support ******************************/ 139 UCHAR PauseFlags; 140 LIST_ENTRY ReadWaitQueue; /* List head for the queue of unique input buffer read wait blocks */ 141 LIST_ENTRY WriteWaitQueue; /* List head for the queue of current screen-buffer write wait blocks */ 142 143 /**************************** Aliases and Histories ***************************/ 144 struct _ALIAS_HEADER *Aliases; 145 LIST_ENTRY HistoryBuffers; 146 ULONG NumberOfHistoryBuffers; /* Number of history buffers */ 147 ULONG MaxNumberOfHistoryBuffers; /* Maximum number of history buffers allowed */ 148 ULONG HistoryBufferSize; /* Size for newly created history buffers */ 149 BOOLEAN HistoryNoDup; /* Remove old duplicate history entries */ 150 151 /**************************** Input Line Discipline ***************************/ 152 PWCHAR LineBuffer; /* Current line being input, in line buffered mode */ 153 ULONG LineMaxSize; /* Maximum size of line in characters (including CR+LF) */ 154 ULONG LineSize; /* Current size of line */ 155 ULONG LinePos; /* Current position within line */ 156 BOOLEAN LineComplete; /* User pressed enter, ready to send back to client */ 157 BOOLEAN LineUpPressed; 158 BOOLEAN LineInsertToggle; /* Replace character over cursor instead of inserting */ 159 ULONG LineWakeupMask; /* Bitmap of which control characters will end line input */ 160 161 BOOLEAN InsertMode; 162 BOOLEAN QuickEdit; 163 164 /************************ Virtual DOS Machine support *************************/ 165 COORD VDMBufferSize; /* Real size of the VDM buffer, in units of ??? */ 166 HANDLE VDMBufferSection; /* Handle to the memory shared section for the VDM buffer */ 167 PVOID VDMBuffer; /* Our VDM buffer */ 168 PVOID ClientVDMBuffer; /* A copy of the client view of our VDM buffer */ 169 HANDLE VDMClientProcess; /* Handle to the client process who opened the buffer, to unmap the view */ 170 171 HANDLE StartHardwareEvent; 172 HANDLE EndHardwareEvent; 173 HANDLE ErrorHardwareEvent; 174 175 /****************************** Other properties ******************************/ 176 LIST_ENTRY PopupWindows; /* List of popup windows */ 177 UNICODE_STRING OriginalTitle; /* Original title of console, the one defined when the console leader is launched; it never changes. Always NULL-terminated */ 178 UNICODE_STRING Title; /* Title of console. Always NULL-terminated */ 179 COLORREF Colors[16]; /* Colour palette */ 180 181 } CONSRV_CONSOLE, *PCONSRV_CONSOLE; 182 183 /* console.c */ 184 VOID ConioPause(PCONSRV_CONSOLE Console, UCHAR Flags); 185 VOID ConioUnpause(PCONSRV_CONSOLE Console, UCHAR Flags); 186 187 PCONSOLE_PROCESS_DATA NTAPI 188 ConSrvGetConsoleLeaderProcess(IN PCONSRV_CONSOLE Console); 189 NTSTATUS 190 ConSrvConsoleCtrlEvent(IN ULONG CtrlEvent, 191 IN PCONSOLE_PROCESS_DATA ProcessData); 192 193 NTSTATUS NTAPI 194 ConSrvConsoleProcessCtrlEvent(IN PCONSRV_CONSOLE Console, 195 IN ULONG ProcessGroupId, 196 IN ULONG CtrlEvent); 197 VOID 198 ConSrvSetProcessFocus(IN PCSR_PROCESS CsrProcess, 199 IN BOOLEAN SetForeground); 200 NTSTATUS NTAPI 201 ConSrvSetConsoleProcessFocus(IN PCONSRV_CONSOLE Console, 202 IN BOOLEAN SetForeground); 203 204 /* coninput.c */ 205 VOID NTAPI ConioProcessKey(PCONSRV_CONSOLE Console, MSG* msg); 206 DWORD ConioEffectiveCursorSize(PCONSRV_CONSOLE Console, 207 DWORD Scale); 208 209 NTSTATUS 210 ConioProcessInputEvent(PCONSRV_CONSOLE Console, 211 PINPUT_RECORD InputEvent); 212 213 /* conoutput.c */ 214 PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y); 215 216 /* terminal.c */ 217 VOID ConioDrawConsole(PCONSRV_CONSOLE Console); 218 219 /* EOF */ 220