[CONSRV]
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sat, 3 May 2014 01:59:28 +0000 (01:59 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sat, 3 May 2014 01:59:28 +0000 (01:59 +0000)
Terminals are for consoles, and frontends for a given win32 terminal.
Start to clarify this situation in the code. Work in progress.

svn path=/branches/condrv_restructure/; revision=63123

win32ss/user/winsrv/consrv/condrv/console.c
win32ss/user/winsrv/consrv/condrv/dummyterm.c
win32ss/user/winsrv/consrv/console.c
win32ss/user/winsrv/consrv/frontends/terminal.c
win32ss/user/winsrv/consrv/include/conio.h
win32ss/user/winsrv/consrv/include/conio_winsrv.h
win32ss/user/winsrv/consrv/include/console.h
win32ss/user/winsrv/consrv/include/term.h

index f69991c..d601bff 100644 (file)
@@ -187,12 +187,11 @@ RemoveConsoleByPointer(IN PCONSOLE Console)
 }
 
 
-/* For resetting the frontend - defined in dummyfrontend.c */
-VOID ResetFrontEnd(IN PCONSOLE Console);
-
-
 /* PRIVATE FUNCTIONS **********************************************************/
 
+/* For resetting the terminal - defined in dummyterm.c */
+VOID ResetTerminal(IN PCONSOLE Console);
+
 VOID NTAPI
 ConDrvPause(PCONSOLE Console)
 {
@@ -417,12 +416,12 @@ ConDrvInitConsole(OUT PHANDLE NewConsoleHandle,
     Console->ReferenceCount = 0;
     InitializeCriticalSection(&Console->Lock);
 
-    /* Initialize the frontend interface */
-    ResetFrontEnd(Console);
+    /* Initialize the terminal interface */
+    ResetTerminal(Console);
 
     memcpy(Console->Colors, ConsoleInfo->Colors, sizeof(ConsoleInfo->Colors));
     Console->ConsoleSize = ConsoleInfo->ConsoleSize;
-    Console->FixedSize   = FALSE; // Value by default; is reseted by the front-ends if needed.
+    Console->FixedSize   = FALSE; // Value by default; is reseted by the terminals if needed.
 
     /*
      * Initialize the input buffer
@@ -538,63 +537,63 @@ ConDrvInitConsole(OUT PHANDLE NewConsoleHandle,
 }
 
 NTSTATUS NTAPI
-ConDrvRegisterFrontEnd(IN PCONSOLE Console,
-                       IN PFRONTEND FrontEnd)
+ConDrvRegisterTerminal(IN PCONSOLE Console,
+                       IN PTERMINAL Terminal)
 {
     NTSTATUS Status;
 
-    if (Console == NULL || FrontEnd == NULL)
+    if (Console == NULL || Terminal == NULL)
         return STATUS_INVALID_PARAMETER;
 
     /* FIXME: Lock the console before ?? */
 
     /*
-     * Attach the frontend to the console. Use now the FrontEndIFace of the console,
-     * and not the user-defined temporary FrontEnd pointer.
+     * Attach the terminal to the console. Use now the TermIFace of the console,
+     * and not the user-defined temporary Terminal pointer.
      */
-    Console->FrontEndIFace = *FrontEnd;
-    Console->FrontEndIFace.Console = Console;
+    Console->TermIFace = *Terminal;
+    Console->TermIFace.Console = Console;
 
-    /* Initialize the frontend AFTER having attached it to the console */
-    DPRINT("Finish initialization of frontend\n");
-    Status = Console->FrontEndIFace.Vtbl->InitFrontEnd(&Console->FrontEndIFace, Console);
+    /* Initialize the terminal AFTER having attached it to the console */
+    DPRINT("Finish initialization of terminal\n");
+    Status = Console->TermIFace.Vtbl->InitTerminal(&Console->TermIFace, Console);
     if (!NT_SUCCESS(Status))
     {
-        DPRINT1("FrontEnd initialization failed, Status = 0x%08lx\n", Status);
+        DPRINT1("Terminal initialization failed, Status = 0x%08lx\n", Status);
 
-        /* We failed, detach the frontend from the console */
-        FrontEnd->Console = NULL; // For the caller
-        ResetFrontEnd(Console);
+        /* We failed, detach the terminal from the console */
+        Terminal->Console = NULL; // For the caller
+        ResetTerminal(Console);
 
         return Status;
     }
 
     /* Copy buffer contents to screen */
-    // FrontEnd.Draw();
+    // Terminal.Draw();
     // ConioDrawConsole(Console);
     DPRINT("Console drawn\n");
 
-    DPRINT("Terminal FrontEnd initialization done\n");
+    DPRINT("Terminal initialization done\n");
     return STATUS_SUCCESS;
 }
 
 NTSTATUS NTAPI
-ConDrvDeregisterFrontEnd(IN PCONSOLE Console)
+ConDrvDeregisterTerminal(IN PCONSOLE Console)
 {
     if (Console == NULL) return STATUS_INVALID_PARAMETER;
 
     /* FIXME: Lock the console before ?? */
 
-    /* Deinitialize the frontend BEFORE detaching it from the console */
-    Console->FrontEndIFace.Vtbl->DeinitFrontEnd(&Console->FrontEndIFace/*, Console*/);
+    /* Deinitialize the terminal BEFORE detaching it from the console */
+    Console->TermIFace.Vtbl->DeinitTerminal(&Console->TermIFace/*, Console*/);
 
     /*
-     * Detach the frontend from the console:
-     * reinitialize the frontend interface.
+     * Detach the terminal from the console:
+     * reinitialize the terminal interface.
      */
-    ResetFrontEnd(Console);
+    ResetTerminal(Console);
 
-    DPRINT("Terminal FrontEnd unregistered\n");
+    DPRINT("Terminal unregistered\n");
     return STATUS_SUCCESS;
 }
 
@@ -643,7 +642,7 @@ ConDrvDeleteConsole(IN PCONSOLE Console)
 
     /* Cleanup the UI-oriented part */
     DPRINT("Deregister console\n");
-    ConDrvDeregisterFrontEnd(Console);
+    ConDrvDeregisterTerminal(Console);
     DPRINT("Console deregistered\n");
 
     /***
index dd995af..3b38329 100644 (file)
 /* DUMMY TERMINAL INTERFACE ***************************************************/
 
 static NTSTATUS NTAPI
-DummyInitFrontEnd(IN OUT PFRONTEND This,
+DummyInitTerminal(IN OUT PTERMINAL This,
                   IN PCONSOLE Console)
 {
-    /* Load some settings ?? */
     return STATUS_SUCCESS;
 }
 
 static VOID NTAPI
-DummyDeinitFrontEnd(IN OUT PFRONTEND This)
+DummyDeinitTerminal(IN OUT PTERMINAL This)
 {
-    /* Free some settings ?? */
 }
 
 static VOID NTAPI
-DummyDrawRegion(IN OUT PFRONTEND This,
+DummyDrawRegion(IN OUT PTERMINAL This,
                 SMALL_RECT* Region)
 {
 }
 
 static VOID NTAPI
-DummyWriteStream(IN OUT PFRONTEND This,
+DummyWriteStream(IN OUT PTERMINAL This,
                  SMALL_RECT* Region,
                  SHORT CursorStartX,
                  SHORT CursorStartY,
@@ -45,15 +43,15 @@ DummyWriteStream(IN OUT PFRONTEND This,
 }
 
 static BOOL NTAPI
-DummySetCursorInfo(IN OUT PFRONTEND This,
-                   PCONSOLE_SCREEN_BUFFER Buff)
+DummySetCursorInfo(IN OUT PTERMINAL This,
+                   PCONSOLE_SCREEN_BUFFER ScreenBuffer)
 {
     return TRUE;
 }
 
 static BOOL NTAPI
-DummySetScreenInfo(IN OUT PFRONTEND This,
-                   PCONSOLE_SCREEN_BUFFER Buff,
+DummySetScreenInfo(IN OUT PTERMINAL This,
+                   PCONSOLE_SCREEN_BUFFER ScreenBuffer,
                    SHORT OldCursorX,
                    SHORT OldCursorY)
 {
@@ -61,122 +59,60 @@ DummySetScreenInfo(IN OUT PFRONTEND This,
 }
 
 static VOID NTAPI
-DummyResizeTerminal(IN OUT PFRONTEND This)
+DummyResizeTerminal(IN OUT PTERMINAL This)
 {
 }
 
 static VOID NTAPI
-DummySetActiveScreenBuffer(IN OUT PFRONTEND This)
+DummySetActiveScreenBuffer(IN OUT PTERMINAL This)
 {
 }
 
 static VOID NTAPI
-DummyReleaseScreenBuffer(IN OUT PFRONTEND This,
+DummyReleaseScreenBuffer(IN OUT PTERMINAL This,
                          IN PCONSOLE_SCREEN_BUFFER ScreenBuffer)
 {
 }
 
-static BOOL NTAPI
-DummyProcessKeyCallback(IN OUT PFRONTEND This,
-                        MSG* msg,
-                        BYTE KeyStateMenu,
-                        DWORD ShiftState,
-                        UINT VirtualKeyCode,
-                        BOOL Down)
-{
-    return FALSE;
-}
-
 static VOID NTAPI
-DummyRefreshInternalInfo(IN OUT PFRONTEND This)
+DummyChangeTitle(IN OUT PTERMINAL This)
 {
 }
 
 static VOID NTAPI
-DummyChangeTitle(IN OUT PFRONTEND This)
-{
-}
-
-static BOOL NTAPI
-DummyChangeIcon(IN OUT PFRONTEND This,
-                HICON IconHandle)
-{
-    return TRUE;
-}
-
-static HWND NTAPI
-DummyGetConsoleWindowHandle(IN OUT PFRONTEND This)
-{
-    return NULL;
-}
-
-static VOID NTAPI
-DummyGetLargestConsoleWindowSize(IN OUT PFRONTEND This,
+DummyGetLargestConsoleWindowSize(IN OUT PTERMINAL This,
                                  PCOORD pSize)
 {
 }
 
+/*
 static BOOL NTAPI
-DummyGetSelectionInfo(IN OUT PFRONTEND This,
+DummyGetSelectionInfo(IN OUT PTERMINAL This,
                       PCONSOLE_SELECTION_INFO pSelectionInfo)
 {
     return TRUE;
 }
+*/
 
 static BOOL NTAPI
-DummySetPalette(IN OUT PFRONTEND This,
+DummySetPalette(IN OUT PTERMINAL This,
                 HPALETTE PaletteHandle,
                 UINT PaletteUsage)
 {
     return TRUE;
 }
 
-static ULONG NTAPI
-DummyGetDisplayMode(IN OUT PFRONTEND This)
-{
-    return 0;
-}
-
-static BOOL NTAPI
-DummySetDisplayMode(IN OUT PFRONTEND This,
-                    ULONG NewMode)
-{
-    return TRUE;
-}
-
 static INT NTAPI
-DummyShowMouseCursor(IN OUT PFRONTEND This,
+DummyShowMouseCursor(IN OUT PTERMINAL This,
                      BOOL Show)
 {
     return 0;
 }
 
-static BOOL NTAPI
-DummySetMouseCursor(IN OUT PFRONTEND This,
-                    HCURSOR CursorHandle)
-{
-    return TRUE;
-}
-
-static HMENU NTAPI
-DummyMenuControl(IN OUT PFRONTEND This,
-                 UINT CmdIdLow,
-                 UINT CmdIdHigh)
-{
-    return NULL;
-}
-
-static BOOL NTAPI
-DummySetMenuClose(IN OUT PFRONTEND This,
-                  BOOL Enable)
-{
-    return TRUE;
-}
-
-static FRONTEND_VTBL DummyVtbl =
+static TERMINAL_VTBL DummyVtbl =
 {
-    DummyInitFrontEnd,
-    DummyDeinitFrontEnd,
+    DummyInitTerminal,
+    DummyDeinitTerminal,
     DummyDrawRegion,
     DummyWriteStream,
     DummySetCursorInfo,
@@ -184,30 +120,21 @@ static FRONTEND_VTBL DummyVtbl =
     DummyResizeTerminal,
     DummySetActiveScreenBuffer,
     DummyReleaseScreenBuffer,
-    DummyProcessKeyCallback,
-    DummyRefreshInternalInfo,
     DummyChangeTitle,
-    DummyChangeIcon,
-    DummyGetConsoleWindowHandle,
     DummyGetLargestConsoleWindowSize,
-    DummyGetSelectionInfo,
+    // DummyGetSelectionInfo,
     DummySetPalette,
-    DummyGetDisplayMode,
-    DummySetDisplayMode,
     DummyShowMouseCursor,
-    DummySetMouseCursor,
-    DummyMenuControl,
-    DummySetMenuClose,
 };
 
 VOID
-ResetFrontEnd(IN PCONSOLE Console)
+ResetTerminal(IN PCONSOLE Console)
 {
     if (!Console) return;
 
-    /* Reinitialize the frontend interface */
-    RtlZeroMemory(&Console->FrontEndIFace, sizeof(Console->FrontEndIFace));
-    Console->FrontEndIFace.Vtbl = &DummyVtbl;
+    /* Reinitialize the terminal interface */
+    RtlZeroMemory(&Console->TermIFace, sizeof(Console->TermIFace));
+    Console->TermIFace.Vtbl = &DummyVtbl;
 }
 
 /* EOF */
index 218f8c1..c4ad7bf 100644 (file)
@@ -82,13 +82,13 @@ ConSrvReleaseConsole(PCONSOLE Console,
 }
 
 
-/* static */ NTSTATUS
-ConSrvLoadFrontEnd(IN OUT PFRONTEND FrontEnd,
+NTSTATUS NTAPI
+ConSrvInitTerminal(IN OUT PTERMINAL Terminal,
                    IN OUT PCONSOLE_INFO ConsoleInfo,
                    IN OUT PVOID ExtraConsoleInfo,
                    IN ULONG ProcessId);
-/* static */ NTSTATUS
-ConSrvUnloadFrontEnd(IN PFRONTEND FrontEnd);
+NTSTATUS NTAPI
+ConSrvDeinitTerminal(IN OUT PTERMINAL Terminal);
 
 NTSTATUS NTAPI
 ConSrvInitConsole(OUT PHANDLE NewConsoleHandle,
@@ -102,7 +102,7 @@ ConSrvInitConsole(OUT PHANDLE NewConsoleHandle,
     CONSOLE_INFO ConsoleInfo;
     SIZE_T Length = 0;
 
-    FRONTEND FrontEnd;
+    TERMINAL Terminal; /* The ConSrv terminal for this console */
 
     if (NewConsole == NULL || ConsoleStartInfo == NULL)
         return STATUS_INVALID_PARAMETER;
@@ -122,7 +122,6 @@ ConSrvInitConsole(OUT PHANDLE NewConsoleHandle,
     wcsncpy(ConsoleInfo.ConsoleTitle, ConsoleStartInfo->ConsoleTitle, Length);
     ConsoleInfo.ConsoleTitle[Length] = L'\0';
 
-#if 0
     /* 3. Initialize the ConSrv terminal */
     Status = ConSrvInitTerminal(&Terminal,
                                 &ConsoleInfo,
@@ -134,18 +133,6 @@ ConSrvInitConsole(OUT PHANDLE NewConsoleHandle,
         return Status;
     }
     DPRINT("CONSRV: Terminal initialized\n");
-#else
-    Status = ConSrvLoadFrontEnd(&FrontEnd,
-                                &ConsoleInfo,
-                                ConsoleStartInfo,
-                                ConsoleLeaderProcessId);
-    if (!NT_SUCCESS(Status))
-    {
-        DPRINT1("CONSRV: Failed to initialize a frontend, Status = 0x%08lx\n", Status);
-        return Status;
-    }
-    DPRINT("CONSRV: Frontend initialized\n");
-#endif
 
     /*
      * 4. Load the remaining console settings via the registry.
@@ -190,7 +177,7 @@ ConSrvInitConsole(OUT PHANDLE NewConsoleHandle,
     if (!NT_SUCCESS(Status))
     {
         DPRINT1("Creating a new console failed, Status = 0x%08lx\n", Status);
-        ConSrvUnloadFrontEnd(&FrontEnd);
+        ConSrvDeinitTerminal(&Terminal);
         return Status;
     }
 
@@ -212,15 +199,15 @@ ConSrvInitConsole(OUT PHANDLE NewConsoleHandle,
     Console->QuickEdit = ConsoleInfo.QuickEdit;
 
     /* Attach the ConSrv terminal to the console */
-    Status = ConDrvRegisterFrontEnd(Console, &FrontEnd);
+    Status = ConDrvRegisterTerminal(Console, &Terminal);
     if (!NT_SUCCESS(Status))
     {
-        DPRINT1("Failed to register frontend to the given console, Status = 0x%08lx\n", Status);
+        DPRINT1("Failed to register terminal to the given console, Status = 0x%08lx\n", Status);
         ConDrvDeleteConsole(Console);
-        ConSrvUnloadFrontEnd(&FrontEnd);
+        ConSrvDeinitTerminal(&Terminal);
         return Status;
     }
-    DPRINT("FrontEnd registered\n");
+    DPRINT("Terminal registered\n");
 
     /* Return the newly created console to the caller and a success code too */
     *NewConsoleHandle = ConsoleHandle;
@@ -233,7 +220,7 @@ ConSrvDeleteConsole(PCONSOLE Console)
 {
     DPRINT("ConSrvDeleteConsole\n");
 
-    /* Just call the driver. ConSrvDeregisterFrontEnd is called on-demand. */
+    /* Just call the driver. ConDrvDeregisterTerminal is called on-demand. */
     ConDrvDeleteConsole(Console);
 }
 
index 8aa19d6..b2ba1a9 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <consrv.h>
 
+// #include "frontends/gui/guiterm.h"
 #ifdef TUITERM_COMPILE
 #include "frontends/tui/tuiterm.h"
 #endif
@@ -81,8 +82,7 @@ struct
 //  {"Not found", 0, NULL}
 };
 
-
-/* static */ NTSTATUS
+static NTSTATUS
 ConSrvLoadFrontEnd(IN OUT PFRONTEND FrontEnd,
                    IN OUT PCONSOLE_INFO ConsoleInfo,
                    IN OUT PVOID ExtraConsoleInfo,
@@ -121,7 +121,7 @@ ConSrvLoadFrontEnd(IN OUT PFRONTEND FrontEnd,
     return Status;
 }
 
-/* static */ NTSTATUS
+static NTSTATUS
 ConSrvUnloadFrontEnd(IN PFRONTEND FrontEnd)
 {
     if (FrontEnd == NULL) return STATUS_INVALID_PARAMETER;
@@ -129,33 +129,105 @@ ConSrvUnloadFrontEnd(IN PFRONTEND FrontEnd)
     return FrontEnd->UnloadFrontEnd(FrontEnd);
 }
 
+// See after...
+static TERMINAL_VTBL ConSrvTermVtbl;
 
-/* DUMMY FRONTEND INTERFACE ***************************************************/
+NTSTATUS NTAPI
+ConSrvInitTerminal(IN OUT PTERMINAL Terminal,
+                   IN OUT PCONSOLE_INFO ConsoleInfo,
+                   IN OUT PVOID ExtraConsoleInfo,
+                   IN ULONG ProcessId)
+{
+    NTSTATUS Status;
+    PFRONTEND FrontEnd;
+
+    /* Load a suitable frontend for the ConSrv terminal */
+    FrontEnd = ConsoleAllocHeap(HEAP_ZERO_MEMORY, sizeof(*FrontEnd));
+    if (!FrontEnd) return STATUS_NO_MEMORY;
+
+    Status = ConSrvLoadFrontEnd(FrontEnd,
+                                ConsoleInfo,
+                                ExtraConsoleInfo,
+                                ProcessId);
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("CONSRV: Failed to initialize a frontend, Status = 0x%08lx\n", Status);
+        ConsoleFreeHeap(FrontEnd);
+        return Status;
+    }
+    DPRINT("CONSRV: Frontend initialized\n");
 
-#if 0
+    /* Initialize the ConSrv terminal */
+    Terminal->Vtbl = &ConSrvTermVtbl;
+    // Terminal->Console will be initialized by ConDrvRegisterTerminal
+    Terminal->Data = FrontEnd; /* We store the frontend pointer in the terminal private data */
+
+    return STATUS_SUCCESS;
+}
+
+NTSTATUS NTAPI
+ConSrvDeinitTerminal(IN OUT PTERMINAL Terminal)
+{
+    NTSTATUS Status = STATUS_SUCCESS;
+    PFRONTEND FrontEnd = Terminal->Data;
+
+    /* Reset the ConSrv terminal */
+    Terminal->Data = NULL;
+    Terminal->Vtbl = NULL;
+
+    /* Unload the frontend */
+    if (FrontEnd != NULL)
+    {
+        Status = ConSrvUnloadFrontEnd(FrontEnd);
+        ConsoleFreeHeap(FrontEnd);
+    }
+
+    return Status;
+}
+
+
+/* CONSRV TERMINAL INTERFACE **************************************************/
 
 static NTSTATUS NTAPI
-DummyInitFrontEnd(IN OUT PFRONTEND This,
+ConSrvTermInitTerminal(IN OUT PTERMINAL This,
                   IN PCONSOLE Console)
 {
-    /* Load some settings ?? */
-    return STATUS_SUCCESS;
+    NTSTATUS Status;
+    PFRONTEND FrontEnd = This->Data;
+
+    /* Initialize the console pointer for our frontend */
+    FrontEnd->Console = Console;
+
+    /** HACK HACK!! Copy FrontEnd into the console!! **/
+    DPRINT1("Using FrontEndIFace HACK(1), should be removed after proper implementation!\n");
+    Console->FrontEndIFace = *FrontEnd;
+
+    Status = FrontEnd->Vtbl->InitFrontEnd(FrontEnd, FrontEnd->Console);
+
+    /** HACK HACK!! Be sure FrontEndIFace is correctly updated in the console!! **/
+    DPRINT1("Using FrontEndIFace HACK(2), should be removed after proper implementation!\n");
+    Console->FrontEndIFace = *FrontEnd;
+
+    return Status;
 }
 
 static VOID NTAPI
-DummyDeinitFrontEnd(IN OUT PFRONTEND This)
+ConSrvTermDeinitTerminal(IN OUT PTERMINAL This)
 {
-    /* Free some settings ?? */
+    PFRONTEND FrontEnd = This->Data;
+    FrontEnd->Vtbl->DeinitFrontEnd(FrontEnd);
 }
 
 static VOID NTAPI
-DummyDrawRegion(IN OUT PFRONTEND This,
+ConSrvTermDrawRegion(IN OUT PTERMINAL This,
                 SMALL_RECT* Region)
 {
+    PFRONTEND FrontEnd = This->Data;
+    FrontEnd->Vtbl->DrawRegion(FrontEnd, Region);
 }
 
 static VOID NTAPI
-DummyWriteStream(IN OUT PFRONTEND This,
+ConSrvTermWriteStream(IN OUT PTERMINAL This,
                  SMALL_RECT* Region,
                  SHORT CursorStartX,
                  SHORT CursorStartY,
@@ -163,164 +235,120 @@ DummyWriteStream(IN OUT PFRONTEND This,
                  PWCHAR Buffer,
                  UINT Length)
 {
+    PFRONTEND FrontEnd = This->Data;
+    FrontEnd->Vtbl->WriteStream(FrontEnd,
+                                Region,
+                                CursorStartX,
+                                CursorStartY,
+                                ScrolledLines,
+                                Buffer,
+                                Length);
 }
 
 static BOOL NTAPI
-DummySetCursorInfo(IN OUT PFRONTEND This,
-                   PCONSOLE_SCREEN_BUFFER Buff)
+ConSrvTermSetCursorInfo(IN OUT PTERMINAL This,
+                   PCONSOLE_SCREEN_BUFFER ScreenBuffer)
 {
-    return TRUE;
+    PFRONTEND FrontEnd = This->Data;
+    return FrontEnd->Vtbl->SetCursorInfo(FrontEnd, ScreenBuffer);
 }
 
 static BOOL NTAPI
-DummySetScreenInfo(IN OUT PFRONTEND This,
-                   PCONSOLE_SCREEN_BUFFER Buff,
+ConSrvTermSetScreenInfo(IN OUT PTERMINAL This,
+                   PCONSOLE_SCREEN_BUFFER ScreenBuffer,
                    SHORT OldCursorX,
                    SHORT OldCursorY)
 {
-    return TRUE;
+    PFRONTEND FrontEnd = This->Data;
+    return FrontEnd->Vtbl->SetScreenInfo(FrontEnd,
+                                         ScreenBuffer,
+                                         OldCursorX,
+                                         OldCursorY);
 }
 
 static VOID NTAPI
-DummyResizeTerminal(IN OUT PFRONTEND This)
+ConSrvTermResizeTerminal(IN OUT PTERMINAL This)
 {
+    PFRONTEND FrontEnd = This->Data;
+    FrontEnd->Vtbl->ResizeTerminal(FrontEnd);
 }
 
 static VOID NTAPI
-DummySetActiveScreenBuffer(IN OUT PFRONTEND This)
+ConSrvTermSetActiveScreenBuffer(IN OUT PTERMINAL This)
 {
+    PFRONTEND FrontEnd = This->Data;
+    FrontEnd->Vtbl->SetActiveScreenBuffer(FrontEnd);
 }
 
 static VOID NTAPI
-DummyReleaseScreenBuffer(IN OUT PFRONTEND This,
+ConSrvTermReleaseScreenBuffer(IN OUT PTERMINAL This,
                          IN PCONSOLE_SCREEN_BUFFER ScreenBuffer)
 {
-}
-
-static BOOL NTAPI
-DummyProcessKeyCallback(IN OUT PFRONTEND This,
-                        MSG* msg,
-                        BYTE KeyStateMenu,
-                        DWORD ShiftState,
-                        UINT VirtualKeyCode,
-                        BOOL Down)
-{
-    return FALSE;
+    PFRONTEND FrontEnd = This->Data;
+    FrontEnd->Vtbl->ReleaseScreenBuffer(FrontEnd, ScreenBuffer);
 }
 
 static VOID NTAPI
-DummyRefreshInternalInfo(IN OUT PFRONTEND This)
+ConSrvTermChangeTitle(IN OUT PTERMINAL This)
 {
+    PFRONTEND FrontEnd = This->Data;
+    FrontEnd->Vtbl->ChangeTitle(FrontEnd);
 }
 
 static VOID NTAPI
-DummyChangeTitle(IN OUT PFRONTEND This)
-{
-}
-
-static BOOL NTAPI
-DummyChangeIcon(IN OUT PFRONTEND This,
-                HICON IconHandle)
-{
-    return TRUE;
-}
-
-static HWND NTAPI
-DummyGetConsoleWindowHandle(IN OUT PFRONTEND This)
-{
-    return NULL;
-}
-
-static VOID NTAPI
-DummyGetLargestConsoleWindowSize(IN OUT PFRONTEND This,
+ConSrvTermGetLargestConsoleWindowSize(IN OUT PTERMINAL This,
                                  PCOORD pSize)
 {
+    PFRONTEND FrontEnd = This->Data;
+    FrontEnd->Vtbl->GetLargestConsoleWindowSize(FrontEnd, pSize);
 }
 
+/*
 static BOOL NTAPI
-DummyGetSelectionInfo(IN OUT PFRONTEND This,
+ConSrvTermGetSelectionInfo(IN OUT PTERMINAL This,
                       PCONSOLE_SELECTION_INFO pSelectionInfo)
 {
-    return TRUE;
+    PFRONTEND FrontEnd = This->Data;
+    return FrontEnd->Vtbl->GetSelectionInfo(FrontEnd, pSelectionInfo);
 }
+*/
 
 static BOOL NTAPI
-DummySetPalette(IN OUT PFRONTEND This,
+ConSrvTermSetPalette(IN OUT PTERMINAL This,
                 HPALETTE PaletteHandle,
                 UINT PaletteUsage)
 {
-    return TRUE;
-}
-
-static ULONG NTAPI
-DummyGetDisplayMode(IN OUT PFRONTEND This)
-{
-    return 0;
-}
-
-static BOOL NTAPI
-DummySetDisplayMode(IN OUT PFRONTEND This,
-                    ULONG NewMode)
-{
-    return TRUE;
+    PFRONTEND FrontEnd = This->Data;
+    return FrontEnd->Vtbl->SetPalette(FrontEnd, PaletteHandle, PaletteUsage);
 }
 
 static INT NTAPI
-DummyShowMouseCursor(IN OUT PFRONTEND This,
+ConSrvTermShowMouseCursor(IN OUT PTERMINAL This,
                      BOOL Show)
 {
-    return 0;
+    PFRONTEND FrontEnd = This->Data;
+    return FrontEnd->Vtbl->ShowMouseCursor(FrontEnd, Show);
 }
 
-static BOOL NTAPI
-DummySetMouseCursor(IN OUT PFRONTEND This,
-                    HCURSOR CursorHandle)
+static TERMINAL_VTBL ConSrvTermVtbl =
 {
-    return TRUE;
-}
-
-static HMENU NTAPI
-DummyMenuControl(IN OUT PFRONTEND This,
-                 UINT CmdIdLow,
-                 UINT CmdIdHigh)
-{
-    return NULL;
-}
-
-static BOOL NTAPI
-DummySetMenuClose(IN OUT PFRONTEND This,
-                  BOOL Enable)
-{
-    return TRUE;
-}
-
-static FRONTEND_VTBL DummyVtbl =
-{
-    DummyInitFrontEnd,
-    DummyDeinitFrontEnd,
-    DummyDrawRegion,
-    DummyWriteStream,
-    DummySetCursorInfo,
-    DummySetScreenInfo,
-    DummyResizeTerminal,
-    DummySetActiveScreenBuffer,
-    DummyReleaseScreenBuffer,
-    DummyProcessKeyCallback,
-    DummyRefreshInternalInfo,
-    DummyChangeTitle,
-    DummyChangeIcon,
-    DummyGetConsoleWindowHandle,
-    DummyGetLargestConsoleWindowSize,
-    DummyGetSelectionInfo,
-    DummySetPalette,
-    DummyGetDisplayMode,
-    DummySetDisplayMode,
-    DummyShowMouseCursor,
-    DummySetMouseCursor,
-    DummyMenuControl,
-    DummySetMenuClose,
+    ConSrvTermInitTerminal,
+    ConSrvTermDeinitTerminal,
+    ConSrvTermDrawRegion,
+    ConSrvTermWriteStream,
+    ConSrvTermSetCursorInfo,
+    ConSrvTermSetScreenInfo,
+    ConSrvTermResizeTerminal,
+    ConSrvTermSetActiveScreenBuffer,
+    ConSrvTermReleaseScreenBuffer,
+    ConSrvTermChangeTitle,
+    ConSrvTermGetLargestConsoleWindowSize,
+    // ConSrvTermGetSelectionInfo,
+    ConSrvTermSetPalette,
+    ConSrvTermShowMouseCursor,
 };
 
+#if 0
 VOID
 ResetFrontEnd(IN PCONSOLE Console)
 {
@@ -328,9 +356,8 @@ ResetFrontEnd(IN PCONSOLE Console)
 
     /* Reinitialize the frontend interface */
     RtlZeroMemory(&Console->FrontEndIFace, sizeof(Console->FrontEndIFace));
-    Console->FrontEndIFace.Vtbl = &DummyVtbl;
+    Console->FrontEndIFace.Vtbl = &ConSrvTermVtbl;
 }
-
 #endif
 
 /* EOF */
index 14b8432..30ac695 100644 (file)
@@ -186,16 +186,16 @@ typedef struct _TERMINAL_VTBL
     /*
      * Internal interface (functions called by the console server only)
      */
-    NTSTATUS (NTAPI *InitFrontEnd)(IN OUT PTERMINAL This,
+    NTSTATUS (NTAPI *InitTerminal)(IN OUT PTERMINAL This,
                                    IN struct _CONSOLE* Console);
-    VOID (NTAPI *DeinitFrontEnd)(IN OUT PTERMINAL This);
+    VOID (NTAPI *DeinitTerminal)(IN OUT PTERMINAL This);
 
     /* Interface used for both text-mode and graphics screen buffers */
     VOID (NTAPI *DrawRegion)(IN OUT PTERMINAL This,
                              SMALL_RECT* Region);
     /* Interface used only for text-mode screen buffers */
     VOID (NTAPI *WriteStream)(IN OUT PTERMINAL This,
-                              SMALL_RECT* Block,
+                              SMALL_RECT* Region,
                               SHORT CursorStartX,
                               SHORT CursorStartY,
                               UINT ScrolledLines,
@@ -211,47 +211,27 @@ typedef struct _TERMINAL_VTBL
     VOID (NTAPI *SetActiveScreenBuffer)(IN OUT PTERMINAL This);
     VOID (NTAPI *ReleaseScreenBuffer)(IN OUT PTERMINAL This,
                                       IN PCONSOLE_SCREEN_BUFFER ScreenBuffer);
-    BOOL (NTAPI *ProcessKeyCallback)(IN OUT PTERMINAL This,
-                                     MSG* msg,
-                                     BYTE KeyStateMenu,
-                                     DWORD ShiftState,
-                                     UINT VirtualKeyCode,
-                                     BOOL Down);
-    VOID (NTAPI *RefreshInternalInfo)(IN OUT PTERMINAL This);
 
     /*
      * External interface (functions corresponding to the Console API)
      */
     VOID (NTAPI *ChangeTitle)(IN OUT PTERMINAL This);
-    BOOL (NTAPI *ChangeIcon)(IN OUT PTERMINAL This,
-                             HICON IconHandle);
-    HWND (NTAPI *GetConsoleWindowHandle)(IN OUT PTERMINAL This);
     VOID (NTAPI *GetLargestConsoleWindowSize)(IN OUT PTERMINAL This,
                                               PCOORD pSize);
-    BOOL (NTAPI *GetSelectionInfo)(IN OUT PTERMINAL This,
-                                   PCONSOLE_SELECTION_INFO pSelectionInfo);
+    // BOOL (NTAPI *GetSelectionInfo)(IN OUT PTERMINAL This,
+                                   // PCONSOLE_SELECTION_INFO pSelectionInfo);
     BOOL (NTAPI *SetPalette)(IN OUT PTERMINAL This,
                              HPALETTE PaletteHandle,
                              UINT PaletteUsage);
-    ULONG (NTAPI *GetDisplayMode)(IN OUT PTERMINAL This);
-    BOOL  (NTAPI *SetDisplayMode)(IN OUT PTERMINAL This,
-                                  ULONG NewMode);
     INT   (NTAPI *ShowMouseCursor)(IN OUT PTERMINAL This,
                                    BOOL Show);
-    BOOL  (NTAPI *SetMouseCursor)(IN OUT PTERMINAL This,
-                                  HCURSOR CursorHandle);
-    HMENU (NTAPI *MenuControl)(IN OUT PTERMINAL This,
-                               UINT CmdIdLow,
-                               UINT CmdIdHigh);
-    BOOL  (NTAPI *SetMenuClose)(IN OUT PTERMINAL This,
-                                BOOL Enable);
 
 #if 0 // Possible future front-end interface
-    BOOL (NTAPI *GetFrontEndProperty)(IN OUT PTERMINAL This,
+    BOOL (NTAPI *GetTerminalProperty)(IN OUT PTERMINAL This,
                                       ULONG Flag,
                                       PVOID Info,
                                       ULONG Size);
-    BOOL (NTAPI *SetFrontEndProperty)(IN OUT PTERMINAL This,
+    BOOL (NTAPI *SetTerminalProperty)(IN OUT PTERMINAL This,
                                       ULONG Flag,
                                       PVOID Info /*,
                                       ULONG Size */);
index d7426b9..cd5c2fc 100644 (file)
@@ -30,7 +30,7 @@ typedef struct _FRONTEND_VTBL
                              SMALL_RECT* Region);
     /* Interface used only for text-mode screen buffers */
     VOID (NTAPI *WriteStream)(IN OUT PFRONTEND This,
-                              SMALL_RECT* Block,
+                              SMALL_RECT* Region,
                               SHORT CursorStartX,
                               SHORT CursorStartY,
                               UINT ScrolledLines,
index 4214e07..623232e 100644 (file)
@@ -17,10 +17,10 @@ ConDrvInitConsole(OUT PHANDLE NewConsoleHandle,
                   IN PCONSOLE_INFO ConsoleInfo,
                   IN ULONG ConsoleLeaderProcessId);
 NTSTATUS NTAPI
-ConDrvRegisterFrontEnd(IN PCONSOLE Console,
-                       IN PFRONTEND FrontEnd);
+ConDrvRegisterTerminal(IN PCONSOLE Console,
+                       IN PTERMINAL Terminal);
 NTSTATUS NTAPI
-ConDrvDeregisterFrontEnd(IN PCONSOLE Console);
+ConDrvDeregisterTerminal(IN PCONSOLE Console);
 VOID NTAPI
 ConDrvDeleteConsole(IN PCONSOLE Console);
 
index d0dc077..bb882c3 100644 (file)
 /* Macros used to call functions in the FRONTEND_VTBL virtual table */
 
 #define TermDrawRegion(Console, Region) \
-    (Console)->FrontEndIFace.Vtbl->DrawRegion(&(Console)->FrontEndIFace, (Region))
-#define TermWriteStream(Console, Block, CurStartX, CurStartY, ScrolledLines, Buffer, Length) \
-    (Console)->FrontEndIFace.Vtbl->WriteStream(&(Console)->FrontEndIFace, (Block), (CurStartX), (CurStartY), \
+    (Console)->TermIFace.Vtbl->DrawRegion(&(Console)->TermIFace, (Region))
+#define TermWriteStream(Console, Region, CurStartX, CurStartY, ScrolledLines, Buffer, Length) \
+    (Console)->TermIFace.Vtbl->WriteStream(&(Console)->TermIFace, (Region), (CurStartX), (CurStartY), \
                                            (ScrolledLines), (Buffer), (Length))
 #define TermSetCursorInfo(Console, ScreenBuffer) \
-    (Console)->FrontEndIFace.Vtbl->SetCursorInfo(&(Console)->FrontEndIFace, (ScreenBuffer))
+    (Console)->TermIFace.Vtbl->SetCursorInfo(&(Console)->TermIFace, (ScreenBuffer))
 #define TermSetScreenInfo(Console, ScreenBuffer, OldCursorX, OldCursorY) \
-    (Console)->FrontEndIFace.Vtbl->SetScreenInfo(&(Console)->FrontEndIFace, (ScreenBuffer), (OldCursorX), (OldCursorY))
+    (Console)->TermIFace.Vtbl->SetScreenInfo(&(Console)->TermIFace, (ScreenBuffer), (OldCursorX), (OldCursorY))
 #define TermResizeTerminal(Console) \
-    (Console)->FrontEndIFace.Vtbl->ResizeTerminal(&(Console)->FrontEndIFace)
+    (Console)->TermIFace.Vtbl->ResizeTerminal(&(Console)->TermIFace)
 #define TermSetActiveScreenBuffer(Console) \
-    (Console)->FrontEndIFace.Vtbl->SetActiveScreenBuffer(&(Console)->FrontEndIFace)
+    (Console)->TermIFace.Vtbl->SetActiveScreenBuffer(&(Console)->TermIFace)
 #define TermReleaseScreenBuffer(Console, ScreenBuffer) \
-    (Console)->FrontEndIFace.Vtbl->ReleaseScreenBuffer(&(Console)->FrontEndIFace, (ScreenBuffer))
+    (Console)->TermIFace.Vtbl->ReleaseScreenBuffer(&(Console)->TermIFace, (ScreenBuffer))
 #define TermProcessKeyCallback(Console, Msg, KeyStateMenu, ShiftState, VirtualKeyCode, Down) \
     (Console)->FrontEndIFace.Vtbl->ProcessKeyCallback(&(Console)->FrontEndIFace, (Msg), (KeyStateMenu), (ShiftState), (VirtualKeyCode), (Down))
 #define TermRefreshInternalInfo(Console) \
     (Console)->FrontEndIFace.Vtbl->RefreshInternalInfo(&(Console)->FrontEndIFace)
 
 #define TermChangeTitle(Console) \
-    (Console)->FrontEndIFace.Vtbl->ChangeTitle(&(Console)->FrontEndIFace)
+    (Console)->TermIFace.Vtbl->ChangeTitle(&(Console)->TermIFace)
 #define TermChangeIcon(Console, IconHandle) \
     (Console)->FrontEndIFace.Vtbl->ChangeIcon(&(Console)->FrontEndIFace, (IconHandle))
 #define TermGetConsoleWindowHandle(Console) \
     (Console)->FrontEndIFace.Vtbl->GetConsoleWindowHandle(&(Console)->FrontEndIFace)
 #define TermGetLargestConsoleWindowSize(Console, pSize) \
-    (Console)->FrontEndIFace.Vtbl->GetLargestConsoleWindowSize(&(Console)->FrontEndIFace, (pSize))
+    (Console)->TermIFace.Vtbl->GetLargestConsoleWindowSize(&(Console)->TermIFace, (pSize))
 #define TermGetSelectionInfo(Console, pSelectionInfo) \
     (Console)->FrontEndIFace.Vtbl->GetSelectionInfo(&(Console)->FrontEndIFace, (pSelectionInfo))
 #define TermSetPalette(Console, PaletteHandle, PaletteUsage) \
-    (Console)->FrontEndIFace.Vtbl->SetPalette(&(Console)->FrontEndIFace, (PaletteHandle), (PaletteUsage))
+    (Console)->TermIFace.Vtbl->SetPalette(&(Console)->TermIFace, (PaletteHandle), (PaletteUsage))
 #define TermGetDisplayMode(Console) \
     (Console)->FrontEndIFace.Vtbl->GetDisplayMode(&(Console)->FrontEndIFace)
 #define TermSetDisplayMode(Console, NewMode) \
     (Console)->FrontEndIFace.Vtbl->SetDisplayMode(&(Console)->FrontEndIFace, (NewMode))
 #define TermShowMouseCursor(Console, Show) \
-    (Console)->FrontEndIFace.Vtbl->ShowMouseCursor(&(Console)->FrontEndIFace, (Show))
+    (Console)->TermIFace.Vtbl->ShowMouseCursor(&(Console)->TermIFace, (Show))
 #define TermSetMouseCursor(Console, CursorHandle) \
     (Console)->FrontEndIFace.Vtbl->SetMouseCursor(&(Console)->FrontEndIFace, (CursorHandle))
 #define TermMenuControl(Console, CmdIdLow, CmdIdHigh) \