+function vhd_common_menuentry {
+
+ if [ "$VTOY_VHD_NO_WARNING" != "1" ]; then
+ if [ "$vtoy_iso_fs" != "ntfs" ]; then
+ echo -e "!!! WARNING !!!\n"
+ echo -e "\nPartition1 ($vtoy_iso_fs) is NOT ntfs, the VHD(x) file may not boot normally \n"
+ echo -e "\nVHD(x) 文件所在分区不是 ntfs 格式, 可能无法正常启动 \n\n"
+ echo -n "press ENTER to continue boot (请按 回车 键继续) ..."
+ read vtInputKey
+ fi
+ fi
+
+ vt_chosen_img_path vt_chosen_path vt_chosen_size
+ 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_x64.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_unsupport_menuentry {
+ common_unsupport_menuentry
+}
+
+function vtoyboot_common_func {
+ set AltBootPart=0
+ set vtoysupport=0
+
+ vt_get_vtoy_type ${1} vtoytype parttype AltBootPart
+
+ if vt_str_begin $vtoytype vhd; then
+ set vtoysupport=1
+ elif [ "$vtoytype" = "raw" ]; then
+ set vtoysupport=1
+ elif [ "$vtoytype" = "vdi" ]; then
+ set vtoysupport=1
+ fi
+
+ if [ $vtoysupport -eq 1 ]; then
+ if [ "$grub_platform" = "pc" ]; then
+ if [ "$parttype" = "gpt" -a $AltBootPart -eq 0 ]; then
+ echo "The OS in the vdisk was created in UEFI mode, but current is Legacy BIOS mode."
+ echo "虚拟磁盘内的系统是在UEFI模式下创建的,而当前系统是Legacy BIOS模式,可能无法正常启动。"
+ ventoy_pause
+ fi
+ else
+ if [ "$parttype" = "mbr" -a $AltBootPart -eq 0 ]; then
+ echo "The OS in the vdisk was created in Legacy BIOS mode, but current is UEFI mode."
+ echo "虚拟磁盘内的系统是在Legacy BIOS模式下创建的,而当前系统是UEFI模式,可能无法正常启动。"
+ ventoy_pause
+ fi
+ fi
+
+ vt_img_sector ${1}
+ vt_raw_chain_data ${1}
+
+ ventoy_debug_pause
+
+ if [ -n "$vtoy_chain_mem_addr" ]; then
+ if [ "$grub_platform" = "pc" ]; then
+ vt_acpi_param ${vtoy_chain_mem_addr} 512
+ linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} bios80 sector512 mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
+ boot
+ else
+ ventoy_acpi_param ${vtoy_chain_mem_addr} 512
+ ventoy_cli_console
+ chainloader ${vtoy_path}/ventoy_x64.efi sector512 env_param=${ventoy_env_param} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
+ boot
+ ventoy_gui_console
+ fi
+ else
+ echo "chain empty failed!"
+ ventoy_pause
+ fi
+ else
+ echo "Unsupported vtoy type $vtoytype"
+ ventoy_pause
+ fi
+}
+
+function vtoy_common_menuentry {
+ vt_chosen_img_path vt_chosen_path vt_chosen_size
+ vtoyboot_common_func ${vtoy_iso_part}${vt_chosen_path}
+}
+
+function vtoy_unsupport_menuentry {
+ common_unsupport_menuentry
+}
+