8 Commits

Author SHA1 Message Date
Lauri Kenttä
3396a4799d Update change log and tag v1.5.1 2018-08-11 14:01:48 +03:00
Lauri Kenttä
d35a9abb0a Add debug=0 to the default config.txt 2018-08-11 13:45:04 +03:00
Lauri Kenttä
85811d62a6 Add note about EFI System Partition to config.txt 2018-08-11 13:42:41 +03:00
Lauri Kenttä
449dc6acc6 Create OsIndications if it's missing 2018-07-19 19:10:01 +03:00
Lauri Kenttä
1980e5c05c Clarify default config.txt 2018-07-19 19:10:01 +03:00
Lauri Kenttä
9a59f69a28 Compile C# with csc (not mcs) 2018-07-11 16:59:27 +03:00
Lauri Kenttä
1fffbcff2c Fix member naming 2018-07-11 16:55:26 +03:00
Soheibooo
bd7a5f3eea Correct typo in README 2018-03-02 00:45:10 -05:00
5 changed files with 31 additions and 16 deletions

View File

@@ -2,6 +2,12 @@
All notable changes to this project will be documented in this file.
## 1.5.1 - 2018-08-11
### Fixed
- Clarify the default config.txt.
- Fix an exception in some cases when trying to boot to UEFI setup.
## 1.5.0 - 2017-09-30
### Added

View File

@@ -31,7 +31,7 @@ src/GIT_DESCRIBE.cs: $(FILES_CS) $(FILES_C) $(FILES_H)
echo 'public class GIT_DESCRIBE { public static string data = "$(GIT_DESCRIBE)"; }' > $@
setup.exe: $(FILES_CS) src/GIT_DESCRIBE.cs
mcs -define:GIT_DESCRIBE -out:$@ $^
csc /define:GIT_DESCRIBE /out:$@ $^
bootx64.efi: CC_PREFIX = x86_64-w64-mingw32
bootx64.efi: GNUEFI_ARCH = x86_64

View File

@@ -4,7 +4,7 @@ HackBGRT is intended as a boot logo changer for UEFI-based Windows systems.
## Summary
When booting on a UEFI-based computer, Windows may show a vendor-defined logo which is stored on the UEFI firmware in a section called Boot Graphics Resource Table (BGRT). It's usually very difficult to change the image permamently, but a custom UEFI application may be used to overwrite it during the boot. HackBGRT does exactly that.
When booting on a UEFI-based computer, Windows may show a vendor-defined logo which is stored on the UEFI firmware in a section called Boot Graphics Resource Table (BGRT). It's usually very difficult to change the image permanently, but a custom UEFI application may be used to overwrite it during the boot. HackBGRT does exactly that.
## Usage

7
config.txt Executable file → Normal file
View File

@@ -1,7 +1,7 @@
# vim: set fileencoding=utf-8
# The same options may be given also as command line parameters in the EFI Shell, which is useful for debugging.
# Boot loader path. Point to the real Windows boot loader.
# Boot loader path. Default: backup of the Windows boot loader.
boot=\EFI\HackBGRT\bootmgfw-original.efi
# The image is specified with an image line.
@@ -16,6 +16,7 @@ boot=\EFI\HackBGRT\bootmgfw-original.efi
# - "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.
# * NOTE: The file must be on the EFI System Partition. Do not add a drive letter!
# Examples:
# - image=remove
# - image=black
@@ -33,3 +34,7 @@ image=path=\EFI\HackBGRT\splash.bmp
# Preferred resolution. Use 0x0 for maximum and -1x-1 for original.
resolution=0x0
# Debug mode (0 for disabled, 1 for enabled).
# Shows debug information and prompts for keypress before booting.
debug=0

View File

@@ -39,9 +39,9 @@ public class Efi {
* Information about an EFI variable.
*/
public class Variable {
public string name, guid;
public UInt32 attributes;
public byte[] data;
public string Name, Guid;
public UInt32 Attributes;
public byte[] Data;
}
public const string EFI_GLOBAL_GUID = "{8be4df61-93ca-11d2-aa0d-00e098032b8c}";
@@ -83,19 +83,19 @@ public class Efi {
*/
private static Variable GetVariable(string name, string guid = EFI_GLOBAL_GUID) {
Variable result = new Variable();
result.name = name;
result.guid = guid;
result.data = null;
result.attributes = 0;
result.Name = name;
result.Guid = guid;
result.Data = null;
result.Attributes = 0;
for (UInt32 i = 4096; i <= 1024*1024; i *= 2) {
byte[] buf = new byte[i];
UInt32 len = GetFirmwareEnvironmentVariableEx(name, guid, buf, (UInt32) buf.Length, out result.attributes);
UInt32 len = GetFirmwareEnvironmentVariableEx(name, guid, buf, (UInt32) buf.Length, out result.Attributes);
if (len == buf.Length) {
continue;
}
if (len > 0 || Marshal.GetLastWin32Error() == 0) {
result.data = new byte[len];
Array.Copy(buf, 0, result.data, 0, len);
result.Data = new byte[len];
Array.Copy(buf, 0, result.Data, 0, len);
return result;
}
switch (len != 0 ? 0 : Marshal.GetLastWin32Error()) {
@@ -119,7 +119,7 @@ public class Efi {
* @param v Information of the variable.
*/
private static void SetVariable(Variable v) {
UInt32 r = SetFirmwareEnvironmentVariableEx(v.name, v.guid, v.data, (UInt32) v.data.Length, v.attributes);
UInt32 r = SetFirmwareEnvironmentVariableEx(v.Name, v.Guid, v.Data, (UInt32) v.Data.Length, v.Attributes);
if (r == 0) {
switch (Marshal.GetLastWin32Error()) {
case 87:
@@ -159,7 +159,7 @@ public class Efi {
public static bool CanBootToFW() {
try {
Variable tmp = GetVariable("OsIndicationsSupported");
return tmp.data != null && (tmp.data[0] & 1) != 0;
return tmp.Data != null && (tmp.Data[0] & 1) != 0;
} catch {
return false;
}
@@ -170,7 +170,11 @@ public class Efi {
*/
public static void SetBootToFW() {
Variable tmp = GetVariable("OsIndications");
tmp.data[0] |= 1;
if (tmp.Data == null) {
tmp.Data = new byte[8];
tmp.Attributes = 7;
}
tmp.Data[0] |= 1;
SetVariable(tmp);
}
}