diff --git a/shim.c b/shim.c index 5329795..a4f7769 100644 --- a/shim.c +++ b/shim.c @@ -1925,6 +1925,16 @@ EFI_STATUS start_image(EFI_HANDLE image_handle, CHAR16 *ImagePath) */ CopyMem(&li_bak, li, sizeof(li_bak)); + /* + * Update the loaded image with the second stage loader file path + */ + li->FilePath = FileDevicePath(NULL, PathName); + if (!li->FilePath) { + perror(L"Unable to update loaded image file path\n"); + efi_status = EFI_OUT_OF_RESOURCES; + goto restore; + } + /* * Verify and, if appropriate, relocate and execute the executable */ @@ -1934,8 +1944,7 @@ EFI_STATUS start_image(EFI_HANDLE image_handle, CHAR16 *ImagePath) perror(L"Failed to load image: %r\n", efi_status); PrintErrors(); ClearErrors(); - CopyMem(li, &li_bak, sizeof(li_bak)); - goto done; + goto restore; } loader_is_participating = 0; @@ -1945,6 +1954,10 @@ EFI_STATUS start_image(EFI_HANDLE image_handle, CHAR16 *ImagePath) */ efi_status = entry_point(image_handle, systab); +restore: + if (li->FilePath) + FreePool(li->FilePath); + /* * Restore our original loaded image values */