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
d151e743
Commit
d151e743
authored
Oct 23, 2021
by
longpanda
Browse files
Optimization for Ventoy2Disk.exe
parent
df87cafd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
20 deletions
+43
-20
INSTALL/Ventoy2Disk.exe
INSTALL/Ventoy2Disk.exe
+0
-0
Ventoy2Disk/Ventoy2Disk/DiskService_vds.c
Ventoy2Disk/Ventoy2Disk/DiskService_vds.c
+14
-13
Ventoy2Disk/Ventoy2Disk/PhyDrive.c
Ventoy2Disk/Ventoy2Disk/PhyDrive.c
+29
-7
No files found.
INSTALL/Ventoy2Disk.exe
View file @
d151e743
No preview for this file type
Ventoy2Disk/Ventoy2Disk/DiskService_vds.c
View file @
d151e743
...
...
@@ -887,7 +887,7 @@ STATIC BOOL VDS_CallBack_CleanDisk(void *pInterface, VDS_DISK_PROP *pDiskProp, U
BOOL
VDS_CleanDisk
(
int
DriveIndex
)
{
BOOL
ret
=
VDS_DiskCommProc
(
INTF_ADVANCEDDISK
,
DriveIndex
,
VDS_CallBack_CleanDisk
,
0
);
Log
(
"VDS_CleanDisk %d ret:%d"
,
DriveIndex
,
ret
);
Log
(
"VDS_CleanDisk %d ret:%d
(%s)
"
,
DriveIndex
,
ret
,
ret
?
"SUCCESS"
:
"FAIL"
);
return
ret
;
}
...
...
@@ -958,15 +958,15 @@ STATIC BOOL VDS_CallBack_DeletePartition(void *pInterface, VDS_DISK_PROP *pDiskP
BOOL
VDS_DeleteAllPartitions
(
int
DriveIndex
)
{
BOOL
ret
=
VDS_DiskCommProc
(
INTF_ADVANCEDDISK
,
DriveIndex
,
VDS_CallBack_DeletePartition
,
0
);
Log
(
"VDS_DeleteAllPartitions %d ret:%d"
,
DriveIndex
,
ret
);
BOOL
ret
=
VDS_DiskCommProc
(
INTF_ADVANCEDDISK
,
DriveIndex
,
VDS_CallBack_DeletePartition
,
0
);
Log
(
"VDS_DeleteAllPartitions %d ret:%d
(%s)
"
,
DriveIndex
,
ret
,
ret
?
"SUCCESS"
:
"FAIL"
);
return
ret
;
}
BOOL
VDS_DeleteVtoyEFIPartition
(
int
DriveIndex
)
{
BOOL
ret
=
VDS_DiskCommProc
(
INTF_ADVANCEDDISK
,
DriveIndex
,
VDS_CallBack_DeletePartition
,
2
);
Log
(
"VDS_DeleteVtoyEFIPartition %d ret:%d"
,
DriveIndex
,
ret
);
Log
(
"VDS_DeleteVtoyEFIPartition %d ret:%d
(%s)
"
,
DriveIndex
,
ret
,
ret
?
"SUCCESS"
:
"FAIL"
);
return
ret
;
}
...
...
@@ -1029,8 +1029,8 @@ STATIC BOOL VDS_CallBack_ChangeEFIAttr(void *pInterface, VDS_DISK_PROP *pDiskPro
BOOL
VDS_ChangeVtoyEFIAttr
(
int
DriveIndex
,
UINT64
Attr
)
{
BOOL
ret
=
VDS_DiskCommProc
(
INTF_ADVANCEDDISK
,
DriveIndex
,
VDS_CallBack_ChangeEFIAttr
,
Attr
);
Log
(
"VDS_ChangeVtoyEFIAttr %d ret:%d"
,
DriveIndex
,
ret
);
BOOL
ret
=
VDS_DiskCommProc
(
INTF_ADVANCEDDISK
,
DriveIndex
,
VDS_CallBack_ChangeEFIAttr
,
Attr
);
Log
(
"VDS_ChangeVtoyEFIAttr %d ret:%d
(%s)
"
,
DriveIndex
,
ret
,
ret
?
"SUCCESS"
:
"FAIL"
);
return
ret
;
}
...
...
@@ -1070,7 +1070,7 @@ BOOL VDS_ChangeVtoyEFI2ESP(int DriveIndex, UINT64 Offset)
Para
.
Offset
=
Offset
;
BOOL
ret
=
VDS_DiskCommProc
(
INTF_ADVANCEDDISK2
,
DriveIndex
,
VDS_CallBack_ChangeEFIType
,
(
ULONG
)
&
Para
);
Log
(
"VDS_ChangeVtoyEFI2ESP %d ret:%d"
,
DriveIndex
,
ret
);
Log
(
"VDS_ChangeVtoyEFI2ESP %d ret:%d
(%s)
"
,
DriveIndex
,
ret
,
ret
?
"SUCCESS"
:
"FAIL"
);
return
ret
;
}
...
...
@@ -1083,7 +1083,7 @@ BOOL VDS_ChangeVtoyEFI2Basic(int DriveIndex, UINT64 Offset)
Para
.
Offset
=
Offset
;
BOOL
ret
=
VDS_DiskCommProc
(
INTF_ADVANCEDDISK2
,
DriveIndex
,
VDS_CallBack_ChangeEFIType
,
(
ULONG
)
&
Para
);
Log
(
"VDS_ChangeVtoyEFI2
ESP
%d ret:%d"
,
DriveIndex
,
ret
);
Log
(
"VDS_ChangeVtoyEFI2
Basic
%d ret:%d
(%s)
"
,
DriveIndex
,
ret
,
ret
?
"SUCCESS"
:
"FAIL"
);
return
ret
;
}
...
...
@@ -1157,8 +1157,8 @@ BOOL VDS_CreateVtoyEFIPart(int DriveIndex, UINT64 Offset)
memcpy
(
&
(
Para
.
Type
),
&
EspPartType
,
sizeof
(
GUID
));
CoCreateGuid
(
&
(
Para
.
Id
));
BOOL
ret
=
VDS_DiskCommProc
(
INTF_CREATEPARTITIONEX
,
DriveIndex
,
VDS_CallBack_CreateVtoyEFI
,
(
ULONG
)
&
Para
);
Log
(
"VDS_CreateVtoyEFIPart %d ret:%d"
,
DriveIndex
,
ret
);
BOOL
ret
=
VDS_DiskCommProc
(
INTF_CREATEPARTITIONEX
,
DriveIndex
,
VDS_CallBack_CreateVtoyEFI
,
(
ULONG
)
&
Para
);
Log
(
"VDS_CreateVtoyEFIPart %d ret:%d
(%s)
"
,
DriveIndex
,
ret
,
ret
?
"SUCCESS"
:
"FAIL"
);
return
ret
;
}
...
...
@@ -1217,7 +1217,8 @@ BOOL VDS_FormatVtoyEFIPart(int DriveIndex, UINT64 Offset)
Para
.
Offset
=
Offset
;
memcpy
(
Para
.
Name
,
L"VTOYEFI"
,
7
*
2
);
BOOL
ret
=
VDS_DiskCommProc
(
INTF_PARTITIONMF
,
DriveIndex
,
VDS_CallBack_FormatVtoyEFI
,
(
ULONG
)
&
Para
);
Log
(
"VDS_FormatVtoyEFIPart %d ret:%d"
,
DriveIndex
,
ret
);
BOOL
ret
=
VDS_DiskCommProc
(
INTF_PARTITIONMF
,
DriveIndex
,
VDS_CallBack_FormatVtoyEFI
,
(
ULONG
)
&
Para
);
Log
(
"VDS_FormatVtoyEFIPart %d ret:%d
(%s)
"
,
DriveIndex
,
ret
,
ret
?
"SUCCESS"
:
"FAIL"
);
return
ret
;
}
\ No newline at end of file
}
Ventoy2Disk/Ventoy2Disk/PhyDrive.c
View file @
d151e743
...
...
@@ -1837,9 +1837,11 @@ static BOOL BackupDataBeforeCleanDisk(int PhyDrive, UINT64 DiskSize, BYTE **pBac
BOOL
Return
=
FALSE
;
BOOL
ret
=
FALSE
;
BYTE
*
backup
=
NULL
;
UINT64
offset
;
HANDLE
hDrive
=
INVALID_HANDLE_VALUE
;
LARGE_INTEGER
liCurPosition
;
LARGE_INTEGER
liNewPosition
;
VTOY_GPT_INFO
*
pGPT
=
NULL
;
Log
(
"BackupDataBeforeCleanDisk %d"
,
PhyDrive
);
...
...
@@ -1870,6 +1872,18 @@ static BOOL BackupDataBeforeCleanDisk(int PhyDrive, UINT64 DiskSize, BYTE **pBac
goto
out
;
}
pGPT
=
(
VTOY_GPT_INFO
*
)
backup
;
offset
=
pGPT
->
Head
.
EfiBackupLBA
*
512
;
if
(
offset
>=
(
DiskSize
-
SIZE_2MB
)
&&
offset
<
DiskSize
)
{
Log
(
"EFI partition table check success"
);
}
else
{
Log
(
"Backup EFI LBA not in last 2MB range: %llu"
,
pGPT
->
Head
.
EfiBackupLBA
);
goto
out
;
}
//read last 2MB
liCurPosition
.
QuadPart
=
DiskSize
-
SIZE_2MB
;
liNewPosition
.
QuadPart
=
0
;
...
...
@@ -2111,6 +2125,13 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int TryId)
{
bWriteBack
=
FALSE
;
}
//write the first 2MB except parttable
if
(
!
WriteBackupDataToDisk
(
hDrive
,
34
*
512
,
pBackup
+
34
*
512
,
SIZE_2MB
-
34
*
512
))
{
bWriteBack
=
FALSE
;
}
Status
=
ERROR_NOT_FOUND
;
}
else
if
(
Esp2Basic
)
...
...
@@ -2288,12 +2309,7 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int TryId)
if
(
CleanDisk
)
{
if
(
!
WriteBackupDataToDisk
(
hDrive
,
4
*
512
,
pBackup
+
4
*
512
,
SIZE_2MB
-
4
*
512
))
{
bWriteBack
=
FALSE
;
}
if
(
!
WriteBackupDataToDisk
(
hDrive
,
0
,
pBackup
,
4
*
512
))
if
(
!
WriteBackupDataToDisk
(
hDrive
,
0
,
pBackup
,
34
*
512
))
{
bWriteBack
=
FALSE
;
}
...
...
@@ -2302,9 +2318,15 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int TryId)
if
(
bWriteBack
)
{
Log
(
"Write success, now delete %s"
,
BackBinFile
);
Log
(
"Write
backup data
success, now delete %s"
,
BackBinFile
);
DeleteFileA
(
BackBinFile
);
}
else
{
Log
(
"Write backup data failed"
);
}
Sleep
(
1000
);
}
//Refresh Drive Layout
...
...
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