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-05-02 16:46:13 +00:00
# define CSR_DEFAULT_CURSOR_SIZE 25
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 ,
IN struct _CONSOLE * Console ) ;
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-05-02 16:46:13 +00:00
struct _CONSOLE * Console ; /* Console to which the frontend is attached to */
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;
// 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 */
BOOLEAN QuickEdit ;
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-05-02 16:46:13 +00:00
} WINSRV_CONSOLE , * PWINSRV_CONSOLE ;
/* console.c */
VOID ConioPause ( PCONSOLE Console , UINT Flags ) ;
VOID ConioUnpause ( PCONSOLE Console , UINT Flags ) ;
PCONSOLE_PROCESS_DATA NTAPI
ConSrvGetConsoleLeaderProcess ( IN PCONSOLE Console ) ;
NTSTATUS
ConSrvConsoleCtrlEvent ( IN ULONG CtrlEvent ,
IN PCONSOLE_PROCESS_DATA ProcessData ) ;
NTSTATUS NTAPI
ConSrvConsoleProcessCtrlEvent ( IN PCONSOLE Console ,
IN ULONG ProcessGroupId ,
IN ULONG CtrlEvent ) ;
/* coninput.c */
VOID NTAPI ConioProcessKey ( PCONSOLE Console , MSG * msg ) ;
2014-08-04 20:23:33 +00:00
DWORD ConioEffectiveCursorSize ( PCONSOLE Console ,
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
ConioAddInputEvents ( PCONSOLE Console ,
PINPUT_RECORD InputRecords ,
ULONG NumEventsToWrite ,
PULONG NumEventsWritten ,
BOOLEAN AppendToEnd ) ;
NTSTATUS
ConioProcessInputEvent ( PCONSOLE Console ,
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 ) ;
VOID ConioDrawConsole ( PCONSOLE Console ) ;
NTSTATUS ConioResizeBuffer ( PCONSOLE Console ,
PTEXTMODE_SCREEN_BUFFER ScreenBuffer ,
COORD Size ) ;
NTSTATUS ConioWriteConsole ( PCONSOLE Console ,
PTEXTMODE_SCREEN_BUFFER Buff ,
PWCHAR Buffer ,
DWORD Length ,
BOOL Attrib ) ;
/* EOF */