Add support for x86 recovery startup AP data entries in special padding files

This commit is contained in:
Nikolaj Schlej 2022-09-10 09:56:14 +02:00 committed by Nikolaj Schlej
parent 06653d024b
commit a4a455d0ff
7 changed files with 485 additions and 439 deletions

View File

@ -215,6 +215,7 @@ void UEFITool::populateUi(const QModelIndex &current)
|| type == Types::CpdEntry || type == Types::CpdEntry
|| type == Types::CpdExtension || type == Types::CpdExtension
|| type == Types::CpdSpiEntry || type == Types::CpdSpiEntry
|| type == Types::StartupApDataEntry
); );
ui->menuStoreActions->setEnabled(type == Types::VssStore ui->menuStoreActions->setEnabled(type == Types::VssStore
|| type == Types::Vss2Store || type == Types::Vss2Store
@ -441,7 +442,6 @@ void UEFITool::replaceBody()
void UEFITool::replace(const UINT8 mode) void UEFITool::replace(const UINT8 mode)
{ {
U_UNUSED_PARAMETER(mode); U_UNUSED_PARAMETER(mode);
} }
void UEFITool::extractAsIs() void UEFITool::extractAsIs()
@ -507,7 +507,7 @@ void UEFITool::extract(const UINT8 mode)
if (subtype == Subtypes::PubkeySlicData) path = QFileDialog::getSaveFileName(this, tr("Save SLIC pubkey to file"), name + ".spk", tr("SLIC pubkey files (*.spk *.bin);;All files (*)")); if (subtype == Subtypes::PubkeySlicData) path = QFileDialog::getSaveFileName(this, tr("Save SLIC pubkey to file"), name + ".spk", tr("SLIC pubkey files (*.spk *.bin);;All files (*)"));
else path = QFileDialog::getSaveFileName(this, tr("Save SLIC marker to file"), name + ".smk", tr("SLIC marker files (*.smk *.bin);;All files (*)")); else path = QFileDialog::getSaveFileName(this, tr("Save SLIC marker to file"), name + ".smk", tr("SLIC marker files (*.smk *.bin);;All files (*)"));
break; break;
default: path = QFileDialog::getSaveFileName(this, tr("Save object to file"), name + ".bin", tr("Binary files (*.bin);;All files (*)")); default: path = QFileDialog::getSaveFileName(this, tr("Save object to file"), name + ".bin", tr("Binary files (*.bin);;All files (*)"));
} }
} }
else if (mode == EXTRACT_MODE_BODY || mode == EXTRACT_MODE_BODY_UNCOMPRESSED) { else if (mode == EXTRACT_MODE_BODY || mode == EXTRACT_MODE_BODY_UNCOMPRESSED) {
@ -534,6 +534,7 @@ void UEFITool::extract(const UINT8 mode)
case Types::VssEntry: case Types::VssEntry:
case Types::EvsaEntry: case Types::EvsaEntry:
case Types::FlashMapEntry: case Types::FlashMapEntry:
case Types::StartupApDataEntry:
case Types::FsysEntry: path = QFileDialog::getSaveFileName(this, tr("Save entry body to file"), name + ".bin", tr("Binary files (*.bin);;All files (*)")); break; case Types::FsysEntry: path = QFileDialog::getSaveFileName(this, tr("Save entry body to file"), name + ".bin", tr("Binary files (*.bin);;All files (*)")); break;
case Types::VssStore: case Types::VssStore:
case Types::Vss2Store: case Types::Vss2Store:
@ -547,10 +548,10 @@ void UEFITool::extract(const UINT8 mode)
if (subtype == Subtypes::PubkeySlicData) path = QFileDialog::getSaveFileName(this, tr("Save SLIC pubkey body to file"), name + ".spb", tr("SLIC pubkey body files (*.spb *.bin);;All files (*)")); if (subtype == Subtypes::PubkeySlicData) path = QFileDialog::getSaveFileName(this, tr("Save SLIC pubkey body to file"), name + ".spb", tr("SLIC pubkey body files (*.spb *.bin);;All files (*)"));
else path = QFileDialog::getSaveFileName(this, tr("Save SLIC marker body to file"), name + ".smb", tr("SLIC marker body files (*.smb *.bin);;All files (*)")); else path = QFileDialog::getSaveFileName(this, tr("Save SLIC marker body to file"), name + ".smb", tr("SLIC marker body files (*.smb *.bin);;All files (*)"));
break; break;
default: path = QFileDialog::getSaveFileName(this, tr("Save object to file"), name + ".bin", tr("Binary files (*.bin);;All files (*)")); default: path = QFileDialog::getSaveFileName(this, tr("Save object to file"), name + ".bin", tr("Binary files (*.bin);;All files (*)"));
} }
} }
else path = QFileDialog::getSaveFileName(this, tr("Save object to file"), name + ".bin", tr("Binary files (*.bin);;All files (*)")); else path = QFileDialog::getSaveFileName(this, tr("Save object to file"), name + ".bin", tr("Binary files (*.bin);;All files (*)"));
if (path.trimmed().isEmpty()) if (path.trimmed().isEmpty())
return; return;
@ -578,17 +579,23 @@ void UEFITool::remove()
void UEFITool::about() void UEFITool::about()
{ {
QMessageBox::about(this, tr("About UEFITool"), tr( QMessageBox::about(this, tr("About UEFITool"),
"Copyright (c) 2019, Nikolaj Schlej.<br>" tr("Copyright (c) 2013-2022, Nikolaj Schlej.<br><br>"
"Program icon made by <a href=https://www.behance.net/alzhidkov>Alexander Zhidkov</a>.<br>" "Program icon made by <a href=https://www.behance.net/alzhidkov>Alexander Zhidkov</a>.<br><br>"
"The program uses QHexEdit2 library made by <a href=https://github.com/Simsys/>Simsys</a>.<br>" "GUI uses QHexEdit2 library made by <a href=https://github.com/Simsys>Simsys</a>.<br>"
"Qt-less engine is using Bstrlib made by <a href=https://github.com/websnarf/>Paul Hsieh</a>.<br><br>" "Qt-less engine uses Bstrlib made by <a href=https://github.com/websnarf>Paul Hsieh</a>.<br>"
"The program is dedicated to <b>RevoGirl</b>. Rest in peace, young genius.<br><br>" "Engine uses Tiano compression code made by <a href=https://github.com/tianocore>TianoCore developers</a>.<br>"
"The program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License.<br>" "Engine uses LZMA compression code made by <a href=https://www.7-zip.org/sdk.html>Igor Pavlov</a>.<br>"
"The full text of the license may be found at <a href=http://opensource.org/licenses/bsd-license.php>OpenSource.org</a>.<br><br>" "Engine uses zlib compression code made by <a href=https://github.com/madler>Mark Adler</a>.<br>"
"<b>THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN \"AS IS\" BASIS, " "Engine uses LibTomCrypt hashing code made by <a href=https://github.com/libtom>LibTom developers</a>.<br>"
"WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, " "Engine uses KaitaiStruct runtime made by <a href=https://github.com/kaitai-io>Kaitai team</a>.<br><br>"
"EITHER EXPRESS OR IMPLIED.</b>")); "The program is dedicated to <b>RevoGirl</b>. Rest in peace, young genius.<br><br>"
"The program and the accompanying materials are licensed and made available under the terms and conditions of the BSD-2-Clause License.<br>"
"The full text of the license may be found at <a href=https://opensource.org/licenses/BSD-2-Clause>OpenSource.org</a>.<br><br>"
"<b>THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN \"AS IS\" BASIS, "
"WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, "
"EITHER EXPRESS OR IMPLIED.</b>"
));
} }
void UEFITool::aboutQt() void UEFITool::aboutQt()
@ -801,309 +808,312 @@ void UEFITool::showParserMessages()
#if QT_VERSION_MAJOR < 6 #if QT_VERSION_MAJOR < 6
std::pair<QString, QModelIndex> msg; std::pair<QString, QModelIndex> msg;
foreach (msg, messages) { foreach (msg, messages)
#else #else
for (const auto &msg : messages) { for (const auto &msg : messages)
#endif #endif
QListWidgetItem* item = new QListWidgetItem(msg.first, NULL, 0); {
item->setData(Qt::UserRole, QByteArray((const char*)&msg.second, sizeof(msg.second))); QListWidgetItem* item = new QListWidgetItem(msg.first, NULL, 0);
ui->parserMessagesListWidget->addItem(item); item->setData(Qt::UserRole, QByteArray((const char*)&msg.second, sizeof(msg.second)));
} ui->parserMessagesListWidget->addItem(item);
ui->messagesTabWidget->setCurrentIndex(TAB_PARSER);
ui->parserMessagesListWidget->scrollToBottom();
} }
void UEFITool::showFinderMessages() ui->messagesTabWidget->setCurrentIndex(TAB_PARSER);
ui->parserMessagesListWidget->scrollToBottom();
}
void UEFITool::showFinderMessages()
{
ui->finderMessagesListWidget->clear();
if (!ffsParser)
return;
std::vector<std::pair<QString, QModelIndex> > messages = ffsFinder->getMessages();
#if QT_VERSION_MAJOR < 6
std::pair<QString, QModelIndex> msg;
foreach (msg, messages)
#else
for (const auto &msg : messages)
#endif
{ {
ui->finderMessagesListWidget->clear(); QListWidgetItem* item = new QListWidgetItem(msg.first, NULL, 0);
if (!ffsParser) item->setData(Qt::UserRole, QByteArray((const char*)&msg.second, sizeof(msg.second)));;
return; ui->finderMessagesListWidget->addItem(item);
}
std::vector<std::pair<QString, QModelIndex> > messages = ffsFinder->getMessages(); ui->messagesTabWidget->setTabEnabled(TAB_SEARCH, true);
ui->messagesTabWidget->setCurrentIndex(TAB_SEARCH);
ui->finderMessagesListWidget->scrollToBottom();
}
void UEFITool::showBuilderMessages()
{
ui->builderMessagesListWidget->clear();
if (!ffsBuilder)
return;
std::vector<std::pair<QString, QModelIndex> > messages = ffsBuilder->getMessages();
#if QT_VERSION_MAJOR < 6 #if QT_VERSION_MAJOR < 6
std::pair<QString, QModelIndex> msg; std::pair<QString, QModelIndex> msg;
foreach (msg, messages) { foreach (msg, messages)
#else #else
for (const auto &msg : messages) { for (const auto &msg : messages)
#endif #endif
QListWidgetItem* item = new QListWidgetItem(msg.first, NULL, 0); {
item->setData(Qt::UserRole, QByteArray((const char*)&msg.second, sizeof(msg.second)));; QListWidgetItem* item = new QListWidgetItem(msg.first, NULL, 0);
ui->finderMessagesListWidget->addItem(item); item->setData(Qt::UserRole, QByteArray((const char*)&msg.second, sizeof(msg.second)));
} ui->builderMessagesListWidget->addItem(item);
}
ui->messagesTabWidget->setTabEnabled(TAB_SEARCH, true); ui->messagesTabWidget->setTabEnabled(TAB_BUILDER, true);
ui->messagesTabWidget->setCurrentIndex(TAB_SEARCH); ui->messagesTabWidget->setCurrentIndex(TAB_BUILDER);
ui->finderMessagesListWidget->scrollToBottom(); ui->builderMessagesListWidget->scrollToBottom();
} }
void UEFITool::showBuilderMessages() void UEFITool::scrollTreeView(QListWidgetItem* item)
{ {
ui->builderMessagesListWidget->clear(); QByteArray second = item->data(Qt::UserRole).toByteArray();
if (!ffsBuilder) QModelIndex *index = (QModelIndex *)second.data();
return; if (index && index->isValid()) {
ui->structureTreeView->scrollTo(*index, QAbstractItemView::PositionAtCenter);
ui->structureTreeView->selectionModel()->select(*index, QItemSelectionModel::Select | QItemSelectionModel::Rows | QItemSelectionModel::Clear);
}
}
std::vector<std::pair<QString, QModelIndex> > messages = ffsBuilder->getMessages(); void UEFITool::scrollTreeView(QTableWidgetItem* item)
{
QByteArray second = item->data(Qt::UserRole).toByteArray();
QModelIndex *index = (QModelIndex *)second.data();
if (index && index->isValid()) {
ui->structureTreeView->scrollTo(*index, QAbstractItemView::PositionAtCenter);
ui->structureTreeView->selectionModel()->select(*index, QItemSelectionModel::Select | QItemSelectionModel::Rows | QItemSelectionModel::Clear);
}
}
#if QT_VERSION_MAJOR < 6 void UEFITool::contextMenuEvent(QContextMenuEvent* event)
std::pair<QString, QModelIndex> msg; {
// The checks involving underMouse do not work well enough on macOS, and result in right-click sometimes
foreach (msg, messages) { // not showing any context menu at all. Most likely it is a bug in Qt, which does not affect other systems.
#else // For this reason we reimplement this manually.
for (const auto &msg : messages) { if (ui->parserMessagesListWidget->rect().contains(ui->parserMessagesListWidget->mapFromGlobal(event->globalPos())) ||
#endif ui->finderMessagesListWidget->rect().contains(ui->finderMessagesListWidget->mapFromGlobal(event->globalPos())) ||
QListWidgetItem* item = new QListWidgetItem(msg.first, NULL, 0); ui->builderMessagesListWidget->rect().contains(ui->builderMessagesListWidget->mapFromGlobal(event->globalPos()))) {
item->setData(Qt::UserRole, QByteArray((const char*)&msg.second, sizeof(msg.second))); ui->menuMessageActions->exec(event->globalPos());
ui->builderMessagesListWidget->addItem(item); return;
} }
ui->messagesTabWidget->setTabEnabled(TAB_BUILDER, true);
ui->messagesTabWidget->setCurrentIndex(TAB_BUILDER);
ui->builderMessagesListWidget->scrollToBottom();
}
void UEFITool::scrollTreeView(QListWidgetItem* item)
{
QByteArray second = item->data(Qt::UserRole).toByteArray();
QModelIndex *index = (QModelIndex *)second.data();
if (index && index->isValid()) {
ui->structureTreeView->scrollTo(*index, QAbstractItemView::PositionAtCenter);
ui->structureTreeView->selectionModel()->select(*index, QItemSelectionModel::Select | QItemSelectionModel::Rows | QItemSelectionModel::Clear);
}
}
void UEFITool::scrollTreeView(QTableWidgetItem* item)
{
QByteArray second = item->data(Qt::UserRole).toByteArray();
QModelIndex *index = (QModelIndex *)second.data();
if (index && index->isValid()) {
ui->structureTreeView->scrollTo(*index, QAbstractItemView::PositionAtCenter);
ui->structureTreeView->selectionModel()->select(*index, QItemSelectionModel::Select | QItemSelectionModel::Rows | QItemSelectionModel::Clear);
}
}
void UEFITool::contextMenuEvent(QContextMenuEvent* event)
{
// The checks involving underMouse do not work well enough on macOS, and result in right-click sometimes
// not showing any context menu at all. Most likely it is a bug in Qt, which does not affect other systems.
// For this reason we reimplement this manually.
if (ui->parserMessagesListWidget->rect().contains(ui->parserMessagesListWidget->mapFromGlobal(event->globalPos())) ||
ui->finderMessagesListWidget->rect().contains(ui->finderMessagesListWidget->mapFromGlobal(event->globalPos())) ||
ui->builderMessagesListWidget->rect().contains(ui->builderMessagesListWidget->mapFromGlobal(event->globalPos()))) {
ui->menuMessageActions->exec(event->globalPos());
return;
}
if (!ui->structureTreeView->rect().contains(ui->structureTreeView->mapFromGlobal(event->globalPos()))) if (!ui->structureTreeView->rect().contains(ui->structureTreeView->mapFromGlobal(event->globalPos())))
return; return;
QPoint pt = event->pos(); QPoint pt = event->pos();
QModelIndex index = ui->structureTreeView->indexAt(ui->structureTreeView->viewport()->mapFrom(this, pt)); QModelIndex index = ui->structureTreeView->indexAt(ui->structureTreeView->viewport()->mapFrom(this, pt));
if (!index.isValid()) { if (!index.isValid()) {
return; return;
} }
switch (model->type(index)) switch (model->type(index))
{ {
case Types::Capsule: ui->menuCapsuleActions->exec(event->globalPos()); break; case Types::Capsule: ui->menuCapsuleActions->exec(event->globalPos()); break;
case Types::Image: ui->menuImageActions->exec(event->globalPos()); break; case Types::Image: ui->menuImageActions->exec(event->globalPos()); break;
case Types::Region: ui->menuRegionActions->exec(event->globalPos()); break; case Types::Region: ui->menuRegionActions->exec(event->globalPos()); break;
case Types::Padding: ui->menuPaddingActions->exec(event->globalPos()); break; case Types::Padding: ui->menuPaddingActions->exec(event->globalPos()); break;
case Types::Volume: ui->menuVolumeActions->exec(event->globalPos()); break; case Types::Volume: ui->menuVolumeActions->exec(event->globalPos()); break;
case Types::File: ui->menuFileActions->exec(event->globalPos()); break; case Types::File: ui->menuFileActions->exec(event->globalPos()); break;
case Types::Section: ui->menuSectionActions->exec(event->globalPos()); break; case Types::Section: ui->menuSectionActions->exec(event->globalPos()); break;
case Types::VssStore: case Types::VssStore:
case Types::Vss2Store: case Types::Vss2Store:
case Types::FdcStore: case Types::FdcStore:
case Types::FsysStore: case Types::FsysStore:
case Types::EvsaStore: case Types::EvsaStore:
case Types::FtwStore: case Types::FtwStore:
case Types::FlashMapStore: case Types::FlashMapStore:
case Types::CmdbStore: case Types::CmdbStore:
case Types::FptStore: case Types::FptStore:
case Types::CpdStore: case Types::CpdStore:
case Types::BpdtStore: ui->menuStoreActions->exec(event->globalPos()); break; case Types::BpdtStore: ui->menuStoreActions->exec(event->globalPos()); break;
case Types::FreeSpace: break; // No menu needed for FreeSpace item case Types::FreeSpace: break; // No menu needed for FreeSpace item
default: ui->menuEntryActions->exec(event->globalPos()); break; default: ui->menuEntryActions->exec(event->globalPos()); break;
} }
} }
void UEFITool::readSettings() void UEFITool::readSettings()
{ {
QSettings settings(this); QSettings settings(this);
restoreGeometry(settings.value("mainWindow/geometry").toByteArray()); restoreGeometry(settings.value("mainWindow/geometry").toByteArray());
restoreState(settings.value("mainWindow/windowState").toByteArray()); restoreState(settings.value("mainWindow/windowState").toByteArray());
QList<int> horList, vertList; QList<int> horList, vertList;
horList.append(settings.value("mainWindow/treeWidth", 600).toInt()); horList.append(settings.value("mainWindow/treeWidth", 600).toInt());
horList.append(settings.value("mainWindow/infoWidth", 180).toInt()); horList.append(settings.value("mainWindow/infoWidth", 180).toInt());
vertList.append(settings.value("mainWindow/treeHeight", 400).toInt()); vertList.append(settings.value("mainWindow/treeHeight", 400).toInt());
vertList.append(settings.value("mainWindow/messageHeight", 180).toInt()); vertList.append(settings.value("mainWindow/messageHeight", 180).toInt());
ui->infoSplitter->setSizes(horList); ui->infoSplitter->setSizes(horList);
ui->messagesSplitter->setSizes(vertList); ui->messagesSplitter->setSizes(vertList);
ui->structureTreeView->setColumnWidth(0, settings.value("tree/columnWidth0", ui->structureTreeView->columnWidth(0)).toInt()); ui->structureTreeView->setColumnWidth(0, settings.value("tree/columnWidth0", ui->structureTreeView->columnWidth(0)).toInt());
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());
markingEnabled = settings.value("tree/markingEnabled", true).toBool(); markingEnabled = settings.value("tree/markingEnabled", true).toBool();
ui->actionToggleBootGuardMarking->setChecked(markingEnabled); ui->actionToggleBootGuardMarking->setChecked(markingEnabled);
// Set monospace font for some controls // Set monospace font for some controls
QString fontName; QString fontName;
int fontSize; int fontSize;
#if defined Q_OS_OSX #if defined Q_OS_OSX
fontName = settings.value("mainWindow/fontName", QString("Menlo")).toString(); fontName = settings.value("mainWindow/fontName", QString("Menlo")).toString();
fontSize = settings.value("mainWindow/fontSize", 10).toInt(); fontSize = settings.value("mainWindow/fontSize", 10).toInt();
#elif defined Q_OS_WIN #elif defined Q_OS_WIN
fontName = settings.value("mainWindow/fontName", QString("Consolas")).toString(); fontName = settings.value("mainWindow/fontName", QString("Consolas")).toString();
fontSize = settings.value("mainWindow/fontSize", 9).toInt(); fontSize = settings.value("mainWindow/fontSize", 9).toInt();
#else #else
fontName = settings.value("mainWindow/fontName", QString("Courier New")).toString(); fontName = settings.value("mainWindow/fontName", QString("Courier New")).toString();
fontSize = settings.value("mainWindow/fontSize", 10).toInt(); fontSize = settings.value("mainWindow/fontSize", 10).toInt();
#endif #endif
currentFont = QFont(fontName, fontSize); currentFont = QFont(fontName, fontSize);
ui->infoEdit->setFont(currentFont); ui->infoEdit->setFont(currentFont);
ui->parserMessagesListWidget->setFont(currentFont); ui->parserMessagesListWidget->setFont(currentFont);
ui->finderMessagesListWidget->setFont(currentFont); ui->finderMessagesListWidget->setFont(currentFont);
ui->builderMessagesListWidget->setFont(currentFont); ui->builderMessagesListWidget->setFont(currentFont);
ui->fitTableWidget->setFont(currentFont); ui->fitTableWidget->setFont(currentFont);
ui->securityEdit->setFont(currentFont); ui->securityEdit->setFont(currentFont);
ui->structureTreeView->setFont(currentFont); ui->structureTreeView->setFont(currentFont);
searchDialog->ui->guidEdit->setFont(currentFont); searchDialog->ui->guidEdit->setFont(currentFont);
searchDialog->ui->hexEdit->setFont(currentFont); searchDialog->ui->hexEdit->setFont(currentFont);
hexViewDialog->setFont(currentFont); hexViewDialog->setFont(currentFont);
goToAddressDialog->ui->hexSpinBox->setFont(currentFont); goToAddressDialog->ui->hexSpinBox->setFont(currentFont);
goToBaseDialog->ui->hexSpinBox->setFont(currentFont); goToBaseDialog->ui->hexSpinBox->setFont(currentFont);
} }
void UEFITool::writeSettings() void UEFITool::writeSettings()
{ {
QSettings settings(this); QSettings settings(this);
settings.setValue("mainWindow/geometry", saveGeometry()); settings.setValue("mainWindow/geometry", saveGeometry());
settings.setValue("mainWindow/windowState", saveState()); settings.setValue("mainWindow/windowState", saveState());
settings.setValue("mainWindow/treeWidth", ui->structureGroupBox->width()); settings.setValue("mainWindow/treeWidth", ui->structureGroupBox->width());
settings.setValue("mainWindow/infoWidth", ui->infoGroupBox->width()); settings.setValue("mainWindow/infoWidth", ui->infoGroupBox->width());
settings.setValue("mainWindow/treeHeight", ui->structureGroupBox->height()); settings.setValue("mainWindow/treeHeight", ui->structureGroupBox->height());
settings.setValue("mainWindow/messageHeight", ui->messagesTabWidget->height()); settings.setValue("mainWindow/messageHeight", ui->messagesTabWidget->height());
settings.setValue("tree/columnWidth0", ui->structureTreeView->columnWidth(0)); settings.setValue("tree/columnWidth0", ui->structureTreeView->columnWidth(0));
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/markingEnabled", markingEnabled); settings.setValue("tree/markingEnabled", markingEnabled);
settings.setValue("mainWindow/fontName", currentFont.family()); settings.setValue("mainWindow/fontName", currentFont.family());
settings.setValue("mainWindow/fontSize", currentFont.pointSize()); settings.setValue("mainWindow/fontSize", currentFont.pointSize());
} }
void UEFITool::showFitTable() void UEFITool::showFitTable()
{ {
std::vector<std::pair<std::vector<UString>, UModelIndex> > fitTable = ffsParser->getFitTable(); std::vector<std::pair<std::vector<UString>, UModelIndex> > fitTable = ffsParser->getFitTable();
if (fitTable.empty()) { if (fitTable.empty()) {
// Disable FIT tab // Disable FIT tab
ui->messagesTabWidget->setTabEnabled(TAB_FIT, false); ui->messagesTabWidget->setTabEnabled(TAB_FIT, false);
return; return;
} }
// Enable FIT tab // Enable FIT tab
ui->messagesTabWidget->setTabEnabled(TAB_FIT, true); ui->messagesTabWidget->setTabEnabled(TAB_FIT, true);
// Set up the FIT table // Set up the FIT table
ui->fitTableWidget->clear(); ui->fitTableWidget->clear();
ui->fitTableWidget->setRowCount((int)fitTable.size()); ui->fitTableWidget->setRowCount((int)fitTable.size());
ui->fitTableWidget->setColumnCount(6); ui->fitTableWidget->setColumnCount(6);
ui->fitTableWidget->setHorizontalHeaderLabels(QStringList() << tr("Address") << tr("Size") << tr("Version") << tr("Checksum") << tr("Type") << tr("Information")); ui->fitTableWidget->setHorizontalHeaderLabels(QStringList() << tr("Address") << tr("Size") << tr("Version") << tr("Checksum") << tr("Type") << tr("Information"));
ui->fitTableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); ui->fitTableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui->fitTableWidget->setSelectionBehavior(QAbstractItemView::SelectRows); ui->fitTableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->fitTableWidget->setSelectionMode(QAbstractItemView::SingleSelection); ui->fitTableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
ui->fitTableWidget->horizontalHeader()->setStretchLastSection(true); ui->fitTableWidget->horizontalHeader()->setStretchLastSection(true);
// Add all data to the table widget // Add all data to the table widget
for (size_t i = 0; i < fitTable.size(); i++) { for (size_t i = 0; i < fitTable.size(); i++) {
for (UINT8 j = 0; j < 6; j++) { for (UINT8 j = 0; j < 6; j++) {
QTableWidgetItem* item = new QTableWidgetItem(fitTable[i].first[j]); QTableWidgetItem* item = new QTableWidgetItem(fitTable[i].first[j]);
item->setData(Qt::UserRole, QByteArray((const char*)&fitTable[i].second, sizeof(fitTable[i].second))); item->setData(Qt::UserRole, QByteArray((const char*)&fitTable[i].second, sizeof(fitTable[i].second)));
ui->fitTableWidget->setItem((int)i, j, item); ui->fitTableWidget->setItem((int)i, j, item);
} }
} }
ui->fitTableWidget->resizeColumnsToContents(); ui->fitTableWidget->resizeColumnsToContents();
ui->fitTableWidget->resizeRowsToContents(); ui->fitTableWidget->resizeRowsToContents();
ui->messagesTabWidget->setCurrentIndex(TAB_FIT); ui->messagesTabWidget->setCurrentIndex(TAB_FIT);
} }
void UEFITool::showSecurityInfo() void UEFITool::showSecurityInfo()
{ {
// Get security info // Get security info
UString secInfo = ffsParser->getSecurityInfo(); UString secInfo = ffsParser->getSecurityInfo();
if (secInfo.isEmpty()) { if (secInfo.isEmpty()) {
ui->messagesTabWidget->setTabEnabled(TAB_SECURITY, false); ui->messagesTabWidget->setTabEnabled(TAB_SECURITY, false);
return; return;
} }
ui->messagesTabWidget->setTabEnabled(TAB_SECURITY, true); ui->messagesTabWidget->setTabEnabled(TAB_SECURITY, true);
ui->securityEdit->setPlainText(secInfo); ui->securityEdit->setPlainText(secInfo);
ui->messagesTabWidget->setCurrentIndex(TAB_SECURITY); ui->messagesTabWidget->setCurrentIndex(TAB_SECURITY);
} }
void UEFITool::currentTabChanged(int index) void UEFITool::currentTabChanged(int index)
{ {
U_UNUSED_PARAMETER(index); U_UNUSED_PARAMETER(index);
ui->menuMessageActions->setEnabled(false); ui->menuMessageActions->setEnabled(false);
ui->actionMessagesCopy->setEnabled(false); ui->actionMessagesCopy->setEnabled(false);
ui->actionMessagesCopyAll->setEnabled(false); ui->actionMessagesCopyAll->setEnabled(false);
ui->actionMessagesClear->setEnabled(false); ui->actionMessagesClear->setEnabled(false);
} }
void UEFITool::loadGuidDatabase() void UEFITool::loadGuidDatabase()
{ {
QString path = QFileDialog::getOpenFileName(this, tr("Select GUID database file to load"), currentDir, tr("Comma-separated values files (*.csv);;All files (*)")); QString path = QFileDialog::getOpenFileName(this, tr("Select GUID database file to load"), currentDir, tr("Comma-separated values files (*.csv);;All files (*)"));
if (!path.isEmpty()) { if (!path.isEmpty()) {
initGuidDatabase(path); initGuidDatabase(path);
if (!currentPath.isEmpty() && QMessageBox::Yes == QMessageBox::information(this, tr("New GUID database loaded"), tr("Apply new GUID database on the opened file?\nUnsaved changes and tree position will be lost."), QMessageBox::Yes, QMessageBox::No)) if (!currentPath.isEmpty() && QMessageBox::Yes == QMessageBox::information(this, tr("New GUID database loaded"), tr("Apply new GUID database on the opened file?\nUnsaved changes and tree position will be lost."), QMessageBox::Yes, QMessageBox::No))
openImageFile(currentPath); openImageFile(currentPath);
} }
} }
void UEFITool::unloadGuidDatabase() void UEFITool::unloadGuidDatabase()
{ {
initGuidDatabase(); initGuidDatabase();
if (!currentPath.isEmpty() && QMessageBox::Yes == QMessageBox::information(this, tr("GUID database unloaded"), tr("Apply changes on the opened file?\nUnsaved changes and tree position will be lost."), QMessageBox::Yes, QMessageBox::No)) if (!currentPath.isEmpty() && QMessageBox::Yes == QMessageBox::information(this, tr("GUID database unloaded"), tr("Apply changes on the opened file?\nUnsaved changes and tree position will be lost."), QMessageBox::Yes, QMessageBox::No))
openImageFile(currentPath); openImageFile(currentPath);
} }
void UEFITool::loadDefaultGuidDatabase() void UEFITool::loadDefaultGuidDatabase()
{ {
initGuidDatabase(":/guids.csv"); initGuidDatabase(":/guids.csv");
if (!currentPath.isEmpty() && QMessageBox::Yes == QMessageBox::information(this, tr("Default GUID database loaded"), tr("Apply default GUID database on the opened file?\nUnsaved changes and tree position will be lost."), QMessageBox::Yes, QMessageBox::No)) if (!currentPath.isEmpty() && QMessageBox::Yes == QMessageBox::information(this, tr("Default GUID database loaded"), tr("Apply default GUID database on the opened file?\nUnsaved changes and tree position will be lost."), QMessageBox::Yes, QMessageBox::No))
openImageFile(currentPath); openImageFile(currentPath);
} }
void UEFITool::exportDiscoveredGuids() void UEFITool::exportDiscoveredGuids()
{ {
GuidDatabase db = guidDatabaseFromTreeRecursive(model, model->index(0, 0)); GuidDatabase db = guidDatabaseFromTreeRecursive(model, model->index(0, 0));
if (!db.empty()) { if (!db.empty()) {
QString path = QFileDialog::getSaveFileName(this, tr("Save parsed GUIDs to database"), currentPath + ".guids.csv", tr("Comma-separated values files (*.csv);;All files (*)")); QString path = QFileDialog::getSaveFileName(this, tr("Save parsed GUIDs to database"), currentPath + ".guids.csv", tr("Comma-separated values files (*.csv);;All files (*)"));
if (!path.isEmpty()) if (!path.isEmpty())
guidDatabaseExportToFile(path, db); guidDatabaseExportToFile(path, db);
} }
} }
void UEFITool::generateReport() void UEFITool::generateReport()
{ {
QString path = QFileDialog::getSaveFileName(this, tr("Save report to text file"), currentPath + ".report.txt", tr("Text files (*.txt);;All files (*)")); QString path = QFileDialog::getSaveFileName(this, tr("Save report to text file"), currentPath + ".report.txt", tr("Text files (*.txt);;All files (*)"));
if (!path.isEmpty()) { if (!path.isEmpty()) {
std::vector<QString> report = ffsReport->generate(); std::vector<QString> report = ffsReport->generate();
if (report.size()) { if (report.size()) {
QFile file; QFile file;
file.setFileName(path); file.setFileName(path);
if (file.open(QFile::Text | QFile::WriteOnly)) { if (file.open(QFile::Text | QFile::WriteOnly)) {
for (size_t i = 0; i < report.size(); i++) { for (size_t i = 0; i < report.size(); i++) {
file.write(report[i].toLatin1().append('\n')); file.write(report[i].toLatin1().append('\n'));
}
file.close();
}
}
} }
file.close();
} }
}
}
}

View File

@ -72,7 +72,7 @@ extern const UByteArray EFI_DXE_APRIORI_FILE_GUID // FC510EE7-FFDC-11D4-BD41-008
// Volume top file // Volume top file
extern const UByteArray EFI_FFS_VOLUME_TOP_FILE_GUID // 1BA0062E-C779-4582-8566-336AE8F78F09 extern const UByteArray EFI_FFS_VOLUME_TOP_FILE_GUID // 1BA0062E-C779-4582-8566-336AE8F78F09
("\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 // Padding file GUID
extern const UByteArray EFI_FFS_PAD_FILE_GUID // E4536585-7909-4A60-B5C6-ECDEA6EBFB5 extern const UByteArray EFI_FFS_PAD_FILE_GUID // E4536585-7909-4A60-B5C6-ECDEA6EBFB5
("\x85\x65\x53\xE4\x09\x79\x60\x4A\xB5\xC6\xEC\xDE\xA6\xEB\xFB\x54", 16); ("\x85\x65\x53\xE4\x09\x79\x60\x4A\xB5\xC6\xEC\xDE\xA6\xEB\xFB\x54", 16);
// AMI DXE core file // AMI DXE core file
@ -125,6 +125,9 @@ const UINT8 ffsAlignmentTable[] =
const UINT8 ffsAlignment2Table[] = const UINT8 ffsAlignment2Table[] =
{ 17, 18, 19, 20, 21, 22, 23, 24 }; { 17, 18, 19, 20, 21, 22, 23, 24 };
extern const UByteArray RECOVERY_STARTUP_AP_DATA_X86_128K // jmp far F000:FFD0, EAD0FF00F0
("\xEA\xD0\xFF\x00\xF0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x27\x2D", RECOVERY_STARTUP_AP_DATA_X86_SIZE);
VOID uint32ToUint24(UINT32 size, UINT8* ffsSize) VOID uint32ToUint24(UINT32 size, UINT8* ffsSize)
{ {
ffsSize[2] = (UINT8)((size) >> 16U); ffsSize[2] = (UINT8)((size) >> 16U);

View File

@ -348,7 +348,7 @@ extern const UByteArray EFI_DXE_APRIORI_FILE_GUID; // FC510EE7-FFDC-11D4-BD41-00
// Volume top file // Volume top file
extern const UByteArray EFI_FFS_VOLUME_TOP_FILE_GUID; // 1BA0062E-C779-4582-8566-336AE8F78F09 extern const UByteArray EFI_FFS_VOLUME_TOP_FILE_GUID; // 1BA0062E-C779-4582-8566-336AE8F78F09
// AMI pad file GUID // AMI padding file GUID
extern const UByteArray EFI_FFS_PAD_FILE_GUID; // E4536585-7909-4A60-B5C6-ECDEA6EBFB5 extern const UByteArray EFI_FFS_PAD_FILE_GUID; // E4536585-7909-4A60-B5C6-ECDEA6EBFB5
// AMI DXE core file // AMI DXE core file
@ -530,6 +530,13 @@ typedef struct POSTCODE_SECTION_ {
/// ///
#define EFI_DEP_SOR 0x09 #define EFI_DEP_SOR 0x09
//*****************************************************************************
// X86 Startup AP Data
//*****************************************************************************
#define RECOVERY_STARTUP_AP_DATA_X86_SIZE 0x10
extern const UByteArray RECOVERY_STARTUP_AP_DATA_X86_64K;
extern const UByteArray RECOVERY_STARTUP_AP_DATA_X86_128K;
//***************************************************************************** //*****************************************************************************
// X86 Reset Vector Data // X86 Reset Vector Data
//***************************************************************************** //*****************************************************************************

View File

@ -1368,7 +1368,8 @@ USTATUS FfsParser::findNextRawAreaItem(const UModelIndex & index, const UINT32 l
nextItemOffset = offset - EFI_FV_SIGNATURE_OFFSET; nextItemOffset = offset - EFI_FV_SIGNATURE_OFFSET;
break; break;
} }
else if (readUnaligned(currentPos) == BPDT_GREEN_SIGNATURE || readUnaligned(currentPos) == BPDT_YELLOW_SIGNATURE) { else if (readUnaligned(currentPos) == BPDT_GREEN_SIGNATURE
|| readUnaligned(currentPos) == BPDT_YELLOW_SIGNATURE) {
// Check data size // Check data size
if (restSize < sizeof(BPDT_HEADER)) if (restSize < sizeof(BPDT_HEADER))
continue; continue;
@ -1548,8 +1549,8 @@ USTATUS FfsParser::parseVolumeBody(const UModelIndex & index)
// We aren't at the end of empty space // We aren't at the end of empty space
// Check that the remaining space can still have a file in it // Check that the remaining space can still have a file in it
if (volumeBodySize - fileOffset < sizeof(EFI_FFS_FILE_HEADER) || // Remaining space is smaller than the smallest possible file if (volumeBodySize - fileOffset < sizeof(EFI_FFS_FILE_HEADER) // Remaining space is smaller than the smallest possible file
volumeBodySize - fileOffset < fileSize) { // Remaining space is smaller than non-empty file size || volumeBodySize - fileOffset < fileSize) { // Remaining space is smaller than non-empty file size
// Parse non-UEFI data // Parse non-UEFI data
parseVolumeNonUefiData(volumeBody.mid(fileOffset), volumeHeaderSize + fileOffset, index); parseVolumeNonUefiData(volumeBody.mid(fileOffset), volumeHeaderSize + fileOffset, index);
@ -1573,8 +1574,9 @@ USTATUS FfsParser::parseVolumeBody(const UModelIndex & index)
for (int i = 0; i < model->rowCount(index); i++) { for (int i = 0; i < model->rowCount(index); i++) {
UModelIndex current = index.model()->index(i, 0, index); UModelIndex current = index.model()->index(i, 0, index);
// Skip non-file entries and pad files // Skip non-file entries and padding files
if (model->type(current) != Types::File || model->subtype(current) == EFI_FV_FILETYPE_PAD) { if (model->type(current) != Types::File
|| model->subtype(current) == EFI_FV_FILETYPE_PAD) {
continue; continue;
} }
@ -1755,7 +1757,7 @@ USTATUS FfsParser::parseFileHeader(const UByteArray & file, const UINT32 localOf
if (fileHeader->Type != EFI_FV_FILETYPE_PAD) { if (fileHeader->Type != EFI_FV_FILETYPE_PAD) {
name = guidToUString(fileHeader->Name); name = guidToUString(fileHeader->Name);
} else { } else {
name = UString("Pad-file"); name = UString("Padding file");
} }
info = UString("File GUID: ") + guidToUString(fileHeader->Name, false) + info = UString("File GUID: ") + guidToUString(fileHeader->Name, false) +
@ -1864,7 +1866,7 @@ USTATUS FfsParser::parseFileBody(const UModelIndex & index)
if (model->type(index) != Types::File) if (model->type(index) != Types::File)
return U_SUCCESS; return U_SUCCESS;
// Parse pad-file body // Parse padding file body
if (model->subtype(index) == EFI_FV_FILETYPE_PAD) if (model->subtype(index) == EFI_FV_FILETYPE_PAD)
return parsePadFileBody(index); return parsePadFileBody(index);
@ -1915,7 +1917,7 @@ USTATUS FfsParser::parsePadFileBody(const UModelIndex & index)
emptyByte = pdata->emptyByte; emptyByte = pdata->emptyByte;
} }
// Check if the while PAD file is empty // Check if the while padding file is empty
if (body.size() == body.count(emptyByte)) if (body.size() == body.count(emptyByte))
return U_SUCCESS; return U_SUCCESS;
@ -1950,20 +1952,39 @@ USTATUS FfsParser::parsePadFileBody(const UModelIndex & index)
// ... and all bytes after as a padding // ... and all bytes after as a padding
UByteArray padding = body.mid(nonEmptyByteOffset); UByteArray padding = body.mid(nonEmptyByteOffset);
// Get info // Check for that data to be recovery startup AP data for x86
UString info = usprintf("Full size: %Xh (%u)", (UINT32)padding.size(), (UINT32)padding.size()); // https://github.com/tianocore/edk2/blob/stable/202011/BaseTools/Source/C/GenFv/GenFvInternalLib.c#L106
if (padding.left(RECOVERY_STARTUP_AP_DATA_X86_SIZE) == RECOVERY_STARTUP_AP_DATA_X86_128K) {
// Get info
UString info = usprintf("Full size: %Xh (%u)", (UINT32)padding.size(), (UINT32)padding.size());
// Add tree item // Add tree item
UModelIndex dataIndex = model->addItem(headerSize + nonEmptyByteOffset, Types::Padding, Subtypes::DataPadding, UString("Non-UEFI data"), UString(), info, UByteArray(), padding, UByteArray(), Fixed, index); (void)model->addItem(headerSize + nonEmptyByteOffset, Types::StartupApDataEntry, Subtypes::x86128kStartupApDataEntry, UString("Startup AP data"), UString(), info, UByteArray(), padding, UByteArray(), Fixed, index);
// Show message // Rename the file
msg(usprintf("%s: non-UEFI data found in pad-file", __FUNCTION__), dataIndex); model->setName(index, UString("Startup AP data padding file"));
// Rename the file // Do not parse contents
model->setName(index, UString("Non-empty pad-file")); return U_SUCCESS;
}
else { // Not a data array
// Get info
UString info = usprintf("Full size: %Xh (%u)", (UINT32)padding.size(), (UINT32)padding.size());
// Parse contents as RAW area // Add tree item
return parseRawArea(dataIndex); UModelIndex dataIndex = model->addItem(headerSize + nonEmptyByteOffset, Types::Padding, Subtypes::DataPadding, UString("Non-UEFI data"), UString(), info, UByteArray(), padding, UByteArray(), Fixed, index);
// Show message
msg(usprintf("%s: non-UEFI data found in padding file", __FUNCTION__), dataIndex);
// Rename the file
model->setName(index, UString("Non-empty padding file"));
// Do not parse contents
return U_SUCCESS;
}
return U_SUCCESS;
} }
USTATUS FfsParser::parseSections(const UByteArray & sections, const UModelIndex & index, const bool insertIntoTree) USTATUS FfsParser::parseSections(const UByteArray & sections, const UModelIndex & index, const bool insertIntoTree)

View File

@ -42,44 +42,44 @@ UString regionTypeToUString(const UINT8 type)
UString itemTypeToUString(const UINT8 type) UString itemTypeToUString(const UINT8 type)
{ {
switch (type) { switch (type) {
case Types::Root: return UString("Root"); case Types::Root: return UString("Root");
case Types::Image: return UString("Image"); case Types::Image: return UString("Image");
case Types::Capsule: return UString("Capsule"); case Types::Capsule: return UString("Capsule");
case Types::Region: return UString("Region"); case Types::Region: return UString("Region");
case Types::Volume: return UString("Volume"); case Types::Volume: return UString("Volume");
case Types::Padding: return UString("Padding"); case Types::Padding: return UString("Padding");
case Types::File: return UString("File"); case Types::File: return UString("File");
case Types::Section: return UString("Section"); case Types::Section: return UString("Section");
case Types::FreeSpace: return UString("Free space"); case Types::FreeSpace: return UString("Free space");
case Types::VssStore: return UString("VSS store"); case Types::VssStore: return UString("VSS store");
case Types::Vss2Store: return UString("VSS2 store"); case Types::Vss2Store: return UString("VSS2 store");
case Types::FtwStore: return UString("FTW store"); case Types::FtwStore: return UString("FTW store");
case Types::FdcStore: return UString("FDC store"); case Types::FdcStore: return UString("FDC store");
case Types::FsysStore: return UString("Fsys store"); case Types::FsysStore: return UString("Fsys store");
case Types::EvsaStore: return UString("EVSA store"); case Types::EvsaStore: return UString("EVSA store");
case Types::CmdbStore: return UString("CMDB store"); case Types::CmdbStore: return UString("CMDB store");
case Types::FlashMapStore: return UString("FlashMap store"); case Types::FlashMapStore: return UString("FlashMap store");
case Types::NvarEntry: return UString("NVAR entry"); case Types::NvarEntry: return UString("NVAR entry");
case Types::VssEntry: return UString("VSS entry"); case Types::VssEntry: return UString("VSS entry");
case Types::FsysEntry: return UString("Fsys entry"); case Types::FsysEntry: return UString("Fsys entry");
case Types::EvsaEntry: return UString("EVSA entry"); case Types::EvsaEntry: return UString("EVSA entry");
case Types::FlashMapEntry: return UString("FlashMap entry"); case Types::FlashMapEntry: return UString("FlashMap entry");
case Types::Microcode: return UString("Microcode"); case Types::Microcode: return UString("Microcode");
case Types::SlicData: return UString("SLIC data"); case Types::SlicData: return UString("SLIC data");
// ME-specific case Types::FptStore: return UString("FPT store");
case Types::FptStore: return UString("FPT store"); case Types::FptEntry: return UString("FPT entry");
case Types::FptEntry: return UString("FPT entry"); case Types::IfwiHeader: return UString("IFWI header");
case Types::IfwiHeader: return UString("IFWI header"); case Types::IfwiPartition: return UString("IFWI partition");
case Types::IfwiPartition: return UString("IFWI partition"); case Types::FptPartition: return UString("FPT partition");
case Types::FptPartition: return UString("FPT partition"); case Types::BpdtStore: return UString("BPDT store");
case Types::BpdtStore: return UString("BPDT store"); case Types::BpdtEntry: return UString("BPDT entry");
case Types::BpdtEntry: return UString("BPDT entry"); case Types::BpdtPartition: return UString("BPDT partition");
case Types::BpdtPartition: return UString("BPDT partition"); case Types::CpdStore: return UString("CPD store");
case Types::CpdStore: return UString("CPD store"); case Types::CpdEntry: return UString("CPD entry");
case Types::CpdEntry: return UString("CPD entry"); case Types::CpdPartition: return UString("CPD partition");
case Types::CpdPartition: return UString("CPD partition"); case Types::CpdExtension: return UString("CPD extension");
case Types::CpdExtension: return UString("CPD extension"); case Types::CpdSpiEntry: return UString("CPD SPI entry");
case Types::CpdSpiEntry: return UString("CPD SPI entry"); case Types::StartupApDataEntry: return UString("Startup AP data");
} }
return usprintf("Unknown %02Xh", type); return usprintf("Unknown %02Xh", type);
@ -89,82 +89,83 @@ UString itemSubtypeToUString(const UINT8 type, const UINT8 subtype)
{ {
switch (type) { switch (type) {
case Types::Image: case Types::Image:
if (subtype == Subtypes::IntelImage) return UString("Intel"); if (subtype == Subtypes::IntelImage) return UString("Intel");
if (subtype == Subtypes::UefiImage) return UString("UEFI"); else if (subtype == Subtypes::UefiImage) return UString("UEFI");
break; break;
case Types::Padding: case Types::Padding:
if (subtype == Subtypes::ZeroPadding) return UString("Empty (0x00)"); if (subtype == Subtypes::ZeroPadding) return UString("Empty (0x00)");
if (subtype == Subtypes::OnePadding) return UString("Empty (0xFF)"); else if (subtype == Subtypes::OnePadding) return UString("Empty (0xFF)");
if (subtype == Subtypes::DataPadding) return UString("Non-empty"); else if (subtype == Subtypes::DataPadding) return UString("Non-empty");
break; break;
case Types::Volume: case Types::Volume:
if (subtype == Subtypes::UnknownVolume) return UString("Unknown"); if (subtype == Subtypes::UnknownVolume) return UString("Unknown");
if (subtype == Subtypes::Ffs2Volume) return UString("FFSv2"); else if (subtype == Subtypes::Ffs2Volume) return UString("FFSv2");
if (subtype == Subtypes::Ffs3Volume) return UString("FFSv3"); else if (subtype == Subtypes::Ffs3Volume) return UString("FFSv3");
if (subtype == Subtypes::NvramVolume) return UString("NVRAM"); else if (subtype == Subtypes::NvramVolume) return UString("NVRAM");
if (subtype == Subtypes::MicrocodeVolume) return UString("Microcode"); else if (subtype == Subtypes::MicrocodeVolume) return UString("Microcode");
break; break;
case Types::Capsule: case Types::Capsule:
if (subtype == Subtypes::AptioSignedCapsule) return UString("Aptio signed"); if (subtype == Subtypes::AptioSignedCapsule) return UString("Aptio signed");
if (subtype == Subtypes::AptioUnsignedCapsule) return UString("Aptio unsigned"); else if (subtype == Subtypes::AptioUnsignedCapsule) return UString("Aptio unsigned");
if (subtype == Subtypes::UefiCapsule) return UString("UEFI 2.0"); else if (subtype == Subtypes::UefiCapsule) return UString("UEFI 2.0");
if (subtype == Subtypes::ToshibaCapsule) return UString("Toshiba"); else if (subtype == Subtypes::ToshibaCapsule) return UString("Toshiba");
break; break;
case Types::Region: return regionTypeToUString(subtype); case Types::Region: return regionTypeToUString(subtype);
case Types::File: return fileTypeToUString(subtype); case Types::File: return fileTypeToUString(subtype);
case Types::Section: return sectionTypeToUString(subtype); case Types::Section: return sectionTypeToUString(subtype);
case Types::NvarEntry: case Types::NvarEntry:
if (subtype == Subtypes::InvalidNvarEntry) return UString("Invalid"); if (subtype == Subtypes::InvalidNvarEntry) return UString("Invalid");
if (subtype == Subtypes::InvalidLinkNvarEntry) return UString("Invalid link"); else if (subtype == Subtypes::InvalidLinkNvarEntry) return UString("Invalid link");
if (subtype == Subtypes::LinkNvarEntry) return UString("Link"); else if (subtype == Subtypes::LinkNvarEntry) return UString("Link");
if (subtype == Subtypes::DataNvarEntry) return UString("Data"); else if (subtype == Subtypes::DataNvarEntry) return UString("Data");
if (subtype == Subtypes::FullNvarEntry) return UString("Full"); else if (subtype == Subtypes::FullNvarEntry) return UString("Full");
break; break;
case Types::VssEntry: case Types::VssEntry:
if (subtype == Subtypes::InvalidVssEntry) return UString("Invalid"); if (subtype == Subtypes::InvalidVssEntry) return UString("Invalid");
if (subtype == Subtypes::StandardVssEntry) return UString("Standard"); else if (subtype == Subtypes::StandardVssEntry) return UString("Standard");
if (subtype == Subtypes::AppleVssEntry) return UString("Apple"); else if (subtype == Subtypes::AppleVssEntry) return UString("Apple");
if (subtype == Subtypes::AuthVssEntry) return UString("Auth"); else if (subtype == Subtypes::AuthVssEntry) return UString("Auth");
if (subtype == Subtypes::IntelVssEntry) return UString("Intel"); else if (subtype == Subtypes::IntelVssEntry) return UString("Intel");
break; break;
case Types::FsysEntry: case Types::FsysEntry:
if (subtype == Subtypes::InvalidFsysEntry) return UString("Invalid"); if (subtype == Subtypes::InvalidFsysEntry) return UString("Invalid");
if (subtype == Subtypes::NormalFsysEntry) return UString("Normal"); else if (subtype == Subtypes::NormalFsysEntry) return UString("Normal");
break; break;
case Types::EvsaEntry: case Types::EvsaEntry:
if (subtype == Subtypes::InvalidEvsaEntry) return UString("Invalid"); if (subtype == Subtypes::InvalidEvsaEntry) return UString("Invalid");
if (subtype == Subtypes::UnknownEvsaEntry) return UString("Unknown"); else if (subtype == Subtypes::UnknownEvsaEntry) return UString("Unknown");
if (subtype == Subtypes::GuidEvsaEntry) return UString("GUID"); else if (subtype == Subtypes::GuidEvsaEntry) return UString("GUID");
if (subtype == Subtypes::NameEvsaEntry) return UString("Name"); else if (subtype == Subtypes::NameEvsaEntry) return UString("Name");
if (subtype == Subtypes::DataEvsaEntry) return UString("Data"); else if (subtype == Subtypes::DataEvsaEntry) return UString("Data");
break; break;
case Types::FlashMapEntry: case Types::FlashMapEntry:
if (subtype == Subtypes::VolumeFlashMapEntry) return UString("Volume"); if (subtype == Subtypes::VolumeFlashMapEntry) return UString("Volume");
if (subtype == Subtypes::DataFlashMapEntry) return UString("Data"); else if (subtype == Subtypes::DataFlashMapEntry) return UString("Data");
break; break;
case Types::Microcode: case Types::Microcode:
if (subtype == Subtypes::IntelMicrocode) return UString("Intel"); if (subtype == Subtypes::IntelMicrocode) return UString("Intel");
if (subtype == Subtypes::AmdMicrocode) return UString("AMD"); else if (subtype == Subtypes::AmdMicrocode) return UString("AMD");
break; break;
// ME-specific
case Types::FptEntry: case Types::FptEntry:
if (subtype == Subtypes::ValidFptEntry) return UString("Valid"); if (subtype == Subtypes::ValidFptEntry) return UString("Valid");
if (subtype == Subtypes::InvalidFptEntry) return UString("Invalid"); else if (subtype == Subtypes::InvalidFptEntry) return UString("Invalid");
break; break;
case Types::FptPartition: case Types::FptPartition:
if (subtype == Subtypes::CodeFptPartition) return UString("Code"); if (subtype == Subtypes::CodeFptPartition) return UString("Code");
if (subtype == Subtypes::DataFptPartition) return UString("Data"); else if (subtype == Subtypes::DataFptPartition) return UString("Data");
if (subtype == Subtypes::GlutFptPartition) return UString("GLUT"); else if (subtype == Subtypes::GlutFptPartition) return UString("GLUT");
break; break;
case Types::IfwiPartition: case Types::IfwiPartition:
if (subtype == Subtypes::BootIfwiPartition) return UString("Boot"); if (subtype == Subtypes::BootIfwiPartition) return UString("Boot");
if (subtype == Subtypes::DataIfwiPartition) return UString("Data"); else if (subtype == Subtypes::DataIfwiPartition) return UString("Data");
break; break;
case Types::CpdPartition: case Types::CpdPartition:
if (subtype == Subtypes::ManifestCpdPartition) return UString("Manifest"); if (subtype == Subtypes::ManifestCpdPartition) return UString("Manifest");
if (subtype == Subtypes::MetadataCpdPartition) return UString("Metadata"); else if (subtype == Subtypes::MetadataCpdPartition) return UString("Metadata");
if (subtype == Subtypes::KeyCpdPartition) return UString("Key"); else if (subtype == Subtypes::KeyCpdPartition) return UString("Key");
if (subtype == Subtypes::CodeCpdPartition) return UString("Code"); else if (subtype == Subtypes::CodeCpdPartition) return UString("Code");
case Types::StartupApDataEntry:
if (subtype == Subtypes::x86128kStartupApDataEntry) return UString("X86 128K");
break; break;
} }

View File

@ -27,7 +27,7 @@ namespace Actions
Replace, Replace,
Remove, Remove,
Rebuild, Rebuild,
Rebase Rebase,
}; };
} }
@ -58,7 +58,6 @@ namespace Types {
FlashMapEntry, FlashMapEntry,
Microcode, Microcode,
SlicData, SlicData,
// ME-specific
IfwiHeader, IfwiHeader,
IfwiPartition, IfwiPartition,
FptStore, FptStore,
@ -71,21 +70,22 @@ namespace Types {
CpdEntry, CpdEntry,
CpdPartition, CpdPartition,
CpdExtension, CpdExtension,
CpdSpiEntry CpdSpiEntry,
StartupApDataEntry,
}; };
} }
namespace Subtypes { namespace Subtypes {
enum ImageSubtypes{ enum ImageSubtypes{
IntelImage = 90, IntelImage = 90,
UefiImage UefiImage,
}; };
enum CapsuleSubtypes { enum CapsuleSubtypes {
AptioSignedCapsule = 100, AptioSignedCapsule = 100,
AptioUnsignedCapsule, AptioUnsignedCapsule,
UefiCapsule, UefiCapsule,
ToshibaCapsule ToshibaCapsule,
}; };
enum VolumeSubtypes { enum VolumeSubtypes {
@ -93,7 +93,7 @@ namespace Subtypes {
Ffs2Volume, Ffs2Volume,
Ffs3Volume, Ffs3Volume,
NvramVolume, NvramVolume,
MicrocodeVolume MicrocodeVolume,
}; };
enum RegionSubtypes { enum RegionSubtypes {
@ -112,13 +112,13 @@ namespace Subtypes {
Tgbe2Region, Tgbe2Region,
Reserved1Region, Reserved1Region,
Reserved2Region, Reserved2Region,
PttRegion PttRegion,
}; };
enum PaddingSubtypes { enum PaddingSubtypes {
ZeroPadding = 120, ZeroPadding = 120,
OnePadding, OnePadding,
DataPadding DataPadding,
}; };
enum NvarEntrySubtypes { enum NvarEntrySubtypes {
@ -126,7 +126,7 @@ namespace Subtypes {
InvalidLinkNvarEntry, InvalidLinkNvarEntry,
LinkNvarEntry, LinkNvarEntry,
DataNvarEntry, DataNvarEntry,
FullNvarEntry FullNvarEntry,
}; };
enum VssEntrySubtypes { enum VssEntrySubtypes {
@ -134,12 +134,12 @@ namespace Subtypes {
StandardVssEntry, StandardVssEntry,
AppleVssEntry, AppleVssEntry,
AuthVssEntry, AuthVssEntry,
IntelVssEntry IntelVssEntry,
}; };
enum FsysEntrySubtypes { enum FsysEntrySubtypes {
InvalidFsysEntry = 150, InvalidFsysEntry = 150,
NormalFsysEntry NormalFsysEntry,
}; };
enum EvsaEntrySubtypes { enum EvsaEntrySubtypes {
@ -152,41 +152,45 @@ namespace Subtypes {
enum FlashMapEntrySubtypes { enum FlashMapEntrySubtypes {
VolumeFlashMapEntry = 170, VolumeFlashMapEntry = 170,
DataFlashMapEntry DataFlashMapEntry,
}; };
enum MicrocodeSubtypes { enum MicrocodeSubtypes {
IntelMicrocode = 180, IntelMicrocode = 180,
AmdMicrocode AmdMicrocode,
}; };
enum SlicDataSubtypes { enum SlicDataSubtypes {
PubkeySlicData = 190, PubkeySlicData = 190,
MarkerSlicData MarkerSlicData,
}; };
// ME-specific // ME-specific
enum IfwiPartitionSubtypes { enum IfwiPartitionSubtypes {
DataIfwiPartition = 200, DataIfwiPartition = 200,
BootIfwiPartition BootIfwiPartition,
}; };
enum FptEntrySubtypes { enum FptEntrySubtypes {
ValidFptEntry = 210, ValidFptEntry = 210,
InvalidFptEntry InvalidFptEntry,
}; };
enum FptPartitionSubtypes { enum FptPartitionSubtypes {
CodeFptPartition = 220, CodeFptPartition = 220,
DataFptPartition, DataFptPartition,
GlutFptPartition GlutFptPartition,
}; };
enum CpdPartitionSubtypes { enum CpdPartitionSubtypes {
ManifestCpdPartition = 230, ManifestCpdPartition = 230,
MetadataCpdPartition, MetadataCpdPartition,
KeyCpdPartition, KeyCpdPartition,
CodeCpdPartition CodeCpdPartition,
};
enum StartupApDataEntrySubtypes {
x86128kStartupApDataEntry = 240,
}; };
} }

View File

@ -67,7 +67,7 @@ UString uniqueItemName(const UModelIndex & index)
{ {
// Sanity check // Sanity check
if (!index.isValid()) if (!index.isValid())
return UString("Invalid_index"); return UString("InvalidIndex");
// Get model from index // Get model from index
const TreeModel* model = (const TreeModel*)index.model(); const TreeModel* model = (const TreeModel*)index.model();