SM: initial work on SM_API_QUERY_INFORMATION (client side; ROS specific).
authorEmanuele Aliberti <ea@iol.it>
Sun, 10 Apr 2005 19:08:23 +0000 (19:08 +0000)
committerEmanuele Aliberti <ea@iol.it>
Sun, 10 Apr 2005 19:08:23 +0000 (19:08 +0000)
SM: fixed connection data in callback SM->subsystem_server during ss registration

svn path=/trunk/; revision=14581

13 files changed:
reactos/include/sm/api.h
reactos/include/sm/helper.h
reactos/lib/smdll/query.c
reactos/lib/smdll/smdll.def
reactos/lib/smdll/testapi.c [deleted file]
reactos/lib/smlib/compses.c
reactos/lib/smlib/connect.c
reactos/lib/smlib/execpgm.c
reactos/subsys/smss/client.c
reactos/subsys/smss/smapi.c
reactos/subsys/smss/smapicomp.c
reactos/subsys/smss/smapiexec.c
reactos/subsys/smss/smapiquery.c

index ecca2b8..9b4944b 100644 (file)
 
 #pragma pack(push,4)
 
-/* SmConnectApiPort */
+/* SmConnectApiPort (SS->SM) */
 typedef struct _SM_CONNECT_DATA
 {
-  ULONG  Subsystem;
+  USHORT SubSystemId;
+  WORD   Unused;
   WCHAR  SbName [SM_SB_NAME_MAX_LENGTH];
 
 } SM_CONNECT_DATA, *PSM_CONNECT_DATA;
 
-/* SmpConnectSbApiPort */
+/* SmpConnectSbApiPort (SM->SS) */
 typedef struct _SB_CONNECT_DATA
 {
   ULONG SmApiMax;
@@ -65,6 +66,47 @@ typedef struct _SM_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
@@ -72,12 +114,22 @@ typedef struct _SM_PORT_MESSAGE
   /*** LPC common header ***/
   LPC_MESSAGE Header;
   /*** SM common header ***/
-  DWORD       ApiIndex;
-  NTSTATUS    Status;
+  struct {
+    DWORD       ApiIndex;
+    NTSTATUS    Status;
+  } SmHeader;
   /*** SM per API arguments ***/
   union {
-    SM_PORT_MESSAGE_COMPSES      CompSes;
-    SM_PORT_MESSAGE_EXECPGM      ExecPgm;
+    union {
+      SM_PORT_MESSAGE_COMPSES      CompSes;
+      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;
@@ -86,7 +138,7 @@ typedef struct _SM_PORT_MESSAGE
 
 /*** 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_MESSAGE_SIZE     (sizeof(SM_PORT_MESSAGE))
 
index aca5158..3ca42df 100644 (file)
@@ -1,13 +1,17 @@
 #if !defined(INCLUDE_SM_HELPER_H)
 #define INCLUDE_SM_HELPER_H
 
+#if !defined(__SM_API_H)
+#include <sm/api.h>
+#endif
+
 /* $Id$ */
 
 /* smlib/connect.c */
 NTSTATUS STDCALL
 SmConnectApiPort (IN      PUNICODE_STRING  pSbApiPortName  OPTIONAL,
                  IN      HANDLE           hSbApiPort      OPTIONAL,
-                 IN      DWORD            dwSubsystem     OPTIONAL, /* pe.h */
+                 IN      WORD             wSubsystem      OPTIONAL, /* pe.h */
                  IN OUT  PHANDLE          phSmApiPort);
 /* smlib/compses.c */
 NTSTATUS STDCALL
@@ -20,14 +24,11 @@ SmExecuteProgram (IN     HANDLE           hSmApiPort,
                  IN     PUNICODE_STRING  Pgm
                  );
 /* smdll/query.c */
-typedef enum {
-       SM_BASE_INFORMATION
-} SM_INFORMATION_CLASS, *PSM_INFORMATION_CLASS;
-
 NTSTATUS STDCALL
-SmQuery (IN      HANDLE                SmApiPort,
-        IN      SM_INFORMATION_CLASS  SmInformationClass,
-        IN OUT  PVOID                 Data,
-        IN OUT  PULONG                DataLength);
+SmQueryInformation (IN      HANDLE                SmApiPort,
+                   IN      SM_INFORMATION_CLASS  SmInformationClass,
+                   IN OUT  PVOID                 Data,
+                   IN      ULONG                 DataLength,
+                   IN OUT  PULONG                ReturnedDataLength OPTIONAL);
 
 #endif /* ndef INCLUDE_SM_HELPER_H */
index 0e8fe38..078cf4b 100644 (file)
-/* $Id: compses.c 13731 2005-02-23 23:37:06Z ea $\r
+/* $Id$\r
  *\r
  * COPYRIGHT:       See COPYING in the top level directory\r
  * PROJECT:         ReactOS system libraries\r
  * FILE:            lib/smdll/query.c\r
- * PURPOSE:         Call SM API SM_API_QUERY (not in NT)\r
+ * PURPOSE:         Call SM API SM_API_QUERY_INFORMATION (not in NT)\r
  */\r
 #define NTOS_MODE_USER\r
 #include <ntos.h>\r
-#include <sm/api.h>\r
 #include <sm/helper.h>\r
 \r
 #define NDEBUG\r
 #include <debug.h>\r
 \r
+\r
 /**********************************************************************\r
  * NAME                                                        EXPORTED\r
- *     SmQuery/4\r
+ *     SmQueryInformation/5\r
  *\r
  * DESCRIPTION\r
+ *     Ask the SM to collect some data from its internal data\r
+ *     structures and send it back.\r
  *\r
  * ARGUMENTS\r
- *\r
+ *     hSmApiPort: handle returned by SmConnectApiPort;\r
+ *     SmInformationClass: an SM information class ID:\r
+ *             SM_BASIC_INFORMATION: the number of registered subsystems\r
+ *     Data: pointer to storage for the information to request;\r
+ *     DataLength: length in bytes of the Data buffer; it must be\r
+ *             set and must match the SmInformationClass info size;\r
+ *     ReturnedDataLength: optional pointer to storage to receive\r
+ *             the size of the returnede data.\r
+ *     \r
  * RETURN VALUE\r
+ *     STATUS_SUCCESS: OK you get what you asked for;\r
+ *     STATUS_INFO_LENGTH_MISMATCH: you set DataLength to 0 or to a\r
+ *             value that does not match whet the SmInformationClass\r
+ *             requires;\r
+ *     STATUS_INVALID_PARAMETER_2: bad information class;\r
+ *     A port error.\r
+ *     \r
  */\r
 NTSTATUS STDCALL\r
-SmQuery (IN      HANDLE                SmApiPort,\r
-        IN      SM_INFORMATION_CLASS  SmInformationClass,\r
-        IN OUT  PVOID                 Data,\r
-        IN OUT  PULONG                DataLength)\r
+SmQueryInformation (IN      HANDLE                hSmApiPort,\r
+                   IN      SM_INFORMATION_CLASS  SmInformationClass,\r
+                   IN OUT  PVOID                 Data,\r
+                   IN      ULONG                 DataLength,\r
+                   IN OUT  PULONG                ReturnedDataLength OPTIONAL)\r
 {\r
-       /* TODO */\r
-       if(NULL != DataLength)\r
+       NTSTATUS         Status = STATUS_SUCCESS;\r
+       SM_PORT_MESSAGE  SmReqMsg;\r
+\r
+\r
+       if(0 == DataLength)\r
+       {\r
+               return STATUS_INFO_LENGTH_MISMATCH;\r
+       }\r
+       /* Marshal data in the port message */\r
+       switch (SmInformationClass)\r
+       {\r
+               case SmBasicInformation:\r
+                       if(DataLength != sizeof (SM_BASIC_INFORMATION))\r
+                       {\r
+                               return STATUS_INFO_LENGTH_MISMATCH;\r
+                       }\r
+                       SmReqMsg.Request.QryInfo.SmInformationClass = SmBasicInformation;\r
+                       SmReqMsg.Request.QryInfo.DataLength = DataLength;\r
+                       SmReqMsg.Request.QryInfo.BasicInformation.SubSystemCount = 0;\r
+                       break;\r
+               case SmSubSystemInformation:\r
+                       if(DataLength != sizeof (SM_SUBSYSTEM_INFORMATION))\r
+                       {\r
+                               return STATUS_INFO_LENGTH_MISMATCH;\r
+                       }\r
+                       SmReqMsg.Request.QryInfo.SmInformationClass = SmSubSystemInformation;\r
+                       SmReqMsg.Request.QryInfo.DataLength = DataLength;\r
+                       SmReqMsg.Request.QryInfo.SubSystemInformation.SubSystemId =\r
+                               ((PSM_SUBSYSTEM_INFORMATION)Data)->SubSystemId;\r
+                       break;\r
+               default:\r
+                       return STATUS_INVALID_PARAMETER_2;\r
+       }\r
+       /* SM API to invoke */\r
+       SmReqMsg.SmHeader.ApiIndex = SM_API_QUERY_INFORMATION;\r
+\r
+       /* Prepare the port request message */\r
+       SmReqMsg.Header.MessageType = LPC_NEW_MESSAGE;\r
+       SmReqMsg.Header.DataSize    = SM_PORT_DATA_SIZE(SmReqMsg.Request);\r
+       SmReqMsg.Header.MessageSize = SM_PORT_MESSAGE_SIZE;\r
+       Status = NtRequestWaitReplyPort (hSmApiPort, (PLPC_MESSAGE) & SmReqMsg, (PLPC_MESSAGE) & SmReqMsg);\r
+       if (NT_SUCCESS(Status))\r
        {\r
-               *DataLength = 0;\r
+               /* Unmarshal data */\r
+               RtlCopyMemory (Data, & SmReqMsg.Reply.QryInfo.BasicInformation, SmReqMsg.Reply.QryInfo.DataLength);\r
+               /* Use caller provided storage to store data size */\r
+               if(NULL != ReturnedDataLength)\r
+               {\r
+                       *ReturnedDataLength = SmReqMsg.Reply.QryInfo.DataLength;\r
+               }\r
+               return SmReqMsg.SmHeader.Status;\r
        }\r
-       return STATUS_SUCCESS;  \r
+       DPRINT("SMLIB: %s failed (Status=0x%08lx)\n", __FUNCTION__, Status);\r
+       return Status;\r
 }\r
 /* EOF */\r
index 8be3c1f..df6394e 100644 (file)
@@ -3,4 +3,4 @@ EXPORTS
 SmCompleteSession@12
 SmConnectApiPort@16
 SmExecuteProgram@8
-SmQuery@16
+SmQueryInformation@20
diff --git a/reactos/lib/smdll/testapi.c b/reactos/lib/smdll/testapi.c
deleted file mode 100644 (file)
index cfb8b45..0000000
+++ /dev/null
@@ -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 */
-
index f4b4316..5454238 100644 (file)
@@ -7,7 +7,6 @@
  */\r
 #define NTOS_MODE_USER\r
 #include <ntos.h>\r
-#include <sm/api.h>\r
 #include <sm/helper.h>\r
 \r
 #define NDEBUG\r
@@ -42,20 +41,20 @@ SmCompleteSession (IN HANDLE hSmApiPort,
   DPRINT("SMLIB: %s called\n", __FUNCTION__);\r
 \r
   /* Marshal Ses in the LPC message */\r
-  SmReqMsg.CompSes.hApiPort   = hApiPort;\r
-  SmReqMsg.CompSes.hSbApiPort = hSbApiPort;\r
+  SmReqMsg.Request.CompSes.hApiPort   = hApiPort;\r
+  SmReqMsg.Request.CompSes.hSbApiPort = hSbApiPort;\r
 \r
   /* SM API to invoke */\r
-  SmReqMsg.ApiIndex = SM_API_COMPLETE_SESSION;\r
+  SmReqMsg.SmHeader.ApiIndex = SM_API_COMPLETE_SESSION;\r
 \r
   /* Port message */\r
   SmReqMsg.Header.MessageType = LPC_NEW_MESSAGE;\r
-  SmReqMsg.Header.DataSize    = SM_PORT_DATA_SIZE(SmReqMsg.CompSes);\r
+  SmReqMsg.Header.DataSize    = SM_PORT_DATA_SIZE(SmReqMsg.Request);\r
   SmReqMsg.Header.MessageSize = SM_PORT_MESSAGE_SIZE;\r
   Status = NtRequestWaitReplyPort (hSmApiPort, (PLPC_MESSAGE) & SmReqMsg, (PLPC_MESSAGE) & SmReqMsg);\r
   if (NT_SUCCESS(Status))\r
   {\r
-    return SmReqMsg.Status;\r
+    return SmReqMsg.SmHeader.Status;\r
   }\r
   DPRINT("SMLIB: %s failed (Status=0x%08lx)\n", __FUNCTION__, Status);\r
   return Status;\r
index ce6f135..dfd5925 100644 (file)
@@ -7,7 +7,6 @@
  */\r
 #define NTOS_MODE_USER\r
 #include <ntos.h>\r
-#include <sm/api.h>\r
 #include <sm/helper.h>\r
 #include <pe.h>\r
 \r
  * ARGUMENTS\r
  *     pSbApiPortName: name of the Sb port the calling subsystem\r
  *             server already created in the system name space;\r
- *     hSbApiPort: LPC port handle (checked, but not used);\r
- *     dwSubsystem: a valid IMAGE_SUBSYSTEM_xxx value;\r
+ *     hSbApiPort: LPC port handle (checked, but not used: the\r
+ *             subsystem is required to have already created\r
+ *             the callback port before it connects to the SM);\r
+ *     wSubsystem: a valid IMAGE_SUBSYSTEM_xxx value;\r
  *     phSmApiPort: a pointer to a HANDLE, which will be\r
  *             filled with a valid client-side LPC comm port.\r
+ *\r
+ *     There should be only two ways to call this API:\r
+ *     a) subsystems willing to register with SM will use it\r
+ *        with full parameters (the function checks them);\r
+ *     b) regular SM clients, will set to 0 the 1st, the 2nd,\r
+ *        and the 3rd parameter.\r
  *     \r
  * RETURN VALUE\r
  *     If all three optional values are omitted, an LPC status.\r
  *     STATUS_INVALID_PARAMETER_MIX if PortName is defined and\r
- *     both hSbApiPort and dwSubsystem are 0.\r
+ *     both hSbApiPort and wSubsystem are 0.\r
  */\r
 NTSTATUS STDCALL\r
 SmConnectApiPort (IN      PUNICODE_STRING  pSbApiPortName  OPTIONAL,\r
                  IN      HANDLE           hSbApiPort      OPTIONAL,\r
-                 IN      DWORD            dwSubsystem     OPTIONAL,\r
+                 IN      WORD             wSubSystemId    OPTIONAL,\r
                  IN OUT  PHANDLE          phSmApiPort)\r
 {\r
   UNICODE_STRING              SmApiPortName;\r
   SECURITY_QUALITY_OF_SERVICE SecurityQos;\r
   NTSTATUS                    Status = STATUS_SUCCESS;\r
-  SM_CONNECT_DATA             ConnectData = {0,{0}};\r
+  SM_CONNECT_DATA             ConnectData = {0,0,{0}};\r
   ULONG                       ConnectDataLength = 0;\r
 \r
   DPRINT("SMLIB: %s called\n", __FUNCTION__);\r
@@ -55,12 +62,13 @@ SmConnectApiPort (IN      PUNICODE_STRING  pSbApiPortName  OPTIONAL,
     {\r
          return STATUS_INVALID_PARAMETER_1;\r
     }\r
-    if (NULL == hSbApiPort || IMAGE_SUBSYSTEM_UNKNOWN == dwSubsystem)\r
+    if (NULL == hSbApiPort || IMAGE_SUBSYSTEM_UNKNOWN == wSubSystemId)\r
     {\r
       return STATUS_INVALID_PARAMETER_MIX;\r
     }\r
     RtlZeroMemory (& ConnectData, sizeof ConnectData);\r
-    ConnectData.Subsystem = dwSubsystem;\r
+    ConnectData.Unused = 0;\r
+    ConnectData.SubSystemId = wSubSystemId;\r
     if (pSbApiPortName->Length > 0)\r
     {\r
       RtlCopyMemory (& ConnectData.SbName,\r
index 75b7aaf..fd29e70 100644 (file)
@@ -7,7 +7,6 @@
  */\r
 #define NTOS_MODE_USER\r
 #include <ntos.h>\r
-#include <sm/api.h>\r
 #include <sm/helper.h>\r
 #include <string.h>\r
 \r
@@ -41,7 +40,8 @@ SmExecuteProgram (IN HANDLE          hSmApiPort,
   SM_PORT_MESSAGE  SmReqMsg;\r
 \r
 \r
-  DPRINT("SMLIB: %s called\n", __FUNCTION__);\r
+  DPRINT("SMLIB: %s(%08lx,'%S') called\n",\r
+       __FUNCTION__, hSmApiPort, Pgm->Buffer);\r
 \r
   /* Check Pgm's length */\r
   if (Pgm->Length > (sizeof (Pgm->Buffer[0]) * SM_EXEXPGM_MAX_LENGTH))\r
@@ -50,24 +50,35 @@ SmExecuteProgram (IN HANDLE          hSmApiPort,
   }\r
   /* Marshal Pgm in the LPC message */\r
   RtlZeroMemory (& SmReqMsg, sizeof SmReqMsg);\r
-  SmReqMsg.ExecPgm.NameLength = Pgm->Length;\r
-  RtlCopyMemory (SmReqMsg.ExecPgm.Name,\r
+  SmReqMsg.Request.ExecPgm.NameLength = Pgm->Length;\r
+  RtlCopyMemory (SmReqMsg.Request.ExecPgm.Name,\r
                 Pgm->Buffer,\r
                 Pgm->Length);\r
                \r
   /* SM API to invoke */\r
-  SmReqMsg.ApiIndex = SM_API_EXECUTE_PROGRAMME;\r
+  SmReqMsg.SmHeader.ApiIndex = SM_API_EXECUTE_PROGRAMME;\r
 \r
   /* LPC message */\r
   SmReqMsg.Header.MessageType = LPC_NEW_MESSAGE;\r
-  SmReqMsg.Header.DataSize    = SM_PORT_DATA_SIZE(SmReqMsg.ExecPgm);\r
+  SmReqMsg.Header.DataSize    = SM_PORT_DATA_SIZE(SmReqMsg.Request);\r
   SmReqMsg.Header.MessageSize = SM_PORT_MESSAGE_SIZE;\r
 \r
+  DPRINT("SMLIB: %s:\n"\r
+         "  MessageType = %d\n"\r
+         "  DataSize    = %d\n"\r
+         "  MessageSize = %d\n"\r
+         "  sizeof(LPC_MESSAGE)==%d\n",\r
+         __FUNCTION__,\r
+         SmReqMsg.Header.MessageType,\r
+         SmReqMsg.Header.DataSize,\r
+         SmReqMsg.Header.MessageSize,\r
+         sizeof(LPC_MESSAGE));\r
+\r
   /* Call SM and wait for a reply */\r
   Status = NtRequestWaitReplyPort (hSmApiPort, (PLPC_MESSAGE) & SmReqMsg, (PLPC_MESSAGE) & SmReqMsg);\r
   if (NT_SUCCESS(Status))\r
   {\r
-    return SmReqMsg.Status;\r
+    return SmReqMsg.SmHeader.Status;\r
   }\r
   DPRINT("SMLIB: %s failed (Status=0x%08lx)\n", __FUNCTION__, Status);\r
   return Status;\r
index 33dc6bf..d0efa95 100644 (file)
@@ -166,14 +166,14 @@ SmCreateClient(PSM_PORT_MESSAGE Request, PSM_CLIENT_DATA * ClientData)
        /*\r
         * Check if a client for the ID already exist.\r
         */\r
-       if (SmpLookupClient(ConnectData->Subsystem))\r
+       if (SmpLookupClient(ConnectData->SubSystemId))\r
        {\r
                DPRINT("SM: %s: attempt to register again subsystem %d.\n",\r
                        __FUNCTION__,\r
-                       ConnectData->Subsystem);\r
+                       ConnectData->SubSystemId);\r
                return STATUS_UNSUCCESSFUL;\r
        }\r
-       DPRINT("SM: %s: registering subsystem %d \n", __FUNCTION__, ConnectData->Subsystem);\r
+       DPRINT("SM: %s: registering subsystem ID=%d \n", __FUNCTION__, ConnectData->SubSystemId);\r
        /*\r
         * Allocate the storage for client data\r
         */\r
@@ -188,7 +188,7 @@ SmCreateClient(PSM_PORT_MESSAGE Request, PSM_CLIENT_DATA * ClientData)
        /*\r
         * Initialize the client data\r
         */\r
-       pClient->SubsystemId = ConnectData->Subsystem;\r
+       pClient->SubsystemId = ConnectData->SubSystemId;\r
        /* SM auto-initializes; other subsystems are required to call\r
         * SM_API_COMPLETE_SESSION via SMDLL. */\r
        pClient->Initialized = (IMAGE_SUBSYSTEM_NATIVE == pClient->SubsystemId);\r
index a157850..b514546 100644 (file)
@@ -21,7 +21,7 @@ static HANDLE SmApiPort = INVALID_HANDLE_VALUE;
 SMAPI(SmInvalid)
 {
        DPRINT("SM: %s called\n",__FUNCTION__);
-       Request->Status = STATUS_NOT_IMPLEMENTED;
+       Request->SmHeader.Status = STATUS_NOT_IMPLEMENTED;
        return STATUS_SUCCESS;
 }
 
@@ -67,10 +67,12 @@ SmpCallbackServer (PSM_PORT_MESSAGE Request,
        PSM_CONNECT_DATA  ConnectData = SmpGetConnectData (Request);
        UNICODE_STRING    CallbackPortName;
        ULONG             CallbackPortNameLength = SM_SB_NAME_MAX_LENGTH; /* TODO: compute length */
+       SB_CONNECT_DATA   SbConnectData;
+       ULONG             SbConnectDataLength = sizeof SbConnectData;
        
        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",
                                __FUNCTION__);
@@ -81,14 +83,16 @@ SmpCallbackServer (PSM_PORT_MESSAGE Request,
                       CallbackPortNameLength);
        RtlInitUnicodeString (& CallbackPortName,
                              ClientData->SbApiPortName);
+
+       SbConnectData.SmApiMax = (sizeof SmApi / sizeof SmApi[0]);
        Status = NtConnectPort (& ClientData->SbApiPort,
                                & CallbackPortName,
                                NULL,
                                NULL,
                                NULL,
                                NULL,
-                               NULL,
-                               NULL);
+                               & SbConnectData,
+                               & SbConnectDataLength);
        return Status;
 }
 
@@ -138,13 +142,13 @@ SmpApiConnectedThread(PVOID pConnectedPort)
                              Reply = NULL;
                              break;
                        default:
-                               if ((Request.ApiIndex) &&
-                                       (Request.ApiIndex < (sizeof SmApi / sizeof SmApi[0])))
+                               if ((Request.SmHeader.ApiIndex) &&
+                                       (Request.SmHeader.ApiIndex < (sizeof SmApi / sizeof SmApi[0])))
                                {
-                                       Status = SmApi[Request.ApiIndex](&Request);
+                                       Status = SmApi[Request.SmHeader.ApiIndex](&Request);
                                        Reply = (PLPC_MESSAGE) & Request;
                                } else {
-                                       Request.Status = STATUS_NOT_IMPLEMENTED;
+                                       Request.SmHeader.Status = STATUS_NOT_IMPLEMENTED;
                                        Reply = (PLPC_MESSAGE) & Request;
                                }
                        }
@@ -181,11 +185,11 @@ SmpHandleConnectionRequest (PSM_PORT_MESSAGE Request)
        PVOID            Context = NULL;
        
        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(IMAGE_SUBSYSTEM_UNKNOWN == ConnectData->Subsystem)
+               if(IMAGE_SUBSYSTEM_UNKNOWN == ConnectData->SubSystemId)
                {
                        /*
                         * 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
                         *  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*.
                                 * If it succeeds, there is something wrong in the
@@ -236,7 +240,7 @@ SmpHandleConnectionRequest (PSM_PORT_MESSAGE Request)
                                        } else {
                                                DPRINT("SM: %s: SmpCallbackServer failed (Status=%08lx)\n",
                                                        __FUNCTION__, Status);
-                                               Status = SmDestroyClient (ConnectData->Subsystem);
+                                               Status = SmDestroyClient (ConnectData->SubSystemId);
                                        }
                                }
                        }
index 52ef961..94abeb9 100644 (file)
@@ -36,15 +36,12 @@ SMAPI(SmCompSes)
 {\r
        NTSTATUS Status = STATUS_SUCCESS;\r
 \r
-       DPRINT("SM: %s called from [%lx|%lx]\n",\r
-               __FUNCTION__,\r
-               Request->ClientId.UniqueProcessId,\r
-               Request->ClientId.UniqueThreadId);\r
+       DPRINT("SM: %s called\n", __FUNCTION__);\r
        \r
        Status = SmCompleteClientInitialization (Request->Header.ClientId.UniqueProcess);\r
        if(!NT_SUCCESS(Status))\r
        {\r
-               Request->Status = STATUS_UNSUCCESSFUL;\r
+               Request->SmHeader.Status = STATUS_UNSUCCESSFUL;\r
        }\r
        return Status;\r
 }\r
index 7efc800..f74ac34 100644 (file)
@@ -253,7 +253,7 @@ SMAPI(SmExecPgm)
        DPRINT("SM: %s called from CID(%lx|%lx)\n",\r
                __FUNCTION__, Request->Header.ClientId.UniqueProcess,\r
                Request->Header.ClientId.UniqueThread);\r
-       ExecPgm = & Request->ExecPgm;\r
+       ExecPgm = & Request->Request.ExecPgm;\r
        /* Check if the name lenght is valid */\r
        if((ExecPgm->NameLength > 0) &&\r
           (ExecPgm->NameLength <= SM_EXEXPGM_MAX_LENGTH) &&\r
@@ -277,7 +277,7 @@ SMAPI(SmExecPgm)
                         * independent process; now it is embedded in the\r
                         * SM for performance or security.\r
                         */\r
-                       Request->Status = SmInitializeDbgSs();\r
+                       Request->SmHeader.Status = SmInitializeDbgSs();\r
                }\r
                else\r
                {\r
@@ -299,20 +299,20 @@ SMAPI(SmExecPgm)
                                wcscat (ImagePath, Data);\r
                        \r
                                /* Create native process */\r
-                               Request->Status = SmCreateUserProcess(ImagePath,\r
+                               Request->SmHeader.Status = SmCreateUserProcess(ImagePath,\r
                                                                      L"", /* FIXME */\r
                                                                      FALSE, /* wait */\r
                                                                      NULL,\r
                                                                      FALSE, /* terminate */\r
                                                                      NULL);\r
                        }else{\r
-                               Request->Status = Status;\r
+                               Request->SmHeader.Status = Status;\r
                        }\r
                }\r
        }\r
        else\r
        {\r
-               Request->Status = Status = STATUS_INVALID_PARAMETER;\r
+               Request->SmHeader.Status = Status = STATUS_INVALID_PARAMETER;\r
        }\r
        return Status;\r
 }\r
index e93e593..4172231 100644 (file)
@@ -38,7 +38,7 @@ SMAPI(SmQryInfo)
 \r
        DPRINT("SM: %s called\n", __FUNCTION__);\r
        \r
-       Request->Status = STATUS_NOT_IMPLEMENTED;\r
+       Request->SmHeader.Status = STATUS_NOT_IMPLEMENTED;\r
        return Status;\r
 }\r
 \r