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
This commit is contained in:
Nikolaj Schlej 2016-03-29 16:15:23 +02:00
parent 95290abb94
commit 5557acd7d8
5 changed files with 43 additions and 10 deletions

View File

@ -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;
}
}

View File

@ -403,6 +403,27 @@
<addaction name="actionExtract"/>
<addaction name="actionExtractBody"/>
<addaction name="separator"/>
<addaction name="actionInsertBefore"/>
<addaction name="actionInsertAfter"/>
<addaction name="separator"/>
<addaction name="actionRebuild"/>
<addaction name="separator"/>
<addaction name="actionReplace"/>
<addaction name="actionReplaceBody"/>
<addaction name="separator"/>
<addaction name="actionRemove"/>
</widget>
<widget class="QMenu" name="menuStorageActions">
<property name="title">
<string>S&amp;torage</string>
</property>
<addaction name="actionExtract"/>
<addaction name="actionExtractBody"/>
<addaction name="separator"/>
<addaction name="actionInsertInto"/>
<addaction name="actionInsertBefore"/>
<addaction name="actionInsertAfter"/>
<addaction name="separator"/>
<addaction name="actionRebuild"/>
<addaction name="separator"/>
<addaction name="actionReplace"/>
@ -415,6 +436,7 @@
<addaction name="menuVolumeActions"/>
<addaction name="menuFileActions"/>
<addaction name="menuSectionActions"/>
<addaction name="menuStorageActions"/>
<addaction name="menuVariableActions"/>
<addaction name="separator"/>
<addaction name="menuMessages"/>

View File

@ -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('/', '_');
}

View File

@ -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();

View File

@ -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());