2010-05-31 06:28:55 +00:00
|
|
|
/*
|
2012-10-25 20:40:41 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS Console Server DLL
|
2015-10-05 12:21:25 +00:00
|
|
|
* FILE: win32ss/user/winsrv/consrv/coninput.c
|
2013-04-07 23:18:59 +00:00
|
|
|
* PURPOSE: Console Input functions
|
2013-04-10 20:22:30 +00:00
|
|
|
* PROGRAMMERS: Jeffrey Morlan
|
|
|
|
* Hermes Belusca-Maito (hermes.belusca@sfr.fr)
|
2010-05-31 06:28:55 +00:00
|
|
|
*/
|
|
|
|
|
2012-11-17 15:41:31 +00:00
|
|
|
/* INCLUDES *******************************************************************/
|
2010-05-31 06:28:55 +00:00
|
|
|
|
2012-10-23 22:31:36 +00:00
|
|
|
#include "consrv.h"
|
|
|
|
|
2010-05-31 06:28:55 +00:00
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
2012-11-17 15:41:31 +00:00
|
|
|
/* GLOBALS ********************************************************************/
|
2010-05-31 06:28:55 +00:00
|
|
|
|
2013-04-07 23:18:59 +00:00
|
|
|
#define ConSrvGetInputBuffer(ProcessData, Handle, Ptr, Access, LockConsole) \
|
|
|
|
ConSrvGetObject((ProcessData), (Handle), (PCONSOLE_IO_OBJECT*)(Ptr), NULL, \
|
|
|
|
(Access), (LockConsole), INPUT_BUFFER)
|
2020-02-08 23:24:21 +00:00
|
|
|
|
2013-04-07 23:18:59 +00:00
|
|
|
#define ConSrvGetInputBufferAndHandleEntry(ProcessData, Handle, Ptr, Entry, Access, LockConsole) \
|
|
|
|
ConSrvGetObject((ProcessData), (Handle), (PCONSOLE_IO_OBJECT*)(Ptr), (Entry), \
|
|
|
|
(Access), (LockConsole), INPUT_BUFFER)
|
2020-02-08 23:24:21 +00:00
|
|
|
|
2013-04-07 23:18:59 +00:00
|
|
|
#define ConSrvReleaseInputBuffer(Buff, IsConsoleLocked) \
|
|
|
|
ConSrvReleaseObject(&(Buff)->Header, (IsConsoleLocked))
|
|
|
|
|
|
|
|
|
2014-08-31 11:07:09 +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-08-31 11:24:23 +00:00
|
|
|
#define ConsoleInputUnicodeToAnsiChar(Console, dChar, sWChar) \
|
2020-02-08 23:24:21 +00:00
|
|
|
do { \
|
|
|
|
ASSERT((ULONG_PTR)(dChar) != (ULONG_PTR)(sWChar)); \
|
|
|
|
WideCharToMultiByte((Console)->InputCodePage, 0, (sWChar), 1, (dChar), 1, NULL, NULL); \
|
|
|
|
} while (0)
|
2014-08-31 11:07:09 +00:00
|
|
|
|
2014-08-31 11:24:23 +00:00
|
|
|
#define ConsoleInputAnsiToUnicodeChar(Console, dWChar, sChar) \
|
2020-02-08 23:24:21 +00:00
|
|
|
do { \
|
|
|
|
ASSERT((ULONG_PTR)(dWChar) != (ULONG_PTR)(sChar)); \
|
|
|
|
MultiByteToWideChar((Console)->InputCodePage, 0, (sChar), 1, (dWChar), 1); \
|
|
|
|
} while (0)
|
2014-08-31 11:07:09 +00:00
|
|
|
|
|
|
|
|
2012-12-08 00:39:24 +00:00
|
|
|
typedef struct _GET_INPUT_INFO
|
|
|
|
{
|
2013-01-24 20:48:42 +00:00
|
|
|
PCSR_THREAD CallingThread; // The thread which called the input API.
|
2013-04-07 23:18:59 +00:00
|
|
|
PVOID HandleEntry; // The handle data associated with the wait thread.
|
2013-01-24 20:48:42 +00:00
|
|
|
PCONSOLE_INPUT_BUFFER InputBuffer; // The input buffer corresponding to the handle.
|
2012-12-08 00:39:24 +00:00
|
|
|
} GET_INPUT_INFO, *PGET_INPUT_INFO;
|
|
|
|
|
|
|
|
|
2012-11-17 15:41:31 +00:00
|
|
|
/* PRIVATE FUNCTIONS **********************************************************/
|
2010-05-31 06:28:55 +00:00
|
|
|
|
2014-08-31 11:07:09 +00:00
|
|
|
static VOID
|
|
|
|
ConioInputEventToAnsi(PCONSOLE Console, PINPUT_RECORD InputEvent)
|
|
|
|
{
|
|
|
|
if (InputEvent->EventType == KEY_EVENT)
|
|
|
|
{
|
|
|
|
WCHAR UnicodeChar = InputEvent->Event.KeyEvent.uChar.UnicodeChar;
|
|
|
|
InputEvent->Event.KeyEvent.uChar.UnicodeChar = 0;
|
2014-08-31 11:24:23 +00:00
|
|
|
ConsoleInputUnicodeToAnsiChar(Console,
|
|
|
|
&InputEvent->Event.KeyEvent.uChar.AsciiChar,
|
|
|
|
&UnicodeChar);
|
2014-08-31 11:07:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static VOID
|
|
|
|
ConioInputEventToUnicode(PCONSOLE Console, PINPUT_RECORD InputEvent)
|
|
|
|
{
|
|
|
|
if (InputEvent->EventType == KEY_EVENT)
|
|
|
|
{
|
|
|
|
CHAR AsciiChar = InputEvent->Event.KeyEvent.uChar.AsciiChar;
|
|
|
|
InputEvent->Event.KeyEvent.uChar.AsciiChar = 0;
|
2014-08-31 11:24:23 +00:00
|
|
|
ConsoleInputAnsiToUnicodeChar(Console,
|
|
|
|
&InputEvent->Event.KeyEvent.uChar.UnicodeChar,
|
|
|
|
&AsciiChar);
|
2014-08-31 11:07:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG
|
2014-08-11 20:39:06 +00:00
|
|
|
PreprocessInput(PCONSRV_CONSOLE Console,
|
2014-08-04 20:23:33 +00:00
|
|
|
PINPUT_RECORD InputEvent,
|
|
|
|
ULONG NumEventsToWrite)
|
|
|
|
{
|
|
|
|
ULONG NumEvents;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Loop each event, and for each, check for pause or unpause
|
|
|
|
* and perform adequate behaviour.
|
|
|
|
*/
|
|
|
|
for (NumEvents = NumEventsToWrite; NumEvents > 0; --NumEvents)
|
|
|
|
{
|
|
|
|
/* Check for pause or unpause */
|
|
|
|
if (InputEvent->EventType == KEY_EVENT && InputEvent->Event.KeyEvent.bKeyDown)
|
|
|
|
{
|
|
|
|
WORD vk = InputEvent->Event.KeyEvent.wVirtualKeyCode;
|
|
|
|
if (!(Console->PauseFlags & PAUSED_FROM_KEYBOARD))
|
|
|
|
{
|
|
|
|
DWORD cks = InputEvent->Event.KeyEvent.dwControlKeyState;
|
|
|
|
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)))))
|
|
|
|
{
|
|
|
|
ConioPause(Console, PAUSED_FROM_KEYBOARD);
|
|
|
|
|
|
|
|
/* Skip the event */
|
|
|
|
RtlMoveMemory(InputEvent,
|
|
|
|
InputEvent + 1,
|
|
|
|
(NumEvents - 1) * sizeof(INPUT_RECORD));
|
|
|
|
--NumEventsToWrite;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((vk < VK_SHIFT || vk > VK_CAPITAL) && vk != VK_LWIN &&
|
|
|
|
vk != VK_RWIN && vk != VK_NUMLOCK && vk != VK_SCROLL)
|
|
|
|
{
|
|
|
|
ConioUnpause(Console, PAUSED_FROM_KEYBOARD);
|
|
|
|
|
|
|
|
/* Skip the event */
|
|
|
|
RtlMoveMemory(InputEvent,
|
|
|
|
InputEvent + 1,
|
|
|
|
(NumEvents - 1) * sizeof(INPUT_RECORD));
|
|
|
|
--NumEventsToWrite;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Go to the next event */
|
|
|
|
++InputEvent;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NumEventsToWrite;
|
|
|
|
}
|
|
|
|
|
2014-08-31 11:07:09 +00:00
|
|
|
static VOID
|
2014-08-11 20:39:06 +00:00
|
|
|
PostprocessInput(PCONSRV_CONSOLE Console)
|
2014-08-04 20:23:33 +00:00
|
|
|
{
|
|
|
|
CsrNotifyWait(&Console->ReadWaitQueue,
|
|
|
|
FALSE,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
if (!IsListEmpty(&Console->ReadWaitQueue))
|
|
|
|
{
|
|
|
|
CsrDereferenceWait(&Console->ReadWaitQueue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-31 11:07:09 +00:00
|
|
|
NTSTATUS NTAPI
|
|
|
|
ConDrvWriteConsoleInput(IN PCONSOLE Console,
|
|
|
|
IN PCONSOLE_INPUT_BUFFER InputBuffer,
|
|
|
|
IN BOOLEAN AppendToEnd,
|
|
|
|
IN PINPUT_RECORD InputRecord,
|
|
|
|
IN ULONG NumEventsToWrite,
|
|
|
|
OUT PULONG NumEventsWritten OPTIONAL);
|
|
|
|
static NTSTATUS
|
2014-08-31 14:04:03 +00:00
|
|
|
ConioAddInputEvents(PCONSRV_CONSOLE Console,
|
2014-08-31 11:07:09 +00:00
|
|
|
PINPUT_RECORD InputRecords, // InputEvent
|
|
|
|
ULONG NumEventsToWrite,
|
|
|
|
PULONG NumEventsWritten,
|
|
|
|
BOOLEAN AppendToEnd)
|
|
|
|
{
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
|
|
|
|
if (NumEventsWritten) *NumEventsWritten = 0;
|
|
|
|
|
|
|
|
NumEventsToWrite = PreprocessInput(Console, InputRecords, NumEventsToWrite);
|
|
|
|
if (NumEventsToWrite == 0) return STATUS_SUCCESS;
|
|
|
|
|
|
|
|
// Status = ConDrvAddInputEvents(Console,
|
|
|
|
// InputRecords,
|
|
|
|
// NumEventsToWrite,
|
|
|
|
// NumEventsWritten,
|
|
|
|
// AppendToEnd);
|
2014-08-04 20:23:33 +00:00
|
|
|
|
2014-08-31 14:04:03 +00:00
|
|
|
Status = ConDrvWriteConsoleInput((PCONSOLE)Console,
|
2014-08-31 11:07:09 +00:00
|
|
|
&Console->InputBuffer,
|
|
|
|
AppendToEnd,
|
|
|
|
InputRecords,
|
|
|
|
NumEventsToWrite,
|
|
|
|
NumEventsWritten);
|
|
|
|
|
|
|
|
// if (NT_SUCCESS(Status))
|
|
|
|
if (Status == STATUS_SUCCESS) PostprocessInput(Console);
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: This function can be called by CONDRV, in ConioResizeBuffer() in text.c */
|
|
|
|
NTSTATUS
|
2014-08-31 14:04:03 +00:00
|
|
|
ConioProcessInputEvent(PCONSRV_CONSOLE Console,
|
2014-08-31 11:07:09 +00:00
|
|
|
PINPUT_RECORD InputEvent)
|
|
|
|
{
|
|
|
|
ULONG NumEventsWritten;
|
|
|
|
return ConioAddInputEvents(Console,
|
|
|
|
InputEvent,
|
|
|
|
1,
|
|
|
|
&NumEventsWritten,
|
|
|
|
TRUE);
|
|
|
|
}
|
2014-08-04 20:23:33 +00:00
|
|
|
|
|
|
|
|
2012-12-08 00:39:24 +00:00
|
|
|
static NTSTATUS
|
|
|
|
WaitBeforeReading(IN PGET_INPUT_INFO InputInfo,
|
|
|
|
IN PCSR_API_MESSAGE ApiMessage,
|
|
|
|
IN CSR_WAIT_FUNCTION WaitFunction OPTIONAL,
|
2013-11-10 20:20:57 +00:00
|
|
|
IN BOOLEAN CreateWaitBlock OPTIONAL)
|
2012-12-08 00:39:24 +00:00
|
|
|
{
|
|
|
|
if (CreateWaitBlock)
|
|
|
|
{
|
|
|
|
PGET_INPUT_INFO CapturedInputInfo;
|
2014-08-31 14:04:03 +00:00
|
|
|
PCONSRV_CONSOLE Console = (PCONSRV_CONSOLE)InputInfo->InputBuffer->Header.Console;
|
2012-11-17 15:41:31 +00:00
|
|
|
|
2013-05-12 00:20:15 +00:00
|
|
|
CapturedInputInfo = ConsoleAllocHeap(0, sizeof(GET_INPUT_INFO));
|
2012-12-08 00:39:24 +00:00
|
|
|
if (!CapturedInputInfo) return STATUS_NO_MEMORY;
|
2012-11-17 15:41:31 +00:00
|
|
|
|
2013-01-24 20:48:42 +00:00
|
|
|
RtlMoveMemory(CapturedInputInfo, InputInfo, sizeof(GET_INPUT_INFO));
|
2012-11-17 21:39:41 +00:00
|
|
|
|
2014-08-31 14:04:03 +00:00
|
|
|
if (!CsrCreateWait(&Console->ReadWaitQueue,
|
2012-12-08 00:39:24 +00:00
|
|
|
WaitFunction,
|
2013-01-24 20:48:42 +00:00
|
|
|
InputInfo->CallingThread,
|
2012-12-08 00:39:24 +00:00
|
|
|
ApiMessage,
|
2013-09-12 21:05:58 +00:00
|
|
|
CapturedInputInfo))
|
2012-12-08 00:39:24 +00:00
|
|
|
{
|
2013-05-12 00:20:15 +00:00
|
|
|
ConsoleFreeHeap(CapturedInputInfo);
|
2012-12-08 00:39:24 +00:00
|
|
|
return STATUS_NO_MEMORY;
|
|
|
|
}
|
|
|
|
}
|
2012-11-17 15:41:31 +00:00
|
|
|
|
2012-12-08 00:39:24 +00:00
|
|
|
/* Wait for input */
|
|
|
|
return STATUS_PENDING;
|
|
|
|
}
|
2012-11-17 15:41:31 +00:00
|
|
|
|
2012-12-08 00:39:24 +00:00
|
|
|
static NTSTATUS
|
2013-06-27 00:20:58 +00:00
|
|
|
ReadChars(IN PGET_INPUT_INFO InputInfo,
|
|
|
|
IN PCSR_API_MESSAGE ApiMessage,
|
2013-11-10 20:20:57 +00:00
|
|
|
IN BOOLEAN CreateWaitBlock OPTIONAL);
|
2012-12-08 00:39:24 +00:00
|
|
|
|
|
|
|
// Wait function CSR_WAIT_FUNCTION
|
|
|
|
static BOOLEAN
|
2013-10-05 23:34:25 +00:00
|
|
|
NTAPI
|
2013-06-27 00:20:58 +00:00
|
|
|
ReadCharsThread(IN PLIST_ENTRY WaitList,
|
|
|
|
IN PCSR_THREAD WaitThread,
|
|
|
|
IN PCSR_API_MESSAGE WaitApiMessage,
|
|
|
|
IN PVOID WaitContext,
|
|
|
|
IN PVOID WaitArgument1,
|
|
|
|
IN PVOID WaitArgument2,
|
|
|
|
IN ULONG WaitFlags)
|
2012-12-08 00:39:24 +00:00
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
PGET_INPUT_INFO InputInfo = (PGET_INPUT_INFO)WaitContext;
|
2012-11-17 21:39:41 +00:00
|
|
|
|
2013-04-07 23:18:59 +00:00
|
|
|
PVOID InputHandle = WaitArgument2;
|
2013-01-24 20:48:42 +00:00
|
|
|
|
2013-06-27 00:20:58 +00:00
|
|
|
DPRINT("ReadCharsThread - WaitContext = 0x%p, WaitArgument1 = 0x%p, WaitArgument2 = 0x%p, WaitFlags = %lu\n", WaitContext, WaitArgument1, WaitArgument2, WaitFlags);
|
2013-01-24 20:48:42 +00:00
|
|
|
|
|
|
|
/*
|
2013-01-26 16:12:05 +00:00
|
|
|
* If we are notified of the process termination via a call
|
|
|
|
* to CsrNotifyWaitBlock triggered by CsrDestroyProcess or
|
|
|
|
* CsrDestroyThread, just return.
|
2013-01-24 20:48:42 +00:00
|
|
|
*/
|
2013-01-26 16:12:05 +00:00
|
|
|
if (WaitFlags & CsrProcessTerminating)
|
2013-01-24 20:48:42 +00:00
|
|
|
{
|
2013-01-26 16:12:05 +00:00
|
|
|
Status = STATUS_THREAD_IS_TERMINATING;
|
2013-01-24 20:48:42 +00:00
|
|
|
goto Quit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2013-01-26 16:12:05 +00:00
|
|
|
* Somebody is closing a handle to this input buffer,
|
|
|
|
* by calling ConSrvCloseHandleEntry.
|
|
|
|
* See whether we are linked to that handle (ie. we
|
|
|
|
* are a waiter for this handle), and if so, return.
|
|
|
|
* Otherwise, ignore the call and continue waiting.
|
2013-01-24 20:48:42 +00:00
|
|
|
*/
|
2013-01-26 16:12:05 +00:00
|
|
|
if (InputHandle != NULL)
|
2013-01-24 20:48:42 +00:00
|
|
|
{
|
2013-01-26 16:12:05 +00:00
|
|
|
Status = (InputHandle == InputInfo->HandleEntry ? STATUS_ALERTED
|
|
|
|
: STATUS_PENDING);
|
2013-01-24 20:48:42 +00:00
|
|
|
goto Quit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we go there, that means we are notified for some new input.
|
|
|
|
* The console is therefore already locked.
|
|
|
|
*/
|
2013-11-10 20:20:57 +00:00
|
|
|
Status = ReadChars(InputInfo, WaitApiMessage, FALSE);
|
2012-12-08 00:39:24 +00:00
|
|
|
|
2013-01-24 20:48:42 +00:00
|
|
|
Quit:
|
2012-12-08 00:39:24 +00:00
|
|
|
if (Status != STATUS_PENDING)
|
2012-11-17 15:41:31 +00:00
|
|
|
{
|
2012-12-08 00:39:24 +00:00
|
|
|
WaitApiMessage->Status = Status;
|
2013-05-12 00:20:15 +00:00
|
|
|
ConsoleFreeHeap(InputInfo);
|
2012-11-17 15:41:31 +00:00
|
|
|
}
|
|
|
|
|
2012-12-08 00:39:24 +00:00
|
|
|
return (Status == STATUS_PENDING ? FALSE : TRUE);
|
|
|
|
}
|
2012-11-17 15:41:31 +00:00
|
|
|
|
2013-06-27 00:20:58 +00:00
|
|
|
NTSTATUS NTAPI
|
|
|
|
ConDrvReadConsole(IN PCONSOLE Console,
|
|
|
|
IN PCONSOLE_INPUT_BUFFER InputBuffer,
|
|
|
|
IN BOOLEAN Unicode,
|
|
|
|
OUT PVOID Buffer,
|
|
|
|
IN OUT PCONSOLE_READCONSOLE_CONTROL ReadControl,
|
2014-12-14 16:53:47 +00:00
|
|
|
IN PVOID Parameter OPTIONAL,
|
2013-06-27 00:20:58 +00:00
|
|
|
IN ULONG NumCharsToRead,
|
|
|
|
OUT PULONG NumCharsRead OPTIONAL);
|
2012-12-08 00:39:24 +00:00
|
|
|
static NTSTATUS
|
2013-06-27 00:20:58 +00:00
|
|
|
ReadChars(IN PGET_INPUT_INFO InputInfo,
|
|
|
|
IN PCSR_API_MESSAGE ApiMessage,
|
2013-11-10 20:20:57 +00:00
|
|
|
IN BOOLEAN CreateWaitBlock OPTIONAL)
|
2012-12-08 00:39:24 +00:00
|
|
|
{
|
2013-06-27 00:20:58 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
PCONSOLE_READCONSOLE ReadConsoleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadConsoleRequest;
|
2013-01-24 20:48:42 +00:00
|
|
|
PCONSOLE_INPUT_BUFFER InputBuffer = InputInfo->InputBuffer;
|
2013-06-27 00:20:58 +00:00
|
|
|
CONSOLE_READCONSOLE_CONTROL ReadControl;
|
2013-01-24 20:48:42 +00:00
|
|
|
|
[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
|
|
|
UNICODE_STRING ExeName;
|
|
|
|
|
|
|
|
PVOID Buffer;
|
|
|
|
ULONG NrCharactersRead = 0;
|
|
|
|
ULONG CharSize = (ReadConsoleRequest->Unicode ? sizeof(WCHAR) : sizeof(CHAR));
|
|
|
|
|
2014-12-14 16:53:47 +00:00
|
|
|
/* Retrieve the executable name, if needed */
|
[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
|
|
|
if (ReadConsoleRequest->InitialNumBytes == 0 &&
|
|
|
|
ReadConsoleRequest->ExeLength <= sizeof(ReadConsoleRequest->StaticBuffer))
|
|
|
|
{
|
|
|
|
ExeName.Length = ExeName.MaximumLength = ReadConsoleRequest->ExeLength;
|
|
|
|
ExeName.Buffer = (PWCHAR)ReadConsoleRequest->StaticBuffer;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ExeName.Length = ExeName.MaximumLength = 0;
|
|
|
|
ExeName.Buffer = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Build the ReadControl structure */
|
2013-06-27 00:20:58 +00:00
|
|
|
ReadControl.nLength = sizeof(CONSOLE_READCONSOLE_CONTROL);
|
[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
|
|
|
ReadControl.nInitialChars = ReadConsoleRequest->InitialNumBytes / CharSize;
|
2013-06-27 00:20:58 +00:00
|
|
|
ReadControl.dwCtrlWakeupMask = ReadConsoleRequest->CtrlWakeupMask;
|
|
|
|
ReadControl.dwControlKeyState = ReadConsoleRequest->ControlKeyState;
|
|
|
|
|
[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
|
|
|
/*
|
|
|
|
* For optimization purposes, Windows (and hence ReactOS, too, for
|
|
|
|
* compatibility reasons) uses a static buffer if no more than eighty
|
|
|
|
* bytes are read. Otherwise a new buffer is used.
|
|
|
|
* The client-side expects that we know this behaviour.
|
|
|
|
*/
|
|
|
|
if (ReadConsoleRequest->CaptureBufferSize <= sizeof(ReadConsoleRequest->StaticBuffer))
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Adjust the internal pointer, because its old value points to
|
|
|
|
* the static buffer in the original ApiMessage structure.
|
|
|
|
*/
|
|
|
|
// ReadConsoleRequest->Buffer = ReadConsoleRequest->StaticBuffer;
|
|
|
|
Buffer = ReadConsoleRequest->StaticBuffer;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Buffer = ReadConsoleRequest->Buffer;
|
|
|
|
}
|
|
|
|
|
2014-11-08 22:19:07 +00:00
|
|
|
DPRINT("Calling ConDrvReadConsole(%wZ)\n", &ExeName);
|
2013-06-27 00:20:58 +00:00
|
|
|
Status = ConDrvReadConsole(InputBuffer->Header.Console,
|
|
|
|
InputBuffer,
|
|
|
|
ReadConsoleRequest->Unicode,
|
[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
|
|
|
Buffer,
|
2013-06-27 00:20:58 +00:00
|
|
|
&ReadControl,
|
2014-12-14 16:53:47 +00:00
|
|
|
&ExeName,
|
[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
|
|
|
ReadConsoleRequest->NumBytes / CharSize, // NrCharactersToRead
|
|
|
|
&NrCharactersRead);
|
2014-11-08 22:19:07 +00:00
|
|
|
DPRINT("ConDrvReadConsole returned (%d ; Status = 0x%08x)\n",
|
[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
|
|
|
NrCharactersRead, Status);
|
2013-06-27 00:20:58 +00:00
|
|
|
|
[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
|
|
|
// ReadConsoleRequest->ControlKeyState = ReadControl.dwControlKeyState;
|
2013-06-27 00:20:58 +00:00
|
|
|
|
|
|
|
if (Status == STATUS_PENDING)
|
2012-11-17 15:41:31 +00:00
|
|
|
{
|
2013-06-27 00:20:58 +00:00
|
|
|
/* We haven't completed a read, so start a wait */
|
|
|
|
return WaitBeforeReading(InputInfo,
|
|
|
|
ApiMessage,
|
|
|
|
ReadCharsThread,
|
|
|
|
CreateWaitBlock);
|
2012-11-17 15:41:31 +00:00
|
|
|
}
|
2012-12-08 00:39:24 +00:00
|
|
|
else
|
2012-11-17 15:41:31 +00:00
|
|
|
{
|
[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
|
|
|
/*
|
|
|
|
* We read all what we wanted. Set the number of bytes read and
|
|
|
|
* return the error code we were given.
|
|
|
|
*/
|
|
|
|
ReadConsoleRequest->NumBytes = NrCharactersRead * CharSize;
|
|
|
|
ReadConsoleRequest->ControlKeyState = ReadControl.dwControlKeyState;
|
|
|
|
|
2013-06-27 00:20:58 +00:00
|
|
|
return Status;
|
|
|
|
// return STATUS_SUCCESS;
|
2012-12-08 00:39:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static NTSTATUS
|
2013-06-27 00:20:58 +00:00
|
|
|
ReadInputBuffer(IN PGET_INPUT_INFO InputInfo,
|
|
|
|
IN PCSR_API_MESSAGE ApiMessage,
|
2013-11-10 20:20:57 +00:00
|
|
|
IN BOOLEAN CreateWaitBlock OPTIONAL);
|
2012-12-08 00:39:24 +00:00
|
|
|
|
|
|
|
// Wait function CSR_WAIT_FUNCTION
|
|
|
|
static BOOLEAN
|
2013-10-05 23:34:25 +00:00
|
|
|
NTAPI
|
2013-06-27 00:20:58 +00:00
|
|
|
ReadInputBufferThread(IN PLIST_ENTRY WaitList,
|
|
|
|
IN PCSR_THREAD WaitThread,
|
|
|
|
IN PCSR_API_MESSAGE WaitApiMessage,
|
|
|
|
IN PVOID WaitContext,
|
|
|
|
IN PVOID WaitArgument1,
|
|
|
|
IN PVOID WaitArgument2,
|
|
|
|
IN ULONG WaitFlags)
|
2012-12-08 00:39:24 +00:00
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
PGET_INPUT_INFO InputInfo = (PGET_INPUT_INFO)WaitContext;
|
|
|
|
|
2013-04-07 23:18:59 +00:00
|
|
|
PVOID InputHandle = WaitArgument2;
|
2013-01-24 20:48:42 +00:00
|
|
|
|
2013-06-27 00:20:58 +00:00
|
|
|
DPRINT("ReadInputBufferThread - WaitContext = 0x%p, WaitArgument1 = 0x%p, WaitArgument2 = 0x%p, WaitFlags = %lu\n", WaitContext, WaitArgument1, WaitArgument2, WaitFlags);
|
2013-01-24 20:48:42 +00:00
|
|
|
|
|
|
|
/*
|
2013-01-26 16:12:05 +00:00
|
|
|
* If we are notified of the process termination via a call
|
|
|
|
* to CsrNotifyWaitBlock triggered by CsrDestroyProcess or
|
|
|
|
* CsrDestroyThread, just return.
|
2013-01-24 20:48:42 +00:00
|
|
|
*/
|
2013-01-26 16:12:05 +00:00
|
|
|
if (WaitFlags & CsrProcessTerminating)
|
2013-01-24 20:48:42 +00:00
|
|
|
{
|
2013-01-26 16:12:05 +00:00
|
|
|
Status = STATUS_THREAD_IS_TERMINATING;
|
2013-01-24 20:48:42 +00:00
|
|
|
goto Quit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2013-01-26 16:12:05 +00:00
|
|
|
* Somebody is closing a handle to this input buffer,
|
|
|
|
* by calling ConSrvCloseHandleEntry.
|
|
|
|
* See whether we are linked to that handle (ie. we
|
|
|
|
* are a waiter for this handle), and if so, return.
|
|
|
|
* Otherwise, ignore the call and continue waiting.
|
2013-01-24 20:48:42 +00:00
|
|
|
*/
|
2013-01-26 16:12:05 +00:00
|
|
|
if (InputHandle != NULL)
|
2013-01-24 20:48:42 +00:00
|
|
|
{
|
2013-01-26 16:12:05 +00:00
|
|
|
Status = (InputHandle == InputInfo->HandleEntry ? STATUS_ALERTED
|
|
|
|
: STATUS_PENDING);
|
2013-01-24 20:48:42 +00:00
|
|
|
goto Quit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we go there, that means we are notified for some new input.
|
|
|
|
* The console is therefore already locked.
|
|
|
|
*/
|
2013-11-10 20:20:57 +00:00
|
|
|
Status = ReadInputBuffer(InputInfo, WaitApiMessage, FALSE);
|
2012-12-08 00:39:24 +00:00
|
|
|
|
2013-01-24 20:48:42 +00:00
|
|
|
Quit:
|
2012-12-08 00:39:24 +00:00
|
|
|
if (Status != STATUS_PENDING)
|
|
|
|
{
|
|
|
|
WaitApiMessage->Status = Status;
|
2013-05-12 00:20:15 +00:00
|
|
|
ConsoleFreeHeap(InputInfo);
|
2012-12-08 00:39:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (Status == STATUS_PENDING ? FALSE : TRUE);
|
|
|
|
}
|
|
|
|
|
2013-06-27 00:20:58 +00:00
|
|
|
NTSTATUS NTAPI
|
|
|
|
ConDrvGetConsoleInput(IN PCONSOLE Console,
|
|
|
|
IN PCONSOLE_INPUT_BUFFER InputBuffer,
|
2013-11-10 20:20:57 +00:00
|
|
|
IN BOOLEAN KeepEvents,
|
2013-06-27 00:20:58 +00:00
|
|
|
IN BOOLEAN WaitForMoreEvents,
|
|
|
|
OUT PINPUT_RECORD InputRecord,
|
|
|
|
IN ULONG NumEventsToRead,
|
2013-11-10 20:20:57 +00:00
|
|
|
OUT PULONG NumEventsRead OPTIONAL);
|
2012-12-08 00:39:24 +00:00
|
|
|
static NTSTATUS
|
2013-06-27 00:20:58 +00:00
|
|
|
ReadInputBuffer(IN PGET_INPUT_INFO InputInfo,
|
|
|
|
IN PCSR_API_MESSAGE ApiMessage,
|
2013-11-10 20:20:57 +00:00
|
|
|
IN BOOLEAN CreateWaitBlock OPTIONAL)
|
2012-12-08 00:39:24 +00:00
|
|
|
{
|
2013-06-27 00:20:58 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
PCONSOLE_GETINPUT GetInputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetInputRequest;
|
2013-01-24 20:48:42 +00:00
|
|
|
PCONSOLE_INPUT_BUFFER InputBuffer = InputInfo->InputBuffer;
|
2014-07-28 21:20:36 +00:00
|
|
|
ULONG NumEventsRead;
|
2012-12-08 00:39:24 +00:00
|
|
|
|
2014-07-28 21:20:36 +00:00
|
|
|
PINPUT_RECORD InputRecord;
|
2012-12-08 00:39:24 +00:00
|
|
|
|
2014-07-28 21:20:36 +00:00
|
|
|
/*
|
|
|
|
* For optimization purposes, Windows (and hence ReactOS, too, for
|
|
|
|
* compatibility reasons) uses a static buffer if no more than five
|
|
|
|
* input records are read. Otherwise a new buffer is used.
|
|
|
|
* The client-side expects that we know this behaviour.
|
|
|
|
*/
|
|
|
|
if (GetInputRequest->NumRecords <= sizeof(GetInputRequest->RecordStaticBuffer)/sizeof(INPUT_RECORD))
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Adjust the internal pointer, because its old value points to
|
|
|
|
* the static buffer in the original ApiMessage structure.
|
|
|
|
*/
|
|
|
|
// GetInputRequest->RecordBufPtr = GetInputRequest->RecordStaticBuffer;
|
|
|
|
InputRecord = GetInputRequest->RecordStaticBuffer;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
InputRecord = GetInputRequest->RecordBufPtr;
|
|
|
|
}
|
|
|
|
|
|
|
|
NumEventsRead = 0;
|
2013-06-27 00:20:58 +00:00
|
|
|
Status = ConDrvGetConsoleInput(InputBuffer->Header.Console,
|
|
|
|
InputBuffer,
|
2014-07-28 21:20:36 +00:00
|
|
|
(GetInputRequest->Flags & CONSOLE_READ_KEEPEVENT) != 0,
|
|
|
|
(GetInputRequest->Flags & CONSOLE_READ_CONTINUE ) == 0,
|
|
|
|
InputRecord,
|
|
|
|
GetInputRequest->NumRecords,
|
|
|
|
&NumEventsRead);
|
2012-11-17 21:39:41 +00:00
|
|
|
|
2013-06-27 00:20:58 +00:00
|
|
|
if (Status == STATUS_PENDING)
|
2012-12-08 00:39:24 +00:00
|
|
|
{
|
2013-06-27 00:20:58 +00:00
|
|
|
/* We haven't completed a read, so start a wait */
|
2012-12-08 00:39:24 +00:00
|
|
|
return WaitBeforeReading(InputInfo,
|
|
|
|
ApiMessage,
|
2013-06-27 00:20:58 +00:00
|
|
|
ReadInputBufferThread,
|
2012-12-08 00:39:24 +00:00
|
|
|
CreateWaitBlock);
|
|
|
|
}
|
2013-06-27 00:20:58 +00:00
|
|
|
else
|
2012-12-08 00:39:24 +00:00
|
|
|
{
|
[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
|
|
|
/*
|
|
|
|
* We read all what we wanted. Set the number of events read and
|
|
|
|
* return the error code we were given.
|
|
|
|
*/
|
2014-07-28 21:20:36 +00:00
|
|
|
GetInputRequest->NumRecords = NumEventsRead;
|
[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
|
|
|
|
2014-08-31 11:07:09 +00:00
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* Now translate everything to ANSI */
|
|
|
|
if (!GetInputRequest->Unicode)
|
|
|
|
{
|
|
|
|
for (; NumEventsRead > 0; --NumEventsRead)
|
|
|
|
{
|
|
|
|
ConioInputEventToAnsi(InputBuffer->Header.Console, --InputRecord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-27 00:20:58 +00:00
|
|
|
return Status;
|
|
|
|
// return STATUS_SUCCESS;
|
2012-12-08 00:39:24 +00:00
|
|
|
}
|
|
|
|
}
|
2012-11-17 21:39:41 +00:00
|
|
|
|
|
|
|
|
2013-03-19 22:05:38 +00:00
|
|
|
/* PUBLIC SERVER APIS *********************************************************/
|
2012-12-08 00:39:24 +00:00
|
|
|
|
2019-12-31 00:21:42 +00:00
|
|
|
/* API_NUMBER: ConsolepReadConsole */
|
2013-01-24 20:48:42 +00:00
|
|
|
CSR_API(SrvReadConsole)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
PCONSOLE_READCONSOLE ReadConsoleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadConsoleRequest;
|
|
|
|
PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process);
|
2013-04-07 23:18:59 +00:00
|
|
|
PVOID HandleEntry;
|
2013-01-24 20:48:42 +00:00
|
|
|
PCONSOLE_INPUT_BUFFER InputBuffer;
|
|
|
|
GET_INPUT_INFO InputInfo;
|
|
|
|
|
|
|
|
DPRINT("SrvReadConsole\n");
|
|
|
|
|
[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
|
|
|
/*
|
|
|
|
* For optimization purposes, Windows (and hence ReactOS, too, for
|
|
|
|
* compatibility reasons) uses a static buffer if no more than eighty
|
|
|
|
* bytes are read. Otherwise a new buffer is used.
|
|
|
|
* The client-side expects that we know this behaviour.
|
|
|
|
*/
|
|
|
|
if (ReadConsoleRequest->CaptureBufferSize <= sizeof(ReadConsoleRequest->StaticBuffer))
|
2013-01-24 20:48:42 +00:00
|
|
|
{
|
[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
|
|
|
/*
|
|
|
|
* Adjust the internal pointer, because its old value points to
|
|
|
|
* the static buffer in the original ApiMessage structure.
|
|
|
|
*/
|
|
|
|
// ReadConsoleRequest->Buffer = ReadConsoleRequest->StaticBuffer;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!CsrValidateMessageBuffer(ApiMessage,
|
|
|
|
(PVOID*)&ReadConsoleRequest->Buffer,
|
|
|
|
ReadConsoleRequest->CaptureBufferSize,
|
|
|
|
sizeof(BYTE)))
|
|
|
|
{
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
}
|
2013-01-24 20:48:42 +00:00
|
|
|
}
|
|
|
|
|
[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
|
|
|
if (ReadConsoleRequest->InitialNumBytes > ReadConsoleRequest->NumBytes)
|
2013-01-24 20:48:42 +00:00
|
|
|
{
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2013-01-24 22:41:33 +00:00
|
|
|
Status = ConSrvGetInputBufferAndHandleEntry(ProcessData, ReadConsoleRequest->InputHandle, &InputBuffer, &HandleEntry, GENERIC_READ, TRUE);
|
2013-01-24 20:48:42 +00:00
|
|
|
if (!NT_SUCCESS(Status)) return Status;
|
|
|
|
|
|
|
|
InputInfo.CallingThread = CsrGetClientThread();
|
|
|
|
InputInfo.HandleEntry = HandleEntry;
|
|
|
|
InputInfo.InputBuffer = InputBuffer;
|
|
|
|
|
2013-11-10 20:20:57 +00:00
|
|
|
Status = ReadChars(&InputInfo, ApiMessage, TRUE);
|
2013-01-24 20:48:42 +00:00
|
|
|
|
2013-01-24 22:41:33 +00:00
|
|
|
ConSrvReleaseInputBuffer(InputBuffer, TRUE);
|
2013-01-24 20:48:42 +00:00
|
|
|
|
2013-06-27 00:20:58 +00:00
|
|
|
if (Status == STATUS_PENDING) *ReplyCode = CsrReplyPending;
|
2013-01-24 20:48:42 +00:00
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2019-12-31 00:21:42 +00:00
|
|
|
/* API_NUMBER: ConsolepGetConsoleInput */
|
2012-12-08 00:39:24 +00:00
|
|
|
CSR_API(SrvGetConsoleInput)
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
2013-01-05 23:10:12 +00:00
|
|
|
PCONSOLE_GETINPUT GetInputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetInputRequest;
|
2012-12-08 00:39:24 +00:00
|
|
|
PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process);
|
2013-04-07 23:18:59 +00:00
|
|
|
PVOID HandleEntry;
|
2013-01-18 22:31:16 +00:00
|
|
|
PCONSOLE_INPUT_BUFFER InputBuffer;
|
2012-12-08 00:39:24 +00:00
|
|
|
GET_INPUT_INFO InputInfo;
|
|
|
|
|
|
|
|
DPRINT("SrvGetConsoleInput\n");
|
|
|
|
|
2014-07-28 21:20:36 +00:00
|
|
|
if (GetInputRequest->Flags & ~(CONSOLE_READ_KEEPEVENT | CONSOLE_READ_CONTINUE))
|
2013-11-10 20:20:57 +00:00
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
2014-07-28 21:20:36 +00:00
|
|
|
/*
|
|
|
|
* For optimization purposes, Windows (and hence ReactOS, too, for
|
|
|
|
* compatibility reasons) uses a static buffer if no more than five
|
|
|
|
* input records are read. Otherwise a new buffer is used.
|
|
|
|
* The client-side expects that we know this behaviour.
|
|
|
|
*/
|
|
|
|
if (GetInputRequest->NumRecords <= sizeof(GetInputRequest->RecordStaticBuffer)/sizeof(INPUT_RECORD))
|
2012-12-08 00:39:24 +00:00
|
|
|
{
|
2014-07-28 21:20:36 +00:00
|
|
|
/*
|
|
|
|
* Adjust the internal pointer, because its old value points to
|
|
|
|
* the static buffer in the original ApiMessage structure.
|
|
|
|
*/
|
2014-07-29 00:00:21 +00:00
|
|
|
// GetInputRequest->RecordBufPtr = GetInputRequest->RecordStaticBuffer;
|
2014-07-28 21:20:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!CsrValidateMessageBuffer(ApiMessage,
|
|
|
|
(PVOID*)&GetInputRequest->RecordBufPtr,
|
|
|
|
GetInputRequest->NumRecords,
|
|
|
|
sizeof(INPUT_RECORD)))
|
|
|
|
{
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
}
|
2012-11-17 15:41:31 +00:00
|
|
|
}
|
|
|
|
|
2013-01-24 22:41:33 +00:00
|
|
|
Status = ConSrvGetInputBufferAndHandleEntry(ProcessData, GetInputRequest->InputHandle, &InputBuffer, &HandleEntry, GENERIC_READ, TRUE);
|
2013-04-11 23:37:09 +00:00
|
|
|
if (!NT_SUCCESS(Status)) return Status;
|
2013-01-22 23:28:51 +00:00
|
|
|
|
2013-01-24 20:48:42 +00:00
|
|
|
InputInfo.CallingThread = CsrGetClientThread();
|
|
|
|
InputInfo.HandleEntry = HandleEntry;
|
|
|
|
InputInfo.InputBuffer = InputBuffer;
|
2012-12-08 00:39:24 +00:00
|
|
|
|
2013-11-10 20:20:57 +00:00
|
|
|
Status = ReadInputBuffer(&InputInfo, ApiMessage, TRUE);
|
2012-12-08 00:39:24 +00:00
|
|
|
|
2013-01-24 22:41:33 +00:00
|
|
|
ConSrvReleaseInputBuffer(InputBuffer, TRUE);
|
2012-11-17 15:41:31 +00:00
|
|
|
|
2013-06-27 00:20:58 +00:00
|
|
|
if (Status == STATUS_PENDING) *ReplyCode = CsrReplyPending;
|
2012-12-08 00:39:24 +00:00
|
|
|
|
2012-11-17 21:39:41 +00:00
|
|
|
return Status;
|
2012-11-17 15:41:31 +00:00
|
|
|
}
|
|
|
|
|
2014-08-31 11:07:09 +00:00
|
|
|
#if 0
|
2013-06-23 23:19:42 +00:00
|
|
|
NTSTATUS NTAPI
|
|
|
|
ConDrvWriteConsoleInput(IN PCONSOLE Console,
|
|
|
|
IN PCONSOLE_INPUT_BUFFER InputBuffer,
|
2013-10-26 20:53:05 +00:00
|
|
|
IN BOOLEAN AppendToEnd,
|
2013-06-23 23:19:42 +00:00
|
|
|
IN PINPUT_RECORD InputRecord,
|
|
|
|
IN ULONG NumEventsToWrite,
|
2013-06-27 00:20:58 +00:00
|
|
|
OUT PULONG NumEventsWritten OPTIONAL);
|
2014-08-31 11:07:09 +00:00
|
|
|
#endif
|
2019-12-31 00:21:42 +00:00
|
|
|
|
|
|
|
/* API_NUMBER: ConsolepWriteConsoleInput */
|
2012-11-17 15:41:31 +00:00
|
|
|
CSR_API(SrvWriteConsoleInput)
|
|
|
|
{
|
2012-11-17 21:39:41 +00:00
|
|
|
NTSTATUS Status;
|
2013-01-05 23:10:12 +00:00
|
|
|
PCONSOLE_WRITEINPUT WriteInputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.WriteInputRequest;
|
2013-01-18 22:31:16 +00:00
|
|
|
PCONSOLE_INPUT_BUFFER InputBuffer;
|
2013-06-27 00:20:58 +00:00
|
|
|
ULONG NumEventsWritten;
|
2012-11-17 15:41:31 +00:00
|
|
|
|
2014-07-28 21:20:36 +00:00
|
|
|
PINPUT_RECORD InputRecord;
|
|
|
|
|
2012-11-17 15:41:31 +00:00
|
|
|
DPRINT("SrvWriteConsoleInput\n");
|
|
|
|
|
2014-07-28 21:20:36 +00:00
|
|
|
/*
|
|
|
|
* For optimization purposes, Windows (and hence ReactOS, too, for
|
|
|
|
* compatibility reasons) uses a static buffer if no more than five
|
|
|
|
* input records are written. Otherwise a new buffer is used.
|
|
|
|
* The client-side expects that we know this behaviour.
|
|
|
|
*/
|
|
|
|
if (WriteInputRequest->NumRecords <= sizeof(WriteInputRequest->RecordStaticBuffer)/sizeof(INPUT_RECORD))
|
2012-11-17 15:41:31 +00:00
|
|
|
{
|
2014-07-28 21:20:36 +00:00
|
|
|
/*
|
|
|
|
* Adjust the internal pointer, because its old value points to
|
|
|
|
* the static buffer in the original ApiMessage structure.
|
|
|
|
*/
|
|
|
|
// WriteInputRequest->RecordBufPtr = WriteInputRequest->RecordStaticBuffer;
|
|
|
|
InputRecord = WriteInputRequest->RecordStaticBuffer;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!CsrValidateMessageBuffer(ApiMessage,
|
|
|
|
(PVOID*)&WriteInputRequest->RecordBufPtr,
|
|
|
|
WriteInputRequest->NumRecords,
|
|
|
|
sizeof(INPUT_RECORD)))
|
|
|
|
{
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
InputRecord = WriteInputRequest->RecordBufPtr;
|
2012-11-17 15:41:31 +00:00
|
|
|
}
|
|
|
|
|
2013-06-23 23:19:42 +00:00
|
|
|
Status = ConSrvGetInputBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
|
|
|
|
WriteInputRequest->InputHandle,
|
|
|
|
&InputBuffer, GENERIC_WRITE, TRUE);
|
[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
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
WriteInputRequest->NumRecords = 0;
|
|
|
|
return Status;
|
|
|
|
}
|
2012-11-18 13:54:32 +00:00
|
|
|
|
2014-08-31 11:07:09 +00:00
|
|
|
/* First translate everything to UNICODE */
|
|
|
|
if (!WriteInputRequest->Unicode)
|
|
|
|
{
|
|
|
|
ULONG i;
|
|
|
|
for (i = 0; i < WriteInputRequest->NumRecords; ++i)
|
|
|
|
{
|
|
|
|
ConioInputEventToUnicode(InputBuffer->Header.Console, &InputRecord[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now, add the events */
|
2013-06-27 00:20:58 +00:00
|
|
|
NumEventsWritten = 0;
|
2014-08-31 14:04:03 +00:00
|
|
|
Status = ConioAddInputEvents((PCONSRV_CONSOLE)InputBuffer->Header.Console,
|
2014-08-31 11:07:09 +00:00
|
|
|
// InputBuffer,
|
|
|
|
InputRecord,
|
|
|
|
WriteInputRequest->NumRecords,
|
|
|
|
&NumEventsWritten,
|
|
|
|
WriteInputRequest->AppendToEnd);
|
|
|
|
|
|
|
|
// Status = ConDrvWriteConsoleInput(InputBuffer->Header.Console,
|
|
|
|
// InputBuffer,
|
|
|
|
// WriteInputRequest->AppendToEnd,
|
|
|
|
// InputRecord,
|
|
|
|
// WriteInputRequest->NumRecords,
|
|
|
|
// &NumEventsWritten);
|
|
|
|
|
2014-07-28 21:20:36 +00:00
|
|
|
WriteInputRequest->NumRecords = NumEventsWritten;
|
2012-11-17 15:41:31 +00:00
|
|
|
|
2013-01-24 22:41:33 +00:00
|
|
|
ConSrvReleaseInputBuffer(InputBuffer, TRUE);
|
2012-11-17 15:41:31 +00:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2013-06-23 23:19:42 +00:00
|
|
|
NTSTATUS NTAPI
|
|
|
|
ConDrvFlushConsoleInputBuffer(IN PCONSOLE Console,
|
|
|
|
IN PCONSOLE_INPUT_BUFFER InputBuffer);
|
2019-12-31 00:21:42 +00:00
|
|
|
/* API_NUMBER: ConsolepFlushInputBuffer */
|
2012-10-22 23:55:51 +00:00
|
|
|
CSR_API(SrvFlushConsoleInputBuffer)
|
2010-05-31 06:28:55 +00:00
|
|
|
{
|
2012-11-17 21:39:41 +00:00
|
|
|
NTSTATUS Status;
|
2013-01-05 23:10:12 +00:00
|
|
|
PCONSOLE_FLUSHINPUTBUFFER FlushInputBufferRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.FlushInputBufferRequest;
|
2013-01-18 22:31:16 +00:00
|
|
|
PCONSOLE_INPUT_BUFFER InputBuffer;
|
2010-05-31 06:28:55 +00:00
|
|
|
|
2012-10-22 23:55:51 +00:00
|
|
|
DPRINT("SrvFlushConsoleInputBuffer\n");
|
2010-05-31 06:28:55 +00:00
|
|
|
|
2013-01-24 22:41:33 +00:00
|
|
|
Status = ConSrvGetInputBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
|
2013-06-23 23:19:42 +00:00
|
|
|
FlushInputBufferRequest->InputHandle,
|
|
|
|
&InputBuffer, GENERIC_WRITE, TRUE);
|
2013-04-11 23:37:09 +00:00
|
|
|
if (!NT_SUCCESS(Status)) return Status;
|
2010-05-31 06:28:55 +00:00
|
|
|
|
2013-06-23 23:19:42 +00:00
|
|
|
Status = ConDrvFlushConsoleInputBuffer(InputBuffer->Header.Console,
|
|
|
|
InputBuffer);
|
2010-05-31 06:28:55 +00:00
|
|
|
|
2013-01-24 22:41:33 +00:00
|
|
|
ConSrvReleaseInputBuffer(InputBuffer, TRUE);
|
2013-06-23 23:19:42 +00:00
|
|
|
return Status;
|
2010-05-31 06:28:55 +00:00
|
|
|
}
|
|
|
|
|
2013-06-23 23:19:42 +00:00
|
|
|
NTSTATUS NTAPI
|
|
|
|
ConDrvGetConsoleNumberOfInputEvents(IN PCONSOLE Console,
|
|
|
|
IN PCONSOLE_INPUT_BUFFER InputBuffer,
|
2014-04-20 11:25:38 +00:00
|
|
|
OUT PULONG NumberOfEvents);
|
2019-12-31 00:21:42 +00:00
|
|
|
/* API_NUMBER: ConsolepGetNumberOfInputEvents */
|
2012-10-22 23:55:51 +00:00
|
|
|
CSR_API(SrvGetConsoleNumberOfInputEvents)
|
2010-05-31 06:28:55 +00:00
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
2013-01-05 23:10:12 +00:00
|
|
|
PCONSOLE_GETNUMINPUTEVENTS GetNumInputEventsRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetNumInputEventsRequest;
|
2013-01-18 22:31:16 +00:00
|
|
|
PCONSOLE_INPUT_BUFFER InputBuffer;
|
2010-05-31 06:28:55 +00:00
|
|
|
|
2012-10-22 23:55:51 +00:00
|
|
|
DPRINT("SrvGetConsoleNumberOfInputEvents\n");
|
2010-05-31 06:28:55 +00:00
|
|
|
|
2013-06-23 23:19:42 +00:00
|
|
|
Status = ConSrvGetInputBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
|
|
|
|
GetNumInputEventsRequest->InputHandle,
|
|
|
|
&InputBuffer, GENERIC_READ, TRUE);
|
2012-11-17 21:39:41 +00:00
|
|
|
if (!NT_SUCCESS(Status)) return Status;
|
2010-05-31 06:28:55 +00:00
|
|
|
|
2013-06-23 23:19:42 +00:00
|
|
|
Status = ConDrvGetConsoleNumberOfInputEvents(InputBuffer->Header.Console,
|
|
|
|
InputBuffer,
|
2014-04-20 11:25:38 +00:00
|
|
|
&GetNumInputEventsRequest->NumberOfEvents);
|
2010-05-31 06:28:55 +00:00
|
|
|
|
2013-01-24 22:41:33 +00:00
|
|
|
ConSrvReleaseInputBuffer(InputBuffer, TRUE);
|
2013-06-23 23:19:42 +00:00
|
|
|
return Status;
|
2010-05-31 06:28:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|