Author: ion
Date: Wed Feb 8 21:56:23 2012
New Revision: 55500
URL:
http://svn.reactos.org/svn/reactos?rev=55500&view=rev
Log:
[CSRSRV]: The connection with SMSS(2) should be done after initialization, not before.
This is because in SMSS2, there is no "Complete" API -- you are assumed to be
ready when you connect, instead of connecting + completing later. Should not break SMSS
behavior, but required for SMSS2.
[CSRSRV]: Fix many bugs in ServerSbApiPortThread. This function never worked as SMSS never
actually connects to the SB API Port. Since SMSS2 does, a few bugs were discovered. Also,
hack-plement the one SB API that is required for SMSS2 (SbpCreateSession). All we do is
resume the thread we receive (Winlogon)... normally we'd also register a hard-error
port, etc.
[CSRSRV]: If connecting with SMDLL to SMSS did not work (such as on my system where SMSS
is no longer there), try using SMLIB and SMSS2 instead. This way CSRSS still works with
both environments.
[CSRSRV]: Required rbuild/cmake changes to build with SMLIB.
Modified:
trunk/reactos/subsystems/win32/csrss/csrsrv/CMakeLists.txt
trunk/reactos/subsystems/win32/csrss/csrsrv/api/wapi.c
trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.rbuild
trunk/reactos/subsystems/win32/csrss/csrsrv/init.c
trunk/reactos/subsystems/win32/csrss/csrsrv/srv.h
Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/csrsrv/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/csrsrv/CMakeLists.txt [iso-8859-1] Wed Feb 8
21:56:23 2012
@@ -15,7 +15,7 @@
add_library(csrsrv SHARED ${SOURCE})
-target_link_libraries(csrsrv ${PSEH_LIB})
+target_link_libraries(csrsrv ${PSEH_LIB} smlib)
set_module_type(csrsrv nativedll)
Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/api/wapi.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/csrsrv/api/wapi.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/csrsrv/api/wapi.c [iso-8859-1] Wed Feb 8
21:56:23 2012
@@ -767,7 +767,7 @@
ServerSbApiPortThread (HANDLE hSbApiPortListen)
{
HANDLE hConnectedPort = (HANDLE) 0;
- PORT_MESSAGE Request;
+ SB_API_MSG Request;
PVOID Context = NULL;
NTSTATUS Status = STATUS_SUCCESS;
PPORT_MESSAGE Reply = NULL;
@@ -775,7 +775,7 @@
DPRINT("CSR: %s called\n", __FUNCTION__);
RtlZeroMemory(&Request, sizeof(PORT_MESSAGE));
- Status = NtListenPort (hSbApiPortListen, & Request);
+ Status = NtListenPort (hSbApiPortListen, & Request.h);
if (!NT_SUCCESS(Status))
{
@@ -785,7 +785,7 @@
DPRINT("-- 1\n");
Status = NtAcceptConnectPort(&hConnectedPort,
NULL,
- &Request,
+ &Request.h,
TRUE,
NULL,
NULL);
@@ -819,7 +819,7 @@
Status = NtReplyWaitReceivePort(hConnectedPort,
Context,
Reply,
- &Request);
+ &Request.h);
if(!NT_SUCCESS(Status))
{
DPRINT1("CSR: %s: NtReplyWaitReceivePort failed
(Status=0x%08lx)\n",
@@ -827,12 +827,30 @@
break;
}
- switch (Request.u2.s2.Type) //fix .h PORT_MESSAGE_TYPE(Request))
+ switch (Request.h.u2.s2.Type) //fix .h PORT_MESSAGE_TYPE(Request))
{
/* TODO */
+ case LPC_PORT_CLOSED:
+ case LPC_CLIENT_DIED:
+ DPRINT1("CSR: SMSS died\n");
+ Reply = NULL;
+ break;
+
default:
DPRINT1("CSR: %s received message (type=%d)\n",
- __FUNCTION__, Request.u2.s2.Type);
+ __FUNCTION__, Request.h.u2.s2.Type);
+
+ if (Request.ApiNumber == SbpCreateSession)
+ {
+ DPRINT("Session create... legacy CSRSS resuming thread
as minimum work done\n");
+ Request.ReturnValue =
NtResumeThread(Request.CreateSession.ProcessInfo.ThreadHandle, NULL);
+ }
+ else
+ {
+ DPRINT1("CSR: %d Not implemented in legacy CSRSS...
faking success\n", Request.ApiNumber);
+ Request.ReturnValue = STATUS_SUCCESS;
+ }
+ Reply = &Request.h;
}
DPRINT("-- 5\n");
}
Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.rbuild [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.rbuild [iso-8859-1] Wed Feb 8
21:56:23 2012
@@ -9,6 +9,7 @@
<library>ntdll</library>
<library>pseh</library>
<library>smdll</library>
+ <library>smlib</library>
<directory name="api">
<file>process.c</file>
<file>user.c</file>
Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/init.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/csrsrv/init.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/csrsrv/init.c [iso-8859-1] Wed Feb 8 21:56:23
2012
@@ -383,9 +383,9 @@
NULL);
Status = NtCreatePort ( Port,
& PortAttributes,
- LPC_MAX_DATA_LENGTH, /* TODO: make caller set it*/
- LPC_MAX_MESSAGE_LENGTH, /* TODO: make caller set it*/
- 0); /* TODO: make caller set it*/
+ sizeof(SB_CONNECTION_INFO),
+ sizeof(SB_API_MSG),
+ 32 * sizeof(SB_API_MSG));
if(!NT_SUCCESS(Status))
{
DPRINT1("CSR: %s: NtCreatePort failed (Status=%08lx)\n",
@@ -540,6 +540,7 @@
/**********************************************************************
* CsrpRegisterSubsystem/3
*/
+BOOLEAN g_ModernSm;
static NTSTATUS
CsrpRegisterSubsystem (int argc, char ** argv, char ** envp)
{
@@ -579,6 +580,11 @@
hSbApiPort,
IMAGE_SUBSYSTEM_WINDOWS_CUI,
& hSmApiPort);
+ if (!NT_SUCCESS(Status))
+ {
+ Status = SmConnectToSm(&Name, hSbApiPort, IMAGE_SUBSYSTEM_WINDOWS_GUI,
&hSmApiPort);
+ g_ModernSm = TRUE;
+ }
if(!NT_SUCCESS(Status))
{
DPRINT("CSR: %s unable to connect to the SM (Status=0x%08lx)\n",
@@ -698,6 +704,7 @@
DPRINT("CSR: %s called\n", __FUNCTION__);
+ if (g_ModernSm) return STATUS_SUCCESS;
/* initialize the process parameters */
RtlInitUnicodeString (& ImagePath,
L"\\SystemRoot\\system32\\winlogon.exe");
@@ -749,8 +756,6 @@
PCHAR ErrorMessage;
} InitRoutine [] = {
{TRUE, CsrpCreateBNODirectory, "create base named objects
directory"},
- {TRUE, CsrpCreateCallbackPort, "create the callback port
\\Windows\\SbApiPort"},
- {TRUE, CsrpRegisterSubsystem, "register with SM"},
{TRUE, CsrpCreateHeap, "create the CSR heap"},
{TRUE, CsrpCreateApiPort, "create the api port \\Windows\\ApiPort"},
{TRUE, CsrpCreateHardErrorPort, "create the hard error port"},
@@ -760,6 +765,8 @@
{TRUE, CsrpApiRegisterDef, "initialize api definitions"},
{TRUE, CsrpCCTS, "connect client to server"},
{TRUE, CsrpInitWin32Csr, "load usermode dll"},
+ {TRUE, CsrpCreateCallbackPort, "create the callback port
\\Windows\\SbApiPort"},
+ {TRUE, CsrpRegisterSubsystem, "register with SM"},
{TRUE, CsrpRunWinlogon, "run WinLogon"},
};
Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/srv.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/csrsrv/srv.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/csrsrv/srv.h [iso-8859-1] Wed Feb 8 21:56:23
2012
@@ -23,6 +23,7 @@
/* Subsystem Manager Header */
#include <sm/helper.h>
+#include <sm/smmsg.h>
/* Internal CSRSS Headers */
#include <api.h>