Author: hbelusca
Date: Sun Aug 31 11:07:09 2014
New Revision: 64004
URL:
http://svn.reactos.org/svn/reactos?rev=64004&view=rev
Log:
[CONSRV][CONDRV]
- Move CSR details (pre/post-processing, unicode translation) of reading/writing console
inputs to consrv, where they belong.
- Add a temporary solution to screenbuffer resizing notifications, to be properly fixed
later on.
Modified:
branches/condrv_restructure/win32ss/user/winsrv/consrv/condrv/coninput.c
branches/condrv_restructure/win32ss/user/winsrv/consrv/condrv/text.c
branches/condrv_restructure/win32ss/user/winsrv/consrv/coninput.c
branches/condrv_restructure/win32ss/user/winsrv/consrv/include/conio.h
branches/condrv_restructure/win32ss/user/winsrv/consrv/include/conio_winsrv.h
Modified: branches/condrv_restructure/win32ss/user/winsrv/consrv/condrv/coninput.c
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/win32ss/user…
==============================================================================
--- branches/condrv_restructure/win32ss/user/winsrv/consrv/condrv/coninput.c [iso-8859-1]
(original)
+++ branches/condrv_restructure/win32ss/user/winsrv/consrv/condrv/coninput.c [iso-8859-1]
Sun Aug 31 11:07:09 2014
@@ -16,20 +16,6 @@
/* GLOBALS ********************************************************************/
-/*
- * 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."
- */
-#define ConsoleInputUnicodeCharToAnsiChar(Console, dChar, sWChar) \
- ASSERT((ULONG_PTR)dChar != (ULONG_PTR)sWChar); \
- WideCharToMultiByte((Console)->InputCodePage, 0, (sWChar), 1, (dChar), 1, NULL,
NULL)
-
-#define ConsoleInputAnsiCharToUnicodeChar(Console, dWChar, sChar) \
- ASSERT((ULONG_PTR)dWChar != (ULONG_PTR)sChar); \
- MultiByteToWideChar((Console)->InputCodePage, 0, (sChar), 1, (dWChar), 1)
-
typedef struct ConsoleInput_t
{
LIST_ENTRY ListEntry;
@@ -39,34 +25,7 @@
/* PRIVATE FUNCTIONS **********************************************************/
-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;
- ConsoleInputUnicodeCharToAnsiChar(Console,
-
&InputEvent->Event.KeyEvent.uChar.AsciiChar,
- &UnicodeChar);
- }
-}
-
-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;
- ConsoleInputAnsiCharToUnicodeChar(Console,
-
&InputEvent->Event.KeyEvent.uChar.UnicodeChar,
- &AsciiChar);
- }
-}
-
-
-NTSTATUS
+static NTSTATUS
ConDrvAddInputEvents(PCONSOLE Console,
PINPUT_RECORD InputRecords, // InputEvent
ULONG NumEventsToWrite,
@@ -218,60 +177,6 @@
return Status;
}
-
-ULONG
-PreprocessInput(PCONSOLE Console,
- PINPUT_RECORD InputEvent,
- ULONG NumEventsToWrite);
-VOID
-PostprocessInput(PCONSOLE Console);
-
-NTSTATUS
-ConioAddInputEvents(PCONSOLE Console,
- PINPUT_RECORD InputRecords, // InputEvent
- ULONG NumEventsToWrite,
- PULONG NumEventsWritten,
- BOOLEAN AppendToEnd)
-{
- NTSTATUS Status = STATUS_SUCCESS;
-
- if (NumEventsWritten) *NumEventsWritten = 0;
-
- /*
- * This pre-processing code MUST be IN consrv ONLY!!
- */
- NumEventsToWrite = PreprocessInput(Console, InputRecords, NumEventsToWrite);
- if (NumEventsToWrite == 0) return STATUS_SUCCESS;
-
- Status = ConDrvAddInputEvents(Console,
- InputRecords,
- NumEventsToWrite,
- NumEventsWritten,
- AppendToEnd);
-
- /*
- * This post-processing code MUST be IN consrv ONLY!!
- */
- // if (NT_SUCCESS(Status))
- if (Status == STATUS_SUCCESS) PostprocessInput(Console);
-
- return Status;
-}
-
-/* Move elsewhere...*/
-NTSTATUS
-ConioProcessInputEvent(PCONSOLE Console,
- PINPUT_RECORD InputEvent)
-{
- ULONG NumEventsWritten;
- return ConioAddInputEvents(Console,
- InputEvent,
- 1,
- &NumEventsWritten,
- TRUE);
-}
-
-
VOID
PurgeInputBuffer(PCONSOLE Console)
{
@@ -329,7 +234,6 @@
IN PCONSOLE_INPUT_BUFFER InputBuffer,
IN BOOLEAN KeepEvents,
IN BOOLEAN WaitForMoreEvents,
- IN BOOLEAN Unicode,
OUT PINPUT_RECORD InputRecord,
IN ULONG NumEventsToRead,
OUT PULONG NumEventsRead OPTIONAL)
@@ -379,15 +283,6 @@
if (NumEventsRead) *NumEventsRead = i;
- /* Now translate everything to ANSI */
- if (!Unicode)
- {
- for (; i > 0; --i)
- {
- ConioInputEventToAnsi(InputBuffer->Header.Console, --InputRecord);
- }
- }
-
if (IsListEmpty(&InputBuffer->InputEvents))
{
ResetEvent(InputBuffer->ActiveEvent);
@@ -400,15 +295,11 @@
NTSTATUS NTAPI
ConDrvWriteConsoleInput(IN PCONSOLE Console,
IN PCONSOLE_INPUT_BUFFER InputBuffer,
- IN BOOLEAN Unicode,
IN BOOLEAN AppendToEnd,
IN PINPUT_RECORD InputRecord,
IN ULONG NumEventsToWrite,
OUT PULONG NumEventsWritten OPTIONAL)
{
- NTSTATUS Status = STATUS_SUCCESS;
- ULONG i;
-
if (Console == NULL || InputBuffer == NULL /* || InputRecord == NULL */)
return STATUS_INVALID_PARAMETER;
@@ -416,26 +307,14 @@
ASSERT(Console == InputBuffer->Header.Console);
ASSERT((InputRecord != NULL) || (InputRecord == NULL && NumEventsToWrite ==
0));
- /* First translate everything to UNICODE */
- if (!Unicode)
- {
- for (i = 0; i < NumEventsToWrite; ++i)
- {
- ConioInputEventToUnicode(Console, &InputRecord[i]);
- }
- }
-
/* Now, add the events */
- // if (NumEventsWritten) *NumEventsWritten = 0;
- // ConDrvAddInputEvents
- Status = ConioAddInputEvents(Console,
- InputRecord,
- NumEventsToWrite,
- NumEventsWritten,
- AppendToEnd);
- // if (NumEventsWritten) *NumEventsWritten = i;
-
- return Status;
+ if (NumEventsWritten) *NumEventsWritten = 0;
+
+ return ConDrvAddInputEvents(Console,
+ InputRecord,
+ NumEventsToWrite,
+ NumEventsWritten,
+ AppendToEnd);
}
NTSTATUS NTAPI
Modified: branches/condrv_restructure/win32ss/user/winsrv/consrv/condrv/text.c
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/win32ss/user…
==============================================================================
--- branches/condrv_restructure/win32ss/user/winsrv/consrv/condrv/text.c [iso-8859-1]
(original)
+++ branches/condrv_restructure/win32ss/user/winsrv/consrv/condrv/text.c [iso-8859-1] Sun
Aug 31 11:07:09 2014
@@ -233,6 +233,15 @@
}
}
+// FIXME!
+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);
+
NTSTATUS
ConioResizeBuffer(PCONSOLE Console,
PTEXTMODE_SCREEN_BUFFER ScreenBuffer,
@@ -341,12 +350,19 @@
*/
if (Console->InputBuffer.Mode & ENABLE_WINDOW_INPUT)
{
+ ULONG NumEventsWritten;
INPUT_RECORD er;
er.EventType = WINDOW_BUFFER_SIZE_EVENT;
er.Event.WindowBufferSizeEvent.dwSize = ScreenBuffer->ScreenBufferSize;
- ConioProcessInputEvent(Console, &er);
+ // ConioProcessInputEvent(Console, &er);
+ ConDrvWriteConsoleInput(Console,
+ &Console->InputBuffer,
+ TRUE,
+ &er,
+ 1,
+ &NumEventsWritten);
}
return STATUS_SUCCESS;
Modified: branches/condrv_restructure/win32ss/user/winsrv/consrv/coninput.c
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/win32ss/user…
==============================================================================
--- branches/condrv_restructure/win32ss/user/winsrv/consrv/coninput.c [iso-8859-1]
(original)
+++ branches/condrv_restructure/win32ss/user/winsrv/consrv/coninput.c [iso-8859-1] Sun Aug
31 11:07:09 2014
@@ -26,6 +26,25 @@
ConSrvReleaseObject(&(Buff)->Header, (IsConsoleLocked))
+
+
+/*
+ * 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."
+ */
+#define ConsoleInputUnicodeCharToAnsiChar(Console, dChar, sWChar) \
+ ASSERT((ULONG_PTR)dChar != (ULONG_PTR)sWChar); \
+ WideCharToMultiByte((Console)->InputCodePage, 0, (sWChar), 1, (dChar), 1, NULL,
NULL)
+
+#define ConsoleInputAnsiCharToUnicodeChar(Console, dWChar, sChar) \
+ ASSERT((ULONG_PTR)dWChar != (ULONG_PTR)sChar); \
+ MultiByteToWideChar((Console)->InputCodePage, 0, (sChar), 1, (dWChar), 1)
+
+
+
+
typedef struct _GET_INPUT_INFO
{
PCSR_THREAD CallingThread; // The thread which called the input API.
@@ -36,10 +55,33 @@
/* PRIVATE FUNCTIONS **********************************************************/
-/*
- * This pre-processing code MUST be IN consrv ONLY
- */
-/* static */ ULONG
+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;
+ ConsoleInputUnicodeCharToAnsiChar(Console,
+
&InputEvent->Event.KeyEvent.uChar.AsciiChar,
+ &UnicodeChar);
+ }
+}
+
+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;
+ ConsoleInputAnsiCharToUnicodeChar(Console,
+
&InputEvent->Event.KeyEvent.uChar.UnicodeChar,
+ &AsciiChar);
+ }
+}
+
+static ULONG
PreprocessInput(PCONSRV_CONSOLE Console,
PINPUT_RECORD InputEvent,
ULONG NumEventsToWrite)
@@ -98,10 +140,7 @@
return NumEventsToWrite;
}
-/*
- * This post-processing code MUST be IN consrv ONLY
- */
-/* static */ VOID
+static VOID
PostprocessInput(PCONSRV_CONSOLE Console)
{
CsrNotifyWait(&Console->ReadWaitQueue,
@@ -115,7 +154,58 @@
}
-
+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
+ConioAddInputEvents(PCONSOLE Console,
+ 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);
+
+ Status = ConDrvWriteConsoleInput(Console,
+ &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
+ConioProcessInputEvent(PCONSOLE Console,
+ PINPUT_RECORD InputEvent)
+{
+ ULONG NumEventsWritten;
+ return ConioAddInputEvents(Console,
+ InputEvent,
+ 1,
+ &NumEventsWritten,
+ TRUE);
+}
static NTSTATUS
@@ -381,7 +471,6 @@
IN PCONSOLE_INPUT_BUFFER InputBuffer,
IN BOOLEAN KeepEvents,
IN BOOLEAN WaitForMoreEvents,
- IN BOOLEAN Unicode,
OUT PINPUT_RECORD InputRecord,
IN ULONG NumEventsToRead,
OUT PULONG NumEventsRead OPTIONAL);
@@ -422,7 +511,6 @@
InputBuffer,
(GetInputRequest->Flags &
CONSOLE_READ_KEEPEVENT) != 0,
(GetInputRequest->Flags & CONSOLE_READ_CONTINUE
) == 0,
- GetInputRequest->Unicode,
InputRecord,
GetInputRequest->NumRecords,
&NumEventsRead);
@@ -442,6 +530,18 @@
* return the error code we were given.
*/
GetInputRequest->NumRecords = NumEventsRead;
+
+ if (NT_SUCCESS(Status))
+ {
+ /* Now translate everything to ANSI */
+ if (!GetInputRequest->Unicode)
+ {
+ for (; NumEventsRead > 0; --NumEventsRead)
+ {
+ ConioInputEventToAnsi(InputBuffer->Header.Console,
--InputRecord);
+ }
+ }
+ }
return Status;
// return STATUS_SUCCESS;
@@ -563,14 +663,15 @@
return Status;
}
+#if 0
NTSTATUS NTAPI
ConDrvWriteConsoleInput(IN PCONSOLE Console,
IN PCONSOLE_INPUT_BUFFER InputBuffer,
- IN BOOLEAN Unicode,
IN BOOLEAN AppendToEnd,
IN PINPUT_RECORD InputRecord,
IN ULONG NumEventsToWrite,
OUT PULONG NumEventsWritten OPTIONAL);
+#endif
CSR_API(SrvWriteConsoleInput)
{
NTSTATUS Status;
@@ -619,14 +720,32 @@
return Status;
}
+ /* 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 */
NumEventsWritten = 0;
- Status = ConDrvWriteConsoleInput(InputBuffer->Header.Console,
- InputBuffer,
- WriteInputRequest->Unicode,
- WriteInputRequest->AppendToEnd,
- InputRecord,
- WriteInputRequest->NumRecords,
- &NumEventsWritten);
+ Status = ConioAddInputEvents(InputBuffer->Header.Console,
+ // InputBuffer,
+ InputRecord,
+ WriteInputRequest->NumRecords,
+ &NumEventsWritten,
+ WriteInputRequest->AppendToEnd);
+
+ // Status = ConDrvWriteConsoleInput(InputBuffer->Header.Console,
+ // InputBuffer,
+ // WriteInputRequest->AppendToEnd,
+ // InputRecord,
+ // WriteInputRequest->NumRecords,
+ // &NumEventsWritten);
+
WriteInputRequest->NumRecords = NumEventsWritten;
ConSrvReleaseInputBuffer(InputBuffer, TRUE);
Modified: branches/condrv_restructure/win32ss/user/winsrv/consrv/include/conio.h
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/win32ss/user…
==============================================================================
--- branches/condrv_restructure/win32ss/user/winsrv/consrv/include/conio.h [iso-8859-1]
(original)
+++ branches/condrv_restructure/win32ss/user/winsrv/consrv/include/conio.h [iso-8859-1]
Sun Aug 31 11:07:09 2014
@@ -326,17 +326,6 @@
ConSrvConsoleCtrlEvent(IN ULONG CtrlEvent,
IN PCONSOLE_PROCESS_DATA ProcessData);
-/* coninput.c */
-NTSTATUS
-ConioAddInputEvents(PCONSOLE Console,
- PINPUT_RECORD InputRecords,
- ULONG NumEventsToWrite,
- PULONG NumEventsWritten,
- BOOLEAN AppendToEnd);
-NTSTATUS
-ConioProcessInputEvent(PCONSOLE Console,
- PINPUT_RECORD InputEvent);
-
/* conoutput.c */
/*
Modified: branches/condrv_restructure/win32ss/user/winsrv/consrv/include/conio_winsrv.h
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/win32ss/user…
==============================================================================
---
branches/condrv_restructure/win32ss/user/winsrv/consrv/include/conio_winsrv.h [iso-8859-1]
(original)
+++
branches/condrv_restructure/win32ss/user/winsrv/consrv/include/conio_winsrv.h [iso-8859-1]
Sun Aug 31 11:07:09 2014
@@ -193,12 +193,6 @@
DWORD Scale);
NTSTATUS
-ConioAddInputEvents(PCONSRV_CONSOLE Console,
- PINPUT_RECORD InputRecords,
- ULONG NumEventsToWrite,
- PULONG NumEventsWritten,
- BOOLEAN AppendToEnd);
-NTSTATUS
ConioProcessInputEvent(PCONSRV_CONSOLE Console,
PINPUT_RECORD InputEvent);