mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +00:00
[CONSRV]
- Isolate the members of the CONSOLE structure which are used as input buffer data, in a new structure called ... CONSOLE_INPUT_BUFFER ! - Rename some helper functions to better match what they are doing. svn path=/branches/ros-csrss/; revision=58191
This commit is contained in:
parent
10422cd7e2
commit
f2e3e7ac9d
9 changed files with 238 additions and 198 deletions
|
@ -324,7 +324,7 @@ CSR_API(SrvAddConsoleAlias)
|
|||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
ApiMessage->Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
ApiMessage->Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
if (!NT_SUCCESS(ApiMessage->Status))
|
||||
{
|
||||
return ApiMessage->Status;
|
||||
|
@ -411,7 +411,7 @@ CSR_API(SrvGetConsoleAlias)
|
|||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
ApiMessage->Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
ApiMessage->Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
if (!NT_SUCCESS(ApiMessage->Status))
|
||||
{
|
||||
return ApiMessage->Status;
|
||||
|
@ -468,7 +468,7 @@ CSR_API(SrvGetConsoleAliases)
|
|||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
ApiMessage->Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
ApiMessage->Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
if (!NT_SUCCESS(ApiMessage->Status))
|
||||
{
|
||||
return ApiMessage->Status;
|
||||
|
@ -516,7 +516,7 @@ CSR_API(SrvGetConsoleAliasesLength)
|
|||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
ApiMessage->Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
ApiMessage->Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
if (!NT_SUCCESS(ApiMessage->Status))
|
||||
{
|
||||
return ApiMessage->Status;
|
||||
|
@ -552,7 +552,7 @@ CSR_API(SrvGetConsoleAliasExes)
|
|||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
ApiMessage->Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
ApiMessage->Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
if (!NT_SUCCESS(ApiMessage->Status))
|
||||
{
|
||||
return ApiMessage->Status;
|
||||
|
@ -587,7 +587,7 @@ CSR_API(SrvGetConsoleAliasExesLength)
|
|||
PCONSOLE Console;
|
||||
DPRINT("SrvGetConsoleAliasExesLength entered\n");
|
||||
|
||||
ApiMessage->Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
ApiMessage->Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
if (NT_SUCCESS(ApiMessage->Status))
|
||||
{
|
||||
GetAliasesExesLengthRequest->Length = IntGetConsoleAliasesExesLength(Console->Aliases);
|
||||
|
|
|
@ -60,7 +60,7 @@ ConioProcessChar(PCONSOLE Console,
|
|||
if (!(Console->PauseFlags & PAUSED_FROM_KEYBOARD))
|
||||
{
|
||||
DWORD cks = InputEvent->Event.KeyEvent.dwControlKeyState;
|
||||
if (Console->Mode & ENABLE_LINE_INPUT &&
|
||||
if (Console->InputBuffer.Mode & ENABLE_LINE_INPUT &&
|
||||
(vk == VK_PAUSE || (vk == 'S' &&
|
||||
(cks & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) &&
|
||||
!(cks & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)))))
|
||||
|
@ -85,10 +85,10 @@ ConioProcessChar(PCONSOLE Console,
|
|||
if (ConInRec == NULL)
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
ConInRec->InputEvent = *InputEvent;
|
||||
InsertTailList(&Console->InputEvents, &ConInRec->ListEntry);
|
||||
InsertTailList(&Console->InputBuffer.InputEvents, &ConInRec->ListEntry);
|
||||
|
||||
SetEvent(Console->ActiveEvent);
|
||||
CsrNotifyWait(&Console->ReadWaitQueue,
|
||||
SetEvent(Console->InputBuffer.ActiveEvent);
|
||||
CsrNotifyWait(&Console->InputBuffer.ReadWaitQueue,
|
||||
WaitAny,
|
||||
NULL,
|
||||
NULL);
|
||||
|
@ -239,7 +239,7 @@ ConioProcessKey(MSG *msg, PCONSOLE Console, BOOL TextMode)
|
|||
return;
|
||||
|
||||
/* process Ctrl-C and Ctrl-Break */
|
||||
if (Console->Mode & ENABLE_PROCESSED_INPUT &&
|
||||
if (Console->InputBuffer.Mode & ENABLE_PROCESSED_INPUT &&
|
||||
er.Event.KeyEvent.bKeyDown &&
|
||||
((er.Event.KeyEvent.wVirtualKeyCode == VK_PAUSE) ||
|
||||
(er.Event.KeyEvent.wVirtualKeyCode == 'C')) &&
|
||||
|
@ -317,7 +317,7 @@ WaitBeforeReading(IN PGET_INPUT_INFO InputInfo,
|
|||
|
||||
memmove(CapturedInputInfo, InputInfo, sizeof(GET_INPUT_INFO));
|
||||
|
||||
if (!CsrCreateWait(&InputInfo->Console->ReadWaitQueue,
|
||||
if (!CsrCreateWait(&InputInfo->Console->InputBuffer.ReadWaitQueue,
|
||||
WaitFunction,
|
||||
CsrGetClientThread(),
|
||||
ApiMessage,
|
||||
|
@ -373,7 +373,7 @@ ReadInputBuffer(IN PGET_INPUT_INFO InputInfo,
|
|||
IN PCSR_API_MESSAGE ApiMessage,
|
||||
IN BOOL CreateWaitBlock OPTIONAL)
|
||||
{
|
||||
if (IsListEmpty(&InputInfo->Console->InputEvents))
|
||||
if (IsListEmpty(&InputInfo->Console->InputBuffer.InputEvents))
|
||||
{
|
||||
if (Wait)
|
||||
{
|
||||
|
@ -397,9 +397,9 @@ ReadInputBuffer(IN PGET_INPUT_INFO InputInfo,
|
|||
PINPUT_RECORD InputRecord = GetInputRequest->InputRecord;
|
||||
|
||||
/* Only get input if there is any */
|
||||
CurrentInput = InputInfo->Console->InputEvents.Flink;
|
||||
CurrentInput = InputInfo->Console->InputBuffer.InputEvents.Flink;
|
||||
|
||||
while ( CurrentInput != &InputInfo->Console->InputEvents &&
|
||||
while ( CurrentInput != &InputInfo->Console->InputBuffer.InputEvents &&
|
||||
GetInputRequest->InputsRead < Length )
|
||||
{
|
||||
Input = CONTAINING_RECORD(CurrentInput, ConsoleInput, ListEntry);
|
||||
|
@ -422,9 +422,9 @@ ReadInputBuffer(IN PGET_INPUT_INFO InputInfo,
|
|||
}
|
||||
}
|
||||
|
||||
if (IsListEmpty(&InputInfo->Console->InputEvents))
|
||||
if (IsListEmpty(&InputInfo->Console->InputBuffer.InputEvents))
|
||||
{
|
||||
ResetEvent(InputInfo->Console->ActiveEvent);
|
||||
ResetEvent(InputInfo->Console->InputBuffer.ActiveEvent);
|
||||
}
|
||||
|
||||
/* We read all the inputs available, we return success */
|
||||
|
@ -479,7 +479,7 @@ ReadChars(IN PGET_INPUT_INFO InputInfo,
|
|||
|
||||
/* We haven't read anything (yet) */
|
||||
|
||||
if (InputInfo->Console->Mode & ENABLE_LINE_INPUT)
|
||||
if (InputInfo->Console->InputBuffer.Mode & ENABLE_LINE_INPUT)
|
||||
{
|
||||
if (InputInfo->Console->LineBuffer == NULL)
|
||||
{
|
||||
|
@ -511,13 +511,13 @@ ReadChars(IN PGET_INPUT_INFO InputInfo,
|
|||
|
||||
/* If we don't have a complete line yet, process the pending input */
|
||||
while ( !InputInfo->Console->LineComplete &&
|
||||
!IsListEmpty(&InputInfo->Console->InputEvents) )
|
||||
!IsListEmpty(&InputInfo->Console->InputBuffer.InputEvents) )
|
||||
{
|
||||
/* Remove input event from queue */
|
||||
CurrentEntry = RemoveHeadList(&InputInfo->Console->InputEvents);
|
||||
if (IsListEmpty(&InputInfo->Console->InputEvents))
|
||||
CurrentEntry = RemoveHeadList(&InputInfo->Console->InputBuffer.InputEvents);
|
||||
if (IsListEmpty(&InputInfo->Console->InputBuffer.InputEvents))
|
||||
{
|
||||
ResetEvent(InputInfo->Console->ActiveEvent);
|
||||
ResetEvent(InputInfo->Console->InputBuffer.ActiveEvent);
|
||||
}
|
||||
Input = CONTAINING_RECORD(CurrentEntry, ConsoleInput, ListEntry);
|
||||
|
||||
|
@ -567,13 +567,13 @@ ReadChars(IN PGET_INPUT_INFO InputInfo,
|
|||
{
|
||||
/* Character input */
|
||||
while ( ReadConsoleRequest->NrCharactersRead < nNumberOfCharsToRead &&
|
||||
!IsListEmpty(&InputInfo->Console->InputEvents) )
|
||||
!IsListEmpty(&InputInfo->Console->InputBuffer.InputEvents) )
|
||||
{
|
||||
/* Remove input event from queue */
|
||||
CurrentEntry = RemoveHeadList(&InputInfo->Console->InputEvents);
|
||||
if (IsListEmpty(&InputInfo->Console->InputEvents))
|
||||
CurrentEntry = RemoveHeadList(&InputInfo->Console->InputBuffer.InputEvents);
|
||||
if (IsListEmpty(&InputInfo->Console->InputBuffer.InputEvents))
|
||||
{
|
||||
ResetEvent(InputInfo->Console->ActiveEvent);
|
||||
ResetEvent(InputInfo->Console->InputBuffer.ActiveEvent);
|
||||
}
|
||||
Input = CONTAINING_RECORD(CurrentEntry, ConsoleInput, ListEntry);
|
||||
|
||||
|
@ -626,7 +626,7 @@ CSR_API(SrvGetConsoleInput)
|
|||
NTSTATUS Status;
|
||||
PCONSOLE_GETINPUT GetInputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetInputRequest;
|
||||
PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process);
|
||||
PCONSOLE Console;
|
||||
PCONSOLE_INPUT_BUFFER InputBuffer;
|
||||
GET_INPUT_INFO InputInfo;
|
||||
|
||||
DPRINT("SrvGetConsoleInput\n");
|
||||
|
@ -639,20 +639,20 @@ CSR_API(SrvGetConsoleInput)
|
|||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = ConioLockConsole(ProcessData, GetInputRequest->InputHandle, &Console, GENERIC_READ);
|
||||
Status = ConioLockInputBuffer(ProcessData, GetInputRequest->InputHandle, &InputBuffer, GENERIC_READ);
|
||||
if(!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
GetInputRequest->InputsRead = 0;
|
||||
|
||||
InputInfo.ProcessData = ProcessData; // ConsoleGetPerProcessData(CsrGetClientThread()->Process);
|
||||
InputInfo.Console = Console;
|
||||
InputInfo.Console = InputBuffer->Header.Console;
|
||||
|
||||
Status = ReadInputBuffer(&InputInfo,
|
||||
GetInputRequest->bRead,
|
||||
ApiMessage,
|
||||
TRUE);
|
||||
|
||||
ConioUnlockConsole(Console);
|
||||
ConioUnlockInputBuffer(InputBuffer);
|
||||
|
||||
if (Status == STATUS_PENDING)
|
||||
*ReplyCode = CsrReplyPending;
|
||||
|
@ -666,6 +666,7 @@ CSR_API(SrvWriteConsoleInput)
|
|||
PCONSOLE_WRITEINPUT WriteInputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.WriteInputRequest;
|
||||
PINPUT_RECORD InputRecord;
|
||||
PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process);
|
||||
PCONSOLE_INPUT_BUFFER InputBuffer;
|
||||
PCONSOLE Console;
|
||||
DWORD Length;
|
||||
DWORD i;
|
||||
|
@ -680,9 +681,10 @@ CSR_API(SrvWriteConsoleInput)
|
|||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = ConioLockConsole(ProcessData, WriteInputRequest->InputHandle, &Console, GENERIC_WRITE);
|
||||
Status = ConioLockInputBuffer(ProcessData, WriteInputRequest->InputHandle, &InputBuffer, GENERIC_WRITE);
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
Console = InputBuffer->Header.Console;
|
||||
InputRecord = WriteInputRequest->InputRecord;
|
||||
Length = WriteInputRequest->Length;
|
||||
|
||||
|
@ -700,7 +702,7 @@ CSR_API(SrvWriteConsoleInput)
|
|||
Status = ConioProcessChar(Console, InputRecord++);
|
||||
}
|
||||
|
||||
ConioUnlockConsole(Console);
|
||||
ConioUnlockInputBuffer(InputBuffer);
|
||||
|
||||
WriteInputRequest->Length = i;
|
||||
|
||||
|
@ -712,7 +714,7 @@ CSR_API(SrvReadConsole)
|
|||
NTSTATUS Status;
|
||||
PCONSOLE_READCONSOLE ReadConsoleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadConsoleRequest;
|
||||
PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process);
|
||||
PCONSOLE Console;
|
||||
PCONSOLE_INPUT_BUFFER InputBuffer;
|
||||
GET_INPUT_INFO InputInfo;
|
||||
|
||||
DPRINT("SrvReadConsole\n");
|
||||
|
@ -731,19 +733,19 @@ CSR_API(SrvReadConsole)
|
|||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = ConioLockConsole(ProcessData, ReadConsoleRequest->InputHandle, &Console, GENERIC_READ);
|
||||
Status = ConioLockInputBuffer(ProcessData, ReadConsoleRequest->InputHandle, &InputBuffer, GENERIC_READ);
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
ReadConsoleRequest->NrCharactersRead = 0;
|
||||
|
||||
InputInfo.ProcessData = ProcessData; // ConsoleGetPerProcessData(CsrGetClientThread()->Process);
|
||||
InputInfo.Console = Console;
|
||||
InputInfo.Console = InputBuffer->Header.Console;
|
||||
|
||||
Status = ReadChars(&InputInfo,
|
||||
ApiMessage,
|
||||
TRUE);
|
||||
|
||||
ConioUnlockConsole(Console);
|
||||
ConioUnlockInputBuffer(InputBuffer);
|
||||
|
||||
if (Status == STATUS_PENDING)
|
||||
*ReplyCode = CsrReplyPending;
|
||||
|
@ -756,28 +758,28 @@ CSR_API(SrvFlushConsoleInputBuffer)
|
|||
NTSTATUS Status;
|
||||
PCONSOLE_FLUSHINPUTBUFFER FlushInputBufferRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.FlushInputBufferRequest;
|
||||
PLIST_ENTRY CurrentEntry;
|
||||
PCONSOLE Console;
|
||||
PCONSOLE_INPUT_BUFFER InputBuffer;
|
||||
ConsoleInput* Input;
|
||||
|
||||
DPRINT("SrvFlushConsoleInputBuffer\n");
|
||||
|
||||
Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
|
||||
Status = ConioLockInputBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
|
||||
FlushInputBufferRequest->InputHandle,
|
||||
&Console,
|
||||
&InputBuffer,
|
||||
GENERIC_WRITE);
|
||||
if(!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
/* Discard all entries in the input event queue */
|
||||
while (!IsListEmpty(&Console->InputEvents))
|
||||
while (!IsListEmpty(&InputBuffer->InputEvents))
|
||||
{
|
||||
CurrentEntry = RemoveHeadList(&Console->InputEvents);
|
||||
CurrentEntry = RemoveHeadList(&InputBuffer->InputEvents);
|
||||
Input = CONTAINING_RECORD(CurrentEntry, ConsoleInput, ListEntry);
|
||||
/* Destroy the event */
|
||||
RtlFreeHeap(ConSrvHeap, 0, Input);
|
||||
}
|
||||
ResetEvent(Console->ActiveEvent);
|
||||
ResetEvent(InputBuffer->ActiveEvent);
|
||||
|
||||
ConioUnlockConsole(Console);
|
||||
ConioUnlockInputBuffer(InputBuffer);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -786,26 +788,26 @@ CSR_API(SrvGetConsoleNumberOfInputEvents)
|
|||
{
|
||||
NTSTATUS Status;
|
||||
PCONSOLE_GETNUMINPUTEVENTS GetNumInputEventsRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetNumInputEventsRequest;
|
||||
PCONSOLE Console;
|
||||
PCONSOLE_INPUT_BUFFER InputBuffer;
|
||||
PLIST_ENTRY CurrentInput;
|
||||
DWORD NumEvents;
|
||||
|
||||
DPRINT("SrvGetConsoleNumberOfInputEvents\n");
|
||||
|
||||
Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), GetNumInputEventsRequest->InputHandle, &Console, GENERIC_READ);
|
||||
Status = ConioLockInputBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process), GetNumInputEventsRequest->InputHandle, &InputBuffer, GENERIC_READ);
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
CurrentInput = Console->InputEvents.Flink;
|
||||
CurrentInput = InputBuffer->InputEvents.Flink;
|
||||
NumEvents = 0;
|
||||
|
||||
/* If there are any events ... */
|
||||
while (CurrentInput != &Console->InputEvents)
|
||||
while (CurrentInput != &InputBuffer->InputEvents)
|
||||
{
|
||||
CurrentInput = CurrentInput->Flink;
|
||||
NumEvents++;
|
||||
}
|
||||
|
||||
ConioUnlockConsole(Console);
|
||||
ConioUnlockInputBuffer(InputBuffer);
|
||||
|
||||
GetNumInputEventsRequest->NumInputEvents = NumEvents;
|
||||
|
||||
|
|
|
@ -28,46 +28,58 @@
|
|||
|
||||
typedef struct _CONSOLE_SCREEN_BUFFER
|
||||
{
|
||||
Object_t Header; /* Object header */
|
||||
LIST_ENTRY ListEntry; /* Entry in console's list of buffers */
|
||||
Object_t Header; /* Object header */
|
||||
LIST_ENTRY ListEntry; /* Entry in console's list of buffers */
|
||||
|
||||
BYTE *Buffer; /* Pointer to screen buffer */
|
||||
USHORT MaxX, MaxY; /* Size of the entire scrollback buffer */
|
||||
USHORT ShowX, ShowY; /* Beginning offset for the actual display area */
|
||||
ULONG CurrentX; /* Current X cursor position */
|
||||
ULONG CurrentY; /* Current Y cursor position */
|
||||
WORD DefaultAttrib; /* Default char attribute */
|
||||
USHORT VirtualY; /* Top row of buffer being displayed, reported to callers */
|
||||
BYTE *Buffer; /* Pointer to screen buffer */
|
||||
USHORT MaxX, MaxY; /* Size of the entire scrollback buffer */
|
||||
USHORT ShowX, ShowY; /* Beginning offset for the actual display area */
|
||||
ULONG CurrentX; /* Current X cursor position */
|
||||
ULONG CurrentY; /* Current Y cursor position */
|
||||
WORD DefaultAttrib; /* Default char attribute */
|
||||
USHORT VirtualY; /* Top row of buffer being displayed, reported to callers */
|
||||
CONSOLE_CURSOR_INFO CursorInfo;
|
||||
USHORT Mode;
|
||||
} CONSOLE_SCREEN_BUFFER, *PCONSOLE_SCREEN_BUFFER;
|
||||
|
||||
typedef struct _CONSOLE_INPUT_BUFFER
|
||||
{
|
||||
Object_t Header; /* Object header */
|
||||
|
||||
LIST_ENTRY InputEvents; /* List head for input event queue */
|
||||
HANDLE ActiveEvent; /* Event set when an input event is added in its queue */
|
||||
LIST_ENTRY ReadWaitQueue; /* List head for the queue of read wait blocks */
|
||||
WORD Mode; /* Console Input Buffer mode flags */
|
||||
} CONSOLE_INPUT_BUFFER, *PCONSOLE_INPUT_BUFFER;
|
||||
|
||||
typedef struct ConsoleInput_t
|
||||
{
|
||||
LIST_ENTRY ListEntry;
|
||||
INPUT_RECORD InputEvent;
|
||||
} ConsoleInput;
|
||||
|
||||
typedef struct _CONSOLE
|
||||
{
|
||||
Object_t Header; /* Object header */
|
||||
LONG ReferenceCount; /* Is incremented each time a handle to a screen-buffer or the input buffer of this console gets referenced, or the console gets locked */
|
||||
LONG ReferenceCount; /* Is incremented each time a handle to a screen-buffer or the input buffer of this console gets referenced, or the console gets locked */
|
||||
CRITICAL_SECTION Lock;
|
||||
|
||||
struct _CONSOLE *Prev, *Next; /* Next and Prev consoles in console wheel */
|
||||
struct _CONSOLE_VTBL *Vtbl; /* Using CUI or GUI consoles */
|
||||
struct _CONSOLE *Prev, *Next; /* Next and Prev consoles in console wheel */
|
||||
struct _CONSOLE_VTBL *Vtbl; /* Using CUI or GUI consoles */
|
||||
|
||||
CLIENT_ID ConsoleLeaderCID; /* Contains the Console Leader Process CID for this console. TODO: Is it possible to compute it via the contents of the ProcessList list ?? */
|
||||
CLIENT_ID ConsoleLeaderCID; /* Contains the Console Leader Process CID for this console. TODO: Is it possible to compute it via the contents of the ProcessList list ?? */
|
||||
LIST_ENTRY ProcessList;
|
||||
|
||||
/**************************** Input buffer and data ***************************/
|
||||
LIST_ENTRY InputEvents; /* List head for input event queue */
|
||||
HANDLE ActiveEvent; /* Event set when an input event is added in its queue */
|
||||
LIST_ENTRY ReadWaitQueue; /* List head for the queue of read wait blocks */
|
||||
WORD Mode; /* Console Input Buffer mode flags */
|
||||
CONSOLE_INPUT_BUFFER InputBuffer; /* Input buffer of the console */
|
||||
|
||||
PWCHAR LineBuffer; /* current line being input, in line buffered mode */
|
||||
WORD LineMaxSize; /* maximum size of line in characters (including CR+LF) */
|
||||
WORD LineSize; /* current size of line */
|
||||
WORD LinePos; /* current position within line */
|
||||
BOOLEAN LineComplete; /* user pressed enter, ready to send back to client */
|
||||
PWCHAR LineBuffer; /* Current line being input, in line buffered mode */
|
||||
WORD LineMaxSize; /* Maximum size of line in characters (including CR+LF) */
|
||||
WORD LineSize; /* Current size of line */
|
||||
WORD 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 LineInsertToggle; /* Replace character over cursor instead of inserting */
|
||||
ULONG LineWakeupMask; /* Bitmap of which control characters will end line input */
|
||||
|
||||
UINT CodePage;
|
||||
UINT OutputCodePage;
|
||||
|
@ -77,21 +89,21 @@ typedef struct _CONSOLE
|
|||
/**************************** Aliases and Histories ***************************/
|
||||
struct _ALIAS_HEADER *Aliases;
|
||||
LIST_ENTRY HistoryBuffers;
|
||||
UINT HistoryBufferSize; /* size for newly created history buffers */
|
||||
UINT NumberOfHistoryBuffers; /* maximum number of history buffers allowed */
|
||||
BOOLEAN HistoryNoDup; /* remove old duplicate history entries */
|
||||
UINT HistoryBufferSize; /* Size for newly created history buffers */
|
||||
UINT NumberOfHistoryBuffers; /* Maximum number of history buffers allowed */
|
||||
BOOLEAN HistoryNoDup; /* Remove old duplicate history entries */
|
||||
|
||||
/******************************* Screen buffers *******************************/
|
||||
LIST_ENTRY BufferList; /* List of all screen buffers for this console */
|
||||
PCONSOLE_SCREEN_BUFFER ActiveBuffer; /* Pointer to currently active screen buffer */
|
||||
LIST_ENTRY BufferList; /* List of all screen buffers for this console */
|
||||
PCONSOLE_SCREEN_BUFFER ActiveBuffer; /* Pointer to currently active screen buffer */
|
||||
BYTE PauseFlags;
|
||||
HANDLE UnpauseEvent;
|
||||
LIST_ENTRY WriteWaitQueue; /* List head for the queue of write wait blocks */
|
||||
LIST_ENTRY WriteWaitQueue; /* List head for the queue of write wait blocks */
|
||||
|
||||
DWORD HardwareState; /* _GDI_MANAGED, _DIRECT */
|
||||
DWORD HardwareState; /* _GDI_MANAGED, _DIRECT */
|
||||
|
||||
/****************************** GUI-related data ******************************/
|
||||
UNICODE_STRING Title; /* Title of console */
|
||||
UNICODE_STRING Title; /* Title of console */
|
||||
HWND hWindow;
|
||||
COORD Size;
|
||||
PVOID PrivateData;
|
||||
|
@ -127,12 +139,6 @@ typedef struct _CONSOLE_VTBL
|
|||
NTSTATUS (WINAPI *ResizeBuffer)(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER ScreenBuffer, COORD Size);
|
||||
} CONSOLE_VTBL, *PCONSOLE_VTBL;
|
||||
|
||||
typedef struct ConsoleInput_t
|
||||
{
|
||||
LIST_ENTRY ListEntry;
|
||||
INPUT_RECORD InputEvent;
|
||||
} ConsoleInput;
|
||||
|
||||
/* CONSOLE_SELECTION_INFO dwFlags values */
|
||||
#define CONSOLE_NO_SELECTION 0x0
|
||||
#define CONSOLE_SELECTION_IN_PROGRESS 0x1
|
||||
|
@ -163,8 +169,10 @@ typedef struct ConsoleInput_t
|
|||
#define ConioResizeBuffer(Console, Buff, Size) (Console)->Vtbl->ResizeBuffer(Console, Buff, Size)
|
||||
|
||||
/* console.c */
|
||||
NTSTATUS FASTCALL ConioConsoleFromProcessData(PCONSOLE_PROCESS_DATA ProcessData,
|
||||
PCONSOLE *Console);
|
||||
#define ConioLockConsole(ProcessData, Console) \
|
||||
ConioConsoleFromProcessData((ProcessData), (Console))
|
||||
#define ConioUnlockConsole(Console) \
|
||||
Win32CsrUnlockConsole(Console)
|
||||
VOID WINAPI ConioDeleteConsole(PCONSOLE Console);
|
||||
VOID WINAPI CsrInitConsoleSupport(VOID);
|
||||
NTSTATUS WINAPI CsrInitConsole(PCONSOLE* NewConsole, int ShowCmd, PCSR_PROCESS ConsoleLeaderProcess);
|
||||
|
@ -176,10 +184,10 @@ VOID FASTCALL ConioConsoleCtrlEventTimeout(DWORD Event,
|
|||
DWORD Timeout);
|
||||
|
||||
/* coninput.c */
|
||||
#define ConioLockConsole(ProcessData, Handle, Ptr, Access) \
|
||||
Win32CsrLockObject((ProcessData), (Handle), (Object_t **)(Ptr), Access, CONIO_CONSOLE_MAGIC)
|
||||
#define ConioUnlockConsole(Console) \
|
||||
Win32CsrUnlockObject((Object_t *) Console)
|
||||
#define ConioLockInputBuffer(ProcessData, Handle, Ptr, Access) \
|
||||
Win32CsrLockObject((ProcessData), (Handle), (Object_t **)(Ptr), (Access), CONIO_INPUT_BUFFER_MAGIC)
|
||||
#define ConioUnlockInputBuffer(Buff) \
|
||||
Win32CsrUnlockObject(&(Buff)->Header)
|
||||
void WINAPI ConioProcessKey(MSG *msg, PCONSOLE Console, BOOL TextMode);
|
||||
|
||||
/* conoutput.c */
|
||||
|
@ -188,9 +196,9 @@ void WINAPI ConioProcessKey(MSG *msg, PCONSOLE Console, BOOL TextMode);
|
|||
#define ConioRectWidth(Rect) \
|
||||
(((Rect)->Left) > ((Rect)->Right) ? 0 : ((Rect)->Right) - ((Rect)->Left) + 1)
|
||||
#define ConioLockScreenBuffer(ProcessData, Handle, Ptr, Access) \
|
||||
Win32CsrLockObject((ProcessData), (Handle), (Object_t **)(Ptr), Access, CONIO_SCREEN_BUFFER_MAGIC)
|
||||
Win32CsrLockObject((ProcessData), (Handle), (Object_t **)(Ptr), (Access), CONIO_SCREEN_BUFFER_MAGIC)
|
||||
#define ConioUnlockScreenBuffer(Buff) \
|
||||
Win32CsrUnlockObject((Object_t *) Buff)
|
||||
Win32CsrUnlockObject(&(Buff)->Header)
|
||||
PBYTE FASTCALL ConioCoordToPointer(PCONSOLE_SCREEN_BUFFER Buf, ULONG X, ULONG Y);
|
||||
VOID FASTCALL ConioDrawConsole(PCONSOLE Console);
|
||||
NTSTATUS FASTCALL ConioWriteConsole(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff,
|
||||
|
|
|
@ -1228,7 +1228,7 @@ CSR_API(SrvCreateConsoleScreenBuffer)
|
|||
|
||||
RtlEnterCriticalSection(&ProcessData->HandleTableLock);
|
||||
|
||||
Status = ConioConsoleFromProcessData(ProcessData, &Console);
|
||||
Status = ConioLockConsole(ProcessData, &Console);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
|
||||
|
|
|
@ -31,30 +31,6 @@ DtbgIsDesktopVisible(VOID)
|
|||
return VisibleDesktopWindow != NULL;
|
||||
}
|
||||
|
||||
NTSTATUS FASTCALL
|
||||
ConioConsoleFromProcessData(PCONSOLE_PROCESS_DATA ProcessData,
|
||||
PCONSOLE *Console)
|
||||
{
|
||||
PCONSOLE ProcessConsole;
|
||||
|
||||
RtlEnterCriticalSection(&ProcessData->HandleTableLock);
|
||||
ProcessConsole = ProcessData->Console;
|
||||
|
||||
if (!ProcessConsole)
|
||||
{
|
||||
*Console = NULL;
|
||||
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
|
||||
return STATUS_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
InterlockedIncrement(&ProcessConsole->ReferenceCount);
|
||||
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
|
||||
EnterCriticalSection(&(ProcessConsole->Lock));
|
||||
*Console = ProcessConsole;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
VOID FASTCALL
|
||||
ConioConsoleCtrlEventTimeout(DWORD Event,
|
||||
PCONSOLE_PROCESS_DATA ProcessData,
|
||||
|
@ -124,16 +100,19 @@ CsrInitConsole(PCONSOLE* NewConsole, int ShowCmd, PCSR_PROCESS ConsoleLeaderProc
|
|||
|
||||
Console->ReferenceCount = 0;
|
||||
Console->LineBuffer = NULL;
|
||||
Console->Header.Type = CONIO_CONSOLE_MAGIC;
|
||||
Console->Header.Console = Console;
|
||||
Console->Mode = ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT;
|
||||
Console->ConsoleLeaderCID = ConsoleLeaderProcess->ClientId;
|
||||
InitializeListHead(&Console->ProcessList);
|
||||
InitializeListHead(&Console->BufferList);
|
||||
Console->ActiveBuffer = NULL;
|
||||
InitializeListHead(&Console->ReadWaitQueue);
|
||||
|
||||
/* Initialize the input buffer */
|
||||
Console->InputBuffer.Header.Type = CONIO_INPUT_BUFFER_MAGIC;
|
||||
Console->InputBuffer.Header.Console = Console;
|
||||
Console->InputBuffer.Mode = ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT;
|
||||
InitializeListHead(&Console->InputBuffer.ReadWaitQueue);
|
||||
InitializeListHead(&Console->InputBuffer.InputEvents);
|
||||
|
||||
InitializeListHead(&Console->WriteWaitQueue);
|
||||
InitializeListHead(&Console->InputEvents);
|
||||
InitializeListHead(&Console->HistoryBuffers);
|
||||
Console->CodePage = GetOEMCP();
|
||||
Console->OutputCodePage = GetOEMCP();
|
||||
|
@ -142,8 +121,8 @@ CsrInitConsole(PCONSOLE* NewConsole, int ShowCmd, PCSR_PROCESS ConsoleLeaderProc
|
|||
SecurityAttributes.lpSecurityDescriptor = NULL;
|
||||
SecurityAttributes.bInheritHandle = TRUE;
|
||||
|
||||
Console->ActiveEvent = CreateEventW(&SecurityAttributes, TRUE, FALSE, NULL);
|
||||
if (NULL == Console->ActiveEvent)
|
||||
Console->InputBuffer.ActiveEvent = CreateEventW(&SecurityAttributes, TRUE, FALSE, NULL);
|
||||
if (NULL == Console->InputBuffer.ActiveEvent)
|
||||
{
|
||||
RtlFreeUnicodeString(&Console->Title);
|
||||
RtlFreeHeap(ConSrvHeap, 0, Console);
|
||||
|
@ -160,7 +139,7 @@ CsrInitConsole(PCONSOLE* NewConsole, int ShowCmd, PCSR_PROCESS ConsoleLeaderProc
|
|||
{
|
||||
RtlFreeUnicodeString(&Console->Title);
|
||||
DeleteCriticalSection(&Console->Lock);
|
||||
CloseHandle(Console->ActiveEvent);
|
||||
CloseHandle(Console->InputBuffer.ActiveEvent);
|
||||
RtlFreeHeap(ConSrvHeap, 0, Console);
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
@ -168,7 +147,7 @@ CsrInitConsole(PCONSOLE* NewConsole, int ShowCmd, PCSR_PROCESS ConsoleLeaderProc
|
|||
NewBuffer->CursorInfo.bVisible = TRUE;
|
||||
NewBuffer->CursorInfo.dwSize = CSR_DEFAULT_CURSOR_SIZE;
|
||||
/* make console active, and insert into console list */
|
||||
Console->ActiveBuffer = (PCONSOLE_SCREEN_BUFFER) NewBuffer;
|
||||
Console->ActiveBuffer = (PCONSOLE_SCREEN_BUFFER)NewBuffer;
|
||||
|
||||
/*
|
||||
* If we are not in GUI-mode, start the text-mode console. If we fail,
|
||||
|
@ -203,7 +182,7 @@ CsrInitConsole(PCONSOLE* NewConsole, int ShowCmd, PCSR_PROCESS ConsoleLeaderProc
|
|||
RtlFreeHeap(ConSrvHeap,0, NewBuffer);
|
||||
RtlFreeUnicodeString(&Console->Title);
|
||||
DeleteCriticalSection(&Console->Lock);
|
||||
CloseHandle(Console->ActiveEvent);
|
||||
CloseHandle(Console->InputBuffer.ActiveEvent);
|
||||
DPRINT1("GuiInitConsole: failed, Status = 0x%08lx\n", Status);
|
||||
RtlFreeHeap(ConSrvHeap, 0, Console);
|
||||
return Status;
|
||||
|
@ -216,7 +195,7 @@ CsrInitConsole(PCONSOLE* NewConsole, int ShowCmd, PCSR_PROCESS ConsoleLeaderProc
|
|||
ConioCleanupConsole(Console);
|
||||
RtlFreeUnicodeString(&Console->Title);
|
||||
DeleteCriticalSection(&Console->Lock);
|
||||
CloseHandle(Console->ActiveEvent);
|
||||
CloseHandle(Console->InputBuffer.ActiveEvent);
|
||||
RtlFreeHeap(ConSrvHeap, 0, NewBuffer);
|
||||
DPRINT1("CsrInitConsoleScreenBuffer: failed\n");
|
||||
RtlFreeHeap(ConSrvHeap, 0, Console);
|
||||
|
@ -259,9 +238,13 @@ CSR_API(SrvOpenConsole)
|
|||
DPRINT1("SrvOpenConsole - Checkpoint 3\n");
|
||||
|
||||
if (OpenConsoleRequest->HandleType == HANDLE_OUTPUT)
|
||||
{
|
||||
Object = &Console->ActiveBuffer->Header;
|
||||
}
|
||||
else // HANDLE_INPUT
|
||||
Object = &Console->Header;
|
||||
{
|
||||
Object = &Console->InputBuffer.Header;
|
||||
}
|
||||
|
||||
if (((DesiredAccess & GENERIC_READ) && Object->ExclusiveRead != 0) ||
|
||||
((DesiredAccess & GENERIC_WRITE) && Object->ExclusiveWrite != 0) ||
|
||||
|
@ -342,7 +325,7 @@ CSR_API(SrvAllocConsole)
|
|||
|
||||
/* Duplicate the Event */
|
||||
Status = NtDuplicateObject(NtCurrentProcess(),
|
||||
ProcessData->Console->ActiveEvent,
|
||||
ProcessData->Console->InputBuffer.ActiveEvent,
|
||||
ProcessData->Process->ProcessHandle,
|
||||
&ProcessData->ConsoleEvent,
|
||||
EVENT_ALL_ACCESS, 0, 0);
|
||||
|
@ -476,7 +459,7 @@ CSR_API(SrvAttachConsole)
|
|||
|
||||
/* Duplicate the Event */
|
||||
Status = NtDuplicateObject(NtCurrentProcess(),
|
||||
TargetProcessData->Console->ActiveEvent,
|
||||
TargetProcessData->Console->InputBuffer.ActiveEvent,
|
||||
TargetProcessData->Process->ProcessHandle,
|
||||
&TargetProcessData->ConsoleEvent,
|
||||
EVENT_ALL_ACCESS, 0, 0);
|
||||
|
@ -524,11 +507,11 @@ ConioDeleteConsole(PCONSOLE Console)
|
|||
DPRINT("ConioDeleteConsole\n");
|
||||
|
||||
/* Drain input event queue */
|
||||
while (Console->InputEvents.Flink != &Console->InputEvents)
|
||||
while (Console->InputBuffer.InputEvents.Flink != &Console->InputBuffer.InputEvents)
|
||||
{
|
||||
Event = (ConsoleInput *) Console->InputEvents.Flink;
|
||||
Console->InputEvents.Flink = Console->InputEvents.Flink->Flink;
|
||||
Console->InputEvents.Flink->Flink->Blink = &Console->InputEvents;
|
||||
Event = (ConsoleInput *) Console->InputBuffer.InputEvents.Flink;
|
||||
Console->InputBuffer.InputEvents.Flink = Console->InputBuffer.InputEvents.Flink->Flink;
|
||||
Console->InputBuffer.InputEvents.Flink->Flink->Blink = &Console->InputBuffer.InputEvents;
|
||||
RtlFreeHeap(ConSrvHeap, 0, Event);
|
||||
}
|
||||
|
||||
|
@ -544,7 +527,7 @@ ConioDeleteConsole(PCONSOLE Console)
|
|||
DPRINT1("BUG: screen buffer list not empty\n");
|
||||
}
|
||||
|
||||
CloseHandle(Console->ActiveEvent);
|
||||
CloseHandle(Console->InputBuffer.ActiveEvent);
|
||||
if (Console->UnpauseEvent) CloseHandle(Console->UnpauseEvent);
|
||||
DeleteCriticalSection(&Console->Lock);
|
||||
RtlFreeUnicodeString(&Console->Title);
|
||||
|
@ -591,24 +574,25 @@ CSR_API(SrvSetConsoleMode)
|
|||
{
|
||||
NTSTATUS Status;
|
||||
PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleModeRequest;
|
||||
PCONSOLE Console;
|
||||
PCONSOLE_SCREEN_BUFFER Buff;
|
||||
Object_t* Object = NULL;
|
||||
|
||||
DPRINT("SrvSetConsoleMode\n");
|
||||
|
||||
Status = Win32CsrLockObject(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
|
||||
ConsoleModeRequest->ConsoleHandle,
|
||||
(Object_t **) &Console, GENERIC_WRITE, 0);
|
||||
&Object, GENERIC_WRITE, 0);
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
Buff = (PCONSOLE_SCREEN_BUFFER)Console;
|
||||
Status = STATUS_SUCCESS;
|
||||
|
||||
if (CONIO_CONSOLE_MAGIC == Console->Header.Type)
|
||||
if (CONIO_INPUT_BUFFER_MAGIC == Object->Type)
|
||||
{
|
||||
Console->Mode = ConsoleModeRequest->ConsoleMode & CONSOLE_INPUT_MODE_VALID;
|
||||
PCONSOLE Console = (PCONSOLE)Object;
|
||||
Console->InputBuffer.Mode = ConsoleModeRequest->ConsoleMode & CONSOLE_INPUT_MODE_VALID;
|
||||
}
|
||||
else if (CONIO_SCREEN_BUFFER_MAGIC == Console->Header.Type)
|
||||
else if (CONIO_SCREEN_BUFFER_MAGIC == Object->Type)
|
||||
{
|
||||
PCONSOLE_SCREEN_BUFFER Buff = (PCONSOLE_SCREEN_BUFFER)Object;
|
||||
Buff->Mode = ConsoleModeRequest->ConsoleMode & CONSOLE_OUTPUT_MODE_VALID;
|
||||
}
|
||||
else
|
||||
|
@ -616,7 +600,7 @@ CSR_API(SrvSetConsoleMode)
|
|||
Status = STATUS_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
Win32CsrUnlockObject((Object_t *)Console);
|
||||
Win32CsrUnlockObject(Object);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -625,25 +609,25 @@ CSR_API(SrvGetConsoleMode)
|
|||
{
|
||||
NTSTATUS Status;
|
||||
PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleModeRequest;
|
||||
PCONSOLE Console;
|
||||
PCONSOLE_SCREEN_BUFFER Buff;
|
||||
Object_t* Object = NULL;
|
||||
|
||||
DPRINT("SrvGetConsoleMode\n");
|
||||
|
||||
Status = Win32CsrLockObject(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
|
||||
ConsoleModeRequest->ConsoleHandle,
|
||||
(Object_t **) &Console, GENERIC_READ, 0);
|
||||
&Object, GENERIC_READ, 0);
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
Status = STATUS_SUCCESS;
|
||||
Buff = (PCONSOLE_SCREEN_BUFFER) Console;
|
||||
|
||||
if (CONIO_CONSOLE_MAGIC == Console->Header.Type)
|
||||
if (CONIO_INPUT_BUFFER_MAGIC == Object->Type)
|
||||
{
|
||||
ConsoleModeRequest->ConsoleMode = Console->Mode;
|
||||
PCONSOLE Console = (PCONSOLE)Object;
|
||||
ConsoleModeRequest->ConsoleMode = Console->InputBuffer.Mode;
|
||||
}
|
||||
else if (CONIO_SCREEN_BUFFER_MAGIC == Buff->Header.Type)
|
||||
else if (CONIO_SCREEN_BUFFER_MAGIC == Object->Type)
|
||||
{
|
||||
PCONSOLE_SCREEN_BUFFER Buff = (PCONSOLE_SCREEN_BUFFER)Object;
|
||||
ConsoleModeRequest->ConsoleMode = Buff->Mode;
|
||||
}
|
||||
else
|
||||
|
@ -651,7 +635,8 @@ CSR_API(SrvGetConsoleMode)
|
|||
Status = STATUS_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
Win32CsrUnlockObject((Object_t *)Console);
|
||||
Win32CsrUnlockObject(Object);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -673,7 +658,7 @@ CSR_API(SrvSetConsoleTitle)
|
|||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
if(NT_SUCCESS(Status))
|
||||
{
|
||||
Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, TitleRequest->Length);
|
||||
|
@ -723,7 +708,7 @@ CSR_API(SrvGetConsoleTitle)
|
|||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("Can't get console\n");
|
||||
|
@ -783,13 +768,14 @@ CSR_API(SrvGetConsoleHardwareState)
|
|||
{
|
||||
NTSTATUS Status;
|
||||
PCONSOLE_GETSETHWSTATE HardwareStateRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HardwareStateRequest;
|
||||
PCONSOLE_SCREEN_BUFFER Buff;
|
||||
PCONSOLE Console;
|
||||
|
||||
DPRINT("SrvGetConsoleHardwareState\n");
|
||||
|
||||
Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
|
||||
Status = ConioLockScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
|
||||
HardwareStateRequest->OutputHandle,
|
||||
&Console,
|
||||
&Buff,
|
||||
GENERIC_READ);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
|
@ -797,9 +783,10 @@ CSR_API(SrvGetConsoleHardwareState)
|
|||
return Status;
|
||||
}
|
||||
|
||||
Console = Buff->Header.Console;
|
||||
HardwareStateRequest->State = Console->HardwareState;
|
||||
|
||||
ConioUnlockConsole(Console);
|
||||
ConioUnlockScreenBuffer(Buff);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -808,13 +795,14 @@ CSR_API(SrvSetConsoleHardwareState)
|
|||
{
|
||||
NTSTATUS Status;
|
||||
PCONSOLE_GETSETHWSTATE HardwareStateRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HardwareStateRequest;
|
||||
PCONSOLE_SCREEN_BUFFER Buff;
|
||||
PCONSOLE Console;
|
||||
|
||||
DPRINT("SrvSetConsoleHardwareState\n");
|
||||
|
||||
Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
|
||||
Status = ConioLockScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
|
||||
HardwareStateRequest->OutputHandle,
|
||||
&Console,
|
||||
&Buff,
|
||||
GENERIC_READ);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
|
@ -823,9 +811,10 @@ CSR_API(SrvSetConsoleHardwareState)
|
|||
}
|
||||
|
||||
DPRINT("Setting console hardware state.\n");
|
||||
Console = Buff->Header.Console;
|
||||
Status = SetConsoleHardwareState(Console, HardwareStateRequest->State);
|
||||
|
||||
ConioUnlockConsole(Console);
|
||||
ConioUnlockScreenBuffer(Buff);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -838,7 +827,7 @@ CSR_API(SrvGetConsoleWindow)
|
|||
|
||||
DPRINT("SrvGetConsoleWindow\n");
|
||||
|
||||
Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
GetWindowRequest->WindowHandle = Console->hWindow;
|
||||
|
@ -855,7 +844,7 @@ CSR_API(SrvSetConsoleIcon)
|
|||
|
||||
DPRINT("SrvSetConsoleIcon\n");
|
||||
|
||||
Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
Status = (ConioChangeIcon(Console, SetIconRequest->WindowIcon)
|
||||
|
@ -876,7 +865,7 @@ CSR_API(SrvGetConsoleCP)
|
|||
DPRINT("SrvGetConsoleCP, getting %s Code Page\n",
|
||||
ConsoleCPRequest->InputCP ? "Input" : "Output");
|
||||
|
||||
Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
ConsoleCPRequest->CodePage = (ConsoleCPRequest->InputCP ? Console->CodePage
|
||||
|
@ -894,7 +883,7 @@ CSR_API(SrvSetConsoleCP)
|
|||
DPRINT("SrvSetConsoleCP, setting %s Code Page\n",
|
||||
ConsoleCPRequest->InputCP ? "Input" : "Output");
|
||||
|
||||
Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
if (IsValidCodePage(ConsoleCPRequest->CodePage))
|
||||
|
@ -935,7 +924,7 @@ CSR_API(SrvGetConsoleProcessList)
|
|||
|
||||
Buffer = GetProcessListRequest->pProcessIds;
|
||||
|
||||
Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
for (current_entry = Console->ProcessList.Flink;
|
||||
|
@ -964,7 +953,7 @@ CSR_API(SrvGenerateConsoleCtrlEvent)
|
|||
PLIST_ENTRY current_entry;
|
||||
DWORD Group;
|
||||
|
||||
Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
Group = GenerateCtrlEventRequest->ProcessGroup;
|
||||
|
@ -992,7 +981,7 @@ CSR_API(SrvGetConsoleSelectionInfo)
|
|||
PCONSOLE_GETSELECTIONINFO GetSelectionInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetSelectionInfoRequest;
|
||||
PCONSOLE Console;
|
||||
|
||||
Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
memset(&GetSelectionInfoRequest->Info, 0, sizeof(CONSOLE_SELECTION_INFO));
|
||||
|
|
|
@ -39,13 +39,13 @@ extern HANDLE ConSrvHeap;
|
|||
// extern PBASE_STATIC_SERVER_DATA BaseStaticServerData;
|
||||
|
||||
/* Object type magic numbers */
|
||||
#define CONIO_CONSOLE_MAGIC 0x00000001 // --> Input-type handles
|
||||
#define CONIO_INPUT_BUFFER_MAGIC 0x00000001 // --> Input-type handles
|
||||
#define CONIO_SCREEN_BUFFER_MAGIC 0x00000002 // --> Output-type handles
|
||||
|
||||
/* Common things to input/output/console objects */
|
||||
typedef struct Object_tt
|
||||
{
|
||||
LONG Type;
|
||||
ULONG Type;
|
||||
struct _CONSOLE *Console;
|
||||
LONG AccessRead, AccessWrite;
|
||||
LONG ExclusiveRead, ExclusiveWrite;
|
||||
|
@ -157,8 +157,9 @@ NTSTATUS FASTCALL Win32CsrLockObject(PCONSOLE_PROCESS_DATA ProcessData,
|
|||
HANDLE Handle,
|
||||
Object_t **Object,
|
||||
DWORD Access,
|
||||
LONG Type);
|
||||
ULONG Type);
|
||||
VOID FASTCALL Win32CsrUnlockObject(Object_t *Object);
|
||||
VOID FASTCALL Win32CsrUnlockConsole(struct _CONSOLE* Console);
|
||||
NTSTATUS FASTCALL Win32CsrReleaseObject(PCONSOLE_PROCESS_DATA ProcessData,
|
||||
HANDLE Handle);
|
||||
|
||||
|
@ -169,6 +170,8 @@ NTSTATUS FASTCALL Win32CsrAllocateConsole(PCONSOLE_PROCESS_DATA ProcessData,
|
|||
int ShowCmd,
|
||||
PCSR_PROCESS CsrProcess);
|
||||
VOID FASTCALL Win32CsrReleaseConsole(PCONSOLE_PROCESS_DATA ProcessData);
|
||||
NTSTATUS FASTCALL ConioConsoleFromProcessData(PCONSOLE_PROCESS_DATA ProcessData,
|
||||
struct _CONSOLE** Console);
|
||||
|
||||
NTSTATUS NTAPI ConsoleNewProcess(PCSR_PROCESS SourceProcess,
|
||||
PCSR_PROCESS TargetProcess);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* LICENSE: GPL - See COPYING in the top level directory
|
||||
* PROJECT: ReactOS Console Server DLL
|
||||
* FILE: win32ss/user/consrv/handle.c
|
||||
* PURPOSE: Console IO Handle functions
|
||||
* PURPOSE: Console I/O Handles functions
|
||||
* PROGRAMMERS:
|
||||
*/
|
||||
|
||||
|
@ -64,10 +64,9 @@ Win32CsrCloseHandleEntry(PCONSOLE_IO_HANDLE Entry)
|
|||
if (Buffer->ListEntry.Flink != Buffer->ListEntry.Blink)
|
||||
ConioDeleteScreenBuffer(Buffer);
|
||||
}
|
||||
else if (Object->Type == CONIO_CONSOLE_MAGIC)
|
||||
else if (Object->Type == CONIO_INPUT_BUFFER_MAGIC)
|
||||
{
|
||||
/* TODO: FIXME: Destroy here the console ?? */
|
||||
// ConioDeleteConsole(Console);
|
||||
DPRINT1("Closing the input buffer\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,7 +103,7 @@ Win32CsrInitHandlesTable(IN OUT PCONSOLE_PROCESS_DATA ProcessData,
|
|||
/* Insert the Input handle */
|
||||
Status = Win32CsrInsertObject(ProcessData,
|
||||
&InputHandle,
|
||||
&ProcessData->Console->Header,
|
||||
&ProcessData->Console->InputBuffer.Header,
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
TRUE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE);
|
||||
|
@ -243,6 +242,8 @@ Win32CsrInsertObject(PCONSOLE_PROCESS_DATA ProcessData,
|
|||
BOOL Inheritable,
|
||||
DWORD ShareMode)
|
||||
{
|
||||
#define IO_HANDLES_INCREMENT 2*3
|
||||
|
||||
ULONG i;
|
||||
PCONSOLE_IO_HANDLE Block;
|
||||
|
||||
|
@ -259,7 +260,8 @@ Win32CsrInsertObject(PCONSOLE_PROCESS_DATA ProcessData,
|
|||
{
|
||||
Block = RtlAllocateHeap(ConSrvHeap,
|
||||
HEAP_ZERO_MEMORY,
|
||||
(ProcessData->HandleTableSize + 64) * sizeof(CONSOLE_IO_HANDLE));
|
||||
(ProcessData->HandleTableSize +
|
||||
IO_HANDLES_INCREMENT) * sizeof(CONSOLE_IO_HANDLE));
|
||||
if (Block == NULL)
|
||||
{
|
||||
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
|
||||
|
@ -270,8 +272,9 @@ Win32CsrInsertObject(PCONSOLE_PROCESS_DATA ProcessData,
|
|||
ProcessData->HandleTableSize * sizeof(CONSOLE_IO_HANDLE));
|
||||
RtlFreeHeap(ConSrvHeap, 0, ProcessData->HandleTable);
|
||||
ProcessData->HandleTable = Block;
|
||||
ProcessData->HandleTableSize += 64;
|
||||
ProcessData->HandleTableSize += IO_HANDLES_INCREMENT;
|
||||
}
|
||||
|
||||
ProcessData->HandleTable[i].Object = Object;
|
||||
ProcessData->HandleTable[i].Access = Access;
|
||||
ProcessData->HandleTable[i].Inheritable = Inheritable;
|
||||
|
@ -280,6 +283,7 @@ Win32CsrInsertObject(PCONSOLE_PROCESS_DATA ProcessData,
|
|||
*Handle = ULongToHandle((i << 2) | 0x3);
|
||||
|
||||
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -314,12 +318,12 @@ Win32CsrLockObject(PCONSOLE_PROCESS_DATA ProcessData,
|
|||
HANDLE Handle,
|
||||
Object_t **Object,
|
||||
DWORD Access,
|
||||
LONG Type)
|
||||
ULONG Type)
|
||||
{
|
||||
ULONG_PTR h = (ULONG_PTR)Handle >> 2;
|
||||
|
||||
DPRINT("Win32CsrLockObject, Object: %x, %x, %x\n",
|
||||
Object, Handle, ProcessData ? ProcessData->HandleTableSize : 0);
|
||||
// DPRINT("Win32CsrLockObject, Object: %x, %x, %x\n",
|
||||
// Object, Handle, ProcessData ? ProcessData->HandleTableSize : 0);
|
||||
|
||||
RtlEnterCriticalSection(&ProcessData->HandleTableLock);
|
||||
|
||||
|
@ -329,7 +333,7 @@ Win32CsrLockObject(PCONSOLE_PROCESS_DATA ProcessData,
|
|||
~ProcessData->HandleTable[h].Access & Access ||
|
||||
(Type != 0 && (*Object)->Type != Type) )
|
||||
{
|
||||
DPRINT1("CsrGetObject returning invalid handle (%x)\n", Handle);
|
||||
DPRINT1("CsrGetObject returning invalid handle (%x) of type %lu with access %lu\n", Handle, Type, Access);
|
||||
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
|
||||
return STATUS_INVALID_HANDLE;
|
||||
}
|
||||
|
@ -337,7 +341,7 @@ Win32CsrLockObject(PCONSOLE_PROCESS_DATA ProcessData,
|
|||
_InterlockedIncrement(&(*Object)->Console->ReferenceCount);
|
||||
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
|
||||
|
||||
EnterCriticalSection(&((*Object)->Console->Lock));
|
||||
EnterCriticalSection(&(*Object)->Console->Lock);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -421,6 +425,31 @@ Win32CsrReleaseConsole(PCONSOLE_PROCESS_DATA ProcessData)
|
|||
}
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
FASTCALL
|
||||
ConioConsoleFromProcessData(PCONSOLE_PROCESS_DATA ProcessData,
|
||||
PCONSOLE* Console)
|
||||
{
|
||||
PCONSOLE ProcessConsole;
|
||||
|
||||
RtlEnterCriticalSection(&ProcessData->HandleTableLock);
|
||||
ProcessConsole = ProcessData->Console;
|
||||
|
||||
if (!ProcessConsole)
|
||||
{
|
||||
*Console = NULL;
|
||||
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
|
||||
return STATUS_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
InterlockedIncrement(&ProcessConsole->ReferenceCount);
|
||||
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
|
||||
EnterCriticalSection(&(ProcessConsole->Lock));
|
||||
*Console = ProcessConsole;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NTSTATUS
|
||||
|
@ -581,7 +610,7 @@ ConsoleConnect(IN PCSR_PROCESS CsrProcess,
|
|||
/// TODO: Move this up ?
|
||||
/* Duplicate the Event */
|
||||
Status = NtDuplicateObject(NtCurrentProcess(),
|
||||
ProcessData->Console->ActiveEvent,
|
||||
ProcessData->Console->InputBuffer.ActiveEvent,
|
||||
ProcessData->Process->ProcessHandle,
|
||||
&ProcessData->ConsoleEvent,
|
||||
EVENT_ALL_ACCESS, 0, 0);
|
||||
|
|
|
@ -448,6 +448,15 @@ CSR_SERVER_DLL_INIT(ConServerDllInitialization)
|
|||
|
||||
/* Initialize memory */
|
||||
ConSrvHeap = RtlGetProcessHeap(); // Initialize our own heap.
|
||||
/*
|
||||
ConSrvHeap = RtlCreateHeap( HEAP_GROWABLE | HEAP_CLASS_5, // Flags
|
||||
NULL, // HeapBase
|
||||
64 * 1024, // ReserveSize
|
||||
4096, // CommitSize
|
||||
NULL, // Lock to use for serialization
|
||||
NULL // GrowthThreshold
|
||||
);
|
||||
*/
|
||||
// BaseSrvSharedHeap = LoadedServerDll->SharedSection; // Get the CSR shared heap.
|
||||
// LoadedServerDll->SharedSection = BaseStaticServerData;
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ CSR_API(SrvGetConsoleCommandHistoryLength)
|
|||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = ConioConsoleFromProcessData(ProcessData, &Console);
|
||||
Status = ConioLockConsole(ProcessData, &Console);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Hist = HistoryFindBuffer(Console, &GetCommandHistoryLengthRequest->ExeName);
|
||||
|
@ -205,7 +205,7 @@ CSR_API(SrvGetConsoleCommandHistory)
|
|||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = ConioConsoleFromProcessData(ProcessData, &Console);
|
||||
Status = ConioLockConsole(ProcessData, &Console);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Hist = HistoryFindBuffer(Console, &GetCommandHistoryRequest->ExeName);
|
||||
|
@ -246,7 +246,7 @@ CSR_API(SrvExpungeConsoleCommandHistory)
|
|||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = ConioConsoleFromProcessData(ProcessData, &Console);
|
||||
Status = ConioLockConsole(ProcessData, &Console);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Hist = HistoryFindBuffer(Console, &ExpungeCommandHistoryRequest->ExeName);
|
||||
|
@ -274,7 +274,7 @@ CSR_API(SrvSetConsoleNumberOfCommands)
|
|||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = ConioConsoleFromProcessData(ProcessData, &Console);
|
||||
Status = ConioLockConsole(ProcessData, &Console);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Hist = HistoryFindBuffer(Console, &SetHistoryNumberCommandsRequest->ExeName);
|
||||
|
@ -311,7 +311,7 @@ CSR_API(SrvGetConsoleHistory)
|
|||
{
|
||||
PCONSOLE_GETSETHISTORYINFO HistoryInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HistoryInfoRequest;
|
||||
PCONSOLE Console;
|
||||
NTSTATUS Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
NTSTATUS Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
HistoryInfoRequest->HistoryBufferSize = Console->HistoryBufferSize;
|
||||
|
@ -326,7 +326,7 @@ CSR_API(SrvSetConsoleHistory)
|
|||
{
|
||||
PCONSOLE_GETSETHISTORYINFO HistoryInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HistoryInfoRequest;
|
||||
PCONSOLE Console;
|
||||
NTSTATUS Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
NTSTATUS Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Console->HistoryBufferSize = HistoryInfoRequest->HistoryBufferSize;
|
||||
|
@ -340,7 +340,7 @@ CSR_API(SrvSetConsoleHistory)
|
|||
static VOID
|
||||
LineInputSetPos(PCONSOLE Console, UINT Pos)
|
||||
{
|
||||
if (Pos != Console->LinePos && Console->Mode & ENABLE_ECHO_INPUT)
|
||||
if (Pos != Console->LinePos && Console->InputBuffer.Mode & ENABLE_ECHO_INPUT)
|
||||
{
|
||||
PCONSOLE_SCREEN_BUFFER Buffer = Console->ActiveBuffer;
|
||||
UINT OldCursorX = Buffer->CurrentX;
|
||||
|
@ -377,7 +377,7 @@ LineInputEdit(PCONSOLE Console, UINT NumToDelete, UINT NumToInsert, WCHAR *Inser
|
|||
(Console->LineSize - (Pos + NumToDelete)) * sizeof(WCHAR));
|
||||
memcpy(&Console->LineBuffer[Pos], Insertion, NumToInsert * sizeof(WCHAR));
|
||||
|
||||
if (Console->Mode & ENABLE_ECHO_INPUT)
|
||||
if (Console->InputBuffer.Mode & ENABLE_ECHO_INPUT)
|
||||
{
|
||||
for (i = Pos; i < NewSize; i++)
|
||||
{
|
||||
|
@ -559,7 +559,7 @@ LineInputKeyDown(PCONSOLE Console, KEY_EVENT_RECORD *KeyEvent)
|
|||
return;
|
||||
}
|
||||
|
||||
if (KeyEvent->uChar.UnicodeChar == L'\b' && Console->Mode & ENABLE_PROCESSED_INPUT)
|
||||
if (KeyEvent->uChar.UnicodeChar == L'\b' && Console->InputBuffer.Mode & ENABLE_PROCESSED_INPUT)
|
||||
{
|
||||
/* backspace handling - if processed input enabled then we handle it here
|
||||
* otherwise we treat it like a normal char. */
|
||||
|
@ -577,17 +577,17 @@ LineInputKeyDown(PCONSOLE Console, KEY_EVENT_RECORD *KeyEvent)
|
|||
|
||||
LineInputSetPos(Console, Console->LineSize);
|
||||
Console->LineBuffer[Console->LineSize++] = L'\r';
|
||||
if (Console->Mode & ENABLE_ECHO_INPUT)
|
||||
if (Console->InputBuffer.Mode & ENABLE_ECHO_INPUT)
|
||||
ConioWriteConsole(Console, Console->ActiveBuffer, "\r", 1, TRUE);
|
||||
|
||||
/* Add \n if processed input. There should usually be room for it,
|
||||
* but an exception to the rule exists: the buffer could have been
|
||||
* pre-filled with LineMaxSize - 1 characters. */
|
||||
if (Console->Mode & ENABLE_PROCESSED_INPUT &&
|
||||
if (Console->InputBuffer.Mode & ENABLE_PROCESSED_INPUT &&
|
||||
Console->LineSize < Console->LineMaxSize)
|
||||
{
|
||||
Console->LineBuffer[Console->LineSize++] = L'\n';
|
||||
if (Console->Mode & ENABLE_ECHO_INPUT)
|
||||
if (Console->InputBuffer.Mode & ENABLE_ECHO_INPUT)
|
||||
ConioWriteConsole(Console, Console->ActiveBuffer, "\n", 1, TRUE);
|
||||
}
|
||||
Console->LineComplete = TRUE;
|
||||
|
|
Loading…
Reference in a new issue