mirror of
https://github.com/reactos/reactos.git
synced 2025-04-27 09:00:27 +00:00
[CONSRV] Finally fix CONSOLE vs. CONSRV_CONSOLE/WINSRV_CONSOLE stuff. CORE-9496
What remains to be cleared up are the ugly casts.
This commit is contained in:
parent
a3ea0a39f1
commit
75d0346c54
17 changed files with 265 additions and 345 deletions
|
@ -40,7 +40,7 @@ list(APPEND CONSRV_SOURCE
|
|||
consrv/consrv.h)
|
||||
|
||||
#
|
||||
# Explicitely enable MS extensions to be able to use unnamed (anonymous) nested structs.
|
||||
# Explicitly enable MS extensions to be able to use unnamed (anonymous) nested structs.
|
||||
#
|
||||
# FIXME: http://www.cmake.org/Bug/view.php?id=12998
|
||||
if(MSVC)
|
||||
|
|
|
@ -18,88 +18,7 @@
|
|||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
/* GLOBALS ********************************************************************/
|
||||
|
||||
static ULONG CurrentConsoleID = 0;
|
||||
|
||||
/* Linked list of consoles */
|
||||
static LIST_ENTRY ConDrvConsoleList;
|
||||
static RTL_RESOURCE ListLock;
|
||||
|
||||
#define ConDrvLockConsoleListExclusive() \
|
||||
RtlAcquireResourceExclusive(&ListLock, TRUE)
|
||||
|
||||
#define ConDrvLockConsoleListShared() \
|
||||
RtlAcquireResourceShared(&ListLock, TRUE)
|
||||
|
||||
#define ConDrvUnlockConsoleList() \
|
||||
RtlReleaseResource(&ListLock)
|
||||
|
||||
|
||||
static NTSTATUS
|
||||
ConDrvInsertConsole(IN PCONSOLE Console)
|
||||
{
|
||||
ASSERT(Console);
|
||||
|
||||
/* All went right, so add the console to the list */
|
||||
ConDrvLockConsoleListExclusive();
|
||||
|
||||
DPRINT("Insert in the list\n");
|
||||
InsertTailList(&ConDrvConsoleList, &Console->ListEntry);
|
||||
|
||||
// FIXME: Move this code to the caller function!!
|
||||
/* Get a new console ID */
|
||||
_InterlockedExchange((PLONG)&Console->ConsoleID, CurrentConsoleID);
|
||||
_InterlockedIncrement((PLONG)&CurrentConsoleID);
|
||||
|
||||
/* Unlock the console list and return success */
|
||||
ConDrvUnlockConsoleList();
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static NTSTATUS
|
||||
RemoveConsole(IN PCONSOLE Console)
|
||||
{
|
||||
// ASSERT(Console);
|
||||
if (!Console) return STATUS_INVALID_PARAMETER;
|
||||
|
||||
/* Remove the console from the list */
|
||||
ConDrvLockConsoleListExclusive();
|
||||
|
||||
RemoveEntryList(&Console->ListEntry);
|
||||
|
||||
/* Unlock the console list and return success */
|
||||
ConDrvUnlockConsoleList();
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/* PRIVATE FUNCTIONS **********************************************************/
|
||||
|
||||
VOID NTAPI
|
||||
ConDrvPause(PCONSOLE Console)
|
||||
{
|
||||
/* In case we are already paused, just exit... */
|
||||
if (Console->ConsolePaused) return;
|
||||
|
||||
/* ... otherwise set the flag */
|
||||
Console->ConsolePaused = TRUE;
|
||||
}
|
||||
|
||||
VOID NTAPI
|
||||
ConDrvUnpause(PCONSOLE Console)
|
||||
{
|
||||
/* In case we are already unpaused, just exit... */
|
||||
if (!Console->ConsolePaused) return;
|
||||
|
||||
/* ... otherwise reset the flag */
|
||||
Console->ConsolePaused = FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Console accessibility check helpers
|
||||
*/
|
||||
/* CONSOLE VALIDATION FUNCTIONS ***********************************************/
|
||||
|
||||
BOOLEAN NTAPI
|
||||
ConDrvValidateConsoleState(IN PCONSOLE Console,
|
||||
|
@ -143,43 +62,24 @@ ConDrvValidateConsoleUnsafe(IN PCONSOLE Console,
|
|||
|
||||
/* CONSOLE INITIALIZATION FUNCTIONS *******************************************/
|
||||
|
||||
VOID NTAPI
|
||||
ConDrvInitConsoleSupport(VOID)
|
||||
{
|
||||
DPRINT("CONSRV: ConDrvInitConsoleSupport()\n");
|
||||
|
||||
/* Initialize the console list and its lock */
|
||||
InitializeListHead(&ConDrvConsoleList);
|
||||
RtlInitializeResource(&ListLock);
|
||||
}
|
||||
|
||||
/* For resetting the terminal - defined in dummyterm.c */
|
||||
VOID ResetTerminal(IN PCONSOLE Console);
|
||||
|
||||
NTSTATUS NTAPI
|
||||
ConDrvInitConsole(OUT PCONSOLE* NewConsole,
|
||||
IN PCONSOLE_INFO ConsoleInfo)
|
||||
ConDrvInitConsole(
|
||||
IN OUT PCONSOLE Console,
|
||||
IN PCONSOLE_INFO ConsoleInfo)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
// CONSOLE_INFO CapturedConsoleInfo;
|
||||
TEXTMODE_BUFFER_INFO ScreenBufferInfo;
|
||||
PCONSOLE Console;
|
||||
PCONSOLE_SCREEN_BUFFER NewBuffer;
|
||||
|
||||
if (NewConsole == NULL || ConsoleInfo == NULL)
|
||||
if (Console == NULL || ConsoleInfo == NULL)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
||||
*NewConsole = NULL;
|
||||
|
||||
/*
|
||||
* Allocate a new console
|
||||
*/
|
||||
Console = ConsoleAllocHeap(HEAP_ZERO_MEMORY, sizeof(*Console));
|
||||
if (NULL == Console)
|
||||
{
|
||||
DPRINT1("Not enough memory for console creation.\n");
|
||||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
/* Reset the console structure */
|
||||
RtlZeroMemory(Console, sizeof(*Console));
|
||||
|
||||
/*
|
||||
* Set and fix the screen buffer size if needed.
|
||||
|
@ -211,7 +111,6 @@ ConDrvInitConsole(OUT PCONSOLE* NewConsole,
|
|||
{
|
||||
DPRINT1("ConDrvInitInputBuffer: failed, Status = 0x%08lx\n", Status);
|
||||
DeleteCriticalSection(&Console->Lock);
|
||||
ConsoleFreeHeap(Console);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -240,7 +139,6 @@ ConDrvInitConsole(OUT PCONSOLE* NewConsole,
|
|||
DPRINT1("ConDrvCreateScreenBuffer: failed, Status = 0x%08lx\n", Status);
|
||||
ConDrvDeinitInputBuffer(Console);
|
||||
DeleteCriticalSection(&Console->Lock);
|
||||
ConsoleFreeHeap(Console);
|
||||
return Status;
|
||||
}
|
||||
/* Make the new screen buffer active */
|
||||
|
@ -249,21 +147,11 @@ ConDrvInitConsole(OUT PCONSOLE* NewConsole,
|
|||
|
||||
DPRINT("Console initialized\n");
|
||||
|
||||
/* All went right, so add the console to the list */
|
||||
Status = ConDrvInsertConsole(Console);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Fail */
|
||||
ConDrvDeleteConsole(Console);
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* The initialization is finished */
|
||||
DPRINT("Change state\n");
|
||||
Console->State = CONSOLE_RUNNING;
|
||||
|
||||
/* Return the newly created console to the caller and a success code too */
|
||||
*NewConsole = Console;
|
||||
/* The caller now has a newly initialized console */
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -334,7 +222,7 @@ ConDrvDeleteConsole(IN PCONSOLE Console)
|
|||
* Forbid validation of any console by other threads
|
||||
* during the deletion of this console.
|
||||
*/
|
||||
ConDrvLockConsoleListExclusive();
|
||||
// ConDrvLockConsoleListExclusive();
|
||||
|
||||
/*
|
||||
* If the console is already being destroyed, i.e. not running
|
||||
|
@ -343,8 +231,6 @@ ConDrvDeleteConsole(IN PCONSOLE Console)
|
|||
if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE) &&
|
||||
!ConDrvValidateConsoleUnsafe(Console, CONSOLE_INITIALIZING, TRUE))
|
||||
{
|
||||
/* Unlock the console list and return */
|
||||
ConDrvUnlockConsoleList();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -358,13 +244,12 @@ ConDrvDeleteConsole(IN PCONSOLE Console)
|
|||
/*
|
||||
* Allow other threads to finish their job: basically, unlock
|
||||
* all other calls to EnterCriticalSection(&Console->Lock); by
|
||||
* ConDrvValidateConsoleUnsafe functions so that they just see
|
||||
* ConDrvValidateConsoleUnsafe() functions so that they just see
|
||||
* that we are not in CONSOLE_RUNNING state anymore, or unlock
|
||||
* other concurrent calls to ConDrvDeleteConsole so that they
|
||||
* other concurrent calls to ConDrvDeleteConsole() so that they
|
||||
* can see that we are in fact already deleting the console.
|
||||
*/
|
||||
LeaveCriticalSection(&Console->Lock);
|
||||
ConDrvUnlockConsoleList();
|
||||
|
||||
/* Deregister the terminal */
|
||||
DPRINT("Deregister terminal\n");
|
||||
|
@ -377,11 +262,8 @@ ConDrvDeleteConsole(IN PCONSOLE Console)
|
|||
* ...unless to cancel console deletion ?).
|
||||
***/
|
||||
|
||||
ConDrvLockConsoleListExclusive();
|
||||
|
||||
if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_TERMINATING, TRUE))
|
||||
{
|
||||
ConDrvUnlockConsoleList();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -391,9 +273,6 @@ ConDrvDeleteConsole(IN PCONSOLE Console)
|
|||
/* We really delete the console. Reset the count to be sure. */
|
||||
Console->ReferenceCount = 0;
|
||||
|
||||
/* Remove the console from the list */
|
||||
RemoveConsole(Console);
|
||||
|
||||
/* Delete the last screen buffer */
|
||||
ConDrvDeleteScreenBuffer(Console->ActiveBuffer);
|
||||
Console->ActiveBuffer = NULL;
|
||||
|
@ -412,18 +291,34 @@ ConDrvDeleteConsole(IN PCONSOLE Console)
|
|||
LeaveCriticalSection(&Console->Lock);
|
||||
DPRINT("ConDrvDeleteConsole - Destroying lock\n");
|
||||
DeleteCriticalSection(&Console->Lock);
|
||||
DPRINT("ConDrvDeleteConsole - Lock destroyed ; freeing console\n");
|
||||
DPRINT("ConDrvDeleteConsole - Lock destroyed\n");
|
||||
|
||||
ConsoleFreeHeap(Console);
|
||||
DPRINT("ConDrvDeleteConsole - Console destroyed\n");
|
||||
|
||||
/* Unlock the console list and return */
|
||||
ConDrvUnlockConsoleList();
|
||||
}
|
||||
|
||||
|
||||
/* PUBLIC DRIVER APIS *********************************************************/
|
||||
|
||||
VOID NTAPI
|
||||
ConDrvPause(PCONSOLE Console)
|
||||
{
|
||||
/* In case we are already paused, just exit... */
|
||||
if (Console->ConsolePaused) return;
|
||||
|
||||
/* ... otherwise set the flag */
|
||||
Console->ConsolePaused = TRUE;
|
||||
}
|
||||
|
||||
VOID NTAPI
|
||||
ConDrvUnpause(PCONSOLE Console)
|
||||
{
|
||||
/* In case we are already unpaused, just exit... */
|
||||
if (!Console->ConsolePaused) return;
|
||||
|
||||
/* ... otherwise reset the flag */
|
||||
Console->ConsolePaused = FALSE;
|
||||
}
|
||||
|
||||
NTSTATUS NTAPI
|
||||
ConDrvGetConsoleMode(IN PCONSOLE Console,
|
||||
IN PCONSOLE_IO_OBJECT Object,
|
||||
|
|
|
@ -35,6 +35,7 @@ CSR_API(SrvInvalidateBitMapRect)
|
|||
{
|
||||
NTSTATUS Status;
|
||||
PCONSOLE_INVALIDATEDIBITS InvalidateDIBitsRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.InvalidateDIBitsRequest;
|
||||
PCONSRV_CONSOLE Console;
|
||||
PCONSOLE_SCREEN_BUFFER Buffer;
|
||||
|
||||
DPRINT("SrvInvalidateBitMapRect\n");
|
||||
|
@ -44,15 +45,17 @@ CSR_API(SrvInvalidateBitMapRect)
|
|||
&Buffer, GENERIC_READ, TRUE);
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
Console = (PCONSRV_CONSOLE)Buffer->Header.Console;
|
||||
|
||||
/* In text-mode only, draw the VDM buffer if present */
|
||||
if (GetType(Buffer) == TEXTMODE_BUFFER && Buffer->Header.Console->VDMBuffer)
|
||||
if (GetType(Buffer) == TEXTMODE_BUFFER && Console->VDMBuffer)
|
||||
{
|
||||
PTEXTMODE_SCREEN_BUFFER TextBuffer = (PTEXTMODE_SCREEN_BUFFER)Buffer;
|
||||
|
||||
/*Status =*/ ConDrvWriteConsoleOutputVDM(Buffer->Header.Console,
|
||||
TextBuffer,
|
||||
Buffer->Header.Console->VDMBuffer,
|
||||
Buffer->Header.Console->VDMBufferSize,
|
||||
Console->VDMBuffer,
|
||||
Console->VDMBufferSize,
|
||||
&InvalidateDIBitsRequest->Region);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,9 +27,12 @@
|
|||
|
||||
/* GLOBALS ********************************************************************/
|
||||
|
||||
// static ULONG CurrentConsoleID = 0;
|
||||
|
||||
/* The list of the ConSrv consoles */
|
||||
static ULONG ConsoleListSize;
|
||||
static PCONSRV_CONSOLE* ConsoleList;
|
||||
// static LIST_ENTRY ConDrvConsoleList;
|
||||
static RTL_RESOURCE ListLock;
|
||||
|
||||
#define ConSrvLockConsoleListExclusive() \
|
||||
|
@ -41,10 +44,34 @@ static RTL_RESOURCE ListLock;
|
|||
#define ConSrvUnlockConsoleList() \
|
||||
RtlReleaseResource(&ListLock)
|
||||
|
||||
#if 0
|
||||
static NTSTATUS
|
||||
ConDrvInsertConsole(
|
||||
IN PCONSOLE Console)
|
||||
{
|
||||
ASSERT(Console);
|
||||
|
||||
/* All went right, so add the console to the list */
|
||||
ConSrvLockConsoleListExclusive();
|
||||
|
||||
DPRINT("Insert in the list\n");
|
||||
InsertTailList(&ConDrvConsoleList, &Console->ListEntry);
|
||||
|
||||
// FIXME: Move this code to the caller function!!
|
||||
/* Get a new console ID */
|
||||
_InterlockedExchange((PLONG)&Console->ConsoleID, CurrentConsoleID);
|
||||
_InterlockedIncrement((PLONG)&CurrentConsoleID);
|
||||
|
||||
/* Unlock the console list and return success */
|
||||
ConSrvUnlockConsoleList();
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
static NTSTATUS
|
||||
InsertConsole(OUT PHANDLE Handle,
|
||||
IN PCONSRV_CONSOLE Console)
|
||||
InsertConsole(
|
||||
OUT PHANDLE Handle,
|
||||
IN PCONSRV_CONSOLE Console)
|
||||
{
|
||||
#define CONSOLE_HANDLES_INCREMENT 2 * 3
|
||||
|
||||
|
@ -163,49 +190,23 @@ RemoveConsoleByPointer(IN PCONSRV_CONSOLE Console)
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
BOOLEAN NTAPI
|
||||
ConSrvValidateConsole(OUT PCONSRV_CONSOLE* Console,
|
||||
IN HANDLE ConsoleHandle,
|
||||
IN CONSOLE_STATE ExpectedState,
|
||||
IN BOOLEAN LockConsole)
|
||||
#if 0
|
||||
static NTSTATUS
|
||||
RemoveConsole(IN PCONSOLE Console)
|
||||
{
|
||||
BOOLEAN RetVal = FALSE;
|
||||
PCONSRV_CONSOLE ValidatedConsole;
|
||||
// ASSERT(Console);
|
||||
if (!Console) return STATUS_INVALID_PARAMETER;
|
||||
|
||||
BOOLEAN ValidHandle = ((HandleToULong(ConsoleHandle) & 0x3) == 0x3);
|
||||
ULONG Index = HandleToULong(ConsoleHandle) >> 2;
|
||||
/* Remove the console from the list */
|
||||
ConSrvLockConsoleListExclusive();
|
||||
|
||||
if (!ValidHandle) return FALSE;
|
||||
RemoveEntryList(&Console->ListEntry);
|
||||
|
||||
if (!Console) return FALSE;
|
||||
*Console = NULL;
|
||||
|
||||
/*
|
||||
* Forbid creation or deletion of consoles when
|
||||
* checking for the existence of a console.
|
||||
*/
|
||||
ConSrvLockConsoleListShared();
|
||||
|
||||
if (Index >= ConsoleListSize ||
|
||||
(ValidatedConsole = ConsoleList[Index]) == NULL)
|
||||
{
|
||||
/* Unlock the console list and return */
|
||||
ConSrvUnlockConsoleList();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ValidatedConsole = ConsoleList[Index];
|
||||
|
||||
/* Unlock the console list and return */
|
||||
/* Unlock the console list and return success */
|
||||
ConSrvUnlockConsoleList();
|
||||
|
||||
RetVal = ConDrvValidateConsoleUnsafe((PCONSOLE)ValidatedConsole,
|
||||
ExpectedState,
|
||||
LockConsole);
|
||||
if (RetVal) *Console = ValidatedConsole;
|
||||
|
||||
return RetVal;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* PRIVATE FUNCTIONS **********************************************************/
|
||||
|
@ -239,32 +240,51 @@ ConsoleFreeUnicodeString(IN PUNICODE_STRING UnicodeString)
|
|||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
ConioPause(PCONSRV_CONSOLE Console, UCHAR Flags)
|
||||
{
|
||||
Console->PauseFlags |= Flags;
|
||||
ConDrvPause((PCONSOLE)Console);
|
||||
}
|
||||
|
||||
VOID
|
||||
ConioUnpause(PCONSRV_CONSOLE Console, UCHAR Flags)
|
||||
{
|
||||
Console->PauseFlags &= ~Flags;
|
||||
/* CONSOLE VALIDATION FUNCTIONS ***********************************************/
|
||||
|
||||
// if ((Console->PauseFlags & (PAUSED_FROM_KEYBOARD | PAUSED_FROM_SCROLLBAR | PAUSED_FROM_SELECTION)) == 0)
|
||||
if (Console->PauseFlags == 0)
|
||||
BOOLEAN NTAPI
|
||||
ConSrvValidateConsole(OUT PCONSRV_CONSOLE* Console,
|
||||
IN HANDLE ConsoleHandle,
|
||||
IN CONSOLE_STATE ExpectedState,
|
||||
IN BOOLEAN LockConsole)
|
||||
{
|
||||
BOOLEAN RetVal = FALSE;
|
||||
PCONSRV_CONSOLE ValidatedConsole;
|
||||
|
||||
BOOLEAN ValidHandle = ((HandleToULong(ConsoleHandle) & 0x3) == 0x3);
|
||||
ULONG Index = HandleToULong(ConsoleHandle) >> 2;
|
||||
|
||||
if (!ValidHandle) return FALSE;
|
||||
|
||||
if (!Console) return FALSE;
|
||||
*Console = NULL;
|
||||
|
||||
/*
|
||||
* Forbid creation or deletion of consoles when
|
||||
* checking for the existence of a console.
|
||||
*/
|
||||
ConSrvLockConsoleListShared();
|
||||
|
||||
if (Index >= ConsoleListSize ||
|
||||
(ValidatedConsole = ConsoleList[Index]) == NULL)
|
||||
{
|
||||
ConDrvUnpause((PCONSOLE)Console);
|
||||
|
||||
CsrNotifyWait(&Console->WriteWaitQueue,
|
||||
TRUE,
|
||||
NULL,
|
||||
NULL);
|
||||
if (!IsListEmpty(&Console->WriteWaitQueue))
|
||||
{
|
||||
CsrDereferenceWait(&Console->WriteWaitQueue);
|
||||
}
|
||||
/* Unlock the console list and return */
|
||||
ConSrvUnlockConsoleList();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ValidatedConsole = ConsoleList[Index];
|
||||
|
||||
/* Unlock the console list */
|
||||
ConSrvUnlockConsoleList();
|
||||
|
||||
RetVal = ConDrvValidateConsoleUnsafe((PCONSOLE)ValidatedConsole,
|
||||
ExpectedState,
|
||||
LockConsole);
|
||||
if (RetVal) *Console = ValidatedConsole;
|
||||
|
||||
return RetVal;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
|
@ -331,6 +351,7 @@ ConSrvInitConsoleSupport(VOID)
|
|||
/* Initialize the console list and its lock */
|
||||
ConsoleListSize = 0;
|
||||
ConsoleList = NULL;
|
||||
// InitializeListHead(&ConDrvConsoleList);
|
||||
RtlInitializeResource(&ListLock);
|
||||
|
||||
/* Should call LoadKeyboardLayout */
|
||||
|
@ -645,15 +666,27 @@ ConSrvInitConsole(OUT PHANDLE NewConsoleHandle,
|
|||
DrvConsoleInfo.ScreenAttrib = ConsoleInfo->ScreenAttributes;
|
||||
DrvConsoleInfo.PopupAttrib = ConsoleInfo->PopupAttributes;
|
||||
DrvConsoleInfo.CodePage = ConsoleInfo->CodePage;
|
||||
Status = ConDrvInitConsole(&Console, &DrvConsoleInfo);
|
||||
|
||||
/*
|
||||
* Allocate a new console
|
||||
*/
|
||||
Console = ConsoleAllocHeap(HEAP_ZERO_MEMORY, sizeof(*Console));
|
||||
if (Console == NULL)
|
||||
{
|
||||
DPRINT1("Not enough memory for console creation.\n");
|
||||
ConSrvDeinitTerminal(&Terminal);
|
||||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
Status = ConDrvInitConsole((PCONSOLE)Console, &DrvConsoleInfo);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("Creating a new console failed, Status = 0x%08lx\n", Status);
|
||||
ConsoleFreeHeap(Console);
|
||||
ConSrvDeinitTerminal(&Terminal);
|
||||
return Status;
|
||||
}
|
||||
|
||||
ASSERT(Console);
|
||||
DPRINT("Console initialized\n");
|
||||
|
||||
/*** Register ConSrv features ***/
|
||||
|
@ -684,6 +717,7 @@ ConSrvInitConsole(OUT PHANDLE NewConsoleHandle,
|
|||
#endif
|
||||
|
||||
/* Initialize process support */
|
||||
// InitProcessSupport(Console);
|
||||
InitializeListHead(&Console->ProcessList);
|
||||
Console->NotifiedLastCloseProcess = NULL;
|
||||
Console->NotifyLastClose = FALSE;
|
||||
|
@ -695,6 +729,7 @@ ConSrvInitConsole(OUT PHANDLE NewConsoleHandle,
|
|||
InitializeListHead(&Console->WriteWaitQueue);
|
||||
|
||||
/* Initialize the alias and history buffers */
|
||||
// InitAliasesHistory(Console);
|
||||
Console->Aliases = NULL;
|
||||
InitializeListHead(&Console->HistoryBuffers);
|
||||
Console->NumberOfHistoryBuffers = 0;
|
||||
|
@ -703,6 +738,7 @@ ConSrvInitConsole(OUT PHANDLE NewConsoleHandle,
|
|||
Console->HistoryNoDup = ConsoleInfo->HistoryNoDup;
|
||||
|
||||
/* Initialize the Input Line Discipline */
|
||||
// InitLineInput(Console);
|
||||
Console->LineBuffer = NULL;
|
||||
Console->LinePos = Console->LineMaxSize = Console->LineSize = 0;
|
||||
Console->LineComplete = Console->LineUpPressed = FALSE;
|
||||
|
@ -724,7 +760,7 @@ ConSrvInitConsole(OUT PHANDLE NewConsoleHandle,
|
|||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("NtCreateEvent(InitEvents[INIT_SUCCESS]) failed: %lu\n", Status);
|
||||
ConDrvDeleteConsole(Console);
|
||||
ConDrvDeleteConsole((PCONSOLE)Console);
|
||||
ConSrvDeinitTerminal(&Terminal);
|
||||
return Status;
|
||||
}
|
||||
|
@ -734,7 +770,7 @@ ConSrvInitConsole(OUT PHANDLE NewConsoleHandle,
|
|||
{
|
||||
DPRINT1("NtCreateEvent(InitEvents[INIT_FAILURE]) failed: %lu\n", Status);
|
||||
NtClose(Console->InitEvents[INIT_SUCCESS]);
|
||||
ConDrvDeleteConsole(Console);
|
||||
ConDrvDeleteConsole((PCONSOLE)Console);
|
||||
ConSrvDeinitTerminal(&Terminal);
|
||||
return Status;
|
||||
}
|
||||
|
@ -743,19 +779,28 @@ ConSrvInitConsole(OUT PHANDLE NewConsoleHandle,
|
|||
* Attach the ConSrv terminal to the console.
|
||||
* This call makes a copy of our local Terminal variable.
|
||||
*/
|
||||
Status = ConDrvAttachTerminal(Console, &Terminal);
|
||||
Status = ConDrvAttachTerminal((PCONSOLE)Console, &Terminal);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("Failed to register terminal to the given console, Status = 0x%08lx\n", Status);
|
||||
NtClose(Console->InitEvents[INIT_FAILURE]);
|
||||
NtClose(Console->InitEvents[INIT_SUCCESS]);
|
||||
ConDrvDeleteConsole(Console);
|
||||
ConDrvDeleteConsole((PCONSOLE)Console);
|
||||
ConSrvDeinitTerminal(&Terminal);
|
||||
return Status;
|
||||
}
|
||||
DPRINT("Terminal attached\n");
|
||||
|
||||
/* All went right, so add the console to the list */
|
||||
#if 0
|
||||
Status = ConDrvInsertConsole((PCONSOLE)Console);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Fail */
|
||||
ConDrvDeleteConsole((PCONSOLE)Console);
|
||||
return Status;
|
||||
}
|
||||
#endif
|
||||
Status = InsertConsole(&ConsoleHandle, Console);
|
||||
|
||||
// FIXME! We do not support at all asynchronous console creation!
|
||||
|
@ -773,7 +818,10 @@ ConSrvDeleteConsole(PCONSRV_CONSOLE Console)
|
|||
{
|
||||
DPRINT("ConSrvDeleteConsole\n");
|
||||
|
||||
// FIXME: Send a terminate message to all the processes owning this console
|
||||
// FIXME: Send a terminate message to all the processes owning this console.
|
||||
// NOTE: In principle there should be none, because such processes would
|
||||
// have a reference to the console and thus this function would not have
|
||||
// been called in the first place.
|
||||
|
||||
/* Remove the console from the list */
|
||||
RemoveConsoleByPointer(Console);
|
||||
|
@ -802,9 +850,36 @@ ConSrvDeleteConsole(PCONSRV_CONSOLE Console)
|
|||
}
|
||||
|
||||
|
||||
VOID
|
||||
ConioPause(PCONSRV_CONSOLE Console, UCHAR Flags)
|
||||
{
|
||||
Console->PauseFlags |= Flags;
|
||||
ConDrvPause((PCONSOLE)Console);
|
||||
}
|
||||
|
||||
VOID
|
||||
ConioUnpause(PCONSRV_CONSOLE Console, UCHAR Flags)
|
||||
{
|
||||
Console->PauseFlags &= ~Flags;
|
||||
|
||||
// if ((Console->PauseFlags & (PAUSED_FROM_KEYBOARD | PAUSED_FROM_SCROLLBAR | PAUSED_FROM_SELECTION)) == 0)
|
||||
if (Console->PauseFlags == 0)
|
||||
{
|
||||
ConDrvUnpause((PCONSOLE)Console);
|
||||
|
||||
CsrNotifyWait(&Console->WriteWaitQueue,
|
||||
TRUE,
|
||||
NULL,
|
||||
NULL);
|
||||
if (!IsListEmpty(&Console->WriteWaitQueue))
|
||||
{
|
||||
CsrDereferenceWait(&Console->WriteWaitQueue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* CONSOLE PROCESS MANAGEMENT FUNCTIONS ***************************************/
|
||||
|
||||
NTSTATUS
|
||||
ConSrvConsoleCtrlEventTimeout(IN ULONG CtrlEvent,
|
||||
|
@ -1157,6 +1232,7 @@ CSR_API(SrvGetConsoleMode)
|
|||
{
|
||||
NTSTATUS Status;
|
||||
PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleModeRequest;
|
||||
PCONSRV_CONSOLE Console;
|
||||
PCONSOLE_IO_OBJECT Object;
|
||||
|
||||
PULONG ConsoleMode = &ConsoleModeRequest->Mode;
|
||||
|
@ -1166,9 +1242,10 @@ CSR_API(SrvGetConsoleMode)
|
|||
&Object, NULL, GENERIC_READ, TRUE, 0);
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
Console = (PCONSRV_CONSOLE)Object->Console;
|
||||
|
||||
/* Get the standard console modes */
|
||||
Status = ConDrvGetConsoleMode(Object->Console, Object,
|
||||
ConsoleMode);
|
||||
Status = ConDrvGetConsoleMode(Object->Console, Object, ConsoleMode);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
/*
|
||||
|
@ -1177,13 +1254,13 @@ CSR_API(SrvGetConsoleMode)
|
|||
*/
|
||||
if (INPUT_BUFFER == Object->Type)
|
||||
{
|
||||
if (Object->Console->InsertMode || Object->Console->QuickEdit)
|
||||
if (Console->InsertMode || Console->QuickEdit)
|
||||
{
|
||||
/* Windows also adds ENABLE_EXTENDED_FLAGS, even if it's not documented on MSDN */
|
||||
*ConsoleMode |= ENABLE_EXTENDED_FLAGS;
|
||||
|
||||
if (Object->Console->InsertMode) *ConsoleMode |= ENABLE_INSERT_MODE;
|
||||
if (Object->Console->QuickEdit ) *ConsoleMode |= ENABLE_QUICK_EDIT_MODE;
|
||||
if (Console->InsertMode) *ConsoleMode |= ENABLE_INSERT_MODE;
|
||||
if (Console->QuickEdit ) *ConsoleMode |= ENABLE_QUICK_EDIT_MODE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1205,6 +1282,7 @@ CSR_API(SrvSetConsoleMode)
|
|||
|
||||
NTSTATUS Status;
|
||||
PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleModeRequest;
|
||||
PCONSRV_CONSOLE Console;
|
||||
PCONSOLE_IO_OBJECT Object;
|
||||
|
||||
ULONG ConsoleMode = ConsoleModeRequest->Mode;
|
||||
|
@ -1214,10 +1292,11 @@ CSR_API(SrvSetConsoleMode)
|
|||
&Object, NULL, GENERIC_WRITE, TRUE, 0);
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
Console = (PCONSRV_CONSOLE)Object->Console;
|
||||
|
||||
/* Set the standard console modes (without the CONSRV-specific input modes) */
|
||||
ConsoleMode &= ~CONSOLE_VALID_CONTROL_MODES; // Remove CONSRV-specific input modes.
|
||||
Status = ConDrvSetConsoleMode(Object->Console, Object,
|
||||
ConsoleMode);
|
||||
Status = ConDrvSetConsoleMode(Object->Console, Object, ConsoleMode);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
/*
|
||||
|
@ -1240,8 +1319,8 @@ CSR_API(SrvSetConsoleMode)
|
|||
}
|
||||
else
|
||||
{
|
||||
Object->Console->InsertMode = !!(ConsoleMode & ENABLE_INSERT_MODE);
|
||||
Object->Console->QuickEdit = !!(ConsoleMode & ENABLE_QUICK_EDIT_MODE);
|
||||
Console->InsertMode = !!(ConsoleMode & ENABLE_INSERT_MODE);
|
||||
Console->QuickEdit = !!(ConsoleMode & ENABLE_QUICK_EDIT_MODE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1407,7 +1486,7 @@ CSR_API(SrvGetConsoleCP)
|
|||
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
Status = ConDrvGetConsoleCP(Console,
|
||||
Status = ConDrvGetConsoleCP((PCONSOLE)Console,
|
||||
&GetConsoleCPRequest->CodePage,
|
||||
GetConsoleCPRequest->OutputCP);
|
||||
|
||||
|
@ -1432,7 +1511,7 @@ CSR_API(SrvSetConsoleCP)
|
|||
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
Status = ConDrvSetConsoleCP(Console,
|
||||
Status = ConDrvSetConsoleCP((PCONSOLE)Console,
|
||||
SetConsoleCPRequest->CodePage,
|
||||
SetConsoleCPRequest->OutputCP);
|
||||
|
||||
|
|
|
@ -60,14 +60,8 @@ typedef struct ConsoleInput_t
|
|||
INPUT_RECORD InputEvent;
|
||||
} ConsoleInput;
|
||||
|
||||
// Helper for code refactoring
|
||||
// #define USE_NEW_CONSOLE_WAY
|
||||
|
||||
#ifndef USE_NEW_CONSOLE_WAY
|
||||
#include "include/conio.h"
|
||||
#else
|
||||
#include "include/conio_winsrv.h"
|
||||
#endif
|
||||
|
||||
#include "include/console.h"
|
||||
#include "include/settings.h"
|
||||
|
|
|
@ -72,7 +72,7 @@ CSR_API(SrvGetConsoleHardwareState)
|
|||
return Status;
|
||||
}
|
||||
|
||||
Console = Buff->Header.Console;
|
||||
Console = (PCONSRV_CONSOLE)Buff->Header.Console;
|
||||
HardwareStateRequest->State = Console->HardwareState;
|
||||
|
||||
ConSrvReleaseScreenBuffer(Buff, TRUE);
|
||||
|
@ -104,7 +104,7 @@ CSR_API(SrvSetConsoleHardwareState)
|
|||
}
|
||||
|
||||
DPRINT("Setting console hardware state.\n");
|
||||
Console = Buff->Header.Console;
|
||||
Console = (PCONSRV_CONSOLE)Buff->Header.Console;
|
||||
Status = SetConsoleHardwareState(Console, HardwareStateRequest->State);
|
||||
|
||||
ConSrvReleaseScreenBuffer(Buff, TRUE);
|
||||
|
@ -168,7 +168,7 @@ CSR_API(SrvGetLargestConsoleWindowSize)
|
|||
{
|
||||
NTSTATUS Status;
|
||||
PCONSOLE_GETLARGESTWINDOWSIZE GetLargestWindowSizeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetLargestWindowSizeRequest;
|
||||
PCONSOLE /*PCONSRV_CONSOLE*/ Console;
|
||||
PCONSRV_CONSOLE Console;
|
||||
PCONSOLE_SCREEN_BUFFER Buff;
|
||||
|
||||
Status = ConSrvGetTextModeBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
|
||||
|
@ -178,7 +178,7 @@ CSR_API(SrvGetLargestConsoleWindowSize)
|
|||
TRUE);
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
Console = Buff->Header.Console;
|
||||
Console = (PCONSRV_CONSOLE)Buff->Header.Console;
|
||||
|
||||
/*
|
||||
* Retrieve the largest possible console window size, without
|
||||
|
@ -196,7 +196,7 @@ CSR_API(SrvShowConsoleCursor)
|
|||
{
|
||||
NTSTATUS Status;
|
||||
PCONSOLE_SHOWCURSOR ShowCursorRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ShowCursorRequest;
|
||||
PCONSOLE /*PCONSRV_CONSOLE*/ Console;
|
||||
PCONSRV_CONSOLE Console;
|
||||
PCONSOLE_SCREEN_BUFFER Buff;
|
||||
|
||||
Status = ConSrvGetScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
|
||||
|
@ -206,7 +206,7 @@ CSR_API(SrvShowConsoleCursor)
|
|||
TRUE);
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
Console = Buff->Header.Console;
|
||||
Console = (PCONSRV_CONSOLE)Buff->Header.Console;
|
||||
|
||||
ShowCursorRequest->RefCount = TermShowMouseCursor(Console, ShowCursorRequest->Show);
|
||||
|
||||
|
@ -380,7 +380,7 @@ CSR_API(SrvGetConsoleNumberOfFonts)
|
|||
{
|
||||
NTSTATUS Status;
|
||||
PCONSOLE_GETNUMFONTS GetNumFontsRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetNumFontsRequest;
|
||||
PCONSOLE /*PCONSRV_CONSOLE*/ Console;
|
||||
PCONSRV_CONSOLE Console;
|
||||
|
||||
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
|
||||
&Console, TRUE);
|
||||
|
@ -400,7 +400,7 @@ CSR_API(SrvGetConsoleFontInfo)
|
|||
{
|
||||
NTSTATUS Status;
|
||||
PCONSOLE_GETFONTINFO GetFontInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetFontInfoRequest;
|
||||
// PCONSOLE /*PCONSRV_CONSOLE*/ Console;
|
||||
// PCONSRV_CONSOLE Console;
|
||||
PCONSOLE_SCREEN_BUFFER Buff;
|
||||
|
||||
Status = ConSrvGetTextModeBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
|
||||
|
@ -411,7 +411,7 @@ CSR_API(SrvGetConsoleFontInfo)
|
|||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
// FIXME!
|
||||
// Console = Buff->Header.Console;
|
||||
// Console = (PCONSRV_CONSOLE)Buff->Header.Console;
|
||||
// TermGetFontInfo(Console, ...);
|
||||
DPRINT1("%s not yet implemented\n", __FUNCTION__);
|
||||
GetFontInfoRequest->NumFonts = 0;
|
||||
|
@ -425,7 +425,7 @@ CSR_API(SrvGetConsoleFontSize)
|
|||
{
|
||||
NTSTATUS Status;
|
||||
PCONSOLE_GETFONTSIZE GetFontSizeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetFontSizeRequest;
|
||||
// PCONSOLE /*PCONSRV_CONSOLE*/ Console;
|
||||
// PCONSRV_CONSOLE Console;
|
||||
PCONSOLE_SCREEN_BUFFER Buff;
|
||||
|
||||
Status = ConSrvGetTextModeBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
|
||||
|
@ -436,7 +436,7 @@ CSR_API(SrvGetConsoleFontSize)
|
|||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
// FIXME!
|
||||
// Console = Buff->Header.Console;
|
||||
// Console = (PCONSRV_CONSOLE)Buff->Header.Console;
|
||||
// TermGetFontSize(Console, ...);
|
||||
DPRINT1("%s not yet implemented\n", __FUNCTION__);
|
||||
|
||||
|
@ -449,7 +449,7 @@ CSR_API(SrvGetConsoleCurrentFont)
|
|||
{
|
||||
NTSTATUS Status;
|
||||
PCONSOLE_GETCURRENTFONT GetCurrentFontRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetCurrentFontRequest;
|
||||
// PCONSOLE /*PCONSRV_CONSOLE*/ Console;
|
||||
// PCONSRV_CONSOLE Console;
|
||||
PCONSOLE_SCREEN_BUFFER Buff;
|
||||
|
||||
Status = ConSrvGetTextModeBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
|
||||
|
@ -460,7 +460,7 @@ CSR_API(SrvGetConsoleCurrentFont)
|
|||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
// FIXME!
|
||||
// Console = Buff->Header.Console;
|
||||
// Console = (PCONSRV_CONSOLE)Buff->Header.Console;
|
||||
// TermGetCurrentFont(Console, ...);
|
||||
DPRINT1("%s not yet implemented\n", __FUNCTION__);
|
||||
GetCurrentFontRequest->FontIndex = 0;
|
||||
|
@ -474,7 +474,7 @@ CSR_API(SrvSetConsoleFont)
|
|||
{
|
||||
NTSTATUS Status;
|
||||
PCONSOLE_SETFONT SetFontRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetFontRequest;
|
||||
// PCONSOLE /*PCONSRV_CONSOLE*/ Console;
|
||||
// PCONSRV_CONSOLE Console;
|
||||
PCONSOLE_SCREEN_BUFFER Buff;
|
||||
|
||||
Status = ConSrvGetTextModeBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
|
||||
|
@ -485,7 +485,7 @@ CSR_API(SrvSetConsoleFont)
|
|||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
// FIXME!
|
||||
// Console = Buff->Header.Console;
|
||||
// Console = (PCONSRV_CONSOLE)Buff->Header.Console;
|
||||
// TermSetFont(Console, ...);
|
||||
DPRINT1("%s not yet implemented\n", __FUNCTION__);
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ GuiPaintGraphicsBuffer(PGRAPHICS_SCREEN_BUFFER Buffer,
|
|||
PRECT rcView,
|
||||
PRECT rcFramebuffer)
|
||||
{
|
||||
PCONSRV_CONSOLE Console = Buffer->Header.Console;
|
||||
PCONSRV_CONSOLE Console = (PCONSRV_CONSOLE)Buffer->Header.Console;
|
||||
// ASSERT(Console == GuiData->Console);
|
||||
|
||||
ConioInitLongRect(rcFramebuffer, 0, 0, 0, 0);
|
||||
|
|
|
@ -768,7 +768,7 @@ GuiSetActiveScreenBuffer(IN OUT PFRONTEND This)
|
|||
GuiData->WindowSizeLock = TRUE;
|
||||
|
||||
InterlockedExchangePointer((PVOID*)&GuiData->ActiveBuffer,
|
||||
ConDrvGetActiveScreenBuffer(GuiData->Console));
|
||||
ConDrvGetActiveScreenBuffer((PCONSOLE)GuiData->Console));
|
||||
|
||||
GuiData->WindowSizeLock = FALSE;
|
||||
LeaveCriticalSection(&GuiData->Lock);
|
||||
|
|
|
@ -343,7 +343,7 @@ GuiPasteToTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
|
|||
* This function supposes that the system clipboard was opened.
|
||||
*/
|
||||
|
||||
PCONSRV_CONSOLE Console = Buffer->Header.Console;
|
||||
PCONSRV_CONSOLE Console = (PCONSRV_CONSOLE)Buffer->Header.Console;
|
||||
|
||||
HANDLE hData;
|
||||
LPWSTR pszText;
|
||||
|
@ -369,7 +369,7 @@ GuiPaintCaret(
|
|||
ULONG LeftColumn,
|
||||
ULONG RightColumn)
|
||||
{
|
||||
PCONSRV_CONSOLE Console = Buffer->Header.Console;
|
||||
PCONSRV_CONSOLE Console = (PCONSRV_CONSOLE)Buffer->Header.Console;
|
||||
|
||||
ULONG CursorX, CursorY, CursorHeight;
|
||||
HBRUSH CursorBrush, OldBrush;
|
||||
|
@ -435,7 +435,7 @@ GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
|
|||
PRECT rcView,
|
||||
PRECT rcFramebuffer)
|
||||
{
|
||||
PCONSRV_CONSOLE Console = Buffer->Header.Console;
|
||||
PCONSRV_CONSOLE Console = (PCONSRV_CONSOLE)Buffer->Header.Console;
|
||||
ULONG TopLine, BottomLine, LeftColumn, RightColumn;
|
||||
ULONG Line, Char, Start;
|
||||
PCHAR_INFO From;
|
||||
|
|
|
@ -262,21 +262,22 @@ ConSrvTermInitTerminal(IN OUT PTERMINAL This,
|
|||
{
|
||||
NTSTATUS Status;
|
||||
PFRONTEND FrontEnd = This->Context;
|
||||
PCONSRV_CONSOLE ConSrvConsole = (PCONSRV_CONSOLE)Console;
|
||||
|
||||
/* Initialize the console pointer for our frontend */
|
||||
FrontEnd->Console = Console;
|
||||
FrontEnd->Console = ConSrvConsole;
|
||||
|
||||
/** HACK HACK!! Copy FrontEnd into the console!! **/
|
||||
DPRINT("Using FrontEndIFace HACK(1), should be removed after proper implementation!\n");
|
||||
Console->FrontEndIFace = *FrontEnd;
|
||||
ConSrvConsole->FrontEndIFace = *FrontEnd;
|
||||
|
||||
Status = FrontEnd->Vtbl->InitFrontEnd(FrontEnd, FrontEnd->Console);
|
||||
Status = FrontEnd->Vtbl->InitFrontEnd(FrontEnd, ConSrvConsole);
|
||||
if (!NT_SUCCESS(Status))
|
||||
DPRINT1("InitFrontEnd failed, Status = 0x%08lx\n", Status);
|
||||
|
||||
/** HACK HACK!! Be sure FrontEndIFace is correctly updated in the console!! **/
|
||||
DPRINT("Using FrontEndIFace HACK(2), should be removed after proper implementation!\n");
|
||||
Console->FrontEndIFace = *FrontEnd;
|
||||
ConSrvConsole->FrontEndIFace = *FrontEnd;
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -969,11 +970,12 @@ static TERMINAL_VTBL ConSrvTermVtbl =
|
|||
VOID
|
||||
ResetFrontEnd(IN PCONSOLE Console)
|
||||
{
|
||||
PCONSRV_CONSOLE ConSrvConsole = (PCONSRV_CONSOLE)Console;
|
||||
if (!Console) return;
|
||||
|
||||
/* Reinitialize the frontend interface */
|
||||
RtlZeroMemory(&Console->FrontEndIFace, sizeof(Console->FrontEndIFace));
|
||||
Console->FrontEndIFace.Vtbl = &ConSrvTermVtbl;
|
||||
RtlZeroMemory(&ConSrvConsole->FrontEndIFace, sizeof(ConSrvConsole->FrontEndIFace));
|
||||
ConSrvConsole->FrontEndIFace.Vtbl = &ConSrvTermVtbl;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ ConSrvCloseHandle(IN PCONSOLE_IO_HANDLE Handle)
|
|||
if (Object->Type == INPUT_BUFFER)
|
||||
{
|
||||
// PCONSOLE_INPUT_BUFFER InputBuffer = (PCONSOLE_INPUT_BUFFER)Object;
|
||||
PCONSOLE Console = Object->Console;
|
||||
PCONSRV_CONSOLE Console = (PCONSRV_CONSOLE)Object->Console;
|
||||
|
||||
/*
|
||||
* Wake up all the writing waiters related to this handle for this
|
||||
|
@ -125,7 +125,7 @@ static VOID ConSrvFreeHandlesTable(PCONSOLE_PROCESS_DATA ProcessData);
|
|||
|
||||
static NTSTATUS
|
||||
ConSrvInitHandlesTable(IN OUT PCONSOLE_PROCESS_DATA ProcessData,
|
||||
IN PCONSOLE Console,
|
||||
IN PCONSRV_CONSOLE Console,
|
||||
OUT PHANDLE pInputHandle,
|
||||
OUT PHANDLE pOutputHandle,
|
||||
OUT PHANDLE pErrorHandle)
|
||||
|
@ -410,7 +410,7 @@ ConSrvGetObject(IN PCONSOLE_PROCESS_DATA ProcessData,
|
|||
ULONG Index = HandleToULong(Handle) >> 2;
|
||||
PCONSOLE_IO_HANDLE HandleEntry = NULL;
|
||||
PCONSOLE_IO_OBJECT ObjectEntry = NULL;
|
||||
// PCONSOLE ObjectConsole;
|
||||
// PCONSRV_CONSOLE ObjectConsole;
|
||||
|
||||
ASSERT(Object);
|
||||
if (Entry) *Entry = NULL;
|
||||
|
@ -465,7 +465,8 @@ VOID
|
|||
ConSrvReleaseObject(IN PCONSOLE_IO_OBJECT Object,
|
||||
IN BOOLEAN IsConsoleLocked)
|
||||
{
|
||||
ConSrvReleaseConsole(Object->Console, IsConsoleLocked);
|
||||
PCONSRV_CONSOLE ObjectConsole = (PCONSRV_CONSOLE)Object->Console;
|
||||
ConSrvReleaseConsole(ObjectConsole, IsConsoleLocked);
|
||||
}
|
||||
|
||||
|
||||
|
@ -611,7 +612,7 @@ ConSrvInheritConsole(PCONSOLE_PROCESS_DATA ProcessData,
|
|||
PCONSOLE_START_INFO ConsoleStartInfo)
|
||||
{
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
PCONSOLE Console;
|
||||
PCONSRV_CONSOLE Console;
|
||||
|
||||
/* Validate and lock the console */
|
||||
if (!ConSrvValidateConsole(&Console,
|
||||
|
@ -734,7 +735,7 @@ Quit:
|
|||
NTSTATUS
|
||||
ConSrvRemoveConsole(PCONSOLE_PROCESS_DATA ProcessData)
|
||||
{
|
||||
PCONSOLE Console;
|
||||
PCONSRV_CONSOLE Console;
|
||||
PCONSOLE_PROCESS_DATA ConsoleLeaderProcess;
|
||||
|
||||
DPRINT("ConSrvRemoveConsole\n");
|
||||
|
@ -808,6 +809,7 @@ ConSrvRemoveConsole(PCONSOLE_PROCESS_DATA ProcessData)
|
|||
|
||||
/* PUBLIC SERVER APIS *********************************************************/
|
||||
|
||||
/* API_NUMBER: ConsolepOpenConsole */
|
||||
CSR_API(SrvOpenConsole)
|
||||
{
|
||||
/*
|
||||
|
@ -818,7 +820,7 @@ CSR_API(SrvOpenConsole)
|
|||
NTSTATUS Status;
|
||||
PCONSOLE_OPENCONSOLE OpenConsoleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.OpenConsoleRequest;
|
||||
PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process);
|
||||
PCONSOLE Console;
|
||||
PCONSRV_CONSOLE Console;
|
||||
|
||||
DWORD DesiredAccess = OpenConsoleRequest->DesiredAccess;
|
||||
DWORD ShareMode = OpenConsoleRequest->ShareMode;
|
||||
|
@ -877,7 +879,7 @@ CSR_API(SrvDuplicateHandle)
|
|||
NTSTATUS Status;
|
||||
PCONSOLE_DUPLICATEHANDLE DuplicateHandleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.DuplicateHandleRequest;
|
||||
PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process);
|
||||
PCONSOLE Console;
|
||||
PCONSRV_CONSOLE Console;
|
||||
|
||||
HANDLE SourceHandle = DuplicateHandleRequest->SourceHandle;
|
||||
ULONG Index = HandleToULong(SourceHandle) >> 2;
|
||||
|
@ -951,7 +953,7 @@ CSR_API(SrvGetHandleInformation)
|
|||
NTSTATUS Status;
|
||||
PCONSOLE_GETHANDLEINFO GetHandleInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetHandleInfoRequest;
|
||||
PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process);
|
||||
PCONSOLE Console;
|
||||
PCONSRV_CONSOLE Console;
|
||||
|
||||
HANDLE Handle = GetHandleInfoRequest->Handle;
|
||||
ULONG Index = HandleToULong(Handle) >> 2;
|
||||
|
@ -1000,7 +1002,7 @@ CSR_API(SrvSetHandleInformation)
|
|||
NTSTATUS Status;
|
||||
PCONSOLE_SETHANDLEINFO SetHandleInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetHandleInfoRequest;
|
||||
PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process);
|
||||
PCONSOLE Console;
|
||||
PCONSRV_CONSOLE Console;
|
||||
|
||||
HANDLE Handle = SetHandleInfoRequest->Handle;
|
||||
ULONG Index = HandleToULong(Handle) >> 2;
|
||||
|
@ -1051,7 +1053,7 @@ CSR_API(SrvCloseHandle)
|
|||
NTSTATUS Status;
|
||||
PCONSOLE_CLOSEHANDLE CloseHandleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.CloseHandleRequest;
|
||||
PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process);
|
||||
PCONSOLE Console;
|
||||
PCONSRV_CONSOLE Console;
|
||||
|
||||
Status = ConSrvGetConsole(ProcessData, &Console, TRUE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
|
@ -1072,7 +1074,7 @@ CSR_API(SrvVerifyConsoleIoHandle)
|
|||
NTSTATUS Status;
|
||||
PCONSOLE_VERIFYHANDLE VerifyHandleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.VerifyHandleRequest;
|
||||
PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process);
|
||||
PCONSOLE Console;
|
||||
PCONSRV_CONSOLE Console;
|
||||
|
||||
HANDLE IoHandle = VerifyHandleRequest->Handle;
|
||||
ULONG Index = HandleToULong(IoHandle) >> 2;
|
||||
|
|
|
@ -12,22 +12,6 @@
|
|||
|
||||
#include "rect.h"
|
||||
|
||||
// This is ALMOST a HACK!!!!!!!
|
||||
// Helpers for code refactoring
|
||||
#ifdef USE_NEW_CONSOLE_WAY
|
||||
|
||||
#define _CONSRV_CONSOLE _WINSRV_CONSOLE
|
||||
#define CONSRV_CONSOLE WINSRV_CONSOLE
|
||||
#define PCONSRV_CONSOLE PWINSRV_CONSOLE
|
||||
|
||||
#else
|
||||
|
||||
#define _CONSRV_CONSOLE _CONSOLE
|
||||
#define CONSRV_CONSOLE CONSOLE
|
||||
#define PCONSRV_CONSOLE PCONSOLE
|
||||
|
||||
#endif
|
||||
|
||||
/* Default attributes */
|
||||
#define DEFAULT_SCREEN_ATTRIB (FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED)
|
||||
#define DEFAULT_POPUP_ATTRIB (FOREGROUND_BLUE | FOREGROUND_RED | \
|
||||
|
@ -308,27 +292,12 @@ typedef enum _CONSOLE_STATE
|
|||
CONSOLE_IN_DESTRUCTION /* Console in destruction */
|
||||
} CONSOLE_STATE, *PCONSOLE_STATE;
|
||||
|
||||
// HACK!!
|
||||
struct _CONSOLE;
|
||||
/* HACK: */ typedef struct _CONSOLE *PCONSOLE;
|
||||
#ifndef USE_NEW_CONSOLE_WAY
|
||||
#include "conio_winsrv.h"
|
||||
#endif
|
||||
|
||||
typedef struct _CONSOLE
|
||||
{
|
||||
/******************************* Console Set-up *******************************/
|
||||
|
||||
#ifndef USE_NEW_CONSOLE_WAY
|
||||
WINSRV_CONSOLE; // HACK HACK!!
|
||||
#endif
|
||||
|
||||
LONG ReferenceCount; /* Is incremented each time a handle to something in the console (a screen-buffer or the input buffer of this console) gets referenced */
|
||||
CRITICAL_SECTION Lock;
|
||||
|
||||
ULONG ConsoleID; /* The ID of the console */
|
||||
LIST_ENTRY ListEntry; /* Entry in the list of consoles */
|
||||
|
||||
CONSOLE_STATE State; /* State of the console */
|
||||
TERMINAL TermIFace; /* Terminal-specific interface */
|
||||
|
||||
|
@ -347,7 +316,7 @@ typedef struct _CONSOLE
|
|||
COORD ConsoleSize; /* The current size of the console, for text-mode only */
|
||||
BOOLEAN FixedSize; /* TRUE if the console is of fixed size */
|
||||
BOOLEAN IsCJK; /* TRUE if Chinese, Japanese or Korean (CJK) */
|
||||
} CONSOLE; // , *PCONSOLE;
|
||||
} CONSOLE, *PCONSOLE;
|
||||
|
||||
/* console.c */
|
||||
VOID NTAPI
|
||||
|
@ -355,11 +324,6 @@ ConDrvPause(PCONSOLE Console);
|
|||
VOID NTAPI
|
||||
ConDrvUnpause(PCONSOLE Console);
|
||||
|
||||
NTSTATUS
|
||||
ConSrvConsoleCtrlEvent(IN ULONG CtrlEvent,
|
||||
IN PCONSOLE_PROCESS_DATA ProcessData);
|
||||
|
||||
|
||||
#define GetConsoleInputBufferMode(Console) \
|
||||
(Console)->InputBuffer.Mode
|
||||
|
||||
|
|
|
@ -11,23 +11,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "rect.h"
|
||||
|
||||
// This is ALMOST a HACK!!!!!!!
|
||||
// Helpers for code refactoring
|
||||
#ifdef USE_NEW_CONSOLE_WAY
|
||||
|
||||
#define _CONSRV_CONSOLE _WINSRV_CONSOLE
|
||||
#define CONSRV_CONSOLE WINSRV_CONSOLE
|
||||
#define PCONSRV_CONSOLE PWINSRV_CONSOLE
|
||||
|
||||
#else
|
||||
|
||||
#define _CONSRV_CONSOLE _CONSOLE
|
||||
#define CONSRV_CONSOLE CONSOLE
|
||||
#define PCONSRV_CONSOLE PCONSOLE
|
||||
|
||||
#endif
|
||||
// #include "rect.h"
|
||||
|
||||
#define CSR_DEFAULT_CURSOR_SIZE 25
|
||||
|
||||
|
@ -39,15 +23,12 @@ typedef struct _CHAR_CELL
|
|||
} CHAR_CELL, *PCHAR_CELL;
|
||||
C_ASSERT(sizeof(CHAR_CELL) == 2);
|
||||
|
||||
// HACK!!
|
||||
struct _WINSRV_CONSOLE;
|
||||
/* HACK: */ typedef struct _WINSRV_CONSOLE *PWINSRV_CONSOLE;
|
||||
#ifdef USE_NEW_CONSOLE_WAY
|
||||
#include "conio.h"
|
||||
#endif
|
||||
// #include "conio.h"
|
||||
|
||||
typedef struct _FRONTEND FRONTEND, *PFRONTEND;
|
||||
|
||||
struct _CONSRV_CONSOLE;
|
||||
|
||||
typedef struct _FRONTEND_VTBL
|
||||
{
|
||||
// NTSTATUS (NTAPI *UnloadFrontEnd)(IN OUT PFRONTEND This);
|
||||
|
@ -127,20 +108,21 @@ struct _FRONTEND
|
|||
#define PAUSED_FROM_SCROLLBAR 0x2
|
||||
#define PAUSED_FROM_SELECTION 0x4
|
||||
|
||||
typedef struct _WINSRV_CONSOLE
|
||||
typedef struct _CONSRV_CONSOLE
|
||||
{
|
||||
/******************************* Console Set-up *******************************/
|
||||
/* This **MUST** be FIRST!! */
|
||||
#ifdef USE_NEW_CONSOLE_WAY
|
||||
CONSOLE;
|
||||
// CONSOLE Console;
|
||||
// // PCONSOLE Console;
|
||||
#endif
|
||||
|
||||
// LONG ReferenceCount; /* Is incremented each time a handle to something in the console (a screen-buffer or the input buffer of this console) gets referenced */
|
||||
// CRITICAL_SECTION Lock;
|
||||
// CONSOLE_STATE State; /* State of the console */
|
||||
|
||||
// ULONG ConsoleID; /* The ID of the console */
|
||||
// LIST_ENTRY ListEntry; /* Entry in the list of consoles */
|
||||
|
||||
HANDLE InitEvents[MAX_INIT_EVENTS]; /* Initialization events */
|
||||
|
||||
FRONTEND FrontEndIFace; /* Frontend-specific interface */
|
||||
|
@ -194,7 +176,7 @@ typedef struct _WINSRV_CONSOLE
|
|||
UNICODE_STRING Title; /* Title of console. Always NULL-terminated */
|
||||
COLORREF Colors[16]; /* Colour palette */
|
||||
|
||||
} WINSRV_CONSOLE; // , *PWINSRV_CONSOLE;
|
||||
} CONSRV_CONSOLE, *PCONSRV_CONSOLE;
|
||||
|
||||
/* console.c */
|
||||
VOID ConioPause(PCONSRV_CONSOLE Console, UCHAR Flags);
|
||||
|
@ -205,6 +187,7 @@ ConSrvGetConsoleLeaderProcess(IN PCONSRV_CONSOLE Console);
|
|||
NTSTATUS
|
||||
ConSrvConsoleCtrlEvent(IN ULONG CtrlEvent,
|
||||
IN PCONSOLE_PROCESS_DATA ProcessData);
|
||||
|
||||
NTSTATUS NTAPI
|
||||
ConSrvConsoleProcessCtrlEvent(IN PCONSRV_CONSOLE Console,
|
||||
IN ULONG ProcessGroupId,
|
||||
|
@ -227,9 +210,6 @@ ConioProcessInputEvent(PCONSRV_CONSOLE Console,
|
|||
|
||||
/* conoutput.c */
|
||||
PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y);
|
||||
NTSTATUS ConioResizeBuffer(PCONSOLE Console,
|
||||
PTEXTMODE_SCREEN_BUFFER ScreenBuffer,
|
||||
COORD Size);
|
||||
|
||||
/* terminal.c */
|
||||
VOID ConioDrawConsole(PCONSRV_CONSOLE Console);
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
VOID NTAPI
|
||||
ConDrvInitConsoleSupport(VOID);
|
||||
|
||||
NTSTATUS NTAPI
|
||||
ConDrvInitConsole(OUT PCONSOLE* NewConsole,
|
||||
IN PCONSOLE_INFO ConsoleInfo);
|
||||
ConDrvInitConsole(
|
||||
IN OUT PCONSOLE Console,
|
||||
IN PCONSOLE_INFO ConsoleInfo);
|
||||
|
||||
NTSTATUS NTAPI
|
||||
ConDrvAttachTerminal(IN PCONSOLE Console,
|
||||
IN PTERMINAL Terminal);
|
||||
|
|
|
@ -26,7 +26,9 @@
|
|||
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
|
||||
VOID ConSrvApplyUserSettings(IN PCONSOLE Console,
|
||||
IN PCONSOLE_STATE_INFO ConsoleInfo);
|
||||
VOID
|
||||
ConSrvApplyUserSettings(
|
||||
IN PCONSRV_CONSOLE Console,
|
||||
IN PCONSOLE_STATE_INFO ConsoleInfo);
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -569,7 +569,6 @@ CSR_SERVER_DLL_INIT(ConServerDllInitialization)
|
|||
if (!ConSrvHeap) return STATUS_NO_MEMORY;
|
||||
*/
|
||||
|
||||
ConDrvInitConsoleSupport();
|
||||
ConSrvInitConsoleSupport();
|
||||
|
||||
/* Setup the DLL Object */
|
||||
|
|
|
@ -29,12 +29,13 @@ ConDrvChangeScreenBufferAttributes(IN PCONSOLE Console,
|
|||
IN USHORT NewScreenAttrib,
|
||||
IN USHORT NewPopupAttrib);
|
||||
/*
|
||||
* NOTE: This function explicitely references Console->ActiveBuffer.
|
||||
* NOTE: This function explicitly references Console->ActiveBuffer.
|
||||
* It is possible that it should go into some frontend...
|
||||
*/
|
||||
VOID
|
||||
ConSrvApplyUserSettings(IN PCONSOLE Console,
|
||||
IN PCONSOLE_STATE_INFO ConsoleInfo)
|
||||
ConSrvApplyUserSettings(
|
||||
IN PCONSRV_CONSOLE Console,
|
||||
IN PCONSOLE_STATE_INFO ConsoleInfo)
|
||||
{
|
||||
PCONSOLE_SCREEN_BUFFER ActiveBuffer = Console->ActiveBuffer;
|
||||
|
||||
|
@ -123,7 +124,7 @@ ConSrvApplyUserSettings(IN PCONSOLE Console,
|
|||
if (BufSize.X != ActiveBuffer->ScreenBufferSize.X ||
|
||||
BufSize.Y != ActiveBuffer->ScreenBufferSize.Y)
|
||||
{
|
||||
if (NT_SUCCESS(ConioResizeBuffer(Console, Buffer, BufSize)))
|
||||
if (NT_SUCCESS(ConioResizeBuffer((PCONSOLE)Console, Buffer, BufSize)))
|
||||
SizeChanged = TRUE;
|
||||
}
|
||||
|
||||
|
@ -131,7 +132,7 @@ ConSrvApplyUserSettings(IN PCONSOLE Console,
|
|||
}
|
||||
|
||||
/* Apply foreground and background colors for both screen and popup */
|
||||
ConDrvChangeScreenBufferAttributes(Console,
|
||||
ConDrvChangeScreenBufferAttributes((PCONSOLE)Console,
|
||||
Buffer,
|
||||
ConsoleInfo->ScreenAttributes,
|
||||
ConsoleInfo->PopupAttributes);
|
||||
|
|
Loading…
Reference in a new issue