mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-25 09:28:22 +08:00
Version 0.16.2
- solved minor bug in section reconstruction - removed some useless and dead code
This commit is contained in:
parent
5789e2f9e6
commit
4edeb4fbef
10
ffs.h
10
ffs.h
@ -99,8 +99,6 @@ const QByteArray EFI_APPLE_BOOT_VOLUME_FILE_SYSTEM_GUID
|
|||||||
const QByteArray EFI_FIRMWARE_FILE_SYSTEM2_GUID
|
const QByteArray EFI_FIRMWARE_FILE_SYSTEM2_GUID
|
||||||
("\x78\xE5\x8C\x8C\x3D\x8A\x1C\x4F\x99\x35\x89\x61\x85\xC3\x2D\xD3", 16);
|
("\x78\xE5\x8C\x8C\x3D\x8A\x1C\x4F\x99\x35\x89\x61\x85\xC3\x2D\xD3", 16);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Firmware volume signature
|
// Firmware volume signature
|
||||||
const QByteArray EFI_FV_SIGNATURE("_FVH", 4);
|
const QByteArray EFI_FV_SIGNATURE("_FVH", 4);
|
||||||
#define EFI_FV_SIGNATURE_OFFSET 0x28
|
#define EFI_FV_SIGNATURE_OFFSET 0x28
|
||||||
@ -216,7 +214,6 @@ typedef struct {
|
|||||||
//UINT8 Data[];
|
//UINT8 Data[];
|
||||||
} EFI_FIRMWARE_VOLUME_EXT_ENTRY_GUID_TYPE;
|
} EFI_FIRMWARE_VOLUME_EXT_ENTRY_GUID_TYPE;
|
||||||
|
|
||||||
|
|
||||||
// Volume header 16bit checksum calculation routine
|
// Volume header 16bit checksum calculation routine
|
||||||
extern UINT16 calculateChecksum16(UINT16* buffer, UINT32 bufferSize);
|
extern UINT16 calculateChecksum16(UINT16* buffer, UINT32 bufferSize);
|
||||||
|
|
||||||
@ -305,13 +302,6 @@ 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);
|
||||||
|
@ -2073,8 +2073,8 @@ out:
|
|||||||
UINT32 offset = 0;
|
UINT32 offset = 0;
|
||||||
QByteArray vtf;
|
QByteArray vtf;
|
||||||
QModelIndex vtfIndex;
|
QModelIndex vtfIndex;
|
||||||
QByteArray amiBeforeVtf;
|
//QByteArray amiBeforeVtf;
|
||||||
QModelIndex amiBeforeVtfIndex;
|
//QModelIndex amiBeforeVtfIndex;
|
||||||
for (int i = 0; i < model->rowCount(index); i++) {
|
for (int i = 0; i < model->rowCount(index); i++) {
|
||||||
// Align to 8 byte boundary
|
// Align to 8 byte boundary
|
||||||
UINT32 alignment = offset % 8;
|
UINT32 alignment = offset % 8;
|
||||||
@ -2101,11 +2101,11 @@ out:
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// AMI file before VTF
|
// AMI file before VTF
|
||||||
if (file.left(sizeof(EFI_GUID)) == EFI_AMI_FFS_FILE_BEFORE_VTF_GUID) {
|
//if (file.left(sizeof(EFI_GUID)) == EFI_AMI_FFS_FILE_BEFORE_VTF_GUID) {
|
||||||
amiBeforeVtf = file;
|
// amiBeforeVtf = file;
|
||||||
amiBeforeVtfIndex = index.child(i, 0);
|
// amiBeforeVtfIndex = index.child(i, 0);
|
||||||
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) {
|
||||||
@ -2146,49 +2146,6 @@ out:
|
|||||||
offset += file.size();
|
offset += file.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert AMI file before VTF to it's correct place
|
|
||||||
if (!amiBeforeVtf.isEmpty()) {
|
|
||||||
// Determine correct offset
|
|
||||||
UINT32 amiOffset = volumeSize - header.size() - amiBeforeVtf.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, volumeHeader->Revision, polarity, pad);
|
|
||||||
if (result)
|
|
||||||
return result;
|
|
||||||
// Append constructed pad file to volume body
|
|
||||||
reconstructed.append(pad);
|
|
||||||
offset = amiOffset;
|
|
||||||
}
|
|
||||||
if (amiOffset < offset) {
|
|
||||||
msg(tr("reconstructVolume: %1: volume has no free space left").arg(guidToQString(volumeHeader->FileSystemGuid)), index);
|
|
||||||
return ERR_INVALID_VOLUME;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reconstruct file again
|
|
||||||
result = reconstructFile(amiBeforeVtfIndex, volumeHeader->Revision, polarity, volumeBase + amiOffset, amiBeforeVtf);
|
|
||||||
if (result)
|
|
||||||
return result;
|
|
||||||
|
|
||||||
// Append AMI file before VTF
|
|
||||||
reconstructed.append(amiBeforeVtf);
|
|
||||||
|
|
||||||
// Change current file offset
|
|
||||||
offset += amiBeforeVtf.size();
|
|
||||||
|
|
||||||
// Align to 8 byte boundary
|
|
||||||
UINT32 alignment = offset % 8;
|
|
||||||
if (alignment) {
|
|
||||||
alignment = 8 - alignment;
|
|
||||||
offset += alignment;
|
|
||||||
reconstructed.append(QByteArray(alignment, empty));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Insert VTF to it's correct place
|
// Insert VTF to it's correct place
|
||||||
if (!vtf.isEmpty()) {
|
if (!vtf.isEmpty()) {
|
||||||
// Determine correct VTF offset
|
// Determine correct VTF offset
|
||||||
@ -2307,9 +2264,6 @@ UINT8 FfsEngine::reconstructFile(const QModelIndex& index, const UINT8 revision,
|
|||||||
return ERR_INVALID_PARAMETER;
|
return ERR_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct empty char for this file
|
|
||||||
char empty = (erasePolarity == ERASE_POLARITY_TRUE ? '\xFF' : '\x00');
|
|
||||||
|
|
||||||
// Check file state
|
// Check file state
|
||||||
// Invert it first if erase polarity is true
|
// Invert it first if erase polarity is true
|
||||||
UINT8 state = fileHeader->State;
|
UINT8 state = fileHeader->State;
|
||||||
@ -2365,7 +2319,7 @@ UINT8 FfsEngine::reconstructFile(const QModelIndex& index, const UINT8 revision,
|
|||||||
if (alignment) {
|
if (alignment) {
|
||||||
alignment = 4 - alignment;
|
alignment = 4 - alignment;
|
||||||
offset += alignment;
|
offset += alignment;
|
||||||
reconstructed.append(QByteArray(alignment, empty));
|
reconstructed.append(QByteArray(alignment, '\x00'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate section base
|
// Calculate section base
|
||||||
|
@ -184,7 +184,6 @@ void UEFITool::insert(const UINT8 mode)
|
|||||||
|
|
||||||
TreeModel* model = ffsEngine->treeModel();
|
TreeModel* model = ffsEngine->treeModel();
|
||||||
UINT8 type;
|
UINT8 type;
|
||||||
UINT8 objectType;
|
|
||||||
|
|
||||||
if (mode == CREATE_MODE_BEFORE || mode == CREATE_MODE_AFTER)
|
if (mode == CREATE_MODE_BEFORE || mode == CREATE_MODE_AFTER)
|
||||||
type = model->type(index.parent());
|
type = model->type(index.parent());
|
||||||
@ -195,12 +194,10 @@ void UEFITool::insert(const UINT8 mode)
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case Volume:
|
case Volume:
|
||||||
path = QFileDialog::getOpenFileName(this, tr("Select FFS file to insert"),".","FFS files (*.ffs *.bin);;All files (*.*)");
|
path = QFileDialog::getOpenFileName(this, tr("Select FFS file to insert"),".","FFS files (*.ffs *.bin);;All files (*.*)");
|
||||||
objectType = File;
|
|
||||||
break;
|
break;
|
||||||
case File:
|
case File:
|
||||||
case Section:
|
case Section:
|
||||||
path = QFileDialog::getOpenFileName(this, tr("Select section file to insert"),".","Section files (*.sct *.bin);;All files (*.*)");
|
path = QFileDialog::getOpenFileName(this, tr("Select section file to insert"),".","Section files (*.sct *.bin);;All files (*.*)");
|
||||||
objectType = Section;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
@ -601,7 +598,6 @@ void UEFITool::readSettings()
|
|||||||
ui->structureTreeView->setColumnWidth(1, settings.value("tree/columnWidth1", ui->structureTreeView->columnWidth(1)).toInt());
|
ui->structureTreeView->setColumnWidth(1, settings.value("tree/columnWidth1", ui->structureTreeView->columnWidth(1)).toInt());
|
||||||
ui->structureTreeView->setColumnWidth(2, settings.value("tree/columnWidth2", ui->structureTreeView->columnWidth(2)).toInt());
|
ui->structureTreeView->setColumnWidth(2, settings.value("tree/columnWidth2", ui->structureTreeView->columnWidth(2)).toInt());
|
||||||
ui->structureTreeView->setColumnWidth(3, settings.value("tree/columnWidth3", ui->structureTreeView->columnWidth(3)).toInt());
|
ui->structureTreeView->setColumnWidth(3, settings.value("tree/columnWidth3", ui->structureTreeView->columnWidth(3)).toInt());
|
||||||
//ui->structureTreeView->setColumnWidth(4, settings.value("tree/columnWidth4", 10).toInt());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UEFITool::writeSettings()
|
void UEFITool::writeSettings()
|
||||||
@ -617,5 +613,4 @@ void UEFITool::writeSettings()
|
|||||||
settings.setValue("tree/columnWidth1", ui->structureTreeView->columnWidth(1));
|
settings.setValue("tree/columnWidth1", ui->structureTreeView->columnWidth(1));
|
||||||
settings.setValue("tree/columnWidth2", ui->structureTreeView->columnWidth(2));
|
settings.setValue("tree/columnWidth2", ui->structureTreeView->columnWidth(2));
|
||||||
settings.setValue("tree/columnWidth3", ui->structureTreeView->columnWidth(3));
|
settings.setValue("tree/columnWidth3", ui->structureTreeView->columnWidth(3));
|
||||||
//settings.setValue("tree/columnWidth4", ui->structureTreeView->columnWidth(4));
|
|
||||||
}
|
}
|
||||||
|
46
uefitool.ui
46
uefitool.ui
@ -20,7 +20,7 @@
|
|||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>UEFITool 0.16.1</string>
|
<string>UEFITool 0.16.2</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralWidget">
|
<widget class="QWidget" name="centralWidget">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -33,7 +33,16 @@
|
|||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="margin">
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
@ -53,7 +62,16 @@
|
|||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="margin">
|
<property name="leftMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
<number>5</number>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
@ -91,7 +109,16 @@
|
|||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="margin">
|
<property name="leftMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
<number>5</number>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
@ -121,7 +148,16 @@
|
|||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="margin">
|
<property name="leftMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
<number>5</number>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
|
Loading…
Reference in New Issue
Block a user