Added some init code for the embedded DBGSS.
Modified: trunk/reactos/subsys/smss/debug.c
Modified: trunk/reactos/subsys/smss/smapi.c

Modified: trunk/reactos/subsys/smss/debug.c
--- trunk/reactos/subsys/smss/debug.c	2005-02-24 21:28:49 UTC (rev 13735)
+++ trunk/reactos/subsys/smss/debug.c	2005-02-24 22:20:43 UTC (rev 13736)
@@ -26,66 +26,147 @@
 #define NTOS_MODE_USER
 #include <ntos.h>
 #include <rosrtl/string.h>
-#include <sm/api.h>
 #include "smss.h"
 
+#define NDEBUG
+#include <debug.h>
+
+
 /* GLOBALS ***********************************************************/
 
-HANDLE DbgSsApiPort = INVALID_HANDLE_VALUE;
-HANDLE DbgUiApiPort = INVALID_HANDLE_VALUE;
+HANDLE DbgSsApiPort = (HANDLE) 0;
+HANDLE DbgUiApiPort = (HANDLE) 0;
 
 /* FUNCTIONS *********************************************************/
 
-NTSTATUS
-SmInitializeDbgSs (VOID)
+static VOID STDCALL
+DbgSsApiPortThread (PVOID dummy)
 {
-  NTSTATUS Status;
-  UNICODE_STRING UnicodeString;
-  OBJECT_ATTRIBUTES ObjectAttributes;
+	NTSTATUS Status = STATUS_SUCCESS;
+	LPC_MAX_MESSAGE	Request = {{0}};
+    
+	while (TRUE)
+	{
+		Status = NtListenPort (DbgSsApiPort, & Request.Header);
+		if (!NT_SUCCESS(Status))
+		{
+			DPRINT1("SM: %s: NtListenPort() failed! (Status==x%08lx)\n", __FUNCTION__, Status);
+			break;
+		}
+		/* TODO */
+	}
+	NtTerminateThread(NtCurrentThread(),Status);
+}
 
+static VOID STDCALL
+DbgUiApiPortThread (PVOID dummy)
+{
+	NTSTATUS Status = STATUS_SUCCESS;
+	LPC_MAX_MESSAGE	Request = {{0}};
+    
+	while (TRUE)
+	{
+		Status = NtListenPort (DbgUiApiPort, & Request.Header);
+		if (!NT_SUCCESS(Status))
+		{
+			DPRINT1("SM: %s: NtListenPort() failed! (Status==x%08lx)\n", __FUNCTION__, Status);
+			break;
+		}
+		/* TODO */
+	}
+	NtTerminateThread(NtCurrentThread(),Status);
+}
 
-  /* Create the \DbgSsApiPort object (LPC) */
-  RtlRosInitUnicodeStringFromLiteral(&UnicodeString,
-		       L"\\DbgSsApiPort");
-  InitializeObjectAttributes(&ObjectAttributes,
-			     &UnicodeString,
-			     PORT_ALL_ACCESS,
-			     NULL,
-			     NULL);
+static NTSTATUS STDCALL
+SmpCreatePT (IN OUT PHANDLE hPort,
+	     IN     LPWSTR  wcPortName,
+	     IN     ULONG   ulMaxDataSize,
+	     IN     ULONG   ulMaxMessageSize,
+	     IN     ULONG   ulPoolCharge OPTIONAL,
+	     IN     VOID    (STDCALL * procServingThread)(PVOID) OPTIONAL,
+	     IN OUT PHANDLE phServingThread OPTIONAL)
+{
+	NTSTATUS          Status = STATUS_SUCCESS;
+	UNICODE_STRING    PortName = {0};
+	OBJECT_ATTRIBUTES ObjectAttributes;
+	HANDLE            Thread = (HANDLE) 0;
+	CLIENT_ID         Cid = {0, 0};
 
-  Status = NtCreatePort(&DbgSsApiPort,
-			&ObjectAttributes,
-			0,
-			0,
-			0);
+	RtlInitUnicodeString (& PortName, wcPortName);
+	InitializeObjectAttributes (& ObjectAttributes,
+				    & PortName,
+				    PORT_ALL_ACCESS,
+				    NULL,
+       				    NULL);
+	Status = NtCreatePort (hPort,
+			       & ObjectAttributes,
+       			       ulMaxDataSize,
+       			       ulMaxMessageSize,
+       			       ulPoolCharge);
+	if(STATUS_SUCCESS != Status)
+	{
+		return Status;
+	}
+	/* Create thread for DbgSsApiPort */
+	RtlCreateUserThread(NtCurrentProcess(),
+			    NULL,
+      			    FALSE,
+      			    0,
+      			    NULL,
+      			    NULL,
+      			    (PTHREAD_START_ROUTINE) procServingThread,
+      			    hPort,
+      			    & Thread,
+      			    & Cid);
+	if((HANDLE) 0 == Thread)
+	{
+		NtClose(*hPort);
+		Status = STATUS_UNSUCCESSFUL;
+	}
+	if(NULL != phServingThread)
+	{
+		*phServingThread = Thread;
+	}
+	return Status;
+}
 
-  if (!NT_SUCCESS(Status))
-    {
-      return(Status);
-    }
-  DbgPrint("SMSS: %s: \\DbgSsApiPort created\n",__FUNCTION__);
+NTSTATUS
+SmInitializeDbgSs (VOID)
+{
+	NTSTATUS  Status = STATUS_SUCCESS;
+	HANDLE    hDbgSsApiPortThread = (HANDLE) 0;
 
-  /* Create the \DbgUiApiPort object (LPC) */
-  RtlRosInitUnicodeStringFromLiteral(&UnicodeString,
-		       L"\\DbgUiApiPort");
-  InitializeObjectAttributes(&ObjectAttributes,
-			     &UnicodeString,
-			     PORT_ALL_ACCESS,
-			     NULL,
+	DPRINT("SM: %s called\n", __FUNCTION__);
+
+	/* Create the \DbgSsApiPort object (LPC) */
+	Status = SmpCreatePT(& DbgSsApiPort,
+			     SM_DBGSS_PORT_NAME,
+			     0, /* MaxDataSize */
+			     0, /* MaxMessageSize */
+			     0, /* PoolCharge */
+			     DbgSsApiPortThread,
+			     & hDbgSsApiPortThread);
+	if(!NT_SUCCESS(Status))
+	{
+		DPRINT("SM: %s: DBGSS port not created\n",__FUNCTION__);
+		return Status;
+	}
+	/* Create the \DbgUiApiPort object (LPC) */
+	Status = SmpCreatePT(& DbgUiApiPort,
+			     SM_DBGUI_PORT_NAME,
+			     0, /* MaxDataSize */
+			     0, /* MaxMessageSize */
+			     0, /* PoolCharge */
+			     DbgUiApiPortThread,
 			     NULL);
-
-  Status = NtCreatePort(&DbgUiApiPort,
-			&ObjectAttributes,
-			0,
-			0,
-			0);
-  if (!NT_SUCCESS(Status))
-    {
-      return(Status);
-    }
-  DbgPrint("SMSS: %s: \\DbgUiApiPort created\n",__FUNCTION__);
-
-  return STATUS_SUCCESS;
+	if(!NT_SUCCESS(Status))
+	{
+		DPRINT("SM: %s: DBGUI port not created\n",__FUNCTION__);
+		NtClose (hDbgSsApiPortThread);
+		NtClose (DbgSsApiPort);
+	  	return Status;
+	}
+	return STATUS_SUCCESS;
 }
 
 /* EOF */

Modified: trunk/reactos/subsys/smss/smapi.c
--- trunk/reactos/subsys/smss/smapi.c	2005-02-24 21:28:49 UTC (rev 13735)
+++ trunk/reactos/subsys/smss/smapi.c	2005-02-24 22:20:43 UTC (rev 13736)
@@ -9,7 +9,7 @@
 #include "smss.h"
 #include <rosrtl/string.h>
 
-//#define NDEBUG
+#define NDEBUG
 #include <debug.h>
 
 /* GLOBAL VARIABLES *********************************************************/