mirror of
https://git.proxmox.com/git/efi-boot-shim
synced 2025-06-12 11:36:40 +00:00
Make sure ImageBase is set appropriately in the loaded_image protocol
This commit is contained in:
parent
ea863d8471
commit
8c173876d1
14
shim.c
14
shim.c
@ -606,7 +606,7 @@ static EFI_STATUS read_header(void *data,
|
|||||||
/*
|
/*
|
||||||
* Once the image has been loaded it needs to be validated and relocated
|
* Once the image has been loaded it needs to be validated and relocated
|
||||||
*/
|
*/
|
||||||
static EFI_STATUS handle_grub (void *data, int datasize)
|
static EFI_STATUS handle_grub (void *data, int datasize, EFI_LOADED_IMAGE *li)
|
||||||
{
|
{
|
||||||
EFI_STATUS efi_status;
|
EFI_STATUS efi_status;
|
||||||
char *buffer;
|
char *buffer;
|
||||||
@ -672,6 +672,9 @@ static EFI_STATUS handle_grub (void *data, int datasize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
entry_point = ImageAddress(buffer, context.ImageSize, context.EntryPoint);
|
entry_point = ImageAddress(buffer, context.ImageSize, context.EntryPoint);
|
||||||
|
li->ImageBase = buffer;
|
||||||
|
li->ImageSize = context.ImageSize;
|
||||||
|
|
||||||
if (!entry_point) {
|
if (!entry_point) {
|
||||||
Print(L"Invalid entry point\n");
|
Print(L"Invalid entry point\n");
|
||||||
FreePool(buffer);
|
FreePool(buffer);
|
||||||
@ -897,7 +900,7 @@ EFI_STATUS init_grub(EFI_HANDLE image_handle)
|
|||||||
{
|
{
|
||||||
EFI_STATUS efi_status;
|
EFI_STATUS efi_status;
|
||||||
EFI_HANDLE grub_handle = NULL;
|
EFI_HANDLE grub_handle = NULL;
|
||||||
EFI_LOADED_IMAGE *li;
|
EFI_LOADED_IMAGE *li, li_bak;
|
||||||
EFI_DEVICE_PATH *grubpath;
|
EFI_DEVICE_PATH *grubpath;
|
||||||
CHAR16 *PathName;
|
CHAR16 *PathName;
|
||||||
EFI_GUID loaded_image_protocol = LOADED_IMAGE_PROTOCOL;
|
EFI_GUID loaded_image_protocol = LOADED_IMAGE_PROTOCOL;
|
||||||
@ -939,14 +942,19 @@ EFI_STATUS init_grub(EFI_HANDLE image_handle)
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
efi_status = handle_grub(data, datasize);
|
CopyMem(&li_bak, li, sizeof(li_bak));
|
||||||
|
|
||||||
|
efi_status = handle_grub(data, datasize, li);
|
||||||
|
|
||||||
if (efi_status != EFI_SUCCESS) {
|
if (efi_status != EFI_SUCCESS) {
|
||||||
Print(L"Failed to load grub\n");
|
Print(L"Failed to load grub\n");
|
||||||
|
CopyMem(li, &li_bak, sizeof(li_bak));
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
efi_status = uefi_call_wrapper(entry_point, 3, image_handle, systab);
|
efi_status = uefi_call_wrapper(entry_point, 3, image_handle, systab);
|
||||||
|
|
||||||
|
CopyMem(li, &li_bak, sizeof(li_bak));
|
||||||
done:
|
done:
|
||||||
|
|
||||||
return efi_status;
|
return efi_status;
|
||||||
|
Loading…
Reference in New Issue
Block a user