Created
September 20, 2014 14:21
-
-
Save vathpela/b6ded1f6070a3072fa78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Retrieves the magic value from the PE/COFF header. | |
@param Hdr The buffer in which to return the PE32, PE32+, or TE header. | |
@return EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC - Image is PE32 | |
@return EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC - Image is PE32+ | |
**/ | |
UINT16 | |
PeCoffLoaderGetPeHeaderMagicValue ( | |
IN EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr | |
) | |
{ | |
// | |
// NOTE: Some versions of Linux ELILO for Itanium have an incorrect magic value | |
// in the PE/COFF Header. If the MachineType is Itanium(IA64) and the | |
// Magic value in the OptionalHeader is EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC | |
// then override the returned value to EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC | |
// | |
if (Hdr.Pe32->FileHeader.Machine == IMAGE_FILE_MACHINE_IA64 && Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { | |
return EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC; | |
} | |
// | |
// Return the magic value from the PC/COFF Optional Header | |
// | |
return Hdr.Pe32->OptionalHeader.Magic; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment