mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-22 07:58:22 +08:00
NE Alpha 41
This commit is contained in:
parent
c0f1a8eadf
commit
227be5480e
23
UEFITool/gotoaddressdialog.h
Normal file
23
UEFITool/gotoaddressdialog.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#ifndef GOTOADDRESSDIALOG_H
|
||||||
|
#define GOTOADDRESSDIALOG_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QDialog>
|
||||||
|
#include "ui_gotoaddressdialog.h"
|
||||||
|
class GoToAddressDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
GoToAddressDialog(QWidget* parent = NULL) :
|
||||||
|
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint),
|
||||||
|
ui(new Ui::GoToAddressDialog) {
|
||||||
|
ui->setupUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
~GoToAddressDialog() { delete ui; }
|
||||||
|
|
||||||
|
Ui::GoToAddressDialog* ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GOTOADDRESSDIALOG_H
|
133
UEFITool/gotoaddressdialog.ui
Normal file
133
UEFITool/gotoaddressdialog.ui
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>GoToAddressDialog</class>
|
||||||
|
<widget class="QDialog" name="GoToAddressDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>270</width>
|
||||||
|
<height>70</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Go to address</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 address:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="HexSpinBox" name="hexSpinBox">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</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>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>HexSpinBox</class>
|
||||||
|
<extends>QSpinBox</extends>
|
||||||
|
<header>hexspinbox.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>buttonBox</tabstop>
|
||||||
|
</tabstops>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>GoToAddressDialog</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>GoToAddressDialog</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>
|
@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>204</width>
|
<width>270</width>
|
||||||
<height>70</height>
|
<height>70</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -56,7 +56,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Select tree item at:</string>
|
<string>Select tree item at offset:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
HexSpinBox::HexSpinBox(QWidget *parent) :
|
HexSpinBox::HexSpinBox(QWidget *parent) :
|
||||||
QSpinBox(parent), validator(QRegExp("0x([0-9a-fA-F]){1,8}"))
|
QSpinBox(parent), validator(QRegExp("0x([0-9a-fA-F]){1,8}"))
|
||||||
{
|
{
|
||||||
this->setRange(0, INT_MAX);
|
this->setRange(INT_MIN, INT_MAX);
|
||||||
this->setPrefix("0x");
|
this->setPrefix("0x");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,10 +28,10 @@ QValidator::State HexSpinBox::validate(QString &text, int &pos) const
|
|||||||
|
|
||||||
QString HexSpinBox::textFromValue(int val) const
|
QString HexSpinBox::textFromValue(int val) const
|
||||||
{
|
{
|
||||||
return QString::number(val, 16).toUpper();
|
return QString::number((uint)val, 16).toUpper();
|
||||||
}
|
}
|
||||||
|
|
||||||
int HexSpinBox::valueFromText(const QString &text) const
|
int HexSpinBox::valueFromText(const QString &text) const
|
||||||
{
|
{
|
||||||
return text.toInt(NULL, 16);
|
return (int)text.toUInt(NULL, 16);
|
||||||
}
|
}
|
||||||
|
7914
UEFITool/qrc_uefitool.cpp
Normal file
7914
UEFITool/qrc_uefitool.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@ -17,7 +17,7 @@
|
|||||||
UEFITool::UEFITool(QWidget *parent) :
|
UEFITool::UEFITool(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::UEFITool),
|
ui(new Ui::UEFITool),
|
||||||
version(tr("NE alpha 40"))
|
version(tr("NE alpha 41"))
|
||||||
{
|
{
|
||||||
clipboard = QApplication::clipboard();
|
clipboard = QApplication::clipboard();
|
||||||
|
|
||||||
@ -26,6 +26,7 @@ version(tr("NE alpha 40"))
|
|||||||
searchDialog = new SearchDialog(this);
|
searchDialog = new SearchDialog(this);
|
||||||
hexViewDialog = new HexViewDialog(this);
|
hexViewDialog = new HexViewDialog(this);
|
||||||
goToOffsetDialog = new GoToOffsetDialog(this);
|
goToOffsetDialog = new GoToOffsetDialog(this);
|
||||||
|
goToAddressDialog = new GoToAddressDialog(this);
|
||||||
model = NULL;
|
model = NULL;
|
||||||
ffsParser = NULL;
|
ffsParser = NULL;
|
||||||
ffsFinder = NULL;
|
ffsFinder = NULL;
|
||||||
@ -57,8 +58,8 @@ version(tr("NE alpha 40"))
|
|||||||
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(ui->actionGoToOffset, SIGNAL(triggered()), this, SLOT(goToOffset()));
|
||||||
|
connect(ui->actionGoToAddress, SIGNAL(triggered()), this, SLOT(goToAddress()));
|
||||||
connect(ui->actionLoadGuidDatabase, SIGNAL(triggered()), this, SLOT(loadGuidDatabase()));
|
connect(ui->actionLoadGuidDatabase, SIGNAL(triggered()), this, SLOT(loadGuidDatabase()));
|
||||||
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
|
||||||
@ -84,6 +85,7 @@ version(tr("NE alpha 40"))
|
|||||||
searchDialog->ui->hexEdit->setFont(font);
|
searchDialog->ui->hexEdit->setFont(font);
|
||||||
hexViewDialog->setFont(font);
|
hexViewDialog->setFont(font);
|
||||||
goToOffsetDialog->ui->hexSpinBox->setFont(font);
|
goToOffsetDialog->ui->hexSpinBox->setFont(font);
|
||||||
|
goToAddressDialog->ui->hexSpinBox->setFont(font);
|
||||||
|
|
||||||
// Load built-in GUID database
|
// Load built-in GUID database
|
||||||
initGuidDatabase(":/guids.csv");
|
initGuidDatabase(":/guids.csv");
|
||||||
@ -124,6 +126,7 @@ void UEFITool::init()
|
|||||||
// Disable menus
|
// Disable menus
|
||||||
ui->actionSearch->setEnabled(false);
|
ui->actionSearch->setEnabled(false);
|
||||||
ui->actionGoToOffset->setEnabled(false);
|
ui->actionGoToOffset->setEnabled(false);
|
||||||
|
ui->actionGoToAddress->setEnabled(false);
|
||||||
ui->menuCapsuleActions->setEnabled(false);
|
ui->menuCapsuleActions->setEnabled(false);
|
||||||
ui->menuImageActions->setEnabled(false);
|
ui->menuImageActions->setEnabled(false);
|
||||||
ui->menuRegionActions->setEnabled(false);
|
ui->menuRegionActions->setEnabled(false);
|
||||||
@ -344,6 +347,21 @@ void UEFITool::goToOffset()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UEFITool::goToAddress()
|
||||||
|
{
|
||||||
|
goToAddressDialog->ui->hexSpinBox->setFocus();
|
||||||
|
goToAddressDialog->ui->hexSpinBox->selectAll();
|
||||||
|
if (goToAddressDialog->exec() != QDialog::Accepted)
|
||||||
|
return;
|
||||||
|
|
||||||
|
UINT32 address = (UINT32)goToAddressDialog->ui->hexSpinBox->value();
|
||||||
|
QModelIndex index = model->findByOffset(address - ffsParser->getAddressDiff());
|
||||||
|
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();
|
||||||
@ -820,8 +838,10 @@ void UEFITool::openImageFile(QString path)
|
|||||||
delete ffsOps;
|
delete ffsOps;
|
||||||
ffsOps = new FfsOperations(model);
|
ffsOps = new FfsOperations(model);
|
||||||
|
|
||||||
// Enable goToOffset
|
// Enable goToOffset and goToAddress
|
||||||
ui->actionGoToOffset->setEnabled(true);
|
ui->actionGoToOffset->setEnabled(true);
|
||||||
|
if (ffsParser->getAddressDiff() < 0xFFFFFFFFUL)
|
||||||
|
ui->actionGoToAddress->setEnabled(true);
|
||||||
|
|
||||||
// Set current directory
|
// Set current directory
|
||||||
currentDir = fileInfo.absolutePath();
|
currentDir = fileInfo.absolutePath();
|
||||||
@ -1107,4 +1127,4 @@ void UEFITool::loadGuidDatabase()
|
|||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
|
|
||||||
#include "searchdialog.h"
|
#include "searchdialog.h"
|
||||||
#include "gotooffsetdialog.h"
|
#include "gotooffsetdialog.h"
|
||||||
|
#include "gotoaddressdialog.h"
|
||||||
#include "hexviewdialog.h"
|
#include "hexviewdialog.h"
|
||||||
#include "ffsfinder.h"
|
#include "ffsfinder.h"
|
||||||
|
|
||||||
@ -74,9 +75,9 @@ private slots:
|
|||||||
void openImageFileInNewWindow();
|
void openImageFileInNewWindow();
|
||||||
void saveImageFile();
|
void saveImageFile();
|
||||||
|
|
||||||
|
|
||||||
void search();
|
void search();
|
||||||
void goToOffset();
|
void goToOffset();
|
||||||
|
void goToAddress();
|
||||||
|
|
||||||
void hexView();
|
void hexView();
|
||||||
void bodyHexView();
|
void bodyHexView();
|
||||||
@ -125,6 +126,7 @@ private:
|
|||||||
SearchDialog* searchDialog;
|
SearchDialog* searchDialog;
|
||||||
HexViewDialog* hexViewDialog;
|
HexViewDialog* hexViewDialog;
|
||||||
GoToOffsetDialog* goToOffsetDialog;
|
GoToOffsetDialog* goToOffsetDialog;
|
||||||
|
GoToAddressDialog* goToAddressDialog;
|
||||||
QClipboard* clipboard;
|
QClipboard* clipboard;
|
||||||
QString currentDir;
|
QString currentDir;
|
||||||
QString currentPath;
|
QString currentPath;
|
||||||
@ -141,7 +143,6 @@ private:
|
|||||||
void showFinderMessages();
|
void showFinderMessages();
|
||||||
void showFitTable();
|
void showFitTable();
|
||||||
void showBuilderMessages();
|
void showBuilderMessages();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // UEFITOOL_H
|
#endif // UEFITOOL_H
|
||||||
|
@ -10,6 +10,7 @@ HEADERS += uefitool.h \
|
|||||||
searchdialog.h \
|
searchdialog.h \
|
||||||
hexviewdialog.h \
|
hexviewdialog.h \
|
||||||
gotooffsetdialog.h \
|
gotooffsetdialog.h \
|
||||||
|
gotoaddressdialog.h \
|
||||||
guidlineedit.h \
|
guidlineedit.h \
|
||||||
ffsfinder.h \
|
ffsfinder.h \
|
||||||
hexspinbox.h \
|
hexspinbox.h \
|
||||||
@ -78,7 +79,8 @@ SOURCES += uefitool_main.cpp \
|
|||||||
FORMS += uefitool.ui \
|
FORMS += uefitool.ui \
|
||||||
searchdialog.ui \
|
searchdialog.ui \
|
||||||
hexviewdialog.ui \
|
hexviewdialog.ui \
|
||||||
gotooffsetdialog.ui
|
gotooffsetdialog.ui \
|
||||||
|
gotoaddressdialog.ui
|
||||||
|
|
||||||
RESOURCES += uefitool.qrc
|
RESOURCES += uefitool.qrc
|
||||||
RC_FILE = uefitool.rc
|
RC_FILE = uefitool.rc
|
||||||
|
@ -272,8 +272,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>850</width>
|
<width>851</width>
|
||||||
<height>22</height>
|
<height>21</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuFile">
|
<widget class="QMenu" name="menuFile">
|
||||||
@ -478,6 +478,7 @@
|
|||||||
<addaction name="actionReplaceBody"/>
|
<addaction name="actionReplaceBody"/>
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="actionGoToOffset"/>
|
<addaction name="actionGoToOffset"/>
|
||||||
|
<addaction name="actionGoToAddress"/>
|
||||||
<addaction name="actionSearch"/>
|
<addaction name="actionSearch"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="menuCapsuleActions"/>
|
<addaction name="menuCapsuleActions"/>
|
||||||
@ -799,6 +800,17 @@
|
|||||||
<string>Ctrl+Alt+G</string>
|
<string>Ctrl+Alt+G</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionGoToAddress">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Go to &address...</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+Shift+G</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
@ -2818,13 +2818,13 @@ USTATUS FfsParser::performSecondPass(const UModelIndex & index)
|
|||||||
|
|
||||||
// Calculate address difference
|
// Calculate address difference
|
||||||
const UINT32 vtfSize = model->header(lastVtf).size() + model->body(lastVtf).size() + model->tail(lastVtf).size();
|
const UINT32 vtfSize = model->header(lastVtf).size() + model->body(lastVtf).size() + model->tail(lastVtf).size();
|
||||||
const UINT32 diff = 0xFFFFFFFFUL - model->offset(lastVtf) - vtfSize + 1;
|
addressDiff = 0xFFFFFFFFUL - model->offset(lastVtf) - vtfSize + 1;
|
||||||
|
|
||||||
// Find and parse FIT
|
// Find and parse FIT
|
||||||
parseFit(index, diff);
|
parseFit(index);
|
||||||
|
|
||||||
// Apply address information to index and all it's child items
|
// Apply address information to index and all it's child items
|
||||||
addMemoryAddressesRecursive(index, diff);
|
addMemoryAddressesRecursive(index);
|
||||||
|
|
||||||
// Add fixed and compressed
|
// Add fixed and compressed
|
||||||
addFixedAndCompressedRecursive(index);
|
addFixedAndCompressedRecursive(index);
|
||||||
@ -2849,7 +2849,7 @@ USTATUS FfsParser::addFixedAndCompressedRecursive(const UModelIndex & index) {
|
|||||||
return U_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
USTATUS FfsParser::parseFit(const UModelIndex & index, const UINT32 diff)
|
USTATUS FfsParser::parseFit(const UModelIndex & index)
|
||||||
{
|
{
|
||||||
// Check sanity
|
// Check sanity
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
@ -2858,7 +2858,7 @@ USTATUS FfsParser::parseFit(const UModelIndex & index, const UINT32 diff)
|
|||||||
// Search for FIT
|
// Search for FIT
|
||||||
UModelIndex fitIndex;
|
UModelIndex fitIndex;
|
||||||
UINT32 fitOffset;
|
UINT32 fitOffset;
|
||||||
USTATUS result = findFitRecursive(index, diff, fitIndex, fitOffset);
|
USTATUS result = findFitRecursive(index, fitIndex, fitOffset);
|
||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
@ -2922,8 +2922,8 @@ USTATUS FfsParser::parseFit(const UModelIndex & index, const UINT32 diff)
|
|||||||
|
|
||||||
case FIT_TYPE_MICROCODE: {
|
case FIT_TYPE_MICROCODE: {
|
||||||
//TODO: refactor into function with error reporting
|
//TODO: refactor into function with error reporting
|
||||||
if (currentEntry->Address > diff && currentEntry->Address < 0xFFFFFFFFUL) {
|
if (currentEntry->Address > addressDiff && currentEntry->Address < 0xFFFFFFFFUL) {
|
||||||
UINT32 offset = (UINT32)currentEntry->Address - diff;
|
UINT32 offset = (UINT32)currentEntry->Address - addressDiff;
|
||||||
UModelIndex mcIndex = model->findByOffset(offset);
|
UModelIndex mcIndex = model->findByOffset(offset);
|
||||||
UByteArray mcFile = model->header(mcIndex) + model->body(mcIndex) + model->tail(mcIndex);
|
UByteArray mcFile = model->header(mcIndex) + model->body(mcIndex) + model->tail(mcIndex);
|
||||||
|
|
||||||
@ -2962,8 +2962,8 @@ USTATUS FfsParser::parseFit(const UModelIndex & index, const UINT32 diff)
|
|||||||
case FIT_TYPE_AC_KEY_MANIFEST:
|
case FIT_TYPE_AC_KEY_MANIFEST:
|
||||||
case FIT_TYPE_AC_BOOT_POLICY:
|
case FIT_TYPE_AC_BOOT_POLICY:
|
||||||
default:
|
default:
|
||||||
if (currentEntry->Address > diff && currentEntry->Address < 0xFFFFFFFFUL) {
|
if (currentEntry->Address > addressDiff && currentEntry->Address < 0xFFFFFFFFUL) {
|
||||||
UINT32 offset = (UINT32)currentEntry->Address - diff;
|
UINT32 offset = (UINT32)currentEntry->Address - addressDiff;
|
||||||
itemIndex = model->findByOffset(offset);
|
itemIndex = model->findByOffset(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2987,7 +2987,7 @@ USTATUS FfsParser::parseFit(const UModelIndex & index, const UINT32 diff)
|
|||||||
return U_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
USTATUS FfsParser::findFitRecursive(const UModelIndex & index, const UINT32 diff, UModelIndex & found, UINT32 & fitOffset)
|
USTATUS FfsParser::findFitRecursive(const UModelIndex & index, UModelIndex & found, UINT32 & fitOffset)
|
||||||
{
|
{
|
||||||
// Sanity check
|
// Sanity check
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
@ -2995,7 +2995,7 @@ USTATUS FfsParser::findFitRecursive(const UModelIndex & index, const UINT32 diff
|
|||||||
|
|
||||||
// Process child items
|
// Process child items
|
||||||
for (int i = 0; i < model->rowCount(index); i++) {
|
for (int i = 0; i < model->rowCount(index); i++) {
|
||||||
findFitRecursive(index.child(i, 0), diff, found, fitOffset);
|
findFitRecursive(index.child(i, 0), found, fitOffset);
|
||||||
if (found.isValid())
|
if (found.isValid())
|
||||||
return U_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -3007,7 +3007,7 @@ USTATUS FfsParser::findFitRecursive(const UModelIndex & index, const UINT32 diff
|
|||||||
offset >= 0;
|
offset >= 0;
|
||||||
offset = model->body(index).indexOf(FIT_SIGNATURE, offset + 1)) {
|
offset = model->body(index).indexOf(FIT_SIGNATURE, offset + 1)) {
|
||||||
// FIT candidate found, calculate it's physical address
|
// FIT candidate found, calculate it's physical address
|
||||||
UINT32 fitAddress = model->offset(index) + diff + model->header(index).size() + (UINT32)offset;
|
UINT32 fitAddress = model->offset(index) + addressDiff + model->header(index).size() + (UINT32)offset;
|
||||||
|
|
||||||
// Check FIT address to be stored in the last VTF
|
// Check FIT address to be stored in the last VTF
|
||||||
if (fitAddress == storedFitAddress) {
|
if (fitAddress == storedFitAddress) {
|
||||||
@ -3023,7 +3023,7 @@ USTATUS FfsParser::findFitRecursive(const UModelIndex & index, const UINT32 diff
|
|||||||
return U_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
USTATUS FfsParser::addMemoryAddressesRecursive(const UModelIndex & index, const UINT32 diff)
|
USTATUS FfsParser::addMemoryAddressesRecursive(const UModelIndex & index)
|
||||||
{
|
{
|
||||||
// Sanity check
|
// Sanity check
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
@ -3032,7 +3032,7 @@ USTATUS FfsParser::addMemoryAddressesRecursive(const UModelIndex & index, const
|
|||||||
// Set address value for non-compressed data
|
// Set address value for non-compressed data
|
||||||
if (!model->compressed(index)) {
|
if (!model->compressed(index)) {
|
||||||
// Check address sanity
|
// Check address sanity
|
||||||
UINT64 address = (const UINT64)diff + model->offset(index);
|
UINT64 address = (const UINT64)addressDiff + model->offset(index);
|
||||||
if (address <= 0xFFFFFFFFUL) {
|
if (address <= 0xFFFFFFFFUL) {
|
||||||
// Update info
|
// Update info
|
||||||
UINT32 headerSize = model->header(index).size();
|
UINT32 headerSize = model->header(index).size();
|
||||||
@ -3098,7 +3098,7 @@ USTATUS FfsParser::addMemoryAddressesRecursive(const UModelIndex & index, const
|
|||||||
|
|
||||||
// Process child items
|
// Process child items
|
||||||
for (int i = 0; i < model->rowCount(index); i++) {
|
for (int i = 0; i < model->rowCount(index); i++) {
|
||||||
addMemoryAddressesRecursive(index.child(i, 0), diff);
|
addMemoryAddressesRecursive(index.child(i, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
return U_SUCCESS;
|
return U_SUCCESS;
|
||||||
|
@ -26,10 +26,10 @@ class FfsParser
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Default constructor and destructor
|
// Default constructor and destructor
|
||||||
FfsParser(TreeModel* treeModel) : model(treeModel), nvramParser(treeModel), meParser(treeModel), capsuleOffsetFixup(0) {}
|
FfsParser(TreeModel* treeModel) : model(treeModel), nvramParser(treeModel), meParser(treeModel), capsuleOffsetFixup(0), addressDiff(0x100000000ULL) {}
|
||||||
~FfsParser() {}
|
~FfsParser() {}
|
||||||
|
|
||||||
// Returns messages
|
// Obtain parser messages
|
||||||
std::vector<std::pair<UString, UModelIndex> > getMessages() const {
|
std::vector<std::pair<UString, UModelIndex> > getMessages() const {
|
||||||
std::vector<std::pair<UString, UModelIndex> > meVector = meParser.getMessages();
|
std::vector<std::pair<UString, UModelIndex> > meVector = meParser.getMessages();
|
||||||
std::vector<std::pair<UString, UModelIndex> > nvramVector = nvramParser.getMessages();
|
std::vector<std::pair<UString, UModelIndex> > nvramVector = nvramParser.getMessages();
|
||||||
@ -39,15 +39,18 @@ public:
|
|||||||
return resultVector;
|
return resultVector;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clears messages
|
// Clear messages
|
||||||
void clearMessages() { messagesVector.clear(); }
|
void clearMessages() { messagesVector.clear(); }
|
||||||
|
|
||||||
// Firmware image parsing
|
// Parse firmware image
|
||||||
USTATUS parse(const UByteArray &buffer);
|
USTATUS parse(const UByteArray &buffer);
|
||||||
|
|
||||||
// Obtain parsed FIT table
|
// Obtain parsed FIT table
|
||||||
std::vector<std::pair<std::vector<UString>, UModelIndex> > getFitTable() const { return fitTable; }
|
std::vector<std::pair<std::vector<UString>, UModelIndex> > getFitTable() const { return fitTable; }
|
||||||
|
|
||||||
|
// Obtain offset/address difference
|
||||||
|
UINT64 getAddressDiff() { return addressDiff; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TreeModel *model;
|
TreeModel *model;
|
||||||
std::vector<std::pair<UString, UModelIndex> > messagesVector;
|
std::vector<std::pair<UString, UModelIndex> > messagesVector;
|
||||||
@ -60,6 +63,7 @@ private:
|
|||||||
|
|
||||||
UModelIndex lastVtf;
|
UModelIndex lastVtf;
|
||||||
UINT32 capsuleOffsetFixup;
|
UINT32 capsuleOffsetFixup;
|
||||||
|
UINT64 addressDiff;
|
||||||
std::vector<std::pair<std::vector<UString>, UModelIndex> > fitTable;
|
std::vector<std::pair<std::vector<UString>, UModelIndex> > fitTable;
|
||||||
|
|
||||||
// First pass
|
// First pass
|
||||||
@ -109,10 +113,10 @@ private:
|
|||||||
// Second pass
|
// Second pass
|
||||||
USTATUS performSecondPass(const UModelIndex & index);
|
USTATUS performSecondPass(const UModelIndex & index);
|
||||||
USTATUS addOffsetsRecursive(const UModelIndex & index);
|
USTATUS addOffsetsRecursive(const UModelIndex & index);
|
||||||
USTATUS addMemoryAddressesRecursive(const UModelIndex & index, const UINT32 diff);
|
USTATUS addMemoryAddressesRecursive(const UModelIndex & index);
|
||||||
USTATUS addFixedAndCompressedRecursive(const UModelIndex & index);
|
USTATUS addFixedAndCompressedRecursive(const UModelIndex & index);
|
||||||
USTATUS parseFit(const UModelIndex & index, const UINT32 diff);
|
USTATUS parseFit(const UModelIndex & index);
|
||||||
USTATUS findFitRecursive(const UModelIndex & index, const UINT32 diff, UModelIndex & found, UINT32 & fitOffset);
|
USTATUS findFitRecursive(const UModelIndex & index, UModelIndex & found, UINT32 & fitOffset);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FFSPARSER_H
|
#endif // FFSPARSER_H
|
||||||
|
@ -124,7 +124,6 @@ public:
|
|||||||
UModelIndex createIndex(int row, int column, void *data) const { return UModelIndex(row, column, data, this); }
|
UModelIndex createIndex(int row, int column, void *data) const { return UModelIndex(row, column, data, this); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
~TreeModel() {
|
~TreeModel() {
|
||||||
delete rootItem;
|
delete rootItem;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user