mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-22 07:58:22 +08:00
GCC and clang adaptations
- it seems that C99-style arrays init is MSVC-specific feature - some more const qualifiers
This commit is contained in:
parent
44a3fb63f0
commit
64a7c2ce2c
@ -1,6 +1,6 @@
|
|||||||
/*++ EfiTianoDecompress.c
|
/*++ EfiTianoDecompress.c
|
||||||
|
|
||||||
Copyright (c) 2014, Nikolaj Schlej. All rights reserved.<BR>
|
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.<BR>
|
||||||
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
@ -702,10 +702,10 @@ Returns: (VOID)
|
|||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
GetInfo(
|
GetInfo(
|
||||||
IN VOID *Source,
|
IN const VOID *Source,
|
||||||
IN UINT32 SrcSize,
|
IN UINT32 SrcSize,
|
||||||
OUT UINT32 *DstSize,
|
OUT UINT32 *DstSize,
|
||||||
OUT UINT32 *ScratchSize
|
OUT UINT32 *ScratchSize
|
||||||
)
|
)
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
@ -727,7 +727,7 @@ EFI_INVALID_PARAMETER - The source data is corrupted
|
|||||||
|
|
||||||
--*/
|
--*/
|
||||||
{
|
{
|
||||||
UINT8 *Src;
|
const UINT8 *Src;
|
||||||
|
|
||||||
*ScratchSize = sizeof(SCRATCH_DATA);
|
*ScratchSize = sizeof(SCRATCH_DATA);
|
||||||
|
|
||||||
@ -742,13 +742,13 @@ EFI_INVALID_PARAMETER - The source data is corrupted
|
|||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
Decompress(
|
Decompress(
|
||||||
IN VOID *Source,
|
IN const VOID *Source,
|
||||||
IN UINT32 SrcSize,
|
IN UINT32 SrcSize,
|
||||||
IN OUT VOID *Destination,
|
IN OUT VOID *Destination,
|
||||||
IN UINT32 DstSize,
|
IN UINT32 DstSize,
|
||||||
IN OUT VOID *Scratch,
|
IN OUT VOID *Scratch,
|
||||||
IN UINT32 ScratchSize,
|
IN UINT32 ScratchSize,
|
||||||
IN UINT8 Version
|
IN UINT8 Version
|
||||||
)
|
)
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
@ -780,7 +780,7 @@ EFI_INVALID_PARAMETER - The source data is corrupted
|
|||||||
UINT32 OrigSize;
|
UINT32 OrigSize;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
SCRATCH_DATA *Sd;
|
SCRATCH_DATA *Sd;
|
||||||
UINT8 *Src;
|
const UINT8 *Src;
|
||||||
UINT8 *Dst;
|
UINT8 *Dst;
|
||||||
|
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
@ -841,7 +841,7 @@ EFI_INVALID_PARAMETER - The source data is corrupted
|
|||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sd->mSrcBase = Src;
|
Sd->mSrcBase = (UINT8*)Src;
|
||||||
Sd->mDstBase = Dst;
|
Sd->mDstBase = Dst;
|
||||||
Sd->mCompSize = CompSize;
|
Sd->mCompSize = CompSize;
|
||||||
Sd->mOrigSize = OrigSize;
|
Sd->mOrigSize = OrigSize;
|
||||||
@ -869,7 +869,7 @@ EFI_INVALID_PARAMETER - The source data is corrupted
|
|||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
EfiTianoGetInfo(
|
EfiTianoGetInfo(
|
||||||
IN VOID *Source,
|
IN const VOID *Source,
|
||||||
IN UINT32 SrcSize,
|
IN UINT32 SrcSize,
|
||||||
OUT UINT32 *DstSize,
|
OUT UINT32 *DstSize,
|
||||||
OUT UINT32 *ScratchSize
|
OUT UINT32 *ScratchSize
|
||||||
@ -906,7 +906,7 @@ EFI_INVALID_PARAMETER - The source data is corrupted
|
|||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
EfiDecompress(
|
EfiDecompress(
|
||||||
IN VOID *Source,
|
IN const VOID *Source,
|
||||||
IN UINT32 SrcSize,
|
IN UINT32 SrcSize,
|
||||||
IN OUT VOID *Destination,
|
IN OUT VOID *Destination,
|
||||||
IN UINT32 DstSize,
|
IN UINT32 DstSize,
|
||||||
@ -953,7 +953,7 @@ EFI_INVALID_PARAMETER - The source data is corrupted
|
|||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
TianoDecompress(
|
TianoDecompress(
|
||||||
IN VOID *Source,
|
IN const VOID *Source,
|
||||||
IN UINT32 SrcSize,
|
IN UINT32 SrcSize,
|
||||||
IN OUT VOID *Destination,
|
IN OUT VOID *Destination,
|
||||||
IN UINT32 DstSize,
|
IN UINT32 DstSize,
|
||||||
|
12
ffs.cpp
12
ffs.cpp
@ -13,6 +13,16 @@ WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include "ffs.h"
|
#include "ffs.h"
|
||||||
|
|
||||||
|
const QVector<QByteArray> FFSv2Volumes =
|
||||||
|
QVector<QByteArray>()
|
||||||
|
<< 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[] =
|
const UINT8 ffsAlignmentTable[] =
|
||||||
{ 0, 4, 7, 9, 10, 12, 15, 16 };
|
{ 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);
|
case SCT_SECTION_POSTCODE: return sizeof(POSTCODE_SECTION);
|
||||||
default: return sizeof(EFI_COMMON_SECTION_HEADER);
|
default: return sizeof(EFI_COMMON_SECTION_HEADER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
11
ffs.h
11
ffs.h
@ -118,16 +118,7 @@ const QByteArray EFI_SONY_FILE_SYSTEM_GUID
|
|||||||
|
|
||||||
|
|
||||||
//Vector of volume GUIDs with FFSv2-compatible files
|
//Vector of volume GUIDs with FFSv2-compatible files
|
||||||
const QVector<QByteArray> FFSv2Volumes
|
extern const QVector<QByteArray> 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
|
|
||||||
});
|
|
||||||
|
|
||||||
// Firmware volume signature
|
// Firmware volume signature
|
||||||
const QByteArray EFI_FV_SIGNATURE("_FVH", 4);
|
const QByteArray EFI_FV_SIGNATURE("_FVH", 4);
|
||||||
|
@ -191,12 +191,13 @@ UINT8 FfsEngine::parseImageFile(const QByteArray & buffer)
|
|||||||
//!TODO: more info about Aptio capsule
|
//!TODO: more info about Aptio capsule
|
||||||
|
|
||||||
// Fill attributes
|
// Fill attributes
|
||||||
CAPSULE_ATTRIBUTES attributes = { 0 };
|
UINT32 attr = 0;
|
||||||
attributes.Type = ATTR_CAPSULE_TYPE_APTIO;
|
CAPSULE_ATTRIBUTES* attributes = (CAPSULE_ATTRIBUTES*)&attr;
|
||||||
attributes.Signed = signedCapsule;
|
attributes->Type = ATTR_CAPSULE_TYPE_APTIO;
|
||||||
|
attributes->Signed = signedCapsule;
|
||||||
|
|
||||||
// Add tree item
|
// 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
|
// Show message about possible Aptio signature break
|
||||||
if (signedCapsule) {
|
if (signedCapsule) {
|
||||||
@ -537,12 +538,13 @@ UINT8 FfsEngine::parseMeRegion(const QByteArray & me, QModelIndex & index, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fill attributes
|
// Fill attributes
|
||||||
REGION_ATTRIBUTES attributes = { 0 };
|
UINT32 attr = 0;
|
||||||
attributes.Type = ATTR_REGION_TYPE_ME;
|
REGION_ATTRIBUTES* attributes = (REGION_ATTRIBUTES*)&attr;
|
||||||
attributes.Empty = emptyRegion;
|
attributes->Type = ATTR_REGION_TYPE_ME;
|
||||||
|
attributes->Empty = emptyRegion;
|
||||||
|
|
||||||
// Add tree item
|
// 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
|
// Show messages
|
||||||
if (emptyRegion) {
|
if (emptyRegion) {
|
||||||
@ -785,13 +787,14 @@ UINT8 FfsEngine::parseVolume(const QByteArray & volume, QModelIndex & index, co
|
|||||||
headerSize = ALIGN8(headerSize);
|
headerSize = ALIGN8(headerSize);
|
||||||
|
|
||||||
// Check for volume structure to be known
|
// Check for volume structure to be known
|
||||||
VOLUME_ATTRIBUTES attributes = { 0 };
|
UINT32 attr = 0;
|
||||||
attributes.Unknown = true;
|
VOLUME_ATTRIBUTES* attributes = (VOLUME_ATTRIBUTES*)&attr;
|
||||||
|
attributes->Unknown = true;
|
||||||
|
|
||||||
// Check for FFS v2 volume
|
// Check for FFS v2 volume
|
||||||
if (FFSv2Volumes.contains(QByteArray::fromRawData((const char*)volumeHeader->FileSystemGuid.Data, sizeof(EFI_GUID)))) {
|
if (FFSv2Volumes.contains(QByteArray::fromRawData((const char*)volumeHeader->FileSystemGuid.Data, sizeof(EFI_GUID)))) {
|
||||||
attributes.Unknown = false;
|
attributes->Unknown = false;
|
||||||
attributes.FsVersion = 2;
|
attributes->FsVersion = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//!TODO:Check for FFS v3 volume
|
//!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
|
// Calculate CRC32 of the volume body
|
||||||
UINT32 crc = crc32(0, (const UINT8*)(volume.constData() + volumeHeader->HeaderLength), volumeSize - volumeHeader->HeaderLength);
|
UINT32 crc = crc32(0, (const UINT8*)(volume.constData() + volumeHeader->HeaderLength), volumeSize - volumeHeader->HeaderLength);
|
||||||
if (crc == crc32FromZeroVector) {
|
if (crc == crc32FromZeroVector) {
|
||||||
attributes.ZeroVectorCrc = true;
|
attributes->ZeroVectorCrc = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check header checksum by recalculating it
|
// Check header checksum by recalculating it
|
||||||
bool msgInvalidChecksum = false;
|
bool msgInvalidChecksum = false;
|
||||||
if (!attributes.Unknown && calculateChecksum16((const UINT16*)volumeHeader, volumeHeader->HeaderLength))
|
if (!attributes->Unknown && calculateChecksum16((const UINT16*)volumeHeader, volumeHeader->HeaderLength))
|
||||||
msgInvalidChecksum = true;
|
msgInvalidChecksum = true;
|
||||||
|
|
||||||
// Get info
|
// Get info
|
||||||
@ -841,7 +844,7 @@ UINT8 FfsEngine::parseVolume(const QByteArray & volume, QModelIndex & index, co
|
|||||||
.arg(empty ? "1" : "0");
|
.arg(empty ? "1" : "0");
|
||||||
|
|
||||||
// Apple CRC32 volume
|
// Apple CRC32 volume
|
||||||
if (attributes.ZeroVectorCrc) {
|
if (attributes->ZeroVectorCrc) {
|
||||||
info += tr("\nCRC32 in ZeroVector: valid");
|
info += tr("\nCRC32 in ZeroVector: valid");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -856,10 +859,10 @@ UINT8 FfsEngine::parseVolume(const QByteArray & volume, QModelIndex & index, co
|
|||||||
// Add tree item
|
// Add tree item
|
||||||
QByteArray header = volume.left(headerSize);
|
QByteArray header = volume.left(headerSize);
|
||||||
QByteArray body = volume.mid(headerSize, volumeSize - 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
|
// Show messages
|
||||||
if (attributes.Unknown) {
|
if (attributes->Unknown) {
|
||||||
msg(tr("parseVolume: Unknown file system %1").arg(guidToQString(volumeHeader->FileSystemGuid)), index);
|
msg(tr("parseVolume: Unknown file system %1").arg(guidToQString(volumeHeader->FileSystemGuid)), index);
|
||||||
// Do not parse unknown volumes
|
// Do not parse unknown volumes
|
||||||
return ERR_SUCCESS;
|
return ERR_SUCCESS;
|
||||||
|
@ -78,11 +78,11 @@ private:
|
|||||||
UINT8 itemType;
|
UINT8 itemType;
|
||||||
UINT32 itemAttributes;
|
UINT32 itemAttributes;
|
||||||
UINT8 itemCompression;
|
UINT8 itemCompression;
|
||||||
|
QString itemName;
|
||||||
|
QString itemText;
|
||||||
|
QString itemInfo;
|
||||||
QByteArray itemHeader;
|
QByteArray itemHeader;
|
||||||
QByteArray itemBody;
|
QByteArray itemBody;
|
||||||
QString itemName;
|
|
||||||
QString itemText;
|
|
||||||
QString itemInfo;
|
|
||||||
TreeItem *parentItem;
|
TreeItem *parentItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user