Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dadigang
Ventoy
Commits
5a7fa0c5
Commit
5a7fa0c5
authored
Jan 03, 2023
by
longpanda
Browse files
Support lenovo product recovery iso file.
parent
287d7722
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
122 additions
and
5 deletions
+122
-5
INSTALL/grub/grub.cfg
INSTALL/grub/grub.cfg
+2
-0
INSTALL/ventoy/vtoyjump32.exe
INSTALL/ventoy/vtoyjump32.exe
+0
-0
INSTALL/ventoy/vtoyjump64.exe
INSTALL/ventoy/vtoyjump64.exe
+0
-0
vtoyjump/vtoyjump/vtoyjump.c
vtoyjump/vtoyjump/vtoyjump.c
+120
-5
No files found.
INSTALL/grub/grub.cfg
View file @
5a7fa0c5
...
@@ -227,6 +227,8 @@ function distro_specify_wim_patch {
...
@@ -227,6 +227,8 @@ function distro_specify_wim_patch {
function distro_specify_wim_patch_phase2 {
function distro_specify_wim_patch_phase2 {
if [ -f (loop)/boot/boot.wim ]; then
if [ -f (loop)/boot/boot.wim ]; then
vt_windows_collect_wim_patch wim /boot/boot.wim
vt_windows_collect_wim_patch wim /boot/boot.wim
elif [ -f (loop)/sources/boot.wim ]; then
vt_windows_collect_wim_patch wim /sources/boot.wim
fi
fi
if vt_str_begin "$vt_volume_id" "DLC Boot"; then
if vt_str_begin "$vt_volume_id" "DLC Boot"; then
...
...
INSTALL/ventoy/vtoyjump32.exe
View file @
5a7fa0c5
No preview for this file type
INSTALL/ventoy/vtoyjump64.exe
View file @
5a7fa0c5
No preview for this file type
vtoyjump/vtoyjump/vtoyjump.c
View file @
5a7fa0c5
...
@@ -60,6 +60,23 @@ static CHAR g_prog_name[MAX_PATH];
...
@@ -60,6 +60,23 @@ static CHAR g_prog_name[MAX_PATH];
#define MUTEX_LOCK(hmutex) if (hmutex != NULL) LockStatus = WaitForSingleObject(hmutex, INFINITE)
#define MUTEX_LOCK(hmutex) if (hmutex != NULL) LockStatus = WaitForSingleObject(hmutex, INFINITE)
#define MUTEX_UNLOCK(hmutex) if (hmutex != NULL && WAIT_OBJECT_0 == LockStatus) ReleaseMutex(hmutex)
#define MUTEX_UNLOCK(hmutex) if (hmutex != NULL && WAIT_OBJECT_0 == LockStatus) ReleaseMutex(hmutex)
#define BREAK() BreakAndLaunchCmd(__LINE__)
static
void
BreakAndLaunchCmd
(
int
line
)
{
STARTUPINFOA
Si
;
PROCESS_INFORMATION
Pi
;
Log
(
"Break at line:%d"
,
line
);
GetStartupInfoA
(
&
Si
);
Si
.
dwFlags
|=
STARTF_USESHOWWINDOW
;
Si
.
wShowWindow
=
SW_NORMAL
;
CreateProcessA
(
NULL
,
"cmd.exe"
,
NULL
,
NULL
,
FALSE
,
0
,
NULL
,
NULL
,
&
Si
,
&
Pi
);
WaitForSingleObject
(
Pi
.
hProcess
,
INFINITE
);
}
static
const
char
*
GetFileNameInPath
(
const
char
*
fullpath
)
static
const
char
*
GetFileNameInPath
(
const
char
*
fullpath
)
{
{
int
i
;
int
i
;
...
@@ -459,6 +476,16 @@ static int IsUTF8Encode(const char *src)
...
@@ -459,6 +476,16 @@ static int IsUTF8Encode(const char *src)
return
0
;
return
0
;
}
}
static
int
Utf16ToUtf8
(
const
WCHAR
*
src
,
char
*
dst
)
{
int
len
;
int
size
;
len
=
(
int
)
wcslen
(
src
)
+
1
;
size
=
WideCharToMultiByte
(
CP_UTF8
,
0
,
src
,
len
,
NULL
,
0
,
NULL
,
NULL
);
return
WideCharToMultiByte
(
CP_UTF8
,
0
,
src
,
len
,
dst
,
size
,
NULL
,
NULL
);
}
static
int
Utf8ToUtf16
(
const
char
*
src
,
WCHAR
*
dst
)
static
int
Utf8ToUtf16
(
const
char
*
src
,
WCHAR
*
dst
)
{
{
int
size
=
MultiByteToWideChar
(
CP_UTF8
,
0
,
src
,
-
1
,
dst
,
0
);
int
size
=
MultiByteToWideChar
(
CP_UTF8
,
0
,
src
,
-
1
,
dst
,
0
);
...
@@ -1046,7 +1073,7 @@ End:
...
@@ -1046,7 +1073,7 @@ End:
return
rc
;
return
rc
;
}
}
static
int
VentoyRunImdisk
(
const
char
*
IsoPath
,
const
char
*
imdiskexe
)
static
int
VentoyRunImdisk
(
const
char
*
IsoPath
,
const
char
*
imdiskexe
,
const
char
*
ExOpt
)
{
{
CHAR
Letter
;
CHAR
Letter
;
CHAR
Cmdline
[
512
];
CHAR
Cmdline
[
512
];
...
@@ -1056,7 +1083,16 @@ static int VentoyRunImdisk(const char *IsoPath, const char *imdiskexe)
...
@@ -1056,7 +1083,16 @@ static int VentoyRunImdisk(const char *IsoPath, const char *imdiskexe)
Log
(
"VentoyRunImdisk <%s> <%s>"
,
IsoPath
,
imdiskexe
);
Log
(
"VentoyRunImdisk <%s> <%s>"
,
IsoPath
,
imdiskexe
);
Letter
=
GetIMDiskMountLogicalDrive
();
Letter
=
GetIMDiskMountLogicalDrive
();
if
(
ExOpt
)
{
sprintf_s
(
Cmdline
,
sizeof
(
Cmdline
),
"%s -a -o ro,%s -f
\"
%s
\"
-m %C:"
,
imdiskexe
,
ExOpt
,
IsoPath
,
Letter
);
}
else
{
sprintf_s
(
Cmdline
,
sizeof
(
Cmdline
),
"%s -a -o ro -f
\"
%s
\"
-m %C:"
,
imdiskexe
,
IsoPath
,
Letter
);
sprintf_s
(
Cmdline
,
sizeof
(
Cmdline
),
"%s -a -o ro -f
\"
%s
\"
-m %C:"
,
imdiskexe
,
IsoPath
,
Letter
);
}
Log
(
"mount iso to %C: use imdisk cmd <%s>"
,
Letter
,
Cmdline
);
Log
(
"mount iso to %C: use imdisk cmd <%s>"
,
Letter
,
Cmdline
);
if
(
IsUTF8Encode
(
IsoPath
))
if
(
IsUTF8Encode
(
IsoPath
))
...
@@ -1099,7 +1135,7 @@ int VentoyMountISOByImdisk(const char *IsoPath, DWORD PhyDrive)
...
@@ -1099,7 +1135,7 @@ int VentoyMountISOByImdisk(const char *IsoPath, DWORD PhyDrive)
if
(
0
==
VentoyCopyImdisk
(
PhyDrive
,
ImPath
))
if
(
0
==
VentoyCopyImdisk
(
PhyDrive
,
ImPath
))
{
{
VentoyRunImdisk
(
IsoPath
,
ImPath
);
VentoyRunImdisk
(
IsoPath
,
ImPath
,
NULL
);
rc
=
0
;
rc
=
0
;
}
}
...
@@ -2269,6 +2305,75 @@ static BOOL CheckVentoyDisk(DWORD DiskNum)
...
@@ -2269,6 +2305,75 @@ static BOOL CheckVentoyDisk(DWORD DiskNum)
return
FALSE
;
return
FALSE
;
}
}
static
BOOL
VentoyIsLenovoRecovery
(
CHAR
*
IsoPath
,
CHAR
*
VTLRIPath
)
{
int
n
;
int
UTF8
=
0
;
HANDLE
hFile
;
DWORD
Attr
;
WCHAR
FilePathW
[
MAX_PATH
];
UTF8
=
IsUTF8Encode
(
IsoPath
);
if
(
UTF8
)
{
Utf8ToUtf16
(
IsoPath
,
FilePathW
);
n
=
(
int
)
wcslen
(
FilePathW
);
if
(
n
>
4
&&
_wcsicmp
(
FilePathW
+
n
-
4
,
L".iso"
)
==
0
)
{
FilePathW
[
n
-
3
]
=
L'V'
;
FilePathW
[
n
-
2
]
=
L'T'
;
FilePathW
[
n
-
1
]
=
L'L'
;
FilePathW
[
n
-
0
]
=
L'R'
;
FilePathW
[
n
+
1
]
=
L'I'
;
FilePathW
[
n
+
2
]
=
0
;
hFile
=
CreateFileW
(
FilePathW
,
FILE_READ_EA
,
FILE_SHARE_READ
,
0
,
OPEN_EXISTING
,
0
,
0
);
if
(
hFile
!=
INVALID_HANDLE_VALUE
)
{
CloseHandle
(
hFile
);
Attr
=
GetFileAttributesW
(
FilePathW
);
if
((
Attr
&
FILE_ATTRIBUTE_DIRECTORY
)
==
0
)
{
Utf16ToUtf8
(
FilePathW
,
VTLRIPath
);
return
TRUE
;
}
}
}
}
else
{
n
=
(
int
)
strlen
(
IsoPath
);
if
(
n
>
4
&&
_stricmp
(
IsoPath
+
n
-
4
,
".iso"
)
==
0
)
{
IsoPath
[
n
-
4
]
=
0
;
sprintf_s
(
VTLRIPath
,
MAX_PATH
,
"%s.VTLRI"
,
IsoPath
);
IsoPath
[
n
-
4
]
=
'.'
;
if
(
IsFileExist
(
VTLRIPath
))
{
return
TRUE
;
}
}
}
return
FALSE
;
}
static
int
MountVTLRI
(
CHAR
*
ImgPath
,
DWORD
PhyDrive
)
{
CHAR
ImDiskPath
[
256
];
Log
(
"MountVTLRI <%s> %u"
,
ImgPath
,
PhyDrive
);
VentoyCopyImdisk
(
PhyDrive
,
ImDiskPath
);
VentoyRunImdisk
(
ImgPath
,
ImDiskPath
,
"rem"
);
return
0
;
}
static
int
VentoyHook
(
ventoy_os_param
*
param
)
static
int
VentoyHook
(
ventoy_os_param
*
param
)
{
{
...
@@ -2288,6 +2393,7 @@ static int VentoyHook(ventoy_os_param *param)
...
@@ -2288,6 +2393,7 @@ static int VentoyHook(ventoy_os_param *param)
DISK_EXTENT
VtoyDiskExtent
;
DISK_EXTENT
VtoyDiskExtent
;
UINT8
UUID
[
16
];
UINT8
UUID
[
16
];
CHAR
IsoPath
[
MAX_PATH
];
CHAR
IsoPath
[
MAX_PATH
];
CHAR
VTLRIPath
[
MAX_PATH
];
Log
(
"VentoyHook Path:<%s>"
,
param
->
vtoy_img_path
);
Log
(
"VentoyHook Path:<%s>"
,
param
->
vtoy_img_path
);
...
@@ -2427,7 +2533,16 @@ static int VentoyHook(ventoy_os_param *param)
...
@@ -2427,7 +2533,16 @@ static int VentoyHook(ventoy_os_param *param)
Drives
=
GetLogicalDrives
();
Drives
=
GetLogicalDrives
();
Log
(
"Drives before mount: 0x%x"
,
Drives
);
Log
(
"Drives before mount: 0x%x"
,
Drives
);
if
(
VentoyIsLenovoRecovery
(
IsoPath
,
VTLRIPath
))
{
Log
(
"This is lenovo recovery image, mount VTLRI file."
);
rc
=
MountVTLRI
(
VTLRIPath
,
VtoyDiskNum
);
}
else
{
Log
(
"This is normal image, mount ISO file."
);
rc
=
MountIsoFile
(
IsoPath
,
VtoyDiskNum
);
rc
=
MountIsoFile
(
IsoPath
,
VtoyDiskNum
);
}
NewDrives
=
GetLogicalDrives
();
NewDrives
=
GetLogicalDrives
();
Log
(
"Drives after mount: 0x%x (0x%x)"
,
NewDrives
,
(
NewDrives
^
Drives
));
Log
(
"Drives after mount: 0x%x (0x%x)"
,
NewDrives
,
(
NewDrives
^
Drives
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment