Home

Awesome

BGRTInjector

Changes the boot screen image on a UEFI computer.

This is a remake of Ben Wang's windows_custom_loader.efi, the source code of which is long lost. Several incompatibilities with non-Apple UEFI implementations are addressed, and you can now replace the logo without recompiling the whole program.

Requirements

Installation

Run BGRTInjector.efi either manually or automatically before your OS loads. You need to disable Secure Boot or sign it on your own, obviously.

Installation on rEFInd

Put a release build of BGRTInjector.efi (driver mode) into ESP:\EFI\refind\drivers_x64 and reboot.

Installation without 3rd-party bootloader

Put a release build of BGRTInjector.efi (Windows loader mode) into your ESP volume and set it as the default loader. This can be achieved by putting it to ESP:\EFI\boot\bootx64.efi. (Firmware on some devices will load Windows first which is a violation of the UEFI standard. You might need to manually register a UEFI boot entry on these systems.)

Usage

Customize the image

To customize the image, put a 24-bit (other modes and formats are not supported) BMP image named boot_image.bmp into the root directory of your ESP volume (right beside the EFI directory). If BGRTInjector complains about image file size incorrect, please open the BMP image in mspaint.exe then save it to fix its header.

The image will be displayed on the center of the screen, 1:1 pixel aligned. If the image is larger than the default UEFI GOP resolution, it will not be displayed.

Change the built-in default image

Convert a 24-bit BMP image to C-style array initializer, replace default_boot_image.bmp.inc and compile. To do the convertion you can use bin2array:

python3 bin2array.py -O default_boot_image.bmp.inc your_image.bmp

Security

Loading untrusted image into memory is dangerous. BGRTInjector only reads the image file from the volume (partition) it lives in, and ESP partition is usually protected under end-user accessible operating systems, so we can assume only a system administrator or a evil maid can load an evil image. Additionally BGRTInjector does some basic sanity checks on the image file, but it is still prone to specially crafted evil images.

If you are not signing your own Secure Boot keys, using BGRTInjector means Secure Boot will be unavailable. In Windows loader mode, BGRTInjector does not verify the authenticity of the target bootloader.

FAQ

Stuck at loading boot image from disk

You have too many hard disks or the NTFS driver comes with rEFInd is causing a hang. Delete ESP:\EFI\refind\drivers_x64\ntfs_x64.efi and other filesystem drivers if you don't need them.

Image is not centered

This typically happens when you are using driver mode and your firmware does not set GOP resolution to the max available value. All the drivers are launched prior to rEFInd setting the GOP resolution, so BGRTInjector would read a smaller screen resolution.

The most simple solution:

Here's a rEFInd config from my computer for reference.

# Your resolution may vary
resolution 3840 2160

menuentry "Windows 10 (BGRT Injected)" {
    # do not switch to text mode when booting; otherwise screen resolution will still be incorrect
    graphics on

    icon \EFI\refind\icons\os_win8.png

    # use BGRTInjector Windows loader mode 
    loader \BGRTInjector.efi
}

Building

Flags:

Notes:

Windows

Requirements:

Open BGRTInjector.sln in Visual Studio and click Build Solution.

Linux

Install mingw-w64 plus the usual C/C++ development packages, then run make. Linux build procedures are not extensively tested, so your mileage may vary.