WdfIoTargetClose function (wdfiotarget.h)

[Applies to KMDF and UMDF]

The WdfIoTargetClose method closes a specified remote I/O target.

Syntax

void WdfIoTargetClose(
  [in] WDFIOTARGET IoTarget
);

Parameters

[in] IoTarget

A handle to an I/O target object that was obtained from a previous call to WdfIoTargetCreate.

Return value

None

Remarks

A bug check occurs if the driver supplies an invalid object handle.

After a driver has called WdfIoTargetClose, it can call WdfIoTargetOpen to reopen the remote I/O target.

Drivers that supply an EvtIoTargetRemoveComplete callback function must call WdfIoTargetClose from within that callback function.

Before the WdfIoTargetClose method returns, the framework cancels all of the target queue's I/O requests.

If a driver has finished using a remote I/O target and will not use the target again, and the target has no child request objects that are still pending, the driver can call WdfObjectDelete without first calling WdfIoTargetClose. The call to WdfObjectDelete will close the remote I/O target, cancel all of the target queue's I/O requests, and delete the I/O target object. (Note that if the remote I/O target's parent object is a device object, the framework closes the target and deletes the target object when it deletes the parent object.) If the target has any child request objects that are still pending, the driver must call WdfIoTargetClose before it can safely call WdfObjectDelete.

For more information about WdfIoTargetClose, see Controlling a General I/O Target's State.

For more information about I/O targets, see Using I/O Targets.

Examples

The following code example is an EvtIoTargetRemoveComplete callback function that removes a specified I/O target from a driver's collection of I/O targets and then closes the I/O target.

VOID
MyEvtIoTargetRemoveComplete(
    WDFIOTARGET IoTarget
)
{
    //
    // Get device information from the I/O target object's
    // context space.
    //
    targetDeviceInfo = GetTargetDeviceInfo(IoTarget);
    deviceExtension = targetDeviceInfo->DeviceExtension;

    //
    // Remove the target device from the collection.
    //
    WdfWaitLockAcquire(
                       deviceExtension->TargetDeviceCollectionLock,
                       NULL
                       );

    WdfCollectionRemove(
                        deviceExtension->TargetDeviceCollection,
                        IoTarget
                        );

    WdfWaitLockRelease(deviceExtension->TargetDeviceCollectionLock);

    //
    // Close the target.
    //
    WdfIoTargetClose(IoTarget);
}

Requirements

Requirement Value
Target Platform Universal
Minimum KMDF version 1.0
Minimum UMDF version 2.0
Header wdfiotarget.h (include Wdf.h)
Library Wdf01000.sys (KMDF); WUDFx02000.dll (UMDF)
IRQL PASSIVE_LEVEL
DDI compliance rules DriverCreate(kmdf), KmdfIrql(kmdf), KmdfIrql2(kmdf), KmdfIrqlExplicit(kmdf)

See also

EvtIoTargetRemoveComplete

WdfIoTargetCreate