UfxEndpointCreate-Funktion (ufxclient.h)

Erstellt ein Endpunktobjekt.

Syntax

NTSTATUS UfxEndpointCreate(
  [in]           UFXDEVICE              UfxDevice,
  [in, out]      PUFXENDPOINT_INIT      EndpointInit,
  [in, optional] PWDF_OBJECT_ATTRIBUTES Attributes,
  [in]           PWDF_IO_QUEUE_CONFIG   TransferQueueConfig,
  [in, optional] PWDF_OBJECT_ATTRIBUTES TransferQueueAttributes,
  [in]           PWDF_IO_QUEUE_CONFIG   CommandQueueConfig,
  [in, optional] PWDF_OBJECT_ATTRIBUTES CommandQueueAttributes,
  [out]          UFXENDPOINT            *UfxEndpoint
);

Parameter

[in] UfxDevice

Ein Handle für ein UFX-Geräteobjekt, das der Treiber durch Aufrufen von UfxDeviceCreate erstellt hat.

[in, out] EndpointInit

Undurchsichtige Struktur, die von UFX im Aufruf von EVT_UFX_DEVICE_ENDPOINT_ADD oder EVT_UFX_DEVICE_DEFAULT_ENDPOINT_ADD übergeben wird.

[in, optional] Attributes

Ein Zeiger auf die vom Aufrufer zugewiesene WDF_OBJECT_ATTRIBUTES-Struktur . Diese Struktur muss mit WDF_OBJECT_ATTRIBUTES_INIT oder WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE initialisiert werden. Dieser Parameter ist optional und kann WDF_NO_OBJECT_ATTRIBUTES werden.

[in] TransferQueueConfig

Ein Zeiger auf einen Aufrufer , der WDF_IO_QUEUE_CONFIG Struktur zugeordnet ist. Diese Struktur muss mit WDF_IO_QUEUE_CONFIG_INIT initialisiert werden.

[in, optional] TransferQueueAttributes

Ein Zeiger auf die vom Aufrufer zugewiesene WDF_OBJECT_ATTRIBUTES-Struktur . Diese Struktur muss mit WDF_OBJECT_ATTRIBUTES_INIT oder WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE initialisiert werden. Dieser Parameter ist optional und kann WDF_NO_OBJECT_ATTRIBUTES werden.

[in] CommandQueueConfig

Ein Zeiger auf einen Aufrufer , der WDF_IO_QUEUE_CONFIG Struktur zugeordnet ist. Diese Struktur muss mit WDF_IO_QUEUE_CONFIG_INIT initialisiert werden.

[in, optional] CommandQueueAttributes

Ein Zeiger auf die vom Aufrufer zugewiesene WDF_OBJECT_ATTRIBUTES-Struktur . Diese Struktur muss mit WDF_OBJECT_ATTRIBUTES_INIT oder WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE initialisiert werden. Dieser Parameter ist optional und kann WDF_NO_OBJECT_ATTRIBUTES werden.

[out] UfxEndpoint

Ein Zeiger auf eine Position, die ein Handle für ein UFXENDPOINT-Objekt empfängt.

Rückgabewert

Wenn der Vorgang erfolgreich ist, gibt die Methode STATUS_SUCCESS oder einen anderen status Wert zurück, für den NT_SUCCESS(status) gleich TRUE ist. Andernfalls wird ein status Wert zurückgegeben, für den NT_SUCCESS(status) gleich FALSE ist.

Hinweise

Die Übertragungswarteschlange verarbeitet die folgenden IOCTLs im Zusammenhang mit Endpunktübertragungen:

Die Befehlswarteschlange verarbeitet die folgenden IOCTLs:

Das folgende Beispiel zeigt, wie Sie ein UFXENDPOINT-Objekt erstellen und dessen Kontext initialisieren.
NTSTATUS
UfxEndpointAdd (
    _In_ UFXDEVICE Device,
    _In_ PUSB_ENDPOINT_DESCRIPTOR Descriptor,
    _Inout_ PUFXENDPOINT_INIT EndpointInit
    )
/*++
Routine Description:

    Creates a UFXENDPOINT object, and initializes its contexts.

Parameters Description:

    Device - UFXDEVICE associated with the endpoint.

    Descriptor - Endpoint descriptor for this endpoint.

    EndpointInit - Opaque structure from UFX.

Return Value:

    STATUS_SUCCESS if successful, appropriate NTSTATUS message otherwise.
--*/
{
    NTSTATUS Status;
    WDF_OBJECT_ATTRIBUTES Attributes;
    WDF_IO_QUEUE_CONFIG TransferQueueConfig;
    WDF_OBJECT_ATTRIBUTES TransferQueueAttributes;
    WDF_IO_QUEUE_CONFIG CommandQueueConfig;
    WDF_OBJECT_ATTRIBUTES CommandQueueAttributes;
    UFXENDPOINT Endpoint;
    PUFXENDPOINT_CONTEXT EpContext;
    PUFXDEVICE_CONTEXT DeviceContext;
    UFX_ENDPOINT_CALLBACKS Callbacks;
    PENDPOINT_QUEUE_CONTEXT QueueContext;
    WDFQUEUE Queue;

    TraceEntry();

    DeviceContext = UfxDeviceGetContext(Device);

    WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&Attributes, UFXENDPOINT_CONTEXT);
    Attributes.ExecutionLevel = WdfExecutionLevelPassive;
    Attributes.EvtCleanupCallback = UfxEndpoint_Cleanup;

    //
    // Note: Execution level needs to be passive to avoid deadlocks with WdfRequestComplete.
    //
    WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&TransferQueueAttributes, ENDPOINT_QUEUE_CONTEXT);
    TransferQueueAttributes.ExecutionLevel = WdfExecutionLevelPassive;
    
    WDF_IO_QUEUE_CONFIG_INIT(&TransferQueueConfig, WdfIoQueueDispatchManual);
    TransferQueueConfig.AllowZeroLengthRequests = TRUE;
    TransferQueueConfig.EvtIoStop = EndpointQueue_EvtIoStop;

    WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&CommandQueueAttributes, ENDPOINT_QUEUE_CONTEXT);
    CommandQueueAttributes.ExecutionLevel = WdfExecutionLevelPassive;

    WDF_IO_QUEUE_CONFIG_INIT(&CommandQueueConfig, WdfIoQueueDispatchSequential);
    CommandQueueConfig.EvtIoInternalDeviceControl = EvtEndpointCommandQueue;

    UFX_ENDPOINT_CALLBACKS_INIT(&Callbacks);
    UfxEndpointInitSetEventCallbacks(EndpointInit, &Callbacks);

    Status = UfxEndpointCreate(
                 Device,
                 EndpointInit,
                 &Attributes,
                 &TransferQueueConfig,
                 &TransferQueueAttributes,
                 &CommandQueueConfig,
                 &CommandQueueAttributes,
                 &Endpoint);
    CHK_NT_MSG(Status, "Failed to create ufxendpoint!");

    Status = WdfCollectionAdd(DeviceContext->Endpoints, Endpoint);
    CHK_NT_MSG(Status, "Failed to add endpoint to collection!");

    EpContext = UfxEndpointGetContext(Endpoint);
    EpContext->UfxDevice = Device;
    EpContext->WdfDevice = DeviceContext->FdoWdfDevice;
    RtlCopyMemory(&EpContext->Descriptor, Descriptor, sizeof(*Descriptor));

    Queue = UfxEndpointGetTransferQueue(Endpoint);
    QueueContext = EndpointQueueGetContext(Queue);
    QueueContext->Endpoint = Endpoint;

    Queue = UfxEndpointGetCommandQueue(Endpoint);
    QueueContext = EndpointQueueGetContext(Queue);
    QueueContext->Endpoint = Endpoint;

    Status = TransferInitialize(Endpoint);
    CHK_NT_MSG(Status, "Failed to initialize endpoint transfers");
    
    //
    // This can happen if we're handling a SetInterface command.
    //
    if (DeviceContext->UsbState == UsbfnDeviceStateConfigured) {
        UfxEndpointConfigure(Endpoint);
    }

    Status = WdfIoQueueReadyNotify(
                 UfxEndpointGetTransferQueue(Endpoint),
                 TransferReadyNotify,
                 Endpoint);
    CHK_NT_MSG(Status, "Failed to register ready notify");

End:
    TraceExit();
    return Status;
}

Anforderungen

Anforderung Wert
Unterstützte Mindestversion (Client) Windows 10
Zielplattform Windows
Kopfzeile ufxclient.h
Bibliothek ufxstub.lib
IRQL PASSIVE_LEVEL