Skip to content
a1ivePublic

About

Chain-load EFI applications from Windows Boot Manager

Topics

Resources

Stars

14 stars

Watchers

0 watching

Forks

Latest commit

 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

efiloader

efiloader is a Windows Boot Application that is launched by Windows Boot Manager and then restores the UEFI firmware execution context so it can call normal UEFI services and start another EFI application.

What It Does

Windows Boot Applications are entered after Boot Manager has switched into its own application context. In that context, direct calls into firmware services such as ST, BS, or console protocols may partially work or may hang.

efiloader reads the firmware descriptor from BOOT_APPLICATION_PARAMETER_BLOCK, prepares a firmware-callable context, verifies screen output through ConOut->OutputString, and then launches a target EFI application.

On x64, the restored firmware context includes:

  • CR3
  • GDTR
  • IDTR
  • LDTR
  • CS
  • DS, ES, FS, GS, SS

On ARM64, the restored firmware context includes:

  • SCTLR_EL1
  • VBAR_EL1
  • TPIDR_EL1
  • TTBR0_EL1, TTBR1_EL1
  • TCR_EL1
  • MAIR_EL1
  • DAIF IRQ state

On x86 (IA32), support is experimental. Current IA32 Boot Manager builds do not export the private firmware/application processor contexts in the firmware descriptor, so efiloader only switches paging and interrupt state (CR0.PG, CR4.PAE, IF) instead of restoring a full processor context. It may not work with every IA32 firmware or Boot Manager build.

Supported Architectures

Architecture Status
x64 Supported
ARM64 Supported
x86 (IA32) Experimental

Secure Boot

Secure Boot is not supported. efiloader is not signed, and it requires Boot Manager integrity checks to be disabled (nointegritychecks). Disable Secure Boot in the firmware settings before using it.

Embedded Payload

efiloader can embed one EFI application or driver as an RCDATA resource. Use Resource Hacker or a similar PE resource editor to replace the placeholder in an existing efiloader.efi:

  1. Open efiloader.efi in the resource editor.
  2. Locate the RCDATA resource with ID 101.
  3. Replace that resource with the desired EFI application or driver.
  4. Save the modified image as a new efiloader.efi.

After restoring the firmware execution context, efiloader loads the embedded image directly from memory and starts it before the target selected by BCD loadoptions.

The original resource is only a text placeholder and is ignored at runtime.

BCD Options

The Boot Application entry should point to:

\efiloader.efi

The BCD entry GUID and the path to efiloader.efi can be customized. Integrity checks must be disabled for the Boot Application entry:

set guid={14530529-1111-2222-abcd-12345678abcd}
bcdedit /create %guid% /d "EFI LOADER" /application bootapp
bcdedit /set %guid% device boot
bcdedit /set %guid% path \efiloader.efi
bcdedit /set %guid% nointegritychecks true
bcdedit /set {bootmgr} displayorder %guid% /addlast

If you are editing an offline BCD store, add the same /store argument to the bcdedit commands as appropriate for your environment.

efiloader also supports overriding the launched EFI application with the BCD loadoptions string element (0x12000030):

bcdedit %bcd% /set %guid% loadoptions \EFI\okr.efi

The option is copied before switching to firmware context. Leading/trailing spaces, NUL characters, and one pair of surrounding quotes are ignored.

If loadoptions is absent or invalid, the fallback target is:

\shell.efi

ISO Boot

When booting from optical media, efiloader first asks firmware to load the target from the El Torito UEFI image. If that fails, it reads the target directly from the ISO9660 or UDF filesystem. The launched EFI application therefore does not need to be inside the El Torito UEFI image.

Example layout:

[ISO]\bootmgr.efi
[ISO]\efiloader.efi
[ISO]\boot\boot.sdi
[ISO]\EFI\microsoft\boot\bcd
[ISO]\shell.efi
[IMG]\EFI\BOOT\BOOTX64.EFI

UDF media using physical (type 1) partition maps is supported. UDF metadata partitions are not currently resolved.

Serial Debug

Serial debug output goes to COM1 and is disabled by default. Define ENABLE_SERIAL_DEBUG when building x86/x64 images to enable diagnostics.

Acknowledgements

This project references work from:

About

Chain-load EFI applications from Windows Boot Manager

Topics

Resources

Stars

14 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages