mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-22 16:08:23 +08:00
Version 0.19.0
- added support for Intel signed sections - massages are cleaned up once again
This commit is contained in:
parent
970ae65b24
commit
262e81720c
@ -95,7 +95,7 @@ UINT32 *DestinationSize
|
|||||||
{
|
{
|
||||||
UInt64 DecodedSize;
|
UInt64 DecodedSize;
|
||||||
|
|
||||||
ASSERT(SourceSize >= LZMA_HEADER_SIZE);
|
ASSERT(SourceSize >= LZMA_HEADER_SIZE); (void)SourceSize;
|
||||||
|
|
||||||
DecodedSize = GetDecodedSizeOfBuf((UINT8*)Source);
|
DecodedSize = GetDecodedSizeOfBuf((UINT8*)Source);
|
||||||
|
|
||||||
|
3
ffs.h
3
ffs.h
@ -398,6 +398,9 @@ const QByteArray EFI_GUIDED_SECTION_TIANO // A31280AD-481E-41B6-95E8-127F4C98477
|
|||||||
const QByteArray EFI_GUIDED_SECTION_LZMA // EE4E5898-3914-4259-9D6E-DC7BD79403CF
|
const QByteArray EFI_GUIDED_SECTION_LZMA // EE4E5898-3914-4259-9D6E-DC7BD79403CF
|
||||||
("\x98\x58\x4E\xEE\x14\x39\x59\x42\x9D\x6E\xDC\x7B\xD7\x94\x03\xCF", 16);
|
("\x98\x58\x4E\xEE\x14\x39\x59\x42\x9D\x6E\xDC\x7B\xD7\x94\x03\xCF", 16);
|
||||||
|
|
||||||
|
const QByteArray EFI_GUIDED_SECTION_INTEL_SIGNED //0F9D89E8-9259-4F76-A5AF-0C89E34023DF
|
||||||
|
("\xE8\x89\x9D\x0F\x59\x92\x76\x4F\xA5\xAF\x0C\x89\xE3\x40\x23\xDF", 16);
|
||||||
|
|
||||||
// Version section
|
// Version section
|
||||||
typedef struct {
|
typedef struct {
|
||||||
UINT8 Size[3];
|
UINT8 Size[3];
|
||||||
|
@ -1355,6 +1355,7 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
|
|||||||
case EFI_SECTION_GUID_DEFINED:
|
case EFI_SECTION_GUID_DEFINED:
|
||||||
{
|
{
|
||||||
bool parseCurrentSection = true;
|
bool parseCurrentSection = true;
|
||||||
|
bool parseAsIntelSigned = false;
|
||||||
bool msgUnknownGuid = false;
|
bool msgUnknownGuid = false;
|
||||||
bool msgInvalidCrc = false;
|
bool msgInvalidCrc = false;
|
||||||
bool msgUnknownAuth = false;
|
bool msgUnknownAuth = false;
|
||||||
@ -1413,6 +1414,11 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
|
|||||||
else
|
else
|
||||||
info += tr("\nCompression type: unknown");
|
info += tr("\nCompression type: unknown");
|
||||||
}
|
}
|
||||||
|
// Intel signed section
|
||||||
|
else if (QByteArray((const char*)&guidDefinedSectionHeader->SectionDefinitionGuid, sizeof(EFI_GUID)) == EFI_GUIDED_SECTION_INTEL_SIGNED) {
|
||||||
|
parseAsIntelSigned = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Unknown GUIDed section
|
// Unknown GUIDed section
|
||||||
else {
|
else {
|
||||||
msgUnknownGuid = true;
|
msgUnknownGuid = true;
|
||||||
@ -1455,6 +1461,22 @@ UINT8 FfsEngine::parseSection(const QByteArray & section, QModelIndex & index, c
|
|||||||
if (!parseCurrentSection) {
|
if (!parseCurrentSection) {
|
||||||
msg(tr("parseSection: GUID defined section can not be processed"), index);
|
msg(tr("parseSection: GUID defined section can not be processed"), index);
|
||||||
}
|
}
|
||||||
|
else if (parseAsIntelSigned) { // Parse as intel signed sections
|
||||||
|
// Get signature
|
||||||
|
QByteArray signature = body.left(*(UINT32*)body.constData());
|
||||||
|
// Get info for it
|
||||||
|
QString signatureInfo = tr("Size: 0x%1").arg(signature.size(), 8, 16, QChar('0'));
|
||||||
|
// Add it to the tree
|
||||||
|
QModelIndex signatureIndex = model->addItem(Types::Padding, Subtypes::DataPadding, COMPRESSION_ALGORITHM_NONE, tr("Padding"), tr("Intel signature"), signatureInfo, QByteArray(), signature, QByteArray(), index, mode);
|
||||||
|
|
||||||
|
// Get internal lzma section data
|
||||||
|
QByteArray lzmaSection = body.mid(signature.size());
|
||||||
|
// Parse internal section
|
||||||
|
QModelIndex lzmaSectionIndex;
|
||||||
|
result = parseSections(lzmaSection, index);
|
||||||
|
if (result)
|
||||||
|
return result;
|
||||||
|
}
|
||||||
else { // Parse decompressed data
|
else { // Parse decompressed data
|
||||||
result = parseSections(decompressed, index);
|
result = parseSections(decompressed, index);
|
||||||
if (result)
|
if (result)
|
||||||
@ -2678,8 +2700,7 @@ UINT8 FfsEngine::reconstructVolume(const QModelIndex & index, QByteArray & recon
|
|||||||
UINT32 vtfOffset = volumeSize - header.size() - vtf.size();
|
UINT32 vtfOffset = volumeSize - header.size() - vtf.size();
|
||||||
|
|
||||||
if (vtfOffset % 8) {
|
if (vtfOffset % 8) {
|
||||||
msg(tr("reconstructVolume: %1: Wrong size of Volume Top File")
|
msg(tr("reconstructVolume: wrong size of the Volume Top File"), index);
|
||||||
.arg(guidToQString(volumeHeader->FileSystemGuid)), index);
|
|
||||||
return ERR_INVALID_FILE;
|
return ERR_INVALID_FILE;
|
||||||
}
|
}
|
||||||
// Insert pad file to fill the gap
|
// Insert pad file to fill the gap
|
||||||
@ -2696,7 +2717,7 @@ UINT8 FfsEngine::reconstructVolume(const QModelIndex & index, QByteArray & recon
|
|||||||
}
|
}
|
||||||
// No more space left in volume
|
// No more space left in volume
|
||||||
else if (vtfOffset < offset) {
|
else if (vtfOffset < offset) {
|
||||||
msg(tr("reconstructVolume: %1: volume has no free space left").arg(guidToQString(volumeHeader->FileSystemGuid)), index);
|
msg(tr("reconstructVolume: volume has no free space left"), index);
|
||||||
return ERR_INVALID_VOLUME;
|
return ERR_INVALID_VOLUME;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2728,7 +2749,7 @@ UINT8 FfsEngine::reconstructVolume(const QModelIndex & index, QByteArray & recon
|
|||||||
// Root volume can't be grown yet
|
// Root volume can't be grown yet
|
||||||
UINT8 parentType = model->type(index.parent());
|
UINT8 parentType = model->type(index.parent());
|
||||||
if (parentType != Types::File && parentType != Types::Section) {
|
if (parentType != Types::File && parentType != Types::Section) {
|
||||||
msg(tr("reconstructVolume: %1: root volume can't be grown").arg(guidToQString(volumeHeader->FileSystemGuid)), index);
|
msg(tr("reconstructVolume: root volume can't be grown"), index);
|
||||||
return ERR_INVALID_VOLUME;
|
return ERR_INVALID_VOLUME;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2788,7 +2809,7 @@ UINT8 FfsEngine::reconstructFile(const QModelIndex& index, const UINT8 revision,
|
|||||||
|
|
||||||
// Check erase polarity
|
// Check erase polarity
|
||||||
if (erasePolarity == ERASE_POLARITY_UNKNOWN) {
|
if (erasePolarity == ERASE_POLARITY_UNKNOWN) {
|
||||||
msg(tr("reconstructFile: %1, unknown erase polarity").arg(guidToQString(fileHeader->Name)), index);
|
msg(tr("reconstructFile: unknown erase polarity"), index);
|
||||||
return ERR_INVALID_PARAMETER;
|
return ERR_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2803,35 +2824,30 @@ UINT8 FfsEngine::reconstructFile(const QModelIndex& index, const UINT8 revision,
|
|||||||
if (state & EFI_FILE_HEADER_INVALID) {
|
if (state & EFI_FILE_HEADER_INVALID) {
|
||||||
// File marked to have invalid header and must be deleted
|
// File marked to have invalid header and must be deleted
|
||||||
// Do not add anything to queue
|
// Do not add anything to queue
|
||||||
msg(tr("reconstructFile: %1, file is HEADER_INVALID state, and will be removed from reconstructed image")
|
msg(tr("reconstructFile: file is HEADER_INVALID state, and will be removed from reconstructed image"), index);
|
||||||
.arg(guidToQString(fileHeader->Name)), index);
|
|
||||||
return ERR_SUCCESS;
|
return ERR_SUCCESS;
|
||||||
}
|
}
|
||||||
else if (state & EFI_FILE_DELETED) {
|
else if (state & EFI_FILE_DELETED) {
|
||||||
// File marked to have been deleted form and must be deleted
|
// File marked to have been deleted form and must be deleted
|
||||||
// Do not add anything to queue
|
// Do not add anything to queue
|
||||||
msg(tr("reconstructFile: %1, file is in DELETED state, and will be removed from reconstructed image")
|
msg(tr("reconstructFile: file is in DELETED state, and will be removed from reconstructed image"), index);
|
||||||
.arg(guidToQString(fileHeader->Name)), index);
|
|
||||||
return ERR_SUCCESS;
|
return ERR_SUCCESS;
|
||||||
}
|
}
|
||||||
else if (state & EFI_FILE_MARKED_FOR_UPDATE) {
|
else if (state & EFI_FILE_MARKED_FOR_UPDATE) {
|
||||||
// File is marked for update, the mark must be removed
|
// File is marked for update, the mark must be removed
|
||||||
msg(tr("reconstructFile: %1, file MARKED_FOR_UPDATE state cleared")
|
msg(tr("reconstructFile: file's MARKED_FOR_UPDATE state cleared"), index);
|
||||||
.arg(guidToQString(fileHeader->Name)), index);
|
|
||||||
}
|
}
|
||||||
else if (state & EFI_FILE_DATA_VALID) {
|
else if (state & EFI_FILE_DATA_VALID) {
|
||||||
// File is in good condition, reconstruct it
|
// File is in good condition, reconstruct it
|
||||||
}
|
}
|
||||||
else if (state & EFI_FILE_HEADER_VALID) {
|
else if (state & EFI_FILE_HEADER_VALID) {
|
||||||
// Header is valid, but data is not, so file must be deleted
|
// Header is valid, but data is not, so file must be deleted
|
||||||
msg(tr("reconstructFile: %1, file is in HEADER_VALID (but not in DATA_VALID) state, and will be removed from reconstructed image")
|
msg(tr("reconstructFile: file is in HEADER_VALID (but not in DATA_VALID) state, and will be removed from reconstructed image"), index);
|
||||||
.arg(guidToQString(fileHeader->Name)), index);
|
|
||||||
return ERR_SUCCESS;
|
return ERR_SUCCESS;
|
||||||
}
|
}
|
||||||
else if (state & EFI_FILE_HEADER_CONSTRUCTION) {
|
else if (state & EFI_FILE_HEADER_CONSTRUCTION) {
|
||||||
// Header construction not finished, so file must be deleted
|
// Header construction not finished, so file must be deleted
|
||||||
msg(tr("reconstructFile: %1, file is in HEADER_CONSTRUCTION (but not in DATA_VALID) state, and will be removed from reconstructed image")
|
msg(tr("reconstructFile: file is in HEADER_CONSTRUCTION (but not in DATA_VALID) state, and will be removed from reconstructed image"), index);
|
||||||
.arg(guidToQString(fileHeader->Name)), index);
|
|
||||||
return ERR_SUCCESS;
|
return ERR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3020,10 +3036,16 @@ UINT8 FfsEngine::reconstructSection(const QModelIndex& index, const UINT32 base,
|
|||||||
*(UINT32*)(header.data() + sizeof(EFI_GUID_DEFINED_SECTION)) = crc;
|
*(UINT32*)(header.data() + sizeof(EFI_GUID_DEFINED_SECTION)) = crc;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
msg(tr("reconstructSection: %1: GUID defined section authentication info can become invalid")
|
msg(tr("reconstructSection: GUID defined section authentication info can become invalid")
|
||||||
.arg(guidToQString(guidDefinedHeader->SectionDefinitionGuid)), index);
|
.arg(guidToQString(guidDefinedHeader->SectionDefinitionGuid)), index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Check for Intel signed section
|
||||||
|
if (guidDefinedHeader->Attributes & EFI_GUIDED_SECTION_PROCESSING_REQUIRED
|
||||||
|
&& QByteArray((const char*)&guidDefinedHeader->SectionDefinitionGuid, sizeof(EFI_GUID)) == EFI_GUIDED_SECTION_INTEL_SIGNED) {
|
||||||
|
msg(tr("reconstructSection: GUID defined section signature can become invalid")
|
||||||
|
.arg(guidToQString(guidDefinedHeader->SectionDefinitionGuid)), index);
|
||||||
|
}
|
||||||
// Replace new section body
|
// Replace new section body
|
||||||
reconstructed = compressed;
|
reconstructed = compressed;
|
||||||
}
|
}
|
||||||
@ -3131,7 +3153,7 @@ UINT8 FfsEngine::reconstruct(const QModelIndex &index, QByteArray& reconstructed
|
|||||||
return result;
|
return result;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
msg(tr("reconstruct: unknown item type (%1)").arg(model->type(index)), index);
|
msg(tr("reconstruct: unknown item type %1").arg(model->type(index)), index);
|
||||||
return ERR_UNKNOWN_ITEM_TYPE;
|
return ERR_UNKNOWN_ITEM_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
UEFITool::UEFITool(QWidget *parent) :
|
UEFITool::UEFITool(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::UEFITool),
|
ui(new Ui::UEFITool),
|
||||||
version(tr("0.18.10"))
|
version(tr("0.19.0"))
|
||||||
{
|
{
|
||||||
clipboard = QApplication::clipboard();
|
clipboard = QApplication::clipboard();
|
||||||
|
|
||||||
@ -508,6 +508,7 @@ void UEFITool::saveImageFile()
|
|||||||
|
|
||||||
QFile outputFile;
|
QFile outputFile;
|
||||||
outputFile.setFileName(path);
|
outputFile.setFileName(path);
|
||||||
|
|
||||||
if (!outputFile.open(QFile::WriteOnly)) {
|
if (!outputFile.open(QFile::WriteOnly)) {
|
||||||
QMessageBox::critical(this, tr("Image reconstruction failed"), tr("Can't open output file for rewriting"), QMessageBox::Ok);
|
QMessageBox::critical(this, tr("Image reconstruction failed"), tr("Can't open output file for rewriting"), QMessageBox::Ok);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user