f9a523b8fd24178e32f6822607aea22112189fd3
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS system libraries
5 * FILE: lib/smdll/execpgm.c
6 * PURPOSE: Call SM API SM_API_EXECPGM
11 #include <sm/helper.h>
15 SmExecPgm (HANDLE hSmApiPort
, PUNICODE_STRING Pgm
)
18 SM_PORT_MESSAGE SmReqMsg
;
21 /* Check Pgm's length */
22 if (Pgm
->Length
> (sizeof (Pgm
->Buffer
[0]) * SM_EXEXPGM_MAX_LENGTH
))
24 return STATUS_INVALID_PARAMETER
;
26 /* Marshal Pgm in the LPC message */
27 RtlZeroMemory (& SmReqMsg
, sizeof SmReqMsg
);
28 SmReqMsg
.ExecPgm
.NameLength
= Pgm
->Length
;
29 RtlCopyMemory (SmReqMsg
.ExecPgm
.Name
, Pgm
->Buffer
, Pgm
->Length
);
31 /* SM API to invoke */
32 SmReqMsg
.ApiIndex
= SM_API_EXECUTE_PROGRAMME
;
35 SmReqMsg
.Header
.MessageType
= LPC_NEW_MESSAGE
;
36 SmReqMsg
.Header
.DataSize
= SM_PORT_DATA_SIZE(SmReqMsg
.ExecPgm
);
37 SmReqMsg
.Header
.MessageSize
= SM_PORT_MESSAGE_SIZE
;
39 /* Call SM and wait for a reply */
40 Status
= NtRequestWaitReplyPort (hSmApiPort
, (PLPC_MESSAGE
) & SmReqMsg
, (PLPC_MESSAGE
) & SmReqMsg
);
41 if (NT_SUCCESS(Status
))
43 return SmReqMsg
.Status
;
45 DbgPrint ("%s failed (Status=0x%08lx)\n", __FUNCTION__
, Status
);