mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-22 07:58:22 +08:00
Version 0.17.10
- added more infomation about volumes, files and sections to info window - removed useless alignment checks for rev1 volumes
This commit is contained in:
parent
a3077215d6
commit
b0d20fad72
158
ffsengine.cpp
158
ffsengine.cpp
@ -515,72 +515,11 @@ UINT8 FfsEngine::parseBios(const QByteArray & bios, const QModelIndex & parent)
|
||||
EFI_FIRMWARE_VOLUME_HEADER* volumeHeader = (EFI_FIRMWARE_VOLUME_HEADER*)(bios.constData() + volumeOffset);
|
||||
UINT32 alignment;
|
||||
if (volumeHeader->Revision == 1) {
|
||||
// Acquire alignment bits
|
||||
bool alignmentCap = volumeHeader->Attributes & EFI_FVB_ALIGNMENT_CAP;
|
||||
bool alignment2 = volumeHeader->Attributes & EFI_FVB_ALIGNMENT_2;
|
||||
bool alignment4 = volumeHeader->Attributes & EFI_FVB_ALIGNMENT_4;
|
||||
bool alignment8 = volumeHeader->Attributes & EFI_FVB_ALIGNMENT_8;
|
||||
bool alignment16 = volumeHeader->Attributes & EFI_FVB_ALIGNMENT_16;
|
||||
bool alignment32 = volumeHeader->Attributes & EFI_FVB_ALIGNMENT_32;
|
||||
bool alignment64 = volumeHeader->Attributes & EFI_FVB_ALIGNMENT_64;
|
||||
bool alignment128 = volumeHeader->Attributes & EFI_FVB_ALIGNMENT_128;
|
||||
bool alignment256 = volumeHeader->Attributes & EFI_FVB_ALIGNMENT_256;
|
||||
bool alignment512 = volumeHeader->Attributes & EFI_FVB_ALIGNMENT_512;
|
||||
bool alignment1k = volumeHeader->Attributes & EFI_FVB_ALIGNMENT_1K;
|
||||
bool alignment2k = volumeHeader->Attributes & EFI_FVB_ALIGNMENT_2K;
|
||||
bool alignment4k = volumeHeader->Attributes & EFI_FVB_ALIGNMENT_4K;
|
||||
bool alignment8k = volumeHeader->Attributes & EFI_FVB_ALIGNMENT_8K;
|
||||
bool alignment16k = volumeHeader->Attributes & EFI_FVB_ALIGNMENT_16K;
|
||||
bool alignment32k = volumeHeader->Attributes & EFI_FVB_ALIGNMENT_32K;
|
||||
bool alignment64k = volumeHeader->Attributes & EFI_FVB_ALIGNMENT_64K;
|
||||
|
||||
// Check alignment setup
|
||||
if (!alignmentCap &&
|
||||
( alignment2 || alignment4 || alignment8 || alignment16
|
||||
|| alignment32 || alignment64 || alignment128 || alignment256
|
||||
|| alignment512 || alignment1k || alignment2k || alignment4k
|
||||
|| alignment8k || alignment16k || alignment32k || alignment64k))
|
||||
msg("parseBios: Incompatible revision 1 volume alignment setup", parent);
|
||||
|
||||
// Assume that smaller alignment value consumes greater
|
||||
//!TODO: refactor this code
|
||||
alignment = 0x01;
|
||||
if (alignment2)
|
||||
alignment = 0x02;
|
||||
else if (alignment4)
|
||||
alignment = 0x04;
|
||||
else if (alignment8)
|
||||
alignment = 0x08;
|
||||
else if (alignment16)
|
||||
alignment = 0x10;
|
||||
else if (alignment32)
|
||||
alignment = 0x20;
|
||||
else if (alignment64)
|
||||
alignment = 0x40;
|
||||
else if (alignment128)
|
||||
alignment = 0x80;
|
||||
else if (alignment256)
|
||||
alignment = 0x100;
|
||||
else if (alignment512)
|
||||
alignment = 0x200;
|
||||
else if (alignment1k)
|
||||
alignment = 0x400;
|
||||
else if (alignment2k)
|
||||
alignment = 0x800;
|
||||
else if (alignment4k)
|
||||
alignment = 0x1000;
|
||||
else if (alignment8k)
|
||||
alignment = 0x2000;
|
||||
else if (alignment16k)
|
||||
alignment = 0x4000;
|
||||
else if (alignment32k)
|
||||
alignment = 0x8000;
|
||||
else if (alignment64k)
|
||||
alignment = 0x10000;
|
||||
|
||||
// Check alignment
|
||||
if (volumeOffset % alignment) {
|
||||
msg(tr("parseBios: Unaligned revision 1 volume"), parent);
|
||||
// Acquire alignment capability bit
|
||||
bool alignmentCap = volumeHeader->Attributes | EFI_FVB_ALIGNMENT_CAP;
|
||||
if (!alignmentCap) {
|
||||
if (volumeHeader->Attributes & 0xFFFF0000)
|
||||
msg("parseBios: Alignment bits set on volume without alignment capability", parent);
|
||||
}
|
||||
}
|
||||
else if (volumeHeader->Revision == 2) {
|
||||
@ -718,7 +657,7 @@ UINT8 FfsEngine::parseVolume(const QByteArray & volume, QModelIndex & index, co
|
||||
|
||||
// Check attributes
|
||||
// Determine value of empty byte
|
||||
char empty = volumeHeader->Attributes & EFI_FVB_ERASE_POLARITY ? '\xFF' : '\x00';
|
||||
char empty = volumeHeader->Attributes | EFI_FVB_ERASE_POLARITY ? '\xFF' : '\x00';
|
||||
|
||||
// Get volume size
|
||||
UINT8 result;
|
||||
@ -746,10 +685,12 @@ UINT8 FfsEngine::parseVolume(const QByteArray & volume, QModelIndex & index, co
|
||||
|
||||
// Get info
|
||||
QString name = guidToQString(volumeHeader->FileSystemGuid);
|
||||
QString info = tr("Size: %1\nRevision: %2\nAttributes: %3\nHeader size: %4")
|
||||
QString info = tr("FileSystem GUID: %1\nSize: %2\nRevision: %3\nAttributes: %4\nErase polarity: %5\nHeader size: %6")
|
||||
.arg(guidToQString(volumeHeader->FileSystemGuid))
|
||||
.arg(volumeSize, 8, 16, QChar('0'))
|
||||
.arg(volumeHeader->Revision)
|
||||
.arg(volumeHeader->Attributes, 8, 16, QChar('0'))
|
||||
.arg(empty ? "1" : "0")
|
||||
.arg(headerSize, 4, 16, QChar('0'));
|
||||
// Extended header present
|
||||
if (volumeHeader->Revision > 1 && volumeHeader->ExtHeaderOffset) {
|
||||
@ -969,7 +910,8 @@ UINT8 FfsEngine::parseFile(const QByteArray & file, QModelIndex & index, const U
|
||||
name = guidToQString(fileHeader->Name);
|
||||
else
|
||||
name = tr("Padding");
|
||||
info = tr("Type: %1\nAttributes: %2\nSize: %3\nState: %4")
|
||||
info = tr("Name: %1\nType: %2\nAttributes: %3\nSize: %4\nState: %5")
|
||||
.arg(guidToQString(fileHeader->Name))
|
||||
.arg(fileHeader->Type, 2, 16, QChar('0'))
|
||||
.arg(fileHeader->Attributes, 2, 16, QChar('0'))
|
||||
.arg(uint24ToUint32(fileHeader->Size), 6, 16, QChar('0'))
|
||||
@ -1069,7 +1011,7 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
|
||||
// Get info
|
||||
info = tr("Type: %1\nSize: %2\nCompression type: %3\nDecompressed size: %4")
|
||||
.arg(sectionHeader->Type, 2, 16, QChar('0'))
|
||||
.arg(body.size(), 8, 16, QChar('0'))
|
||||
.arg(body.size(), 6, 16, QChar('0'))
|
||||
.arg(compressionTypeToQString(algorithm))
|
||||
.arg(compressedSectionHeader->UncompressedLength, 8, 16, QChar('0'));
|
||||
|
||||
@ -1099,7 +1041,7 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
|
||||
name = guidToQString(guidDefinedSectionHeader->SectionDefinitionGuid);
|
||||
info = tr("Type: %1\nSize: %2\nData offset: %3\nAttributes: %4")
|
||||
.arg(sectionHeader->Type, 2, 16, QChar('0'))
|
||||
.arg(body.size(), 8, 16, QChar('0'))
|
||||
.arg(body.size(), 6, 16, QChar('0'))
|
||||
.arg(guidDefinedSectionHeader->DataOffset, 4, 16, QChar('0'))
|
||||
.arg(guidDefinedSectionHeader->Attributes, 4, 16, QChar('0'));
|
||||
|
||||
@ -1152,7 +1094,7 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
|
||||
}
|
||||
}
|
||||
else {
|
||||
msg(tr("parseSection: GUID defined section (%1) with unknown authentification method")
|
||||
msg(tr("parseSection: GUID defined section (%1) with unknown authentication method")
|
||||
.arg(guidToQString(guidDefinedSectionHeader->SectionDefinitionGuid)), parent);
|
||||
}
|
||||
}
|
||||
@ -1176,7 +1118,7 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
|
||||
// Get info
|
||||
info = tr("parseSection: %1\nSize: %2")
|
||||
.arg(sectionHeader->Type, 2, 16, QChar('0'))
|
||||
.arg(body.size(), 8, 16, QChar('0'));
|
||||
.arg(body.size(), 6, 16, QChar('0'));
|
||||
|
||||
// Add tree item
|
||||
index = model->addItem(Types::Section, sectionHeader->Type, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body, QByteArray(), parent, mode);
|
||||
@ -1187,17 +1129,14 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
|
||||
// Leaf sections
|
||||
case EFI_SECTION_PE32:
|
||||
case EFI_SECTION_TE:
|
||||
case EFI_SECTION_PIC:
|
||||
case EFI_SECTION_VERSION:
|
||||
case EFI_SECTION_FREEFORM_SUBTYPE_GUID:
|
||||
case EFI_SECTION_DXE_DEPEX:
|
||||
case EFI_SECTION_PEI_DEPEX:
|
||||
case EFI_SECTION_SMM_DEPEX:
|
||||
case EFI_SECTION_COMPATIBILITY16:
|
||||
case EFI_SECTION_COMPATIBILITY16: {
|
||||
headerSize = sizeOfSectionHeaderOfType(sectionHeader->Type);
|
||||
header = section.left(headerSize);
|
||||
body = section.mid(headerSize, sectionSize - headerSize);
|
||||
@ -1205,7 +1144,7 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
|
||||
// Get info
|
||||
info = tr("Type: %1\nSize: %2")
|
||||
.arg(sectionHeader->Type, 2, 16, QChar('0'))
|
||||
.arg(body.size(), 8, 16, QChar('0'));
|
||||
.arg(body.size(), 6, 16, QChar('0'));
|
||||
|
||||
// Add tree item
|
||||
index = model->addItem(Types::Section, sectionHeader->Type, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body, QByteArray(), parent, mode);
|
||||
@ -1216,33 +1155,66 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
|
||||
if (result)
|
||||
msg(tr("parseSection: can't get entry point of image file"), index);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EFI_SECTION_USER_INTERFACE:
|
||||
{
|
||||
header = section.left(sizeof(EFI_USER_INTERFACE_SECTION));
|
||||
body = section.mid(sizeof(EFI_USER_INTERFACE_SECTION), sectionSize - sizeof(EFI_USER_INTERFACE_SECTION));
|
||||
case EFI_SECTION_FREEFORM_SUBTYPE_GUID: {
|
||||
header = section.left(sizeof(EFI_FREEFORM_SUBTYPE_GUID_SECTION));
|
||||
body = section.mid(sizeof(EFI_FREEFORM_SUBTYPE_GUID_SECTION), sectionSize - sizeof(EFI_FREEFORM_SUBTYPE_GUID_SECTION));
|
||||
|
||||
EFI_FREEFORM_SUBTYPE_GUID_SECTION* fsgHeader = (EFI_FREEFORM_SUBTYPE_GUID_SECTION*)sectionHeader;
|
||||
// Get info
|
||||
info = tr("Type: %1\nSize: %2\nSubtype GUID: %3")
|
||||
.arg(fsgHeader->Type, 2, 16, QChar('0'))
|
||||
.arg(body.size(), 6, 16, QChar('0'))
|
||||
.arg(guidToQString(fsgHeader->SubTypeGuid));
|
||||
|
||||
// Add tree item
|
||||
index = model->addItem(Types::Section, sectionHeader->Type, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body, QByteArray(), parent, mode);
|
||||
}
|
||||
break;
|
||||
case EFI_SECTION_VERSION: {
|
||||
header = section.left(sizeof(EFI_VERSION_SECTION));
|
||||
body = section.mid(sizeof(EFI_VERSION_SECTION), sectionSize - sizeof(EFI_VERSION_SECTION));
|
||||
|
||||
EFI_VERSION_SECTION* versionHeader = (EFI_VERSION_SECTION*)sectionHeader;
|
||||
|
||||
// Get info
|
||||
info = tr("Type: %1\nSize: %2")
|
||||
info = tr("Type: %1\nSize: %2\nBuild number: %3\nVersion string: %4")
|
||||
.arg(versionHeader->Type, 2, 16, QChar('0'))
|
||||
.arg(body.size(), 6, 16, QChar('0'))
|
||||
.arg(versionHeader->BuildNumber, 4, 16, QChar('0'))
|
||||
.arg(QString::fromUtf16((const ushort*)body.constData()));
|
||||
|
||||
// Add tree item
|
||||
index = model->addItem(Types::Section, sectionHeader->Type, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body, QByteArray(), parent, mode);
|
||||
}
|
||||
break;
|
||||
case EFI_SECTION_USER_INTERFACE: {
|
||||
header = section.left(sizeof(EFI_USER_INTERFACE_SECTION));
|
||||
body = section.mid(sizeof(EFI_USER_INTERFACE_SECTION), sectionSize - sizeof(EFI_USER_INTERFACE_SECTION));
|
||||
QString text = QString::fromUtf16((const ushort*)body.constData());
|
||||
|
||||
// Get info
|
||||
info = tr("Type: %1\nSize: %2\nText: %3")
|
||||
.arg(sectionHeader->Type, 2, 16, QChar('0'))
|
||||
.arg(body.size(), 8, 16, QChar('0'));
|
||||
.arg(body.size(), 6, 16, QChar('0'))
|
||||
.arg(text);
|
||||
|
||||
// Add tree item
|
||||
index = model->addItem(Types::Section, sectionHeader->Type, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body, QByteArray(), parent, mode);
|
||||
|
||||
// Rename parent file
|
||||
QString text = QString::fromUtf16((const ushort*)body.constData());
|
||||
model->setTextString(model->findParentOfType(parent, Types::File), text);
|
||||
}
|
||||
break;
|
||||
case EFI_SECTION_FIRMWARE_VOLUME_IMAGE:
|
||||
case EFI_SECTION_FIRMWARE_VOLUME_IMAGE: {
|
||||
header = section.left(sizeof(EFI_FIRMWARE_VOLUME_IMAGE_SECTION));
|
||||
body = section.mid(sizeof(EFI_FIRMWARE_VOLUME_IMAGE_SECTION), sectionSize - sizeof(EFI_FIRMWARE_VOLUME_IMAGE_SECTION));
|
||||
|
||||
// Get info
|
||||
info = tr("Type: %1\nSize: %2")
|
||||
.arg(sectionHeader->Type, 2, 16, QChar('0'))
|
||||
.arg(body.size(), 8, 16, QChar('0'));
|
||||
.arg(body.size(), 6, 16, QChar('0'));
|
||||
|
||||
// Add tree item
|
||||
index = model->addItem(Types::Section, sectionHeader->Type, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body, QByteArray(), parent, mode);
|
||||
@ -1253,15 +1225,16 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
|
||||
msg(tr("parseSection: Firmware volume image can not be parsed as BIOS (%1)").arg(result), index);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EFI_SECTION_RAW:
|
||||
case EFI_SECTION_RAW: {
|
||||
header = section.left(sizeof(EFI_RAW_SECTION));
|
||||
body = section.mid(sizeof(EFI_RAW_SECTION), sectionSize - sizeof(EFI_RAW_SECTION));
|
||||
|
||||
// Get info
|
||||
info = tr("Type: %1\nSize: %2")
|
||||
.arg(sectionHeader->Type, 2, 16, QChar('0'))
|
||||
.arg(body.size(), 8, 16, QChar('0'));
|
||||
.arg(body.size(), 6, 16, QChar('0'));
|
||||
|
||||
// Add tree item
|
||||
index = model->addItem(Types::Section, sectionHeader->Type, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body, QByteArray(), parent, mode);
|
||||
@ -1272,6 +1245,7 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
|
||||
msg(tr("parseSection: Raw section can not be parsed as BIOS (%1)").arg(result), index);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
header = section.left(sizeof(EFI_COMMON_SECTION_HEADER));
|
||||
@ -1279,7 +1253,7 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
|
||||
// Get info
|
||||
info = tr("Type: %1\nSize: %2")
|
||||
.arg(sectionHeader->Type, 2, 16, QChar('0'))
|
||||
.arg(body.size(), 8, 16, QChar('0'));
|
||||
.arg(body.size(), 6, 16, QChar('0'));
|
||||
|
||||
// Add tree item
|
||||
index = model->addItem(Types::Section, sectionHeader->Type, COMPRESSION_ALGORITHM_NONE, name, "", info, header, body, QByteArray(), parent, mode);
|
||||
@ -2150,7 +2124,7 @@ UINT8 FfsEngine::reconstructVolume(const QModelIndex & index, QByteArray & recon
|
||||
// VTF found
|
||||
if (file.left(sizeof(EFI_GUID)) == EFI_FFS_VOLUME_TOP_FILE_GUID) {
|
||||
baseFound = true;
|
||||
volumeBase = (UINT32) 0x100000000 - volumeSize;
|
||||
volumeBase = (UINT32) (0x100000000 - volumeSize);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2632,7 +2606,7 @@ UINT8 FfsEngine::reconstructSection(const QModelIndex& index, const UINT32 base,
|
||||
*(UINT32*)(header.data() + sizeof(EFI_GUID_DEFINED_SECTION)) = crc;
|
||||
}
|
||||
else {
|
||||
msg(tr("reconstructSection: %1: GUID defined section authentification info can become invalid")
|
||||
msg(tr("reconstructSection: %1: GUID defined section authentication info can become invalid")
|
||||
.arg(guidToQString(guidDefinedHeader->SectionDefinitionGuid)), index);
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>UEFITool 0.17.9</string>
|
||||
<string>UEFITool 0.17.10</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<property name="sizePolicy">
|
||||
|
Loading…
Reference in New Issue
Block a user