Adding a driver to a UEFI firmware

Pete Batard edited this page Dec 14, 2017 · 15 revisions

The content of this page describes how you an add a new file system EFI driver, such as the ones produced by EfiFs, to an existing UEFI firmware image.

This can be useful for instance if you want to add native NTFS support to an existing UEFI firmware, so that you can boot from NTFS removable media directly.

For this example, we'll be using the NTFS x64 EFI driver ntfs_x64.efi along VMWare's x64 UEFI firmware, which we'll then run with VMWare Player in 64-bit mode on Windows.

Note however that, if you are planning to modify an actual desktop UEFI firmware, it is possible that your firmware image is signed by the motherboard manufacturer, in which case you might not be able to reflash it. I also take NO RESPONSIBILITY for any damage resulting from trying to modify and reflash a modified UEFI firmware — USE THIS GUIDE AT YOUR OWN RISK!!

Creating the UEFI firmware module

  1. Download and extract the latest .7z release of FFS, which is a convenient repackaging of the EDK2's GenSec and GenFfs base tools.
  2. In the directory where you extracted the FFS files, also copy the ntfs_x64.efi binary (a version of which can be downloaded here) and then either.
  • Call the GenMod script provided. This will take care of everything and create a new GUID for you if you don't pass one as parameter:
GenMod ntfs_x64.efi

GenMod output

  • Or, if you want to issue the commands manually, and after having generated your own GUID, issue something like:
GenSec -o pe32.sec ntfs_x64.efi -S EFI_SECTION_PE32
GenSec -o name.sec -S EFI_SECTION_USER_INTERFACE -n "Ntfs"
GenSec -o ver.sec -S EFI_SECTION_VERSION -n "1.0"
GenFfs -g "4319CBBA-0980-4245-B511-D1CEFC1FFBEA" -o ntfs_x64.ffs -i pe32.sec -i name.sec -i ver.sec -t EFI_FV_FILETYPE_DRIVER

Either of these should result in a new ntfs_x64.ffs module having been created in your directory. This .ffs is a module that you are now able to import in your UEFI firmware.

Note: If you want to know exactly how an ffs driver module is structure, please have a look at the readme from the FFS project.

Extracting the VMWare UEFI firmware

As detailed in this blog post, if you have VMWare Player 64-bit installed, you should first navigate to C:\Program Files (x86)\VMware\VMware Workstation\x64 and open vmware-vmx.exe in 7-zip.

There, in .rsrc\1042\BINRES you will find two 2MB binary resources, the second of which being the X64 UEFI firmware that is of interest to us:

VMWare UEFI firmware extraction

Simply extract this file somewhere as efi64.rom.

Adding the module to the firmware

  1. Download LongSoft's UEFITool (UEFI BIOS Updater) 0.21.5 from here (or any UEFI BIOS editor you prefer). Be mindful that the more recent "NE" versions of UEFITool do not allow editing of a firmware image (issue #67), so make sure you use version 0.21.5.
  2. Launch the BIOS editing application and open the efi64.rom file you previously extracted.
  3. Locate the Fat module in the firmware. In the case of the current VMWare application, it should be under UEFI Image8C8CE578-8A3D-4F1C-9935-896185C32DD320BC8AC9-94D1-4208-AB28-5D673FD73486EE4E5898-3914-4259-9D6E-DC7BD79403CFVolume Image Section8C8CE578-8A3D-4F1C-9935-896185C32DD3, with GUID 961578FE-B6B7-44C3-AF35-6BC705CD2B1F.

FAT module location in UBU 4. Select Insert After and select the ntfs_x64.ffs module we previously created.

NTFS module location in UBU

  1. Save the firmware back (FileSave Image File) as efi64_ntfs.rom.

Running the modified firmware in VMWare Player

  1. Create a new Virtual Machine, or locate an existing one
  2. Copy efi64_ntfs.rom in your Virtual Machine directory
  3. Edit the .vmx so that it contains the lines:
firmware = "efi"
efi64.filename = "efi64_ntfs.rom"
  1. Run the VM (make sure it's running in 64-bit mode, else an unmodified 32-bit EFI firmware will be used!) and try to launch the embedded EFI Shell (by pressing F2 or Del until you get into the BIOS):

VMWare EFI Shell

If you issue drivers you should be able to see that the NTFS driver was natively loaded:

VMWare EFI Shell

And if you issue map and navigate to a volume, you should find that you can access NTFS content:

VMWare EFI Shell

VMWare EFI Shell

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.