mirror of
https://github.com/ventoy/Ventoy.git
synced 2025-06-04 00:48:48 -04:00
1.0.80 release
This commit is contained in:
parent
6b22a6200e
commit
17f9e2fd09
31 changed files with 844 additions and 120 deletions
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue