]> glassweightruler.freedombox.rocks Git - Ventoy.git/commitdiff
Update for Ventoy2Disk.exe
authorlongpanda <admin@ventoy.net>
Tue, 23 Feb 2021 09:49:28 +0000 (17:49 +0800)
committerlongpanda <admin@ventoy.net>
Tue, 23 Feb 2021 09:49:28 +0000 (17:49 +0800)
1. Add "Show All Devices" option
2. Add "Partition align with 4KB" option
3. Display size optimization
4. Doesn't check partition active flag anymore

INSTALL/Ventoy2Disk.exe
LANGUAGES/languages.ini
Ventoy2Disk/Ventoy2Disk/Language.h
Ventoy2Disk/Ventoy2Disk/PartDialog.c
Ventoy2Disk/Ventoy2Disk/Utility.c
Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.aps
Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.c
Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.h
Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.rc
Ventoy2Disk/Ventoy2Disk/WinDialog.c
Ventoy2Disk/Ventoy2Disk/resource.h

index 597dc3570e1604e69ccc3e57ab4dec5525b09080..8aa71d64f8f14c165e2290b9cffedab56507e7aa 100644 (file)
Binary files a/INSTALL/Ventoy2Disk.exe and b/INSTALL/Ventoy2Disk.exe differ
index 0af2c4b0b2a764d3769bfda3b91737f575b1cee7..b7f64a2c499309ab7d7404ff787b753988be40c8 100644 (file)
Binary files a/LANGUAGES/languages.ini and b/LANGUAGES/languages.ini differ
index b365481f92af2890d694ce29ed8a978d6aaeee95..4ab138441f9f681f516a39cd91931bf07186347f 100644 (file)
@@ -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;
index f1659ccc484ae9d6bf49149aaa2c929b39c32629..429252ac9ac45d05302b81caf7c47ef4eb5872c1 100644 (file)
Binary files a/Ventoy2Disk/Ventoy2Disk/PartDialog.c and b/Ventoy2Disk/Ventoy2Disk/PartDialog.c differ
index 91403bd297457c3b1aa57f0669f0cbc801208260..cf86fef4924dc78dbc29c8321f77218a0ba352bb 100644 (file)
@@ -468,6 +468,17 @@ int VentoyFillMBR(UINT64 DiskSizeBytes, MBR_HEAD *pMBR, int PartStyle)
         ReservedSector += 33; // backup GPT part table\r
     }\r
 \r
+    // check aligned with 4KB\r
+    if (IsPartNeed4KBAlign())\r
+    {\r
+        UINT64 sectors = DiskSizeBytes / 512;\r
+        if (sectors % 8)\r
+        {\r
+            Log("Disk need to align with 4KB %u", (UINT32)(sectors % 8));\r
+            ReservedSector += (UINT32)(sectors % 8);\r
+        }\r
+    }\r
+\r
        Log("ReservedSector: %u", ReservedSector);\r
 \r
     //Part1\r
@@ -598,6 +609,16 @@ int VentoyFillGpt(UINT64 DiskSizeBytes, VTOY_GPT_INFO *pInfo)
         ReservedSector += ReservedValue * 2048;\r
     }\r
 \r
+    // check aligned with 4KB\r
+    if (IsPartNeed4KBAlign())\r
+    {\r
+        if (DiskSectorCount % 8)\r
+        {\r
+            Log("Disk need to align with 4KB %u", (UINT32)(DiskSectorCount % 8));\r
+            ReservedSector += (DiskSectorCount % 8);\r
+        }\r
+    }\r
+\r
     Part1SectorCount = DiskSectorCount - ReservedSector - (VENTOY_EFI_PART_SIZE / 512) - 2048;\r
 \r
     memcpy(Head->Signature, "EFI PART", 8);\r
@@ -746,6 +767,11 @@ int GetHumanReadableGBSize(UINT64 SizeBytes)
     double Delta;\r
     double GB = SizeBytes * 1.0 / 1000 / 1000 / 1000;\r
 \r
+    if ((SizeBytes % 1073741824) == 0)\r
+    {\r
+        return (int)(SizeBytes / 1073741824);\r
+    }\r
+\r
     for (i = 0; i < 12; i++)\r
     {\r
         if (Pow2 > GB)\r
index 3687cc0d6b89a4e62c7f66e67ddc234af10169bf..4ed5d4f25e391d864c969e1092eb5c77339017b5 100644 (file)
Binary files a/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.aps and b/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.aps differ
index 1f206aaa28d33416e155dd478572787c8356f372..91352d675462fb3f6df59269687115da87ec33ff 100644 (file)
@@ -26,7 +26,7 @@
 PHY_DRIVE_INFO *g_PhyDriveList = NULL;\r
 DWORD g_PhyDriveCount = 0;\r
 static int g_FilterRemovable = 0;\r
-static int g_FilterUSB = 1;\r
+int g_FilterUSB = 1;\r
 int g_ForceOperation = 1;\r
 \r
 int ParseCmdLineOption(LPSTR lpCmdLine)\r
@@ -152,6 +152,23 @@ static BOOL IsVentoyPhyDrive(int PhyDrive, UINT64 SizeBytes, MBR_HEAD *pMBR, UIN
                        return FALSE;\r
                }\r
 \r
+        if (pGpt->PartTbl[0].StartLBA != 2048)\r
+        {\r
+            Log("Part1 not match %llu", pGpt->PartTbl[0].StartLBA);\r
+            return FALSE;\r
+        }\r
+\r
+        PartSectorCount = VENTOY_EFI_PART_SIZE / 512;\r
+\r
+        if (pGpt->PartTbl[1].StartLBA != pGpt->PartTbl[0].LastLBA + 1 ||\r
+            (UINT32)(pGpt->PartTbl[1].LastLBA + 1 - pGpt->PartTbl[1].StartLBA) != PartSectorCount)\r
+        {\r
+            Log("Part2 not match [%llu %llu] [%llu %llu]",\r
+                pGpt->PartTbl[0].StartLBA, pGpt->PartTbl[0].LastLBA,\r
+                pGpt->PartTbl[1].StartLBA, pGpt->PartTbl[1].LastLBA);\r
+            return FALSE;\r
+        }\r
+\r
                *Part2StartSector = pGpt->PartTbl[1].StartLBA;\r
 \r
         memcpy(pMBR, &(pGpt->MBR), sizeof(MBR_HEAD));\r
@@ -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)\r
             {\r
                 Log("Part3 and Part4 are both NOT active 0x%x 0x%x", MBR.PartTbl[2].Active, MBR.PartTbl[3].Active);\r
-                return FALSE;\r
+                //return FALSE;\r
             }\r
                }\r
 \r
index 8407ae1420c4c4d0cf38b4c8c2c902c4e154a558..153141847372f659ba2c01daa857377ac09093ae 100644 (file)
@@ -183,6 +183,7 @@ extern int g_ForceOperation;
 extern HWND g_ProgressBarHwnd;\r
 extern HFONT g_language_normal_font;\r
 extern HFONT g_language_bold_font;\r
+extern int g_FilterUSB;\r
 \r
 void Log(const char *Fmt, ...);\r
 BOOL IsPathExist(BOOL Dir, const char *Fmt, ...);\r
@@ -220,6 +221,7 @@ int INIT unxz(unsigned char *in, int in_size,
 void disk_io_set_param(HANDLE Handle, UINT64 SectorCount);\r
 INT_PTR CALLBACK PartDialogProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam);\r
 int GetReservedSpaceInMB(void);\r
+int IsPartNeed4KBAlign(void);\r
 int FindProcessOccupyDisk(HANDLE hDrive, PHY_DRIVE_INFO *pPhyDrive);\r
 int VentoyFillMBRLocation(UINT64 DiskSizeInBytes, UINT32 StartSectorId, UINT32 SectorCount, PART_TABLE *Table);\r
 int ClearVentoyFromPhyDrive(HWND hWnd, PHY_DRIVE_INFO *pPhyDrive, char *pDrvLetter);\r
index e454bb56faf63dd76ab17505f2d29e2d544d3a94..838217107d1a655b059deb983e7d5c813dcc561c 100644 (file)
Binary files a/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.rc and b/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.rc differ
index 63bb191ae8ac7e3dff11f5a756a0cf1c6ad9422c..d82253e560705c884fa5fa452d473704af38863f 100644 (file)
Binary files a/Ventoy2Disk/Ventoy2Disk/WinDialog.c and b/Ventoy2Disk/Ventoy2Disk/WinDialog.c differ
index fa0b4ab19f1073da8066d352c4c07ecc4180ea67..f65e0643c7dd359ebbf359a9d12a6fdef7bc0a64 100644 (file)
Binary files a/Ventoy2Disk/Ventoy2Disk/resource.h and b/Ventoy2Disk/Ventoy2Disk/resource.h differ