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
6a244ff2
Commit
6a244ff2
authored
Aug 16, 2021
by
longpanda
Browse files
Fix the mount issue for 2K10 Win7x64 PE
parent
b5503a73
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
85 additions
and
33 deletions
+85
-33
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
+85
-33
No files found.
INSTALL/ventoy/vtoyjump32.exe
View file @
6a244ff2
No preview for this file type
INSTALL/ventoy/vtoyjump64.exe
View file @
6a244ff2
No preview for this file type
vtoyjump/vtoyjump/vtoyjump.c
View file @
6a244ff2
...
@@ -698,12 +698,45 @@ static int VentoyFatDiskRead(uint32 Sector, uint8 *Buffer, uint32 SectorCount)
...
@@ -698,12 +698,45 @@ static int VentoyFatDiskRead(uint32 Sector, uint8 *Buffer, uint32 SectorCount)
return
1
;
return
1
;
}
}
static
BOOL
Is2K10PE
(
void
)
{
BOOL
bRet
=
FALSE
;
FILE
*
fp
=
NULL
;
CHAR
szLine
[
1024
];
fopen_s
(
&
fp
,
"X:
\\
Windows
\\
System32
\\
PECMD.INI"
,
"r"
);
if
(
!
fp
)
{
return
FALSE
;
}
memset
(
szLine
,
0
,
sizeof
(
szLine
));
while
(
fgets
(
szLine
,
sizeof
(
szLine
)
-
1
,
fp
))
{
if
(
strstr
(
szLine
,
"
\\
2k10
\\
"
))
{
bRet
=
TRUE
;
break
;
}
}
fclose
(
fp
);
return
bRet
;
}
static
CHAR
GetMountLogicalDrive
(
void
)
static
CHAR
GetMountLogicalDrive
(
void
)
{
{
CHAR
Letter
=
'Y'
;
CHAR
Letter
=
'Y'
;
DWORD
Drives
;
DWORD
Drives
;
DWORD
Mask
=
0x1000000
;
DWORD
Mask
=
0x1000000
;
// fixed use M as mountpoint for 2K10 PE
if
(
Is2K10PE
())
{
Log
(
"Use M: for 2K10 PE"
);
return
'M'
;
}
Drives
=
GetLogicalDrives
();
Drives
=
GetLogicalDrives
();
Log
(
"Drives=0x%x"
,
Drives
);
Log
(
"Drives=0x%x"
,
Drives
);
...
@@ -770,20 +803,68 @@ UINT64 GetVentoyEfiPartStartSector(HANDLE hDrive)
...
@@ -770,20 +803,68 @@ UINT64 GetVentoyEfiPartStartSector(HANDLE hDrive)
return
StartSector
;
return
StartSector
;
}
}
static
int
VentoyRunImdisk
(
const
char
*
IsoPath
,
const
char
*
imdiskexe
)
{
CHAR
Letter
;
CHAR
Cmdline
[
512
];
WCHAR
CmdlineW
[
512
];
PROCESS_INFORMATION
Pi
;
Log
(
"VentoyRunImdisk <%s> <%s>"
,
IsoPath
,
imdiskexe
);
Letter
=
GetMountLogicalDrive
();
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
);
if
(
IsUTF8Encode
(
IsoPath
))
{
STARTUPINFOW
Si
;
GetStartupInfoW
(
&
Si
);
Si
.
dwFlags
|=
STARTF_USESHOWWINDOW
;
Si
.
wShowWindow
=
SW_HIDE
;
Utf8ToUtf16
(
Cmdline
,
CmdlineW
);
CreateProcessW
(
NULL
,
CmdlineW
,
NULL
,
NULL
,
FALSE
,
0
,
NULL
,
NULL
,
&
Si
,
&
Pi
);
Log
(
"This is UTF8 encoding"
);
}
else
{
STARTUPINFOA
Si
;
GetStartupInfoA
(
&
Si
);
Si
.
dwFlags
|=
STARTF_USESHOWWINDOW
;
Si
.
wShowWindow
=
SW_HIDE
;
CreateProcessA
(
NULL
,
Cmdline
,
NULL
,
NULL
,
FALSE
,
0
,
NULL
,
NULL
,
&
Si
,
&
Pi
);
Log
(
"This is ANSI encoding"
);
}
Log
(
"Wait for imdisk process ..."
);
WaitForSingleObject
(
Pi
.
hProcess
,
INFINITE
);
Log
(
"imdisk process finished"
);
return
0
;
}
int
VentoyMountISOByImdisk
(
const
char
*
IsoPath
,
DWORD
PhyDrive
)
int
VentoyMountISOByImdisk
(
const
char
*
IsoPath
,
DWORD
PhyDrive
)
{
{
int
rc
=
1
;
int
rc
=
1
;
BOOL
bRet
;
BOOL
bRet
;
CHAR
Letter
;
DWORD
dwBytes
;
DWORD
dwBytes
;
HANDLE
hDrive
;
HANDLE
hDrive
;
CHAR
PhyPath
[
MAX_PATH
];
CHAR
PhyPath
[
MAX_PATH
];
WCHAR
PhyPathW
[
MAX_PATH
];
PROCESS_INFORMATION
Pi
;
GET_LENGTH_INFORMATION
LengthInfo
;
GET_LENGTH_INFORMATION
LengthInfo
;
Log
(
"VentoyMountISOByImdisk %s"
,
IsoPath
);
Log
(
"VentoyMountISOByImdisk %s"
,
IsoPath
);
if
(
IsFileExist
(
"X:
\\
Windows
\\
System32
\\
imdisk.exe"
))
{
Log
(
"imdisk.exe exist, use it directly..."
);
VentoyRunImdisk
(
IsoPath
,
"imdisk.exe"
);
return
0
;
}
sprintf_s
(
PhyPath
,
sizeof
(
PhyPath
),
"
\\\\
.
\\
PhysicalDrive%d"
,
PhyDrive
);
sprintf_s
(
PhyPath
,
sizeof
(
PhyPath
),
"
\\\\
.
\\
PhysicalDrive%d"
,
PhyDrive
);
hDrive
=
CreateFileA
(
PhyPath
,
GENERIC_READ
,
FILE_SHARE_READ
|
FILE_SHARE_WRITE
,
0
,
OPEN_EXISTING
,
0
,
0
);
hDrive
=
CreateFileA
(
PhyPath
,
GENERIC_READ
,
FILE_SHARE_READ
|
FILE_SHARE_WRITE
,
0
,
OPEN_EXISTING
,
0
,
0
);
if
(
hDrive
==
INVALID_HANDLE_VALUE
)
if
(
hDrive
==
INVALID_HANDLE_VALUE
)
...
@@ -826,37 +907,8 @@ int VentoyMountISOByImdisk(const char *IsoPath, DWORD PhyDrive)
...
@@ -826,37 +907,8 @@ int VentoyMountISOByImdisk(const char *IsoPath, DWORD PhyDrive)
if
(
LoadNtDriver
(
PhyPath
)
==
0
)
if
(
LoadNtDriver
(
PhyPath
)
==
0
)
{
{
VentoyRunImdisk
(
IsoPath
,
"ventoy
\\
imdisk.exe"
);
rc
=
0
;
rc
=
0
;
Letter
=
GetMountLogicalDrive
();
sprintf_s
(
PhyPath
,
sizeof
(
PhyPath
),
"ventoy
\\
imdisk.exe -a -o ro -f
\"
%s
\"
-m %C:"
,
IsoPath
,
Letter
);
Log
(
"mount iso to %C: use imdisk cmd <%s>"
,
Letter
,
PhyPath
);
if
(
IsUTF8Encode
(
IsoPath
))
{
STARTUPINFOW
Si
;
GetStartupInfoW
(
&
Si
);
Si
.
dwFlags
|=
STARTF_USESHOWWINDOW
;
Si
.
wShowWindow
=
SW_HIDE
;
Utf8ToUtf16
(
PhyPath
,
PhyPathW
);
CreateProcessW
(
NULL
,
PhyPathW
,
NULL
,
NULL
,
FALSE
,
0
,
NULL
,
NULL
,
&
Si
,
&
Pi
);
Log
(
"This is UTF8 encoding"
);
}
else
{
STARTUPINFOA
Si
;
GetStartupInfoA
(
&
Si
);
Si
.
dwFlags
|=
STARTF_USESHOWWINDOW
;
Si
.
wShowWindow
=
SW_HIDE
;
CreateProcessA
(
NULL
,
PhyPath
,
NULL
,
NULL
,
FALSE
,
0
,
NULL
,
NULL
,
&
Si
,
&
Pi
);
Log
(
"This is ANSI encoding"
);
}
WaitForSingleObject
(
Pi
.
hProcess
,
INFINITE
);
}
}
}
}
fl_shutdown
();
fl_shutdown
();
...
...
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