共用方式為


UcxIoDeviceControl 函式 (ucxcontroller.h)

允許 USB 主機控制器擴充功能 (UCX) 處理使用者模式的 I/O 控制程式代碼 (IOCTL) 要求。

語法

BOOLEAN UcxIoDeviceControl(
  [in] WDFDEVICE  Device,
  [in] WDFREQUEST Request,
  [in] size_t     OutputBufferLength,
  [in] size_t     InputBufferLength,
  [in] ULONG      IoControlCode
);

參數

[in] Device

用戶端驅動程式在先前 呼叫 WdfDeviceCreate中擷取之架構裝置物件的句柄。

[in] Request

表示使用者模式 IOCTL 要求的架構要求物件的句柄。

[in] OutputBufferLength

如果可用的輸出緩衝區,則要求輸出緩衝區的長度,以位元組為單位。

[in] InputBufferLength

如果輸入緩衝區可用,則要求輸入緩衝區的長度,以位元組為單位。

[in] IoControlCode

與要求相關聯的驅動程式定義或系統定義的IOCTL。

傳回值

如果作業成功,此方法會傳回 TRUE。 否則會傳回 FALSE。

言論

用戶端驅動程式可以呼叫此方法,以允許 UCX 處理下表所列的 IOCTL:User-Mode USB的 IOCTL。 如果 IOCTL 程式代碼是 IOCTL_USB_DIAGNOSTIC_MODE_OFFIOCTL_USB_DIAGNOSTIC_MODE_ON,UCX 就會順利完成要求。 對於用來擷取 USB 主機控制器驅動程式密鑰名稱的 IOCTLS,例如 IOCTL_USB_GET_ROOT_HUB_NAMEIOCTL_GET_HCD_DRIVERKEY_NAME,UCX 會擷取 Unicode 字元串。 如果使用者模式 IOCTL 是 IOCTL_USB_USER_REQUEST,輸入和輸出緩衝區長度必須相等,輸出緩衝區必須包含 USBUSER_REQUEST_HEADER 結構。 對於其餘的 IOCTLs,UCX 會傳回 FALSE,而用戶端驅動程式可以提供自己的處理邏輯。

例子

VOID
Controller_WdfEvtIoDeviceControl(
    WDFQUEUE    WdfQueue,
    WDFREQUEST  WdfRequest,
    size_t      OutputBufferLength,
    size_t      InputBufferLength,
    ULONG       IoControlCode
)
/*++

Routine Description:

    This routine is a callback function which is called by WDF when a driver
    receives an I/O control request from the queue this callback is registered
    with.

    The controller driver calls UcxIoDeviceControl() to allow UCX to try and
    handle the IOCTL.  If UCX cannot handle the IOCTL, the controller driver
    must handle it, perhaps by failing it.

    The default queue only expects to receive IOCTLs from user mode (via the
    interface defined by GUID_DEVINTERFACE_USB_HOST_CONTROLLER).

Arguments:

    WdfQueue - A handle to the framework I/O queue object.

    WdfRequest - A handle to the framework request object that contains the IOCTL.

    OutputBufferLength - Length of the IOCTL output buffer, if an output buffer
        is available.

    InputBufferLength - Length of the IOCTL input buffer, if an input buffer
        is available.

    IoControlCode - I/O control code associated with the request.

Return Value:

    None.

--*/
{
    KPROCESSOR_MODE requestorMode;

    //
    // Allow UCX to try and handle the request
    //
    if (UcxIoDeviceControl(WdfIoQueueGetDevice(WdfQueue),
                           WdfRequest,
                           OutputBufferLength,
                           InputBufferLength,
                           IoControlCode)) {
        DbgTrace(TL_VERBOSE, Controller, "IoControlCode 0x%x was handled by UCX", IoControlCode);
        goto WdfEvtIoDeviceControlEnd;
    }

    //
    // Check that the request is coming from user mode
    //
    requestorMode = WdfRequestGetRequestorMode(WdfRequest);

    if (requestorMode != UserMode) {
        DbgTrace(TL_WARNING, Controller, "Invalid RequestorMode %d", requestorMode);
    }

    //
    // UCX could not handle the request, so handle it here
    //
    switch (IoControlCode) {

    default:
        DbgTrace(TL_WARNING, Controller, "Unsupported IoControlCode 0x%x", IoControlCode);
        WdfRequestComplete(WdfRequest, STATUS_INVALID_DEVICE_REQUEST);
    }

WdfEvtIoDeviceControlEnd:

    return;
}

要求

要求 價值
最低支援的用戶端 Windows 10
目標平臺 窗戶
標頭 ucxcontroller.h (include Ucxclass.h)
IRQL <=DISPATCH_LEVEL

另請參閱

適用於USB User-Mode IOCTL