mirror of
https://github.com/ventoy/Ventoy.git
synced 2025-09-17 09:21:15 +00:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
47e77e003c | ||
|
d05eab2be1 | ||
|
849dfb463d | ||
|
7715bd705c | ||
|
042ca4b5e3 | ||
|
e1099e1e5b | ||
|
c6be35f2c0 |
@@ -1603,6 +1603,7 @@ module = {
|
||||
module = {
|
||||
name = ventoy;
|
||||
common = ventoy/ventoy.c;
|
||||
common = ventoy/ventoy_cmd.c;
|
||||
common = ventoy/ventoy_linux.c;
|
||||
common = ventoy/ventoy_unix.c;
|
||||
common = ventoy/ventoy_windows.c;
|
||||
|
File diff suppressed because it is too large
Load Diff
4497
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c
Normal file
4497
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -140,6 +140,7 @@ typedef struct cpio_newc_header
|
||||
typedef int (*grub_char_check_func)(int c);
|
||||
#define ventoy_is_decimal(str) ventoy_string_check(str, grub_isdigit)
|
||||
|
||||
#define OFFSET_OF(TYPE, MEMBER) ((grub_size_t) &((TYPE *)0)->MEMBER)
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct ventoy_patch_vhd
|
||||
@@ -527,7 +528,8 @@ typedef struct plugin_entry
|
||||
ventoy_plugin_check_pf checkfunc;
|
||||
}plugin_entry;
|
||||
|
||||
|
||||
int ventoy_strcmp(const char *pattern, const char *str);
|
||||
int ventoy_strncmp (const char *pattern, const char *str, grub_size_t n);
|
||||
void ventoy_fill_os_param(grub_file_t file, ventoy_os_param *param);
|
||||
grub_err_t ventoy_cmd_isolinux_initrd_collect(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_grub_initrd_collect(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
@@ -829,6 +831,7 @@ typedef struct menu_class
|
||||
{
|
||||
int type;
|
||||
int patlen;
|
||||
int parent;
|
||||
char pattern[256];
|
||||
char class[64];
|
||||
|
||||
@@ -930,6 +933,8 @@ extern grub_uint8_t *g_conf_replace_new_buf;
|
||||
extern int g_conf_replace_new_len;
|
||||
extern int g_conf_replace_new_len_align;
|
||||
extern grub_uint64_t g_ventoy_disk_size;
|
||||
extern grub_uint64_t g_ventoy_disk_part_size[2];
|
||||
extern grub_uint32_t g_ventoy_plat_data;
|
||||
|
||||
#define ventoy_unix_fill_virt(new_data, new_len) \
|
||||
{ \
|
||||
@@ -947,19 +952,23 @@ extern grub_uint64_t g_ventoy_disk_size;
|
||||
chain->virt_img_size_in_bytes += data_secs * 2048; \
|
||||
}
|
||||
|
||||
#define ventoy_syscall0(name) grub_##name()
|
||||
#define ventoy_syscall1(name, a) grub_##name(a)
|
||||
|
||||
char * ventoy_get_line(char *start);
|
||||
int ventoy_cmp_img(img_info *img1, img_info *img2);
|
||||
void ventoy_swap_img(img_info *img1, img_info *img2);
|
||||
char * ventoy_plugin_get_cur_install_template(const char *isopath);
|
||||
install_template * ventoy_plugin_find_install_template(const char *isopath);
|
||||
persistence_config * ventoy_plugin_find_persistent(const char *isopath);
|
||||
grub_uint64_t ventoy_get_vtoy_partsize(int part);
|
||||
void ventoy_plugin_dump_injection(void);
|
||||
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_injection(const char *isopath);
|
||||
const char * ventoy_plugin_get_menu_alias(int type, const char *isopath);
|
||||
const char * ventoy_plugin_get_menu_class(int type, const char *name);
|
||||
const char * ventoy_plugin_get_menu_class(int type, const char *name, const char *path);
|
||||
int ventoy_plugin_check_memdisk(const char *isopath);
|
||||
int ventoy_plugin_get_image_list_index(int type, const char *name);
|
||||
conf_replace * ventoy_plugin_find_conf_replace(const char *iso);
|
||||
@@ -992,11 +1001,16 @@ grub_err_t ventoy_cmd_patch_vhdboot(grub_extcmd_context_t ctxt, int argc, char *
|
||||
grub_err_t ventoy_cmd_raw_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
int ventoy_check_password(const vtoy_password *pwd, int retry);
|
||||
int ventoy_gzip_compress(void *mem_in, int mem_in_len, void *mem_out, int mem_out_len);
|
||||
grub_uint64_t ventoy_get_part1_size(ventoy_gpt_info *gpt);
|
||||
int ventoy_plugin_add_custom_boot(const char *vcfgpath);
|
||||
const char * ventoy_plugin_get_custom_boot(const char *isopath);
|
||||
grub_err_t ventoy_cmd_dump_custom_boot(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
int ventoy_gzip_compress(void *mem_in, int mem_in_len, void *mem_out, int mem_out_len);
|
||||
int ventoy_load_part_table(const char *diskname);
|
||||
int ventoy_env_init(void);
|
||||
int ventoy_register_all_cmd(void);
|
||||
int ventoy_unregister_all_cmd(void);
|
||||
|
||||
#define VTOY_CMD_CHECK(a) if (33554432 != g_ventoy_disk_part_size[a]) ventoy_syscall0(exit)
|
||||
|
||||
#endif /* __VENTOY_DEF_H__ */
|
||||
|
||||
|
@@ -481,6 +481,7 @@ static int ventoy_plugin_auto_install_check(VTOY_JSON *json, const char *isodisk
|
||||
{
|
||||
int pathnum = 0;
|
||||
int autosel = 0;
|
||||
char *pos = NULL;
|
||||
const char *iso = NULL;
|
||||
VTOY_JSON *pNode = NULL;
|
||||
|
||||
@@ -500,9 +501,10 @@ static int ventoy_plugin_auto_install_check(VTOY_JSON *json, const char *isodisk
|
||||
iso = vtoy_json_get_string_ex(pNode->pstChild, "image");
|
||||
if (iso)
|
||||
{
|
||||
if (0 == ventoy_plugin_check_path(isodisk, iso))
|
||||
pos = grub_strchr(iso, '*');
|
||||
if (pos || 0 == ventoy_plugin_check_path(isodisk, iso))
|
||||
{
|
||||
grub_printf("image: %s [OK]\n", iso);
|
||||
grub_printf("image: %s [%s]\n", iso, (pos ? "*" : "OK"));
|
||||
ventoy_plugin_check_fullpath(pNode->pstChild, isodisk, "template", &pathnum);
|
||||
|
||||
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "autosel", &autosel))
|
||||
@@ -599,6 +601,7 @@ static int ventoy_plugin_auto_install_entry(VTOY_JSON *json, const char *isodisk
|
||||
static int ventoy_plugin_dud_check(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int pathnum = 0;
|
||||
char *pos = NULL;
|
||||
const char *iso = NULL;
|
||||
VTOY_JSON *pNode = NULL;
|
||||
|
||||
@@ -618,9 +621,10 @@ static int ventoy_plugin_dud_check(VTOY_JSON *json, const char *isodisk)
|
||||
iso = vtoy_json_get_string_ex(pNode->pstChild, "image");
|
||||
if (iso)
|
||||
{
|
||||
if (0 == ventoy_plugin_check_path(isodisk, iso))
|
||||
pos = grub_strchr(iso, '*');
|
||||
if (pos || 0 == ventoy_plugin_check_path(isodisk, iso))
|
||||
{
|
||||
grub_printf("image: %s [OK]\n", iso);
|
||||
grub_printf("image: %s [%s]\n", iso, (pos ? "*" : "OK"));
|
||||
ventoy_plugin_check_fullpath(pNode->pstChild, isodisk, "dud", &pathnum);
|
||||
}
|
||||
else
|
||||
@@ -884,6 +888,7 @@ static int ventoy_plugin_pwd_entry(VTOY_JSON *json, const char *isodisk)
|
||||
|
||||
static int ventoy_plugin_pwd_check(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
char *pos = NULL;
|
||||
const char *iso = NULL;
|
||||
const char *pwd = NULL;
|
||||
VTOY_JSON *pNode = NULL;
|
||||
@@ -922,13 +927,14 @@ static int ventoy_plugin_pwd_check(VTOY_JSON *json, const char *isodisk)
|
||||
iso = vtoy_json_get_string_ex(pCNode->pstChild, "file");
|
||||
if (iso)
|
||||
{
|
||||
if (0 == ventoy_plugin_check_path(isodisk, iso))
|
||||
pos = grub_strchr(iso, '*');
|
||||
if (pos || 0 == ventoy_plugin_check_path(isodisk, iso))
|
||||
{
|
||||
pwd = vtoy_json_get_string_ex(pCNode->pstChild, "pwd");
|
||||
|
||||
if (0 == ventoy_plugin_parse_pwdstr((char *)pwd, NULL))
|
||||
{
|
||||
grub_printf("file:<%s> [OK]\n", iso);
|
||||
grub_printf("file:<%s> [%s]\n", iso, (pos ? "*" : "OK"));
|
||||
grub_printf("pwd:<%s>\n\n", pwd);
|
||||
}
|
||||
else
|
||||
@@ -956,6 +962,7 @@ static int ventoy_plugin_persistence_check(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int autosel = 0;
|
||||
int pathnum = 0;
|
||||
char *pos = NULL;
|
||||
const char *iso = NULL;
|
||||
VTOY_JSON *pNode = NULL;
|
||||
|
||||
@@ -975,9 +982,10 @@ static int ventoy_plugin_persistence_check(VTOY_JSON *json, const char *isodisk)
|
||||
iso = vtoy_json_get_string_ex(pNode->pstChild, "image");
|
||||
if (iso)
|
||||
{
|
||||
if (0 == ventoy_plugin_check_path(isodisk, iso))
|
||||
pos = grub_strchr(iso, '*');
|
||||
if (pos || 0 == ventoy_plugin_check_path(isodisk, iso))
|
||||
{
|
||||
grub_printf("image: %s [OK]\n", iso);
|
||||
grub_printf("image: %s [%s]\n", iso, (pos ? "*" : "OK"));
|
||||
ventoy_plugin_check_fullpath(pNode->pstChild, isodisk, "backend", &pathnum);
|
||||
|
||||
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "autosel", &autosel))
|
||||
@@ -1102,8 +1110,12 @@ static int ventoy_plugin_menualias_check(VTOY_JSON *json, const char *isodisk)
|
||||
if (path && path[0] == '/' && alias)
|
||||
{
|
||||
if (vtoy_alias_image_file == type)
|
||||
{
|
||||
if (ventoy_is_file_exist("%s%s", isodisk, path))
|
||||
{
|
||||
if (grub_strchr(path, '*'))
|
||||
{
|
||||
grub_printf("image: <%s> [ * ]\n", path);
|
||||
}
|
||||
else if (ventoy_is_file_exist("%s%s", isodisk, path))
|
||||
{
|
||||
grub_printf("image: <%s> [ OK ]\n", path);
|
||||
}
|
||||
@@ -1223,7 +1235,15 @@ static int ventoy_plugin_injection_check(VTOY_JSON *json, const char *isodisk)
|
||||
continue;
|
||||
}
|
||||
|
||||
grub_printf("image: <%s> [%s]\n", path, ventoy_check_file_exist("%s%s", isodisk, path) ? "OK" : "NOT EXIST");
|
||||
if (grub_strchr(path, '*'))
|
||||
{
|
||||
grub_printf("image: <%s> [*]\n", path);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("image: <%s> [%s]\n", path, ventoy_check_file_exist("%s%s", isodisk, path) ? "OK" : "NOT EXIST");
|
||||
}
|
||||
|
||||
grub_printf("archive: <%s> [%s]\n\n", archive, ventoy_check_file_exist("%s%s", isodisk, archive) ? "OK" : "NOT EXIST");
|
||||
}
|
||||
|
||||
@@ -1285,6 +1305,7 @@ static int ventoy_plugin_injection_entry(VTOY_JSON *json, const char *isodisk)
|
||||
static int ventoy_plugin_menuclass_entry(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int type;
|
||||
int parent = 0;
|
||||
const char *key = NULL;
|
||||
const char *class = NULL;
|
||||
VTOY_JSON *pNode = NULL;
|
||||
@@ -1313,12 +1334,21 @@ static int ventoy_plugin_menuclass_entry(VTOY_JSON *json, const char *isodisk)
|
||||
|
||||
for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
|
||||
{
|
||||
parent = 0;
|
||||
type = vtoy_class_image_file;
|
||||
key = vtoy_json_get_string_ex(pNode->pstChild, "key");
|
||||
if (!key)
|
||||
{
|
||||
key = vtoy_json_get_string_ex(pNode->pstChild, "dir");
|
||||
type = vtoy_class_directory;
|
||||
key = vtoy_json_get_string_ex(pNode->pstChild, "parent");
|
||||
if (key)
|
||||
{
|
||||
parent = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
key = vtoy_json_get_string_ex(pNode->pstChild, "dir");
|
||||
type = vtoy_class_directory;
|
||||
}
|
||||
}
|
||||
|
||||
class = vtoy_json_get_string_ex(pNode->pstChild, "class");
|
||||
@@ -1328,6 +1358,7 @@ static int ventoy_plugin_menuclass_entry(VTOY_JSON *json, const char *isodisk)
|
||||
if (node)
|
||||
{
|
||||
node->type = type;
|
||||
node->parent = parent;
|
||||
node->patlen = grub_snprintf(node->pattern, sizeof(node->pattern), "%s", key);
|
||||
grub_snprintf(node->class, sizeof(node->class), "%s", class);
|
||||
|
||||
@@ -1349,7 +1380,7 @@ static int ventoy_plugin_menuclass_entry(VTOY_JSON *json, const char *isodisk)
|
||||
|
||||
static int ventoy_plugin_menuclass_check(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int type;
|
||||
const char *name = NULL;
|
||||
const char *key = NULL;
|
||||
const char *class = NULL;
|
||||
VTOY_JSON *pNode = NULL;
|
||||
@@ -1364,18 +1395,23 @@ static int ventoy_plugin_menuclass_check(VTOY_JSON *json, const char *isodisk)
|
||||
|
||||
for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
|
||||
{
|
||||
type = vtoy_class_image_file;
|
||||
name = "key";
|
||||
key = vtoy_json_get_string_ex(pNode->pstChild, "key");
|
||||
if (!key)
|
||||
{
|
||||
key = vtoy_json_get_string_ex(pNode->pstChild, "dir");
|
||||
type = vtoy_class_directory;
|
||||
name = "parent";
|
||||
key = vtoy_json_get_string_ex(pNode->pstChild, "parent");
|
||||
if (!key)
|
||||
{
|
||||
name = "dir";
|
||||
key = vtoy_json_get_string_ex(pNode->pstChild, "dir");
|
||||
}
|
||||
}
|
||||
|
||||
class = vtoy_json_get_string_ex(pNode->pstChild, "class");
|
||||
if (key && class)
|
||||
{
|
||||
grub_printf("%s: <%s>\n", (type == vtoy_class_directory) ? "dir" : "key", key);
|
||||
grub_printf("%s: <%s>\n", name, key);
|
||||
grub_printf("class: <%s>\n\n", class);
|
||||
}
|
||||
}
|
||||
@@ -1611,6 +1647,11 @@ static int ventoy_plugin_conf_replace_check(VTOY_JSON *json, const char *isodisk
|
||||
|
||||
grub_script_execute_sourcecode("loopback -d vtisocheck");
|
||||
}
|
||||
else if (grub_strchr(isof, '*'))
|
||||
{
|
||||
grub_printf("iso:<%s> [*]\n", isof);
|
||||
grub_printf("org:<%s>\n", orgf);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("iso:<%s> [NOT Exist]\n", isof);
|
||||
@@ -1704,7 +1745,11 @@ static int ventoy_plugin_auto_memdisk_check(VTOY_JSON *json, const char *isodisk
|
||||
{
|
||||
grub_printf("<%s> ", pNode->unData.pcStrVal);
|
||||
|
||||
if (ventoy_check_file_exist("%s%s", isodisk, pNode->unData.pcStrVal))
|
||||
if (grub_strchr(pNode->unData.pcStrVal, '*'))
|
||||
{
|
||||
grub_printf(" [*]\n");
|
||||
}
|
||||
else if (ventoy_check_file_exist("%s%s", isodisk, pNode->unData.pcStrVal))
|
||||
{
|
||||
grub_printf(" [OK]\n");
|
||||
}
|
||||
@@ -1794,7 +1839,11 @@ static int ventoy_plugin_image_list_check(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
grub_printf("<%s> ", pNode->unData.pcStrVal);
|
||||
|
||||
if (ventoy_check_file_exist("%s%s", isodisk, pNode->unData.pcStrVal))
|
||||
if (grub_strchr(pNode->unData.pcStrVal, '*'))
|
||||
{
|
||||
grub_printf(" [*]\n");
|
||||
}
|
||||
else if (ventoy_check_file_exist("%s%s", isodisk, pNode->unData.pcStrVal))
|
||||
{
|
||||
grub_printf(" [OK]\n");
|
||||
}
|
||||
@@ -1996,7 +2045,7 @@ install_template * ventoy_plugin_find_install_template(const char *isopath)
|
||||
len = (int)grub_strlen(isopath);
|
||||
for (node = g_install_template_head; node; node = node->next)
|
||||
{
|
||||
if (node->pathlen == len && grub_strcmp(node->isopath, isopath) == 0)
|
||||
if (node->pathlen == len && ventoy_strcmp(node->isopath, isopath) == 0)
|
||||
{
|
||||
return node;
|
||||
}
|
||||
@@ -2036,7 +2085,7 @@ persistence_config * ventoy_plugin_find_persistent(const char *isopath)
|
||||
len = (int)grub_strlen(isopath);
|
||||
for (node = g_persistence_head; node; node = node->next)
|
||||
{
|
||||
if ((len == node->pathlen) && (grub_strcmp(node->isopath, isopath) == 0))
|
||||
if ((len == node->pathlen) && (ventoy_strcmp(node->isopath, isopath) == 0))
|
||||
{
|
||||
return node;
|
||||
}
|
||||
@@ -2117,7 +2166,7 @@ const char * ventoy_plugin_get_injection(const char *isopath)
|
||||
len = (int)grub_strlen(isopath);
|
||||
for (node = g_injection_head; node; node = node->next)
|
||||
{
|
||||
if (node->pathlen == len && grub_strcmp(node->isopath, isopath) == 0)
|
||||
if (node->pathlen == len && ventoy_strcmp(node->isopath, isopath) == 0)
|
||||
{
|
||||
return node->archive;
|
||||
}
|
||||
@@ -2140,7 +2189,7 @@ const char * ventoy_plugin_get_menu_alias(int type, const char *isopath)
|
||||
for (node = g_menu_alias_head; node; node = node->next)
|
||||
{
|
||||
if (node->type == type && node->pathlen &&
|
||||
node->pathlen == len && grub_strcmp(node->isopath, isopath) == 0)
|
||||
node->pathlen == len && ventoy_strcmp(node->isopath, isopath) == 0)
|
||||
{
|
||||
return node->alias;
|
||||
}
|
||||
@@ -2149,7 +2198,7 @@ const char * ventoy_plugin_get_menu_alias(int type, const char *isopath)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char * ventoy_plugin_get_menu_class(int type, const char *name)
|
||||
const char * ventoy_plugin_get_menu_class(int type, const char *name, const char *path)
|
||||
{
|
||||
int len;
|
||||
menu_class *node = NULL;
|
||||
@@ -2158,21 +2207,38 @@ const char * ventoy_plugin_get_menu_class(int type, const char *name)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
len = (int)grub_strlen(name);
|
||||
|
||||
if (vtoy_class_image_file == type)
|
||||
{
|
||||
for (node = g_menu_class_head; node; node = node->next)
|
||||
{
|
||||
if (node->type == type && node->patlen <= len && grub_strstr(name, node->pattern))
|
||||
if (node->type != type)
|
||||
{
|
||||
return node->class;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (node->parent)
|
||||
{
|
||||
len = (int)grub_strlen(path);
|
||||
if ((node->patlen < len) && (path[node->patlen] == '/') &&
|
||||
(grub_strncmp(path, node->pattern, node->patlen) == 0))
|
||||
{
|
||||
return node->class;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
len = (int)grub_strlen(name);
|
||||
if ((node->patlen < len) && grub_strstr(name, node->pattern))
|
||||
{
|
||||
return node->class;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
len = (int)grub_strlen(name);
|
||||
for (node = g_menu_class_head; node; node = node->next)
|
||||
{
|
||||
if (node->type == type && node->patlen == len && grub_strncmp(name, node->pattern, len) == 0)
|
||||
@@ -2288,7 +2354,7 @@ int ventoy_plugin_check_memdisk(const char *isopath)
|
||||
len = (int)grub_strlen(isopath);
|
||||
for (node = g_auto_memdisk_head; node; node = node->next)
|
||||
{
|
||||
if (node->pathlen == len && grub_strncmp(isopath, node->isopath, len) == 0)
|
||||
if (node->pathlen == len && ventoy_strncmp(node->isopath, isopath, len) == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -2314,14 +2380,14 @@ int ventoy_plugin_get_image_list_index(int type, const char *name)
|
||||
{
|
||||
if (vtoy_class_directory == type)
|
||||
{
|
||||
if (len < node->pathlen && grub_strncmp(name, node->isopath, len) == 0)
|
||||
if (len < node->pathlen && ventoy_strncmp(node->isopath, name, len) == 0)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (len == node->pathlen && grub_strncmp(name, node->isopath, len) == 0)
|
||||
if (len == node->pathlen && ventoy_strncmp(node->isopath, name, len) == 0)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
@@ -2345,7 +2411,7 @@ conf_replace * ventoy_plugin_find_conf_replace(const char *iso)
|
||||
|
||||
for (node = g_conf_replace_head; node; node = node->next)
|
||||
{
|
||||
if (node->pathlen == len && grub_strncmp(iso, node->isopath, len) == 0)
|
||||
if (node->pathlen == len && ventoy_strncmp(node->isopath, iso, len) == 0)
|
||||
{
|
||||
return node;
|
||||
}
|
||||
@@ -2367,7 +2433,7 @@ dud * ventoy_plugin_find_dud(const char *iso)
|
||||
len = (int)grub_strlen(iso);
|
||||
for (node = g_dud_head; node; node = node->next)
|
||||
{
|
||||
if (node->pathlen == len && grub_strncmp(iso, node->isopath, len) == 0)
|
||||
if (node->pathlen == len && ventoy_strncmp(node->isopath, iso, len) == 0)
|
||||
{
|
||||
return node;
|
||||
}
|
||||
@@ -2420,7 +2486,7 @@ static const vtoy_password * ventoy_plugin_get_password(const char *isopath)
|
||||
len = (int)grub_strlen(isopath);
|
||||
for (node = g_pwd_head; node; node = node->next)
|
||||
{
|
||||
if (node->pathlen == len && grub_strncmp(isopath, node->isopath, len) == 0)
|
||||
if (node->pathlen == len && ventoy_strncmp(node->isopath, isopath, len) == 0)
|
||||
{
|
||||
return &(node->password);
|
||||
}
|
||||
|
@@ -720,7 +720,7 @@ grub_err_t ventoy_cmd_unix_fill_image_desc(grub_extcmd_context_t ctxt, int argc,
|
||||
|
||||
desc = (ventoy_image_desc *)(byte + i);
|
||||
desc->disk_size = g_ventoy_disk_size;
|
||||
desc->part1_size = ventoy_get_part1_size(g_ventoy_part_info);
|
||||
desc->part1_size = g_ventoy_disk_part_size[0];
|
||||
grub_memcpy(desc->disk_uuid, g_ventoy_part_info->MBR.BootCode + 0x180, 16);
|
||||
grub_memcpy(desc->disk_signature, g_ventoy_part_info->MBR.BootCode + 0x1B8, 4);
|
||||
|
||||
|
@@ -44,14 +44,12 @@
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
static int g_vhdboot_bcd_offset = 0;
|
||||
static int g_vhdboot_bcd_len = 0;
|
||||
static int g_vhdboot_isolen = 0;
|
||||
static char *g_vhdboot_totbuf = NULL;
|
||||
static char *g_vhdboot_isobuf = NULL;
|
||||
static grub_uint64_t g_img_trim_head_secnum = 0;
|
||||
|
||||
static int ventoy_vhd_find_bcd(int *bcdoffset, int *bcdlen)
|
||||
static int ventoy_vhd_find_bcd(int *bcdoffset, int *bcdlen, const char *path)
|
||||
{
|
||||
grub_uint32_t offset;
|
||||
grub_file_t file;
|
||||
@@ -61,10 +59,9 @@ static int ventoy_vhd_find_bcd(int *bcdoffset, int *bcdlen)
|
||||
|
||||
grub_script_execute_sourcecode(cmdbuf);
|
||||
|
||||
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s", "(vhdiso)/boot/bcd");
|
||||
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "(vhdiso)%s", path);
|
||||
if (!file)
|
||||
{
|
||||
grub_printf("Failed to open bcd file in the image file\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -83,13 +80,15 @@ static int ventoy_vhd_find_bcd(int *bcdoffset, int *bcdlen)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_vhd_patch_path(char *vhdpath, ventoy_patch_vhd *patch1, ventoy_patch_vhd *patch2)
|
||||
static int ventoy_vhd_patch_path(char *vhdpath, ventoy_patch_vhd *patch1, ventoy_patch_vhd *patch2,
|
||||
int bcdoffset, int bcdlen)
|
||||
{
|
||||
int i;
|
||||
int cnt = 0;
|
||||
char *pos;
|
||||
grub_size_t pathlen;
|
||||
const char *plat;
|
||||
char *newpath = NULL;
|
||||
grub_uint16_t *unicode_path;
|
||||
const grub_uint8_t winloadexe[] =
|
||||
{
|
||||
@@ -97,6 +96,11 @@ static int ventoy_vhd_patch_path(char *vhdpath, ventoy_patch_vhd *patch1, ventoy
|
||||
0x65, 0x00, 0x78, 0x00, 0x65, 0x00
|
||||
};
|
||||
|
||||
while ((*vhdpath) != '/')
|
||||
{
|
||||
vhdpath++;
|
||||
}
|
||||
|
||||
pathlen = sizeof(grub_uint16_t) * (grub_strlen(vhdpath) + 1);
|
||||
debug("unicode path for <%s> len:%d\n", vhdpath, (int)pathlen);
|
||||
|
||||
@@ -110,10 +114,10 @@ static int ventoy_vhd_patch_path(char *vhdpath, ventoy_patch_vhd *patch1, ventoy
|
||||
|
||||
if (plat && (plat[0] == 'e')) /* UEFI */
|
||||
{
|
||||
pos = g_vhdboot_isobuf + g_vhdboot_bcd_offset;
|
||||
pos = g_vhdboot_isobuf + bcdoffset;
|
||||
|
||||
/* winload.exe ==> winload.efi */
|
||||
for (i = 0; i + (int)sizeof(winloadexe) < g_vhdboot_bcd_len; i++)
|
||||
for (i = 0; i + (int)sizeof(winloadexe) < bcdlen; i++)
|
||||
{
|
||||
if (*((grub_uint32_t *)(pos + i)) == 0x00690077 &&
|
||||
grub_memcmp(pos + i, winloadexe, sizeof(winloadexe)) == 0)
|
||||
@@ -127,7 +131,8 @@ static int ventoy_vhd_patch_path(char *vhdpath, ventoy_patch_vhd *patch1, ventoy
|
||||
debug("winload patch %d times\n", cnt);
|
||||
}
|
||||
|
||||
for (pos = vhdpath; *pos; pos++)
|
||||
newpath = grub_strdup(vhdpath);
|
||||
for (pos = newpath; *pos; pos++)
|
||||
{
|
||||
if (*pos == '/')
|
||||
{
|
||||
@@ -135,40 +140,159 @@ static int ventoy_vhd_patch_path(char *vhdpath, ventoy_patch_vhd *patch1, ventoy
|
||||
}
|
||||
}
|
||||
|
||||
grub_utf8_to_utf16(unicode_path, pathlen, (grub_uint8_t *)vhdpath, -1, NULL);
|
||||
grub_utf8_to_utf16(unicode_path, pathlen, (grub_uint8_t *)newpath, -1, NULL);
|
||||
grub_memcpy(patch1->vhd_file_path, unicode_path, pathlen);
|
||||
grub_memcpy(patch2->vhd_file_path, unicode_path, pathlen);
|
||||
|
||||
grub_free(newpath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_vhd_patch_disk(ventoy_patch_vhd *patch1, ventoy_patch_vhd *patch2)
|
||||
static int ventoy_vhd_read_parttbl(const char *filename, ventoy_gpt_info *gpt, int *index)
|
||||
{
|
||||
int i;
|
||||
int ret = 1;
|
||||
grub_uint64_t start;
|
||||
grub_file_t file = NULL;
|
||||
grub_disk_t disk = NULL;
|
||||
grub_uint8_t zeroguid[16] = {0};
|
||||
|
||||
file = grub_file_open(filename, VENTOY_FILE_TYPE);
|
||||
if (!file)
|
||||
{
|
||||
goto end;
|
||||
}
|
||||
|
||||
disk = grub_disk_open(file->device->disk->name);
|
||||
if (!disk)
|
||||
{
|
||||
goto end;
|
||||
}
|
||||
|
||||
grub_disk_read(disk, 0, 0, sizeof(ventoy_gpt_info), gpt);
|
||||
|
||||
start = file->device->disk->partition->start;
|
||||
|
||||
if (grub_memcmp(gpt->Head.Signature, "EFI PART", 8) == 0)
|
||||
{
|
||||
debug("GPT part start: %llu\n", (ulonglong)start);
|
||||
for (i = 0; i < 128; i++)
|
||||
{
|
||||
if (grub_memcmp(gpt->PartTbl[i].PartGuid, zeroguid, 16))
|
||||
{
|
||||
if (start == gpt->PartTbl[i].StartLBA)
|
||||
{
|
||||
*index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("MBR part start: %llu\n", (ulonglong)start);
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if ((grub_uint32_t)start == gpt->MBR.PartTbl[i].StartSectorId)
|
||||
{
|
||||
*index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
end:
|
||||
check_free(file, grub_file_close);
|
||||
check_free(disk, grub_disk_close);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ventoy_vhd_patch_disk(const char *vhdpath, ventoy_patch_vhd *patch1, ventoy_patch_vhd *patch2)
|
||||
{
|
||||
int partIndex = 0;
|
||||
grub_uint64_t offset = 0;
|
||||
char efipart[16] = {0};
|
||||
ventoy_gpt_info *gpt = NULL;
|
||||
|
||||
grub_memcpy(efipart, g_ventoy_part_info->Head.Signature, sizeof(g_ventoy_part_info->Head.Signature));
|
||||
if (vhdpath[0] == '/')
|
||||
{
|
||||
gpt = g_ventoy_part_info;
|
||||
partIndex = 0;
|
||||
debug("This is Ventoy ISO partIndex %d %s\n", partIndex, vhdpath);
|
||||
}
|
||||
else
|
||||
{
|
||||
gpt = grub_zalloc(sizeof(ventoy_gpt_info));
|
||||
ventoy_vhd_read_parttbl(vhdpath, gpt, &partIndex);
|
||||
debug("This is HDD partIndex %d %s\n", partIndex, vhdpath);
|
||||
}
|
||||
|
||||
debug("part1 type: 0x%x <%s>\n", g_ventoy_part_info->MBR.PartTbl[0].FsFlag, efipart);
|
||||
grub_memcpy(efipart, gpt->Head.Signature, sizeof(gpt->Head.Signature));
|
||||
|
||||
grub_memset(patch1, 0, OFFSET_OF(ventoy_patch_vhd, vhd_file_path));
|
||||
grub_memset(patch2, 0, OFFSET_OF(ventoy_patch_vhd, vhd_file_path));
|
||||
|
||||
if (grub_strncmp(efipart, "EFI PART", 8) == 0)
|
||||
{
|
||||
ventoy_debug_dump_guid("GPT disk GUID: ", g_ventoy_part_info->Head.DiskGuid);
|
||||
ventoy_debug_dump_guid("GPT part GUID: ", g_ventoy_part_info->PartTbl[0].PartGuid);
|
||||
ventoy_debug_dump_guid("GPT disk GUID: ", gpt->Head.DiskGuid);
|
||||
ventoy_debug_dump_guid("GPT partIndex GUID: ", gpt->PartTbl[partIndex].PartGuid);
|
||||
|
||||
grub_memcpy(patch1->disk_signature_or_guid, g_ventoy_part_info->Head.DiskGuid, 16);
|
||||
grub_memcpy(patch1->part_offset_or_guid, g_ventoy_part_info->PartTbl[0].PartGuid, 16);
|
||||
grub_memcpy(patch2->disk_signature_or_guid, g_ventoy_part_info->Head.DiskGuid, 16);
|
||||
grub_memcpy(patch2->part_offset_or_guid, g_ventoy_part_info->PartTbl[0].PartGuid, 16);
|
||||
grub_memcpy(patch1->disk_signature_or_guid, gpt->Head.DiskGuid, 16);
|
||||
grub_memcpy(patch1->part_offset_or_guid, gpt->PartTbl[partIndex].PartGuid, 16);
|
||||
grub_memcpy(patch2->disk_signature_or_guid, gpt->Head.DiskGuid, 16);
|
||||
grub_memcpy(patch2->part_offset_or_guid, gpt->PartTbl[partIndex].PartGuid, 16);
|
||||
|
||||
patch1->part_type = patch2->part_type = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("MBR disk signature: %02x%02x%02x%02x\n",
|
||||
g_ventoy_part_info->MBR.BootCode[0x1b8 + 0], g_ventoy_part_info->MBR.BootCode[0x1b8 + 1],
|
||||
g_ventoy_part_info->MBR.BootCode[0x1b8 + 2], g_ventoy_part_info->MBR.BootCode[0x1b8 + 3]);
|
||||
grub_memcpy(patch1->disk_signature_or_guid, g_ventoy_part_info->MBR.BootCode + 0x1b8, 4);
|
||||
grub_memcpy(patch2->disk_signature_or_guid, g_ventoy_part_info->MBR.BootCode + 0x1b8, 4);
|
||||
offset = gpt->MBR.PartTbl[partIndex].StartSectorId;
|
||||
offset *= 512;
|
||||
|
||||
debug("MBR disk signature: %02x%02x%02x%02x Part(%d) offset:%llu\n",
|
||||
gpt->MBR.BootCode[0x1b8 + 0], gpt->MBR.BootCode[0x1b8 + 1],
|
||||
gpt->MBR.BootCode[0x1b8 + 2], gpt->MBR.BootCode[0x1b8 + 3],
|
||||
partIndex + 1, offset);
|
||||
|
||||
grub_memcpy(patch1->part_offset_or_guid, &offset, 8);
|
||||
grub_memcpy(patch2->part_offset_or_guid, &offset, 8);
|
||||
|
||||
grub_memcpy(patch1->disk_signature_or_guid, gpt->MBR.BootCode + 0x1b8, 4);
|
||||
grub_memcpy(patch2->disk_signature_or_guid, gpt->MBR.BootCode + 0x1b8, 4);
|
||||
|
||||
patch1->part_type = patch2->part_type = 1;
|
||||
}
|
||||
|
||||
if (gpt != g_ventoy_part_info)
|
||||
{
|
||||
grub_free(gpt);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_find_vhdpatch_offset(int bcdoffset, int bcdlen, int *offset)
|
||||
{
|
||||
int i;
|
||||
int cnt = 0;
|
||||
grub_uint8_t *buf = (grub_uint8_t *)(g_vhdboot_isobuf + bcdoffset);
|
||||
grub_uint8_t magic[16] = {
|
||||
0x5C, 0x00, 0x58, 0x00, 0x58, 0x00, 0x58, 0x00, 0x58, 0x00, 0x58, 0x00, 0x58, 0x00, 0x58, 0x00
|
||||
};
|
||||
|
||||
for (i = 0; i < bcdlen - 16 && cnt < 2; i++)
|
||||
{
|
||||
if (*(grub_uint32_t *)(buf + i) == 0x0058005C)
|
||||
{
|
||||
if (grub_memcmp(magic, buf + i, 16) == 0)
|
||||
{
|
||||
*offset++ = i - (int)OFFSET_OF(ventoy_patch_vhd, vhd_file_path);
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -177,6 +301,8 @@ static int ventoy_vhd_patch_disk(ventoy_patch_vhd *patch1, ventoy_patch_vhd *pat
|
||||
grub_err_t ventoy_cmd_patch_vhdboot(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int rc;
|
||||
int bcdoffset, bcdlen;
|
||||
int patchoffset[2];
|
||||
ventoy_patch_vhd *patch1;
|
||||
ventoy_patch_vhd *patch2;
|
||||
char envbuf[64];
|
||||
@@ -194,18 +320,39 @@ grub_err_t ventoy_cmd_patch_vhdboot(grub_extcmd_context_t ctxt, int argc, char *
|
||||
return 0;
|
||||
}
|
||||
|
||||
rc = ventoy_vhd_find_bcd(&g_vhdboot_bcd_offset, &g_vhdboot_bcd_len);
|
||||
rc = ventoy_vhd_find_bcd(&bcdoffset, &bcdlen, "/boot/bcd");
|
||||
if (rc)
|
||||
{
|
||||
debug("failed to get bcd location %d\n", rc);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ventoy_find_vhdpatch_offset(bcdoffset, bcdlen, patchoffset);
|
||||
patch1 = (ventoy_patch_vhd *)(g_vhdboot_isobuf + bcdoffset + patchoffset[0]);
|
||||
patch2 = (ventoy_patch_vhd *)(g_vhdboot_isobuf + bcdoffset + patchoffset[1]);
|
||||
|
||||
debug("Find /boot/bcd (%d %d) now patch it (offset: 0x%x 0x%x) ...\n",
|
||||
bcdoffset, bcdlen, patchoffset[0], patchoffset[1]);
|
||||
ventoy_vhd_patch_disk(args[0], patch1, patch2);
|
||||
ventoy_vhd_patch_path(args[0], patch1, patch2, bcdoffset, bcdlen);
|
||||
}
|
||||
|
||||
patch1 = (ventoy_patch_vhd *)(g_vhdboot_isobuf + g_vhdboot_bcd_offset + 0x495a);
|
||||
patch2 = (ventoy_patch_vhd *)(g_vhdboot_isobuf + g_vhdboot_bcd_offset + 0x50aa);
|
||||
|
||||
ventoy_vhd_patch_disk(patch1, patch2);
|
||||
ventoy_vhd_patch_path(args[0], patch1, patch2);
|
||||
rc = ventoy_vhd_find_bcd(&bcdoffset, &bcdlen, "/boot/BCD");
|
||||
if (rc)
|
||||
{
|
||||
debug("No file /boot/BCD \n");
|
||||
}
|
||||
else
|
||||
{
|
||||
ventoy_find_vhdpatch_offset(bcdoffset, bcdlen, patchoffset);
|
||||
patch1 = (ventoy_patch_vhd *)(g_vhdboot_isobuf + bcdoffset + patchoffset[0]);
|
||||
patch2 = (ventoy_patch_vhd *)(g_vhdboot_isobuf + bcdoffset + patchoffset[1]);
|
||||
|
||||
debug("Find /boot/BCD (%d %d) now patch it (offset: 0x%x 0x%x) ...\n",
|
||||
bcdoffset, bcdlen, patchoffset[0], patchoffset[1]);
|
||||
ventoy_vhd_patch_disk(args[0], patch1, patch2);
|
||||
ventoy_vhd_patch_path(args[0], patch1, patch2, bcdoffset, bcdlen);
|
||||
}
|
||||
|
||||
/* set buffer and size */
|
||||
#ifdef GRUB_MACHINE_EFI
|
||||
@@ -220,7 +367,7 @@ grub_err_t ventoy_cmd_patch_vhdboot(grub_extcmd_context_t ctxt, int argc, char *
|
||||
grub_env_set("vtoy_vhd_buf_size", envbuf);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_load_vhdboot(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
|
@@ -153,6 +153,8 @@ ventoy_get_os_type() {
|
||||
echo 'rhel7'; return
|
||||
elif $GREP -q 'openEuler' /etc/os-release; then
|
||||
echo 'openEuler'; return
|
||||
elif $GREP -q 'fuyu' /etc/os-release; then
|
||||
echo 'openEuler'; return
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@@ -198,6 +198,8 @@ ventoy_get_os_type() {
|
||||
echo 'rhel7'; return
|
||||
elif $GREP -q 'openEuler' /etc/os-release; then
|
||||
echo 'openEuler'; return
|
||||
elif $GREP -q 'fuyu' /etc/os-release; then
|
||||
echo 'openEuler'; return
|
||||
fi
|
||||
fi
|
||||
|
||||
|
Binary file not shown.
@@ -1,7 +1,7 @@
|
||||
|
||||
source $prefix/keyboard.cfg
|
||||
|
||||
submenu "Resolution Configuration" --class=debug_resolution {
|
||||
submenu "Resolution Configuration" --class=debug_resolution --class=F5tool {
|
||||
menuentry 'Return to previous menu [Esc]' --class=vtoyret VTOY_RET {
|
||||
echo 'Return ...'
|
||||
}
|
||||
@@ -16,7 +16,7 @@ submenu "Resolution Configuration" --class=debug_resolution {
|
||||
set vtActive="[*]"
|
||||
fi
|
||||
|
||||
menuentry "$vtCurMode $vtActive" --class=debug_videomode VTOY_RUN_RET {
|
||||
menuentry "$vtCurMode $vtActive" --class=debug_videomode --class=debug_resolution --class=F5tool VTOY_RUN_RET {
|
||||
terminal_output console
|
||||
set gfxmode=$1
|
||||
terminal_output gfxterm
|
||||
@@ -26,11 +26,11 @@ submenu "Resolution Configuration" --class=debug_resolution {
|
||||
done
|
||||
}
|
||||
|
||||
submenu "Screen Display Mode" --class=debug_screen_mode {
|
||||
menuentry 'Force Text Mode' --class=debug_text_mode {
|
||||
submenu "Screen Display Mode" --class=debug_screen_mode --class=F5tool {
|
||||
menuentry 'Force Text Mode' --class=debug_text_mode --class=debug_screen_mode --class=F5tool {
|
||||
terminal_output console
|
||||
}
|
||||
menuentry 'Force Graphics Mode' --class=debug_gui_mode {
|
||||
menuentry 'Force Graphics Mode' --class=debug_gui_mode --class=debug_screen_mode --class=F5tool {
|
||||
terminal_output gfxterm
|
||||
}
|
||||
menuentry 'Return to previous menu [Esc]' --class=vtoyret VTOY_RET {
|
||||
@@ -39,8 +39,8 @@ submenu "Screen Display Mode" --class=debug_screen_mode {
|
||||
}
|
||||
|
||||
if [ "$grub_platform" != "pc" ]; then
|
||||
submenu 'Ventoy UEFI Utilities' --class=debug_util {
|
||||
menuentry 'Fixup Windows BlinitializeLibrary Failure' --class=debug_util_blinit {
|
||||
submenu 'Ventoy UEFI Utilities' --class=debug_util --class=F5tool {
|
||||
menuentry 'Fixup Windows BlinitializeLibrary Failure' --class=debug_util_blinit --class=debug_util --class=F5tool {
|
||||
chainloader ${vtoy_path}/vtoyutil_${VTOY_EFI_ARCH}.efi env_param=${env_param} ${vtdebug_flag} feature=fix_windows_mmap
|
||||
boot
|
||||
echo -e "\npress ENTER to exit ..."
|
||||
@@ -54,8 +54,8 @@ if [ "$grub_platform" != "pc" ]; then
|
||||
fi
|
||||
|
||||
|
||||
submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
|
||||
menuentry 'Check global control plugin configuration' --class=debug_control {
|
||||
submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json --class=F5tool {
|
||||
menuentry 'Check global control plugin configuration' --class=debug_control --class=debug_json --class=F5tool {
|
||||
set pager=1
|
||||
vt_check_plugin_json $vt_plugin_path control $vtoy_iso_part
|
||||
|
||||
@@ -64,7 +64,7 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
|
||||
unset pager
|
||||
}
|
||||
|
||||
menuentry 'Check theme plugin configuration' --class=debug_theme {
|
||||
menuentry 'Check theme plugin configuration' --class=debug_theme --class=debug_json --class=F5tool {
|
||||
set pager=1
|
||||
vt_check_plugin_json $vt_plugin_path theme $vtoy_iso_part
|
||||
|
||||
@@ -73,7 +73,7 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
|
||||
unset pager
|
||||
}
|
||||
|
||||
menuentry 'Check auto install plugin configuration' --class=debug_autoinstall {
|
||||
menuentry 'Check auto install plugin configuration' --class=debug_autoinstall --class=debug_json --class=F5tool {
|
||||
set pager=1
|
||||
vt_check_plugin_json $vt_plugin_path auto_install $vtoy_iso_part
|
||||
|
||||
@@ -82,7 +82,7 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
|
||||
unset pager
|
||||
}
|
||||
|
||||
menuentry 'Check persistence plugin configuration' --class=debug_persistence {
|
||||
menuentry 'Check persistence plugin configuration' --class=debug_persistence --class=debug_json --class=F5tool {
|
||||
set pager=1
|
||||
vt_check_plugin_json $vt_plugin_path persistence $vtoy_iso_part
|
||||
|
||||
@@ -94,7 +94,7 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
|
||||
unset pager
|
||||
}
|
||||
|
||||
menuentry 'Check menu alias plugin configuration' --class=debug_menualias {
|
||||
menuentry 'Check menu alias plugin configuration' --class=debug_menualias --class=debug_json --class=F5tool {
|
||||
set pager=1
|
||||
vt_check_plugin_json $vt_plugin_path menu_alias $vtoy_iso_part
|
||||
|
||||
@@ -103,7 +103,7 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
|
||||
unset pager
|
||||
}
|
||||
|
||||
menuentry 'Check menu class plugin configuration' --class=debug_menuclass {
|
||||
menuentry 'Check menu class plugin configuration' --class=debug_menuclass --class=debug_json --class=F5tool {
|
||||
set pager=1
|
||||
vt_check_plugin_json $vt_plugin_path menu_class $vtoy_iso_part
|
||||
|
||||
@@ -112,7 +112,7 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
|
||||
unset pager
|
||||
}
|
||||
|
||||
menuentry 'Check injection plugin configuration' --class=debug_injection {
|
||||
menuentry 'Check injection plugin configuration' --class=debug_injection --class=debug_json --class=F5tool {
|
||||
set pager=1
|
||||
vt_check_plugin_json $vt_plugin_path injection $vtoy_iso_part
|
||||
|
||||
@@ -121,7 +121,7 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
|
||||
unset pager
|
||||
}
|
||||
|
||||
menuentry 'Check auto memdisk plugin configuration' --class=debug_automemdisk {
|
||||
menuentry 'Check auto memdisk plugin configuration' --class=debug_automemdisk --class=debug_json --class=F5tool {
|
||||
set pager=1
|
||||
vt_check_plugin_json $vt_plugin_path auto_memdisk $vtoy_iso_part
|
||||
|
||||
@@ -130,7 +130,7 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
|
||||
unset pager
|
||||
}
|
||||
|
||||
menuentry 'Check image list plugin configuration' --class=debug_imagelist {
|
||||
menuentry 'Check image list plugin configuration' --class=debug_imagelist --class=debug_json --class=F5tool {
|
||||
set pager=1
|
||||
vt_check_plugin_json $vt_plugin_path image_list $vtoy_iso_part
|
||||
|
||||
@@ -139,7 +139,7 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
|
||||
unset pager
|
||||
}
|
||||
|
||||
menuentry 'Check image blacklist plugin configuration' --class=debug_imageblacklist {
|
||||
menuentry 'Check image blacklist plugin configuration' --class=debug_imageblacklist --class=debug_json --class=F5tool {
|
||||
set pager=1
|
||||
vt_check_plugin_json $vt_plugin_path image_blacklist $vtoy_iso_part
|
||||
|
||||
@@ -148,7 +148,7 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
|
||||
unset pager
|
||||
}
|
||||
|
||||
menuentry 'Check boot conf replace plugin configuration' --class=debug_bootconf_replace {
|
||||
menuentry 'Check boot conf replace plugin configuration' --class=debug_bootconf_replace --class=debug_json --class=F5tool {
|
||||
set pager=1
|
||||
vt_check_plugin_json $vt_plugin_path conf_replace $vtoy_iso_part
|
||||
|
||||
@@ -157,7 +157,7 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
|
||||
unset pager
|
||||
}
|
||||
|
||||
menuentry 'Check dud plugin configuration' --class=debug_dud {
|
||||
menuentry 'Check dud plugin configuration' --class=debug_dud --class=debug_json --class=F5tool {
|
||||
set pager=1
|
||||
vt_check_plugin_json $vt_plugin_path dud $vtoy_iso_part
|
||||
|
||||
@@ -166,7 +166,7 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
|
||||
unset pager
|
||||
}
|
||||
|
||||
menuentry 'Check password plugin configuration' --class=debug_pwd {
|
||||
menuentry 'Check password plugin configuration' --class=debug_pwd --class=debug_json --class=F5tool {
|
||||
set pager=1
|
||||
vt_check_plugin_json $vt_plugin_path password $vtoy_iso_part
|
||||
|
||||
@@ -175,7 +175,7 @@ submenu 'Check plugin json configuration (ventoy.json)' --class=debug_json {
|
||||
unset pager
|
||||
}
|
||||
|
||||
menuentry 'Check custom boot plugin configuration' --class=debug_custom_boot {
|
||||
menuentry 'Check custom boot plugin configuration' --class=debug_custom_boot --class=debug_json --class=F5tool {
|
||||
set pager=1
|
||||
vt_check_plugin_json $vt_plugin_path custom_boot $vtoy_iso_part
|
||||
|
||||
|
@@ -131,7 +131,7 @@ function get_os_type {
|
||||
function vt_check_compatible_pe {
|
||||
#Check for PE without external tools
|
||||
if [ -f "$1/HBCD_PE.ini" ]; then
|
||||
set ventoy_compatible=YES
|
||||
set ventoy_compatible=YES
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -1230,6 +1230,30 @@ function efi_unsupport_menuentry {
|
||||
common_unsupport_menuentry
|
||||
}
|
||||
|
||||
function vhdboot_common_func {
|
||||
vt_patch_vhdboot "$1"
|
||||
|
||||
ventoy_debug_pause
|
||||
|
||||
if [ -n "$vtoy_vhd_buf_addr" ]; then
|
||||
if [ "$grub_platform" = "pc" ]; then
|
||||
ventoy_cli_console
|
||||
linux16 $vtoy_path/memdisk iso raw
|
||||
initrd16 mem:${vtoy_vhd_buf_addr}:size:${vtoy_vhd_buf_size}
|
||||
boot
|
||||
ventoy_gui_console
|
||||
else
|
||||
ventoy_cli_console
|
||||
chainloader ${vtoy_path}/ventoy_${VTOY_EFI_ARCH}.efi memdisk env_param=${env_param} isoefi=${LoadIsoEfiDriver} ${vtdebug_flag} mem:${vtoy_vhd_buf_addr}:size:${vtoy_vhd_buf_size}
|
||||
boot
|
||||
ventoy_gui_console
|
||||
fi
|
||||
else
|
||||
echo "Please put the right ventoy_vhdboot.img file to the 1st partition"
|
||||
ventoy_pause
|
||||
fi
|
||||
}
|
||||
|
||||
function vhd_common_menuentry {
|
||||
|
||||
if [ "$VTOY_VHD_NO_WARNING" != "1" ]; then
|
||||
@@ -1252,25 +1276,7 @@ function vhd_common_menuentry {
|
||||
return
|
||||
fi
|
||||
|
||||
vt_patch_vhdboot "$vt_chosen_path"
|
||||
|
||||
ventoy_debug_pause
|
||||
|
||||
if [ -n "$vtoy_vhd_buf_addr" ]; then
|
||||
if [ "$grub_platform" = "pc" ]; then
|
||||
linux16 $vtoy_path/memdisk iso raw
|
||||
initrd16 mem:${vtoy_vhd_buf_addr}:size:${vtoy_vhd_buf_size}
|
||||
boot
|
||||
else
|
||||
ventoy_cli_console
|
||||
chainloader ${vtoy_path}/ventoy_${VTOY_EFI_ARCH}.efi memdisk env_param=${env_param} isoefi=${LoadIsoEfiDriver} ${vtdebug_flag} mem:${vtoy_vhd_buf_addr}:size:${vtoy_vhd_buf_size}
|
||||
boot
|
||||
ventoy_gui_console
|
||||
fi
|
||||
else
|
||||
echo "Please put the right ventoy_vhdboot.img file to the 1st partition"
|
||||
ventoy_pause
|
||||
fi
|
||||
vhdboot_common_func "${vt_chosen_path}"
|
||||
}
|
||||
|
||||
function vhd_unsupport_menuentry {
|
||||
@@ -1702,7 +1708,7 @@ function img_unsupport_menuentry {
|
||||
#############################################################
|
||||
#############################################################
|
||||
|
||||
set VENTOY_VERSION="1.0.41"
|
||||
set VENTOY_VERSION="1.0.43"
|
||||
|
||||
#ACPI not compatible with Window7/8, so disable by default
|
||||
set VTOY_PARAM_NO_ACPI=1
|
||||
|
@@ -1,62 +1,62 @@
|
||||
submenu "Keyboard Layouts" --class=debug_krdlayout {
|
||||
menuentry QWERTY_USA --class=debug_kbd {
|
||||
submenu "Keyboard Layouts" --class=debug_krdlayout --class=F5tool {
|
||||
menuentry QWERTY_USA --class=debug_kbd --class=debug_krdlayout --class=F5tool {
|
||||
set_keyboard_layout QWERTY_USA
|
||||
}
|
||||
menuentry AZERTY --class=debug_kbd {
|
||||
menuentry AZERTY --class=debug_kbd --class=debug_krdlayout --class=F5tool {
|
||||
set_keyboard_layout AZERTY
|
||||
}
|
||||
menuentry CZECH_QWERTY --class=debug_kbd {
|
||||
menuentry CZECH_QWERTY --class=debug_kbd --class=debug_krdlayout --class=F5tool {
|
||||
set_keyboard_layout CZECH_QWERTY
|
||||
}
|
||||
menuentry CZECH_QWERTZ --class=debug_kbd {
|
||||
menuentry CZECH_QWERTZ --class=debug_kbd --class=debug_krdlayout --class=F5tool {
|
||||
set_keyboard_layout CZECH_QWERTZ
|
||||
}
|
||||
menuentry DANISH --class=debug_kbd {
|
||||
menuentry DANISH --class=debug_kbd --class=debug_krdlayout --class=F5tool {
|
||||
set_keyboard_layout DANISH
|
||||
}
|
||||
menuentry DVORAK_USA --class=debug_kbd {
|
||||
menuentry DVORAK_USA --class=debug_kbd --class=debug_krdlayout --class=F5tool {
|
||||
set_keyboard_layout DVORAK_USA
|
||||
}
|
||||
menuentry FRENCH --class=debug_kbd {
|
||||
menuentry FRENCH --class=debug_kbd --class=debug_krdlayout --class=F5tool {
|
||||
set_keyboard_layout FRENCH
|
||||
}
|
||||
menuentry GERMAN --class=debug_kbd {
|
||||
menuentry GERMAN --class=debug_kbd --class=debug_krdlayout --class=F5tool {
|
||||
set_keyboard_layout GERMAN
|
||||
}
|
||||
menuentry ITALIANO --class=debug_kbd {
|
||||
menuentry ITALIANO --class=debug_kbd --class=debug_krdlayout --class=F5tool {
|
||||
set_keyboard_layout ITALIANO
|
||||
}
|
||||
menuentry JAPAN_106 --class=debug_kbd {
|
||||
menuentry JAPAN_106 --class=debug_kbd --class=debug_krdlayout --class=F5tool {
|
||||
set_keyboard_layout JAPAN_106
|
||||
}
|
||||
menuentry LATIN_USA --class=debug_kbd {
|
||||
menuentry LATIN_USA --class=debug_kbd --class=debug_krdlayout --class=F5tool {
|
||||
set_keyboard_layout LATIN_USA
|
||||
}
|
||||
menuentry PORTU_BRAZIL --class=debug_kbd {
|
||||
menuentry PORTU_BRAZIL --class=debug_kbd --class=debug_krdlayout --class=F5tool {
|
||||
set_keyboard_layout PORTU_BRAZIL
|
||||
}
|
||||
menuentry QWERTY_UK --class=debug_kbd {
|
||||
menuentry QWERTY_UK --class=debug_kbd --class=debug_krdlayout --class=F5tool {
|
||||
set_keyboard_layout QWERTY_UK
|
||||
}
|
||||
menuentry QWERTZ --class=debug_kbd {
|
||||
menuentry QWERTZ --class=debug_kbd --class=debug_krdlayout --class=F5tool {
|
||||
set_keyboard_layout QWERTZ
|
||||
}
|
||||
menuentry QWERTZ_HUN --class=debug_kbd {
|
||||
menuentry QWERTZ_HUN --class=debug_kbd --class=debug_krdlayout --class=F5tool {
|
||||
set_keyboard_layout QWERTZ_HUN
|
||||
}
|
||||
menuentry QWERTZ_SLOV_CROAT --class=debug_kbd {
|
||||
menuentry QWERTZ_SLOV_CROAT --class=debug_kbd --class=debug_krdlayout --class=F5tool {
|
||||
set_keyboard_layout QWERTZ_SLOV_CROAT
|
||||
}
|
||||
menuentry SPANISH --class=debug_kbd {
|
||||
menuentry SPANISH --class=debug_kbd --class=debug_krdlayout --class=F5tool {
|
||||
set_keyboard_layout SPANISH
|
||||
}
|
||||
menuentry SWEDISH --class=debug_kbd {
|
||||
menuentry SWEDISH --class=debug_kbd --class=debug_krdlayout --class=F5tool {
|
||||
set_keyboard_layout SWEDISH
|
||||
}
|
||||
menuentry TURKISH_Q --class=debug_kbd {
|
||||
menuentry TURKISH_Q --class=debug_kbd --class=debug_krdlayout --class=F5tool {
|
||||
set_keyboard_layout TURKISH_Q
|
||||
}
|
||||
menuentry VIETNAMESE --class=debug_kbd {
|
||||
menuentry VIETNAMESE --class=debug_kbd --class=debug_krdlayout --class=F5tool {
|
||||
set_keyboard_layout VIETNAMESE
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
|
||||
if [ "$grub_platform" = "pc" ]; then
|
||||
menuentry 'Search and boot Windows' --class=boot_windows {
|
||||
menuentry 'Search and boot Windows' --class=boot_windows --class=F4boot {
|
||||
|
||||
set partid=3
|
||||
while [ $partid -le 128 ]; do
|
||||
@@ -38,7 +38,7 @@ if [ "$grub_platform" = "pc" ]; then
|
||||
fi
|
||||
}
|
||||
|
||||
menuentry 'Search and boot Grub4dos' --class=boot_g4d {
|
||||
menuentry 'Search and boot Grub4dos' --class=boot_g4d --class=F4boot {
|
||||
if search -n -s -f /grldr; then
|
||||
ntldr /grldr
|
||||
else
|
||||
@@ -46,19 +46,19 @@ if [ "$grub_platform" = "pc" ]; then
|
||||
fi
|
||||
}
|
||||
|
||||
menuentry 'Boot the 1st local disk' --class=boot_disk {
|
||||
menuentry 'Boot the 1st local disk' --class=boot_disk --class=F4boot {
|
||||
set root=(hd0,1)
|
||||
chainloader +1
|
||||
boot
|
||||
}
|
||||
|
||||
menuentry 'Boot the 2nd local disk' --class=boot_disk {
|
||||
menuentry 'Boot the 2nd local disk' --class=boot_disk --class=F4boot {
|
||||
set root=(hd1,1)
|
||||
chainloader +1
|
||||
boot
|
||||
}
|
||||
|
||||
menuentry 'Boot the 3rd local disk' --class=boot_disk {
|
||||
menuentry 'Boot the 3rd local disk' --class=boot_disk --class=F4boot {
|
||||
set root=(hd2,1)
|
||||
chainloader +1
|
||||
boot
|
||||
@@ -66,7 +66,7 @@ if [ "$grub_platform" = "pc" ]; then
|
||||
|
||||
else
|
||||
|
||||
menuentry 'Search and boot Windows' --class=boot_windows {
|
||||
menuentry 'Search and boot Windows' --class=boot_windows --class=F4boot {
|
||||
|
||||
set partid=3
|
||||
while [ $partid -le 128 ]; do
|
||||
@@ -93,7 +93,7 @@ else
|
||||
}
|
||||
|
||||
if [ "$grub_cpu" = "i386" ]; then
|
||||
menuentry 'Search and boot BOOTIA32.EFI' --class=boot_uefi {
|
||||
menuentry 'Search and boot BOOTIA32.EFI' --class=boot_uefi --class=F4boot {
|
||||
set VTOY_SEARCH_NO_VTOYEFI=1
|
||||
if search -n -s -f /efi/boot/bootia32.efi; then
|
||||
unset VTOY_SEARCH_NO_VTOYEFI
|
||||
@@ -106,7 +106,7 @@ else
|
||||
fi
|
||||
}
|
||||
elif [ "$grub_cpu" = "arm64" ]; then
|
||||
menuentry 'Search and boot BOOTAA64.EFI' --class=boot_uefi {
|
||||
menuentry 'Search and boot BOOTAA64.EFI' --class=boot_uefi --class=F4boot {
|
||||
set VTOY_SEARCH_NO_VTOYEFI=1
|
||||
if search -n -s -f /efi/boot/bootaa64.efi; then
|
||||
unset VTOY_SEARCH_NO_VTOYEFI
|
||||
@@ -119,7 +119,7 @@ else
|
||||
fi
|
||||
}
|
||||
else
|
||||
menuentry 'Search and boot BOOTX64.EFI' --class=boot_uefi {
|
||||
menuentry 'Search and boot BOOTX64.EFI' --class=boot_uefi --class=F4boot {
|
||||
set VTOY_SEARCH_NO_VTOYEFI=1
|
||||
if search -n -s -f /efi/boot/bootx64.efi; then
|
||||
unset VTOY_SEARCH_NO_VTOYEFI
|
||||
|
@@ -365,11 +365,15 @@ else
|
||||
|
||||
oldver=$(get_disk_ventoy_version $DISK)
|
||||
if [ $? -ne 0 ]; then
|
||||
vtwarn "$DISK does not contain Ventoy or data corrupted"
|
||||
echo ""
|
||||
vtwarn "Please use -i option if you want to install ventoy to $DISK"
|
||||
echo ""
|
||||
exit 1
|
||||
if is_disk_contains_ventoy $DISK; then
|
||||
oldver="Unknown"
|
||||
else
|
||||
vtwarn "$DISK does not contain Ventoy or data corrupted"
|
||||
echo ""
|
||||
vtwarn "Please use -i option if you want to install ventoy to $DISK"
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
#reserve secure boot option
|
||||
|
@@ -151,7 +151,7 @@ tar -czvf ventoy-${curver}-linux.tar.gz $tmpdir
|
||||
|
||||
rm -f ventoy-${curver}-windows.zip
|
||||
cp $OPT Ventoy2Disk*.exe $tmpdir/
|
||||
cp $OPT $LANG_DIR/languages.ini $tmpdir/ventoy/
|
||||
cp $OPT $LANG_DIR/languages.json $tmpdir/ventoy/
|
||||
rm -rf $tmpdir/tool
|
||||
rm -f $tmpdir/*.sh
|
||||
rm -rf $tmpdir/WebUI
|
||||
|
17
LANGUAGES/README
Normal file
17
LANGUAGES/README
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
File encoding: UTF-8
|
||||
|
||||
language name must in the format: "Language-XXX (YYY)"
|
||||
1. Language- fixed 9 characters
|
||||
2. XXX: name in English
|
||||
3. a space (ASCII: 0x20)
|
||||
4. a left brace (ASCII: 0x28)
|
||||
5. YYY: name in the specified language
|
||||
6. a right brace (ASCII: 0x29)
|
||||
|
||||
string translation:
|
||||
all the String Define
|
||||
#@ will be replaced with \r\n
|
||||
|
||||
All the languages will be sorted by the name
|
||||
|
17
LANGUAGES/check.sh
Normal file
17
LANGUAGES/check.sh
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
VTOY_PATH=$1
|
||||
|
||||
if [ ! -f $VTOY_PATH/LANGUAGES/languages.json ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
gcc -DFOR_VTOY_JSON_CHECK $VTOY_PATH/Ventoy2Disk/Ventoy2Disk/VentoyJson.c -I $VTOY_PATH/Ventoy2Disk/Ventoy2Disk/ -o checkjson
|
||||
|
||||
./checkjson $VTOY_PATH/LANGUAGES/languages.json
|
||||
ret=$?
|
||||
|
||||
rm -f ./checkjson
|
||||
[ $ret -eq 0 ]
|
||||
|
||||
|
Binary file not shown.
1741
LANGUAGES/languages.json
Normal file
1741
LANGUAGES/languages.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -514,6 +514,8 @@ int ventoy_get_vtoy_data(ventoy_disk *info, int *ppartstyle)
|
||||
vdebug("ventoy partition layout check OK: [%llu %llu] [%llu %llu]\n",
|
||||
part1_start_sector, part1_sector_count, part2_start_sector, part2_sector_count);
|
||||
|
||||
vtoy->ventoy_valid = 1;
|
||||
|
||||
vdebug("now check secure boot for %s ...\n", info->disk_path);
|
||||
|
||||
g_fatlib_media_fd = fd;
|
||||
@@ -526,7 +528,6 @@ int ventoy_get_vtoy_data(ventoy_disk *info, int *ppartstyle)
|
||||
if (ret == 0 && vtoy->ventoy_ver[0])
|
||||
{
|
||||
vtoy->secure_boot_flag = fatlib_is_secure_boot_enable();
|
||||
vtoy->ventoy_valid = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -542,6 +543,11 @@ int ventoy_get_vtoy_data(ventoy_disk *info, int *ppartstyle)
|
||||
g_fatlib_media_fd = -1;
|
||||
g_fatlib_media_offset = 0;
|
||||
|
||||
if (vtoy->ventoy_ver[0] == 0)
|
||||
{
|
||||
vtoy->ventoy_ver[0] = '?';
|
||||
}
|
||||
|
||||
if (0 == vtoy->ventoy_valid)
|
||||
{
|
||||
goto end;
|
||||
|
@@ -1,37 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "generating languages.js ..."
|
||||
VTOY_PATH=$PWD/../
|
||||
|
||||
iconv -f utf-16 -t utf-8 ../LANGUAGES/languages.ini | egrep -v '=STR|^;' | egrep 'Language-|STR_' > languages.js
|
||||
echo "checking languages.json ..."
|
||||
sh $VTOY_PATH/LANGUAGES/check.sh $VTOY_PATH || exit 1
|
||||
|
||||
echo "generating languages.json ..."
|
||||
|
||||
echo "var vtoy_language_data = " > languages.js
|
||||
cat $VTOY_PATH/LANGUAGES/languages.json >> languages.js
|
||||
echo ";" >> languages.js
|
||||
|
||||
dos2unix languages.js
|
||||
|
||||
sed 's/\(STR_.*\)=/"\1":/g' -i languages.js
|
||||
|
||||
sed "s/: *'/:\"/g" -i languages.js
|
||||
|
||||
sed "s/'\s*$/\",/g" -i languages.js
|
||||
|
||||
sed 's/\[Language-\(.*\)\].*/"STR_XXX":""},{"name":"\1",/g' -i languages.js
|
||||
|
||||
sed "1s/.*\},/var vtoy_language_data = \[/" -i languages.js
|
||||
|
||||
sed 's/\("STR_WEB_COMMUNICATION_ERR"[^,]*\)/\1,/g' -i languages.js
|
||||
sed 's/,,/,/g' -i languages.js
|
||||
|
||||
CNT=$(grep -v -c ',$' languages.js)
|
||||
|
||||
if [ $CNT -gt 0 ]; then
|
||||
echo "====== FAILED ========="
|
||||
grep -v -n ',$' languages.js
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
echo '"STR_XXX":""}' >> languages.js
|
||||
echo '];' >> languages.js
|
||||
|
||||
rm -f WebUI/static/js/languages.js
|
||||
mv languages.js WebUI/static/js/
|
||||
|
||||
echo "====== SUCCESS =========="
|
||||
echo "====== SUCCESS =========="
|
||||
|
@@ -101,13 +101,19 @@ typedef enum OPT_SUBMENU
|
||||
#define VTOY_MENU_LANGUAGE_BEGIN 0xB000
|
||||
|
||||
|
||||
#define VENTOY_LANGUAGE_INI TEXT(".\\ventoy\\languages.ini")
|
||||
#define VENTOY_LANGUAGE_INI TEXT(".\\ventoy\\languages.ini")
|
||||
#define VENTOY_LANGUAGE_JSON TEXT(".\\ventoy\\languages.json")
|
||||
#define VENTOY_LANGUAGE_INI_A ".\\ventoy\\languages.ini"
|
||||
#define VENTOY_LANGUAGE_JSON_A ".\\ventoy\\languages.json"
|
||||
|
||||
#define VENTOY_CFG_INI TEXT(".\\Ventoy2Disk.ini")
|
||||
#define VENTOY_CFG_INI_A ".\\Ventoy2Disk.ini"
|
||||
#define VENTOY_MAX_LANGUAGE 200
|
||||
|
||||
#define GET_INI_STRING(Section, Key, Buf) GetPrivateProfileString(Section, Key, TEXT("#"), Buf, sizeof(Buf), VENTOY_LANGUAGE_INI)
|
||||
|
||||
|
||||
|
||||
typedef struct VENTOY_LANGUAGE
|
||||
{
|
||||
WCHAR Name[128];
|
||||
|
@@ -283,6 +283,12 @@ static int FilterPhysicalDrive(PHY_DRIVE_INFO *pDriveList, DWORD DriveCount)
|
||||
CurDrive->PartStyle = (MBR.PartTbl[0].FsFlag == 0xEE) ? 1 : 0;
|
||||
GetVentoyVerInPhyDrive(CurDrive, Part2StartSector, CurDrive->VentoyVersion, sizeof(CurDrive->VentoyVersion), &(CurDrive->SecureBootSupport));
|
||||
Log("PhyDrive %d is Ventoy Disk ver:%s SecureBoot:%u", CurDrive->PhyDrive, CurDrive->VentoyVersion, CurDrive->SecureBootSupport);
|
||||
|
||||
if (CurDrive->VentoyVersion[0] == 0)
|
||||
{
|
||||
CurDrive->VentoyVersion[0] = '?';
|
||||
Log("Unknown Ventoy Version");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -148,7 +148,7 @@ typedef struct PHY_DRIVE_INFO
|
||||
STORAGE_BUS_TYPE BusType;
|
||||
|
||||
CHAR DriveLetters[64];
|
||||
|
||||
|
||||
CHAR VentoyVersion[32];
|
||||
|
||||
BOOL SecureBootSupport;
|
||||
|
@@ -110,6 +110,7 @@
|
||||
<ClCompile Include="process.c" />
|
||||
<ClCompile Include="Utility.c" />
|
||||
<ClCompile Include="Ventoy2Disk.c" />
|
||||
<ClCompile Include="VentoyJson.c" />
|
||||
<ClCompile Include="WinDialog.c" />
|
||||
<ClCompile Include="xz-embedded-20130513\linux\lib\decompress_unxz.c" />
|
||||
</ItemGroup>
|
||||
@@ -133,6 +134,7 @@
|
||||
<ClInclude Include="process.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="Ventoy2Disk.h" />
|
||||
<ClInclude Include="VentoyJson.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="Ventoy2Disk.rc" />
|
||||
|
@@ -78,6 +78,9 @@
|
||||
<ClCompile Include="crc32.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="VentoyJson.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Ventoy2Disk.h">
|
||||
@@ -137,6 +140,9 @@
|
||||
<ClInclude Include="process.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="VentoyJson.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="Ventoy2Disk.rc">
|
||||
|
771
Ventoy2Disk/Ventoy2Disk/VentoyJson.c
Normal file
771
Ventoy2Disk/Ventoy2Disk/VentoyJson.c
Normal file
@@ -0,0 +1,771 @@
|
||||
/******************************************************************************
|
||||
* VentoyJson.c
|
||||
*
|
||||
* Copyright (c) 2021, 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef FOR_VTOY_JSON_CHECK
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <Windows.h>
|
||||
#include "Ventoy2Disk.h"
|
||||
#endif
|
||||
|
||||
#include "VentoyJson.h"
|
||||
|
||||
static void vtoy_json_free(VTOY_JSON *pstJsonHead)
|
||||
{
|
||||
VTOY_JSON *pstNext = NULL;
|
||||
|
||||
while (NULL != pstJsonHead)
|
||||
{
|
||||
pstNext = pstJsonHead->pstNext;
|
||||
if ((pstJsonHead->enDataType < JSON_TYPE_BUTT) && (NULL != pstJsonHead->pstChild))
|
||||
{
|
||||
vtoy_json_free(pstJsonHead->pstChild);
|
||||
}
|
||||
|
||||
free(pstJsonHead);
|
||||
pstJsonHead = pstNext;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static char *vtoy_json_skip(const char *pcData)
|
||||
{
|
||||
while ((NULL != pcData) && ('\0' != *pcData) && (*pcData <= 32))
|
||||
{
|
||||
pcData++;
|
||||
}
|
||||
|
||||
return (char *)pcData;
|
||||
}
|
||||
|
||||
VTOY_JSON *vtoy_json_find_item
|
||||
(
|
||||
VTOY_JSON *pstJson,
|
||||
JSON_TYPE enDataType,
|
||||
const char *szKey
|
||||
)
|
||||
{
|
||||
while (NULL != pstJson)
|
||||
{
|
||||
if ((enDataType == pstJson->enDataType) &&
|
||||
(0 == strcmp(szKey, pstJson->pcName)))
|
||||
{
|
||||
return pstJson;
|
||||
}
|
||||
pstJson = pstJson->pstNext;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int vtoy_json_parse_number
|
||||
(
|
||||
VTOY_JSON *pstJson,
|
||||
const char *pcData,
|
||||
const char **ppcEnd
|
||||
)
|
||||
{
|
||||
unsigned long Value;
|
||||
|
||||
Value = strtoul(pcData, (char **)ppcEnd, 10);
|
||||
if (*ppcEnd == pcData)
|
||||
{
|
||||
Log("Failed to parse json number %s.", pcData);
|
||||
return JSON_FAILED;
|
||||
}
|
||||
|
||||
pstJson->enDataType = JSON_TYPE_NUMBER;
|
||||
pstJson->unData.lValue = Value;
|
||||
|
||||
return JSON_SUCCESS;
|
||||
}
|
||||
|
||||
static int vtoy_json_parse_string
|
||||
(
|
||||
char *pcNewStart,
|
||||
char *pcRawStart,
|
||||
VTOY_JSON *pstJson,
|
||||
const char *pcData,
|
||||
const char **ppcEnd
|
||||
)
|
||||
{
|
||||
UINT32 uiLen = 0;
|
||||
const char *pcPos = NULL;
|
||||
const char *pcTmp = pcData + 1;
|
||||
|
||||
*ppcEnd = pcData;
|
||||
|
||||
if ('\"' != *pcData)
|
||||
{
|
||||
return JSON_FAILED;
|
||||
}
|
||||
|
||||
pcPos = strchr(pcTmp, '\"');
|
||||
if ((NULL == pcPos) || (pcPos < pcTmp))
|
||||
{
|
||||
Log("Invalid string %s.", pcData);
|
||||
return JSON_FAILED;
|
||||
}
|
||||
|
||||
*ppcEnd = pcPos + 1;
|
||||
uiLen = (UINT32)(unsigned long)(pcPos - pcTmp);
|
||||
|
||||
pstJson->enDataType = JSON_TYPE_STRING;
|
||||
pstJson->unData.pcStrVal = pcNewStart + (pcTmp - pcRawStart);
|
||||
pstJson->unData.pcStrVal[uiLen] = '\0';
|
||||
|
||||
return JSON_SUCCESS;
|
||||
}
|
||||
|
||||
static int vtoy_json_parse_array
|
||||
(
|
||||
char *pcNewStart,
|
||||
char *pcRawStart,
|
||||
VTOY_JSON *pstJson,
|
||||
const char *pcData,
|
||||
const char **ppcEnd
|
||||
)
|
||||
{
|
||||
int Ret = JSON_SUCCESS;
|
||||
VTOY_JSON *pstJsonChild = NULL;
|
||||
VTOY_JSON *pstJsonItem = NULL;
|
||||
const char *pcTmp = pcData + 1;
|
||||
|
||||
*ppcEnd = pcData;
|
||||
pstJson->enDataType = JSON_TYPE_ARRAY;
|
||||
|
||||
if ('[' != *pcData)
|
||||
{
|
||||
return JSON_FAILED;
|
||||
}
|
||||
|
||||
pcTmp = vtoy_json_skip(pcTmp);
|
||||
|
||||
if (']' == *pcTmp)
|
||||
{
|
||||
*ppcEnd = pcTmp + 1;
|
||||
return JSON_SUCCESS;
|
||||
}
|
||||
|
||||
JSON_NEW_ITEM(pstJson->pstChild, JSON_FAILED);
|
||||
|
||||
Ret = vtoy_json_parse_value(pcNewStart, pcRawStart, pstJson->pstChild, pcTmp, ppcEnd);
|
||||
if (JSON_SUCCESS != Ret)
|
||||
{
|
||||
Log("Failed to parse array child.");
|
||||
return JSON_FAILED;
|
||||
}
|
||||
|
||||
pstJsonChild = pstJson->pstChild;
|
||||
pcTmp = vtoy_json_skip(*ppcEnd);
|
||||
while ((NULL != pcTmp) && (',' == *pcTmp))
|
||||
{
|
||||
JSON_NEW_ITEM(pstJsonItem, JSON_FAILED);
|
||||
pstJsonChild->pstNext = pstJsonItem;
|
||||
pstJsonItem->pstPrev = pstJsonChild;
|
||||
pstJsonChild = pstJsonItem;
|
||||
|
||||
Ret = vtoy_json_parse_value(pcNewStart, pcRawStart, pstJsonChild, vtoy_json_skip(pcTmp + 1), ppcEnd);
|
||||
if (JSON_SUCCESS != Ret)
|
||||
{
|
||||
Log("Failed to parse array child.");
|
||||
return JSON_FAILED;
|
||||
}
|
||||
pcTmp = vtoy_json_skip(*ppcEnd);
|
||||
}
|
||||
|
||||
if ((NULL != pcTmp) && (']' == *pcTmp))
|
||||
{
|
||||
*ppcEnd = pcTmp + 1;
|
||||
return JSON_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
*ppcEnd = pcTmp;
|
||||
return JSON_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
static int vtoy_json_parse_object
|
||||
(
|
||||
char *pcNewStart,
|
||||
char *pcRawStart,
|
||||
VTOY_JSON *pstJson,
|
||||
const char *pcData,
|
||||
const char **ppcEnd
|
||||
)
|
||||
{
|
||||
int Ret = JSON_SUCCESS;
|
||||
VTOY_JSON *pstJsonChild = NULL;
|
||||
VTOY_JSON *pstJsonItem = NULL;
|
||||
const char *pcTmp = pcData + 1;
|
||||
|
||||
*ppcEnd = pcData;
|
||||
pstJson->enDataType = JSON_TYPE_OBJECT;
|
||||
|
||||
if ('{' != *pcData)
|
||||
{
|
||||
return JSON_FAILED;
|
||||
}
|
||||
|
||||
pcTmp = vtoy_json_skip(pcTmp);
|
||||
if ('}' == *pcTmp)
|
||||
{
|
||||
*ppcEnd = pcTmp + 1;
|
||||
return JSON_SUCCESS;
|
||||
}
|
||||
|
||||
JSON_NEW_ITEM(pstJson->pstChild, JSON_FAILED);
|
||||
|
||||
Ret = vtoy_json_parse_string(pcNewStart, pcRawStart, pstJson->pstChild, pcTmp, ppcEnd);
|
||||
if (JSON_SUCCESS != Ret)
|
||||
{
|
||||
Log("Failed to parse array child.");
|
||||
return JSON_FAILED;
|
||||
}
|
||||
|
||||
pstJsonChild = pstJson->pstChild;
|
||||
pstJsonChild->pcName = pstJsonChild->unData.pcStrVal;
|
||||
pstJsonChild->unData.pcStrVal = NULL;
|
||||
|
||||
pcTmp = vtoy_json_skip(*ppcEnd);
|
||||
if ((NULL == pcTmp) || (':' != *pcTmp))
|
||||
{
|
||||
*ppcEnd = pcTmp;
|
||||
return JSON_FAILED;
|
||||
}
|
||||
|
||||
Ret = vtoy_json_parse_value(pcNewStart, pcRawStart, pstJsonChild, vtoy_json_skip(pcTmp + 1), ppcEnd);
|
||||
if (JSON_SUCCESS != Ret)
|
||||
{
|
||||
Log("Failed to parse array child.");
|
||||
return JSON_FAILED;
|
||||
}
|
||||
|
||||
pcTmp = vtoy_json_skip(*ppcEnd);
|
||||
while ((NULL != pcTmp) && (',' == *pcTmp))
|
||||
{
|
||||
JSON_NEW_ITEM(pstJsonItem, JSON_FAILED);
|
||||
pstJsonChild->pstNext = pstJsonItem;
|
||||
pstJsonItem->pstPrev = pstJsonChild;
|
||||
pstJsonChild = pstJsonItem;
|
||||
|
||||
Ret = vtoy_json_parse_string(pcNewStart, pcRawStart, pstJsonChild, vtoy_json_skip(pcTmp + 1), ppcEnd);
|
||||
if (JSON_SUCCESS != Ret)
|
||||
{
|
||||
Log("Failed to parse array child.");
|
||||
return JSON_FAILED;
|
||||
}
|
||||
|
||||
pcTmp = vtoy_json_skip(*ppcEnd);
|
||||
pstJsonChild->pcName = pstJsonChild->unData.pcStrVal;
|
||||
pstJsonChild->unData.pcStrVal = NULL;
|
||||
if ((NULL == pcTmp) || (':' != *pcTmp))
|
||||
{
|
||||
*ppcEnd = pcTmp;
|
||||
return JSON_FAILED;
|
||||
}
|
||||
|
||||
Ret = vtoy_json_parse_value(pcNewStart, pcRawStart, pstJsonChild, vtoy_json_skip(pcTmp + 1), ppcEnd);
|
||||
if (JSON_SUCCESS != Ret)
|
||||
{
|
||||
Log("Failed to parse array child.");
|
||||
return JSON_FAILED;
|
||||
}
|
||||
|
||||
pcTmp = vtoy_json_skip(*ppcEnd);
|
||||
}
|
||||
|
||||
if ((NULL != pcTmp) && ('}' == *pcTmp))
|
||||
{
|
||||
*ppcEnd = pcTmp + 1;
|
||||
return JSON_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
*ppcEnd = pcTmp;
|
||||
return JSON_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
int vtoy_json_parse_value
|
||||
(
|
||||
char *pcNewStart,
|
||||
char *pcRawStart,
|
||||
VTOY_JSON *pstJson,
|
||||
const char *pcData,
|
||||
const char **ppcEnd
|
||||
)
|
||||
{
|
||||
pcData = vtoy_json_skip(pcData);
|
||||
|
||||
switch (*pcData)
|
||||
{
|
||||
case 'n':
|
||||
{
|
||||
if (0 == strncmp(pcData, "null", 4))
|
||||
{
|
||||
pstJson->enDataType = JSON_TYPE_NULL;
|
||||
*ppcEnd = pcData + 4;
|
||||
return JSON_SUCCESS;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'f':
|
||||
{
|
||||
if (0 == strncmp(pcData, "false", 5))
|
||||
{
|
||||
pstJson->enDataType = JSON_TYPE_BOOL;
|
||||
pstJson->unData.lValue = 0;
|
||||
*ppcEnd = pcData + 5;
|
||||
return JSON_SUCCESS;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 't':
|
||||
{
|
||||
if (0 == strncmp(pcData, "true", 4))
|
||||
{
|
||||
pstJson->enDataType = JSON_TYPE_BOOL;
|
||||
pstJson->unData.lValue = 1;
|
||||
*ppcEnd = pcData + 4;
|
||||
return JSON_SUCCESS;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '\"':
|
||||
{
|
||||
return vtoy_json_parse_string(pcNewStart, pcRawStart, pstJson, pcData, ppcEnd);
|
||||
}
|
||||
case '[':
|
||||
{
|
||||
return vtoy_json_parse_array(pcNewStart, pcRawStart, pstJson, pcData, ppcEnd);
|
||||
}
|
||||
case '{':
|
||||
{
|
||||
return vtoy_json_parse_object(pcNewStart, pcRawStart, pstJson, pcData, ppcEnd);
|
||||
}
|
||||
case '-':
|
||||
{
|
||||
return vtoy_json_parse_number(pstJson, pcData, ppcEnd);
|
||||
}
|
||||
default :
|
||||
{
|
||||
if (*pcData >= '0' && *pcData <= '9')
|
||||
{
|
||||
return vtoy_json_parse_number(pstJson, pcData, ppcEnd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*ppcEnd = pcData;
|
||||
Log("Invalid json data %u.", (UINT8)(*pcData));
|
||||
return JSON_FAILED;
|
||||
}
|
||||
|
||||
VTOY_JSON * vtoy_json_create(void)
|
||||
{
|
||||
VTOY_JSON *pstJson = NULL;
|
||||
|
||||
pstJson = (VTOY_JSON *)malloc(sizeof(VTOY_JSON));
|
||||
if (NULL == pstJson)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
memset(pstJson, 0, sizeof(VTOY_JSON));
|
||||
return pstJson;
|
||||
}
|
||||
|
||||
int vtoy_json_parse(VTOY_JSON *pstJson, const char *szJsonData)
|
||||
{
|
||||
UINT32 uiMemSize = 0;
|
||||
int Ret = JSON_SUCCESS;
|
||||
char *pcNewBuf = NULL;
|
||||
const char *pcEnd = NULL;
|
||||
|
||||
uiMemSize = strlen(szJsonData) + 1;
|
||||
pcNewBuf = (char *)malloc(uiMemSize);
|
||||
if (NULL == pcNewBuf)
|
||||
{
|
||||
Log("Failed to alloc new buf.");
|
||||
return JSON_FAILED;
|
||||
}
|
||||
memcpy(pcNewBuf, szJsonData, uiMemSize);
|
||||
pcNewBuf[uiMemSize - 1] = 0;
|
||||
|
||||
Ret = vtoy_json_parse_value(pcNewBuf, (char *)szJsonData, pstJson, szJsonData, &pcEnd);
|
||||
if (JSON_SUCCESS != Ret)
|
||||
{
|
||||
Log("Failed to parse json data start=%p, end=%p", szJsonData, pcEnd);
|
||||
return JSON_FAILED;
|
||||
}
|
||||
|
||||
return JSON_SUCCESS;
|
||||
}
|
||||
|
||||
int vtoy_json_scan_parse
|
||||
(
|
||||
const VTOY_JSON *pstJson,
|
||||
UINT32 uiParseNum,
|
||||
JSON_PARSE *pstJsonParse
|
||||
)
|
||||
{
|
||||
UINT32 i = 0;
|
||||
const VTOY_JSON *pstJsonCur = NULL;
|
||||
JSON_PARSE *pstCurParse = NULL;
|
||||
|
||||
for (pstJsonCur = pstJson; NULL != pstJsonCur; pstJsonCur = pstJsonCur->pstNext)
|
||||
{
|
||||
if ((JSON_TYPE_OBJECT == pstJsonCur->enDataType) ||
|
||||
(JSON_TYPE_ARRAY == pstJsonCur->enDataType))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (i = 0, pstCurParse = NULL; i < uiParseNum; i++)
|
||||
{
|
||||
if (0 == strcmp(pstJsonParse[i].pcKey, pstJsonCur->pcName))
|
||||
{
|
||||
pstCurParse = pstJsonParse + i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL == pstCurParse)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (pstJsonCur->enDataType)
|
||||
{
|
||||
case JSON_TYPE_NUMBER:
|
||||
{
|
||||
if (sizeof(UINT32) == pstCurParse->uiBufSize)
|
||||
{
|
||||
*(UINT32 *)(pstCurParse->pDataBuf) = (UINT32)pstJsonCur->unData.lValue;
|
||||
}
|
||||
else if (sizeof(UINT16) == pstCurParse->uiBufSize)
|
||||
{
|
||||
*(UINT16 *)(pstCurParse->pDataBuf) = (UINT16)pstJsonCur->unData.lValue;
|
||||
}
|
||||
else if (sizeof(UINT8) == pstCurParse->uiBufSize)
|
||||
{
|
||||
*(UINT8 *)(pstCurParse->pDataBuf) = (UINT8)pstJsonCur->unData.lValue;
|
||||
}
|
||||
else if ((pstCurParse->uiBufSize > sizeof(UINT64)))
|
||||
{
|
||||
sprintf_s((char *)pstCurParse->pDataBuf, pstCurParse->uiBufSize, "%llu",
|
||||
(unsigned long long)(pstJsonCur->unData.lValue));
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("Invalid number data buf size %u.", pstCurParse->uiBufSize);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case JSON_TYPE_STRING:
|
||||
{
|
||||
strcpy_s((char *)pstCurParse->pDataBuf, pstCurParse->uiBufSize, pstJsonCur->unData.pcStrVal);
|
||||
break;
|
||||
}
|
||||
case JSON_TYPE_BOOL:
|
||||
{
|
||||
*(UINT8 *)(pstCurParse->pDataBuf) = (pstJsonCur->unData.lValue) > 0 ? 1 : 0;
|
||||
break;
|
||||
}
|
||||
default :
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return JSON_SUCCESS;
|
||||
}
|
||||
|
||||
int vtoy_json_scan_array
|
||||
(
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
VTOY_JSON **ppstArrayItem
|
||||
)
|
||||
{
|
||||
VTOY_JSON *pstJsonItem = NULL;
|
||||
|
||||
pstJsonItem = vtoy_json_find_item(pstJson, JSON_TYPE_ARRAY, szKey);
|
||||
if (NULL == pstJsonItem)
|
||||
{
|
||||
Log("Key %s is not found in json data.", szKey);
|
||||
return JSON_NOT_FOUND;
|
||||
}
|
||||
|
||||
*ppstArrayItem = pstJsonItem;
|
||||
|
||||
return JSON_SUCCESS;
|
||||
}
|
||||
|
||||
int vtoy_json_scan_array_ex
|
||||
(
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
VTOY_JSON **ppstArrayItem
|
||||
)
|
||||
{
|
||||
VTOY_JSON *pstJsonItem = NULL;
|
||||
|
||||
pstJsonItem = vtoy_json_find_item(pstJson, JSON_TYPE_ARRAY, szKey);
|
||||
if (NULL == pstJsonItem)
|
||||
{
|
||||
Log("Key %s is not found in json data.", szKey);
|
||||
return JSON_NOT_FOUND;
|
||||
}
|
||||
|
||||
*ppstArrayItem = pstJsonItem->pstChild;
|
||||
|
||||
return JSON_SUCCESS;
|
||||
}
|
||||
|
||||
int vtoy_json_scan_object
|
||||
(
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
VTOY_JSON **ppstObjectItem
|
||||
)
|
||||
{
|
||||
VTOY_JSON *pstJsonItem = NULL;
|
||||
|
||||
pstJsonItem = vtoy_json_find_item(pstJson, JSON_TYPE_OBJECT, szKey);
|
||||
if (NULL == pstJsonItem)
|
||||
{
|
||||
Log("Key %s is not found in json data.", szKey);
|
||||
return JSON_NOT_FOUND;
|
||||
}
|
||||
|
||||
*ppstObjectItem = pstJsonItem;
|
||||
|
||||
return JSON_SUCCESS;
|
||||
}
|
||||
|
||||
int vtoy_json_get_int
|
||||
(
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
int *piValue
|
||||
)
|
||||
{
|
||||
VTOY_JSON *pstJsonItem = NULL;
|
||||
|
||||
pstJsonItem = vtoy_json_find_item(pstJson, JSON_TYPE_NUMBER, szKey);
|
||||
if (NULL == pstJsonItem)
|
||||
{
|
||||
Log("Key %s is not found in json data.", szKey);
|
||||
return JSON_NOT_FOUND;
|
||||
}
|
||||
|
||||
*piValue = (int)pstJsonItem->unData.lValue;
|
||||
|
||||
return JSON_SUCCESS;
|
||||
}
|
||||
|
||||
int vtoy_json_get_uint
|
||||
(
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
UINT32 *puiValue
|
||||
)
|
||||
{
|
||||
VTOY_JSON *pstJsonItem = NULL;
|
||||
|
||||
pstJsonItem = vtoy_json_find_item(pstJson, JSON_TYPE_NUMBER, szKey);
|
||||
if (NULL == pstJsonItem)
|
||||
{
|
||||
Log("Key %s is not found in json data.", szKey);
|
||||
return JSON_NOT_FOUND;
|
||||
}
|
||||
|
||||
*puiValue = (UINT32)pstJsonItem->unData.lValue;
|
||||
|
||||
return JSON_SUCCESS;
|
||||
}
|
||||
|
||||
int vtoy_json_get_uint64
|
||||
(
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
UINT64 *pui64Value
|
||||
)
|
||||
{
|
||||
VTOY_JSON *pstJsonItem = NULL;
|
||||
|
||||
pstJsonItem = vtoy_json_find_item(pstJson, JSON_TYPE_NUMBER, szKey);
|
||||
if (NULL == pstJsonItem)
|
||||
{
|
||||
Log("Key %s is not found in json data.", szKey);
|
||||
return JSON_NOT_FOUND;
|
||||
}
|
||||
|
||||
*pui64Value = (UINT64)pstJsonItem->unData.lValue;
|
||||
|
||||
return JSON_SUCCESS;
|
||||
}
|
||||
|
||||
int vtoy_json_get_bool
|
||||
(
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
UINT8 *pbValue
|
||||
)
|
||||
{
|
||||
VTOY_JSON *pstJsonItem = NULL;
|
||||
|
||||
pstJsonItem = vtoy_json_find_item(pstJson, JSON_TYPE_BOOL, szKey);
|
||||
if (NULL == pstJsonItem)
|
||||
{
|
||||
Log("Key %s is not found in json data.", szKey);
|
||||
return JSON_NOT_FOUND;
|
||||
}
|
||||
|
||||
*pbValue = pstJsonItem->unData.lValue > 0 ? 1 : 0;
|
||||
|
||||
return JSON_SUCCESS;
|
||||
}
|
||||
|
||||
int vtoy_json_get_string
|
||||
(
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
UINT32 uiBufLen,
|
||||
char *pcBuf
|
||||
)
|
||||
{
|
||||
VTOY_JSON *pstJsonItem = NULL;
|
||||
|
||||
pstJsonItem = vtoy_json_find_item(pstJson, JSON_TYPE_STRING, szKey);
|
||||
if (NULL == pstJsonItem)
|
||||
{
|
||||
Log("Key %s is not found in json data.", szKey);
|
||||
return JSON_NOT_FOUND;
|
||||
}
|
||||
|
||||
strcpy_s(pcBuf, uiBufLen, pstJsonItem->unData.pcStrVal);
|
||||
|
||||
return JSON_SUCCESS;
|
||||
}
|
||||
|
||||
const char * vtoy_json_get_string_ex(VTOY_JSON *pstJson, const char *szKey)
|
||||
{
|
||||
VTOY_JSON *pstJsonItem = NULL;
|
||||
|
||||
if ((NULL == pstJson) || (NULL == szKey))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pstJsonItem = vtoy_json_find_item(pstJson, JSON_TYPE_STRING, szKey);
|
||||
if (NULL == pstJsonItem)
|
||||
{
|
||||
Log("Key %s is not found in json data.", szKey);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pstJsonItem->unData.pcStrVal;
|
||||
}
|
||||
|
||||
int vtoy_json_destroy(VTOY_JSON *pstJson)
|
||||
{
|
||||
if (NULL == pstJson)
|
||||
{
|
||||
return JSON_SUCCESS;
|
||||
}
|
||||
|
||||
if (NULL != pstJson->pstChild)
|
||||
{
|
||||
vtoy_json_free(pstJson->pstChild);
|
||||
}
|
||||
|
||||
if (NULL != pstJson->pstNext)
|
||||
{
|
||||
vtoy_json_free(pstJson->pstNext);
|
||||
}
|
||||
|
||||
free(pstJson);
|
||||
|
||||
return JSON_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
#ifdef FOR_VTOY_JSON_CHECK
|
||||
|
||||
int main(int argc, char**argv)
|
||||
{
|
||||
int ret = 1;
|
||||
int FileSize;
|
||||
FILE *fp;
|
||||
void *Data = NULL;
|
||||
VTOY_JSON *json = NULL;
|
||||
|
||||
fp = fopen(argv[1], "rb");
|
||||
if (!fp)
|
||||
{
|
||||
Log("Failed to open %s\n", argv[1]);
|
||||
goto out;
|
||||
}
|
||||
|
||||
fseek(fp, 0, SEEK_END);
|
||||
FileSize = (int)ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
|
||||
Data = malloc(FileSize + 4);
|
||||
if (!Data)
|
||||
{
|
||||
Log("Failed to malloc %d\n", FileSize + 4);
|
||||
goto out;
|
||||
}
|
||||
*((char *)Data + FileSize) = 0;
|
||||
|
||||
fread(Data, 1, FileSize, fp);
|
||||
|
||||
json = vtoy_json_create();
|
||||
if (!json)
|
||||
{
|
||||
Log("Failed vtoy_json_create\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (vtoy_json_parse(json, (char *)Data) != JSON_SUCCESS)
|
||||
{
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
out:
|
||||
if (fp) fclose(fp);
|
||||
if (Data) free(Data);
|
||||
if (json) vtoy_json_destroy(json);
|
||||
|
||||
printf("\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
164
Ventoy2Disk/Ventoy2Disk/VentoyJson.h
Normal file
164
Ventoy2Disk/Ventoy2Disk/VentoyJson.h
Normal file
@@ -0,0 +1,164 @@
|
||||
/******************************************************************************
|
||||
* VentoyJson.h
|
||||
*
|
||||
* Copyright (c) 2021, 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __VENTOY_JSON_H__
|
||||
#define __VENTOY_JSON_H__
|
||||
|
||||
#ifdef FOR_VTOY_JSON_CHECK
|
||||
typedef unsigned char UINT8;
|
||||
typedef unsigned short UINT16;
|
||||
typedef unsigned int UINT32;
|
||||
typedef unsigned long long UINT64;
|
||||
|
||||
#define Log printf
|
||||
#define strcpy_s(a, b, c) strncpy(a, c, b)
|
||||
#define sprintf_s snprintf
|
||||
#endif
|
||||
|
||||
#define JSON_SUCCESS 0
|
||||
#define JSON_FAILED 1
|
||||
#define JSON_NOT_FOUND 2
|
||||
|
||||
typedef enum _JSON_TYPE
|
||||
{
|
||||
JSON_TYPE_NUMBER = 0,
|
||||
JSON_TYPE_STRING,
|
||||
JSON_TYPE_BOOL,
|
||||
JSON_TYPE_ARRAY,
|
||||
JSON_TYPE_OBJECT,
|
||||
JSON_TYPE_NULL,
|
||||
JSON_TYPE_BUTT
|
||||
}JSON_TYPE;
|
||||
|
||||
|
||||
typedef struct _VTOY_JSON
|
||||
{
|
||||
struct _VTOY_JSON *pstPrev;
|
||||
struct _VTOY_JSON *pstNext;
|
||||
struct _VTOY_JSON *pstChild;
|
||||
|
||||
JSON_TYPE enDataType;
|
||||
union
|
||||
{
|
||||
char *pcStrVal;
|
||||
int iNumVal;
|
||||
UINT64 lValue;
|
||||
}unData;
|
||||
|
||||
char *pcName;
|
||||
}VTOY_JSON;
|
||||
|
||||
typedef struct _JSON_PARSE
|
||||
{
|
||||
char *pcKey;
|
||||
void *pDataBuf;
|
||||
UINT32 uiBufSize;
|
||||
}JSON_PARSE;
|
||||
|
||||
#define JSON_NEW_ITEM(pstJson, ret) \
|
||||
{ \
|
||||
(pstJson) = (VTOY_JSON *)malloc(sizeof(VTOY_JSON)); \
|
||||
if (NULL == (pstJson)) \
|
||||
{ \
|
||||
Log("Failed to alloc memory for json.\n"); \
|
||||
return (ret); \
|
||||
} \
|
||||
memset((pstJson), 0, sizeof(VTOY_JSON));\
|
||||
}
|
||||
|
||||
VTOY_JSON *vtoy_json_find_item
|
||||
(
|
||||
VTOY_JSON *pstJson,
|
||||
JSON_TYPE enDataType,
|
||||
const char *szKey
|
||||
);
|
||||
int vtoy_json_parse_value
|
||||
(
|
||||
char *pcNewStart,
|
||||
char *pcRawStart,
|
||||
VTOY_JSON *pstJson,
|
||||
const char *pcData,
|
||||
const char **ppcEnd
|
||||
);
|
||||
VTOY_JSON * vtoy_json_create(void);
|
||||
int vtoy_json_parse(VTOY_JSON *pstJson, const char *szJsonData);
|
||||
|
||||
int vtoy_json_scan_parse
|
||||
(
|
||||
const VTOY_JSON *pstJson,
|
||||
UINT32 uiParseNum,
|
||||
JSON_PARSE *pstJsonParse
|
||||
);
|
||||
|
||||
int vtoy_json_scan_array
|
||||
(
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
VTOY_JSON **ppstArrayItem
|
||||
);
|
||||
|
||||
int vtoy_json_scan_array_ex
|
||||
(
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
VTOY_JSON **ppstArrayItem
|
||||
);
|
||||
int vtoy_json_scan_object
|
||||
(
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
VTOY_JSON **ppstObjectItem
|
||||
);
|
||||
int vtoy_json_get_int
|
||||
(
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
int *piValue
|
||||
);
|
||||
int vtoy_json_get_uint
|
||||
(
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
UINT32 *puiValue
|
||||
);
|
||||
int vtoy_json_get_uint64
|
||||
(
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
UINT64 *pui64Value
|
||||
);
|
||||
int vtoy_json_get_bool
|
||||
(
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
UINT8 *pbValue
|
||||
);
|
||||
int vtoy_json_get_string
|
||||
(
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
UINT32 uiBufLen,
|
||||
char *pcBuf
|
||||
);
|
||||
const char * vtoy_json_get_string_ex(VTOY_JSON *pstJson, const char *szKey);
|
||||
int vtoy_json_destroy(VTOY_JSON *pstJson);
|
||||
|
||||
#endif /* __VENTOY_JSON_H__ */
|
||||
|
Binary file not shown.
@@ -464,10 +464,13 @@ static int vtoy_check_device(ventoy_os_param *param, const char *device)
|
||||
|
||||
static int vtoy_print_os_param(ventoy_os_param *param, char *diskname)
|
||||
{
|
||||
int cnt = 0;
|
||||
int fd, size;
|
||||
int cnt = 0;
|
||||
char *path = param->vtoy_img_path;
|
||||
const char *fs;
|
||||
|
||||
char diskpath[256] = {0};
|
||||
char sizebuf[64] = {0};
|
||||
|
||||
cnt = vtoy_find_disk_by_size(param->vtoy_disk_size, diskname);
|
||||
debug("find disk by size %llu, cnt=%d...\n", (unsigned long long)param->vtoy_disk_size, cnt);
|
||||
if (1 == cnt)
|
||||
@@ -494,6 +497,37 @@ static int vtoy_print_os_param(ventoy_os_param *param, char *diskname)
|
||||
|
||||
if (1 == cnt)
|
||||
{
|
||||
if (strstr(diskname, "nvme") || strstr(diskname, "mmc") || strstr(diskname, "nbd"))
|
||||
{
|
||||
snprintf(diskpath, sizeof(diskpath) - 1, "/sys/class/block/%sp2/size", diskname);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(diskpath, sizeof(diskpath) - 1, "/sys/class/block/%s2/size", diskname);
|
||||
}
|
||||
|
||||
if (access(diskpath, F_OK) >= 0)
|
||||
{
|
||||
debug("get part size from sysfs for %s\n", diskpath);
|
||||
|
||||
fd = open(diskpath, O_RDONLY | O_BINARY);
|
||||
if (fd >= 0)
|
||||
{
|
||||
read(fd, sizebuf, sizeof(sizebuf));
|
||||
size = (int)strtoull(sizebuf, NULL, 10);
|
||||
close(fd);
|
||||
if ((size != (64 * 1024)) && (size != (8 * 1024)))
|
||||
{
|
||||
debug("sizebuf=<%s> size=%d\n", sizebuf, size);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("%s not exist \n", diskpath);
|
||||
}
|
||||
|
||||
printf("/dev/%s#%s#%s\n", diskname, fs, path);
|
||||
return 0;
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user