mirror of
https://github.com/acidanthera/audk.git
synced 2025-09-22 17:27:44 +02:00
MdeModulePkg/UefiBootManagerLib: Do not parse the UEFI image
This commit is contained in:
parent
1e673c4935
commit
c36bf0ae08
@ -1213,55 +1213,6 @@ EfiBootManagerFreeLoadOptions (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Return whether the PE header of the load option is valid or not.
|
||||
|
||||
@param[in] Type The load option type.
|
||||
It's used to check whether the load option is valid.
|
||||
When it's LoadOptionTypeMax, the routine only guarantees
|
||||
the load option is a valid PE image but doesn't guarantee
|
||||
the PE's subsystem type is valid.
|
||||
@param[in] FileBuffer The PE file buffer of the load option.
|
||||
@param[in] FileSize The size of the load option file.
|
||||
|
||||
@retval TRUE The PE header of the load option is valid.
|
||||
@retval FALSE The PE header of the load option is not valid.
|
||||
**/
|
||||
BOOLEAN
|
||||
BmIsLoadOptionPeHeaderValid (
|
||||
IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE Type,
|
||||
IN VOID *FileBuffer,
|
||||
IN UINTN FileSize
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UEFI_IMAGE_LOADER_IMAGE_CONTEXT ImageContext;
|
||||
UINT16 Subsystem;
|
||||
|
||||
if ((FileBuffer == NULL) || (FileSize == 0)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Status = UefiImageInitializeContext (&ImageContext, FileBuffer, (UINT32) FileSize);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Subsystem = UefiImageGetSubsystem (&ImageContext);
|
||||
|
||||
if ((Type == LoadOptionTypeMax) ||
|
||||
(Type == LoadOptionTypeDriver && Subsystem == EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER) ||
|
||||
(Type == LoadOptionTypeDriver && Subsystem == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER) ||
|
||||
(Type == LoadOptionTypeSysPrep && Subsystem == EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION) ||
|
||||
(Type == LoadOptionTypeBoot && Subsystem == EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION) ||
|
||||
(Type == LoadOptionTypePlatformRecovery && Subsystem == EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION)
|
||||
) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
Return the next matched load option buffer.
|
||||
The routine keeps calling BmGetNextLoadOptionDevicePath() until a valid
|
||||
@ -1295,7 +1246,6 @@ BmGetNextLoadOptionBuffer (
|
||||
EFI_DEVICE_PATH_PROTOCOL *CurFullPath;
|
||||
UINTN LocalFileSize;
|
||||
UINT32 AuthenticationStatus;
|
||||
EFI_DEVICE_PATH_PROTOCOL *RamDiskDevicePath;
|
||||
|
||||
LocalFileSize = 0;
|
||||
FileBuffer = NULL;
|
||||
@ -1315,22 +1265,6 @@ BmGetNextLoadOptionBuffer (
|
||||
}
|
||||
|
||||
FileBuffer = GetFileBufferByFilePath (TRUE, CurFullPath, &LocalFileSize, &AuthenticationStatus);
|
||||
if ((FileBuffer != NULL) && !BmIsLoadOptionPeHeaderValid (Type, FileBuffer, LocalFileSize)) {
|
||||
//
|
||||
// Free the RAM disk file system if the load option is invalid.
|
||||
//
|
||||
RamDiskDevicePath = BmGetRamDiskDevicePath (FilePath);
|
||||
if (RamDiskDevicePath != NULL) {
|
||||
BmDestroyRamDisk (RamDiskDevicePath);
|
||||
FreePool (RamDiskDevicePath);
|
||||
}
|
||||
|
||||
//
|
||||
// Free the invalid load option buffer.
|
||||
//
|
||||
FreePool (FileBuffer);
|
||||
FileBuffer = NULL;
|
||||
}
|
||||
} while (FileBuffer == NULL);
|
||||
|
||||
if (FileBuffer == NULL) {
|
||||
@ -1372,6 +1306,7 @@ EfiBootManagerProcessLoadOption (
|
||||
EFI_LOADED_IMAGE_PROTOCOL *ImageInfo;
|
||||
VOID *FileBuffer;
|
||||
UINTN FileSize;
|
||||
EFI_DEVICE_PATH_PROTOCOL *RamDiskDevicePath;
|
||||
|
||||
if ((UINT32)LoadOption->OptionType >= LoadOptionTypeMax) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
@ -1438,6 +1373,15 @@ EfiBootManagerProcessLoadOption (
|
||||
if (Status == EFI_SECURITY_VIOLATION) {
|
||||
gBS->UnloadImage (ImageHandle);
|
||||
}
|
||||
|
||||
//
|
||||
// Free the RAM disk file system if the load option is invalid.
|
||||
//
|
||||
RamDiskDevicePath = BmGetRamDiskDevicePath (LoadOption->FilePath);
|
||||
if (RamDiskDevicePath != NULL) {
|
||||
BmDestroyRamDisk (RamDiskDevicePath);
|
||||
FreePool (RamDiskDevicePath);
|
||||
}
|
||||
} else {
|
||||
Status = gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **)&ImageInfo);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
@ -68,7 +68,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#include <Library/CapsuleLib.h>
|
||||
#include <Library/PerformanceLib.h>
|
||||
#include <Library/HiiLib.h>
|
||||
#include <Library/UefiImageLib.h>
|
||||
|
||||
#if !defined (EFI_REMOVABLE_MEDIA_FILE_NAME)
|
||||
#if defined (MDE_CPU_EBC)
|
||||
|
@ -62,7 +62,6 @@
|
||||
HiiLib
|
||||
SortLib
|
||||
VariablePolicyHelperLib
|
||||
UefiImageLib
|
||||
|
||||
[Guids]
|
||||
## SOMETIMES_CONSUMES ## SystemTable (The identifier of memory type information type in system table)
|
||||
|
Loading…
x
Reference in New Issue
Block a user