[LIBS]
[reactos.git] / reactos / lib / smlib / compses.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: lib/smlib/compses.c
5 * PURPOSE: Call SM API SM_API_COMPLETE_SESSION
6 */
7
8 #include "precomp.h"
9
10 #define NDEBUG
11 #include <debug.h>
12
13 /**********************************************************************
14 * NAME EXPORTED
15 * SmCompleteSession/3
16 *
17 * DESCRIPTION
18 * This function is called by an environment subsystem server to
19 * tell the SM it finished initialization phase and is ready to
20 * manage processes it registered for (SmConnectApiPort).
21 *
22 * ARGUMENTS
23 * hSmApiPort: port handle returned by SmConnectApiPort;
24 * hSbApiPort: call back API port of the subsystem (handle);
25 * hApiPort : API port of the subsystem (handle).
26 *
27 * RETURN VALUE
28 * Success status as handed by the SM reply; otherwise a failure
29 * status code.
30 */
31 NTSTATUS WINAPI
32 SmCompleteSession (IN HANDLE hSmApiPort,
33 IN HANDLE hSbApiPort,
34 IN HANDLE hApiPort)
35 {
36 NTSTATUS Status;
37 SM_PORT_MESSAGE SmReqMsg;
38
39 DPRINT("SMLIB: %s called\n", __FUNCTION__);
40
41 /* Marshal Ses in the LPC message */
42 SmReqMsg.Request.CompSes.hApiPort = hApiPort;
43 SmReqMsg.Request.CompSes.hSbApiPort = hSbApiPort;
44
45 /* SM API to invoke */
46 SmReqMsg.SmHeader.ApiIndex = SM_API_COMPLETE_SESSION;
47
48 /* Port message */
49 SmReqMsg.Header.u2.s2.Type = LPC_NEW_MESSAGE;
50 SmReqMsg.Header.u1.s1.DataLength = SM_PORT_DATA_SIZE(SmReqMsg.Request);
51 SmReqMsg.Header.u1.s1.TotalLength = SM_PORT_MESSAGE_SIZE;
52 Status = NtRequestWaitReplyPort (hSmApiPort, (PPORT_MESSAGE) & SmReqMsg, (PPORT_MESSAGE) & SmReqMsg);
53 if (NT_SUCCESS(Status))
54 {
55 return SmReqMsg.SmHeader.Status;
56 }
57 DPRINT("SMLIB: %s failed (Status=0x%08lx)\n", __FUNCTION__, Status);
58 return Status;
59 }
60
61 /* EOF */