From 7cdc7386a89143dfe1b1a4397cfa20e3a0770dfd Mon Sep 17 00:00:00 2001 From: longpanda Date: Fri, 8 Jan 2021 20:08:32 +0800 Subject: [PATCH] Fix a bug when use workaround for Legacy BIOS access limitation with GPT partition style --- .../grub-2.04/grub-core/ventoy/ventoy.c | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy.c b/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy.c index 6b4ee013..a1a8cf8e 100644 --- a/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy.c +++ b/GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy.c @@ -1772,12 +1772,25 @@ int ventoy_check_device(grub_device_t dev) if (workaround) { - ventoy_part_table *PartTbl = g_ventoy_part_info->MBR.PartTbl; - if (PartTbl[1].StartSectorId != PartTbl[0].StartSectorId + PartTbl[0].SectorCount || - PartTbl[1].SectorCount != 65536) + if (grub_strncmp(g_ventoy_part_info->Head.Signature, "EFI PART", 8) == 0) { - grub_file_close(file); - return ventoy_check_device_result(6); + ventoy_gpt_part_tbl *PartTbl = g_ventoy_part_info->PartTbl; + if (PartTbl[1].StartLBA != PartTbl[0].LastLBA + 1 || + (PartTbl[1].LastLBA + 1 - PartTbl[1].StartLBA) != 65536) + { + grub_file_close(file); + return ventoy_check_device_result(6); + } + } + else + { + ventoy_part_table *PartTbl = g_ventoy_part_info->MBR.PartTbl; + if (PartTbl[1].StartSectorId != PartTbl[0].StartSectorId + PartTbl[0].SectorCount || + PartTbl[1].SectorCount != 65536) + { + grub_file_close(file); + return ventoy_check_device_result(6); + } } } else