VBoxGuest-win-pnp.cpp revision 8ad79874169cc981a694a15e8a806b9a39133673
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * VBoxGuest-win-pnp - Windows Plug'n'Play specifics.
c7814cf6e1240a519cbec0441e033d0e2470ed00vboxsync * Copyright (C) 2010-2011 Oracle Corporation
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * available from http://www.virtualbox.org. This file is free software;
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * you can redistribute it and/or modify it under the terms of the GNU
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * General Public License (GPL) as published by the Free Software
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
b2640405e06105d868b5fc8f7b676bb680884380vboxsync/*******************************************************************************
b2640405e06105d868b5fc8f7b676bb680884380vboxsync* Header Files *
b2640405e06105d868b5fc8f7b676bb680884380vboxsync*******************************************************************************/
b2640405e06105d868b5fc8f7b676bb680884380vboxsync/*******************************************************************************
b2640405e06105d868b5fc8f7b676bb680884380vboxsync* Defined Constants And Macros *
b2640405e06105d868b5fc8f7b676bb680884380vboxsync*******************************************************************************/
8ad79874169cc981a694a15e8a806b9a39133673vboxsyncstatic NTSTATUS vbgdNtSendIrpSynchronously(PDEVICE_OBJECT pDevObj, PIRP pIrp, BOOLEAN fStrict);
8ad79874169cc981a694a15e8a806b9a39133673vboxsyncstatic NTSTATUS vbgdNtPnPIrpComplete(PDEVICE_OBJECT pDevObj, PIRP pIrp, PKEVENT pEvent);
8ad79874169cc981a694a15e8a806b9a39133673vboxsyncstatic VOID vbgdNtShowDeviceResources(PCM_PARTIAL_RESOURCE_LIST pResourceList);
8ad79874169cc981a694a15e8a806b9a39133673vboxsync#pragma alloc_text (PAGE, vbgdNtSendIrpSynchronously)
8ad79874169cc981a694a15e8a806b9a39133673vboxsync#pragma alloc_text (PAGE, vbgdNtShowDeviceResources)
b2640405e06105d868b5fc8f7b676bb680884380vboxsync/* Reenable logging, this was #undef'ed on iprt/log.h for RING0. */
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * Irp completion routine for PnP Irps we send.
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * @param pDevObj Device object.
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * @param pIrp Request packet.
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * @param event Semaphore.
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * @return NT status code
8ad79874169cc981a694a15e8a806b9a39133673vboxsyncstatic NTSTATUS vbgdNtPnpIrpComplete(PDEVICE_OBJECT pDevObj, PIRP pIrp, PKEVENT pEvent)
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * Helper to send a PnP IRP and wait until it's done.
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * @param pDevObj Device object.
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * @param pIrp Request packet.
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * @param fStrict When set, returns an error if the IRP gives an error.
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * @return NT status code
8ad79874169cc981a694a15e8a806b9a39133673vboxsyncstatic NTSTATUS vbgdNtSendIrpSynchronously(PDEVICE_OBJECT pDevObj, PIRP pIrp, BOOLEAN fStrict)
b2640405e06105d868b5fc8f7b676bb680884380vboxsync KeInitializeEvent(&event, SynchronizationEvent, FALSE);
8ad79874169cc981a694a15e8a806b9a39133673vboxsync IoSetCompletionRoutine(pIrp, (PIO_COMPLETION_ROUTINE)vbgdNtPnpIrpComplete,
b2640405e06105d868b5fc8f7b676bb680884380vboxsync KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync && (rc == STATUS_NOT_SUPPORTED || rc == STATUS_INVALID_DEVICE_REQUEST))
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtSendIrpSynchronously: Returning 0x%x\n", rc));
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * PnP Request handler.
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * @param pDevObj Device object.
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * @param pIrp Request packet.
8ad79874169cc981a694a15e8a806b9a39133673vboxsyncNTSTATUS vbgdNtPnP(PDEVICE_OBJECT pDevObj, PIRP pIrp)
b2640405e06105d868b5fc8f7b676bb680884380vboxsync PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)pDevObj->DeviceExtension;
b2640405e06105d868b5fc8f7b676bb680884380vboxsync PIO_STACK_LOCATION pStack = IoGetCurrentIrpStackLocation(pIrp);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync static char* aszFnctName[] =
b2640405e06105d868b5fc8f7b676bb680884380vboxsync "IRP_MN_START_DEVICE",
b2640405e06105d868b5fc8f7b676bb680884380vboxsync "IRP_MN_QUERY_REMOVE_DEVICE",
b2640405e06105d868b5fc8f7b676bb680884380vboxsync "IRP_MN_REMOVE_DEVICE",
b2640405e06105d868b5fc8f7b676bb680884380vboxsync "IRP_MN_CANCEL_REMOVE_DEVICE",
b2640405e06105d868b5fc8f7b676bb680884380vboxsync "IRP_MN_STOP_DEVICE",
b2640405e06105d868b5fc8f7b676bb680884380vboxsync "IRP_MN_QUERY_STOP_DEVICE",
b2640405e06105d868b5fc8f7b676bb680884380vboxsync "IRP_MN_CANCEL_STOP_DEVICE",
b2640405e06105d868b5fc8f7b676bb680884380vboxsync "IRP_MN_QUERY_DEVICE_RELATIONS",
b2640405e06105d868b5fc8f7b676bb680884380vboxsync "IRP_MN_QUERY_INTERFACE",
b2640405e06105d868b5fc8f7b676bb680884380vboxsync "IRP_MN_QUERY_CAPABILITIES",
b2640405e06105d868b5fc8f7b676bb680884380vboxsync "IRP_MN_QUERY_RESOURCES",
b2640405e06105d868b5fc8f7b676bb680884380vboxsync "IRP_MN_QUERY_RESOURCE_REQUIREMENTS",
b2640405e06105d868b5fc8f7b676bb680884380vboxsync "IRP_MN_QUERY_DEVICE_TEXT",
b2640405e06105d868b5fc8f7b676bb680884380vboxsync "IRP_MN_FILTER_RESOURCE_REQUIREMENTS",
b2640405e06105d868b5fc8f7b676bb680884380vboxsync "IRP_MN_READ_CONFIG",
b2640405e06105d868b5fc8f7b676bb680884380vboxsync "IRP_MN_WRITE_CONFIG",
b2640405e06105d868b5fc8f7b676bb680884380vboxsync "IRP_MN_EJECT",
b2640405e06105d868b5fc8f7b676bb680884380vboxsync "IRP_MN_SET_LOCK",
b2640405e06105d868b5fc8f7b676bb680884380vboxsync "IRP_MN_QUERY_ID",
b2640405e06105d868b5fc8f7b676bb680884380vboxsync "IRP_MN_QUERY_PNP_DEVICE_STATE",
b2640405e06105d868b5fc8f7b676bb680884380vboxsync "IRP_MN_QUERY_BUS_INFORMATION",
b2640405e06105d868b5fc8f7b676bb680884380vboxsync "IRP_MN_DEVICE_USAGE_NOTIFICATION",
b2640405e06105d868b5fc8f7b676bb680884380vboxsync "IRP_MN_SURPRISE_REMOVAL",
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtGuestPnp: MinorFunction: %s\n",
b2640405e06105d868b5fc8f7b676bb680884380vboxsync pStack->MinorFunction < (sizeof(aszFnctName) / sizeof(aszFnctName[0]))
b2640405e06105d868b5fc8f7b676bb680884380vboxsync : "Unknown"));
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtVBoxGuestPnP: START_DEVICE\n"));
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync /* This must be handled first by the lower driver. */
8ad79874169cc981a694a15e8a806b9a39133673vboxsync rc = vbgdNtSendIrpSynchronously(pDevExt->win.s.pNextLowerDriver, pIrp, TRUE);
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtVBoxGuestPnP: START_DEVICE: pStack->Parameters.StartDevice.AllocatedResources = %p\n",
b2640405e06105d868b5fc8f7b676bb680884380vboxsync pStack->Parameters.StartDevice.AllocatedResources));
b2640405e06105d868b5fc8f7b676bb680884380vboxsync if (!pStack->Parameters.StartDevice.AllocatedResources)
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtVBoxGuestPnP: START_DEVICE: No resources, pDevExt = %p, nextLowerDriver = %p!\n",
b2640405e06105d868b5fc8f7b676bb680884380vboxsync pDevExt, pDevExt ? pDevExt->win.s.pNextLowerDriver : NULL));
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtGuestPnp: START_DEVICE: Error: rc = 0x%x\n", rc));
b2640405e06105d868b5fc8f7b676bb680884380vboxsync /* Need to unmap memory in case of errors ... */
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtVBoxGuestPnP: CANCEL_REMOVE_DEVICE\n"));
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync /* This must be handled first by the lower driver. */
8ad79874169cc981a694a15e8a806b9a39133673vboxsync rc = vbgdNtSendIrpSynchronously(pDevExt->win.s.pNextLowerDriver, pIrp, TRUE);
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync if (NT_SUCCESS(rc) && pDevExt->win.s.devState == PENDINGREMOVE)
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync /* Return to the state prior to receiving the IRP_MN_QUERY_REMOVE_DEVICE request. */
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync pDevExt->win.s.devState = pDevExt->win.s.prevDevState;
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync /* Complete the IRP. */
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtVBoxGuestPnP: IRP_MN_SURPRISE_REMOVAL\n"));
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync VBOXGUEST_UPDATE_DEVSTATE(pDevExt, SURPRISEREMOVED);
b0a3d0ec5780199a2f379da63c59ccf48f1a73b9vboxsync /* Do nothing here actually. Cleanup is done in IRP_MN_REMOVE_DEVICE.
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync * This request is not expected for VBoxGuest.
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync LogRel(("VBoxGuest: unexpected device removal\n"));
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync /* Pass to the lower driver. */
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync rc = IoCallDriver(pDevExt->win.s.pNextLowerDriver, pIrp);
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync /* Do not complete the IRP. */
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtVBoxGuestPnP: QUERY_REMOVE_DEVICE\n"));
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtGuestPnp: QUERY_REMOVE_DEVICE: Device cannot be removed without a reboot.\n"));
b2640405e06105d868b5fc8f7b676bb680884380vboxsync#endif /* VBOX_REBOOT_ON_UNINSTALL */
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync /* This IRP passed down to lower driver. */
3383321ffc6907012f92f16b26b026908de7fe7fvboxsync rc = IoCallDriver(pDevExt->win.s.pNextLowerDriver, pIrp);
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtGuestPnp: QUERY_REMOVE_DEVICE: Next lower driver replied rc = 0x%x\n", rc));
69dc1a8b612032236f9f04033e7c53ce7a478f17vboxsync /* we must not do anything the IRP after doing IoSkip & CallDriver
485e602154df33e5466e0dcca16d8f97914ce41dvboxsync * since the driver below us will complete (or already have completed) the IRP.
485e602154df33e5466e0dcca16d8f97914ce41dvboxsync * I.e. just return the status we got from IoCallDriver */
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync /* Complete the IRP on failure. */
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtVBoxGuestPnP: REMOVE_DEVICE\n"));
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync /* Free hardware resources. */
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync /* @todo this should actually free I/O ports, interrupts, etc. */
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtGuestPnp: REMOVE_DEVICE: vbgdNtCleanup rc = 0x%08X\n", rc));
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync * We need to send the remove down the stack before we detach,
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync * but we don't need to wait for the completion of this operation
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync * (and to register a completion routine).
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync rc = IoCallDriver(pDevExt->win.s.pNextLowerDriver, pIrp);
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtGuestPnp: REMOVE_DEVICE: Next lower driver replied rc = 0x%x\n", rc));
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtGuestPnp: REMOVE_DEVICE: Removing device ...\n"));
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync /* Destroy device extension and clean up everything else. */
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync /* Remove DOS device + symbolic link. */
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync RtlInitUnicodeString(&win32Name, VBOXGUEST_DEVICE_NAME_DOS);
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtGuestPnp: REMOVE_DEVICE: Deleting device ...\n"));
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync /* Last action: Delete our device! pDevObj is *not* failed
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync * anymore after this call! */
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtGuestPnp: REMOVE_DEVICE: Device removed!\n"));
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync /* Propagating rc from IoCallDriver. */
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync return rc; /* Make sure that we don't do anything below here anymore! */
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtVBoxGuestPnP: CANCEL_STOP_DEVICE\n"));
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync /* This must be handled first by the lower driver. */
8ad79874169cc981a694a15e8a806b9a39133673vboxsync rc = vbgdNtSendIrpSynchronously(pDevExt->win.s.pNextLowerDriver, pIrp, TRUE);
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync if (NT_SUCCESS(rc) && pDevExt->win.s.devState == PENDINGSTOP)
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync /* Return to the state prior to receiving the IRP_MN_QUERY_STOP_DEVICE request. */
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync pDevExt->win.s.devState = pDevExt->win.s.prevDevState;
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync /* Complete the IRP. */
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtVBoxGuestPnP: QUERY_STOP_DEVICE\n"));
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtGuestPnp: QUERY_STOP_DEVICE: Device cannot be stopped without a reboot!\n"));
b2640405e06105d868b5fc8f7b676bb680884380vboxsync#endif /* VBOX_REBOOT_ON_UNINSTALL */
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync /* This IRP passed down to lower driver. */
3383321ffc6907012f92f16b26b026908de7fe7fvboxsync rc = IoCallDriver(pDevExt->win.s.pNextLowerDriver, pIrp);
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtGuestPnp: QUERY_STOP_DEVICE: Next lower driver replied rc = 0x%x\n", rc));
69dc1a8b612032236f9f04033e7c53ce7a478f17vboxsync /* we must not do anything with the IRP after doing IoSkip & CallDriver
485e602154df33e5466e0dcca16d8f97914ce41dvboxsync * since the driver below us will complete (or already have completed) the IRP.
485e602154df33e5466e0dcca16d8f97914ce41dvboxsync * I.e. just return the status we got from IoCallDriver */
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync /* Complete the IRP on failure. */
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtVBoxGuestPnP: STOP_DEVICE\n"));
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync /* Free hardware resources. */
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync /* @todo this should actually free I/O ports, interrupts, etc. */
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtGuestPnp: STOP_DEVICE: cleaning up, rc = 0x%x\n", rc));
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync /* Pass to the lower driver. */
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync rc = IoCallDriver(pDevExt->win.s.pNextLowerDriver, pIrp);
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtGuestPnp: STOP_DEVICE: Next lower driver replied rc = 0x%x\n", rc));
b2640405e06105d868b5fc8f7b676bb680884380vboxsync rc = IoCallDriver(pDevExt->win.s.pNextLowerDriver, pIrp);
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtGuestPnp: Returning with rc = 0x%x\n", rc));
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * Handle the power completion event.
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * @returns NT status code.
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * @param pDevObj Targetted device object.
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * @param pIrp IO request packet.
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * @param pContext Context value passed to IoSetCompletionRoutine in VBoxGuestPower.
8ad79874169cc981a694a15e8a806b9a39133673vboxsyncstatic NTSTATUS vbgdNtPowerComplete(IN PDEVICE_OBJECT pDevObj, IN PIRP pIrp, IN PVOID pContext)
b2640405e06105d868b5fc8f7b676bb680884380vboxsync PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)pContext;
b2640405e06105d868b5fc8f7b676bb680884380vboxsync ASSERT(pDevExt->signature == DEVICE_EXTENSION_SIGNATURE);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync switch (pIrpSp->Parameters.Power.State.DeviceState)
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * Handle the Power requests.
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * @returns NT status code
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * @param pDevObj device object
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * @param pIrp IRP
8ad79874169cc981a694a15e8a806b9a39133673vboxsyncNTSTATUS vbgdNtPower(PDEVICE_OBJECT pDevObj, PIRP pIrp)
b2640405e06105d868b5fc8f7b676bb680884380vboxsync PIO_STACK_LOCATION pStack = IoGetCurrentIrpStackLocation(pIrp);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)pDevObj->DeviceExtension;
b2640405e06105d868b5fc8f7b676bb680884380vboxsync powerAction = pStack->Parameters.Power.ShutdownType;
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtGuestPower: IRP_MN_SET_POWER, type= %d\n", powerType));
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtGuestPower: SystemPowerState, action = %d, state = %d\n", powerAction, powerState));
b2640405e06105d868b5fc8f7b676bb680884380vboxsync /* System now is in a working state. */
b2640405e06105d868b5fc8f7b676bb680884380vboxsync && pDevExt->win.s.LastSystemPowerAction == PowerActionHibernate)
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtGuestPower: Returning from hibernation!\n"));
8ad79874169cc981a694a15e8a806b9a39133673vboxsync int rc = VBoxGuestReinitDevExtAfterHibernation(pDevExt,
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtGuestPower: Cannot re-init VMMDev chain, rc = %d!\n", rc));
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtGuestPower: Power action reset!\n"));
b2640405e06105d868b5fc8f7b676bb680884380vboxsync /* Tell the VMM that we no longer support mouse pointer integration. */
083344b49cc7370da15d3cb7e3a9c9cb2d8dfbb0vboxsync int vrc = VbglGRAlloc((VMMDevRequestHeader **)&pReq, sizeof (VMMDevReqMouseStatus), VMMDevReq_SetMouseStatus);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync Log(("VBoxGuest::PowerStateRequest: error communicating new power status to VMMDev. "
ce95f18112057771f68abe58df709edd7c467db1vboxsync /* Don't do any cleanup here; there might be still coming in some IOCtls after we got this
ce95f18112057771f68abe58df709edd7c467db1vboxsync * power action and would assert/crash when we already cleaned up all the stuff! */
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtGuestPower: Power action shutdown!\n"));
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtGuestPower: Telling the VMMDev to close the VM ...\n"));
b2640405e06105d868b5fc8f7b676bb680884380vboxsync VMMDevPowerStateRequest *pReq = pDevExt->win.s.pPowerStateRequest;
b2640405e06105d868b5fc8f7b676bb680884380vboxsync pReq->header.requestType = VMMDevReq_SetPowerStatus;
b2640405e06105d868b5fc8f7b676bb680884380vboxsync Log(("VBoxGuest::PowerStateRequest: Error communicating new power status to VMMDev. "
083344b49cc7370da15d3cb7e3a9c9cb2d8dfbb0vboxsync /* No need to do cleanup here; at this point we should've been
083344b49cc7370da15d3cb7e3a9c9cb2d8dfbb0vboxsync * turned off by VMMDev already! */
8ad79874169cc981a694a15e8a806b9a39133673vboxsync Log(("VBoxGuest::vbgdNtGuestPower: Power action hibernate!\n"));
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * Save the current system power action for later use.
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * This becomes handy when we return from hibernation for example.
b2640405e06105d868b5fc8f7b676bb680884380vboxsync pDevExt->win.s.LastSystemPowerAction = powerAction;
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * Whether we are completing or relaying this power IRP,
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * we must call PoStartNextPowerIrp.
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * Send the IRP down the driver stack,
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * using PoCallDriver (not IoCallDriver, as for non-power irps).