mirror of
https://github.com/Metabolix/HackBGRT.git
synced 2025-12-06 17:15:42 -08:00
Configure before installing
This commit is contained in:
11
README.md
11
README.md
@@ -18,14 +18,11 @@ When booting on a UEFI-based computer, Windows may show a vendor-defined logo wh
|
||||
* Get the latest release from the Releases page.
|
||||
* Start `setup.exe` and follow the instructions.
|
||||
* You may need to manually disable Secure Boot and then retry.
|
||||
* The installer will launch Notepad for modifying the configuration.
|
||||
* If you need only one custom image, the defaults are fine.
|
||||
* Otherwise, check out the examples in the configuration file.
|
||||
* The installer will launch Paint for creating the image(s).
|
||||
* You can create multiple images by using Save As.
|
||||
* The installer will launch Paint for editing the image.
|
||||
* Be sure to always use the 24-bit BMP/DIB format.
|
||||
* If Windows later restores the original boot loader, just reinstall.
|
||||
* If you wish to change the image or other configuration, just reinstall.
|
||||
* For advanced settings, edit `config.txt` before installing. No extra support provided!
|
||||
|
||||
### Multi-boot configurations
|
||||
|
||||
@@ -45,7 +42,7 @@ On 32-bit machines, use `bootia32.efi` instead of `bootx64.efi`.
|
||||
|
||||
## Configuration
|
||||
|
||||
The configuration options are described in `config.txt`, which should be stored in `[EFI System Partition]\EFI\HackBGRT\config.txt`.
|
||||
The configuration options are described in `config.txt`, which the installer copies into `[EFI System Partition]\EFI\HackBGRT\config.txt`.
|
||||
|
||||
## Images
|
||||
|
||||
@@ -53,7 +50,7 @@ The image path can be changed in the configuration file. The default path is `[E
|
||||
|
||||
The image must be a 24-bit BMP file with a 54-byte header. That's a TrueColor BMP3 in Imagemagick, or 24-bit BMP/DIB in Microsoft Paint.
|
||||
|
||||
Multiple images may be specified, in which case one is picked at random.
|
||||
Advanced users may edit the `config.txt` to define multiple images, in which case one is picked at random. The installer copies files whose `path` starts with `\EFI\HackBGRT\`.
|
||||
|
||||
## Recovery
|
||||
|
||||
|
||||
@@ -15,7 +15,9 @@ boot=\EFI\HackBGRT\bootmgfw-original.efi
|
||||
# - "keep" to keep the firmware logo. Sets also x=native,y=native by default.
|
||||
# - "remove" to remove the BGRT. Makes x and y meaningless.
|
||||
# - "black" to use only a black image. Makes x and y meaningless.
|
||||
# - "path=..." to read a BMP file. The file must be a 24-bit BMP file with a 54-byte header.
|
||||
# - "path=..." to read a BMP file.
|
||||
# * NOTE: The installer will only install files with path=\EFI\HackBGRT\*.
|
||||
# * NOTE: The file must be a 24-bit BMP file with a 54-byte header.
|
||||
# * NOTE: The file must be on the EFI System Partition. Do not add a drive letter!
|
||||
# Examples:
|
||||
# - image=remove
|
||||
|
||||
50
src/Setup.cs
50
src/Setup.cs
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
/**
|
||||
* HackBGRT Setup.
|
||||
@@ -123,7 +124,18 @@ public class Setup: SetupHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Install files and replace the MsLoader with our own.
|
||||
* Install a single file.
|
||||
*/
|
||||
protected void InstallFile(string name, string newName = null) {
|
||||
newName = Path.Combine(InstallPath, newName == null ? name : newName);
|
||||
if (!Copy(name, newName)) {
|
||||
throw new SetupException($"Failed to install file {name} to {newName}.");
|
||||
}
|
||||
Console.WriteLine($"Installed {name} to {newName}.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Install files to ESP.
|
||||
*/
|
||||
protected void Install() {
|
||||
try {
|
||||
@@ -145,13 +157,14 @@ public class Setup: SetupHelper {
|
||||
if (!NewLoader.ReplaceWith(NewLoaderSource)) {
|
||||
throw new SetupException("Couldn't copy new HackBGRT to ESP.");
|
||||
}
|
||||
if (!File.Exists(Config)) {
|
||||
Copy("config.txt", Config);
|
||||
InstallFile("config.txt");
|
||||
foreach (var line in File.ReadAllLines("config.txt").Where(s => s.StartsWith("image="))) {
|
||||
var delim = "path=\\EFI\\HackBGRT\\";
|
||||
var i = line.IndexOf(delim);
|
||||
if (i > 0) {
|
||||
InstallFile(line.Substring(i + delim.Length));
|
||||
}
|
||||
}
|
||||
if (!File.Exists(Splash)) {
|
||||
Copy("splash.bmp", Splash);
|
||||
}
|
||||
Configure();
|
||||
if (!MsLoader.ReplaceWith(NewLoader)) {
|
||||
MsLoader.ReplaceWith(MsLoaderBackup);
|
||||
throw new SetupException("Couldn't copy new HackBGRT over the MS loader (bootmgfw.efi).");
|
||||
@@ -163,23 +176,18 @@ public class Setup: SetupHelper {
|
||||
* Configure HackBGRT.
|
||||
*/
|
||||
protected void Configure() {
|
||||
// Open config.txt in notepad.
|
||||
Console.WriteLine("Check the configuration in " + Config + ".");
|
||||
Console.WriteLine(" - Use the supplied config.txt as reference.");
|
||||
Console.WriteLine(" - Be sure to check for any format changes if updating!");
|
||||
try {
|
||||
StartProcess("notepad", Config).WaitForExit();
|
||||
} catch {
|
||||
Console.WriteLine("Editing config.txt with notepad failed!");
|
||||
}
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("This setup program lets you edit just one image.");
|
||||
Console.WriteLine("Edit config.txt manually for advanced configuration.");
|
||||
|
||||
// Open splash.bmp in mspaint.
|
||||
Console.WriteLine("Draw or copy your preferred image to " + Splash + ".");
|
||||
Console.WriteLine("Draw or copy your preferred image to splash.bmp.");
|
||||
try {
|
||||
StartProcess("mspaint", Splash).WaitForExit();
|
||||
StartProcess("mspaint", "splash.bmp").WaitForExit();
|
||||
} catch {
|
||||
Console.WriteLine("Editing splash.bmp with mspaint failed!");
|
||||
Console.WriteLine("Edit splash.bmp with your preferred editor.");
|
||||
Console.WriteLine("Press any key to continue.");
|
||||
Console.ReadKey();
|
||||
}
|
||||
Console.WriteLine();
|
||||
}
|
||||
@@ -254,7 +262,6 @@ public class Setup: SetupHelper {
|
||||
}
|
||||
}
|
||||
|
||||
protected string Config, Splash;
|
||||
protected BootLoaderInfo MsLoader, MsLoaderBackup, NewLoader, NewLoaderSource;
|
||||
protected string EfiArch;
|
||||
|
||||
@@ -263,8 +270,6 @@ public class Setup: SetupHelper {
|
||||
*/
|
||||
protected Setup() {
|
||||
InstallPath = Path.Combine(Esp.Location, "EFI", "HackBGRT");
|
||||
Config = Path.Combine(InstallPath, "config.txt");
|
||||
Splash = Path.Combine(InstallPath, "splash.bmp");
|
||||
MsLoaderBackup = new BootLoaderInfo(BackupLoaderPath);
|
||||
MsLoader = new BootLoaderInfo(Esp.MsLoaderPath);
|
||||
if (MsLoader.Type == BootLoaderType.MS) {
|
||||
@@ -312,6 +317,7 @@ public class Setup: SetupHelper {
|
||||
var k = Console.ReadKey().Key;
|
||||
Console.WriteLine();
|
||||
if (k == ConsoleKey.I) {
|
||||
Configure();
|
||||
Install();
|
||||
} else if ((isEnabled && k == ConsoleKey.D) || (isInstalled && k == ConsoleKey.R)) {
|
||||
if (isEnabled) {
|
||||
|
||||
Reference in New Issue
Block a user