diff --git a/GRUB2/MOD_SRC/grub-2.04/grub-core/kern/efi/efi.c b/GRUB2/MOD_SRC/grub-2.04/grub-core/kern/efi/efi.c index a93da199..64c73916 100644 --- a/GRUB2/MOD_SRC/grub-2.04/grub-core/kern/efi/efi.c +++ b/GRUB2/MOD_SRC/grub-2.04/grub-core/kern/efi/efi.c @@ -281,7 +281,8 @@ grub_addr_t grub_efi_modules_addr (void) { grub_efi_loaded_image_t *image; - struct grub_pe32_header *header; + struct grub_msdos_image_header *header; + struct grub_pe_image_header *pe_image_header; struct grub_pe32_coff_header *coff_header; struct grub_pe32_section_table *sections; struct grub_pe32_section_table *section; @@ -293,7 +294,10 @@ grub_efi_modules_addr (void) return 0; header = image->image_base; - coff_header = &(header->coff_header); + pe_image_header + = (struct grub_pe_image_header *) ((char *) header + + header->pe_image_header_offset); + coff_header = &(pe_image_header->coff_header); sections = (struct grub_pe32_section_table *) ((char *) coff_header + sizeof (*coff_header) diff --git a/GRUB2/MOD_SRC/grub-2.04/grub-core/loader/efi/linux.c b/GRUB2/MOD_SRC/grub-2.04/grub-core/loader/efi/linux.c index f980f33b..fad2478d 100644 --- a/GRUB2/MOD_SRC/grub-2.04/grub-core/loader/efi/linux.c +++ b/GRUB2/MOD_SRC/grub-2.04/grub-core/loader/efi/linux.c @@ -25,7 +25,7 @@ #include #include #include -#include +//#include #include #include #include diff --git a/GRUB2/MOD_SRC/grub-2.04/include/grub/efi/efi.h b/GRUB2/MOD_SRC/grub-2.04/include/grub/efi/efi.h index 0aa3eb33..7c2419ce 100644 --- a/GRUB2/MOD_SRC/grub-2.04/include/grub/efi/efi.h +++ b/GRUB2/MOD_SRC/grub-2.04/include/grub/efi/efi.h @@ -23,6 +23,18 @@ #include #include #include +#include + +#define GRUB_LINUX_ARM_MAGIC_SIGNATURE 0x016f2818 + +struct linux_arch_kernel_header { + grub_uint32_t code0; + grub_uint32_t code1; + grub_uint64_t reserved[6]; + grub_uint32_t magic; + grub_uint32_t hdr_offset; /* Offset of PE/COFF header. */ + struct grub_pe_image_header pe_image_header; +}; /* Functions. */ void *EXPORT_FUNC(grub_efi_locate_protocol) (grub_efi_guid_t *protocol, @@ -97,7 +109,6 @@ extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd, #if defined(__arm__) || defined(__aarch64__) || defined(__riscv) || defined(__loongarch__) void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void); grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *); -#include grub_err_t grub_arch_efi_linux_check_image(struct linux_arch_kernel_header *lh); grub_err_t grub_arch_efi_linux_boot_image(grub_addr_t addr, grub_size_t size, char *args); diff --git a/GRUB2/MOD_SRC/grub-2.04/include/grub/efi/efi.h.orig b/GRUB2/MOD_SRC/grub-2.04/include/grub/efi/efi.h.orig deleted file mode 100644 index aec589c3..00000000 --- a/GRUB2/MOD_SRC/grub-2.04/include/grub/efi/efi.h.orig +++ /dev/null @@ -1,125 +0,0 @@ -/* efi.h - declare variables and functions for EFI support */ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc. - * - * GRUB is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GRUB is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GRUB. If not, see . - */ - -#ifndef GRUB_EFI_EFI_HEADER -#define GRUB_EFI_EFI_HEADER 1 - -#include -#include -#include - -/* Functions. */ -void *EXPORT_FUNC(grub_efi_locate_protocol) (grub_efi_guid_t *protocol, - void *registration); -grub_efi_handle_t * -EXPORT_FUNC(grub_efi_locate_handle) (grub_efi_locate_search_type_t search_type, - grub_efi_guid_t *protocol, - void *search_key, - grub_efi_uintn_t *num_handles); -void *EXPORT_FUNC(grub_efi_open_protocol) (grub_efi_handle_t handle, - grub_efi_guid_t *protocol, - grub_efi_uint32_t attributes); -int EXPORT_FUNC(grub_efi_set_text_mode) (int on); -void EXPORT_FUNC(grub_efi_stall) (grub_efi_uintn_t microseconds); -void * -EXPORT_FUNC(grub_efi_allocate_pages_real) (grub_efi_physical_address_t address, - grub_efi_uintn_t pages, - grub_efi_allocate_type_t alloctype, - grub_efi_memory_type_t memtype); -void * -EXPORT_FUNC(grub_efi_allocate_fixed) (grub_efi_physical_address_t address, - grub_efi_uintn_t pages); -void * -EXPORT_FUNC(grub_efi_allocate_any_pages) (grub_efi_uintn_t pages); -void EXPORT_FUNC(grub_efi_free_pages) (grub_efi_physical_address_t address, - grub_efi_uintn_t pages); -grub_efi_uintn_t EXPORT_FUNC(grub_efi_find_mmap_size) (void); -int -EXPORT_FUNC(grub_efi_get_memory_map) (grub_efi_uintn_t *memory_map_size, - grub_efi_memory_descriptor_t *memory_map, - grub_efi_uintn_t *map_key, - grub_efi_uintn_t *descriptor_size, - grub_efi_uint32_t *descriptor_version); -void grub_efi_memory_fini (void); -grub_efi_loaded_image_t *EXPORT_FUNC(grub_efi_get_loaded_image) (grub_efi_handle_t image_handle); -void EXPORT_FUNC(grub_efi_print_device_path) (grub_efi_device_path_t *dp); -char *EXPORT_FUNC(grub_efi_get_filename) (grub_efi_device_path_t *dp); -grub_efi_device_path_t * -EXPORT_FUNC(grub_efi_get_device_path) (grub_efi_handle_t handle); -grub_efi_device_path_t * -EXPORT_FUNC(grub_efi_find_last_device_path) (const grub_efi_device_path_t *dp); -grub_efi_device_path_t * -EXPORT_FUNC(grub_efi_duplicate_device_path) (const grub_efi_device_path_t *dp); -grub_err_t EXPORT_FUNC (grub_efi_finish_boot_services) (grub_efi_uintn_t *outbuf_size, void *outbuf, - grub_efi_uintn_t *map_key, - grub_efi_uintn_t *efi_desc_size, - grub_efi_uint32_t *efi_desc_version); -grub_err_t EXPORT_FUNC (grub_efi_set_virtual_address_map) (grub_efi_uintn_t memory_map_size, - grub_efi_uintn_t descriptor_size, - grub_efi_uint32_t descriptor_version, - grub_efi_memory_descriptor_t *virtual_map); -void *EXPORT_FUNC (grub_efi_get_variable) (const char *variable, - const grub_efi_guid_t *guid, - grub_size_t *datasize_out); -grub_err_t -EXPORT_FUNC (grub_efi_set_variable) (const char *var, - const grub_efi_guid_t *guid, - void *data, - grub_size_t datasize); -int -EXPORT_FUNC (grub_efi_compare_device_paths) (const grub_efi_device_path_t *dp1, - const grub_efi_device_path_t *dp2); - -void * EXPORT_FUNC (grub_efi_allocate_iso_buf) (grub_uint64_t size); -void * EXPORT_FUNC (grub_efi_allocate_chain_buf) (grub_uint64_t size); -void EXPORT_FUNC (grub_efi_get_reserved_page_num) (grub_uint64_t *total, grub_uint64_t *org_required, grub_uint64_t *new_required); - -extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd, - char **device, - char **path); - -#if defined(__arm__) || defined(__aarch64__) || defined(__riscv) -void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void); -grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *); -#include -grub_err_t grub_arch_efi_linux_check_image(struct linux_arch_kernel_header *lh); -grub_err_t grub_arch_efi_linux_boot_image(grub_addr_t addr, grub_size_t size, - char *args); -#endif - -grub_addr_t grub_efi_modules_addr (void); - -void grub_efi_mm_init (void); -void grub_efi_mm_fini (void); -void grub_efi_init (void); -void grub_efi_fini (void); -void grub_efi_set_prefix (void); - -/* Variables. */ -extern grub_efi_system_table_t *EXPORT_VAR(grub_efi_system_table); -extern grub_efi_handle_t EXPORT_VAR(grub_efi_image_handle); - -extern int EXPORT_VAR(grub_efi_is_finished); - -struct grub_net_card; - -grub_efi_handle_t -grub_efinet_get_device_handle (struct grub_net_card *card); - -#endif /* ! GRUB_EFI_EFI_HEADER */ diff --git a/GRUB2/MOD_SRC/grub-2.04/include/grub/efi/pe32.h b/GRUB2/MOD_SRC/grub-2.04/include/grub/efi/pe32.h index 4543387a..3eaaf108 100644 --- a/GRUB2/MOD_SRC/grub-2.04/include/grub/efi/pe32.h +++ b/GRUB2/MOD_SRC/grub-2.04/include/grub/efi/pe32.h @@ -48,6 +48,17 @@ #define GRUB_PE32_MAGIC 0x5a4d +struct grub_msdos_image_header +{ + /* This is always 'MZ'. (GRUB_PE32_MAGIC) */ + grub_uint16_t msdos_magic; + + grub_uint16_t reserved[29]; + + /* The file offset of the PE image header. */ + grub_uint32_t pe_image_header_offset; +}; + /* According to the spec, the minimal alignment is 512 bytes... But some examples (such as EFI drivers in the Intel Sample Implementation) use 32 bytes (0x20) instead, and it seems @@ -257,11 +268,8 @@ struct grub_pe32_section_table #define GRUB_PE32_SIGNATURE_SIZE 4 -struct grub_pe32_header +struct grub_pe_image_header { - /* This should be filled in with GRUB_PE32_MSDOS_STUB. */ - grub_uint8_t msdos_stub[GRUB_PE32_MSDOS_STUB_SIZE]; - /* This is always PE\0\0. */ char signature[GRUB_PE32_SIGNATURE_SIZE];