1.0.78 release

This commit is contained in:
longpanda 2022-07-01 19:10:12 +08:00
parent 0b81845e42
commit e46e24dde7
24 changed files with 338 additions and 167 deletions

View File

@ -21,7 +21,7 @@ body:
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

View File

@ -60,7 +60,7 @@ ventoy_grub_param_file_replace *g_file_replace_list = NULL;
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;
@ -829,6 +829,7 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
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))
@ -926,18 +927,27 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
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);
@ -1178,8 +1188,7 @@ EFI_STATUS EFIAPI ventoy_boot(IN EFI_HANDLE ImageHandle)
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;

View File

@ -244,6 +244,7 @@ typedef int (*grub_env_printf_pf)(const char *fmt, ...);
#pragma pack(1)
#define VTOY_MAX_CONF_REPLACE 2
#define GRUB_FILE_REPLACE_MAGIC 0x1258BEEF
#define GRUB_IMG_REPLACE_MAGIC 0x1259BEEF
@ -270,7 +271,7 @@ typedef struct ventoy_grub_param
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;
@ -400,7 +401,7 @@ extern ventoy_virt_chunk *g_virt_chunk;
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;

View File

@ -37,9 +37,6 @@
#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;
@ -1251,13 +1248,96 @@ ventoy_wrapper_file_flush_ex(EFI_FILE_HANDLE This, EFI_FILE_IO_TOKEN *Token)
/* 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)
@ -1288,7 +1368,7 @@ ventoy_wrapper_file_set_pos(EFI_FILE_HANDLE This, UINT64 Position)
{
ventoy_efi_file_replace *replace = NULL;
ASSIGN_REPLACE(This, replace);
replace = ventoy_wrapper_get_replace(This);
if (Position <= replace->FileSizeBytes)
{
@ -1307,7 +1387,7 @@ ventoy_wrapper_file_get_pos(EFI_FILE_HANDLE This, UINT64 *Position)
{
ventoy_efi_file_replace *replace = NULL;
ASSIGN_REPLACE(This, replace);
replace = ventoy_wrapper_get_replace(This);
*Position = replace->CurPos;
@ -1321,7 +1401,7 @@ ventoy_wrapper_file_get_info(EFI_FILE_HANDLE This, EFI_GUID *Type, UINTN *Len, V
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);
@ -1356,7 +1436,7 @@ ventoy_wrapper_file_read(EFI_FILE_HANDLE This, UINTN *Len, VOID *Data)
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);
@ -1382,7 +1462,7 @@ ventoy_wrapper_file_read_ex(IN EFI_FILE_PROTOCOL *This, IN OUT EFI_FILE_IO_TOKEN
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;
@ -1398,7 +1478,15 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_procotol(EFI_FILE_PROTOCOL *File, B
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;
}
@ -1419,6 +1507,7 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
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);
@ -1449,7 +1538,7 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
{
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;
@ -1475,15 +1564,18 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
}
}
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++)
{
AsciiSPrint(TmpName, sizeof(TmpName), "%s", Name);
for (j = 0; j < g_img_replace_list->old_file_cnt; j++)
replace = g_img_replace_list + i;
if (replace->magic != GRUB_IMG_REPLACE_MAGIC || replace->new_file_virtual_id >= g_virt_chunk_num)
{
AsciiStrCpyS(OldName, sizeof(OldName), g_img_replace_list[i].old_file_name[j]);
continue;
}
AsciiSPrint(TmpName, sizeof(TmpName), "%s", Name);
for (j = 0; j < replace->old_file_cnt; 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
@ -1491,31 +1583,31 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
)
{
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;

View File

@ -28,6 +28,8 @@ typedef int (*grub_env_set_pf)(const char *name, const char *val);
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;
@ -41,7 +43,7 @@ typedef struct ventoy_grub_param
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()

View File

@ -107,12 +107,14 @@ grub_uint32_t g_wimiso_size = 0;
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;
@ -3250,8 +3252,9 @@ static grub_err_t ventoy_cmd_img_sector(grub_extcmd_context_t ctxt, int argc, ch
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)
{
@ -3294,11 +3297,15 @@ static grub_err_t ventoy_cmd_img_sector(grub_extcmd_context_t ctxt, int argc, ch
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;
@ -3310,67 +3317,72 @@ static grub_err_t ventoy_select_conf_replace(grub_extcmd_context_t ctxt, int arg
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);
node = nodes[i];
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;
}
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;
}
align = ((int)file->size + 2047) / 2048 * 2048;
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;
}
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;
g_conf_replace_node[i] = node;
g_conf_replace_offset[i] = offset + 2;
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++;
}
debug("conf_replace OK: newlen[%d]: %d img:%d\n", i, g_conf_replace_new_len[i], node->img);
}
else if (node->img > 0)
{
offset = 0;
}
else
{
debug("<(loop)%s> NOT exist\n", node->orgconf);
goto end;
}
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;
}
align = ((int)file->size + 2047) / 2048 * 2048;
if (align > vtoy_max_replace_file_size)
{
debug("New config file <%s%s> too big\n", args[0], node->newconf);
goto end;
}
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;
g_conf_replace_node = node;
g_conf_replace_offset = offset + 2;
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);
}
debug("conf_replace OK: newlen: %d\n", g_conf_replace_new_len);
end:
if (file)
{
grub_file_close(file);
}
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
@ -5945,6 +5957,7 @@ static grub_err_t ventoy_cmd_dump_rsv_page(grub_extcmd_context_t ctxt, int argc,
int ventoy_env_init(void)
{
int i;
char buf[64];
grub_env_set("vtdebug_flag", "");
@ -5952,7 +5965,10 @@ int ventoy_env_init(void)
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);

View File

@ -960,7 +960,7 @@ typedef struct custom_boot
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;
@ -1046,12 +1046,13 @@ extern int g_vhdboot_enable;
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];
@ -1095,7 +1096,7 @@ const menu_tip * ventoy_plugin_get_menu_tip(int type, const char *isopath);
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);

View File

@ -654,11 +654,18 @@ int ventoy_cpio_newc_fill_head(void *buf, int filesize, const void *filedata, co
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)
@ -671,13 +678,20 @@ static grub_uint32_t ventoy_linux_get_virt_chunk_count(void)
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)
@ -690,6 +704,7 @@ static grub_uint32_t ventoy_linux_get_virt_chunk_size(void)
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;
@ -699,6 +714,7 @@ static void ventoy_linux_fill_virt_data( grub_uint64_t isosize, ventoy_chain_
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;
@ -764,30 +780,37 @@ static void ventoy_linux_fill_virt_data( grub_uint64_t isosize, ventoy_chain_
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;
grub_memcpy(override + offset, g_conf_replace_new_buf, g_conf_replace_new_len);
chain->virt_img_size_in_bytes += g_conf_replace_new_len_align;
if (g_grub_param->img_replace.magic == GRUB_IMG_REPLACE_MAGIC)
for (i = 0; i < g_conf_replace_count; i++)
{
g_grub_param->img_replace.new_file_virtual_id = virtid;
}
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;
offset += g_conf_replace_new_len_align;
sector += cpio_secs;
cur++;
virtid++;
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[i];
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[i];
sector += cpio_secs;
cur++;
virtid++;
}
}
}
return;
@ -795,11 +818,18 @@ static void ventoy_linux_fill_virt_data( grub_uint64_t isosize, ventoy_chain_
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)
@ -812,11 +842,18 @@ static grub_uint32_t ventoy_linux_get_override_chunk_count(void)
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)
@ -829,6 +866,7 @@ static grub_uint32_t ventoy_linux_get_override_chunk_size(void)
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;
@ -883,23 +921,29 @@ static void ventoy_linux_fill_override_data( grub_uint64_t isosize, void *ove
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;

View File

@ -3054,14 +3054,15 @@ int ventoy_plugin_get_image_list_index(int type, const char *name)
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);
@ -3070,11 +3071,15 @@ conf_replace * ventoy_plugin_find_conf_replace(const char *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)

View File

@ -262,6 +262,7 @@ typedef struct ventoy_img_chunk_list
#pragma pack(1)
#define VTOY_MAX_CONF_REPLACE 2
#define GRUB_FILE_REPLACE_MAGIC 0x1258BEEF
#define GRUB_IMG_REPLACE_MAGIC 0x1259BEEF
@ -282,7 +283,7 @@ typedef struct ventoy_grub_param
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;

View File

@ -2145,7 +2145,7 @@ function img_unsupport_menuentry {
#############################################################
#############################################################
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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -18,7 +18,7 @@ You can also browse ISO/WIM/IMG/VHD(x)/EFI files in local disk and boot them.<br
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>
@ -70,7 +70,7 @@ A GUI Ventoy plugin configurator. [VentoyPlugson](https://www.ventoy.net/en/plug
* 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