VOID ToastMon_EvtIoTargetRemoveCanceled( WDFIOTARGET IoTarget ) /*++ Routine Description: Called when the Target device received IRP_MN_CANCEL_REMOVE. This happens if another app or driver talking to the target device doesn't close handle or veto query-remove notification. Arguments: IoTarget - Return Value: --*/ { PTARGET_DEVICE_INFO targetDeviceInfo = NULL; WDF_IO_TARGET_OPEN_PARAMS openParams; NTSTATUS status; PAGED_CODE(); KdPrint((("Device Removal (remove cancelled) Notification\n"))); targetDeviceInfo = GetTargetDeviceInfo(IoTarget); // // Reopen the Target. // WDF_IO_TARGET_OPEN_PARAMS_INIT_REOPEN(&openParams); status = WdfIoTargetOpen(IoTarget, &openParams); if (!NT_SUCCESS(status)) { KdPrint(("WdfIoTargetOpen failed 0x%x\n", status)); WdfObjectDelete(IoTarget); return; } // // Restart the timer. // WdfTimerStart(targetDeviceInfo->TimerForPostingRequests, WDF_REL_TIMEOUT_IN_SEC(1)); }
VOID ToastMon_EvtIoTargetRemoveCanceled( WDFIOTARGET IoTarget ) /*++ Routine Description: Called when the Target device received IRP_MN_CANCEL_REMOVE. This happens if another app or driver talking to the target device doesn't close handle or veto query-remove notification. Arguments: IoTarget - Return Value: --*/ { PTARGET_DEVICE_INFO targetDeviceInfo = NULL; WDFWAITLOCK targetDeviceCollectionLock; WDF_IO_TARGET_OPEN_PARAMS openParams; NTSTATUS status; PAGED_CODE(); KdPrint((("Device Removal (remove cancelled) Notification\n"))); targetDeviceInfo = GetTargetDeviceInfo(IoTarget); // // Reopen the Target. // WDF_IO_TARGET_OPEN_PARAMS_INIT_REOPEN(&openParams); status = WdfIoTargetOpen(IoTarget, &openParams); if (!NT_SUCCESS(status)) { KdPrint(("WdfIoTargetOpen failed 0x%x\n", status)); WdfObjectDelete(IoTarget); return; } targetDeviceCollectionLock = targetDeviceInfo->DeviceExtension->TargetDeviceCollectionLock; // // The query remove has failed and the target has been successfully reopened. Set Opened // back to TRUE to reflect the state change. // WdfWaitLockAcquire(targetDeviceCollectionLock, NULL); targetDeviceInfo->Opened = TRUE; WdfWaitLockRelease(targetDeviceCollectionLock); // // Restart the timer. // WdfTimerStart(targetDeviceInfo->TimerForPostingRequests, WDF_REL_TIMEOUT_IN_SEC(1)); }