+ linux16 $vtoy_path/memdisk iso raw
+ echo "Loading ISO file to memory ..."
+ initrd16 ${1}${2}
+ boot
+}
+
+
+function iso_endless_os_proc {
+ if [ -d (loop)/ ]; then
+ loopback -d loop
+ fi
+
+ loopback loop ${1}${2}
+ vt_img_sector ${1}${2}
+
+ vt_load_cpio $vtoy_path/ventoy.cpio $2 $1 "busybox=$ventoy_busybox_ver"
+ vt_trailer_cpio $1 $2 noinit
+
+ ventoy_debug_pause
+
+ vt_set_boot_opt '@kparams' rdinit=/vtoy/vtoy
+
+ set eosimage=loop
+ set ventoy_bls_bootdev=/boot
+ set ventoy_loading_tip="Loading files ......"
+
+ export eosimage
+ configfile (loop)/endless/grub/grub.cfg
+
+ unset eosimage
+ unset ventoy_bls_bootdev
+ unset ventoy_loading_tip
+
+ vt_unset_boot_opt
+}
+
+
+function ventoy_iso_busybox_ver {
+ set ventoy_busybox_ver=32
+
+ #special process for deepin-live iso
+ if [ "$vt_chosen_size" = "403701760" ]; then
+ if vt_str_str $vt_chosen_path "/deepin-live"; then
+ set ventoy_busybox_ver=64
+ fi
+ elif vt_str_begin $vt_volume_id "PHOTON_"; then
+ set ventoy_busybox_ver=64
+ elif vt_str_begin $vt_volume_id "smgl-test-quinq-x86_64"; then
+ set ventoy_busybox_ver=64
+
+ fi
+}
+
+function iso_common_menuentry {
+ unset vt_system_id
+ unset vt_volume_id
+
+ vt_chosen_img_path vt_chosen_path vt_chosen_size
+ vt_parse_iso_volume ${vtoy_iso_part}${vt_chosen_path} vt_system_id vt_volume_id
+
+ ventoy_iso_busybox_ver
+
+ #special process for Endless OS
+ if vt_str_begin $vt_volume_id "Endless-OS"; then
+ iso_endless_os_proc $vtoy_iso_part $vt_chosen_path
+ elif vt_str_begin $vt_volume_id "TENS-Public"; then
+ set vtcompat=1
+ fi
+
+ if [ "$grub_platform" = "pc" ]; then
+ if vt_check_mode 0; then
+ legacy_iso_memdisk $vtoy_iso_part $vt_chosen_path
+ else
+ legacy_iso_menu_func $vtoy_iso_part $vt_chosen_path
+ fi
+ else
+ if vt_check_mode 0; then
+ uefi_iso_memdisk $vtoy_iso_part $vt_chosen_path
+ else
+ uefi_iso_menu_func $vtoy_iso_part $vt_chosen_path
+ fi
+ fi
+}
+
+function miso_common_menuentry {
+ vt_chosen_img_path vt_chosen_path vt_chosen_size
+
+ if [ "$grub_platform" = "pc" ]; then
+ legacy_iso_memdisk $vtoy_iso_part $vt_chosen_path
+ else
+ uefi_iso_memdisk $vtoy_iso_part $vt_chosen_path
+ fi
+}
+
+
+function common_unsupport_menuentry {
+ echo -e "\n The name of the iso file could NOT contain space or non-ascii characters. \n"
+ echo -e " 文件名中不能有中文或空格 \n"
+ echo -e "\npress ENTER to exit (请按 回车 键返回) ..."
+ read vtInputKey
+}
+
+function miso_unsupport_menuentry {
+ common_unsupport_menuentry
+}
+
+function iso_unsupport_menuentry {
+ common_unsupport_menuentry
+}
+
+function wim_common_menuentry {
+ vt_chosen_img_path vt_chosen_path vt_chosen_size
+ vt_wim_chain_data ${vtoy_iso_part}${vt_chosen_path}
+
+ ventoy_debug_pause
+
+ if [ -n "$vtoy_chain_mem_addr" ]; then
+ if [ "$grub_platform" = "pc" ]; then
+ linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
+ set gfxmode=1920x1080,1366x768,1024x768,800x600,auto
+ terminal_output gfxterm
+ else
+ ventoy_cli_console
+ chainloader ${vtoy_path}/ventoy_x64.efi env_param=${env_param} isoefi=${LoadIsoEfiDriver} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
+ ventoy_gui_console
+ fi
+ boot
+ else
+ echo "chain empty failed"
+ ventoy_pause
+ fi
+}
+
+function wim_unsupport_menuentry {
+ common_unsupport_menuentry
+}
+
+function efi_common_menuentry {
+ vt_chosen_img_path vt_chosen_path vt_chosen_size
+
+ vt_concat_efi_iso ${vtoy_iso_part}${vt_chosen_path} vtoy_iso_buf
+
+ ventoy_debug_pause
+
+ ventoy_cli_console
+
+ unset vtoy_dotefi_retry
+ chainloader ${vtoy_path}/ventoy_x64.efi memdisk env_param=${env_param} dotefi isoefi=on ${vtdebug_flag} mem:${vtoy_iso_buf_addr}:size:${vtoy_iso_buf_size}
+ boot
+
+ if [ -n "$vtoy_dotefi_retry" ]; then
+ unset vtoy_dotefi_retry
+ chainloader ${vtoy_iso_part}${vt_chosen_path}
+ boot
+ fi
+
+ ventoy_gui_console
+}
+
+function efi_unsupport_menuentry {
+ common_unsupport_menuentry
+}
+
+
+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 ${vtoy_iso_part} ${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}
+
+ set gfxmode=1920x1080,1366x768,1024x768,800x600,auto
+ terminal_output gfxterm
+ 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 "Failed to boot vhd file"
+ ventoy_pause
+ fi
+}
+
+function vhd_unsupport_menuentry {
+ common_unsupport_menuentry
+}
+
+#
+#============================================================#
+# IMG file boot process #
+#============================================================#
+#
+
+
+function ventoy_img_easyos {
+ vt_load_cpio $vtoy_path/ventoy.cpio ${vt_chosen_path} ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
+ vt_trailer_cpio ${vtoy_iso_part} ${vt_chosen_path} noinit
+
+ loopback easysfs (vtimghd,1)/easy.sfs
+ vt_get_lib_module_ver (easysfs) /lib/modules/ vt_module_ver
+
+ if [ -n "$vt_module_ver" ]; then
+ for mod in "kernel/drivers/md/dm-mod.ko" "kernel/drivers/dax/dax.ko"; do
+ vt_img_extra_initrd_append (easysfs)/lib/modules/$vt_module_ver/$mod
+ done
+ fi
+
+ ventoy_debug_pause
+
+ #boot image file
+ vt_set_boot_opt rdinit=/vtoy/vtoy
+ vt_img_hook_root
+
+ syslinux_configfile (vtimghd,1)/syslinux.cfg
+
+ vt_img_unhook_root
+ vt_unset_boot_opt
+ loopback -d easysfs
+}
+
+function ventoy_img_volumio {
+ vt_load_cpio $vtoy_path/ventoy.cpio ${vt_chosen_path} ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
+ vt_trailer_cpio ${vtoy_iso_part} ${vt_chosen_path} noinit
+
+ ventoy_debug_pause
+
+ #boot image file
+ vt_set_boot_opt rdinit=/vtoy/vtoy imgpart=/dev/ventoy2 bootpart=/dev/ventoy1
+ vt_img_hook_root
+
+ syslinux_configfile (vtimghd,1)/syslinux.cfg
+
+ vt_img_unhook_root
+ vt_unset_boot_opt
+}
+
+function ventoy_img_openelec {
+ elec_ver=$1
+
+ vt_load_cpio $vtoy_path/ventoy.cpio ${vt_chosen_path} ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
+ vt_trailer_cpio ${vtoy_iso_part} ${vt_chosen_path} noinit
+
+ loopback vtloopex $vtoy_efi_part/ventoy/vtloopex.cpio
+ vt_img_extra_initrd_append (vtloopex)/$elec_ver/vtloopex.tar.xz