mirror of
https://github.com/Metabolix/HackBGRT.git
synced 2025-12-07 09:36:10 -08:00
Warn about Fast Startup (Hiberboot)
This commit is contained in:
46
src/Setup.cs
46
src/Setup.cs
@@ -10,6 +10,8 @@ using System.Diagnostics;
|
|||||||
using System.Security.Principal;
|
using System.Security.Principal;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Management;
|
||||||
|
using Microsoft.Win32;
|
||||||
|
|
||||||
[assembly: AssemblyInformationalVersionAttribute(GIT_DESCRIBE.data)]
|
[assembly: AssemblyInformationalVersionAttribute(GIT_DESCRIBE.data)]
|
||||||
[assembly: AssemblyProductAttribute("HackBGRT")]
|
[assembly: AssemblyProductAttribute("HackBGRT")]
|
||||||
@@ -674,6 +676,40 @@ public class Setup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log the boot time.
|
||||||
|
*
|
||||||
|
* @return The boot time, or null if it couldn't be determined.
|
||||||
|
*/
|
||||||
|
protected DateTime? GetBootTime() {
|
||||||
|
try {
|
||||||
|
var query = new ObjectQuery("SELECT LastBootUpTime FROM Win32_OperatingSystem WHERE Primary='true'");
|
||||||
|
foreach (var m in new ManagementObjectSearcher(query).Get()) {
|
||||||
|
return ManagementDateTimeConverter.ToDateTime(m["LastBootUpTime"].ToString());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log($"GetBootTime failed: {e.ToString()}");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if Hiberboot is enabled.
|
||||||
|
*
|
||||||
|
* @return True, if Hiberboot is enabled.
|
||||||
|
*/
|
||||||
|
protected bool IsHiberbootEnabled() {
|
||||||
|
try {
|
||||||
|
return (int) Registry.GetValue(
|
||||||
|
"HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Power",
|
||||||
|
"HiberbootEnabled",
|
||||||
|
0
|
||||||
|
) != 0;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ask for user's choice and install/uninstall.
|
* Ask for user's choice and install/uninstall.
|
||||||
*/
|
*/
|
||||||
@@ -759,6 +795,16 @@ public class Setup {
|
|||||||
InitEspInfo();
|
InitEspInfo();
|
||||||
Efi.LogBGRT();
|
Efi.LogBGRT();
|
||||||
Efi.LogBootEntries();
|
Efi.LogBootEntries();
|
||||||
|
if (GetBootTime() is DateTime bootTime) {
|
||||||
|
var configTime = new[] { File.GetCreationTime("config.txt"), File.GetLastWriteTime("config.txt") }.Max();
|
||||||
|
Log($"Boot time = {bootTime}, config.txt changed = {configTime}");
|
||||||
|
if (configTime > bootTime) {
|
||||||
|
WriteLine($"Windows was booted at {bootTime}. Remember to reboot after installing!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (IsHiberbootEnabled()) {
|
||||||
|
WriteLine("You may have to disable Fast Startup (Hiberboot) to reboot properly.");
|
||||||
|
}
|
||||||
bool allowSecureBoot = false;
|
bool allowSecureBoot = false;
|
||||||
bool allowBitLocker = false;
|
bool allowBitLocker = false;
|
||||||
bool allowBadLoader = false;
|
bool allowBadLoader = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user