141 - Patch BOOTX64.EFI to boot a different BCD

If you wish to boot from a FAT32 USB drive containing multiple boot.wim files, the usual way to do this is to modify the UEFI BCD file located at \efi\microsoft\boot\bcd so that the user can choose from a Windows menu.

However, here is a way to patch the BOOTX64.EFI file so that it will load a different BCD file - e.g. BC1 or BC2 or BC3, etc.

This means that you could boot to a grub2 menu (via UEFI) and then select different .EFI boot files, e.g.

\BOOTX64.EFI

\BOOTX64_1.EFI

\BOOTX64_2.EFI

\EFI\MICROSOFT\BOOT\BCD

\EFI\MICROSOFT\BOOT\BC1

\EFI\MICROSOFT\BOOT\BC2

I used a Windows 10 BCD from a Microsoft Windows 10 Install ISO and the \EFI\BOOT\BOOTX64.EFI boot file for test purposes.

1. Make the above file structure using existing BOOTX64.EFI and BCD files

2. Use BootIce (best version is 1.3.4) to load each BCD file (BCD, BC1, BC2, etc. and change the Global and current system settings as follows:

Display boot menu = OFF

No integrity checks = ON

Metro Boot Manager = OFF

Change the File: \sources\boot.wim as required.

3. Click on the Save Globals and Save current system buttons and then Close (for each BCD file)

4. Now we need to patch the other EFI files (the unmodified one will boot using \EFI\MICROSOFT\BOOT\BCD).

\BOOTX64_1.EFI

\BOOTX64_2.EFI

to patch the .EFI files, we must boot to grub4dos.

We can do this by copying these .EFI files onto a grub4dos USB drive (e.g Easy2Boot) and then boot from the USB drive.

set L=\x5c\x00\x42\x00\x43\x00

# replace \BCD with \BC1

cat --locate=%L%D --replace=%L%1 /BOOTX64_1.efi

# replace \BCD with \BC2

cat --locate=%L%D --replace=%L%2 /BOOTX64_2.efi

Tip: You could add this to a grub4dos menu file so you don't need to type it.

OR - You could instead use a file editor such a WinHex to edit the files directly.

Once this has been done, copy the modified .EFI files back to your grub2 USB drive. We can now boot via UEFI to grub2 and use (for example)

chainloader /bootx64_1.efi

This will load \EFI\MICROSOFT\BOOT\BC1 which we can configure to load any boot.wim file we want.

Note: Test using a real system or a VM set up for Windows 8 or 10 64-bit UEFI booting.