ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

connect.c
Go to the documentation of this file.
00001 /* $Id: connect.c 37763 2008-11-30 11:42:05Z sginsberg $
00002  *
00003  * COPYRIGHT:  See COPYING in the top level directory
00004  * PROJECT:    ReactOS system libraries
00005  * FILE:       reactos/lib/smlib/connect.c
00006  * PURPOSE:    Connect to the API LPC port exposed by the SM
00007  */
00008 
00009 #include "precomp.h"
00010 
00011 #define NDEBUG
00012 #include <debug.h>
00013 
00014 /**********************************************************************
00015  * NAME                         EXPORTED
00016  *  SmConnectApiPort/4
00017  *
00018  * DESCRIPTION
00019  *  Connect to SM API port and register a session "begin" port (Sb)
00020  *  or to issue API requests to SmApiPort.
00021  *
00022  * ARGUMENTS
00023  *  pSbApiPortName: name of the Sb port the calling subsystem
00024  *      server already created in the system name space;
00025  *  hSbApiPort: LPC port handle (checked, but not used: the
00026  *      subsystem is required to have already created
00027  *      the callback port before it connects to the SM);
00028  *  wSubsystem: a valid IMAGE_SUBSYSTEM_xxx value;
00029  *  phSmApiPort: a pointer to a HANDLE, which will be
00030  *      filled with a valid client-side LPC comm port.
00031  *
00032  *  There should be only two ways to call this API:
00033  *  a) subsystems willing to register with SM will use it
00034  *     with full parameters (the function checks them);
00035  *  b) regular SM clients, will set to 0 the 1st, the 2nd,
00036  *     and the 3rd parameter.
00037  *
00038  * RETURN VALUE
00039  *  If all three optional values are omitted, an LPC status.
00040  *  STATUS_INVALID_PARAMETER_MIX if PortName is defined and
00041  *  both hSbApiPort and wSubsystem are 0.
00042  */
00043 NTSTATUS WINAPI
00044 SmConnectApiPort (IN      PUNICODE_STRING  pSbApiPortName  OPTIONAL,
00045           IN      HANDLE           hSbApiPort      OPTIONAL,
00046           IN      WORD             wSubSystemId    OPTIONAL,
00047           IN OUT  PHANDLE          phSmApiPort)
00048 {
00049   UNICODE_STRING              SmApiPortName;
00050   SECURITY_QUALITY_OF_SERVICE SecurityQos;
00051   NTSTATUS                    Status = STATUS_SUCCESS;
00052   SM_CONNECT_DATA             ConnectData = {0,0,{0}};
00053   ULONG                       ConnectDataLength = 0;
00054 
00055   DPRINT("SMLIB: %s called\n", __FUNCTION__);
00056 
00057   if (pSbApiPortName)
00058   {
00059     if (pSbApiPortName->Length > (sizeof pSbApiPortName->Buffer[0] * SM_SB_NAME_MAX_LENGTH))
00060     {
00061       return STATUS_INVALID_PARAMETER_1;
00062     }
00063     if (NULL == hSbApiPort || IMAGE_SUBSYSTEM_UNKNOWN == wSubSystemId)
00064     {
00065       return STATUS_INVALID_PARAMETER_MIX;
00066     }
00067     RtlZeroMemory (& ConnectData, sizeof ConnectData);
00068     ConnectData.Unused = 0;
00069     ConnectData.SubSystemId = wSubSystemId;
00070     if (pSbApiPortName->Length > 0)
00071     {
00072       RtlCopyMemory (& ConnectData.SbName,
00073              pSbApiPortName->Buffer,
00074              pSbApiPortName->Length);
00075     }
00076   }
00077   ConnectDataLength = sizeof ConnectData;
00078 
00079   SecurityQos.Length              = sizeof (SecurityQos);
00080   SecurityQos.ImpersonationLevel  = SecurityIdentification;
00081   SecurityQos.ContextTrackingMode = SECURITY_DYNAMIC_TRACKING;
00082   SecurityQos.EffectiveOnly       = TRUE;
00083 
00084   RtlInitUnicodeString (& SmApiPortName, SM_API_PORT_NAME);
00085 
00086   Status = NtConnectPort (
00087              phSmApiPort,
00088              & SmApiPortName,
00089              & SecurityQos,
00090              NULL,
00091              NULL,
00092              NULL,
00093              & ConnectData,
00094              & ConnectDataLength
00095              );
00096   if (NT_SUCCESS(Status))
00097   {
00098     return STATUS_SUCCESS;
00099   }
00100   DPRINT("SMLIB: %s failed (Status=0x%08lx)\n", __FUNCTION__, Status);
00101   return Status;
00102 }
00103 
00104 /* EOF */

Generated on Sun May 27 2012 04:22:34 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.