Search code examples
gnuuefignu-efi

How to read a file of the EFI partition using gnu-efi


I used gnu-efi.
I do not understand how to simply read file.
I understand about using the BlockIOProtocol.

Could you tell us along with a simple example?


Solution

  • I don't have a simple example handy, sorry. But in general you proceed like this

    • in EfiMain you have an IMAGE_HANDLE of your loaded image
    • use LOADED_IMAGE_PROTOCOL on the image handle to obtain an device handle of the device this image was loaded from (= the EFI partition)
    • Use SIMPLE_FILE_SYSTEM_PROTOCOL on the device handle to call OpenVolume, which will give you a EFI_FILE of the filesystem root
    • call Open on the root to open your file and Read on the resulting handle to read from it.
    • Don't forget to release all your handles afterwards.

    Hope this helps.