NtSetIoCompletion - NtDoc

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

/**
 * Posts a caller-defined packet to an I/O completion port, without issuing file I/O.
 * Useful for notifying workers through the same queue used for I/O completions.
 *
 * \param[in] IoCompletionHandle Handle with IO_COMPLETION_MODIFY_STATE (0x2).
 * \param[in, optional] KeyContext Opaque pointer-sized value returned to the consumer.
 * \param[in, optional] ApcContext Opaque pointer-sized value returned to the consumer;
 * it is not an APC routine and this call does not dispatch a user callback.
 * \param[in] IoStatus Status value stored in the packet, independent of this call's status.
 * \param[in] IoStatusInformation Pointer-sized packet information, often a byte count.
 * \return NTSTATUS describing posting, not the supplied IoStatus. A negative
 * IoStatus can be posted successfully and later dequeued with STATUS_SUCCESS.
 * \remarks Context values may be NULL and are not dereferenced or copied as buffers.
 * The call does not require prior file association. Use NtSetIoCompletionEx with a
 * separately allocated memory reserve when a reusable packet allocation is needed.
 * \sa https://learn.microsoft.com/en-us/windows/win32/api/ioapiset/nf-ioapiet-postqueuedcompletionstatus
 */
_Kernel_entry_
NTSYSCALLAPI
NTSTATUS
NTAPI
NtSetIoCompletion(
    _In_ HANDLE IoCompletionHandle,
    _In_opt_ PVOID KeyContext,
    _In_opt_ PVOID ApcContext,
    _In_ NTSTATUS IoStatus,
    _In_ ULONG_PTR IoStatusInformation
    );

#endif

View code on GitHub
#ifndef _NTZWAPI_H

_Kernel_entry_
NTSYSCALLAPI
NTSTATUS
NTAPI
ZwSetIoCompletion(
    _In_ HANDLE IoCompletionHandle,
    _In_opt_ PVOID KeyContext,
    _In_opt_ PVOID ApcContext,
    _In_ NTSTATUS IoStatus,
    _In_ ULONG_PTR IoStatusInformation
    );

#endif

View code on GitHub

NtDoc

No description available.

NTinternals.net (undocumented.ntinternals.net)

Function NtSetIoCompletion increments pending IO counter in IO Completion Object. It can be used to manual finish IO operation.

IoCompletionHandle

HANDLE to IO Completion Object opened with IO_COMPLETION_MODIFY_STATE access.

CompletionKey

User's defined key received by NtRemoveIoCompletion function.

IoStatusBlock

IO result of call.

CompletionStatus

IO operation status.

NumberOfBytesTransferred

Number of bytes transferred in manually finished IO operation.

Documented by

See also