NtConnectPort - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
#ifndef _NTLPCAPI_H

//
// Port connection (client)
//

/**
 * The NtConnectPort routine requests a connection to a named port.
 *
 * \param PortHandle Receives a handle to the client-side communication port.
 * \param PortName Name of the port to connect to.
 * \param SecurityQos Security quality of service for the connection.
 * \param ClientView Optional shared memory mapping for the client.
 * \param ServerView Optional shared memory mapping for the server.
 * \param MaxMessageLength Optional receives the maximum message length supported.
 * \param ConnectionInformation Optional data to send to the server.
 * \param ConnectionInformationLength Optional size of the connection information.
 * \return NTSTATUS Successful or errant status.
 */
NTSYSCALLAPI
NTSTATUS
NTAPI
NtConnectPort(
    _Out_ PHANDLE PortHandle,
    _In_ PCUNICODE_STRING PortName,
    _In_ PSECURITY_QUALITY_OF_SERVICE SecurityQos,
    _Inout_opt_ PPORT_VIEW ClientView,
    _Inout_opt_ PREMOTE_PORT_VIEW ServerView,
    _Out_opt_ PULONG MaxMessageLength,
    _Inout_updates_bytes_to_opt_(*ConnectionInformationLength, *ConnectionInformationLength) PVOID ConnectionInformation,
    _Inout_opt_ PULONG ConnectionInformationLength
    );

#endif

View code on GitHub
#ifndef _NTZWAPI_H

NTSYSCALLAPI
NTSTATUS
NTAPI
ZwConnectPort(
    _Out_ PHANDLE PortHandle,
    _In_ PCUNICODE_STRING PortName,
    _In_ PSECURITY_QUALITY_OF_SERVICE SecurityQos,
    _Inout_opt_ PPORT_VIEW ClientView,
    _Inout_opt_ PREMOTE_PORT_VIEW ServerView,
    _Out_opt_ PULONG MaxMessageLength,
    _Inout_updates_bytes_to_opt_(*ConnectionInformationLength, *ConnectionInformationLength) PVOID ConnectionInformation,
    _Inout_opt_ PULONG ConnectionInformationLength
    );

#endif

View code on GitHub

NtDoc

No description available.

NTinternals.net (undocumented.ntinternals.net)

NtConnectPort is used by client process for establish LPC connection with Named Port's owner.

ClientPortHandle

Result of call - HANDLE to Port Object.

ServerPortName

Name of port to connect to.

SecurityQos

ClientSharedMemory

Used when calling process created Section Object for shared memory. See NtAcceptConnectPort for details.

ServerSharedMemory

Used when calling process didn't create Section Object. See NtAcceptConnectPort for details.

MaximumMessageLength

Maximum communication message length. This value is calculated by server on port creation process (see NtCreatePort).

ConnectionInfo

Pointer to RAW buffer containing information from client. That information is received by server through LPC_MESSAGE with MessageType field set to LPC_CONNECTION_REQUEST.

ConnectionInfoLength

Size of ConnectionInfo buffer, in bytes.

Documented by

See also