NE Alpha 35

This commit is contained in:
Cr4sh 2016-11-03 02:40:38 +07:00
parent 52c7a56f68
commit 4160a6a580
24 changed files with 477 additions and 94 deletions

View File

@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "uefidump.h" #include "uefidump.h"
#include "../common/ffs.h" #include "../common/ffs.h"
#include "../common/utility.h"
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
@ -77,17 +78,18 @@ USTATUS UEFIDumper::dump(const UByteArray & buffer, const UString & inPath, cons
} }
// Show FIT table // Show FIT table
std::vector<std::vector<UString> > fitTable = ffsParser.getFitTable(); std::vector<std::pair<std::vector<UString>, UModelIndex > > fitTable = ffsParser.getFitTable();
if (fitTable.size()) { if (fitTable.size()) {
std::cout << "-------------------------------------------------------------------" << std::endl; std::cout << "-------------------------------------------------------------------------" << std::endl;
std::cout << " Address | Size | Ver | CS | Type " << std::endl; std::cout << " Address | Size | Ver | CS | Type / Info " << std::endl;
std::cout << "-------------------------------------------------------------------" << std::endl; std::cout << "-------------------------------------------------------------------------" << std::endl;
for (size_t i = 0; i < fitTable.size(); i++) { for (size_t i = 0; i < fitTable.size(); i++) {
std::cout << (const char*)fitTable[i][0].toLocal8Bit() << " | " std::cout << (const char*)fitTable[i].first[0].toLocal8Bit() << " | "
<< (const char*)fitTable[i][1].toLocal8Bit() << " | " << (const char*)fitTable[i].first[1].toLocal8Bit() << " | "
<< (const char*)fitTable[i][2].toLocal8Bit() << " | " << (const char*)fitTable[i].first[2].toLocal8Bit() << " | "
<< (const char*)fitTable[i][3].toLocal8Bit() << " | " << (const char*)fitTable[i].first[3].toLocal8Bit() << " | "
<< (const char*)fitTable[i][4].toLocal8Bit() << std::endl; << (const char*)fitTable[i].first[4].toLocal8Bit() << " | "
<< (const char*)fitTable[i].first[5].toLocal8Bit() << std::endl;
} }
} }

View File

@ -29,7 +29,7 @@ int main(int argc, char *argv[])
return (uefidumper.dump(buffer, UString(argv[1])) != U_SUCCESS); return (uefidumper.dump(buffer, UString(argv[1])) != U_SUCCESS);
} }
std::cout << "UEFIDump 0.1.2" << std::endl << std::endl std::cout << "UEFIDump 0.1.3" << std::endl << std::endl
<< "Usage: UEFIDump imagefile" << std::endl; << "Usage: UEFIDump imagefile" << std::endl;
return 0; return 0;
} }

View File

@ -61,17 +61,18 @@ int main(int argc, char *argv[])
} }
// Get last VTF // Get last VTF
std::vector<std::vector<QString> > fitTable = ffsParser.getFitTable(); std::vector<std::pair<std::vector<QString>, QModelIndex > > fitTable = ffsParser.getFitTable();
if (fitTable.size()) { if (fitTable.size()) {
std::cout << "-------------------------------------------------------------------" << std::endl; std::cout << "---------------------------------------------------------------------------" << std::endl;
std::cout << " Address | Size | Ver | CS | Type " << std::endl; std::cout << " Address | Size | Ver | CS | Type / Info " << std::endl;
std::cout << "-------------------------------------------------------------------" << std::endl; std::cout << "---------------------------------------------------------------------------" << std::endl;
for (size_t i = 0; i < fitTable.size(); i++) { for (size_t i = 0; i < fitTable.size(); i++) {
std::cout << fitTable[i][0].toLatin1().constData() << " | " std::cout << fitTable[i].first[0].toLatin1().constData() << " | "
<< fitTable[i][1].toLatin1().constData() << " | " << fitTable[i].first[1].toLatin1().constData() << " | "
<< fitTable[i][2].toLatin1().constData() << " | " << fitTable[i].first[2].toLatin1().constData() << " | "
<< fitTable[i][3].toLatin1().constData() << " | " << fitTable[i].first[3].toLatin1().constData() << " | "
<< fitTable[i][4].toLatin1().constData() << std::endl; << fitTable[i].first[4].toLatin1().constData() << " | "
<< fitTable[i].first[5].toLatin1().constData() << std::endl;
} }
} }
@ -120,7 +121,7 @@ int main(int argc, char *argv[])
} }
} }
// If parameters are different, show version and usage information // If parameters are different, show version and usage information
std::cout << "UEFIExtract 0.13.1" << std::endl << std::endl std::cout << "UEFIExtract 0.13.2" << std::endl << std::endl
<< "Usage: UEFIExtract imagefile - generate report and dump only leaf tree items into .dump folder." << std::endl << "Usage: UEFIExtract imagefile - generate report and dump only leaf tree items into .dump folder." << std::endl
<< " UEFIExtract imagefile all - generate report and dump all tree items." << std::endl << " UEFIExtract imagefile all - generate report and dump all tree items." << std::endl
<< " UEFIExtract imagefile dump - only generate dump, no report needed." << std::endl << " UEFIExtract imagefile dump - only generate dump, no report needed." << std::endl

View File

@ -70,7 +70,7 @@ USTATUS UEFIFind::find(const UINT8 mode, const bool count, const QString & hexPa
return U_SUCCESS; return U_SUCCESS;
} }
for (std::set<std::pair<QModelIndex, QModelIndex> >::const_iterator citer = files.cbegin(); citer != files.cend(); ++citer) { for (std::set<std::pair<QModelIndex, QModelIndex> >::const_iterator citer = files.begin(); citer != files.end(); ++citer) {
QByteArray data(16, '\x00'); QByteArray data(16, '\x00');
std::pair<QModelIndex, QModelIndex> indexes = *citer; std::pair<QModelIndex, QModelIndex> indexes = *citer;
if (!model->hasEmptyHeader(indexes.first)) if (!model->hasEmptyHeader(indexes.first))

View File

@ -14,6 +14,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#ifndef UEFIFIND_H #ifndef UEFIFIND_H
#define UEFIFIND_H #define UEFIFIND_H
#include <iterator>
#include <set> #include <set>
#include <QObject> #include <QObject>

View File

@ -0,0 +1,23 @@
#ifndef GOTOOFFSETDIALOG_H
#define GOTOOFFSETDIALOG_H
#include <QObject>
#include <QDialog>
#include "ui_gotooffsetdialog.h"
class GoToOffsetDialog : public QDialog
{
Q_OBJECT
public:
GoToOffsetDialog(QWidget* parent = NULL):
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint),
ui(new Ui::GoToOffsetDialog) {
ui->setupUi(this);
}
~GoToOffsetDialog() {delete ui;}
Ui::GoToOffsetDialog* ui;
};
#endif // GOTOOFFSETDIALOG_H

View File

@ -0,0 +1,138 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GoToOffsetDialog</class>
<widget class="QDialog" name="GoToOffsetDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>204</width>
<height>70</height>
</rect>
</property>
<property name="windowTitle">
<string>Go to offset</string>
</property>
<property name="modal">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>5</number>
</property>
<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>
</property>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>5</number>
</property>
<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>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Select tree item at:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="hexSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="suffix">
<string/>
</property>
<property name="prefix">
<string>0x</string>
</property>
<property name="maximum">
<number>1000000000</number>
</property>
<property name="displayIntegerBase">
<number>16</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>GoToOffsetDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>182</x>
<y>185</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>194</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>GoToOffsetDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>182</x>
<y>185</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>194</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -14,7 +14,7 @@
#include "searchdialog.h" #include "searchdialog.h"
SearchDialog::SearchDialog(QWidget *parent) : SearchDialog::SearchDialog(QWidget *parent) :
QDialog(parent), QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint),
ui(new Ui::SearchDialog), ui(new Ui::SearchDialog),
hexValidator(QRegExp("([0-9a-fA-F\\. ])*")), hexValidator(QRegExp("([0-9a-fA-F\\. ])*")),
guidValidator(QRegExp("[0-9a-fA-F\\.]{8}-[0-9a-fA-F\\.]{4}-[0-9a-fA-F\\.]{4}-[0-9a-fA-F\\.]{4}-[0-9a-fA-F\\.]{12}")) guidValidator(QRegExp("[0-9a-fA-F\\.]{8}-[0-9a-fA-F\\.]{4}-[0-9a-fA-F\\.]{4}-[0-9a-fA-F\\.]{4}-[0-9a-fA-F\\.]{12}"))

View File

@ -14,10 +14,11 @@
#include "uefitool.h" #include "uefitool.h"
#include "ui_uefitool.h" #include "ui_uefitool.h"
UEFITool::UEFITool(QWidget *parent) : UEFITool::UEFITool(QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
ui(new Ui::UEFITool), ui(new Ui::UEFITool),
version(tr("NE Alpha34")) version(tr("NE Alpha35"))
{ {
clipboard = QApplication::clipboard(); clipboard = QApplication::clipboard();
@ -25,6 +26,7 @@ version(tr("NE Alpha34"))
ui->setupUi(this); ui->setupUi(this);
searchDialog = new SearchDialog(this); searchDialog = new SearchDialog(this);
hexViewDialog = new HexViewDialog(this); hexViewDialog = new HexViewDialog(this);
goToOffsetDialog = new GoToOffsetDialog(this);
model = NULL; model = NULL;
ffsParser = NULL; ffsParser = NULL;
ffsFinder = NULL; ffsFinder = NULL;
@ -54,6 +56,7 @@ version(tr("NE Alpha34"))
connect(ui->actionAboutQt, SIGNAL(triggered()), this, SLOT(aboutQt())); connect(ui->actionAboutQt, SIGNAL(triggered()), this, SLOT(aboutQt()));
connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(exit())); connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(exit()));
connect(ui->actionGoToData, SIGNAL(triggered()), this, SLOT(goToData())); connect(ui->actionGoToData, SIGNAL(triggered()), this, SLOT(goToData()));
connect(ui->actionGoToOffset, SIGNAL(triggered()), this, SLOT(goToOffset()));
connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(writeSettings())); connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(writeSettings()));
// Enable Drag-and-Drop actions // Enable Drag-and-Drop actions
@ -78,6 +81,7 @@ version(tr("NE Alpha34"))
searchDialog->ui->guidEdit->setFont(font); searchDialog->ui->guidEdit->setFont(font);
searchDialog->ui->hexEdit->setFont(font); searchDialog->ui->hexEdit->setFont(font);
hexViewDialog->setFont(font); hexViewDialog->setFont(font);
goToOffsetDialog->ui->hexSpinBox->setFont(font);
// Initialize non-persistent data // Initialize non-persistent data
init(); init();
@ -113,18 +117,18 @@ void UEFITool::init()
setWindowTitle(tr("UEFITool %1").arg(version)); setWindowTitle(tr("UEFITool %1").arg(version));
// Disable menus // Disable menus
ui->menuCapsuleActions->setDisabled(true); ui->actionSearch->setEnabled(false);
ui->menuImageActions->setDisabled(true); ui->actionGoToOffset->setEnabled(false);
ui->menuRegionActions->setDisabled(true); ui->menuCapsuleActions->setEnabled(false);
ui->menuPaddingActions->setDisabled(true); ui->menuImageActions->setEnabled(false);
ui->menuVolumeActions->setDisabled(true); ui->menuRegionActions->setEnabled(false);
ui->menuFileActions->setDisabled(true); ui->menuPaddingActions->setEnabled(false);
ui->menuSectionActions->setDisabled(true); ui->menuVolumeActions->setEnabled(false);
ui->menuStoreActions->setDisabled(true); ui->menuFileActions->setEnabled(false);
ui->menuVariableActions->setDisabled(true); ui->menuSectionActions->setEnabled(false);
ui->menuStoreActions->setEnabled(false);
ui->actionMessagesCopy->setDisabled(true); ui->menuVariableActions->setEnabled(false);
ui->actionMessagesCopyAll->setDisabled(true); ui->menuMessageActions->setEnabled(false);
// Create new model ... // Create new model ...
delete model; delete model;
@ -137,12 +141,24 @@ void UEFITool::init()
// Connect // Connect
connect(ui->structureTreeView->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), connect(ui->structureTreeView->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
this, SLOT(populateUi(const QModelIndex &))); this, SLOT(populateUi(const QModelIndex &)));
connect(ui->structureTreeView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
this, SLOT(populateUi(const QItemSelection &)));
connect(ui->parserMessagesListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(scrollTreeView(QListWidgetItem*))); connect(ui->parserMessagesListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(scrollTreeView(QListWidgetItem*)));
connect(ui->parserMessagesListWidget, SIGNAL(itemEntered(QListWidgetItem*)), this, SLOT(enableMessagesCopyActions(QListWidgetItem*))); connect(ui->parserMessagesListWidget, SIGNAL(itemEntered(QListWidgetItem*)), this, SLOT(enableMessagesCopyActions(QListWidgetItem*)));
connect(ui->finderMessagesListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(scrollTreeView(QListWidgetItem*))); connect(ui->finderMessagesListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(scrollTreeView(QListWidgetItem*)));
connect(ui->finderMessagesListWidget, SIGNAL(itemEntered(QListWidgetItem*)), this, SLOT(enableMessagesCopyActions(QListWidgetItem*))); connect(ui->finderMessagesListWidget, SIGNAL(itemEntered(QListWidgetItem*)), this, SLOT(enableMessagesCopyActions(QListWidgetItem*)));
connect(ui->builderMessagesListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(scrollTreeView(QListWidgetItem*))); connect(ui->builderMessagesListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(scrollTreeView(QListWidgetItem*)));
connect(ui->builderMessagesListWidget, SIGNAL(itemEntered(QListWidgetItem*)), this, SLOT(enableMessagesCopyActions(QListWidgetItem*))); connect(ui->builderMessagesListWidget, SIGNAL(itemEntered(QListWidgetItem*)), this, SLOT(enableMessagesCopyActions(QListWidgetItem*)));
connect(ui->fitTableWidget, SIGNAL(itemDoubleClicked(QTableWidgetItem*)), this, SLOT(scrollTreeView(QTableWidgetItem*)));
connect(ui->messagesTabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int)));
}
void UEFITool::populateUi(const QItemSelection &selected)
{
if (selected.isEmpty())
return;
populateUi(selected.indexes().at(0));
} }
void UEFITool::populateUi(const QModelIndex &current) void UEFITool::populateUi(const QModelIndex &current)
@ -200,7 +216,8 @@ void UEFITool::populateUi(const QModelIndex &current)
//ui->actionInsertAfter->setEnabled(type == Types::File || type == Types::Section); //ui->actionInsertAfter->setEnabled(type == Types::File || type == Types::Section);
//ui->actionReplace->setEnabled((type == Types::Region && subtype != Subtypes::DescriptorRegion) || type == Types::Volume || type == Types::File || type == Types::Section); //ui->actionReplace->setEnabled((type == Types::Region && subtype != Subtypes::DescriptorRegion) || type == Types::Volume || type == Types::File || type == Types::Section);
//ui->actionReplaceBody->setEnabled(type == Types::Volume || type == Types::File || type == Types::Section); //ui->actionReplaceBody->setEnabled(type == Types::Volume || type == Types::File || type == Types::Section);
ui->actionMessagesCopy->setEnabled(false);
ui->menuMessageActions->setEnabled(false);
} }
bool UEFITool::enableExtractBodyUncompressed(const QModelIndex &current) bool UEFITool::enableExtractBodyUncompressed(const QModelIndex &current)
@ -296,6 +313,19 @@ void UEFITool::hexView()
hexViewDialog->exec(); hexViewDialog->exec();
} }
void UEFITool::goToOffset()
{
if (goToOffsetDialog->exec() != QDialog::Accepted)
return;
UINT32 offset = (UINT32)goToOffsetDialog->ui->hexSpinBox->value();
QModelIndex index = model->findByOffset(offset);
if (index.isValid()) {
ui->structureTreeView->scrollTo(index, QAbstractItemView::PositionAtCenter);
ui->structureTreeView->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows | QItemSelectionModel::Clear);
}
}
void UEFITool::goToData() void UEFITool::goToData()
{ {
QModelIndex index = ui->structureTreeView->selectionModel()->currentIndex(); QModelIndex index = ui->structureTreeView->selectionModel()->currentIndex();
@ -334,6 +364,7 @@ void UEFITool::goToData()
void UEFITool::insert(const UINT8 mode) void UEFITool::insert(const UINT8 mode)
{ {
U_UNUSED_PARAMETER(mode); U_UNUSED_PARAMETER(mode);
/*QModelIndex index = ui->structureTreeView->selectionModel()->currentIndex(); /*QModelIndex index = ui->structureTreeView->selectionModel()->currentIndex();
if (!index.isValid()) if (!index.isValid())
return; return;
@ -413,6 +444,9 @@ void UEFITool::replaceBody()
void UEFITool::replace(const UINT8 mode) void UEFITool::replace(const UINT8 mode)
{ {
U_UNUSED_PARAMETER(mode);
/*
QModelIndex index = ui->structureTreeView->selectionModel()->currentIndex(); QModelIndex index = ui->structureTreeView->selectionModel()->currentIndex();
if (!index.isValid()) if (!index.isValid())
return; return;
@ -502,6 +536,7 @@ void UEFITool::replace(const UINT8 mode)
return; return;
} }
ui->actionSaveImageFile->setEnabled(true); ui->actionSaveImageFile->setEnabled(true);
*/
} }
void UEFITool::extractAsIs() void UEFITool::extractAsIs()
@ -626,22 +661,26 @@ void UEFITool::extract(const UINT8 mode)
void UEFITool::rebuild() void UEFITool::rebuild()
{ {
/*
UModelIndex index = ui->structureTreeView->selectionModel()->currentIndex(); UModelIndex index = ui->structureTreeView->selectionModel()->currentIndex();
if (!index.isValid()) if (!index.isValid())
return; return;
if (U_SUCCESS == ffsOps->rebuild(index)) if (U_SUCCESS == ffsOps->rebuild(index))
ui->actionSaveImageFile->setEnabled(true); ui->actionSaveImageFile->setEnabled(true);
*/
} }
void UEFITool::remove() void UEFITool::remove()
{ {
/*
UModelIndex index = ui->structureTreeView->selectionModel()->currentIndex(); UModelIndex index = ui->structureTreeView->selectionModel()->currentIndex();
if (!index.isValid()) if (!index.isValid())
return; return;
if (U_SUCCESS == ffsOps->remove(index)) if (U_SUCCESS == ffsOps->remove(index))
ui->actionSaveImageFile->setEnabled(true); ui->actionSaveImageFile->setEnabled(true);
*/
} }
void UEFITool::about() void UEFITool::about()
@ -671,7 +710,7 @@ void UEFITool::exit()
void UEFITool::saveImageFile() void UEFITool::saveImageFile()
{ {
QString path = QFileDialog::getSaveFileName(this, tr("Save BIOS image file"), currentDir, "BIOS image files (*.rom *.bin *.cap *.scap *.bio *.fd *.wph *.dec);;All files (*)"); /*QString path = QFileDialog::getSaveFileName(this, tr("Save BIOS image file"), currentDir, "BIOS image files (*.rom *.bin *.cap *.scap *.bio *.fd *.wph *.dec);;All files (*)");
if (path.isEmpty()) if (path.isEmpty())
return; return;
@ -699,6 +738,7 @@ void UEFITool::saveImageFile()
outputFile.close(); outputFile.close();
if (QMessageBox::Yes == QMessageBox::information(this, tr("Image build successful"), tr("Open the resulting file?"), QMessageBox::Yes, QMessageBox::No)) if (QMessageBox::Yes == QMessageBox::information(this, tr("Image build successful"), tr("Open the resulting file?"), QMessageBox::Yes, QMessageBox::No))
openImageFile(path); openImageFile(path);
*/
} }
void UEFITool::openImageFile() void UEFITool::openImageFile()
@ -758,6 +798,11 @@ void UEFITool::openImageFile(QString path)
delete ffsOps; delete ffsOps;
ffsOps = new FfsOperations(model); ffsOps = new FfsOperations(model);
// Set max offset and enable goToOffset
// FIXME: doesn't work properly
//goToOffsetDialog->ui->hexSpinBox->setMaximum(buffer.size() - 1);
ui->actionGoToOffset->setEnabled(true);
// Enable or disable FIT tab // Enable or disable FIT tab
showFitTable(); showFitTable();
@ -765,6 +810,14 @@ void UEFITool::openImageFile(QString path)
currentDir = fileInfo.absolutePath(); currentDir = fileInfo.absolutePath();
} }
void UEFITool::enableMessagesCopyActions(QListWidgetItem* item)
{
ui->menuMessageActions->setEnabled(item != NULL);
ui->actionMessagesCopy->setEnabled(item != NULL);
ui->actionMessagesCopyAll->setEnabled(item != NULL);
ui->actionMessagesClear->setEnabled(item != NULL);
}
void UEFITool::copyMessage() void UEFITool::copyMessage()
{ {
clipboard->clear(); clipboard->clear();
@ -797,12 +850,6 @@ void UEFITool::copyAllMessages()
} }
} }
void UEFITool::enableMessagesCopyActions(QListWidgetItem* item)
{
ui->actionMessagesCopy->setEnabled(item != NULL);
ui->actionMessagesCopyAll->setEnabled(item != NULL);
}
void UEFITool::clearMessages() void UEFITool::clearMessages()
{ {
if (ui->messagesTabWidget->currentIndex() == 0) { // Parser tab if (ui->messagesTabWidget->currentIndex() == 0) { // Parser tab
@ -818,8 +865,10 @@ void UEFITool::clearMessages()
ui->builderMessagesListWidget->clear(); ui->builderMessagesListWidget->clear();
} }
ui->menuMessageActions->setEnabled(false);
ui->actionMessagesCopy->setEnabled(false); ui->actionMessagesCopy->setEnabled(false);
ui->actionMessagesCopyAll->setEnabled(false); ui->actionMessagesCopyAll->setEnabled(false);
ui->actionMessagesClear->setEnabled(false);
} }
void UEFITool::dragEnterEvent(QDragEnterEvent* event) void UEFITool::dragEnterEvent(QDragEnterEvent* event)
@ -843,7 +892,9 @@ void UEFITool::showParserMessages()
std::vector<std::pair<QString, QModelIndex> > messages = ffsParser->getMessages(); std::vector<std::pair<QString, QModelIndex> > messages = ffsParser->getMessages();
std::pair<QString, QModelIndex> msg; std::pair<QString, QModelIndex> msg;
foreach (msg, messages) { foreach (msg, messages) {
ui->parserMessagesListWidget->addItem(new MessageListItem(msg.first, NULL, 0, msg.second)); QListWidgetItem* item = new QListWidgetItem(msg.first, NULL, 0);
item->setData(Qt::UserRole, msg.second);
ui->parserMessagesListWidget->addItem(item);
} }
ui->messagesTabWidget->setCurrentIndex(0); ui->messagesTabWidget->setCurrentIndex(0);
@ -859,7 +910,9 @@ void UEFITool::showFinderMessages()
std::vector<std::pair<QString, QModelIndex> > messages = ffsFinder->getMessages(); std::vector<std::pair<QString, QModelIndex> > messages = ffsFinder->getMessages();
std::pair<QString, QModelIndex> msg; std::pair<QString, QModelIndex> msg;
foreach (msg, messages) { foreach (msg, messages) {
ui->finderMessagesListWidget->addItem(new MessageListItem(msg.first, NULL, 0, msg.second)); QListWidgetItem* item = new QListWidgetItem(msg.first, NULL, 0);
item->setData(Qt::UserRole, msg.second);
ui->finderMessagesListWidget->addItem(item);
} }
ui->messagesTabWidget->setCurrentIndex(2); ui->messagesTabWidget->setCurrentIndex(2);
@ -875,7 +928,9 @@ void UEFITool::showBuilderMessages()
std::vector<std::pair<QString, QModelIndex> > messages = ffsBuilder->getMessages(); std::vector<std::pair<QString, QModelIndex> > messages = ffsBuilder->getMessages();
std::pair<QString, QModelIndex> msg; std::pair<QString, QModelIndex> msg;
foreach (msg, messages) { foreach (msg, messages) {
ui->builderMessagesListWidget->addItem(new MessageListItem(msg.first, NULL, 0, msg.second)); QListWidgetItem* item = new QListWidgetItem(msg.first, NULL, 0);
item->setData(Qt::UserRole, msg.second);
ui->builderMessagesListWidget->addItem(item);
} }
ui->messagesTabWidget->setCurrentIndex(3); ui->messagesTabWidget->setCurrentIndex(3);
@ -884,8 +939,16 @@ void UEFITool::showBuilderMessages()
void UEFITool::scrollTreeView(QListWidgetItem* item) void UEFITool::scrollTreeView(QListWidgetItem* item)
{ {
MessageListItem* messageItem = static_cast<MessageListItem*>(item); QModelIndex index = item->data(Qt::UserRole).toModelIndex();
QModelIndex index = messageItem->index(); if (index.isValid()) {
ui->structureTreeView->scrollTo(index, QAbstractItemView::PositionAtCenter);
ui->structureTreeView->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows | QItemSelectionModel::Clear);
}
}
void UEFITool::scrollTreeView(QTableWidgetItem* item)
{
QModelIndex index = item->data(Qt::UserRole).toModelIndex();
if (index.isValid()) { if (index.isValid()) {
ui->structureTreeView->scrollTo(index, QAbstractItemView::PositionAtCenter); ui->structureTreeView->scrollTo(index, QAbstractItemView::PositionAtCenter);
ui->structureTreeView->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows | QItemSelectionModel::Clear); ui->structureTreeView->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows | QItemSelectionModel::Clear);
@ -897,7 +960,7 @@ void UEFITool::contextMenuEvent(QContextMenuEvent* event)
if (ui->parserMessagesListWidget->underMouse() || if (ui->parserMessagesListWidget->underMouse() ||
ui->finderMessagesListWidget->underMouse() || ui->finderMessagesListWidget->underMouse() ||
ui->builderMessagesListWidget->underMouse()) { ui->builderMessagesListWidget->underMouse()) {
ui->menuMessages->exec(event->globalPos()); ui->menuMessageActions->exec(event->globalPos());
return; return;
} }
@ -970,7 +1033,7 @@ void UEFITool::writeSettings()
void UEFITool::showFitTable() void UEFITool::showFitTable()
{ {
std::vector<std::vector<QString> > 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(1, false); ui->messagesTabWidget->setTabEnabled(1, false);
@ -983,8 +1046,8 @@ void UEFITool::showFitTable()
// Set up the FIT table // Set up the FIT table
ui->fitTableWidget->clear(); ui->fitTableWidget->clear();
ui->fitTableWidget->setRowCount(fitTable.size()); ui->fitTableWidget->setRowCount(fitTable.size());
ui->fitTableWidget->setColumnCount(5); ui->fitTableWidget->setColumnCount(6);
ui->fitTableWidget->setHorizontalHeaderLabels(QStringList() << tr("Address") << tr("Size") << tr("Version") << tr("Checksum") << tr("Type")); 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);
@ -992,8 +1055,10 @@ void UEFITool::showFitTable()
// 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 < 5; j++) { for (UINT8 j = 0; j < 6; j++) {
ui->fitTableWidget->setItem(i, j, new QTableWidgetItem(fitTable[i][j])); QTableWidgetItem* item = new QTableWidgetItem(fitTable[i].first[j]);
item->setData(Qt::UserRole, fitTable[i].second);
ui->fitTableWidget->setItem(i, j, item);
} }
} }
@ -1001,3 +1066,13 @@ void UEFITool::showFitTable()
ui->fitTableWidget->resizeRowsToContents(); ui->fitTableWidget->resizeRowsToContents();
ui->messagesTabWidget->setCurrentIndex(1); ui->messagesTabWidget->setCurrentIndex(1);
} }
void UEFITool::currentTabChanged(int index)
{
U_UNUSED_PARAMETER(index);
ui->menuMessageActions->setEnabled(false);
ui->actionMessagesCopy->setEnabled(false);
ui->actionMessagesCopyAll->setEnabled(false);
ui->actionMessagesClear->setEnabled(false);
}

View File

@ -31,6 +31,7 @@
#include <QSettings> #include <QSettings>
#include <QSplitter> #include <QSplitter>
#include <QString> #include <QString>
#include <QTableWidget>
#include <QTreeView> #include <QTreeView>
#include <QUrl> #include <QUrl>
@ -42,8 +43,8 @@
#include "../common/ffsbuilder.h" #include "../common/ffsbuilder.h"
#include "searchdialog.h" #include "searchdialog.h"
#include "gotooffsetdialog.h"
#include "hexviewdialog.h" #include "hexviewdialog.h"
#include "messagelistitem.h"
#include "ffsfinder.h" #include "ffsfinder.h"
namespace Ui { namespace Ui {
@ -63,16 +64,20 @@ public:
private slots: private slots:
void init(); void init();
void populateUi(const QItemSelection &selected);
void populateUi(const QModelIndex &current); void populateUi(const QModelIndex &current);
void scrollTreeView(QListWidgetItem* item); void scrollTreeView(QListWidgetItem* item); // For messages
void scrollTreeView(QTableWidgetItem* item); // For FIT table entries
void openImageFile(); void openImageFile();
void openImageFileInNewWindow(); void openImageFileInNewWindow();
void saveImageFile(); void saveImageFile();
void search(); void search();
void goToOffset();
void hexView(); void hexView();
void goToData(); void goToData();
void extract(const UINT8 mode); void extract(const UINT8 mode);
@ -104,6 +109,8 @@ private slots:
void exit(); void exit();
void writeSettings(); void writeSettings();
void currentTabChanged(int index);
private: private:
Ui::UEFITool* ui; Ui::UEFITool* ui;
TreeModel* model; TreeModel* model;
@ -113,6 +120,7 @@ private:
FfsBuilder* ffsBuilder; FfsBuilder* ffsBuilder;
SearchDialog* searchDialog; SearchDialog* searchDialog;
HexViewDialog* hexViewDialog; HexViewDialog* hexViewDialog;
GoToOffsetDialog* goToOffsetDialog;
QClipboard* clipboard; QClipboard* clipboard;
QString currentDir; QString currentDir;
QString currentProgramPath; QString currentProgramPath;
@ -128,6 +136,7 @@ private:
void showFinderMessages(); void showFinderMessages();
void showFitTable(); void showFitTable();
void showBuilderMessages(); void showBuilderMessages();
}; };
#endif // UEFITOOL_H #endif // UEFITOOL_H

View File

@ -8,7 +8,6 @@ DEFINES += "U_ENABLE_NVRAM_PARSING_SUPPORT"
HEADERS += uefitool.h \ HEADERS += uefitool.h \
searchdialog.h \ searchdialog.h \
hexviewdialog.h \ hexviewdialog.h \
messagelistitem.h \
guidlineedit.h \ guidlineedit.h \
ffsfinder.h \ ffsfinder.h \
../common/nvram.h \ ../common/nvram.h \
@ -36,13 +35,13 @@ HEADERS += uefitool.h \
../common/ubytearray.h \ ../common/ubytearray.h \
../qhexedit2/qhexedit.h \ ../qhexedit2/qhexedit.h \
../qhexedit2/chunks.h \ ../qhexedit2/chunks.h \
../qhexedit2/commands.h ../qhexedit2/commands.h \
gotooffsetdialog.h
SOURCES += uefitool_main.cpp \ SOURCES += uefitool_main.cpp \
uefitool.cpp \ uefitool.cpp \
searchdialog.cpp \ searchdialog.cpp \
hexviewdialog.cpp \ hexviewdialog.cpp \
messagelistitem.cpp \
guidlineedit.cpp \ guidlineedit.cpp \
ffsfinder.cpp \ ffsfinder.cpp \
../common/nvram.cpp \ ../common/nvram.cpp \
@ -72,7 +71,8 @@ SOURCES += uefitool_main.cpp \
FORMS += uefitool.ui \ FORMS += uefitool.ui \
searchdialog.ui \ searchdialog.ui \
hexviewdialog.ui hexviewdialog.ui \
gotooffsetdialog.ui
RC_FILE = uefitool.rc RC_FILE = uefitool.rc

View File

@ -284,8 +284,6 @@
<addaction name="actionOpenImageFileInNewWindow"/> <addaction name="actionOpenImageFileInNewWindow"/>
<addaction name="actionSaveImageFile"/> <addaction name="actionSaveImageFile"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionSearch"/>
<addaction name="separator"/>
<addaction name="actionQuit"/> <addaction name="actionQuit"/>
</widget> </widget>
<widget class="QMenu" name="menuHelp"> <widget class="QMenu" name="menuHelp">
@ -300,6 +298,9 @@
<string>&amp;Action</string> <string>&amp;Action</string>
</property> </property>
<widget class="QMenu" name="menuCapsuleActions"> <widget class="QMenu" name="menuCapsuleActions">
<property name="enabled">
<bool>false</bool>
</property>
<property name="title"> <property name="title">
<string>&amp;Capsule</string> <string>&amp;Capsule</string>
</property> </property>
@ -309,6 +310,9 @@
<addaction name="actionExtractBody"/> <addaction name="actionExtractBody"/>
</widget> </widget>
<widget class="QMenu" name="menuImageActions"> <widget class="QMenu" name="menuImageActions">
<property name="enabled">
<bool>false</bool>
</property>
<property name="title"> <property name="title">
<string>&amp;Image</string> <string>&amp;Image</string>
</property> </property>
@ -317,6 +321,9 @@
<addaction name="actionExtract"/> <addaction name="actionExtract"/>
</widget> </widget>
<widget class="QMenu" name="menuRegionActions"> <widget class="QMenu" name="menuRegionActions">
<property name="enabled">
<bool>false</bool>
</property>
<property name="title"> <property name="title">
<string>&amp;Region</string> <string>&amp;Region</string>
</property> </property>
@ -329,6 +336,9 @@
<addaction name="actionReplace"/> <addaction name="actionReplace"/>
</widget> </widget>
<widget class="QMenu" name="menuPaddingActions"> <widget class="QMenu" name="menuPaddingActions">
<property name="enabled">
<bool>false</bool>
</property>
<property name="title"> <property name="title">
<string>&amp;Padding</string> <string>&amp;Padding</string>
</property> </property>
@ -337,6 +347,9 @@
<addaction name="actionExtract"/> <addaction name="actionExtract"/>
</widget> </widget>
<widget class="QMenu" name="menuVolumeActions"> <widget class="QMenu" name="menuVolumeActions">
<property name="enabled">
<bool>false</bool>
</property>
<property name="title"> <property name="title">
<string>&amp;Volume</string> <string>&amp;Volume</string>
</property> </property>
@ -353,6 +366,9 @@
<addaction name="actionReplaceBody"/> <addaction name="actionReplaceBody"/>
</widget> </widget>
<widget class="QMenu" name="menuFileActions"> <widget class="QMenu" name="menuFileActions">
<property name="enabled">
<bool>false</bool>
</property>
<property name="title"> <property name="title">
<string>&amp;File</string> <string>&amp;File</string>
</property> </property>
@ -373,6 +389,9 @@
<addaction name="actionRemove"/> <addaction name="actionRemove"/>
</widget> </widget>
<widget class="QMenu" name="menuSectionActions"> <widget class="QMenu" name="menuSectionActions">
<property name="enabled">
<bool>false</bool>
</property>
<property name="title"> <property name="title">
<string>&amp;Section</string> <string>&amp;Section</string>
</property> </property>
@ -393,7 +412,10 @@
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionRemove"/> <addaction name="actionRemove"/>
</widget> </widget>
<widget class="QMenu" name="menuMessages"> <widget class="QMenu" name="menuMessageActions">
<property name="enabled">
<bool>false</bool>
</property>
<property name="title"> <property name="title">
<string>&amp;Messages</string> <string>&amp;Messages</string>
</property> </property>
@ -403,6 +425,9 @@
<addaction name="actionMessagesClear"/> <addaction name="actionMessagesClear"/>
</widget> </widget>
<widget class="QMenu" name="menuVariableActions"> <widget class="QMenu" name="menuVariableActions">
<property name="enabled">
<bool>false</bool>
</property>
<property name="title"> <property name="title">
<string>Variable</string> <string>Variable</string>
</property> </property>
@ -424,6 +449,9 @@
<addaction name="actionRemove"/> <addaction name="actionRemove"/>
</widget> </widget>
<widget class="QMenu" name="menuStoreActions"> <widget class="QMenu" name="menuStoreActions">
<property name="enabled">
<bool>false</bool>
</property>
<property name="title"> <property name="title">
<string>S&amp;tore</string> <string>S&amp;tore</string>
</property> </property>
@ -441,6 +469,9 @@
<addaction name="actionReplace"/> <addaction name="actionReplace"/>
<addaction name="actionReplaceBody"/> <addaction name="actionReplaceBody"/>
</widget> </widget>
<addaction name="actionGoToOffset"/>
<addaction name="actionSearch"/>
<addaction name="separator"/>
<addaction name="menuCapsuleActions"/> <addaction name="menuCapsuleActions"/>
<addaction name="menuImageActions"/> <addaction name="menuImageActions"/>
<addaction name="menuRegionActions"/> <addaction name="menuRegionActions"/>
@ -451,7 +482,7 @@
<addaction name="menuStoreActions"/> <addaction name="menuStoreActions"/>
<addaction name="menuVariableActions"/> <addaction name="menuVariableActions"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="menuMessages"/> <addaction name="menuMessageActions"/>
</widget> </widget>
<addaction name="menuFile"/> <addaction name="menuFile"/>
<addaction name="menuAction"/> <addaction name="menuAction"/>
@ -609,6 +640,9 @@
<property name="text"> <property name="text">
<string>About &amp;Qt</string> <string>About &amp;Qt</string>
</property> </property>
<property name="shortcut">
<string>Shift+F1</string>
</property>
<property name="menuRole"> <property name="menuRole">
<enum>QAction::AboutQtRole</enum> <enum>QAction::AboutQtRole</enum>
</property> </property>
@ -633,6 +667,9 @@
</property> </property>
</action> </action>
<action name="actionMessagesClear"> <action name="actionMessagesClear">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text"> <property name="text">
<string>Clea&amp;r</string> <string>Clea&amp;r</string>
</property> </property>
@ -658,6 +695,9 @@
</property> </property>
</action> </action>
<action name="actionMessagesCopy"> <action name="actionMessagesCopy">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text"> <property name="text">
<string>&amp;Copy</string> <string>&amp;Copy</string>
</property> </property>
@ -666,6 +706,9 @@
</property> </property>
</action> </action>
<action name="actionMessagesCopyAll"> <action name="actionMessagesCopyAll">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text"> <property name="text">
<string>Copy &amp;all</string> <string>Copy &amp;all</string>
</property> </property>
@ -700,7 +743,10 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Go to &amp;data</string> <string>Go &amp;to data</string>
</property>
<property name="shortcut">
<string>Ctrl+T</string>
</property> </property>
</action> </action>
<action name="actionHexView"> <action name="actionHexView">
@ -714,6 +760,17 @@
<string>Ctrl+D</string> <string>Ctrl+D</string>
</property> </property>
</action> </action>
<action name="actionGoToOffset">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>&amp;Go to offset...</string>
</property>
<property name="shortcut">
<string>Ctrl+G</string>
</property>
</action>
</widget> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>
<resources/> <resources/>

View File

@ -557,7 +557,7 @@ size_t len;
a->slen = i; a->slen = i;
len = strlen (str + i); len = strlen (str + i);
if (len + 1 > INT_MAX - i || if (len + 1 > (size_t)(INT_MAX - i) ||
0 > balloc (a, (int) (i + len + 1))) return BSTR_ERR; 0 > balloc (a, (int) (i + len + 1))) return BSTR_ERR;
bBlockCopy (a->data + i, str + i, (size_t) len + 1); bBlockCopy (a->data + i, str + i, (size_t) len + 1);
a->slen += (int) len; a->slen += (int) len;

View File

@ -19,6 +19,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
USTATUS FfsBuilder::erase(const UModelIndex & index, UByteArray & erased) USTATUS FfsBuilder::erase(const UModelIndex & index, UByteArray & erased)
{ {
U_UNUSED_PARAMETER(erased);
// Sanity check // Sanity check
if (!index.isValid()) if (!index.isValid())
return U_INVALID_PARAMETER; return U_INVALID_PARAMETER;
@ -358,21 +360,33 @@ USTATUS FfsBuilder::buildFreeSpace(const UModelIndex & index, UByteArray & freeS
USTATUS FfsBuilder::buildVolume(const UModelIndex & index, UByteArray & volume) USTATUS FfsBuilder::buildVolume(const UModelIndex & index, UByteArray & volume)
{ {
U_UNUSED_PARAMETER(index);
U_UNUSED_PARAMETER(volume);
return U_NOT_IMPLEMENTED; return U_NOT_IMPLEMENTED;
} }
USTATUS FfsBuilder::buildPadFile(const UModelIndex & index, UByteArray & padFile) USTATUS FfsBuilder::buildPadFile(const UModelIndex & index, UByteArray & padFile)
{ {
U_UNUSED_PARAMETER(index);
U_UNUSED_PARAMETER(padFile);
return U_NOT_IMPLEMENTED; return U_NOT_IMPLEMENTED;
} }
USTATUS FfsBuilder::buildFile(const UModelIndex & index, UByteArray & file) USTATUS FfsBuilder::buildFile(const UModelIndex & index, UByteArray & file)
{ {
U_UNUSED_PARAMETER(index);
U_UNUSED_PARAMETER(file);
return U_NOT_IMPLEMENTED; return U_NOT_IMPLEMENTED;
} }
USTATUS FfsBuilder::buildSection(const UModelIndex & index, UByteArray & section) USTATUS FfsBuilder::buildSection(const UModelIndex & index, UByteArray & section)
{ {
U_UNUSED_PARAMETER(index);
U_UNUSED_PARAMETER(section);
return U_NOT_IMPLEMENTED; return U_NOT_IMPLEMENTED;
} }

View File

@ -65,6 +65,8 @@ USTATUS FfsOperations::extract(const UModelIndex & index, UString & name, UByteA
USTATUS FfsOperations::replace(const UModelIndex & index, const UString & data, const UINT8 mode) USTATUS FfsOperations::replace(const UModelIndex & index, const UString & data, const UINT8 mode)
{ {
U_UNUSED_PARAMETER(data);
// Sanity check // Sanity check
if (!index.isValid()) if (!index.isValid())
return U_INVALID_PARAMETER; return U_INVALID_PARAMETER;

View File

@ -15,7 +15,7 @@ WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <map> #include <map>
#include <algorithm> #include <algorithm>
#include <cmath> #include <cmath>
#include <cinttypes> #include <inttypes.h>
#include "descriptor.h" #include "descriptor.h"
#include "ffs.h" #include "ffs.h"
@ -478,9 +478,6 @@ USTATUS FfsParser::parseIntelImage(const UByteArray & intelImage, const UINT32 l
descriptorMap->NumberOfPchStraps, descriptorMap->NumberOfPchStraps,
descriptorMap->NumberOfProcStraps); descriptorMap->NumberOfProcStraps);
// Construct parsing data
//pdata.offset = localOffset;
// Add Intel image tree item // Add Intel image tree item
index = model->addItem(localOffset, Types::Image, Subtypes::IntelImage, name, UString(), info, UByteArray(), intelImage, UByteArray(), Fixed, parent); index = model->addItem(localOffset, Types::Image, Subtypes::IntelImage, name, UString(), info, UByteArray(), intelImage, UByteArray(), Fixed, parent);
@ -2866,6 +2863,7 @@ USTATUS FfsParser::parseFit(const UModelIndex & index, const UINT32 diff)
return U_SUCCESS; return U_SUCCESS;
// Explicitly set the item as fixed // Explicitly set the item as fixed
// TODO: update info
model->setFixed(fitIndex, true); model->setFixed(fitIndex, true);
// Special case of FIT header // Special case of FIT header
@ -2890,20 +2888,24 @@ USTATUS FfsParser::parseFit(const UModelIndex & index, const UINT32 diff)
msg(("Invalid FIT header type"), fitIndex); msg(("Invalid FIT header type"), fitIndex);
// Add FIT header to fitTable // Add FIT header
std::vector<UString> currentStrings; std::vector<UString> currentStrings;
currentStrings.push_back(UString("_FIT_ ")); currentStrings.push_back(UString("_FIT_ "));
currentStrings.push_back(usprintf("%08Xh", fitSize)); currentStrings.push_back(usprintf("%08Xh", fitSize));
currentStrings.push_back(usprintf("%04Xh", fitHeader->Version)); currentStrings.push_back(usprintf("%04Xh", fitHeader->Version));
currentStrings.push_back(usprintf("%02Xh", fitHeader->Checksum)); currentStrings.push_back(usprintf("%02Xh", fitHeader->Checksum));
currentStrings.push_back(fitEntryTypeToUString(fitHeader->Type)); currentStrings.push_back(fitEntryTypeToUString(fitHeader->Type));
fitTable.push_back(currentStrings); currentStrings.push_back(UString("")); // Empty info for FIT header
fitTable.push_back(std::pair<std::vector<UString>, UModelIndex>(currentStrings, fitIndex));
// Process all other entries // Process all other entries
bool msgModifiedImageMayNotWork = false; bool msgModifiedImageMayNotWork = false;
UModelIndex itemIndex;
UString info;
for (UINT32 i = 1; i < fitHeader->Size; i++) { for (UINT32 i = 1; i < fitHeader->Size; i++) {
currentStrings.clear(); currentStrings.clear();
const FIT_ENTRY* currentEntry = fitHeader + i; const FIT_ENTRY* currentEntry = fitHeader + i;
UINT32 currentEntrySize = currentEntry->Size;
// Check entry type // Check entry type
switch (currentEntry->Type & 0x7F) { switch (currentEntry->Type & 0x7F) {
@ -2912,7 +2914,40 @@ USTATUS FfsParser::parseFit(const UModelIndex & index, const UINT32 diff)
break; break;
case FIT_TYPE_EMPTY: case FIT_TYPE_EMPTY:
break;
case FIT_TYPE_MICROCODE: case FIT_TYPE_MICROCODE:
//TODO: refactor into function with error reporting
if (currentEntry->Address > diff && currentEntry->Address < 0xFFFFFFFFUL) {
UINT32 offset = currentEntry->Address - diff;
UModelIndex mcIndex = model->findByOffset(offset);
UByteArray mcFile = model->header(mcIndex) + model->body(mcIndex) + model->tail(mcIndex);
UINT32 mcOffset = offset - model->offset(mcIndex);
if (mcOffset + sizeof(INTEL_MICROCODE_HEADER) <= (UINT32)mcFile.size()) {
const INTEL_MICROCODE_HEADER* header = (const INTEL_MICROCODE_HEADER*)(mcFile.constData() + mcOffset);
if (header->Version == INTEL_MICROCODE_HEADER_VERSION) {
bool reservedBytesValid = true;
for (UINT8 i = 0; i < sizeof(header->Reserved); i++)
if (header->Reserved[i] != INTEL_MICROCODE_HEADER_RESERVED_BYTE) {
reservedBytesValid = false;
break;
}
if (reservedBytesValid) {
UINT32 mcSize = header->TotalSize;
if (mcOffset + mcSize <= (UINT32)mcFile.size()) {
info = usprintf("LocalOffset %08Xh, CPUID %Xh, Revision %Xh, Date %08Xh",
mcOffset,
header->CpuSignature,
header->Revision,
header->Date);
currentEntrySize = header->TotalSize;
itemIndex = mcIndex;
}
}
}
}
}
break; break;
case FIT_TYPE_BIOS_AC_MODULE: case FIT_TYPE_BIOS_AC_MODULE:
@ -2929,11 +2964,12 @@ USTATUS FfsParser::parseFit(const UModelIndex & index, const UINT32 diff)
// Add entry to fitTable // Add entry to fitTable
currentStrings.push_back(usprintf("%016" PRIX64, currentEntry->Address)); currentStrings.push_back(usprintf("%016" PRIX64, currentEntry->Address));
currentStrings.push_back(usprintf("%08Xh", currentEntry->Size, currentEntry->Size)); currentStrings.push_back(usprintf("%08Xh", currentEntrySize, currentEntrySize));
currentStrings.push_back(usprintf("%04Xh", currentEntry->Version)); currentStrings.push_back(usprintf("%04Xh", currentEntry->Version));
currentStrings.push_back(usprintf("%02Xh", currentEntry->Checksum)); currentStrings.push_back(usprintf("%02Xh", currentEntry->Checksum));
currentStrings.push_back(fitEntryTypeToUString(currentEntry->Type)); currentStrings.push_back(fitEntryTypeToUString(currentEntry->Type));
fitTable.push_back(currentStrings); currentStrings.push_back(info);
fitTable.push_back(std::pair<std::vector<UString>, UModelIndex>(currentStrings, itemIndex));
} }
if (msgModifiedImageMayNotWork) if (msgModifiedImageMayNotWork)

View File

@ -32,7 +32,7 @@ public:
std::vector<std::pair<UString, UModelIndex> > getMessages() const { std::vector<std::pair<UString, UModelIndex> > getMessages() const {
std::vector<std::pair<UString, UModelIndex> > nvramVector = nvramParser.getMessages(); std::vector<std::pair<UString, UModelIndex> > nvramVector = nvramParser.getMessages();
std::vector<std::pair<UString, UModelIndex> > resultVector = messagesVector; std::vector<std::pair<UString, UModelIndex> > resultVector = messagesVector;
resultVector.insert(std::end(resultVector), std::begin(nvramVector), std::end(nvramVector)); resultVector.insert(resultVector.end(), nvramVector.begin(), nvramVector.end());
return resultVector; return resultVector;
} }
@ -43,7 +43,7 @@ public:
USTATUS parse(const UByteArray &buffer); USTATUS parse(const UByteArray &buffer);
// Obtain parsed FIT table // Obtain parsed FIT table
std::vector<std::vector<UString> > getFitTable() const { return fitTable; } std::vector<std::pair<std::vector<UString>, UModelIndex> > getFitTable() const { return fitTable; }
private: private:
TreeModel *model; TreeModel *model;
@ -52,11 +52,11 @@ private:
messagesVector.push_back(std::pair<UString, UModelIndex>(message, index)); messagesVector.push_back(std::pair<UString, UModelIndex>(message, index));
}; };
NvramParser nvramParser;
UModelIndex lastVtf; UModelIndex lastVtf;
UINT32 capsuleOffsetFixup; UINT32 capsuleOffsetFixup;
std::vector<std::vector<UString> > fitTable; std::vector<std::pair<std::vector<UString>, UModelIndex> > fitTable;
NvramParser nvramParser;
// First pass // First pass
USTATUS performFirstPass(const UByteArray & imageFile, UModelIndex & index); USTATUS performFirstPass(const UByteArray & imageFile, UModelIndex & index);

View File

@ -12,7 +12,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/ */
#include <cinttypes> #include <inttypes.h>
#include <map>
#include "nvramparser.h" #include "nvramparser.h"
#include "parsingdata.h" #include "parsingdata.h"
@ -1184,13 +1185,14 @@ USTATUS NvramParser::parseIntelMicrocodeHeader(const UByteArray & store, const U
// Add info // Add info
UString name("Intel microcode"); UString name("Intel microcode");
UString info = usprintf("Revision: 1h\nFull size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\n" UString info = usprintf("\nFull size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\n"
"Date: %08Xh\nCPU signature: %08Xh\nChecksum: %08Xh\nLoader revision: %08Xh\nCPU flags: %08Xh", "Date: %08Xh\nCPU signature: %08Xh\nRevision: %08Xh\nChecksum: %08Xh\nLoader revision: %08Xh\nCPU flags: %08Xh",
ucodeHeader->TotalSize, ucodeHeader->TotalSize, ucodeHeader->TotalSize, ucodeHeader->TotalSize,
header.size(), header.size(), header.size(), header.size(),
body.size(), body.size(), body.size(), body.size(),
ucodeHeader->Date, ucodeHeader->Date,
ucodeHeader->CpuSignature, ucodeHeader->CpuSignature,
ucodeHeader->Revision,
ucodeHeader->Checksum, ucodeHeader->Checksum,
ucodeHeader->LoaderRevision, ucodeHeader->LoaderRevision,
ucodeHeader->CpuFlags); ucodeHeader->CpuFlags);
@ -1588,14 +1590,13 @@ USTATUS NvramParser::parseEvsaStoreBody(const UModelIndex & index)
if (body.count(emptyByte) == body.size()) { // Free space if (body.count(emptyByte) == body.size()) { // Free space
// Add free space tree item // Add free space tree item
UModelIndex itemIndex = model->addItem(localOffset + offset, Types::FreeSpace, 0, UString("Free space"), UString(), info, UByteArray(), body, UByteArray(), Movable, index); model->addItem(localOffset + offset, Types::FreeSpace, 0, UString("Free space"), UString(), info, UByteArray(), body, UByteArray(), Movable, index);
} }
else { else {
// Add padding tree item // Add padding tree item
UModelIndex itemIndex = model->addItem(localOffset + offset, Types::Padding, getPaddingType(body), UString("Padding"), UString(), info, UByteArray(), body, UByteArray(), Fixed, index); UModelIndex itemIndex = model->addItem(localOffset + offset, Types::Padding, getPaddingType(body), UString("Padding"), UString(), info, UByteArray(), body, UByteArray(), Fixed, index);
// Show message // Show message
msg(UString("parseEvsaStoreBody: variable parsing failed, the rest of unparsed store added as padding"), itemIndex); msg(UString("parseEvsaStoreBody: variable parsing failed, the rest of unparsed store added as padding"), itemIndex);
} }
break; break;
@ -1681,7 +1682,7 @@ USTATUS NvramParser::parseEvsaStoreBody(const UModelIndex & index)
if (body.count(emptyByte) == body.size()) { // Free space if (body.count(emptyByte) == body.size()) { // Free space
// Add free space tree item // Add free space tree item
UModelIndex itemIndex = model->addItem(localOffset + offset, Types::FreeSpace, 0, UString("Free space"), UString(), info, UByteArray(), body, UByteArray(), Movable, index); model->addItem(localOffset + offset, Types::FreeSpace, 0, UString("Free space"), UString(), info, UByteArray(), body, UByteArray(), Movable, index);
} }
else { else {
// Add padding tree item // Add padding tree item

View File

@ -20,7 +20,7 @@ UString machineTypeToUString(UINT16 machineType)
case EFI_IMAGE_FILE_MACHINE_ARM: return UString("ARM"); case EFI_IMAGE_FILE_MACHINE_ARM: return UString("ARM");
case EFI_IMAGE_FILE_MACHINE_ARMNT: return UString("ARMv7"); case EFI_IMAGE_FILE_MACHINE_ARMNT: return UString("ARMv7");
case EFI_IMAGE_FILE_MACHINE_APPLE_ARM: return UString("Apple ARM"); case EFI_IMAGE_FILE_MACHINE_APPLE_ARM: return UString("Apple ARM");
case EFI_IMAGE_FILE_MACHINE_AARCH64: return UString("AARCH64"); case EFI_IMAGE_FILE_MACHINE_AARCH64: return UString("AArch64");
case EFI_IMAGE_FILE_MACHINE_EBC: return UString("EBC"); case EFI_IMAGE_FILE_MACHINE_EBC: return UString("EBC");
case EFI_IMAGE_FILE_MACHINE_I386: return UString("x86"); case EFI_IMAGE_FILE_MACHINE_I386: return UString("x86");
case EFI_IMAGE_FILE_MACHINE_IA64: return UString("IA64"); case EFI_IMAGE_FILE_MACHINE_IA64: return UString("IA64");

View File

@ -19,8 +19,8 @@ TreeItem::TreeItem(const UINT32 offset, const UINT8 type, const UINT8 subtype,
const UByteArray & header, const UByteArray & body, const UByteArray & tail, const UByteArray & header, const UByteArray & body, const UByteArray & tail,
const bool fixed, const bool compressed, const bool fixed, const bool compressed,
TreeItem *parent) : TreeItem *parent) :
itemAction(Actions::NoAction),
itemOffset(offset), itemOffset(offset),
itemAction(Actions::NoAction),
itemType(type), itemType(type),
itemSubtype(subtype), itemSubtype(subtype),
itemName(name), itemName(name),

View File

@ -13,6 +13,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "treemodel.h" #include "treemodel.h"
#include "stack"
#if defined(QT_CORE_LIB) #if defined(QT_CORE_LIB)
QVariant TreeModel::data(const UModelIndex &index, int role) const QVariant TreeModel::data(const UModelIndex &index, int role) const
{ {
@ -491,4 +493,25 @@ UModelIndex TreeModel::findParentOfType(const UModelIndex& index, UINT8 type) co
return parent; return parent;
return UModelIndex(); return UModelIndex();
}
UModelIndex TreeModel::findByOffset(UINT32 offset) const
{
UModelIndex parentIndex = index(0,0);
goDeeper:
int n = rowCount(parentIndex);
for (int i = 0; i < n; i++) {
UModelIndex currentIndex = parentIndex.child(i, 0);
UINTN currentOffset = this->offset(currentIndex);
UINTN fullSize = header(currentIndex).size() + body(currentIndex).size() + tail(currentIndex).size();
if ((compressed(currentIndex) == false || (compressed(currentIndex) == true && compressed(currentIndex.parent()) == false)) // Offset is meaningful only for uncompressed items
&& currentOffset <= offset && offset < currentOffset + fullSize) { // Offset must be in range [currentOffset, currentOffset + fullSize)
// Found a better candidate
parentIndex = currentIndex;
goto goDeeper;
}
}
return (parentIndex == index(0, 0) ? UModelIndex() : parentIndex);
} }

View File

@ -93,7 +93,7 @@ public:
QVariant headerData(int section, Qt::Orientation orientation, QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const; int role = Qt::DisplayRole) const;
TreeModel(QObject *parent = 0) : QAbstractItemModel(parent) { TreeModel(QObject *parent = 0) : QAbstractItemModel(parent) {
rootItem = new TreeItem(0, Types::Root, 0, UString(), UString(), UString(), UByteArray(), UByteArray(), UByteArray(), TRUE, FALSE); rootItem = new TreeItem(0, Types::Root, 0, UString(), UString(), UString(), UByteArray(), UByteArray(), UByteArray(), true, false);
} }
#else #else
@ -129,8 +129,7 @@ public:
delete rootItem; delete rootItem;
} }
UModelIndex index(int row, int column, UModelIndex index(int row, int column, const UModelIndex &parent = UModelIndex()) const;
const UModelIndex &parent = UModelIndex()) const;
UModelIndex parent(const UModelIndex &index) const; UModelIndex parent(const UModelIndex &index) const;
int rowCount(const UModelIndex &parent = UModelIndex()) const; int rowCount(const UModelIndex &parent = UModelIndex()) const;
int columnCount(const UModelIndex &parent = UModelIndex()) const; int columnCount(const UModelIndex &parent = UModelIndex()) const;
@ -174,6 +173,7 @@ public:
const UModelIndex & parent = UModelIndex(), const UINT8 mode = CREATE_MODE_APPEND); const UModelIndex & parent = UModelIndex(), const UINT8 mode = CREATE_MODE_APPEND);
UModelIndex findParentOfType(const UModelIndex & index, UINT8 type) const; UModelIndex findParentOfType(const UModelIndex & index, UINT8 type) const;
UModelIndex findByOffset(UINT32 offset) const;
}; };
#if defined(QT_CORE_LIB) #if defined(QT_CORE_LIB)

View File

@ -43,7 +43,7 @@ public:
void clear() { d.clear(); } void clear() { d.clear(); }
UByteArray toUpper() { std::basic_string<char> s = d; std::transform(s.begin(), s.end(), s.begin(), ::toupper); return UByteArray(s); } UByteArray toUpper() { std::basic_string<char> s = d; std::transform(s.begin(), s.end(), s.begin(), ::toupper); return UByteArray(s); }
uint32_t toUInt(bool* ok = NULL, const uint8_t base = 10) { return (uint32_t)std::strtoul(d.c_str(), NULL, base); } uint32_t toUInt(bool* ok = NULL, const uint8_t base = 10) { return (uint32_t)strtoul(d.c_str(), NULL, base); }
int32_t size() const { return d.size(); } int32_t size() const { return d.size(); }
int32_t count(char ch) const { return std::count(d.begin(), d.end(), ch); } int32_t count(char ch) const { return std::count(d.begin(), d.end(), ch); }

View File

@ -47,7 +47,8 @@ UString uniqueItemName(const UModelIndex & index)
} }
if (hasExtendedHeader) if (hasExtendedHeader)
name = guidToUString(extendedHeaderGuid).replace('-', '_'); name = guidToUString(extendedHeaderGuid);
name.findreplace('-', '_');
} break; } break;
case Types::NvarEntry: case Types::NvarEntry:
case Types::VssEntry: case Types::VssEntry: