Author: hbelusca
Date: Sat Jul 6 19:47:53 2013
New Revision: 59435
URL:
http://svn.reactos.org/svn/reactos?rev=59435&view=rev
Log:
[CONSRV]
- Use a handle table for storing consoles. Now checking validity of console handles is
done in O(1) instead of O(n) as before.
I will see later on whether it would be good to have both a handle table and a linked
list (which is removed here) for storing them
(when condrv will be a real console driver, handles to consoles will be obtained as you
would obtain usual handles to devices, etc...
so that consoles will be internally stored in a linked list again).
- Add a "dummy" frontend to have the possibility to adopt default actions when
no frontend is attached to a console, and to always have
a valid virtual table for them.
Added:
trunk/reactos/win32ss/user/consrv/condrv/dummyfrontend.c (with props)
Modified:
trunk/reactos/win32ss/user/consrv/CMakeLists.txt
trunk/reactos/win32ss/user/consrv/condrv/console.c
trunk/reactos/win32ss/user/consrv/console.c
trunk/reactos/win32ss/user/consrv/console.h
trunk/reactos/win32ss/user/consrv/consrv.h
trunk/reactos/win32ss/user/consrv/handle.c
trunk/reactos/win32ss/user/consrv/include/conio.h
trunk/reactos/win32ss/user/consrv/include/console.h
trunk/reactos/win32ss/user/consrv/init.c
trunk/reactos/win32ss/user/consrv/procinit.h
Modified: trunk/reactos/win32ss/user/consrv/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/consrv/CMakeL…
==============================================================================
--- trunk/reactos/win32ss/user/consrv/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/consrv/CMakeLists.txt [iso-8859-1] Sat Jul 6 19:47:53
2013
@@ -21,6 +21,7 @@
condrv/coninput.c
condrv/conoutput.c
condrv/console.c
+ condrv/dummyfrontend.c
condrv/graphics.c
condrv/text.c
frontends/input.c
Modified: trunk/reactos/win32ss/user/consrv/condrv/console.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/consrv/condrv…
==============================================================================
--- trunk/reactos/win32ss/user/consrv/condrv/console.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/consrv/condrv/console.c [iso-8859-1] Sat Jul 6 19:47:53
2013
@@ -1,6 +1,6 @@
/*
* COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS Console Server DLL
+ * PROJECT: ReactOS Console Driver DLL
* FILE: win32ss/user/consrv/condrv/console.c
* PURPOSE: Console Management Functions
* PROGRAMMERS: Gé van Geldorp
@@ -34,7 +34,8 @@
/* GLOBALS ********************************************************************/
-static LIST_ENTRY ConsoleList; /* The list of all the allocated consoles */
+static ULONG ConsoleListSize;
+static PCONSOLE* ConsoleList; /* The list of all the allocated consoles */
static RTL_RESOURCE ListLock;
#define ConDrvLockConsoleListExclusive() \
@@ -47,7 +48,7 @@
RtlReleaseResource(&ListLock)
// Adapted from reactos/lib/rtl/unicode.c, RtlCreateUnicodeString line 2180
-BOOLEAN
+static BOOLEAN
ConsoleCreateUnicodeString(IN OUT PUNICODE_STRING UniDest,
IN PCWSTR Source)
{
@@ -65,7 +66,7 @@
}
// Adapted from reactos/lib/rtl/unicode.c, RtlFreeUnicodeString line 431
-VOID
+static VOID
ConsoleFreeUnicodeString(IN PUNICODE_STRING UnicodeString)
{
if (UnicodeString->Buffer)
@@ -74,6 +75,129 @@
RtlZeroMemory(UnicodeString, sizeof(UNICODE_STRING));
}
}
+
+
+static NTSTATUS
+InsertConsole(OUT PHANDLE Handle,
+ IN PCONSOLE Console)
+{
+#define CONSOLE_HANDLES_INCREMENT 2 * 3
+
+ NTSTATUS Status = STATUS_SUCCESS;
+ ULONG i = 0;
+ PCONSOLE* Block;
+
+ ASSERT( (ConsoleList == NULL && ConsoleListSize == 0) ||
+ (ConsoleList != NULL && ConsoleListSize != 0) );
+
+ /* All went right, so add the console to the list */
+ ConDrvLockConsoleListExclusive();
+ DPRINT1("Insert in the list\n");
+
+ if (ConsoleList)
+ {
+ for (i = 0; i < ConsoleListSize; i++)
+ {
+ if (ConsoleList[i] == NULL) break;
+ }
+ }
+
+ if (i >= ConsoleListSize)
+ {
+ DPRINT1("Creation of a new handles table\n");
+ /* Allocate a new handles table */
+ Block = ConsoleAllocHeap(HEAP_ZERO_MEMORY,
+ (ConsoleListSize +
+ CONSOLE_HANDLES_INCREMENT) * sizeof(PCONSOLE));
+ if (Block == NULL)
+ {
+ Status = STATUS_UNSUCCESSFUL;
+ goto Quit;
+ }
+
+ /* If we previously had a handles table, free it and use the new one */
+ if (ConsoleList)
+ {
+ /* Copy the handles from the old table to the new one */
+ RtlCopyMemory(Block,
+ ConsoleList,
+ ConsoleListSize * sizeof(PCONSOLE));
+ ConsoleFreeHeap(ConsoleList);
+ }
+ ConsoleList = Block;
+ ConsoleListSize += CONSOLE_HANDLES_INCREMENT;
+ }
+
+ ConsoleList[i] = Console;
+ *Handle = ULongToHandle((i << 2) | 0x3);
+
+Quit:
+ /* Unlock the console list and return status */
+ ConDrvUnlockConsoleList();
+ return Status;
+}
+
+/* Unused */
+#if 0
+static NTSTATUS
+RemoveConsoleByHandle(IN HANDLE Handle)
+{
+ NTSTATUS Status = STATUS_SUCCESS;
+ ULONG Index = HandleToULong(Handle) >> 2;
+ PCONSOLE Console;
+
+ ASSERT( (ConsoleList == NULL && ConsoleListSize == 0) ||
+ (ConsoleList != NULL && ConsoleListSize != 0) );
+
+ /* Remove the console from the list */
+ ConDrvLockConsoleListExclusive();
+
+ if (Index >= ConsoleListSize ||
+ (Console = ConsoleList[Index]) == NULL)
+ {
+ Status = STATUS_INVALID_HANDLE;
+ goto Quit;
+ }
+
+ ConsoleList[Index] = NULL;
+
+Quit:
+ /* Unlock the console list and return status */
+ ConDrvUnlockConsoleList();
+ return Status;
+}
+#endif
+
+static NTSTATUS
+RemoveConsoleByPointer(IN PCONSOLE Console)
+{
+ ULONG i = 0;
+
+ if (!Console) return STATUS_INVALID_PARAMETER;
+
+ ASSERT( (ConsoleList == NULL && ConsoleListSize == 0) ||
+ (ConsoleList != NULL && ConsoleListSize != 0) );
+
+ /* Remove the console from the list */
+ ConDrvLockConsoleListExclusive();
+
+ if (ConsoleList)
+ {
+ for (i = 0; i < ConsoleListSize; i++)
+ {
+ if (ConsoleList[i] == Console) ConsoleList[i] = NULL;
+ }
+ }
+
+ /* Unlock the console list */
+ ConDrvUnlockConsoleList();
+
+ return STATUS_SUCCESS;
+}
+
+
+/* For resetting the frontend - defined in dummyfrontend.c */
+VOID ResetFrontEnd(IN PCONSOLE Console);
/* PRIVATE FUNCTIONS **********************************************************/
@@ -170,28 +294,6 @@
*/
BOOLEAN NTAPI
-ConDrvValidateConsolePointer(IN PCONSOLE Console)
-{
- PLIST_ENTRY ConsoleEntry;
- PCONSOLE CurrentConsole = NULL;
-
- if (!Console) return FALSE;
-
- /* The console list must be locked */
- // ASSERT(Console_list_locked);
-
- ConsoleEntry = ConsoleList.Flink;
- while (ConsoleEntry != &ConsoleList)
- {
- CurrentConsole = CONTAINING_RECORD(ConsoleEntry, CONSOLE, Entry);
- ConsoleEntry = ConsoleEntry->Flink;
- if (CurrentConsole == Console) return TRUE;
- }
-
- return FALSE;
-}
-
-BOOLEAN NTAPI
ConDrvValidateConsoleState(IN PCONSOLE Console,
IN CONSOLE_STATE ExpectedState)
{
@@ -231,13 +333,18 @@
}
BOOLEAN NTAPI
-ConDrvValidateConsole(IN PCONSOLE Console,
+ConDrvValidateConsole(OUT PCONSOLE* Console,
+ IN HANDLE ConsoleHandle,
IN CONSOLE_STATE ExpectedState,
IN BOOLEAN LockConsole)
{
BOOLEAN RetVal = FALSE;
+ ULONG Index = HandleToULong(ConsoleHandle) >> 2;
+ PCONSOLE ValidatedConsole;
+
if (!Console) return FALSE;
+ *Console = NULL;
/*
* Forbid creation or deletion of consoles when
@@ -245,27 +352,46 @@
*/
ConDrvLockConsoleListShared();
- if (ConDrvValidateConsolePointer(Console))
- {
- RetVal = ConDrvValidateConsoleUnsafe(Console,
- ExpectedState,
- LockConsole);
- }
+ if (Index >= ConsoleListSize ||
+ (ValidatedConsole = ConsoleList[Index]) == NULL)
+ {
+ /* Unlock the console list */
+ ConDrvUnlockConsoleList();
+
+ return FALSE;
+ }
+
+ ValidatedConsole = ConsoleList[Index];
/* Unlock the console list and return */
ConDrvUnlockConsoleList();
+
+ RetVal = ConDrvValidateConsoleUnsafe(ValidatedConsole,
+ ExpectedState,
+ LockConsole);
+ if (RetVal) *Console = ValidatedConsole;
+
return RetVal;
}
NTSTATUS NTAPI
-ConDrvGrabConsole(IN PCONSOLE Console,
- IN BOOLEAN LockConsole)
+ConDrvGetConsole(OUT PCONSOLE* Console,
+ IN HANDLE ConsoleHandle,
+ IN BOOLEAN LockConsole)
{
NTSTATUS Status = STATUS_INVALID_HANDLE;
-
- if (ConDrvValidateConsole(Console, CONSOLE_RUNNING, LockConsole))
- {
- InterlockedIncrement(&Console->ReferenceCount);
+ PCONSOLE GrabConsole;
+
+ if (Console == NULL) return STATUS_INVALID_PARAMETER;
+ *Console = NULL;
+
+ if (ConDrvValidateConsole(&GrabConsole,
+ ConsoleHandle,
+ CONSOLE_RUNNING,
+ LockConsole))
+ {
+ InterlockedIncrement(&GrabConsole->ReferenceCount);
+ *Console = GrabConsole;
Status = STATUS_SUCCESS;
}
@@ -309,15 +435,16 @@
DPRINT("CONSRV: ConDrvInitConsoleSupport()\n");
/* Initialize the console list and its lock */
- InitializeListHead(&ConsoleList);
+ ConsoleListSize = 0;
+ ConsoleList = NULL;
RtlInitializeResource(&ListLock);
/* Should call LoadKeyboardLayout */
}
-
NTSTATUS NTAPI
-ConDrvInitConsole(OUT PCONSOLE* NewConsole,
+ConDrvInitConsole(OUT PHANDLE NewConsoleHandle,
+ OUT PCONSOLE* NewConsole,
IN PCONSOLE_INFO ConsoleInfo,
IN ULONG ConsoleLeaderProcessId)
{
@@ -325,13 +452,15 @@
SECURITY_ATTRIBUTES SecurityAttributes;
// CONSOLE_INFO CapturedConsoleInfo;
TEXTMODE_BUFFER_INFO ScreenBufferInfo;
+ HANDLE ConsoleHandle;
PCONSOLE Console;
PCONSOLE_SCREEN_BUFFER NewBuffer;
// WCHAR DefaultTitle[128];
- if (NewConsole == NULL || ConsoleInfo == NULL)
+ if (NewConsoleHandle == NULL || NewConsole == NULL || ConsoleInfo == NULL)
return STATUS_INVALID_PARAMETER;
-
+
+ *NewConsoleHandle = NULL;
*NewConsole = NULL;
/*
@@ -409,7 +538,9 @@
Console->ReferenceCount = 0;
InitializeCriticalSection(&Console->Lock);
InitializeListHead(&Console->ProcessList);
- RtlZeroMemory(&Console->TermIFace, sizeof(Console->TermIFace));
+
+ /* Initialize the frontend interface */
+ ResetFrontEnd(Console);
memcpy(Console->Colors, ConsoleInfo->Colors, sizeof(ConsoleInfo->Colors));
Console->ConsoleSize = ConsoleInfo->ConsoleSize;
@@ -511,9 +642,13 @@
DPRINT("Console initialized\n");
/* All went right, so add the console to the list */
- ConDrvLockConsoleListExclusive();
- DPRINT("Insert in the list\n");
- InsertTailList(&ConsoleList, &Console->Entry);
+ Status = InsertConsole(&ConsoleHandle, Console);
+ if (!NT_SUCCESS(Status))
+ {
+ /* Fail */
+ ConDrvDeleteConsole(Console);
+ return Status;
+ }
/* The initialization is finished */
DPRINT("Change state\n");
@@ -522,11 +657,9 @@
/* Unlock the console */
// LeaveCriticalSection(&Console->Lock);
- /* Unlock the console list */
- ConDrvUnlockConsoleList();
-
/* Return the newly created console to the caller and a success code too */
- *NewConsole = Console;
+ *NewConsoleHandle = ConsoleHandle;
+ *NewConsole = Console;
return STATUS_SUCCESS;
}
@@ -557,7 +690,7 @@
/* We failed, detach the frontend from the console */
FrontEnd->Console = NULL; // For the caller
- RtlZeroMemory(&Console->TermIFace, sizeof(Console->TermIFace));
+ ResetFrontEnd(Console);
return Status;
}
@@ -581,8 +714,11 @@
/* Deinitialize the frontend BEFORE detaching it from the console */
Console->TermIFace.Vtbl->DeinitFrontEnd(&Console->TermIFace/*,
Console*/);
- /* Detach the frontend from the console */
- RtlZeroMemory(&Console->TermIFace, sizeof(Console->TermIFace));
+ /*
+ * Detach the frontend from the console:
+ * reinitialize the frontend interface.
+ */
+ ResetFrontEnd(Console);
DPRINT("Terminal FrontEnd unregistered\n");
return STATUS_SUCCESS;
@@ -599,19 +735,12 @@
*/
ConDrvLockConsoleListExclusive();
- /* Check the existence of the console, and if it's ok, continue */
- if (!ConDrvValidateConsolePointer(Console))
- {
- /* Unlock the console list and return */
- ConDrvUnlockConsoleList();
- return;
- }
-
- /*
- * If the console is already being destroyed
- * (thus not running), just return.
- */
- if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE))
+ /*
+ * If the console is already being destroyed, i.e. not running
+ * or finishing to be initialized, just return.
+ */
+ if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE) &&
+ !ConDrvValidateConsoleUnsafe(Console, CONSOLE_INITIALIZING, TRUE))
{
/* Unlock the console list and return */
ConDrvUnlockConsoleList();
@@ -651,29 +780,21 @@
ConDrvLockConsoleListExclusive();
- /* Re-check the existence of the console, and if it's ok, continue */
- if (!ConDrvValidateConsolePointer(Console))
- {
- /* Unlock the console list and return */
+ if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_TERMINATING, TRUE))
+ {
ConDrvUnlockConsoleList();
return;
}
- if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_TERMINATING, TRUE))
- {
- ConDrvUnlockConsoleList();
- return;
- }
-
/* We are now in destruction */
Console->State = CONSOLE_IN_DESTRUCTION;
- /* Remove the console from the list */
- RemoveEntryList(&Console->Entry);
-
/* We really delete the console. Reset the count to be sure. */
Console->ReferenceCount = 0;
+ /* Remove the console from the list */
+ RemoveConsoleByPointer(Console);
+
/* Discard all entries in the input event queue */
PurgeInputBuffer(Console);
@@ -683,6 +804,7 @@
HistoryDeleteBuffers(Console);
ConioDeleteScreenBuffer(Console->ActiveBuffer);
+ Console->ActiveBuffer = NULL;
if (!IsListEmpty(&Console->BufferList))
{
DPRINT1("BUG: screen buffer list not empty\n");
@@ -709,7 +831,7 @@
}
-/* PUBLIC SERVER APIS *********************************************************/
+/* PUBLIC DRIVER APIS *********************************************************/
NTSTATUS NTAPI
ConDrvGetConsoleMode(IN PCONSOLE Console,
@@ -953,7 +1075,7 @@
PCONSOLE_PROCESS_DATA current;
/* If the console is already being destroyed, just return */
- if (!ConDrvValidateConsole(Console, CONSOLE_RUNNING, FALSE))
+ if (!ConDrvValidateConsoleState(Console, CONSOLE_RUNNING))
return STATUS_UNSUCCESSFUL;
/*
Added: trunk/reactos/win32ss/user/consrv/condrv/dummyfrontend.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/consrv/condrv…
==============================================================================
--- trunk/reactos/win32ss/user/consrv/condrv/dummyfrontend.c (added)
+++ trunk/reactos/win32ss/user/consrv/condrv/dummyfrontend.c [iso-8859-1] Sat Jul 6
19:47:53 2013
@@ -0,0 +1,185 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS Console Server DLL
+ * FILE: win32ss/user/consrv/condrv/dummyfrontend.c
+ * PURPOSE: Dummy Terminal Front-End used when no frontend
+ * is attached to the specified console.
+ * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca(a)sfr.fr)
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include "consrv.h"
+#include "include/conio.h"
+
+
+/* DUMMY FRONTEND INTERFACE ***************************************************/
+
+static NTSTATUS NTAPI
+DummyInitFrontEnd(IN OUT PFRONTEND This,
+ IN PCONSOLE Console)
+{
+ /* Load some settings ?? */
+ return STATUS_SUCCESS;
+}
+
+static VOID NTAPI
+DummyDeinitFrontEnd(IN OUT PFRONTEND This)
+{
+ /* Free some settings ?? */
+}
+
+static VOID NTAPI
+DummyDrawRegion(IN OUT PFRONTEND This,
+ SMALL_RECT* Region)
+{
+}
+
+static VOID NTAPI
+DummyWriteStream(IN OUT PFRONTEND This,
+ SMALL_RECT* Region,
+ SHORT CursorStartX,
+ SHORT CursorStartY,
+ UINT ScrolledLines,
+ PWCHAR Buffer,
+ UINT Length)
+{
+}
+
+static BOOL NTAPI
+DummySetCursorInfo(IN OUT PFRONTEND This,
+ PCONSOLE_SCREEN_BUFFER Buff)
+{
+ return TRUE;
+}
+
+static BOOL NTAPI
+DummySetScreenInfo(IN OUT PFRONTEND This,
+ PCONSOLE_SCREEN_BUFFER Buff,
+ SHORT OldCursorX,
+ SHORT OldCursorY)
+{
+ return TRUE;
+}
+
+static VOID NTAPI
+DummyResizeTerminal(IN OUT PFRONTEND This)
+{
+}
+
+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)
+{
+}
+
+static VOID NTAPI
+DummyChangeTitle(IN OUT PFRONTEND This)
+{
+}
+
+static BOOL NTAPI
+DummyChangeIcon(IN OUT PFRONTEND This,
+ HICON hWindowIcon)
+{
+ return TRUE;
+}
+
+static HWND NTAPI
+DummyGetConsoleWindowHandle(IN OUT PFRONTEND This)
+{
+ return NULL;
+}
+
+static VOID NTAPI
+DummyGetLargestConsoleWindowSize(IN OUT PFRONTEND This,
+ PCOORD pSize)
+{
+}
+
+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,
+ BOOL Show)
+{
+ return 0;
+}
+
+static BOOL NTAPI
+DummySetMouseCursor(IN OUT PFRONTEND This,
+ HCURSOR hCursor)
+{
+ 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,
+ DummyProcessKeyCallback,
+ DummyRefreshInternalInfo,
+ DummyChangeTitle,
+ DummyChangeIcon,
+ DummyGetConsoleWindowHandle,
+ DummyGetLargestConsoleWindowSize,
+ DummyGetDisplayMode,
+ DummySetDisplayMode,
+ DummyShowMouseCursor,
+ DummySetMouseCursor,
+ DummyMenuControl,
+ DummySetMenuClose,
+};
+
+VOID
+ResetFrontEnd(IN PCONSOLE Console)
+{
+ if (!Console) return;
+
+ /* Reinitialize the frontend interface */
+ RtlZeroMemory(&Console->TermIFace, sizeof(Console->TermIFace));
+ Console->TermIFace.Vtbl = &DummyVtbl;
+}
+
+/* EOF */
Propchange: trunk/reactos/win32ss/user/consrv/condrv/dummyfrontend.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/win32ss/user/consrv/console.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/consrv/consol…
==============================================================================
--- trunk/reactos/win32ss/user/consrv/console.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/consrv/console.c [iso-8859-1] Sat Jul 6 19:47:53 2013
@@ -147,9 +147,8 @@
*Console = NULL;
// RtlEnterCriticalSection(&ProcessData->HandleTableLock);
- ProcessConsole = ProcessData->Console;
-
- Status = ConDrvGrabConsole(ProcessConsole, LockConsole);
+
+ Status = ConDrvGetConsole(&ProcessConsole, ProcessData->ConsoleHandle,
LockConsole);
if (NT_SUCCESS(Status)) *Console = ProcessConsole;
// RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
@@ -166,11 +165,13 @@
NTSTATUS WINAPI
-ConSrvInitConsole(OUT PCONSOLE* NewConsole,
+ConSrvInitConsole(OUT PHANDLE NewConsoleHandle,
+ OUT PCONSOLE* NewConsole,
IN OUT PCONSOLE_START_INFO ConsoleStartInfo,
IN ULONG ConsoleLeaderProcessId)
{
NTSTATUS Status;
+ HANDLE ConsoleHandle;
PCONSOLE Console;
CONSOLE_INFO ConsoleInfo;
SIZE_T Length = 0;
@@ -266,7 +267,10 @@
ConsoleInfo.CodePage = GetOEMCP();
/******************************************************************************/
- Status = ConDrvInitConsole(&Console, &ConsoleInfo, ConsoleLeaderProcessId);
+ Status = ConDrvInitConsole(&ConsoleHandle,
+ &Console,
+ &ConsoleInfo,
+ ConsoleLeaderProcessId);
if (!NT_SUCCESS(Status))
{
DPRINT1("Creating a new console failed, Status = 0x%08lx\n", Status);
@@ -288,7 +292,8 @@
DPRINT("FrontEnd registered\n");
/* Return the newly created console to the caller and a success code too */
- *NewConsole = Console;
+ *NewConsoleHandle = ConsoleHandle;
+ *NewConsole = Console;
return STATUS_SUCCESS;
}
@@ -311,7 +316,7 @@
PCSR_PROCESS CsrProcess = CsrGetClientThread()->Process;
PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrProcess);
- if (ProcessData->Console != NULL)
+ if (ProcessData->ConsoleHandle != NULL)
{
DPRINT1("Process already has a console\n");
return STATUS_ACCESS_DENIED;
@@ -337,16 +342,12 @@
return Status;
}
- /* Return it to the caller */
- AllocConsoleRequest->Console = ProcessData->Console;
-
- /* Input Wait Handle */
+ /* Return the console handle and the input wait handle to the caller */
+ AllocConsoleRequest->ConsoleHandle = ProcessData->ConsoleHandle;
AllocConsoleRequest->InputWaitHandle = ProcessData->ConsoleEvent;
- /* Set the Property Dialog Handler */
+ /* Set the Property-Dialog and Control-Dispatcher handlers */
ProcessData->PropDispatcher = AllocConsoleRequest->PropDispatcher;
-
- /* Set the Ctrl Dispatcher */
ProcessData->CtrlDispatcher = AllocConsoleRequest->CtrlDispatcher;
return STATUS_SUCCESS;
@@ -363,7 +364,7 @@
TargetProcessData = ConsoleGetPerProcessData(TargetProcess);
- if (TargetProcessData->Console != NULL)
+ if (TargetProcessData->ConsoleHandle != NULL)
{
DPRINT1("Process already has a console\n");
return STATUS_ACCESS_DENIED;
@@ -396,7 +397,7 @@
SourceProcessData = ConsoleGetPerProcessData(SourceProcess);
- if (SourceProcessData->Console == NULL)
+ if (SourceProcessData->ConsoleHandle == NULL)
{
Status = STATUS_INVALID_HANDLE;
goto Quit;
@@ -407,7 +408,7 @@
* if any, otherwise return an error.
*/
Status = ConSrvInheritConsole(TargetProcessData,
- SourceProcessData->Console,
+ SourceProcessData->ConsoleHandle,
TRUE,
&AttachConsoleRequest->InputHandle,
&AttachConsoleRequest->OutputHandle,
@@ -418,16 +419,12 @@
goto Quit;
}
- /* Return it to the caller */
- AttachConsoleRequest->Console = TargetProcessData->Console;
-
- /* Input Wait Handle */
+ /* Return the console handle and the input wait handle to the caller */
+ AttachConsoleRequest->ConsoleHandle = TargetProcessData->ConsoleHandle;
AttachConsoleRequest->InputWaitHandle = TargetProcessData->ConsoleEvent;
- /* Set the Property Dialog Handler */
+ /* Set the Property-Dialog and Control-Dispatcher handlers */
TargetProcessData->PropDispatcher = AttachConsoleRequest->PropDispatcher;
-
- /* Set the Ctrl Dispatcher */
TargetProcessData->CtrlDispatcher = AttachConsoleRequest->CtrlDispatcher;
Status = STATUS_SUCCESS;
Modified: trunk/reactos/win32ss/user/consrv/console.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/consrv/consol…
==============================================================================
--- trunk/reactos/win32ss/user/consrv/console.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/consrv/console.h [iso-8859-1] Sat Jul 6 19:47:53 2013
@@ -8,11 +8,12 @@
#pragma once
-VOID NTAPI
-ConDrvInitConsoleSupport(VOID);
+// FIXME: Fix compilation
+struct _CONSOLE;
NTSTATUS WINAPI
-ConSrvInitConsole(OUT struct _CONSOLE** /* PCONSOLE* */ NewConsole,
+ConSrvInitConsole(OUT PHANDLE NewConsoleHandle,
+ OUT struct _CONSOLE** /* PCONSOLE* */ NewConsole,
IN OUT PCONSOLE_START_INFO ConsoleStartInfo,
IN ULONG ConsoleLeaderProcessId);
VOID WINAPI ConSrvDeleteConsole(struct _CONSOLE* /* PCONSOLE */ Console);
@@ -23,29 +24,4 @@
VOID FASTCALL ConSrvReleaseConsole(struct _CONSOLE* /* PCONSOLE */ Console,
BOOL WasConsoleLocked);
-/******************************************************************************/
-
-NTSTATUS NTAPI
-ConDrvGrabConsole(IN struct _CONSOLE* /* PCONSOLE */ Console,
- IN BOOLEAN LockConsole);
-VOID NTAPI
-ConDrvReleaseConsole(IN struct _CONSOLE* /* PCONSOLE */ Console,
- IN BOOLEAN WasConsoleLocked);
-
-typedef struct _FRONTEND FRONTEND, *PFRONTEND;
-typedef struct _CONSOLE_INFO CONSOLE_INFO, *PCONSOLE_INFO;
-
-NTSTATUS NTAPI
-ConDrvInitConsole(OUT struct _CONSOLE** /* PCONSOLE* */ NewConsole,
- // IN OUT PCONSOLE_START_INFO ConsoleStartInfo,
- IN PCONSOLE_INFO ConsoleInfo,
- IN ULONG ConsoleLeaderProcessId);
-NTSTATUS NTAPI
-ConDrvRegisterFrontEnd(IN struct _CONSOLE* /* PCONSOLE */ Console,
- IN PFRONTEND FrontEnd);
-NTSTATUS NTAPI
-ConDrvDeregisterFrontEnd(IN struct _CONSOLE* /* PCONSOLE */ Console);
-VOID NTAPI
-ConDrvDeleteConsole(IN struct _CONSOLE* /* PCONSOLE */ Console);
-
/* EOF */
Modified: trunk/reactos/win32ss/user/consrv/consrv.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/consrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/consrv/consrv.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/consrv/consrv.h [iso-8859-1] Sat Jul 6 19:47:53 2013
@@ -60,8 +60,9 @@
LIST_ENTRY ConsoleLink;
PCSR_PROCESS Process; // Process owning this structure.
HANDLE ConsoleEvent;
- struct _CONSOLE* /* PCONSOLE */ Console;
- struct _CONSOLE* /* PCONSOLE */ ParentConsole;
+
+ HANDLE ConsoleHandle;
+ HANDLE ParentConsoleHandle;
BOOL ConsoleApp; // TRUE if it is a CUI app, FALSE otherwise.
Modified: trunk/reactos/win32ss/user/consrv/handle.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/consrv/handle…
==============================================================================
--- trunk/reactos/win32ss/user/consrv/handle.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/consrv/handle.c [iso-8859-1] Sat Jul 6 19:47:53 2013
@@ -135,6 +135,7 @@
static NTSTATUS
ConSrvInitHandlesTable(IN OUT PCONSOLE_PROCESS_DATA ProcessData,
+ IN PCONSOLE Console,
OUT PHANDLE pInputHandle,
OUT PHANDLE pOutputHandle,
OUT PHANDLE pErrorHandle)
@@ -157,7 +158,7 @@
/* Insert the Input handle */
Status = ConSrvInsertObject(ProcessData,
&InputHandle,
- &ProcessData->Console->InputBuffer.Header,
+ &Console->InputBuffer.Header,
GENERIC_READ | GENERIC_WRITE,
TRUE,
FILE_SHARE_READ | FILE_SHARE_WRITE);
@@ -172,7 +173,7 @@
/* Insert the Output handle */
Status = ConSrvInsertObject(ProcessData,
&OutputHandle,
-
&ProcessData->Console->ActiveBuffer->Header,
+ &Console->ActiveBuffer->Header,
GENERIC_READ | GENERIC_WRITE,
TRUE,
FILE_SHARE_READ | FILE_SHARE_WRITE);
@@ -187,7 +188,7 @@
/* Insert the Error handle */
Status = ConSrvInsertObject(ProcessData,
&ErrorHandle,
-
&ProcessData->Console->ActiveBuffer->Header,
+ &Console->ActiveBuffer->Header,
GENERIC_READ | GENERIC_WRITE,
TRUE,
FILE_SHARE_READ | FILE_SHARE_WRITE);
@@ -270,12 +271,12 @@
ULONG i;
/*
- * ProcessData->Console is NULL (and the assertion fails) when
+ * ProcessData->ConsoleHandle is NULL (and the assertion fails) when
* ConSrvFreeHandlesTable is called in ConSrvConnect during the
* allocation of a new console.
*/
- // ASSERT(ProcessData->Console);
- if (ProcessData->Console != NULL)
+ // ASSERT(ProcessData->ConsoleHandle);
+ if (ProcessData->ConsoleHandle != NULL)
{
/* Close all the console handles */
for (i = 0; i < ProcessData->HandleTableSize; i++)
@@ -380,22 +381,22 @@
ConSrvRemoveObject(PCONSOLE_PROCESS_DATA ProcessData,
HANDLE Handle)
{
- ULONG_PTR h = (ULONG_PTR)Handle >> 2;
+ ULONG Index = HandleToULong(Handle) >> 2;
PCONSOLE_IO_OBJECT Object;
RtlEnterCriticalSection(&ProcessData->HandleTableLock);
ASSERT(ProcessData->HandleTable);
- if (h >= ProcessData->HandleTableSize ||
- (Object = ProcessData->HandleTable[h].Object) == NULL)
+ if (Index >= ProcessData->HandleTableSize ||
+ (Object = ProcessData->HandleTable[Index].Object) == NULL)
{
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
return STATUS_INVALID_HANDLE;
}
- ASSERT(ProcessData->Console);
- ConSrvCloseHandleEntry(&ProcessData->HandleTable[h]);
+ ASSERT(ProcessData->ConsoleHandle);
+ ConSrvCloseHandleEntry(&ProcessData->HandleTable[Index]);
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
return STATUS_SUCCESS;
@@ -411,9 +412,11 @@
BOOL LockConsole,
CONSOLE_IO_OBJECT_TYPE Type)
{
- ULONG_PTR h = (ULONG_PTR)Handle >> 2;
+ // NTSTATUS Status;
+ ULONG Index = HandleToULong(Handle) >> 2;
PCONSOLE_IO_HANDLE HandleEntry = NULL;
PCONSOLE_IO_OBJECT ObjectEntry = NULL;
+ // PCONSOLE ObjectConsole;
ASSERT(Object);
if (Entry) *Entry = NULL;
@@ -423,9 +426,9 @@
RtlEnterCriticalSection(&ProcessData->HandleTableLock);
if ( IsConsoleHandle(Handle) &&
- h < ProcessData->HandleTableSize )
- {
- HandleEntry = &ProcessData->HandleTable[h];
+ Index < ProcessData->HandleTableSize )
+ {
+ HandleEntry = &ProcessData->HandleTable[Index];
ObjectEntry = HandleEntry->Object;
}
@@ -444,7 +447,9 @@
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
- if (ConDrvValidateConsole(ObjectEntry->Console, CONSOLE_RUNNING, LockConsole))
+ // Status = ConDrvGetConsole(&ObjectConsole, ProcessData->ConsoleHandle,
LockConsole);
+ // if (NT_SUCCESS(Status))
+ if (ConDrvValidateConsoleUnsafe(ObjectEntry->Console, CONSOLE_RUNNING,
LockConsole))
{
_InterlockedIncrement(&ObjectEntry->Console->ReferenceCount);
@@ -479,6 +484,8 @@
PCONSOLE_START_INFO ConsoleStartInfo)
{
NTSTATUS Status = STATUS_SUCCESS;
+ HANDLE ConsoleHandle;
+ PCONSOLE Console;
/*
* We are about to create a new console. However when ConSrvNewProcess
@@ -493,7 +500,8 @@
ConSrvFreeHandlesTable(ProcessData);
/* Initialize a new Console owned by this process */
- Status = ConSrvInitConsole(&ProcessData->Console,
+ Status = ConSrvInitConsole(&ConsoleHandle,
+ &Console,
ConsoleStartInfo,
HandleToUlong(ProcessData->Process->ClientId.UniqueProcess));
if (!NT_SUCCESS(Status))
@@ -502,22 +510,26 @@
return Status;
}
+ /* Assign the new console handle */
+ ProcessData->ConsoleHandle = ConsoleHandle;
+
/* Initialize the handles table */
Status = ConSrvInitHandlesTable(ProcessData,
+ Console,
pInputHandle,
pOutputHandle,
pErrorHandle);
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to initialize the handles table\n");
- ConSrvDeleteConsole(ProcessData->Console);
- ProcessData->Console = NULL;
+ ConSrvDeleteConsole(Console);
+ ProcessData->ConsoleHandle = NULL;
return Status;
}
/* Duplicate the Input Event */
Status = NtDuplicateObject(NtCurrentProcess(),
- ProcessData->Console->InputBuffer.ActiveEvent,
+ Console->InputBuffer.ActiveEvent,
ProcessData->Process->ProcessHandle,
&ProcessData->ConsoleEvent,
EVENT_ALL_ACCESS, 0, 0);
@@ -525,19 +537,19 @@
{
DPRINT1("NtDuplicateObject() failed: %lu\n", Status);
ConSrvFreeHandlesTable(ProcessData);
- ConSrvDeleteConsole(ProcessData->Console);
- ProcessData->Console = NULL;
+ ConSrvDeleteConsole(Console);
+ ProcessData->ConsoleHandle = NULL;
return Status;
}
/* Insert the process into the processes list of the console */
- InsertHeadList(&ProcessData->Console->ProcessList,
&ProcessData->ConsoleLink);
+ InsertHeadList(&Console->ProcessList, &ProcessData->ConsoleLink);
/* Add a reference count because the process is tied to the console */
- _InterlockedIncrement(&ProcessData->Console->ReferenceCount);
+ _InterlockedIncrement(&Console->ReferenceCount);
/* Update the internal info of the terminal */
- ConioRefreshInternalInfo(ProcessData->Console);
+ ConioRefreshInternalInfo(Console);
return STATUS_SUCCESS;
}
@@ -545,23 +557,26 @@
NTSTATUS
FASTCALL
ConSrvInheritConsole(PCONSOLE_PROCESS_DATA ProcessData,
- PCONSOLE Console,
+ HANDLE ConsoleHandle,
BOOL CreateNewHandlesTable,
PHANDLE pInputHandle,
PHANDLE pOutputHandle,
PHANDLE pErrorHandle)
{
NTSTATUS Status = STATUS_SUCCESS;
+ PCONSOLE Console;
/* Validate and lock the console */
- if (!ConDrvValidateConsole(Console, CONSOLE_RUNNING, TRUE))
+ if (!ConDrvValidateConsole(&Console,
+ ConsoleHandle,
+ CONSOLE_RUNNING, TRUE))
{
// FIXME: Find another status code
return STATUS_UNSUCCESSFUL;
}
/* Inherit the console */
- ProcessData->Console = Console;
+ ProcessData->ConsoleHandle = ConsoleHandle;
if (CreateNewHandlesTable)
{
@@ -579,20 +594,21 @@
/* Initialize the handles table */
Status = ConSrvInitHandlesTable(ProcessData,
+ Console,
pInputHandle,
pOutputHandle,
pErrorHandle);
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to initialize the handles table\n");
- ProcessData->Console = NULL;
+ ProcessData->ConsoleHandle = NULL;
goto Quit;
}
}
/* Duplicate the Input Event */
Status = NtDuplicateObject(NtCurrentProcess(),
- ProcessData->Console->InputBuffer.ActiveEvent,
+ Console->InputBuffer.ActiveEvent,
ProcessData->Process->ProcessHandle,
&ProcessData->ConsoleEvent,
EVENT_ALL_ACCESS, 0, 0);
@@ -600,18 +616,18 @@
{
DPRINT1("NtDuplicateObject() failed: %lu\n", Status);
ConSrvFreeHandlesTable(ProcessData); // NOTE: Always free the handles table.
- ProcessData->Console = NULL;
+ ProcessData->ConsoleHandle = NULL;
goto Quit;
}
/* Insert the process into the processes list of the console */
- InsertHeadList(&ProcessData->Console->ProcessList,
&ProcessData->ConsoleLink);
+ InsertHeadList(&Console->ProcessList, &ProcessData->ConsoleLink);
/* Add a reference count because the process is tied to the console */
- _InterlockedIncrement(&ProcessData->Console->ReferenceCount);
+ _InterlockedIncrement(&Console->ReferenceCount);
/* Update the internal info of the terminal */
- ConioRefreshInternalInfo(ProcessData->Console);
+ ConioRefreshInternalInfo(Console);
Status = STATUS_SUCCESS;
@@ -625,14 +641,16 @@
FASTCALL
ConSrvRemoveConsole(PCONSOLE_PROCESS_DATA ProcessData)
{
- PCONSOLE Console = ProcessData->Console;
+ PCONSOLE Console;
DPRINT("ConSrvRemoveConsole\n");
// RtlEnterCriticalSection(&ProcessData->HandleTableLock);
/* Validate and lock the console */
- if (ConDrvValidateConsole(Console, CONSOLE_RUNNING, TRUE))
+ if (ConDrvValidateConsole(&Console,
+ ProcessData->ConsoleHandle,
+ CONSOLE_RUNNING, TRUE))
{
DPRINT("ConSrvRemoveConsole - Locking OK\n");
@@ -640,7 +658,7 @@
ConSrvFreeHandlesTable(ProcessData);
/* Detach the process from the console */
- ProcessData->Console = NULL;
+ ProcessData->ConsoleHandle = NULL;
/* Remove ourselves from the console's list of processes */
RemoveEntryList(&ProcessData->ConsoleLink);
@@ -650,7 +668,7 @@
/* Release the console */
DPRINT("ConSrvRemoveConsole - Decrement Console->ReferenceCount =
%lu\n", Console->ReferenceCount);
- ConSrvReleaseConsole(Console, TRUE);
+ ConDrvReleaseConsole(Console, TRUE);
//CloseHandle(ProcessData->ConsoleEvent);
//ProcessData->ConsoleEvent = NULL;
}
@@ -752,7 +770,7 @@
PCONSOLE Console;
HANDLE ConsoleHandle = VerifyHandleRequest->ConsoleHandle;
- ULONG_PTR Index = (ULONG_PTR)ConsoleHandle >> 2;
+ ULONG Index = HandleToULong(ConsoleHandle) >> 2;
Status = ConSrvGetConsole(ProcessData, &Console, TRUE);
if (!NT_SUCCESS(Status))
@@ -785,7 +803,7 @@
PCONSOLE Console;
HANDLE ConsoleHandle = DuplicateHandleRequest->ConsoleHandle;
- ULONG_PTR Index = (ULONG_PTR)ConsoleHandle >> 2;
+ ULONG Index = HandleToULong(ConsoleHandle) >> 2;
PCONSOLE_IO_HANDLE Entry;
DWORD DesiredAccess;
Modified: trunk/reactos/win32ss/user/consrv/include/conio.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/consrv/includ…
==============================================================================
--- trunk/reactos/win32ss/user/consrv/include/conio.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/consrv/include/conio.h [iso-8859-1] Sat Jul 6 19:47:53
2013
@@ -270,13 +270,12 @@
CRITICAL_SECTION Lock;
CONSOLE_STATE State; /* State of the console */
- LIST_ENTRY Entry; /* Entry in the list of consoles */
LIST_ENTRY ProcessList; /* List of processes owning the console. The
first one is the so-called "Console Leader Process" */
FRONTEND TermIFace; /* Frontend-specific interface */
/**************************** Input buffer and data ***************************/
- CONSOLE_INPUT_BUFFER InputBuffer; /* Input buffer of the console */
+ CONSOLE_INPUT_BUFFER InputBuffer; /* Input buffer of the console */
/** Put those things in TEXTMODE_SCREEN_BUFFER ?? **/
PWCHAR LineBuffer; /* Current line being input, in line buffered
mode */
Modified: trunk/reactos/win32ss/user/consrv/include/console.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/consrv/includ…
==============================================================================
--- trunk/reactos/win32ss/user/consrv/include/console.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/consrv/include/console.h [iso-8859-1] Sat Jul 6 19:47:53
2013
@@ -8,8 +8,23 @@
#pragma once
-BOOLEAN NTAPI
-ConDrvValidateConsolePointer(IN PCONSOLE Console);
+VOID NTAPI
+ConDrvInitConsoleSupport(VOID);
+
+NTSTATUS NTAPI
+ConDrvInitConsole(OUT PHANDLE NewConsoleHandle,
+ OUT PCONSOLE* NewConsole,
+ IN PCONSOLE_INFO ConsoleInfo,
+ IN ULONG ConsoleLeaderProcessId);
+NTSTATUS NTAPI
+ConDrvRegisterFrontEnd(IN PCONSOLE Console,
+ IN PFRONTEND FrontEnd);
+NTSTATUS NTAPI
+ConDrvDeregisterFrontEnd(IN PCONSOLE Console);
+VOID NTAPI
+ConDrvDeleteConsole(IN PCONSOLE Console);
+
+
BOOLEAN NTAPI
ConDrvValidateConsoleState(IN PCONSOLE Console,
@@ -21,8 +36,19 @@
IN BOOLEAN LockConsole);
BOOLEAN NTAPI
-ConDrvValidateConsole(IN PCONSOLE Console,
+ConDrvValidateConsole(OUT PCONSOLE* Console,
+ IN HANDLE ConsoleHandle,
IN CONSOLE_STATE ExpectedState,
IN BOOLEAN LockConsole);
+
+
+NTSTATUS NTAPI
+ConDrvGetConsole(OUT PCONSOLE* Console,
+ IN HANDLE ConsoleHandle,
+ IN BOOLEAN LockConsole);
+VOID NTAPI
+ConDrvReleaseConsole(IN PCONSOLE Console,
+ IN BOOLEAN WasConsoleLocked);
+
/* EOF */
Modified: trunk/reactos/win32ss/user/consrv/init.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/consrv/init.c…
==============================================================================
--- trunk/reactos/win32ss/user/consrv/init.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/consrv/init.c [iso-8859-1] Sat Jul 6 19:47:53 2013
@@ -326,7 +326,7 @@
**************************************************************************/
NTSTATUS Status = STATUS_SUCCESS;
- PCONSOLE_PROCESS_DATA /* SourceProcessData, */ TargetProcessData;
+ PCONSOLE_PROCESS_DATA TargetProcessData;
/* An empty target process is invalid */
if (!TargetProcess) return STATUS_INVALID_PARAMETER;
@@ -337,7 +337,7 @@
RtlZeroMemory(TargetProcessData, sizeof(*TargetProcessData));
TargetProcessData->Process = TargetProcess;
TargetProcessData->ConsoleEvent = NULL;
- TargetProcessData->Console = TargetProcessData->ParentConsole = NULL;
+ TargetProcessData->ConsoleHandle = TargetProcessData->ParentConsoleHandle =
NULL;
TargetProcessData->ConsoleApp = ((TargetProcess->Flags &
CsrProcessIsConsoleApp) ? TRUE : FALSE);
/*
@@ -363,20 +363,23 @@
if (TargetProcessData->ConsoleApp /* && SourceProcessData->ConsoleApp
*/)
{
PCONSOLE_PROCESS_DATA SourceProcessData =
ConsoleGetPerProcessData(SourceProcess);
+ PCONSOLE SourceConsole;
/* Validate and lock the parent's console */
- if (ConDrvValidateConsole(SourceProcessData->Console, CONSOLE_RUNNING, TRUE))
+ if (ConDrvValidateConsole(&SourceConsole,
+ SourceProcessData->ConsoleHandle,
+ CONSOLE_RUNNING, TRUE))
{
/* Inherit the parent's handles table */
Status = ConSrvInheritHandlesTable(SourceProcessData, TargetProcessData);
if (NT_SUCCESS(Status))
{
/* Temporary save the parent's console too */
- TargetProcessData->ParentConsole = SourceProcessData->Console;
+ TargetProcessData->ParentConsoleHandle =
SourceProcessData->ConsoleHandle;
}
/* Unlock the parent's console */
- LeaveCriticalSection(&SourceProcessData->Console->Lock);
+ LeaveCriticalSection(&SourceConsole->Lock);
}
}
@@ -412,8 +415,8 @@
}
/* If we don't have a console, then create a new one... */
- if (!ConnectInfo->Console ||
- ConnectInfo->Console != ProcessData->ParentConsole)
+ if (!ConnectInfo->ConsoleHandle ||
+ ConnectInfo->ConsoleHandle != ProcessData->ParentConsoleHandle)
{
DPRINT("ConSrvConnect - Allocate a new console\n");
@@ -446,7 +449,7 @@
/* Reuse our current console */
Status = ConSrvInheritConsole(ProcessData,
- ConnectInfo->Console,
+ ConnectInfo->ConsoleHandle,
FALSE,
NULL, // &ConnectInfo->InputHandle,
NULL, // &ConnectInfo->OutputHandle,
@@ -458,16 +461,12 @@
}
}
- /* Return it to the caller */
- ConnectInfo->Console = ProcessData->Console;
-
- /* Input Wait Handle */
+ /* Return the console handle and the input wait handle to the caller */
+ ConnectInfo->ConsoleHandle = ProcessData->ConsoleHandle;
ConnectInfo->InputWaitHandle = ProcessData->ConsoleEvent;
- /* Set the Property Dialog Handler */
+ /* Set the Property-Dialog and Control-Dispatcher handlers */
ProcessData->PropDispatcher = ConnectInfo->PropDispatcher;
-
- /* Set the Ctrl Dispatcher */
ProcessData->CtrlDispatcher = ConnectInfo->CtrlDispatcher;
return STATUS_SUCCESS;
@@ -483,8 +482,8 @@
* This function is called whenever a new process (GUI or CUI) is destroyed.
**************************************************************************/
- if ( ProcessData->Console != NULL ||
- ProcessData->HandleTable != NULL )
+ if ( ProcessData->ConsoleHandle != NULL ||
+ ProcessData->HandleTable != NULL )
{
DPRINT("ConSrvDisconnect - calling ConSrvRemoveConsole\n");
ConSrvRemoveConsole(ProcessData);
Modified: trunk/reactos/win32ss/user/consrv/procinit.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/consrv/procin…
==============================================================================
--- trunk/reactos/win32ss/user/consrv/procinit.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/consrv/procinit.h [iso-8859-1] Sat Jul 6 19:47:53 2013
@@ -14,7 +14,7 @@
PHANDLE pErrorHandle,
PCONSOLE_START_INFO ConsoleStartInfo);
NTSTATUS FASTCALL ConSrvInheritConsole(PCONSOLE_PROCESS_DATA ProcessData,
- struct _CONSOLE* /* PCONSOLE */ Console,
+ HANDLE ConsoleHandle,
BOOL CreateNewHandlesTable,
PHANDLE pInputHandle,
PHANDLE pOutputHandle,