|
NTSTATUS ntStatus;
PIO_STACK_LOCATION IrpStack, NextStack;
PDEVICE_EXTENSION pdx;
pdx = fdo->DeviceExtension;
Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = 0;
IrpStack = IoGetCurrentIrpStackLocation (Irp);
switch (IrpStack->MinorFunction) {
case IRP_MN_SET_POWER: //设置系统或设备电源状态
switch (IrpStack->Parameters.Power.Type) {
case SystemPowerState:
break;
case DevicePowerState:
switch (IrpStack->Parameters.Power.State.DeviceState) {
case PowerDeviceD3:
break;
case PowerDeviceD2:
break;
case PowerDeviceD1:
break;
case PowerDeviceD0:
break;
}
break;
}
break;
case IRP_MN_QUERY_POWER: //查询能否更改系统或设备电源状态
switch (IrpStack->Parameters.Power.Type) {
case SystemPowerState:
break;
case DevicePowerState:
switch (IrpStack->Parameters.Power.State.DeviceState) {
case PowerDeviceD2:
break;
case PowerDeviceD1:
break;
case PowerDeviceD3:
break;
}
break;
}
break;
default:
;
}
NextStack = IoGetNextIrpStackLocation(Irp);
ASSERT(NextStack != NULL);
RtlCopyMemory(NextStack, IrpStack, sizeof(IO_STACK_LOCATION));
#ifdef WIN95
ntStatus = IoCallDriver(pdx->StackDeviceObject, Irp);
#else
PoStartNextPowerIrp(Irp);
IoSkipCurrentIrpStackLocation(Irp);
Irp->IoStatus.Status = STATUS_SUCCESS;
ntStatus = PoCallDriver(pdx->StackDeviceObject,Irp);
#endif
/*PoStartNextPowerIrp(Irp);
IoSkipCurrentIrpStackLocation(Irp);
ntStatus = PoCallDriver(pdx->StackDeviceObject, Irp);
*/
if (ntStatus == STATUS_PENDING) {
IoMarkIrpPending(Irp);//标识为等待,是否是此处引起电源不能关闭的原因
}
return ntStatus;
这个例程,在XP系统关机时,没有任何问题,而在2003下关机最后则关不了机,不知道为什么,请各位来帮忙解决一下.
|
|