SM - some more work
Modified: trunk/reactos/subsys/smss/client.c
Modified: trunk/reactos/subsys/smss/init.c
Modified: trunk/reactos/subsys/smss/smapi.c
Modified: trunk/reactos/subsys/smss/smss.c
Modified: trunk/reactos/subsys/smss/smss.h
_____
Modified: trunk/reactos/subsys/smss/client.c
--- trunk/reactos/subsys/smss/client.c 2005-02-13 22:54:35 UTC (rev
13546)
+++ trunk/reactos/subsys/smss/client.c 2005-02-13 22:55:28 UTC (rev
13547)
@@ -27,20 +27,12 @@
#include <ntos.h>
#include "smss.h"
+#define NDEBUG
+#include <debug.h>
+
/* Private ADT */
-typedef struct _SM_CLIENT_DATA
-{
- USHORT SubsystemId;
- BOOL Initialized;
- HANDLE ServerProcess;
- HANDLE ApiPort;
- HANDLE SbApiPort;
- struct _SM_CLIENT_DATA * Next;
-
-} SM_CLIENT_DATA, *PSM_CLIENT_DATA;
-
struct _SM_CLIENT_DIRECTORY
{
RTL_CRITICAL_SECTION Lock;
@@ -55,6 +47,7 @@
NTSTATUS
SmInitializeClientManagement (VOID)
{
+ DPRINT("SM: %s called\n", __FUNCTION__);
RtlInitializeCriticalSection(& SmpClientDirectory.Lock);
SmpClientDirectory.Count = 0;
SmpClientDirectory.Client = NULL;
@@ -64,22 +57,24 @@
/**********************************************************************
* SmpLookupClient/1
*/
-PSM_CLIENT_DATA STDCALL
+static PSM_CLIENT_DATA STDCALL
SmpLookupClient (USHORT SubsystemId)
{
PSM_CLIENT_DATA Client = NULL;
+ DPRINT("SM: %s called\n", __FUNCTION__);
+
+ RtlEnterCriticalSection (& SmpClientDirectory.Lock);
if (SmpClientDirectory.Count > 0)
{
- RtlEnterCriticalSection (& SmpClientDirectory.Lock);
Client = SmpClientDirectory.Client;
- while (NULL != Client->Next)
+ while (NULL != Client)
{
if (SubsystemId == Client->SubsystemId) break;
Client = Client->Next;
}
- RtlLeaveCriticalSection (& SmpClientDirectory.Lock);
}
+ RtlLeaveCriticalSection (& SmpClientDirectory.Lock);
return Client;
}
@@ -87,14 +82,17 @@
* SmpCreateClient/1
*/
NTSTATUS STDCALL
-SmpCreateClient(SM_PORT_MESSAGE Request)
+SmCreateClient(PSM_PORT_MESSAGE Request, PSM_CLIENT_DATA * ClientData)
{
PSM_CLIENT_DATA pClient = NULL;
+ PSM_CONNECT_DATA ConnectData = (PSM_CONNECT_DATA) ((PBYTE)
Request) + sizeof (LPC_REQUEST);
+ DPRINT("SM: %s called\n", __FUNCTION__);
+
/*
* Check if a client for the ID already exist.
*/
- if (SmpLookupClient(0)) //FIXME
+ if (SmpLookupClient(ConnectData->Subsystem))
{
DbgPrint("SMSS: %s: attempt to register again subsystem
%d.\n",__FUNCTION__,0);
return STATUS_UNSUCCESSFUL;
@@ -105,11 +103,15 @@
pClient = RtlAllocateHeap (SmpHeap,
HEAP_ZERO_MEMORY,
sizeof (SM_CLIENT_DATA));
- if (NULL == pClient) return STATUS_NO_MEMORY;
+ if (NULL == pClient)
+ {
+ DPRINT("SM: %s: out of memory!\n",__FUNCTION__);
+ return STATUS_NO_MEMORY;
+ }
/*
* Initialize the client data
*/
-// pClient->SubsystemId = Request->Subsystem;
+ pClient->SubsystemId = ConnectData->Subsystem;
pClient->Initialized = FALSE;
// TODO
/*
@@ -128,8 +130,10 @@
pCD = pCD->Next);
pCD->Next = pClient;
}
+ pClient->Next = NULL;
++ SmpClientDirectory.Count;
RtlLeaveCriticalSection (& SmpClientDirectory.Lock);
+ if (ClientData) *ClientData = pClient;
return STATUS_SUCCESS;
}
@@ -137,8 +141,10 @@
* SmpDestroyClient/1
*/
NTSTATUS STDCALL
-SmpDestroyClient (ULONG SubsystemId)
+SmDestroyClient (ULONG SubsystemId)
{
+ DPRINT("SM: %s called\n", __FUNCTION__);
+
RtlEnterCriticalSection (& SmpClientDirectory.Lock);
/* TODO */
RtlLeaveCriticalSection (& SmpClientDirectory.Lock);
_____
Modified: trunk/reactos/subsys/smss/init.c
--- trunk/reactos/subsys/smss/init.c 2005-02-13 22:54:35 UTC (rev
13546)
+++ trunk/reactos/subsys/smss/init.c 2005-02-13 22:55:28 UTC (rev
13547)
@@ -98,7 +98,7 @@
};
NTSTATUS
-InitSessionManager(HANDLE Children[])
+InitSessionManager(VOID)
{
int i;
NTSTATUS Status;
_____
Modified: trunk/reactos/subsys/smss/smapi.c
--- trunk/reactos/subsys/smss/smapi.c 2005-02-13 22:54:35 UTC (rev
13546)
+++ trunk/reactos/subsys/smss/smapi.c 2005-02-13 22:55:28 UTC (rev
13547)
@@ -1,19 +1,16 @@
/* $Id$
*
+ * smapi.c - \SmApiPort LPC port message management
+ *
* Reactos Session Manager
*
- *
*/
-/*#include <ddk/ntddk.h>
-#include <ntdll/rtl.h>*/
-#define NTOS_MODE_USER
-#include <ntos.h>
-#include <sm/api.h>
+#include "smss.h"
#include <rosrtl/string.h>
-#include "smss.h"
#define NDEBUG
+#include <debug.h>
/* GLOBAL VARIABLES
*********************************************************/
@@ -26,20 +23,20 @@
SMAPI(SmInvalid)
{
- DbgPrint("SMSS: %s called\n",__FUNCTION__);
+ DPRINT("SM: %s called\n",__FUNCTION__);
Request->Status = STATUS_NOT_IMPLEMENTED;
return STATUS_SUCCESS;
}
SMAPI(SmCompSes)
{
- DbgPrint("SMSS: %s called\n",__FUNCTION__);
+ DPRINT("SM: %s called\n",__FUNCTION__);
Request->Status = STATUS_NOT_IMPLEMENTED;
return STATUS_SUCCESS;
}
SMAPI(SmExecPgm)
{
- DbgPrint("SMSS: %s called\n",__FUNCTION__);
+ DPRINT("SM: %s called\n",__FUNCTION__);
Request->Status = STATUS_NOT_IMPLEMENTED;
return STATUS_SUCCESS;
}
@@ -67,8 +64,54 @@
NTSTATUS STDCALL
SmpHandleConnectionRequest (HANDLE Port, PSM_PORT_MESSAGE Request)
{
- DbgPrint("SMSS: %s called\n",__FUNCTION__);
- return STATUS_SUCCESS;
+ NTSTATUS Status = STATUS_SUCCESS;
+ PSM_CLIENT_DATA ClientData = NULL;
+ PVOID Context = NULL;
+
+ DPRINT("SM: %s called\n",__FUNCTION__);
+
+ Status = SmCreateClient (Request, & ClientData);
+ if(STATUS_SUCCESS == Status)
+ {
+#ifdef __USE_NT_LPC__
+ Status = NtAcceptConnectPort (& ClientData->ApiPort,
+ Context,
+ SmApiPort,
+ TRUE, //accept
+ NULL,
+ NULL);
+#else
+ Status = NtAcceptConnectPort (& ClientData->ApiPort,
+ Context,
+ (PLPC_MESSAGE) Request,
+ TRUE, //accept
+ NULL,
+ NULL);
+#endif
+ if(NT_SUCCESS(Status))
+ {
+ Status =
NtCompleteConnectPort(ClientData->ApiPort);
+ }
+ return STATUS_SUCCESS;
+ } else {
+ /* Reject the subsystem */
+#ifdef __USE_NT_LPC__
+ Status = NtAcceptConnectPort (& ClientData->ApiPort,
+ Context,
+ SmApiPort,
+ FALSE, //reject
+ NULL,
+ NULL);
+#else
+ Status = NtAcceptConnectPort (& ClientData->ApiPort,
+ Context,
+ (PLPC_MESSAGE) Request,
+ FALSE, //reject
+ NULL,
+ NULL);
+#endif
+ }
+ return Status;
}
/**********************************************************************
@@ -82,23 +125,25 @@
SmpApiThread(HANDLE Port)
{
NTSTATUS Status = STATUS_SUCCESS;
- ULONG Unknown = 0;
+ PVOID Unknown = NULL;
PLPC_MESSAGE Reply = NULL;
SM_PORT_MESSAGE Request = {{0}};
- DbgPrint("SMSS: %s running.\n",__FUNCTION__);
+ DPRINT("SM: %s running\n",__FUNCTION__);
while (TRUE)
{
- DbgPrint("SMSS: %s: waiting for
message\n",__FUNCTION__);
+ DPRINT("SM: %s: waiting for message\n",__FUNCTION__);
Status = NtReplyWaitReceivePort(Port,
- & Unknown,
+ (PULONG) & Unknown,
Reply,
(PLPC_MESSAGE) &
Request);
if (NT_SUCCESS(Status))
{
- DbgPrint("SMSS: %s: message
received\n",__FUNCTION__);
+ DPRINT("SM: %s: message received (type=%d)\n",
+ __FUNCTION__,
+ PORT_MESSAGE_TYPE(Request));
switch (Request.Header.MessageType)
{
_____
Modified: trunk/reactos/subsys/smss/smss.c
--- trunk/reactos/subsys/smss/smss.c 2005-02-13 22:54:35 UTC (rev
13546)
+++ trunk/reactos/subsys/smss/smss.c 2005-02-13 22:55:28 UTC (rev
13547)
@@ -36,7 +36,7 @@
{
NTSTATUS Status;
- Status = InitSessionManager(Children);
+ Status = InitSessionManager();
if (!NT_SUCCESS(Status))
{
int i;
_____
Modified: trunk/reactos/subsys/smss/smss.h
--- trunk/reactos/subsys/smss/smss.h 2005-02-13 22:54:35 UTC (rev
13546)
+++ trunk/reactos/subsys/smss/smss.h 2005-02-13 22:55:28 UTC (rev
13547)
@@ -4,15 +4,16 @@
#define NTOS_MODE_USER
#include <ntos.h>
#include <sm/api.h>
+#include <sm/helper.h>
#define CHILD_CSRSS 0
#define CHILD_WINLOGON 1
/* init.c */
-extern HANDLE SmpHeap;
-NTSTATUS InitSessionManager(HANDLE Children[]);
+NTSTATUS InitSessionManager(VOID);
/* initheap.c */
+extern HANDLE SmpHeap;
NTSTATUS SmCreateHeap(VOID);
/* initenv.c */
@@ -53,9 +54,20 @@
VOID STDCALL SmpApiThread(HANDLE Port);
/* client.c */
+typedef struct _SM_CLIENT_DATA
+{
+ USHORT SubsystemId;
+ BOOL Initialized;
+ HANDLE ServerProcess;
+ HANDLE ApiPort;
+ HANDLE SbApiPort;
+ WCHAR SbApiPortName [SM_SB_NAME_MAX_LENGTH];
+ struct _SM_CLIENT_DATA * Next;
+
+} SM_CLIENT_DATA, *PSM_CLIENT_DATA;
NTSTATUS SmInitializeClientManagement(VOID);
-NTSTATUS STDCALL SmpCreateClient(SM_PORT_MESSAGE);
-NTSTATUS STDCALL SmpDestroyClient(ULONG);
+NTSTATUS STDCALL SmCreateClient(PSM_PORT_MESSAGE,PSM_CLIENT_DATA*);
+NTSTATUS STDCALL SmDestroyClient(ULONG);
/* debug.c */
extern HANDLE DbgSsApiPort;