WdfIoTargetCloseForQueryRemove function (wdfiotarget.h)

[Applies to KMDF and UMDF]

The WdfIoTargetCloseForQueryRemove method temporarily closes a specified remote I/O target because the target device might soon be removed.

Syntax

void WdfIoTargetCloseForQueryRemove(
  WDFIOTARGET IoTarget
);

Parameters

IoTarget

[in] A handle to a remote 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.

Drivers that supply an EvtIoTargetQueryRemove callback function must call WdfIoTargetCloseForQueryRemove from within that callback function, if the driver determines that the target device can be safely removed.

For more information about WdfIoTargetCloseForQueryRemove, 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 the EvtIoTargetQueryRemove callback function from the Toaster sample driver. The function stops a timer, ensures that a previously submitted work item has been serviced, and then calls WdfIoTargetCloseForQueryRemove.

NTSTATUS
ToastMon_EvtIoTargetQueryRemove(
    WDFIOTARGET IoTarget
)
{
    PTARGET_DEVICE_INFO  targetDeviceInfo = NULL;

    //
    // Get I/O target object's context space.
    //
    targetDeviceInfo = GetTargetDeviceInfo(IoTarget);

    //
    // Stop the timer and wait for any outstanding work items
    // to finish before closing the target.
    //
    WdfTimerStop(targetDeviceInfo->TimerForPostingRequests, TRUE);
    WdfWorkItemFlush(targetDeviceInfo->WorkItemForPostingRequests);

    WdfIoTargetCloseForQueryRemove(IoTarget);

    return STATUS_SUCCESS;
}

Requirements

   
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, KmdfIrql, KmdfIrql2

See also

EvtIoTargetQueryRemove

WdfIoTargetCreate