diff --git a/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c b/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c index e4f42750..2c4e0e06 100644 --- a/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c +++ b/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c @@ -3659,12 +3659,12 @@ static grub_err_t ventoy_cmd_sel_auto_install(grub_extcmd_context_t ctxt, int ar vtoy_ssprintf(buf, pos, "set timeout=%d\n", node->timeout); } - vtoy_ssprintf(buf, pos, "menuentry \"Boot without auto installation template\" {\n" + vtoy_ssprintf(buf, pos, "menuentry \"Boot without auto installation template\" --class=\"sel_auto_install\" {\n" " echo %s\n}\n", ""); for (i = 0; i < node->templatenum; i++) { - vtoy_ssprintf(buf, pos, "menuentry \"Boot with %s\"{\n" + vtoy_ssprintf(buf, pos, "menuentry \"Boot with %s\" --class=\"sel_auto_install\" {\n" " echo \"\"\n}\n", node->templatepath[i].path); } @@ -3765,12 +3765,12 @@ static grub_err_t ventoy_cmd_sel_persistence(grub_extcmd_context_t ctxt, int arg vtoy_ssprintf(buf, pos, "set timeout=%d\n", node->timeout); } - vtoy_ssprintf(buf, pos, "menuentry \"Boot without persistence\" {\n" + vtoy_ssprintf(buf, pos, "menuentry \"Boot without persistence\" --class=\"sel_persistence\" {\n" " echo %s\n}\n", ""); for (i = 0; i < node->backendnum; i++) { - vtoy_ssprintf(buf, pos, "menuentry \"Boot with %s\" {\n" + vtoy_ssprintf(buf, pos, "menuentry \"Boot with %s\" --class=\"sel_persistence\" {\n" " echo \"\"\n}\n", node->backendpath[i].path); @@ -5958,6 +5958,145 @@ static grub_err_t ventoy_cmd_dump_rsv_page(grub_extcmd_context_t ctxt, int argc, VENTOY_CMD_RETURN(GRUB_ERR_NONE); } +static grub_err_t ventoy_cmd_need_secondary_menu(grub_extcmd_context_t ctxt, int argc, char **args) +{ + const char *env = NULL; + + (void)ctxt; + (void)argc; + + if (g_ventoy_memdisk_mode || g_ventoy_grub2_mode || g_ventoy_wimboot_mode || g_ventoy_iso_raw) + { + return 1; + } + + if (ventoy_check_mode_by_name(args[0], "vtmemdisk") || + ventoy_check_mode_by_name(args[0], "vtgrub2") || + ventoy_check_mode_by_name(args[0], "vtwimboot")) + { + return 1; + } + + env = grub_env_get("VTOY_SECONDARY_BOOT_MENU"); + if (env && env[0] == '0' && env[1] == 0) + { + return 1; + } + + return 0; +} + +static grub_err_t ventoy_cmd_show_secondary_menu(grub_extcmd_context_t ctxt, int argc, char **args) +{ + int n = 0; + int pos = 0; + int len = 0; + int select = 0; + int timeout = 0; + char *cmd = NULL; + const char *env = NULL; + ulonglong fsize = 0; + char cfgfile[128]; + int seldata[16] = {0}; + + (void)ctxt; + (void)argc; + + len = 8 * VTOY_SIZE_1KB; + cmd = (char *)grub_malloc(len); + if (!cmd) + { + return 1; + } + + grub_env_unset("VTOY_CHKSUM_FILE_PATH"); + + env = grub_env_get("VTOY_SECONDARY_TIMEOUT"); + if (env) + { + timeout = (int)grub_strtol(env, NULL, 10); + } + + if (timeout > 0) + { + vtoy_len_ssprintf(cmd, pos, len, "set timeout=%d\n", timeout); + } + + fsize = grub_strtoull(args[2], NULL, 10); + + vtoy_dummy_menuentry(cmd, pos, len, "Boot in normal mode", "second_normal"); seldata[n++] = 1; + + if (grub_strcmp(args[1], "Unix") != 0) + { + if (grub_strcmp(args[1], "Windows") == 0) + { + vtoy_dummy_menuentry(cmd, pos, len, "Boot in wimboot mode", "second_wimboot"); seldata[n++] = 2; + } + else + { + vtoy_dummy_menuentry(cmd, pos, len, "Boot in grub2 mode", "second_grub2"); seldata[n++] = 3; + } + + if (fsize <= VTOY_SIZE_1GB) + { + vtoy_dummy_menuentry(cmd, pos, len, "Boot in memdisk mode", "second_memdisk"); seldata[n++] = 4; + } + } + + vtoy_dummy_menuentry(cmd, pos, len, "File checksum", "second_checksum"); seldata[n++] = 5; + + do { + g_ventoy_menu_esc = 1; + g_ventoy_suppress_esc = 1; + g_ventoy_suppress_esc_default = 0; + grub_snprintf(cfgfile, sizeof(cfgfile), "configfile mem:0x%llx:size:%d", (ulonglong)(ulong)cmd, pos); + grub_script_execute_sourcecode(cfgfile); + g_ventoy_menu_esc = 0; + g_ventoy_suppress_esc = 0; + g_ventoy_suppress_esc_default = 1; + + select = seldata[g_ventoy_last_entry]; + + if (select == 2) + { + g_ventoy_wimboot_mode = 1; + } + else if (select == 3) + { + g_ventoy_grub2_mode = 1; + } + else if (select == 4) + { + g_ventoy_memdisk_mode = 1; + } + else if (select == 5) + { + grub_env_set("VTOY_CHKSUM_FILE_PATH", args[0]); + grub_script_execute_sourcecode("configfile $vtoy_efi_part/grub/checksum.cfg"); + } + }while (select == 5); + + grub_free(cmd); + return 0; +} + +static grub_err_t ventoy_cmd_fs_ignore_case(grub_extcmd_context_t ctxt, int argc, char **args) +{ + (void)ctxt; + (void)argc; + + if (args[0][0] == '0') + { + g_ventoy_case_insensitive = 0; + } + else + { + g_ventoy_case_insensitive = 1; + } + + return 0; +} + int ventoy_env_init(void) { int i; @@ -6158,6 +6297,12 @@ static cmd_para ventoy_cmds[] = { "vt_iso_vd_id_begin", ventoy_cmd_iso_vd_id_begin, 0, NULL, "", "", NULL }, { "vt_fn_mutex_lock", ventoy_cmd_fn_mutex_lock, 0, NULL, "", "", NULL }, { "vt_efi_dump_rsv_page", ventoy_cmd_dump_rsv_page, 0, NULL, "", "", NULL }, + { "vt_is_standard_winiso", ventoy_cmd_is_standard_winiso, 0, NULL, "", "", NULL }, + { "vt_sel_winpe_wim", ventoy_cmd_sel_winpe_wim, 0, NULL, "", "", NULL }, + { "vt_need_secondary_menu", ventoy_cmd_need_secondary_menu, 0, NULL, "", "", NULL }, + { "vt_show_secondary_menu", ventoy_cmd_show_secondary_menu, 0, NULL, "", "", NULL }, + { "vt_fs_ignore_case", ventoy_cmd_fs_ignore_case, 0, NULL, "", "", NULL }, + { "vt_systemd_menu", ventoy_cmd_linux_systemd_menu, 0, NULL, "", "", NULL }, }; int ventoy_register_all_cmd(void) 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 2f4d1406..42235c67 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 @@ -29,6 +29,8 @@ #define VTOY_FILT_MIN_FILE_SIZE 32768 +#define VTOY_LINUX_SYSTEMD_MENU_MAX_BUF 16384 + #define VTOY_SIZE_1GB 1073741824 #define VTOY_SIZE_1MB (1024 * 1024) #define VTOY_SIZE_2MB (2 * 1024 * 1024) @@ -329,9 +331,16 @@ void ventoy_debug(const char *fmt, ...); #define vtoy_ssprintf(buf, pos, fmt, args...) \ pos += grub_snprintf(buf + pos, VTOY_MAX_SCRIPT_BUF - pos, fmt, ##args) +#define vtoy_len_ssprintf(buf, pos, len, fmt, args...) \ + pos += grub_snprintf(buf + pos, len - pos, fmt, ##args) + #define browser_ssprintf(mbuf, fmt, args...) \ (mbuf)->pos += grub_snprintf((mbuf)->buf + (mbuf)->pos, (mbuf)->max - (mbuf)->pos, fmt, ##args) +#define vtoy_dummy_menuentry(buf, pos, len, title, class) \ + vtoy_len_ssprintf(buf, pos, len, "menuentry \"%s\" --class=\"%s\" {\n echo \"\"\n}\n", title, class) + + #define FLAG_HEADER_RESERVED 0x00000001 #define FLAG_HEADER_COMPRESSION 0x00000002 #define FLAG_HEADER_READONLY 0x00000004 @@ -613,6 +622,7 @@ grub_err_t ventoy_cmd_clear_initrd_list(grub_extcmd_context_t ctxt, int argc, ch grub_uint32_t ventoy_get_iso_boot_catlog(grub_file_t file); int ventoy_has_efi_eltorito(grub_file_t file, grub_uint32_t sector); grub_err_t ventoy_cmd_linux_chain_data(grub_extcmd_context_t ctxt, int argc, char **args); +grub_err_t ventoy_cmd_linux_systemd_menu(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_linux_locate_initrd(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_valid_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args); @@ -633,6 +643,7 @@ grub_err_t ventoy_cmd_windows_chain_data(grub_extcmd_context_t ctxt, int argc, c grub_err_t ventoy_cmd_windows_wimboot_data(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_wim_chain_data(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_wim_check_bootable(grub_extcmd_context_t ctxt, int argc, char **args); +grub_err_t ventoy_cmd_is_standard_winiso(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_dump_wim_patch(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_sel_wimboot(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_set_wim_prompt(grub_extcmd_context_t ctxt, int argc, char **args); @@ -1111,6 +1122,7 @@ grub_err_t ventoy_cmd_linux_get_main_initrd_index(grub_extcmd_context_t ctxt, in grub_err_t ventoy_cmd_collect_wim_patch(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_wim_patch_count(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_locate_wim_patch(grub_extcmd_context_t ctxt, int argc, char **args); +grub_err_t ventoy_cmd_sel_winpe_wim(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_unix_chain_data(grub_extcmd_context_t ctxt, int argc, char **args); int ventoy_get_disk_guid(const char *filename, grub_uint8_t *guid, grub_uint8_t *signature); grub_err_t ventoy_cmd_unix_reset(grub_extcmd_context_t ctxt, int argc, char **args); @@ -1218,6 +1230,16 @@ typedef struct var_node struct var_node *next; }var_node; +typedef struct systemd_menu_ctx +{ + char *dev; + char *buf; + int pos; + int len; +}systemd_menu_ctx; + +#define vtoy_check_goto_out(p) if (!p) goto out + extern char *g_tree_script_buf; extern int g_tree_script_pos; extern int g_tree_script_pre; 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 e32ff02f..bfeb8589 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 @@ -1811,3 +1811,173 @@ grub_err_t ventoy_cmd_linux_chain_data(grub_extcmd_context_t ctxt, int argc, cha VENTOY_CMD_RETURN(GRUB_ERR_NONE); } +static char *ventoy_systemd_conf_tag(char *buf, const char *tag, int optional) +{ + int taglen = 0; + char *start = NULL; + char *nextline = NULL; + + taglen = grub_strlen(tag); + for (start = buf; start; start = nextline) + { + nextline = ventoy_get_line(start); + while (ventoy_isspace(*start)) + { + start++; + } + + if (grub_strncmp(start, tag, taglen) == 0 && (start[taglen] == ' ' || start[taglen] == '\t')) + { + start += taglen; + while (ventoy_isspace(*start)) + { + start++; + } + return start; + } + } + + if (optional == 0) + { + debug("tag<%s> NOT found\n", tag); + } + return NULL; +} + +static int ventoy_systemd_conf_hook(const char *filename, const struct grub_dirhook_info *info, void *data) +{ + int oldpos = 0; + char *tag = NULL; + char *bkbuf = NULL; + char *filebuf = NULL; + grub_file_t file = NULL; + systemd_menu_ctx *ctx = (systemd_menu_ctx *)data; + + debug("ventoy_systemd_conf_hook %s\n", filename); + + if (info->dir || NULL == grub_strstr(filename, ".conf")) + { + return 0; + } + + + file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s/loader/entries/%s", ctx->dev, filename); + if (!file) + { + return 0; + } + + filebuf = grub_zalloc(2 * file->size + 8); + if (!filebuf) + { + goto out; + } + + bkbuf = filebuf + file->size + 4; + grub_file_read(file, bkbuf, file->size); + + oldpos = ctx->pos; + + /* title --> menuentry */ + grub_memcpy(filebuf, bkbuf, file->size); + tag = ventoy_systemd_conf_tag(filebuf, "title", 0); + vtoy_check_goto_out(tag); + vtoy_len_ssprintf(ctx->buf, ctx->pos, ctx->len, "menuentry \"%s\" {\n", tag); + + /* linux xxx */ + grub_memcpy(filebuf, bkbuf, file->size); + tag = ventoy_systemd_conf_tag(filebuf, "linux", 0); + if (!tag) + { + ctx->pos = oldpos; + goto out; + } + vtoy_len_ssprintf(ctx->buf, ctx->pos, ctx->len, " echo \"Downloading kernel ...\"\n linux %s ", tag); + + /* kernel options */ + grub_memcpy(filebuf, bkbuf, file->size); + tag = ventoy_systemd_conf_tag(filebuf, "options", 0); + vtoy_len_ssprintf(ctx->buf, ctx->pos, ctx->len, "%s \n", tag ? tag : ""); + + + /* initrd xxx xxx xxx */ + vtoy_len_ssprintf(ctx->buf, ctx->pos, ctx->len, " echo \"Downloading initrd ...\"\n initrd "); + grub_memcpy(filebuf, bkbuf, file->size); + tag = ventoy_systemd_conf_tag(filebuf, "initrd", 1); + while (tag) + { + vtoy_len_ssprintf(ctx->buf, ctx->pos, ctx->len, "%s ", tag); + tag = ventoy_systemd_conf_tag(tag + grub_strlen(tag) + 1, "initrd", 1); + } + + vtoy_len_ssprintf(ctx->buf, ctx->pos, ctx->len, "\n boot\n}\n"); + +out: + grub_check_free(filebuf); + grub_file_close(file); + return 0; +} + +grub_err_t ventoy_cmd_linux_systemd_menu(grub_extcmd_context_t ctxt, int argc, char **args) +{ + static char *buf = NULL; + char name[128]; + char value[64]; + grub_fs_t fs; + char *device_name = NULL; + grub_device_t dev = NULL; + systemd_menu_ctx ctx; + + (void)ctxt; + (void)argc; + + if (!buf) + { + buf = grub_malloc(VTOY_LINUX_SYSTEMD_MENU_MAX_BUF); + if (!buf) + { + goto end; + } + } + + device_name = grub_file_get_device_name(args[0]); + if (!device_name) + { + debug("failed to get device name %s\n", args[0]); + goto end; + } + + dev = grub_device_open(device_name); + if (!dev) + { + debug("failed to open device %s\n", device_name); + goto end; + } + + fs = grub_fs_probe(dev); + if (!fs) + { + debug("failed to probe fs %d\n", grub_errno); + goto end; + } + + ctx.dev = args[0]; + ctx.buf = buf; + ctx.pos = 0; + ctx.len = VTOY_LINUX_SYSTEMD_MENU_MAX_BUF; + fs->fs_dir(dev, "/loader/entries", ventoy_systemd_conf_hook, &ctx); + + grub_snprintf(name, sizeof(name), "%s_addr", args[1]); + grub_snprintf(value, sizeof(value), "0x%llx", (ulonglong)(ulong)buf); + grub_env_set(name, value); + + grub_snprintf(name, sizeof(name), "%s_size", args[1]); + grub_snprintf(value, sizeof(value), "%d", ctx.pos); + grub_env_set(name, value); + +end: + grub_check_free(device_name); + check_free(dev, grub_device_close); + VENTOY_CMD_RETURN(GRUB_ERR_NONE); +} + 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 2fc7f20a..8105e0e3 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 @@ -1364,6 +1364,110 @@ static int ventoy_wimdows_locate_wim(const char *disk, wim_patch *patch, int win return 0; } +grub_err_t ventoy_cmd_sel_winpe_wim(grub_extcmd_context_t ctxt, int argc, char **args) +{ + int i = 0; + int pos = 0; + int len = 0; + int find = 0; + char *cmd = NULL; + wim_patch *node = NULL; + wim_patch *tmp = NULL; + grub_file_t file = NULL; + wim_header *head = NULL; + char cfgfile[128]; + + (void)ctxt; + (void)argc; + + len = 8 * VTOY_SIZE_1KB; + cmd = (char *)grub_malloc(len + sizeof(wim_header)); + if (!cmd) + { + return 1; + } + + head = (wim_header *)(cmd + len); + grub_env_unset("vtoy_pe_wim_path"); + + for (node = g_wim_patch_head; node; node = node->next) + { + find = 0; + for (tmp = g_wim_patch_head; tmp != node; tmp = tmp->next) + { + if (tmp->valid && grub_strcasecmp(tmp->path, node->path) == 0) + { + find = 1; + break; + } + } + + if (find) + { + continue; + } + + g_ventoy_case_insensitive = 1; + file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s%s", args[0], node->path); + g_ventoy_case_insensitive = 0; + if (!file) + { + debug("File %s%s NOT exist\n", args[0], node->path); + continue; + } + + grub_file_read(file, head, sizeof(wim_header)); + if (grub_memcmp(head->signature, WIM_HEAD_SIGNATURE, sizeof(head->signature))) + { + debug("Not a valid wim file %s\n", (char *)head->signature); + grub_file_close(file); + continue; + } + + if (head->flags & FLAG_HEADER_COMPRESS_LZMS) + { + debug("LZMS compress is not supported 0x%x\n", head->flags); + grub_file_close(file); + continue; + } + + grub_file_close(file); + node->valid = 1; + + vtoy_len_ssprintf(cmd, pos, len, "menuentry \"%s\" --class=\"sel_wim\" {\n echo \"\"\n}\n", node->path); + } + + if (pos > 0) + { + g_ventoy_menu_esc = 1; + g_ventoy_suppress_esc = 1; + g_ventoy_suppress_esc_default = 0; + + grub_snprintf(cfgfile, sizeof(cfgfile), "configfile mem:0x%llx:size:%d", (ulonglong)(ulong)cmd, pos); + grub_script_execute_sourcecode(cfgfile); + + g_ventoy_menu_esc = 0; + g_ventoy_suppress_esc = 0; + g_ventoy_suppress_esc_default = 1; + + for (node = g_wim_patch_head; node; node = node->next) + { + if (node->valid) + { + if (i == g_ventoy_last_entry) + { + grub_env_set("vtoy_pe_wim_path", node->path); + break; + } + i++; + } + } + } + + grub_free(cmd); + return 0; +} + grub_err_t ventoy_cmd_locate_wim_patch(grub_extcmd_context_t ctxt, int argc, char **args) { int datalen = 0; @@ -1919,6 +2023,7 @@ out: grub_err_t ventoy_cmd_windows_wimboot_data(grub_extcmd_context_t ctxt, int argc, char **args) { int rc = 0; + int wim64 = 0; int datalen = 0; int dataflag = 0; grub_uint32_t exe_len = 0; @@ -1957,6 +2062,7 @@ grub_err_t ventoy_cmd_windows_wimboot_data(grub_extcmd_context_t ctxt, int argc, { return 1; } + wim64 = ventoy_is_pe64(exe_data); grub_memset(&wim_data, 0, sizeof(wim_data)); ventoy_cat_exe_file_data(&wim_data, exe_len, exe_data, datalen); @@ -1979,6 +2085,7 @@ grub_err_t ventoy_cmd_windows_wimboot_data(grub_extcmd_context_t ctxt, int argc, debug("vtoy_wimboot_mem_size: %s\n", envbuf); grub_env_set(args[1], exename); + grub_env_set(args[2], wim64 ? "64" : "32"); VENTOY_CMD_RETURN(GRUB_ERR_NONE); } @@ -2020,7 +2127,10 @@ grub_err_t ventoy_cmd_windows_chain_data(grub_extcmd_context_t ctxt, int argc, c if (0 == ventoy_compatible && g_wim_valid_patch_count == 0) { unknown_image = 1; - debug("Warning: %s was not recognized by Ventoy\n", args[0]); + if (!g_ventoy_wimboot_mode) + { + debug("Warning: %s was not recognized by Ventoy\n", args[0]); + } } file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s", args[0]); @@ -2212,6 +2322,67 @@ static int ventoy_get_wim_chunklist(grub_file_t wimfile, ventoy_img_chunk_list * return 0; } +grub_err_t ventoy_cmd_is_standard_winiso(grub_extcmd_context_t ctxt, int argc, char **args) +{ + int i; + int ret = 1; + char prefix[32] = {0}; + const char *chkfile[] = + { + "boot/bcd", "boot/boot.sdi", NULL + }; + + (void)ctxt; + (void)argc; + + if (ventoy_check_file_exist("%s/sources/boot.wim", args[0])) + { + prefix[0] = 0; + } + else if (ventoy_check_file_exist("%s/x86/sources/boot.wim", args[0])) + { + grub_snprintf(prefix, sizeof(prefix), "/x86"); + } + else if (ventoy_check_file_exist("%s/x64/sources/boot.wim", args[0])) + { + grub_snprintf(prefix, sizeof(prefix), "/x64"); + } + else + { + debug("No boot.wim found.\n"); + goto out; + } + + for (i = 0; chkfile[i]; i++) + { + if (!ventoy_check_file_exist("%s%s/%s", args[0], prefix, chkfile[i])) + { + debug("%s not found.\n", chkfile[i]); + goto out; + } + } + + if ((!ventoy_check_file_exist("%s%s/sources/install.wim", args[0], prefix)) && + (!ventoy_check_file_exist("%s%s/sources/install.esd", args[0], prefix))) + { + debug("No install.wim(esd) found.\n"); + goto out; + } + + if (!ventoy_check_file_exist("%s/setup.exe", args[0])) + { + debug("No setup.exe found.\n"); + goto out; + } + + ret = 0; + debug("This is standard Windows ISO.\n"); + +out: + + return ret; +} + grub_err_t ventoy_cmd_wim_check_bootable(grub_extcmd_context_t ctxt, int argc, char **args) { grub_uint32_t boot_index; diff --git a/INSTALL/ExtendPersistentImg.sh b/INSTALL/ExtendPersistentImg.sh index bd51912c..87afd081 100644 --- a/INSTALL/ExtendPersistentImg.sh +++ b/INSTALL/ExtendPersistentImg.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash print_usage() { echo 'Usage: ExtendPersistentImg.sh file size' @@ -19,6 +19,18 @@ if [ -z "$2" ]; then exit 1 fi + +if [ "$1" = "__vbash__" ]; then + shift +else + if readlink /bin/sh | grep -q bash; then + : + else + exec /bin/bash $0 "__vbash__" "$@" + fi +fi + + file=$1 size=$2 diff --git a/INSTALL/VentoyPlugson.sh b/INSTALL/VentoyPlugson.sh index b23218af..5ded1863 100644 --- a/INSTALL/VentoyPlugson.sh +++ b/INSTALL/VentoyPlugson.sh @@ -1,9 +1,9 @@ -#!/bin/sh +#!/bin/bash . ./tool/ventoy_lib.sh print_usage() { - echo 'Usage: sudo sh VentoyPlugson.sh [OPTION] /dev/sdX' + echo 'Usage: sudo bash VentoyPlugson.sh [OPTION] /dev/sdX' echo ' OPTION: (optional)' echo ' -H x.x.x.x http server IP address (default is 127.0.0.1)' echo ' -P PORT http server PORT (default is 24681)' diff --git a/INSTALL/VentoyWeb.sh b/INSTALL/VentoyWeb.sh index 76ed0d56..f06ae066 100644 --- a/INSTALL/VentoyWeb.sh +++ b/INSTALL/VentoyWeb.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash print_usage() { echo 'Usage: VentoyWeb.sh [ OPTION ]' diff --git a/INSTALL/grub/arm64-efi/normal.mod b/INSTALL/grub/arm64-efi/normal.mod index b056d858..a1238fb8 100644 Binary files a/INSTALL/grub/arm64-efi/normal.mod and b/INSTALL/grub/arm64-efi/normal.mod differ diff --git a/INSTALL/grub/grub.cfg b/INSTALL/grub/grub.cfg index a53de0a0..8b5396fa 100644 --- a/INSTALL/grub/grub.cfg +++ b/INSTALL/grub/grub.cfg @@ -599,33 +599,36 @@ function ventoy_unix_comm_proc { function uefi_windows_menu_func { vt_windows_reset + unset vt_cur_wimboot_mode if vt_check_mode 4 "$vt_chosen_name"; then - vt_windows_chain_data "${1}${chosen_path}" - ventoy_debug_pause - vtoy_wimboot_func - else - if [ "$ventoy_compatible" = "NO" ]; then - - if [ "$ventoy_fs_probe" = "iso9660" ]; then - loopback -d loop - vt_iso9660_nojoliet 1 - loopback loop "$1$2" - fi - - for file in "efi/microsoft/boot/bcd"; do - vt_windows_collect_wim_patch bcd (loop)/$file - done + set vt_cur_wimboot_mode=1 + fi - vt_windows_count_wim_patch vt_wim_cnt - if [ $vt_wim_cnt -eq 0 ]; then - distro_specify_wim_patch_phase2 - fi - - ventoy_debug_pause - locate_wim "${chosen_path}" + if [ "$ventoy_compatible" = "NO" -o "$vt_cur_wimboot_mode" = "1" ]; then + if [ "$ventoy_fs_probe" = "iso9660" ]; then + loopback -d loop + vt_iso9660_nojoliet 1 + loopback loop "$1$2" fi - vt_windows_chain_data "${1}${chosen_path}" - ventoy_debug_pause + + for file in "efi/microsoft/boot/bcd"; do + vt_windows_collect_wim_patch bcd (loop)/$file + done + + vt_windows_count_wim_patch vt_wim_cnt + if [ $vt_wim_cnt -eq 0 ]; then + distro_specify_wim_patch_phase2 + fi + + ventoy_debug_pause + locate_wim "${chosen_path}" + fi + + vt_windows_chain_data "${1}${chosen_path}" + ventoy_debug_pause + + if [ "$vt_cur_wimboot_mode" = "1" ]; then + vtoy_wimboot_func fi if [ -n "$vtoy_chain_mem_addr" ]; then @@ -784,6 +787,10 @@ function uefi_linux_menu_func { unset vtGrub2Mode if vt_check_mode 3 "$vt_chosen_name"; then set vtGrub2Mode=1 + elif vt_str_begin "$vt_volume_id" "HOLO_"; then + if [ -d (loop)/loader/entries ]; then + set vtGrub2Mode=1 + fi elif vt_str_begin "$vt_volume_id" "KRD"; then if [ -f (loop)/boot/grub/grub.cfg.sig ]; then set vtGrub2Mode=1 @@ -817,6 +824,18 @@ function uefi_linux_menu_func { break fi done + if [ $vtback_cfg_find -eq 0 ]; then + if [ -f (loop)/loader/loader.conf -a -d (loop)/loader/entries ]; then + if vt_str_begin "$vt_volume_id" "HOLO_"; then + set root=(loop,2) + vt_systemd_menu (loop,2) vt_sys_menu_mem + else + vt_systemd_menu (loop) vt_sys_menu_mem + fi + set vtback_cfg_find=1 + configfile "mem:${vt_sys_menu_mem_addr}:size:${vt_sys_menu_mem_size}" + fi + fi if [ "$vtback_cfg_find" = "0" ]; then echo " " @@ -913,6 +932,14 @@ function uefi_iso_menu_func { vt_check_compatible (loop) fi + if vt_need_secondary_menu "$vt_chosen_name"; then + vt_show_secondary_menu "$vt_chosen_path" "$vtoy_os" $vt_chosen_size + if vt_check_mode 0 "$vt_chosen_name"; then + uefi_iso_memdisk $vtoy_iso_part "$vt_chosen_path" + return + fi + fi + vt_img_sector "${1}${chosen_path}" if [ "$ventoy_fs_probe" = "iso9660" ]; then @@ -964,17 +991,7 @@ function vtoy_windows_wimboot { echo vtoy_wimboot_prefix=$vtoy_wimboot_prefix vtoy_wimboot_bit=$vtoy_wimboot_bit vt_wimkernel=$vt_wimkernel fi - for wmfile in sources/boot.wim boot/bcd boot/boot.sdi; do - if [ ! -f $vtoy_wimboot_prefix/$wmfile ]; then - return - fi - done - - if [ -f $vtoy_wimboot_prefix/sources/install.wim -o -f $vtoy_wimboot_prefix/sources/install.esd ]; then - vt_windows_wimboot_data "$vtoy_wimboot_prefix/sources/boot.wim" vtoy_init_exe - else - return - fi + vt_windows_wimboot_data "$vtoy_wimboot_prefix/sources/boot.wim" vtoy_init_exe vtoy_wim_bit if [ "$grub_platform" = "pc" ]; then linux16 "$vtoy_path/$vt_wimkernel" quiet @@ -1014,39 +1031,42 @@ function vtoy_windows_wimboot { } function vtoy_winpe_wimboot { - unset vtoy_boot_mgr_exe - unset vtoy_boot_mgr_efi - set vtoy_wimboot_prefix=(loop) - set vtoy_bcd_path="$1" - set vtoy_sdi_path="$2" - set vtoy_wim_path="$3" - set vtoy_mgr_flag="$4" + unset vtoy_boot_sdi_legacy + unset vtoy_boot_sdi_efi - if [ $vtoy_mgr_flag -eq 1 ]; then - set vtoy_boot_mgr_exe="newc:bootmgr.exe:$vtoy_wimboot_prefix/$5" - elif [ $vtoy_mgr_flag -eq 2 ]; then - set vtoy_boot_mgr_efi="vf=bootmgr.efi:$vtoy_wimboot_prefix/$5" - elif [ $vtoy_mgr_flag -eq 3 ]; then - set vtoy_boot_mgr_exe="newc:bootmgr.exe:$vtoy_wimboot_prefix/$5" - set vtoy_boot_mgr_efi="vf=bootmgr.efi:$vtoy_wimboot_prefix/$6" + set vtoy_wimboot_prefix=(loop) + set vtoy_wim_path="$1" + + if [ -n "${vtdebug_flag}" ]; then + echo "winpe_wimboot $1 $2 $3" + fi + + if [ "$2" != "0" ]; then + set vtoy_boot_sdi_legacy="newc:boot.sdi:$vtoy_wimboot_prefix/$2" + set vtoy_boot_sdi_efi="vf=boot.sdi:$vtoy_wimboot_prefix/$2" fi - vt_windows_wimboot_data $vtoy_wimboot_prefix/$vtoy_wim_path vtoy_init_exe + vt_windows_wimboot_data $vtoy_wimboot_prefix/$vtoy_wim_path vtoy_init_exe vtoy_wim_bit if [ "$grub_platform" = "pc" ]; then - linux16 "$vtoy_path/$vt_wimkernel" quiet + linux16 "$vtoy_path/$vt_wimkernel" quiet ventoy_debug_pause - vt_set_wim_load_prompt 1 "Loading files......" + vt_set_wim_load_prompt 1 "Loading files......" initrd16 newc:$vtoy_init_exe:mem:${vtoy_wimboot_mem_addr}:size:${vtoy_wimboot_mem_size} \ - $vtoy_boot_mgr_exe \ - newc:vtoy_wimboot:$vtoy_wimboot_prefix/$vtoy_bcd_path \ - newc:bcd:$vtoy_wimboot_prefix/$vtoy_bcd_path \ - newc:boot.sdi:$vtoy_wimboot_prefix/$vtoy_sdi_path \ + newc:vtoy_wimboot:$vtoy_path/$vt_wimkernel \ + newc:bootmgr.exe:mem:${vtoy_pe_bootmgr_mem_addr}:size:${vtoy_pe_bootmgr_mem_size} \ + newc:bcd:mem:${vtoy_pe_bcd_mem_addr}:size:${vtoy_pe_bcd_mem_size} \ + $vtoy_boot_sdi_legacy \ newc:boot.wim:$vtoy_wimboot_prefix/$vtoy_wim_path - vt_set_wim_load_prompt 0 + vt_set_wim_load_prompt 0 boot else + if [ "$VTOY_EFI_ARCH" = "x64" -a "$vtoy_wim_bit" = "32" ]; then + echo -e "\nThis is 32bit Windows and does NOT support x86_64 UEFI firmware.\n" + echo -e "这是32位的 Windows 系统,不支持当前的64位 UEFI 环境。\n" + fi + vt_set_wim_load_prompt 1 "Loading files......" vt_load_file_to_mem "nodecompress" $vtoy_wimboot_prefix/$vtoy_wim_path vtoy_wimfile_mem vt_set_wim_load_prompt 0 @@ -1056,14 +1076,19 @@ function vtoy_winpe_wimboot { else set vtoy_wimfile_path=$vtoy_wimboot_prefix/$vtoy_wim_path fi + + unset vtoy_boot_efi_path + if [ -F (loop)/efi/boot/boot${VTOY_EFI_ARCH}.efi ]; then + set vtoy_boot_efi_path="vf=bootx64.efi:(loop)/efi/boot/boot${VTOY_EFI_ARCH}.efi" + fi ventoy_cli_console chainloader "$vtoy_path/$vt_wimkernel" quiet \ "vf=$vtoy_init_exe:mem:${vtoy_wimboot_mem_addr}:size:${vtoy_wimboot_mem_size}" \ - "vf=vtoy_wimboot:$vtoy_wimboot_prefix/$vtoy_bcd_path" \ - "$vtoy_boot_mgr_efi" \ - "vf=bcd:$vtoy_wimboot_prefix/$vtoy_bcd_path" \ - "vf=boot.sdi:$vtoy_wimboot_prefix/$vtoy_sdi_path" \ + "vf=vtoy_wimboot:$vtoy_path/$vt_wimkernel" \ + "vf=bcd:mem:${vtoy_pe_bcd_mem_addr}:size:${vtoy_pe_bcd_mem_size}" \ + "$vtoy_boot_sdi_efi" \ + "$vtoy_boot_efi_path" \ "vf=boot.wim:$vtoy_wimfile_path" \ pfsize=$vtoy_chain_file_size \ pfread=$vtoy_chain_file_read @@ -1073,8 +1098,6 @@ function vtoy_winpe_wimboot { } function vtoy_wimboot_func { - echo -e "\n===================== VENTOY WIMBOOT ===================\n" - if [ "$grub_platform" = "pc" ]; then set vt_wimkernel=wimboot.x86_64.xz else @@ -1085,46 +1108,75 @@ function vtoy_wimboot_func { fi fi - if vt_str_begin "$vt_volume_id" "Modified-Win10PEx64"; then - vtoy_winpe_wimboot 'Boot/bcd' 'Boot/boot.sdi' 'sources/boot.wim' 1 'bootmgr.exe' - else + if vt_is_standard_winiso (loop); then + echo -e "\n==================== VENTOY WIMBOOT ==================\n" vtoy_windows_wimboot + else + vt_sel_winpe_wim (loop) + if [ -n "$vtoy_pe_wim_path" ]; then + echo -e "\n==================== VENTOY WIMBOOT ==================\n" + + vt_fs_ignore_case 1 + vt_load_file_to_mem "auto" $vtoy_path/common_bcd.xz vtoy_pe_bcd_mem + + set vt_sdi_path=0 + for vsdi in "boot/boot.sdi" "2K10/FONTS/boot.sdi" "SSTR/boot.sdi" "ISPE/BOOT.SDI" \ + "boot/uqi.sdi" "ISYL/boot.sdi" "WEPE/WEPE.SDI" ; do + if [ -F "(loop)/$vsdi" ]; then + set vt_sdi_path=$vsdi + break + fi + done + + if [ "$grub_platform" = "pc" ]; then + vt_load_file_to_mem "auto" $vtoy_path/common_bootmgr.xz vtoy_pe_bootmgr_mem + vtoy_winpe_wimboot "$vtoy_pe_wim_path" "$vt_sdi_path" 1 + else + vtoy_winpe_wimboot "$vtoy_pe_wim_path" "$vt_sdi_path" 0 + fi + + vt_fs_ignore_case 0 + fi fi } function legacy_windows_menu_func { vt_windows_reset + unset vt_cur_wimboot_mode if vt_check_mode 4 "$vt_chosen_name"; then - vt_windows_chain_data "${1}${chosen_path}" - ventoy_debug_pause - vtoy_wimboot_func - else - if [ "$ventoy_compatible" = "NO" ]; then - - if [ "$ventoy_fs_probe" = "iso9660" ]; then - loopback -d loop - vt_iso9660_nojoliet 1 - loopback loop "$1$2" - fi - - for file in "boot/bcd" "/efi/microsoft/boot/bcd" "SSTR/BCD" "boot/bce"; do - vt_windows_collect_wim_patch bcd (loop)/$file - done - - distro_specify_wim_patch - - vt_windows_count_wim_patch vt_wim_cnt - if [ $vt_wim_cnt -eq 0 ]; then - distro_specify_wim_patch_phase2 - fi - - ventoy_debug_pause - locate_wim "${chosen_path}" + set vt_cur_wimboot_mode=1 + fi + + if [ "$ventoy_compatible" = "NO" -o "$vt_cur_wimboot_mode" = "1" ]; then + if [ "$ventoy_fs_probe" = "iso9660" ]; then + loopback -d loop + vt_iso9660_nojoliet 1 + loopback loop "$1$2" + fi + + for file in "boot/bcd" "/efi/microsoft/boot/bcd" "SSTR/BCD" "boot/bce"; do + vt_windows_collect_wim_patch bcd (loop)/$file + done + + distro_specify_wim_patch + + vt_windows_count_wim_patch vt_wim_cnt + if [ $vt_wim_cnt -eq 0 ]; then + distro_specify_wim_patch_phase2 fi - vt_windows_chain_data "${1}${chosen_path}" ventoy_debug_pause + if [ -z "$vt_cur_wimboot_mode" ]; then + locate_wim "${chosen_path}" + fi + fi + + vt_windows_chain_data "${1}${chosen_path}" + ventoy_debug_pause + + if [ "$vt_cur_wimboot_mode" = "1" ]; then + vtoy_wimboot_func fi if [ -n "$vtoy_chain_mem_addr" ]; then @@ -1206,10 +1258,19 @@ function legacy_linux_menu_func { ventoy_debug_pause if [ -n "$vtoy_chain_mem_addr" ]; then + unset vtGrub2Mode if vt_check_mode 3 "$vt_chosen_name"; then + set vtGrub2Mode=1 + elif vt_str_begin "$vt_volume_id" "HOLO_"; then + if [ -d (loop)/loader/entries ]; then + set vtGrub2Mode=1 + fi + fi + + if [ -n "$vtGrub2Mode" ]; then ventoy_acpi_param ${vtoy_chain_mem_addr} 2048 ventoy_cli_console - + # fallback set vtback_root=$root vt_push_last_entry @@ -1228,6 +1289,18 @@ function legacy_linux_menu_func { break fi done + if [ $vtback_cfg_find -eq 0 ]; then + if [ -f (loop)/loader/loader.conf -a -d (loop)/loader/entries ]; then + if vt_str_begin "$vt_volume_id" "HOLO_"; then + set root=(loop,2) + vt_systemd_menu (loop,2) vt_sys_menu_mem + else + vt_systemd_menu (loop) vt_sys_menu_mem + fi + set vtback_cfg_find=1 + configfile "mem:${vt_sys_menu_mem_addr}:size:${vt_sys_menu_mem_size}" + fi + fi vt_unset_boot_opt set root=$vtback_root @@ -1291,6 +1364,14 @@ function legacy_iso_menu_func { vt_check_compatible (loop) fi + if vt_need_secondary_menu "$vt_chosen_name"; then + vt_show_secondary_menu "$vt_chosen_path" "$vtoy_os" $vt_chosen_size + if vt_check_mode 0 "$vt_chosen_name"; then + legacy_iso_memdisk $vtoy_iso_part "$vt_chosen_path" + return + fi + fi + vt_img_sector "${1}${chosen_path}" if [ "$ventoy_fs_probe" = "iso9660" ]; then @@ -2222,7 +2303,7 @@ function img_unsupport_menuentry { ############################################################# ############################################################# -set VENTOY_VERSION="1.0.79" +set VENTOY_VERSION="1.0.80" #ACPI not compatible with Window7/8, so disable by default set VTOY_PARAM_NO_ACPI=1 @@ -2280,6 +2361,11 @@ if [ "$vtoy_dev" = "tftp" ]; then done loadfont ascii + if [ -n "$vtoy_efi_part" ]; then + vt_load_file_to_mem "auto" $vtoy_efi_part/grub/fonts/unicode.pf2 vtoy_font_mem + loadfont mem:${vtoy_font_mem_addr}:size:${vtoy_font_mem_size} + fi + if [ -f $vtoy_iso_part/ventoy/ventoy.json ]; then set vt_plugin_path=$vtoy_iso_part else diff --git a/INSTALL/grub/i386-efi/normal.mod b/INSTALL/grub/i386-efi/normal.mod index c647ca64..abd1ca60 100644 Binary files a/INSTALL/grub/i386-efi/normal.mod and b/INSTALL/grub/i386-efi/normal.mod differ diff --git a/INSTALL/grub/mips64el-efi/normal.mod b/INSTALL/grub/mips64el-efi/normal.mod index 9d625d3d..6a954a7e 100644 Binary files a/INSTALL/grub/mips64el-efi/normal.mod and b/INSTALL/grub/mips64el-efi/normal.mod differ diff --git a/INSTALL/grub/x86_64-efi/normal.mod b/INSTALL/grub/x86_64-efi/normal.mod index 853d5157..fa921eb5 100644 Binary files a/INSTALL/grub/x86_64-efi/normal.mod and b/INSTALL/grub/x86_64-efi/normal.mod differ diff --git a/INSTALL/ventoy/common_bcd.xz b/INSTALL/ventoy/common_bcd.xz new file mode 100644 index 00000000..b81f6c29 Binary files /dev/null and b/INSTALL/ventoy/common_bcd.xz differ diff --git a/INSTALL/ventoy/common_bootmgr.xz b/INSTALL/ventoy/common_bootmgr.xz new file mode 100644 index 00000000..bdaa0ef4 Binary files /dev/null and b/INSTALL/ventoy/common_bootmgr.xz differ diff --git a/INSTALL/ventoy/ventoy.cpio b/INSTALL/ventoy/ventoy.cpio index 5a514ccc..5b982232 100644 Binary files a/INSTALL/ventoy/ventoy.cpio and b/INSTALL/ventoy/ventoy.cpio differ diff --git a/INSTALL/ventoy/ventoy_arm64.cpio b/INSTALL/ventoy/ventoy_arm64.cpio index 76f065c2..b8c68096 100644 Binary files a/INSTALL/ventoy/ventoy_arm64.cpio and b/INSTALL/ventoy/ventoy_arm64.cpio differ diff --git a/INSTALL/ventoy/ventoy_mips64.cpio b/INSTALL/ventoy/ventoy_mips64.cpio index ed2edeb9..4cbeda68 100644 Binary files a/INSTALL/ventoy/ventoy_mips64.cpio and b/INSTALL/ventoy/ventoy_mips64.cpio differ diff --git a/INSTALL/ventoy/ventoy_unix.cpio b/INSTALL/ventoy/ventoy_unix.cpio index 7131cab9..c4e6ed9e 100644 Binary files a/INSTALL/ventoy/ventoy_unix.cpio and b/INSTALL/ventoy/ventoy_unix.cpio differ diff --git a/INSTALL/ventoy/ventoy_x86.cpio b/INSTALL/ventoy/ventoy_x86.cpio index 20585438..61a106bb 100644 Binary files a/INSTALL/ventoy/ventoy_x86.cpio and b/INSTALL/ventoy/ventoy_x86.cpio differ diff --git a/INSTALL/ventoy/vtloopex.cpio b/INSTALL/ventoy/vtloopex.cpio index bc99e27d..ccf0bf80 100644 Binary files a/INSTALL/ventoy/vtloopex.cpio and b/INSTALL/ventoy/vtloopex.cpio differ diff --git a/INSTALL/ventoy/wimboot.i386.efi.xz b/INSTALL/ventoy/wimboot.i386.efi.xz index 42abe44d..ca8ca6b3 100644 Binary files a/INSTALL/ventoy/wimboot.i386.efi.xz and b/INSTALL/ventoy/wimboot.i386.efi.xz differ diff --git a/INSTALL/ventoy/wimboot.x86_64.xz b/INSTALL/ventoy/wimboot.x86_64.xz index 3f628676..66fc5562 100644 Binary files a/INSTALL/ventoy/wimboot.x86_64.xz and b/INSTALL/ventoy/wimboot.x86_64.xz differ diff --git a/Plugson/src/Web/ventoy_http.c b/Plugson/src/Web/ventoy_http.c index a84ac426..1fbc1c97 100644 --- a/Plugson/src/Web/ventoy_http.c +++ b/Plugson/src/Web/ventoy_http.c @@ -486,9 +486,11 @@ void ventoy_data_default_control(data_control *data) { memset(data, 0, sizeof(data_control)); + data->secondary_menu = 1; data->filter_dot_underscore = 1; data->max_search_level = -1; data->menu_timeout = 0; + data->secondary_menu_timeout = 0; strlcpy(data->default_kbd_layout, "QWERTY_USA"); strlcpy(data->help_text_language, "en_US"); @@ -510,7 +512,9 @@ int ventoy_data_cmp_control(data_control *data1, data_control *data2) data1->filter_vtoy != data2->filter_vtoy || data1->win11_bypass_check != data2->win11_bypass_check || data1->linux_remount != data2->linux_remount || - data1->menu_timeout != data2->menu_timeout) + data1->secondary_menu != data2->secondary_menu || + data1->menu_timeout != data2->menu_timeout || + data1->secondary_menu_timeout != data2->secondary_menu_timeout) { return 1; } @@ -555,7 +559,9 @@ int ventoy_data_save_control(data_control *data, const char *title, char *buf, i VTOY_JSON_FMT_CTRL_INT(L2, "VTOY_FILE_FLT_VTOY", filter_vtoy); VTOY_JSON_FMT_CTRL_INT(L2, "VTOY_WIN11_BYPASS_CHECK", win11_bypass_check); VTOY_JSON_FMT_CTRL_INT(L2, "VTOY_LINUX_REMOUNT", linux_remount); + VTOY_JSON_FMT_CTRL_INT(L2, "VTOY_SECONDARY_BOOT_MENU", secondary_menu); VTOY_JSON_FMT_CTRL_INT(L2, "VTOY_MENU_TIMEOUT", menu_timeout); + VTOY_JSON_FMT_CTRL_INT(L2, "VTOY_SECONDARY_TIMEOUT", secondary_menu_timeout); VTOY_JSON_FMT_CTRL_STRN(L2, "VTOY_DEFAULT_KBD_LAYOUT", default_kbd_layout); VTOY_JSON_FMT_CTRL_STRN(L2, "VTOY_HELP_TXT_LANGUAGE", help_text_language); @@ -600,7 +606,9 @@ int ventoy_data_json_control(data_control *ctrl, char *buf, int buflen) VTOY_JSON_FMT_SINT("filter_vtoy", ctrl->filter_vtoy); VTOY_JSON_FMT_SINT("win11_bypass_check", ctrl->win11_bypass_check); VTOY_JSON_FMT_SINT("linux_remount", ctrl->linux_remount); + VTOY_JSON_FMT_SINT("secondary_menu", ctrl->secondary_menu); VTOY_JSON_FMT_SINT("menu_timeout", ctrl->menu_timeout); + VTOY_JSON_FMT_SINT("secondary_menu_timeout", ctrl->secondary_menu_timeout); VTOY_JSON_FMT_STRN("default_kbd_layout", ctrl->default_kbd_layout); VTOY_JSON_FMT_STRN("help_text_language", ctrl->help_text_language); @@ -666,7 +674,9 @@ static int ventoy_api_save_control(struct mg_connection *conn, VTOY_JSON *json) VTOY_JSON_INT("filter_vtoy", ctrl->filter_vtoy); VTOY_JSON_INT("win11_bypass_check", ctrl->win11_bypass_check); VTOY_JSON_INT("linux_remount", ctrl->linux_remount); + VTOY_JSON_INT("secondary_menu", ctrl->secondary_menu); VTOY_JSON_INT("menu_timeout", ctrl->menu_timeout); + VTOY_JSON_INT("secondary_menu_timeout", ctrl->secondary_menu_timeout); VTOY_JSON_STR("default_image", ctrl->default_image); VTOY_JSON_STR("default_search_root", ctrl->default_search_root); @@ -3808,6 +3818,10 @@ static int ventoy_parse_control(VTOY_JSON *json, void *p) { CONTROL_PARSE_INT(child, data->linux_remount); } + else if (strcmp(child->pcName, "VTOY_SECONDARY_BOOT_MENU") == 0) + { + CONTROL_PARSE_INT(child, data->secondary_menu); + } else if (strcmp(child->pcName, "VTOY_TREE_VIEW_MENU_STYLE") == 0) { CONTROL_PARSE_INT(child, data->treeview_style); @@ -3865,6 +3879,10 @@ static int ventoy_parse_control(VTOY_JSON *json, void *p) { data->menu_timeout = (int)strtol(child->unData.pcStrVal, NULL, 10); } + else if (strcmp(child->pcName, "VTOY_SECONDARY_TIMEOUT") == 0) + { + data->secondary_menu_timeout = (int)strtol(child->unData.pcStrVal, NULL, 10); + } else if (strcmp(child->pcName, "VTOY_VHD_NO_WARNING") == 0) { CONTROL_PARSE_INT(child, data->vhd_no_warning); diff --git a/Plugson/src/Web/ventoy_http.h b/Plugson/src/Web/ventoy_http.h index 17b21bf0..18447c16 100644 --- a/Plugson/src/Web/ventoy_http.h +++ b/Plugson/src/Web/ventoy_http.h @@ -58,7 +58,9 @@ typedef struct data_control int filter_vtoy; int win11_bypass_check; int menu_timeout; + int secondary_menu_timeout; int linux_remount; + int secondary_menu; char default_search_root[MAX_PATH]; char default_image[MAX_PATH]; char default_kbd_layout[32]; diff --git a/Plugson/vs/VentoyPlugson/Release/VentoyPlugson.exe b/Plugson/vs/VentoyPlugson/Release/VentoyPlugson.exe index ed09c29e..1aa6483f 100644 Binary files a/Plugson/vs/VentoyPlugson/Release/VentoyPlugson.exe and b/Plugson/vs/VentoyPlugson/Release/VentoyPlugson.exe differ diff --git a/Plugson/www/buildtime b/Plugson/www/buildtime index 89141bd2..fb13048d 100644 --- a/Plugson/www/buildtime +++ b/Plugson/www/buildtime @@ -1 +1 @@ -20220430 13:06:42 \ No newline at end of file +20220921 18:42:35 \ No newline at end of file diff --git a/Plugson/www/index.html b/Plugson/www/index.html index 49ce8e6b..b0cdca85 100644 --- a/Plugson/www/index.html +++ b/Plugson/www/index.html @@ -723,7 +723,7 @@ diff --git a/Plugson/www/plugson_control.html b/Plugson/www/plugson_control.html index 0d05fd94..2452ac7c 100644 --- a/Plugson/www/plugson_control.html +++ b/Plugson/www/plugson_control.html @@ -390,6 +390,85 @@ + +
+
+

VTOY_SECONDARY_BOOT_MENU + —— 二级启动菜单显示开关

+
+ +
+
+
+ + + + + + + + + + + + + +
选项设置 +      + +
选项说明二级启动菜单控制开关 + 0 不显示    + 1 显示 +
Option Description + Secondary boot menu display option + 0 Don't display     + 1 Display +
+
+
+ +
+
+

VTOY_SECONDARY_TIMEOUT + —— 二级启动菜单倒计时

+
+ +
+
+
+ + + + + + + + + + + + + +
选项设置 +
+ +
+
选项说明 + 二级菜单倒计时(秒)。只有当 VTOY_SECONDARY_BOOT_MENU 设置为1时才有效。
+ 默认不设置,设置之后,比如设置为10,则在倒计时10秒之后,会自动选择第一项,即:Boot in normal mode
+ 在倒计时的过程中按任意键会停止倒计时,等待用户操作。 +
Option Description + Timeout seconds for the secondary boot menu. Only take effect when VTOY_SECONDARY_BOOT_MENU is 1.
+ By default no timeout is set. When you set it to 10 for example, the first entry (Boot in normal mode) will be selected an run after 10 seconds. +
+
+
+ +
@@ -906,7 +985,7 @@
- + @@ -935,8 +1014,10 @@ data.win11_bypass_check = parseInt($('input:radio[name=id_ctrl_bypass_win11_radio]:checked').val()); data.linux_remount = parseInt($('input:radio[name=id_ctrl_linux_remount_radio]:checked').val()); + data.secondary_menu = parseInt($('input:radio[name=id_ctrl_secondary_radio]:checked').val()); data.default_search_root = $('input:text[id=id_ctrl_text_search_root]').val(); data.menu_timeout = parseInt($('input:text[id=id_ctrl_text_timeout]').val()); + data.secondary_menu_timeout = parseInt($('input:text[id=id_ctrl_text_secondary_timeout]').val()); data.default_image = $('input:text[id=id_ctrl_text_default_img]').val(); level = $('select[id=id_ctrl_sel_max_depth').val(); @@ -968,6 +1049,7 @@ //VTOY_WIN11_BYPASS_CHECK $('input:radio[name=id_ctrl_bypass_win11_radio]')[data.win11_bypass_check].checked = true; $('input:radio[name=id_ctrl_linux_remount_radio]')[data.linux_remount].checked = true; + $('input:radio[name=id_ctrl_secondary_radio]')[data.secondary_menu].checked = true; //VTOY_DEFAULT_SEARCH_ROOT $('input:text[id=id_ctrl_text_search_root]').val(data.default_search_root); @@ -986,6 +1068,9 @@ //VTOY_MENU_TIMEOUT $('input:text[id=id_ctrl_text_timeout]').val(data.menu_timeout); + + //VTOY_SECONDARY_TIMEOUT + $('input:text[id=id_ctrl_text_secondary_timeout]').val(data.secondary_menu_timeout); //VTOY_DEFAULT_IMAGE @@ -1070,8 +1155,10 @@ index: current_tab_index, win11_bypass_check: data.win11_bypass_check, linux_remount:data.linux_remount, + secondary_menu:data.secondary_menu, default_search_root: data.default_search_root, menu_timeout: data.menu_timeout, + secondary_menu_timeout: data.secondary_menu_timeout, default_image: data.default_image, max_search_level: data.max_search_level, default_kbd_layout: data.default_kbd_layout, @@ -1200,6 +1287,15 @@ $('input:text[id=id_ctrl_text_timeout]').val(m_data_control[current_tab_index].menu_timeout); } }); + $('input[id=id_ctrl_text_secondary_timeout]').change(function() { + var value = $('input:text[id=id_ctrl_text_secondary_timeout]').val(); + if (/^[0-9][0-9]*$/.test(value)) { + VtoySaveCurrentPage(); + } else { + Message.error(g_vtoy_cur_language.STR_INVALID_TIMEOUT); + $('input:text[id=id_ctrl_text_secondary_timeout]').val(m_data_control[current_tab_index].secondary_menu_timeout); + } + }); $('#id_tab_control a[href="#tab_0"]').click(OnClickMultiModeTab); $('#id_tab_control a[href="#tab_1"]').click(OnClickMultiModeTab); diff --git a/README.md b/README.md index 7ae3a10b..d28a0dde 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ You can also browse ISO/WIM/IMG/VHD(x)/EFI files in local disk and boot them.
Both MBR and GPT partition style are supported in the same way.
Most type of OS supported(Windows/WinPE/Linux/Unix/ChromeOS/Vmware/Xen...)
- 940+ ISO files are tested (List). 90%+ distros in distrowatch.com supported (Details).
+ 1000+ ISO files are tested (List). 90%+ distros in distrowatch.com supported (Details).

Official Website: https://www.ventoy.net @@ -27,7 +27,7 @@ Most type of OS supported(Windows/WinPE/Linux/Unix/ChromeOS/Vmware/Xen...)
Windows 7, Windows 8, Windows 8.1, Windows 10, Windows 11, Windows Server 2012, Windows Server 2012 R2, Windows Server 2016, Windows Server 2019, Windows Server 2022, WinPE **Linux** -Debian, Ubuntu, CentOS(6/7/8/9), RHEL(6/7/8/9), Deepin, Fedora, EuroLinux(6/7/8/9), Rocky Linux, AlmaLinux, openEuler, OpenAnolis, SLES, openSUSE, MX Linux, Manjaro, Linux Mint, Endless OS, Elementary OS, Solus, Linx, Zorin, antiX, PClinuxOS, Arch, ArcoLinux, ArchLabs, BlackArch, Obarun, Artix Linux, Puppy Linux, Tails, Slax, Kali, Mageia, Slackware, Q4OS, Archman, Gentoo, Pentoo, NixOS, Kylin, openKylin, Ubuntu Kylin, Lubuntu, Xubuntu, Kubuntu, Ubuntu MATE, Ubuntu Budgie, Ubuntu Studio, Bluestar, OpenMandriva, ExTiX, Netrunner, ALT Linux, Nitrux, Peppermint, KDE neon, Linux Lite, Parrot OS, Qubes, Pop OS, ROSA, Void Linux, Star Linux, EndeavourOS, MakuluLinux, Voyager, Feren, ArchBang, LXLE, Knoppix, Calculate Linux, Clear Linux, Pure OS, Oracle Linux, Trident, Septor, Porteus, Devuan, GoboLinux, 4MLinux, Simplicity Linux, Zeroshell, Android-x86, netboot.xyz, Slitaz, SuperGrub2Disk, Proxmox VE, Kaspersky Rescue, SystemRescueCD, MemTest86, MemTest86+, MiniTool Partition Wizard, Parted Magic, veket, Sabayon, Scientific, alpine, ClearOS, CloneZilla, Berry Linux, Trisquel, Ataraxia Linux, Minimal Linux Live, BackBox Linux, Emmabuntüs, ESET SysRescue Live,Nova Linux, AV Linux, RoboLinux, NuTyX, IPFire, SELKS, ZStack, Enso Linux, Security Onion, Network Security Toolkit, Absolute Linux, TinyCore, Springdale Linux, Frost Linux, Shark Linux, LinuxFX, Snail Linux, Astra Linux, Namib Linux, Resilient Linux, Virage Linux, Blackweb Security OS, R-DriveImage, O-O.DiskImage, Macrium, ToOpPy LINUX, GNU Guix, YunoHost, foxclone, siduction, Adelie Linux, Elive, Pardus, CDlinux, AcademiX, Austrumi, Zenwalk, Anarchy, DuZeru, BigLinux, OpenMediaVault, Ubuntu DP, Exe GNU/Linux, 3CX Phone System, KANOTIX, Grml, Karoshi, PrimTux, ArchStrike, CAELinux, Cucumber, Fatdog, ForLEx, Hanthana, Kwort, MiniNo, Redcore, Runtu, Asianux, Clu Linux Live, Uruk, OB2D, BlueOnyx, Finnix, HamoniKR, Parabola, LinHES, LinuxConsole, BEE free, Untangle, Pearl, Thinstation, TurnKey, tuxtrans, Neptune, HefftorLinux, GeckoLinux, Mabox Linux, Zentyal, Maui, Reborn OS, SereneLinux , SkyWave Linux, Kaisen Linux, Regata OS, TROM-Jaro, DRBL Linux, Chalet OS, Chapeau, Desa OS, BlankOn, OpenMamba, Frugalware, Kibojoe Linux, Revenge OS, Tsurugi Linux, Drauger OS, Hash Linux, gNewSense, Ikki Boot, SteamOS, Hyperbola, VyOS, EasyNAS, SuperGamer, Live Raizo, Swift Linux, RebeccaBlackOS, Daphile, CRUX, Univention, Ufficio Zero, Rescuezilla, Phoenix OS, Garuda Linux, Mll, NethServer, OSGeoLive, Easy OS, Volumio, FreedomBox, paldo, UBOS, Recalbox, batocera, Lakka, LibreELEC, Pardus Topluluk, Pinguy, KolibriOS, Elastix, Arya, Omoikane, Omarine, Endian Firewall, Hamara, Rocks Cluster, MorpheusArch, Redo, Slackel, SME Server, APODIO, Smoothwall, Dragora, Linspire, Secure-K OS, Peach OSI, Photon, Plamo, SuperX, Bicom, Ploplinux, HP SPP, LliureX, Freespire, DietPi, BOSS, Webconverger, Lunar, TENS, Source Mage, RancherOS, T2, Vine, Pisi, blackPanther, mAid, Acronis, Active.Boot, AOMEI, Boot.Repair, CAINE, DaRT, EasyUEFI, R-Drive, PrimeOS, Avira Rescue System, bitdefender, Checkra1n Linux, Lenovo Diagnostics, Clover, Bliss-OS, Lenovo BIOS Update, Arcabit Rescue Disk, MiyoLinux, TeLOS, Kerio Control, RED OS, OpenWrt, MocaccinoOS, EasyStartup, Pyabr, Refracta, Eset SysRescue, Linpack Xtreme, Archcraft, NHVBOOT, pearOS, SeaTools, Easy Recovery Essentional, iKuai, StorageCraft SCRE, ZFSBootMenu, TROMjaro, BunsenLabs, Todo en Uno, ...... +Debian, Ubuntu, CentOS(6/7/8/9), RHEL(6/7/8/9), Deepin, Fedora, EuroLinux(6/7/8/9), Rocky Linux, AlmaLinux, openEuler, OpenAnolis, SLES, openSUSE, MX Linux, Manjaro, Linux Mint, Endless OS, Elementary OS, Solus, Linx, Zorin, antiX, PClinuxOS, Arch, ArcoLinux, ArchLabs, BlackArch, Obarun, Artix Linux, Puppy Linux, Tails, Slax, Kali, Mageia, Slackware, Q4OS, Archman, Gentoo, Pentoo, NixOS, Kylin, openKylin, Ubuntu Kylin, Lubuntu, Xubuntu, Kubuntu, Ubuntu MATE, Ubuntu Budgie, Ubuntu Studio, Bluestar, OpenMandriva, ExTiX, Netrunner, ALT Linux, Nitrux, Peppermint, KDE neon, Linux Lite, Parrot OS, Qubes, Pop OS, ROSA, Void Linux, Star Linux, EndeavourOS, MakuluLinux, Voyager, Feren, ArchBang, LXLE, Knoppix, Calculate Linux, Clear Linux, Pure OS, Oracle Linux, Trident, Septor, Porteus, Devuan, GoboLinux, 4MLinux, Simplicity Linux, Zeroshell, Android-x86, netboot.xyz, Slitaz, SuperGrub2Disk, Proxmox VE, Kaspersky Rescue, SystemRescueCD, MemTest86, MemTest86+, MiniTool Partition Wizard, Parted Magic, veket, Sabayon, Scientific, alpine, ClearOS, CloneZilla, Berry Linux, Trisquel, Ataraxia Linux, Minimal Linux Live, BackBox Linux, Emmabuntüs, ESET SysRescue Live,Nova Linux, AV Linux, RoboLinux, NuTyX, IPFire, SELKS, ZStack, Enso Linux, Security Onion, Network Security Toolkit, Absolute Linux, TinyCore, Springdale Linux, Frost Linux, Shark Linux, LinuxFX, Snail Linux, Astra Linux, Namib Linux, Resilient Linux, Virage Linux, Blackweb Security OS, R-DriveImage, O-O.DiskImage, Macrium, ToOpPy LINUX, GNU Guix, YunoHost, foxclone, siduction, Adelie Linux, Elive, Pardus, CDlinux, AcademiX, Austrumi, Zenwalk, Anarchy, DuZeru, BigLinux, OpenMediaVault, Ubuntu DP, Exe GNU/Linux, 3CX Phone System, KANOTIX, Grml, Karoshi, PrimTux, ArchStrike, CAELinux, Cucumber, Fatdog, ForLEx, Hanthana, Kwort, MiniNo, Redcore, Runtu, Asianux, Clu Linux Live, Uruk, OB2D, BlueOnyx, Finnix, HamoniKR, Parabola, LinHES, LinuxConsole, BEE free, Untangle, Pearl, Thinstation, TurnKey, tuxtrans, Neptune, HefftorLinux, GeckoLinux, Mabox Linux, Zentyal, Maui, Reborn OS, SereneLinux , SkyWave Linux, Kaisen Linux, Regata OS, TROM-Jaro, DRBL Linux, Chalet OS, Chapeau, Desa OS, BlankOn, OpenMamba, Frugalware, Kibojoe Linux, Revenge OS, Tsurugi Linux, Drauger OS, Hash Linux, gNewSense, Ikki Boot, SteamOS, Hyperbola, VyOS, EasyNAS, SuperGamer, Live Raizo, Swift Linux, RebeccaBlackOS, Daphile, CRUX, Univention, Ufficio Zero, Rescuezilla, Phoenix OS, Garuda Linux, Mll, NethServer, OSGeoLive, Easy OS, Volumio, FreedomBox, paldo, UBOS, Recalbox, batocera, Lakka, LibreELEC, Pardus Topluluk, Pinguy, KolibriOS, Elastix, Arya, Omoikane, Omarine, Endian Firewall, Hamara, Rocks Cluster, MorpheusArch, Redo, Slackel, SME Server, APODIO, Smoothwall, Dragora, Linspire, Secure-K OS, Peach OSI, Photon, Plamo, SuperX, Bicom, Ploplinux, HP SPP, LliureX, Freespire, DietPi, BOSS, Webconverger, Lunar, TENS, Source Mage, RancherOS, T2, Vine, Pisi, blackPanther, mAid, Acronis, Active.Boot, AOMEI, Boot.Repair, CAINE, DaRT, EasyUEFI, R-Drive, PrimeOS, Avira Rescue System, bitdefender, Checkra1n Linux, Lenovo Diagnostics, Clover, Bliss-OS, Lenovo BIOS Update, Arcabit Rescue Disk, MiyoLinux, TeLOS, Kerio Control, RED OS, OpenWrt, MocaccinoOS, EasyStartup, Pyabr, Refracta, Eset SysRescue, Linpack Xtreme, Archcraft, NHVBOOT, pearOS, SeaTools, Easy Recovery Essentional, iKuai, StorageCraft SCRE, ZFSBootMenu, TROMjaro, BunsenLabs, Todo en Uno, ChallengerOS, Nobara, Holo, ...... **Unix** DragonFly FreeBSD pfSense GhostBSD FreeNAS TrueNAS XigmaNAS FuryBSD OPNsense HardenedBSD MidnightBSD ClonOS EmergencyBootKit @@ -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, 940+ iso files tested +* Most types of OS supported, 1000+ iso files tested * Linux vDisk boot supported * Not only boot but also complete installation process * Menu dynamically switchable between List/TreeView mode diff --git a/wimboot/wimboot-2.7.3/src/wim.c b/wimboot/wimboot-2.7.3/src/wim.c index 614305ca..3ccfa9e0 100644 --- a/wimboot/wimboot-2.7.3/src/wim.c +++ b/wimboot/wimboot-2.7.3/src/wim.c @@ -32,6 +32,7 @@ #include "wimboot.h" #include "vdisk.h" #include "lzx.h" +#include "xca.h" #include "wim.h" /** WIM chunk buffer */ @@ -180,6 +181,8 @@ static int wim_chunk ( struct vdisk_file *file, struct wim_header *header, /* Identify decompressor */ if ( header->flags & WIM_HDR_LZX ) { decompress = lzx_decompress; + } else if (header->flags & WIM_HDR_XPRESS) { + decompress = xca_decompress; } else { DBG ( "Can't handle unknown compression scheme %#08x " "for %#llx chunk %d at [%#llx+%#llx)\n", @@ -447,8 +450,10 @@ int wim_path ( struct vdisk_file *file, struct wim_header *header, return rc; /* Get root directory offset */ - direntry->subdir = ( ( security.len + sizeof ( uint64_t ) - 1 ) & - ~( sizeof ( uint64_t ) - 1 ) ); + if (security.len > 0) + direntry->subdir = ( ( security.len + sizeof ( uint64_t ) - 1 ) & ~( sizeof ( uint64_t ) - 1 ) ); + else + direntry->subdir = security.len + 8; /* Find directory entry */ name = memcpy ( path_copy, path, sizeof ( path_copy ) ); diff --git a/wimboot/wimboot-2.7.3/src/xca.c b/wimboot/wimboot-2.7.3/src/xca.c index 52a691aa..aaa030b1 100644 --- a/wimboot/wimboot-2.7.3/src/xca.c +++ b/wimboot/wimboot-2.7.3/src/xca.c @@ -42,7 +42,7 @@ */ ssize_t xca_decompress ( const void *data, size_t len, void *buf ) { const void *src = data; - const void *end = ( src + len ); + const void *end = ( uint8_t * ) src + len; uint8_t *out = buf; size_t out_len = 0; size_t out_len_threshold = 0; @@ -67,11 +67,9 @@ ssize_t xca_decompress ( const void *data, size_t len, void *buf ) { /* Construct symbol lengths */ lengths = src; - src += sizeof ( *lengths ); + src = ( uint8_t * ) src + sizeof ( *lengths ); if ( src > end ) { - DBG ( "XCA too short to hold Huffman lengths " - "table at input offset %#zx\n", - ( src - data ) ); + DBG ( "XCA too short to hold Huffman lengths table.\n"); return -1; } for ( raw = 0 ; raw < XCA_CODES ; raw++ ) @@ -113,7 +111,7 @@ ssize_t xca_decompress ( const void *data, size_t len, void *buf ) { out_len++; } else if ( ( raw == XCA_END_MARKER ) && - ( src >= ( end - 1 ) ) ) { + ( (uint8_t *) src >= ( ( uint8_t * ) end - 1 ) ) ) { /* End marker symbol */ return out_len; @@ -157,6 +155,5 @@ ssize_t xca_decompress ( const void *data, size_t len, void *buf ) { } } - DBG ( "XCA input overrun at output length %#zx\n", out_len ); - return -1; + return out_len; }