mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-27 02:18:22 +08:00
UT 0.21.2
- fixed a bug with tailed files extraction and replacing (#35) - fixed a bug with wrong source of padding after all Intel image regions (#34)
This commit is contained in:
parent
ed038c21bf
commit
388dd25093
@ -1259,7 +1259,7 @@ UINT8 FfsEngine::parseFile(const QByteArray & file, QModelIndex & index, const U
|
|||||||
.arg(guidToQString(fileHeader->Name))
|
.arg(guidToQString(fileHeader->Name))
|
||||||
.hexarg2(fileHeader->Type, 2)
|
.hexarg2(fileHeader->Type, 2)
|
||||||
.hexarg2(fileHeader->Attributes, 2)
|
.hexarg2(fileHeader->Attributes, 2)
|
||||||
.hexarg(header.size() + body.size()).arg(header.size() + body.size())
|
.hexarg(header.size() + body.size() + tail.size()).arg(header.size() + body.size() + tail.size())
|
||||||
.hexarg(header.size()).arg(header.size())
|
.hexarg(header.size()).arg(header.size())
|
||||||
.hexarg(body.size()).arg(body.size())
|
.hexarg(body.size()).arg(body.size())
|
||||||
.hexarg2(fileHeader->State, 2);
|
.hexarg2(fileHeader->State, 2);
|
||||||
@ -2137,12 +2137,22 @@ UINT8 FfsEngine::create(const QModelIndex & index, const UINT8 type, const QByte
|
|||||||
return ERR_INVALID_FILE;
|
return ERR_INVALID_FILE;
|
||||||
|
|
||||||
QByteArray newHeader = header;
|
QByteArray newHeader = header;
|
||||||
|
QByteArray newBody = body;
|
||||||
EFI_FFS_FILE_HEADER* fileHeader = (EFI_FFS_FILE_HEADER*)newHeader.data();
|
EFI_FFS_FILE_HEADER* fileHeader = (EFI_FFS_FILE_HEADER*)newHeader.data();
|
||||||
|
|
||||||
|
// Check if the file has a tail
|
||||||
|
UINT8 tailSize = fileHeader->Attributes & FFS_ATTRIB_TAIL_PRESENT ? sizeof(UINT16) : 0;
|
||||||
|
if (tailSize) {
|
||||||
|
// Remove the tail, it will then be added back for revision 1 volumes
|
||||||
|
newBody = newBody.left(newBody.size() - tailSize);
|
||||||
|
// Remove the attribute for rev2+ volumes
|
||||||
|
if (revision != 1) {
|
||||||
|
fileHeader->Attributes &= ~(FFS_ATTRIB_TAIL_PRESENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Correct file size
|
// Correct file size
|
||||||
UINT8 tailSize = fileHeader->Attributes & FFS_ATTRIB_TAIL_PRESENT ? sizeof(UINT16) : 0;
|
uint32ToUint24(sizeof(EFI_FFS_FILE_HEADER) + newBody.size() + tailSize, fileHeader->Size);
|
||||||
uint32ToUint24(sizeof(EFI_FFS_FILE_HEADER) + body.size() + tailSize, fileHeader->Size);
|
|
||||||
|
|
||||||
// Recalculate header checksum
|
// Recalculate header checksum
|
||||||
fileHeader->IntegrityCheck.Checksum.Header = 0;
|
fileHeader->IntegrityCheck.Checksum.Header = 0;
|
||||||
@ -2151,17 +2161,17 @@ UINT8 FfsEngine::create(const QModelIndex & index, const UINT8 type, const QByte
|
|||||||
|
|
||||||
// Recalculate data checksum, if needed
|
// Recalculate data checksum, if needed
|
||||||
if (fileHeader->Attributes & FFS_ATTRIB_CHECKSUM)
|
if (fileHeader->Attributes & FFS_ATTRIB_CHECKSUM)
|
||||||
fileHeader->IntegrityCheck.Checksum.File = calculateChecksum8((const UINT8*)body.constData(), body.size());
|
fileHeader->IntegrityCheck.Checksum.File = calculateChecksum8((const UINT8*)newBody.constData(), newBody.size());
|
||||||
else if (revision == 1)
|
else if (revision == 1)
|
||||||
fileHeader->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;
|
fileHeader->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;
|
||||||
else
|
else
|
||||||
fileHeader->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM2;
|
fileHeader->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM2;
|
||||||
|
|
||||||
// Append body
|
// Append new body
|
||||||
created.append(body);
|
created.append(newBody);
|
||||||
|
|
||||||
// Append tail, if needed
|
// Append tail, if needed
|
||||||
if (tailSize) {
|
if (revision ==1 && tailSize) {
|
||||||
UINT8 ht = ~fileHeader->IntegrityCheck.Checksum.Header;
|
UINT8 ht = ~fileHeader->IntegrityCheck.Checksum.Header;
|
||||||
UINT8 ft = ~fileHeader->IntegrityCheck.Checksum.File;
|
UINT8 ft = ~fileHeader->IntegrityCheck.Checksum.File;
|
||||||
created.append(ht).append(ft);
|
created.append(ht).append(ft);
|
||||||
|
@ -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.21.1"))
|
version(tr("0.21.2"))
|
||||||
{
|
{
|
||||||
clipboard = QApplication::clipboard();
|
clipboard = QApplication::clipboard();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user