mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-25 17:38:22 +08:00
Version 0.14.1
-solved a serious bug with AMI-specific file displacement after volume modification
This commit is contained in:
parent
41fb0cbbf5
commit
17ee8a445a
10
ffs.h
10
ffs.h
@ -63,7 +63,8 @@ typedef struct {
|
|||||||
} APTIO_CAPSULE_HEADER;
|
} APTIO_CAPSULE_HEADER;
|
||||||
|
|
||||||
// AMI Aptio extended capsule GUID
|
// AMI Aptio extended capsule GUID
|
||||||
const QByteArray APTIO_CAPSULE_GUID("\x8B\xA6\x3C\x4A\x23\x77\xFB\x48\x80\x3D\x57\x8C\xC1\xFE\xC4\x4D", 16);
|
const QByteArray APTIO_CAPSULE_GUID
|
||||||
|
("\x8B\xA6\x3C\x4A\x23\x77\xFB\x48\x80\x3D\x57\x8C\xC1\xFE\xC4\x4D", 16);
|
||||||
|
|
||||||
//*****************************************************************************
|
//*****************************************************************************
|
||||||
// EFI Firmware Volume
|
// EFI Firmware Volume
|
||||||
@ -300,6 +301,13 @@ 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);
|
||||||
|
|
||||||
|
// AMI volume top file
|
||||||
|
// This file must also be located near the end volume, right before VTF
|
||||||
|
const QByteArray EFI_AMI_FFS_FILE_BEFORE_VTF_GUID
|
||||||
|
("\x50\x9F\xE5\xD1\xC3\xE8\x45\x45\xBF\x61\x11\xF0\x02\x23\x3C\x97", 16);
|
||||||
|
// Offset of this file
|
||||||
|
#define EFI_AMI_FFS_FILE_BEFORE_VTF_OFFSET 0xEF0
|
||||||
|
|
||||||
// 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);
|
||||||
|
@ -1929,6 +1929,19 @@ UINT8 FfsEngine::reconstruct(const QModelIndex & index, QQueue<QByteArray> & que
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure that AMI file before VTF is the second latest file of the volume
|
||||||
|
foreach(const QByteArray & child, childrenQueue) {
|
||||||
|
// Check for AMI before VTF file
|
||||||
|
if (child.left(sizeof(EFI_GUID)) == EFI_AMI_FFS_FILE_BEFORE_VTF_GUID) {
|
||||||
|
if(childrenQueue.indexOf(child) + 2 != childrenQueue.length()) {
|
||||||
|
// Remove file and add it to the end of the volume
|
||||||
|
QByteArray amiBeforeVtf = child;
|
||||||
|
childrenQueue.removeAll(child);
|
||||||
|
childrenQueue.insert(--childrenQueue.end(), amiBeforeVtf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get volume size
|
// Get volume size
|
||||||
UINT32 volumeSize;
|
UINT32 volumeSize;
|
||||||
result = getVolumeSize(header, 0, volumeSize);
|
result = getVolumeSize(header, 0, volumeSize);
|
||||||
@ -1951,6 +1964,32 @@ UINT8 FfsEngine::reconstruct(const QModelIndex & index, QQueue<QByteArray> & que
|
|||||||
QByteArray file = childrenQueue.dequeue();
|
QByteArray file = childrenQueue.dequeue();
|
||||||
EFI_FFS_FILE_HEADER* fileHeader = (EFI_FFS_FILE_HEADER*) file.data();
|
EFI_FFS_FILE_HEADER* fileHeader = (EFI_FFS_FILE_HEADER*) file.data();
|
||||||
|
|
||||||
|
// This is the second latest file in the volume
|
||||||
|
if (childrenQueue.count() == 1) {
|
||||||
|
// This file can be AMI file before VTF
|
||||||
|
if (file.left(sizeof(EFI_GUID)) == EFI_AMI_FFS_FILE_BEFORE_VTF_GUID) {
|
||||||
|
// Determine correct offset
|
||||||
|
UINT32 amiOffset = volumeSize - header.size() - file.size() - EFI_AMI_FFS_FILE_BEFORE_VTF_OFFSET;
|
||||||
|
// Insert pad file to fill the gap
|
||||||
|
if (amiOffset > offset) {
|
||||||
|
// Determine pad file size
|
||||||
|
UINT32 size = amiOffset - offset;
|
||||||
|
// Construct pad file
|
||||||
|
QByteArray pad;
|
||||||
|
result = constructPadFile(size, revision, polarity, pad);
|
||||||
|
if (result)
|
||||||
|
return result;
|
||||||
|
// Append constructed pad file to volume body
|
||||||
|
reconstructed.append(pad);
|
||||||
|
offset = amiOffset;
|
||||||
|
}
|
||||||
|
if (amiOffset < offset) {
|
||||||
|
msg(tr("%1: volume has no free space left").arg(guidToQString(volumeHeader->FileSystemGuid)), index);
|
||||||
|
return ERR_INVALID_VOLUME;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check alignment
|
// Check alignment
|
||||||
UINT8 alignmentPower;
|
UINT8 alignmentPower;
|
||||||
UINT32 base;
|
UINT32 base;
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>UEFITool 0.14.0</string>
|
<string>UEFITool 0.14.1</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