mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 11:02:16 +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,18 +27,10 @@
|
|||
#include <ntos.h>
|
||||
#include "smss.h"
|
||||
|
||||
/* Private ADT */
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
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;
|
||||
/* Private ADT */
|
||||
|
||||
|
||||
struct _SM_CLIENT_DIRECTORY
|
||||
|
@ -55,6 +47,7 @@ struct _SM_CLIENT_DIRECTORY
|
|||
NTSTATUS
|
||||
SmInitializeClientManagement (VOID)
|
||||
{
|
||||
DPRINT("SM: %s called\n", __FUNCTION__);
|
||||
RtlInitializeCriticalSection(& SmpClientDirectory.Lock);
|
||||
SmpClientDirectory.Count = 0;
|
||||
SmpClientDirectory.Client = NULL;
|
||||
|
@ -64,22 +57,24 @@ SmInitializeClientManagement (VOID)
|
|||
/**********************************************************************
|
||||
* 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 @@ SmpLookupClient (USHORT SubsystemId)
|
|||
* 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 @@ SmpCreateClient(SM_PORT_MESSAGE Request)
|
|||
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 @@ SmpCreateClient(SM_PORT_MESSAGE Request)
|
|||
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 @@ SmpCreateClient(SM_PORT_MESSAGE Request)
|
|||
* SmpDestroyClient/1
|
||||
*/
|
||||
NTSTATUS STDCALL
|
||||
SmpDestroyClient (ULONG SubsystemId)
|
||||
SmDestroyClient (ULONG SubsystemId)
|
||||
{
|
||||
DPRINT("SM: %s called\n", __FUNCTION__);
|
||||
|
||||
RtlEnterCriticalSection (& SmpClientDirectory.Lock);
|
||||
/* TODO */
|
||||
RtlLeaveCriticalSection (& SmpClientDirectory.Lock);
|
||||
|
|
|
@ -98,7 +98,7 @@ struct {
|
|||
};
|
||||
|
||||
NTSTATUS
|
||||
InitSessionManager(HANDLE Children[])
|
||||
InitSessionManager(VOID)
|
||||
{
|
||||
int i;
|
||||
NTSTATUS Status;
|
||||
|
|
|
@ -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 <rosrtl/string.h>
|
||||
#include "smss.h"
|
||||
#include <rosrtl/string.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
/* GLOBAL VARIABLES *********************************************************/
|
||||
|
||||
|
@ -26,20 +23,20 @@ NTSTATUS FASTCALL n (PSM_PORT_MESSAGE Request)
|
|||
|
||||
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 @@ SM_PORT_API SmApi [] =
|
|||
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 @@ VOID STDCALL
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -36,7 +36,7 @@ NtProcessStartup(PPEB Peb)
|
|||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
Status = InitSessionManager(Children);
|
||||
Status = InitSessionManager();
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
int i;
|
||||
|
|
|
@ -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 @@ NTSTATUS SmCreateApiPort(VOID);
|
|||
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue