mirror of
https://github.com/ventoy/Ventoy.git
synced 2026-04-19 20:26:17 +00:00
Improve for UEFI boot Windows/WinPE resolution issue fix.
This commit is contained in:
@@ -438,11 +438,11 @@ static void menu_set_chosen_tip(grub_menu_t menu, int entry)
|
||||
|
||||
if (g_ventoy_theme_path[0])
|
||||
{
|
||||
grub_env_set("theme", g_ventoy_theme_path);
|
||||
grub_env_set("theme", g_ventoy_theme_path);
|
||||
}
|
||||
|
||||
g_ventoy_tip_msg1 = g_ventoy_tip_msg2 = NULL;
|
||||
if (e && e->id && grub_strncmp(e->id, "VID_", 4) == 0)
|
||||
if (e && e->id && grub_strncmp(e->id, "VID_", 4) == 0)
|
||||
{
|
||||
g_ventoy_theme_path[0] = 0;
|
||||
img = (img_info *)(void *)grub_strtoul(e->id + 4, NULL, 16);
|
||||
@@ -480,7 +480,7 @@ static void
|
||||
menu_set_chosen_entry (grub_menu_t menu, int entry)
|
||||
{
|
||||
struct grub_menu_viewer *cur;
|
||||
|
||||
|
||||
menu_set_chosen_tip(menu, entry);
|
||||
for (cur = viewers; cur; cur = cur->next)
|
||||
cur->set_chosen_entry (entry, cur->data);
|
||||
@@ -972,7 +972,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
||||
;
|
||||
menu_fini ();
|
||||
goto refresh;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case (GRUB_TERM_CTRL | 'd'):
|
||||
@@ -981,7 +981,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
||||
{
|
||||
menu_fini ();
|
||||
g_ventoy_memdisk_mode = 1 - g_ventoy_memdisk_mode;
|
||||
g_ventoy_menu_refresh = 1;
|
||||
g_ventoy_menu_refresh = 1;
|
||||
goto refresh;
|
||||
}
|
||||
break;
|
||||
@@ -992,7 +992,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
||||
menu_fini ();
|
||||
g_ventoy_iso_raw = 1 - g_ventoy_iso_raw;
|
||||
g_ventoy_menu_refresh = 1;
|
||||
goto refresh;
|
||||
goto refresh;
|
||||
}
|
||||
break;
|
||||
case (GRUB_TERM_CTRL | 'r'):
|
||||
@@ -1001,10 +1001,10 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
||||
{
|
||||
menu_fini ();
|
||||
g_ventoy_grub2_mode = 1 - g_ventoy_grub2_mode;
|
||||
g_ventoy_menu_refresh = 1;
|
||||
g_ventoy_menu_refresh = 1;
|
||||
goto refresh;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case (GRUB_TERM_CTRL | 'w'):
|
||||
case 'w':
|
||||
if (0 == g_ventoy_secondary_menu_on)
|
||||
@@ -1039,7 +1039,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
||||
case 'm':
|
||||
{
|
||||
if (0 == g_ventoy_secondary_menu_on)
|
||||
{
|
||||
{
|
||||
if (g_ventoy_cur_img_path)
|
||||
{
|
||||
grub_env_set("VTOY_CHKSUM_FILE_PATH", g_ventoy_cur_img_path);
|
||||
@@ -1128,16 +1128,17 @@ static struct grub_menu_execute_callback execution_callback =
|
||||
static grub_err_t
|
||||
show_menu (grub_menu_t menu, int nested, int autobooted)
|
||||
{
|
||||
const char *def;
|
||||
const char *def;
|
||||
def = grub_env_get("VTOY_DEFAULT_IMAGE");
|
||||
|
||||
|
||||
while (1)
|
||||
{
|
||||
int ndown;
|
||||
char *pos = NULL;
|
||||
int boot_entry;
|
||||
grub_menu_entry_t e;
|
||||
int auto_boot;
|
||||
|
||||
|
||||
boot_entry = run_menu (menu, nested, &auto_boot);
|
||||
if (boot_entry < 0)
|
||||
break;
|
||||
@@ -1149,7 +1150,7 @@ show_menu (grub_menu_t menu, int nested, int autobooted)
|
||||
if (autobooted == 0 && auto_boot == 0) {
|
||||
g_ventoy_last_entry = boot_entry;
|
||||
if (g_ventoy_menu_esc)
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
if (autobooted == 0 && g_ventoy_menu_esc && auto_boot) {
|
||||
@@ -1162,7 +1163,7 @@ show_menu (grub_menu_t menu, int nested, int autobooted)
|
||||
continue; /* Menu is empty. */
|
||||
|
||||
if (2 == e->argc && e->args && e->args[1] && grub_strncmp(e->args[1], "VTOY_RET", 8) == 0)
|
||||
break;
|
||||
break;
|
||||
|
||||
grub_cls ();
|
||||
|
||||
@@ -1175,16 +1176,29 @@ show_menu (grub_menu_t menu, int nested, int autobooted)
|
||||
break;
|
||||
|
||||
if (2 == e->argc && e->args && e->args[1] && grub_strncmp(e->args[1], "VTOY_RUN_RET", 12) == 0)
|
||||
break;
|
||||
else if (2 == e->argc && e->args && e->args[1] && grub_strncmp(e->args[1], "VTOY_RUN_SET", 12) == 0) {
|
||||
ndown = (int)grub_strtol(e->args[1] + 12, NULL, 10);
|
||||
break;
|
||||
else if (2 == e->argc && e->args && e->args[1] && grub_strncmp(e->args[1], "VTOY_RUN_SET_", 13) == 0) {
|
||||
pos = NULL;
|
||||
ndown = (int)grub_strtol(e->args[1] + 13, &pos, 10);
|
||||
while (ndown > 0)
|
||||
{
|
||||
ventoy_menu_push_key(GRUB_TERM_KEY_DOWN);
|
||||
ndown--;
|
||||
}
|
||||
|
||||
ventoy_menu_push_key('\n');
|
||||
break;
|
||||
|
||||
if (pos && *pos == '_')
|
||||
{
|
||||
ndown = (int)grub_strtol(pos + 1, NULL, 10);
|
||||
while (ndown > 0)
|
||||
{
|
||||
ventoy_menu_push_key(GRUB_TERM_KEY_DOWN);
|
||||
ndown--;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -431,12 +431,12 @@ int ventoy_global_var_init(void)
|
||||
|
||||
static ctrl_var_cfg g_ctrl_vars[] =
|
||||
{
|
||||
{ "VTOY_WIN11_BYPASS_CHECK", 1 },
|
||||
{ "VTOY_WIN11_BYPASS_NRO", 1 },
|
||||
{ "VTOY_LINUX_REMOUNT", 0 },
|
||||
{ "VTOY_SECONDARY_BOOT_MENU", 1 },
|
||||
{ "VTOY_WIN_UEFI_MAX_RES", 1 },
|
||||
{ NULL, 0 }
|
||||
{ "VTOY_WIN11_BYPASS_CHECK", "1" },
|
||||
{ "VTOY_WIN11_BYPASS_NRO", "1" },
|
||||
{ "VTOY_LINUX_REMOUNT", "0" },
|
||||
{ "VTOY_SECONDARY_BOOT_MENU", "1" },
|
||||
{ "VTOY_WIN_UEFI_RES_LOCK", "1" },
|
||||
{ NULL, "" }
|
||||
};
|
||||
|
||||
static const char * ventoy_ctrl_var_read_hook(struct grub_env_var *var, const char *val)
|
||||
@@ -447,7 +447,7 @@ static const char * ventoy_ctrl_var_read_hook(struct grub_env_var *var, const ch
|
||||
{
|
||||
if (grub_strcmp(g_ctrl_vars[i].name, var->name) == 0)
|
||||
{
|
||||
return g_ctrl_vars[i].value ? "1" : "0";
|
||||
return g_ctrl_vars[i].szval;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -462,14 +462,14 @@ static char * ventoy_ctrl_var_write_hook(struct grub_env_var *var, const char *v
|
||||
{
|
||||
if (grub_strcmp(g_ctrl_vars[i].name, var->name) == 0)
|
||||
{
|
||||
if (val && val[0] == '1' && val[1] == 0)
|
||||
if (val && grub_isdigit(val[0]) && val[1] == 0)
|
||||
{
|
||||
g_ctrl_vars[i].value = 1;
|
||||
return grub_strdup("1");
|
||||
g_ctrl_vars[i].szval[0] = val[0];
|
||||
return grub_strdup(val);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_ctrl_vars[i].value = 0;
|
||||
g_ctrl_vars[i].szval[0] = '0';
|
||||
return grub_strdup("0");
|
||||
}
|
||||
}
|
||||
@@ -480,12 +480,13 @@ static char * ventoy_ctrl_var_write_hook(struct grub_env_var *var, const char *v
|
||||
|
||||
int ventoy_ctrl_var_init(void)
|
||||
{
|
||||
int i;
|
||||
ctrl_var_cfg *cfg = g_ctrl_vars;
|
||||
|
||||
for (i = 0; g_ctrl_vars[i].name; i++)
|
||||
while (cfg->name)
|
||||
{
|
||||
ventoy_env_export(g_ctrl_vars[i].name, g_ctrl_vars[i].value ? "1" : "0");
|
||||
grub_register_variable_hook(g_ctrl_vars[i].name, ventoy_ctrl_var_read_hook, ventoy_ctrl_var_write_hook);
|
||||
ventoy_env_export(cfg->name, cfg->szval);
|
||||
grub_register_variable_hook(cfg->name, ventoy_ctrl_var_read_hook, ventoy_ctrl_var_write_hook);
|
||||
cfg++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -3246,13 +3246,20 @@ void ventoy_fill_os_param(grub_file_t file, ventoy_os_param *param)
|
||||
grub_memcpy(param->vtoy_reserved + 7, g_ventoy_part_info->MBR.BootCode + 0x1b8, 4);
|
||||
|
||||
|
||||
/* Windows UEFI force highest resolution */
|
||||
/* Windows UEFI force resolution lock */
|
||||
if (g_ventoy_chain_type == 1) /* Windows */
|
||||
{
|
||||
val = ventoy_get_env("VTOY_WIN_UEFI_MAX_RES");
|
||||
if (val && val[0] == '1' && val[1] == 0)
|
||||
val = ventoy_get_env("VTOY_WIN_UEFI_RES_LOCK");
|
||||
if (val && val[1] == 0)
|
||||
{
|
||||
param->vtoy_reserved[11] = 1;
|
||||
if (val[0] == '1')
|
||||
{
|
||||
param->vtoy_reserved[11] = 1;
|
||||
}
|
||||
else if (val[0] == '2')
|
||||
{
|
||||
param->vtoy_reserved[11] = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
* 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/>.
|
||||
*
|
||||
@@ -142,7 +142,7 @@ typedef enum VTOY_FILE_FLT
|
||||
VTOY_FILE_FLT_IMG, /* .img */
|
||||
VTOY_FILE_FLT_VHD, /* .vhd(x) */
|
||||
VTOY_FILE_FLT_VTOY, /* .vtoy */
|
||||
|
||||
|
||||
VTOY_FILE_FLT_BUTT
|
||||
}VTOY_FILE_FLT;
|
||||
|
||||
@@ -160,7 +160,7 @@ typedef struct cmd_para
|
||||
grub_extcmd_func_t func;
|
||||
grub_command_flags_t flags;
|
||||
const struct grub_arg_option *parser;
|
||||
|
||||
|
||||
const char *summary;
|
||||
const char *description;
|
||||
|
||||
@@ -171,7 +171,7 @@ typedef struct cmd_para
|
||||
#define ventoy_align(value, align) (((value) + ((align) - 1)) & (~((align) - 1)))
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct cpio_newc_header
|
||||
typedef struct cpio_newc_header
|
||||
{
|
||||
char c_magic[6];
|
||||
char c_ino[8];
|
||||
@@ -206,7 +206,7 @@ typedef struct ventoy_patch_vhd
|
||||
grub_uint8_t part_offset_or_guid[16];
|
||||
grub_uint32_t reserved1;
|
||||
grub_uint32_t part_type;
|
||||
grub_uint8_t disk_signature_or_guid[16];
|
||||
grub_uint8_t disk_signature_or_guid[16];
|
||||
grub_uint8_t reserved2[16];
|
||||
grub_uint8_t vhd_file_path[1];
|
||||
}ventoy_patch_vhd;
|
||||
@@ -284,7 +284,7 @@ typedef struct img_info
|
||||
const char *tip2;
|
||||
const char *class;
|
||||
const char *menu_prefix;
|
||||
|
||||
|
||||
int id;
|
||||
int type;
|
||||
int plugin_list_index;
|
||||
@@ -313,8 +313,8 @@ typedef struct img_iterator_node
|
||||
|
||||
struct img_iterator_node *parent;
|
||||
struct img_iterator_node *firstchild;
|
||||
|
||||
void *firstiso;
|
||||
|
||||
void *firstiso;
|
||||
}img_iterator_node;
|
||||
|
||||
|
||||
@@ -328,7 +328,7 @@ typedef struct initrd_info
|
||||
|
||||
grub_uint8_t iso_type; // 0: iso9660 1:udf
|
||||
grub_uint32_t udf_start_block;
|
||||
|
||||
|
||||
grub_uint64_t override_offset;
|
||||
grub_uint32_t override_length;
|
||||
char override_data[32];
|
||||
@@ -397,7 +397,7 @@ void ventoy_debug(const char *fmt, ...);
|
||||
#pragma pack(1)
|
||||
|
||||
/* A WIM resource header */
|
||||
typedef struct wim_resource_header
|
||||
typedef struct wim_resource_header
|
||||
{
|
||||
grub_uint64_t size_in_wim:56; /* Compressed length */
|
||||
grub_uint64_t flags:8; /* flags */
|
||||
@@ -409,7 +409,7 @@ typedef struct wim_resource_header
|
||||
#define WIM_RESHDR_ZLEN_MASK 0x00ffffffffffffffULL
|
||||
|
||||
/* WIM resource header flags */
|
||||
typedef enum wim_resource_header_flags
|
||||
typedef enum wim_resource_header_flags
|
||||
{
|
||||
WIM_RESHDR_METADATA = ( 0x02ULL << 56 ), /* Resource contains metadata */
|
||||
WIM_RESHDR_COMPRESSED = ( 0x04ULL << 56 ), /* Resource is compressed */
|
||||
@@ -419,7 +419,7 @@ typedef enum wim_resource_header_flags
|
||||
#define WIM_HEAD_SIGNATURE "MSWIM\0\0"
|
||||
|
||||
/* WIM header */
|
||||
typedef struct wim_header
|
||||
typedef struct wim_header
|
||||
{
|
||||
grub_uint8_t signature[8]; /* Signature */
|
||||
grub_uint32_t header_len; /* Header length */
|
||||
@@ -439,21 +439,21 @@ typedef struct wim_header
|
||||
} wim_header;
|
||||
|
||||
/* WIM header flags */
|
||||
typedef enum wim_header_flags
|
||||
typedef enum wim_header_flags
|
||||
{
|
||||
WIM_HDR_XPRESS = 0x00020000, /* WIM uses Xpress compresson */
|
||||
WIM_HDR_LZX = 0x00040000, /* WIM uses LZX compression */
|
||||
}wim_header_flags;
|
||||
|
||||
/* A WIM file hash */
|
||||
typedef struct wim_hash
|
||||
typedef struct wim_hash
|
||||
{
|
||||
/* SHA-1 hash */
|
||||
grub_uint8_t sha1[20];
|
||||
}wim_hash;
|
||||
|
||||
/* A WIM lookup table entry */
|
||||
typedef struct wim_lookup_entry
|
||||
typedef struct wim_lookup_entry
|
||||
{
|
||||
wim_resource_header resource; /* Resource header */
|
||||
grub_uint16_t part; /* Part number */
|
||||
@@ -465,19 +465,19 @@ typedef struct wim_lookup_entry
|
||||
#define WIM_CHUNK_LEN 32768
|
||||
|
||||
/* A WIM chunk buffer */
|
||||
typedef struct wim_chunk_buffer
|
||||
typedef struct wim_chunk_buffer
|
||||
{
|
||||
grub_uint8_t data[WIM_CHUNK_LEN]; /*Data */
|
||||
}wim_chunk_buffer;
|
||||
|
||||
/* Security data */
|
||||
typedef struct wim_security_header
|
||||
typedef struct wim_security_header
|
||||
{
|
||||
grub_uint32_t len; /* Length */
|
||||
grub_uint32_t count; /* Number of entries */
|
||||
}wim_security_header;
|
||||
|
||||
typedef struct wim_stream_entry
|
||||
typedef struct wim_stream_entry
|
||||
{
|
||||
grub_uint64_t len;
|
||||
grub_uint64_t unused1;
|
||||
@@ -487,7 +487,7 @@ typedef struct wim_stream_entry
|
||||
}wim_stream_entry;
|
||||
|
||||
/* Directory entry */
|
||||
typedef struct wim_directory_entry
|
||||
typedef struct wim_directory_entry
|
||||
{
|
||||
grub_uint64_t len; /* Length */
|
||||
grub_uint32_t attributes; /* Attributes */
|
||||
@@ -590,7 +590,7 @@ typedef struct _VTOY_JSON
|
||||
struct _VTOY_JSON *pstChild;
|
||||
|
||||
JSON_TYPE enDataType;
|
||||
union
|
||||
union
|
||||
{
|
||||
char *pcStrVal;
|
||||
int iNumVal;
|
||||
@@ -702,7 +702,7 @@ int vtoy_json_parse_value
|
||||
(
|
||||
char *pcNewStart,
|
||||
char *pcRawStart,
|
||||
VTOY_JSON *pstJson,
|
||||
VTOY_JSON *pstJson,
|
||||
const char *pcData,
|
||||
const char **ppcEnd
|
||||
);
|
||||
@@ -718,51 +718,51 @@ int vtoy_json_scan_parse
|
||||
|
||||
int vtoy_json_scan_array
|
||||
(
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
VTOY_JSON **ppstArrayItem
|
||||
);
|
||||
|
||||
int vtoy_json_scan_array_ex
|
||||
(
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
VTOY_JSON **ppstArrayItem
|
||||
);
|
||||
int vtoy_json_scan_object
|
||||
(
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
VTOY_JSON **ppstObjectItem
|
||||
);
|
||||
int vtoy_json_get_int
|
||||
(
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
int *piValue
|
||||
);
|
||||
int vtoy_json_get_uint
|
||||
(
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
grub_uint32_t *puiValue
|
||||
);
|
||||
int vtoy_json_get_uint64
|
||||
(
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
grub_uint64_t *pui64Value
|
||||
);
|
||||
int vtoy_json_get_bool
|
||||
(
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
const char *szKey,
|
||||
grub_uint8_t *pbValue
|
||||
);
|
||||
int vtoy_json_get_string
|
||||
(
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
VTOY_JSON *pstJson,
|
||||
const char *szKey,
|
||||
grub_uint32_t uiBufLen,
|
||||
char *pcBuf
|
||||
);
|
||||
@@ -784,7 +784,7 @@ static inline int ventoy_isspace (int c)
|
||||
|
||||
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)
|
||||
@@ -956,7 +956,7 @@ typedef struct persistence_config
|
||||
int cursel;
|
||||
int backendnum;
|
||||
file_fullpath *backendpath;
|
||||
|
||||
|
||||
struct persistence_config *next;
|
||||
}persistence_config;
|
||||
|
||||
@@ -1296,7 +1296,7 @@ typedef struct global_var_cfg
|
||||
typedef struct ctrl_var_cfg
|
||||
{
|
||||
const char *name;
|
||||
int value;
|
||||
char szval[2];
|
||||
}ctrl_var_cfg;
|
||||
|
||||
#define vtoy_check_goto_out(p) if (!p) goto out
|
||||
|
||||
Reference in New Issue
Block a user