Author: hbelusca
Date: Sat Nov 22 22:13:08 2014
New Revision: 65449
URL:
http://svn.reactos.org/svn/reactos?rev=65449&view=rev
Log:
[KERNEL32][CONSRV]
- Remove the USE_CONSOLE_INIT_HANDLES define since now we "support" the console
initialization events.
- The events in the CONSOLE_START_INFO structure are console initialization events used
for asynchronous console creation, that are set whenever console creation succeeds, or
fails.
- Stubplement their usage in CONSRV.
Now we are able to fully use Windows 2k3 kernel32.dll and be able to run console programs
with it.
Modified:
trunk/reactos/dll/win32/kernel32/client/console/console.c
trunk/reactos/dll/win32/kernel32/client/console/init.c
trunk/reactos/dll/win32/kernel32/include/console.h
trunk/reactos/include/reactos/subsys/win/conmsg.h
trunk/reactos/win32ss/user/winsrv/consrv/condrv/coninput.c
trunk/reactos/win32ss/user/winsrv/consrv/condrv/console.c
trunk/reactos/win32ss/user/winsrv/consrv/console.c
trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c
trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c
trunk/reactos/win32ss/user/winsrv/consrv/handle.c
trunk/reactos/win32ss/user/winsrv/consrv/include/conio_winsrv.h
trunk/reactos/win32ss/user/winsrv/consrv/init.c
trunk/reactos/win32ss/user/winsrv/consrv/procinit.h
Modified: trunk/reactos/dll/win32/kernel32/client/console/console.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/console/console.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/client/console/console.c [iso-8859-1] Sat Nov 22
22:13:08 2014
@@ -1166,9 +1166,7 @@
PCONSOLE_START_INFO ConsoleStartInfo)
{
BOOL Success = TRUE;
-#ifdef USE_CONSOLE_INIT_HANDLES
NTSTATUS Status;
-#endif
CONSOLE_API_MESSAGE ApiMessage;
PCONSOLE_ALLOCCONSOLE AllocConsoleRequest =
&ApiMessage.Data.AllocConsoleRequest;
@@ -1229,9 +1227,9 @@
goto Quit;
}
-#ifdef USE_CONSOLE_INIT_HANDLES
- // Is AllocConsoleRequest->ConsoleStartInfo->Events aligned on handle boundary
????
- Status = NtWaitForMultipleObjects(2,
AllocConsoleRequest->ConsoleStartInfo->Events,
+ // Is AllocConsoleRequest->ConsoleStartInfo->InitEvents aligned on handle
boundary ????
+ Status = NtWaitForMultipleObjects(MAX_INIT_EVENTS,
+
AllocConsoleRequest->ConsoleStartInfo->InitEvents,
WaitAny, FALSE, NULL);
if (!NT_SUCCESS(Status))
{
@@ -1240,15 +1238,14 @@
goto Quit;
}
- NtClose(AllocConsoleRequest->ConsoleStartInfo->Events[0]);
- NtClose(AllocConsoleRequest->ConsoleStartInfo->Events[1]);
- if (Status != STATUS_SUCCESS)
+ NtClose(AllocConsoleRequest->ConsoleStartInfo->InitEvents[INIT_SUCCESS]);
+ NtClose(AllocConsoleRequest->ConsoleStartInfo->InitEvents[INIT_FAILURE]);
+ if (Status != INIT_SUCCESS)
{
NtCurrentPeb()->ProcessParameters->ConsoleHandle = NULL;
Success = FALSE;
}
else
-#endif
{
RtlCopyMemory(ConsoleStartInfo,
AllocConsoleRequest->ConsoleStartInfo,
@@ -2505,9 +2502,7 @@
PCONSOLE_START_INFO ConsoleStartInfo)
{
BOOL Success = TRUE;
-#ifdef USE_CONSOLE_INIT_HANDLES
NTSTATUS Status;
-#endif
CONSOLE_API_MESSAGE ApiMessage;
PCONSOLE_ATTACHCONSOLE AttachConsoleRequest =
&ApiMessage.Data.AttachConsoleRequest;
@@ -2541,9 +2536,9 @@
goto Quit;
}
-#ifdef USE_CONSOLE_INIT_HANDLES
- // Is AttachConsoleRequest->ConsoleStartInfo->Events aligned on handle boundary
????
- Status = NtWaitForMultipleObjects(2,
AttachConsoleRequest->ConsoleStartInfo->Events,
+ // Is AttachConsoleRequest->ConsoleStartInfo->InitEvents aligned on handle
boundary ????
+ Status = NtWaitForMultipleObjects(MAX_INIT_EVENTS,
+
AttachConsoleRequest->ConsoleStartInfo->InitEvents,
WaitAny, FALSE, NULL);
if (!NT_SUCCESS(Status))
{
@@ -2552,15 +2547,14 @@
goto Quit;
}
- NtClose(AttachConsoleRequest->ConsoleStartInfo->Events[0]);
- NtClose(AttachConsoleRequest->ConsoleStartInfo->Events[1]);
- if (Status != STATUS_SUCCESS)
+ NtClose(AttachConsoleRequest->ConsoleStartInfo->InitEvents[INIT_SUCCESS]);
+ NtClose(AttachConsoleRequest->ConsoleStartInfo->InitEvents[INIT_FAILURE]);
+ if (Status != INIT_SUCCESS)
{
NtCurrentPeb()->ProcessParameters->ConsoleHandle = NULL;
Success = FALSE;
}
else
-#endif
{
RtlCopyMemory(ConsoleStartInfo,
AttachConsoleRequest->ConsoleStartInfo,
Modified: trunk/reactos/dll/win32/kernel32/client/console/init.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/console/init.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/client/console/init.c [iso-8859-1] Sat Nov 22
22:13:08 2014
@@ -308,9 +308,10 @@
/* Nothing to do if this is not a console app */
if (!ConnectInfo->IsConsoleApp) return TRUE;
-#ifdef USE_CONSOLE_INIT_HANDLES
/* Wait for the connection to finish */
- Status = NtWaitForMultipleObjects(2, ConnectInfo->ConsoleStartInfo.Events,
+ // Is ConnectInfo->ConsoleStartInfo.InitEvents aligned on handle boundary ????
+ Status = NtWaitForMultipleObjects(MAX_INIT_EVENTS,
+ ConnectInfo->ConsoleStartInfo.InitEvents,
WaitAny, FALSE, NULL);
if (!NT_SUCCESS(Status))
{
@@ -318,15 +319,13 @@
return FALSE;
}
- NtClose(ConnectInfo->ConsoleStartInfo.Events[0]);
- NtClose(ConnectInfo->ConsoleStartInfo.Events[1]);
-
- if (Status != STATUS_SUCCESS)
+ NtClose(ConnectInfo->ConsoleStartInfo.InitEvents[INIT_SUCCESS]);
+ NtClose(ConnectInfo->ConsoleStartInfo.InitEvents[INIT_FAILURE]);
+ if (Status != INIT_SUCCESS)
{
NtCurrentPeb()->ProcessParameters->ConsoleHandle = NULL;
return FALSE;
}
-#endif
return TRUE;
}
Modified: trunk/reactos/dll/win32/kernel32/include/console.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/include…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/include/console.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/include/console.h [iso-8859-1] Sat Nov 22 22:13:08
2014
@@ -13,10 +13,6 @@
#define HANDLE_DETACHED_PROCESS (HANDLE)-1
#define HANDLE_CREATE_NEW_CONSOLE (HANDLE)-2
#define HANDLE_CREATE_NO_WINDOW (HANDLE)-3
-
-// Enable (and then get rid of) this define when support for
-// console initialization handles is implemented in CONSRV.
-// #define USE_CONSOLE_INIT_HANDLES
/* FUNCTION PROTOTYPES ********************************************************/
Modified: trunk/reactos/include/reactos/subsys/win/conmsg.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/subsys/win…
==============================================================================
--- trunk/reactos/include/reactos/subsys/win/conmsg.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/subsys/win/conmsg.h [iso-8859-1] Sat Nov 22 22:13:08
2014
@@ -158,6 +158,13 @@
UINT uCodePage;
} CONSOLE_PROPERTIES;
+enum
+{
+ INIT_SUCCESS, // STATUS_WAIT_0
+ INIT_FAILURE, // STATUS_WAIT_1
+ MAX_INIT_EVENTS
+};
+
typedef struct _CONSOLE_START_INFO
{
HANDLE ConsoleHandle;
@@ -165,7 +172,7 @@
HANDLE InputHandle;
HANDLE OutputHandle;
HANDLE ErrorHandle;
- HANDLE Events[2];
+ HANDLE InitEvents[MAX_INIT_EVENTS];
CONSOLE_PROPERTIES;
} CONSOLE_START_INFO, *PCONSOLE_START_INFO;
Modified: trunk/reactos/win32ss/user/winsrv/consrv/condrv/coninput.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/condrv/coninput.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/condrv/coninput.c [iso-8859-1] Sat Nov 22
22:13:08 2014
@@ -170,7 +170,7 @@
Status = STATUS_SUCCESS;
}
- if (SetWaitEvent) SetEvent(Console->InputBuffer.ActiveEvent);
+ if (SetWaitEvent) NtSetEvent(Console->InputBuffer.ActiveEvent, NULL);
Done:
if (NumEventsWritten) *NumEventsWritten = i;
@@ -198,16 +198,24 @@
ConDrvInitInputBuffer(IN PCONSOLE Console,
IN ULONG InputBufferSize)
{
- SECURITY_ATTRIBUTES SecurityAttributes;
+ NTSTATUS Status;
+ OBJECT_ATTRIBUTES ObjectAttributes;
ConSrvInitObject(&Console->InputBuffer.Header, INPUT_BUFFER, Console);
- SecurityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
- SecurityAttributes.lpSecurityDescriptor = NULL;
- SecurityAttributes.bInheritHandle = TRUE;
-
- Console->InputBuffer.ActiveEvent = CreateEventW(&SecurityAttributes, TRUE,
FALSE, NULL);
- if (Console->InputBuffer.ActiveEvent == NULL) return STATUS_UNSUCCESSFUL;
+ InitializeObjectAttributes(&ObjectAttributes,
+ NULL,
+ OBJ_INHERIT,
+ NULL,
+ NULL);
+
+ Status = NtCreateEvent(&Console->InputBuffer.ActiveEvent, EVENT_ALL_ACCESS,
+ &ObjectAttributes, NotificationEvent, FALSE);
+ if (!NT_SUCCESS(Status))
+ {
+ return STATUS_UNSUCCESSFUL;
+ // return Status;
+ }
Console->InputBuffer.InputBufferSize = InputBufferSize;
InitializeListHead(&Console->InputBuffer.InputEvents);
Modified: trunk/reactos/win32ss/user/winsrv/consrv/condrv/console.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/condrv/console.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/condrv/console.c [iso-8859-1] Sat Nov 22
22:13:08 2014
@@ -80,7 +80,10 @@
ConDrvPause(PCONSOLE Console)
{
if (!Console->UnpauseEvent)
- Console->UnpauseEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+ {
+ NtCreateEvent(&Console->UnpauseEvent, EVENT_ALL_ACCESS,
+ NULL, NotificationEvent, FALSE);
+ }
}
VOID NTAPI
@@ -88,8 +91,8 @@
{
if (Console->UnpauseEvent)
{
- SetEvent(Console->UnpauseEvent);
- CloseHandle(Console->UnpauseEvent);
+ NtSetEvent(Console->UnpauseEvent, NULL);
+ NtClose(Console->UnpauseEvent);
Console->UnpauseEvent = NULL;
}
}
Modified: trunk/reactos/win32ss/user/winsrv/consrv/console.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/console.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/console.c [iso-8859-1] Sat Nov 22 22:13:08
2014
@@ -663,6 +663,27 @@
/* Colour table */
memcpy(Console->Colors, ConsoleInfo.Colors, sizeof(ConsoleInfo.Colors));
+ /* Create the Initialization Events */
+ Status = NtCreateEvent(&Console->InitEvents[INIT_SUCCESS], EVENT_ALL_ACCESS,
+ NULL, NotificationEvent, FALSE);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("NtCreateEvent(InitEvents[INIT_SUCCESS]) failed: %lu\n",
Status);
+ ConDrvDeleteConsole(Console);
+ ConSrvDeinitTerminal(&Terminal);
+ return Status;
+ }
+ Status = NtCreateEvent(&Console->InitEvents[INIT_FAILURE], EVENT_ALL_ACCESS,
+ NULL, NotificationEvent, FALSE);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("NtCreateEvent(InitEvents[INIT_FAILURE]) failed: %lu\n",
Status);
+ NtClose(Console->InitEvents[INIT_SUCCESS]);
+ ConDrvDeleteConsole(Console);
+ ConSrvDeinitTerminal(&Terminal);
+ return Status;
+ }
+
/*
* Attach the ConSrv terminal to the console.
* This call makes a copy of our local Terminal variable.
@@ -671,6 +692,8 @@
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);
ConSrvDeinitTerminal(&Terminal);
return Status;
@@ -679,6 +702,10 @@
/* All went right, so add the console to the list */
Status = InsertConsole(&ConsoleHandle, Console);
+
+ // FIXME! We do not support at all asynchronous console creation!
+ NtSetEvent(Console->InitEvents[INIT_SUCCESS], NULL);
+ // NtSetEvent(Console->InitEvents[INIT_FAILURE], NULL);
/* Return the newly created console to the caller and a success code too */
*NewConsoleHandle = ConsoleHandle;
@@ -695,6 +722,10 @@
/* Remove the console from the list */
RemoveConsoleByPointer(Console);
+
+ /* Destroy the Initialization Events */
+ NtClose(Console->InitEvents[INIT_FAILURE]);
+ NtClose(Console->InitEvents[INIT_SUCCESS]);
/* Clean the Input Line Discipline */
if (Console->LineBuffer) ConsoleFreeHeap(Console->LineBuffer);
@@ -999,7 +1030,8 @@
TRUE,
&AttachConsoleRequest->ConsoleStartInfo->InputHandle,
&AttachConsoleRequest->ConsoleStartInfo->OutputHandle,
-
&AttachConsoleRequest->ConsoleStartInfo->ErrorHandle);
+
&AttachConsoleRequest->ConsoleStartInfo->ErrorHandle,
+ AttachConsoleRequest->ConsoleStartInfo);
if (!NT_SUCCESS(Status))
{
DPRINT1("Console inheritance failed\n");
Modified: trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c [iso-8859-1]
(original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c [iso-8859-1] Sat Nov
22 22:13:08 2014
@@ -663,7 +663,7 @@
{
DPRINT1("GuiConsoleNcCreate: InitFonts failed\n");
GuiData->hWindow = NULL;
- SetEvent(GuiData->hGuiInitEvent);
+ NtSetEvent(GuiData->hGuiInitEvent, NULL);
return FALSE;
}
@@ -691,7 +691,7 @@
//CreateSysMenu(GuiData->hWindow);
DPRINT("OnNcCreate - setting start event\n");
- SetEvent(GuiData->hGuiInitEvent);
+ NtSetEvent(GuiData->hGuiInitEvent, NULL);
return (BOOL)DefWindowProcW(GuiData->hWindow, WM_NCCREATE, 0, (LPARAM)Create);
}
Modified: trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c [iso-8859-1]
(original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c [iso-8859-1] Sat Nov
22 22:13:08 2014
@@ -149,12 +149,12 @@
MSG msg;
/*
- * This thread dispatches all the console notifications to the notify window.
- * It is common for all the console windows.
+ * This thread dispatches all the console notifications to the
+ * notification window. It is common for all the console windows.
*/
/* The thread has been initialized, set the event */
- SetEvent(*GraphicsStartupEvent);
+ NtSetEvent(*GraphicsStartupEvent, NULL);
while (GetMessageW(&msg, NULL, 0, 0))
{
@@ -250,7 +250,7 @@
DestroyWindow(GuiData->hWindow);
PrivateCsrssManualGuiCheck(+1); // RemoveGuiApp
- SetEvent(GuiData->hGuiTermEvent);
+ NtSetEvent(GuiData->hGuiTermEvent, NULL);
if (InterlockedDecrement(&WindowCount) == 0)
{
@@ -295,8 +295,12 @@
*/
if (hInputThread == NULL)
{
- HANDLE GraphicsStartupEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
- if (GraphicsStartupEvent == NULL) return FALSE;
+ HANDLE GraphicsStartupEvent;
+ NTSTATUS Status;
+
+ Status = NtCreateEvent(&GraphicsStartupEvent, EVENT_ALL_ACCESS,
+ NULL, SynchronizationEvent, FALSE);
+ if (!NT_SUCCESS(Status)) return FALSE;
hInputThread = CreateThread(NULL,
0,
@@ -306,7 +310,7 @@
&dwInputThreadId);
if (hInputThread == NULL)
{
- CloseHandle(GraphicsStartupEvent);
+ NtClose(GraphicsStartupEvent);
DPRINT1("CONSRV: Failed to create graphics console thread.\n");
return FALSE;
}
@@ -314,7 +318,7 @@
CloseHandle(hInputThread);
WaitForSingleObject(GraphicsStartupEvent, INFINITE);
- CloseHandle(GraphicsStartupEvent);
+ NtClose(GraphicsStartupEvent);
}
// ConsInitialized = TRUE;
@@ -471,8 +475,10 @@
* Ideally we could use SendNotifyMessage for this but its not
* yet implemented.
*/
- GuiData->hGuiInitEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
- GuiData->hGuiTermEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
+ NtCreateEvent(&GuiData->hGuiInitEvent, EVENT_ALL_ACCESS,
+ NULL, SynchronizationEvent, FALSE);
+ NtCreateEvent(&GuiData->hGuiTermEvent, EVENT_ALL_ACCESS,
+ NULL, SynchronizationEvent, FALSE);
DPRINT("GUI - Checkpoint\n");
@@ -482,7 +488,7 @@
/* Wait until initialization has finished */
WaitForSingleObject(GuiData->hGuiInitEvent, INFINITE);
DPRINT("OK we created the console window\n");
- CloseHandle(GuiData->hGuiInitEvent);
+ NtClose(GuiData->hGuiInitEvent);
GuiData->hGuiInitEvent = NULL;
/* Check whether we really succeeded in initializing the terminal window */
@@ -505,7 +511,7 @@
PostThreadMessageW(dwInputThreadId, PM_DESTROY_CONSOLE, 0, (LPARAM)GuiData);
WaitForSingleObject(GuiData->hGuiTermEvent, INFINITE);
DPRINT("hGuiTermEvent set\n");
- CloseHandle(GuiData->hGuiTermEvent);
+ NtClose(GuiData->hGuiTermEvent);
GuiData->hGuiTermEvent = NULL;
DPRINT("Destroying icons !! - GuiData->hIcon = 0x%p ; ghDefaultIcon = 0x%p ;
GuiData->hIconSm = 0x%p ; ghDefaultIconSm = 0x%p\n",
Modified: trunk/reactos/win32ss/user/winsrv/consrv/handle.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/handle.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/handle.c [iso-8859-1] Sat Nov 22 22:13:08
2014
@@ -521,6 +521,36 @@
return Status;
}
+ /* Duplicate the Initialization Events */
+ Status = NtDuplicateObject(NtCurrentProcess(),
+ Console->InitEvents[INIT_SUCCESS],
+ ProcessData->Process->ProcessHandle,
+
&ConsoleInitInfo->ConsoleStartInfo->InitEvents[INIT_SUCCESS],
+ EVENT_ALL_ACCESS, 0, 0);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("NtDuplicateObject(InitEvents[INIT_SUCCESS]) failed: %lu\n",
Status);
+ ConSrvFreeHandlesTable(ProcessData);
+ ConSrvDeleteConsole(Console);
+ ProcessData->ConsoleHandle = NULL;
+ return Status;
+ }
+
+ Status = NtDuplicateObject(NtCurrentProcess(),
+ Console->InitEvents[INIT_FAILURE],
+ ProcessData->Process->ProcessHandle,
+
&ConsoleInitInfo->ConsoleStartInfo->InitEvents[INIT_FAILURE],
+ EVENT_ALL_ACCESS, 0, 0);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("NtDuplicateObject(InitEvents[INIT_FAILURE]) failed: %lu\n",
Status);
+ NtClose(ConsoleInitInfo->ConsoleStartInfo->InitEvents[INIT_SUCCESS]);
+ ConSrvFreeHandlesTable(ProcessData);
+ ConSrvDeleteConsole(Console);
+ ProcessData->ConsoleHandle = NULL;
+ return Status;
+ }
+
/* Duplicate the Input Event */
Status = NtDuplicateObject(NtCurrentProcess(),
Console->InputBuffer.ActiveEvent,
@@ -529,7 +559,9 @@
EVENT_ALL_ACCESS, 0, 0);
if (!NT_SUCCESS(Status))
{
- DPRINT1("NtDuplicateObject() failed: %lu\n", Status);
+ DPRINT1("NtDuplicateObject(InputWaitHandle) failed: %lu\n", Status);
+ NtClose(ConsoleInitInfo->ConsoleStartInfo->InitEvents[INIT_FAILURE]);
+ NtClose(ConsoleInitInfo->ConsoleStartInfo->InitEvents[INIT_SUCCESS]);
ConSrvFreeHandlesTable(ProcessData);
ConSrvDeleteConsole(Console);
ProcessData->ConsoleHandle = NULL;
@@ -554,7 +586,8 @@
BOOLEAN CreateNewHandlesTable,
PHANDLE pInputHandle,
PHANDLE pOutputHandle,
- PHANDLE pErrorHandle)
+ PHANDLE pErrorHandle,
+ PCONSOLE_START_INFO ConsoleStartInfo)
{
NTSTATUS Status = STATUS_SUCCESS;
PCONSOLE Console;
@@ -599,6 +632,34 @@
}
}
+ /* Duplicate the Initialization Events */
+ Status = NtDuplicateObject(NtCurrentProcess(),
+ Console->InitEvents[INIT_SUCCESS],
+ ProcessData->Process->ProcessHandle,
+ &ConsoleStartInfo->InitEvents[INIT_SUCCESS],
+ EVENT_ALL_ACCESS, 0, 0);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("NtDuplicateObject(InitEvents[INIT_SUCCESS]) failed: %lu\n",
Status);
+ ConSrvFreeHandlesTable(ProcessData);
+ ProcessData->ConsoleHandle = NULL;
+ goto Quit;
+ }
+
+ Status = NtDuplicateObject(NtCurrentProcess(),
+ Console->InitEvents[INIT_FAILURE],
+ ProcessData->Process->ProcessHandle,
+ &ConsoleStartInfo->InitEvents[INIT_FAILURE],
+ EVENT_ALL_ACCESS, 0, 0);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("NtDuplicateObject(InitEvents[INIT_FAILURE]) failed: %lu\n",
Status);
+ NtClose(ConsoleStartInfo->InitEvents[INIT_SUCCESS]);
+ ConSrvFreeHandlesTable(ProcessData);
+ ProcessData->ConsoleHandle = NULL;
+ goto Quit;
+ }
+
/* Duplicate the Input Event */
Status = NtDuplicateObject(NtCurrentProcess(),
Console->InputBuffer.ActiveEvent,
@@ -607,7 +668,9 @@
EVENT_ALL_ACCESS, 0, 0);
if (!NT_SUCCESS(Status))
{
- DPRINT1("NtDuplicateObject() failed: %lu\n", Status);
+ DPRINT1("NtDuplicateObject(InputWaitHandle) failed: %lu\n", Status);
+ NtClose(ConsoleStartInfo->InitEvents[INIT_FAILURE]);
+ NtClose(ConsoleStartInfo->InitEvents[INIT_SUCCESS]);
ConSrvFreeHandlesTable(ProcessData); // NOTE: Always free the handles table.
ProcessData->ConsoleHandle = NULL;
goto Quit;
Modified: trunk/reactos/win32ss/user/winsrv/consrv/include/conio_winsrv.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/include/conio_winsrv.h [iso-8859-1]
(original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/include/conio_winsrv.h [iso-8859-1] Sat Nov
22 22:13:08 2014
@@ -139,6 +139,8 @@
// CRITICAL_SECTION Lock;
// CONSOLE_STATE State; /* State of the console */
+ HANDLE InitEvents[MAX_INIT_EVENTS]; /* Initialization events */
+
FRONTEND FrontEndIFace; /* Frontend-specific interface */
/******************************* Process support ******************************/
Modified: trunk/reactos/win32ss/user/winsrv/consrv/init.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/init.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/init.c [iso-8859-1] Sat Nov 22 22:13:08 2014
@@ -480,9 +480,10 @@
Status = ConSrvInheritConsole(ProcessData,
ConnectInfo->ConsoleStartInfo.ConsoleHandle,
FALSE,
- NULL, //
&ConnectInfo->ConsoleStartInfo.InputHandle,
- NULL, //
&ConnectInfo->ConsoleStartInfo.OutputHandle,
- NULL); //
&ConnectInfo->ConsoleStartInfo.ErrorHandle);
+ NULL, //
&ConnectInfo->ConsoleStartInfo.InputHandle,
+ NULL, //
&ConnectInfo->ConsoleStartInfo.OutputHandle,
+ NULL, //
&ConnectInfo->ConsoleStartInfo.ErrorHandle,
+ &ConnectInfo->ConsoleStartInfo);
if (!NT_SUCCESS(Status))
{
DPRINT1("Console inheritance failed\n");
Modified: trunk/reactos/win32ss/user/winsrv/consrv/procinit.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/procinit.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/procinit.h [iso-8859-1] Sat Nov 22 22:13:08
2014
@@ -18,5 +18,6 @@
BOOLEAN CreateNewHandlesTable,
PHANDLE pInputHandle,
PHANDLE pOutputHandle,
- PHANDLE pErrorHandle);
+ PHANDLE pErrorHandle,
+ PCONSOLE_START_INFO ConsoleStartInfo);
VOID ConSrvRemoveConsole(PCONSOLE_PROCESS_DATA ProcessData);