3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS system libraries
5 * FILE: reactos/lib/smdll/connect.c
6 * PURPOSE: Connect to the API LPC port exposed by the SM
11 #include <sm/helper.h>
14 /**********************************************************************
19 * Connect to SM API port and register a session "begin" port (Sb)
20 * or to issue API requests to SmApiPort.
23 * pSbApiPortName: name of the Sb port the calling subsystem
24 * server already created in the system name space;
25 * hSbApiPort: LPC port handle (checked, but not used);
26 * dwSubsystem: a valid IMAGE_SUBSYSTEM_xxx value;
27 * phSmApiPort: a pointer to a HANDLE, which will be
28 * filled with a valid client-side LPC comm port.
31 * If all three optional values are omitted, an LPC status.
32 * STATUS_INVALID_PARAMETER_MIX if PortName is defined and
33 * both hSbApiPort and dwSubsystem are 0.
36 SmConnectApiPort (IN PUNICODE_STRING pSbApiPortName OPTIONAL
,
37 IN HANDLE hSbApiPort OPTIONAL
,
38 IN DWORD dwSubsystem OPTIONAL
,
39 IN OUT PHANDLE phSmApiPort
)
41 UNICODE_STRING SmApiPortName
;
42 SECURITY_QUALITY_OF_SERVICE SecurityQos
;
43 NTSTATUS Status
= STATUS_SUCCESS
;
44 SM_CONNECT_DATA ConnectData
= {0,{0}};
45 ULONG ConnectDataLength
= 0;
49 if (NULL
== hSbApiPort
|| IMAGE_SUBSYSTEM_UNKNOWN
== dwSubsystem
)
51 return STATUS_INVALID_PARAMETER_MIX
;
53 ConnectData
.Subsystem
= dwSubsystem
;
54 memmove (& ConnectData
.SbName
, pSbApiPortName
->Buffer
, pSbApiPortName
->Length
);
56 ConnectDataLength
= sizeof (ConnectData
);
58 SecurityQos
.Length
= sizeof (SecurityQos
);
59 SecurityQos
.ImpersonationLevel
= SecurityIdentification
;
60 SecurityQos
.ContextTrackingMode
= TRUE
;
61 SecurityQos
.EffectiveOnly
= TRUE
;
63 RtlInitUnicodeString (& SmApiPortName
, SM_API_PORT_NAME
);
65 Status
= NtConnectPort (
75 if (NT_SUCCESS(Status
))
77 return STATUS_SUCCESS
;
79 DbgPrint ("%s failed (Status=0x%08lx)\n", __FUNCTION__
, Status
);