SMDLL + SMLIB (static code in SMSS.EXE)
authorEmanuele Aliberti <ea@iol.it>
Mon, 14 Mar 2005 22:38:12 +0000 (22:38 +0000)
committerEmanuele Aliberti <ea@iol.it>
Mon, 14 Mar 2005 22:38:12 +0000 (22:38 +0000)
SM now self registers for IMAGE_SUBSYSTEM_NATIVE.

svn path=/trunk/; revision=14080

reactos/Makefile
reactos/include/sm/helper.h
reactos/lib/smdll/makefile
reactos/lib/smdll/query.c [new file with mode: 0644]
reactos/lib/smdll/smdll.def
reactos/lib/smlib/compses.c [moved from reactos/lib/smdll/compses.c with 88% similarity]
reactos/lib/smlib/connect.c [moved from reactos/lib/smdll/connect.c with 90% similarity]
reactos/lib/smlib/execpgm.c [moved from reactos/lib/smdll/execpgm.c with 87% similarity]
reactos/lib/smlib/makefile [new file with mode: 0644]
reactos/subsys/smss/initss.c
reactos/subsys/smss/makefile

index 15d73f3..005116e 100644 (file)
@@ -61,8 +61,8 @@ DLLS_SHELLEXT = shellext
 DLLS = acledit aclui advapi32 advpack cabinet cards comctl32 crtdll comdlg32 d3d8thk dbghelp expat fmifs freetype \
        gdi32 gdiplus glu32 hid imagehlp imm32 iphlpapi kernel32 lzexpand mesa32 midimap mmdrv mpr msacm msafd \
        msgina msi msimg32 msvcrt20 msvideo mswsock netapi32 ntdll ole32 oleaut32 oledlg olepro32 opengl32 \
-       packet psapi riched20 richedit rpcrt4 samlib secur32 setupapi shell32 shlwapi smdll snmpapi syssetup \
-       twain user32 userenv version wininet winmm winspool ws2help ws2_32 wsock32 wshirda dnsapi \
+       packet psapi riched20 richedit rpcrt4 samlib secur32 setupapi shell32 shlwapi smlib smdll snmpapi \
+       syssetup twain user32 userenv version wininet winmm winspool ws2help ws2_32 wsock32 wshirda dnsapi \
        urlmon shdocvw dinput dinput8 dxdiagn devenum dsound lsasrv $(DLLS_KBD) $(DLLS_CPL) $(DLLS_SHELLEXT)
 
 SUBSYS = smss win32k csrss ntvdm
index 01bc9a1..aca5158 100644 (file)
@@ -3,21 +3,31 @@
 
 /* $Id$ */
 
-/* smdll/connect.c */
+/* smlib/connect.c */
 NTSTATUS STDCALL
 SmConnectApiPort (IN      PUNICODE_STRING  pSbApiPortName  OPTIONAL,
                  IN      HANDLE           hSbApiPort      OPTIONAL,
                  IN      DWORD            dwSubsystem     OPTIONAL, /* pe.h */
                  IN OUT  PHANDLE          phSmApiPort);
-/* smdll/compses.c */
+/* smlib/compses.c */
 NTSTATUS STDCALL
 SmCompleteSession (IN     HANDLE  hSmApiPort,
                   IN     HANDLE  hSbApiPort,
                   IN     HANDLE  hApiPort);
-/* smdll/execpgm.c */
+/* smlib/execpgm.c */
 NTSTATUS STDCALL
 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);
 
 #endif /* ndef INCLUDE_SM_HELPER_H */
index 3275d1b..44c3b18 100644 (file)
@@ -6,7 +6,7 @@ TARGET_TYPE = dynlink
 
 TARGET_NAME = smdll
 
-TARGET_SDKLIBS = ntdll.a
+TARGET_SDKLIBS = smlib.a ntdll.a
 
 TARGET_CFLAGS = -I./include -Wall -Werror
 
@@ -19,9 +19,7 @@ TARGET_LFLAGS = -nostartfiles -nostdlib
 
 TARGET_OBJECTS = \
        dllmain.o \
-       connect.o \
-       execpgm.o \
-       compses.o
+       query.o
        
 DEP_OBJECTS = $(TARGET_OBJECTS)
 
diff --git a/reactos/lib/smdll/query.c b/reactos/lib/smdll/query.c
new file mode 100644 (file)
index 0000000..0e8fe38
--- /dev/null
@@ -0,0 +1,39 @@
+/* $Id: compses.c 13731 2005-02-23 23:37:06Z ea $\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
+ */\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
+ * NAME                                                        EXPORTED\r
+ *     SmQuery/4\r
+ *\r
+ * DESCRIPTION\r
+ *\r
+ * ARGUMENTS\r
+ *\r
+ * RETURN VALUE\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
+{\r
+       /* TODO */\r
+       if(NULL != DataLength)\r
+       {\r
+               *DataLength = 0;\r
+       }\r
+       return STATUS_SUCCESS;  \r
+}\r
+/* EOF */\r
index 0c2e91e..8be3c1f 100644 (file)
@@ -3,3 +3,4 @@ EXPORTS
 SmCompleteSession@12
 SmConnectApiPort@16
 SmExecuteProgram@8
+SmQuery@16
similarity index 88%
rename from reactos/lib/smdll/compses.c
rename to reactos/lib/smlib/compses.c
index eaaccbc..f4b4316 100644 (file)
@@ -1,64 +1,64 @@
-/* $Id$
- *
- * COPYRIGHT:       See COPYING in the top level directory
- * PROJECT:         ReactOS system libraries
- * FILE:            lib/smlib/compses.c
- * PURPOSE:         Call SM API SM_API_COMPLETE_SESSION
- */
-#define NTOS_MODE_USER
-#include <ntos.h>
-#include <sm/api.h>
-#include <sm/helper.h>
-
-#define NDEBUG
-#include <debug.h>
-
-/**********************************************************************
- * NAME                                                        EXPORTED
- *     SmCompleteSession/3
- *
- * DESCRIPTION
- *     This function is called by an environment subsystem server to
- *     tell the SM it finished initialization phase and is ready to
- *     manage processes it registered for (SmConnectApiPort).
- *
- * ARGUMENTS
- *     hSmApiPort: port handle returned by SmConnectApiPort;
- *     hSbApiPort: call back API port of the subsystem (handle);
- *     hApiPort  : API port of the subsystem (handle).
- *
- * RETURN VALUE
- *     Success status as handed by the SM reply; otherwise a failure
- *     status code.
- */
-NTSTATUS STDCALL
-SmCompleteSession (IN HANDLE hSmApiPort,
-                  IN HANDLE hSbApiPort,
-                  IN HANDLE hApiPort)
-{
-  NTSTATUS         Status;
-  SM_PORT_MESSAGE  SmReqMsg;
-    
-  DPRINT("SMDLL: %s called\n", __FUNCTION__);
-
-  /* Marshal Ses in the LPC message */
-  SmReqMsg.CompSes.hApiPort   = hApiPort;
-  SmReqMsg.CompSes.hSbApiPort = hSbApiPort;
-
-  /* SM API to invoke */
-  SmReqMsg.ApiIndex = SM_API_COMPLETE_SESSION;
-
-  /* Port message */
-  SmReqMsg.Header.MessageType = LPC_NEW_MESSAGE;
-  SmReqMsg.Header.DataSize    = SM_PORT_DATA_SIZE(SmReqMsg.CompSes);
-  SmReqMsg.Header.MessageSize = SM_PORT_MESSAGE_SIZE;
-  Status = NtRequestWaitReplyPort (hSmApiPort, (PLPC_MESSAGE) & SmReqMsg, (PLPC_MESSAGE) & SmReqMsg);
-  if (NT_SUCCESS(Status))
-  {
-    return SmReqMsg.Status;
-  }
-  DPRINT("SMDLL: %s failed (Status=0x%08lx)\n", __FUNCTION__, Status);
-  return Status;
-}
-
-/* EOF */
+/* $Id: compses.c 13731 2005-02-23 23:37:06Z ea $\r
+ *\r
+ * COPYRIGHT:       See COPYING in the top level directory\r
+ * PROJECT:         ReactOS system libraries\r
+ * FILE:            lib/smlib/compses.c\r
+ * PURPOSE:         Call SM API SM_API_COMPLETE_SESSION\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
+ * NAME                                                        EXPORTED\r
+ *     SmCompleteSession/3\r
+ *\r
+ * DESCRIPTION\r
+ *     This function is called by an environment subsystem server to\r
+ *     tell the SM it finished initialization phase and is ready to\r
+ *     manage processes it registered for (SmConnectApiPort).\r
+ *\r
+ * ARGUMENTS\r
+ *     hSmApiPort: port handle returned by SmConnectApiPort;\r
+ *     hSbApiPort: call back API port of the subsystem (handle);\r
+ *     hApiPort  : API port of the subsystem (handle).\r
+ *\r
+ * RETURN VALUE\r
+ *     Success status as handed by the SM reply; otherwise a failure\r
+ *     status code.\r
+ */\r
+NTSTATUS STDCALL\r
+SmCompleteSession (IN HANDLE hSmApiPort,\r
+                  IN HANDLE hSbApiPort,\r
+                  IN HANDLE hApiPort)\r
+{\r
+  NTSTATUS         Status;\r
+  SM_PORT_MESSAGE  SmReqMsg;\r
+    \r
+  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
+\r
+  /* SM API to invoke */\r
+  SmReqMsg.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.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
+  }\r
+  DPRINT("SMLIB: %s failed (Status=0x%08lx)\n", __FUNCTION__, Status);\r
+  return Status;\r
+}\r
+\r
+/* EOF */\r
similarity index 90%
rename from reactos/lib/smdll/connect.c
rename to reactos/lib/smlib/connect.c
index 32a1ab6..ce6f135 100644 (file)
@@ -1,98 +1,98 @@
-/* $Id$
- *
- * COPYRIGHT:  See COPYING in the top level directory
- * PROJECT:    ReactOS system libraries
- * FILE:       reactos/lib/smdll/connect.c
- * PURPOSE:    Connect to the API LPC port exposed by the SM
- */
-#define NTOS_MODE_USER
-#include <ntos.h>
-#include <sm/api.h>
-#include <sm/helper.h>
-#include <pe.h>
-
-#define NDEBUG
-#include <debug.h>
-
-/**********************************************************************
- * NAME                                                        EXPORTED
- *     SmConnectApiPort/4
- *
- * DESCRIPTION
- *     Connect to SM API port and register a session "begin" port (Sb)
- *     or to issue API requests to SmApiPort.
- *
- * ARGUMENTS
- *     pSbApiPortName: name of the Sb port the calling subsystem
- *             server already created in the system name space;
- *     hSbApiPort: LPC port handle (checked, but not used);
- *     dwSubsystem: a valid IMAGE_SUBSYSTEM_xxx value;
- *     phSmApiPort: a pointer to a HANDLE, which will be
- *             filled with a valid client-side LPC comm port.
- *     
- * RETURN VALUE
- *     If all three optional values are omitted, an LPC status.
- *     STATUS_INVALID_PARAMETER_MIX if PortName is defined and
- *     both hSbApiPort and dwSubsystem are 0.
- */
-NTSTATUS STDCALL
-SmConnectApiPort (IN      PUNICODE_STRING  pSbApiPortName  OPTIONAL,
-                 IN      HANDLE           hSbApiPort      OPTIONAL,
-                 IN      DWORD            dwSubsystem     OPTIONAL,
-                 IN OUT  PHANDLE          phSmApiPort)
-{
-  UNICODE_STRING              SmApiPortName;
-  SECURITY_QUALITY_OF_SERVICE SecurityQos;
-  NTSTATUS                    Status = STATUS_SUCCESS;
-  SM_CONNECT_DATA             ConnectData = {0,{0}};
-  ULONG                       ConnectDataLength = 0;
-
-  DPRINT("SMDLL: %s called\n", __FUNCTION__);
-
-  if (pSbApiPortName)
-  {
-    if (pSbApiPortName->Length > (sizeof pSbApiPortName->Buffer[0] * SM_SB_NAME_MAX_LENGTH))
-    {
-         return STATUS_INVALID_PARAMETER_1;
-    }
-    if (NULL == hSbApiPort || IMAGE_SUBSYSTEM_UNKNOWN == dwSubsystem)
-    {
-      return STATUS_INVALID_PARAMETER_MIX;
-    }
-    RtlZeroMemory (& ConnectData, sizeof ConnectData);
-    ConnectData.Subsystem = dwSubsystem;
-    if (pSbApiPortName->Length > 0)
-    {
-      RtlCopyMemory (& ConnectData.SbName,
-                    pSbApiPortName->Buffer,
-                    pSbApiPortName->Length);
-    }
-  }
-  ConnectDataLength = sizeof ConnectData;
-
-  SecurityQos.Length              = sizeof (SecurityQos);
-  SecurityQos.ImpersonationLevel  = SecurityIdentification;
-  SecurityQos.ContextTrackingMode = TRUE;
-  SecurityQos.EffectiveOnly       = TRUE;
-
-  RtlInitUnicodeString (& SmApiPortName, SM_API_PORT_NAME);
-
-  Status = NtConnectPort (
-             phSmApiPort,
-             & SmApiPortName,
-             & SecurityQos,
-             NULL,
-             NULL,
-             NULL,
-             & ConnectData,
-             & ConnectDataLength
-             );
-  if (NT_SUCCESS(Status))
-  {
-    return STATUS_SUCCESS;
-  }
-  DPRINT("SMDLL: %s failed (Status=0x%08lx)\n", __FUNCTION__, Status);
-  return Status;
-}
-
-/* EOF */
+/* $Id: connect.c 14015 2005-03-13 17:00:19Z ea $\r
+ *\r
+ * COPYRIGHT:  See COPYING in the top level directory\r
+ * PROJECT:    ReactOS system libraries\r
+ * FILE:       reactos/lib/smlib/connect.c\r
+ * PURPOSE:    Connect to the API LPC port exposed by the SM\r
+ */\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
+#define NDEBUG\r
+#include <debug.h>\r
+\r
+/**********************************************************************\r
+ * NAME                                                        EXPORTED\r
+ *     SmConnectApiPort/4\r
+ *\r
+ * DESCRIPTION\r
+ *     Connect to SM API port and register a session "begin" port (Sb)\r
+ *     or to issue API requests to SmApiPort.\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
+ *     phSmApiPort: a pointer to a HANDLE, which will be\r
+ *             filled with a valid client-side LPC comm port.\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
+ */\r
+NTSTATUS STDCALL\r
+SmConnectApiPort (IN      PUNICODE_STRING  pSbApiPortName  OPTIONAL,\r
+                 IN      HANDLE           hSbApiPort      OPTIONAL,\r
+                 IN      DWORD            dwSubsystem     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
+  ULONG                       ConnectDataLength = 0;\r
+\r
+  DPRINT("SMLIB: %s called\n", __FUNCTION__);\r
+\r
+  if (pSbApiPortName)\r
+  {\r
+    if (pSbApiPortName->Length > (sizeof pSbApiPortName->Buffer[0] * SM_SB_NAME_MAX_LENGTH))\r
+    {\r
+         return STATUS_INVALID_PARAMETER_1;\r
+    }\r
+    if (NULL == hSbApiPort || IMAGE_SUBSYSTEM_UNKNOWN == dwSubsystem)\r
+    {\r
+      return STATUS_INVALID_PARAMETER_MIX;\r
+    }\r
+    RtlZeroMemory (& ConnectData, sizeof ConnectData);\r
+    ConnectData.Subsystem = dwSubsystem;\r
+    if (pSbApiPortName->Length > 0)\r
+    {\r
+      RtlCopyMemory (& ConnectData.SbName,\r
+                    pSbApiPortName->Buffer,\r
+                    pSbApiPortName->Length);\r
+    }\r
+  }\r
+  ConnectDataLength = sizeof ConnectData;\r
+\r
+  SecurityQos.Length              = sizeof (SecurityQos);\r
+  SecurityQos.ImpersonationLevel  = SecurityIdentification;\r
+  SecurityQos.ContextTrackingMode = TRUE;\r
+  SecurityQos.EffectiveOnly       = TRUE;\r
+\r
+  RtlInitUnicodeString (& SmApiPortName, SM_API_PORT_NAME);\r
+\r
+  Status = NtConnectPort (\r
+             phSmApiPort,\r
+             & SmApiPortName,\r
+             & SecurityQos,\r
+             NULL,\r
+             NULL,\r
+             NULL,\r
+             & ConnectData,\r
+             & ConnectDataLength\r
+             );\r
+  if (NT_SUCCESS(Status))\r
+  {\r
+    return STATUS_SUCCESS;\r
+  }\r
+  DPRINT("SMLIB: %s failed (Status=0x%08lx)\n", __FUNCTION__, Status);\r
+  return Status;\r
+}\r
+\r
+/* EOF */\r
similarity index 87%
rename from reactos/lib/smdll/execpgm.c
rename to reactos/lib/smlib/execpgm.c
index 4770968..75b7aaf 100644 (file)
@@ -1,76 +1,76 @@
-/* $Id$
- *
- * COPYRIGHT:       See COPYING in the top level directory
- * PROJECT:         ReactOS system libraries
- * FILE:            lib/smdll/execpgm.c
- * PURPOSE:         Call SM API SM_API_EXECPGM
- */
-#define NTOS_MODE_USER
-#include <ntos.h>
-#include <sm/api.h>
-#include <sm/helper.h>
-#include <string.h>
-
-#define NDEBUG
-#include <debug.h>
-
-/**********************************************************************
- * NAME                                                        EXPORTED
- *     SmExecuteProgram/2
- *
- * DESCRIPTION
- *     This function is used to make the SM start an environment
- *     subsystem server process.
- *
- * ARGUMENTS
- *     hSmApiPort: port handle returned by SmConnectApiPort;
- *     Pgm       : name of the subsystem (to be used by the SM to
- *                 lookup the image name from the registry).
- *                 Valid names are: DEBUG, WINDOWS, POSIX, OS2,
- *                 and VMS.
- *     
- * RETURN VALUE
- *     Success status as handed by the SM reply; otherwise a failure
- *     status code.
- */
-NTSTATUS STDCALL
-SmExecuteProgram (IN HANDLE          hSmApiPort,
-                 IN PUNICODE_STRING Pgm)
-{
-  NTSTATUS         Status;
-  SM_PORT_MESSAGE  SmReqMsg;
-
-
-  DPRINT("SMDLL: %s called\n", __FUNCTION__);
-
-  /* Check Pgm's length */
-  if (Pgm->Length > (sizeof (Pgm->Buffer[0]) * SM_EXEXPGM_MAX_LENGTH))
-  {
-    return STATUS_INVALID_PARAMETER;
-  }
-  /* Marshal Pgm in the LPC message */
-  RtlZeroMemory (& SmReqMsg, sizeof SmReqMsg);
-  SmReqMsg.ExecPgm.NameLength = Pgm->Length;
-  RtlCopyMemory (SmReqMsg.ExecPgm.Name,
-                Pgm->Buffer,
-                Pgm->Length);
-               
-  /* SM API to invoke */
-  SmReqMsg.ApiIndex = SM_API_EXECUTE_PROGRAMME;
-
-  /* LPC message */
-  SmReqMsg.Header.MessageType = LPC_NEW_MESSAGE;
-  SmReqMsg.Header.DataSize    = SM_PORT_DATA_SIZE(SmReqMsg.ExecPgm);
-  SmReqMsg.Header.MessageSize = SM_PORT_MESSAGE_SIZE;
-
-  /* Call SM and wait for a reply */
-  Status = NtRequestWaitReplyPort (hSmApiPort, (PLPC_MESSAGE) & SmReqMsg, (PLPC_MESSAGE) & SmReqMsg);
-  if (NT_SUCCESS(Status))
-  {
-    return SmReqMsg.Status;
-  }
-  DPRINT("SMDLL: %s failed (Status=0x%08lx)\n", __FUNCTION__, Status);
-  return Status;
-}
-
-/* EOF */
+/* $Id: execpgm.c 13731 2005-02-23 23:37:06Z ea $\r
+ *\r
+ * COPYRIGHT:       See COPYING in the top level directory\r
+ * PROJECT:         ReactOS system libraries\r
+ * FILE:            lib/smlib/execpgm.c\r
+ * PURPOSE:         Call SM API SM_API_EXECPGM\r
+ */\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
+#define NDEBUG\r
+#include <debug.h>\r
+\r
+/**********************************************************************\r
+ * NAME                                                        EXPORTED\r
+ *     SmExecuteProgram/2\r
+ *\r
+ * DESCRIPTION\r
+ *     This function is used to make the SM start an environment\r
+ *     subsystem server process.\r
+ *\r
+ * ARGUMENTS\r
+ *     hSmApiPort: port handle returned by SmConnectApiPort;\r
+ *     Pgm       : name of the subsystem (to be used by the SM to\r
+ *                 lookup the image name from the registry).\r
+ *                 Valid names are: DEBUG, WINDOWS, POSIX, OS2,\r
+ *                 and VMS.\r
+ *     \r
+ * RETURN VALUE\r
+ *     Success status as handed by the SM reply; otherwise a failure\r
+ *     status code.\r
+ */\r
+NTSTATUS STDCALL\r
+SmExecuteProgram (IN HANDLE          hSmApiPort,\r
+                 IN PUNICODE_STRING Pgm)\r
+{\r
+  NTSTATUS         Status;\r
+  SM_PORT_MESSAGE  SmReqMsg;\r
+\r
+\r
+  DPRINT("SMLIB: %s called\n", __FUNCTION__);\r
+\r
+  /* Check Pgm's length */\r
+  if (Pgm->Length > (sizeof (Pgm->Buffer[0]) * SM_EXEXPGM_MAX_LENGTH))\r
+  {\r
+    return STATUS_INVALID_PARAMETER;\r
+  }\r
+  /* Marshal Pgm in the LPC message */\r
+  RtlZeroMemory (& SmReqMsg, sizeof SmReqMsg);\r
+  SmReqMsg.ExecPgm.NameLength = Pgm->Length;\r
+  RtlCopyMemory (SmReqMsg.ExecPgm.Name,\r
+                Pgm->Buffer,\r
+                Pgm->Length);\r
+               \r
+  /* SM API to invoke */\r
+  SmReqMsg.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.MessageSize = SM_PORT_MESSAGE_SIZE;\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
+  }\r
+  DPRINT("SMLIB: %s failed (Status=0x%08lx)\n", __FUNCTION__, Status);\r
+  return Status;\r
+}\r
+\r
+/* EOF */\r
diff --git a/reactos/lib/smlib/makefile b/reactos/lib/smlib/makefile
new file mode 100644 (file)
index 0000000..9ec7cc1
--- /dev/null
@@ -0,0 +1,35 @@
+\r
+PATH_TO_TOP = ../..\r
+\r
+TARGET_TYPE = library\r
+\r
+TARGET_NAME = smlib\r
+\r
+include $(PATH_TO_TOP)/config\r
+\r
+TARGET_CFLAGS = -Wall -Werror -ffreestanding\r
+\r
+# require os code to explicitly request A/W version of structs/functions\r
+TARGET_CFLAGS += -D_DISABLE_TIDENTS\r
+\r
+ifneq ($(DBG), 0)\r
+TARGET_CFLAGS += -DDBG\r
+endif\r
+\r
+TARGET_OBJECTS = \\r
+       connect.o \\r
+       execpgm.o \\r
+       compses.o\r
+\r
+\r
+include $(PATH_TO_TOP)/rules.mak\r
+\r
+include $(TOOLS_PATH)/helper.mk\r
+\r
+DEP_OBJECTS := $(TARGET_OBJECTS)\r
+\r
+TARGET_CLEAN = $(DEP_FILES)\r
+\r
+include $(PATH_TO_TOP)/tools/depend.mk\r
+\r
+# EOF\r
index f9ff6a8..392595b 100644 (file)
@@ -60,7 +60,7 @@ HANDLE hSmApiPort = (HANDLE) 0;
  *     (programmatically). This also open hSmApiPort to be used\r
  *     in loading required subsystems.\r
  */\r
-#if 0\r
+\r
 static NTSTATUS\r
 SmpRegisterSmss(VOID)\r
 {\r
@@ -68,7 +68,8 @@ SmpRegisterSmss(VOID)
        UNICODE_STRING SbApiPortName = {0,0,NULL};\r
 \r
        DPRINT("SM: %s called\n",__FUNCTION__);\r
-       \r
+\r
+       RtlInitUnicodeString (& SbApiPortName, L"");    \r
        Status = SmConnectApiPort(& SbApiPortName,\r
                                  (HANDLE) 0,\r
                                  IMAGE_SUBSYSTEM_NATIVE,\r
@@ -79,6 +80,7 @@ SmpRegisterSmss(VOID)
                        __FUNCTION__,Status);\r
                return Status;\r
        }\r
+       DPRINT("SM self registered\n");\r
        /*\r
         * Note that you don't need to call complete session\r
         * because connection handling code autocompletes\r
@@ -86,7 +88,7 @@ SmpRegisterSmss(VOID)
         */\r
        return Status;\r
 }\r
-#endif\r
+\r
 \r
 /**********************************************************************\r
  */\r
@@ -103,13 +105,12 @@ SmLoadSubsystems(VOID)
        DPRINT("SM: loading subsystems\n");\r
 \r
        /* SM self registers */\r
-#if 0\r
        Status = SmpRegisterSmss();\r
        if(!NT_SUCCESS(Status))\r
        {\r
                DPRINT1("SM: SM failed to self register: system is not secure!\n");\r
        }\r
-#endif\r
+\r
        /* Load Kmode subsystem (aka win32k.sys) */\r
        Status = SmLookupSubsystem (L"Kmode",\r
                                    Data,\r
@@ -136,7 +137,7 @@ SmLoadSubsystems(VOID)
        }\r
        /* TODO: load Required subsystems (Debug Windows) */\r
 #if 0\r
-       Status = SmExecuteProgram(L"DEBUG");\r
+       Status = SmExecuteProgram (hSmApiPort, L"DEBUG");\r
        if(!NT_SUCCESS(Status))\r
        {\r
                DPRINT1("SM: DBSS failed to initialize!\n");\r
index 823310e..ebfc47e 100644 (file)
@@ -6,7 +6,7 @@ TARGET_TYPE = program
 
 TARGET_APPTYPE = native
 
-TARGET_SDKLIBS = ntdll.a smdll.a
+TARGET_SDKLIBS = smlib.a ntdll.a
 
 TARGET_NAME = smss