驅動中區分 win8 的 fast startup 與普通的 cold startup

    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.


發佈了67 篇原創文章 · 獲贊 12 · 訪問量 57萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章