From 5557acd7d837de6cbb60684497d2596a0fbc16e0 Mon Sep 17 00:00:00 2001 From: Nikolaj Schlej Date: Tue, 29 Mar 2016 16:15:23 +0200 Subject: [PATCH] UT NE A23 - added UI for VSS storage operations - changed VSS storage/vars parsing order - solved problems with GUIDs as filenames - Fsys, _FDC and other NVRAM formats TBD --- UEFITool/uefitool.cpp | 9 +++++++++ UEFITool/uefitool.ui | 22 ++++++++++++++++++++++ common/ffsops.cpp | 5 +++-- common/ffsparser.cpp | 15 ++++++++------- common/ffsparser.h | 2 +- 5 files changed, 43 insertions(+), 10 deletions(-) diff --git a/UEFITool/uefitool.cpp b/UEFITool/uefitool.cpp index fcc5844..7cbb2bb 100644 --- a/UEFITool/uefitool.cpp +++ b/UEFITool/uefitool.cpp @@ -536,6 +536,9 @@ void UEFITool::extract(const UINT8 mode) case Types::NvramVariableVss: path = QFileDialog::getSaveFileName(this, tr("Save variable to file"), name + ".var", "Variable files (*.var *.bin);;All files (*)"); break; + case Types::NvramStorageVss: + path = QFileDialog::getSaveFileName(this, tr("Save variable storage to file"), name + ".vss", "Variable storage files (*.vss *.bin);;All files (*)"); + break; default: path = QFileDialog::getSaveFileName(this, tr("Save object to file"), name + ".bin", "Binary files (*.bin);;All files (*)"); } @@ -572,6 +575,9 @@ void UEFITool::extract(const UINT8 mode) case Types::NvramVariableVss: path = QFileDialog::getSaveFileName(this, tr("Save variable body to file"), name + ".bin", "Binary files (*.bin);;All files (*)"); break; + case Types::NvramStorageVss: + path = QFileDialog::getSaveFileName(this, tr("Save variable storage body to file"), name + ".vsb", "Variable storage body files (*.vsb *.bin);;All files (*)"); + break; default: path = QFileDialog::getSaveFileName(this, tr("Save object to file"), name + ".bin", "Binary files (*.bin);;All files (*)"); } @@ -937,6 +943,9 @@ void UEFITool::contextMenuEvent(QContextMenuEvent* event) case Types::NvramVariableVss: ui->menuVariableActions->exec(event->globalPos()); break; + case Types::NvramStorageVss: + ui->menuStorageActions->exec(event->globalPos()); + break; } } diff --git a/UEFITool/uefitool.ui b/UEFITool/uefitool.ui index 9dd1f31..7e4d60e 100644 --- a/UEFITool/uefitool.ui +++ b/UEFITool/uefitool.ui @@ -403,6 +403,27 @@ + + + + + + + + + + + + + S&torage + + + + + + + + @@ -415,6 +436,7 @@ + diff --git a/common/ffsops.cpp b/common/ffsops.cpp index 39c6b44..8b4bb87 100644 --- a/common/ffsops.cpp +++ b/common/ffsops.cpp @@ -52,9 +52,9 @@ STATUS FfsOperations::extract(const QModelIndex & index, QString & name, QByteAr switch (model->type(index)) { case Types::Volume: { if (pdata.volume.hasExtendedHeader) - name = guidToQString(pdata.volume.extendedHeaderGuid); + name = guidToQString(pdata.volume.extendedHeaderGuid).replace('-', '_'); else - name = itemName; + name = itemName.replace('-', '_'); } break; case Types::NvramVariableNvar: case Types::NvramVariableVss: @@ -73,6 +73,7 @@ STATUS FfsOperations::extract(const QModelIndex & index, QString & name, QByteAr case Types::Image: case Types::Region: case Types::Padding: + case Types::NvramStorageVss: default: name = itemName.replace(' ', '_').replace('/', '_'); } diff --git a/common/ffsparser.cpp b/common/ffsparser.cpp index 7cfaed1..bfabacb 100644 --- a/common/ffsparser.cpp +++ b/common/ffsparser.cpp @@ -3360,11 +3360,11 @@ STATUS FfsParser::parseStorageArea(const QByteArray & data, const QModelIndex & } // Parse bodies - /* for (int i = 0; i < model->rowCount(index); i++) { + for (int i = 0; i < model->rowCount(index); i++) { QModelIndex current = index.child(i, 0); switch (model->type(current)) { - case Types::Volume: - parseVolumeBody(current); + case Types::NvramStorageVss: + parseVssStorageBody(current); break; case Types::Padding: // No parsing required @@ -3373,7 +3373,7 @@ STATUS FfsParser::parseStorageArea(const QByteArray & data, const QModelIndex & return ERR_UNKNOWN_ITEM_TYPE; } } - */ + return ERR_SUCCESS; } @@ -3421,7 +3421,7 @@ STATUS FfsParser::findNextStorage(const QModelIndex & index, const QByteArray & STATUS FfsParser::getStorageSize(const QByteArray & data, const UINT32 storageOffset, UINT32 & storageSize) { - //TODO: add Fsys support + //TODO: add Fsys, GUID and _FDC support const VSS_VARIABLE_STORE_HEADER* vssHeader = (const VSS_VARIABLE_STORE_HEADER*)(data.constData() + storageOffset); storageSize = vssHeader->Size; return ERR_SUCCESS; @@ -3480,12 +3480,12 @@ STATUS FfsParser::parseStorageHeader(const QByteArray & storage, const UINT32 pa index = model->addItem(Types::NvramStorageVss, 0, name, QString(), info, header, body, TRUE, parsingDataToQByteArray(pdata), parent); //Parse the storage - parseVssStorageBody(body, index); + //parseVssStorageBody(body, index); return ERR_SUCCESS; } -STATUS FfsParser::parseVssStorageBody(const QByteArray & data, const QModelIndex & index) +STATUS FfsParser::parseVssStorageBody(const QModelIndex & index) { // Sanity check if (!index.isValid()) @@ -3494,6 +3494,7 @@ STATUS FfsParser::parseVssStorageBody(const QByteArray & data, const QModelIndex // Get parsing data for the current item PARSING_DATA pdata = parsingDataFromQModelIndex(index); UINT32 parentOffset = pdata.offset + model->header(index).size(); + const QByteArray data = model->body(index); // Check that the is enough space for variable header const UINT32 dataSize = (UINT32)data.size(); diff --git a/common/ffsparser.h b/common/ffsparser.h index 9949c2c..e202187 100644 --- a/common/ffsparser.h +++ b/common/ffsparser.h @@ -113,7 +113,7 @@ private: STATUS findNextStorage(const QModelIndex & index, const QByteArray & data, const UINT32 parentOffset, const UINT32 storageOffset, UINT32 & nextStorageOffset); STATUS getStorageSize(const QByteArray & data, const UINT32 storageOffset, UINT32 & storageSize); STATUS parseStorageHeader(const QByteArray & storage, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index); - STATUS parseVssStorageBody(const QByteArray & data, const QModelIndex & index); + STATUS parseVssStorageBody(const QModelIndex & index); // Message helper void msg(const QString & message, const QModelIndex &index = QModelIndex());