Add a way to check PE/COFF image machine type

This commit is contained in:
2022-12-20 15:37:13 +01:00
parent 7bcdd8562d
commit eb5998c58e
4 changed files with 22 additions and 0 deletions

View File

@@ -50,6 +50,19 @@ PeGetEntryPoint(IN PPECOFF_IMAGE_CONTEXT Image,
return STATUS_EFI_SUCCESS;
}
EFI_STATUS
PeGetMachineType(IN PPECOFF_IMAGE_CONTEXT Image,
OUT PUSHORT MachineType)
{
if(!Image || !Image->PeHeader)
{
return STATUS_EFI_INVALID_PARAMETER;
}
*MachineType = Image->PeHeader->FileHeader.Machine;
return STATUS_EFI_SUCCESS;
}
/**
* Returns an information about subsystem that is required to run PE/COFF image.
*
@@ -548,6 +561,7 @@ BlXtLdrModuleMain(IN EFI_HANDLE ImageHandle,
/* Set routines available via PE/COFF image protocol */
XtPeCoffProtocol.GetEntryPoint = PeGetEntryPoint;
XtPeCoffProtocol.GetMachineType = PeGetMachineType;
XtPeCoffProtocol.GetSubSystem = PeGetSubSystem;
XtPeCoffProtocol.Load = PeLoadImage;
XtPeCoffProtocol.Relocate = PeRelocateImage;