1 /******************************************************************************
4 * Copyright (c) 2020, longpanda <admin@ventoy.net>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 3 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
27 #include <VersionHelpers.h>
29 #include "fat_filelib.h"
31 static UINT8 g_os_param_reserved
[32];
32 static BOOL g_64bit_system
= FALSE
;
33 static ventoy_guid g_ventoy_guid
= VENTOY_GUID
;
35 void Log(const char *Fmt
, ...)
44 Len
+= sprintf_s(szBuf
, sizeof(szBuf
),
45 "[%4d/%02d/%02d %02d:%02d:%02d.%03d] ",
46 Sys
.wYear
, Sys
.wMonth
, Sys
.wDay
,
47 Sys
.wHour
, Sys
.wMinute
, Sys
.wSecond
,
51 Len
+= vsnprintf_s(szBuf
+ Len
, sizeof(szBuf
)-Len
, sizeof(szBuf
)-Len
, Fmt
, Arg
);
54 fopen_s(&File
, "ventoy.log", "a+");
57 fwrite(szBuf
, 1, Len
, File
);
58 fwrite("\n", 1, 1, File
);
64 static int LoadNtDriver(const char *DrvBinPath
)
70 SC_HANDLE hServiceMgr
;
72 char name
[256] = { 0 };
74 for (i
= (int)strlen(DrvBinPath
) - 1; i
>= 0; i
--)
76 if (DrvBinPath
[i
] == '\\' || DrvBinPath
[i
] == '/')
78 sprintf_s(name
, sizeof(name
), "%s", DrvBinPath
+ i
+ 1);
83 Log("Load NT driver: %s %s", DrvBinPath
, name
);
85 hServiceMgr
= OpenSCManagerA(NULL
, NULL
, SC_MANAGER_ALL_ACCESS
);
86 if (hServiceMgr
== NULL
)
88 Log("OpenSCManager failed Error:%u", GetLastError());
92 Log("OpenSCManager OK");
94 hService
= CreateServiceA(hServiceMgr
,
98 SERVICE_KERNEL_DRIVER
,
100 SERVICE_ERROR_NORMAL
,
102 NULL
, NULL
, NULL
, NULL
, NULL
);
103 if (hService
== NULL
)
105 Status
= GetLastError();
106 if (Status
!= ERROR_IO_PENDING
&& Status
!= ERROR_SERVICE_EXISTS
)
108 Log("CreateService failed v %u", Status
);
109 CloseServiceHandle(hServiceMgr
);
113 hService
= OpenServiceA(hServiceMgr
, name
, SERVICE_ALL_ACCESS
);
114 if (hService
== NULL
)
116 Log("OpenService failed %u", Status
);
117 CloseServiceHandle(hServiceMgr
);
122 Log("CreateService imdisk OK");
124 Ret
= StartServiceA(hService
, 0, NULL
);
127 Log("StartService OK");
131 Status
= GetLastError();
132 if (Status
== ERROR_SERVICE_ALREADY_RUNNING
)
138 Log("StartService error %u", Status
);
143 CloseServiceHandle(hService
);
144 CloseServiceHandle(hServiceMgr
);
146 Log("Load NT driver %s", rc
? "failed" : "success");
151 static int ReadWholeFile2Buf(const char *Fullpath
, void **Data
, DWORD
*Size
)
159 Log("ReadWholeFile2Buf <%s>", Fullpath
);
161 Handle
= CreateFileA(Fullpath
, GENERIC_READ
, FILE_SHARE_READ
| FILE_SHARE_WRITE
, 0, OPEN_EXISTING
, 0, 0);
162 if (Handle
== INVALID_HANDLE_VALUE
)
164 Log("Could not open the file<%s>, error:%u", Fullpath
, GetLastError());
168 FileSize
= SetFilePointer(Handle
, 0, NULL
, FILE_END
);
170 Buffer
= malloc(FileSize
);
173 Log("Failed to alloc memory size:%u", FileSize
);
177 SetFilePointer(Handle
, 0, NULL
, FILE_BEGIN
);
178 if (!ReadFile(Handle
, Buffer
, FileSize
, &dwSize
, NULL
))
180 Log("ReadFile failed, dwSize:%u error:%u", dwSize
, GetLastError());
187 Log("Success read file size:%u", FileSize
);
192 SAFE_CLOSE_HANDLE(Handle
);
197 static BOOL
CheckPeHead(BYTE
*Head
)
201 if (Head
[0] != 'M' || Head
[1] != 'Z')
206 PeOffset
= *(UINT32
*)(Head
+ 60);
207 if (*(UINT32
*)(Head
+ PeOffset
) != 0x00004550)
215 static BOOL
IsPe64(BYTE
*buffer
)
219 if (!CheckPeHead(buffer
))
224 pe_off
= *(UINT32
*)(buffer
+ 60);
225 if (*(UINT16
*)(buffer
+ pe_off
+ 24) == 0x020b)
234 static BOOL
CheckOsParam(ventoy_os_param
*param
)
239 if (memcmp(¶m
->guid
, &g_ventoy_guid
, sizeof(ventoy_guid
)))
244 for (i
= 0; i
< sizeof(ventoy_os_param
); i
++)
246 Sum
+= *((BYTE
*)param
+ i
);
254 if (param
->vtoy_img_location_addr
% 4096)
262 static int SaveBuffer2File(const char *Fullpath
, void *Buffer
, DWORD Length
)
268 Log("SaveBuffer2File <%s> len:%u", Fullpath
, Length
);
270 Handle
= CreateFileA(Fullpath
, GENERIC_READ
| GENERIC_WRITE
,
271 FILE_SHARE_READ
| FILE_SHARE_WRITE
, 0, CREATE_NEW
, 0, 0);
272 if (Handle
== INVALID_HANDLE_VALUE
)
274 Log("Could not create new file, error:%u", GetLastError());
278 WriteFile(Handle
, Buffer
, Length
, &dwSize
, NULL
);
283 SAFE_CLOSE_HANDLE(Handle
);
288 static BOOL
IsPathExist(BOOL Dir
, const char *Fmt
, ...)
293 CHAR FilePath
[MAX_PATH
];
296 vsnprintf_s(FilePath
, sizeof(FilePath
), sizeof(FilePath
), Fmt
, Arg
);
299 hFile
= CreateFileA(FilePath
, FILE_READ_EA
, FILE_SHARE_READ
, 0, OPEN_EXISTING
, 0, 0);
300 if (INVALID_HANDLE_VALUE
== hFile
)
307 Attr
= GetFileAttributesA(FilePath
);
311 if ((Attr
& FILE_ATTRIBUTE_DIRECTORY
) == 0)
318 if (Attr
& FILE_ATTRIBUTE_DIRECTORY
)
327 static int GetPhyDiskUUID(const char LogicalDrive
, UINT8
*UUID
, DISK_EXTENT
*DiskExtent
)
332 VOLUME_DISK_EXTENTS DiskExtents
;
334 UINT8 SectorBuf
[512];
336 Log("GetPhyDiskUUID %C", LogicalDrive
);
338 sprintf_s(PhyPath
, sizeof(PhyPath
), "\\\\.\\%C:", LogicalDrive
);
339 Handle
= CreateFileA(PhyPath
, GENERIC_READ
, FILE_SHARE_READ
| FILE_SHARE_WRITE
, 0, OPEN_EXISTING
, 0, 0);
340 if (Handle
== INVALID_HANDLE_VALUE
)
342 Log("Could not open the disk<%s>, error:%u", PhyPath
, GetLastError());
346 Ret
= DeviceIoControl(Handle
,
347 IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
,
351 (DWORD
)(sizeof(DiskExtents
)),
354 if (!Ret
|| DiskExtents
.NumberOfDiskExtents
== 0)
356 Log("DeviceIoControl IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS failed, error:%u", GetLastError());
362 memcpy(DiskExtent
, DiskExtents
.Extents
, sizeof(DiskExtent
));
363 Log("%C: is in PhysicalDrive%d ", LogicalDrive
, DiskExtents
.Extents
[0].DiskNumber
);
365 sprintf_s(PhyPath
, sizeof(PhyPath
), "\\\\.\\PhysicalDrive%d", DiskExtents
.Extents
[0].DiskNumber
);
366 Handle
= CreateFileA(PhyPath
, GENERIC_READ
, FILE_SHARE_READ
| FILE_SHARE_WRITE
, 0, OPEN_EXISTING
, 0, 0);
367 if (Handle
== INVALID_HANDLE_VALUE
)
369 Log("Could not open the disk<%s>, error:%u", PhyPath
, GetLastError());
373 if (!ReadFile(Handle
, SectorBuf
, sizeof(SectorBuf
), &dwSize
, NULL
))
375 Log("ReadFile failed, dwSize:%u error:%u", dwSize
, GetLastError());
380 memcpy(UUID
, SectorBuf
+ 0x180, 16);
385 int VentoyMountISOByAPI(const char *IsoPath
)
389 WCHAR wFilePath
[512] = { 0 };
390 VIRTUAL_STORAGE_TYPE StorageType
;
391 OPEN_VIRTUAL_DISK_PARAMETERS OpenParameters
;
392 ATTACH_VIRTUAL_DISK_PARAMETERS AttachParameters
;
394 Log("VentoyMountISOByAPI <%s>", IsoPath
);
396 MultiByteToWideChar(CP_ACP
, 0, IsoPath
, (int)strlen(IsoPath
), wFilePath
, (int)(sizeof(wFilePath
) / sizeof(WCHAR
)));
398 memset(&StorageType
, 0, sizeof(StorageType
));
399 memset(&OpenParameters
, 0, sizeof(OpenParameters
));
400 memset(&AttachParameters
, 0, sizeof(AttachParameters
));
402 OpenParameters
.Version
= OPEN_VIRTUAL_DISK_VERSION_1
;
403 AttachParameters
.Version
= ATTACH_VIRTUAL_DISK_VERSION_1
;
405 Status
= OpenVirtualDisk(&StorageType
, wFilePath
, VIRTUAL_DISK_ACCESS_READ
, 0, &OpenParameters
, &Handle
);
406 if (Status
!= ERROR_SUCCESS
)
408 if (ERROR_VIRTDISK_PROVIDER_NOT_FOUND
== Status
)
410 Log("VirtualDisk for ISO file is not supported in current system");
414 Log("Failed to open virtual disk ErrorCode:%u", Status
);
419 Log("OpenVirtualDisk success");
421 Status
= AttachVirtualDisk(Handle
, NULL
, ATTACH_VIRTUAL_DISK_FLAG_READ_ONLY
| ATTACH_VIRTUAL_DISK_FLAG_PERMANENT_LIFETIME
, 0, &AttachParameters
, NULL
);
422 if (Status
!= ERROR_SUCCESS
)
424 Log("Failed to attach virtual disk ErrorCode:%u", Status
);
434 static HANDLE g_FatPhyDrive
;
435 static UINT64 g_Part2StartSec
;
437 static int CopyFileFromFatDisk(const CHAR
* SrcFile
, const CHAR
*DstFile
)
444 Log("CopyFileFromFatDisk (%s)==>(%s)", SrcFile
, DstFile
);
446 flfile
= fl_fopen(SrcFile
, "rb");
449 fl_fseek(flfile
, 0, SEEK_END
);
450 size
= (int)fl_ftell(flfile
);
451 fl_fseek(flfile
, 0, SEEK_SET
);
453 buf
= (char *)malloc(size
);
456 fl_fread(buf
, 1, size
, flfile
);
459 SaveBuffer2File(DstFile
, buf
, size
);
469 static int VentoyFatDiskRead(uint32 Sector
, uint8
*Buffer
, uint32 SectorCount
)
474 LARGE_INTEGER liCurrentPosition
;
476 liCurrentPosition
.QuadPart
= Sector
+ g_Part2StartSec
;
477 liCurrentPosition
.QuadPart
*= 512;
478 SetFilePointerEx(g_FatPhyDrive
, liCurrentPosition
, &liCurrentPosition
, FILE_BEGIN
);
480 ReadSize
= (DWORD
)(SectorCount
* 512);
482 bRet
= ReadFile(g_FatPhyDrive
, Buffer
, ReadSize
, &dwSize
, NULL
);
483 if (bRet
== FALSE
|| dwSize
!= ReadSize
)
485 Log("ReadFile error bRet:%u WriteSize:%u dwSize:%u ErrCode:%u\n", bRet
, ReadSize
, dwSize
, GetLastError());
491 static CHAR
GetMountLogicalDrive(void)
495 DWORD Mask
= 0x2000000;
497 Drives
= GetLogicalDrives();
498 Log("Drives=0x%x", Drives
);
502 if ((Drives
& Mask
) == 0)
514 int VentoyMountISOByImdisk(const char *IsoPath
, DWORD PhyDrive
)
521 CHAR PhyPath
[MAX_PATH
];
523 PROCESS_INFORMATION Pi
;
524 GET_LENGTH_INFORMATION LengthInfo
;
526 Log("VentoyMountISOByImdisk %s", IsoPath
);
528 sprintf_s(PhyPath
, sizeof(PhyPath
), "\\\\.\\PhysicalDrive%d", PhyDrive
);
529 hDrive
= CreateFileA(PhyPath
, GENERIC_READ
, FILE_SHARE_READ
| FILE_SHARE_WRITE
, 0, OPEN_EXISTING
, 0, 0);
530 if (hDrive
== INVALID_HANDLE_VALUE
)
532 Log("Could not open the disk<%s>, error:%u", PhyPath
, GetLastError());
536 bRet
= DeviceIoControl(hDrive
, IOCTL_DISK_GET_LENGTH_INFO
, NULL
, 0, &LengthInfo
, sizeof(LengthInfo
), &dwBytes
, NULL
);
539 Log("Could not get phy disk %s size, error:%u", PhyPath
, GetLastError());
543 g_FatPhyDrive
= hDrive
;
544 g_Part2StartSec
= (LengthInfo
.Length
.QuadPart
- VENTOY_EFI_PART_SIZE
) / 512;
546 Log("Parse FAT fs...");
550 if (0 == fl_attach_media(VentoyFatDiskRead
, NULL
))
554 CopyFileFromFatDisk("/ventoy/imdisk/64/imdisk.sys", "ventoy\\imdisk.sys");
555 CopyFileFromFatDisk("/ventoy/imdisk/64/imdisk.exe", "ventoy\\imdisk.exe");
556 CopyFileFromFatDisk("/ventoy/imdisk/64/imdisk.cpl", "ventoy\\imdisk.cpl");
560 CopyFileFromFatDisk("/ventoy/imdisk/32/imdisk.sys", "ventoy\\imdisk.sys");
561 CopyFileFromFatDisk("/ventoy/imdisk/32/imdisk.exe", "ventoy\\imdisk.exe");
562 CopyFileFromFatDisk("/ventoy/imdisk/32/imdisk.cpl", "ventoy\\imdisk.cpl");
565 GetCurrentDirectoryA(sizeof(PhyPath
), PhyPath
);
566 strcat_s(PhyPath
, sizeof(PhyPath
), "\\ventoy\\imdisk.sys");
568 if (LoadNtDriver(PhyPath
) == 0)
572 Letter
= GetMountLogicalDrive();
573 sprintf_s(PhyPath
, sizeof(PhyPath
), "ventoy\\imdisk.exe -a -o ro -f %s -m %C:", IsoPath
, Letter
);
575 Log("mount iso to %C: use imdisk cmd <%s>", Letter
, PhyPath
);
577 GetStartupInfoA(&Si
);
579 Si
.dwFlags
|= STARTF_USESHOWWINDOW
;
580 Si
.wShowWindow
= SW_HIDE
;
582 CreateProcessA(NULL
, PhyPath
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &Si
, &Pi
);
583 WaitForSingleObject(Pi
.hProcess
, INFINITE
);
590 SAFE_CLOSE_HANDLE(hDrive
);
595 static int MountIsoFile(CONST CHAR
*IsoPath
, DWORD PhyDrive
)
597 if (IsWindows8OrGreater())
599 Log("This is Windows 8 or latter...");
600 if (VentoyMountISOByAPI(IsoPath
) == 0)
602 Log("Mount iso by API success");
607 Log("Mount iso by API failed, maybe not supported, try imdisk");
608 return VentoyMountISOByImdisk(IsoPath
, PhyDrive
);
613 Log("This is before Windows 8 ...");
614 if (VentoyMountISOByImdisk(IsoPath
, PhyDrive
) == 0)
616 Log("Mount iso by imdisk success");
621 return VentoyMountISOByAPI(IsoPath
);
626 static int GetPhyDriveByLogicalDrive(int DriveLetter
)
631 VOLUME_DISK_EXTENTS DiskExtents
;
634 sprintf_s(PhyPath
, sizeof(PhyPath
), "\\\\.\\%C:", (CHAR
)DriveLetter
);
636 Handle
= CreateFileA(PhyPath
, GENERIC_READ
, FILE_SHARE_READ
| FILE_SHARE_WRITE
, 0, OPEN_EXISTING
, 0, 0);
637 if (Handle
== INVALID_HANDLE_VALUE
)
639 Log("Could not open the disk<%s>, error:%u", PhyPath
, GetLastError());
643 Ret
= DeviceIoControl(Handle
,
644 IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
,
648 (DWORD
)(sizeof(DiskExtents
)),
652 if (!Ret
|| DiskExtents
.NumberOfDiskExtents
== 0)
654 Log("DeviceIoControl IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS failed %s, error:%u", PhyPath
, GetLastError());
655 SAFE_CLOSE_HANDLE(Handle
);
658 SAFE_CLOSE_HANDLE(Handle
);
660 Log("LogicalDrive:%s PhyDrive:%d Offset:%llu ExtentLength:%llu",
662 DiskExtents
.Extents
[0].DiskNumber
,
663 DiskExtents
.Extents
[0].StartingOffset
.QuadPart
,
664 DiskExtents
.Extents
[0].ExtentLength
.QuadPart
667 return (int)DiskExtents
.Extents
[0].DiskNumber
;
671 static int DeleteVentoyPart2MountPoint(DWORD PhyDrive
)
676 CHAR DriveName
[] = "?:\\";
678 Log("DeleteVentoyPart2MountPoint Phy%u ...", PhyDrive
);
680 Drives
= GetLogicalDrives();
683 if ((Drives
& 0x01) && IsPathExist(FALSE
, "%C:\\ventoy\\ventoy.cpio", Letter
))
685 Log("File %C:\\ventoy\\ventoy.cpio exist", Letter
);
687 PhyDisk
= GetPhyDriveByLogicalDrive(Letter
);
688 Log("PhyDisk=%u for %C", PhyDisk
, Letter
);
690 if (PhyDisk
== PhyDrive
)
692 DriveName
[0] = Letter
;
693 DeleteVolumeMountPointA(DriveName
);
705 static int VentoyHook(ventoy_os_param
*param
)
709 DISK_EXTENT DiskExtent
;
710 DWORD Drives
= GetLogicalDrives();
712 CHAR IsoPath
[MAX_PATH
];
714 Log("Logical Drives=0x%x Path:<%s>", Drives
, param
->vtoy_img_path
);
720 sprintf_s(IsoPath
, sizeof(IsoPath
), "%C:\\%s", Letter
, param
->vtoy_img_path
);
721 if (IsPathExist(FALSE
, "%s", IsoPath
))
723 Log("File exist under %C:", Letter
);
724 if (GetPhyDiskUUID(Letter
, UUID
, &DiskExtent
) == 0)
726 if (memcmp(UUID
, param
->vtoy_disk_guid
, 16) == 0)
728 Log("Disk UUID match");
735 Log("File NOT exist under %C:", Letter
);
745 Log("Failed to find ISO file");
749 Log("Find ISO file <%s>", IsoPath
);
751 rc
= MountIsoFile(IsoPath
, DiskExtent
.DiskNumber
);
752 Log("Mount ISO FILE: %s", rc
== 0 ? "SUCCESS" : "FAILED");
755 rc
= DeleteVentoyPart2MountPoint(DiskExtent
.DiskNumber
);
756 Log("Delete ventoy mountpoint: %s", rc
== 0 ? "SUCCESS" : "NO NEED");
761 const char * GetFileNameInPath(const char *fullpath
)
764 const char *pos
= NULL
;
766 if (strstr(fullpath
, ":"))
768 for (i
= (int)strlen(fullpath
); i
> 0; i
--)
770 if (fullpath
[i
- 1] == '/' || fullpath
[i
- 1] == '\\')
780 int VentoyJump(INT argc
, CHAR
**argv
, CHAR
*LunchFile
)
787 ventoy_os_param os_param
;
788 CHAR ExeFileName
[MAX_PATH
];
790 sprintf_s(ExeFileName
, sizeof(ExeFileName
), "%s", argv
[0]);
791 if (!IsPathExist(FALSE
, "%s", ExeFileName
))
793 Log("File %s NOT exist, now try %s.exe", ExeFileName
, ExeFileName
);
794 sprintf_s(ExeFileName
, sizeof(ExeFileName
), "%s.exe", argv
[0]);
796 Log("File %s exist ? %s", ExeFileName
, IsPathExist(FALSE
, "%s", ExeFileName
) ? "YES" : "NO");
799 if (ReadWholeFile2Buf(ExeFileName
, (void **)&Buffer
, &FileSize
))
804 g_64bit_system
= IsPe64(Buffer
);
806 if (!IsPathExist(TRUE
, "ventoy"))
808 if (!CreateDirectoryA("ventoy", NULL
))
810 Log("Failed to create ventoy directory err:%u", GetLastError());
815 for (PeStart
= 0; PeStart
< FileSize
; PeStart
+= 16)
817 if (CheckOsParam((ventoy_os_param
*)(Buffer
+ PeStart
)) &&
818 CheckPeHead(Buffer
+ PeStart
+ sizeof(ventoy_os_param
)))
820 Log("Find os pararm at %u", PeStart
);
821 memcpy(&os_param
, Buffer
+ PeStart
, sizeof(ventoy_os_param
));
823 memcpy(g_os_param_reserved
, os_param
.vtoy_reserved
, sizeof(g_os_param_reserved
));
825 if (g_os_param_reserved
[0] == 1)
827 Log("break here for debug .....");
832 for (Pos
= 0; Pos
< sizeof(os_param
.vtoy_img_path
) && os_param
.vtoy_img_path
[Pos
]; Pos
++)
834 if (os_param
.vtoy_img_path
[Pos
] == '/')
836 os_param
.vtoy_img_path
[Pos
] = '\\';
840 PeStart
+= sizeof(ventoy_os_param
);
841 sprintf_s(LunchFile
, MAX_PATH
, "ventoy\\%s", GetFileNameInPath(ExeFileName
));
842 SaveBuffer2File(LunchFile
, Buffer
+ PeStart
, FileSize
- PeStart
);
847 if (PeStart
>= FileSize
)
849 Log("OS param not found");
853 if (g_os_param_reserved
[0] == 2)
855 Log("skip hook for debug .....");
860 rc
= VentoyHook(&os_param
);
872 int main(int argc
, char **argv
)
877 CHAR CurDir
[MAX_PATH
];
878 CHAR LunchFile
[MAX_PATH
];
880 PROCESS_INFORMATION Pi
;
882 if (argv
[0] && argv
[0][0] && argv
[0][1] == ':')
884 GetCurrentDirectoryA(sizeof(CurDir
), CurDir
);
886 strcpy_s(LunchFile
, sizeof(LunchFile
), argv
[0]);
887 Pos
= (char *)GetFileNameInPath(LunchFile
);
889 strcat_s(CurDir
, sizeof(CurDir
), "\\");
890 strcat_s(CurDir
, sizeof(CurDir
), Pos
);
892 if (_stricmp(argv
[0], CurDir
) != 0)
895 SetCurrentDirectoryA(LunchFile
);
899 Log("######## VentoyJump ##########");
900 Log("argc = %d argv[0] = <%s>", argc
, argv
[0]);
902 if (Pos
&& *Pos
== 0)
904 Log("Old current directory = <%s>", CurDir
);
905 Log("New current directory = <%s>", LunchFile
);
909 GetCurrentDirectoryA(sizeof(CurDir
), CurDir
);
910 Log("Current directory = <%s>", CurDir
);
913 GetStartupInfoA(&Si
);
915 for (i
= 0; i
< 10; i
++)
917 Log("VentoyJump loop %d", i
+ 1);
919 memset(LunchFile
, 0, sizeof(LunchFile
));
920 rc
= VentoyJump(argc
, argv
, LunchFile
);
922 if (g_os_param_reserved
[0] == 3)
924 Log("Open log for debug ...");
925 sprintf_s(LunchFile
, sizeof(LunchFile
), "%s", "notepad.exe ventoy.log");
930 Log("Ventoy jump success ...");
931 Si
.dwFlags
|= STARTF_USESHOWWINDOW
;
932 Si
.wShowWindow
= SW_HIDE
;
937 Log("Ventoy jump fail, now wait ...");
938 sprintf_s(LunchFile
, sizeof(LunchFile
), "%s", "cmd.exe");
943 CreateProcessA(NULL
, LunchFile
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &Si
, &Pi
);
944 WaitForSingleObject(Pi
.hProcess
, INFINITE
);