/* INCLUDES ******************************************************************/
-#include "initguid.h"
#include <ntoskrnl.h>
#define NDEBUG
#include <debug.h>
PREQUEST_POWER_COMPLETE CompletionRoutine;
POWER_STATE PowerState;
PVOID Context;
+ PDEVICE_OBJECT TopDeviceObject;
} REQUEST_POWER_ITEM, *PREQUEST_POWER_ITEM;
typedef struct _POWER_STATE_TRAVERSE_CONTEXT
RequestPowerItem->Context,
&Irp->IoStatus);
- ExFreePool(Context);
-
IoFreeIrp(Irp);
+ ObDereferenceObject(RequestPowerItem->TopDeviceObject);
+ ExFreePool(Context);
+
return STATUS_MORE_PROCESSING_REQUIRED;
}
PIO_STACK_LOCATION IrpSp;
PIRP Irp;
NTSTATUS Status;
-
+
KeInitializeEvent(&Event,
NotificationEvent,
FALSE);
-
+
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_POWER,
DeviceObject,
NULL,
NULL,
&Event,
&IoStatusBlock);
-
+ if (!Irp) return STATUS_INSUFFICIENT_RESOURCES;
+
IrpSp = IoGetNextIrpStackLocation(Irp);
IrpSp->MinorFunction = IRP_MN_QUERY_POWER;
IrpSp->Parameters.Power.Type = SystemPowerState;
IrpSp->Parameters.Power.State.SystemState = SystemState;
IrpSp->Parameters.Power.ShutdownType = PowerAction;
-
+
Status = PoCallDriver(DeviceObject, Irp);
if (Status == STATUS_PENDING)
{
NULL);
Status = IoStatusBlock.Status;
}
-
+
return Status;
}
PIO_STACK_LOCATION IrpSp;
PIRP Irp;
NTSTATUS Status;
-
+
KeInitializeEvent(&Event,
NotificationEvent,
FALSE);
-
+
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_POWER,
DeviceObject,
NULL,
NULL,
&Event,
&IoStatusBlock);
-
+ if (!Irp) return STATUS_INSUFFICIENT_RESOURCES;
+
IrpSp = IoGetNextIrpStackLocation(Irp);
IrpSp->MinorFunction = IRP_MN_SET_POWER;
IrpSp->Parameters.Power.Type = SystemPowerState;
IrpSp->Parameters.Power.State.SystemState = SystemState;
IrpSp->Parameters.Power.ShutdownType = PowerAction;
-
+
Status = PoCallDriver(DeviceObject, Irp);
if (Status == STATUS_PENDING)
{
NULL);
Status = IoStatusBlock.Status;
}
-
+
return Status;
}
/* Initialize support for dope */
KeInitializeSpinLock(&PopDopeGlobalLock);
+
+ /* Initialize support for shutdown waits and work-items */
+ PopInitShutdownList();
+
return TRUE;
}
BugCheckParameter4);
}
-/*
- * @unimplemented
- */
-NTSTATUS
-NTAPI
-PoRequestShutdownEvent(OUT PVOID *Event)
-{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
-}
-
/*
* @unimplemented
*/
NULL);
if (!Irp)
{
+ ObDereferenceObject(TopDeviceObject);
ExFreePool(RequestPowerItem);
return STATUS_INSUFFICIENT_RESOURCES;
}
RequestPowerItem->CompletionRoutine = CompletionFunction;
RequestPowerItem->PowerState = PowerState;
RequestPowerItem->Context = Context;
+ RequestPowerItem->TopDeviceObject = TopDeviceObject;
if (pIrp != NULL)
*pIrp = Irp;
UNIMPLEMENTED;
}
-/*
- * @unimplemented
- */
-NTSTATUS
-NTAPI
-PoQueueShutdownWorkItem(IN PWORK_QUEUE_ITEM WorkItem)
-{
- PAGED_CODE();
-
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
-}
-
/*
* @unimplemented
*/
PAGED_CODE();
- DPRINT("NtPowerInformation(PowerInformationLevel 0x%x, InputBuffer 0x%x, "
- "InputBufferLength 0x%x, OutputBuffer 0x%x, OutputBufferLength 0x%x)\n",
+ DPRINT("NtPowerInformation(PowerInformationLevel 0x%x, InputBuffer 0x%p, "
+ "InputBufferLength 0x%x, OutputBuffer 0x%p, OutputBufferLength 0x%x)\n",
PowerInformationLevel,
InputBuffer, InputBufferLength,
OutputBuffer, OutputBufferLength);
{
/* Not granted */
DPRINT1("ERROR: Privilege not held for shutdown\n");
- //return STATUS_PRIVILEGE_NOT_HELD; HACK!
+ return STATUS_PRIVILEGE_NOT_HELD;
}
/* Do it as a kernel-mode caller for consistency with system state */
#endif
/* Flush all volumes and the registry */
- DPRINT1("Flushing volumes, cache flushed %d pages\n", Dummy);
+ DPRINT1("Flushing volumes, cache flushed %lu pages\n", Dummy);
PopFlushVolumes(PopAction.Shutdown);
/* Set IRP for drivers */
}
/* You should not have made it this far */
- ASSERT(FALSE && "System is still up and running?!");
+ ASSERTMSG("System is still up and running?!", FALSE);
break;
}