]> glassweightruler.freedombox.rocks Git - Ventoy.git/blobdiff - Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.c
Optimization for Ventoy2Disk.exe
[Ventoy.git] / Ventoy2Disk / Ventoy2Disk / Ventoy2Disk.c
index 9eb257015f9813ec7ff654c192681b3f5763c35e..5ba9e71ae7f1adbb0fe1d8f72bc942462e4aa29b 100644 (file)
@@ -71,7 +71,7 @@ int ParseCmdLineOption(LPSTR lpCmdLine)
     return 0;\r
 }\r
 \r
-static BOOL IsVentoyPhyDrive(int PhyDrive, UINT64 SizeBytes, MBR_HEAD *pMBR, UINT64 *Part2StartSector)\r
+static BOOL IsVentoyPhyDrive(int PhyDrive, UINT64 SizeBytes, MBR_HEAD *pMBR, UINT64 *Part2StartSector, UINT64 *GptPart2Attr)\r
 {\r
     int i;\r
     BOOL bRet;\r
@@ -149,7 +149,15 @@ static BOOL IsVentoyPhyDrive(int PhyDrive, UINT64 SizeBytes, MBR_HEAD *pMBR, UIN
 \r
                if (memcmp(pGpt->PartTbl[1].Name, L"VTOYEFI", 7 * 2))\r
                {\r
-                       Log("Invalid ventoy efi part name");\r
+                       if (pGpt->PartTbl[1].Name[0])\r
+                       {\r
+                               Log("Invalid ventoy efi part name <%S>", pGpt->PartTbl[1].Name);\r
+                       }\r
+                       else\r
+                       {\r
+                               Log("Invalid ventoy efi part name <null>");\r
+                       }\r
+                       \r
                        return FALSE;\r
                }\r
 \r
@@ -170,6 +178,7 @@ static BOOL IsVentoyPhyDrive(int PhyDrive, UINT64 SizeBytes, MBR_HEAD *pMBR, UIN
             return FALSE;\r
         }\r
 \r
+        *GptPart2Attr = pGpt->PartTbl[1].Attr;\r
                *Part2StartSector = pGpt->PartTbl[1].StartLBA;\r
 \r
         memcpy(pMBR, &(pGpt->MBR), sizeof(MBR_HEAD));\r
@@ -225,6 +234,7 @@ static int FilterPhysicalDrive(PHY_DRIVE_INFO *pDriveList, DWORD DriveCount)
     int Letter = 'A';\r
     int Id = 0;\r
     int LetterCount = 0;\r
+    UINT64 Part2GPTAttr = 0;\r
        UINT64 Part2StartSector = 0;\r
     PHY_DRIVE_INFO *CurDrive;\r
        MBR_HEAD MBR;\r
@@ -247,6 +257,7 @@ static int FilterPhysicalDrive(PHY_DRIVE_INFO *pDriveList, DWORD DriveCount)
 \r
     for (i = 0; i < DriveCount; i++)\r
     {\r
+        Part2GPTAttr = 0;\r
         CurDrive = pDriveList + i;\r
 \r
         CurDrive->Id = -1;\r
@@ -278,10 +289,11 @@ static int FilterPhysicalDrive(PHY_DRIVE_INFO *pDriveList, DWORD DriveCount)
             }\r
         }\r
 \r
-               if (IsVentoyPhyDrive(CurDrive->PhyDrive, CurDrive->SizeInBytes, &MBR, &Part2StartSector))\r
+        if (IsVentoyPhyDrive(CurDrive->PhyDrive, CurDrive->SizeInBytes, &MBR, &Part2StartSector, &Part2GPTAttr))\r
         {\r
             memcpy(&(CurDrive->MBR), &MBR, sizeof(MBR));\r
             CurDrive->PartStyle = (MBR.PartTbl[0].FsFlag == 0xEE) ? 1 : 0;\r
+            CurDrive->Part2GPTAttr = Part2GPTAttr;\r
             GetVentoyVerInPhyDrive(CurDrive, Part2StartSector, CurDrive->VentoyVersion, sizeof(CurDrive->VentoyVersion), &(CurDrive->SecureBootSupport));\r
             Log("PhyDrive %d is Ventoy Disk ver:%s SecureBoot:%u", CurDrive->PhyDrive, CurDrive->VentoyVersion, CurDrive->SecureBootSupport);\r
 \r