Esempio n. 1
0
_Use_decl_annotations_
VOID
ToastMon_EvtDeviceContextCleanup(
    WDFOBJECT Device
    )
/*++

Routine Description:

   EvtDeviceContextCleanup event callback must perform any operations that are
   necessary before the specified device is removed. The framework calls
   the driver's EvtDeviceRemove callback when the PnP manager sends
   an IRP_MN_REMOVE_DEVICE request to the driver stack. Function driver
   typically undo whatever they did in EvtDeviceAdd callback - free
   structures, cleanup collections, etc.

Arguments:

    Device - Handle to a framework device object.

Return Value:

    VOID

--*/
{
    PDEVICE_EXTENSION           deviceExtension;

    KdPrint( ("ToastMon_EvtDeviceContextCleanup\n"));

    PAGED_CODE();

    deviceExtension = GetDeviceExtension((WDFDEVICE)Device);

    //
    // Unregister the interface notification
    //
    if(deviceExtension->NotificationHandle) {
        IoUnregisterPlugPlayNotification(deviceExtension->NotificationHandle);
    }

    //
    // TargetDeviceCollection will get deleted automatically when
    // the Device is deleted due to the association we made when
    // we created the object in EvtDeviceAdd.
    //
    // Any targets remaining in the collection will also be automaticaly closed
    // and deleted.
    //
    deviceExtension->TargetDeviceCollection = NULL;

    UnregisterForWMINotification(deviceExtension);

    return;
}
Esempio n. 2
0
File: device.c Progetto: MHesham/bsp
/*++

Routine Description:

     EvtDeviceReleaseHardware for Vchiq.

Arguments:

     Device - A handle to a framework device object.

     ResourcesTranslated - A handle to a resource list object that identifies
          the translated hardware resources that the Plug and Play manager has
          assigned to the device.

Return Value:

     NTSTATUS value

--*/
_Use_decl_annotations_
NTSTATUS VchiqReleaseHardware (
    WDFDEVICE Device,
    WDFCMRESLIST ResourcesTranslated
    )
{
    NTSTATUS status;
    DEVICE_CONTEXT* deviceContextPtr;

    UNREFERENCED_PARAMETER(ResourcesTranslated);

    PAGED_CODE();

    deviceContextPtr = VchiqGetDeviceContext(Device);


    if (deviceContextPtr->VchiqRegisterPtr != NULL) {
        MmUnmapIoSpace(deviceContextPtr->VchiqRegisterPtr,
            deviceContextPtr->VchiqRegisterLength);
        deviceContextPtr->VchiqRegisterPtr = NULL;
    }

    status = VchiqRelease(deviceContextPtr);
    if (!NT_SUCCESS(status)) {
        VCHIQ_LOG_ERROR("Fail to release VCHIQ resource %!STATUS!", status);
    }

    if (deviceContextPtr->RpiqNotificationHandle != NULL) {

        status = IoUnregisterPlugPlayNotification(
            deviceContextPtr->RpiqNotificationHandle);
        if (!NT_SUCCESS(status)) {
            VCHIQ_LOG_ERROR(
                "Rpiq interface notification deregistration fails %!STATUS!",
                status);
        }

        deviceContextPtr->RpiqNotificationHandle = NULL;
    }

    NT_ASSERT(deviceContextPtr->AllocPhyMemCount == 0);

    return STATUS_SUCCESS;
}
Esempio n. 3
0
static
VOID
Test_IoRegisterPlugPlayNotification(VOID)
{
    NTSTATUS Status;
    PVOID NotificationEntry;

    Status = IoRegisterPlugPlayNotification(EventCategoryDeviceInterfaceChange,
                                            PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES,
                                            (PVOID)&GUID_DEVICE_SYS_BUTTON,
                                            KmtDriverObject,
                                            NotificationCallback,
                                            &NotificationContext,
                                            &NotificationEntry);
    ok_eq_hex(Status, STATUS_SUCCESS);
    if (!skip(NT_SUCCESS(Status), "PlugPlayNotification not registered\n"))
    {
        Status = IoUnregisterPlugPlayNotification(NotificationEntry);
        ok_eq_hex(Status, STATUS_SUCCESS);
    }
}
Esempio n. 4
0
NTSTATUS
NTAPI
WdmAudClose(
    IN  PDEVICE_OBJECT DeviceObject,
    IN  PIRP Irp)
{
    /* nothing to do complete request */
#if KS_IMPLEMENTED
    Status = KsDereferenceSoftwareBusObject(DeviceExtension->DeviceHeader);

    if (NT_SUCCESS(Status))
    {
        if (DeviceExtension->SysAudioNotification)
            Status = IoUnregisterPlugPlayNotification(DeviceExtension->SysAudioNotification);
    }
#endif

    Irp->IoStatus.Status = STATUS_SUCCESS;
    Irp->IoStatus.Information = 0;
    IoCompleteRequest(Irp, IO_NO_INCREMENT);

    /* done */
    return STATUS_SUCCESS;
}