Skip to content

Commit 4e8d8b2

Browse files
committed
Fix Windows 11 error 0x80070001. (ventoy#3010 ventoy#3029 ventoy#3105)
1 parent 60d88cb commit 4e8d8b2

32 files changed

+57
-14
lines changed

INSTALL/Ventoy2Disk.exe

0 Bytes
Binary file not shown.

INSTALL/Ventoy2Disk_ARM.exe

512 Bytes
Binary file not shown.

INSTALL/Ventoy2Disk_ARM64.exe

0 Bytes
Binary file not shown.

INSTALL/Ventoy2Disk_X64.exe

0 Bytes
Binary file not shown.

INSTALL/tool/VentoyWorker.sh

+4
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,10 @@ else
625625
check_umount_disk "$DISK"
626626
vtoycli partresize -s $DISK $part2_start
627627
fi
628+
629+
vtinfo "update esp partition attribute"
630+
vtoycli gpt -f $DISK
631+
sync
628632

629633
echo ""
630634
vtinfo "Update Ventoy on $DISK successfully finished."

INSTALL/tool/aarch64/V2DServer

0 Bytes
Binary file not shown.

INSTALL/tool/aarch64/Ventoy2Disk.gtk3

0 Bytes
Binary file not shown.

INSTALL/tool/aarch64/Ventoy2Disk.qt5

4.05 KB
Binary file not shown.

INSTALL/tool/aarch64/vtoycli

0 Bytes
Binary file not shown.

INSTALL/tool/i386/V2DServer

0 Bytes
Binary file not shown.

INSTALL/tool/i386/Ventoy2Disk.gtk2

0 Bytes
Binary file not shown.

INSTALL/tool/i386/Ventoy2Disk.gtk3

0 Bytes
Binary file not shown.

INSTALL/tool/i386/Ventoy2Disk.qt5

44 Bytes
Binary file not shown.

INSTALL/tool/i386/vtoycli

44 Bytes
Binary file not shown.

INSTALL/tool/mips64el/V2DServer

880 Bytes
Binary file not shown.
2.58 KB
Binary file not shown.

INSTALL/tool/mips64el/Ventoy2Disk.qt5

2.6 KB
Binary file not shown.

INSTALL/tool/mips64el/vtoycli

0 Bytes
Binary file not shown.

INSTALL/tool/ventoy_lib.sh

-1
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,6 @@ format_ventoy_disk_gpt() {
449449
mkpart Ventoy ntfs $part1_start_sector $part1_end_sector \
450450
mkpart VTOYEFI fat16 $part2_start_sector $part2_end_sector \
451451
$vt_set_efi_type \
452-
set 2 hidden on \
453452
quit
454453

455454
sync

INSTALL/tool/x86_64/V2DServer

0 Bytes
Binary file not shown.

INSTALL/tool/x86_64/Ventoy2Disk.gtk2

0 Bytes
Binary file not shown.

INSTALL/tool/x86_64/Ventoy2Disk.gtk3

0 Bytes
Binary file not shown.

INSTALL/tool/x86_64/Ventoy2Disk.qt5

48 Bytes
Binary file not shown.

INSTALL/tool/x86_64/vtoycli

48 Bytes
Binary file not shown.

LinuxGUI/Ventoy2Disk/Core/ventoy_util.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ int ventoy_fill_gpt(uint64_t size, uint64_t reserve, int align4k, VTOY_GPT_INFO
442442
ventoy_gen_preudo_uuid(&(Table[1].PartGuid));
443443
Table[1].StartLBA = Table[0].LastLBA + 1;
444444
Table[1].LastLBA = Table[1].StartLBA + VTOYEFI_PART_BYTES / 512 - 1;
445-
Table[1].Attr = 0xC000000000000001ULL;
445+
Table[1].Attr = 0x8000000000000000ULL;
446446
ventoy_fill_gpt_partname(Table[1].Name, "VTOYEFI");
447447

448448
#if 0

LinuxGUI/Ventoy2Disk/Web/ventoy_http.c

+29
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,7 @@ static void * ventoy_update_thread(void *data)
727727
MBR_HEAD MBR;
728728
ventoy_disk *disk = NULL;
729729
ventoy_thread_data *thread = (ventoy_thread_data *)data;
730+
VTOY_GPT_INFO *pstGPT = NULL;
730731

731732
vdebug("ventoy_update_thread run ...\n");
732733

@@ -790,6 +791,34 @@ static void * ventoy_update_thread(void *data)
790791
vlog("No need to update MBR\n");
791792
}
792793

794+
795+
if (disk->vtoydata.partition_style)
796+
{
797+
pstGPT = (VTOY_GPT_INFO *)malloc(sizeof(VTOY_GPT_INFO));
798+
memset(pstGPT, 0, sizeof(VTOY_GPT_INFO));
799+
800+
offset = lseek(fd, 0, SEEK_SET);
801+
len = read(fd, pstGPT, sizeof(VTOY_GPT_INFO));
802+
vlog("Read GPT table offset:%llu len:%llu ...\n", (_ull)offset, (_ull)len);
803+
804+
if (pstGPT->PartTbl[1].Attr != 0x8000000000000000ULL)
805+
{
806+
vlog("Update EFI part attr from 0x%016llx to 0x%016llx\n",
807+
pstGPT->PartTbl[1].Attr, 0x8000000000000000ULL);
808+
809+
pstGPT->PartTbl[1].Attr = 0x8000000000000000ULL;
810+
pstGPT->Head.Crc = 0;
811+
pstGPT->Head.Crc = ventoy_crc32(&(pstGPT->Head), pstGPT->Head.Length);
812+
ventoy_write_gpt_part_table(fd, disk->size_in_byte, pstGPT);
813+
}
814+
else
815+
{
816+
vlog("No need to update EFI part attr\n");
817+
}
818+
free(pstGPT);
819+
}
820+
821+
793822
g_current_progress = PT_SYNC_DATA1;
794823

795824
vlog("fsync data1...\n");

Ventoy2Disk/Ventoy2Disk/PhyDrive.c

+16-8
Original file line numberDiff line numberDiff line change
@@ -2520,7 +2520,7 @@ int PartitionResizeForVentoy(PHY_DRIVE_INFO *pPhyDrive)
25202520

25212521
pGPT->PartTbl[1].StartLBA = pGPT->PartTbl[0].LastLBA + 1;
25222522
pGPT->PartTbl[1].LastLBA = pGPT->PartTbl[1].StartLBA + VENTOY_EFI_PART_SIZE / 512 - 1;
2523-
pGPT->PartTbl[1].Attr = 0xC000000000000001ULL;
2523+
pGPT->PartTbl[1].Attr = VENTOY_EFI_PART_ATTR;
25242524
memcpy(pGPT->PartTbl[1].Name, L"VTOYEFI", 7 * 2);
25252525

25262526
//Update CRC
@@ -2797,6 +2797,7 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int TryId)
27972797
BOOL CleanDisk = FALSE;
27982798
BOOL DelEFI = FALSE;
27992799
BOOL bWriteBack = TRUE;
2800+
BOOL bUpdateEFIAttr = FALSE;
28002801
HANDLE hVolume;
28012802
HANDLE hDrive;
28022803
DWORD Status;
@@ -2904,7 +2905,13 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int TryId)
29042905
if (pPhyDrive->PartStyle == 1)
29052906
{
29062907
Log("TryId=%d EFI GPT partition type is 0x%llx", TryId, pPhyDrive->Part2GPTAttr);
2907-
PROGRESS_BAR_SET_POS(PT_DEL_ALL_PART);
2908+
PROGRESS_BAR_SET_POS(PT_DEL_ALL_PART);
2909+
2910+
if (pGptInfo->PartTbl[1].Attr != VENTOY_EFI_PART_ATTR)
2911+
{
2912+
bUpdateEFIAttr = TRUE;
2913+
}
2914+
29082915

29092916
if (TryId == 1)
29102917
{
@@ -2917,8 +2924,8 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int TryId)
29172924
}
29182925
else if (TryId == 2)
29192926
{
2920-
Log("Change GPT partition attribute");
2921-
if (DISK_ChangeVtoyEFIAttr(pPhyDrive->PhyDrive, StartSector * 512ULL, 0x8000000000000001))
2927+
Log("Try2 Change GPT partition attribute to 0x%016llx", VENTOY_EFI_PART_ATTR & 0xFFFFFFFFFFFFFFFEULL);
2928+
if (DISK_ChangeVtoyEFIAttr(pPhyDrive->PhyDrive, StartSector * 512ULL, VENTOY_EFI_PART_ATTR & 0xFFFFFFFFFFFFFFFEULL))
29222929
{
29232930
ChangeAttr = TRUE;
29242931
Sleep(2000);
@@ -3253,15 +3260,16 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int TryId)
32533260
DISK_ChangeVtoyEFI2Basic(pPhyDrive->PhyDrive, StartSector * 512);
32543261
}
32553262

3263+
32563264
if (pPhyDrive->PartStyle == 1)
32573265
{
3258-
if (ChangeAttr || ((pPhyDrive->Part2GPTAttr >> 56) != 0xC0))
3266+
if (ChangeAttr || bUpdateEFIAttr)
32593267
{
3260-
Log("Change EFI partition attr %u <0x%llx> to <0x%llx>", ChangeAttr, pPhyDrive->Part2GPTAttr, 0xC000000000000001ULL);
3261-
if (DISK_ChangeVtoyEFIAttr(pPhyDrive->PhyDrive, StartSector * 512ULL, 0xC000000000000001ULL))
3268+
Log("Change EFI partition attr %u <0x%llx> to <0x%llx>", ChangeAttr, pGptInfo->PartTbl[1].Attr, VENTOY_EFI_PART_ATTR);
3269+
if (DISK_ChangeVtoyEFIAttr(pPhyDrive->PhyDrive, StartSector * 512ULL, VENTOY_EFI_PART_ATTR))
32623270
{
32633271
Log("Change EFI partition attr success");
3264-
pPhyDrive->Part2GPTAttr = 0xC000000000000001ULL;
3272+
pPhyDrive->Part2GPTAttr = VENTOY_EFI_PART_ATTR;
32653273
}
32663274
else
32673275
{

Ventoy2Disk/Ventoy2Disk/Utility.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ int VentoyFillGpt(UINT64 DiskSizeBytes, VTOY_GPT_INFO *pInfo)
982982
CoCreateGuid(&(Table[1].PartGuid));
983983
Table[1].StartLBA = Table[0].LastLBA + 1;
984984
Table[1].LastLBA = Table[1].StartLBA + VENTOY_EFI_PART_SIZE / 512 - 1;
985-
Table[1].Attr = 0xC000000000000001ULL;
985+
Table[1].Attr = VENTOY_EFI_PART_ATTR;
986986
memcpy(Table[1].Name, L"VTOYEFI", 7 * 2);
987987

988988
#if 0

Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.h

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ typedef enum VTOY_FS
3434

3535
#define FAT32_MAX_LIMIT (32 * 1073741824ULL)
3636

37+
#define VENTOY_EFI_PART_ATTR 0x8000000000000000ULL
38+
39+
3740
#define SIZE_1KB (1024)
3841
#define SIZE_1GB (1024 * 1024 * 1024)
3942
#define SIZE_1TB (1024ULL * 1024ULL * 1024ULL * 1024ULL)

vtoycli/partresize.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ static int update_part_table(char *disk, UINT64 part2start)
599599

600600
PartTbl[1].StartLBA = PartTbl[0].LastLBA + 1;
601601
PartTbl[1].LastLBA = PartTbl[1].StartLBA + VENTOY_EFI_PART_SIZE / 512 - 1;
602-
PartTbl[1].Attr = 0xC000000000000001ULL;
602+
PartTbl[1].Attr = VENTOY_EFI_PART_ATTR;
603603
PartTbl[1].Name[0] = 'V';
604604
PartTbl[1].Name[1] = 'T';
605605
PartTbl[1].Name[2] = 'O';

vtoycli/vtoycli.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#ifndef __VTOYCLI_H__
2222
#define __VTOYCLI_H__
2323

24-
#define VENTOY_EFI_PART_ATTR 0xC000000000000001ULL
24+
#define VENTOY_EFI_PART_ATTR 0x8000000000000000ULL
2525

2626
#define SIZE_1MB (1024 * 1024)
2727
#define VENTOY_EFI_PART_SIZE (32 * SIZE_1MB)

vtoygpt/vtoygpt.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ int DumpGptInfo(VTOY_GPT_INFO *pGptInfo)
244244
return 0;
245245
}
246246

247-
#define VENTOY_EFI_PART_ATTR 0xC000000000000001ULL
247+
#define VENTOY_EFI_PART_ATTR 0x8000000000000000ULL
248248

249249
int main(int argc, const char **argv)
250250
{

0 commit comments

Comments
 (0)