Modified: trunk/reactos/Makefile
Modified: trunk/reactos/bootdata/packages/reactos.dff
Added: trunk/reactos/include/rosrtl/smapi.h
Added: trunk/reactos/include/rosrtl/smhelper.h
Modified: trunk/reactos/lib/rosrtl/makefile
Added: trunk/reactos/lib/rosrtl/sm/
Added: trunk/reactos/lib/rosrtl/sm/compses.c
Added: trunk/reactos/lib/rosrtl/sm/connect.c
Added: trunk/reactos/lib/rosrtl/sm/execpgm.c
Added: trunk/reactos/lib/rosrtl/sm/readme.txt
Added: trunk/reactos/lib/rosrtl/sm/testapi.c
--- trunk/reactos/Makefile 2005-02-07 10:33:44 UTC (rev 13456)
+++ trunk/reactos/Makefile 2005-02-07 11:34:52 UTC (rev 13457)
@@ -58,7 +58,7 @@
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 \
+ packet psapi riched20 richedit rpcrt4 samlib secur32 setupapi shell32 shlwapi snmpapi syssetup \
twain unicode user32 userenv version wininet winmm winspool ws2help ws2_32 wsock32 wshirda dnsapi \
urlmon shdocvw dinput dinput8 dxdiagn devenum dsound $(DLLS_KBD) $(DLLS_CPL) $(DLLS_SHELLEXT)
--- trunk/reactos/bootdata/packages/reactos.dff 2005-02-07 10:33:44 UTC (rev 13456)
+++ trunk/reactos/bootdata/packages/reactos.dff 2005-02-07 11:34:52 UTC (rev 13457)
@@ -116,7 +116,6 @@
lib\shdocvw\shdocvw.dll 1
lib\shell32\shell32.dll 1
lib\shlwapi\shlwapi.dll 1
-lib\smdll\smdll.dll 1
lib\syssetup\syssetup.dll 1
lib\twain\twain_32.dll 1
lib\urlmon\urlmon.dll 1
--- trunk/reactos/include/rosrtl/smapi.h 2005-02-07 10:33:44 UTC (rev 13456)
+++ trunk/reactos/include/rosrtl/smapi.h 2005-02-07 11:34:52 UTC (rev 13457)
@@ -0,0 +1,72 @@
+/* $Id$ */
+#ifndef __ROSRTL_SM_API_H
+#define __ROSRTL_SM_API_H
+
+#define SM_API_PORT_NAME L"\\SmApiPort"
+#define SM_DBGSS_PORT_NAME L"\\DbgSsApiPort"
+#define SM_DBGUI_PORT_NAME L"\\DbgUiApiPort"
+
+#pragma pack(push,4)
+
+/*** 1 ****************************************************************/
+
+#define SM_API_COMPLETE_SESSION 1 /* complete a session initialization */
+
+typedef struct _SM_PORT_MESSAGE_COMPSES
+{
+ HANDLE hApiPort;
+ HANDLE hSbApiPort;
+
+} SM_PORT_MESSAGE_COMPSES, *PSM_PORT_MESSAGE_COMPSES;
+
+/*** 2 ****************************************************************/
+
+#define SM_API_2 2
+
+/* obsolete */
+
+/*** 3 ****************************************************************/
+
+#define SM_API_3 3
+
+/* unknown */
+
+/*** 4 ****************************************************************/
+
+#define SM_API_EXECUTE_PROGRAMME 4 /* start a subsystem (server) */
+
+#define SM_EXEXPGM_MAX_LENGTH 32 /* max count of wide string */
+
+typedef struct _SM_PORT_MESSAGE_EXECPGM
+{
+ ULONG NameLength;
+ WCHAR Name [SM_EXEXPGM_MAX_LENGTH];
+
+} SM_PORT_MESSAGE_EXECPGM, *PSM_PORT_MESSAGE_EXECPGM;
+
+/*** | ****************************************************************/
+
+typedef struct _SM_PORT_MESSAGE
+{
+ /*** LPC common header ***/
+ LPC_MESSAGE Header;
+ /*** SM common header ***/
+ DWORD ApiIndex;
+ NTSTATUS Status;
+ /*** SM per API arguments ***/
+ union {
+ SM_PORT_MESSAGE_COMPSES CompSes;
+ SM_PORT_MESSAGE_EXECPGM ExecPgm;
+ };
+
+} SM_PORT_MESSAGE, * PSM_PORT_MESSAGE;
+
+#pragma pack(pop)
+
+/*** MACRO ***********************************************************/
+
+#define SM_PORT_DATA_SIZE(c) (sizeof(DWORD)+sizeof(NTSTATUS)+sizeof(c))
+#define SM_PORT_MESSAGE_SIZE (sizeof(SM_PORT_MESSAGE))
+
+
+#endif /* !def __ROSRTL_SM_API_H */
Property changes on: trunk/reactos/include/rosrtl/smapi.h
___________________________________________________________________
Name: svn:keywords
+ author date id revision
Name: svn:eol-style
+ native
--- trunk/reactos/include/rosrtl/smhelper.h 2005-02-07 10:33:44 UTC (rev 13456)
+++ trunk/reactos/include/rosrtl/smhelper.h 2005-02-07 11:34:52 UTC (rev 13457)
@@ -0,0 +1,46 @@
+#ifndef _ROSRTL_SM_HELPER_H
+
+/*** DATA TYPES ******************************************************/
+
+#define SM_SB_NAME_MAX_LENGTH 120
+
+#pragma pack(push,4)
+
+/* SmConnectApiPort */
+typedef struct _SM_CONNECT_DATA
+{
+ ULONG Subsystem;
+ WCHAR SbName [SM_SB_NAME_MAX_LENGTH];
+
+} SM_CONNECT_DATA, *PSM_CONNECT_DATA;
+
+/* SmpConnectSbApiPort */
+typedef struct _SB_CONNECT_DATA
+{
+ ULONG SmApiMax;
+} SB_CONNECT_DATA, *PSB_CONNECT_DATA;
+
+#pragma pack(pop)
+
+
+/*** PROTOTYPES ******************************************************/
+
+
+/* smdll/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 */
+NTSTATUS STDCALL
+SmCompleteSession (IN HANDLE hSmApiPort,
+ IN HANDLE hSbApiPort,
+ IN HANDLE hApiPort);
+/* smdll/execpgm.c */
+NTSTATUS STDCALL
+SmExecuteProgram (IN HANDLE hSmApiPort,
+ IN PUNICODE_STRING Pgm
+ );
+
+#endif /* ndef _ROSRTL_SM_HELPER_H */
Property changes on: trunk/reactos/include/rosrtl/smhelper.h
___________________________________________________________________
Name: svn:keywords
+ author date id revision
Name: svn:eol-style
+ native
--- trunk/reactos/lib/rosrtl/makefile 2005-02-07 10:33:44 UTC (rev 13456)
+++ trunk/reactos/lib/rosrtl/makefile 2005-02-07 11:34:52 UTC (rev 13457)
@@ -33,6 +33,12 @@
file/sparse.o \
file/path.o
+SM_OBJECTS = \
+ sm/compses.o \
+ sm/connect.o \
+ sm/execpgm.o \
+ sm/testapi.o
+
RECMUTEX_OBJECTS = recmutex/recmutex.o
include $(PATH_TO_TOP)/config
@@ -46,7 +52,8 @@
TARGET_CFLAGS = -D__USE_W32API -Wall -Werror
TARGET_OBJECTS = $(THREAD_OBJECTS) $(MISC_OBJECTS) $(STRING_OBJECTS) \
- $(REGISTRY_OBJECTS) $(FILE_OBJECTS) $(RECMUTEX_OBJECTS)
+ $(REGISTRY_OBJECTS) $(FILE_OBJECTS) $(RECMUTEX_OBJECTS) \
+ $(SM_OBJECTS)
DEP_OBJECTS = $(TARGET_OBJECTS)
--- trunk/reactos/lib/rosrtl/sm/compses.c 2005-02-07 10:33:44 UTC (rev 13456)
+++ trunk/reactos/lib/rosrtl/sm/compses.c 2005-02-07 11:34:52 UTC (rev 13457)
@@ -0,0 +1,39 @@
+/* $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 <rosrtl/smapi.h>
+#include <rosrtl/smhelper.h>
+
+NTSTATUS STDCALL
+SmCompleteSession (HANDLE hSmApiPort, HANDLE hSbApiPort, HANDLE hApiPort)
+{
+ NTSTATUS Status;
+ SM_PORT_MESSAGE SmReqMsg;
+
+ /* 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;
+ }
+ DbgPrint ("%s failed (Status=0x%08lx)\n", __FUNCTION__, Status);
+ return Status;
+}
+
+/* EOF */
Property changes on: trunk/reactos/lib/rosrtl/sm/compses.c
___________________________________________________________________
Name: svn:keywords
+ author date id revision
Name: svn:eol-style
+ native
--- trunk/reactos/lib/rosrtl/sm/connect.c 2005-02-07 10:33:44 UTC (rev 13456)
+++ trunk/reactos/lib/rosrtl/sm/connect.c 2005-02-07 11:34:52 UTC (rev 13457)
@@ -0,0 +1,83 @@
+/* $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 <rosrtl/smapi.h>
+#include <rosrtl/smhelper.h>
+#include <pe.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;
+
+ if (pSbApiPortName)
+ {
+ if (NULL == hSbApiPort || IMAGE_SUBSYSTEM_UNKNOWN == dwSubsystem)
+ {
+ return STATUS_INVALID_PARAMETER_MIX;
+ }
+ ConnectData.Subsystem = dwSubsystem;
+ memmove (& 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;
+ }
+ DbgPrint ("%s failed (Status=0x%08lx)\n", __FUNCTION__, Status);
+ return Status;
+}
+
+/* EOF */
Property changes on: trunk/reactos/lib/rosrtl/sm/connect.c
___________________________________________________________________
Name: svn:keywords
+ author date id revision
Name: svn:eol-style
+ native
--- trunk/reactos/lib/rosrtl/sm/execpgm.c 2005-02-07 10:33:44 UTC (rev 13456)
+++ trunk/reactos/lib/rosrtl/sm/execpgm.c 2005-02-07 11:34:52 UTC (rev 13457)
@@ -0,0 +1,49 @@
+/* $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 <rosrtl/smapi.h>
+#include <rosrtl/smhelper.h>
+#include <string.h>
+
+NTSTATUS STDCALL
+SmExecPgm (HANDLE hSmApiPort, PUNICODE_STRING Pgm)
+{
+ NTSTATUS Status;
+ SM_PORT_MESSAGE SmReqMsg;
+
+
+ /* 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;
+ }
+ DbgPrint ("%s failed (Status=0x%08lx)\n", __FUNCTION__, Status);
+ return Status;
+}
+
+/* EOF */
Property changes on: trunk/reactos/lib/rosrtl/sm/execpgm.c
___________________________________________________________________
Name: svn:keywords
+ author date id revision
Name: svn:eol-style
+ native
--- trunk/reactos/lib/rosrtl/sm/readme.txt 2005-02-07 10:33:44 UTC (rev 13456)
+++ trunk/reactos/lib/rosrtl/sm/readme.txt 2005-02-07 11:34:52 UTC (rev 13457)
@@ -0,0 +1,18 @@
+$Id$
+
+This is a helper library to talk to the ReactOS session manager (SM).
+
+It should be linked in the following components:
+
+a) the SM itself, because iy registers for managing native processes
+ IMAGE_SUBSYSTEM_NATIVE;
+
+b) environment subsystem servers, because each one should register in
+ the SM its own subsystem (willing to manageg those processes);
+
+c) terminal emulators for optional subsystems, like posixw32 and os2w32,
+ to ask the SM to start the optional subsystem server they need connect to;
+
+d) system and development utilites to debug/query the SM.
+
+2004-02-15 ea
\ No newline at end of file
Property changes on: trunk/reactos/lib/rosrtl/sm/readme.txt
___________________________________________________________________
Name: svn:keywords
+ author date id revision
Name: svn:eol-style
+ native
--- trunk/reactos/lib/rosrtl/sm/testapi.c 2005-02-07 10:33:44 UTC (rev 13456)
+++ trunk/reactos/lib/rosrtl/sm/testapi.c 2005-02-07 11:34:52 UTC (rev 13457)
@@ -0,0 +1,20 @@
+/* $Id$ */
+#define NTOS_MODE_USER
+#include <ntos.h>
+#include <rosrtl/smapi.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 */
+
Property changes on: trunk/reactos/lib/rosrtl/sm/testapi.c
___________________________________________________________________
Name: svn:keywords
+ author date id revision
Name: svn:eol-style
+ native