mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 21:42:57 +00:00
SM - some more work
svn path=/trunk/; revision=13547
This commit is contained in:
parent
f890195506
commit
f4bc26733a
5 changed files with 106 additions and 43 deletions
|
@ -27,19 +27,11 @@
|
||||||
#include <ntos.h>
|
#include <ntos.h>
|
||||||
#include "smss.h"
|
#include "smss.h"
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
/* Private ADT */
|
/* 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
|
struct _SM_CLIENT_DIRECTORY
|
||||||
{
|
{
|
||||||
|
@ -55,6 +47,7 @@ struct _SM_CLIENT_DIRECTORY
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
SmInitializeClientManagement (VOID)
|
SmInitializeClientManagement (VOID)
|
||||||
{
|
{
|
||||||
|
DPRINT("SM: %s called\n", __FUNCTION__);
|
||||||
RtlInitializeCriticalSection(& SmpClientDirectory.Lock);
|
RtlInitializeCriticalSection(& SmpClientDirectory.Lock);
|
||||||
SmpClientDirectory.Count = 0;
|
SmpClientDirectory.Count = 0;
|
||||||
SmpClientDirectory.Client = NULL;
|
SmpClientDirectory.Client = NULL;
|
||||||
|
@ -64,22 +57,24 @@ SmInitializeClientManagement (VOID)
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* SmpLookupClient/1
|
* SmpLookupClient/1
|
||||||
*/
|
*/
|
||||||
PSM_CLIENT_DATA STDCALL
|
static PSM_CLIENT_DATA STDCALL
|
||||||
SmpLookupClient (USHORT SubsystemId)
|
SmpLookupClient (USHORT SubsystemId)
|
||||||
{
|
{
|
||||||
PSM_CLIENT_DATA Client = NULL;
|
PSM_CLIENT_DATA Client = NULL;
|
||||||
|
|
||||||
|
DPRINT("SM: %s called\n", __FUNCTION__);
|
||||||
|
|
||||||
|
RtlEnterCriticalSection (& SmpClientDirectory.Lock);
|
||||||
if (SmpClientDirectory.Count > 0)
|
if (SmpClientDirectory.Count > 0)
|
||||||
{
|
{
|
||||||
RtlEnterCriticalSection (& SmpClientDirectory.Lock);
|
|
||||||
Client = SmpClientDirectory.Client;
|
Client = SmpClientDirectory.Client;
|
||||||
while (NULL != Client->Next)
|
while (NULL != Client)
|
||||||
{
|
{
|
||||||
if (SubsystemId == Client->SubsystemId) break;
|
if (SubsystemId == Client->SubsystemId) break;
|
||||||
Client = Client->Next;
|
Client = Client->Next;
|
||||||
}
|
}
|
||||||
RtlLeaveCriticalSection (& SmpClientDirectory.Lock);
|
|
||||||
}
|
}
|
||||||
|
RtlLeaveCriticalSection (& SmpClientDirectory.Lock);
|
||||||
return Client;
|
return Client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,14 +82,17 @@ SmpLookupClient (USHORT SubsystemId)
|
||||||
* SmpCreateClient/1
|
* SmpCreateClient/1
|
||||||
*/
|
*/
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
SmpCreateClient(SM_PORT_MESSAGE Request)
|
SmCreateClient(PSM_PORT_MESSAGE Request, PSM_CLIENT_DATA * ClientData)
|
||||||
{
|
{
|
||||||
PSM_CLIENT_DATA pClient = NULL;
|
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.
|
* 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);
|
DbgPrint("SMSS: %s: attempt to register again subsystem %d.\n",__FUNCTION__,0);
|
||||||
return STATUS_UNSUCCESSFUL;
|
return STATUS_UNSUCCESSFUL;
|
||||||
|
@ -105,11 +103,15 @@ SmpCreateClient(SM_PORT_MESSAGE Request)
|
||||||
pClient = RtlAllocateHeap (SmpHeap,
|
pClient = RtlAllocateHeap (SmpHeap,
|
||||||
HEAP_ZERO_MEMORY,
|
HEAP_ZERO_MEMORY,
|
||||||
sizeof (SM_CLIENT_DATA));
|
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
|
* Initialize the client data
|
||||||
*/
|
*/
|
||||||
// pClient->SubsystemId = Request->Subsystem;
|
pClient->SubsystemId = ConnectData->Subsystem;
|
||||||
pClient->Initialized = FALSE;
|
pClient->Initialized = FALSE;
|
||||||
// TODO
|
// TODO
|
||||||
/*
|
/*
|
||||||
|
@ -128,8 +130,10 @@ SmpCreateClient(SM_PORT_MESSAGE Request)
|
||||||
pCD = pCD->Next);
|
pCD = pCD->Next);
|
||||||
pCD->Next = pClient;
|
pCD->Next = pClient;
|
||||||
}
|
}
|
||||||
|
pClient->Next = NULL;
|
||||||
++ SmpClientDirectory.Count;
|
++ SmpClientDirectory.Count;
|
||||||
RtlLeaveCriticalSection (& SmpClientDirectory.Lock);
|
RtlLeaveCriticalSection (& SmpClientDirectory.Lock);
|
||||||
|
if (ClientData) *ClientData = pClient;
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,8 +141,10 @@ SmpCreateClient(SM_PORT_MESSAGE Request)
|
||||||
* SmpDestroyClient/1
|
* SmpDestroyClient/1
|
||||||
*/
|
*/
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
SmpDestroyClient (ULONG SubsystemId)
|
SmDestroyClient (ULONG SubsystemId)
|
||||||
{
|
{
|
||||||
|
DPRINT("SM: %s called\n", __FUNCTION__);
|
||||||
|
|
||||||
RtlEnterCriticalSection (& SmpClientDirectory.Lock);
|
RtlEnterCriticalSection (& SmpClientDirectory.Lock);
|
||||||
/* TODO */
|
/* TODO */
|
||||||
RtlLeaveCriticalSection (& SmpClientDirectory.Lock);
|
RtlLeaveCriticalSection (& SmpClientDirectory.Lock);
|
||||||
|
|
|
@ -98,7 +98,7 @@ struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
InitSessionManager(HANDLE Children[])
|
InitSessionManager(VOID)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
|
@ -1,19 +1,16 @@
|
||||||
/* $Id$
|
/* $Id$
|
||||||
|
*
|
||||||
|
* smapi.c - \SmApiPort LPC port message management
|
||||||
*
|
*
|
||||||
* Reactos Session Manager
|
* Reactos Session Manager
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*#include <ddk/ntddk.h>
|
|
||||||
#include <ntdll/rtl.h>*/
|
|
||||||
#define NTOS_MODE_USER
|
|
||||||
#include <ntos.h>
|
|
||||||
#include <sm/api.h>
|
|
||||||
#include <rosrtl/string.h>
|
|
||||||
#include "smss.h"
|
#include "smss.h"
|
||||||
|
#include <rosrtl/string.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
/* GLOBAL VARIABLES *********************************************************/
|
/* GLOBAL VARIABLES *********************************************************/
|
||||||
|
|
||||||
|
@ -26,20 +23,20 @@ NTSTATUS FASTCALL n (PSM_PORT_MESSAGE Request)
|
||||||
|
|
||||||
SMAPI(SmInvalid)
|
SMAPI(SmInvalid)
|
||||||
{
|
{
|
||||||
DbgPrint("SMSS: %s called\n",__FUNCTION__);
|
DPRINT("SM: %s called\n",__FUNCTION__);
|
||||||
Request->Status = STATUS_NOT_IMPLEMENTED;
|
Request->Status = STATUS_NOT_IMPLEMENTED;
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMAPI(SmCompSes)
|
SMAPI(SmCompSes)
|
||||||
{
|
{
|
||||||
DbgPrint("SMSS: %s called\n",__FUNCTION__);
|
DPRINT("SM: %s called\n",__FUNCTION__);
|
||||||
Request->Status = STATUS_NOT_IMPLEMENTED;
|
Request->Status = STATUS_NOT_IMPLEMENTED;
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
SMAPI(SmExecPgm)
|
SMAPI(SmExecPgm)
|
||||||
{
|
{
|
||||||
DbgPrint("SMSS: %s called\n",__FUNCTION__);
|
DPRINT("SM: %s called\n",__FUNCTION__);
|
||||||
Request->Status = STATUS_NOT_IMPLEMENTED;
|
Request->Status = STATUS_NOT_IMPLEMENTED;
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -67,8 +64,54 @@ SM_PORT_API SmApi [] =
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
SmpHandleConnectionRequest (HANDLE Port, PSM_PORT_MESSAGE Request)
|
SmpHandleConnectionRequest (HANDLE Port, PSM_PORT_MESSAGE Request)
|
||||||
{
|
{
|
||||||
DbgPrint("SMSS: %s called\n",__FUNCTION__);
|
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;
|
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 @@ VOID STDCALL
|
||||||
SmpApiThread(HANDLE Port)
|
SmpApiThread(HANDLE Port)
|
||||||
{
|
{
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
ULONG Unknown = 0;
|
PVOID Unknown = NULL;
|
||||||
PLPC_MESSAGE Reply = NULL;
|
PLPC_MESSAGE Reply = NULL;
|
||||||
SM_PORT_MESSAGE Request = {{0}};
|
SM_PORT_MESSAGE Request = {{0}};
|
||||||
|
|
||||||
DbgPrint("SMSS: %s running.\n",__FUNCTION__);
|
DPRINT("SM: %s running\n",__FUNCTION__);
|
||||||
|
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
DbgPrint("SMSS: %s: waiting for message\n",__FUNCTION__);
|
DPRINT("SM: %s: waiting for message\n",__FUNCTION__);
|
||||||
|
|
||||||
Status = NtReplyWaitReceivePort(Port,
|
Status = NtReplyWaitReceivePort(Port,
|
||||||
& Unknown,
|
(PULONG) & Unknown,
|
||||||
Reply,
|
Reply,
|
||||||
(PLPC_MESSAGE) & Request);
|
(PLPC_MESSAGE) & Request);
|
||||||
if (NT_SUCCESS(Status))
|
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)
|
switch (Request.Header.MessageType)
|
||||||
{
|
{
|
||||||
|
|
|
@ -36,7 +36,7 @@ NtProcessStartup(PPEB Peb)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
Status = InitSessionManager(Children);
|
Status = InitSessionManager();
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -4,15 +4,16 @@
|
||||||
#define NTOS_MODE_USER
|
#define NTOS_MODE_USER
|
||||||
#include <ntos.h>
|
#include <ntos.h>
|
||||||
#include <sm/api.h>
|
#include <sm/api.h>
|
||||||
|
#include <sm/helper.h>
|
||||||
|
|
||||||
#define CHILD_CSRSS 0
|
#define CHILD_CSRSS 0
|
||||||
#define CHILD_WINLOGON 1
|
#define CHILD_WINLOGON 1
|
||||||
|
|
||||||
/* init.c */
|
/* init.c */
|
||||||
extern HANDLE SmpHeap;
|
NTSTATUS InitSessionManager(VOID);
|
||||||
NTSTATUS InitSessionManager(HANDLE Children[]);
|
|
||||||
|
|
||||||
/* initheap.c */
|
/* initheap.c */
|
||||||
|
extern HANDLE SmpHeap;
|
||||||
NTSTATUS SmCreateHeap(VOID);
|
NTSTATUS SmCreateHeap(VOID);
|
||||||
|
|
||||||
/* initenv.c */
|
/* initenv.c */
|
||||||
|
@ -53,9 +54,20 @@ NTSTATUS SmCreateApiPort(VOID);
|
||||||
VOID STDCALL SmpApiThread(HANDLE Port);
|
VOID STDCALL SmpApiThread(HANDLE Port);
|
||||||
|
|
||||||
/* client.c */
|
/* 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 SmInitializeClientManagement(VOID);
|
||||||
NTSTATUS STDCALL SmpCreateClient(SM_PORT_MESSAGE);
|
NTSTATUS STDCALL SmCreateClient(PSM_PORT_MESSAGE,PSM_CLIENT_DATA*);
|
||||||
NTSTATUS STDCALL SmpDestroyClient(ULONG);
|
NTSTATUS STDCALL SmDestroyClient(ULONG);
|
||||||
|
|
||||||
/* debug.c */
|
/* debug.c */
|
||||||
extern HANDLE DbgSsApiPort;
|
extern HANDLE DbgSsApiPort;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue