attributes:
label: Ventoy Version
description: What version of ventoy are you running?
- placeholder: 1.0.76
+ placeholder: 1.0.78
validations:
required: true
- type: dropdown
ventoy_efi_file_replace g_efi_file_replace;
ventoy_grub_param_file_replace *g_img_replace_list = NULL;
-ventoy_efi_file_replace g_img_file_replace;
+ventoy_efi_file_replace g_img_file_replace[VTOY_MAX_CONF_REPLACE];
CONST CHAR16 gIso9660EfiDriverPath[] = ISO9660_EFI_DRIVER_PATH;
CONST CHAR16 gUdfEfiDriverPath[] = UDF_EFI_DRIVER_PATH;
ventoy_grub_param *pGrubParam = NULL;
EFI_LOADED_IMAGE_PROTOCOL *pImageInfo = NULL;
ventoy_chain_head *chain = NULL;
+ ventoy_grub_param_file_replace *replace = NULL;
Status = gBS->HandleProtocol(ImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **)&pImageInfo);
if (EFI_ERROR(Status))
old_cnt > 3 ? g_file_replace_list->old_file_name[3] : ""
);
- g_img_replace_list = &pGrubParam->img_replace;
- ventoy_proc_img_replace_name(g_img_replace_list);
- old_cnt = g_img_replace_list->old_file_cnt;
- debug("img replace: magic:0x%x virtid:%u name count:%u <%a> <%a> <%a> <%a>",
- g_img_replace_list->magic,
- g_img_replace_list->new_file_virtual_id,
- old_cnt,
- old_cnt > 0 ? g_img_replace_list->old_file_name[0] : "",
- old_cnt > 1 ? g_img_replace_list->old_file_name[1] : "",
- old_cnt > 2 ? g_img_replace_list->old_file_name[2] : "",
- old_cnt > 3 ? g_img_replace_list->old_file_name[3] : ""
- );
+
+ for (i = 0; i < VTOY_MAX_CONF_REPLACE; i++)
+ {
+ replace = pGrubParam->img_replace + i;
+ if (replace->magic == GRUB_IMG_REPLACE_MAGIC)
+ {
+ ventoy_proc_img_replace_name(replace);
+ old_cnt = replace->old_file_cnt;
+ debug("img replace[%d]: magic:0x%x virtid:%u name count:%u <%a> <%a> <%a> <%a>",
+ i, replace->magic,
+ replace->new_file_virtual_id,
+ old_cnt,
+ old_cnt > 0 ? replace->old_file_name[0] : "",
+ old_cnt > 1 ? replace->old_file_name[1] : "",
+ old_cnt > 2 ? replace->old_file_name[2] : "",
+ old_cnt > 3 ? replace->old_file_name[3] : ""
+ );
+ g_img_replace_list = pGrubParam->img_replace;
+ }
+ }
+
pPos = StrStr(pCmdLine, L"mem:");
chain = (ventoy_chain_head *)StrHexToUintn(pPos + 4);
gST->ConIn->Reset(gST->ConIn, FALSE);
}
- if ((g_file_replace_list && g_file_replace_list->magic == GRUB_FILE_REPLACE_MAGIC) ||
- (g_img_replace_list && g_img_replace_list->magic == GRUB_IMG_REPLACE_MAGIC))
+ if ((g_file_replace_list && g_file_replace_list->magic == GRUB_FILE_REPLACE_MAGIC) || g_img_replace_list)
{
ventoy_wrapper_push_openvolume(pFile->OpenVolume);
pFile->OpenVolume = ventoy_wrapper_open_volume;
#pragma pack(1)
+#define VTOY_MAX_CONF_REPLACE 2
#define GRUB_FILE_REPLACE_MAGIC 0x1258BEEF
#define GRUB_IMG_REPLACE_MAGIC 0x1259BEEF
grub_env_get_pf grub_env_get;
grub_env_set_pf grub_env_set;
ventoy_grub_param_file_replace file_replace;
- ventoy_grub_param_file_replace img_replace;
+ ventoy_grub_param_file_replace img_replace[VTOY_MAX_CONF_REPLACE];
grub_env_printf_pf grub_env_printf;
}ventoy_grub_param;
extern UINT32 g_virt_chunk_num;
extern vtoy_block_data gBlockData;
extern ventoy_efi_file_replace g_efi_file_replace;
-extern ventoy_efi_file_replace g_img_file_replace;
+extern ventoy_efi_file_replace g_img_file_replace[VTOY_MAX_CONF_REPLACE];
extern ventoy_sector_flag *g_sector_flag;
extern UINT32 g_sector_flag_num;
extern BOOLEAN gMemdiskMode;
#include <Protocol/DriverBinding.h>
#include <Ventoy.h>
-#define ASSIGN_REPLACE(This, replace) \
- replace = (This->FlushEx == ventoy_wrapper_file_flush_ex) ? &g_efi_file_replace : &g_img_file_replace
-
UINT8 *g_iso_data_buf = NULL;
UINTN g_iso_buf_size = 0;
BOOLEAN gMemdiskMode = FALSE;
/* Ex version */
STATIC EFI_STATUS EFIAPI
-ventoy_wrapper_file_flush_ex_img(EFI_FILE_HANDLE This, EFI_FILE_IO_TOKEN *Token)
+ventoy_wrapper_file_flush_ex_img0(EFI_FILE_HANDLE This, EFI_FILE_IO_TOKEN *Token)
+{
+ (VOID)This;
+ (VOID)Token;
+ return EFI_SUCCESS;
+}
+/* Ex version */
+STATIC EFI_STATUS EFIAPI
+ventoy_wrapper_file_flush_ex_img1(EFI_FILE_HANDLE This, EFI_FILE_IO_TOKEN *Token)
{
(VOID)This;
(VOID)Token;
return EFI_SUCCESS;
}
+#define DEF_WRAP_FUNC(n) \
+STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_flush_ex_img#n(EFI_FILE_HANDLE This, EFI_FILE_IO_TOKEN *Token) \
+{\
+ (VOID)This;\
+ (VOID)Token;\
+ return EFI_SUCCESS;\
+}
+
+#define ITEM_WRAP_FUNC(n) ventoy_wrapper_file_flush_ex_img#n
+
+#if (VTOY_MAX_CONF_REPLACE > 2)
+DEF_WRAP_FUNC(2);
+#endif
+#if (VTOY_MAX_CONF_REPLACE > 3)
+DEF_WRAP_FUNC(3);
+#endif
+#if (VTOY_MAX_CONF_REPLACE > 4)
+DEF_WRAP_FUNC(4);
+#endif
+#if (VTOY_MAX_CONF_REPLACE > 5)
+DEF_WRAP_FUNC(5);
+#endif
+#if (VTOY_MAX_CONF_REPLACE > 6)
+DEF_WRAP_FUNC(6);
+#endif
+#if (VTOY_MAX_CONF_REPLACE > 7)
+DEF_WRAP_FUNC(7);
+#endif
+#if (VTOY_MAX_CONF_REPLACE > 8)
+#error "VTOY_MAX_CONF_REPLACE overflow"
+#endif
+
+static EFI_FILE_FLUSH_EX g_img_flush_func[VTOY_MAX_CONF_REPLACE] =
+{
+ ventoy_wrapper_file_flush_ex_img0,
+ ventoy_wrapper_file_flush_ex_img1,
+#if (VTOY_MAX_CONF_REPLACE > 2)
+ ITEM_WRAP_FUNC(2),
+#endif
+#if (VTOY_MAX_CONF_REPLACE > 3)
+ ITEM_WRAP_FUNC(3),
+#endif
+#if (VTOY_MAX_CONF_REPLACE > 4)
+ ITEM_WRAP_FUNC(4),
+#endif
+#if (VTOY_MAX_CONF_REPLACE > 5)
+ ITEM_WRAP_FUNC(5),
+#endif
+#if (VTOY_MAX_CONF_REPLACE > 6)
+ ITEM_WRAP_FUNC(6),
+#endif
+#if (VTOY_MAX_CONF_REPLACE > 7)
+ ITEM_WRAP_FUNC(7),
+#endif
+};
+
+STATIC ventoy_efi_file_replace *ventoy_wrapper_get_replace(EFI_FILE_HANDLE This)
+{
+ UINTN i;
+
+ if (This->FlushEx == ventoy_wrapper_file_flush_ex)
+ {
+ return &g_efi_file_replace;
+ }
+
+ for (i = 0; i < VTOY_MAX_CONF_REPLACE; i++)
+ {
+ if (This->FlushEx == g_img_flush_func[i])
+ {
+ return g_img_file_replace + i;
+ }
+ }
+
+ return NULL;
+}
STATIC EFI_STATUS EFIAPI
ventoy_wrapper_file_write(EFI_FILE_HANDLE This, UINTN *Len, VOID *Data)
{
ventoy_efi_file_replace *replace = NULL;
- ASSIGN_REPLACE(This, replace);
+ replace = ventoy_wrapper_get_replace(This);
if (Position <= replace->FileSizeBytes)
{
{
ventoy_efi_file_replace *replace = NULL;
- ASSIGN_REPLACE(This, replace);
+ replace = ventoy_wrapper_get_replace(This);
*Position = replace->CurPos;
EFI_FILE_INFO *Info = (EFI_FILE_INFO *) Data;
ventoy_efi_file_replace *replace = NULL;
- ASSIGN_REPLACE(This, replace);
+ replace = ventoy_wrapper_get_replace(This);
debug("ventoy_wrapper_file_get_info ... %u", *Len);
UINTN ReadLen = *Len;
ventoy_efi_file_replace *replace = NULL;
- ASSIGN_REPLACE(This, replace);
+ replace = ventoy_wrapper_get_replace(This);
debug("ventoy_wrapper_file_read ... %u", *Len);
return ventoy_wrapper_file_read(This, &(Token->BufferSize), Token->Buffer);
}
-STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_procotol(EFI_FILE_PROTOCOL *File, BOOLEAN Img)
+STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_procotol(EFI_FILE_PROTOCOL *File, BOOLEAN Img, UINTN Index)
{
File->Revision = EFI_FILE_PROTOCOL_REVISION2;
File->Open = ventoy_wrapper_fs_open;
File->OpenEx = ventoy_wrapper_file_open_ex;
File->ReadEx = ventoy_wrapper_file_read_ex;
File->WriteEx = ventoy_wrapper_file_write_ex;
- File->FlushEx = Img ? ventoy_wrapper_file_flush_ex_img : ventoy_wrapper_file_flush_ex;
+
+ if (Img)
+ {
+ File->FlushEx = g_img_flush_func[Index];
+ }
+ else
+ {
+ File->FlushEx = ventoy_wrapper_file_flush_ex;
+ }
return EFI_SUCCESS;
}
CHAR8 TmpName[256];
CHAR8 OldName[256];
ventoy_virt_chunk *virt = NULL;
+ ventoy_grub_param_file_replace *replace = NULL;
debug("## ventoy_wrapper_file_open <%s> ", Name);
{
g_original_fclose(*New);
*New = &g_efi_file_replace.WrapperHandle;
- ventoy_wrapper_file_procotol(*New, FALSE);
+ ventoy_wrapper_file_procotol(*New, FALSE, 0);
virt = g_virt_chunk + g_file_replace_list->new_file_virtual_id;
}
}
-
-
- if (g_img_replace_list && g_img_replace_list->magic == GRUB_IMG_REPLACE_MAGIC &&
- g_img_replace_list->new_file_virtual_id < g_virt_chunk_num)
+ for (i = 0; g_img_replace_list && i < VTOY_MAX_CONF_REPLACE; i++)
{
+ replace = g_img_replace_list + i;
+ if (replace->magic != GRUB_IMG_REPLACE_MAGIC || replace->new_file_virtual_id >= g_virt_chunk_num)
+ {
+ continue;
+ }
+
AsciiSPrint(TmpName, sizeof(TmpName), "%s", Name);
- for (j = 0; j < g_img_replace_list->old_file_cnt; j++)
+ for (j = 0; j < replace->old_file_cnt; j++)
{
- AsciiStrCpyS(OldName, sizeof(OldName), g_img_replace_list[i].old_file_name[j]);
+ AsciiStrCpyS(OldName, sizeof(OldName), replace->old_file_name[j]);
if ((0 == AsciiStrCmp(OldName, TmpName)) ||
(AsciiStrnCmp(OldName, "\\loader\\entries\\", 16) == 0 &&
AsciiStrCmp(OldName + 16, TmpName) == 0
)
{
g_original_fclose(*New);
- *New = &g_img_file_replace.WrapperHandle;
- ventoy_wrapper_file_procotol(*New, TRUE);
+ *New = &(g_img_file_replace[i].WrapperHandle);
+ ventoy_wrapper_file_procotol(*New, TRUE, i);
- virt = g_virt_chunk + g_img_replace_list->new_file_virtual_id;
+ virt = g_virt_chunk + replace->new_file_virtual_id;
Sectors = (virt->mem_sector_end - virt->mem_sector_start) + (virt->remap_sector_end - virt->remap_sector_start);
- g_img_file_replace.BlockIoSectorStart = virt->mem_sector_start;
- g_img_file_replace.FileSizeBytes = Sectors * 2048;
+ g_img_file_replace[i].BlockIoSectorStart = virt->mem_sector_start;
+ g_img_file_replace[i].FileSizeBytes = Sectors * 2048;
if (gDebugPrint)
{
debug("## ventoy_wrapper_file_open2 <%s> BlockStart:%lu Sectors:%lu Bytes:%lu", Name,
- g_img_file_replace.BlockIoSectorStart, Sectors, Sectors * 2048);
+ g_img_file_replace[i].BlockIoSectorStart, Sectors, Sectors * 2048);
sleep(3);
}
return Status;
}
}
+ }
- if (StrCmp(Name, L"\\loader\\entries") == 0)
- {
- (*New)->Open = ventoy_wrapper_file_open;
- }
+ if (g_img_replace_list && StrCmp(Name, L"\\loader\\entries") == 0)
+ {
+ (*New)->Open = ventoy_wrapper_file_open;
}
return Status;
typedef const char * (*grub_env_get_pf)(const char *name);
typedef int (*grub_env_printf_pf)(const char *fmt, ...);
+#define VTOY_MAX_CONF_REPLACE 2
+
typedef struct ventoy_grub_param_file_replace
{
UINT32 magic;
grub_env_get_pf grub_env_get;
grub_env_set_pf grub_env_set;
ventoy_grub_param_file_replace file_replace;
- ventoy_grub_param_file_replace img_replace;
+ ventoy_grub_param_file_replace img_replace[VTOY_MAX_CONF_REPLACE];
grub_env_printf_pf grub_env_printf;
}ventoy_grub_param;
#pragma pack()
int g_vhdboot_enable = 0;
-grub_uint64_t g_conf_replace_offset = 0;
grub_uint64_t g_svd_replace_offset = 0;
-conf_replace *g_conf_replace_node = NULL;
-grub_uint8_t *g_conf_replace_new_buf = NULL;
-int g_conf_replace_new_len = 0;
-int g_conf_replace_new_len_align = 0;
+
+int g_conf_replace_count = 0;
+grub_uint64_t g_conf_replace_offset[VTOY_MAX_CONF_REPLACE] = { 0 };
+conf_replace *g_conf_replace_node[VTOY_MAX_CONF_REPLACE] = { NULL };
+grub_uint8_t *g_conf_replace_new_buf[VTOY_MAX_CONF_REPLACE] = { NULL };
+int g_conf_replace_new_len[VTOY_MAX_CONF_REPLACE] = { 0 };
+int g_conf_replace_new_len_align[VTOY_MAX_CONF_REPLACE] = { 0 };
int g_ventoy_disk_bios_id = 0;
ventoy_gpt_info *g_ventoy_part_info = NULL;
return grub_error(GRUB_ERR_BAD_ARGUMENT, "Can't open file %s\n", args[0]);
}
- g_conf_replace_node = NULL;
- g_conf_replace_offset = 0;
+ g_conf_replace_count = 0;
+ grub_memset(g_conf_replace_node, 0, sizeof(g_conf_replace_node ));
+ grub_memset(g_conf_replace_offset, 0, sizeof(g_conf_replace_offset ));
if (g_img_chunk_list.chunk)
{
static grub_err_t ventoy_select_conf_replace(grub_extcmd_context_t ctxt, int argc, char **args)
{
+ int i;
+ int n;
grub_uint64_t offset = 0;
grub_uint32_t align = 0;
grub_file_t file = NULL;
conf_replace *node = NULL;
-
+ conf_replace *nodes[VTOY_MAX_CONF_REPLACE] = { NULL };
+ ventoy_grub_param_file_replace *replace = NULL;
+
(void)ctxt;
(void)argc;
(void)args;
return 0;
}
- node = ventoy_plugin_find_conf_replace(args[1]);
- if (!node)
+ n = ventoy_plugin_find_conf_replace(args[1], nodes);
+ if (!n)
{
debug("Conf replace not found for %s\n", args[1]);
goto end;
}
- debug("Find conf replace for %s\n", args[1]);
+ debug("Find %d conf replace for %s\n", n, args[1]);
- file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "(loop)%s", node->orgconf);
- if (file)
+ g_conf_replace_count = n;
+ for (i = 0; i < n; i++)
{
- offset = grub_iso9660_get_last_file_dirent_pos(file);
- grub_file_close(file);
- }
- else if (node->img > 0)
- {
- offset = 0;
- }
- else
- {
- debug("<(loop)%s> NOT exist\n", node->orgconf);
- goto end;
- }
+ node = nodes[i];
- file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s%s", args[0], node->newconf);
- if (!file)
- {
- debug("New config file <%s%s> NOT exist\n", args[0], node->newconf);
- goto end;
- }
+ file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "(loop)%s", node->orgconf);
+ if (file)
+ {
+ offset = grub_iso9660_get_last_file_dirent_pos(file);
+ grub_file_close(file);
+ }
+ else if (node->img > 0)
+ {
+ offset = 0;
+ }
+ else
+ {
+ debug("<(loop)%s> NOT exist\n", node->orgconf);
+ continue;
+ }
- align = ((int)file->size + 2047) / 2048 * 2048;
+ file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s%s", args[0], node->newconf);
+ if (!file)
+ {
+ debug("New config file <%s%s> NOT exist\n", args[0], node->newconf);
+ continue;
+ }
- if (align > vtoy_max_replace_file_size)
- {
- debug("New config file <%s%s> too big\n", args[0], node->newconf);
- goto end;
- }
+ align = ((int)file->size + 2047) / 2048 * 2048;
- grub_file_read(file, g_conf_replace_new_buf, file->size);
- g_conf_replace_new_len = (int)file->size;
- g_conf_replace_new_len_align = align;
+ if (align > vtoy_max_replace_file_size)
+ {
+ debug("New config file <%s%s> too big\n", args[0], node->newconf);
+ grub_file_close(file);
+ continue;
+ }
- g_conf_replace_node = node;
- g_conf_replace_offset = offset + 2;
+ grub_file_read(file, g_conf_replace_new_buf[i], file->size);
+ grub_file_close(file);
+ g_conf_replace_new_len[i] = (int)file->size;
+ g_conf_replace_new_len_align[i] = align;
- if (node->img > 0)
- {
- g_grub_param->img_replace.magic = GRUB_IMG_REPLACE_MAGIC;
- g_grub_param->img_replace.old_name_cnt = 1;
- grub_snprintf(g_grub_param->img_replace.old_file_name[0], 256, "%s", node->orgconf);
- }
+ g_conf_replace_node[i] = node;
+ g_conf_replace_offset[i] = offset + 2;
- debug("conf_replace OK: newlen: %d\n", g_conf_replace_new_len);
+ if (node->img > 0)
+ {
+ replace = &(g_grub_param->img_replace[i]);
+ replace->magic = GRUB_IMG_REPLACE_MAGIC;
+ grub_snprintf(replace->old_file_name[replace->old_name_cnt], 256, "%s", node->orgconf);
+ replace->old_name_cnt++;
+ }
-end:
- if (file)
- {
- grub_file_close(file);
+ debug("conf_replace OK: newlen[%d]: %d img:%d\n", i, g_conf_replace_new_len[i], node->img);
}
+
+end:
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
int ventoy_env_init(void)
{
+ int i;
char buf[64];
grub_env_set("vtdebug_flag", "");
g_part_list_buf = grub_malloc(VTOY_PART_BUF_LEN);
g_tree_script_buf = grub_malloc(VTOY_MAX_SCRIPT_BUF);
g_list_script_buf = grub_malloc(VTOY_MAX_SCRIPT_BUF);
- g_conf_replace_new_buf = grub_malloc(vtoy_max_replace_file_size);
+ for (i = 0; i < VTOY_MAX_CONF_REPLACE; i++)
+ {
+ g_conf_replace_new_buf[i] = grub_malloc(vtoy_max_replace_file_size);
+ }
ventoy_filt_register(0, ventoy_wrapper_open);
struct custom_boot *next;
}custom_boot;
-#define vtoy_max_replace_file_size (2 * 1024 * 1024)
+#define vtoy_max_replace_file_size (1024 * 1024)
typedef struct conf_replace
{
int pathlen;
extern int g_plugin_image_list;
extern ventoy_gpt_info *g_ventoy_part_info;
-extern grub_uint64_t g_conf_replace_offset;
+extern int g_conf_replace_count;
+extern grub_uint64_t g_conf_replace_offset[VTOY_MAX_CONF_REPLACE];
extern grub_uint64_t g_svd_replace_offset;
-extern conf_replace *g_conf_replace_node;
-extern grub_uint8_t *g_conf_replace_new_buf;
-extern int g_conf_replace_new_len;
-extern int g_conf_replace_new_len_align;
+extern conf_replace *g_conf_replace_node[VTOY_MAX_CONF_REPLACE];
+extern grub_uint8_t *g_conf_replace_new_buf[VTOY_MAX_CONF_REPLACE];
+extern int g_conf_replace_new_len[VTOY_MAX_CONF_REPLACE];
+extern int g_conf_replace_new_len_align[VTOY_MAX_CONF_REPLACE];
extern int g_ventoy_disk_bios_id;
extern grub_uint64_t g_ventoy_disk_size;
extern grub_uint64_t g_ventoy_disk_part_size[2];
const char * ventoy_plugin_get_menu_class(int type, const char *name, const char *path);
int ventoy_plugin_check_memdisk(const char *isopath);
int ventoy_plugin_get_image_list_index(int type, const char *name);
-conf_replace * ventoy_plugin_find_conf_replace(const char *iso);
+int ventoy_plugin_find_conf_replace(const char *iso, conf_replace *nodes[VTOY_MAX_CONF_REPLACE]);
dud * ventoy_plugin_find_dud(const char *iso);
int ventoy_plugin_load_dud(dud *node, const char *isopart);
int ventoy_get_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, grub_disk_addr_t start);
static grub_uint32_t ventoy_linux_get_virt_chunk_count(void)
{
+ int i;
grub_uint32_t count = g_valid_initrd_count;
- if (g_conf_replace_offset > 0)
+ if (g_conf_replace_count > 0)
{
- count++;
+ for (i = 0; i < g_conf_replace_count; i++)
+ {
+ if (g_conf_replace_offset[i] > 0)
+ {
+ count++;
+ }
+ }
}
if (g_append_ext_sector > 0)
static grub_uint32_t ventoy_linux_get_virt_chunk_size(void)
{
+ int i;
grub_uint32_t size;
size = (sizeof(ventoy_virt_chunk) + g_ventoy_cpio_size) * g_valid_initrd_count;
-
- if (g_conf_replace_offset > 0)
+
+ if (g_conf_replace_count > 0)
{
- size += sizeof(ventoy_virt_chunk) + g_conf_replace_new_len_align;
+ for (i = 0; i < g_conf_replace_count; i++)
+ {
+ if (g_conf_replace_offset[i] > 0)
+ {
+ size += sizeof(ventoy_virt_chunk) + g_conf_replace_new_len_align[i];
+ }
+ }
}
if (g_append_ext_sector > 0)
static void ventoy_linux_fill_virt_data( grub_uint64_t isosize, ventoy_chain_head *chain)
{
+ int i = 0;
int id = 0;
int virtid = 0;
initrd_info *node;
grub_uint32_t initrd_secs;
char *override;
ventoy_virt_chunk *cur;
+ ventoy_grub_param_file_replace *replace = NULL;
char name[32];
override = (char *)chain + chain->virt_chunk_offset;
virtid++;
}
- if (g_conf_replace_offset > 0)
+ if (g_conf_replace_count > 0)
{
- cpio_secs = g_conf_replace_new_len_align / 2048;
-
- cur->mem_sector_start = sector;
- cur->mem_sector_end = cur->mem_sector_start + cpio_secs;
- cur->mem_sector_offset = offset;
- cur->remap_sector_start = 0;
- cur->remap_sector_end = 0;
- cur->org_sector_start = 0;
+ for (i = 0; i < g_conf_replace_count; i++)
+ {
+ if (g_conf_replace_offset[i] > 0)
+ {
+ cpio_secs = g_conf_replace_new_len_align[i] / 2048;
+
+ cur->mem_sector_start = sector;
+ cur->mem_sector_end = cur->mem_sector_start + cpio_secs;
+ cur->mem_sector_offset = offset;
+ cur->remap_sector_start = 0;
+ cur->remap_sector_end = 0;
+ cur->org_sector_start = 0;
- grub_memcpy(override + offset, g_conf_replace_new_buf, g_conf_replace_new_len);
+ grub_memcpy(override + offset, g_conf_replace_new_buf[i], g_conf_replace_new_len[i]);
- chain->virt_img_size_in_bytes += g_conf_replace_new_len_align;
+ chain->virt_img_size_in_bytes += g_conf_replace_new_len_align[i];
- if (g_grub_param->img_replace.magic == GRUB_IMG_REPLACE_MAGIC)
- {
- g_grub_param->img_replace.new_file_virtual_id = virtid;
- }
+ replace = g_grub_param->img_replace + i;
+ if (replace->magic == GRUB_IMG_REPLACE_MAGIC)
+ {
+ replace->new_file_virtual_id = virtid;
+ }
- offset += g_conf_replace_new_len_align;
- sector += cpio_secs;
- cur++;
- virtid++;
+ offset += g_conf_replace_new_len_align[i];
+ sector += cpio_secs;
+ cur++;
+ virtid++;
+ }
+ }
}
return;
static grub_uint32_t ventoy_linux_get_override_chunk_count(void)
{
+ int i;
grub_uint32_t count = g_valid_initrd_count;
-
- if (g_conf_replace_offset > 0)
+
+ if (g_conf_replace_count > 0)
{
- count++;
+ for (i = 0; i < g_conf_replace_count; i++)
+ {
+ if (g_conf_replace_offset[i] > 0)
+ {
+ count++;
+ }
+ }
}
if (g_svd_replace_offset > 0)
static grub_uint32_t ventoy_linux_get_override_chunk_size(void)
{
+ int i;
int count = g_valid_initrd_count;
-
- if (g_conf_replace_offset > 0)
+
+ if (g_conf_replace_count > 0)
{
- count++;
+ for (i = 0; i < g_conf_replace_count; i++)
+ {
+ if (g_conf_replace_offset[i] > 0)
+ {
+ count++;
+ }
+ }
}
if (g_svd_replace_offset > 0)
static void ventoy_linux_fill_override_data( grub_uint64_t isosize, void *override)
{
+ int i;
initrd_info *node;
grub_uint32_t mod;
grub_uint32_t newlen;
cur++;
}
- if (g_conf_replace_offset > 0)
- {
- cur->img_offset = g_conf_replace_offset;
- cur->override_size = sizeof(ventoy_iso9660_override);
+ if (g_conf_replace_count > 0)
+ {
+ for (i = 0; i < g_conf_replace_count; i++)
+ {
+ if (g_conf_replace_offset[i] > 0)
+ {
+ cur->img_offset = g_conf_replace_offset[i];
+ cur->override_size = sizeof(ventoy_iso9660_override);
- newlen = (grub_uint32_t)(g_conf_replace_new_len);
+ newlen = (grub_uint32_t)(g_conf_replace_new_len[i]);
- dirent = (ventoy_iso9660_override *)cur->override_data;
- dirent->first_sector = (grub_uint32_t)sector;
- dirent->size = newlen;
- dirent->first_sector_be = grub_swap_bytes32(dirent->first_sector);
- dirent->size_be = grub_swap_bytes32(dirent->size);
+ dirent = (ventoy_iso9660_override *)cur->override_data;
+ dirent->first_sector = (grub_uint32_t)sector;
+ dirent->size = newlen;
+ dirent->first_sector_be = grub_swap_bytes32(dirent->first_sector);
+ dirent->size_be = grub_swap_bytes32(dirent->size);
- sector += (dirent->size + 2047) / 2048;
- cur++;
+ sector += (dirent->size + 2047) / 2048;
+ cur++;
+ }
+ }
}
-
+
if (g_svd_replace_offset > 0)
{
cur->img_offset = g_svd_replace_offset;
return 0;
}
-conf_replace * ventoy_plugin_find_conf_replace(const char *iso)
+int ventoy_plugin_find_conf_replace(const char *iso, conf_replace *nodes[VTOY_MAX_CONF_REPLACE])
{
+ int n = 0;
int len;
conf_replace *node;
if (!g_conf_replace_head)
{
- return NULL;
+ return 0;
}
len = (int)grub_strlen(iso);
{
if (node->pathlen == len && ventoy_strncmp(node->isopath, iso, len) == 0)
{
- return node;
+ nodes[n++] = node;
+ if (n >= VTOY_MAX_CONF_REPLACE)
+ {
+ return n;
+ }
}
}
- return NULL;
+ return n;
}
dud * ventoy_plugin_find_dud(const char *iso)
#pragma pack(1)
+#define VTOY_MAX_CONF_REPLACE 2
#define GRUB_FILE_REPLACE_MAGIC 0x1258BEEF
#define GRUB_IMG_REPLACE_MAGIC 0x1259BEEF
grub_env_get_pf grub_env_get;
grub_env_set_pf grub_env_set;
ventoy_grub_param_file_replace file_replace;
- ventoy_grub_param_file_replace img_replace;
+ ventoy_grub_param_file_replace img_replace[VTOY_MAX_CONF_REPLACE];
grub_env_printf_pf grub_env_printf;
}ventoy_grub_param;
#############################################################
#############################################################
-set VENTOY_VERSION="1.0.77"
+set VENTOY_VERSION="1.0.78"
#ACPI not compatible with Window7/8, so disable by default
set VTOY_PARAM_NO_ACPI=1
x86 Legacy BIOS, IA32 UEFI, x86_64 UEFI, ARM64 UEFI and MIPS64EL UEFI are supported in the same way.<br/>
Both MBR and GPT partition style are supported in the same way.<br/>
Most type of OS supported(Windows/WinPE/Linux/Unix/ChromeOS/Vmware/Xen...) <br/>
- 900+ ISO files are tested (<a href="https://www.ventoy.net/en/isolist.html">List</a>). 90%+ distros in <a href="https://distrowatch.com/">distrowatch.com</a> supported (<a href="https://www.ventoy.net/en/distrowatch.html">Details</a>). <br/>
+ 920+ ISO files are tested (<a href="https://www.ventoy.net/en/isolist.html">List</a>). 90%+ distros in <a href="https://distrowatch.com/">distrowatch.com</a> supported (<a href="https://www.ventoy.net/en/distrowatch.html">Details</a>). <br/>
<br/>Official Website: <a href=https://www.ventoy.net>https://www.ventoy.net</a>
</h4>
* FAT32/exFAT/NTFS/UDF/XFS/Ext2(3)(4) supported for main partition
* ISO files larger than 4GB supported
* Native boot menu style for Legacy & UEFI
-* Most types of OS supported, 900+ iso files tested
+* Most types of OS supported, 920+ iso files tested
* Linux vDisk boot supported
* Not only boot but also complete installation process
* Menu dynamically switchable between List/TreeView mode