Skip to content

wirespider87/efi-base

Repository files navigation

efi-base - Base EFI Application

what is this thing?

this is clean base efi application for detecting usb devices so you can work with files and launching windows boot manager. it hooks exitbootservices for persistence and checks if usb device exists before continuing boot process.

project structure explanation

efi-base/                      # main project directory
├── src/                       # source implementation files
│   ├── util.c                 # utility functions for memory operations
│   ├── usb_detect.c           # usb device detection
│   └── boot_manager.c         # windows boot manager launcher
├── include/                   # module header files
│   ├── util.h                 # utility function declarations
│   ├── usb_detect.h           # usb detection declarations
│   └── boot_manager.h         # boot manager declarations
├── main.c                     # main application entry point
├── stdafx.h                   # standard includes and common definitions
├── efi-base.vcxproj           # visual studio project file
├── efi-base.sln               # solution file
└── README.md                  # this file

where to put visualuefi framework

you need to clone visualuefi framework to parent directory like this:

project/
├── VisualUefi/               # clone visualuefi here !!!
│   ├── EDK-II/
│   ├── debugger/
│   ├── edk2/
│   ├── openssl/
│   └── samples/
└── efi-base/                 # your project is here
    ├── src/
    ├── include/
    └── main.c

how to setup build environment

  1. first clone visualuefi framework (this will take some time, be patient):
cd project/
git clone --recurse-submodules https://github.com/ionescu007/VisualUefi

note: the recurse-submodules is important because visualuefi has many submodules. this command may take long time to complete because it downloads edk2, openssl and other dependencies.

  1. navigate to VisualUefi directory: open the VisualUefi folder in your project structure.

  2. open EDK-II solution: navigate to the EDK-II subdirectory and open the EDK-II.sln solution file in visual studio.

  3. build EDK-II libraries: build the entire EDK-II solution. this will compile all the necessary uefi libraries that your applications will depend on. you should be able to build without any issues in either visual studio 2015 or 2017. wdk should not be needed.

  4. open visual studio and load efi-base/efi-base.sln

  5. make sure you select "Release" configuration and "x64" platform

  6. build the project (F7 or Build -> Build Solution)

  7. if build successful, you will get bootx64.efi file in x64/Release/ directory

how to use the compiled efi file

  1. take fat32 formatted usb drive

  2. create directory structure on usb:

USB:/
└── efi/
    └── boot/
        └── bootx64.efi    # put your compiled file here
  1. make sure your compiled bootx64.efi is placed exactly at efi/boot/bootx64.efi on the usb drive

  2. boot your computer from this usb drive:

    • enter bios/uefi settings (usually F2, F12, DEL during boot)
    • find boot options and select your usb device
    • computer will boot from usb and run your efi application

what this application does

  1. installs exitbootservices hook - this allows persistence
  2. checks for usb device - looks for a mounted filesystem
  3. waits for usb removal - displays message "unplug usb" until device is removed
  4. launches windows boot manager - finds and starts windows bootmgfw.efi after usb is unplugged

troubleshooting

if build fails:

  • make sure visualuefi is cloned to correct location with --recurse-submodules
  • check that visual studio has c++ build tools installed
  • verify you selected release x64 configuration

if efi doesn't boot:

  • ensure usb is fat32 formatted
  • verify efi file is at exactly efi/boot/bootx64.efi path
  • try different usb port or usb device

About

an efi base for making your own bootkits

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages