1 /* $Id: execpgm.c 13731 2005-02-23 23:37:06Z ea $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS system libraries
5 * FILE: lib/smlib/execpgm.c
6 * PURPOSE: Call SM API SM_API_EXECPGM
11 #include <sm/helper.h>
17 /**********************************************************************
22 * This function is used to make the SM start an environment
23 * subsystem server process.
26 * hSmApiPort: port handle returned by SmConnectApiPort;
27 * Pgm : name of the subsystem (to be used by the SM to
28 * lookup the image name from the registry).
29 * Valid names are: DEBUG, WINDOWS, POSIX, OS2,
33 * Success status as handed by the SM reply; otherwise a failure
37 SmExecuteProgram (IN HANDLE hSmApiPort
,
38 IN PUNICODE_STRING Pgm
)
41 SM_PORT_MESSAGE SmReqMsg
;
44 DPRINT("SMLIB: %s called\n", __FUNCTION__
);
46 /* Check Pgm's length */
47 if (Pgm
->Length
> (sizeof (Pgm
->Buffer
[0]) * SM_EXEXPGM_MAX_LENGTH
))
49 return STATUS_INVALID_PARAMETER
;
51 /* Marshal Pgm in the LPC message */
52 RtlZeroMemory (& SmReqMsg
, sizeof SmReqMsg
);
53 SmReqMsg
.ExecPgm
.NameLength
= Pgm
->Length
;
54 RtlCopyMemory (SmReqMsg
.ExecPgm
.Name
,
58 /* SM API to invoke */
59 SmReqMsg
.ApiIndex
= SM_API_EXECUTE_PROGRAMME
;
62 SmReqMsg
.Header
.MessageType
= LPC_NEW_MESSAGE
;
63 SmReqMsg
.Header
.DataSize
= SM_PORT_DATA_SIZE(SmReqMsg
.ExecPgm
);
64 SmReqMsg
.Header
.MessageSize
= SM_PORT_MESSAGE_SIZE
;
66 /* Call SM and wait for a reply */
67 Status
= NtRequestWaitReplyPort (hSmApiPort
, (PLPC_MESSAGE
) & SmReqMsg
, (PLPC_MESSAGE
) & SmReqMsg
);
68 if (NT_SUCCESS(Status
))
70 return SmReqMsg
.Status
;
72 DPRINT("SMLIB: %s failed (Status=0x%08lx)\n", __FUNCTION__
, Status
);