diff --git a/FUSEISO/build.sh b/FUSEISO/build.sh index 69f3b80e..17950add 100644 --- a/FUSEISO/build.sh +++ b/FUSEISO/build.sh @@ -15,7 +15,7 @@ fi export C_INCLUDE_PATH=$LIBFUSE_DIR/include rm -f $name -gcc -O2 -D_FILE_OFFSET_BITS=64 vtoy_fuse_iso.c -o $name $LIBFUSE_DIR/lib/libfuse.a -lpthread -ldl $opt +gcc -static -O2 -D_FILE_OFFSET_BITS=64 vtoy_fuse_iso.c -o $name $LIBFUSE_DIR/lib/libfuse.a -lpthread -ldl $opt if [ -e $name ]; then echo -e "\n############### SUCCESS $name ##################\n" diff --git a/GRUB2/grub-2.04/grub-core/ventoy/ventoy.c b/GRUB2/grub-2.04/grub-core/ventoy/ventoy.c index bf1694dc..d79532f0 100644 --- a/GRUB2/grub-2.04/grub-core/ventoy/ventoy.c +++ b/GRUB2/grub-2.04/grub-core/ventoy/ventoy.c @@ -1197,6 +1197,7 @@ static cmd_para ventoy_cmds[] = { "vt_linux_clear_initrd", ventoy_cmd_clear_initrd_list, 0, NULL, "", "", NULL }, { "vt_linux_dump_initrd", ventoy_cmd_dump_initrd_list, 0, NULL, "", "", NULL }, { "vt_linux_initrd_count", ventoy_cmd_initrd_count, 0, NULL, "", "", NULL }, + { "vt_linux_valid_initrd_count", ventoy_cmd_valid_initrd_count, 0, NULL, "", "", NULL }, { "vt_linux_locate_initrd", ventoy_cmd_linux_locate_initrd, 0, NULL, "", "", NULL }, { "vt_linux_chain_data", ventoy_cmd_linux_chain_data, 0, NULL, "", "", NULL }, diff --git a/GRUB2/grub-2.04/grub-core/ventoy/ventoy_def.h b/GRUB2/grub-2.04/grub-core/ventoy/ventoy_def.h index 4b28bc26..8e261506 100644 --- a/GRUB2/grub-2.04/grub-core/ventoy/ventoy_def.h +++ b/GRUB2/grub-2.04/grub-core/ventoy/ventoy_def.h @@ -398,6 +398,7 @@ int ventoy_has_efi_eltorito(grub_file_t file, grub_uint32_t sector); grub_err_t ventoy_cmd_linux_chain_data(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_linux_locate_initrd(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args); +grub_err_t ventoy_cmd_valid_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args); grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **args); int ventoy_cpio_newc_fill_head(void *buf, int filesize, void *filedata, const char *name); grub_file_t ventoy_grub_file_open(enum grub_file_type type, const char *fmt, ...); diff --git a/GRUB2/grub-2.04/grub-core/ventoy/ventoy_linux.c b/GRUB2/grub-2.04/grub-core/ventoy/ventoy_linux.c index cc35a845..798f5b16 100644 --- a/GRUB2/grub-2.04/grub-core/ventoy/ventoy_linux.c +++ b/GRUB2/grub-2.04/grub-core/ventoy/ventoy_linux.c @@ -543,6 +543,7 @@ grub_err_t ventoy_cmd_specify_initrd_file(grub_extcmd_context_t ctxt, int argc, grub_strncpy(img->name, args[0], sizeof(img->name)); if (ventoy_find_initrd_by_name(g_initrd_img_list, img->name)) { + debug("%s is already exist\n", args[0]); grub_free(img); } else @@ -738,6 +739,23 @@ grub_err_t ventoy_cmd_initrd_count(grub_extcmd_context_t ctxt, int argc, char ** (void)argc; (void)args; + if (argc == 1) + { + grub_snprintf(buf, sizeof(buf), "%d", g_initrd_img_count); + grub_env_set(args[0], buf); + } + + VENTOY_CMD_RETURN(GRUB_ERR_NONE); +} + +grub_err_t ventoy_cmd_valid_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args) +{ + char buf[32] = {0}; + + (void)ctxt; + (void)argc; + (void)args; + if (argc == 1) { grub_snprintf(buf, sizeof(buf), "%d", g_valid_initrd_count); @@ -750,6 +768,7 @@ grub_err_t ventoy_cmd_initrd_count(grub_extcmd_context_t ctxt, int argc, char ** static grub_err_t ventoy_linux_locate_initrd(int filt, int *filtcnt) { int data; + int filtbysize = 1; int sizefilt = 0; grub_file_t file; initrd_info *node; @@ -757,6 +776,11 @@ static grub_err_t ventoy_linux_locate_initrd(int filt, int *filtcnt) debug("ventoy_linux_locate_initrd %d\n", filt); g_valid_initrd_count = 0; + + if (grub_env_get("INITRD_NO_SIZE_FILT")) + { + filtbysize = 0; + } for (node = g_initrd_img_list; node; node = node->next) { @@ -769,12 +793,18 @@ static grub_err_t ventoy_linux_locate_initrd(int filt, int *filtcnt) debug("file <%s> size:%d\n", node->name, (int)file->size); /* initrd file too small */ - if (filt > 0 && file->size <= g_ventoy_cpio_size + 2048) + if (filtbysize + && (NULL == grub_strstr(node->name, "minirt.gz")) + && (NULL == grub_strstr(node->name, "initrd.xz")) + ) { - debug("file size too small %d\n", (int)g_ventoy_cpio_size); - grub_file_close(file); - sizefilt++; - continue; + if (filt > 0 && file->size <= g_ventoy_cpio_size + 2048) + { + debug("file size too small %d\n", (int)g_ventoy_cpio_size); + grub_file_close(file); + sizefilt++; + continue; + } } if (grub_strcmp(file->fs->name, "iso9660") == 0) diff --git a/IMG/cpio/ventoy/hook/debian/antix-disk.sh b/IMG/cpio/ventoy/hook/debian/antix-disk.sh index 31ff1ca9..5ef8f511 100644 --- a/IMG/cpio/ventoy/hook/debian/antix-disk.sh +++ b/IMG/cpio/ventoy/hook/debian/antix-disk.sh @@ -97,6 +97,9 @@ ventoy_os_install_dmsetup() { fi } + +wait_for_usb_disk_ready + vtdiskname=$(get_ventoy_disk_name) if [ "$vtdiskname" = "unknown" ]; then vtlog "ventoy disk not found" diff --git a/IMG/cpio/ventoy/hook/debian/ventoy-hook.sh b/IMG/cpio/ventoy/hook/debian/ventoy-hook.sh index 22e2790d..997e8360 100644 --- a/IMG/cpio/ventoy/hook/debian/ventoy-hook.sh +++ b/IMG/cpio/ventoy/hook/debian/ventoy-hook.sh @@ -21,11 +21,36 @@ DISTRO='default' -if [ -e /etc/initrd-release ]; then +if [ -d /KNOPPIX ]; then + DISTRO='knoppix' +elif [ -e /etc/initrd-release ]; then if $EGREP -q "ID=.*antix|ID=.*mx" /etc/initrd-release; then DISTRO='antix' fi fi +if [ -e /init ]; then + if $GREP -q PUPPYSFS /init; then + if $GREP -q VEKETSFS /init; then + DISTRO='veket' + else + DISTRO='puppy' + fi + fi +fi + +if [ -e /etc/os-release ]; then + if $GREP -q 'Tails' /etc/os-release; then + DISTRO='tails' + fi +fi + +if [ "$DISTRO"="default" ]; then + if $GREP -q 'slax/' /proc/cmdline; then + DISTRO='slax' + fi +fi + + echo "##### distribution = $DISTRO ######" >> $VTLOG . $VTOY_PATH/hook/debian/${DISTRO}-hook.sh diff --git a/IMG/cpio/ventoy/hook/gentoo/ventoy-hook.sh b/IMG/cpio/ventoy/hook/gentoo/ventoy-hook.sh index d9034fbf..2a2588bd 100644 --- a/IMG/cpio/ventoy/hook/gentoo/ventoy-hook.sh +++ b/IMG/cpio/ventoy/hook/gentoo/ventoy-hook.sh @@ -23,5 +23,9 @@ if [ -d /etc/udev/rules.d ]; then ventoy_systemd_udevd_work_around ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k noreplace" else - $SED "/mdev *-s/a\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/gentoo/disk_hook.sh" -i /init + if $GREP -q kaspersky /proc/version; then + $SED "/sysresccd_stage1_normal[^(]*$/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/gentoo/disk_hook.sh" -i /init + else + $SED "/mdev *-s/a\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/gentoo/disk_hook.sh" -i /init + fi fi diff --git a/IMG/cpio/ventoy/hook/ventoy-hook-lib.sh b/IMG/cpio/ventoy/hook/ventoy-hook-lib.sh index c182a549..76098296 100644 --- a/IMG/cpio/ventoy/hook/ventoy-hook-lib.sh +++ b/IMG/cpio/ventoy/hook/ventoy-hook-lib.sh @@ -29,7 +29,7 @@ SED=$BUSYBOX_PATH/sed SLEEP=$BUSYBOX_PATH/sleep HEAD=$BUSYBOX_PATH/head VTOY_DM_PATH=/dev/mapper/ventoy -VTOY_DEBUG_LEVEL=$($BUSYBOX_PATH/hexdump -n 1 -s 430 -e '1/1 "%02x"' $VTOY_PATH/ventoy_os_param) +VTOY_DEBUG_LEVEL=$($BUSYBOX_PATH/hexdump -n 1 -s 450 -e '1/1 "%02x"' $VTOY_PATH/ventoy_os_param) if [ "$VTOY_DEBUG_LEVEL" = "01" ]; then if [ -e /dev/console ]; then diff --git a/IMG/cpio/ventoy/init b/IMG/cpio/ventoy/init index bfb7adf4..fa3f6843 100644 --- a/IMG/cpio/ventoy/init +++ b/IMG/cpio/ventoy/init @@ -23,7 +23,7 @@ # Step 1 : parse kernel debug parameter # # # #################################################################### -mkdir /proc; mount -t proc proc /proc +[ -d /proc ] || mkdir /proc; mount -t proc proc /proc vtcmdline=$(cat /proc/cmdline) vtkerver=$(cat /proc/version) umount /proc; rm -rf /proc @@ -71,9 +71,9 @@ ventoy_unpack_initramfs() { if [ "${vtx:0:4}" = "${vtmagic:0:4}" ]; then echo "vtx=$vtx" >> $VTLOG if [ $vtskip -eq 0 ]; then - ${vtx:5} $vtfile | (cpio -idm 2>>$VTLOG; cat > $vttmp) + ${vtx:5} $vtfile | (cpio -idmu 2>>$VTLOG; cat > $vttmp) else - dd if=$vtfile skip=$vtskip iflag=skip_bytes status=none | ${vtx:5} | (cpio -idm 2>>$VTLOG; cat > $vttmp) + dd if=$vtfile skip=$vtskip iflag=skip_bytes status=none | ${vtx:5} | (cpio -idmu 2>>$VTLOG; cat > $vttmp) fi break fi @@ -98,36 +98,57 @@ ventoy_unpack_initrd() { # This export is for busybox cpio command export EXTRACT_UNSAFE_SYMLINKS=1 -for vtfile in $(ls /initrd*); do - #decompress first initrd - vtmagic=$(hexdump -n 2 -e '2/1 "%02X"' $vtfile) - - if ventoy_is_initrd_ramdisk; then - ventoy_unpack_initrd $vtfile $vtmagic ${vtfile}_tmp - mv ${vtfile}_tmp $vtfile - break +# special process +need_xzminidec() { + testmagic=$(hexdump -n 2 -e '2/1 "%02X"' /initrd001) + if [ "FD37" = "${testmagic:0:4}" ]; then + if echo $vtkerver | grep -q 'kaspersky'; then + true + elif echo $vtkerver | grep -q 'kiosk.*Gentoo'; then + true + else + false + fi else - ventoy_unpack_initramfs $vtfile 0 $vtmagic ${vtfile}_tmp + false fi +} - #only for cpio,cpio,...,initrd sequence, initrd,cpio or initrd,initrd sequence is not supported - while [ -e ${vtfile}_tmp ] && [ $(stat -c '%s' ${vtfile}_tmp) -gt 512 ]; do - mv ${vtfile}_tmp $vtfile - vtdump=$(hexdump -n 512 -e '512/1 "%02X"' $vtfile) - vtmagic=$(echo $vtdump | sed 's/^\(00\)*//') - let vtoffset="(${#vtdump}-${#vtmagic})/2" - - if [ -z "$vtmagic" ]; then - echo "terminate with all zero data file" >> $VTLOG +if need_xzminidec; then + echo "use xzminidec" >> $VTLOG + cat /initrd001 | xzminidec | cpio -idmu 2>>$VTLOG + rm -f /initrd001 +else + for vtfile in $(ls /initrd*); do + #decompress first initrd + vtmagic=$(hexdump -n 2 -e '2/1 "%02X"' $vtfile) + + if ventoy_is_initrd_ramdisk; then + ventoy_unpack_initrd $vtfile $vtmagic ${vtfile}_tmp + mv ${vtfile}_tmp $vtfile break + else + ventoy_unpack_initramfs $vtfile 0 $vtmagic ${vtfile}_tmp fi + + #only for cpio,cpio,...,initrd sequence, initrd,cpio or initrd,initrd sequence is not supported + while [ -e ${vtfile}_tmp ] && [ $(stat -c '%s' ${vtfile}_tmp) -gt 512 ]; do + mv ${vtfile}_tmp $vtfile + vtdump=$(hexdump -n 512 -e '512/1 "%02X"' $vtfile) + vtmagic=$(echo $vtdump | sed 's/^\(00\)*//') + let vtoffset="(${#vtdump}-${#vtmagic})/2" + + if [ -z "$vtmagic" ]; then + echo "terminate with all zero data file" >> $VTLOG + break + fi + + ventoy_unpack_initramfs $vtfile $vtoffset ${vtmagic:0:4} ${vtfile}_tmp + done - ventoy_unpack_initramfs $vtfile $vtoffset ${vtmagic:0:4} ${vtfile}_tmp + rm -f $vtfile ${vtfile}_tmp done - - rm -f $vtfile ${vtfile}_tmp -done - +fi #break here for debug if [ "$VTOY_BREAK_LEVEL" = "02" ] || [ "$VTOY_BREAK_LEVEL" = "12" ]; then diff --git a/IMG/cpio/ventoy/ventoy.sh b/IMG/cpio/ventoy/ventoy.sh index 6426dc83..6da1e7d0 100644 --- a/IMG/cpio/ventoy/ventoy.sh +++ b/IMG/cpio/ventoy/ventoy.sh @@ -142,6 +142,12 @@ ventoy_get_os_type() { echo 'slackware'; return fi + if [ -e /init ]; then + if $GREP -i -q zeroshell /init; then + echo 'zeroshell'; return + fi + fi + echo "default" } diff --git a/INSTALL/EFI/BOOT/BOOTX64.EFI b/INSTALL/EFI/BOOT/BOOTX64.EFI index c95e1968..691ee80f 100644 Binary files a/INSTALL/EFI/BOOT/BOOTX64.EFI and b/INSTALL/EFI/BOOT/BOOTX64.EFI differ diff --git a/INSTALL/grub/grub.cfg b/INSTALL/grub/grub.cfg index 2a71af36..92657044 100644 --- a/INSTALL/grub/grub.cfg +++ b/INSTALL/grub/grub.cfg @@ -30,7 +30,7 @@ function get_os_type { fi } -function locate_initrd { +function locate_initrd { vt_linux_locate_initrd if [ -n "${vtdebug_flag}" ]; then @@ -64,6 +64,16 @@ function distro_specify_initrd_file { if [ -e (loop)/casper/initrd-oem ]; then vt_linux_specify_initrd_file /casper/initrd-oem fi + elif [ -e (loop)/boot/grub/initrd.xz ]; then + vt_linux_specify_initrd_file /boot/grub/initrd.xz + elif [ -e (loop)/initrd.gz ]; then + vt_linux_specify_initrd_file /initrd.gz + elif [ -e (loop)/slax/boot/initrfs.img ]; then + vt_linux_specify_initrd_file /slax/boot/initrfs.img + elif [ -e (loop)/pmagic/initrd.img ]; then + vt_linux_specify_initrd_file /pmagic/initrd.img + elif [ -e (loop)/boot/initrd.xz ]; then + vt_linux_specify_initrd_file /boot/initrd.xz fi } @@ -99,28 +109,25 @@ function uefi_linux_menu_func { vt_linux_clear_initrd - for file in "boot/grub/grub.cfg" "EFI/BOOT/grub.cfg" "EFI/boot/grub.cfg" "efi/boot/grub.cfg" "EFI/BOOT/BOOTX64.conf"; do - if [ -e (loop)/$file ]; then - vt_linux_parse_initrd_grub file (loop)/$file - fi - done - - vt_linux_initrd_count initrd_count + if [ -d (loop)/pmagic ]; then + vt_linux_specify_initrd_file /pmagic/initrd.img + else + for file in "boot/grub/grub.cfg" "EFI/BOOT/grub.cfg" "EFI/boot/grub.cfg" "efi/boot/grub.cfg" "EFI/BOOT/BOOTX64.conf"; do + if [ -e (loop)/$file ]; then + vt_linux_parse_initrd_grub file (loop)/$file + fi + done + fi # special process for special distros - if vt_cmp $initrd_count eq 0; then - if [ -d (loop)/loader/entries ]; then - set LoadIsoEfiDriver=on - vt_linux_parse_initrd_grub dir (loop)/loader/entries/ - elif [ -d (loop)/boot/grub ]; then - vt_linux_parse_initrd_grub dir (loop)/boot/grub/ - fi + if [ -d (loop)/loader/entries ]; then + set LoadIsoEfiDriver=on + vt_linux_parse_initrd_grub dir (loop)/loader/entries/ + elif [ -d (loop)/boot/grub ]; then + vt_linux_parse_initrd_grub dir (loop)/boot/grub/ fi - vt_linux_initrd_count initrd_count - if vt_cmp $initrd_count eq 0; then - distro_specify_initrd_file - fi + distro_specify_initrd_file locate_initrd fi @@ -237,36 +244,33 @@ function legacy_linux_menu_func { vt_load_cpio $vtoy_path/ventoy.cpio vt_linux_clear_initrd - - for dir in "isolinux" "boot/isolinux" "boot/x86_64/loader" "syslinux" "boot/syslinux"; do - if [ -d (loop)/$dir ]; then - vt_linux_parse_initrd_isolinux (loop)/$dir/ - fi - done - vt_linux_initrd_count initrd_count + if [ -d (loop)/pmagic ]; then + vt_linux_specify_initrd_file /pmagic/initrd.img + else + for dir in "isolinux" "boot/isolinux" "boot/x86_64/loader" "syslinux" "boot/syslinux"; do + if [ -d (loop)/$dir ]; then + vt_linux_parse_initrd_isolinux (loop)/$dir/ + fi + done + fi # special process for special distros - if vt_cmp $initrd_count eq 0; then - #archlinux - if [ -d (loop)/arch/boot/syslinux ]; then - vt_linux_parse_initrd_isolinux (loop)/arch/boot/syslinux/ /arch/ - vt_linux_parse_initrd_isolinux (loop)/arch/boot/syslinux/ /arch/boot/syslinux/ - - #manjaro - elif [ -d (loop)/manjaro ]; then - if [ -e (loop)/boot/grub/kernels.cfg ]; then - vt_linux_parse_initrd_grub file (loop)/boot/grub/kernels.cfg - fi - elif [ -e (loop)/boot/grub/grub.cfg ]; then - vt_linux_parse_initrd_grub file (loop)/boot/grub/grub.cfg + #archlinux + if [ -d (loop)/arch/boot/syslinux ]; then + vt_linux_parse_initrd_isolinux (loop)/arch/boot/syslinux/ /arch/ + vt_linux_parse_initrd_isolinux (loop)/arch/boot/syslinux/ /arch/boot/syslinux/ + + #manjaro + elif [ -d (loop)/manjaro ]; then + if [ -e (loop)/boot/grub/kernels.cfg ]; then + vt_linux_parse_initrd_grub file (loop)/boot/grub/kernels.cfg fi + elif [ -e (loop)/boot/grub/grub.cfg ]; then + vt_linux_parse_initrd_grub file (loop)/boot/grub/grub.cfg fi - vt_linux_initrd_count initrd_count - if vt_cmp $initrd_count eq 0; then - distro_specify_initrd_file - fi + distro_specify_initrd_file locate_initrd fi @@ -344,7 +348,7 @@ function legacy_iso_memdisk { ############################################################# ############################################################# -set VENTOY_VERSION="1.0.04" +set VENTOY_VERSION="1.0.05" #disable timeout unset timeout @@ -358,7 +362,7 @@ vt_device $root vtoy_dev if [ "$vtoy_dev" = "tftp" ]; then set vtoy_path=($root) for vtid in 0 1 2 3; do - if [ -d (hd$vtid,2)/grub ]; then + if [ -d (hd$vtid,2)/ventoy ]; then set iso_path=(hd$vtid,1) break fi diff --git a/INSTALL/grub/i386-pc/core.img b/INSTALL/grub/i386-pc/core.img index f7792e78..ce96631d 100644 Binary files a/INSTALL/grub/i386-pc/core.img and b/INSTALL/grub/i386-pc/core.img differ diff --git a/INSTALL/ventoy/ventoy.cpio b/INSTALL/ventoy/ventoy.cpio index f4330b5b..b94fd473 100644 Binary files a/INSTALL/ventoy/ventoy.cpio and b/INSTALL/ventoy/ventoy.cpio differ diff --git a/INSTALL/ventoy/vtoyjump32.exe b/INSTALL/ventoy/vtoyjump32.exe index abe951d1..3b86178f 100644 Binary files a/INSTALL/ventoy/vtoyjump32.exe and b/INSTALL/ventoy/vtoyjump32.exe differ diff --git a/INSTALL/ventoy/vtoyjump64.exe b/INSTALL/ventoy/vtoyjump64.exe index c3e21302..27e75825 100644 Binary files a/INSTALL/ventoy/vtoyjump64.exe and b/INSTALL/ventoy/vtoyjump64.exe differ diff --git a/vtoyjump/vtoyjump/vtoyjump.c b/vtoyjump/vtoyjump/vtoyjump.c index d4aebce5..9e38b80d 100644 --- a/vtoyjump/vtoyjump/vtoyjump.c +++ b/vtoyjump/vtoyjump/vtoyjump.c @@ -28,6 +28,7 @@ #include "vtoyjump.h" #include "fat_filelib.h" +static ventoy_os_param g_os_param; static UINT8 g_os_param_reserved[32]; static BOOL g_64bit_system = FALSE; static ventoy_guid g_ventoy_guid = VENTOY_GUID; @@ -784,7 +785,6 @@ int VentoyJump(INT argc, CHAR **argv, CHAR *LunchFile) DWORD PeStart; DWORD FileSize; BYTE *Buffer = NULL; - ventoy_os_param os_param; CHAR ExeFileName[MAX_PATH]; sprintf_s(ExeFileName, sizeof(ExeFileName), "%s", argv[0]); @@ -818,9 +818,9 @@ int VentoyJump(INT argc, CHAR **argv, CHAR *LunchFile) CheckPeHead(Buffer + PeStart + sizeof(ventoy_os_param))) { Log("Find os pararm at %u", PeStart); - memcpy(&os_param, Buffer + PeStart, sizeof(ventoy_os_param)); - memcpy(g_os_param_reserved, os_param.vtoy_reserved, sizeof(g_os_param_reserved)); + memcpy(&g_os_param, Buffer + PeStart, sizeof(ventoy_os_param)); + memcpy(g_os_param_reserved, g_os_param.vtoy_reserved, sizeof(g_os_param_reserved)); if (g_os_param_reserved[0] == 1) { @@ -829,11 +829,11 @@ int VentoyJump(INT argc, CHAR **argv, CHAR *LunchFile) } // convert / to \\ - for (Pos = 0; Pos < sizeof(os_param.vtoy_img_path) && os_param.vtoy_img_path[Pos]; Pos++) + for (Pos = 0; Pos < sizeof(g_os_param.vtoy_img_path) && g_os_param.vtoy_img_path[Pos]; Pos++) { - if (os_param.vtoy_img_path[Pos] == '/') + if (g_os_param.vtoy_img_path[Pos] == '/') { - os_param.vtoy_img_path[Pos] = '\\'; + g_os_param.vtoy_img_path[Pos] = '\\'; } } @@ -857,7 +857,7 @@ int VentoyJump(INT argc, CHAR **argv, CHAR *LunchFile) goto End; } - rc = VentoyHook(&os_param); + rc = VentoyHook(&g_os_param); End: @@ -912,35 +912,31 @@ int main(int argc, char **argv) GetStartupInfoA(&Si); - for (i = 0; i < 10; i++) + memset(LunchFile, 0, sizeof(LunchFile)); + rc = VentoyJump(argc, argv, LunchFile); + + if (g_os_param_reserved[0] == 3) + { + Log("Open log for debug ..."); + sprintf_s(LunchFile, sizeof(LunchFile), "%s", "notepad.exe ventoy.log"); + } + else { - Log("VentoyJump loop %d", i + 1); + Si.dwFlags |= STARTF_USESHOWWINDOW; + Si.wShowWindow = SW_HIDE; + Log("Ventoy jump %s ...", rc == 0 ? "success" : "failed"); + } - memset(LunchFile, 0, sizeof(LunchFile)); - rc = VentoyJump(argc, argv, LunchFile); + CreateProcessA(NULL, LunchFile, NULL, NULL, FALSE, 0, NULL, NULL, &Si, &Pi); - if (g_os_param_reserved[0] == 3) - { - Log("Open log for debug ..."); - sprintf_s(LunchFile, sizeof(LunchFile), "%s", "notepad.exe ventoy.log"); - break; - } - else if (rc == 0) - { - Log("Ventoy jump success ..."); - Si.dwFlags |= STARTF_USESHOWWINDOW; - Si.wShowWindow = SW_HIDE; - break; - } - else - { - Log("Ventoy jump fail, now wait ..."); - sprintf_s(LunchFile, sizeof(LunchFile), "%s", "cmd.exe"); - Sleep(3000); - } + while (rc) + { + Log("Ventoy hook failed, now wait and retry ..."); + Sleep(1000); + + rc = VentoyHook(&g_os_param); } - CreateProcessA(NULL, LunchFile, NULL, NULL, FALSE, 0, NULL, NULL, &Si, &Pi); WaitForSingleObject(Pi.hProcess, INFINITE); return 0;