mirror of
https://github.com/ventoy/Ventoy.git
synced 2026-06-29 06:28:13 +00:00
Fix the boot issue when Secure Boot is disabled in the UEFI firmware. (#3650)
This commit is contained in:
@@ -190,7 +190,6 @@ EFI_STATUS EFIAPI LaunchRealGrub(EFI_HANDLE ImageHandle, CONST CHAR16 *FileName)
|
|||||||
goto END;
|
goto END;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Status = gBS->StartImage(ChildHandle, NULL, NULL);
|
Status = gBS->StartImage(ChildHandle, NULL, NULL);
|
||||||
if (EFI_ERROR(Status))
|
if (EFI_ERROR(Status))
|
||||||
{
|
{
|
||||||
@@ -199,7 +198,6 @@ EFI_STATUS EFIAPI LaunchRealGrub(EFI_HANDLE ImageHandle, CONST CHAR16 *FileName)
|
|||||||
goto END;
|
goto END;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
END:
|
END:
|
||||||
|
|
||||||
CheckBSFreePool(DevDpStr);
|
CheckBSFreePool(DevDpStr);
|
||||||
@@ -604,7 +602,6 @@ STATIC BOOLEAN EFIAPI IsSecureBootEnabled(VOID)
|
|||||||
STATIC EFI_STATUS EFIAPI EnvInit(VOID)
|
STATIC EFI_STATUS EFIAPI EnvInit(VOID)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_GUID Guid = SHIM_LOCK_GUID;
|
|
||||||
|
|
||||||
Status = gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, NULL, (VOID**)&gDpToText);
|
Status = gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, NULL, (VOID**)&gDpToText);
|
||||||
if (EFI_ERROR(Status) || !gDpToText || !gDpToText->ConvertDevicePathToText)
|
if (EFI_ERROR(Status) || !gDpToText || !gDpToText->ConvertDevicePathToText)
|
||||||
@@ -620,13 +617,6 @@ STATIC EFI_STATUS EFIAPI EnvInit(VOID)
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = gBS->LocateProtocol(&Guid, NULL, (VOID**)&gShimLock);
|
|
||||||
if (EFI_ERROR(Status) || !gShimLock)
|
|
||||||
{
|
|
||||||
vLog(L"Failed to locate SHIM LOCK Protocol %lx", Status);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -638,21 +628,35 @@ EFI_STATUS EFIAPI VtoyShimEfiMain
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
EFI_GUID Guid = SHIM_LOCK_GUID;
|
||||||
unhook_system_services_pf Func = NULL;
|
unhook_system_services_pf Func = NULL;
|
||||||
|
|
||||||
/* If secure boot is not enabled, nothing needed, just launch Ventoy grub */
|
|
||||||
if (!IsSecureBootEnabled())
|
|
||||||
{
|
|
||||||
return LaunchRealGrub(ImageHandle, REAL_GRUB_FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = EnvInit();
|
Status = EnvInit();
|
||||||
if (EFI_ERROR(Status))
|
if (EFI_ERROR(Status))
|
||||||
{
|
{
|
||||||
vErr(L"Failed to prepare env");
|
vErr(L"Failed to prepare env");
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If secure boot is not enabled, nothing needed, just launch Ventoy grub */
|
||||||
|
if (!IsSecureBootEnabled())
|
||||||
|
{
|
||||||
|
Status = LaunchRealGrub(ImageHandle, REAL_GRUB_FILE);
|
||||||
|
if (EFI_ERROR(Status))
|
||||||
|
{
|
||||||
|
vErr(L"Failed to launch %s", REAL_GRUB_FILE);
|
||||||
|
}
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = gBS->LocateProtocol(&Guid, NULL, (VOID**)&gShimLock);
|
||||||
|
if (EFI_ERROR(Status) || !gShimLock)
|
||||||
|
{
|
||||||
|
vErr(L"Failed to locate SHIM LOCK Protocol %lx", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Status = InstallVtoyShimProtocol();
|
Status = InstallVtoyShimProtocol();
|
||||||
if (EFI_ERROR(Status))
|
if (EFI_ERROR(Status))
|
||||||
{
|
{
|
||||||
@@ -696,6 +700,11 @@ EFI_STATUS EFIAPI VtoyShimEfiMain
|
|||||||
|
|
||||||
/* Finally launch Ventoy grub */
|
/* Finally launch Ventoy grub */
|
||||||
Status = LaunchRealGrub(ImageHandle, REAL_GRUB_FILE);
|
Status = LaunchRealGrub(ImageHandle, REAL_GRUB_FILE);
|
||||||
|
if (EFI_ERROR(Status))
|
||||||
|
{
|
||||||
|
vErr(L"Failed to finally launch real grub %s", REAL_GRUB_FILE);
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
END:
|
END:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user