Reputation: 4863
I am looking at using Bootservices function LoadImage to load a UEFI application image from memory. Function parameters are:
typedef
EFI_STATUS
LoadImage (
IN BOOLEAN BootPolicy,
IN EFI_HANDLE ParentImageHandle,
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
IN VOID *SourceBuffer OPTIONAL,
IN UINTN SourceSize,
OUT EFI_HANDLE *ImageHandle
);
Where I am allowed to provide a sourcebuffer that is already populated with the PE/COFF image to load. I am currently using sourcebuffer, and have prepopulated the buffer with a valid PE/COFF files contents. I pass that in under SourceBuffer and set DevicePath to Null. I receive the error "EFI_LOAD_ERROR Image was not loaded because the image format was corrupt or not understood
."
What am I doing wrong?
Upvotes: 1
Views: 3170
Reputation: 6234
You need to provide the information about the memory buffer as a device path - in the DevicePath
argument.
Have a look through chapter 9 Device Path Protocol in the UEFI 2.5 specification (from the UEFI forum). Especially 9.3.2.3 Memory Mapped Device Path.
You should load the entire file just as is is - no picking apart of sections required.
For an example, you can have a look at the GRUB arm64 Linux loader, which does just this.
Upvotes: 3