--- trunk/reactos/subsys/csrss/init.c 2005-02-19 22:30:27 UTC (rev 13652)
+++ trunk/reactos/subsys/csrss/init.c 2005-02-19 22:56:59 UTC (rev 13653)
@@ -17,11 +17,12 @@
#include <ntdll/ldr.h>
#include <win32k/win32k.h>
#include <rosrtl/string.h>
+#include <sm/helper.h>
#include "api.h"
#include "csrplugin.h"
-#define NDEBUG
+//#define NDEBUG
#include <debug.h>
/* GLOBALS ******************************************************************/
@@ -218,7 +219,38 @@
{ 0, 0, 0, NULL }
};
+/**********************************************************************
+ * NAME
+ * CsrpRegisterSubsystem/0
+ *
+ * DESCRIPTION
+ * Register CSRSS in the SM to manage IMAGE_SUBSYSTEM_WINDOWS_CUI
+ * processes (environment subsystem server).
+ *
+ * RETURN VALUE
+ * STATUS_SUCCESS on success.
+ */
+static NTSTATUS FASTCALL
+CsrpRegisterSubsystem(PHANDLE hSmApiPort)
+{
+ NTSTATUS Status = STATUS_SUCCESS;
+ UNICODE_STRING SbApiPortName;
+ RtlInitUnicodeString (& SbApiPortName, L"\\Windows\\SbApiPort");
+ Status = SmConnectApiPort (& SbApiPortName,
+ (HANDLE)-1, //unused
+ IMAGE_SUBSYSTEM_WINDOWS_CUI,
+ hSmApiPort);
+ if(!NT_SUCCESS(Status))
+ {
+ DPRINT("CSR: unable to connect to the SM (Status=0x%lx)\n", Status);
+ return Status;
+ }
+ DisplayString(L"CSR: registered with SM\n");
+ return Status;
+}
+
+
/**********************************************************************
* NAME
* CsrServerInitialization
@@ -238,10 +270,21 @@
)
{
NTSTATUS Status;
+ HANDLE hSmApiPort = (HANDLE) 0;
OBJECT_ATTRIBUTES ObAttributes;
UNICODE_STRING PortName;
HANDLE ApiPortHandle;
+// HANDLE hSbApiPort = (HANDLE) 0;
+DisplayString(L"CSR: CsrServerInitialization\n");
+
+ Status = CsrpRegisterSubsystem(& hSmApiPort);
+ if (! NT_SUCCESS(Status))
+ {
+ DPRINT1("CSR: Unable to register subsystem (Status: %x)\n", Status);
+ return FALSE;
+ }
+
Status = CsrParseCommandLine (ArgumentCount, ArgumentArray);
if (! NT_SUCCESS(Status))
{
@@ -269,7 +312,7 @@
return Status;
}
- /* NEW NAMED PORT: \ApiPort */
+ /* NEW NAMED PORT: \Windows\ApiPort */
RtlRosInitUnicodeStringFromLiteral(&PortName, L"\\Windows\\ApiPort");
InitializeObjectAttributes(&ObAttributes,
&PortName,
@@ -283,7 +326,7 @@
0);
if (! NT_SUCCESS(Status))
{
- DPRINT1("CSR: Unable to create \\ApiPort (Status %x)\n", Status);
+ DPRINT1("CSR: Unable to create \\Windows\\ApiPort (Status %x)\n", Status);
return FALSE;
}
Status = RtlCreateUserThread(NtCurrentProcess(),
@@ -302,6 +345,9 @@
NtClose(ApiPortHandle);
return FALSE;
}
+
+ /* TODO: create \Windows\SbApiPort */
+
Status = CsrClientConnectToServer();
if (!NT_SUCCESS(Status))
{
@@ -315,7 +361,15 @@
return FALSE;
}
- return CallInitComplete();
+ if (CallInitComplete())
+ {
+#if 0
+ Status = SmCompleteSession (hSmApiPort,hSbApiPort,ApiPortHandle);
+#endif
+ NtClose (hSmApiPort);
+ return TRUE;
+ }
+ return FALSE;
}
/* EOF */