mirror of
https://github.com/ventoy/Ventoy.git
synced 2025-08-28 00:11:15 +00:00
1.0.14 release
This commit is contained in:
@@ -38,7 +38,7 @@ int g_ventoy_menu_refresh = 0;
|
||||
int g_ventoy_memdisk_mode = 0;
|
||||
int g_ventoy_iso_raw = 0;
|
||||
int g_ventoy_iso_uefi_drv = 0;
|
||||
int g_ventoy_last_entry = 0;
|
||||
int g_ventoy_last_entry = -1;
|
||||
int g_ventoy_suppress_esc = 0;
|
||||
int g_ventoy_menu_esc = 0;
|
||||
int g_ventoy_fn_mutex = 0;
|
||||
|
@@ -69,6 +69,7 @@ img_iterator_node *g_img_iterator_tail = NULL;
|
||||
grub_uint8_t g_ventoy_break_level = 0;
|
||||
grub_uint8_t g_ventoy_debug_level = 0;
|
||||
grub_uint8_t g_ventoy_chain_type = 0;
|
||||
|
||||
grub_uint8_t *g_ventoy_cpio_buf = NULL;
|
||||
grub_uint32_t g_ventoy_cpio_size = 0;
|
||||
cpio_newc_header *g_ventoy_initrd_head = NULL;
|
||||
@@ -90,6 +91,15 @@ static int g_tree_script_pos = 0;
|
||||
static char *g_list_script_buf = NULL;
|
||||
static int g_list_script_pos = 0;
|
||||
|
||||
static const char *g_menu_class[] =
|
||||
{
|
||||
"vtoyiso", "vtoywim", "vtoyefi", "vtoyimg"
|
||||
};
|
||||
|
||||
static const char *g_menu_prefix[] =
|
||||
{
|
||||
"iso", "wim", "efi", "img"
|
||||
};
|
||||
|
||||
void ventoy_debug(const char *fmt, ...)
|
||||
{
|
||||
@@ -806,6 +816,12 @@ static int ventoy_colect_img_files(const char *filename, const struct grub_dirho
|
||||
{
|
||||
type = img_type_wim;
|
||||
}
|
||||
#ifdef GRUB_MACHINE_EFI
|
||||
else if (0 == grub_strcasecmp(filename + len - 4, ".efi"))
|
||||
{
|
||||
type = img_type_efi;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
@@ -831,12 +847,12 @@ static int ventoy_colect_img_files(const char *filename, const struct grub_dirho
|
||||
}
|
||||
}
|
||||
|
||||
grub_snprintf(img->path, sizeof(img->path), "%s%s", node->dir, img->name);
|
||||
img->pathlen = grub_snprintf(img->path, sizeof(img->path), "%s%s", node->dir, img->name);
|
||||
|
||||
img->size = info->size;
|
||||
if (0 == img->size)
|
||||
{
|
||||
img->size = ventoy_grub_get_file_size("%s/%s", g_iso_path, img->path);
|
||||
img->size = ventoy_grub_get_file_size("%s/%s%s", g_iso_path, node->dir, filename);
|
||||
}
|
||||
|
||||
if (img->size < VTOY_FILT_MIN_FILE_SIZE)
|
||||
@@ -876,6 +892,12 @@ static int ventoy_colect_img_files(const char *filename, const struct grub_dirho
|
||||
g_ventoy_img_count++;
|
||||
|
||||
img->alias = ventoy_plugin_get_menu_alias(img->path);
|
||||
img->class = ventoy_plugin_get_menu_class(img->name);
|
||||
if (!img->class)
|
||||
{
|
||||
img->class = g_menu_class[type];
|
||||
}
|
||||
img->menu_prefix = g_menu_prefix[type];
|
||||
|
||||
debug("Add %s%s to list %d\n", node->dir, filename, g_ventoy_img_count);
|
||||
}
|
||||
@@ -1025,7 +1047,7 @@ static int ventoy_dynamic_tree_menu(img_iterator_node *node)
|
||||
if (g_default_menu_mode == 0)
|
||||
{
|
||||
vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
|
||||
"menuentry \"%-10s [Return to ListView]\" VTOY_RET {\n "
|
||||
"menuentry \"%-10s [Return to ListView]\" --class=\"vtoyret\" VTOY_RET {\n "
|
||||
" echo 'return ...' \n"
|
||||
"}\n", "<--");
|
||||
}
|
||||
@@ -1034,11 +1056,11 @@ static int ventoy_dynamic_tree_menu(img_iterator_node *node)
|
||||
{
|
||||
node->dir[node->dirlen - 1] = 0;
|
||||
vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
|
||||
"submenu \"%-10s [%s]\" {\n",
|
||||
"submenu \"%-10s [%s]\" --class=\"vtoydir\" {\n",
|
||||
"DIR", node->dir + offset);
|
||||
|
||||
vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
|
||||
"menuentry \"%-10s [../]\" VTOY_RET {\n "
|
||||
"menuentry \"%-10s [../]\" --class=\"vtoyret\" VTOY_RET {\n "
|
||||
" echo 'return ...' \n"
|
||||
"}\n", "<--");
|
||||
}
|
||||
@@ -1051,13 +1073,13 @@ static int ventoy_dynamic_tree_menu(img_iterator_node *node)
|
||||
while ((img = ventoy_get_min_iso(node)) != NULL)
|
||||
{
|
||||
vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
|
||||
"menuentry \"%-10s %s%s\" --id=\"VID_%d\" {\n"
|
||||
"menuentry \"%-10s %s%s\" --class=\"%s\" --id=\"VID_%d\" {\n"
|
||||
" %s_%s \n"
|
||||
"}\n",
|
||||
grub_get_human_size(img->size, GRUB_HUMAN_SIZE_SHORT),
|
||||
img->unsupport ? "[unsupported] " : "",
|
||||
img->alias ? img->alias : img->name, img->id,
|
||||
(img->type == img_type_iso) ? "iso" : "wim",
|
||||
img->alias ? img->alias : img->name, img->class, img->id,
|
||||
img->menu_prefix,
|
||||
img->unsupport ? "unsupport_menuentry" : "common_menuentry");
|
||||
}
|
||||
|
||||
@@ -1077,8 +1099,11 @@ static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char
|
||||
grub_device_t dev = NULL;
|
||||
img_info *cur = NULL;
|
||||
img_info *tail = NULL;
|
||||
img_info *default_node = NULL;
|
||||
const char *strdata = NULL;
|
||||
char *device_name = NULL;
|
||||
const char *default_image = NULL;
|
||||
int img_len = 0;
|
||||
char buf[32];
|
||||
img_iterator_node *node = NULL;
|
||||
img_iterator_node *tmp = NULL;
|
||||
@@ -1188,22 +1213,45 @@ static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char
|
||||
if (g_default_menu_mode == 1)
|
||||
{
|
||||
vtoy_ssprintf(g_list_script_buf, g_list_script_pos,
|
||||
"menuentry \"%s [Return to TreeView]\" VTOY_RET {\n "
|
||||
"menuentry \"%s [Return to TreeView]\" --class=\"vtoyret\" VTOY_RET {\n "
|
||||
" echo 'return ...' \n"
|
||||
"}\n", "<--");
|
||||
}
|
||||
|
||||
if (g_default_menu_mode == 0)
|
||||
{
|
||||
default_image = ventoy_get_env("VTOY_DEFAULT_IMAGE");
|
||||
if (default_image)
|
||||
{
|
||||
img_len = grub_strlen(default_image);
|
||||
}
|
||||
}
|
||||
|
||||
for (cur = g_ventoy_img_list; cur; cur = cur->next)
|
||||
{
|
||||
vtoy_ssprintf(g_list_script_buf, g_list_script_pos,
|
||||
"menuentry \"%s%s\" --id=\"VID_%d\" {\n"
|
||||
"menuentry \"%s%s\" --class=\"%s\" --id=\"VID_%d\" {\n"
|
||||
" %s_%s \n"
|
||||
"}\n",
|
||||
cur->unsupport ? "[unsupported] " : "",
|
||||
cur->alias ? cur->alias : cur->name, cur->id,
|
||||
(cur->type == img_type_iso) ? "iso" : "wim",
|
||||
cur->alias ? cur->alias : cur->name, cur->class, cur->id,
|
||||
cur->menu_prefix,
|
||||
cur->unsupport ? "unsupport_menuentry" : "common_menuentry");
|
||||
|
||||
if (g_default_menu_mode == 0 && default_image && default_node == NULL)
|
||||
{
|
||||
if (img_len == cur->pathlen && grub_strcmp(default_image, cur->path) == 0)
|
||||
{
|
||||
default_node = cur;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (default_node)
|
||||
{
|
||||
vtoy_ssprintf(g_list_script_buf, g_list_script_pos, "set default='VID_%d'\n", default_node->id);
|
||||
}
|
||||
|
||||
g_list_script_buf[g_list_script_pos] = 0;
|
||||
|
||||
grub_snprintf(buf, sizeof(buf), "%d", g_ventoy_img_count);
|
||||
@@ -1421,6 +1469,7 @@ void ventoy_fill_os_param(grub_file_t file, ventoy_os_param *param)
|
||||
{
|
||||
char *pos;
|
||||
const char *fs = NULL;
|
||||
const char *cdprompt = NULL;
|
||||
grub_uint32_t i;
|
||||
grub_uint8_t chksum = 0;
|
||||
grub_disk_t disk;
|
||||
@@ -1449,6 +1498,17 @@ void ventoy_fill_os_param(grub_file_t file, ventoy_os_param *param)
|
||||
|
||||
param->vtoy_reserved[2] = g_ventoy_chain_type;
|
||||
|
||||
/* Windows CD/DVD prompt 0:suppress 1:reserved */
|
||||
param->vtoy_reserved[4] = 0;
|
||||
if (g_ventoy_chain_type == 1) /* Windows */
|
||||
{
|
||||
cdprompt = ventoy_get_env("VTOY_WINDOWS_CD_PROMPT");
|
||||
if (cdprompt && cdprompt[0] == '1' && cdprompt[1] == 0)
|
||||
{
|
||||
param->vtoy_reserved[4] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
fs = ventoy_get_env("ventoy_fs_probe");
|
||||
if (fs && grub_strcmp(fs, "udf") == 0)
|
||||
{
|
||||
@@ -1905,7 +1965,7 @@ static grub_err_t ventoy_cmd_dump_img_list(grub_extcmd_context_t ctxt, int argc,
|
||||
|
||||
while (cur)
|
||||
{
|
||||
grub_printf("path:<%s>\n", cur->path);
|
||||
grub_printf("path:<%s> id=%d\n", cur->path, cur->id);
|
||||
grub_printf("name:<%s>\n\n", cur->name);
|
||||
cur = cur->next;
|
||||
}
|
||||
|
@@ -127,13 +127,18 @@ typedef struct ventoy_udf_override
|
||||
|
||||
#define img_type_iso 0
|
||||
#define img_type_wim 1
|
||||
#define img_type_efi 2
|
||||
#define img_type_img 3
|
||||
|
||||
typedef struct img_info
|
||||
{
|
||||
int pathlen;
|
||||
char path[512];
|
||||
char name[256];
|
||||
|
||||
const char *alias;
|
||||
const char *class;
|
||||
const char *menu_prefix;
|
||||
|
||||
int id;
|
||||
int type;
|
||||
@@ -623,6 +628,15 @@ typedef struct menu_alias
|
||||
struct menu_alias *next;
|
||||
}menu_alias;
|
||||
|
||||
typedef struct menu_class
|
||||
{
|
||||
int patlen;
|
||||
char pattern[256];
|
||||
char class[64];
|
||||
|
||||
struct menu_class *next;
|
||||
}menu_class;
|
||||
|
||||
extern int g_ventoy_menu_esc;
|
||||
extern int g_ventoy_suppress_esc;
|
||||
extern int g_ventoy_last_entry;
|
||||
@@ -641,6 +655,7 @@ void ventoy_plugin_dump_auto_install(void);
|
||||
int ventoy_fill_windows_rtdata(void *buf, char *isopath);
|
||||
int ventoy_plugin_get_persistent_chunklist(const char *isopath, int index, ventoy_img_chunk_list *chunk_list);
|
||||
const char * ventoy_plugin_get_menu_alias(const char *isopath);
|
||||
const char * ventoy_plugin_get_menu_class(const char *isoname);
|
||||
int ventoy_get_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, grub_disk_addr_t start);
|
||||
int ventoy_check_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, grub_disk_addr_t start);
|
||||
void ventoy_plugin_dump_persistence(void);
|
||||
|
@@ -33,6 +33,7 @@
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/net.h>
|
||||
#include <grub/time.h>
|
||||
#include <grub/font.h>
|
||||
#include <grub/ventoy.h>
|
||||
#include "ventoy_def.h"
|
||||
|
||||
@@ -42,6 +43,7 @@ static char g_iso_disk_name[128];
|
||||
static install_template *g_install_template_head = NULL;
|
||||
static persistence_config *g_persistence_head = NULL;
|
||||
static menu_alias *g_menu_alias_head = NULL;
|
||||
static menu_class *g_menu_class_head = NULL;
|
||||
|
||||
static int ventoy_plugin_control_check(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
@@ -114,6 +116,7 @@ static int ventoy_plugin_theme_check(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int exist = 0;
|
||||
const char *value;
|
||||
VTOY_JSON *node;
|
||||
|
||||
value = vtoy_json_get_string_ex(json->pstChild, "file");
|
||||
if (value)
|
||||
@@ -165,6 +168,29 @@ static int ventoy_plugin_theme_check(VTOY_JSON *json, const char *isodisk)
|
||||
grub_printf("ventoy_color: %s\n", value);
|
||||
}
|
||||
|
||||
node = vtoy_json_find_item(json->pstChild, JSON_TYPE_ARRAY, "fonts");
|
||||
if (node)
|
||||
{
|
||||
for (node = node->pstChild; node; node = node->pstNext)
|
||||
{
|
||||
if (node->enDataType == JSON_TYPE_STRING)
|
||||
{
|
||||
if (ventoy_check_file_exist("%s%s", isodisk, node->unData.pcStrVal))
|
||||
{
|
||||
grub_printf("%s [OK]\n", node->unData.pcStrVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("%s [NOT EXIST]\n", node->unData.pcStrVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("fonts NOT found\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -172,6 +198,7 @@ static int ventoy_plugin_theme_entry(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
const char *value;
|
||||
char filepath[256];
|
||||
VTOY_JSON *node;
|
||||
|
||||
value = vtoy_json_get_string_ex(json->pstChild, "file");
|
||||
if (value)
|
||||
@@ -227,6 +254,20 @@ static int ventoy_plugin_theme_entry(VTOY_JSON *json, const char *isodisk)
|
||||
grub_env_set("VTLE_CLR", value);
|
||||
}
|
||||
|
||||
node = vtoy_json_find_item(json->pstChild, JSON_TYPE_ARRAY, "fonts");
|
||||
if (node)
|
||||
{
|
||||
for (node = node->pstChild; node; node = node->pstNext)
|
||||
{
|
||||
if (node->enDataType == JSON_TYPE_STRING &&
|
||||
ventoy_check_file_exist("%s%s", isodisk, node->unData.pcStrVal))
|
||||
{
|
||||
grub_snprintf(filepath, sizeof(filepath), "%s%s", isodisk, node->unData.pcStrVal);
|
||||
grub_font_load(filepath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -612,7 +653,15 @@ static int ventoy_plugin_menualias_check(VTOY_JSON *json, const char *isodisk)
|
||||
alias = vtoy_json_get_string_ex(pNode->pstChild, "alias");
|
||||
if (iso && iso[0] == '/' && alias)
|
||||
{
|
||||
grub_printf("image: <%s>\n", iso);
|
||||
if (ventoy_is_file_exist("%s%s", isodisk, iso))
|
||||
{
|
||||
grub_printf("image: <%s> [ OK ]\n", iso);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("image: <%s> [ NOT EXIST ]\n", iso);
|
||||
}
|
||||
|
||||
grub_printf("alias: <%s>\n\n", alias);
|
||||
}
|
||||
}
|
||||
@@ -672,6 +721,90 @@ static int ventoy_plugin_menualias_entry(VTOY_JSON *json, const char *isodisk)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_plugin_menuclass_entry(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
const char *key = NULL;
|
||||
const char *class = NULL;
|
||||
VTOY_JSON *pNode = NULL;
|
||||
menu_class *tail = NULL;
|
||||
menu_class *node = NULL;
|
||||
menu_class *next = NULL;
|
||||
|
||||
(void)isodisk;
|
||||
|
||||
if (json->enDataType != JSON_TYPE_ARRAY)
|
||||
{
|
||||
debug("Not array %d\n", json->enDataType);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (g_menu_class_head)
|
||||
{
|
||||
for (node = g_menu_class_head; node; node = next)
|
||||
{
|
||||
next = node->next;
|
||||
grub_free(node);
|
||||
}
|
||||
|
||||
g_menu_class_head = NULL;
|
||||
}
|
||||
|
||||
for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
|
||||
{
|
||||
key = vtoy_json_get_string_ex(pNode->pstChild, "key");
|
||||
class = vtoy_json_get_string_ex(pNode->pstChild, "class");
|
||||
if (key && class)
|
||||
{
|
||||
node = grub_zalloc(sizeof(menu_class));
|
||||
if (node)
|
||||
{
|
||||
node->patlen = grub_snprintf(node->pattern, sizeof(node->pattern), "%s", key);
|
||||
grub_snprintf(node->class, sizeof(node->class), "%s", class);
|
||||
|
||||
if (g_menu_class_head)
|
||||
{
|
||||
tail->next = node;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_menu_class_head = node;
|
||||
}
|
||||
tail = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_plugin_menuclass_check(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
const char *key = NULL;
|
||||
const char *class = NULL;
|
||||
VTOY_JSON *pNode = NULL;
|
||||
|
||||
(void)isodisk;
|
||||
|
||||
if (json->enDataType != JSON_TYPE_ARRAY)
|
||||
{
|
||||
grub_printf("Not array %d\n", json->enDataType);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
|
||||
{
|
||||
key = vtoy_json_get_string_ex(pNode->pstChild, "key");
|
||||
class = vtoy_json_get_string_ex(pNode->pstChild, "class");
|
||||
if (key && class)
|
||||
{
|
||||
grub_printf("key: <%s>\n", key);
|
||||
grub_printf("class: <%s>\n\n", class);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static plugin_entry g_plugin_entries[] =
|
||||
{
|
||||
{ "control", ventoy_plugin_control_entry, ventoy_plugin_control_check },
|
||||
@@ -679,6 +812,7 @@ static plugin_entry g_plugin_entries[] =
|
||||
{ "auto_install", ventoy_plugin_auto_install_entry, ventoy_plugin_auto_install_check },
|
||||
{ "persistence", ventoy_plugin_persistence_entry, ventoy_plugin_persistence_check },
|
||||
{ "menu_alias", ventoy_plugin_menualias_entry, ventoy_plugin_menualias_check },
|
||||
{ "menu_class", ventoy_plugin_menuclass_entry, ventoy_plugin_menuclass_check },
|
||||
};
|
||||
|
||||
static int ventoy_parse_plugin_config(VTOY_JSON *json, const char *isodisk)
|
||||
@@ -932,6 +1066,23 @@ const char * ventoy_plugin_get_menu_alias(const char *isopath)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char * ventoy_plugin_get_menu_class(const char *isoname)
|
||||
{
|
||||
menu_class *node = NULL;
|
||||
int len = (int)grub_strlen(isoname);
|
||||
|
||||
for (node = g_menu_class_head; node; node = node->next)
|
||||
{
|
||||
if (node->patlen <= len && grub_strstr(isoname, node->pattern))
|
||||
{
|
||||
return node->class;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
grub_err_t ventoy_cmd_plugin_check_json(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int i = 0;
|
||||
|
@@ -45,6 +45,9 @@ static int g_wim_total_patch_count = 0;
|
||||
static int g_wim_valid_patch_count = 0;
|
||||
static wim_patch *g_wim_patch_head = NULL;
|
||||
|
||||
static grub_uint64_t g_suppress_wincd_override_offset = 0;
|
||||
static grub_uint32_t g_suppress_wincd_override_data = 0;
|
||||
|
||||
grub_uint8_t g_temp_buf[512];
|
||||
|
||||
grub_ssize_t lzx_decompress ( const void *data, grub_size_t len, void *buf );
|
||||
@@ -923,13 +926,15 @@ grub_err_t ventoy_cmd_locate_wim_patch(grub_extcmd_context_t ctxt, int argc, cha
|
||||
|
||||
static grub_uint32_t ventoy_get_override_chunk_num(void)
|
||||
{
|
||||
grub_uint32_t chunk_num = 0;
|
||||
|
||||
if (g_iso_fs_type == 0)
|
||||
{
|
||||
/* ISO9660: */
|
||||
/* per wim */
|
||||
/* 1: file_size and file_offset */
|
||||
/* 2: new wim file header */
|
||||
return g_wim_valid_patch_count * 2;
|
||||
chunk_num = g_wim_valid_patch_count * 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -941,8 +946,24 @@ static grub_uint32_t ventoy_get_override_chunk_num(void)
|
||||
/* 1: file_size in file_entry or extend_file_entry */
|
||||
/* 2: data_size and position in extend data short ad */
|
||||
/* 3: new wim file header */
|
||||
return g_wim_valid_patch_count * 3 + 1;
|
||||
chunk_num = g_wim_valid_patch_count * 3 + 1;
|
||||
}
|
||||
|
||||
if (g_suppress_wincd_override_offset > 0)
|
||||
{
|
||||
chunk_num++;
|
||||
}
|
||||
|
||||
return chunk_num;
|
||||
}
|
||||
|
||||
static void ventoy_fill_suppress_wincd_override_data(void *override)
|
||||
{
|
||||
ventoy_override_chunk *cur = (ventoy_override_chunk *)override;
|
||||
|
||||
cur->override_size = 4;
|
||||
cur->img_offset = g_suppress_wincd_override_offset;
|
||||
grub_memcpy(cur->override_data, &g_suppress_wincd_override_data, cur->override_size);
|
||||
}
|
||||
|
||||
static void ventoy_windows_fill_override_data_iso9660( grub_uint64_t isosize, void *override)
|
||||
@@ -958,6 +979,12 @@ static void ventoy_windows_fill_override_data_iso9660( grub_uint64_t isosize,
|
||||
|
||||
cur = (ventoy_override_chunk *)override;
|
||||
|
||||
if (g_suppress_wincd_override_offset > 0)
|
||||
{
|
||||
ventoy_fill_suppress_wincd_override_data(cur);
|
||||
cur++;
|
||||
}
|
||||
|
||||
debug("ventoy_windows_fill_override_data_iso9660 %lu\n", (ulong)isosize);
|
||||
|
||||
for (node = g_wim_patch_head; node; node = node->next)
|
||||
@@ -1012,6 +1039,12 @@ static void ventoy_windows_fill_override_data_udf( grub_uint64_t isosize, voi
|
||||
sector = (isosize + 2047) / 2048;
|
||||
|
||||
cur = (ventoy_override_chunk *)override;
|
||||
|
||||
if (g_suppress_wincd_override_offset > 0)
|
||||
{
|
||||
ventoy_fill_suppress_wincd_override_data(cur);
|
||||
cur++;
|
||||
}
|
||||
|
||||
debug("ventoy_windows_fill_override_data_udf %lu\n", (ulong)isosize);
|
||||
|
||||
@@ -1182,6 +1215,61 @@ static int ventoy_windows_drive_map(ventoy_chain_head *chain)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_suppress_windows_cd_prompt(void)
|
||||
{
|
||||
int rc = 1;
|
||||
const char *cdprompt = NULL;
|
||||
grub_uint64_t readpos = 0;
|
||||
grub_file_t file = NULL;
|
||||
grub_uint8_t data[32];
|
||||
|
||||
cdprompt = ventoy_get_env("VTOY_WINDOWS_CD_PROMPT");
|
||||
if (cdprompt && cdprompt[0] == '1' && cdprompt[1] == 0)
|
||||
{
|
||||
debug("VTOY_WINDOWS_CD_PROMPT:<%s>\n", cdprompt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_ventoy_case_insensitive = 1;
|
||||
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s/boot/bootfix.bin", "(loop)");
|
||||
g_ventoy_case_insensitive = 0;
|
||||
|
||||
if (!file)
|
||||
{
|
||||
debug("Failed to open %s\n", "bootfix.bin");
|
||||
goto end;
|
||||
}
|
||||
|
||||
grub_file_read(file, data, 32);
|
||||
|
||||
if (file->fs && file->fs->name && grub_strcmp(file->fs->name, "udf") == 0)
|
||||
{
|
||||
readpos = grub_udf_get_file_offset(file);
|
||||
}
|
||||
else
|
||||
{
|
||||
readpos = grub_iso9660_get_last_read_pos(file);
|
||||
}
|
||||
|
||||
debug("bootfix.bin readpos:%lu (sector:%lu) data: %02x %02x %02x %02x\n",
|
||||
(ulong)readpos, (ulong)readpos / 2048, data[24], data[25], data[26], data[27]);
|
||||
|
||||
if (*(grub_uint32_t *)(data + 24) == 0x13cd0080)
|
||||
{
|
||||
g_suppress_wincd_override_offset = readpos + 24;
|
||||
g_suppress_wincd_override_data = 0x13cd00fd;
|
||||
|
||||
rc = 0;
|
||||
}
|
||||
|
||||
debug("g_suppress_wincd_override_offset:%lu\n", (ulong)g_suppress_wincd_override_offset);
|
||||
|
||||
end:
|
||||
check_free(file, grub_file_close);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_windows_chain_data(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int unknown_image = 0;
|
||||
@@ -1250,11 +1338,18 @@ grub_err_t ventoy_cmd_windows_chain_data(grub_extcmd_context_t ctxt, int argc, c
|
||||
}
|
||||
}
|
||||
|
||||
g_suppress_wincd_override_offset = 0;
|
||||
if (!ventoy_is_efi_os()) /* legacy mode */
|
||||
{
|
||||
ventoy_suppress_windows_cd_prompt();
|
||||
}
|
||||
|
||||
img_chunk_size = g_img_chunk_list.cur_chunk * sizeof(ventoy_img_chunk);
|
||||
|
||||
if (ventoy_compatible || unknown_image)
|
||||
{
|
||||
size = sizeof(ventoy_chain_head) + img_chunk_size;
|
||||
override_size = g_suppress_wincd_override_offset > 0 ? sizeof(ventoy_override_chunk) : 0;
|
||||
size = sizeof(ventoy_chain_head) + img_chunk_size + override_size;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1319,6 +1414,13 @@ grub_err_t ventoy_cmd_windows_chain_data(grub_extcmd_context_t ctxt, int argc, c
|
||||
|
||||
if (ventoy_compatible || unknown_image)
|
||||
{
|
||||
if (g_suppress_wincd_override_offset > 0)
|
||||
{
|
||||
chain->override_chunk_offset = chain->img_chunk_offset + img_chunk_size;
|
||||
chain->override_chunk_num = 1;
|
||||
ventoy_fill_suppress_wincd_override_data((char *)chain + chain->override_chunk_offset);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -111,6 +111,7 @@ typedef struct ventoy_os_param
|
||||
* vtoy_reserved[1]: vtoy_debug_level
|
||||
* vtoy_reserved[2]: vtoy_chain_type 0:Linux 1:Windows
|
||||
* vtoy_reserved[3]: vtoy_iso_format 0:iso9660 1:udf
|
||||
* vtoy_reserved[4]: vtoy_windows_cd_prompt
|
||||
*
|
||||
*/
|
||||
grub_uint8_t vtoy_reserved[32]; // Internal use by ventoy
|
||||
|
@@ -12,14 +12,15 @@ make install
|
||||
PATH=$PATH:$VT_DIR/GRUB2/INSTALL/bin/:$VT_DIR/GRUB2/INSTALL/sbin/
|
||||
|
||||
net_modules_legacy="net tftp http"
|
||||
all_modules_legacy="date drivemap blocklist ntldr search at_keyboard usb_keyboard gcry_md5 hashsum gzio xzio lzopio lspci pci ext2 xfs ventoy chain read halt iso9660 linux16 test true sleep reboot echo videotest videoinfo videotest_checksum video_colors video_cirrus video_bochs vga vbe video_fb font video gettext extcmd terminal linux minicmd help configfile tr trig boot biosdisk disk ls tar squash4 password_pbkdf2 all_video png jpeg part_msdos fat exfat ntfs loopback gzio normal udf gfxmenu gfxterm gfxterm_background gfxterm_menu"
|
||||
all_modules_legacy="date drivemap blocklist ntldr search at_keyboard usb_keyboard gcry_md5 hashsum gzio xzio lzopio lspci pci ext2 xfs ventoy chain read halt iso9660 linux16 test true sleep reboot echo videotest videoinfo videotest_checksum video_colors video_cirrus video_bochs vga vbe video_fb font video gettext extcmd terminal linux minicmd help configfile tr trig boot biosdisk disk ls tar squash4 password_pbkdf2 all_video png jpeg part_gpt part_msdos fat exfat ntfs loopback gzio normal udf gfxmenu gfxterm gfxterm_background gfxterm_menu"
|
||||
|
||||
net_modules_uefi="efinet net tftp http"
|
||||
all_modules_uefi="blocklist ventoy test search at_keyboard usb_keyboard gcry_md5 hashsum gzio xzio lzopio ext2 xfs read halt sleep serial terminfo png password_pbkdf2 gcry_sha512 pbkdf2 part_gpt part_msdos ls tar squash4 loopback part_apple minicmd diskfilter linux relocator jpeg iso9660 udf hfsplus halt acpi mmap gfxmenu video_colors trig bitmap_scale gfxterm bitmap font fat exfat ntfs fshelp efifwsetup reboot echo configfile normal terminal gettext chain priority_queue bufio datetime cat extcmd crypto gzio boot all_video efi_gop efi_uga video_bochs video_cirrus video video_fb gfxterm_background gfxterm_menu"
|
||||
|
||||
all_extra_modules="elf macho offsetio regexp file"
|
||||
|
||||
if [ "$1" = "uefi" ]; then
|
||||
all_modules="$net_modules_uefi $all_modules_uefi"
|
||||
all_modules="$net_modules_uefi $all_modules_uefi $all_extra_modules"
|
||||
grub-mkimage -v --directory "$VT_DIR/GRUB2/INSTALL/lib/grub/x86_64-efi" --prefix '(,msdos2)/grub' --output "$VT_DIR/INSTALL/EFI/BOOT/grubx64_real.efi" --format 'x86_64-efi' --compression 'auto' $all_modules_uefi 'fat' 'part_msdos'
|
||||
else
|
||||
all_modules="$net_modules_legacy $all_modules_legacy"
|
||||
@@ -38,6 +39,11 @@ else
|
||||
rm -f $VT_DIR/GRUB2/NBP/core.0
|
||||
cp -a $VT_DIR/GRUB2/PXE/grub2/i386-pc/core.0 $VT_DIR/GRUB2/NBP/core.0 || exit 1
|
||||
|
||||
for md in $all_extra_modules; do
|
||||
rm -f $VT_DIR/INSTALL/grub/i386-pc/${md}.mod
|
||||
cp -a $VT_DIR/GRUB2/INSTALL/lib/grub/i386-pc/${md}.mod $VT_DIR/INSTALL/grub/i386-pc/
|
||||
done
|
||||
|
||||
rm -f $VT_DIR/INSTALL/grub/i386-pc/boot.img
|
||||
cp -a $VT_DIR/GRUB2/INSTALL/lib/grub/i386-pc/boot.img $VT_DIR/INSTALL/grub/i386-pc/boot.img || exit 1
|
||||
fi
|
||||
|
Reference in New Issue
Block a user