2014-05-02 16:46:13 +00:00
/*
* COPYRIGHT : See COPYING in the top level directory
* PROJECT : ReactOS Console Server DLL
* FILE : consrv / include / conio_winsrv . h
* PURPOSE : Public Console I / O Interface
* PROGRAMMERS : G <EFBFBD> van Geldorp
* Jeffrey Morlan
* Hermes Belusca - Maito ( hermes . belusca @ sfr . fr )
*/
# pragma once
2014-08-04 16:25:12 +00:00
# include "rect.h"
2014-08-11 20:28:40 +00:00
// This is ALMOST a HACK!!!!!!!
// Helpers for code refactoring
# define _CONSRV_CONSOLE _CONSOLE
# define CONSRV_CONSOLE CONSOLE
# define PCONSRV_CONSOLE PCONSOLE
2014-08-12 14:59:13 +00:00
// #define _CONSRV_CONSOLE _WINSRV_CONSOLE
// #define CONSRV_CONSOLE WINSRV_CONSOLE
// #define PCONSRV_CONSOLE PWINSRV_CONSOLE
2014-08-11 20:28:40 +00:00
2014-05-02 16:46:13 +00:00
# define CSR_DEFAULT_CURSOR_SIZE 25
2014-08-12 14:59:13 +00:00
/* VGA character cell */
typedef struct _CHAR_CELL
{
CHAR Char ;
BYTE Attributes ;
} CHAR_CELL , * PCHAR_CELL ;
C_ASSERT ( sizeof ( CHAR_CELL ) = = 2 ) ;
2014-05-02 16:46:13 +00:00
typedef struct _FRONTEND FRONTEND , * PFRONTEND ;
/* HACK: */ typedef struct _CONSOLE_INFO * PCONSOLE_INFO ;
typedef struct _FRONTEND_VTBL
{
// NTSTATUS (NTAPI *UnloadFrontEnd)(IN OUT PFRONTEND This);
/*
* Internal interface ( functions called by the console server only )
*/
NTSTATUS ( NTAPI * InitFrontEnd ) ( IN OUT PFRONTEND This ,
2014-08-11 20:28:40 +00:00
IN struct _CONSRV_CONSOLE * Console ) ;
2014-05-02 16:46:13 +00:00
VOID ( NTAPI * DeinitFrontEnd ) ( IN OUT PFRONTEND This ) ;
/* Interface used for both text-mode and graphics screen buffers */
VOID ( NTAPI * DrawRegion ) ( IN OUT PFRONTEND This ,
SMALL_RECT * Region ) ;
/* Interface used only for text-mode screen buffers */
VOID ( NTAPI * WriteStream ) ( IN OUT PFRONTEND This ,
2014-05-03 01:59:28 +00:00
SMALL_RECT * Region ,
2014-05-02 16:46:13 +00:00
SHORT CursorStartX ,
SHORT CursorStartY ,
UINT ScrolledLines ,
PWCHAR Buffer ,
UINT Length ) ;
BOOL ( NTAPI * SetCursorInfo ) ( IN OUT PFRONTEND This ,
PCONSOLE_SCREEN_BUFFER ScreenBuffer ) ;
BOOL ( NTAPI * SetScreenInfo ) ( IN OUT PFRONTEND This ,
PCONSOLE_SCREEN_BUFFER ScreenBuffer ,
SHORT OldCursorX ,
SHORT OldCursorY ) ;
VOID ( NTAPI * ResizeTerminal ) ( IN OUT PFRONTEND This ) ;
VOID ( NTAPI * SetActiveScreenBuffer ) ( IN OUT PFRONTEND This ) ;
VOID ( NTAPI * ReleaseScreenBuffer ) ( IN OUT PFRONTEND This ,
IN PCONSOLE_SCREEN_BUFFER ScreenBuffer ) ;
VOID ( NTAPI * RefreshInternalInfo ) ( IN OUT PFRONTEND This ) ;
/*
* External interface ( functions corresponding to the Console API )
*/
VOID ( NTAPI * ChangeTitle ) ( IN OUT PFRONTEND This ) ;
BOOL ( NTAPI * ChangeIcon ) ( IN OUT PFRONTEND This ,
HICON IconHandle ) ;
HWND ( NTAPI * GetConsoleWindowHandle ) ( IN OUT PFRONTEND This ) ;
VOID ( NTAPI * GetLargestConsoleWindowSize ) ( IN OUT PFRONTEND This ,
PCOORD pSize ) ;
BOOL ( NTAPI * GetSelectionInfo ) ( IN OUT PFRONTEND This ,
PCONSOLE_SELECTION_INFO pSelectionInfo ) ;
BOOL ( NTAPI * SetPalette ) ( IN OUT PFRONTEND This ,
HPALETTE PaletteHandle ,
UINT PaletteUsage ) ;
ULONG ( NTAPI * GetDisplayMode ) ( IN OUT PFRONTEND This ) ;
BOOL ( NTAPI * SetDisplayMode ) ( IN OUT PFRONTEND This ,
ULONG NewMode ) ;
INT ( NTAPI * ShowMouseCursor ) ( IN OUT PFRONTEND This ,
BOOL Show ) ;
BOOL ( NTAPI * SetMouseCursor ) ( IN OUT PFRONTEND This ,
HCURSOR CursorHandle ) ;
HMENU ( NTAPI * MenuControl ) ( IN OUT PFRONTEND This ,
UINT CmdIdLow ,
UINT CmdIdHigh ) ;
BOOL ( NTAPI * SetMenuClose ) ( IN OUT PFRONTEND This ,
BOOL Enable ) ;
} FRONTEND_VTBL , * PFRONTEND_VTBL ;
struct _FRONTEND
{
PFRONTEND_VTBL Vtbl ; /* Virtual table */
2014-05-02 18:44:26 +00:00
NTSTATUS ( NTAPI * UnloadFrontEnd ) ( IN OUT PFRONTEND This ) ;
2014-08-11 20:28:40 +00:00
struct _CONSRV_CONSOLE * Console ; /* Console to which the frontend is attached to */
2014-05-02 16:46:13 +00:00
PVOID Data ; /* Private data */
PVOID OldData ; /* Reserved */
} ;
/* PauseFlags values (internal only) */
# define PAUSED_FROM_KEYBOARD 0x1
# define PAUSED_FROM_SCROLLBAR 0x2
# define PAUSED_FROM_SELECTION 0x4
typedef struct _WINSRV_CONSOLE
{
/******************************* Console Set-up *******************************/
/* This **MUST** be FIRST!! */
// CONSOLE;
2014-08-12 14:59:13 +00:00
// PCONSOLE Console;
2014-05-02 16:46:13 +00:00
// 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 */
// CRITICAL_SECTION Lock;
// CONSOLE_STATE State; /* State of the console */
FRONTEND FrontEndIFace ; /* Frontend-specific interface */
2014-05-04 00:01:48 +00:00
/******************************* Process support ******************************/
2014-05-02 16:46:13 +00:00
LIST_ENTRY ProcessList ; /* List of processes owning the console. The first one is the so-called "Console Leader Process" */
PCONSOLE_PROCESS_DATA NotifiedLastCloseProcess ; /* Pointer to the unique process that needs to be notified when the console leader process is killed */
BOOLEAN NotifyLastClose ; /* TRUE if the console should send a control event when the console leader process is killed */
2014-05-04 00:01:48 +00:00
/******************************* Pausing support ******************************/
2014-05-02 16:46:13 +00:00
BYTE PauseFlags ;
LIST_ENTRY ReadWaitQueue ; /* List head for the queue of unique input buffer read wait blocks */
LIST_ENTRY WriteWaitQueue ; /* List head for the queue of current screen-buffer write wait blocks */
2014-05-04 00:01:48 +00:00
/**************************** Aliases and Histories ***************************/
struct _ALIAS_HEADER * Aliases ;
LIST_ENTRY HistoryBuffers ;
ULONG HistoryBufferSize ; /* Size for newly created history buffers */
ULONG NumberOfHistoryBuffers ; /* Maximum number of history buffers allowed */
BOOLEAN HistoryNoDup ; /* Remove old duplicate history entries */
2014-08-29 19:45:45 +00:00
/**************************** Input Line Discipline ***************************/
PWCHAR LineBuffer ; /* Current line being input, in line buffered mode */
ULONG LineMaxSize ; /* Maximum size of line in characters (including CR+LF) */
ULONG LineSize ; /* Current size of line */
ULONG LinePos ; /* Current position within line */
BOOLEAN LineComplete ; /* User pressed enter, ready to send back to client */
BOOLEAN LineUpPressed ;
BOOLEAN LineInsertToggle ; /* Replace character over cursor instead of inserting */
ULONG LineWakeupMask ; /* Bitmap of which control characters will end line input */
BOOLEAN InsertMode ;
BOOLEAN QuickEdit ;
2014-08-11 20:28:40 +00:00
/************************ Virtual DOS Machine support *************************/
COORD VDMBufferSize ; /* Real size of the VDM buffer, in units of ??? */
HANDLE VDMBufferSection ; /* Handle to the memory shared section for the VDM buffer */
PVOID VDMBuffer ; /* Our VDM buffer */
PVOID ClientVDMBuffer ; /* A copy of the client view of our VDM buffer */
HANDLE VDMClientProcess ; /* Handle to the client process who opened the buffer, to unmap the view */
HANDLE StartHardwareEvent ;
HANDLE EndHardwareEvent ;
HANDLE ErrorHardwareEvent ;
/****************************** Other properties ******************************/
COLORREF Colors [ 16 ] ; /* Colour palette */
2014-05-02 16:46:13 +00:00
} WINSRV_CONSOLE , * PWINSRV_CONSOLE ;
/* console.c */
2014-08-11 20:28:40 +00:00
VOID ConioPause ( PCONSRV_CONSOLE Console , UINT Flags ) ;
VOID ConioUnpause ( PCONSRV_CONSOLE Console , UINT Flags ) ;
2014-05-02 16:46:13 +00:00
PCONSOLE_PROCESS_DATA NTAPI
2014-08-11 20:28:40 +00:00
ConSrvGetConsoleLeaderProcess ( IN PCONSRV_CONSOLE Console ) ;
2014-05-02 16:46:13 +00:00
NTSTATUS
ConSrvConsoleCtrlEvent ( IN ULONG CtrlEvent ,
IN PCONSOLE_PROCESS_DATA ProcessData ) ;
NTSTATUS NTAPI
2014-08-11 20:28:40 +00:00
ConSrvConsoleProcessCtrlEvent ( IN PCONSRV_CONSOLE Console ,
2014-05-02 16:46:13 +00:00
IN ULONG ProcessGroupId ,
IN ULONG CtrlEvent ) ;
/* coninput.c */
2014-08-11 20:28:40 +00:00
VOID NTAPI ConioProcessKey ( PCONSRV_CONSOLE Console , MSG * msg ) ;
DWORD ConioEffectiveCursorSize ( PCONSRV_CONSOLE Console ,
2014-08-04 20:23:33 +00:00
DWORD Scale ) ;
[KERNEL32][CONSRV]
- Make kernel32 / winsrv console CSR structures Win2k3-compliant for Read/WriteConsole functions.
An attentive code reader will see that there are structure members in CONSOLE_WRITECONSOLE that are
indeed unused by kernel32 that can be used in ReactOS for undocumented extensions of WriteConsole...
(for instance, adding a parameter for ANSI codes support, who knows!... :P)
- Fix a bit the support for the CONSOLE_READCONSOLE_CONTROL parameter in ReadConsole (for unicode only).
- Use the actual exe name for command history management, given via a hackish way by ReadConsole:
the exe name is passed via the 80-byte-length limited static buffer, and is of course retrieved before
actually using the static buffer (if needed).
[CONSRV]
- Fix writing input events in the console, but first preprocessing them for pausing commands (we treat them separately and remove them),
then, in case we write many single events, we merge them in case they are mouse moves or repeated key down presses. This helps in not
overflowing too quickly the input buffer, and that fixes all the remaining kernel32:console winetests!! (see CORE-8256)
- Use the actual exe name for command history management, given via a hackish way by ReadConsole (blame MS!)
Part 8/X
CORE-7931
CORE-8256 #resolve #comment Fixed in the condrv_restructure branch in revision .
svn path=/branches/condrv_restructure/; revision=63793
2014-08-01 18:08:29 +00:00
NTSTATUS
2014-08-11 20:28:40 +00:00
ConioAddInputEvents ( PCONSRV_CONSOLE Console ,
[KERNEL32][CONSRV]
- Make kernel32 / winsrv console CSR structures Win2k3-compliant for Read/WriteConsole functions.
An attentive code reader will see that there are structure members in CONSOLE_WRITECONSOLE that are
indeed unused by kernel32 that can be used in ReactOS for undocumented extensions of WriteConsole...
(for instance, adding a parameter for ANSI codes support, who knows!... :P)
- Fix a bit the support for the CONSOLE_READCONSOLE_CONTROL parameter in ReadConsole (for unicode only).
- Use the actual exe name for command history management, given via a hackish way by ReadConsole:
the exe name is passed via the 80-byte-length limited static buffer, and is of course retrieved before
actually using the static buffer (if needed).
[CONSRV]
- Fix writing input events in the console, but first preprocessing them for pausing commands (we treat them separately and remove them),
then, in case we write many single events, we merge them in case they are mouse moves or repeated key down presses. This helps in not
overflowing too quickly the input buffer, and that fixes all the remaining kernel32:console winetests!! (see CORE-8256)
- Use the actual exe name for command history management, given via a hackish way by ReadConsole (blame MS!)
Part 8/X
CORE-7931
CORE-8256 #resolve #comment Fixed in the condrv_restructure branch in revision .
svn path=/branches/condrv_restructure/; revision=63793
2014-08-01 18:08:29 +00:00
PINPUT_RECORD InputRecords ,
ULONG NumEventsToWrite ,
PULONG NumEventsWritten ,
BOOLEAN AppendToEnd ) ;
NTSTATUS
2014-08-11 20:28:40 +00:00
ConioProcessInputEvent ( PCONSRV_CONSOLE Console ,
[KERNEL32][CONSRV]
- Make kernel32 / winsrv console CSR structures Win2k3-compliant for Read/WriteConsole functions.
An attentive code reader will see that there are structure members in CONSOLE_WRITECONSOLE that are
indeed unused by kernel32 that can be used in ReactOS for undocumented extensions of WriteConsole...
(for instance, adding a parameter for ANSI codes support, who knows!... :P)
- Fix a bit the support for the CONSOLE_READCONSOLE_CONTROL parameter in ReadConsole (for unicode only).
- Use the actual exe name for command history management, given via a hackish way by ReadConsole:
the exe name is passed via the 80-byte-length limited static buffer, and is of course retrieved before
actually using the static buffer (if needed).
[CONSRV]
- Fix writing input events in the console, but first preprocessing them for pausing commands (we treat them separately and remove them),
then, in case we write many single events, we merge them in case they are mouse moves or repeated key down presses. This helps in not
overflowing too quickly the input buffer, and that fixes all the remaining kernel32:console winetests!! (see CORE-8256)
- Use the actual exe name for command history management, given via a hackish way by ReadConsole (blame MS!)
Part 8/X
CORE-7931
CORE-8256 #resolve #comment Fixed in the condrv_restructure branch in revision .
svn path=/branches/condrv_restructure/; revision=63793
2014-08-01 18:08:29 +00:00
PINPUT_RECORD InputEvent ) ;
2014-05-02 16:46:13 +00:00
/* conoutput.c */
2014-07-29 12:54:01 +00:00
/*
* From MSDN :
* " The lpMultiByteStr and lpWideCharStr pointers must not be the same.
* If they are the same , the function fails , and GetLastError returns
* ERROR_INVALID_PARAMETER . "
*/
2014-05-02 16:46:13 +00:00
# define ConsoleUnicodeCharToAnsiChar(Console, dChar, sWChar) \
2014-07-29 12:54:01 +00:00
ASSERT ( ( ULONG_PTR ) dChar ! = ( ULONG_PTR ) sWChar ) ; \
2014-05-02 16:46:13 +00:00
WideCharToMultiByte ( ( Console ) - > OutputCodePage , 0 , ( sWChar ) , 1 , ( dChar ) , 1 , NULL , NULL )
# define ConsoleAnsiCharToUnicodeChar(Console, dWChar, sChar) \
2014-07-29 12:54:01 +00:00
ASSERT ( ( ULONG_PTR ) dWChar ! = ( ULONG_PTR ) sChar ) ; \
2014-05-02 16:46:13 +00:00
MultiByteToWideChar ( ( Console ) - > OutputCodePage , 0 , ( sChar ) , 1 , ( dWChar ) , 1 )
PCHAR_INFO ConioCoordToPointer ( PTEXTMODE_SCREEN_BUFFER Buff , ULONG X , ULONG Y ) ;
2014-08-11 20:28:40 +00:00
VOID ConioDrawConsole ( PCONSRV_CONSOLE Console ) ;
NTSTATUS ConioResizeBuffer ( PCONSRV_CONSOLE Console ,
2014-05-02 16:46:13 +00:00
PTEXTMODE_SCREEN_BUFFER ScreenBuffer ,
COORD Size ) ;
/* EOF */