驱动中区分 win8 的 fast startup 与普通的 cold startup

本文介绍了Windows 8中的快速启动(Fast Startup)与传统冷启动(Cold Startup)的区别,并详细说明了如何在驱动程序中通过检查IRP_MN_SET_POWER Irp中的SystemPowerState来区分两者。在快速启动时,SystemPowerState为PowerSystemHibernate,而在冷启动时为PowerSystemShutdown。此外,还提供了检查SYSTEM_POWER_STATE_CONTEXT结构的TargetSystemState和EffectiveSystemState字段来判断是快速启动还是从休眠状态唤醒。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

    win8在电源管理中有一个选项,default会是enable的。他就是 “turn on fast startup”。

    我们要如何找到这个选项并进行设置呢,可以参考:http://www.eightforums.com/tutorials/6320-fast-startup-turn-off-windows-8-a.html

    Locates: control panel -> power options -> choose what the power buttons do -> change settings that are currently unavailable -> shutup settings

    具体位置:控制面板 -> 电源选项 -> 选择电源按钮的功能 -> 更改当前无法显示的设定 -> 关机设定   中会显示。

    

    但是我们如何区分fast startup与通常的 tranditional cold startup 呢?

    相信调试过driver的一定可以获得这两者的区别,笔者在调试中发现,fast startup,在power off阶段,系统会下发 IRP_MN_SET_POWER Irp,这其中包括两个,一个是用于通知SystemPowerState,另一个用于通知DevicePowerState。而差别正在与 SystemPowerState。

fast startup时,SystemPowerState对应的state是 PowerSystemHibernate

tranditional cold startup时,SystemPowerState对应的state是 PowerSystemShutdown

由此可以看出他们的区别。按照MS的解释,上述的区别是正常的。

MS关于fast startup的解释可以参考:http://msdn.microsoft.com/en-us/library/windows/hardware/jj835779(v=vs.85).aspx

因此,如果需要区别上述两种startup,可以考虑采用此处IRP_MN_SET_POWER Irp中的区别。

    而我们的driver需要一些特别设定来区别 hibernate 和 cold boot。因此在boot时需要区分它们的不同。这可以透过MS提供的方法:

To distinguish a fast startup from a wake-from-hibernation, a driver can inspect the information in the system set-power (IRP_MN_SET_POWER) IRP that informs the driver that the computer has entered the S0 (working) state. The driver's I/O stack location in this IRP contains a Power member, which is a structure that contains power-related information. Starting with Windows Vista, the Power member structure contains a SystemPowerStateContext member, which is aSYSTEM_POWER_STATE_CONTEXT structure that contains information about the previous system power states. This information is encoded in bit fields in the SYSTEM_POWER_STATE_CONTEXT structure.

Most of the bit fields in the SYSTEM_POWER_STATE_CONTEXT structure are reserved for system use and are opaque to drivers. However, this structure contains two bit fields, TargetSystemState and EffectiveSystemState, that can be read by drivers to determine whether a fast startup or a wake-from-hibernation occurred.

The TargetSystemState and EffectiveSystemState bit fields are set to SYSTEM_POWER_STATE enumeration values. IfTargetSystemState = PowerSystemHibernate and EffectiveSystemState = PowerSystemHibernate, a wake-from-hibernation occurred. However, if TargetSystemState = PowerSystemHibernate and EffectiveSystemState =PowerSystemShutdown, a fast startup occurred.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值