[KERNEL32][CONSRV]
[reactos.git] / reactos / win32ss / user / winsrv / consrv / coninput.c
index bf1982d..ee383d7 100644 (file)
@@ -45,7 +45,7 @@ static NTSTATUS
 WaitBeforeReading(IN PGET_INPUT_INFO InputInfo,
                   IN PCSR_API_MESSAGE ApiMessage,
                   IN CSR_WAIT_FUNCTION WaitFunction OPTIONAL,
-                  IN BOOL CreateWaitBlock OPTIONAL)
+                  IN BOOLEAN CreateWaitBlock OPTIONAL)
 {
     if (CreateWaitBlock)
     {
@@ -74,7 +74,7 @@ WaitBeforeReading(IN PGET_INPUT_INFO InputInfo,
 static NTSTATUS
 ReadChars(IN PGET_INPUT_INFO InputInfo,
           IN PCSR_API_MESSAGE ApiMessage,
-          IN BOOL CreateWaitBlock OPTIONAL);
+          IN BOOLEAN CreateWaitBlock OPTIONAL);
 
 // Wait function CSR_WAIT_FUNCTION
 static BOOLEAN
@@ -123,9 +123,7 @@ ReadCharsThread(IN PLIST_ENTRY WaitList,
      * If we go there, that means we are notified for some new input.
      * The console is therefore already locked.
      */
-    Status = ReadChars(InputInfo,
-                       WaitApiMessage,
-                       FALSE);
+    Status = ReadChars(InputInfo, WaitApiMessage, FALSE);
 
 Quit:
     if (Status != STATUS_PENDING)
@@ -148,7 +146,7 @@ ConDrvReadConsole(IN PCONSOLE Console,
 static NTSTATUS
 ReadChars(IN PGET_INPUT_INFO InputInfo,
           IN PCSR_API_MESSAGE ApiMessage,
-          IN BOOL CreateWaitBlock OPTIONAL)
+          IN BOOLEAN CreateWaitBlock OPTIONAL)
 {
     NTSTATUS Status;
     PCONSOLE_READCONSOLE ReadConsoleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadConsoleRequest;
@@ -188,9 +186,8 @@ ReadChars(IN PGET_INPUT_INFO InputInfo,
 
 static NTSTATUS
 ReadInputBuffer(IN PGET_INPUT_INFO InputInfo,
-                IN BOOL Wait,
                 IN PCSR_API_MESSAGE ApiMessage,
-                IN BOOL CreateWaitBlock OPTIONAL);
+                IN BOOLEAN CreateWaitBlock OPTIONAL);
 
 // Wait function CSR_WAIT_FUNCTION
 static BOOLEAN
@@ -204,7 +201,6 @@ ReadInputBufferThread(IN PLIST_ENTRY WaitList,
                       IN ULONG WaitFlags)
 {
     NTSTATUS Status;
-    PCONSOLE_GETINPUT GetInputRequest = &((PCONSOLE_API_MESSAGE)WaitApiMessage)->Data.GetInputRequest;
     PGET_INPUT_INFO InputInfo = (PGET_INPUT_INFO)WaitContext;
 
     PVOID InputHandle = WaitArgument2;
@@ -240,10 +236,7 @@ ReadInputBufferThread(IN PLIST_ENTRY WaitList,
      * If we go there, that means we are notified for some new input.
      * The console is therefore already locked.
      */
-    Status = ReadInputBuffer(InputInfo,
-                             GetInputRequest->bRead,
-                             WaitApiMessage,
-                             FALSE);
+    Status = ReadInputBuffer(InputInfo, WaitApiMessage, FALSE);
 
 Quit:
     if (Status != STATUS_PENDING)
@@ -258,16 +251,16 @@ Quit:
 NTSTATUS NTAPI
 ConDrvGetConsoleInput(IN PCONSOLE Console,
                       IN PCONSOLE_INPUT_BUFFER InputBuffer,
+                      IN BOOLEAN KeepEvents,
                       IN BOOLEAN WaitForMoreEvents,
                       IN BOOLEAN Unicode,
                       OUT PINPUT_RECORD InputRecord,
                       IN ULONG NumEventsToRead,
-                      OUT PULONG NumEventsRead);
+                      OUT PULONG NumEventsRead OPTIONAL);
 static NTSTATUS
 ReadInputBuffer(IN PGET_INPUT_INFO InputInfo,
-                IN BOOL Wait,   // TRUE --> Read ; FALSE --> Peek
                 IN PCSR_API_MESSAGE ApiMessage,
-                IN BOOL CreateWaitBlock OPTIONAL)
+                IN BOOLEAN CreateWaitBlock OPTIONAL)
 {
     NTSTATUS Status;
     PCONSOLE_GETINPUT GetInputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetInputRequest;
@@ -277,7 +270,8 @@ ReadInputBuffer(IN PGET_INPUT_INFO InputInfo,
 
     Status = ConDrvGetConsoleInput(InputBuffer->Header.Console,
                                    InputBuffer,
-                                   Wait,
+                                   (GetInputRequest->wFlags & CONSOLE_READ_KEEPEVENT) != 0,
+                                   (GetInputRequest->wFlags & CONSOLE_READ_CONTINUE ) == 0,
                                    GetInputRequest->Unicode,
                                    GetInputRequest->InputRecord,
                                    GetInputRequest->Length,
@@ -336,9 +330,7 @@ CSR_API(SrvReadConsole)
     InputInfo.HandleEntry   = HandleEntry;
     InputInfo.InputBuffer   = InputBuffer;
 
-    Status = ReadChars(&InputInfo,
-                       ApiMessage,
-                       TRUE);
+    Status = ReadChars(&InputInfo, ApiMessage, TRUE);
 
     ConSrvReleaseInputBuffer(InputBuffer, TRUE);
 
@@ -358,6 +350,9 @@ CSR_API(SrvGetConsoleInput)
 
     DPRINT("SrvGetConsoleInput\n");
 
+    if (GetInputRequest->wFlags & ~(CONSOLE_READ_KEEPEVENT | CONSOLE_READ_CONTINUE))
+        return STATUS_INVALID_PARAMETER;
+
     if (!CsrValidateMessageBuffer(ApiMessage,
                                   (PVOID*)&GetInputRequest->InputRecord,
                                   GetInputRequest->Length,
@@ -375,10 +370,7 @@ CSR_API(SrvGetConsoleInput)
     InputInfo.HandleEntry   = HandleEntry;
     InputInfo.InputBuffer   = InputBuffer;
 
-    Status = ReadInputBuffer(&InputInfo,
-                             GetInputRequest->bRead,
-                             ApiMessage,
-                             TRUE);
+    Status = ReadInputBuffer(&InputInfo, ApiMessage, TRUE);
 
     ConSrvReleaseInputBuffer(InputBuffer, TRUE);