Edit

WinI3CDisableIbisWithFileHandle function (wini3c.h)

Initiates an overlapped disable of In-Band-Interrupts (IBIs) for a WinI3C-Target using a client-supplied file handle.

WinI3CDisableIbisWithFileHandle is a Non-library-managed WinI3C API. It uses a client-supplied file handle and returns a WinI3CAsyncOperation.

Non-library-managed WinI3C API are intended only for advanced scenarios; this is generally not recommended. For most applications, use the Library-managed WinI3C APIs WinI3CDisableIbis instead.

Note: Library-managed and non-library-managed APIs cannot be used simultaneously by a client on a single WinI3C-Target.

Syntax

_Must_inspect_result_
HRESULT WINAPI WinI3CDisableIbisWithFileHandle(
    _In_ HANDLE targetFileHandle,
    _In_ OVERLAPPED* ibiDisableOverlapped,
    _Out_ WinI3CAsyncOperation* ibiDisableOperation);

Parameters

[in] targetFileHandle

The file handle associated with the WinI3C-Target to disable IBIs for.

The handle shall have been opened with FILE_FLAG_OVERLAPPED in the dwFlagsAndAttributes parameter of CreateFile.

A WinI3CTarget handle cannot be passed.

[in] ibiDisableOverlapped

A client-allocated OVERLAPPED to supply to the underlying overlapped I/O call.

Note: The hEvent member shall be initialized with a valid event by the client.

[out] ibiDisableOperation

Receives a library-created WinI3CAsyncOperation representing this overlapped operation.

Valid only when the function returns S_OK.

The client shall destroy it with WinI3CRelease after the operation completes and before destroying the associated OVERLAPPED.

Return value

On successfully initiating the operation, this function returns S_OK.

On failure this function returns an appropriate HRESULT error code, including the following.

Return code Description
S_OK Successfully initiated disabling IBIs for the WinI3C-Target.
E_INVALIDARG One or more parameters are invalid.
E_OUTOFMEMORY Available memory is insufficient to execute this function.
HRESULT_FROM_WIN32(ERROR_INVALID_HANDLE) targetFileHandle is invalid or was not opened with FILE_FLAG_OVERLAPPED.
HRESULT_FROM_WIN32(ERROR_DEVICE_HARDWARE_ERROR) A fatal hardware error occurred. Close targetFileHandle with CloseHandle.

Remarks

IBIs are disabled by default.

IBIs shall have been previously enabled with WinI3CEnableIbisWithFileHandle or WinI3CEnableIbisWithAutoCommandReadWithFileHandle.

Vendors understand the capabilities of their devices, so there is no provided mechanism to determine if IBIs are supported.

Use the standard Win32 I/O APIs (e.g. GetOverlappedResult, CancelIo or an I/O completion port) to manage the overlapped operation.

If any IBI pended reads are outstanding at the time of this call, each is completed with HRESULT_FROM_WIN32(ERROR_OPERATION_ABORTED) before this call returns. Any IBIs that the WinI3C-Target has sent but that have not yet been dispatched to the client may be discarded.

When the overlapped operation has completed, destroy the library-created ibiDisableOperation with WinI3CRelease.

If the targetFileHandle is closed with CloseHandle while IBIs are still enabled, IBIs are disabled automatically.

If the client unexpectedly terminates before disabling IBIs, IBIs are disabled automatically.

This function is thread-safe.

Completion status

When the overlapped operation completes, its result (e.g. from GetOverlappedResult with HRESULT_FROM_WIN32(GetLastError())) is one of the following:

Completion code Description
S_OK Successfully disabled IBIs for the WinI3C-Target.
E_INVALIDARG One or more parameters are invalid, or WinI3CDisableIbisWithFileHandle was called again before WinI3CEnableIbisWithFileHandle or WinI3CEnableIbisWithAutoCommandReadWithFileHandle.
HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED) IBIs are not supported for this WinI3C-Target.

Example

Disables IBIs for the WinI3C-Target (described by winI3cTargetHandle).

#include <wil\result.h>
#include <wil\resource.h>

#include <wini3c.h>

int main()
{
    ...

    OVERLAPPED disableIbisOverlapped{};
    disableIbisOverlapped.hEvent = CreateEventW(nullptr, TRUE, FALSE, nullptr);
    RETURN_LAST_ERROR_IF(disableIbisOverlapped.hEvent == nullptr);

    auto closeDisableIbisOverlappedEventOnExit = wil::scope_exit([&]()
    {
        CloseHandle(disableIbisOverlapped.hEvent);
    });

    WinI3CAsyncOperation disableIbisOperation;
    HRESULT disableIbisResult = WinI3CDisableIbisWithFileHandle(
        winI3cTargetHandle,
        &disableIbisOverlapped,
        &disableIbisOperation);
    if (FAILED(disableIbisResult) && disableIbisResult != HRESULT_FROM_WIN32(ERROR_IO_PENDING))
    {
        // Error sending the disable.
        return disableIbisResult;
    }

    auto destroyDisableIbisOperationOnExit = wil::scope_exit([&]()
    {
        WinI3CRelease(disableIbisOperation);
    });

    DWORD disableIbisNumberOfBytesTransferred;
    if (!GetOverlappedResult(
        winI3cTargetHandle,
        &disableIbisOverlapped,
        &disableIbisNumberOfBytesTransferred,
        true))
    {
        RETURN_LAST_ERROR();
    }

    ...
}

Requirements

Requirement Value
Minimum supported client Windows 11 25H2 October update (build 26200)
Target Platform Windows
Header wini3c.h
DLL wini3c.dll

See also

WinI3CDisableIbis

WinI3CEnableIbisWithFileHandle

WinI3CPendIbiReadWithFileHandle

WinI3CRelease