diff --git a/common/ffs.h b/common/ffs.h index 410c3f8..4a7ccae 100644 --- a/common/ffs.h +++ b/common/ffs.h @@ -27,27 +27,6 @@ extern bool ustringToGuid(const UString& str, EFI_GUID& guid); extern UString fileTypeToUString(const UINT8 type); extern UString sectionTypeToUString(const UINT8 type); -//***************************************************************************** -// Mac Image -//***************************************************************************** -typedef struct MAC_IMAGE_HEADER_ { - UINT64 Magic; // _MEFIBIN - UINT32 FirstImage; // 0x00000000 - UINT32 SecondImage; // 0x00080000 - // Region numbers? - UINT32 Unk1; // 1 - UINT32 Unk2; // 0/4/5 - UINT32 Unk3; // 2/7 - // Region image choices? - UINT32 UnkOff1; // 0x00080000 - UINT32 UnkOff2; // 0x00080000 - UINT32 UnkOff3; // 0x0 - UINT8 Zero[0x100 - sizeof (UINT64) - sizeof (UINT32)*8]; -} MAC_IMAGE_HEADER; - -// Mac Image magic -const UByteArray MAC_IMAGE_MAGIC -("\x5F\x4D\x45\x46\x49\x42\x49\x4E", 8); //***************************************************************************** // EFI Capsule diff --git a/common/ffsparser.cpp b/common/ffsparser.cpp index 972a72b..7432f0e 100644 --- a/common/ffsparser.cpp +++ b/common/ffsparser.cpp @@ -133,12 +133,6 @@ USTATUS FfsParser::performFirstPass(const UByteArray & buffer, UModelIndex & ind return result; } - // Try parsing as Mac EFI - result = parseMacImage(buffer, 0, UModelIndex(), index);; - if (result != U_ITEM_NOT_FOUND) { - return result; - } - // Try parsing as Intel image result = parseIntelImage(buffer, 0, UModelIndex(), index); if (result != U_ITEM_NOT_FOUND) { @@ -306,55 +300,6 @@ USTATUS FfsParser::parseCapsule(const UByteArray & capsule, const UINT32 localOf return U_ITEM_NOT_FOUND; } -USTATUS FfsParser::parseMacImage(const UByteArray & macImage, const UINT32 localOffset, const UModelIndex & parent, UModelIndex & index) -{ - // Check buffer size to be more than or equal to size of MAC_IMAGE_HEADER - if ((UINT32)macImage.size() < sizeof(MAC_IMAGE_HEADER)) { - return U_ITEM_NOT_FOUND; - } - - // Check buffer for being normal Mac Image header - if (macImage.startsWith(MAC_IMAGE_MAGIC)) { - // Get info - const MAC_IMAGE_HEADER* macImageHeader = (const MAC_IMAGE_HEADER*)macImage.constData(); - - if (macImageHeader->FirstImage >= macImage.size() - sizeof(MAC_IMAGE_HEADER) - || macImageHeader->SecondImage >= macImage.size() - sizeof(MAC_IMAGE_HEADER) - || macImageHeader->FirstImage >= macImageHeader->SecondImage) { - msg(usprintf("%s: unsupported image combination %Xh %Xh", __FUNCTION__, macImageHeader->FirstImage, macImageHeader->SecondImage)); - return U_INVALID_FLASH_DESCRIPTOR; - } - - UByteArray header = macImage.left(sizeof(MAC_IMAGE_HEADER)); - UByteArray fullBody = macImage.mid(sizeof(MAC_IMAGE_HEADER)); - UByteArray firstBody = macImage.mid(sizeof(MAC_IMAGE_HEADER) + macImageHeader->FirstImage, macImageHeader->SecondImage); - UByteArray secondBody = macImage.mid(sizeof(MAC_IMAGE_HEADER) + macImageHeader->SecondImage); - - UString name("Mac image"); - UString info = usprintf("Mac image:\nFirst image: %Xh\nSecond image: %08Xh", - macImageHeader->FirstImage, macImageHeader->SecondImage); - - // Add tree item - index = model->addItem(localOffset, Types::MacImage, Subtypes::MacGenericImage, name, UString(), info, header, fullBody, UByteArray(), Fixed, parent); - - UModelIndex imageIndex; - - // Try parsing as Intel image - USTATUS result = parseIntelImage(firstBody, sizeof(MAC_IMAGE_HEADER) + macImageHeader->FirstImage, index, imageIndex); - if (result == U_SUCCESS) { - result = parseIntelImage(secondBody, sizeof(MAC_IMAGE_HEADER) + macImageHeader->SecondImage, index, imageIndex); - } - if (result != U_ITEM_NOT_FOUND) { - return result; - } - - // Parse as generic image - return parseGenericImage(fullBody, sizeof(MAC_IMAGE_HEADER), index, imageIndex); - } - - return U_ITEM_NOT_FOUND; -} - USTATUS FfsParser::parseIntelImage(const UByteArray & intelImage, const UINT32 localOffset, const UModelIndex & parent, UModelIndex & index) { // Check for buffer size to be greater or equal to descriptor region size @@ -1010,7 +955,7 @@ USTATUS FfsParser::parseVolumeHeader(const UByteArray & volume, const UINT32 loc return U_INVALID_PARAMETER; // Check that there is space for the volume header - if ((UINT32)volume.size() < sizeof(EFI_FIRMWARE_VOLUME_HEADER)) { + if ((UINT32)volume.size() < sizeof(EFI_FIRMWARE_VOLUME_HEADER)) { msg(usprintf("%s: input volume size %Xh (%u) is smaller than volume header size 40h (64)", __FUNCTION__, volume.size(), volume.size())); return U_INVALID_VOLUME; } @@ -1279,17 +1224,6 @@ USTATUS FfsParser::findNextRawAreaItem(const UModelIndex & index, const UINT32 l nextItemType = Types::Volume; nextItemSize = (UINT32)volumeHeader->FvLength; nextItemOffset = offset - EFI_FV_SIGNATURE_OFFSET; - - // Hack for Apple images with an extra zero typo in NVRAM volume size. - uint32_t appleWrongSize = 0x2F0000; - uint32_t appleRightSize = 0x2EFC0; - if ((volumeHeader->FvLength == appleWrongSize) - && UByteArray((const char *)&volumeHeader->FileSystemGuid, sizeof(EFI_GUID)) == NVRAM_MAIN_STORE_VOLUME_GUID - && UByteArray((const char *)volumeHeader + appleRightSize + sizeof(EFI_GUID), sizeof(EFI_GUID)) == APPLE_UNKNOWN_STORE_VOLUME_GUID) { - msg(usprintf("%s: hack, fixing up NVRAM volume size from %Xh to %Xh", __FUNCTION__, volumeHeader->FvLength, appleRightSize), index); - nextItemSize = appleRightSize; - } - break; } } diff --git a/common/ffsparser.h b/common/ffsparser.h index 979a9fe..74febfc 100644 --- a/common/ffsparser.h +++ b/common/ffsparser.h @@ -94,7 +94,6 @@ private: USTATUS performFirstPass(const UByteArray & imageFile, UModelIndex & index); USTATUS parseCapsule(const UByteArray & capsule, const UINT32 localOffset, const UModelIndex & parent, UModelIndex & index); - USTATUS parseMacImage(const UByteArray & macImage, const UINT32 localOffset, const UModelIndex & parent, UModelIndex & index); USTATUS parseIntelImage(const UByteArray & intelImage, const UINT32 localOffset, const UModelIndex & parent, UModelIndex & index); USTATUS parseGenericImage(const UByteArray & intelImage, const UINT32 localOffset, const UModelIndex & parent, UModelIndex & index); diff --git a/common/nvram.h b/common/nvram.h index a234f12..74d9126 100755 --- a/common/nvram.h +++ b/common/nvram.h @@ -84,10 +84,6 @@ const UByteArray NVRAM_MAIN_STORE_VOLUME_GUID const UByteArray NVRAM_ADDITIONAL_STORE_VOLUME_GUID ("\x24\x46\x50\x00\x59\x8A\xEB\x4E\xBD\x0F\x6B\x36\xE9\x61\x28\xE0", 16); -// TODO: Explore -const UByteArray APPLE_UNKNOWN_STORE_VOLUME_GUID -("\xE4\x0E\x81\x0A\x93\xBF\x59\x4B\xDD\xBC\xA2\x9D\xB4\x4B\x4A\x95", 16); - #define NVRAM_VSS_STORE_SIGNATURE 0x53535624 // $VSS #define NVRAM_APPLE_SVS_STORE_SIGNATURE 0x53565324 // $SVS #define NVRAM_APPLE_NSS_STORE_SIGNATURE 0x53534E24 // $NSS diff --git a/common/types.cpp b/common/types.cpp index d67def5..ca365ba 100755 --- a/common/types.cpp +++ b/common/types.cpp @@ -110,9 +110,6 @@ UString itemSubtypeToUString(const UINT8 type, const UINT8 subtype) if (subtype == Subtypes::UefiCapsule) return UString("UEFI 2.0"); if (subtype == Subtypes::ToshibaCapsule) return UString("Toshiba"); break; - case Types::MacImage: - if (subtype == Subtypes::MacGenericImage) return UString("Mac 1.0"); - break; case Types::Region: return regionTypeToUString(subtype); case Types::File: return fileTypeToUString(subtype); case Types::Section: return sectionTypeToUString(subtype); @@ -219,4 +216,4 @@ UString fitEntryTypeToUString(const UINT8 type) } return UString("Unknown"); -} +} \ No newline at end of file diff --git a/common/types.h b/common/types.h index b4669fb..edab19f 100755 --- a/common/types.h +++ b/common/types.h @@ -36,7 +36,6 @@ namespace Types { enum ItemTypes { Root = 60, Capsule, - MacImage, Image, Region, Padding, @@ -89,12 +88,8 @@ namespace Subtypes { ToshibaCapsule }; - enum MacImageSubtypes { - MacGenericImage = 110, - }; - enum VolumeSubtypes { - UnknownVolume = 120, + UnknownVolume = 110, Ffs2Volume, Ffs3Volume, NvramVolume, @@ -121,13 +116,13 @@ namespace Subtypes { }; enum PaddingSubtypes { - ZeroPadding = 130, + ZeroPadding = 120, OnePadding, DataPadding }; enum NvarEntrySubtypes { - InvalidNvarEntry = 140, + InvalidNvarEntry = 130, InvalidLinkNvarEntry, LinkNvarEntry, DataNvarEntry, @@ -135,7 +130,7 @@ namespace Subtypes { }; enum VssEntrySubtypes { - InvalidVssEntry = 150, + InvalidVssEntry = 140, StandardVssEntry, AppleVssEntry, AuthVssEntry, @@ -143,12 +138,12 @@ namespace Subtypes { }; enum FsysEntrySubtypes { - InvalidFsysEntry = 160, + InvalidFsysEntry = 150, NormalFsysEntry }; enum EvsaEntrySubtypes { - InvalidEvsaEntry = 170, + InvalidEvsaEntry = 160, UnknownEvsaEntry, GuidEvsaEntry, NameEvsaEntry, @@ -156,39 +151,39 @@ namespace Subtypes { }; enum FlashMapEntrySubtypes { - VolumeFlashMapEntry = 180, + VolumeFlashMapEntry = 170, DataFlashMapEntry }; enum MicrocodeSubtypes { - IntelMicrocode = 190, + IntelMicrocode = 180, AmdMicrocode }; enum SlicDataSubtypes { - PubkeySlicData = 200, + PubkeySlicData = 190, MarkerSlicData }; // ME-specific enum IfwiPartitionSubtypes { - DataIfwiPartition = 210, + DataIfwiPartition = 200, BootIfwiPartition }; enum FptEntrySubtypes { - ValidFptEntry = 220, + ValidFptEntry = 210, InvalidFptEntry }; enum FptPartitionSubtypes { - CodeFptPartition = 230, + CodeFptPartition = 220, DataFptPartition, GlutFptPartition }; enum CpdPartitionSubtypes { - ManifestCpdPartition = 240, + ManifestCpdPartition = 230, MetadataCpdPartition, KeyCpdPartition, CodeCpdPartition