mirror of
https://github.com/ventoy/Ventoy.git
synced 2025-09-17 17:31:16 +00:00
Compare commits
7 Commits
v1.0.08bet
...
v1.0.09bet
Author | SHA1 | Date | |
---|---|---|---|
|
3ca624f3ee | ||
|
d42bc35915 | ||
|
39b5edc345 | ||
|
9c183ed416 | ||
|
8e0c630fe5 | ||
|
9f57cb3929 | ||
|
525ef4f516 |
@@ -964,6 +964,12 @@ grub_fat_dir (grub_device_t device, const char *path, grub_fs_dir_hook_t hook,
|
|||||||
|
|
||||||
info.dir = !! (ctxt.dir.attr & GRUB_FAT_ATTR_DIRECTORY);
|
info.dir = !! (ctxt.dir.attr & GRUB_FAT_ATTR_DIRECTORY);
|
||||||
info.case_insensitive = 1;
|
info.case_insensitive = 1;
|
||||||
|
|
||||||
|
#ifdef MODE_EXFAT
|
||||||
|
if (!info.dir)
|
||||||
|
info.size = ctxt.dir.file_size;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef MODE_EXFAT
|
#ifdef MODE_EXFAT
|
||||||
if (!ctxt.dir.have_stream)
|
if (!ctxt.dir.have_stream)
|
||||||
continue;
|
continue;
|
||||||
@@ -1445,4 +1451,3 @@ END:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -34,6 +34,12 @@
|
|||||||
#include <grub/dl.h>
|
#include <grub/dl.h>
|
||||||
#include <grub/env.h>
|
#include <grub/env.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
/* Time to delay after displaying an error message about a default/fallback
|
/* Time to delay after displaying an error message about a default/fallback
|
||||||
entry failing to boot. */
|
entry failing to boot. */
|
||||||
#define DEFAULT_ENTRY_ERROR_DELAY_MS 2500
|
#define DEFAULT_ENTRY_ERROR_DELAY_MS 2500
|
||||||
@@ -577,16 +583,20 @@ print_countdown (struct grub_term_coordinate *pos, int n)
|
|||||||
static int
|
static int
|
||||||
run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
||||||
{
|
{
|
||||||
|
const char *cmdstr;
|
||||||
grub_uint64_t saved_time;
|
grub_uint64_t saved_time;
|
||||||
int default_entry, current_entry;
|
int default_entry,current_entry;
|
||||||
int timeout;
|
int timeout;
|
||||||
enum timeout_style timeout_style;
|
enum timeout_style timeout_style;
|
||||||
|
|
||||||
default_entry = get_entry_number (menu, "default");
|
default_entry = get_entry_number (menu, "default");
|
||||||
|
|
||||||
|
if (g_ventoy_last_entry >= 0 && g_ventoy_last_entry < menu->size) {
|
||||||
|
default_entry = g_ventoy_last_entry;
|
||||||
|
}
|
||||||
/* If DEFAULT_ENTRY is not within the menu entries, fall back to
|
/* If DEFAULT_ENTRY is not within the menu entries, fall back to
|
||||||
the first entry. */
|
the first entry. */
|
||||||
if (default_entry < 0 || default_entry >= menu->size)
|
else if (default_entry < 0 || default_entry >= menu->size)
|
||||||
default_entry = 0;
|
default_entry = 0;
|
||||||
|
|
||||||
timeout = grub_menu_get_timeout ();
|
timeout = grub_menu_get_timeout ();
|
||||||
@@ -787,34 +797,76 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
|||||||
}
|
}
|
||||||
goto refresh;
|
goto refresh;
|
||||||
|
|
||||||
|
case GRUB_TERM_KEY_F2:
|
||||||
|
cmdstr = grub_env_get("VTOY_F2_CMD");
|
||||||
|
if (cmdstr)
|
||||||
|
{
|
||||||
|
menu_fini ();
|
||||||
|
grub_script_execute_sourcecode(cmdstr);
|
||||||
|
goto refresh;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GRUB_TERM_KEY_F3:
|
||||||
|
cmdstr = grub_env_get("VTOY_F3_CMD");
|
||||||
|
if (cmdstr)
|
||||||
|
{
|
||||||
|
menu_fini ();
|
||||||
|
grub_script_execute_sourcecode(cmdstr);
|
||||||
|
goto refresh;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GRUB_TERM_KEY_F4:
|
||||||
|
cmdstr = grub_env_get("VTOY_F4_CMD");
|
||||||
|
if (cmdstr)
|
||||||
|
{
|
||||||
|
menu_fini ();
|
||||||
|
grub_script_execute_sourcecode(cmdstr);
|
||||||
|
goto refresh;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GRUB_TERM_KEY_F5:
|
||||||
|
cmdstr = grub_env_get("VTOY_F5_CMD");
|
||||||
|
if (cmdstr)
|
||||||
|
{
|
||||||
|
menu_fini ();
|
||||||
|
grub_script_execute_sourcecode(cmdstr);
|
||||||
|
goto refresh;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GRUB_TERM_KEY_F6:
|
||||||
|
cmdstr = grub_env_get("VTOY_F6_CMD");
|
||||||
|
if (cmdstr)
|
||||||
|
{
|
||||||
|
menu_fini ();
|
||||||
|
grub_script_execute_sourcecode(cmdstr);
|
||||||
|
goto refresh;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GRUB_TERM_KEY_F7:
|
||||||
|
cmdstr = grub_env_get("VTOY_F7_CMD");
|
||||||
|
if (cmdstr)
|
||||||
|
{
|
||||||
|
menu_fini ();
|
||||||
|
grub_script_execute_sourcecode(cmdstr);
|
||||||
|
goto refresh;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case GRUB_TERM_KEY_F1:
|
case GRUB_TERM_KEY_F1:
|
||||||
menu_fini ();
|
menu_fini ();
|
||||||
if (grub_env_get("VTOY_MEM_DISK")) {
|
g_ventoy_memdisk_mode = 1 - g_ventoy_memdisk_mode;
|
||||||
grub_env_unset("VTOY_MEM_DISK");
|
g_ventoy_menu_refresh = 1;
|
||||||
}else {
|
|
||||||
grub_env_set("VTOY_MEM_DISK", grub_env_get("VTOY_MEM_DISK_STR"));
|
|
||||||
}
|
|
||||||
grub_env_set("VTOY_MENU_REFRESH", "1");
|
|
||||||
goto refresh;
|
goto refresh;
|
||||||
|
|
||||||
case GRUB_TERM_KEY_F3:
|
case (GRUB_TERM_CTRL | 'i'):
|
||||||
menu_fini ();
|
menu_fini ();
|
||||||
if (grub_env_get("VTOY_ISO_RAW")) {
|
g_ventoy_iso_raw = 1 - g_ventoy_iso_raw;
|
||||||
grub_env_unset("VTOY_ISO_RAW");
|
g_ventoy_menu_refresh = 1;
|
||||||
}else {
|
|
||||||
grub_env_set("VTOY_ISO_RAW", grub_env_get("VTOY_ISO_RAW_STR"));
|
|
||||||
}
|
|
||||||
grub_env_set("VTOY_MENU_REFRESH", "1");
|
|
||||||
goto refresh;
|
goto refresh;
|
||||||
|
|
||||||
case GRUB_TERM_KEY_F4:
|
case (GRUB_TERM_CTRL | 'u'):
|
||||||
menu_fini ();
|
menu_fini ();
|
||||||
if (grub_env_get("VTOY_ISO_UEFI_DRV")) {
|
g_ventoy_iso_uefi_drv = 1 - g_ventoy_iso_uefi_drv;
|
||||||
grub_env_unset("VTOY_ISO_UEFI_DRV");
|
g_ventoy_menu_refresh = 1;
|
||||||
}else {
|
|
||||||
grub_env_set("VTOY_ISO_UEFI_DRV", grub_env_get("VTOY_ISO_UEFI_DRV_STR"));
|
|
||||||
}
|
|
||||||
grub_env_set("VTOY_MENU_REFRESH", "1");
|
|
||||||
goto refresh;
|
goto refresh;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -897,6 +949,8 @@ show_menu (grub_menu_t menu, int nested, int autobooted)
|
|||||||
if (boot_entry < 0)
|
if (boot_entry < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
g_ventoy_last_entry = boot_entry;
|
||||||
|
|
||||||
e = grub_menu_get_entry (menu, boot_entry);
|
e = grub_menu_get_entry (menu, boot_entry);
|
||||||
if (! e)
|
if (! e)
|
||||||
continue; /* Menu is empty. */
|
continue; /* Menu is empty. */
|
||||||
|
@@ -52,11 +52,14 @@ int g_valid_initrd_count = 0;
|
|||||||
static grub_file_t g_old_file;
|
static grub_file_t g_old_file;
|
||||||
|
|
||||||
char g_img_swap_tmp_buf[1024];
|
char g_img_swap_tmp_buf[1024];
|
||||||
|
img_info g_img_swap_tmp;
|
||||||
img_info *g_ventoy_img_list = NULL;
|
img_info *g_ventoy_img_list = NULL;
|
||||||
int g_ventoy_img_count = 0;
|
int g_ventoy_img_count = 0;
|
||||||
|
|
||||||
|
grub_device_t g_enum_dev = NULL;
|
||||||
|
grub_fs_t g_enum_fs = NULL;
|
||||||
img_iterator_node g_img_iterator_head;
|
img_iterator_node g_img_iterator_head;
|
||||||
|
img_iterator_node *g_img_iterator_tail = NULL;
|
||||||
|
|
||||||
grub_uint8_t g_ventoy_break_level = 0;
|
grub_uint8_t g_ventoy_break_level = 0;
|
||||||
grub_uint8_t g_ventoy_debug_level = 0;
|
grub_uint8_t g_ventoy_debug_level = 0;
|
||||||
@@ -71,6 +74,13 @@ ventoy_guid g_ventoy_guid = VENTOY_GUID;
|
|||||||
|
|
||||||
ventoy_img_chunk_list g_img_chunk_list;
|
ventoy_img_chunk_list g_img_chunk_list;
|
||||||
|
|
||||||
|
static char *g_tree_script_buf = NULL;
|
||||||
|
static int g_tree_script_pos = 0;
|
||||||
|
|
||||||
|
static char *g_list_script_buf = NULL;
|
||||||
|
static int g_list_script_pos = 0;
|
||||||
|
|
||||||
|
|
||||||
void ventoy_debug(const char *fmt, ...)
|
void ventoy_debug(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
@@ -530,7 +540,7 @@ static grub_err_t ventoy_cmd_check_compatible(grub_extcmd_context_t ctxt, int ar
|
|||||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ventoy_cmp_img(img_info *img1, img_info *img2)
|
int ventoy_cmp_img(img_info *img1, img_info *img2)
|
||||||
{
|
{
|
||||||
char *s1, *s2;
|
char *s1, *s2;
|
||||||
int c1 = 0;
|
int c1 = 0;
|
||||||
@@ -560,15 +570,17 @@ static int ventoy_cmp_img(img_info *img1, img_info *img2)
|
|||||||
return (c1 - c2);
|
return (c1 - c2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ventoy_swap_img(img_info *img1, img_info *img2)
|
void ventoy_swap_img(img_info *img1, img_info *img2)
|
||||||
{
|
{
|
||||||
grub_memcpy(g_img_swap_tmp_buf, img1->name, sizeof(img1->name));
|
grub_memcpy(&g_img_swap_tmp, img1, sizeof(img_info));
|
||||||
grub_memcpy(img1->name, img2->name, sizeof(img1->name));
|
|
||||||
grub_memcpy(img2->name, g_img_swap_tmp_buf, sizeof(img1->name));
|
|
||||||
|
|
||||||
grub_memcpy(g_img_swap_tmp_buf, img1->path, sizeof(img1->path));
|
grub_memcpy(img1, img2, sizeof(img_info));
|
||||||
grub_memcpy(img1->path, img2->path, sizeof(img1->path));
|
img1->next = g_img_swap_tmp.next;
|
||||||
grub_memcpy(img2->path, g_img_swap_tmp_buf, sizeof(img1->path));
|
img1->prev = g_img_swap_tmp.prev;
|
||||||
|
|
||||||
|
g_img_swap_tmp.next = img2->next;
|
||||||
|
g_img_swap_tmp.prev = img2->prev;
|
||||||
|
grub_memcpy(img2, &g_img_swap_tmp, sizeof(img_info));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ventoy_img_name_valid(const char *filename, grub_size_t namelen)
|
static int ventoy_img_name_valid(const char *filename, grub_size_t namelen)
|
||||||
@@ -591,11 +603,27 @@ static int ventoy_img_name_valid(const char *filename, grub_size_t namelen)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int ventoy_check_ignore_flag(const char *filename, const struct grub_dirhook_info *info, void *data)
|
||||||
|
{
|
||||||
|
if (0 == info->dir)
|
||||||
|
{
|
||||||
|
if (filename && filename[0] == '.' && 0 == grub_strncmp(filename, ".ventoyignore", 13))
|
||||||
|
{
|
||||||
|
*((int *)data) = 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int ventoy_colect_img_files(const char *filename, const struct grub_dirhook_info *info, void *data)
|
static int ventoy_colect_img_files(const char *filename, const struct grub_dirhook_info *info, void *data)
|
||||||
{
|
{
|
||||||
|
int ignore = 0;
|
||||||
grub_size_t len;
|
grub_size_t len;
|
||||||
img_info *img;
|
img_info *img;
|
||||||
img_info *tail;
|
img_info *tail;
|
||||||
|
img_iterator_node *tmp;
|
||||||
img_iterator_node *new_node;
|
img_iterator_node *new_node;
|
||||||
img_iterator_node *node = (img_iterator_node *)data;
|
img_iterator_node *node = (img_iterator_node *)data;
|
||||||
|
|
||||||
@@ -609,14 +637,47 @@ static int ventoy_colect_img_files(const char *filename, const struct grub_dirho
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
new_node = grub_malloc(sizeof(img_iterator_node));
|
if (!ventoy_img_name_valid(filename, len))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filename[0] == '$' && 0 == grub_strncmp(filename, "$RECYCLE.BIN", 12))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
new_node = grub_zalloc(sizeof(img_iterator_node));
|
||||||
if (new_node)
|
if (new_node)
|
||||||
{
|
{
|
||||||
new_node->tail = node->tail;
|
new_node->dirlen = grub_snprintf(new_node->dir, sizeof(new_node->dir), "%s%s/", node->dir, filename);
|
||||||
grub_snprintf(new_node->dir, sizeof(new_node->dir), "%s%s/", node->dir, filename);
|
|
||||||
|
|
||||||
new_node->next = g_img_iterator_head.next;
|
g_enum_fs->fs_dir(g_enum_dev, new_node->dir, ventoy_check_ignore_flag, &ignore);
|
||||||
g_img_iterator_head.next = new_node;
|
if (ignore)
|
||||||
|
{
|
||||||
|
debug("Directory %s ignored...\n", new_node->dir);
|
||||||
|
grub_free(new_node);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
new_node->tail = node->tail;
|
||||||
|
|
||||||
|
new_node->parent = node;
|
||||||
|
if (!node->firstchild)
|
||||||
|
{
|
||||||
|
node->firstchild = new_node;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_img_iterator_tail)
|
||||||
|
{
|
||||||
|
g_img_iterator_tail->next = new_node;
|
||||||
|
g_img_iterator_tail = new_node;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_img_iterator_head.next = new_node;
|
||||||
|
g_img_iterator_tail = new_node;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -647,6 +708,22 @@ static int ventoy_colect_img_files(const char *filename, const struct grub_dirho
|
|||||||
g_ventoy_img_list = img;
|
g_ventoy_img_list = img;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
img->size = info->size;
|
||||||
|
img->id = g_ventoy_img_count;
|
||||||
|
img->parent = node;
|
||||||
|
if (node && NULL == node->firstiso)
|
||||||
|
{
|
||||||
|
node->firstiso = img;
|
||||||
|
}
|
||||||
|
|
||||||
|
node->isocnt++;
|
||||||
|
tmp = node->parent;
|
||||||
|
while (tmp)
|
||||||
|
{
|
||||||
|
tmp->isocnt++;
|
||||||
|
tmp = tmp->parent;
|
||||||
|
}
|
||||||
|
|
||||||
*((img_info **)(node->tail)) = img;
|
*((img_info **)(node->tail)) = img;
|
||||||
g_ventoy_img_count++;
|
g_ventoy_img_count++;
|
||||||
|
|
||||||
@@ -734,6 +811,96 @@ int ventoy_fill_data(grub_uint32_t buflen, char *buffer)
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static img_info * ventoy_get_min_iso(img_iterator_node *node)
|
||||||
|
{
|
||||||
|
img_info *minimg = NULL;
|
||||||
|
img_info *img = (img_info *)(node->firstiso);
|
||||||
|
|
||||||
|
while (img && (img_iterator_node *)(img->parent) == node)
|
||||||
|
{
|
||||||
|
if (img->select == 0 && (NULL == minimg || grub_strcmp(img->name, minimg->name) < 0))
|
||||||
|
{
|
||||||
|
minimg = img;
|
||||||
|
}
|
||||||
|
img = img->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (minimg)
|
||||||
|
{
|
||||||
|
minimg->select = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return minimg;
|
||||||
|
}
|
||||||
|
|
||||||
|
static img_iterator_node * ventoy_get_min_child(img_iterator_node *node)
|
||||||
|
{
|
||||||
|
img_iterator_node *Minchild = NULL;
|
||||||
|
img_iterator_node *child = node->firstchild;
|
||||||
|
|
||||||
|
while (child && child->parent == node)
|
||||||
|
{
|
||||||
|
if (child->select == 0 && (NULL == Minchild || grub_strcmp(child->dir, Minchild->dir) < 0))
|
||||||
|
{
|
||||||
|
Minchild = child;
|
||||||
|
}
|
||||||
|
child = child->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Minchild)
|
||||||
|
{
|
||||||
|
Minchild->select = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Minchild;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ventoy_dynamic_tree_menu(img_iterator_node *node)
|
||||||
|
{
|
||||||
|
int offset = 1;
|
||||||
|
img_info *img;
|
||||||
|
img_iterator_node *child = NULL;
|
||||||
|
|
||||||
|
if (node->isocnt == 0 || node->done == 1)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node->parent && node->parent->dirlen < node->dirlen)
|
||||||
|
{
|
||||||
|
offset = node->parent->dirlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node != &g_img_iterator_head)
|
||||||
|
{
|
||||||
|
node->dir[node->dirlen - 1] = 0;
|
||||||
|
g_tree_script_pos += grub_snprintf(g_tree_script_buf + g_tree_script_pos, VTOY_MAX_SCRIPT_BUF - g_tree_script_pos,
|
||||||
|
"submenu \"%-10s [%s]\" {\n", "DIR", node->dir + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
while ((child = ventoy_get_min_child(node)) != NULL)
|
||||||
|
{
|
||||||
|
ventoy_dynamic_tree_menu(child);
|
||||||
|
}
|
||||||
|
|
||||||
|
while ((img = ventoy_get_min_iso(node)) != NULL)
|
||||||
|
{
|
||||||
|
g_tree_script_pos += grub_snprintf(g_tree_script_buf + g_tree_script_pos, VTOY_MAX_SCRIPT_BUF - g_tree_script_pos,
|
||||||
|
"menuentry \"%-10s %s\" --id=\"VID_%d\" {\n"
|
||||||
|
" common_menuentry \n"
|
||||||
|
"}\n",
|
||||||
|
grub_get_human_size(img->size, GRUB_HUMAN_SIZE_SHORT), img->name, img->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node != &g_img_iterator_head)
|
||||||
|
{
|
||||||
|
g_tree_script_pos += grub_snprintf(g_tree_script_buf + g_tree_script_pos, VTOY_MAX_SCRIPT_BUF - g_tree_script_pos, "}\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
node->done = 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char **args)
|
static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
{
|
{
|
||||||
grub_fs_t fs;
|
grub_fs_t fs;
|
||||||
@@ -743,6 +910,7 @@ static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char
|
|||||||
char *device_name = NULL;
|
char *device_name = NULL;
|
||||||
char buf[32];
|
char buf[32];
|
||||||
img_iterator_node *node = NULL;
|
img_iterator_node *node = NULL;
|
||||||
|
img_iterator_node *tmp = NULL;
|
||||||
|
|
||||||
(void)ctxt;
|
(void)ctxt;
|
||||||
|
|
||||||
@@ -762,13 +930,13 @@ static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev = grub_device_open(device_name);
|
g_enum_dev = dev = grub_device_open(device_name);
|
||||||
if (!dev)
|
if (!dev)
|
||||||
{
|
{
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
fs = grub_fs_probe(dev);
|
g_enum_fs = fs = grub_fs_probe(dev);
|
||||||
if (!fs)
|
if (!fs)
|
||||||
{
|
{
|
||||||
goto fail;
|
goto fail;
|
||||||
@@ -776,18 +944,27 @@ static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char
|
|||||||
|
|
||||||
grub_memset(&g_img_iterator_head, 0, sizeof(g_img_iterator_head));
|
grub_memset(&g_img_iterator_head, 0, sizeof(g_img_iterator_head));
|
||||||
|
|
||||||
|
g_img_iterator_head.dirlen = 1;
|
||||||
g_img_iterator_head.tail = &tail;
|
g_img_iterator_head.tail = &tail;
|
||||||
grub_strcpy(g_img_iterator_head.dir, "/");
|
grub_strcpy(g_img_iterator_head.dir, "/");
|
||||||
|
|
||||||
fs->fs_dir(dev, "/", ventoy_colect_img_files, &g_img_iterator_head);
|
for (node = &g_img_iterator_head; node; node = node->next)
|
||||||
|
|
||||||
while (g_img_iterator_head.next)
|
|
||||||
{
|
{
|
||||||
node = g_img_iterator_head.next;
|
|
||||||
g_img_iterator_head.next = node->next;
|
|
||||||
|
|
||||||
fs->fs_dir(dev, node->dir, ventoy_colect_img_files, node);
|
fs->fs_dir(dev, node->dir, ventoy_colect_img_files, node);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (node = &g_img_iterator_head; node; node = node->next)
|
||||||
|
{
|
||||||
|
ventoy_dynamic_tree_menu(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free node */
|
||||||
|
node = g_img_iterator_head.next;
|
||||||
|
while (node)
|
||||||
|
{
|
||||||
|
tmp = node->next;
|
||||||
grub_free(node);
|
grub_free(node);
|
||||||
|
node = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sort image list by image name */
|
/* sort image list by image name */
|
||||||
@@ -802,6 +979,16 @@ static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (cur = g_ventoy_img_list; cur; cur = cur->next)
|
||||||
|
{
|
||||||
|
g_list_script_pos += grub_snprintf(g_list_script_buf + g_list_script_pos, VTOY_MAX_SCRIPT_BUF - g_list_script_pos,
|
||||||
|
"menuentry \"%s\" --id=\"VID_%d\" {\n"
|
||||||
|
" common_menuentry \n"
|
||||||
|
"}\n",
|
||||||
|
cur->name, cur->id);
|
||||||
|
}
|
||||||
|
g_list_script_buf[g_list_script_pos] = 0;
|
||||||
|
|
||||||
grub_snprintf(buf, sizeof(buf), "%d", g_ventoy_img_count);
|
grub_snprintf(buf, sizeof(buf), "%d", g_ventoy_img_count);
|
||||||
grub_env_set(args[1], buf);
|
grub_env_set(args[1], buf);
|
||||||
|
|
||||||
@@ -876,7 +1063,9 @@ static grub_err_t ventoy_cmd_img_name(grub_extcmd_context_t ctxt, int argc, char
|
|||||||
|
|
||||||
static grub_err_t ventoy_cmd_chosen_img_path(grub_extcmd_context_t ctxt, int argc, char **args)
|
static grub_err_t ventoy_cmd_chosen_img_path(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
{
|
{
|
||||||
const char *name = NULL;
|
int img_id = 0;
|
||||||
|
char *pos = NULL;
|
||||||
|
const char *id = NULL;
|
||||||
img_info *cur = g_ventoy_img_list;
|
img_info *cur = g_ventoy_img_list;
|
||||||
|
|
||||||
(void)ctxt;
|
(void)ctxt;
|
||||||
@@ -886,13 +1075,22 @@ static grub_err_t ventoy_cmd_chosen_img_path(grub_extcmd_context_t ctxt, int arg
|
|||||||
return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s {var}", cmd_raw_name);
|
return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s {var}", cmd_raw_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
name = grub_env_get("chosen");
|
id = grub_env_get("chosen");
|
||||||
|
|
||||||
|
pos = grub_strstr(id, "VID_");
|
||||||
|
if (pos)
|
||||||
|
{
|
||||||
|
img_id = (int)grub_strtoul(pos + 4, NULL, 10);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
img_id = (int)grub_strtoul(id, NULL, 10);
|
||||||
|
}
|
||||||
|
|
||||||
while (cur)
|
while (cur)
|
||||||
{
|
{
|
||||||
if (0 == grub_strcmp(name, cur->name))
|
if (img_id == cur->id)
|
||||||
{
|
{
|
||||||
grub_env_set(args[0], cur->path);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
@@ -903,6 +1101,8 @@ static grub_err_t ventoy_cmd_chosen_img_path(grub_extcmd_context_t ctxt, int arg
|
|||||||
return grub_error(GRUB_ERR_BAD_ARGUMENT, "No such image");
|
return grub_error(GRUB_ERR_BAD_ARGUMENT, "No such image");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
grub_env_set(args[0], cur->path);
|
||||||
|
|
||||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1138,6 +1338,146 @@ static grub_err_t ventoy_cmd_add_replace_file(grub_extcmd_context_t ctxt, int ar
|
|||||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static grub_err_t ventoy_cmd_dump_menu(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
|
{
|
||||||
|
(void)ctxt;
|
||||||
|
(void)argc;
|
||||||
|
(void)args;
|
||||||
|
|
||||||
|
if (argc == 0)
|
||||||
|
{
|
||||||
|
grub_printf("List Mode: CurLen:%d MaxLen:%u\n", g_list_script_pos, VTOY_MAX_SCRIPT_BUF);
|
||||||
|
grub_printf("%s", g_list_script_buf);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
grub_printf("Tree Mode: CurLen:%d MaxLen:%u\n", g_tree_script_pos, VTOY_MAX_SCRIPT_BUF);
|
||||||
|
grub_printf("%s", g_tree_script_buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t ventoy_cmd_check_mode(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
|
{
|
||||||
|
(void)ctxt;
|
||||||
|
(void)argc;
|
||||||
|
(void)args;
|
||||||
|
|
||||||
|
if (argc != 1)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0][0] == '0')
|
||||||
|
{
|
||||||
|
return g_ventoy_memdisk_mode ? 0 : 1;
|
||||||
|
}
|
||||||
|
else if (args[0][0] == '1')
|
||||||
|
{
|
||||||
|
return g_ventoy_iso_raw ? 0 : 1;
|
||||||
|
}
|
||||||
|
else if (args[0][0] == '2')
|
||||||
|
{
|
||||||
|
return g_ventoy_iso_uefi_drv ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t ventoy_cmd_dynamic_menu(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
|
{
|
||||||
|
char memfile[128] = {0};
|
||||||
|
|
||||||
|
(void)ctxt;
|
||||||
|
(void)argc;
|
||||||
|
(void)args;
|
||||||
|
|
||||||
|
if (argc == 0)
|
||||||
|
{
|
||||||
|
grub_script_execute_sourcecode(g_list_script_buf);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_ventoy_last_entry = -1;
|
||||||
|
grub_snprintf(memfile, sizeof(memfile), "configfile mem:0x%llx:size:%d",
|
||||||
|
(ulonglong)(ulong)g_tree_script_buf, g_tree_script_pos);
|
||||||
|
grub_script_execute_sourcecode(memfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t ventoy_cmd_find_bootable_hdd(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
|
{
|
||||||
|
int id = 0;
|
||||||
|
int find = 0;
|
||||||
|
grub_disk_t disk;
|
||||||
|
const char *isopath = NULL;
|
||||||
|
char hdname[32];
|
||||||
|
ventoy_mbr_head mbr;
|
||||||
|
|
||||||
|
(void)ctxt;
|
||||||
|
(void)argc;
|
||||||
|
|
||||||
|
if (argc != 1)
|
||||||
|
{
|
||||||
|
return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s variable\n", cmd_raw_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
isopath = grub_env_get("iso_path");
|
||||||
|
if (!isopath)
|
||||||
|
{
|
||||||
|
debug("isopath is null %p\n", isopath);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
debug("isopath is %s\n", isopath);
|
||||||
|
|
||||||
|
for (id = 0; id < 30 && (find == 0); id++)
|
||||||
|
{
|
||||||
|
grub_snprintf(hdname, sizeof(hdname), "hd%d,", id);
|
||||||
|
if (grub_strstr(isopath, hdname))
|
||||||
|
{
|
||||||
|
debug("skip %s ...\n", hdname);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_snprintf(hdname, sizeof(hdname), "hd%d", id);
|
||||||
|
|
||||||
|
disk = grub_disk_open(hdname);
|
||||||
|
if (!disk)
|
||||||
|
{
|
||||||
|
debug("%s not exist\n", hdname);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_memset(&mbr, 0, sizeof(mbr));
|
||||||
|
if (0 == grub_disk_read(disk, 0, 0, 512, &mbr))
|
||||||
|
{
|
||||||
|
if (mbr.Byte55 == 0x55 && mbr.ByteAA == 0xAA)
|
||||||
|
{
|
||||||
|
if (mbr.PartTbl[0].Active == 0x80 || mbr.PartTbl[1].Active == 0x80 ||
|
||||||
|
mbr.PartTbl[2].Active == 0x80 || mbr.PartTbl[3].Active == 0x80)
|
||||||
|
{
|
||||||
|
|
||||||
|
grub_env_set(args[0], hdname);
|
||||||
|
find = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
debug("%s is %s\n", hdname, find ? "bootable" : "NOT bootable");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
debug("read %s failed\n", hdname);
|
||||||
|
}
|
||||||
|
|
||||||
|
grub_disk_close(disk);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
grub_file_t ventoy_grub_file_open(enum grub_file_type type, const char *fmt, ...)
|
grub_file_t ventoy_grub_file_open(enum grub_file_type type, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@@ -1189,6 +1529,10 @@ static int ventoy_env_init(void)
|
|||||||
char buf[64];
|
char buf[64];
|
||||||
|
|
||||||
grub_env_set("vtdebug_flag", "");
|
grub_env_set("vtdebug_flag", "");
|
||||||
|
grub_env_export("vtdebug_flag");
|
||||||
|
|
||||||
|
g_tree_script_buf = grub_malloc(VTOY_MAX_SCRIPT_BUF);
|
||||||
|
g_list_script_buf = grub_malloc(VTOY_MAX_SCRIPT_BUF);
|
||||||
|
|
||||||
ventoy_filt_register(0, ventoy_wrapper_open);
|
ventoy_filt_register(0, ventoy_wrapper_open);
|
||||||
|
|
||||||
@@ -1219,6 +1563,10 @@ static cmd_para ventoy_cmds[] =
|
|||||||
{ "vt_img_sector", ventoy_cmd_img_sector, 0, NULL, "{imageName}", "", NULL },
|
{ "vt_img_sector", ventoy_cmd_img_sector, 0, NULL, "{imageName}", "", NULL },
|
||||||
{ "vt_dump_img_sector", ventoy_cmd_dump_img_sector, 0, NULL, "", "", NULL },
|
{ "vt_dump_img_sector", ventoy_cmd_dump_img_sector, 0, NULL, "", "", NULL },
|
||||||
{ "vt_load_cpio", ventoy_cmd_load_cpio, 0, NULL, "", "", NULL },
|
{ "vt_load_cpio", ventoy_cmd_load_cpio, 0, NULL, "", "", NULL },
|
||||||
|
{ "vt_find_first_bootable_hd", ventoy_cmd_find_bootable_hdd, 0, NULL, "", "", NULL },
|
||||||
|
{ "vt_dump_menu", ventoy_cmd_dump_menu, 0, NULL, "", "", NULL },
|
||||||
|
{ "vt_dynamic_menu", ventoy_cmd_dynamic_menu, 0, NULL, "", "", NULL },
|
||||||
|
{ "vt_check_mode", ventoy_cmd_check_mode, 0, NULL, "", "", NULL },
|
||||||
|
|
||||||
{ "vt_is_udf", ventoy_cmd_is_udf, 0, NULL, "", "", NULL },
|
{ "vt_is_udf", ventoy_cmd_is_udf, 0, NULL, "", "", NULL },
|
||||||
{ "vt_file_size", ventoy_cmd_file_size, 0, NULL, "", "", NULL },
|
{ "vt_file_size", ventoy_cmd_file_size, 0, NULL, "", "", NULL },
|
||||||
|
@@ -21,10 +21,13 @@
|
|||||||
#ifndef __VENTOY_DEF_H__
|
#ifndef __VENTOY_DEF_H__
|
||||||
#define __VENTOY_DEF_H__
|
#define __VENTOY_DEF_H__
|
||||||
|
|
||||||
|
#define VTOY_MAX_SCRIPT_BUF (4 * 1024 * 1024)
|
||||||
|
|
||||||
#define JSON_SUCCESS 0
|
#define JSON_SUCCESS 0
|
||||||
#define JSON_FAILED 1
|
#define JSON_FAILED 1
|
||||||
#define JSON_NOT_FOUND 2
|
#define JSON_NOT_FOUND 2
|
||||||
|
|
||||||
|
#define ulong unsigned long
|
||||||
#define ulonglong unsigned long long
|
#define ulonglong unsigned long long
|
||||||
|
|
||||||
#define vtoy_to_upper(c) (((char)(c) >= 'a' && (char)(c) <= 'z') ? ((char)(c) - 'a' + 'A') : (char)(c))
|
#define vtoy_to_upper(c) (((char)(c) >= 'a' && (char)(c) <= 'z') ? ((char)(c) - 'a' + 'A') : (char)(c))
|
||||||
@@ -115,11 +118,15 @@ typedef struct ventoy_udf_override
|
|||||||
|
|
||||||
#pragma pack()
|
#pragma pack()
|
||||||
|
|
||||||
|
|
||||||
typedef struct img_info
|
typedef struct img_info
|
||||||
{
|
{
|
||||||
char path[512];
|
char path[512];
|
||||||
char name[256];
|
char name[256];
|
||||||
|
int id;
|
||||||
|
grub_uint64_t size;
|
||||||
|
int select;
|
||||||
|
|
||||||
|
void *parent;
|
||||||
|
|
||||||
struct img_info *next;
|
struct img_info *next;
|
||||||
struct img_info *prev;
|
struct img_info *prev;
|
||||||
@@ -130,8 +137,19 @@ typedef struct img_iterator_node
|
|||||||
struct img_iterator_node *next;
|
struct img_iterator_node *next;
|
||||||
img_info **tail;
|
img_info **tail;
|
||||||
char dir[400];
|
char dir[400];
|
||||||
|
int dirlen;
|
||||||
|
int isocnt;
|
||||||
|
int done;
|
||||||
|
int select;
|
||||||
|
|
||||||
|
struct img_iterator_node *parent;
|
||||||
|
struct img_iterator_node *firstchild;
|
||||||
|
|
||||||
|
void *firstiso;
|
||||||
}img_iterator_node;
|
}img_iterator_node;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct initrd_info
|
typedef struct initrd_info
|
||||||
{
|
{
|
||||||
char name[256];
|
char name[256];
|
||||||
@@ -504,5 +522,41 @@ static inline int ventoy_is_word_end(int c)
|
|||||||
return (c == 0 || c == ',' || ventoy_isspace(c));
|
return (c == 0 || c == ',' || ventoy_isspace(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma pack(1)
|
||||||
|
typedef struct ventoy_part_table
|
||||||
|
{
|
||||||
|
grub_uint8_t Active; // 0x00 0x80
|
||||||
|
|
||||||
|
grub_uint8_t StartHead;
|
||||||
|
grub_uint16_t StartSector : 6;
|
||||||
|
grub_uint16_t StartCylinder : 10;
|
||||||
|
|
||||||
|
grub_uint8_t FsFlag;
|
||||||
|
|
||||||
|
grub_uint8_t EndHead;
|
||||||
|
grub_uint16_t EndSector : 6;
|
||||||
|
grub_uint16_t EndCylinder : 10;
|
||||||
|
|
||||||
|
grub_uint32_t StartSectorId;
|
||||||
|
grub_uint32_t SectorCount;
|
||||||
|
}ventoy_part_table;
|
||||||
|
|
||||||
|
typedef struct ventoy_mbr_head
|
||||||
|
{
|
||||||
|
grub_uint8_t BootCode[446];
|
||||||
|
ventoy_part_table PartTbl[4];
|
||||||
|
grub_uint8_t Byte55;
|
||||||
|
grub_uint8_t ByteAA;
|
||||||
|
}ventoy_mbr_head;
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
extern int g_ventoy_last_entry;
|
||||||
|
extern int g_ventoy_memdisk_mode;
|
||||||
|
extern int g_ventoy_iso_raw;
|
||||||
|
extern int g_ventoy_iso_uefi_drv;
|
||||||
|
|
||||||
|
int ventoy_cmp_img(img_info *img1, img_info *img2);
|
||||||
|
void ventoy_swap_img(img_info *img1, img_info *img2);
|
||||||
|
|
||||||
#endif /* __VENTOY_DEF_H__ */
|
#endif /* __VENTOY_DEF_H__ */
|
||||||
|
|
||||||
|
38
IMG/cpio/ventoy/hook/berry/ventoy-disk.sh
Normal file
38
IMG/cpio/ventoy/hook/berry/ventoy-disk.sh
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#!/ventoy/busybox/sh
|
||||||
|
#************************************************************************************
|
||||||
|
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License as
|
||||||
|
# published by the Free Software Foundation; either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful, but
|
||||||
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#************************************************************************************
|
||||||
|
|
||||||
|
. /ventoy/hook/ventoy-hook-lib.sh
|
||||||
|
|
||||||
|
vtlog "####### $0 $* ########"
|
||||||
|
|
||||||
|
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||||
|
|
||||||
|
wait_for_usb_disk_ready
|
||||||
|
|
||||||
|
vtdiskname=$(get_ventoy_disk_name)
|
||||||
|
if [ "$vtdiskname" = "unknown" ]; then
|
||||||
|
vtlog "ventoy disk not found"
|
||||||
|
PATH=$VTPATH_OLD
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"
|
||||||
|
|
||||||
|
PATH=$VTPATH_OLD
|
||||||
|
|
20
IMG/cpio/ventoy/hook/berry/ventoy-hook.sh
Normal file
20
IMG/cpio/ventoy/hook/berry/ventoy-hook.sh
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/ventoy/busybox/sh
|
||||||
|
#************************************************************************************
|
||||||
|
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License as
|
||||||
|
# published by the Free Software Foundation; either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful, but
|
||||||
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#************************************************************************************
|
||||||
|
|
||||||
|
$SED "/for .*\$DEVICES/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/berry/ventoy-disk.sh" -i /init
|
@@ -22,10 +22,15 @@
|
|||||||
#ventoy_systemd_udevd_work_around
|
#ventoy_systemd_udevd_work_around
|
||||||
#ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k noreplace"
|
#ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k noreplace"
|
||||||
|
|
||||||
$SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE inst.stage2=hd:/dev/dm-0#" -i /lib/dracut-lib.sh
|
if $GREP -q 'root=live' /proc/cmdline; then
|
||||||
|
$SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE root=live:/dev/dm-0#" -i /lib/dracut-lib.sh
|
||||||
|
else
|
||||||
|
$SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE inst.stage2=hd:/dev/dm-0#" -i /lib/dracut-lib.sh
|
||||||
|
fi
|
||||||
|
|
||||||
ventoy_set_inotify_script rhel7/ventoy-inotifyd-hook.sh
|
ventoy_set_inotify_script rhel7/ventoy-inotifyd-hook.sh
|
||||||
|
|
||||||
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/default/ventoy-inotifyd-start.sh /lib/dracut/hooks/pre-udev/01-ventoy-inotifyd-start.sh
|
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/rhel7/ventoy-inotifyd-start.sh /lib/dracut/hooks/pre-udev/01-ventoy-inotifyd-start.sh
|
||||||
|
|
||||||
# suppress write protected mount warning
|
# suppress write protected mount warning
|
||||||
if [ -e /usr/sbin/anaconda-diskroot ]; then
|
if [ -e /usr/sbin/anaconda-diskroot ]; then
|
||||||
|
31
IMG/cpio/ventoy/hook/rhel7/ventoy-inotifyd-start.sh
Normal file
31
IMG/cpio/ventoy/hook/rhel7/ventoy-inotifyd-start.sh
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#!/ventoy/busybox/sh
|
||||||
|
#************************************************************************************
|
||||||
|
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License as
|
||||||
|
# published by the Free Software Foundation; either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful, but
|
||||||
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#************************************************************************************
|
||||||
|
|
||||||
|
. /ventoy/hook/ventoy-hook-lib.sh
|
||||||
|
|
||||||
|
vtHook=$($CAT $VTOY_PATH/inotifyd-hook-script.txt)
|
||||||
|
|
||||||
|
vtdisk=$(get_ventoy_disk_name)
|
||||||
|
if [ "$vtdisk" = "unknown" ]; then
|
||||||
|
vtlog "... start inotifyd listen $vtHook ..."
|
||||||
|
$BUSYBOX_PATH/nohup $VTOY_PATH/tool/inotifyd $vtHook /dev:n 2>&- &
|
||||||
|
else
|
||||||
|
vtlog "... $vtdisk already exist ..."
|
||||||
|
$BUSYBOX_PATH/sh $vtHook n /dev "${vtdisk#/dev/}2"
|
||||||
|
fi
|
@@ -165,6 +165,12 @@ ventoy_get_os_type() {
|
|||||||
echo 'arch'; return
|
echo 'arch'; return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if $GREP -q 'berry ' /proc/version; then
|
||||||
|
echo 'berry'; return
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo "default"
|
echo "default"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
5
INSTALL/DO_NOT_RUN_Ventoy2Disk_HERE.txt
Normal file
5
INSTALL/DO_NOT_RUN_Ventoy2Disk_HERE.txt
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
For Ventoy2Disk.exe (Windows) or Ventoy2Disk.sh (Linux).
|
||||||
|
|
||||||
|
You should download the install package, decompress it, and run the exe/sh there.
|
||||||
|
They should NOT be run in the source tree(INSTALL directory).
|
||||||
|
|
Binary file not shown.
Binary file not shown.
@@ -26,20 +26,29 @@ echo ''
|
|||||||
|
|
||||||
vtdebug "############# Ventoy2Disk $0 ################"
|
vtdebug "############# Ventoy2Disk $0 ################"
|
||||||
|
|
||||||
if [ "$1" = "-i" ]; then
|
while [ -n "$1" ]; do
|
||||||
MODE="install"
|
if [ "$1" = "-i" ]; then
|
||||||
elif [ "$1" = "-I" ]; then
|
MODE="install"
|
||||||
MODE="install"
|
elif [ "$1" = "-I" ]; then
|
||||||
FORCE="Y"
|
MODE="install"
|
||||||
elif [ "$1" = "-u" ]; then
|
FORCE="Y"
|
||||||
MODE="update"
|
elif [ "$1" = "-u" ]; then
|
||||||
else
|
MODE="update"
|
||||||
print_usage
|
elif [ "$1" = "-s" ]; then
|
||||||
cd $OLDDIR
|
SECUREBOOT="YES"
|
||||||
exit 1
|
else
|
||||||
fi
|
if ! [ -b "$1" ]; then
|
||||||
|
print_usage
|
||||||
|
cd $OLDDIR
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
DISK=$1
|
||||||
|
fi
|
||||||
|
|
||||||
if ! [ -b "$2" ]; then
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$MODE" ]; then
|
||||||
print_usage
|
print_usage
|
||||||
cd $OLDDIR
|
cd $OLDDIR
|
||||||
exit 1
|
exit 1
|
||||||
@@ -56,6 +65,15 @@ fi
|
|||||||
|
|
||||||
vtdebug "MODE=$MODE FORCE=$FORCE"
|
vtdebug "MODE=$MODE FORCE=$FORCE"
|
||||||
|
|
||||||
|
if ! [ -f ./boot/boot.img ]; then
|
||||||
|
if [ -d ./grub ]; then
|
||||||
|
vterr "Don't run me here, please download the released install package, and run there."
|
||||||
|
else
|
||||||
|
vterr "Please run under the right directory!"
|
||||||
|
fi
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
#decompress tool
|
#decompress tool
|
||||||
cd tool
|
cd tool
|
||||||
chmod +x ./xzcat
|
chmod +x ./xzcat
|
||||||
@@ -76,8 +94,6 @@ if ! check_tool_work_ok; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
DISK=$2
|
|
||||||
|
|
||||||
if ! [ -b "$DISK" ]; then
|
if ! [ -b "$DISK" ]; then
|
||||||
vterr "Disk $DISK does not exist"
|
vterr "Disk $DISK does not exist"
|
||||||
cd $OLDDIR
|
cd $OLDDIR
|
||||||
@@ -92,7 +108,7 @@ if [ -e /sys/class/block/${DISK#/dev/}/start ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
grep "^$DISK" /proc/mounts | while read mtline; do
|
grep "^$DISK" /proc/mounts | while read mtline; do
|
||||||
mtpnt=$(echo $mtline | awk '{print $2}')
|
mtpnt=$(echo $mtline | awk '{print $DISK}')
|
||||||
vtdebug "Trying to umount $mtpnt ..."
|
vtdebug "Trying to umount $mtpnt ..."
|
||||||
umount $mtpnt >/dev/null 2>&1
|
umount $mtpnt >/dev/null 2>&1
|
||||||
done
|
done
|
||||||
@@ -195,6 +211,7 @@ if [ "$MODE" = "install" ]; then
|
|||||||
|
|
||||||
chmod +x ./tool/vtoy_gen_uuid
|
chmod +x ./tool/vtoy_gen_uuid
|
||||||
|
|
||||||
|
vtinfo "writing data to disk ..."
|
||||||
dd status=none conv=fsync if=./boot/boot.img of=$DISK bs=1 count=446
|
dd status=none conv=fsync if=./boot/boot.img of=$DISK bs=1 count=446
|
||||||
./tool/xzcat ./boot/core.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=2047 seek=1
|
./tool/xzcat ./boot/core.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=2047 seek=1
|
||||||
./tool/xzcat ./ventoy/ventoy.disk.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=$VENTOY_SECTOR_NUM seek=$part2_start_sector
|
./tool/xzcat ./ventoy/ventoy.disk.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=$VENTOY_SECTOR_NUM seek=$part2_start_sector
|
||||||
@@ -205,8 +222,32 @@ if [ "$MODE" = "install" ]; then
|
|||||||
#disk signature
|
#disk signature
|
||||||
./tool/vtoy_gen_uuid | dd status=none conv=fsync of=${DISK} skip=12 seek=440 bs=1 count=4
|
./tool/vtoy_gen_uuid | dd status=none conv=fsync of=${DISK} skip=12 seek=440 bs=1 count=4
|
||||||
|
|
||||||
|
vtinfo "sync data ..."
|
||||||
sync
|
sync
|
||||||
|
|
||||||
|
vtinfo "esp partition processing ..."
|
||||||
|
|
||||||
|
if [ "$SECUREBOOT" != "YES" ]; then
|
||||||
|
mkdir ./tmp_mnt
|
||||||
|
|
||||||
|
vtdebug "mounting part2 ...."
|
||||||
|
for tt in 1 2 3; do
|
||||||
|
if mount ${DISK}2 ./tmp_mnt; then
|
||||||
|
vtdebug "mounting part2 success"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
|
||||||
|
rm -f ./tmp_mnt/EFI/BOOT/BOOTX64.EFI
|
||||||
|
rm -f ./tmp_mnt/EFI/BOOT/grubx64.efi
|
||||||
|
rm -f ./tmp_mnt/EFI/BOOT/MokManager.efi
|
||||||
|
mv ./tmp_mnt/EFI/BOOT/grubx64_real.efi ./tmp_mnt/EFI/BOOT/BOOTX64.EFI
|
||||||
|
|
||||||
|
umount ./tmp_mnt
|
||||||
|
rm -rf ./tmp_mnt
|
||||||
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
vtinfo "Install Ventoy to $DISK successfully finished."
|
vtinfo "Install Ventoy to $DISK successfully finished."
|
||||||
echo ""
|
echo ""
|
||||||
@@ -249,6 +290,27 @@ else
|
|||||||
|
|
||||||
sync
|
sync
|
||||||
|
|
||||||
|
if [ "$SECUREBOOT" != "YES" ]; then
|
||||||
|
mkdir ./tmp_mnt
|
||||||
|
|
||||||
|
vtdebug "mounting part2 ...."
|
||||||
|
for tt in 1 2 3; do
|
||||||
|
if mount ${DISK}2 ./tmp_mnt; then
|
||||||
|
vtdebug "mounting part2 success"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
|
||||||
|
rm -f ./tmp_mnt/EFI/BOOT/BOOTX64.EFI
|
||||||
|
rm -f ./tmp_mnt/EFI/BOOT/grubx64.efi
|
||||||
|
rm -f ./tmp_mnt/EFI/BOOT/MokManager.efi
|
||||||
|
mv ./tmp_mnt/EFI/BOOT/grubx64_real.efi ./tmp_mnt/EFI/BOOT/BOOTX64.EFI
|
||||||
|
|
||||||
|
umount ./tmp_mnt
|
||||||
|
rm -rf ./tmp_mnt
|
||||||
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
vtinfo "Update Ventoy to $DISK successfully finished."
|
vtinfo "Update Ventoy to $DISK successfully finished."
|
||||||
echo ""
|
echo ""
|
||||||
|
@@ -16,33 +16,26 @@
|
|||||||
#
|
#
|
||||||
#************************************************************************************
|
#************************************************************************************
|
||||||
|
|
||||||
function ventoy_boot_from_hdd {
|
function ventoy_power {
|
||||||
if [ "$grub_platform" = "pc" ]; then
|
echo '<1> Reboot'
|
||||||
if [ "$iso_path" = "(hd0,1)" ]; then
|
echo '<2> Halt'
|
||||||
if [ -b (hd1) ]; then
|
echo '<0> Return to menu'
|
||||||
set root=(hd1)
|
echo -e '\nPlease enter your choice:'
|
||||||
drivemap -s hd0 hd1
|
|
||||||
chainloader +1
|
unset vtOpt
|
||||||
boot
|
read vtOpt
|
||||||
else
|
|
||||||
echo "No local hdd found ..."
|
if [ "$vtOpt" = "1" ]; then
|
||||||
sleep 3
|
echo -e '\n\nSystem is rebooting ... \n'
|
||||||
fi
|
sleep 1
|
||||||
else
|
reboot
|
||||||
set root=(hd0)
|
elif [ "$vtOpt" = "2" ]; then
|
||||||
chainloader +1
|
echo -e '\n\nSystem is halting ... \n'
|
||||||
boot
|
sleep 1
|
||||||
fi
|
halt
|
||||||
else
|
|
||||||
exit
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function ventoy_reboot {
|
|
||||||
reboot
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function get_os_type {
|
function get_os_type {
|
||||||
set vtoy_os=Linux
|
set vtoy_os=Linux
|
||||||
for file in "efi/microsoft" "sources/boot.wim" "boot/bcd" "bootmgr.efi" "boot/etfsboot.com"; do
|
for file in "efi/microsoft" "sources/boot.wim" "boot/bcd" "bootmgr.efi" "boot/etfsboot.com"; do
|
||||||
@@ -115,6 +108,9 @@ function distro_specify_initrd_file {
|
|||||||
function distro_specify_initrd_file_phase2 {
|
function distro_specify_initrd_file_phase2 {
|
||||||
if [ -f (loop)/boot/initrd.img ]; then
|
if [ -f (loop)/boot/initrd.img ]; then
|
||||||
vt_linux_specify_initrd_file /boot/initrd.img
|
vt_linux_specify_initrd_file /boot/initrd.img
|
||||||
|
elif [ -f (loop)/Setup/initrd.gz ]; then
|
||||||
|
vt_linux_specify_initrd_file /Setup/initrd.gz
|
||||||
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,7 +207,7 @@ function uefi_iso_menu_func {
|
|||||||
if [ -n "$vtisouefi" ]; then
|
if [ -n "$vtisouefi" ]; then
|
||||||
set LoadIsoEfiDriver=on
|
set LoadIsoEfiDriver=on
|
||||||
unset vtisouefi
|
unset vtisouefi
|
||||||
elif [ -n "$VTOY_ISO_UEFI_DRV" ]; then
|
elif vt_check_mode 2; then
|
||||||
set LoadIsoEfiDriver=on
|
set LoadIsoEfiDriver=on
|
||||||
else
|
else
|
||||||
unset LoadIsoEfiDriver
|
unset LoadIsoEfiDriver
|
||||||
@@ -239,7 +235,7 @@ function uefi_iso_menu_func {
|
|||||||
if [ -n "$vtcompat" ]; then
|
if [ -n "$vtcompat" ]; then
|
||||||
set ventoy_compatible=YES
|
set ventoy_compatible=YES
|
||||||
unset vtcompat
|
unset vtcompat
|
||||||
elif [ -n "$VTOY_ISO_RAW" ]; then
|
elif vt_check_mode 1; then
|
||||||
set ventoy_compatible=YES
|
set ventoy_compatible=YES
|
||||||
else
|
else
|
||||||
vt_check_compatible (loop)
|
vt_check_compatible (loop)
|
||||||
@@ -274,8 +270,6 @@ function uefi_iso_memdisk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function legacy_windows_menu_func {
|
function legacy_windows_menu_func {
|
||||||
vt_windows_reset
|
vt_windows_reset
|
||||||
|
|
||||||
@@ -383,7 +377,7 @@ function legacy_iso_menu_func {
|
|||||||
if [ -n "$vtcompat" ]; then
|
if [ -n "$vtcompat" ]; then
|
||||||
set ventoy_compatible=YES
|
set ventoy_compatible=YES
|
||||||
unset vtcompat
|
unset vtcompat
|
||||||
elif [ -n "$VTOY_ISO_RAW" ]; then
|
elif vt_check_mode 1; then
|
||||||
set ventoy_compatible=YES
|
set ventoy_compatible=YES
|
||||||
else
|
else
|
||||||
vt_check_compatible (loop)
|
vt_check_compatible (loop)
|
||||||
@@ -413,6 +407,22 @@ function legacy_iso_memdisk {
|
|||||||
boot
|
boot
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function common_menuentry {
|
||||||
|
if [ "$grub_platform" = "pc" ]; then
|
||||||
|
if vt_check_mode 0; then
|
||||||
|
legacy_iso_memdisk $iso_path
|
||||||
|
else
|
||||||
|
legacy_iso_menu_func $iso_path
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if vt_check_mode 0; then
|
||||||
|
uefi_iso_memdisk $iso_path
|
||||||
|
else
|
||||||
|
uefi_iso_menu_func $iso_path
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#############################################################
|
#############################################################
|
||||||
#############################################################
|
#############################################################
|
||||||
@@ -422,7 +432,7 @@ function legacy_iso_memdisk {
|
|||||||
#############################################################
|
#############################################################
|
||||||
#############################################################
|
#############################################################
|
||||||
|
|
||||||
set VENTOY_VERSION="1.0.08b2"
|
set VENTOY_VERSION="1.0.08"
|
||||||
|
|
||||||
#disable timeout
|
#disable timeout
|
||||||
unset timeout
|
unset timeout
|
||||||
@@ -431,8 +441,15 @@ set VTOY_MEM_DISK_STR="MEMDISK"
|
|||||||
set VTOY_ISO_RAW_STR="ISO RAW"
|
set VTOY_ISO_RAW_STR="ISO RAW"
|
||||||
set VTOY_ISO_UEFI_DRV_STR="UEFI FS"
|
set VTOY_ISO_UEFI_DRV_STR="UEFI FS"
|
||||||
|
|
||||||
set VTOY_F2_CMD="ventoy_boot_from_hdd"
|
set VTOY_F2_CMD="ventoy_power"
|
||||||
set VTOY_F3_CMD="ventoy_reboot"
|
set VTOY_F3_CMD="vt_dynamic_menu tree"
|
||||||
|
|
||||||
|
set VTOY_HOTKEY_TIP="F1:Memdisk F2:Power F3:TreeView"
|
||||||
|
if [ "$grub_platform" = "pc" ]; then
|
||||||
|
set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION BIOS www.ventoy.net"
|
||||||
|
else
|
||||||
|
set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION UEFI www.ventoy.net"
|
||||||
|
fi
|
||||||
|
|
||||||
vt_device $root vtoy_dev
|
vt_device $root vtoy_dev
|
||||||
|
|
||||||
@@ -473,33 +490,12 @@ terminal_output gfxterm
|
|||||||
set ventoy_img_count=0
|
set ventoy_img_count=0
|
||||||
vt_list_img $iso_path ventoy_img_count
|
vt_list_img $iso_path ventoy_img_count
|
||||||
|
|
||||||
#Dynamic menu for every iso file
|
#Main menu
|
||||||
if vt_cmp $ventoy_img_count ne 0; then
|
if [ $ventoy_img_count -gt 0 ]; then
|
||||||
set imgid=0
|
vt_dynamic_menu
|
||||||
while vt_cmp $imgid lt $ventoy_img_count; do
|
|
||||||
vt_img_name $imgid img_name
|
|
||||||
menuentry "$img_name" {
|
|
||||||
if [ "$grub_platform" = "pc" ]; then
|
|
||||||
if [ -n "$VTOY_MEM_DISK" ]; then
|
|
||||||
legacy_iso_memdisk $iso_path
|
|
||||||
else
|
|
||||||
legacy_iso_menu_func $iso_path
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if [ -n "$VTOY_MEM_DISK" ]; then
|
|
||||||
uefi_iso_memdisk $iso_path
|
|
||||||
else
|
|
||||||
uefi_iso_menu_func $iso_path
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
vt_incr imgid 1
|
|
||||||
done
|
|
||||||
else
|
else
|
||||||
menuentry "No ISO files found (Press enter to reboot ...)" {
|
menuentry "No ISO files found (Press enter to reboot ...)" {
|
||||||
echo -e "\n Rebooting ... "
|
echo -e "\n Rebooting ... "
|
||||||
reboot
|
reboot
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Binary file not shown.
@@ -19,7 +19,7 @@ terminal-box: "terminal_box_*.png"
|
|||||||
item_font = "ascii"
|
item_font = "ascii"
|
||||||
item_color = "#ffffff"
|
item_color = "#ffffff"
|
||||||
item_height = 30
|
item_height = 30
|
||||||
item_icon_space = 1
|
|
||||||
item_spacing = 1
|
item_spacing = 1
|
||||||
item_padding = 1
|
item_padding = 1
|
||||||
|
|
||||||
@@ -27,8 +27,7 @@ terminal-box: "terminal_box_*.png"
|
|||||||
selected_item_color= "#f2f2f2"
|
selected_item_color= "#f2f2f2"
|
||||||
selected_item_pixmap_style = "select_*.png"
|
selected_item_pixmap_style = "select_*.png"
|
||||||
|
|
||||||
#icon_height = 30
|
item_icon_space = 0
|
||||||
#icon_width = 30
|
|
||||||
|
|
||||||
scrollbar = true
|
scrollbar = true
|
||||||
scrollbar_width = 10
|
scrollbar_width = 10
|
||||||
@@ -50,11 +49,11 @@ terminal-box: "terminal_box_*.png"
|
|||||||
}
|
}
|
||||||
|
|
||||||
+ hbox{
|
+ hbox{
|
||||||
left = 40%
|
left = 30%
|
||||||
top = 95%
|
top = 95%
|
||||||
width = 10%
|
width = 10%
|
||||||
height = 25
|
height = 25
|
||||||
+ label {text = "F1:Memdisk" color = "blue" align = "left"}
|
+ label {text = "@VTOY_HOTKEY_TIP@" color = "blue" align = "left"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Binary file not shown.
Binary file not shown.
@@ -5,7 +5,7 @@ You can copy many iso files at a time and ventoy will give you a boot menu to se
|
|||||||
Both Legacy BIOS and UEFI are supported in the same way. 200+ ISO files are tested.
|
Both Legacy BIOS and UEFI are supported in the same way. 200+ ISO files are tested.
|
||||||
A "Ventoy Compatible" concept is introduced by ventoy, which can help to support any ISO file.
|
A "Ventoy Compatible" concept is introduced by ventoy, which can help to support any ISO file.
|
||||||
|
|
||||||
See http://www.ventoy.net for detail.
|
See https://www.ventoy.net for detail.
|
||||||
|
|
||||||
# Features
|
# Features
|
||||||
* 100% open source
|
* 100% open source
|
||||||
@@ -25,4 +25,4 @@ See http://www.ventoy.net for detail.
|
|||||||
* Data nondestructive during version upgrade
|
* Data nondestructive during version upgrade
|
||||||
* No need to update Ventoy when a new distro is released
|
* No need to update Ventoy when a new distro is released
|
||||||
|
|
||||||

|

|
||||||
|
@@ -52,8 +52,8 @@ const TCHAR * g_Str_ChineseSimple[STR_ID_MAX] =
|
|||||||
TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"),
|
TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"),
|
||||||
TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD>Ŀ¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!"),
|
TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD>Ŀ¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!"),
|
||||||
TEXT("<EFBFBD>豸"),
|
TEXT("<EFBFBD>豸"),
|
||||||
TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ventoy"),
|
TEXT("<EFBFBD><EFBFBD>װ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ventoy <20>汾"),
|
||||||
TEXT("<EFBFBD>豸<EFBFBD><EFBFBD> Ventoy"),
|
TEXT("<EFBFBD>豸<EFBFBD>ڲ<EFBFBD> Ventoy <20>汾"),
|
||||||
TEXT("״̬ - <><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"),
|
TEXT("״̬ - <><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"),
|
||||||
TEXT("<EFBFBD><EFBFBD>װ"),
|
TEXT("<EFBFBD><EFBFBD>װ"),
|
||||||
TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"),
|
TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"),
|
||||||
@@ -70,5 +70,5 @@ const TCHAR * g_Str_ChineseSimple[STR_ID_MAX] =
|
|||||||
|
|
||||||
const TCHAR * GetString(enum STR_ID ID)
|
const TCHAR * GetString(enum STR_ID ID)
|
||||||
{
|
{
|
||||||
return g_Str_English[ID];
|
return g_cur_lang_data->MsgString[ID];
|
||||||
};
|
};
|
||||||
|
@@ -21,35 +21,64 @@
|
|||||||
#ifndef __LANGUAGE_H__
|
#ifndef __LANGUAGE_H__
|
||||||
#define __LANGUAGE_H__
|
#define __LANGUAGE_H__
|
||||||
|
|
||||||
|
|
||||||
typedef enum STR_ID
|
typedef enum STR_ID
|
||||||
{
|
{
|
||||||
STR_ERROR = 0,
|
STR_ERROR = 0,
|
||||||
STR_WARNING,
|
STR_WARNING, // 1
|
||||||
STR_INFO,
|
STR_INFO, // 2
|
||||||
STR_INCORRECT_DIR,
|
STR_INCORRECT_DIR, //3
|
||||||
|
STR_INCORRECT_TREE_DIR, //4
|
||||||
|
|
||||||
STR_DEVICE,
|
STR_DEVICE, //5
|
||||||
STR_LOCAL_VER,
|
STR_LOCAL_VER, //6
|
||||||
STR_DISK_VER,
|
STR_DISK_VER, //7
|
||||||
STR_STATUS,
|
STR_STATUS, //8
|
||||||
STR_INSTALL,
|
STR_INSTALL, //9
|
||||||
STR_UPDATE,
|
STR_UPDATE, //10
|
||||||
|
|
||||||
STR_UPDATE_TIP,
|
STR_UPDATE_TIP, //11
|
||||||
STR_INSTALL_TIP,
|
STR_INSTALL_TIP, //12
|
||||||
STR_INSTALL_TIP2,
|
STR_INSTALL_TIP2,//13
|
||||||
|
|
||||||
STR_INSTALL_SUCCESS,
|
STR_INSTALL_SUCCESS,//14
|
||||||
STR_INSTALL_FAILED,
|
STR_INSTALL_FAILED,//15
|
||||||
STR_UPDATE_SUCCESS,
|
STR_UPDATE_SUCCESS,//16
|
||||||
STR_UPDATE_FAILED,
|
STR_UPDATE_FAILED,//17
|
||||||
|
|
||||||
STR_WAIT_PROCESS,
|
STR_WAIT_PROCESS,//18
|
||||||
|
|
||||||
|
STR_MENU_OPTION,//19
|
||||||
|
STR_MENU_SECURE_BOOT,//20
|
||||||
|
|
||||||
STR_ID_MAX
|
STR_ID_MAX
|
||||||
}STR_ID;
|
}STR_ID;
|
||||||
|
|
||||||
|
extern BOOL g_SecureBoot;
|
||||||
|
|
||||||
|
#define VTOY_MENU_SECURE_BOOT 0xA000
|
||||||
|
#define VTOY_MENU_LANGUAGE_BEGIN 0xB000
|
||||||
|
|
||||||
|
|
||||||
|
#define VENTOY_LANGUAGE_INI TEXT(".\\ventoy\\languages.ini")
|
||||||
|
#define VENTOY_CFG_INI TEXT(".\\Ventoy2Disk.ini")
|
||||||
|
#define VENTOY_MAX_LANGUAGE 200
|
||||||
|
|
||||||
|
#define GET_INI_STRING(Key, Buf) GetPrivateProfileString(Language, Key, TEXT("#"), Buf, sizeof(Buf), VENTOY_LANGUAGE_INI)
|
||||||
|
|
||||||
|
typedef struct VENTOY_LANGUAGE
|
||||||
|
{
|
||||||
|
WCHAR Name[64];
|
||||||
|
WCHAR FontFamily[64];
|
||||||
|
int FontSize;
|
||||||
|
|
||||||
|
WCHAR StrId[STR_ID_MAX][64];
|
||||||
|
WCHAR MsgString[STR_ID_MAX][1024];
|
||||||
|
|
||||||
|
}VENTOY_LANGUAGE;
|
||||||
|
|
||||||
|
extern VENTOY_LANGUAGE *g_cur_lang_data;
|
||||||
|
|
||||||
const TCHAR * GetString(enum STR_ID ID);
|
const TCHAR * GetString(enum STR_ID ID);
|
||||||
|
|
||||||
#define _G(a) GetString(a)
|
#define _G(a) GetString(a)
|
||||||
|
@@ -824,10 +824,128 @@ int GetVentoyVerInPhyDrive(const PHY_DRIVE_INFO *pDriveInfo, CHAR *VerBuf, size_
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static unsigned int g_disk_unxz_len = 0;
|
static unsigned int g_disk_unxz_len = 0;
|
||||||
static BYTE *g_part_img_pos = NULL;
|
static BYTE *g_part_img_pos = NULL;
|
||||||
static BYTE *g_part_img_buf[VENTOY_EFI_PART_SIZE / SIZE_1MB];
|
static BYTE *g_part_img_buf[VENTOY_EFI_PART_SIZE / SIZE_1MB];
|
||||||
|
|
||||||
|
|
||||||
|
static int VentoyFatMemRead(uint32 Sector, uint8 *Buffer, uint32 SectorCount)
|
||||||
|
{
|
||||||
|
uint32 i;
|
||||||
|
uint32 offset;
|
||||||
|
BYTE *MbBuf = NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < SectorCount; i++)
|
||||||
|
{
|
||||||
|
offset = (Sector + i) * 512;
|
||||||
|
|
||||||
|
if (g_part_img_buf[1] == NULL)
|
||||||
|
{
|
||||||
|
MbBuf = g_part_img_buf[0] + offset;
|
||||||
|
memcpy(Buffer + i * 512, MbBuf, 512);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MbBuf = g_part_img_buf[offset / SIZE_1MB];
|
||||||
|
memcpy(Buffer + i * 512, MbBuf + (offset % SIZE_1MB), 512);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int VentoyFatMemWrite(uint32 Sector, uint8 *Buffer, uint32 SectorCount)
|
||||||
|
{
|
||||||
|
uint32 i;
|
||||||
|
uint32 offset;
|
||||||
|
BYTE *MbBuf = NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < SectorCount; i++)
|
||||||
|
{
|
||||||
|
offset = (Sector + i) * 512;
|
||||||
|
|
||||||
|
if (g_part_img_buf[1] == NULL)
|
||||||
|
{
|
||||||
|
MbBuf = g_part_img_buf[0] + offset;
|
||||||
|
memcpy(MbBuf, Buffer + i * 512, 512);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MbBuf = g_part_img_buf[offset / SIZE_1MB];
|
||||||
|
memcpy(MbBuf + (offset % SIZE_1MB), Buffer + i * 512, 512);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int VentoyProcSecureBoot(BOOL SecureBoot)
|
||||||
|
{
|
||||||
|
int rc = 0;
|
||||||
|
int size;
|
||||||
|
char *filebuf = NULL;
|
||||||
|
void *file = NULL;
|
||||||
|
|
||||||
|
Log("VentoyProcSecureBoot %d ...", SecureBoot);
|
||||||
|
|
||||||
|
if (SecureBoot)
|
||||||
|
{
|
||||||
|
Log("Secure boot is enabled ...");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
fl_init();
|
||||||
|
|
||||||
|
if (0 == fl_attach_media(VentoyFatMemRead, VentoyFatMemWrite))
|
||||||
|
{
|
||||||
|
file = fl_fopen("/EFI/BOOT/grubx64_real.efi", "rb");
|
||||||
|
Log("Open ventoy efi file %p ", file);
|
||||||
|
if (file)
|
||||||
|
{
|
||||||
|
fl_fseek(file, 0, SEEK_END);
|
||||||
|
size = (int)fl_ftell(file);
|
||||||
|
fl_fseek(file, 0, SEEK_SET);
|
||||||
|
|
||||||
|
Log("ventoy efi file size %d ...", size);
|
||||||
|
|
||||||
|
filebuf = (char *)malloc(size);
|
||||||
|
if (filebuf)
|
||||||
|
{
|
||||||
|
fl_fread(filebuf, 1, size, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
fl_fclose(file);
|
||||||
|
|
||||||
|
Log("Now delete all efi files ...");
|
||||||
|
fl_remove("/EFI/BOOT/BOOTX64.EFI");
|
||||||
|
fl_remove("/EFI/BOOT/grubx64.efi");
|
||||||
|
fl_remove("/EFI/BOOT/grubx64_real.efi");
|
||||||
|
fl_remove("/EFI/BOOT/MokManager.efi");
|
||||||
|
|
||||||
|
file = fl_fopen("/EFI/BOOT/BOOTX64.EFI", "wb");
|
||||||
|
Log("Open bootx64 efi file %p ", file);
|
||||||
|
if (file)
|
||||||
|
{
|
||||||
|
fl_fwrite(filebuf, 1, size, file);
|
||||||
|
fl_fflush(file);
|
||||||
|
fl_fclose(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rc = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fl_shutdown();
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int disk_xz_flush(void *src, unsigned int size)
|
static int disk_xz_flush(void *src, unsigned int size)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
@@ -919,6 +1037,9 @@ static int FormatPart2Fat(HANDLE hDrive, UINT64 StartSectorId)
|
|||||||
if (len == writelen)
|
if (len == writelen)
|
||||||
{
|
{
|
||||||
Log("decompress finished success");
|
Log("decompress finished success");
|
||||||
|
|
||||||
|
VentoyProcSecureBoot(g_SecureBoot);
|
||||||
|
|
||||||
for (i = 0; i < VENTOY_EFI_PART_SIZE / SIZE_1MB; i++)
|
for (i = 0; i < VENTOY_EFI_PART_SIZE / SIZE_1MB; i++)
|
||||||
{
|
{
|
||||||
dwSize = 0;
|
dwSize = 0;
|
||||||
@@ -965,6 +1086,9 @@ static int FormatPart2Fat(HANDLE hDrive, UINT64 StartSectorId)
|
|||||||
if (g_disk_unxz_len == VENTOY_EFI_PART_SIZE)
|
if (g_disk_unxz_len == VENTOY_EFI_PART_SIZE)
|
||||||
{
|
{
|
||||||
Log("decompress finished success");
|
Log("decompress finished success");
|
||||||
|
|
||||||
|
VentoyProcSecureBoot(g_SecureBoot);
|
||||||
|
|
||||||
for (int i = 0; i < VENTOY_EFI_PART_SIZE / SIZE_1MB; i++)
|
for (int i = 0; i < VENTOY_EFI_PART_SIZE / SIZE_1MB; i++)
|
||||||
{
|
{
|
||||||
dwSize = 0;
|
dwSize = 0;
|
||||||
|
Binary file not shown.
@@ -26,17 +26,55 @@
|
|||||||
|
|
||||||
HINSTANCE g_hInst;
|
HINSTANCE g_hInst;
|
||||||
|
|
||||||
|
|
||||||
|
BOOL g_SecureBoot = FALSE;
|
||||||
HWND g_DialogHwnd;
|
HWND g_DialogHwnd;
|
||||||
HWND g_ComboxHwnd;
|
HWND g_ComboxHwnd;
|
||||||
HWND g_StaticLocalVerHwnd;
|
HWND g_StaticLocalVerHwnd;
|
||||||
HWND g_StaticDiskVerHwnd;
|
HWND g_StaticDiskVerHwnd;
|
||||||
HWND g_BtnInstallHwnd;
|
HWND g_BtnInstallHwnd;
|
||||||
|
HWND g_StaticDevHwnd;
|
||||||
|
HWND g_StaticLocalHwnd;
|
||||||
|
HWND g_StaticDiskHwnd;
|
||||||
HWND g_BtnUpdateHwnd;
|
HWND g_BtnUpdateHwnd;
|
||||||
HWND g_ProgressBarHwnd;
|
HWND g_ProgressBarHwnd;
|
||||||
HWND g_StaticStatusHwnd;
|
HWND g_StaticStatusHwnd;
|
||||||
CHAR g_CurVersion[64];
|
CHAR g_CurVersion[64];
|
||||||
HANDLE g_ThreadHandle = NULL;
|
HANDLE g_ThreadHandle = NULL;
|
||||||
|
|
||||||
|
int g_language_count = 0;
|
||||||
|
int g_cur_lang_id = 0;
|
||||||
|
VENTOY_LANGUAGE *g_language_data = NULL;
|
||||||
|
VENTOY_LANGUAGE *g_cur_lang_data = NULL;
|
||||||
|
|
||||||
|
static int LoadCfgIni(void)
|
||||||
|
{
|
||||||
|
int value;
|
||||||
|
|
||||||
|
value = GetPrivateProfileInt(TEXT("Ventoy"), TEXT("SecureBoot"), 0, VENTOY_CFG_INI);
|
||||||
|
|
||||||
|
if (value == 1)
|
||||||
|
{
|
||||||
|
g_SecureBoot = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int WriteCfgIni(void)
|
||||||
|
{
|
||||||
|
WCHAR TmpBuf[128];
|
||||||
|
|
||||||
|
swprintf_s(TmpBuf, 128, TEXT("%d"), g_cur_lang_id);
|
||||||
|
WritePrivateProfileString(TEXT("Ventoy"), TEXT("Language"), TmpBuf, VENTOY_CFG_INI);
|
||||||
|
|
||||||
|
swprintf_s(TmpBuf, 128, TEXT("%d"), g_SecureBoot);
|
||||||
|
WritePrivateProfileString(TEXT("Ventoy"), TEXT("SecureBoot"), TmpBuf, VENTOY_CFG_INI);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void GetExeVersionInfo(const char *FilePath)
|
void GetExeVersionInfo(const char *FilePath)
|
||||||
{
|
{
|
||||||
UINT length;
|
UINT length;
|
||||||
@@ -124,15 +162,126 @@ static void OnComboxSelChange(HWND hCombox)
|
|||||||
UpdateWindow(g_DialogHwnd);
|
UpdateWindow(g_DialogHwnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void UpdateItemString(int defaultLangId)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
HMENU SubMenu;
|
||||||
|
HFONT hLangFont;
|
||||||
|
HMENU hMenu = GetMenu(g_DialogHwnd);
|
||||||
|
|
||||||
|
g_cur_lang_id = defaultLangId;
|
||||||
|
g_cur_lang_data = g_language_data + defaultLangId;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
hLangFont = CreateFont(g_language_data[defaultLangId].FontSize, 0, 0, 0, 400, FALSE, FALSE, 0,
|
||||||
|
DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
|
||||||
|
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
|
||||||
|
DEFAULT_PITCH, g_language_data[defaultLangId].FontFamily);
|
||||||
|
|
||||||
|
SendMessage(g_BtnInstallHwnd, WM_SETFONT, (WPARAM)hLangFont, TRUE);
|
||||||
|
SendMessage(g_BtnUpdateHwnd, WM_SETFONT, (WPARAM)hLangFont, TRUE);
|
||||||
|
SendMessage(g_StaticStatusHwnd, WM_SETFONT, (WPARAM)hLangFont, TRUE);
|
||||||
|
SendMessage(g_StaticLocalHwnd, WM_SETFONT, (WPARAM)hLangFont, TRUE);
|
||||||
|
SendMessage(g_StaticDiskHwnd, WM_SETFONT, (WPARAM)hLangFont, TRUE);
|
||||||
|
SendMessage(g_StaticDevHwnd, WM_SETFONT, (WPARAM)hLangFont, TRUE);
|
||||||
|
SendMessage(g_DialogHwnd, WM_SETFONT, (WPARAM)hLangFont, TRUE);
|
||||||
|
|
||||||
|
ModifyMenu(hMenu, 0, MF_BYPOSITION | MF_STRING, 0, _G(STR_MENU_OPTION));
|
||||||
|
|
||||||
|
SetWindowText(GetDlgItem(g_DialogHwnd, IDC_STATIC_DEV), _G(STR_DEVICE));
|
||||||
|
SetWindowText(GetDlgItem(g_DialogHwnd, IDC_STATIC_LOCAL), _G(STR_LOCAL_VER));
|
||||||
|
SetWindowText(GetDlgItem(g_DialogHwnd, IDC_STATIC_DISK), _G(STR_DISK_VER));
|
||||||
|
SetWindowText(g_StaticStatusHwnd, _G(STR_STATUS));
|
||||||
|
|
||||||
|
SetWindowText(g_BtnInstallHwnd, _G(STR_INSTALL));
|
||||||
|
SetWindowText(g_BtnUpdateHwnd, _G(STR_UPDATE));
|
||||||
|
|
||||||
|
SubMenu = GetSubMenu(hMenu, 0);
|
||||||
|
if (g_SecureBoot)
|
||||||
|
{
|
||||||
|
ModifyMenu(SubMenu, 0, MF_BYPOSITION | MF_STRING | MF_CHECKED, 0, _G(STR_MENU_SECURE_BOOT));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ModifyMenu(SubMenu, 0, MF_BYPOSITION | MF_STRING | MF_UNCHECKED, 0, _G(STR_MENU_SECURE_BOOT));
|
||||||
|
}
|
||||||
|
|
||||||
|
ShowWindow(g_DialogHwnd, SW_HIDE);
|
||||||
|
ShowWindow(g_DialogHwnd, SW_NORMAL);
|
||||||
|
|
||||||
|
//Update check
|
||||||
|
for (i = 0; i < g_language_count; i++)
|
||||||
|
{
|
||||||
|
CheckMenuItem(hMenu, VTOY_MENU_LANGUAGE_BEGIN | i, MF_BYCOMMAND | MF_STRING | MF_UNCHECKED);
|
||||||
|
}
|
||||||
|
CheckMenuItem(hMenu, VTOY_MENU_LANGUAGE_BEGIN | defaultLangId, MF_BYCOMMAND | MF_STRING | MF_CHECKED);
|
||||||
|
}
|
||||||
|
|
||||||
static void LanguageInit(void)
|
static void LanguageInit(void)
|
||||||
{
|
{
|
||||||
SetWindowText(GetDlgItem(g_DialogHwnd, IDC_STATIC_DEV), _G(STR_DEVICE));
|
int i, j, k;
|
||||||
SetWindowText(GetDlgItem(g_DialogHwnd, IDC_STATIC_LOCAL), _G(STR_LOCAL_VER));
|
int id, DefaultId;
|
||||||
SetWindowText(GetDlgItem(g_DialogHwnd, IDC_STATIC_DISK), _G(STR_DISK_VER));
|
WCHAR Language[64];
|
||||||
SetWindowText(g_StaticStatusHwnd, _G(STR_STATUS));
|
WCHAR TmpBuf[256];
|
||||||
|
LANGID LangId = GetSystemDefaultUILanguage();
|
||||||
|
HMENU SubMenu;
|
||||||
|
HMENU hMenu = GetMenu(g_DialogHwnd);
|
||||||
|
|
||||||
SetWindowText(g_BtnInstallHwnd, _G(STR_INSTALL));
|
SubMenu = GetSubMenu(hMenu, 1);
|
||||||
SetWindowText(g_BtnUpdateHwnd, _G(STR_UPDATE));
|
DeleteMenu(SubMenu, 0, MF_BYPOSITION);
|
||||||
|
|
||||||
|
g_language_data = (VENTOY_LANGUAGE *)malloc(sizeof(VENTOY_LANGUAGE)* VENTOY_MAX_LANGUAGE);
|
||||||
|
memset(g_language_data, 0, sizeof(VENTOY_LANGUAGE)* VENTOY_MAX_LANGUAGE);
|
||||||
|
|
||||||
|
swprintf_s(Language, 64, L"StringDefine");
|
||||||
|
for (i = 0; i < STR_ID_MAX; i++)
|
||||||
|
{
|
||||||
|
swprintf_s(TmpBuf, 256, L"%d", i);
|
||||||
|
GET_INI_STRING(TmpBuf, g_language_data[0].StrId[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < VENTOY_MAX_LANGUAGE; i++)
|
||||||
|
{
|
||||||
|
swprintf_s(Language, 64, L"Language%d", i);
|
||||||
|
GET_INI_STRING(TEXT("name"), g_language_data[i].Name);
|
||||||
|
|
||||||
|
if (g_language_data[i].Name[0] == '#')
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_language_count++;
|
||||||
|
Log("Find Language%d ...", i);
|
||||||
|
|
||||||
|
AppendMenu(SubMenu, MF_STRING | MF_BYCOMMAND, VTOY_MENU_LANGUAGE_BEGIN | i, g_language_data[i].Name);
|
||||||
|
|
||||||
|
GET_INI_STRING(TEXT("FontFamily"), g_language_data[i].FontFamily);
|
||||||
|
g_language_data[i].FontSize = GetPrivateProfileInt(Language, TEXT("FontSize"), 10, VENTOY_LANGUAGE_INI);
|
||||||
|
|
||||||
|
for (j = 0; j < STR_ID_MAX; j++)
|
||||||
|
{
|
||||||
|
GET_INI_STRING(g_language_data[0].StrId[j], g_language_data[i].MsgString[j]);
|
||||||
|
|
||||||
|
for (k = 0; g_language_data[i].MsgString[j][k] && g_language_data[i].MsgString[j][k + 1]; k++)
|
||||||
|
{
|
||||||
|
if (g_language_data[i].MsgString[j][k] == '#' && g_language_data[i].MsgString[j][k + 1] == '@')
|
||||||
|
{
|
||||||
|
g_language_data[i].MsgString[j][k] = '\r';
|
||||||
|
g_language_data[i].MsgString[j][k + 1] = '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DefaultId = (MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED) == LangId) ? 0 : 1;
|
||||||
|
id = GetPrivateProfileInt(TEXT("Ventoy"), TEXT("Language"), DefaultId, VENTOY_CFG_INI);
|
||||||
|
if (id >= i)
|
||||||
|
{
|
||||||
|
id = DefaultId;
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateItemString(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL InitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
static BOOL InitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||||
@@ -149,6 +298,13 @@ static BOOL InitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||||||
g_StaticLocalVerHwnd = GetDlgItem(hWnd, IDC_STATIC_LOCAL_VER);
|
g_StaticLocalVerHwnd = GetDlgItem(hWnd, IDC_STATIC_LOCAL_VER);
|
||||||
g_StaticDiskVerHwnd = GetDlgItem(hWnd, IDC_STATIC_DISK_VER);
|
g_StaticDiskVerHwnd = GetDlgItem(hWnd, IDC_STATIC_DISK_VER);
|
||||||
g_BtnInstallHwnd = GetDlgItem(hWnd, IDC_BUTTON4);
|
g_BtnInstallHwnd = GetDlgItem(hWnd, IDC_BUTTON4);
|
||||||
|
|
||||||
|
|
||||||
|
g_StaticDevHwnd = GetDlgItem(hWnd, IDC_STATIC_DEV);
|
||||||
|
g_StaticLocalHwnd = GetDlgItem(hWnd, IDC_STATIC_LOCAL);
|
||||||
|
g_StaticDiskHwnd = GetDlgItem(hWnd, IDC_STATIC_DISK);
|
||||||
|
|
||||||
|
|
||||||
g_BtnUpdateHwnd = GetDlgItem(hWnd, IDC_BUTTON3);
|
g_BtnUpdateHwnd = GetDlgItem(hWnd, IDC_BUTTON3);
|
||||||
g_ProgressBarHwnd = GetDlgItem(hWnd, IDC_PROGRESS1);
|
g_ProgressBarHwnd = GetDlgItem(hWnd, IDC_PROGRESS1);
|
||||||
g_StaticStatusHwnd = GetDlgItem(hWnd, IDC_STATIC_STATUS);
|
g_StaticStatusHwnd = GetDlgItem(hWnd, IDC_STATIC_STATUS);
|
||||||
@@ -160,8 +316,12 @@ static BOOL InitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||||||
SendMessage(g_ProgressBarHwnd, PBM_SETRANGE, (WPARAM)0, (LPARAM)(MAKELPARAM(0, PT_FINISH)));
|
SendMessage(g_ProgressBarHwnd, PBM_SETRANGE, (WPARAM)0, (LPARAM)(MAKELPARAM(0, PT_FINISH)));
|
||||||
PROGRESS_BAR_SET_POS(PT_START);
|
PROGRESS_BAR_SET_POS(PT_START);
|
||||||
|
|
||||||
|
SetMenu(hWnd, LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENU1)));
|
||||||
|
|
||||||
|
LoadCfgIni();
|
||||||
LanguageInit();
|
LanguageInit();
|
||||||
|
|
||||||
|
|
||||||
// Fill device combox
|
// Fill device combox
|
||||||
hCombox = GetDlgItem(hWnd, IDC_COMBO1);
|
hCombox = GetDlgItem(hWnd, IDC_COMBO1);
|
||||||
for (i = 0; i < g_PhyDriveCount; i++)
|
for (i = 0; i < g_PhyDriveCount; i++)
|
||||||
@@ -358,6 +518,31 @@ static void OnUpdateBtnClick(void)
|
|||||||
g_ThreadHandle = CreateThread(NULL, 0, UpdateVentoyThread, (LPVOID)pPhyDrive, 0, NULL);
|
g_ThreadHandle = CreateThread(NULL, 0, UpdateVentoyThread, (LPVOID)pPhyDrive, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void MenuProc(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
WORD CtrlID;
|
||||||
|
HMENU hMenu = GetMenu(hWnd);
|
||||||
|
|
||||||
|
CtrlID = LOWORD(wParam);
|
||||||
|
|
||||||
|
if (CtrlID == 0)
|
||||||
|
{
|
||||||
|
g_SecureBoot = !g_SecureBoot;
|
||||||
|
|
||||||
|
if (g_SecureBoot)
|
||||||
|
{
|
||||||
|
CheckMenuItem(hMenu, 0, MF_BYCOMMAND | MF_STRING | MF_CHECKED);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CheckMenuItem(hMenu, 0, MF_BYCOMMAND | MF_STRING | MF_UNCHECKED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (CtrlID >= VTOY_MENU_LANGUAGE_BEGIN && CtrlID < VTOY_MENU_LANGUAGE_BEGIN + g_language_count)
|
||||||
|
{
|
||||||
|
UpdateItemString(CtrlID - VTOY_MENU_LANGUAGE_BEGIN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
INT_PTR CALLBACK DialogProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
INT_PTR CALLBACK DialogProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
@@ -385,6 +570,10 @@ INT_PTR CALLBACK DialogProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lPara
|
|||||||
OnUpdateBtnClick();
|
OnUpdateBtnClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lParam == 0 && NotifyCode == 0)
|
||||||
|
{
|
||||||
|
MenuProc(hWnd, wParam, lParam);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -417,6 +606,7 @@ INT_PTR CALLBACK DialogProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lPara
|
|||||||
{
|
{
|
||||||
EndDialog(hWnd, 0);
|
EndDialog(hWnd, 0);
|
||||||
}
|
}
|
||||||
|
WriteCfgIni();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -430,7 +620,14 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
|
|||||||
|
|
||||||
if (!IsFileExist(VENTOY_FILE_VERSION))
|
if (!IsFileExist(VENTOY_FILE_VERSION))
|
||||||
{
|
{
|
||||||
MessageBox(NULL, _G(STR_INCORRECT_DIR), _G(STR_ERROR), MB_OK | MB_ICONERROR);
|
if (IsDirExist("grub"))
|
||||||
|
{
|
||||||
|
MessageBox(NULL, _G(STR_INCORRECT_DIR), _G(STR_ERROR), MB_OK | MB_ICONERROR);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox(NULL, _G(STR_INCORRECT_DIR), _G(STR_ERROR), MB_OK | MB_ICONERROR);
|
||||||
|
}
|
||||||
return ERROR_NOT_FOUND;
|
return ERROR_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -444,6 +641,8 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
|
|||||||
|
|
||||||
Ventoy2DiskInit();
|
Ventoy2DiskInit();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
g_hInst = hInstance;
|
g_hInst = hInstance;
|
||||||
DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, DialogProc);
|
DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, DialogProc);
|
||||||
|
|
||||||
|
Binary file not shown.
Reference in New Issue
Block a user