diff --git a/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy.c b/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy.c index 41036950..2f1faa34 100644 --- a/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy.c +++ b/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy.c @@ -38,6 +38,7 @@ #include #ifdef GRUB_MACHINE_EFI #include +#include #endif #include #include "ventoy_def.h" @@ -135,6 +136,22 @@ int ventoy_is_efi_os(void) return g_efi_os; } +void * ventoy_alloc_chain(grub_size_t size) +{ + void *p = NULL; + + p = grub_malloc(size); +#ifdef GRUB_MACHINE_EFI + if (!p) + { + p = grub_efi_allocate_any_pages(GRUB_EFI_BYTES_TO_PAGES(size)); + } +#endif + + return p; +} + + static int ventoy_arch_mode_init(void) { #ifdef GRUB_MACHINE_EFI diff --git a/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h b/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h index 27209da6..d1163628 100644 --- a/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h +++ b/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h @@ -1206,6 +1206,7 @@ grub_err_t ventoy_cmd_browser_dir(grub_extcmd_context_t ctxt, int argc, char **a grub_err_t ventoy_cmd_browser_disk(grub_extcmd_context_t ctxt, int argc, char **args); int ventoy_get_fs_type(const char *fs); int ventoy_img_name_valid(const char *filename, grub_size_t namelen); +void * ventoy_alloc_chain(grub_size_t size); #endif /* __VENTOY_DEF_H__ */ diff --git a/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_linux.c b/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_linux.c index 37910c76..244a684e 100644 --- a/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_linux.c +++ b/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_linux.c @@ -1623,10 +1623,10 @@ grub_err_t ventoy_cmd_linux_chain_data(grub_extcmd_context_t ctxt, int argc, cha } } - chain = grub_malloc(size); + chain = ventoy_alloc_chain(size); if (!chain) { - grub_printf("Failed to alloc chain memory size %u\n", size); + grub_printf("Failed to alloc chain linux memory size %u\n", size); grub_file_close(file); return 1; } diff --git a/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_unix.c b/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_unix.c index 8ff21248..005cb5eb 100644 --- a/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_unix.c +++ b/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_unix.c @@ -1185,10 +1185,10 @@ grub_err_t ventoy_cmd_unix_chain_data(grub_extcmd_context_t ctxt, int argc, char } } - chain = grub_malloc(size); + chain = ventoy_alloc_chain(size); if (!chain) { - grub_printf("Failed to alloc chain memory size %u\n", size); + grub_printf("Failed to alloc chain unix memory size %u\n", size); grub_file_close(file); return 1; } diff --git a/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_vhd.c b/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_vhd.c index 7bc7d90f..7aa3e8f0 100644 --- a/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_vhd.c +++ b/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_vhd.c @@ -687,10 +687,10 @@ grub_err_t ventoy_cmd_raw_chain_data(grub_extcmd_context_t ctxt, int argc, char } } - chain = grub_malloc(size); + chain = ventoy_alloc_chain(size); if (!chain) { - grub_printf("Failed to alloc chain memory size %u\n", size); + grub_printf("Failed to alloc chain raw memory size %u\n", size); grub_file_close(file); return 1; } diff --git a/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_windows.c b/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_windows.c index ba956080..23bbc8b7 100644 --- a/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_windows.c +++ b/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_windows.c @@ -1896,10 +1896,10 @@ grub_err_t ventoy_cmd_windows_chain_data(grub_extcmd_context_t ctxt, int argc, c } } - chain = grub_malloc(size); + chain = ventoy_alloc_chain(size); if (!chain) { - grub_printf("Failed to alloc chain memory size %u\n", size); + grub_printf("Failed to alloc chain win1 memory size %u\n", size); grub_file_close(file); return 1; } @@ -2129,10 +2129,10 @@ static grub_err_t ventoy_vlnk_wim_chain_data(grub_file_t wimfile) } } - chain = grub_malloc(size); + chain = ventoy_alloc_chain(size); if (!chain) { - grub_printf("Failed to alloc chain memory size %u\n", size); + grub_printf("Failed to alloc chain win2 memory size %u\n", size); grub_file_close(file); return 1; } @@ -2294,10 +2294,10 @@ static grub_err_t ventoy_normal_wim_chain_data(grub_file_t wimfile) } } - chain = grub_malloc(size); + chain = ventoy_alloc_chain(size); if (!chain) { - grub_printf("Failed to alloc chain memory size %u\n", size); + grub_printf("Failed to alloc chain win3 memory size %u\n", size); grub_file_close(file); return 1; }