Share via


Función UcxIoDeviceControl (ucxcontroller.h)

Permite que la extensión del controlador de host USB (UCX) controle una solicitud de código de control de E/S (IOCTL) desde el modo de usuario.

Sintaxis

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

Parámetros

[in] Device

Identificador del objeto de dispositivo de marco que el controlador cliente recuperó en la llamada anterior a WdfDeviceCreate.

[in] Request

Identificador de un objeto de solicitud de marco que representa la solicitud IOCTL en modo de usuario.

[in] OutputBufferLength

Longitud, en bytes, del búfer de salida de la solicitud, si hay disponible un búfer de salida.

[in] InputBufferLength

Longitud, en bytes, del búfer de entrada de la solicitud, si hay disponible un búfer de entrada.

[in] IoControlCode

IOCTL definido por el controlador o definido por el sistema que está asociado a la solicitud.

Valor devuelto

Si la operación se realiza correctamente, el método devuelve TRUE. De lo contrario, devuelve FALSE.

Comentarios

El controlador cliente puede llamar a este método para permitir que UCX controle las ICTLs enumeradas en esta tabla: IOCTLs de modo de usuario para USB. Si el código IOCTL es IOCTL_USB_DIAGNOSTIC_MODE_OFF o IOCTL_USB_DIAGNOSTIC_MODE_ON, UCX completa la solicitud correctamente. En el caso de IOCTLS que se usan para recuperar el nombre de clave del controlador de controladores de host USB, como IOCTL_USB_GET_ROOT_HUB_NAME o IOCTL_GET_HCD_DRIVERKEY_NAME, UCX recupera la cadena Unicode. Si el IOCTL del modo de usuario es IOCTL_USB_USER_REQUEST, las longitudes del búfer de entrada y salida deben ser iguales y el búfer de salida debe contener la estructura USBUSER_REQUEST_HEADER . En el caso de los ICTLs restantes, UCX devuelve FALSE y el controlador de cliente puede proporcionar su propia lógica de control.

Ejemplos

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;
}

Requisitos

Requisito Value
Cliente mínimo compatible Windows 10
Plataforma de destino Windows
Encabezado ucxcontroller.h (incluya Ucxclass.h)
IRQL <=DISPATCH_LEVEL

Consulte también

IOCTLs en modo de usuario para USB