diff --git a/Tiano/EfiTianoDecompress.c b/Tiano/EfiTianoDecompress.c index 9a3484c..156392c 100644 --- a/Tiano/EfiTianoDecompress.c +++ b/Tiano/EfiTianoDecompress.c @@ -1,6 +1,6 @@ /*++ EfiTianoDecompress.c -Copyright (c) 2014, Nikolaj Schlej. All rights reserved.
+Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -702,10 +702,10 @@ Returns: (VOID) EFI_STATUS GetInfo( -IN VOID *Source, -IN UINT32 SrcSize, -OUT UINT32 *DstSize, -OUT UINT32 *ScratchSize +IN const VOID *Source, +IN UINT32 SrcSize, +OUT UINT32 *DstSize, +OUT UINT32 *ScratchSize ) /*++ @@ -727,7 +727,7 @@ EFI_INVALID_PARAMETER - The source data is corrupted --*/ { - UINT8 *Src; + const UINT8 *Src; *ScratchSize = sizeof(SCRATCH_DATA); @@ -742,13 +742,13 @@ EFI_INVALID_PARAMETER - The source data is corrupted EFI_STATUS Decompress( -IN VOID *Source, -IN UINT32 SrcSize, -IN OUT VOID *Destination, -IN UINT32 DstSize, -IN OUT VOID *Scratch, -IN UINT32 ScratchSize, -IN UINT8 Version +IN const VOID *Source, +IN UINT32 SrcSize, +IN OUT VOID *Destination, +IN UINT32 DstSize, +IN OUT VOID *Scratch, +IN UINT32 ScratchSize, +IN UINT8 Version ) /*++ @@ -780,7 +780,7 @@ EFI_INVALID_PARAMETER - The source data is corrupted UINT32 OrigSize; EFI_STATUS Status; SCRATCH_DATA *Sd; - UINT8 *Src; + const UINT8 *Src; UINT8 *Dst; Status = EFI_SUCCESS; @@ -841,7 +841,7 @@ EFI_INVALID_PARAMETER - The source data is corrupted return EFI_INVALID_PARAMETER; } - Sd->mSrcBase = Src; + Sd->mSrcBase = (UINT8*)Src; Sd->mDstBase = Dst; Sd->mCompSize = CompSize; Sd->mOrigSize = OrigSize; @@ -869,7 +869,7 @@ EFI_INVALID_PARAMETER - The source data is corrupted EFI_STATUS EFIAPI EfiTianoGetInfo( -IN VOID *Source, +IN const VOID *Source, IN UINT32 SrcSize, OUT UINT32 *DstSize, OUT UINT32 *ScratchSize @@ -906,7 +906,7 @@ EFI_INVALID_PARAMETER - The source data is corrupted EFI_STATUS EFIAPI EfiDecompress( -IN VOID *Source, +IN const VOID *Source, IN UINT32 SrcSize, IN OUT VOID *Destination, IN UINT32 DstSize, @@ -953,7 +953,7 @@ EFI_INVALID_PARAMETER - The source data is corrupted EFI_STATUS EFIAPI TianoDecompress( -IN VOID *Source, +IN const VOID *Source, IN UINT32 SrcSize, IN OUT VOID *Destination, IN UINT32 DstSize, diff --git a/ffs.cpp b/ffs.cpp index 12faa12..b94dfa0 100644 --- a/ffs.cpp +++ b/ffs.cpp @@ -13,6 +13,16 @@ WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include "ffs.h" +const QVector FFSv2Volumes = + QVector() + << EFI_FIRMWARE_FILE_SYSTEM_GUID + << EFI_FIRMWARE_FILE_SYSTEM2_GUID + << EFI_APPLE_BOOT_VOLUME_FILE_SYSTEM_GUID + << EFI_APPLE_BOOT_VOLUME_FILE_SYSTEM2_GUID + << EFI_INTEL_FILE_SYSTEM_GUID + << EFI_INTEL_FILE_SYSTEM2_GUID + << EFI_SONY_FILE_SYSTEM_GUID; + const UINT8 ffsAlignmentTable[] = { 0, 4, 7, 9, 10, 12, 15, 16 }; @@ -164,4 +174,4 @@ UINT32 sizeOfSectionHeader(const EFI_COMMON_SECTION_HEADER* header) case SCT_SECTION_POSTCODE: return sizeof(POSTCODE_SECTION); default: return sizeof(EFI_COMMON_SECTION_HEADER); } -} \ No newline at end of file +} diff --git a/ffs.h b/ffs.h index 2cb2a48..8287e3d 100644 --- a/ffs.h +++ b/ffs.h @@ -118,16 +118,7 @@ const QByteArray EFI_SONY_FILE_SYSTEM_GUID //Vector of volume GUIDs with FFSv2-compatible files -const QVector FFSv2Volumes -({ - EFI_FIRMWARE_FILE_SYSTEM_GUID, - EFI_FIRMWARE_FILE_SYSTEM2_GUID, - EFI_APPLE_BOOT_VOLUME_FILE_SYSTEM_GUID, - EFI_APPLE_BOOT_VOLUME_FILE_SYSTEM2_GUID, - EFI_INTEL_FILE_SYSTEM_GUID, - EFI_INTEL_FILE_SYSTEM2_GUID, - EFI_SONY_FILE_SYSTEM_GUID -}); +extern const QVector FFSv2Volumes; // Firmware volume signature const QByteArray EFI_FV_SIGNATURE("_FVH", 4); diff --git a/ffsengine.cpp b/ffsengine.cpp index 687711e..1c7e9a6 100644 --- a/ffsengine.cpp +++ b/ffsengine.cpp @@ -191,12 +191,13 @@ UINT8 FfsEngine::parseImageFile(const QByteArray & buffer) //!TODO: more info about Aptio capsule // Fill attributes - CAPSULE_ATTRIBUTES attributes = { 0 }; - attributes.Type = ATTR_CAPSULE_TYPE_APTIO; - attributes.Signed = signedCapsule; + UINT32 attr = 0; + CAPSULE_ATTRIBUTES* attributes = (CAPSULE_ATTRIBUTES*)&attr; + attributes->Type = ATTR_CAPSULE_TYPE_APTIO; + attributes->Signed = signedCapsule; // Add tree item - index = model->addItem(Types::Capsule, *(UINT32*)&attributes, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body); + index = model->addItem(Types::Capsule, attr, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body); // Show message about possible Aptio signature break if (signedCapsule) { @@ -537,12 +538,13 @@ UINT8 FfsEngine::parseMeRegion(const QByteArray & me, QModelIndex & index, const } // Fill attributes - REGION_ATTRIBUTES attributes = { 0 }; - attributes.Type = ATTR_REGION_TYPE_ME; - attributes.Empty = emptyRegion; + UINT32 attr = 0; + REGION_ATTRIBUTES* attributes = (REGION_ATTRIBUTES*)&attr; + attributes->Type = ATTR_REGION_TYPE_ME; + attributes->Empty = emptyRegion; // Add tree item - index = model->addItem(Types::Region, *(UINT32*)&attributes, COMPRESSION_ALGORITHM_NONE, name, "", info, QByteArray(), me, parent, mode); + index = model->addItem(Types::Region, attr, COMPRESSION_ALGORITHM_NONE, name, "", info, QByteArray(), me, parent, mode); // Show messages if (emptyRegion) { @@ -785,13 +787,14 @@ UINT8 FfsEngine::parseVolume(const QByteArray & volume, QModelIndex & index, co headerSize = ALIGN8(headerSize); // Check for volume structure to be known - VOLUME_ATTRIBUTES attributes = { 0 }; - attributes.Unknown = true; + UINT32 attr = 0; + VOLUME_ATTRIBUTES* attributes = (VOLUME_ATTRIBUTES*)&attr; + attributes->Unknown = true; // Check for FFS v2 volume if (FFSv2Volumes.contains(QByteArray::fromRawData((const char*)volumeHeader->FileSystemGuid.Data, sizeof(EFI_GUID)))) { - attributes.Unknown = false; - attributes.FsVersion = 2; + attributes->Unknown = false; + attributes->FsVersion = 2; } //!TODO:Check for FFS v3 volume @@ -815,13 +818,13 @@ UINT8 FfsEngine::parseVolume(const QByteArray & volume, QModelIndex & index, co // Calculate CRC32 of the volume body UINT32 crc = crc32(0, (const UINT8*)(volume.constData() + volumeHeader->HeaderLength), volumeSize - volumeHeader->HeaderLength); if (crc == crc32FromZeroVector) { - attributes.ZeroVectorCrc = true; + attributes->ZeroVectorCrc = true; } } // Check header checksum by recalculating it bool msgInvalidChecksum = false; - if (!attributes.Unknown && calculateChecksum16((const UINT16*)volumeHeader, volumeHeader->HeaderLength)) + if (!attributes->Unknown && calculateChecksum16((const UINT16*)volumeHeader, volumeHeader->HeaderLength)) msgInvalidChecksum = true; // Get info @@ -841,7 +844,7 @@ UINT8 FfsEngine::parseVolume(const QByteArray & volume, QModelIndex & index, co .arg(empty ? "1" : "0"); // Apple CRC32 volume - if (attributes.ZeroVectorCrc) { + if (attributes->ZeroVectorCrc) { info += tr("\nCRC32 in ZeroVector: valid"); } @@ -856,10 +859,10 @@ UINT8 FfsEngine::parseVolume(const QByteArray & volume, QModelIndex & index, co // Add tree item QByteArray header = volume.left(headerSize); QByteArray body = volume.mid(headerSize, volumeSize - headerSize); - index = model->addItem(Types::Volume, *(UINT32*)&attributes, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body, parent, mode); + index = model->addItem(Types::Volume, attr, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body, parent, mode); // Show messages - if (attributes.Unknown) { + if (attributes->Unknown) { msg(tr("parseVolume: Unknown file system %1").arg(guidToQString(volumeHeader->FileSystemGuid)), index); // Do not parse unknown volumes return ERR_SUCCESS; diff --git a/treeitem.h b/treeitem.h index a5b8469..205ce50 100644 --- a/treeitem.h +++ b/treeitem.h @@ -78,11 +78,11 @@ private: UINT8 itemType; UINT32 itemAttributes; UINT8 itemCompression; + QString itemName; + QString itemText; + QString itemInfo; QByteArray itemHeader; QByteArray itemBody; - QString itemName; - QString itemText; - QString itemInfo; TreeItem *parentItem; };