> Windows Syscalls
ntoskrnl.exeT1068T1559T1106

NtAlpcConnectPort

Establece una conexión cliente ALPC con un puerto servidor con nombre e intercambia un mensaje inicial.

Prototipo

NTSTATUS NtAlpcConnectPort(
  PHANDLE                    PortHandle,
  PUNICODE_STRING            PortName,
  POBJECT_ATTRIBUTES         ObjectAttributes,
  PALPC_PORT_ATTRIBUTES      PortAttributes,
  ULONG                      Flags,
  PSID                       RequiredServerSid,
  PPORT_MESSAGE              ConnectionMessage,
  PULONG                     BufferLength,
  PALPC_MESSAGE_ATTRIBUTES   OutMessageAttributes,
  PALPC_MESSAGE_ATTRIBUTES   InMessageAttributes,
  PLARGE_INTEGER             Timeout
);

Argumentos

NameTypeDirDescription
PortHandlePHANDLEoutRecibe el handle de la nueva conexión cliente ALPC.
PortNamePUNICODE_STRINGinNombre del puerto servidor en el espacio de objetos, p. ej. \RPC Control\foo, \Sessions\1\... .
ObjectAttributesPOBJECT_ATTRIBUTESinAtributos de objeto opcionales para el puerto cliente; típicamente NULL.
PortAttributesPALPC_PORT_ATTRIBUTESinAtributos del puerto en el cliente (longitud máxima de mensaje, tamaño de vista, QoS de seguridad).
FlagsULONGinBanderas ALPC_MSGFLG_* y de conexión (p. ej. ALPC_PORFLG_ALLOW_LPC_REQUESTS).
RequiredServerSidPSIDinSID opcional que el kernel debe verificar en el servidor antes de aceptar la conexión.
ConnectionMessagePPORT_MESSAGEin/outCarga útil del mensaje de conexión; actualizada con la respuesta de aceptación del servidor.
BufferLengthPULONGin/outEn entrada, tamaño de ConnectionMessage; en salida, tamaño de la respuesta del servidor.
OutMessageAttributesPALPC_MESSAGE_ATTRIBUTESin/outAtributos del mensaje (handle, contexto de seguridad, vista) que el cliente envía en el connect.
InMessageAttributesPALPC_MESSAGE_ATTRIBUTESin/outRecibe los atributos de la respuesta del servidor (p. ej. handles de vista compartida).
TimeoutPLARGE_INTEGERinTiempo de espera opcional para el handshake de conexión (unidades de 100 ns, negativo = relativo).

IDs de syscalls por versión de Windows

Versión de WindowsID de syscallBuild
Win10 15070x75win10-1507
Win10 16070x75win10-1607
Win10 17030x76win10-1703
Win10 17090x76win10-1709
Win10 18030x77win10-1803
Win10 18090x77win10-1809
Win10 19030x77win10-1903
Win10 19090x77win10-1909
Win10 20040x79win10-2004
Win10 20H20x79win10-20h2
Win10 21H10x79win10-21h1
Win10 21H20x79win10-21h2
Win10 22H20x79win10-22h2
Win11 21H20x79win11-21h2
Win11 22H20x79win11-22h2
Win11 23H20x79win11-23h2
Win11 24H20x7Bwin11-24h2
Server 20160x75winserver-2016
Server 20190x77winserver-2019
Server 20220x79winserver-2022
Server 20250x7Bwinserver-2025

Módulo del kernel

ntoskrnl.exeNtAlpcConnectPort

APIs relacionadas

RpcBindingFromStringBindingWRpcStringBindingComposeWNtAlpcSendWaitReceivePortNtAlpcCreatePortNtAlpcDisconnectPortNtAlpcAcceptConnectPort

Stub del syscall

4C 8B D1            mov r10, rcx
B8 7B 00 00 00      mov eax, 0x7B
F6 04 25 08 03 FE 7F 01   test byte ptr [0x7FFE0308], 1
75 03               jne short +3
0F 05               syscall
C3                  ret
CD 2E               int 2Eh
C3                  ret

Notas no documentadas

ALPC (Advanced/Asynchronous Local Procedure Call) es el sucesor moderno y no documentado del subsistema LPC heredado y el sustrato de casi todos los servicios RPC de Windows que no usan SMB ni TCP. `NtAlpcConnectPort` es el handshake del lado cliente — el equivalente a `connect()` para puertos ALPC. **No hay superficie Win32 pública**; los consumidores llegan a él indirectamente vía el runtime RPC (`RpcBindingFromStringBindingW` con secuencia `ncalrpc`) o, más abajo, vía el IPC TraceLogging de ETW. La firma de 11 argumentos la reproducen fielmente phnt y SystemInformer.

Uso común por malware

ALPC es superficie de elevación de privilegios, no de ejecución de código. CVE-2018-8440 (LPE *ALPC Task Scheduler* de SandboxEscaper) abusó de una llamada SetSecurityInfo alcanzable por conexión ALPC desde cualquier usuario para tomar archivos de SYSTEM. PrintNightmare (CVE-2021-1675 / 34527) y exploits cercanos a Follina también alcanzan Print Spooler y servicios de diagnóstico vía ALPC. Más allá del exploit, algunos implantes avanzados usan ALPC como canal C2 sigiloso intra-proceso o intra-host entre componentes cooperantes (loader ↔ DLL inyectada ↔ servicio de persistencia) porque el tráfico ALPC es invisible a los eventos de red de Sysmon y a la mayoría de EDRs.

Oportunidades de detección

El proveedor ETW `Microsoft-Windows-Kernel-ALPC` expone eventos connect/send/receive por puerto pero rara vez está activo por defecto — habilitarlo a escala es caro. EDRs que hookean `NtAlpcConnectPort` en user mode (o en `kernel.appcore.dll`) pueden correlacionar el nombre del puerto con el proceso llamante: conexiones desde un proceso no sistema hacia puertos de alto valor (`\RPC Control\AppInfo`, `\RPC Control\SECLOGON`, `\Sessions\1\Windows\BaseNamedObjects\spoolss`) merecen alerta. Herramientas forenses como SystemInformer enumeran puertos ALPC por proceso, método más fiable en post-incidente.

Ejemplos de syscalls directos

asmx64 direct stub (Win11 24H2)

; Direct syscall stub for NtAlpcConnectPort (SSN 0x7B on Win11 24H2)
NtAlpcConnectPort PROC
    mov  r10, rcx          ; PortHandle
    mov  eax, 7Bh          ; SSN — drifts per build
    syscall
    ret
NtAlpcConnectPort ENDP

cConnect to an LRPC server port

// Connect from a user-mode client to a named ALPC server port.
#include <windows.h>
#include <winternl.h>

typedef NTSTATUS (NTAPI *pNtAlpcConnectPort)(
    PHANDLE, PUNICODE_STRING, POBJECT_ATTRIBUTES, PVOID,
    ULONG, PSID, PVOID, PULONG, PVOID, PVOID, PLARGE_INTEGER);

HANDLE OpenServerPort(LPCWSTR name) {
    UNICODE_STRING us; RtlInitUnicodeString(&us, name);
    HANDLE hPort = NULL;
    ULONG bufLen = 0;
    pNtAlpcConnectPort fn = (pNtAlpcConnectPort)GetProcAddress(
        GetModuleHandleA("ntdll.dll"), "NtAlpcConnectPort");
    fn(&hPort, &us, NULL, NULL, 0, NULL, NULL, &bufLen, NULL, NULL, NULL);
    return hPort;
}

cRPC ncalrpc binding (high-level equivalent)

// What 99% of legitimate callers actually do — RpcBindingFromStringBindingW
// drives NtAlpcConnectPort under the hood for the ncalrpc transport.
#include <windows.h>
#include <rpc.h>

RPC_BINDING_HANDLE BindLrpc(LPCWSTR ep) {
    LPWSTR bindStr = NULL;
    RpcStringBindingComposeW(NULL, (RPC_WSTR)L"ncalrpc", NULL,
                             (RPC_WSTR)ep, NULL, (RPC_WSTR*)&bindStr);
    RPC_BINDING_HANDLE h = NULL;
    RpcBindingFromStringBindingW((RPC_WSTR)bindStr, &h);
    RpcStringFreeW((RPC_WSTR*)&bindStr);
    return h;
}

Mapeos MITRE ATT&CK

Last verified: 2026-05-20