NtCreateNamedPipeFile - NtDoc

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

/**
 * The NtCreateNamedPipeFile routine deletes the specified file.
 *
 * \param[out] FileHandle Pointer to a variable that receives a handle to the pipe.
 * \param[in] DesiredAccess The requested access to the object.
 * \param[in] ObjectAttributes Pointer to an OBJECT_ATTRIBUTES structure that contains the object attributes, including pipe name.
 * \param[out] IoStatusBlock Pointer to an IO_STATUS_BLOCK structure that receives the final completion status and information about the operation.
 * \param[in] ShareAccess Specifies the type of share access for the file.
 * \param[in] CreateDisposition Specifies how the file should be handled when the file already exists.
 * \param[in] CreateOptions Specifies the options to be applied when creating or opening the file.
 * \param[in] NamedPipeType Type of named pipe to create (byte-type or message-type).
 * \param[in] ReadMode Mode in which to read the pipe (byte-type or message-type).
 * \param[in] CompletionMode Specifies blocking or non-blocking mode of the pipe.
 * \param[in] MaximumInstances Maximum number of simultaneous instances of the named pipe.
 * \param[in] InboundQuota Specifies the pool quota that is reserved for writes to the inbound side of the named pipe.
 * \param[in] OutboundQuota Specifies the pool quota that is reserved for writes to the inbound side of the named pipe.
 * \param[in] DefaultTimeout An optional pointer to a timeout value that is used if a timeout value is not specified when waiting for an instance of a named pipe.
 * \return NTSTATUS Successful or errant status.
 * \sa https://learn.microsoft.com/en-us/windows/win32/devnotes/nt-create-named-pipe-file
 */
NTSYSCALLAPI
NTSTATUS
NTAPI
NtCreateNamedPipeFile(
    _Out_ PHANDLE FileHandle,
    _In_ ACCESS_MASK DesiredAccess,
    _In_ PCOBJECT_ATTRIBUTES ObjectAttributes,
    _Out_ PIO_STATUS_BLOCK IoStatusBlock,
    _In_ ULONG ShareAccess,
    _In_ ULONG CreateDisposition,
    _In_ ULONG CreateOptions,
    _In_ ULONG NamedPipeType,
    _In_ ULONG ReadMode,
    _In_ ULONG CompletionMode,
    _In_ ULONG MaximumInstances,
    _In_ ULONG InboundQuota,
    _In_ ULONG OutboundQuota,
    _In_ PLARGE_INTEGER DefaultTimeout
    );

#endif

View code on GitHub
#ifndef _NTZWAPI_H

NTSYSCALLAPI
NTSTATUS
NTAPI
ZwCreateNamedPipeFile(
    _Out_ PHANDLE FileHandle,
    _In_ ACCESS_MASK DesiredAccess,
    _In_ PCOBJECT_ATTRIBUTES ObjectAttributes,
    _Out_ PIO_STATUS_BLOCK IoStatusBlock,
    _In_ ULONG ShareAccess,
    _In_ ULONG CreateDisposition,
    _In_ ULONG CreateOptions,
    _In_ ULONG NamedPipeType,
    _In_ ULONG ReadMode,
    _In_ ULONG CompletionMode,
    _In_ ULONG MaximumInstances,
    _In_ ULONG InboundQuota,
    _In_ ULONG OutboundQuota,
    _In_ PLARGE_INTEGER DefaultTimeout
    );

#endif

View code on GitHub

This function is documented in Windows SDK.


Function NtCreateNamedPipeFile creates Named Pipe File Object. Named Pipes are especial kind of files, so all functionality is provided with file's functions like NtReadFile, NtWriteFile etc.
Named Pipes are frequently used in NT system, for example as stdin and stdout handles.

NamedPipeFileHandle

Result of call - pointer to HANDLE to Named Pipe.

DesiredAccess

Access rights for object's handle. Can be one or combination of:

ObjectAttributes

Pointer to OBJECT_ATTRIBUTES structure contains name of named pipe. Name must begin with "\??\PIPE\" string, that is Symbolic Link to NamedPipe device object.

IoStatusBlock

IO result of call.

ShareAccess

Can be combination of following:

CreateDisposition

Use FILE_CREATE, FILE_OPEN or FILE_OPEN_IF.

CreateOptions

See description of NtCreateFile for possible creation flags.

WriteModeMessage

If set, writing to created pipe are processed in Message Mode. If not, all writes are in Byte Mode.

ReadModeMessage

The same functionality as WriteModeMessage parameter, but for reading data.

NonBlocking

If set, all operations on created pipe are asynchronous.

MaxInstances

Maximum number of open handles for Named Pipe, or FILE_PIPE_UNLIMITED_INSTANCES constant.

InBufferSize

Input buffer size, in bytes.

OutBufferSize

Output buffer size, in bytes.

DefaultTimeOut

Pointer to LARGE_INTEGER value specifying pipe's time out, in 100-ns units. Negative value means relative time.

Documented by

See also