Author: ion Date: Sat Feb 18 22:29:46 2012 New Revision: 55684
URL: http://svn.reactos.org/svn/reactos?rev=55684&view=rev Log: [KERNEL32]: Try to connect to the Console Server when initializing console support. For normal apps, won't do anything since ConnectionInfo == NULL (to hack around the fact there's no server in ReactOS for this), but for DLLs running inside of CSRSS, because we now support Server-to-Server, the call will detect that and not fail. This fixes the "failed to give us console" error when kernel32 inside of csrss tries to get a console (which it shouldn't). There's still user32 to cleanup.
Modified: trunk/reactos/dll/win32/kernel32/client/dllmain.c
Modified: trunk/reactos/dll/win32/kernel32/client/dllmain.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/d... ============================================================================== --- trunk/reactos/dll/win32/kernel32/client/dllmain.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/client/dllmain.c [iso-8859-1] Sat Feb 18 22:29:46 2012 @@ -68,7 +68,10 @@ PRTL_USER_PROCESS_PARAMETERS Parameters = NtCurrentPeb()->ProcessParameters; LPCWSTR ExeName; STARTUPINFO si; - + WCHAR SessionDir[256]; + ULONG SessionId = NtCurrentPeb()->SessionId; + BOOLEAN InServer; + WCHAR lpTest[MAX_PATH]; GetModuleFileNameW(NULL, lpTest, MAX_PATH); DPRINT("BasepInitConsole for : %S\n", lpTest); @@ -136,6 +139,38 @@
/* Now use the proper console handle */ Request.Data.AllocConsoleRequest.Console = Parameters->ConsoleHandle; + + /* Setup the right Object Directory path */ + if (!SessionId) + { + /* Use the raw path */ + wcscpy(SessionDir, WIN_OBJ_DIR); + } + else + { + /* Use the session path */ + swprintf(SessionDir, + L"%ws\%ld%ws", + SESSION_DIR, + SessionId, + WIN_OBJ_DIR); + } + + /* Connect to the base server */ + DPRINT("Connecting to CSR...\n"); + Status = CsrClientConnectToServer(SessionDir, + 2, + NULL, + NULL, + &InServer); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to connect to CSR (Status %lx)\n", Status); + return FALSE; + } + + /* Nothing to do for server-to-server */ + if (InServer) return TRUE;
/* * Normally, we should be connecting to the Console CSR Server... @@ -156,6 +191,7 @@ return TRUE; }
+ /* Nothing to do if not a console app */ if (NotConsole) return TRUE;
/* We got the handles, let's set them */