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 ULONG (NTAPI *GetDisplayMode)(IN OUT PFRONTEND This); 83 BOOL (NTAPI *SetDisplayMode)(IN OUT PFRONTEND This, 84 ULONG NewMode); 85 INT (NTAPI *ShowMouseCursor)(IN OUT PFRONTEND This, 86 BOOL Show); 87 BOOL (NTAPI *SetMouseCursor)(IN OUT PFRONTEND This, 88 HCURSOR CursorHandle); 89 HMENU (NTAPI *MenuControl)(IN OUT PFRONTEND This, 90 UINT CmdIdLow, 91 UINT CmdIdHigh); 92 BOOL (NTAPI *SetMenuClose)(IN OUT PFRONTEND This, 93 BOOL Enable); 94 } FRONTEND_VTBL, *PFRONTEND_VTBL; 95 96 struct _FRONTEND 97 { 98 PFRONTEND_VTBL Vtbl; /* Virtual table */ 99 NTSTATUS (NTAPI *UnloadFrontEnd)(IN OUT PFRONTEND This); 100 101 struct _CONSRV_CONSOLE* Console; /* Console to which the frontend is attached to */ 102 PVOID Context; /* Private context */ 103 PVOID Context2; /* Private context */ 104 }; 105 106 /* PauseFlags values (internal only) */ 107 #define PAUSED_FROM_KEYBOARD 0x1 108 #define PAUSED_FROM_SCROLLBAR 0x2 109 #define PAUSED_FROM_SELECTION 0x4 110 111 typedef struct _CONSRV_CONSOLE 112 { 113 /******************************* Console Set-up *******************************/ 114 /* This **MUST** be FIRST!! */ 115 CONSOLE; 116 // CONSOLE Console; 117 // // PCONSOLE Console; 118 119 // 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 */ 120 // CRITICAL_SECTION Lock; 121 // CONSOLE_STATE State; /* State of the console */ 122 123 // ULONG ConsoleID; /* The ID of the console */ 124 // LIST_ENTRY ListEntry; /* Entry in the list of consoles */ 125 126 HANDLE InitEvents[MAX_INIT_EVENTS]; /* Initialization events */ 127 128 FRONTEND FrontEndIFace; /* Frontend-specific interface */ 129 130 /******************************* Process support ******************************/ 131 LIST_ENTRY ProcessList; /* List of processes owning the console. The first one is the so-called "Console Leader Process" */ 132 PCONSOLE_PROCESS_DATA NotifiedLastCloseProcess; /* Pointer to the unique process that needs to be notified when the console leader process is killed */ 133 BOOLEAN NotifyLastClose; /* TRUE if the console should send a control event when the console leader process is killed */ 134 BOOLEAN HasFocus; /* TRUE if the console has focus (is in the foreground) */ 135 136 /******************************* Pausing support ******************************/ 137 UCHAR PauseFlags; 138 LIST_ENTRY ReadWaitQueue; /* List head for the queue of unique input buffer read wait blocks */ 139 LIST_ENTRY WriteWaitQueue; /* List head for the queue of current screen-buffer write wait blocks */ 140 141 /**************************** Aliases and Histories ***************************/ 142 struct _ALIAS_HEADER *Aliases; 143 LIST_ENTRY HistoryBuffers; 144 ULONG NumberOfHistoryBuffers; /* Number of history buffers */ 145 ULONG MaxNumberOfHistoryBuffers; /* Maximum number of history buffers allowed */ 146 ULONG HistoryBufferSize; /* Size for newly created history buffers */ 147 BOOLEAN HistoryNoDup; /* Remove old duplicate history entries */ 148 149 /**************************** Input Line Discipline ***************************/ 150 PWCHAR LineBuffer; /* Current line being input, in line buffered mode */ 151 ULONG LineMaxSize; /* Maximum size of line in characters (including CR+LF) */ 152 ULONG LineSize; /* Current size of line */ 153 ULONG LinePos; /* Current position within line */ 154 BOOLEAN LineComplete; /* User pressed enter, ready to send back to client */ 155 BOOLEAN LineUpPressed; 156 BOOLEAN LineInsertToggle; /* Replace character over cursor instead of inserting */ 157 ULONG LineWakeupMask; /* Bitmap of which control characters will end line input */ 158 159 BOOLEAN InsertMode; 160 BOOLEAN QuickEdit; 161 162 /************************ Virtual DOS Machine support *************************/ 163 COORD VDMBufferSize; /* Real size of the VDM buffer, in units of ??? */ 164 HANDLE VDMBufferSection; /* Handle to the memory shared section for the VDM buffer */ 165 PVOID VDMBuffer; /* Our VDM buffer */ 166 PVOID ClientVDMBuffer; /* A copy of the client view of our VDM buffer */ 167 HANDLE VDMClientProcess; /* Handle to the client process who opened the buffer, to unmap the view */ 168 169 HANDLE StartHardwareEvent; 170 HANDLE EndHardwareEvent; 171 HANDLE ErrorHardwareEvent; 172 173 /****************************** Other properties ******************************/ 174 LIST_ENTRY PopupWindows; /* List of popup windows */ 175 UNICODE_STRING OriginalTitle; /* Original title of console, the one defined when the console leader is launched; it never changes. Always NULL-terminated */ 176 UNICODE_STRING Title; /* Title of console. Always NULL-terminated */ 177 COLORREF Colors[16]; /* Colour palette */ 178 179 } CONSRV_CONSOLE, *PCONSRV_CONSOLE; 180 181 /* console.c */ 182 VOID ConioPause(PCONSRV_CONSOLE Console, UCHAR Flags); 183 VOID ConioUnpause(PCONSRV_CONSOLE Console, UCHAR Flags); 184 185 PCONSOLE_PROCESS_DATA NTAPI 186 ConSrvGetConsoleLeaderProcess(IN PCONSRV_CONSOLE Console); 187 NTSTATUS 188 ConSrvConsoleCtrlEvent(IN ULONG CtrlEvent, 189 IN PCONSOLE_PROCESS_DATA ProcessData); 190 191 NTSTATUS NTAPI 192 ConSrvConsoleProcessCtrlEvent(IN PCONSRV_CONSOLE Console, 193 IN ULONG ProcessGroupId, 194 IN ULONG CtrlEvent); 195 VOID 196 ConSrvSetProcessFocus(IN PCSR_PROCESS CsrProcess, 197 IN BOOLEAN SetForeground); 198 NTSTATUS NTAPI 199 ConSrvSetConsoleProcessFocus(IN PCONSRV_CONSOLE Console, 200 IN BOOLEAN SetForeground); 201 202 /* coninput.c */ 203 VOID NTAPI ConioProcessKey(PCONSRV_CONSOLE Console, MSG* msg); 204 DWORD ConioEffectiveCursorSize(PCONSRV_CONSOLE Console, 205 DWORD Scale); 206 207 NTSTATUS 208 ConioProcessInputEvent(PCONSRV_CONSOLE Console, 209 PINPUT_RECORD InputEvent); 210 211 /* conoutput.c */ 212 PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y); 213 214 /* terminal.c */ 215 VOID ConioDrawConsole(PCONSRV_CONSOLE Console); 216 217 /* EOF */ 218