Version 0.16.1

- fixed a serious bug in section rebuild process
- opening search windows sets text focus into search edit box
This commit is contained in:
Nikolaj Schlej 2014-01-12 00:02:54 +01:00
parent 1fedb2becf
commit 5789e2f9e6
15 changed files with 641 additions and 670 deletions

View File

@ -85,9 +85,9 @@ typedef struct {
typedef struct { typedef struct {
FLASH_PARAMETERS FlashParameters; FLASH_PARAMETERS FlashParameters;
UINT8 InvalidInstruction0; // Instructions for SPI chip, that must not be executed, like FLASH ERASE UINT8 InvalidInstruction0; // Instructions for SPI chip, that must not be executed, like FLASH ERASE
UINT8 InvalidInstruction1; // UINT8 InvalidInstruction1; //
UINT8 InvalidInstruction2; // UINT8 InvalidInstruction2; //
UINT8 InvalidInstruction3; // UINT8 InvalidInstruction3; //
UINT16 PartitionBoundary; // Upper 16 bit of partition boundary address. Default is 0x0000, which makes the boundary to be 0x00001000 UINT16 PartitionBoundary; // Upper 16 bit of partition boundary address. Default is 0x0000, which makes the boundary to be 0x00001000
UINT16 ReservedZero; // Still unknown, zero in all descriptors I have seen UINT16 ReservedZero; // Still unknown, zero in all descriptors I have seen
} FLASH_DESCRIPTOR_COMPONENT_SECTION; } FLASH_DESCRIPTOR_COMPONENT_SECTION;
@ -98,8 +98,8 @@ typedef struct {
typedef struct { typedef struct {
UINT16 ReservedZero; // Still unknown, zero in all descriptors I have seen UINT16 ReservedZero; // Still unknown, zero in all descriptors I have seen
UINT16 FlashBlockEraseSize; // Size of block erased by single BLOCK ERASE command UINT16 FlashBlockEraseSize; // Size of block erased by single BLOCK ERASE command
UINT16 BiosBase; UINT16 BiosBase;
UINT16 BiosLimit; UINT16 BiosLimit;
UINT16 MeBase; UINT16 MeBase;
UINT16 MeLimit; UINT16 MeLimit;
UINT16 GbeBase; UINT16 GbeBase;

30
ffs.cpp
View File

@ -55,9 +55,9 @@ VOID uint32ToUint24(UINT32 size, UINT8* ffsSize)
UINT32 uint24ToUint32(UINT8* ffsSize) UINT32 uint24ToUint32(UINT8* ffsSize)
{ {
return (ffsSize[2] << 16) + return (ffsSize[2] << 16) +
(ffsSize[1] << 8) + (ffsSize[1] << 8) +
ffsSize[0]; ffsSize[0];
} }
QString guidToQString(const EFI_GUID guid) QString guidToQString(const EFI_GUID guid)
@ -76,17 +76,17 @@ QString guidToQString(const EFI_GUID guid)
UINT8 i8_7 = *(UINT8*)baGuid.mid(15, 1).constData(); UINT8 i8_7 = *(UINT8*)baGuid.mid(15, 1).constData();
return QString("%1-%2-%3-%4%5-%6%7%8%9%10%11") return QString("%1-%2-%3-%4%5-%6%7%8%9%10%11")
.arg(i32, 8, 16, QChar('0')) .arg(i32, 8, 16, QChar('0'))
.arg(i16_0, 4, 16, QChar('0')) .arg(i16_0, 4, 16, QChar('0'))
.arg(i16_1, 4, 16, QChar('0')) .arg(i16_1, 4, 16, QChar('0'))
.arg(i8_0, 2, 16, QChar('0')) .arg(i8_0, 2, 16, QChar('0'))
.arg(i8_1, 2, 16, QChar('0')) .arg(i8_1, 2, 16, QChar('0'))
.arg(i8_2, 2, 16, QChar('0')) .arg(i8_2, 2, 16, QChar('0'))
.arg(i8_3, 2, 16, QChar('0')) .arg(i8_3, 2, 16, QChar('0'))
.arg(i8_4, 2, 16, QChar('0')) .arg(i8_4, 2, 16, QChar('0'))
.arg(i8_5, 2, 16, QChar('0')) .arg(i8_5, 2, 16, QChar('0'))
.arg(i8_6, 2, 16, QChar('0')) .arg(i8_6, 2, 16, QChar('0'))
.arg(i8_7, 2, 16, QChar('0')).toUpper(); .arg(i8_7, 2, 16, QChar('0')).toUpper();
} }
QString fileTypeToQString(const UINT8 type) QString fileTypeToQString(const UINT8 type)
@ -202,4 +202,4 @@ UINT32 sizeOfSectionHeaderOfType(const UINT8 type)
default: default:
return sizeof(EFI_COMMON_SECTION_HEADER); return sizeof(EFI_COMMON_SECTION_HEADER);
} }
} }

36
ffs.h
View File

@ -36,10 +36,10 @@ extern "C" {
//***************************************************************************** //*****************************************************************************
// Capsule header // Capsule header
typedef struct { typedef struct {
EFI_GUID CapsuleGuid; EFI_GUID CapsuleGuid;
UINT32 HeaderSize; UINT32 HeaderSize;
UINT32 Flags; UINT32 Flags;
UINT32 CapsuleImageSize; UINT32 CapsuleImageSize;
} EFI_CAPSULE_HEADER; } EFI_CAPSULE_HEADER;
// Capsule flags // Capsule flags
@ -54,10 +54,10 @@ const QByteArray EFI_CAPSULE_GUID("\xBD\x86\x66\x3B\x76\x0D\x30\x40\xB7\x0E\xB5\
typedef struct { typedef struct {
EFI_CAPSULE_HEADER CapsuleHeader; EFI_CAPSULE_HEADER CapsuleHeader;
UINT16 RomImageOffset; // offset in bytes from the beginning of the capsule header to the start of UINT16 RomImageOffset; // offset in bytes from the beginning of the capsule header to the start of
// the capsule volume // the capsule volume
//!TODO: Enable certificate and rom layout reading //!TODO: Enable certificate and rom layout reading
//UINT16 RomLayoutOffset; // offset to the table of the module descriptors in the capsule's volume //UINT16 RomLayoutOffset; // offset to the table of the module descriptors in the capsule's volume
// that are included in the signature calculation // that are included in the signature calculation
//FW_CERTIFICATE FWCert; //FW_CERTIFICATE FWCert;
//ROM_AREA RomAreaMap[1]; //ROM_AREA RomAreaMap[1];
} APTIO_CAPSULE_HEADER; } APTIO_CAPSULE_HEADER;
@ -72,8 +72,8 @@ const QByteArray APTIO_CAPSULE_GUID
// Firmware block map entry // Firmware block map entry
// FvBlockMap ends with an entry {0x00000000, 0x00000000} // FvBlockMap ends with an entry {0x00000000, 0x00000000}
typedef struct { typedef struct {
UINT32 NumBlocks; UINT32 NumBlocks;
UINT32 Length; UINT32 Length;
} EFI_FV_BLOCK_MAP_ENTRY; } EFI_FV_BLOCK_MAP_ENTRY;
// Volume header // Volume header
@ -188,8 +188,8 @@ const QByteArray EFI_FV_SIGNATURE("_FVH", 4);
// Extended firmware volume header // Extended firmware volume header
typedef struct { typedef struct {
EFI_GUID FvName; EFI_GUID FvName;
UINT32 ExtHeaderSize; UINT32 ExtHeaderSize;
} EFI_FIRMWARE_VOLUME_EXT_HEADER; } EFI_FIRMWARE_VOLUME_EXT_HEADER;
// Extended header entry // Extended header entry
@ -197,23 +197,23 @@ typedef struct {
// terminated by ExtHeaderType EFI_FV_EXT_TYPE_END // terminated by ExtHeaderType EFI_FV_EXT_TYPE_END
#define EFI_FV_EXT_TYPE_END 0x00 #define EFI_FV_EXT_TYPE_END 0x00
typedef struct { typedef struct {
UINT16 ExtEntrySize; UINT16 ExtEntrySize;
UINT16 ExtEntryType; UINT16 ExtEntryType;
} EFI_FIRMWARE_VOLUME_EXT_ENTRY; } EFI_FIRMWARE_VOLUME_EXT_ENTRY;
// GUID that maps OEM file types to GUIDs // GUID that maps OEM file types to GUIDs
#define EFI_FV_EXT_TYPE_OEM_TYPE 0x01 #define EFI_FV_EXT_TYPE_OEM_TYPE 0x01
typedef struct { typedef struct {
EFI_FIRMWARE_VOLUME_EXT_ENTRY Header; EFI_FIRMWARE_VOLUME_EXT_ENTRY Header;
UINT32 TypeMask; UINT32 TypeMask;
//EFI_GUID Types[1]; //EFI_GUID Types[1];
} EFI_FIRMWARE_VOLUME_EXT_HEADER_OEM_TYPE; } EFI_FIRMWARE_VOLUME_EXT_HEADER_OEM_TYPE;
#define EFI_FV_EXT_TYPE_GUID_TYPE 0x02 #define EFI_FV_EXT_TYPE_GUID_TYPE 0x02
typedef struct { typedef struct {
EFI_FIRMWARE_VOLUME_EXT_ENTRY Header; EFI_FIRMWARE_VOLUME_EXT_ENTRY Header;
EFI_GUID FormatType; EFI_GUID FormatType;
//UINT8 Data[]; //UINT8 Data[];
} EFI_FIRMWARE_VOLUME_EXT_ENTRY_GUID_TYPE; } EFI_FIRMWARE_VOLUME_EXT_ENTRY_GUID_TYPE;

View File

@ -94,9 +94,9 @@ UINT8 FfsEngine::parseInputFile(const QByteArray & buffer)
QByteArray body = buffer.right(buffer.size() - capsuleHeaderSize); QByteArray body = buffer.right(buffer.size() - capsuleHeaderSize);
QString name = tr("UEFI capsule"); QString name = tr("UEFI capsule");
QString info = tr("Header size: %1\nFlags: %2\nImage size: %3") QString info = tr("Header size: %1\nFlags: %2\nImage size: %3")
.arg(capsuleHeader->HeaderSize, 8, 16, QChar('0')) .arg(capsuleHeader->HeaderSize, 8, 16, QChar('0'))
.arg(capsuleHeader->Flags, 8, 16, QChar('0')) .arg(capsuleHeader->Flags, 8, 16, QChar('0'))
.arg(capsuleHeader->CapsuleImageSize, 8, 16, QChar('0')); .arg(capsuleHeader->CapsuleImageSize, 8, 16, QChar('0'));
// Add tree item // Add tree item
index = model->addItem(Capsule, UefiCapsule, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body); index = model->addItem(Capsule, UefiCapsule, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body);
} }
@ -110,9 +110,9 @@ UINT8 FfsEngine::parseInputFile(const QByteArray & buffer)
QByteArray body = buffer.right(buffer.size() - capsuleHeaderSize); QByteArray body = buffer.right(buffer.size() - capsuleHeaderSize);
QString name = tr("AMI Aptio capsule"); QString name = tr("AMI Aptio capsule");
QString info = tr("Header size: %1\nFlags: %2\nImage size: %3") QString info = tr("Header size: %1\nFlags: %2\nImage size: %3")
.arg(aptioCapsuleHeader->RomImageOffset, 4, 16, QChar('0')) .arg(aptioCapsuleHeader->RomImageOffset, 4, 16, QChar('0'))
.arg(aptioCapsuleHeader->CapsuleHeader.Flags, 8, 16, QChar('0')) .arg(aptioCapsuleHeader->CapsuleHeader.Flags, 8, 16, QChar('0'))
.arg(aptioCapsuleHeader->CapsuleHeader.CapsuleImageSize - aptioCapsuleHeader->RomImageOffset, 8, 16, QChar('0')); .arg(aptioCapsuleHeader->CapsuleHeader.CapsuleImageSize - aptioCapsuleHeader->RomImageOffset, 8, 16, QChar('0'));
//!TODO: more info about Aptio capsule //!TODO: more info about Aptio capsule
// Add tree item // Add tree item
index = model->addItem(Capsule, AptioCapsule, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body); index = model->addItem(Capsule, AptioCapsule, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body);
@ -137,7 +137,7 @@ UINT8 FfsEngine::parseInputFile(const QByteArray & buffer)
// Get info // Get info
QString name = tr("BIOS image"); QString name = tr("BIOS image");
QString info = tr("Size: %1") QString info = tr("Size: %1")
.arg(flashImage.size(), 8, 16, QChar('0')); .arg(flashImage.size(), 8, 16, QChar('0'));
// Add tree item // Add tree item
index = model->addItem(Image, BiosImage, COMPRESSION_ALGORITHM_NONE, name, "", info, QByteArray(), flashImage, QByteArray(), index); index = model->addItem(Image, BiosImage, COMPRESSION_ALGORITHM_NONE, name, "", info, QByteArray(), flashImage, QByteArray(), index);
@ -261,13 +261,13 @@ UINT8 FfsEngine::parseIntelImage(const QByteArray & intelImage, QModelIndex & in
// Intel image // Intel image
name = tr("Intel image"); name = tr("Intel image");
info = tr("Size: %1\nFlash chips: %2\nRegions: %3\nMasters: %4\nPCH straps: %5\nPROC straps: %6\nICC table entries: %7") info = tr("Size: %1\nFlash chips: %2\nRegions: %3\nMasters: %4\nPCH straps: %5\nPROC straps: %6\nICC table entries: %7")
.arg(intelImage.size(), 8, 16, QChar('0')) .arg(intelImage.size(), 8, 16, QChar('0'))
.arg(descriptorMap->NumberOfFlashChips + 1) // .arg(descriptorMap->NumberOfFlashChips + 1) //
.arg(descriptorMap->NumberOfRegions + 1) // Zero-based numbers in storage .arg(descriptorMap->NumberOfRegions + 1) // Zero-based numbers in storage
.arg(descriptorMap->NumberOfMasters + 1) // .arg(descriptorMap->NumberOfMasters + 1) //
.arg(descriptorMap->NumberOfPchStraps) .arg(descriptorMap->NumberOfPchStraps)
.arg(descriptorMap->NumberOfProcStraps) .arg(descriptorMap->NumberOfProcStraps)
.arg(descriptorMap->NumberOfIccTableEntries); .arg(descriptorMap->NumberOfIccTableEntries);
// Add Intel image tree item // Add Intel image tree item
index = model->addItem(Image, IntelImage, COMPRESSION_ALGORITHM_NONE, name, "", info, QByteArray(), intelImage, QByteArray(), parent); index = model->addItem(Image, IntelImage, COMPRESSION_ALGORITHM_NONE, name, "", info, QByteArray(), intelImage, QByteArray(), parent);
@ -343,15 +343,15 @@ UINT8 FfsEngine::parseGbeRegion(const QByteArray & gbe, QModelIndex & index, con
GBE_MAC* mac = (GBE_MAC*) gbe.constData(); GBE_MAC* mac = (GBE_MAC*) gbe.constData();
GBE_VERSION* version = (GBE_VERSION*) (gbe.constData() + GBE_VERSION_OFFSET); GBE_VERSION* version = (GBE_VERSION*) (gbe.constData() + GBE_VERSION_OFFSET);
QString info = tr("Size: %1\nMAC: %2:%3:%4:%5:%6:%7\nVersion: %8.%9") QString info = tr("Size: %1\nMAC: %2:%3:%4:%5:%6:%7\nVersion: %8.%9")
.arg(gbe.size(), 8, 16, QChar('0')) .arg(gbe.size(), 8, 16, QChar('0'))
.arg(mac->vendor[0], 2, 16, QChar('0')) .arg(mac->vendor[0], 2, 16, QChar('0'))
.arg(mac->vendor[1], 2, 16, QChar('0')) .arg(mac->vendor[1], 2, 16, QChar('0'))
.arg(mac->vendor[2], 2, 16, QChar('0')) .arg(mac->vendor[2], 2, 16, QChar('0'))
.arg(mac->device[0], 2, 16, QChar('0')) .arg(mac->device[0], 2, 16, QChar('0'))
.arg(mac->device[1], 2, 16, QChar('0')) .arg(mac->device[1], 2, 16, QChar('0'))
.arg(mac->device[2], 2, 16, QChar('0')) .arg(mac->device[2], 2, 16, QChar('0'))
.arg(version->major) .arg(version->major)
.arg(version->minor); .arg(version->minor);
// Add tree item // Add tree item
index = model->addItem( Region, GbeRegion, COMPRESSION_ALGORITHM_NONE, name, "", info, QByteArray(), gbe, QByteArray(), parent); index = model->addItem( Region, GbeRegion, COMPRESSION_ALGORITHM_NONE, name, "", info, QByteArray(), gbe, QByteArray(), parent);
@ -367,7 +367,7 @@ UINT8 FfsEngine::parseMeRegion(const QByteArray & me, QModelIndex & index, const
// Get info // Get info
QString name = tr("ME region"); QString name = tr("ME region");
QString info = tr("Size: %1"). QString info = tr("Size: %1").
arg(me.size(), 8, 16, QChar('0')); arg(me.size(), 8, 16, QChar('0'));
ME_VERSION* version; ME_VERSION* version;
INT32 versionOffset = me.indexOf(ME_VERSION_SIGNATURE); INT32 versionOffset = me.indexOf(ME_VERSION_SIGNATURE);
@ -378,10 +378,10 @@ UINT8 FfsEngine::parseMeRegion(const QByteArray & me, QModelIndex & index, const
else { else {
version = (ME_VERSION*) (me.constData() + versionOffset); version = (ME_VERSION*) (me.constData() + versionOffset);
info += tr("\nVersion: %1.%2.%3.%4") info += tr("\nVersion: %1.%2.%3.%4")
.arg(version->major) .arg(version->major)
.arg(version->minor) .arg(version->minor)
.arg(version->bugfix) .arg(version->bugfix)
.arg(version->build); .arg(version->build);
} }
// Add tree item // Add tree item
@ -398,7 +398,7 @@ UINT8 FfsEngine::parsePdrRegion(const QByteArray & pdr, QModelIndex & index, con
// Get info // Get info
QString name = tr("PDR region"); QString name = tr("PDR region");
QString info = tr("Size: %1"). QString info = tr("Size: %1").
arg(pdr.size(), 8, 16, QChar('0')); arg(pdr.size(), 8, 16, QChar('0'));
// Add tree item // Add tree item
index = model->addItem( Region, PdrRegion, COMPRESSION_ALGORITHM_NONE, name, "", info, QByteArray(), pdr, QByteArray(), parent); index = model->addItem( Region, PdrRegion, COMPRESSION_ALGORITHM_NONE, name, "", info, QByteArray(), pdr, QByteArray(), parent);
@ -414,7 +414,7 @@ UINT8 FfsEngine::parseBiosRegion(const QByteArray & bios, QModelIndex & index, c
// Get info // Get info
QString name = tr("BIOS region"); QString name = tr("BIOS region");
QString info = tr("Size: %1"). QString info = tr("Size: %1").
arg(bios.size(), 8, 16, QChar('0')); arg(bios.size(), 8, 16, QChar('0'));
// Add tree item // Add tree item
index = model->addItem( Region, BiosRegion, COMPRESSION_ALGORITHM_NONE, name, "", info, QByteArray(), bios, QByteArray(), parent); index = model->addItem( Region, BiosRegion, COMPRESSION_ALGORITHM_NONE, name, "", info, QByteArray(), bios, QByteArray(), parent);
@ -440,7 +440,7 @@ UINT8 FfsEngine::parseBios(const QByteArray & bios, const QModelIndex & parent)
QByteArray padding = bios.left(prevVolumeOffset); QByteArray padding = bios.left(prevVolumeOffset);
name = tr("Padding"); name = tr("Padding");
info = tr("Size: %1") info = tr("Size: %1")
.arg(padding.size(), 8, 16, QChar('0')); .arg(padding.size(), 8, 16, QChar('0'));
// Add tree item // Add tree item
model->addItem( Padding, 0, COMPRESSION_ALGORITHM_NONE, name, "", info, QByteArray(), padding, QByteArray(), parent); model->addItem( Padding, 0, COMPRESSION_ALGORITHM_NONE, name, "", info, QByteArray(), padding, QByteArray(), parent);
} }
@ -459,7 +459,7 @@ UINT8 FfsEngine::parseBios(const QByteArray & bios, const QModelIndex & parent)
// Get info // Get info
name = tr("Padding"); name = tr("Padding");
info = tr("Size: %1") info = tr("Size: %1")
.arg(padding.size(), 8, 16, QChar('0')); .arg(padding.size(), 8, 16, QChar('0'));
// Add tree item // Add tree item
model->addItem( Padding, 0, COMPRESSION_ALGORITHM_NONE, name, "", info, QByteArray(), padding, QByteArray(), parent); model->addItem( Padding, 0, COMPRESSION_ALGORITHM_NONE, name, "", info, QByteArray(), padding, QByteArray(), parent);
} }
@ -500,10 +500,10 @@ UINT8 FfsEngine::parseBios(const QByteArray & bios, const QModelIndex & parent)
// Check alignment setup // Check alignment setup
if (!alignmentCap && if (!alignmentCap &&
( alignment2 || alignment4 || alignment8 || alignment16 ( alignment2 || alignment4 || alignment8 || alignment16
|| alignment32 || alignment64 || alignment128 || alignment256 || alignment32 || alignment64 || alignment128 || alignment256
|| alignment512 || alignment1k || alignment2k || alignment4k || alignment512 || alignment1k || alignment2k || alignment4k
|| alignment8k || alignment16k || alignment32k || alignment64k)) || alignment8k || alignment16k || alignment32k || alignment64k))
msg("parseBios: Incompatible revision 1 volume alignment setup", parent); msg("parseBios: Incompatible revision 1 volume alignment setup", parent);
// Assume that smaller alignment value consumes greater // Assume that smaller alignment value consumes greater
@ -578,7 +578,7 @@ UINT8 FfsEngine::parseBios(const QByteArray & bios, const QModelIndex & parent)
// Get info // Get info
name = tr("Padding"); name = tr("Padding");
info = tr("Size: %2") info = tr("Size: %2")
.arg(padding.size(), 8, 16, QChar('0')); .arg(padding.size(), 8, 16, QChar('0'));
// Add tree item // Add tree item
model->addItem( Padding, 0, COMPRESSION_ALGORITHM_NONE, name, "", info, QByteArray(), padding, QByteArray(), parent); model->addItem( Padding, 0, COMPRESSION_ALGORITHM_NONE, name, "", info, QByteArray(), padding, QByteArray(), parent);
} }
@ -687,10 +687,10 @@ UINT8 FfsEngine::parseVolume(const QByteArray & volume, QModelIndex & index, co
// Get info // Get info
QString name = guidToQString(volumeHeader->FileSystemGuid); QString name = guidToQString(volumeHeader->FileSystemGuid);
QString info = tr("Size: %1\nRevision: %2\nAttributes: %3\nHeader size: %4") QString info = tr("Size: %1\nRevision: %2\nAttributes: %3\nHeader size: %4")
.arg(volumeSize, 8, 16, QChar('0')) .arg(volumeSize, 8, 16, QChar('0'))
.arg(volumeHeader->Revision) .arg(volumeHeader->Revision)
.arg(volumeHeader->Attributes, 8, 16, QChar('0')) .arg(volumeHeader->Attributes, 8, 16, QChar('0'))
.arg(volumeHeader->HeaderLength, 4, 16, QChar('0')); .arg(volumeHeader->HeaderLength, 4, 16, QChar('0'));
// Add tree item // Add tree item
QByteArray header = volume.left(headerSize); QByteArray header = volume.left(headerSize);
@ -831,9 +831,9 @@ UINT8 FfsEngine::parseFile(const QByteArray & file, QModelIndex & index, const U
UINT16 tailValue = *(UINT16*) tail.constData(); UINT16 tailValue = *(UINT16*) tail.constData();
if (fileHeader->IntegrityCheck.TailReference != (UINT16)~tailValue) if (fileHeader->IntegrityCheck.TailReference != (UINT16)~tailValue)
msg(tr("parseFile: %1, bitwise not of tail value %2 differs from %3 stored in file header") msg(tr("parseFile: %1, bitwise not of tail value %2 differs from %3 stored in file header")
.arg(guidToQString(fileHeader->Name)) .arg(guidToQString(fileHeader->Name))
.arg(~tailValue, 4, 16, QChar('0')) .arg(~tailValue, 4, 16, QChar('0'))
.arg(fileHeader->IntegrityCheck.TailReference, 4, 16, QChar('0')), parent); .arg(fileHeader->IntegrityCheck.TailReference, 4, 16, QChar('0')), parent);
// Remove tail from file body // Remove tail from file body
body = body.left(body.size() - sizeof(UINT16)); body = body.left(body.size() - sizeof(UINT16));
@ -903,10 +903,10 @@ UINT8 FfsEngine::parseFile(const QByteArray & file, QModelIndex & index, const U
else else
name = tr("Padding"); name = tr("Padding");
info = tr("Type: %1\nAttributes: %2\nSize: %3\nState: %4") info = tr("Type: %1\nAttributes: %2\nSize: %3\nState: %4")
.arg(fileHeader->Type, 2, 16, QChar('0')) .arg(fileHeader->Type, 2, 16, QChar('0'))
.arg(fileHeader->Attributes, 2, 16, QChar('0')) .arg(fileHeader->Attributes, 2, 16, QChar('0'))
.arg(uint24ToUint32(fileHeader->Size), 6, 16, QChar('0')) .arg(uint24ToUint32(fileHeader->Size), 6, 16, QChar('0'))
.arg(fileHeader->State, 2, 16, QChar('0')); .arg(fileHeader->State, 2, 16, QChar('0'));
// Add tree item // Add tree item
index = model->addItem( File, fileHeader->Type, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body, tail, parent, mode); index = model->addItem( File, fileHeader->Type, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body, tail, parent, mode);
@ -984,106 +984,106 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
switch (sectionHeader->Type) { switch (sectionHeader->Type) {
// Encapsulated sections // Encapsulated sections
case EFI_SECTION_COMPRESSION: case EFI_SECTION_COMPRESSION:
{ {
bool parseCurrentSection = true; bool parseCurrentSection = true;
QByteArray decompressed; QByteArray decompressed;
UINT8 algorithm; UINT8 algorithm;
EFI_COMPRESSION_SECTION* compressedSectionHeader = (EFI_COMPRESSION_SECTION*) sectionHeader; EFI_COMPRESSION_SECTION* compressedSectionHeader = (EFI_COMPRESSION_SECTION*) sectionHeader;
header = section.left(sizeof(EFI_COMPRESSION_SECTION)); header = section.left(sizeof(EFI_COMPRESSION_SECTION));
body = section.mid(sizeof(EFI_COMPRESSION_SECTION), sectionSize - sizeof(EFI_COMPRESSION_SECTION)); body = section.mid(sizeof(EFI_COMPRESSION_SECTION), sectionSize - sizeof(EFI_COMPRESSION_SECTION));
algorithm = COMPRESSION_ALGORITHM_UNKNOWN; algorithm = COMPRESSION_ALGORITHM_UNKNOWN;
// Decompress section // Decompress section
result = decompress(body, compressedSectionHeader->CompressionType, decompressed, &algorithm); result = decompress(body, compressedSectionHeader->CompressionType, decompressed, &algorithm);
if (result) { if (result) {
msg(tr("parseSection: Section decompression failed (%1)").arg(result), parent); msg(tr("parseSection: Section decompression failed (%1)").arg(result), parent);
parseCurrentSection = false; parseCurrentSection = false;
} }
// Get info // Get info
info = tr("Type: %1\nSize: %2\nCompression type: %3\nDecompressed size: %4") info = tr("Type: %1\nSize: %2\nCompression type: %3\nDecompressed size: %4")
.arg(sectionHeader->Type, 2, 16, QChar('0')) .arg(sectionHeader->Type, 2, 16, QChar('0'))
.arg(body.size(), 8, 16, QChar('0')) .arg(body.size(), 8, 16, QChar('0'))
.arg(compressionTypeToQString(algorithm)) .arg(compressionTypeToQString(algorithm))
.arg(compressedSectionHeader->UncompressedLength, 8, 16, QChar('0')); .arg(compressedSectionHeader->UncompressedLength, 8, 16, QChar('0'));
// Add tree item // Add tree item
index = model->addItem( Section, sectionHeader->Type, algorithm, name, "", info, header, body, QByteArray(), parent, mode); index = model->addItem( Section, sectionHeader->Type, algorithm, name, "", info, header, body, QByteArray(), parent, mode);
// Parse decompressed data // Parse decompressed data
if (parseCurrentSection) { if (parseCurrentSection) {
result = parseSections(decompressed, index); result = parseSections(decompressed, index);
if (result) if (result)
return result; return result;
}
} }
}
break; break;
case EFI_SECTION_GUID_DEFINED: case EFI_SECTION_GUID_DEFINED:
{ {
bool parseCurrentSection = true; bool parseCurrentSection = true;
EFI_GUID_DEFINED_SECTION* guidDefinedSectionHeader; EFI_GUID_DEFINED_SECTION* guidDefinedSectionHeader;
header = section.left(sizeof(EFI_GUID_DEFINED_SECTION)); header = section.left(sizeof(EFI_GUID_DEFINED_SECTION));
guidDefinedSectionHeader = (EFI_GUID_DEFINED_SECTION*) (header.constData()); guidDefinedSectionHeader = (EFI_GUID_DEFINED_SECTION*) (header.constData());
header = section.left(guidDefinedSectionHeader->DataOffset); header = section.left(guidDefinedSectionHeader->DataOffset);
guidDefinedSectionHeader = (EFI_GUID_DEFINED_SECTION*) (header.constData()); guidDefinedSectionHeader = (EFI_GUID_DEFINED_SECTION*) (header.constData());
body = section.mid(guidDefinedSectionHeader->DataOffset, sectionSize - guidDefinedSectionHeader->DataOffset); body = section.mid(guidDefinedSectionHeader->DataOffset, sectionSize - guidDefinedSectionHeader->DataOffset);
QByteArray decompressed = body; QByteArray decompressed = body;
UINT8 algorithm = COMPRESSION_ALGORITHM_NONE; UINT8 algorithm = COMPRESSION_ALGORITHM_NONE;
// Check if section requires processing // Check if section requires processing
if (guidDefinedSectionHeader->Attributes & EFI_GUIDED_SECTION_PROCESSING_REQUIRED) { if (guidDefinedSectionHeader->Attributes & EFI_GUIDED_SECTION_PROCESSING_REQUIRED) {
// Try to decompress section body using both known compression algorithms // Try to decompress section body using both known compression algorithms
algorithm = COMPRESSION_ALGORITHM_UNKNOWN; algorithm = COMPRESSION_ALGORITHM_UNKNOWN;
// Tiano // Tiano
result = decompress(body, EFI_STANDARD_COMPRESSION, decompressed, &algorithm); result = decompress(body, EFI_STANDARD_COMPRESSION, decompressed, &algorithm);
if (result) {
result = decompress(body, EFI_CUSTOMIZED_COMPRESSION, decompressed, &algorithm);
if (result) { if (result) {
result = decompress(body, EFI_CUSTOMIZED_COMPRESSION, decompressed, &algorithm); msg(tr("parseSection: GUID defined section can not be decompressed (%1)").arg(result), parent);
if (result) { parseCurrentSection = false;
msg(tr("parseSection: GUID defined section can not be decompressed (%1)").arg(result), parent);
parseCurrentSection = false;
}
} }
} }
}
// Get info // Get info
name = guidToQString(guidDefinedSectionHeader->SectionDefinitionGuid); name = guidToQString(guidDefinedSectionHeader->SectionDefinitionGuid);
info = tr("Type: %1\nSize: %2\nData offset: %3\nAttributes: %4\nCompression type: %5") info = tr("Type: %1\nSize: %2\nData offset: %3\nAttributes: %4\nCompression type: %5")
.arg(sectionHeader->Type, 2, 16, QChar('0')) .arg(sectionHeader->Type, 2, 16, QChar('0'))
.arg(body.size(), 8, 16, QChar('0')) .arg(body.size(), 8, 16, QChar('0'))
.arg(guidDefinedSectionHeader->DataOffset, 4, 16, QChar('0')) .arg(guidDefinedSectionHeader->DataOffset, 4, 16, QChar('0'))
.arg(guidDefinedSectionHeader->Attributes, 4, 16, QChar('0')) .arg(guidDefinedSectionHeader->Attributes, 4, 16, QChar('0'))
.arg(compressionTypeToQString(algorithm)); .arg(compressionTypeToQString(algorithm));
// Add tree item // Add tree item
index = model->addItem( Section, sectionHeader->Type, algorithm, name, "", info, header, body, QByteArray(), parent, mode); index = model->addItem( Section, sectionHeader->Type, algorithm, name, "", info, header, body, QByteArray(), parent, mode);
// Parse decompressed data // Parse decompressed data
if (parseCurrentSection) { if (parseCurrentSection) {
result = parseSections(decompressed, index); result = parseSections(decompressed, index);
if (result)
return result;
}
}
break;
case EFI_SECTION_DISPOSABLE:
{
header = section.left(sizeof(EFI_DISPOSABLE_SECTION));
body = section.mid(sizeof(EFI_DISPOSABLE_SECTION), sectionSize - sizeof(EFI_DISPOSABLE_SECTION));
// Get info
info = tr("parseSection: %1\nSize: %2")
.arg(sectionHeader->Type, 2, 16, QChar('0'))
.arg(body.size(), 8, 16, QChar('0'));
// Add tree item
index = model->addItem( Section, sectionHeader->Type, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body, QByteArray(), parent, mode);
// Parse section body
result = parseSections(body, index);
if (result) if (result)
return result; return result;
} }
}
break;
case EFI_SECTION_DISPOSABLE:
{
header = section.left(sizeof(EFI_DISPOSABLE_SECTION));
body = section.mid(sizeof(EFI_DISPOSABLE_SECTION), sectionSize - sizeof(EFI_DISPOSABLE_SECTION));
// Get info
info = tr("parseSection: %1\nSize: %2")
.arg(sectionHeader->Type, 2, 16, QChar('0'))
.arg(body.size(), 8, 16, QChar('0'));
// Add tree item
index = model->addItem( Section, sectionHeader->Type, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body, QByteArray(), parent, mode);
// Parse section body
result = parseSections(body, index);
if (result)
return result;
}
break; break;
// Leaf sections // Leaf sections
case EFI_SECTION_PE32: case EFI_SECTION_PE32:
case EFI_SECTION_TE: case EFI_SECTION_TE:
case EFI_SECTION_PIC: case EFI_SECTION_PIC:
@ -1099,36 +1099,36 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
// Get info // Get info
info = tr("Type: %1\nSize: %2") info = tr("Type: %1\nSize: %2")
.arg(sectionHeader->Type, 2, 16, QChar('0')) .arg(sectionHeader->Type, 2, 16, QChar('0'))
.arg(body.size(), 8, 16, QChar('0')); .arg(body.size(), 8, 16, QChar('0'));
// Add tree item // Add tree item
index = model->addItem( Section, sectionHeader->Type, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body, QByteArray(), parent, mode); index = model->addItem( Section, sectionHeader->Type, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body, QByteArray(), parent, mode);
// Special case of PEI Core // Special case of PEI Core
if ((sectionHeader->Type == EFI_SECTION_PE32 || sectionHeader->Type == EFI_SECTION_TE) && model->subtype(parent) == EFI_FV_FILETYPE_PEI_CORE) { if ((sectionHeader->Type == EFI_SECTION_PE32 || sectionHeader->Type == EFI_SECTION_TE) && model->subtype(parent) == EFI_FV_FILETYPE_PEI_CORE) {
result = getEntryPoint(model->body(index) , oldPeiCoreEntryPoint); result = getEntryPoint(model->body(index) , oldPeiCoreEntryPoint);
if (result) if (result)
msg(tr("parseSection: can't get entry point of image file"), index); msg(tr("parseSection: can't get entry point of image file"), index);
} }
break; break;
case EFI_SECTION_USER_INTERFACE: case EFI_SECTION_USER_INTERFACE:
{ {
header = section.left(sizeof(EFI_USER_INTERFACE_SECTION)); header = section.left(sizeof(EFI_USER_INTERFACE_SECTION));
body = section.mid(sizeof(EFI_USER_INTERFACE_SECTION), sectionSize - sizeof(EFI_USER_INTERFACE_SECTION)); body = section.mid(sizeof(EFI_USER_INTERFACE_SECTION), sectionSize - sizeof(EFI_USER_INTERFACE_SECTION));
// Get info // Get info
info = tr("Type: %1\nSize: %2") info = tr("Type: %1\nSize: %2")
.arg(sectionHeader->Type, 2, 16, QChar('0')) .arg(sectionHeader->Type, 2, 16, QChar('0'))
.arg(body.size(), 8, 16, QChar('0')); .arg(body.size(), 8, 16, QChar('0'));
// Add tree item // Add tree item
index = model->addItem( Section, sectionHeader->Type, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body, QByteArray(), parent, mode); index = model->addItem( Section, sectionHeader->Type, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body, QByteArray(), parent, mode);
// Rename parent file // Rename parent file
QString text = QString::fromUtf16((const ushort*)body.constData()); QString text = QString::fromUtf16((const ushort*)body.constData());
model->setTextString(model->findParentOfType(parent, File), text); model->setTextString(model->findParentOfType(parent, File), text);
} }
break; break;
case EFI_SECTION_FIRMWARE_VOLUME_IMAGE: case EFI_SECTION_FIRMWARE_VOLUME_IMAGE:
header = section.left(sizeof(EFI_FIRMWARE_VOLUME_IMAGE_SECTION)); header = section.left(sizeof(EFI_FIRMWARE_VOLUME_IMAGE_SECTION));
@ -1136,8 +1136,8 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
// Get info // Get info
info = tr("Type: %1\nSize: %2") info = tr("Type: %1\nSize: %2")
.arg(sectionHeader->Type, 2, 16, QChar('0')) .arg(sectionHeader->Type, 2, 16, QChar('0'))
.arg(body.size(), 8, 16, QChar('0')); .arg(body.size(), 8, 16, QChar('0'));
// Add tree item // Add tree item
index = model->addItem( Section, sectionHeader->Type, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body, QByteArray(), parent, mode); index = model->addItem( Section, sectionHeader->Type, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body, QByteArray(), parent, mode);
@ -1155,8 +1155,8 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
// Get info // Get info
info = tr("Type: %1\nSize: %2") info = tr("Type: %1\nSize: %2")
.arg(sectionHeader->Type, 2, 16, QChar('0')) .arg(sectionHeader->Type, 2, 16, QChar('0'))
.arg(body.size(), 8, 16, QChar('0')); .arg(body.size(), 8, 16, QChar('0'));
// Add tree item // Add tree item
index = model->addItem( Section, sectionHeader->Type, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body, QByteArray(), parent, mode); index = model->addItem( Section, sectionHeader->Type, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body, QByteArray(), parent, mode);
@ -1173,8 +1173,8 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
body = section.mid(sizeof(EFI_COMMON_SECTION_HEADER), sectionSize - sizeof(EFI_COMMON_SECTION_HEADER)); body = section.mid(sizeof(EFI_COMMON_SECTION_HEADER), sectionSize - sizeof(EFI_COMMON_SECTION_HEADER));
// Get info // Get info
info = tr("Type: %1\nSize: %2") info = tr("Type: %1\nSize: %2")
.arg(sectionHeader->Type, 2, 16, QChar('0')) .arg(sectionHeader->Type, 2, 16, QChar('0'))
.arg(body.size(), 8, 16, QChar('0')); .arg(body.size(), 8, 16, QChar('0'));
// Add tree item // Add tree item
index = model->addItem( Section, sectionHeader->Type, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body, QByteArray(), parent, mode); index = model->addItem( Section, sectionHeader->Type, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body, QByteArray(), parent, mode);
@ -1284,98 +1284,98 @@ UINT8 FfsEngine::create(const QModelIndex & index, const UINT8 type, const QByte
switch (commonHeader->Type) switch (commonHeader->Type)
{ {
case EFI_SECTION_COMPRESSION: { case EFI_SECTION_COMPRESSION: {
EFI_COMPRESSION_SECTION* sectionHeader = (EFI_COMPRESSION_SECTION*) newHeader.data(); EFI_COMPRESSION_SECTION* sectionHeader = (EFI_COMPRESSION_SECTION*) newHeader.data();
// Correct uncompressed size // Correct uncompressed size
sectionHeader->UncompressedLength = body.size(); sectionHeader->UncompressedLength = body.size();
// Set compression type // Set compression type
if (algorithm == COMPRESSION_ALGORITHM_NONE) if (algorithm == COMPRESSION_ALGORITHM_NONE)
sectionHeader->CompressionType = EFI_NOT_COMPRESSED; sectionHeader->CompressionType = EFI_NOT_COMPRESSED;
else if (algorithm == COMPRESSION_ALGORITHM_EFI11 || algorithm == COMPRESSION_ALGORITHM_TIANO) else if (algorithm == COMPRESSION_ALGORITHM_EFI11 || algorithm == COMPRESSION_ALGORITHM_TIANO)
sectionHeader->CompressionType = EFI_STANDARD_COMPRESSION; sectionHeader->CompressionType = EFI_STANDARD_COMPRESSION;
else if (algorithm == COMPRESSION_ALGORITHM_LZMA || algorithm == COMPRESSION_ALGORITHM_IMLZMA) else if (algorithm == COMPRESSION_ALGORITHM_LZMA || algorithm == COMPRESSION_ALGORITHM_IMLZMA)
sectionHeader->CompressionType = EFI_CUSTOMIZED_COMPRESSION; sectionHeader->CompressionType = EFI_CUSTOMIZED_COMPRESSION;
else else
return ERR_UNKNOWN_COMPRESSION_ALGORITHM; return ERR_UNKNOWN_COMPRESSION_ALGORITHM;
// Compress body // Compress body
QByteArray compressed; QByteArray compressed;
result = compress(body, algorithm, compressed); result = compress(body, algorithm, compressed);
if (result) if (result)
return result; return result;
// Correct section size // Correct section size
uint32ToUint24(header.size() + compressed.size(), commonHeader->Size); uint32ToUint24(header.size() + compressed.size(), commonHeader->Size);
// Append header and body // Append header and body
created.append(newHeader).append(compressed); created.append(newHeader).append(compressed);
// Parse section // Parse section
QModelIndex sectionIndex; QModelIndex sectionIndex;
result = parseSection(created, sectionIndex, index, mode); result = parseSection(created, sectionIndex, index, mode);
if (result) if (result)
return result; return result;
// Set create action // Set create action
model->setAction(sectionIndex, action); model->setAction(sectionIndex, action);
// If inside boot volume, rebase all PE32 and TE sections, that follow // If inside boot volume, rebase all PE32 and TE sections, that follow
QModelIndex fileIndex = model->findParentOfType(parent, File); QModelIndex fileIndex = model->findParentOfType(parent, File);
if (model->subtype(fileIndex.parent()) == BootVolume) { if (model->subtype(fileIndex.parent()) == BootVolume) {
for(int i = fileIndex.row(); i < model->rowCount(fileIndex.parent()); i++) { for(int i = fileIndex.row(); i < model->rowCount(fileIndex.parent()); i++) {
// File inside boot volume // File inside boot volume
QModelIndex currentFileIndex = fileIndex.parent().child(i, index.column()); QModelIndex currentFileIndex = fileIndex.parent().child(i, index.column());
for(int j = 0; j < model->rowCount(currentFileIndex); j++) { for(int j = 0; j < model->rowCount(currentFileIndex); j++) {
// Section in that file // Section in that file
QModelIndex currentSectionIndex = currentFileIndex.child(j, currentFileIndex.column()); QModelIndex currentSectionIndex = currentFileIndex.child(j, currentFileIndex.column());
// If section stores PE32 or TE image // If section stores PE32 or TE image
if (model->subtype(currentSectionIndex) == EFI_SECTION_PE32 || model->subtype(currentSectionIndex) == EFI_SECTION_TE) if (model->subtype(currentSectionIndex) == EFI_SECTION_PE32 || model->subtype(currentSectionIndex) == EFI_SECTION_TE)
// Set rebase action // Set rebase action
model->setAction(currentSectionIndex, Rebase); model->setAction(currentSectionIndex, Rebase);
}
} }
} }
} }
}
break; break;
case EFI_SECTION_GUID_DEFINED:{ case EFI_SECTION_GUID_DEFINED:{
// Compress body // Compress body
QByteArray compressed; QByteArray compressed;
result = compress(body, algorithm, compressed); result = compress(body, algorithm, compressed);
if (result) if (result)
return result; return result;
// Correct section size // Correct section size
uint32ToUint24(header.size() + compressed.size(), commonHeader->Size); uint32ToUint24(header.size() + compressed.size(), commonHeader->Size);
// Append header and body // Append header and body
created.append(newHeader).append(compressed); created.append(newHeader).append(compressed);
// Parse section // Parse section
QModelIndex sectionIndex; QModelIndex sectionIndex;
result = parseSection(created, sectionIndex, index, mode); result = parseSection(created, sectionIndex, index, mode);
if (result) if (result)
return result; return result;
// Set create action // Set create action
model->setAction(sectionIndex, action); model->setAction(sectionIndex, action);
// If inside boot volume, rebase all PE32 and TE sections, that follow // If inside boot volume, rebase all PE32 and TE sections, that follow
QModelIndex fileIndex = model->findParentOfType(parent, File); QModelIndex fileIndex = model->findParentOfType(parent, File);
if (model->subtype(fileIndex.parent()) == BootVolume) { if (model->subtype(fileIndex.parent()) == BootVolume) {
for(int i = fileIndex.row(); i < model->rowCount(fileIndex.parent()); i++) { for(int i = fileIndex.row(); i < model->rowCount(fileIndex.parent()); i++) {
// File inside boot volume // File inside boot volume
QModelIndex currentFileIndex = fileIndex.parent().child(i, index.column()); QModelIndex currentFileIndex = fileIndex.parent().child(i, index.column());
for(int j = 0; j < model->rowCount(currentFileIndex); j++) { for(int j = 0; j < model->rowCount(currentFileIndex); j++) {
// Section in that file // Section in that file
QModelIndex currentSectionIndex = currentFileIndex.child(j, currentFileIndex.column()); QModelIndex currentSectionIndex = currentFileIndex.child(j, currentFileIndex.column());
// If section stores PE32 or TE image // If section stores PE32 or TE image
if (model->subtype(currentSectionIndex) == EFI_SECTION_PE32 || model->subtype(currentSectionIndex) == EFI_SECTION_TE) if (model->subtype(currentSectionIndex) == EFI_SECTION_PE32 || model->subtype(currentSectionIndex) == EFI_SECTION_TE)
// Set rebase action // Set rebase action
model->setAction(currentSectionIndex, Rebase); model->setAction(currentSectionIndex, Rebase);
}
} }
} }
} }
}
break; break;
default: default:
// Correct section size // Correct section size
@ -1714,63 +1714,63 @@ UINT8 FfsEngine::compress(const QByteArray & data, const UINT8 algorithm, QByteA
switch (algorithm) { switch (algorithm) {
case COMPRESSION_ALGORITHM_NONE: case COMPRESSION_ALGORITHM_NONE:
{ {
compressedData = data; compressedData = data;
return ERR_SUCCESS; return ERR_SUCCESS;
} }
break; break;
case COMPRESSION_ALGORITHM_EFI11: case COMPRESSION_ALGORITHM_EFI11:
{ {
if (EfiCompress((UINT8*) data.constData(), data.size(), NULL, &compressedSize) != ERR_BUFFER_TOO_SMALL) if (EfiCompress((UINT8*) data.constData(), data.size(), NULL, &compressedSize) != ERR_BUFFER_TOO_SMALL)
return ERR_STANDARD_COMPRESSION_FAILED; return ERR_STANDARD_COMPRESSION_FAILED;
compressed = new UINT8[compressedSize]; compressed = new UINT8[compressedSize];
if (EfiCompress((UINT8*) data.constData(), data.size(), compressed, &compressedSize) != ERR_SUCCESS) if (EfiCompress((UINT8*) data.constData(), data.size(), compressed, &compressedSize) != ERR_SUCCESS)
return ERR_STANDARD_COMPRESSION_FAILED; return ERR_STANDARD_COMPRESSION_FAILED;
compressedData = QByteArray((const char*) compressed, compressedSize); compressedData = QByteArray((const char*) compressed, compressedSize);
delete[] compressed; delete[] compressed;
return ERR_SUCCESS; return ERR_SUCCESS;
} }
break; break;
case COMPRESSION_ALGORITHM_TIANO: case COMPRESSION_ALGORITHM_TIANO:
{ {
if (TianoCompress((UINT8*) data.constData(), data.size(), NULL, &compressedSize) != ERR_BUFFER_TOO_SMALL) if (TianoCompress((UINT8*) data.constData(), data.size(), NULL, &compressedSize) != ERR_BUFFER_TOO_SMALL)
return ERR_STANDARD_COMPRESSION_FAILED; return ERR_STANDARD_COMPRESSION_FAILED;
compressed = new UINT8[compressedSize]; compressed = new UINT8[compressedSize];
if (TianoCompress((UINT8*) data.constData(), data.size(), compressed, &compressedSize) != ERR_SUCCESS) if (TianoCompress((UINT8*) data.constData(), data.size(), compressed, &compressedSize) != ERR_SUCCESS)
return ERR_STANDARD_COMPRESSION_FAILED; return ERR_STANDARD_COMPRESSION_FAILED;
compressedData = QByteArray((const char*) compressed, compressedSize); compressedData = QByteArray((const char*) compressed, compressedSize);
delete[] compressed; delete[] compressed;
return ERR_SUCCESS; return ERR_SUCCESS;
} }
break; break;
case COMPRESSION_ALGORITHM_LZMA: case COMPRESSION_ALGORITHM_LZMA:
{ {
if (LzmaCompress((const UINT8*) data.constData(), data.size(), NULL, &compressedSize) != ERR_BUFFER_TOO_SMALL) if (LzmaCompress((const UINT8*) data.constData(), data.size(), NULL, &compressedSize) != ERR_BUFFER_TOO_SMALL)
return ERR_CUSTOMIZED_COMPRESSION_FAILED; return ERR_CUSTOMIZED_COMPRESSION_FAILED;
compressed = new UINT8[compressedSize]; compressed = new UINT8[compressedSize];
if (LzmaCompress((const UINT8*) data.constData(), data.size(), compressed, &compressedSize) != ERR_SUCCESS) if (LzmaCompress((const UINT8*) data.constData(), data.size(), compressed, &compressedSize) != ERR_SUCCESS)
return ERR_CUSTOMIZED_COMPRESSION_FAILED; return ERR_CUSTOMIZED_COMPRESSION_FAILED;
compressedData = QByteArray((const char*) compressed, compressedSize); compressedData = QByteArray((const char*) compressed, compressedSize);
delete[] compressed; delete[] compressed;
return ERR_SUCCESS; return ERR_SUCCESS;
} }
break; break;
case COMPRESSION_ALGORITHM_IMLZMA: case COMPRESSION_ALGORITHM_IMLZMA:
{ {
QByteArray header = data.left(sizeof(EFI_COMMON_SECTION_HEADER)); QByteArray header = data.left(sizeof(EFI_COMMON_SECTION_HEADER));
EFI_COMMON_SECTION_HEADER* sectionHeader = (EFI_COMMON_SECTION_HEADER*) header.constData(); EFI_COMMON_SECTION_HEADER* sectionHeader = (EFI_COMMON_SECTION_HEADER*) header.constData();
UINT32 headerSize = sizeOfSectionHeaderOfType(sectionHeader->Type); UINT32 headerSize = sizeOfSectionHeaderOfType(sectionHeader->Type);
header = data.left(headerSize); header = data.left(headerSize);
QByteArray newData = data.mid(headerSize); QByteArray newData = data.mid(headerSize);
if (LzmaCompress((UINT8*) newData.constData(), newData.size(), NULL, &compressedSize) != ERR_BUFFER_TOO_SMALL) if (LzmaCompress((UINT8*) newData.constData(), newData.size(), NULL, &compressedSize) != ERR_BUFFER_TOO_SMALL)
return ERR_CUSTOMIZED_COMPRESSION_FAILED; return ERR_CUSTOMIZED_COMPRESSION_FAILED;
compressed = new UINT8[compressedSize]; compressed = new UINT8[compressedSize];
if (LzmaCompress((UINT8*) newData.constData(), newData.size(), compressed, &compressedSize) != ERR_SUCCESS) if (LzmaCompress((UINT8*) newData.constData(), newData.size(), compressed, &compressedSize) != ERR_SUCCESS)
return ERR_CUSTOMIZED_COMPRESSION_FAILED; return ERR_CUSTOMIZED_COMPRESSION_FAILED;
compressedData = header.append(QByteArray((const char*) compressed, compressedSize)); compressedData = header.append(QByteArray((const char*) compressed, compressedSize));
delete[] compressed; delete[] compressed;
return ERR_SUCCESS; return ERR_SUCCESS;
} }
break; break;
default: default:
msg(tr("compress: Unknown compression algorithm (%1)").arg(algorithm)); msg(tr("compress: Unknown compression algorithm (%1)").arg(algorithm));
@ -1946,13 +1946,13 @@ UINT8 FfsEngine::reconstructRegion(const QModelIndex& index, QByteArray& reconst
// Check size of reconstructed region, it must be same // Check size of reconstructed region, it must be same
if (reconstructed.size() > model->body(index).size()) { if (reconstructed.size() > model->body(index).size()) {
msg(tr("reconstructRegion: reconstructed body %1 is bigger then original %2") msg(tr("reconstructRegion: reconstructed region (%1) is bigger then original (%2)")
.arg(reconstructed.size(), 8, 16, QChar('0')) .arg(reconstructed.size(), 8, 16, QChar('0'))
.arg(model->body(index).size(), 8, 16, QChar('0')), index); .arg(model->body(index).size(), 8, 16, QChar('0')), index);
return ERR_INVALID_PARAMETER; return ERR_INVALID_PARAMETER;
} }
else if (reconstructed.size() < model->body(index).size()) { else if (reconstructed.size() < model->body(index).size()) {
msg(tr("reconstructRegion: reconstructed body %1 is smaller then original %2") msg(tr("reconstructRegion: reconstructed region (%1) is smaller then original (%2)")
.arg(reconstructed.size(), 8, 16, QChar('0')) .arg(reconstructed.size(), 8, 16, QChar('0'))
.arg(model->body(index).size(), 8, 16, QChar('0')), index); .arg(model->body(index).size(), 8, 16, QChar('0')), index);
return ERR_INVALID_PARAMETER; return ERR_INVALID_PARAMETER;
@ -2009,8 +2009,8 @@ UINT8 FfsEngine::reconstructVolume(const QModelIndex& index, QByteArray& reconst
// Calculate volume base for boot volume // Calculate volume base for boot volume
UINT32 volumeBase = 0; UINT32 volumeBase = 0;
QByteArray file;
if (model->subtype(index) == BootVolume) { if (model->subtype(index) == BootVolume) {
QByteArray file;
bool baseFound = false; bool baseFound = false;
// Search for VTF // Search for VTF
for (int i = 0; i < model->rowCount(index); i++) { for (int i = 0; i < model->rowCount(index); i++) {
@ -2027,39 +2027,39 @@ UINT8 FfsEngine::reconstructVolume(const QModelIndex& index, QByteArray& reconst
if (!baseFound) { if (!baseFound) {
// Search for first PEI-file and use it as base source // Search for first PEI-file and use it as base source
UINT32 fileOffset = header.size(); UINT32 fileOffset = header.size();
for (int i = 0; i < model->rowCount(index); i++) { for (int i = 0; i < model->rowCount(index); i++) {
if ((model->subtype(index.child(i, 0)) == EFI_FV_FILETYPE_PEI_CORE || if ((model->subtype(index.child(i, 0)) == EFI_FV_FILETYPE_PEI_CORE ||
model->subtype(index.child(i, 0)) == EFI_FV_FILETYPE_PEIM || model->subtype(index.child(i, 0)) == EFI_FV_FILETYPE_PEIM ||
model->subtype(index.child(i, 0)) == EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER)){ model->subtype(index.child(i, 0)) == EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER)){
QModelIndex peiFile = index.child(i, 0); QModelIndex peiFile = index.child(i, 0);
UINT32 sectionOffset = sizeof(EFI_FFS_FILE_HEADER); UINT32 sectionOffset = sizeof(EFI_FFS_FILE_HEADER);
// Search for PE32 or TE section // Search for PE32 or TE section
for(int j = 0; j < model->rowCount(peiFile); j++) { for(int j = 0; j < model->rowCount(peiFile); j++) {
if (model->subtype(peiFile.child(j,0)) == EFI_SECTION_PE32 || if (model->subtype(peiFile.child(j,0)) == EFI_SECTION_PE32 ||
model->subtype(peiFile.child(j,0)) == EFI_SECTION_TE) { model->subtype(peiFile.child(j,0)) == EFI_SECTION_TE) {
QModelIndex image = peiFile.child(j,0); QModelIndex image = peiFile.child(j,0);
// Check for correct action // Check for correct action
if (model->action(image) == Remove || model->action(image) == Insert) if (model->action(image) == Remove || model->action(image) == Insert)
continue; continue;
// Calculate relative base address // Calculate relative base address
UINT32 relbase = fileOffset + sectionOffset + model->header(image).size(); UINT32 relbase = fileOffset + sectionOffset + model->header(image).size();
// Calculate offset of image relative to file base // Calculate offset of image relative to file base
UINT32 imagebase; UINT32 imagebase;
result = getBase(model->body(image), imagebase); result = getBase(model->body(image), imagebase);
if (!result) { if (!result) {
// Calculate volume base // Calculate volume base
volumeBase = imagebase - relbase; volumeBase = imagebase - relbase;
baseFound = true; baseFound = true;
} }
goto out; goto out;
} }
sectionOffset += model->header(peiFile.child(j,0)).size() + model->body(peiFile.child(j,0)).size(); sectionOffset += model->header(peiFile.child(j,0)).size() + model->body(peiFile.child(j,0)).size();
sectionOffset = ALIGN4(sectionOffset); sectionOffset = ALIGN4(sectionOffset);
} }
} }
fileOffset += model->header(index.child(i, 0)).size() + model->body(index.child(i, 0)).size() + model->tail(index.child(i, 0)).size(); fileOffset += model->header(index.child(i, 0)).size() + model->body(index.child(i, 0)).size() + model->tail(index.child(i, 0)).size();
fileOffset = ALIGN8(fileOffset); fileOffset = ALIGN8(fileOffset);
} }
} }
out: out:
@ -2085,6 +2085,7 @@ out:
} }
// Reconstruct file // Reconstruct file
QByteArray file;
result = reconstructFile(index.child(i, 0), volumeHeader->Revision, polarity, volumeBase + offset, file); result = reconstructFile(index.child(i, 0), volumeHeader->Revision, polarity, volumeBase + offset, file);
if (result) if (result)
return result; return result;
@ -2357,7 +2358,7 @@ UINT8 FfsEngine::reconstructFile(const QModelIndex& index, const UINT8 revision,
reconstructed.clear(); reconstructed.clear();
// Construct new file body // Construct new file body
UINT32 offset = 0; UINT32 offset = 0;
QByteArray section;
for (int i = 0; i < model->rowCount(index); i++) { for (int i = 0; i < model->rowCount(index); i++) {
// Align to 4 byte boundary // Align to 4 byte boundary
UINT8 alignment = offset % 4; UINT8 alignment = offset % 4;
@ -2373,6 +2374,7 @@ UINT8 FfsEngine::reconstructFile(const QModelIndex& index, const UINT8 revision,
sectionBase = base + sizeof(EFI_FFS_FILE_HEADER) + offset; sectionBase = base + sizeof(EFI_FFS_FILE_HEADER) + offset;
// Reconstruct section // Reconstruct section
QByteArray section;
result = reconstructSection(index.child(i, 0), sectionBase, section); result = reconstructSection(index.child(i, 0), sectionBase, section);
if (result) if (result)
return result; return result;
@ -2456,9 +2458,10 @@ UINT8 FfsEngine::reconstructSection(const QModelIndex& index, const UINT32 base,
// Reconstruct section with children // Reconstruct section with children
if (model->rowCount(index)) { if (model->rowCount(index)) {
reconstructed.clear();
// Construct new section body // Construct new section body
UINT32 offset = 0; UINT32 offset = 0;
QByteArray section;
// Reconstruct section body // Reconstruct section body
for (int i = 0; i < model->rowCount(index); i++) { for (int i = 0; i < model->rowCount(index); i++) {
// Align to 4 byte boundary // Align to 4 byte boundary
@ -2470,6 +2473,7 @@ UINT8 FfsEngine::reconstructSection(const QModelIndex& index, const UINT32 base,
} }
// Reconstruct subsections // Reconstruct subsections
QByteArray section;
result = reconstruct(index.child(i,0), section); result = reconstruct(index.child(i,0), section);
if (result) if (result)
return result; return result;
@ -2547,9 +2551,9 @@ UINT8 FfsEngine::reconstructSection(const QModelIndex& index, const UINT32 base,
// Special case of PEI Core rebase // Special case of PEI Core rebase
if (model->subtype(index.parent()) == EFI_FV_FILETYPE_PEI_CORE) { if (model->subtype(index.parent()) == EFI_FV_FILETYPE_PEI_CORE) {
result = getEntryPoint(reconstructed, newPeiCoreEntryPoint); result = getEntryPoint(reconstructed, newPeiCoreEntryPoint);
if (result) if (result)
msg(tr("reconstructSection: can't get entry point of image file"), index); msg(tr("reconstructSection: can't get entry point of image file"), index);
} }
} }
// Reconstruction successfull // Reconstruction successfull
@ -2796,7 +2800,7 @@ UINT8 FfsEngine::rebase(QByteArray &executable, const UINT32 base)
relocSize = optHeader->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size; relocSize = optHeader->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC].Size;
// Set new base // Set new base
optHeader->ImageBase = base; optHeader->ImageBase = base;
} }
else else
return ERR_UNKNOWN_PE_OPTIONAL_HEADER_TYPE; return ERR_UNKNOWN_PE_OPTIONAL_HEADER_TYPE;
} }
@ -2815,8 +2819,8 @@ UINT8 FfsEngine::rebase(QByteArray &executable, const UINT32 base)
} }
else else
return ERR_UNKNOWN_IMAGE_TYPE; return ERR_UNKNOWN_IMAGE_TYPE;
// No relocations // No relocations
if (relocOffset == 0) { if (relocOffset == 0) {
// No need to fix relocations // No need to fix relocations
executable = file; executable = file;
@ -2894,10 +2898,10 @@ UINT8 FfsEngine::patchVtf(QByteArray &vtf)
return ERR_PEI_CORE_ENTRY_POINT_NOT_FOUND; return ERR_PEI_CORE_ENTRY_POINT_NOT_FOUND;
} }
if (!newPeiCoreEntryPoint || oldPeiCoreEntryPoint == newPeiCoreEntryPoint) if (!newPeiCoreEntryPoint || oldPeiCoreEntryPoint == newPeiCoreEntryPoint)
// No need to patch anything // No need to patch anything
return ERR_SUCCESS; return ERR_SUCCESS;
// Replace last occurence of oldPeiCoreEntryPoint with newPeiCoreEntryPoint // Replace last occurence of oldPeiCoreEntryPoint with newPeiCoreEntryPoint
QByteArray old((char*) &oldPeiCoreEntryPoint, sizeof(oldPeiCoreEntryPoint)); QByteArray old((char*) &oldPeiCoreEntryPoint, sizeof(oldPeiCoreEntryPoint));
int i = vtf.lastIndexOf(old); int i = vtf.lastIndexOf(old);
@ -2940,8 +2944,8 @@ UINT8 FfsEngine::getEntryPoint(const QByteArray &file, UINT32& peiCoreEntryPoint
EFI_IMAGE_OPTIONAL_HEADER64* optHeader = (EFI_IMAGE_OPTIONAL_HEADER64*) (file.data() + offset); EFI_IMAGE_OPTIONAL_HEADER64* optHeader = (EFI_IMAGE_OPTIONAL_HEADER64*) (file.data() + offset);
peiCoreEntryPoint = optHeader->ImageBase + optHeader->AddressOfEntryPoint; peiCoreEntryPoint = optHeader->ImageBase + optHeader->AddressOfEntryPoint;
} }
else else
return ERR_UNKNOWN_PE_OPTIONAL_HEADER_TYPE; return ERR_UNKNOWN_PE_OPTIONAL_HEADER_TYPE;
} }
else if (dosHeader->e_magic == EFI_IMAGE_TE_SIGNATURE){ else if (dosHeader->e_magic == EFI_IMAGE_TE_SIGNATURE){
// Populate TE header // Populate TE header
@ -2949,12 +2953,12 @@ UINT8 FfsEngine::getEntryPoint(const QByteArray &file, UINT32& peiCoreEntryPoint
UINT32 teFixup = teHeader->StrippedSize - sizeof(EFI_IMAGE_TE_HEADER); UINT32 teFixup = teHeader->StrippedSize - sizeof(EFI_IMAGE_TE_HEADER);
peiCoreEntryPoint = teHeader->ImageBase + teHeader->AddressOfEntryPoint - teFixup; peiCoreEntryPoint = teHeader->ImageBase + teHeader->AddressOfEntryPoint - teFixup;
} }
return ERR_SUCCESS; return ERR_SUCCESS;
} }
UINT8 FfsEngine::getBase(const QByteArray& file, UINT32& base) UINT8 FfsEngine::getBase(const QByteArray& file, UINT32& base)
{ {
if(file.isEmpty()) if(file.isEmpty())
return ERR_INVALID_FILE; return ERR_INVALID_FILE;
// Populate DOS header // Populate DOS header
@ -2981,14 +2985,14 @@ UINT8 FfsEngine::getBase(const QByteArray& file, UINT32& base)
EFI_IMAGE_OPTIONAL_HEADER64* optHeader = (EFI_IMAGE_OPTIONAL_HEADER64*) (file.data() + offset); EFI_IMAGE_OPTIONAL_HEADER64* optHeader = (EFI_IMAGE_OPTIONAL_HEADER64*) (file.data() + offset);
base = optHeader->ImageBase; base = optHeader->ImageBase;
} }
else else
return ERR_UNKNOWN_PE_OPTIONAL_HEADER_TYPE; return ERR_UNKNOWN_PE_OPTIONAL_HEADER_TYPE;
} }
else if (dosHeader->e_magic == EFI_IMAGE_TE_SIGNATURE){ else if (dosHeader->e_magic == EFI_IMAGE_TE_SIGNATURE){
// Populate TE header // Populate TE header
EFI_IMAGE_TE_HEADER* teHeader = (EFI_IMAGE_TE_HEADER*) file.data(); EFI_IMAGE_TE_HEADER* teHeader = (EFI_IMAGE_TE_HEADER*) file.data();
base = teHeader->ImageBase; base = teHeader->ImageBase;
} }
return ERR_SUCCESS; return ERR_SUCCESS;
} }

View File

@ -94,14 +94,14 @@ public:
private: private:
TreeModel *model; TreeModel *model;
// PEI Core entry point // PEI Core entry point
UINT32 oldPeiCoreEntryPoint; UINT32 oldPeiCoreEntryPoint;
UINT32 newPeiCoreEntryPoint; UINT32 newPeiCoreEntryPoint;
// Rebase routines // Rebase routines
UINT8 getBase(const QByteArray& file, UINT32& base); UINT8 getBase(const QByteArray& file, UINT32& base);
UINT8 getEntryPoint(const QByteArray& file, UINT32 &peiCoreEntryPoint); UINT8 getEntryPoint(const QByteArray& file, UINT32 &peiCoreEntryPoint);
UINT8 rebase(QByteArray & executable, const UINT32 base); UINT8 rebase(QByteArray & executable, const UINT32 base);
// Patch routines // Patch routines

View File

@ -44,4 +44,4 @@ QModelIndex MessageListItem::index() const
void MessageListItem::setIndex(QModelIndex & index) void MessageListItem::setIndex(QModelIndex & index)
{ {
itemIndex = index; itemIndex = index;
} }

454
peimage.h
View File

@ -48,38 +48,38 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
// under DOS it can print an error message. // under DOS it can print an error message.
// //
typedef struct { typedef struct {
UINT16 e_magic; // Magic number UINT16 e_magic; // Magic number
UINT16 e_cblp; // Bytes on last page of file UINT16 e_cblp; // Bytes on last page of file
UINT16 e_cp; // Pages in file UINT16 e_cp; // Pages in file
UINT16 e_crlc; // Relocations UINT16 e_crlc; // Relocations
UINT16 e_cparhdr; // Size of header in paragraphs UINT16 e_cparhdr; // Size of header in paragraphs
UINT16 e_minalloc; // Minimum extra paragraphs needed UINT16 e_minalloc; // Minimum extra paragraphs needed
UINT16 e_maxalloc; // Maximum extra paragraphs needed UINT16 e_maxalloc; // Maximum extra paragraphs needed
UINT16 e_ss; // Initial (relative) SS value UINT16 e_ss; // Initial (relative) SS value
UINT16 e_sp; // Initial SP value UINT16 e_sp; // Initial SP value
UINT16 e_csum; // Checksum UINT16 e_csum; // Checksum
UINT16 e_ip; // Initial IP value UINT16 e_ip; // Initial IP value
UINT16 e_cs; // Initial (relative) CS value UINT16 e_cs; // Initial (relative) CS value
UINT16 e_lfarlc; // File address of relocation table UINT16 e_lfarlc; // File address of relocation table
UINT16 e_ovno; // Overlay number UINT16 e_ovno; // Overlay number
UINT16 e_res[4]; // Reserved words UINT16 e_res[4]; // Reserved words
UINT16 e_oemid; // OEM identifier (for e_oeminfo) UINT16 e_oemid; // OEM identifier (for e_oeminfo)
UINT16 e_oeminfo; // OEM information; e_oemid specific UINT16 e_oeminfo; // OEM information; e_oemid specific
UINT16 e_res2[10]; // Reserved words UINT16 e_res2[10]; // Reserved words
UINT32 e_lfanew; // File address of new exe header UINT32 e_lfanew; // File address of new exe header
} EFI_IMAGE_DOS_HEADER; } EFI_IMAGE_DOS_HEADER;
// //
// COFF File Header (Object and Image) // COFF File Header (Object and Image)
// //
typedef struct { typedef struct {
UINT16 Machine; UINT16 Machine;
UINT16 NumberOfSections; UINT16 NumberOfSections;
UINT32 TimeDateStamp; UINT32 TimeDateStamp;
UINT32 PointerToSymbolTable; UINT32 PointerToSymbolTable;
UINT32 NumberOfSymbols; UINT32 NumberOfSymbols;
UINT16 SizeOfOptionalHeader; UINT16 SizeOfOptionalHeader;
UINT16 Characteristics; UINT16 Characteristics;
} EFI_IMAGE_FILE_HEADER; } EFI_IMAGE_FILE_HEADER;
// //
@ -105,8 +105,8 @@ typedef struct {
// Header Data Directories. // Header Data Directories.
// //
typedef struct { typedef struct {
UINT32 VirtualAddress; UINT32 VirtualAddress;
UINT32 Size; UINT32 Size;
} EFI_IMAGE_DATA_DIRECTORY; } EFI_IMAGE_DATA_DIRECTORY;
// //
@ -132,48 +132,48 @@ typedef struct {
// The data structures only vary after NT additional fields // The data structures only vary after NT additional fields
// //
#define EFI_IMAGE_PE_OPTIONAL_HDR32_MAGIC 0x10b #define EFI_IMAGE_PE_OPTIONAL_HDR32_MAGIC 0x10b
// //
// Optional Header Standard Fields for PE32 // Optional Header Standard Fields for PE32
// //
typedef struct { typedef struct {
// //
// Standard fields. // Standard fields.
// //
UINT16 Magic; UINT16 Magic;
UINT8 MajorLinkerVersion; UINT8 MajorLinkerVersion;
UINT8 MinorLinkerVersion; UINT8 MinorLinkerVersion;
UINT32 SizeOfCode; UINT32 SizeOfCode;
UINT32 SizeOfInitializedData; UINT32 SizeOfInitializedData;
UINT32 SizeOfUninitializedData; UINT32 SizeOfUninitializedData;
UINT32 AddressOfEntryPoint; UINT32 AddressOfEntryPoint;
UINT32 BaseOfCode; UINT32 BaseOfCode;
UINT32 BaseOfData; // PE32 contains this additional field, which is absent in PE32+. UINT32 BaseOfData; // PE32 contains this additional field, which is absent in PE32+.
// //
// Optional Header Windows-Specific Fields. // Optional Header Windows-Specific Fields.
// //
UINT32 ImageBase; UINT32 ImageBase;
UINT32 SectionAlignment; UINT32 SectionAlignment;
UINT32 FileAlignment; UINT32 FileAlignment;
UINT16 MajorOperatingSystemVersion; UINT16 MajorOperatingSystemVersion;
UINT16 MinorOperatingSystemVersion; UINT16 MinorOperatingSystemVersion;
UINT16 MajorImageVersion; UINT16 MajorImageVersion;
UINT16 MinorImageVersion; UINT16 MinorImageVersion;
UINT16 MajorSubsystemVersion; UINT16 MajorSubsystemVersion;
UINT16 MinorSubsystemVersion; UINT16 MinorSubsystemVersion;
UINT32 Win32VersionValue; UINT32 Win32VersionValue;
UINT32 SizeOfImage; UINT32 SizeOfImage;
UINT32 SizeOfHeaders; UINT32 SizeOfHeaders;
UINT32 CheckSum; UINT32 CheckSum;
UINT16 Subsystem; UINT16 Subsystem;
UINT16 DllCharacteristics; UINT16 DllCharacteristics;
UINT32 SizeOfStackReserve; UINT32 SizeOfStackReserve;
UINT32 SizeOfStackCommit; UINT32 SizeOfStackCommit;
UINT32 SizeOfHeapReserve; UINT32 SizeOfHeapReserve;
UINT32 SizeOfHeapCommit; UINT32 SizeOfHeapCommit;
UINT32 LoaderFlags; UINT32 LoaderFlags;
UINT32 NumberOfRvaAndSizes; UINT32 NumberOfRvaAndSizes;
EFI_IMAGE_DATA_DIRECTORY DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES]; EFI_IMAGE_DATA_DIRECTORY DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES];
} EFI_IMAGE_OPTIONAL_HEADER32; } EFI_IMAGE_OPTIONAL_HEADER32;
// //
@ -187,42 +187,42 @@ typedef struct {
// Optional Header Standard Fields for PE32+. // Optional Header Standard Fields for PE32+.
// //
typedef struct { typedef struct {
// //
// Standard fields. // Standard fields.
// //
UINT16 Magic; UINT16 Magic;
UINT8 MajorLinkerVersion; UINT8 MajorLinkerVersion;
UINT8 MinorLinkerVersion; UINT8 MinorLinkerVersion;
UINT32 SizeOfCode; UINT32 SizeOfCode;
UINT32 SizeOfInitializedData; UINT32 SizeOfInitializedData;
UINT32 SizeOfUninitializedData; UINT32 SizeOfUninitializedData;
UINT32 AddressOfEntryPoint; UINT32 AddressOfEntryPoint;
UINT32 BaseOfCode; UINT32 BaseOfCode;
// //
// Optional Header Windows-Specific Fields. // Optional Header Windows-Specific Fields.
// //
UINT64 ImageBase; UINT64 ImageBase;
UINT32 SectionAlignment; UINT32 SectionAlignment;
UINT32 FileAlignment; UINT32 FileAlignment;
UINT16 MajorOperatingSystemVersion; UINT16 MajorOperatingSystemVersion;
UINT16 MinorOperatingSystemVersion; UINT16 MinorOperatingSystemVersion;
UINT16 MajorImageVersion; UINT16 MajorImageVersion;
UINT16 MinorImageVersion; UINT16 MinorImageVersion;
UINT16 MajorSubsystemVersion; UINT16 MajorSubsystemVersion;
UINT16 MinorSubsystemVersion; UINT16 MinorSubsystemVersion;
UINT32 Win32VersionValue; UINT32 Win32VersionValue;
UINT32 SizeOfImage; UINT32 SizeOfImage;
UINT32 SizeOfHeaders; UINT32 SizeOfHeaders;
UINT32 CheckSum; UINT32 CheckSum;
UINT16 Subsystem; UINT16 Subsystem;
UINT16 DllCharacteristics; UINT16 DllCharacteristics;
UINT64 SizeOfStackReserve; UINT64 SizeOfStackReserve;
UINT64 SizeOfStackCommit; UINT64 SizeOfStackCommit;
UINT64 SizeOfHeapReserve; UINT64 SizeOfHeapReserve;
UINT64 SizeOfHeapCommit; UINT64 SizeOfHeapCommit;
UINT32 LoaderFlags; UINT32 LoaderFlags;
UINT32 NumberOfRvaAndSizes; UINT32 NumberOfRvaAndSizes;
EFI_IMAGE_DATA_DIRECTORY DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES]; EFI_IMAGE_DATA_DIRECTORY DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES];
} EFI_IMAGE_OPTIONAL_HEADER64; } EFI_IMAGE_OPTIONAL_HEADER64;
typedef struct typedef struct
@ -251,26 +251,26 @@ typedef struct
// Section Table. This table immediately follows the optional header. // Section Table. This table immediately follows the optional header.
// //
typedef struct { typedef struct {
UINT8 Name[EFI_IMAGE_SIZEOF_SHORT_NAME]; UINT8 Name[EFI_IMAGE_SIZEOF_SHORT_NAME];
union { union {
UINT32 PhysicalAddress; UINT32 PhysicalAddress;
UINT32 VirtualSize; UINT32 VirtualSize;
} Misc; } Misc;
UINT32 VirtualAddress; UINT32 VirtualAddress;
UINT32 SizeOfRawData; UINT32 SizeOfRawData;
UINT32 PointerToRawData; UINT32 PointerToRawData;
UINT32 PointerToRelocations; UINT32 PointerToRelocations;
UINT32 PointerToLinenumbers; UINT32 PointerToLinenumbers;
UINT16 NumberOfRelocations; UINT16 NumberOfRelocations;
UINT16 NumberOfLinenumbers; UINT16 NumberOfLinenumbers;
UINT32 Characteristics; UINT32 Characteristics;
} EFI_IMAGE_SECTION_HEADER; } EFI_IMAGE_SECTION_HEADER;
// //
// Size of EFI_IMAGE_SECTION_HEADER // Size of EFI_IMAGE_SECTION_HEADER
// //
#define EFI_IMAGE_SIZEOF_SECTION_HEADER 40 #define EFI_IMAGE_SIZEOF_SECTION_HEADER 40
// //
// Section Flags Values // Section Flags Values
// //
@ -278,12 +278,12 @@ typedef struct {
#define EFI_IMAGE_SCN_CNT_CODE 0x00000020 #define EFI_IMAGE_SCN_CNT_CODE 0x00000020
#define EFI_IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040 #define EFI_IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
#define EFI_IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080 #define EFI_IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
#define EFI_IMAGE_SCN_LNK_OTHER 0x00000100 // Reserved #define EFI_IMAGE_SCN_LNK_OTHER 0x00000100 // Reserved
#define EFI_IMAGE_SCN_LNK_INFO 0x00000200 // Section contains comments or some other type of information #define EFI_IMAGE_SCN_LNK_INFO 0x00000200 // Section contains comments or some other type of information
#define EFI_IMAGE_SCN_LNK_REMOVE 0x00000800 // Section contents will not become part of image #define EFI_IMAGE_SCN_LNK_REMOVE 0x00000800 // Section contents will not become part of image
#define EFI_IMAGE_SCN_LNK_COMDAT 0x00001000 #define EFI_IMAGE_SCN_LNK_COMDAT 0x00001000
#define EFI_IMAGE_SCN_ALIGN_1BYTES 0x00100000 #define EFI_IMAGE_SCN_ALIGN_1BYTES 0x00100000
#define EFI_IMAGE_SCN_ALIGN_2BYTES 0x00200000 #define EFI_IMAGE_SCN_ALIGN_2BYTES 0x00200000
#define EFI_IMAGE_SCN_ALIGN_4BYTES 0x00300000 #define EFI_IMAGE_SCN_ALIGN_4BYTES 0x00300000
@ -291,7 +291,7 @@ typedef struct {
#define EFI_IMAGE_SCN_ALIGN_16BYTES 0x00500000 #define EFI_IMAGE_SCN_ALIGN_16BYTES 0x00500000
#define EFI_IMAGE_SCN_ALIGN_32BYTES 0x00600000 #define EFI_IMAGE_SCN_ALIGN_32BYTES 0x00600000
#define EFI_IMAGE_SCN_ALIGN_64BYTES 0x00700000 #define EFI_IMAGE_SCN_ALIGN_64BYTES 0x00700000
#define EFI_IMAGE_SCN_MEM_DISCARDABLE 0x02000000 #define EFI_IMAGE_SCN_MEM_DISCARDABLE 0x02000000
#define EFI_IMAGE_SCN_MEM_NOT_CACHED 0x04000000 #define EFI_IMAGE_SCN_MEM_NOT_CACHED 0x04000000
#define EFI_IMAGE_SCN_MEM_NOT_PAGED 0x08000000 #define EFI_IMAGE_SCN_MEM_NOT_PAGED 0x08000000
@ -389,7 +389,7 @@ typedef struct {
#define EFI_IMAGE_COMDAT_SELECT_SAME_SIZE 3 #define EFI_IMAGE_COMDAT_SELECT_SAME_SIZE 3
#define EFI_IMAGE_COMDAT_SELECT_EXACT_MATCH 4 #define EFI_IMAGE_COMDAT_SELECT_EXACT_MATCH 4
#define EFI_IMAGE_COMDAT_SELECT_ASSOCIATIVE 5 #define EFI_IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
// //
// The following values only be referred in PeCoff, not defined in PECOFF // The following values only be referred in PeCoff, not defined in PECOFF
// //
@ -401,9 +401,9 @@ typedef struct {
// Relocation format // Relocation format
// //
typedef struct { typedef struct {
UINT32 VirtualAddress; UINT32 VirtualAddress;
UINT32 SymbolTableIndex; UINT32 SymbolTableIndex;
UINT16 Type; UINT16 Type;
} EFI_IMAGE_RELOCATION; } EFI_IMAGE_RELOCATION;
// //
@ -449,8 +449,8 @@ typedef struct {
// Based relocation format // Based relocation format
// //
typedef struct { typedef struct {
UINT32 VirtualAddress; UINT32 VirtualAddress;
UINT32 SizeOfBlock; UINT32 SizeOfBlock;
} EFI_IMAGE_BASE_RELOCATION; } EFI_IMAGE_BASE_RELOCATION;
// //
@ -477,11 +477,11 @@ typedef struct {
// Line number format // Line number format
// //
typedef struct { typedef struct {
union { union {
UINT32 SymbolTableIndex; // Symbol table index of function name if Linenumber is 0 UINT32 SymbolTableIndex; // Symbol table index of function name if Linenumber is 0
UINT32 VirtualAddress; // Virtual address of line number UINT32 VirtualAddress; // Virtual address of line number
} Type; } Type;
UINT16 Linenumber; // Line number UINT16 Linenumber; // Line number
} EFI_IMAGE_LINENUMBER; } EFI_IMAGE_LINENUMBER;
// //
@ -503,13 +503,13 @@ typedef struct {
// Archive Member Headers // Archive Member Headers
// //
typedef struct { typedef struct {
UINT8 Name[16]; // File member name - `/' terminated UINT8 Name[16]; // File member name - `/' terminated
UINT8 Date[12]; // File member date - decimal UINT8 Date[12]; // File member date - decimal
UINT8 UserID[6]; // File member user id - decimal UINT8 UserID[6]; // File member user id - decimal
UINT8 GroupID[6]; // File member group id - decimal UINT8 GroupID[6]; // File member group id - decimal
UINT8 Mode[8]; // File member mode - octal UINT8 Mode[8]; // File member mode - octal
UINT8 Size[10]; // File member size - decimal UINT8 Size[10]; // File member size - decimal
UINT8 EndHeader[2]; // String to end header. (0x60 0x0A) UINT8 EndHeader[2]; // String to end header. (0x60 0x0A)
} EFI_IMAGE_ARCHIVE_MEMBER_HEADER; } EFI_IMAGE_ARCHIVE_MEMBER_HEADER;
// //
@ -526,36 +526,36 @@ typedef struct {
// Export Directory Table // Export Directory Table
// //
typedef struct { typedef struct {
UINT32 Characteristics; UINT32 Characteristics;
UINT32 TimeDateStamp; UINT32 TimeDateStamp;
UINT16 MajorVersion; UINT16 MajorVersion;
UINT16 MinorVersion; UINT16 MinorVersion;
UINT32 Name; UINT32 Name;
UINT32 Base; UINT32 Base;
UINT32 NumberOfFunctions; UINT32 NumberOfFunctions;
UINT32 NumberOfNames; UINT32 NumberOfNames;
UINT32 AddressOfFunctions; UINT32 AddressOfFunctions;
UINT32 AddressOfNames; UINT32 AddressOfNames;
UINT32 AddressOfNameOrdinals; UINT32 AddressOfNameOrdinals;
} EFI_IMAGE_EXPORT_DIRECTORY; } EFI_IMAGE_EXPORT_DIRECTORY;
// //
// Hint/Name Table // Hint/Name Table
// //
typedef struct { typedef struct {
UINT16 Hint; UINT16 Hint;
UINT8 Name[1]; UINT8 Name[1];
} EFI_IMAGE_IMPORT_BY_NAME; } EFI_IMAGE_IMPORT_BY_NAME;
// //
// Import Address Table RVA (Thunk Table) // Import Address Table RVA (Thunk Table)
// //
typedef struct { typedef struct {
union { union {
UINT32 Function; UINT32 Function;
UINT32 Ordinal; UINT32 Ordinal;
EFI_IMAGE_IMPORT_BY_NAME *AddressOfData; EFI_IMAGE_IMPORT_BY_NAME *AddressOfData;
} u1; } u1;
} EFI_IMAGE_THUNK_DATA; } EFI_IMAGE_THUNK_DATA;
#define EFI_IMAGE_ORDINAL_FLAG 0x80000000 // Flag for PE32. #define EFI_IMAGE_ORDINAL_FLAG 0x80000000 // Flag for PE32.
@ -566,11 +566,11 @@ typedef struct {
// Import Directory Table // Import Directory Table
// //
typedef struct { typedef struct {
UINT32 Characteristics; UINT32 Characteristics;
UINT32 TimeDateStamp; UINT32 TimeDateStamp;
UINT32 ForwarderChain; UINT32 ForwarderChain;
UINT32 Name; UINT32 Name;
EFI_IMAGE_THUNK_DATA *FirstThunk; EFI_IMAGE_THUNK_DATA *FirstThunk;
} EFI_IMAGE_IMPORT_DESCRIPTOR; } EFI_IMAGE_IMPORT_DESCRIPTOR;
@ -578,14 +578,14 @@ typedef struct {
// Debug Directory Format // Debug Directory Format
// //
typedef struct { typedef struct {
UINT32 Characteristics; UINT32 Characteristics;
UINT32 TimeDateStamp; UINT32 TimeDateStamp;
UINT16 MajorVersion; UINT16 MajorVersion;
UINT16 MinorVersion; UINT16 MinorVersion;
UINT32 Type; UINT32 Type;
UINT32 SizeOfData; UINT32 SizeOfData;
UINT32 RVA; // The address of the debug data when loaded, relative to the image base UINT32 RVA; // The address of the debug data when loaded, relative to the image base
UINT32 FileOffset; // The file pointer to the debug data UINT32 FileOffset; // The file pointer to the debug data
} EFI_IMAGE_DEBUG_DIRECTORY_ENTRY; } EFI_IMAGE_DEBUG_DIRECTORY_ENTRY;
#define EFI_IMAGE_DEBUG_TYPE_CODEVIEW 2 // The Visual C++ debug information. #define EFI_IMAGE_DEBUG_TYPE_CODEVIEW 2 // The Visual C++ debug information.
@ -595,13 +595,13 @@ typedef struct {
// //
#define CODEVIEW_SIGNATURE_NB10 0x3031424E // NB10 #define CODEVIEW_SIGNATURE_NB10 0x3031424E // NB10
typedef struct { typedef struct {
UINT32 Signature; UINT32 Signature;
UINT32 Unknown; UINT32 Unknown;
UINT32 Unknown2; UINT32 Unknown2;
UINT32 Unknown3; UINT32 Unknown3;
// //
// Filename of .PDB goes here // Filename of .PDB goes here
// //
} EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY; } EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY;
// //
@ -609,15 +609,15 @@ typedef struct {
// //
#define CODEVIEW_SIGNATURE_RSDS 0x53445352 // RSDS #define CODEVIEW_SIGNATURE_RSDS 0x53445352 // RSDS
typedef struct { typedef struct {
UINT32 Signature; UINT32 Signature;
UINT32 Unknown; UINT32 Unknown;
UINT32 Unknown2; UINT32 Unknown2;
UINT32 Unknown3; UINT32 Unknown3;
UINT32 Unknown4; UINT32 Unknown4;
UINT32 Unknown5; UINT32 Unknown5;
// //
// Filename of .PDB goes here // Filename of .PDB goes here
// //
} EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY; } EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY;
@ -626,79 +626,79 @@ typedef struct {
// //
#define CODEVIEW_SIGNATURE_MTOC 0x434F544D // MTOC #define CODEVIEW_SIGNATURE_MTOC 0x434F544D // MTOC
typedef struct { typedef struct {
UINT32 Signature; UINT32 Signature;
UINT8 MachOUuid[16]; UINT8 MachOUuid[16];
// //
// Filename of .DLL (Mach-O with debug info) goes here // Filename of .DLL (Mach-O with debug info) goes here
// //
} EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY; } EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY;
// //
// Resource format // Resource format
// //
typedef struct { typedef struct {
UINT32 Characteristics; UINT32 Characteristics;
UINT32 TimeDateStamp; UINT32 TimeDateStamp;
UINT16 MajorVersion; UINT16 MajorVersion;
UINT16 MinorVersion; UINT16 MinorVersion;
UINT16 NumberOfNamedEntries; UINT16 NumberOfNamedEntries;
UINT16 NumberOfIdEntries; UINT16 NumberOfIdEntries;
// //
// Array of EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY entries goes here // Array of EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY entries goes here
// //
} EFI_IMAGE_RESOURCE_DIRECTORY; } EFI_IMAGE_RESOURCE_DIRECTORY;
// //
// Resource directory entry format // Resource directory entry format
// //
typedef struct { typedef struct {
union { union {
struct { struct {
UINT32 NameOffset:31; UINT32 NameOffset:31;
UINT32 NameIsString:1; UINT32 NameIsString:1;
} s; } s;
UINT32 Id; UINT32 Id;
} u1; } u1;
union { union {
UINT32 OffsetToData; UINT32 OffsetToData;
struct { struct {
UINT32 OffsetToDirectory:31; UINT32 OffsetToDirectory:31;
UINT32 DataIsDirectory:1; UINT32 DataIsDirectory:1;
} s; } s;
} u2; } u2;
} EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY; } EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY;
// //
// Resource directory entry for string // Resource directory entry for string
// //
typedef struct { typedef struct {
UINT16 Length; UINT16 Length;
CHAR16 String[1]; CHAR16 String[1];
} EFI_IMAGE_RESOURCE_DIRECTORY_STRING; } EFI_IMAGE_RESOURCE_DIRECTORY_STRING;
// //
// Resource directory entry for data array // Resource directory entry for data array
// //
typedef struct { typedef struct {
UINT32 OffsetToData; UINT32 OffsetToData;
UINT32 Size; UINT32 Size;
UINT32 CodePage; UINT32 CodePage;
UINT32 Reserved; UINT32 Reserved;
} EFI_IMAGE_RESOURCE_DATA_ENTRY; } EFI_IMAGE_RESOURCE_DATA_ENTRY;
// //
// Header format for TE images, defined in the PI Specification 1.0. // Header format for TE images, defined in the PI Specification 1.0.
// //
typedef struct { typedef struct {
UINT16 Signature; // The signature for TE format = "VZ" UINT16 Signature; // The signature for TE format = "VZ"
UINT16 Machine; // From original file header UINT16 Machine; // From original file header
UINT8 NumberOfSections; // From original file header UINT8 NumberOfSections; // From original file header
UINT8 Subsystem; // From original optional header UINT8 Subsystem; // From original optional header
UINT16 StrippedSize; // Number of bytes we removed from header UINT16 StrippedSize; // Number of bytes we removed from header
UINT32 AddressOfEntryPoint; // Offset to entry point -- from original optional header UINT32 AddressOfEntryPoint; // Offset to entry point -- from original optional header
UINT32 BaseOfCode; // From original image -- required for ITP debug UINT32 BaseOfCode; // From original image -- required for ITP debug
UINT64 ImageBase; // From original file header UINT64 ImageBase; // From original file header
EFI_IMAGE_DATA_DIRECTORY DataDirectory[2]; // Only base relocation and debug directory EFI_IMAGE_DATA_DIRECTORY DataDirectory[2]; // Only base relocation and debug directory
} EFI_IMAGE_TE_HEADER; } EFI_IMAGE_TE_HEADER;
#define EFI_IMAGE_TE_SIGNATURE 0x5A56 // VZ #define EFI_IMAGE_TE_SIGNATURE 0x5A56 // VZ

View File

@ -23,11 +23,11 @@ class SearchDialog : public QDialog
public: public:
SearchDialog(QWidget *parent = 0); SearchDialog(QWidget *parent = 0);
~SearchDialog(); ~SearchDialog();
Ui::SearchDialog* ui; Ui::SearchDialog* ui;
private slots: private slots:
//void setEditMask(); //void setEditMask();
}; };

View File

@ -299,8 +299,8 @@ void TreeItem::setAction(const UINT8 action)
// Set rebuild action for parent, if it has no action now // Set rebuild action for parent, if it has no action now
if (parentItem && parentItem->type() != Root if (parentItem && parentItem->type() != Root
&& parentItem->action() == NoAction) && parentItem->action() == NoAction)
parentItem->setAction(Rebuild); parentItem->setAction(Rebuild);
} }
void TreeItem::setSubtype(const UINT8 subtype) void TreeItem::setSubtype(const UINT8 subtype)

View File

@ -29,9 +29,9 @@ class TreeItem
{ {
public: public:
TreeItem(const UINT8 type, const UINT8 subtype = 0, const UINT8 compression = COMPRESSION_ALGORITHM_NONE, TreeItem(const UINT8 type, const UINT8 subtype = 0, const UINT8 compression = COMPRESSION_ALGORITHM_NONE,
const QString &name = QString(), const QString &text = QString(), const QString &info = QString(), const QString &name = QString(), const QString &text = QString(), const QString &info = QString(),
const QByteArray & header = QByteArray(), const QByteArray & body = QByteArray(), const QByteArray & tail = QByteArray(), const QByteArray & header = QByteArray(), const QByteArray & body = QByteArray(), const QByteArray & tail = QByteArray(),
TreeItem *parent = 0); TreeItem *parent = 0);
~TreeItem(); ~TreeItem();
// Operations with items // Operations with items

View File

@ -82,7 +82,7 @@ QVariant TreeModel::headerData(int section, Qt::Orientation orientation,
} }
QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent) QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent)
const const
{ {
if (!hasIndex(row, column, parent)) if (!hasIndex(row, column, parent))
return QModelIndex(); return QModelIndex();

View File

@ -68,9 +68,9 @@ public:
UINT8 compression(const QModelIndex &index) const; UINT8 compression(const QModelIndex &index) const;
QModelIndex addItem(const UINT8 type, const UINT8 subtype = 0, const UINT8 compression = COMPRESSION_ALGORITHM_NONE, QModelIndex addItem(const UINT8 type, const UINT8 subtype = 0, const UINT8 compression = COMPRESSION_ALGORITHM_NONE,
const QString & name = QString(), const QString & text = QString(), const QString & info = QString(), const QString & name = QString(), const QString & text = QString(), const QString & info = QString(),
const QByteArray & header = QByteArray(), const QByteArray & body = QByteArray(), const QByteArray & tail = QByteArray(), const QByteArray & header = QByteArray(), const QByteArray & body = QByteArray(), const QByteArray & tail = QByteArray(),
const QModelIndex & parent = QModelIndex(), const UINT8 mode = CREATE_MODE_APPEND); const QModelIndex & parent = QModelIndex(), const UINT8 mode = CREATE_MODE_APPEND);
QModelIndex findParentOfType(const QModelIndex & index, UINT8 type) const; QModelIndex findParentOfType(const QModelIndex & index, UINT8 type) const;

View File

@ -82,7 +82,7 @@ void UEFITool::init()
// Connect // Connect
connect(ui->structureTreeView->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), connect(ui->structureTreeView->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
this, SLOT(populateUi(const QModelIndex &))); this, SLOT(populateUi(const QModelIndex &)));
connect(ui->messageListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(scrollTreeView(QListWidgetItem*))); connect(ui->messageListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(scrollTreeView(QListWidgetItem*)));
} }
@ -121,6 +121,9 @@ void UEFITool::populateUi(const QModelIndex &current)
void UEFITool::search() void UEFITool::search()
{ {
// Set focus to edit box
searchDialog->ui->searchEdit->setFocus();
if (searchDialog->exec() != QDialog::Accepted) if (searchDialog->exec() != QDialog::Accepted)
return; return;
@ -144,7 +147,7 @@ void UEFITool::search()
if (pattern.isEmpty()) if (pattern.isEmpty())
return; return;
ffsEngine->findTextPattern(pattern, searchDialog->ui->unicodeCheckBox->isChecked(), ffsEngine->findTextPattern(pattern, searchDialog->ui->unicodeCheckBox->isChecked(),
(Qt::CaseSensitivity) searchDialog->ui->caseSensitiveCheckBox->isChecked()); (Qt::CaseSensitivity) searchDialog->ui->caseSensitiveCheckBox->isChecked());
showMessages(); showMessages();
} }
} }
@ -193,12 +196,12 @@ void UEFITool::insert(const UINT8 mode)
case Volume: case Volume:
path = QFileDialog::getOpenFileName(this, tr("Select FFS file to insert"),".","FFS files (*.ffs *.bin);;All files (*.*)"); path = QFileDialog::getOpenFileName(this, tr("Select FFS file to insert"),".","FFS files (*.ffs *.bin);;All files (*.*)");
objectType = File; objectType = File;
break; break;
case File: case File:
case Section: case Section:
path = QFileDialog::getOpenFileName(this, tr("Select section file to insert"),".","Section files (*.sct *.bin);;All files (*.*)"); path = QFileDialog::getOpenFileName(this, tr("Select section file to insert"),".","Section files (*.sct *.bin);;All files (*.*)");
objectType = Section; objectType = Section;
break; break;
default: default:
return; return;
} }
@ -361,7 +364,7 @@ void UEFITool::extract(const UINT8 mode)
break; break;
case Section: case Section:
path = QFileDialog::getSaveFileName(this, tr("Save section file to file"),".","Section files (*.sct *.bin);;All files (*.*)"); path = QFileDialog::getSaveFileName(this, tr("Save section file to file"),".","Section files (*.sct *.bin);;All files (*.*)");
break; break;
default: default:
path = QFileDialog::getSaveFileName(this, tr("Save object to file"),".","Binary files (*.bin);;All files (*.*)"); path = QFileDialog::getSaveFileName(this, tr("Save object to file"),".","Binary files (*.bin);;All files (*.*)");
} }
@ -372,11 +375,11 @@ void UEFITool::extract(const UINT8 mode)
path = QFileDialog::getSaveFileName(this, tr("Save capsule body to image file"),".","Image files (*.rom *.bin);;All files (*.*)"); path = QFileDialog::getSaveFileName(this, tr("Save capsule body to image file"),".","Image files (*.rom *.bin);;All files (*.*)");
break; break;
case File: { case File: {
if (model->subtype(index) == EFI_FV_FILETYPE_ALL || model->subtype(index) == EFI_FV_FILETYPE_RAW) if (model->subtype(index) == EFI_FV_FILETYPE_ALL || model->subtype(index) == EFI_FV_FILETYPE_RAW)
path = QFileDialog::getSaveFileName(this, tr("Save FFS file body to raw file"),".","Raw files (*.raw *.bin);;All files (*.*)"); path = QFileDialog::getSaveFileName(this, tr("Save FFS file body to raw file"),".","Raw files (*.raw *.bin);;All files (*.*)");
else else
path = QFileDialog::getSaveFileName(this, tr("Save FFS file body to file"),".","FFS file body files (*.fbd *.bin);;All files (*.*)"); path = QFileDialog::getSaveFileName(this, tr("Save FFS file body to file"),".","FFS file body files (*.fbd *.bin);;All files (*.*)");
} }
break; break;
case Section: { case Section: {
if (model->subtype(index) == EFI_SECTION_COMPRESSION || model->subtype(index) == EFI_SECTION_GUID_DEFINED || model->subtype(index) == EFI_SECTION_DISPOSABLE) if (model->subtype(index) == EFI_SECTION_COMPRESSION || model->subtype(index) == EFI_SECTION_GUID_DEFINED || model->subtype(index) == EFI_SECTION_DISPOSABLE)
@ -387,8 +390,8 @@ void UEFITool::extract(const UINT8 mode)
path = QFileDialog::getSaveFileName(this, tr("Save section body to raw file"),".","Raw files (*.raw *.bin);;All files (*.*)"); path = QFileDialog::getSaveFileName(this, tr("Save section body to raw file"),".","Raw files (*.raw *.bin);;All files (*.*)");
else else
path = QFileDialog::getSaveFileName(this, tr("Save section body to file"),".","Binary files (*.bin);;All files (*.*)"); path = QFileDialog::getSaveFileName(this, tr("Save section body to file"),".","Binary files (*.bin);;All files (*.*)");
} }
break; break;
default: default:
path = QFileDialog::getSaveFileName(this, tr("Save object to file"),".","Binary files (*.bin);;All files (*.*)"); path = QFileDialog::getSaveFileName(this, tr("Save object to file"),".","Binary files (*.bin);;All files (*.*)");
} }
@ -417,13 +420,13 @@ void UEFITool::extract(const UINT8 mode)
void UEFITool::about() void UEFITool::about()
{ {
QMessageBox::about(this, tr("About UEFITool"), tr( QMessageBox::about(this, tr("About UEFITool"), tr(
"Copyright (c) 2013, Nikolaj Schlej aka <b>CodeRush</b>.<br><br>" "Copyright (c) 2013, Nikolaj Schlej aka <b>CodeRush</b>.<br><br>"
"The program is dedicated to <b>RevoGirl</b>. Rest in peace, young genius.<br><br>" "The program is dedicated to <b>RevoGirl</b>. Rest in peace, young genius.<br><br>"
"The program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License.<br>" "The program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License.<br>"
"The full text of the license may be found at <a href=http://opensource.org/licenses/bsd-license.php>OpenSource.org</a>.<br><br>" "The full text of the license may be found at <a href=http://opensource.org/licenses/bsd-license.php>OpenSource.org</a>.<br><br>"
"<b>THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN \"AS IS\" BASIS, " "<b>THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN \"AS IS\" BASIS, "
"WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, " "WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, "
"EITHER EXPRESS OR IMPLIED.</b>")); "EITHER EXPRESS OR IMPLIED.</b>"));
} }
void UEFITool::aboutQt() void UEFITool::aboutQt()
@ -508,7 +511,7 @@ void UEFITool::clearMessages()
void UEFITool::dragEnterEvent(QDragEnterEvent* event) void UEFITool::dragEnterEvent(QDragEnterEvent* event)
{ {
if (event->mimeData()->hasFormat("text/uri-list")) if (event->mimeData()->hasFormat("text/uri-list"))
event->acceptProposedAction(); event->acceptProposedAction();
} }
void UEFITool::dropEvent(QDropEvent* event) void UEFITool::dropEvent(QDropEvent* event)

View File

@ -38,7 +38,7 @@
#include "searchdialog.h" #include "searchdialog.h"
namespace Ui { namespace Ui {
class UEFITool; class UEFITool;
} }
class UEFITool : public QMainWindow class UEFITool : public QMainWindow
@ -54,13 +54,13 @@ public:
private slots: private slots:
void init(); void init();
void populateUi(const QModelIndex &current); void populateUi(const QModelIndex &current);
//void resizeTreeViewColumns(); //void resizeTreeViewColumns();
void scrollTreeView(QListWidgetItem* item); void scrollTreeView(QListWidgetItem* item);
void openImageFile(); void openImageFile();
void saveImageFile(); void saveImageFile();
void search(); void search();
void extract(const UINT8 mode); void extract(const UINT8 mode);
void extractAsIs(); void extractAsIs();
void extractBody(); void extractBody();
@ -70,21 +70,21 @@ private slots:
void insertBefore(); void insertBefore();
void insertAfter(); void insertAfter();
void replace(const UINT8 mode); void replace(const UINT8 mode);
void replaceAsIs(); void replaceAsIs();
void replaceBody(); void replaceBody();
void rebuild(); void rebuild();
void remove(); void remove();
void clearMessages(); void clearMessages();
void about(); void about();
void aboutQt(); void aboutQt();
void exit(); void exit();
void writeSettings(); void writeSettings();
private: private:
Ui::UEFITool* ui; Ui::UEFITool* ui;
@ -97,7 +97,7 @@ private:
void dragEnterEvent(QDragEnterEvent* event); void dragEnterEvent(QDragEnterEvent* event);
void dropEvent(QDropEvent* event); void dropEvent(QDropEvent* event);
void contextMenuEvent(QContextMenuEvent* event); void contextMenuEvent(QContextMenuEvent* event);
void readSettings(); void readSettings();
}; };
#endif #endif

View File

@ -20,7 +20,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>UEFITool 0.16.0</string> <string>UEFITool 0.16.1</string>
</property> </property>
<widget class="QWidget" name="centralWidget"> <widget class="QWidget" name="centralWidget">
<property name="sizePolicy"> <property name="sizePolicy">
@ -33,16 +33,7 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="leftMargin"> <property name="margin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -62,16 +53,7 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="leftMargin"> <property name="margin">
<number>5</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number> <number>5</number>
</property> </property>
<item> <item>
@ -109,16 +91,7 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="leftMargin"> <property name="margin">
<number>5</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number> <number>5</number>
</property> </property>
<item> <item>
@ -148,16 +121,7 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="leftMargin"> <property name="margin">
<number>5</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number> <number>5</number>
</property> </property>
<item> <item>