diff --git a/INSTALL/Ventoy2Disk.exe b/INSTALL/Ventoy2Disk.exe index 597dc357..8aa71d64 100644 Binary files a/INSTALL/Ventoy2Disk.exe and b/INSTALL/Ventoy2Disk.exe differ diff --git a/LANGUAGES/languages.ini b/LANGUAGES/languages.ini index 0af2c4b0..b7f64a2c 100644 Binary files a/LANGUAGES/languages.ini and b/LANGUAGES/languages.ini differ diff --git a/Ventoy2Disk/Ventoy2Disk/Language.h b/Ventoy2Disk/Ventoy2Disk/Language.h index b365481f..4ab13844 100644 --- a/Ventoy2Disk/Ventoy2Disk/Language.h +++ b/Ventoy2Disk/Ventoy2Disk/Language.h @@ -63,6 +63,13 @@ typedef enum STR_ID STR_MENU_PART_STYLE, //29 STR_DISK_2TB_MBR_ERROR,//30 + STR_SHOW_ALL_DEV, //31 + STR_PART_ALIGN_4KB, //32 + STR_WEB_COMMUNICATION_ERR, //33 + STR_WEB_REMOTE_ABNORMAL, //34 + STR_WEB_REQUEST_TIMEOUT, //35 + STR_WEB_SERVICE_UNAVAILABLE, //36 + STR_WEB_TOKEN_MISMATCH, //37 STR_ID_MAX }STR_ID; @@ -75,6 +82,7 @@ extern BOOL g_SecureBoot; #define VTOY_MENU_PART_STYLE 0xA003 #define VTOY_MENU_PART_MBR 0xA004 #define VTOY_MENU_PART_GPT 0xA005 +#define VTOY_MENU_ALL_DEV 0xA006 typedef enum OPT_SUBMENU @@ -83,6 +91,7 @@ typedef enum OPT_SUBMENU OPT_SUBMENU_PART_STYLE, OPT_SUBMENU_PART_CFG, OPT_SUBMENU_CLEAR, + OPT_SUBMENU_ALL_DEV, OPT_SUBMENU_MAX }OPT_SUBMENU; diff --git a/Ventoy2Disk/Ventoy2Disk/PartDialog.c b/Ventoy2Disk/Ventoy2Disk/PartDialog.c index f1659ccc..429252ac 100644 Binary files a/Ventoy2Disk/Ventoy2Disk/PartDialog.c and b/Ventoy2Disk/Ventoy2Disk/PartDialog.c differ diff --git a/Ventoy2Disk/Ventoy2Disk/Utility.c b/Ventoy2Disk/Ventoy2Disk/Utility.c index 91403bd2..cf86fef4 100644 --- a/Ventoy2Disk/Ventoy2Disk/Utility.c +++ b/Ventoy2Disk/Ventoy2Disk/Utility.c @@ -468,6 +468,17 @@ int VentoyFillMBR(UINT64 DiskSizeBytes, MBR_HEAD *pMBR, int PartStyle) ReservedSector += 33; // backup GPT part table } + // check aligned with 4KB + if (IsPartNeed4KBAlign()) + { + UINT64 sectors = DiskSizeBytes / 512; + if (sectors % 8) + { + Log("Disk need to align with 4KB %u", (UINT32)(sectors % 8)); + ReservedSector += (UINT32)(sectors % 8); + } + } + Log("ReservedSector: %u", ReservedSector); //Part1 @@ -598,6 +609,16 @@ int VentoyFillGpt(UINT64 DiskSizeBytes, VTOY_GPT_INFO *pInfo) ReservedSector += ReservedValue * 2048; } + // check aligned with 4KB + if (IsPartNeed4KBAlign()) + { + if (DiskSectorCount % 8) + { + Log("Disk need to align with 4KB %u", (UINT32)(DiskSectorCount % 8)); + ReservedSector += (DiskSectorCount % 8); + } + } + Part1SectorCount = DiskSectorCount - ReservedSector - (VENTOY_EFI_PART_SIZE / 512) - 2048; memcpy(Head->Signature, "EFI PART", 8); @@ -746,6 +767,11 @@ int GetHumanReadableGBSize(UINT64 SizeBytes) double Delta; double GB = SizeBytes * 1.0 / 1000 / 1000 / 1000; + if ((SizeBytes % 1073741824) == 0) + { + return (int)(SizeBytes / 1073741824); + } + for (i = 0; i < 12; i++) { if (Pow2 > GB) diff --git a/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.aps b/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.aps index 3687cc0d..4ed5d4f2 100644 Binary files a/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.aps and b/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.aps differ diff --git a/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.c b/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.c index 1f206aaa..91352d67 100644 --- a/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.c +++ b/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.c @@ -26,7 +26,7 @@ PHY_DRIVE_INFO *g_PhyDriveList = NULL; DWORD g_PhyDriveCount = 0; static int g_FilterRemovable = 0; -static int g_FilterUSB = 1; +int g_FilterUSB = 1; int g_ForceOperation = 1; int ParseCmdLineOption(LPSTR lpCmdLine) @@ -152,6 +152,23 @@ static BOOL IsVentoyPhyDrive(int PhyDrive, UINT64 SizeBytes, MBR_HEAD *pMBR, UIN return FALSE; } + if (pGpt->PartTbl[0].StartLBA != 2048) + { + Log("Part1 not match %llu", pGpt->PartTbl[0].StartLBA); + return FALSE; + } + + PartSectorCount = VENTOY_EFI_PART_SIZE / 512; + + if (pGpt->PartTbl[1].StartLBA != pGpt->PartTbl[0].LastLBA + 1 || + (UINT32)(pGpt->PartTbl[1].LastLBA + 1 - pGpt->PartTbl[1].StartLBA) != PartSectorCount) + { + Log("Part2 not match [%llu %llu] [%llu %llu]", + pGpt->PartTbl[0].StartLBA, pGpt->PartTbl[0].LastLBA, + pGpt->PartTbl[1].StartLBA, pGpt->PartTbl[1].LastLBA); + return FALSE; + } + *Part2StartSector = pGpt->PartTbl[1].StartLBA; memcpy(pMBR, &(pGpt->MBR), sizeof(MBR_HEAD)); @@ -185,7 +202,7 @@ static BOOL IsVentoyPhyDrive(int PhyDrive, UINT64 SizeBytes, MBR_HEAD *pMBR, UIN if (MBR.PartTbl[2].Active != 0x80 && MBR.PartTbl[3].Active != 0x80) { Log("Part3 and Part4 are both NOT active 0x%x 0x%x", MBR.PartTbl[2].Active, MBR.PartTbl[3].Active); - return FALSE; + //return FALSE; } } diff --git a/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.h b/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.h index 8407ae14..15314184 100644 --- a/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.h +++ b/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.h @@ -183,6 +183,7 @@ extern int g_ForceOperation; extern HWND g_ProgressBarHwnd; extern HFONT g_language_normal_font; extern HFONT g_language_bold_font; +extern int g_FilterUSB; void Log(const char *Fmt, ...); BOOL IsPathExist(BOOL Dir, const char *Fmt, ...); @@ -220,6 +221,7 @@ int INIT unxz(unsigned char *in, int in_size, void disk_io_set_param(HANDLE Handle, UINT64 SectorCount); INT_PTR CALLBACK PartDialogProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam); int GetReservedSpaceInMB(void); +int IsPartNeed4KBAlign(void); int FindProcessOccupyDisk(HANDLE hDrive, PHY_DRIVE_INFO *pPhyDrive); int VentoyFillMBRLocation(UINT64 DiskSizeInBytes, UINT32 StartSectorId, UINT32 SectorCount, PART_TABLE *Table); int ClearVentoyFromPhyDrive(HWND hWnd, PHY_DRIVE_INFO *pPhyDrive, char *pDrvLetter); diff --git a/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.rc b/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.rc index e454bb56..83821710 100644 Binary files a/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.rc and b/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.rc differ diff --git a/Ventoy2Disk/Ventoy2Disk/WinDialog.c b/Ventoy2Disk/Ventoy2Disk/WinDialog.c index 63bb191a..d82253e5 100644 Binary files a/Ventoy2Disk/Ventoy2Disk/WinDialog.c and b/Ventoy2Disk/Ventoy2Disk/WinDialog.c differ diff --git a/Ventoy2Disk/Ventoy2Disk/resource.h b/Ventoy2Disk/Ventoy2Disk/resource.h index fa0b4ab1..f65e0643 100644 Binary files a/Ventoy2Disk/Ventoy2Disk/resource.h and b/Ventoy2Disk/Ventoy2Disk/resource.h differ