SM: initial work on SM_API_QUERY_INFORMATION (client side; ROS specific).

SM: fixed connection data in callback SM->subsystem_server during ss registration

svn path=/trunk/; revision=14581
This commit is contained in:
Emanuele Aliberti 2005-04-10 19:08:23 +00:00
parent c1a2f01875
commit 810d009783
13 changed files with 218 additions and 100 deletions

View file

@ -12,15 +12,16 @@
#pragma pack(push,4) #pragma pack(push,4)
/* SmConnectApiPort */ /* SmConnectApiPort (SS->SM) */
typedef struct _SM_CONNECT_DATA typedef struct _SM_CONNECT_DATA
{ {
ULONG Subsystem; USHORT SubSystemId;
WORD Unused;
WCHAR SbName [SM_SB_NAME_MAX_LENGTH]; WCHAR SbName [SM_SB_NAME_MAX_LENGTH];
} SM_CONNECT_DATA, *PSM_CONNECT_DATA; } SM_CONNECT_DATA, *PSM_CONNECT_DATA;
/* SmpConnectSbApiPort */ /* SmpConnectSbApiPort (SM->SS) */
typedef struct _SB_CONNECT_DATA typedef struct _SB_CONNECT_DATA
{ {
ULONG SmApiMax; ULONG SmApiMax;
@ -65,6 +66,47 @@ typedef struct _SM_PORT_MESSAGE_EXECPGM
} SM_PORT_MESSAGE_EXECPGM, *PSM_PORT_MESSAGE_EXECPGM; } SM_PORT_MESSAGE_EXECPGM, *PSM_PORT_MESSAGE_EXECPGM;
/*** 5 ****************************************************************/
#define SM_API_QUERY_INFORMATION 5 /* ask SM to send back some data */
/* Note: this is not in NT */
#define SM_QRYINFO_MAX_SS_COUNT 8
#define SM_QRYINFO_MAX_ROOT_NODE 30
typedef enum {
SmBasicInformation = 0,
SmSubSystemInformation = 1,
} SM_INFORMATION_CLASS;
typedef struct _SM_BASIC_INFORMATION
{
USHORT SubSystemCount;
WORD Unused;
struct {
WORD Id;
WORD Flags;
DWORD ProcessId;
} SubSystem [SM_QRYINFO_MAX_SS_COUNT];
} SM_BASIC_INFORMATION, *PSM_BASIC_INFORMATION;
typedef struct _SM_SUBSYSTEM_INFORMATION
{
WORD SubSystemId;
WORD Flags;
DWORD ProcessId;
WCHAR NameSpaceRootNode [SM_QRYINFO_MAX_ROOT_NODE];
} SM_SUBSYSTEM_INFORMATION, *PSM_SUBSYSTEM_INFORMATION;
typedef struct _SM_PORT_MESSAGE_QRYINFO
{
SM_INFORMATION_CLASS SmInformationClass;
ULONG DataLength;
union {
SM_BASIC_INFORMATION BasicInformation;
SM_SUBSYSTEM_INFORMATION SubSystemInformation;
};
} SM_PORT_MESSAGE_QRYINFO, * PSM_PORT_MESSAGE_QRYINFO;
/*** | ****************************************************************/ /*** | ****************************************************************/
typedef struct _SM_PORT_MESSAGE typedef struct _SM_PORT_MESSAGE
@ -72,12 +114,22 @@ typedef struct _SM_PORT_MESSAGE
/*** LPC common header ***/ /*** LPC common header ***/
LPC_MESSAGE Header; LPC_MESSAGE Header;
/*** SM common header ***/ /*** SM common header ***/
struct {
DWORD ApiIndex; DWORD ApiIndex;
NTSTATUS Status; NTSTATUS Status;
} SmHeader;
/*** SM per API arguments ***/ /*** SM per API arguments ***/
union {
union { union {
SM_PORT_MESSAGE_COMPSES CompSes; SM_PORT_MESSAGE_COMPSES CompSes;
SM_PORT_MESSAGE_EXECPGM ExecPgm; SM_PORT_MESSAGE_EXECPGM ExecPgm;
SM_PORT_MESSAGE_QRYINFO QryInfo;
} Request;
union {
SM_PORT_MESSAGE_COMPSES CompSes;
SM_PORT_MESSAGE_EXECPGM ExecPgm;
SM_PORT_MESSAGE_QRYINFO QryInfo;
} Reply;
}; };
} SM_PORT_MESSAGE, * PSM_PORT_MESSAGE; } SM_PORT_MESSAGE, * PSM_PORT_MESSAGE;
@ -86,7 +138,7 @@ typedef struct _SM_PORT_MESSAGE
/*** MACRO ***********************************************************/ /*** MACRO ***********************************************************/
#define SM_CONNECT_DATA_SIZE(m) ((m).Header.DataSize-sizeof(ULONG)) #define SM_CONNECT_DATA_SIZE(m) ((m).Header.DataSize-sizeof(USHORT)-sizeof(WORD))
#define SM_PORT_DATA_SIZE(c) (sizeof(DWORD)+sizeof(NTSTATUS)+sizeof(c)) #define SM_PORT_DATA_SIZE(c) (sizeof(DWORD)+sizeof(NTSTATUS)+sizeof(c))
#define SM_PORT_MESSAGE_SIZE (sizeof(SM_PORT_MESSAGE)) #define SM_PORT_MESSAGE_SIZE (sizeof(SM_PORT_MESSAGE))

View file

@ -1,13 +1,17 @@
#if !defined(INCLUDE_SM_HELPER_H) #if !defined(INCLUDE_SM_HELPER_H)
#define INCLUDE_SM_HELPER_H #define INCLUDE_SM_HELPER_H
#if !defined(__SM_API_H)
#include <sm/api.h>
#endif
/* $Id$ */ /* $Id$ */
/* smlib/connect.c */ /* smlib/connect.c */
NTSTATUS STDCALL NTSTATUS STDCALL
SmConnectApiPort (IN PUNICODE_STRING pSbApiPortName OPTIONAL, SmConnectApiPort (IN PUNICODE_STRING pSbApiPortName OPTIONAL,
IN HANDLE hSbApiPort OPTIONAL, IN HANDLE hSbApiPort OPTIONAL,
IN DWORD dwSubsystem OPTIONAL, /* pe.h */ IN WORD wSubsystem OPTIONAL, /* pe.h */
IN OUT PHANDLE phSmApiPort); IN OUT PHANDLE phSmApiPort);
/* smlib/compses.c */ /* smlib/compses.c */
NTSTATUS STDCALL NTSTATUS STDCALL
@ -20,14 +24,11 @@ SmExecuteProgram (IN HANDLE hSmApiPort,
IN PUNICODE_STRING Pgm IN PUNICODE_STRING Pgm
); );
/* smdll/query.c */ /* smdll/query.c */
typedef enum {
SM_BASE_INFORMATION
} SM_INFORMATION_CLASS, *PSM_INFORMATION_CLASS;
NTSTATUS STDCALL NTSTATUS STDCALL
SmQuery (IN HANDLE SmApiPort, SmQueryInformation (IN HANDLE SmApiPort,
IN SM_INFORMATION_CLASS SmInformationClass, IN SM_INFORMATION_CLASS SmInformationClass,
IN OUT PVOID Data, IN OUT PVOID Data,
IN OUT PULONG DataLength); IN ULONG DataLength,
IN OUT PULONG ReturnedDataLength OPTIONAL);
#endif /* ndef INCLUDE_SM_HELPER_H */ #endif /* ndef INCLUDE_SM_HELPER_H */

View file

@ -1,39 +1,105 @@
/* $Id: compses.c 13731 2005-02-23 23:37:06Z ea $ /* $Id$
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
* FILE: lib/smdll/query.c * FILE: lib/smdll/query.c
* PURPOSE: Call SM API SM_API_QUERY (not in NT) * PURPOSE: Call SM API SM_API_QUERY_INFORMATION (not in NT)
*/ */
#define NTOS_MODE_USER #define NTOS_MODE_USER
#include <ntos.h> #include <ntos.h>
#include <sm/api.h>
#include <sm/helper.h> #include <sm/helper.h>
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
/********************************************************************** /**********************************************************************
* NAME EXPORTED * NAME EXPORTED
* SmQuery/4 * SmQueryInformation/5
* *
* DESCRIPTION * DESCRIPTION
* Ask the SM to collect some data from its internal data
* structures and send it back.
* *
* ARGUMENTS * ARGUMENTS
* hSmApiPort: handle returned by SmConnectApiPort;
* SmInformationClass: an SM information class ID:
* SM_BASIC_INFORMATION: the number of registered subsystems
* Data: pointer to storage for the information to request;
* DataLength: length in bytes of the Data buffer; it must be
* set and must match the SmInformationClass info size;
* ReturnedDataLength: optional pointer to storage to receive
* the size of the returnede data.
* *
* RETURN VALUE * RETURN VALUE
* STATUS_SUCCESS: OK you get what you asked for;
* STATUS_INFO_LENGTH_MISMATCH: you set DataLength to 0 or to a
* value that does not match whet the SmInformationClass
* requires;
* STATUS_INVALID_PARAMETER_2: bad information class;
* A port error.
*
*/ */
NTSTATUS STDCALL NTSTATUS STDCALL
SmQuery (IN HANDLE SmApiPort, SmQueryInformation (IN HANDLE hSmApiPort,
IN SM_INFORMATION_CLASS SmInformationClass, IN SM_INFORMATION_CLASS SmInformationClass,
IN OUT PVOID Data, IN OUT PVOID Data,
IN OUT PULONG DataLength) IN ULONG DataLength,
IN OUT PULONG ReturnedDataLength OPTIONAL)
{ {
/* TODO */ NTSTATUS Status = STATUS_SUCCESS;
if(NULL != DataLength) SM_PORT_MESSAGE SmReqMsg;
if(0 == DataLength)
{ {
*DataLength = 0; return STATUS_INFO_LENGTH_MISMATCH;
} }
return STATUS_SUCCESS; /* Marshal data in the port message */
switch (SmInformationClass)
{
case SmBasicInformation:
if(DataLength != sizeof (SM_BASIC_INFORMATION))
{
return STATUS_INFO_LENGTH_MISMATCH;
}
SmReqMsg.Request.QryInfo.SmInformationClass = SmBasicInformation;
SmReqMsg.Request.QryInfo.DataLength = DataLength;
SmReqMsg.Request.QryInfo.BasicInformation.SubSystemCount = 0;
break;
case SmSubSystemInformation:
if(DataLength != sizeof (SM_SUBSYSTEM_INFORMATION))
{
return STATUS_INFO_LENGTH_MISMATCH;
}
SmReqMsg.Request.QryInfo.SmInformationClass = SmSubSystemInformation;
SmReqMsg.Request.QryInfo.DataLength = DataLength;
SmReqMsg.Request.QryInfo.SubSystemInformation.SubSystemId =
((PSM_SUBSYSTEM_INFORMATION)Data)->SubSystemId;
break;
default:
return STATUS_INVALID_PARAMETER_2;
}
/* SM API to invoke */
SmReqMsg.SmHeader.ApiIndex = SM_API_QUERY_INFORMATION;
/* Prepare the port request message */
SmReqMsg.Header.MessageType = LPC_NEW_MESSAGE;
SmReqMsg.Header.DataSize = SM_PORT_DATA_SIZE(SmReqMsg.Request);
SmReqMsg.Header.MessageSize = SM_PORT_MESSAGE_SIZE;
Status = NtRequestWaitReplyPort (hSmApiPort, (PLPC_MESSAGE) & SmReqMsg, (PLPC_MESSAGE) & SmReqMsg);
if (NT_SUCCESS(Status))
{
/* Unmarshal data */
RtlCopyMemory (Data, & SmReqMsg.Reply.QryInfo.BasicInformation, SmReqMsg.Reply.QryInfo.DataLength);
/* Use caller provided storage to store data size */
if(NULL != ReturnedDataLength)
{
*ReturnedDataLength = SmReqMsg.Reply.QryInfo.DataLength;
}
return SmReqMsg.SmHeader.Status;
}
DPRINT("SMLIB: %s failed (Status=0x%08lx)\n", __FUNCTION__, Status);
return Status;
} }
/* EOF */ /* EOF */

View file

@ -3,4 +3,4 @@ EXPORTS
SmCompleteSession@12 SmCompleteSession@12
SmConnectApiPort@16 SmConnectApiPort@16
SmExecuteProgram@8 SmExecuteProgram@8
SmQuery@16 SmQueryInformation@20

View file

@ -1,20 +0,0 @@
/* $Id$ */
#define NTOS_MODE_USER
#include <ntos.h>
#include <sm/api.h>
VOID STDCALL SmPrintPortMessage (PSM_PORT_MESSAGE SmMessage)
{
DbgPrint ("SM_PORT_MESSAGE %08lx:\n", (ULONG) SmMessage);
DbgPrint (" Header:\n");
DbgPrint (" MessageType = %u\n", SmMessage->Header.MessageType);
DbgPrint (" DataSize = %d\n", SmMessage->Header.DataSize);
DbgPrint (" MessageSize = %d\n", SmMessage->Header.MessageSize);
DbgPrint (" ApiIndex = %ld\n", SmMessage->ApiIndex);
DbgPrint (" Status = %08lx\n", SmMessage->Status);
DbgPrint (" ExecPgm:\n");
DbgPrint (" NameLength = %ld\n", SmMessage->ExecPgm.NameLength);
DbgPrint (" Name = %ls\n", (LPWSTR) & SmMessage->ExecPgm.Name);
}
/* EOF */

View file

@ -7,7 +7,6 @@
*/ */
#define NTOS_MODE_USER #define NTOS_MODE_USER
#include <ntos.h> #include <ntos.h>
#include <sm/api.h>
#include <sm/helper.h> #include <sm/helper.h>
#define NDEBUG #define NDEBUG
@ -42,20 +41,20 @@ SmCompleteSession (IN HANDLE hSmApiPort,
DPRINT("SMLIB: %s called\n", __FUNCTION__); DPRINT("SMLIB: %s called\n", __FUNCTION__);
/* Marshal Ses in the LPC message */ /* Marshal Ses in the LPC message */
SmReqMsg.CompSes.hApiPort = hApiPort; SmReqMsg.Request.CompSes.hApiPort = hApiPort;
SmReqMsg.CompSes.hSbApiPort = hSbApiPort; SmReqMsg.Request.CompSes.hSbApiPort = hSbApiPort;
/* SM API to invoke */ /* SM API to invoke */
SmReqMsg.ApiIndex = SM_API_COMPLETE_SESSION; SmReqMsg.SmHeader.ApiIndex = SM_API_COMPLETE_SESSION;
/* Port message */ /* Port message */
SmReqMsg.Header.MessageType = LPC_NEW_MESSAGE; SmReqMsg.Header.MessageType = LPC_NEW_MESSAGE;
SmReqMsg.Header.DataSize = SM_PORT_DATA_SIZE(SmReqMsg.CompSes); SmReqMsg.Header.DataSize = SM_PORT_DATA_SIZE(SmReqMsg.Request);
SmReqMsg.Header.MessageSize = SM_PORT_MESSAGE_SIZE; SmReqMsg.Header.MessageSize = SM_PORT_MESSAGE_SIZE;
Status = NtRequestWaitReplyPort (hSmApiPort, (PLPC_MESSAGE) & SmReqMsg, (PLPC_MESSAGE) & SmReqMsg); Status = NtRequestWaitReplyPort (hSmApiPort, (PLPC_MESSAGE) & SmReqMsg, (PLPC_MESSAGE) & SmReqMsg);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
return SmReqMsg.Status; return SmReqMsg.SmHeader.Status;
} }
DPRINT("SMLIB: %s failed (Status=0x%08lx)\n", __FUNCTION__, Status); DPRINT("SMLIB: %s failed (Status=0x%08lx)\n", __FUNCTION__, Status);
return Status; return Status;

View file

@ -7,7 +7,6 @@
*/ */
#define NTOS_MODE_USER #define NTOS_MODE_USER
#include <ntos.h> #include <ntos.h>
#include <sm/api.h>
#include <sm/helper.h> #include <sm/helper.h>
#include <pe.h> #include <pe.h>
@ -25,26 +24,34 @@
* ARGUMENTS * ARGUMENTS
* pSbApiPortName: name of the Sb port the calling subsystem * pSbApiPortName: name of the Sb port the calling subsystem
* server already created in the system name space; * server already created in the system name space;
* hSbApiPort: LPC port handle (checked, but not used); * hSbApiPort: LPC port handle (checked, but not used: the
* dwSubsystem: a valid IMAGE_SUBSYSTEM_xxx value; * subsystem is required to have already created
* the callback port before it connects to the SM);
* wSubsystem: a valid IMAGE_SUBSYSTEM_xxx value;
* phSmApiPort: a pointer to a HANDLE, which will be * phSmApiPort: a pointer to a HANDLE, which will be
* filled with a valid client-side LPC comm port. * filled with a valid client-side LPC comm port.
* *
* There should be only two ways to call this API:
* a) subsystems willing to register with SM will use it
* with full parameters (the function checks them);
* b) regular SM clients, will set to 0 the 1st, the 2nd,
* and the 3rd parameter.
*
* RETURN VALUE * RETURN VALUE
* If all three optional values are omitted, an LPC status. * If all three optional values are omitted, an LPC status.
* STATUS_INVALID_PARAMETER_MIX if PortName is defined and * STATUS_INVALID_PARAMETER_MIX if PortName is defined and
* both hSbApiPort and dwSubsystem are 0. * both hSbApiPort and wSubsystem are 0.
*/ */
NTSTATUS STDCALL NTSTATUS STDCALL
SmConnectApiPort (IN PUNICODE_STRING pSbApiPortName OPTIONAL, SmConnectApiPort (IN PUNICODE_STRING pSbApiPortName OPTIONAL,
IN HANDLE hSbApiPort OPTIONAL, IN HANDLE hSbApiPort OPTIONAL,
IN DWORD dwSubsystem OPTIONAL, IN WORD wSubSystemId OPTIONAL,
IN OUT PHANDLE phSmApiPort) IN OUT PHANDLE phSmApiPort)
{ {
UNICODE_STRING SmApiPortName; UNICODE_STRING SmApiPortName;
SECURITY_QUALITY_OF_SERVICE SecurityQos; SECURITY_QUALITY_OF_SERVICE SecurityQos;
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
SM_CONNECT_DATA ConnectData = {0,{0}}; SM_CONNECT_DATA ConnectData = {0,0,{0}};
ULONG ConnectDataLength = 0; ULONG ConnectDataLength = 0;
DPRINT("SMLIB: %s called\n", __FUNCTION__); DPRINT("SMLIB: %s called\n", __FUNCTION__);
@ -55,12 +62,13 @@ SmConnectApiPort (IN PUNICODE_STRING pSbApiPortName OPTIONAL,
{ {
return STATUS_INVALID_PARAMETER_1; return STATUS_INVALID_PARAMETER_1;
} }
if (NULL == hSbApiPort || IMAGE_SUBSYSTEM_UNKNOWN == dwSubsystem) if (NULL == hSbApiPort || IMAGE_SUBSYSTEM_UNKNOWN == wSubSystemId)
{ {
return STATUS_INVALID_PARAMETER_MIX; return STATUS_INVALID_PARAMETER_MIX;
} }
RtlZeroMemory (& ConnectData, sizeof ConnectData); RtlZeroMemory (& ConnectData, sizeof ConnectData);
ConnectData.Subsystem = dwSubsystem; ConnectData.Unused = 0;
ConnectData.SubSystemId = wSubSystemId;
if (pSbApiPortName->Length > 0) if (pSbApiPortName->Length > 0)
{ {
RtlCopyMemory (& ConnectData.SbName, RtlCopyMemory (& ConnectData.SbName,

View file

@ -7,7 +7,6 @@
*/ */
#define NTOS_MODE_USER #define NTOS_MODE_USER
#include <ntos.h> #include <ntos.h>
#include <sm/api.h>
#include <sm/helper.h> #include <sm/helper.h>
#include <string.h> #include <string.h>
@ -41,7 +40,8 @@ SmExecuteProgram (IN HANDLE hSmApiPort,
SM_PORT_MESSAGE SmReqMsg; SM_PORT_MESSAGE SmReqMsg;
DPRINT("SMLIB: %s called\n", __FUNCTION__); DPRINT("SMLIB: %s(%08lx,'%S') called\n",
__FUNCTION__, hSmApiPort, Pgm->Buffer);
/* Check Pgm's length */ /* Check Pgm's length */
if (Pgm->Length > (sizeof (Pgm->Buffer[0]) * SM_EXEXPGM_MAX_LENGTH)) if (Pgm->Length > (sizeof (Pgm->Buffer[0]) * SM_EXEXPGM_MAX_LENGTH))
@ -50,24 +50,35 @@ SmExecuteProgram (IN HANDLE hSmApiPort,
} }
/* Marshal Pgm in the LPC message */ /* Marshal Pgm in the LPC message */
RtlZeroMemory (& SmReqMsg, sizeof SmReqMsg); RtlZeroMemory (& SmReqMsg, sizeof SmReqMsg);
SmReqMsg.ExecPgm.NameLength = Pgm->Length; SmReqMsg.Request.ExecPgm.NameLength = Pgm->Length;
RtlCopyMemory (SmReqMsg.ExecPgm.Name, RtlCopyMemory (SmReqMsg.Request.ExecPgm.Name,
Pgm->Buffer, Pgm->Buffer,
Pgm->Length); Pgm->Length);
/* SM API to invoke */ /* SM API to invoke */
SmReqMsg.ApiIndex = SM_API_EXECUTE_PROGRAMME; SmReqMsg.SmHeader.ApiIndex = SM_API_EXECUTE_PROGRAMME;
/* LPC message */ /* LPC message */
SmReqMsg.Header.MessageType = LPC_NEW_MESSAGE; SmReqMsg.Header.MessageType = LPC_NEW_MESSAGE;
SmReqMsg.Header.DataSize = SM_PORT_DATA_SIZE(SmReqMsg.ExecPgm); SmReqMsg.Header.DataSize = SM_PORT_DATA_SIZE(SmReqMsg.Request);
SmReqMsg.Header.MessageSize = SM_PORT_MESSAGE_SIZE; SmReqMsg.Header.MessageSize = SM_PORT_MESSAGE_SIZE;
DPRINT("SMLIB: %s:\n"
" MessageType = %d\n"
" DataSize = %d\n"
" MessageSize = %d\n"
" sizeof(LPC_MESSAGE)==%d\n",
__FUNCTION__,
SmReqMsg.Header.MessageType,
SmReqMsg.Header.DataSize,
SmReqMsg.Header.MessageSize,
sizeof(LPC_MESSAGE));
/* Call SM and wait for a reply */ /* Call SM and wait for a reply */
Status = NtRequestWaitReplyPort (hSmApiPort, (PLPC_MESSAGE) & SmReqMsg, (PLPC_MESSAGE) & SmReqMsg); Status = NtRequestWaitReplyPort (hSmApiPort, (PLPC_MESSAGE) & SmReqMsg, (PLPC_MESSAGE) & SmReqMsg);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
return SmReqMsg.Status; return SmReqMsg.SmHeader.Status;
} }
DPRINT("SMLIB: %s failed (Status=0x%08lx)\n", __FUNCTION__, Status); DPRINT("SMLIB: %s failed (Status=0x%08lx)\n", __FUNCTION__, Status);
return Status; return Status;

View file

@ -166,14 +166,14 @@ SmCreateClient(PSM_PORT_MESSAGE Request, PSM_CLIENT_DATA * ClientData)
/* /*
* Check if a client for the ID already exist. * Check if a client for the ID already exist.
*/ */
if (SmpLookupClient(ConnectData->Subsystem)) if (SmpLookupClient(ConnectData->SubSystemId))
{ {
DPRINT("SM: %s: attempt to register again subsystem %d.\n", DPRINT("SM: %s: attempt to register again subsystem %d.\n",
__FUNCTION__, __FUNCTION__,
ConnectData->Subsystem); ConnectData->SubSystemId);
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
DPRINT("SM: %s: registering subsystem %d \n", __FUNCTION__, ConnectData->Subsystem); DPRINT("SM: %s: registering subsystem ID=%d \n", __FUNCTION__, ConnectData->SubSystemId);
/* /*
* Allocate the storage for client data * Allocate the storage for client data
*/ */
@ -188,7 +188,7 @@ SmCreateClient(PSM_PORT_MESSAGE Request, PSM_CLIENT_DATA * ClientData)
/* /*
* Initialize the client data * Initialize the client data
*/ */
pClient->SubsystemId = ConnectData->Subsystem; pClient->SubsystemId = ConnectData->SubSystemId;
/* SM auto-initializes; other subsystems are required to call /* SM auto-initializes; other subsystems are required to call
* SM_API_COMPLETE_SESSION via SMDLL. */ * SM_API_COMPLETE_SESSION via SMDLL. */
pClient->Initialized = (IMAGE_SUBSYSTEM_NATIVE == pClient->SubsystemId); pClient->Initialized = (IMAGE_SUBSYSTEM_NATIVE == pClient->SubsystemId);

View file

@ -21,7 +21,7 @@ static HANDLE SmApiPort = INVALID_HANDLE_VALUE;
SMAPI(SmInvalid) SMAPI(SmInvalid)
{ {
DPRINT("SM: %s called\n",__FUNCTION__); DPRINT("SM: %s called\n",__FUNCTION__);
Request->Status = STATUS_NOT_IMPLEMENTED; Request->SmHeader.Status = STATUS_NOT_IMPLEMENTED;
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -67,10 +67,12 @@ SmpCallbackServer (PSM_PORT_MESSAGE Request,
PSM_CONNECT_DATA ConnectData = SmpGetConnectData (Request); PSM_CONNECT_DATA ConnectData = SmpGetConnectData (Request);
UNICODE_STRING CallbackPortName; UNICODE_STRING CallbackPortName;
ULONG CallbackPortNameLength = SM_SB_NAME_MAX_LENGTH; /* TODO: compute length */ ULONG CallbackPortNameLength = SM_SB_NAME_MAX_LENGTH; /* TODO: compute length */
SB_CONNECT_DATA SbConnectData;
ULONG SbConnectDataLength = sizeof SbConnectData;
DPRINT("SM: %s called\n", __FUNCTION__); DPRINT("SM: %s called\n", __FUNCTION__);
if(IMAGE_SUBSYSTEM_NATIVE == ConnectData->Subsystem) if(IMAGE_SUBSYSTEM_NATIVE == ConnectData->SubSystemId)
{ {
DPRINT("SM: %s: we do not need calling back SM!\n", DPRINT("SM: %s: we do not need calling back SM!\n",
__FUNCTION__); __FUNCTION__);
@ -81,14 +83,16 @@ SmpCallbackServer (PSM_PORT_MESSAGE Request,
CallbackPortNameLength); CallbackPortNameLength);
RtlInitUnicodeString (& CallbackPortName, RtlInitUnicodeString (& CallbackPortName,
ClientData->SbApiPortName); ClientData->SbApiPortName);
SbConnectData.SmApiMax = (sizeof SmApi / sizeof SmApi[0]);
Status = NtConnectPort (& ClientData->SbApiPort, Status = NtConnectPort (& ClientData->SbApiPort,
& CallbackPortName, & CallbackPortName,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, & SbConnectData,
NULL); & SbConnectDataLength);
return Status; return Status;
} }
@ -138,13 +142,13 @@ SmpApiConnectedThread(PVOID pConnectedPort)
Reply = NULL; Reply = NULL;
break; break;
default: default:
if ((Request.ApiIndex) && if ((Request.SmHeader.ApiIndex) &&
(Request.ApiIndex < (sizeof SmApi / sizeof SmApi[0]))) (Request.SmHeader.ApiIndex < (sizeof SmApi / sizeof SmApi[0])))
{ {
Status = SmApi[Request.ApiIndex](&Request); Status = SmApi[Request.SmHeader.ApiIndex](&Request);
Reply = (PLPC_MESSAGE) & Request; Reply = (PLPC_MESSAGE) & Request;
} else { } else {
Request.Status = STATUS_NOT_IMPLEMENTED; Request.SmHeader.Status = STATUS_NOT_IMPLEMENTED;
Reply = (PLPC_MESSAGE) & Request; Reply = (PLPC_MESSAGE) & Request;
} }
} }
@ -181,11 +185,11 @@ SmpHandleConnectionRequest (PSM_PORT_MESSAGE Request)
PVOID Context = NULL; PVOID Context = NULL;
DPRINT("SM: %s called:\n SubSystemID=%d\n SbName=\"%S\"\n", DPRINT("SM: %s called:\n SubSystemID=%d\n SbName=\"%S\"\n",
__FUNCTION__, ConnectData->Subsystem, ConnectData->SbName); __FUNCTION__, ConnectData->SubSystemId, ConnectData->SbName);
if(sizeof (SM_CONNECT_DATA) == Request->Header.DataSize) if(sizeof (SM_CONNECT_DATA) == Request->Header.DataSize)
{ {
if(IMAGE_SUBSYSTEM_UNKNOWN == ConnectData->Subsystem) if(IMAGE_SUBSYSTEM_UNKNOWN == ConnectData->SubSystemId)
{ {
/* /*
* This is not a call to register an image set, * This is not a call to register an image set,
@ -202,9 +206,9 @@ SmpHandleConnectionRequest (PSM_PORT_MESSAGE Request)
* Reject GUIs classes: only odd subsystem IDs are * Reject GUIs classes: only odd subsystem IDs are
* allowed to register here (tty mode images). * allowed to register here (tty mode images).
*/ */
if(1 == (ConnectData->Subsystem % 2)) if(1 == (ConnectData->SubSystemId % 2))
{ {
DPRINT("SM: %s: id = %d\n", __FUNCTION__, ConnectData->Subsystem); DPRINT("SM: %s: id = %d\n", __FUNCTION__, ConnectData->SubSystemId);
/* /*
* SmCreateClient/2 is called here explicitly to *fail*. * SmCreateClient/2 is called here explicitly to *fail*.
* If it succeeds, there is something wrong in the * If it succeeds, there is something wrong in the
@ -236,7 +240,7 @@ SmpHandleConnectionRequest (PSM_PORT_MESSAGE Request)
} else { } else {
DPRINT("SM: %s: SmpCallbackServer failed (Status=%08lx)\n", DPRINT("SM: %s: SmpCallbackServer failed (Status=%08lx)\n",
__FUNCTION__, Status); __FUNCTION__, Status);
Status = SmDestroyClient (ConnectData->Subsystem); Status = SmDestroyClient (ConnectData->SubSystemId);
} }
} }
} }

View file

@ -36,15 +36,12 @@ SMAPI(SmCompSes)
{ {
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
DPRINT("SM: %s called from [%lx|%lx]\n", DPRINT("SM: %s called\n", __FUNCTION__);
__FUNCTION__,
Request->ClientId.UniqueProcessId,
Request->ClientId.UniqueThreadId);
Status = SmCompleteClientInitialization (Request->Header.ClientId.UniqueProcess); Status = SmCompleteClientInitialization (Request->Header.ClientId.UniqueProcess);
if(!NT_SUCCESS(Status)) if(!NT_SUCCESS(Status))
{ {
Request->Status = STATUS_UNSUCCESSFUL; Request->SmHeader.Status = STATUS_UNSUCCESSFUL;
} }
return Status; return Status;
} }

View file

@ -253,7 +253,7 @@ SMAPI(SmExecPgm)
DPRINT("SM: %s called from CID(%lx|%lx)\n", DPRINT("SM: %s called from CID(%lx|%lx)\n",
__FUNCTION__, Request->Header.ClientId.UniqueProcess, __FUNCTION__, Request->Header.ClientId.UniqueProcess,
Request->Header.ClientId.UniqueThread); Request->Header.ClientId.UniqueThread);
ExecPgm = & Request->ExecPgm; ExecPgm = & Request->Request.ExecPgm;
/* Check if the name lenght is valid */ /* Check if the name lenght is valid */
if((ExecPgm->NameLength > 0) && if((ExecPgm->NameLength > 0) &&
(ExecPgm->NameLength <= SM_EXEXPGM_MAX_LENGTH) && (ExecPgm->NameLength <= SM_EXEXPGM_MAX_LENGTH) &&
@ -277,7 +277,7 @@ SMAPI(SmExecPgm)
* independent process; now it is embedded in the * independent process; now it is embedded in the
* SM for performance or security. * SM for performance or security.
*/ */
Request->Status = SmInitializeDbgSs(); Request->SmHeader.Status = SmInitializeDbgSs();
} }
else else
{ {
@ -299,20 +299,20 @@ SMAPI(SmExecPgm)
wcscat (ImagePath, Data); wcscat (ImagePath, Data);
/* Create native process */ /* Create native process */
Request->Status = SmCreateUserProcess(ImagePath, Request->SmHeader.Status = SmCreateUserProcess(ImagePath,
L"", /* FIXME */ L"", /* FIXME */
FALSE, /* wait */ FALSE, /* wait */
NULL, NULL,
FALSE, /* terminate */ FALSE, /* terminate */
NULL); NULL);
}else{ }else{
Request->Status = Status; Request->SmHeader.Status = Status;
} }
} }
} }
else else
{ {
Request->Status = Status = STATUS_INVALID_PARAMETER; Request->SmHeader.Status = Status = STATUS_INVALID_PARAMETER;
} }
return Status; return Status;
} }

View file

@ -38,7 +38,7 @@ SMAPI(SmQryInfo)
DPRINT("SM: %s called\n", __FUNCTION__); DPRINT("SM: %s called\n", __FUNCTION__);
Request->Status = STATUS_NOT_IMPLEMENTED; Request->SmHeader.Status = STATUS_NOT_IMPLEMENTED;
return Status; return Status;
} }