NTSTATUS BalloonEvtDeviceD0Exit( IN WDFDEVICE Device, IN WDF_POWER_DEVICE_STATE TargetState ) { PDEVICE_CONTEXT devCtx = GetDeviceContext(Device); UNREFERENCED_PARAMETER(TargetState); TraceEvents(TRACE_LEVEL_INFORMATION, DBG_INIT, "<--> %s\n", __FUNCTION__); PAGED_CODE(); if (devCtx->evLowMem) { ZwClose(devCtx->hLowMem); devCtx->evLowMem = NULL; } /* * interrupts were already disabled (between BalloonEvtDeviceD0ExitPreInterruptsDisabled and this call) * we should flush StatWorkItem before calling BalloonTerm which will delete virtio queues */ if (devCtx->StatWorkItem) { WdfWorkItemFlush(devCtx->StatWorkItem); devCtx->StatWorkItem = NULL; } BalloonTerm(Device); return STATUS_SUCCESS; }
NTSTATUS BalloonEvtDeviceD0Exit( IN WDFDEVICE Device, IN WDF_POWER_DEVICE_STATE TargetState ) { #if (WINVER >= 0x0501) PDEVICE_CONTEXT devCtx = GetDeviceContext(Device); #endif // (WINVER >= 0x0501) TraceEvents(TRACE_LEVEL_INFORMATION, DBG_INIT, "<--> %s\n", __FUNCTION__); PAGED_CODE(); #if (WINVER >= 0x0501) if (devCtx->evLowMem) { ZwClose(devCtx->hLowMem); devCtx->evLowMem = NULL; } #endif // (WINVER >= 0x0501) BalloonTerm(Device); return STATUS_SUCCESS; }
NTSTATUS BalloonEvtDeviceD0Entry( IN WDFDEVICE Device, IN WDF_POWER_DEVICE_STATE PreviousState ) { NTSTATUS status = STATUS_SUCCESS; PDEVICE_CONTEXT devCtx = GetDeviceContext(Device); UNREFERENCED_PARAMETER(PreviousState); TraceEvents(TRACE_LEVEL_INFORMATION, DBG_INIT, "--> %s\n", __FUNCTION__); status = BalloonInit(Device); if(!NT_SUCCESS(status)) { TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, "BalloonInit failed with status 0x%08x\n", status); BalloonTerm(Device); return status; } status = BalloonCreateWorkerThread(Device); if(!NT_SUCCESS(status)) { TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, "BalloonCreateWorkerThread failed with status 0x%08x\n", status); } devCtx->evLowMem = IoCreateNotificationEvent( (PUNICODE_STRING)&evLowMemString, &devCtx->hLowMem); return status; }