mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-25 17:38:22 +08:00
Version 0.17.2
- Pad file GUID are now preserved
This commit is contained in:
parent
dfb307b4aa
commit
f2ad796dc0
4
ffs.h
4
ffs.h
@ -305,6 +305,10 @@ extern const UINT8 ffsAlignmentTable[];
|
|||||||
const QByteArray EFI_FFS_VOLUME_TOP_FILE_GUID
|
const QByteArray EFI_FFS_VOLUME_TOP_FILE_GUID
|
||||||
("\x2E\x06\xA0\x1B\x79\xC7\x82\x45\x85\x66\x33\x6A\xE8\xF7\x8F\x09", 16);
|
("\x2E\x06\xA0\x1B\x79\xC7\x82\x45\x85\x66\x33\x6A\xE8\xF7\x8F\x09", 16);
|
||||||
|
|
||||||
|
// Pad file GUID
|
||||||
|
const QByteArray EFI_FFS_PAD_FILE_GUID
|
||||||
|
("\x85\x65\x53\xE4\x09\x79\x60\x4A\xB5\xC6\xEC\xDE\xA6\xEB\xFB\x54", 16);
|
||||||
|
|
||||||
// FFS size conversion routines
|
// FFS size conversion routines
|
||||||
extern VOID uint32ToUint24(UINT32 size, UINT8* ffsSize);
|
extern VOID uint32ToUint24(UINT32 size, UINT8* ffsSize);
|
||||||
extern UINT32 uint24ToUint32(UINT8* ffsSize);
|
extern UINT32 uint24ToUint32(UINT8* ffsSize);
|
||||||
|
@ -753,7 +753,7 @@ UINT8 FfsEngine::parseVolume(const QByteArray & volume, QModelIndex & index, co
|
|||||||
|
|
||||||
// Check file size to be at least size of EFI_FFS_FILE_HEADER
|
// Check file size to be at least size of EFI_FFS_FILE_HEADER
|
||||||
if (fileSize < sizeof(EFI_FFS_FILE_HEADER)) {
|
if (fileSize < sizeof(EFI_FFS_FILE_HEADER)) {
|
||||||
msg(tr("parseVolume: File with invalid size"), index);
|
msg(tr("parseVolume: FFS file with invalid size"), index);
|
||||||
return ERR_INVALID_FILE;
|
return ERR_INVALID_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -774,7 +774,7 @@ UINT8 FfsEngine::parseVolume(const QByteArray & volume, QModelIndex & index, co
|
|||||||
|
|
||||||
// Check file GUID
|
// Check file GUID
|
||||||
if (fileHeader->Type != EFI_FV_FILETYPE_PAD && files.indexOf(header.left(sizeof(EFI_GUID))) != -1)
|
if (fileHeader->Type != EFI_FV_FILETYPE_PAD && files.indexOf(header.left(sizeof(EFI_GUID))) != -1)
|
||||||
msg(tr("%1: file with duplicate GUID").arg(guidToQString(fileHeader->Name)), index);
|
msg(tr("parseVolume: %1, file with duplicate GUID").arg(guidToQString(fileHeader->Name)), index);
|
||||||
|
|
||||||
// Add file GUID to queue
|
// Add file GUID to queue
|
||||||
files.enqueue(header.left(sizeof(EFI_GUID)));
|
files.enqueue(header.left(sizeof(EFI_GUID)));
|
||||||
@ -783,7 +783,7 @@ UINT8 FfsEngine::parseVolume(const QByteArray & volume, QModelIndex & index, co
|
|||||||
QModelIndex fileIndex;
|
QModelIndex fileIndex;
|
||||||
result = parseFile(file, fileIndex, empty == '\xFF' ? ERASE_POLARITY_TRUE : ERASE_POLARITY_FALSE, index);
|
result = parseFile(file, fileIndex, empty == '\xFF' ? ERASE_POLARITY_TRUE : ERASE_POLARITY_FALSE, index);
|
||||||
if (result)
|
if (result)
|
||||||
msg(tr("parseVolume: Parse FFS file failed (%1)").arg(result), index);
|
msg(tr("parseVolume: FFS file parse failed (%1)").arg(result), index);
|
||||||
|
|
||||||
// Move to next file
|
// Move to next file
|
||||||
fileOffset += fileSize;
|
fileOffset += fileSize;
|
||||||
@ -1826,12 +1826,13 @@ UINT8 FfsEngine::compress(const QByteArray & data, const UINT8 algorithm, QByteA
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Construction routines
|
// Construction routines
|
||||||
UINT8 FfsEngine::constructPadFile(const UINT32 size, const UINT8 revision, const UINT8 erasePolarity, QByteArray & pad)
|
UINT8 FfsEngine::constructPadFile(const QByteArray guid, const UINT32 size, const UINT8 revision, const UINT8 erasePolarity, QByteArray & pad)
|
||||||
{
|
{
|
||||||
if (size < sizeof(EFI_FFS_FILE_HEADER) || erasePolarity == ERASE_POLARITY_UNKNOWN)
|
if (size < sizeof(EFI_FFS_FILE_HEADER) || erasePolarity == ERASE_POLARITY_UNKNOWN)
|
||||||
return ERR_INVALID_PARAMETER;
|
return ERR_INVALID_PARAMETER;
|
||||||
|
|
||||||
pad = QByteArray(size, erasePolarity == ERASE_POLARITY_TRUE ? '\xFF' : '\x00');
|
pad = QByteArray(size - guid.size(), erasePolarity == ERASE_POLARITY_TRUE ? '\xFF' : '\x00');
|
||||||
|
pad.prepend(guid);
|
||||||
EFI_FFS_FILE_HEADER* header = (EFI_FFS_FILE_HEADER*) pad.data();
|
EFI_FFS_FILE_HEADER* header = (EFI_FFS_FILE_HEADER*) pad.data();
|
||||||
uint32ToUint24(size, header->Size);
|
uint32ToUint24(size, header->Size);
|
||||||
header->Attributes = 0x00;
|
header->Attributes = 0x00;
|
||||||
@ -2121,6 +2122,7 @@ out:
|
|||||||
|
|
||||||
// Reconstruct files in volume
|
// Reconstruct files in volume
|
||||||
UINT32 offset = 0;
|
UINT32 offset = 0;
|
||||||
|
QByteArray padFileGuid = EFI_FFS_PAD_FILE_GUID;
|
||||||
QByteArray vtf;
|
QByteArray vtf;
|
||||||
QModelIndex vtfIndex;
|
QModelIndex vtfIndex;
|
||||||
for (int i = 0; i < model->rowCount(index); i++) {
|
for (int i = 0; i < model->rowCount(index); i++) {
|
||||||
@ -2147,8 +2149,10 @@ out:
|
|||||||
EFI_FFS_FILE_HEADER* fileHeader = (EFI_FFS_FILE_HEADER*) file.data();
|
EFI_FFS_FILE_HEADER* fileHeader = (EFI_FFS_FILE_HEADER*) file.data();
|
||||||
|
|
||||||
// Pad file
|
// Pad file
|
||||||
if (fileHeader->Type == EFI_FV_FILETYPE_PAD)
|
if (fileHeader->Type == EFI_FV_FILETYPE_PAD) {
|
||||||
|
padFileGuid = file.left(sizeof(EFI_GUID));
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Volume Top File
|
// Volume Top File
|
||||||
if (file.left(sizeof(EFI_GUID)) == EFI_FFS_VOLUME_TOP_FILE_GUID) {
|
if (file.left(sizeof(EFI_GUID)) == EFI_FFS_VOLUME_TOP_FILE_GUID) {
|
||||||
@ -2174,7 +2178,7 @@ out:
|
|||||||
}
|
}
|
||||||
// Construct pad file
|
// Construct pad file
|
||||||
QByteArray pad;
|
QByteArray pad;
|
||||||
result = constructPadFile(size, volumeHeader->Revision, polarity, pad);
|
result = constructPadFile(padFileGuid, size, volumeHeader->Revision, polarity, pad);
|
||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
// Append constructed pad file to volume body
|
// Append constructed pad file to volume body
|
||||||
@ -2205,7 +2209,7 @@ out:
|
|||||||
UINT32 size = vtfOffset - offset;
|
UINT32 size = vtfOffset - offset;
|
||||||
// Construct pad file
|
// Construct pad file
|
||||||
QByteArray pad;
|
QByteArray pad;
|
||||||
result = constructPadFile(size, volumeHeader->Revision, polarity, pad);
|
result = constructPadFile(padFileGuid, size, volumeHeader->Revision, polarity, pad);
|
||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
// Append constructed pad file to volume body
|
// Append constructed pad file to volume body
|
||||||
|
@ -98,7 +98,7 @@ private:
|
|||||||
UINT8 getSectionSize(const QByteArray & file, const UINT32 sectionOffset, UINT32 & sectionSize);
|
UINT8 getSectionSize(const QByteArray & file, const UINT32 sectionOffset, UINT32 & sectionSize);
|
||||||
|
|
||||||
// Reconstruction helpers
|
// Reconstruction helpers
|
||||||
UINT8 constructPadFile(const UINT32 size, const UINT8 revision, const UINT8 erasePolarity, QByteArray & pad);
|
UINT8 constructPadFile(const QByteArray guid, const UINT32 size, const UINT8 revision, const UINT8 erasePolarity, QByteArray & pad);
|
||||||
UINT8 growVolume(QByteArray & header, const UINT32 size, UINT32 & newSize);
|
UINT8 growVolume(QByteArray & header, const UINT32 size, UINT32 & newSize);
|
||||||
|
|
||||||
// Rebase routines
|
// Rebase routines
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>UEFITool 0.17.1</string>
|
<string>UEFITool 0.17.2</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralWidget">
|
<widget class="QWidget" name="centralWidget">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
Loading…
Reference in New Issue
Block a user