Add WIMBOOT mode

This commit is contained in:
longpanda 2021-05-12 22:49:12 +08:00
parent 265b70f1c7
commit ca62128f9b
14 changed files with 182 additions and 11 deletions

View File

@ -29,6 +29,7 @@
extern int g_ventoy_memdisk_mode;
extern int g_ventoy_iso_raw;
extern int g_ventoy_grub2_mode;
extern int g_ventoy_wimboot_mode;
extern int g_ventoy_iso_uefi_drv;
static const char *align_options[] =
@ -209,6 +210,9 @@ label_set_property (void *vself, const char *name, const char *value)
else if (grub_strcmp (value, "@VTOY_GRUB2_MODE@") == 0) {
value = g_ventoy_grub2_mode ? grub_env_get("VTOY_GRUB2_MODE_STR") : " ";
}
else if (grub_strcmp (value, "@VTOY_WIMBOOT_MODE@") == 0) {
value = g_ventoy_wimboot_mode ? grub_env_get("VTOY_WIMBOOT_MODE_STR") : " ";
}
else if (grub_strcmp (value, "@VTOY_ISO_UEFI_DRV@") == 0) {
value = g_ventoy_iso_uefi_drv ? grub_env_get("VTOY_ISO_UEFI_DRV_STR") : " ";
}

View File

@ -38,6 +38,7 @@ int g_ventoy_menu_refresh = 0;
int g_ventoy_memdisk_mode = 0;
int g_ventoy_iso_raw = 0;
int g_ventoy_grub2_mode = 0;
int g_ventoy_wimboot_mode = 0;
int g_ventoy_iso_uefi_drv = 0;
int g_ventoy_last_entry = -1;
int g_ventoy_suppress_esc = 0;
@ -904,6 +905,12 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
g_ventoy_menu_refresh = 1;
goto refresh;
case (GRUB_TERM_CTRL | 'w'):
menu_fini ();
g_ventoy_wimboot_mode = 1 - g_ventoy_wimboot_mode;
g_ventoy_menu_refresh = 1;
goto refresh;
case (GRUB_TERM_CTRL | 'u'):
menu_fini ();
g_ventoy_iso_uefi_drv = 1 - g_ventoy_iso_uefi_drv;

View File

@ -3163,6 +3163,10 @@ static grub_err_t ventoy_cmd_check_mode(grub_extcmd_context_t ctxt, int argc, ch
{
return g_ventoy_grub2_mode ? 0 : 1;
}
else if (args[0][0] == '4')
{
return g_ventoy_wimboot_mode ? 0 : 1;
}
return 1;
}
@ -4426,6 +4430,7 @@ static cmd_para ventoy_cmds[] =
{ "vt_windows_reset", ventoy_cmd_wimdows_reset, 0, NULL, "", "", NULL },
{ "vt_windows_chain_data", ventoy_cmd_windows_chain_data, 0, NULL, "", "", NULL },
{ "vt_windows_wimboot_data", ventoy_cmd_windows_wimboot_data, 0, NULL, "", "", NULL },
{ "vt_windows_collect_wim_patch", ventoy_cmd_collect_wim_patch, 0, NULL, "", "", NULL },
{ "vt_windows_locate_wim_patch", ventoy_cmd_locate_wim_patch, 0, NULL, "", "", NULL },
{ "vt_windows_count_wim_patch", ventoy_cmd_wim_patch_count, 0, NULL, "", "", NULL },

View File

@ -555,6 +555,7 @@ int ventoy_fill_data(grub_uint32_t buflen, char *buffer);
grub_err_t ventoy_cmd_load_plugin(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_wimdows_reset(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_windows_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_windows_wimboot_data(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_wim_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_wim_check_bootable(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_dump_wim_patch(grub_extcmd_context_t ctxt, int argc, char **args);
@ -916,6 +917,7 @@ extern int g_ventoy_last_entry;
extern int g_ventoy_memdisk_mode;
extern int g_ventoy_iso_raw;
extern int g_ventoy_grub2_mode;
extern int g_ventoy_wimboot_mode;
extern int g_ventoy_iso_uefi_drv;
extern int g_ventoy_case_insensitive;
extern grub_uint8_t g_ventoy_chain_type;

View File

@ -1330,6 +1330,54 @@ end:
return rc;
}
grub_err_t ventoy_cmd_windows_wimboot_data(grub_extcmd_context_t ctxt, int argc, char **args)
{
grub_uint32_t size = 0;
const char *addr = NULL;
ventoy_chain_head *chain = NULL;
ventoy_os_param *param = NULL;
char envbuf[64];
(void)ctxt;
(void)argc;
(void)args;
addr = grub_env_get("vtoy_chain_mem_addr");
if (!addr)
{
debug("Failed to find vtoy_chain_mem_addr\n");
return 1;
}
chain = (ventoy_chain_head *)(void *)grub_strtoul(addr, NULL, 16);
if (grub_memcmp(&g_ventoy_guid, &chain->os_param.guid, 16) != 0)
{
debug("os_param.guid not match\n");
return 1;
}
size = sizeof(ventoy_os_param) + sizeof(ventoy_windows_data);
param = (ventoy_os_param *)grub_zalloc(size);
if (!param)
{
return 1;
}
grub_memcpy(param, &chain->os_param, sizeof(ventoy_os_param));
ventoy_fill_windows_rtdata(param + 1, param->vtoy_img_path);
grub_snprintf(envbuf, sizeof(envbuf), "0x%lx", (unsigned long)param);
grub_env_set("vtoy_wimboot_mem_addr", envbuf);
debug("vtoy_wimboot_mem_addr: %s\n", envbuf);
grub_snprintf(envbuf, sizeof(envbuf), "%u", size);
grub_env_set("vtoy_wimboot_mem_size", envbuf);
debug("vtoy_wimboot_mem_size: %s\n", envbuf);
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
grub_err_t ventoy_cmd_windows_chain_data(grub_extcmd_context_t ctxt, int argc, char **args)
{
int unknown_image = 0;

View File

@ -805,6 +805,25 @@ function uefi_iso_memdisk {
}
function legacy_windows_wimboot_func {
set wimbootfile=(loop)/sources/boot.wim
set wimbit=64
vt_windows_wimboot_data
linux16 $vtoy_efi_part/ventoy/wimboot quiet
ventoy_debug_pause
echo Loading files...... (This may take a few minutes, please wait.)
initrd16 newc:vtoyjump.exe:$vtoy_efi_part/ventoy/vtoyjump${wimbit}.exe \
newc:wimboot.data:mem:${vtoy_wimboot_mem_addr}:size:${vtoy_wimboot_mem_size} \
newc:winpeshl.ini:$vtoy_efi_part/ventoy/winpeshl.ini \
newc:bcd:(loop)/boot/bcd \
newc:boot.sdi:(loop)/boot/boot.sdi \
newc:boot.wim:$wimbootfile
boot
}
function legacy_windows_menu_func {
vt_windows_reset
@ -833,7 +852,11 @@ function legacy_windows_menu_func {
vt_windows_chain_data "${1}${chosen_path}"
ventoy_debug_pause
if vt_check_mode 4; then
legacy_windows_wimboot_func
fi
if [ -n "$vtoy_chain_mem_addr" ]; then
ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} ibft mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
@ -1721,6 +1744,7 @@ set VTOY_DEFAULT_MENU_MODE=0
set VTOY_MEM_DISK_STR="[Memdisk]"
set VTOY_ISO_RAW_STR="Compatible Mode"
set VTOY_GRUB2_MODE_STR="GRUB2 Mode"
set VTOY_WIMBOOT_MODE_STR="WIMBOOT Mode"
set VTOY_ISO_UEFI_DRV_STR="UEFI FS"
set VTOY_F2_CMD="ventoy_power"

View File

@ -78,6 +78,14 @@ terminal-box: "terminal_box_*.png"
+ label {text = "@VTOY_GRUB2_MODE@" color = "red" align = "left"}
}
+ hbox{
left = 30%+200
top = 95%-25
width = 10%
height = 25
+ label {text = "@VTOY_WIMBOOT_MODE@" color = "red" align = "left"}
}
+ hbox{
left = 90%
top = 55

Binary file not shown.

Binary file not shown.

BIN
INSTALL/ventoy/wimboot Normal file

Binary file not shown.

View File

@ -0,0 +1,2 @@
[LaunchApps]
vtoyjump.exe

View File

@ -1,5 +1,4 @@
wimboot follows GPLv2+ license (see gpl-2.0.txt)
Ventoy use the lzx decompress file from wimboot. These code follow the same license as wimboot.
Ventoy modified the code and follow the same license as wimboot.

View File

@ -1105,6 +1105,64 @@ const char * GetFileNameInPath(const char *fullpath)
return fullpath;
}
int VentoyJumpWimboot(INT argc, CHAR **argv, CHAR *LunchFile)
{
int rc = 1;
char *buf = NULL;
DWORD size = 0;
DWORD Pos;
#ifdef VTOY_32
g_64bit_system = FALSE;
#else
g_64bit_system = TRUE;
#endif
Log("VentoyJumpWimboot 64bit:%u", g_64bit_system);
sprintf_s(LunchFile, MAX_PATH, "X:\\setup.exe");
ReadWholeFile2Buf("wimboot.data", &buf, &size);
Log("wimboot.data size:%d", size);
memcpy(&g_os_param, buf, sizeof(ventoy_os_param));
memcpy(&g_windows_data, buf + sizeof(ventoy_os_param), sizeof(ventoy_windows_data));
memcpy(g_os_param_reserved, g_os_param.vtoy_reserved, sizeof(g_os_param_reserved));
if (g_os_param_reserved[0] == 1)
{
Log("break here for debug .....");
goto End;
}
// convert / to \\
for (Pos = 0; Pos < sizeof(g_os_param.vtoy_img_path) && g_os_param.vtoy_img_path[Pos]; Pos++)
{
if (g_os_param.vtoy_img_path[Pos] == '/')
{
g_os_param.vtoy_img_path[Pos] = '\\';
}
}
if (g_os_param_reserved[0] == 2)
{
Log("skip hook for debug .....");
rc = 0;
goto End;
}
rc = VentoyHook(&g_os_param);
End:
if (buf)
{
free(buf);
}
return rc;
}
int VentoyJump(INT argc, CHAR **argv, CHAR *LunchFile)
{
int rc = 1;
@ -1241,7 +1299,15 @@ int main(int argc, char **argv)
GetStartupInfoA(&Si);
memset(LunchFile, 0, sizeof(LunchFile));
rc = VentoyJump(argc, argv, LunchFile);
if (strstr(argv[0], "vtoyjump.exe"))
{
rc = VentoyJumpWimboot(argc, argv, LunchFile);
}
else
{
rc = VentoyJump(argc, argv, LunchFile);
}
if (g_os_param_reserved[0] == 3)
{
@ -1250,11 +1316,17 @@ int main(int argc, char **argv)
}
else
{
Si.dwFlags |= STARTF_USESHOWWINDOW;
Si.wShowWindow = SW_HIDE;
if (NULL == strstr(LunchFile, "setup.exe"))
{
Log("Not setup.exe, hide windows.");
Si.dwFlags |= STARTF_USESHOWWINDOW;
Si.wShowWindow = SW_HIDE;
}
Log("Ventoy jump %s ...", rc == 0 ? "success" : "failed");
}
Log("Now launch <%s> ...", LunchFile);
CreateProcessA(NULL, LunchFile, NULL, NULL, FALSE, 0, NULL, NULL, &Si, &Pi);
while (rc)

View File

@ -92,7 +92,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>FATFS_INC_FORMAT_SUPPORT=0;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>VTOY_32;FATFS_INC_FORMAT_SUPPORT=0;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
@ -108,7 +108,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>FATFS_INC_FORMAT_SUPPORT=0;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>VTOY_64;FATFS_INC_FORMAT_SUPPORT=0;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
@ -126,7 +126,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>FATFS_INC_FORMAT_SUPPORT=0;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>VTOY_32;FATFS_INC_FORMAT_SUPPORT=0;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
@ -146,7 +146,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>FATFS_INC_FORMAT_SUPPORT=0;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>VTOY_64;FATFS_INC_FORMAT_SUPPORT=0;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>