[CONSRV]: Code reorganization part 1.
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Fri, 5 Sep 2014 21:06:36 +0000 (21:06 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Fri, 5 Sep 2014 21:06:36 +0000 (21:06 +0000)
svn path=/branches/condrv_restructure/; revision=64042

win32ss/user/winsrv/consrv/condrv/coninput.c
win32ss/user/winsrv/consrv/condrv/conoutput.c
win32ss/user/winsrv/consrv/condrv/console.c
win32ss/user/winsrv/consrv/coninput.h
win32ss/user/winsrv/consrv/conoutput.h

index a28a207..800abb4 100644 (file)
@@ -178,7 +178,7 @@ Done:
     return Status;
 }
 
-VOID
+static VOID
 PurgeInputBuffer(PCONSOLE Console)
 {
     PLIST_ENTRY CurrentEntry;
@@ -191,6 +191,36 @@ PurgeInputBuffer(PCONSOLE Console)
         ConsoleFreeHeap(Event);
     }
 
+    // CloseHandle(Console->InputBuffer.ActiveEvent);
+}
+
+NTSTATUS NTAPI
+ConDrvInitInputBuffer(IN PCONSOLE Console,
+                      IN ULONG InputBufferSize)
+{
+    SECURITY_ATTRIBUTES SecurityAttributes;
+
+    ConSrvInitObject(&Console->InputBuffer.Header, INPUT_BUFFER, Console);
+
+    SecurityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
+    SecurityAttributes.lpSecurityDescriptor = NULL;
+    SecurityAttributes.bInheritHandle = TRUE;
+
+    Console->InputBuffer.ActiveEvent = CreateEventW(&SecurityAttributes, TRUE, FALSE, NULL);
+    if (Console->InputBuffer.ActiveEvent == NULL) return STATUS_UNSUCCESSFUL;
+
+    Console->InputBuffer.InputBufferSize = InputBufferSize;
+    InitializeListHead(&Console->InputBuffer.InputEvents);
+    Console->InputBuffer.Mode = ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT |
+                                ENABLE_ECHO_INPUT      | ENABLE_MOUSE_INPUT;
+
+    return STATUS_SUCCESS;
+}
+
+VOID NTAPI
+ConDrvDeinitInputBuffer(IN PCONSOLE Console)
+{
+    PurgeInputBuffer(Console);
     CloseHandle(Console->InputBuffer.ActiveEvent);
 }
 
index 4fe6574..b6ce1bc 100644 (file)
@@ -115,7 +115,7 @@ static VOID
 ConioSetActiveScreenBuffer(PCONSOLE_SCREEN_BUFFER Buffer);
 
 VOID NTAPI
-ConioDeleteScreenBuffer(PCONSOLE_SCREEN_BUFFER Buffer)
+ConDrvDeleteScreenBuffer(PCONSOLE_SCREEN_BUFFER Buffer)
 {
     PCONSOLE Console = Buffer->Header.Console;
     PCONSOLE_SCREEN_BUFFER NewBuffer;
@@ -190,7 +190,7 @@ ConDrvSetConsoleActiveScreenBuffer(IN PCONSOLE Console,
     /* If old buffer has no handles, it's now unreferenced */
     if (Console->ActiveBuffer->Header.ReferenceCount == 0)
     {
-        ConioDeleteScreenBuffer(Console->ActiveBuffer);
+        ConDrvDeleteScreenBuffer(Console->ActiveBuffer);
     }
 
     /* Tie console to new buffer and signal the change to the frontend */
index b0e4ba7..6e289a2 100644 (file)
@@ -190,7 +190,6 @@ ConDrvInitConsole(OUT PCONSOLE* NewConsole,
                   IN PCONSOLE_INFO ConsoleInfo)
 {
     NTSTATUS Status;
-    SECURITY_ATTRIBUTES SecurityAttributes;
     // CONSOLE_INFO CapturedConsoleInfo;
     TEXTMODE_BUFFER_INFO ScreenBufferInfo;
     PCONSOLE Console;
@@ -236,27 +235,16 @@ ConDrvInitConsole(OUT PCONSOLE* NewConsole,
     Console->ConsoleSize = ConsoleInfo->ConsoleSize;
     Console->FixedSize   = FALSE; // Value by default; is reseted by the terminals if needed.
 
-    /*
-     * Initialize the input buffer
-     */
-    ConSrvInitObject(&Console->InputBuffer.Header, INPUT_BUFFER, Console);
-
-    SecurityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
-    SecurityAttributes.lpSecurityDescriptor = NULL;
-    SecurityAttributes.bInheritHandle = TRUE;
-    Console->InputBuffer.ActiveEvent = CreateEventW(&SecurityAttributes, TRUE, FALSE, NULL);
-    if (NULL == Console->InputBuffer.ActiveEvent)
+    /* Initialize the input buffer */
+    Status = ConDrvInitInputBuffer(Console, 0 /* ConsoleInfo->InputBufferSize */);
+    if (!NT_SUCCESS(Status))
     {
+        DPRINT1("ConDrvInitInputBuffer: failed, Status = 0x%08lx\n", Status);
         DeleteCriticalSection(&Console->Lock);
         ConsoleFreeHeap(Console);
-        return STATUS_UNSUCCESSFUL;
+        return Status;
     }
 
-    Console->InputBuffer.InputBufferSize = 0; // FIXME!
-    InitializeListHead(&Console->InputBuffer.InputEvents);
-    Console->InputBuffer.Mode = ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT |
-                                ENABLE_ECHO_INPUT      | ENABLE_MOUSE_INPUT;
-
     /* Set-up the code page */
     Console->InputCodePage = Console->OutputCodePage = ConsoleInfo->CodePage;
 
@@ -275,7 +263,7 @@ ConDrvInitConsole(OUT PCONSOLE* NewConsole,
     if (!NT_SUCCESS(Status))
     {
         DPRINT1("ConDrvCreateScreenBuffer: failed, Status = 0x%08lx\n", Status);
-        CloseHandle(Console->InputBuffer.ActiveEvent);
+        ConDrvDeinitInputBuffer(Console);
         DeleteCriticalSection(&Console->Lock);
         ConsoleFreeHeap(Console);
         return Status;
@@ -430,10 +418,10 @@ ConDrvDeleteConsole(IN PCONSOLE Console)
 
     /* FIXME: Send a terminate message to all the processes owning this console */
 
-    /* Cleanup the UI-oriented part */
-    DPRINT("Deregister console\n");
+    /* Deregister the terminal */
+    DPRINT("Deregister terminal\n");
     ConDrvDeregisterTerminal(Console);
-    DPRINT("Console deregistered\n");
+    DPRINT("Terminal deregistered\n");
 
     /***
      * Check that the console is in terminating state before continuing
@@ -458,19 +446,18 @@ ConDrvDeleteConsole(IN PCONSOLE Console)
     /* Remove the console from the list */
     RemoveConsole(Console);
 
-    /* Discard all entries in the input event queue */
-    PurgeInputBuffer(Console);
-
     /* Delete the last screen buffer */
-    ConioDeleteScreenBuffer(Console->ActiveBuffer);
+    ConDrvDeleteScreenBuffer(Console->ActiveBuffer);
     Console->ActiveBuffer = NULL;
     if (!IsListEmpty(&Console->BufferList))
     {
-        DPRINT1("BUG: screen buffer list not empty\n");
-        ASSERT(FALSE);
+        /***ConDrvUnlockConsoleList();***/
+        ASSERTMSG("BUGBUGBUG!! screen buffer list not empty\n", FALSE);
     }
 
-    /**/ CloseHandle(Console->InputBuffer.ActiveEvent); /**/
+    /* Deinitialize the input buffer */
+    ConDrvDeinitInputBuffer(Console);
+
     if (Console->UnpauseEvent) CloseHandle(Console->UnpauseEvent);
 
     ConsoleFreeUnicodeString(&Console->OriginalTitle);
index 7ab4694..ea186b0 100644 (file)
@@ -9,4 +9,8 @@
 
 #pragma once
 
-VOID PurgeInputBuffer(PCONSOLE Console);
+NTSTATUS NTAPI
+ConDrvInitInputBuffer(IN PCONSOLE Console,
+                      IN ULONG InputBufferSize);
+VOID NTAPI
+ConDrvDeinitInputBuffer(IN PCONSOLE Console);
index 802b8c4..943fff0 100644 (file)
@@ -37,7 +37,7 @@ NTSTATUS ConDrvCreateScreenBuffer(OUT PCONSOLE_SCREEN_BUFFER* Buffer,
                                            IN OUT PCONSOLE Console,
                                            IN ULONG BufferType,
                                            IN PVOID ScreenBufferInfo);
-VOID NTAPI ConioDeleteScreenBuffer(PCONSOLE_SCREEN_BUFFER Buffer);
+VOID NTAPI ConDrvDeleteScreenBuffer(PCONSOLE_SCREEN_BUFFER Buffer);
 // VOID ConioSetActiveScreenBuffer(PCONSOLE_SCREEN_BUFFER Buffer);
 
 PCONSOLE_SCREEN_BUFFER