A bit of refactoring here and there

- more refactoring to go, because new NVRAM code was written in a hurry
and needs to be cleaned up
This commit is contained in:
Nikolaj Schlej 2016-04-17 01:25:44 +02:00
parent 4b34fe546d
commit cda0018a29
12 changed files with 438 additions and 629 deletions

View File

@ -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("0.30.0_alpha25")) version(tr("0.30.0_alpha26"))
{ {
clipboard = QApplication::clipboard(); clipboard = QApplication::clipboard();
@ -31,9 +31,6 @@ version(tr("0.30.0_alpha25"))
ffsOps = NULL; ffsOps = NULL;
ffsBuilder = NULL; ffsBuilder = NULL;
// Set window title
this->setWindowTitle(tr("UEFITool %1").arg(version));
// Connect signals to slots // Connect signals to slots
connect(ui->actionOpenImageFile, SIGNAL(triggered()), this, SLOT(openImageFile())); connect(ui->actionOpenImageFile, SIGNAL(triggered()), this, SLOT(openImageFile()));
connect(ui->actionOpenImageFileInNewWindow, SIGNAL(triggered()), this, SLOT(openImageFileInNewWindow())); connect(ui->actionOpenImageFileInNewWindow, SIGNAL(triggered()), this, SLOT(openImageFileInNewWindow()));
@ -59,7 +56,7 @@ version(tr("0.30.0_alpha25"))
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
this->setAcceptDrops(true); setAcceptDrops(true);
// Set current directory // Set current directory
currentDir = "."; currentDir = ".";
@ -73,8 +70,9 @@ version(tr("0.30.0_alpha25"))
#endif #endif
ui->infoEdit->setFont(font); ui->infoEdit->setFont(font);
ui->parserMessagesListWidget->setFont(font); ui->parserMessagesListWidget->setFont(font);
ui->finderMessagesListWidget->setFont(font);
ui->fitMessagesListWidget->setFont(font); ui->fitMessagesListWidget->setFont(font);
ui->finderMessagesListWidget->setFont(font);
ui->builderMessagesListWidget->setFont(font);
ui->fitTableWidget->setFont(font); ui->fitTableWidget->setFont(font);
ui->structureTreeView->setFont(font); ui->structureTreeView->setFont(font);
searchDialog->ui->guidEdit->setFont(font); searchDialog->ui->guidEdit->setFont(font);
@ -89,21 +87,16 @@ version(tr("0.30.0_alpha25"))
UEFITool::~UEFITool() UEFITool::~UEFITool()
{ {
delete ffsBuilder;
delete ffsOps; delete ffsOps;
delete ffsFinder; delete ffsFinder;
delete fitParser; delete fitParser;
delete ffsParser; delete ffsParser;
delete ffsBuilder;
delete model; delete model;
delete searchDialog; delete searchDialog;
delete ui; delete ui;
} }
void UEFITool::setProgramPath(QString path)
{
currentProgramPath = path;
};
void UEFITool::init() void UEFITool::init()
{ {
// Clear components // Clear components
@ -116,7 +109,7 @@ void UEFITool::init()
ui->messagesTabWidget->setTabEnabled(1, false); ui->messagesTabWidget->setTabEnabled(1, false);
// Set window title // Set window title
this->setWindowTitle(tr("UEFITool %1").arg(version)); setWindowTitle(tr("UEFITool %1").arg(version));
// Disable menus // Disable menus
ui->menuCapsuleActions->setDisabled(true); ui->menuCapsuleActions->setDisabled(true);
@ -126,6 +119,9 @@ void UEFITool::init()
ui->menuVolumeActions->setDisabled(true); ui->menuVolumeActions->setDisabled(true);
ui->menuFileActions->setDisabled(true); ui->menuFileActions->setDisabled(true);
ui->menuSectionActions->setDisabled(true); ui->menuSectionActions->setDisabled(true);
ui->menuStoreActions->setDisabled(true);
ui->menuVariableActions->setDisabled(true);
ui->actionMessagesCopy->setDisabled(true); ui->actionMessagesCopy->setDisabled(true);
ui->actionMessagesCopyAll->setDisabled(true); ui->actionMessagesCopyAll->setDisabled(true);
@ -145,16 +141,17 @@ void UEFITool::init()
this, SLOT(populateUi(const QModelIndex &))); this, SLOT(populateUi(const QModelIndex &)));
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(itemEntered(QListWidgetItem*)), this, SLOT(enableMessagesCopyActions(QListWidgetItem*)));
connect(ui->fitMessagesListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(scrollTreeView(QListWidgetItem*))); connect(ui->fitMessagesListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(scrollTreeView(QListWidgetItem*)));
connect(ui->fitMessagesListWidget, SIGNAL(itemEntered(QListWidgetItem*)), this, SLOT(enableMessagesCopyActions(QListWidgetItem*))); connect(ui->fitMessagesListWidget, SIGNAL(itemEntered(QListWidgetItem*)), this, SLOT(enableMessagesCopyActions(QListWidgetItem*)));
connect(ui->finderMessagesListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(scrollTreeView(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*)));
} }
void UEFITool::populateUi(const QModelIndex &current) void UEFITool::populateUi(const QModelIndex &current)
{ {
// Check sanity
if (!current.isValid()) if (!current.isValid())
return; return;
@ -172,15 +169,24 @@ void UEFITool::populateUi(const QModelIndex &current)
ui->menuVolumeActions->setEnabled(type == Types::Volume); ui->menuVolumeActions->setEnabled(type == Types::Volume);
ui->menuFileActions->setEnabled(type == Types::File); ui->menuFileActions->setEnabled(type == Types::File);
ui->menuSectionActions->setEnabled(type == Types::Section); ui->menuSectionActions->setEnabled(type == Types::Section);
ui->menuVariableActions->setEnabled(type == Types::NvramVariableNvar || type == Types::NvramVariableVss || type == Types::NvramEntryFsys ui->menuVariableActions->setEnabled(type == Types::NvarEntry
|| type == Types::NvramEntryEvsa || type == Types::NvramEntryFlashMap); || type == Types::VssEntry
ui->menuStoreActions->setEnabled(type == Types::NvramStoreVss || type == Types::NvramStoreFdc || type == Types::NvramStoreFsys || type == Types::FsysEntry
|| type == Types::NvramStoreEvsa || type == Types::NvramStoreFtw || type == Types::NvramStoreFlashMap || type == Types::NvramStoreCmdb || type == Types::EvsaEntry
|| type == Types::Microcode || type == Types::SlicPubkey || type == Types::SlicMarker); || type == Types::FlashMapEntry);
ui->menuStoreActions->setEnabled(type == Types::VssStore
|| type == Types::FdcStore
|| type == Types::FsysStore
|| type == Types::EvsaStore
|| type == Types::FtwStore
|| type == Types::FlashMapStore
|| type == Types::CmdbStore
|| type == Types::Microcode
|| type == Types::SlicData);
// Enable actions // Enable actions
ui->actionExtract->setDisabled(model->hasEmptyHeader(current) && model->hasEmptyBody(current)); ui->actionExtract->setDisabled(model->hasEmptyHeader(current) && model->hasEmptyBody(current));
ui->actionGoToData->setEnabled(type == Types::NvramVariableNvar && subtype == Subtypes::LinkNvarVariable); ui->actionGoToData->setEnabled(type == Types::NvarEntry && subtype == Subtypes::LinkNvarEntry);
// Disable rebuild for now // Disable rebuild for now
//ui->actionRebuild->setDisabled(type == Types::Region && subtype == Subtypes::DescriptorRegion); //ui->actionRebuild->setDisabled(type == Types::Region && subtype == Subtypes::DescriptorRegion);
@ -284,7 +290,7 @@ void UEFITool::search()
void UEFITool::goToData() void UEFITool::goToData()
{ {
QModelIndex index = ui->structureTreeView->selectionModel()->currentIndex(); QModelIndex index = ui->structureTreeView->selectionModel()->currentIndex();
if (!index.isValid() || model->type(index) != Types::NvramVariableNvar || model->subtype(index) != Subtypes::LinkNvarVariable) if (!index.isValid() || model->type(index) != Types::NvarEntry || model->subtype(index) != Subtypes::LinkNvarEntry)
return; return;
// Get parent // Get parent
@ -515,122 +521,77 @@ void UEFITool::extract(const UINT8 mode)
//ui->statusBar->showMessage(name); //ui->statusBar->showMessage(name);
UINT8 type = model->type(index); UINT8 type = model->type(index);
UINT8 subtype = model->subtype(index);
QString path; QString path;
if (mode == EXTRACT_MODE_AS_IS) { if (mode == EXTRACT_MODE_AS_IS) {
switch (type) { switch (type) {
case Types::Capsule: case Types::Capsule: path = QFileDialog::getSaveFileName(this, tr("Save capsule to file"), name + ".cap", "Capsule files (*.cap *.bin);;All files (*)"); break;
path = QFileDialog::getSaveFileName(this, tr("Save capsule to file"), name + ".cap", "Capsule files (*.cap *.bin);;All files (*)"); case Types::Image: path = QFileDialog::getSaveFileName(this, tr("Save image to file"), name + ".rom", "Image files (*.rom *.bin);;All files (*)"); break;
case Types::Region: path = QFileDialog::getSaveFileName(this, tr("Save region to file"), name + ".rgn", "Region files (*.rgn *.bin);;All files (*)"); break;
case Types::Padding: path = QFileDialog::getSaveFileName(this, tr("Save padding to file"), name + ".pad", "Padding files (*.pad *.bin);;All files (*)"); break;
case Types::Volume: path = QFileDialog::getSaveFileName(this, tr("Save volume to file"), name + ".vol", "Volume files (*.vol *.bin);;All files (*)"); break;
case Types::File: path = QFileDialog::getSaveFileName(this, tr("Save FFS file to file"), name + ".ffs", "FFS files (*.ffs *.bin);;All files (*)"); break;
case Types::Section: path = QFileDialog::getSaveFileName(this, tr("Save section to file"), name + ".sct", "Section files (*.sct *.bin);;All files (*)"); break;
case Types::NvarEntry: path = QFileDialog::getSaveFileName(this, tr("Save NVAR entry to file"), name + ".nvar", "NVAR entry files (*.nvar *.bin);;All files (*)"); break;
case Types::VssEntry: path = QFileDialog::getSaveFileName(this, tr("Save VSS entry to file"), name + ".vss", "VSS entry files (*.vss *.bin);;All files (*)"); break;
case Types::FsysEntry: path = QFileDialog::getSaveFileName(this, tr("Save Fsys entry to file"), name + ".fse", "Fsys entry files (*.fse *.bin);;All files (*)"); break;
case Types::EvsaEntry: path = QFileDialog::getSaveFileName(this, tr("Save EVSA entry to file"), name + ".evse", "EVSA entry files (*.evse *.bin);;All files (*)"); break;
case Types::FlashMapEntry: path = QFileDialog::getSaveFileName(this, tr("Save FlashMap entry to file"), name + ".fme", "FlashMap entry files (*.fme *.bin);;All files (*)"); break;
case Types::VssStore: path = QFileDialog::getSaveFileName(this, tr("Save VSS store to file"), name + ".vss", "VSS store files (*.vss *.bin);;All files (*)"); break;
case Types::FdcStore: path = QFileDialog::getSaveFileName(this, tr("Save FDC store to file"), name + ".fdc", "FDC store files (*.fdc *.bin);;All files (*)"); break;
case Types::FsysStore: path = QFileDialog::getSaveFileName(this, tr("Save Fsys store to file"), name + ".fsys", "Fsys store files (*.fsys *.bin);;All files (*)"); break;
case Types::EvsaStore: path = QFileDialog::getSaveFileName(this, tr("Save EVSA store to file"), name + ".evsa", "EVSA store files (*.evsa *.bin);;All files (*)"); break;
case Types::FtwStore: path = QFileDialog::getSaveFileName(this, tr("Save FTW store to file"), name + ".ftw", "FTW store files (*.ftw *.bin);;All files (*)"); break;
case Types::FlashMapStore: path = QFileDialog::getSaveFileName(this, tr("Save FlashMap store to file"), name + ".fmap", "FlashMap store files (*.fmap *.bin);;All files (*)"); break;
case Types::CmdbStore: path = QFileDialog::getSaveFileName(this, tr("Save CMDB store to file"), name + ".cmdb", "CMDB store files (*.cmdb *.bin);;All files (*)"); break;
case Types::Microcode: path = QFileDialog::getSaveFileName(this, tr("Save microcode binary to file"), name + ".ucd", "Microcode binary files (*.ucd *.bin);;All files (*)"); break;
case Types::SlicData:
if (subtype == Subtypes::PubkeySlicData) path = QFileDialog::getSaveFileName(this, tr("Save SLIC pubkey to file"), name + ".spk", "SLIC pubkey files (*.spk *.bin);;All files (*)");
else path = QFileDialog::getSaveFileName(this, tr("Save SLIC marker to file"), name + ".smk", "SLIC marker files (*.smk *.bin);;All files (*)");
break; break;
case Types::Image: default: path = QFileDialog::getSaveFileName(this, tr("Save object to file"), name + ".bin", "Binary files (*.bin);;All files (*)");
path = QFileDialog::getSaveFileName(this, tr("Save image to file"), name + ".rom", "Image files (*.rom *.bin);;All files (*)");
break;
case Types::Region:
path = QFileDialog::getSaveFileName(this, tr("Save region to file"), name + ".rgn", "Region files (*.rgn *.bin);;All files (*)");
break;
case Types::Padding:
path = QFileDialog::getSaveFileName(this, tr("Save padding to file"), name + ".pad", "Padding files (*.pad *.bin);;All files (*)");
break;
case Types::Volume:
path = QFileDialog::getSaveFileName(this, tr("Save volume to file"), name + ".vol", "Volume files (*.vol *.bin);;All files (*)");
break;
case Types::File:
path = QFileDialog::getSaveFileName(this, tr("Save FFS file to file"), name + ".ffs", "FFS files (*.ffs *.bin);;All files (*)");
break;
case Types::Section:
path = QFileDialog::getSaveFileName(this, tr("Save section to file"), name + ".sct", "Section files (*.sct *.bin);;All files (*)");
break;
case Types::NvramVariableNvar:
path = QFileDialog::getSaveFileName(this, tr("Save NVAR variable to file"), name + ".nvar", "NVAR variable files (*.nvar *.bin);;All files (*)");
break;
case Types::NvramVariableVss:
path = QFileDialog::getSaveFileName(this, tr("Save VSS variable to file"), name + ".var", "VSS variable files (*.var *.bin);;All files (*)");
break;
case Types::NvramEntryFsys:
path = QFileDialog::getSaveFileName(this, tr("Save Fsys entry to file"), name + ".fse", "Fsys entry files (*.fse *.bin);;All files (*)");
break;
case Types::NvramEntryEvsa:
path = QFileDialog::getSaveFileName(this, tr("Save EVSA entry to file"), name + ".evse", "EVSA entry files (*.evse *.bin);;All files (*)");
break;
case Types::NvramEntryFlashMap:
path = QFileDialog::getSaveFileName(this, tr("Save FlashMap entry to file"), name + ".fme", "FlashMap entry files (*.fme *.bin);;All files (*)");
break;
case Types::NvramStoreVss:
path = QFileDialog::getSaveFileName(this, tr("Save VSS store to file"), name + ".vss", "VSS store files (*.vss *.bin);;All files (*)");
break;
case Types::NvramStoreFdc:
path = QFileDialog::getSaveFileName(this, tr("Save FDC store to file"), name + ".fdc", "FDC store files (*.fdc *.bin);;All files (*)");
break;
case Types::NvramStoreFsys:
path = QFileDialog::getSaveFileName(this, tr("Save Fsys store to file"), name + ".fsys", "Fsys store files (*.fsys *.bin);;All files (*)");
break;
case Types::NvramStoreEvsa:
path = QFileDialog::getSaveFileName(this, tr("Save EVSA store to file"), name + ".evsa", "EVSA store files (*.evsa *.bin);;All files (*)");
break;
case Types::NvramStoreFtw:
path = QFileDialog::getSaveFileName(this, tr("Save FTW store to file"), name + ".ftw", "FTW store files (*.ftw *.bin);;All files (*)");
break;
case Types::NvramStoreFlashMap:
path = QFileDialog::getSaveFileName(this, tr("Save FlashMap store to file"), name + ".fmap", "FlashMap store files (*.fmap *.bin);;All files (*)");
break;
default:
path = QFileDialog::getSaveFileName(this, tr("Save object to file"), name + ".bin", "Binary files (*.bin);;All files (*)");
} }
} }
else if (mode == EXTRACT_MODE_BODY || mode == EXTRACT_MODE_BODY_UNCOMPRESSED) { else if (mode == EXTRACT_MODE_BODY || mode == EXTRACT_MODE_BODY_UNCOMPRESSED) {
switch (type) { switch (type) {
case Types::Capsule: case Types::Capsule: path = QFileDialog::getSaveFileName(this, tr("Save capsule body to image file"), name + ".rom", "Image files (*.rom *.bin);;All files (*)"); break;
path = QFileDialog::getSaveFileName(this, tr("Save capsule body to image file"), name + ".rom", "Image files (*.rom *.bin);;All files (*)"); case Types::Volume: path = QFileDialog::getSaveFileName(this, tr("Save volume body to file"), name + ".vbd", "Volume body files (*.vbd *.bin);;All files (*)"); break;
case Types::File:
if (subtype == EFI_FV_FILETYPE_ALL
|| subtype == EFI_FV_FILETYPE_RAW) path = QFileDialog::getSaveFileName(this, tr("Save FFS file body to raw file"), name + ".raw", "Raw files (*.raw *.bin);;All files (*)");
else path = QFileDialog::getSaveFileName(this, tr("Save FFS file body to file"), name + ".fbd", "FFS file body files (*.fbd *.bin);;All files (*)");
break; break;
case Types::Volume: case Types::Section:
path = QFileDialog::getSaveFileName(this, tr("Save volume body to file"), name + ".vbd", "Volume body files (*.vbd *.bin);;All files (*)"); if (subtype == EFI_SECTION_COMPRESSION
|| subtype == EFI_SECTION_GUID_DEFINED
|| subtype == EFI_SECTION_DISPOSABLE) path = QFileDialog::getSaveFileName(this, tr("Save encapsulation section body to FFS body file"), name + ".fbd", "FFS file body files (*.fbd *.bin);;All files (*)");
else if (subtype == EFI_SECTION_FIRMWARE_VOLUME_IMAGE) path = QFileDialog::getSaveFileName(this, tr("Save section body to volume file"), name + ".vol", "Volume files (*.vol *.bin);;All files (*)");
else if (subtype == EFI_SECTION_RAW) path = QFileDialog::getSaveFileName(this, tr("Save section body to raw file"), name + ".raw", "Raw files (*.raw *.bin);;All files (*)");
else if (subtype == EFI_SECTION_PE32
|| subtype == EFI_SECTION_TE
|| subtype == EFI_SECTION_PIC) path = QFileDialog::getSaveFileName(this, tr("Save section body to EFI executable file"), name + ".efi", "EFI executable files (*.efi *.bin);;All files (*)");
else path = QFileDialog::getSaveFileName(this, tr("Save section body to file"), name + ".bin", "Binary files (*.bin);;All files (*)");
break; break;
case Types::File: { case Types::NvarEntry:
if (model->subtype(index) == EFI_FV_FILETYPE_ALL || model->subtype(index) == EFI_FV_FILETYPE_RAW) case Types::VssEntry:
path = QFileDialog::getSaveFileName(this, tr("Save FFS file body to raw file"), name + ".raw", "Raw files (*.raw *.bin);;All files (*)"); case Types::EvsaEntry:
else case Types::FlashMapEntry:
path = QFileDialog::getSaveFileName(this, tr("Save FFS file body to file"), name + ".fbd", "FFS file body files (*.fbd *.bin);;All files (*)"); case Types::FsysEntry: path = QFileDialog::getSaveFileName(this, tr("Save entry body to file"), name + ".bin", "Binary files (*.bin);;All files (*)"); break;
} case Types::VssStore:
case Types::FtwStore:
case Types::FdcStore:
case Types::FsysStore:
case Types::FlashMapStore:
case Types::CmdbStore: path = QFileDialog::getSaveFileName(this, tr("Save store body to file"), name + ".bin", "Binary files (*.bin);;All files (*)"); break;
case Types::Microcode: path = QFileDialog::getSaveFileName(this, tr("Save microcode body to file"), name + ".ucb", "Microcode body files (*.ucb *.bin);;All files (*)"); break;
case Types::SlicData:
if (subtype == Subtypes::PubkeySlicData) path = QFileDialog::getSaveFileName(this, tr("Save SLIC pubkey body to file"), name + ".spb", "SLIC pubkey body files (*.spb *.bin);;All files (*)");
else path = QFileDialog::getSaveFileName(this, tr("Save SLIC marker body to file"), name + ".smb", "SLIC marker body files (*.smb *.bin);;All files (*)");
break; break;
case Types::Section: { default: path = QFileDialog::getSaveFileName(this, tr("Save object to file"), name + ".bin", "Binary files (*.bin);;All files (*)");
if (model->subtype(index) == EFI_SECTION_COMPRESSION || model->subtype(index) == EFI_SECTION_GUID_DEFINED || model->subtype(index) == EFI_SECTION_DISPOSABLE)
path = QFileDialog::getSaveFileName(this, tr("Save encapsulation section body to FFS body file"), name + ".fbd", "FFS file body files (*.fbd *.bin);;All files (*)");
else if (model->subtype(index) == EFI_SECTION_FIRMWARE_VOLUME_IMAGE)
path = QFileDialog::getSaveFileName(this, tr("Save section body to volume file"), name + ".vol", "Volume files (*.vol *.bin);;All files (*)");
else if (model->subtype(index) == EFI_SECTION_RAW)
path = QFileDialog::getSaveFileName(this, tr("Save section body to raw file"), name + ".raw", "Raw files (*.raw *.bin);;All files (*)");
else if (model->subtype(index) == EFI_SECTION_PE32 || model->subtype(index) == EFI_SECTION_TE || model->subtype(index) == EFI_SECTION_PIC)
path = QFileDialog::getSaveFileName(this, tr("Save section body to EFI executable file"), name + ".efi", "EFI executable files (*.efi *.dxe *.pei *.bin);;All files (*)");
else
path = QFileDialog::getSaveFileName(this, tr("Save section body to file"), name + ".bin", "Binary files (*.bin);;All files (*)");
}
break;
case Types::NvramVariableNvar:
case Types::NvramVariableVss:
case Types::NvramEntryEvsa:
path = QFileDialog::getSaveFileName(this, tr("Save variable body to file"), name + ".bin", "Binary files (*.bin);;All files (*)");
break;
case Types::NvramStoreVss:
case Types::NvramStoreFdc:
path = QFileDialog::getSaveFileName(this, tr("Save VSS variable store body to file"), name + ".vsb", "VSS variable store body files (*.vsb *.bin);;All files (*)");
break;
case Types::NvramStoreFsys:
path = QFileDialog::getSaveFileName(this, tr("Save Fsys store body to file"), name + ".fsb", "Fsys store body files (*.fsb *.bin);;All files (*)");
break;
case Types::NvramStoreEvsa:
path = QFileDialog::getSaveFileName(this, tr("Save EVSA store body to file"), name + ".esb", "EVSA store body files (*.esb *.bin);;All files (*)");
break;
case Types::NvramStoreFtw:
path = QFileDialog::getSaveFileName(this, tr("Save FTW store body to file"), name + ".ftb", "FTW store body files (*.ftb *.bin);;All files (*)");
break;
case Types::NvramStoreFlashMap:
path = QFileDialog::getSaveFileName(this, tr("Save FlashMap store body to file"), name + ".fmb", "FlashMap store body files (*.fmb *.bin);;All files (*)");
break;
default:
path = QFileDialog::getSaveFileName(this, tr("Save object to file"), name + ".bin", "Binary files (*.bin);;All files (*)");
} }
} }
else else path = QFileDialog::getSaveFileName(this, tr("Save object to file"), name + ".bin", "Binary files (*.bin);;All files (*)");
path = QFileDialog::getSaveFileName(this, tr("Save object to file"), name + ".bin", "Binary files (*.bin);;All files (*)");
if (path.trimmed().isEmpty()) if (path.trimmed().isEmpty())
return; return;
@ -962,46 +923,27 @@ void UEFITool::contextMenuEvent(QContextMenuEvent* event)
switch (model->type(index)) switch (model->type(index))
{ {
case Types::Capsule: case Types::Capsule: ui->menuCapsuleActions->exec(event->globalPos()); break;
ui->menuCapsuleActions->exec(event->globalPos()); case Types::Image: ui->menuImageActions->exec(event->globalPos()); break;
break; case Types::Region: ui->menuRegionActions->exec(event->globalPos()); break;
case Types::Image: case Types::Padding: ui->menuPaddingActions->exec(event->globalPos()); break;
ui->menuImageActions->exec(event->globalPos()); case Types::Volume: ui->menuVolumeActions->exec(event->globalPos()); break;
break; case Types::File: ui->menuFileActions->exec(event->globalPos()); break;
case Types::Region: case Types::Section: ui->menuSectionActions->exec(event->globalPos()); break;
ui->menuRegionActions->exec(event->globalPos()); case Types::NvarEntry:
break; case Types::VssEntry:
case Types::Padding: case Types::FsysEntry:
ui->menuPaddingActions->exec(event->globalPos()); case Types::EvsaEntry:
break; case Types::FlashMapEntry: ui->menuVariableActions->exec(event->globalPos()); break;
case Types::Volume: case Types::VssStore:
ui->menuVolumeActions->exec(event->globalPos()); case Types::FdcStore:
break; case Types::FsysStore:
case Types::File: case Types::EvsaStore:
ui->menuFileActions->exec(event->globalPos()); case Types::FtwStore:
break; case Types::FlashMapStore:
case Types::Section: case Types::CmdbStore:
ui->menuSectionActions->exec(event->globalPos());
break;
case Types::NvramVariableNvar:
case Types::NvramVariableVss:
case Types::NvramEntryFsys:
case Types::NvramEntryEvsa:
case Types::NvramEntryFlashMap:
ui->menuVariableActions->exec(event->globalPos());
break;
case Types::NvramStoreVss:
case Types::NvramStoreFdc:
case Types::NvramStoreFsys:
case Types::NvramStoreEvsa:
case Types::NvramStoreFtw:
case Types::NvramStoreFlashMap:
case Types::NvramStoreCmdb:
case Types::Microcode: case Types::Microcode:
case Types::SlicPubkey: case Types::SlicData: ui->menuStoreActions->exec(event->globalPos()); break;
case Types::SlicMarker:
ui->menuStoreActions->exec(event->globalPos());
break;
} }
} }

View File

@ -59,7 +59,7 @@ public:
~UEFITool(); ~UEFITool();
void openImageFile(QString path); void openImageFile(QString path);
void setProgramPath(QString path); void setProgramPath(QString path) { currentProgramPath = path; }
private slots: private slots:
void init(); void init();

View File

@ -166,4 +166,7 @@ UINT8: 8;
#define hexarg(X) arg(QString("%1").arg((X),0,16).toUpper()) #define hexarg(X) arg(QString("%1").arg((X),0,16).toUpper())
#define hexarg2(X, Y) arg(QString("%1").arg((X),(Y),16,QLatin1Char('0')).toUpper()) #define hexarg2(X, Y) arg(QString("%1").arg((X),(Y),16,QLatin1Char('0')).toUpper())
// SHA256 hash size in bytes
#define SHA256_HASH_SIZE 0x20
#endif // BASETYPES_H #endif // BASETYPES_H

View File

@ -13,30 +13,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "ffsops.h" #include "ffsops.h"
FfsOperations::FfsOperations(TreeModel* treeModel)
: model(treeModel)
{
}
FfsOperations::~FfsOperations()
{
}
void FfsOperations::msg(const QString & message, const QModelIndex & index)
{
messagesVector.push_back(std::pair<QString, QModelIndex>(message, index));
}
std::vector<std::pair<QString, QModelIndex> > FfsOperations::getMessages() const
{
return messagesVector;
}
void FfsOperations::clearMessages()
{
messagesVector.clear();
}
STATUS FfsOperations::extract(const QModelIndex & index, QString & name, QByteArray & extracted, const UINT8 mode) STATUS FfsOperations::extract(const QModelIndex & index, QString & name, QByteArray & extracted, const UINT8 mode)
{ {
// Sanity check // Sanity check
@ -49,18 +25,18 @@ STATUS FfsOperations::extract(const QModelIndex & index, QString & name, QByteAr
// Construct a name for extracted data // Construct a name for extracted data
QString itemName = model->name(index); QString itemName = model->name(index);
QString itemText = model->text(index); QString itemText = model->text(index);
// Default name
name = itemName.replace(' ', '_').replace('/', '_').replace('-', '_');
switch (model->type(index)) { switch (model->type(index)) {
case Types::Volume: { case Types::Volume: if (pdata.volume.hasExtendedHeader) name = guidToQString(pdata.volume.extendedHeaderGuid).replace('-', '_'); break;
if (pdata.volume.hasExtendedHeader) case Types::NvarEntry:
name = guidToQString(pdata.volume.extendedHeaderGuid).replace('-', '_'); case Types::VssEntry:
else case Types::FsysEntry:
name = itemName.replace('-', '_'); case Types::EvsaEntry:
} break; case Types::FlashMapEntry:
case Types::NvramVariableNvar: case Types::File: name = itemText.isEmpty() ? itemName : itemText.replace(' ', '_').replace('-', '_'); break;
case Types::NvramVariableVss:
case Types::File: {
name = itemText.isEmpty() ? itemName : itemText.replace(' ', '_').replace('-', '_');
} break;
case Types::Section: { case Types::Section: {
// Get parent file name // Get parent file name
QModelIndex fileIndex = model->findParentOfType(index, Types::File); QModelIndex fileIndex = model->findParentOfType(index, Types::File);
@ -69,8 +45,6 @@ STATUS FfsOperations::extract(const QModelIndex & index, QString & name, QByteAr
// Append section subtype name // Append section subtype name
name += QChar('_') + itemName.replace(' ', '_'); name += QChar('_') + itemName.replace(' ', '_');
} break; } break;
default:
name = itemName.replace(' ', '_').replace('/', '_').replace('-', '_');
} }
// Get extracted data // Get extracted data

View File

@ -29,11 +29,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
class FfsOperations class FfsOperations
{ {
public: public:
explicit FfsOperations(TreeModel * treeModel);
~FfsOperations();
std::vector<std::pair<QString, QModelIndex> > getMessages() const; FfsOperations(TreeModel * treeModel) : model(treeModel) {}
void clearMessages(); ~FfsOperations() {};
std::vector<std::pair<QString, QModelIndex> > getMessages() const { return messagesVector; }
void clearMessages() { messagesVector.clear(); }
STATUS extract(const QModelIndex & index, QString & name, QByteArray & extracted, const UINT8 mode); STATUS extract(const QModelIndex & index, QString & name, QByteArray & extracted, const UINT8 mode);
STATUS replace(const QModelIndex & index, const QString & data, const UINT8 mode); STATUS replace(const QModelIndex & index, const QString & data, const UINT8 mode);
@ -45,7 +46,9 @@ private:
TreeModel* model; TreeModel* model;
std::vector<std::pair<QString, QModelIndex> > messagesVector; std::vector<std::pair<QString, QModelIndex> > messagesVector;
void msg(const QString & message, const QModelIndex &index = QModelIndex()); void msg(const QString & message, const QModelIndex &index = QModelIndex()) {
messagesVector.push_back(std::pair<QString, QModelIndex>(message, index));
}
}; };
#endif // FFSOPS_H #endif // FFSOPS_H

View File

@ -33,12 +33,10 @@ STATUS FfsParser::parse(const QByteArray & buffer)
if (result) if (result)
return result; return result;
if (lastVtf.isValid()) { if (lastVtf.isValid())
result = performSecondPass(root); result = performSecondPass(root);
} else
else {
msg(QObject::tr("parse: not a single Volume Top File is found, the image may be corrupted")); msg(QObject::tr("parse: not a single Volume Top File is found, the image may be corrupted"));
}
return result; return result;
} }
@ -202,7 +200,7 @@ STATUS FfsParser::performFirstPass(const QByteArray & buffer, QModelIndex & inde
QModelIndex biosIndex = model->addItem(Types::Image, Subtypes::UefiImage, name, QString(), info, QByteArray(), flashImage, TRUE, parsingDataToQByteArray(pdata), index); QModelIndex biosIndex = model->addItem(Types::Image, Subtypes::UefiImage, name, QString(), info, QByteArray(), flashImage, TRUE, parsingDataToQByteArray(pdata), index);
// Parse the image // Parse the image
result = parseRawArea(flashImage, biosIndex); result = parseRawArea(biosIndex);
if (!index.isValid()) if (!index.isValid())
index = biosIndex; index = biosIndex;
return result; return result;
@ -742,7 +740,7 @@ STATUS FfsParser::parsePdrRegion(const QByteArray & pdr, const UINT32 parentOffs
index = model->addItem(Types::Region, Subtypes::PdrRegion, name, QString(), info, QByteArray(), pdr, TRUE, parsingDataToQByteArray(pdata), parent); index = model->addItem(Types::Region, Subtypes::PdrRegion, name, QString(), info, QByteArray(), pdr, TRUE, parsingDataToQByteArray(pdata), parent);
// Parse PDR region as BIOS space // Parse PDR region as BIOS space
UINT8 result = parseRawArea(pdr, index); UINT8 result = parseRawArea(index);
if (result && result != ERR_VOLUMES_NOT_FOUND && result != ERR_INVALID_VOLUME) if (result && result != ERR_VOLUMES_NOT_FOUND && result != ERR_INVALID_VOLUME)
return result; return result;
@ -792,7 +790,7 @@ STATUS FfsParser::parseBiosRegion(const QByteArray & bios, const UINT32 parentOf
// Add tree item // Add tree item
index = model->addItem(Types::Region, Subtypes::BiosRegion, name, QString(), info, QByteArray(), bios, TRUE, parsingDataToQByteArray(pdata), parent); index = model->addItem(Types::Region, Subtypes::BiosRegion, name, QString(), info, QByteArray(), bios, TRUE, parsingDataToQByteArray(pdata), parent);
return parseRawArea(bios, index); return parseRawArea(index);
} }
UINT8 FfsParser::getPaddingType(const QByteArray & padding) UINT8 FfsParser::getPaddingType(const QByteArray & padding)
@ -804,7 +802,7 @@ UINT8 FfsParser::getPaddingType(const QByteArray & padding)
return Subtypes::DataPadding; return Subtypes::DataPadding;
} }
STATUS FfsParser::parseRawArea(const QByteArray & data, const QModelIndex & index) STATUS FfsParser::parseRawArea(const QModelIndex & index)
{ {
// Sanity check // Sanity check
if (!index.isValid()) if (!index.isValid())
@ -815,6 +813,9 @@ STATUS FfsParser::parseRawArea(const QByteArray & data, const QModelIndex & inde
UINT32 headerSize = model->header(index).size(); UINT32 headerSize = model->header(index).size();
UINT32 offset = pdata.offset + headerSize; UINT32 offset = pdata.offset + headerSize;
// Get item data
QByteArray data = model->body(index);
// Search for first volume // Search for first volume
STATUS result; STATUS result;
UINT32 prevVolumeOffset; UINT32 prevVolumeOffset;
@ -1322,7 +1323,7 @@ STATUS FfsParser::parseVolumeBody(const QModelIndex & index)
// Parse VSS NVRAM volumes with a dedicated function // Parse VSS NVRAM volumes with a dedicated function
if (model->subtype(index) == Subtypes::NvramVolume) if (model->subtype(index) == Subtypes::NvramVolume)
return parseStoreArea(volumeBody, index); return parseNvramVolumeBody(index);
if (pdata.ffsVersion != 2 && pdata.ffsVersion != 3) // Don't parse unknown volumes if (pdata.ffsVersion != 2 && pdata.ffsVersion != 3) // Don't parse unknown volumes
return ERR_SUCCESS; return ERR_SUCCESS;
@ -1680,7 +1681,7 @@ STATUS FfsParser::parseFileBody(const QModelIndex & index)
if (pdata.file.format == RAW_FILE_FORMAT_NVAR_STORE) if (pdata.file.format == RAW_FILE_FORMAT_NVAR_STORE)
return parseNvarStore(model->body(index), index); return parseNvarStore(model->body(index), index);
return parseRawArea(model->body(index), index); return parseRawArea(index);
} }
// Parse sections // Parse sections
@ -2252,7 +2253,7 @@ STATUS FfsParser::parseSectionBody(const QModelIndex & index)
case EFI_SECTION_GUID_DEFINED: return parseGuidedSectionBody(index); case EFI_SECTION_GUID_DEFINED: return parseGuidedSectionBody(index);
case EFI_SECTION_DISPOSABLE: return parseSections(model->body(index), index); case EFI_SECTION_DISPOSABLE: return parseSections(model->body(index), index);
// Leaf // Leaf
case EFI_SECTION_FREEFORM_SUBTYPE_GUID: return parseRawArea(model->body(index), index); case EFI_SECTION_FREEFORM_SUBTYPE_GUID: return parseRawArea(index);
case EFI_SECTION_VERSION: return parseVersionSectionBody(index); case EFI_SECTION_VERSION: return parseVersionSectionBody(index);
case EFI_SECTION_DXE_DEPEX: case EFI_SECTION_DXE_DEPEX:
case EFI_SECTION_PEI_DEPEX: case EFI_SECTION_PEI_DEPEX:
@ -2261,7 +2262,7 @@ STATUS FfsParser::parseSectionBody(const QModelIndex & index)
case EFI_SECTION_PE32: case EFI_SECTION_PE32:
case EFI_SECTION_PIC: return parsePeImageSectionBody(index); case EFI_SECTION_PIC: return parsePeImageSectionBody(index);
case EFI_SECTION_USER_INTERFACE: return parseUiSectionBody(index); case EFI_SECTION_USER_INTERFACE: return parseUiSectionBody(index);
case EFI_SECTION_FIRMWARE_VOLUME_IMAGE: return parseRawArea(model->body(index), index); case EFI_SECTION_FIRMWARE_VOLUME_IMAGE: return parseRawArea(index);
case EFI_SECTION_RAW: return parseRawSectionBody(index); case EFI_SECTION_RAW: return parseRawSectionBody(index);
// No parsing needed // No parsing needed
case EFI_SECTION_COMPATIBILITY16: case EFI_SECTION_COMPATIBILITY16:
@ -2615,7 +2616,7 @@ STATUS FfsParser::parseRawSectionBody(const QModelIndex & index)
} }
// Parse as raw area // Parse as raw area
return parseRawArea(model->body(index), index); return parseRawArea(index);
} }
@ -2873,7 +2874,7 @@ STATUS FfsParser::parseNvarStore(const QByteArray & data, const QModelIndex & in
UINT32 offset = 0; UINT32 offset = 0;
UINT32 guidsInStore = 0; UINT32 guidsInStore = 0;
// Parse all variables // Parse all entries
while (1) { while (1) {
bool msgUnknownExtDataFormat = false; bool msgUnknownExtDataFormat = false;
bool msgExtHeaderTooLong = false; bool msgExtHeaderTooLong = false;
@ -2894,7 +2895,7 @@ STATUS FfsParser::parseNvarStore(const QByteArray & data, const QModelIndex & in
UINT64 timestamp = 0; UINT64 timestamp = 0;
QByteArray hash; QByteArray hash;
UINT8 subtype = Subtypes::FullNvarVariable; UINT8 subtype = Subtypes::FullNvarEntry;
QString name; QString name;
QString text; QString text;
QByteArray header; QByteArray header;
@ -2904,13 +2905,12 @@ STATUS FfsParser::parseNvarStore(const QByteArray & data, const QModelIndex & in
UINT32 guidAreaSize = guidsInStore * sizeof(EFI_GUID); UINT32 guidAreaSize = guidsInStore * sizeof(EFI_GUID);
UINT32 unparsedSize = (UINT32)data.size() - offset - guidAreaSize; UINT32 unparsedSize = (UINT32)data.size() - offset - guidAreaSize;
// Get variable header // Get entry header
const NVAR_VARIABLE_HEADER* variableHeader = (const NVAR_VARIABLE_HEADER*)(data.constData() + offset); const NVAR_ENTRY_HEADER* entryHeader = (const NVAR_ENTRY_HEADER*)(data.constData() + offset);
// Check variable header // Check header size
if (unparsedSize < sizeof(NVAR_VARIABLE_HEADER) || if (unparsedSize < sizeof(NVAR_ENTRY_HEADER) ||
variableHeader->Signature != NVRAM_NVAR_VARIABLE_SIGNATURE || unparsedSize < entryHeader->Size) {
unparsedSize < variableHeader->Size) {
// Check if the data left is a free space or a padding // Check if the data left is a free space or a padding
QByteArray padding = data.mid(offset, unparsedSize); QByteArray padding = data.mid(offset, unparsedSize);
@ -2958,29 +2958,29 @@ STATUS FfsParser::parseNvarStore(const QByteArray & data, const QModelIndex & in
} }
// Contruct generic header and body // Contruct generic header and body
header = data.mid(offset, sizeof(NVAR_VARIABLE_HEADER)); header = data.mid(offset, sizeof(NVAR_ENTRY_HEADER));
body = data.mid(offset + sizeof(NVAR_VARIABLE_HEADER), variableHeader->Size - sizeof(NVAR_VARIABLE_HEADER)); body = data.mid(offset + sizeof(NVAR_ENTRY_HEADER), entryHeader->Size - sizeof(NVAR_ENTRY_HEADER));
UINT32 lastVariableFlag = pdata.emptyByte ? 0xFFFFFF : 0; UINT32 lastVariableFlag = pdata.emptyByte ? 0xFFFFFF : 0;
// Set default next to predefined last value // Set default next to predefined last value
pdata.nvram.nvar.next = lastVariableFlag; pdata.nvram.nvar.next = lastVariableFlag;
// Variable is marked as invalid // Entry is marked as invalid
if ((variableHeader->Attributes & NVRAM_NVAR_VARIABLE_ATTRIB_VALID) == 0) { // Valid attribute is not set if ((entryHeader->Attributes & NVRAM_NVAR_ENTRY_ATTRIB_VALID) == 0) { // Valid attribute is not set
isInvalid = true; isInvalid = true;
// Do not parse further // Do not parse further
goto parsing_done; goto parsing_done;
} }
// Add next node information to parsing data // Add next node information to parsing data
if (variableHeader->Next != lastVariableFlag) { if (entryHeader->Next != lastVariableFlag) {
subtype = Subtypes::LinkNvarVariable; subtype = Subtypes::LinkNvarEntry;
pdata.nvram.nvar.next = variableHeader->Next; pdata.nvram.nvar.next = entryHeader->Next;
} }
// Variable with extended header // Exntry with extended header
if (variableHeader->Attributes & NVRAM_NVAR_VARIABLE_ATTRIB_EXT_HEADER) { if (entryHeader->Attributes & NVRAM_NVAR_ENTRY_ATTRIB_EXT_HEADER) {
hasExtendedHeader = true; hasExtendedHeader = true;
msgUnknownExtDataFormat = true; msgUnknownExtDataFormat = true;
@ -2995,24 +2995,24 @@ STATUS FfsParser::parseNvarStore(const QByteArray & data, const QModelIndex & in
extendedAttributes = *(UINT8*)(body.constData() + body.size() - extendedHeaderSize); extendedAttributes = *(UINT8*)(body.constData() + body.size() - extendedHeaderSize);
// Variable with checksum // Variable with checksum
if (extendedAttributes & NVRAM_NVAR_VARIABLE_EXT_ATTRIB_CHECKSUM) { if (extendedAttributes & NVRAM_NVAR_ENTRY_EXT_ATTRIB_CHECKSUM) {
// Get stored checksum // Get stored checksum
storedChecksum = *(UINT8*)(body.constData() + body.size() - sizeof(UINT16) - sizeof(UINT8)); storedChecksum = *(UINT8*)(body.constData() + body.size() - sizeof(UINT16) - sizeof(UINT8));
// Recalculate checksum for the variable // Recalculate checksum for the variable
calculatedChecksum = 0; calculatedChecksum = 0;
// Include variable data // Include entry data
UINT8* start = (UINT8*)(variableHeader + 1); UINT8* start = (UINT8*)(entryHeader + 1);
for (UINT8* p = start; p < start + variableHeader->Size - sizeof(NVAR_VARIABLE_HEADER); p++) { for (UINT8* p = start; p < start + entryHeader->Size - sizeof(NVAR_ENTRY_HEADER); p++) {
calculatedChecksum += *p; calculatedChecksum += *p;
} }
// Include variable size and flags // Include entry size and flags
start = (UINT8*)&variableHeader->Size; start = (UINT8*)&entryHeader->Size;
for (UINT8*p = start; p < start + sizeof(UINT16); p++) { for (UINT8*p = start; p < start + sizeof(UINT16); p++) {
calculatedChecksum += *p; calculatedChecksum += *p;
} }
// Include variable attributes // Include entry attributes
calculatedChecksum += variableHeader->Attributes; calculatedChecksum += entryHeader->Attributes;
hasChecksum = true; hasChecksum = true;
msgUnknownExtDataFormat = false; msgUnknownExtDataFormat = false;
@ -3021,9 +3021,9 @@ STATUS FfsParser::parseNvarStore(const QByteArray & data, const QModelIndex & in
extendedData = body.mid(body.size() - extendedHeaderSize + sizeof(UINT8), extendedHeaderSize - sizeof(UINT16) - sizeof(UINT8) - (hasChecksum ? 1 : 0)); extendedData = body.mid(body.size() - extendedHeaderSize + sizeof(UINT8), extendedHeaderSize - sizeof(UINT16) - sizeof(UINT8) - (hasChecksum ? 1 : 0));
body = body.left(body.size() - extendedHeaderSize); body = body.left(body.size() - extendedHeaderSize);
// Variable with authenticated write (for SecureBoot) // Entry with authenticated write (for SecureBoot)
if (variableHeader->Attributes & NVRAM_NVAR_VARIABLE_ATTRIB_AUTH_WRITE) { if (entryHeader->Attributes & NVRAM_NVAR_ENTRY_ATTRIB_AUTH_WRITE) {
if (extendedData.size() < 40) { if (extendedData.size() < sizeof(UINT64) + SHA256_HASH_SIZE) {
msgExtDataTooShort = true; msgExtDataTooShort = true;
isInvalid = true; isInvalid = true;
// Do not parse further // Do not parse further
@ -3031,17 +3031,17 @@ STATUS FfsParser::parseNvarStore(const QByteArray & data, const QModelIndex & in
} }
timestamp = *(UINT64*)(extendedData.constData()); timestamp = *(UINT64*)(extendedData.constData());
hash = extendedData.mid(sizeof(UINT64), 0x20); //Length of SHA256 hash hash = extendedData.mid(sizeof(UINT64), SHA256_HASH_SIZE);
hasTimestampAndHash = true; hasTimestampAndHash = true;
msgUnknownExtDataFormat = false; msgUnknownExtDataFormat = false;
} }
} }
// Variable is data-only (nameless and GUIDless link) // Entry is data-only (nameless and GUIDless entry or link)
if (variableHeader->Attributes & NVRAM_NVAR_VARIABLE_ATTRIB_DATA_ONLY) { // Data-only attribute is set if (entryHeader->Attributes & NVRAM_NVAR_ENTRY_ATTRIB_DATA_ONLY) { // Data-only attribute is set
isInvalid = true; isInvalid = true;
QModelIndex nvarIndex; QModelIndex nvarIndex;
// Search prevously added variable for a link to this variable // Search prevously added entries for a link to this variable //TODO:replace with linked lists
for (int i = 0; i < model->rowCount(index); i++) { for (int i = 0; i < model->rowCount(index); i++) {
nvarIndex = index.child(i, 0); nvarIndex = index.child(i, 0);
PARSING_DATA nvarPdata = parsingDataFromQModelIndex(nvarIndex); PARSING_DATA nvarPdata = parsingDataFromQModelIndex(nvarIndex);
@ -3056,8 +3056,8 @@ STATUS FfsParser::parseNvarStore(const QByteArray & data, const QModelIndex & in
name = model->name(nvarIndex); name = model->name(nvarIndex);
text = model->text(nvarIndex); text = model->text(nvarIndex);
if (variableHeader->Next == lastVariableFlag) if (entryHeader->Next == lastVariableFlag)
subtype = Subtypes::DataNvarVariable; subtype = Subtypes::DataNvarEntry;
} }
isDataOnly = true; isDataOnly = true;
@ -3065,12 +3065,12 @@ STATUS FfsParser::parseNvarStore(const QByteArray & data, const QModelIndex & in
goto parsing_done; goto parsing_done;
} }
// Get variable name // Get entry name
{ {
UINT32 nameOffset = (variableHeader->Attributes & NVRAM_NVAR_VARIABLE_ATTRIB_GUID) ? sizeof(EFI_GUID) : 1; // GUID can be stored with the variable or in a separate store, so there will only be an index of it UINT32 nameOffset = (entryHeader->Attributes & NVRAM_NVAR_ENTRY_ATTRIB_GUID) ? sizeof(EFI_GUID) : 1; // GUID can be stored with the variable or in a separate store, so there will only be an index of it
CHAR8* namePtr = (CHAR8*)(variableHeader + 1) + nameOffset; CHAR8* namePtr = (CHAR8*)(entryHeader + 1) + nameOffset;
UINT32 nameSize = 0; UINT32 nameSize = 0;
if (variableHeader->Attributes & NVRAM_NVAR_VARIABLE_ATTRIB_ASCII_NAME) { // Name is stored as ASCII string of CHAR8s if (entryHeader->Attributes & NVRAM_NVAR_ENTRY_ATTRIB_ASCII_NAME) { // Name is stored as ASCII string of CHAR8s
text = QString(namePtr); text = QString(namePtr);
nameSize = text.length() + 1; nameSize = text.length() + 1;
} }
@ -3079,13 +3079,13 @@ STATUS FfsParser::parseNvarStore(const QByteArray & data, const QModelIndex & in
nameSize = (text.length() + 1) * 2; nameSize = (text.length() + 1) * 2;
} }
// Get variable GUID // Get entry GUID
if (variableHeader->Attributes & NVRAM_NVAR_VARIABLE_ATTRIB_GUID) { // GUID is strored in the variable itself if (entryHeader->Attributes & NVRAM_NVAR_ENTRY_ATTRIB_GUID) { // GUID is strored in the variable itself
name = guidToQString(*(EFI_GUID*)(variableHeader + 1)); name = guidToQString(*(EFI_GUID*)(entryHeader + 1));
} }
// GUID is stored in GUID list at the end of the store // GUID is stored in GUID list at the end of the store
else { else {
guidIndex = *(UINT8*)(variableHeader + 1); guidIndex = *(UINT8*)(entryHeader + 1);
if (guidsInStore < guidIndex + 1) if (guidsInStore < guidIndex + 1)
guidsInStore = guidIndex + 1; guidsInStore = guidIndex + 1;
@ -3095,24 +3095,24 @@ STATUS FfsParser::parseNvarStore(const QByteArray & data, const QModelIndex & in
hasGuidIndex = true; hasGuidIndex = true;
} }
// Include variable name and GUID into the header and remove them from body // Include name and GUID into the header and remove them from body
header = data.mid(offset, sizeof(NVAR_VARIABLE_HEADER) + nameOffset + nameSize); header = data.mid(offset, sizeof(NVAR_ENTRY_HEADER) + nameOffset + nameSize);
body = body.mid(nameOffset + nameSize); body = body.mid(nameOffset + nameSize);
} }
parsing_done: parsing_done:
QString info; QString info;
// Rename invalid variables according to their types // Rename invalid entries according to their types
if (isInvalid) { if (isInvalid) {
if (variableHeader->Next != lastVariableFlag) { if (entryHeader->Next != lastVariableFlag) {
name = QObject::tr("Invalid link"); name = QObject::tr("Invalid link");
subtype = Subtypes::InvalidLinkNvarVariable; subtype = Subtypes::InvalidLinkNvarEntry;
} }
else { else {
name = QObject::tr("Invalid"); name = QObject::tr("Invalid");
subtype = Subtypes::InvalidNvarVariable; subtype = Subtypes::InvalidNvarEntry;
} }
} }
else // Add GUID info for valid variables else // Add GUID info for valid entries
info += QObject::tr("Variable GUID: %1\n").arg(name); info += QObject::tr("Variable GUID: %1\n").arg(name);
// Add GUID index information // Add GUID index information
@ -3121,20 +3121,20 @@ parsing_done:
// Add header, body and extended data info // Add header, body and extended data info
info += QObject::tr("Full size: %1h (%2)\nHeader size %3h (%4)\nBody size: %5h (%6)") info += QObject::tr("Full size: %1h (%2)\nHeader size %3h (%4)\nBody size: %5h (%6)")
.hexarg(variableHeader->Size).arg(variableHeader->Size) .hexarg(entryHeader->Size).arg(entryHeader->Size)
.hexarg(header.size()).arg(header.size()) .hexarg(header.size()).arg(header.size())
.hexarg(body.size()).arg(body.size()); .hexarg(body.size()).arg(body.size());
// Add attributes info // Add attributes info
info += QObject::tr("\nAttributes: %1h").hexarg2(variableHeader->Attributes, 2); info += QObject::tr("\nAttributes: %1h").hexarg2(entryHeader->Attributes, 2);
// Translate attributes to text // Translate attributes to text
if (variableHeader->Attributes) if (entryHeader->Attributes)
info += QObject::tr("\nAttributes as text: %1").arg(nvarAttributesToQString(variableHeader->Attributes)); info += QObject::tr("\nAttributes as text: %1").arg(nvarAttributesToQString(entryHeader->Attributes));
pdata.nvram.nvar.attributes = variableHeader->Attributes; pdata.nvram.nvar.attributes = entryHeader->Attributes;
// Add next node info // Add next node info
if (!isInvalid && variableHeader->Next != lastVariableFlag) if (!isInvalid && entryHeader->Next != lastVariableFlag)
info += QObject::tr("\nNext node at offset: %1h").hexarg(parentOffset + offset + variableHeader->Next); info += QObject::tr("\nNext node at offset: %1h").hexarg(parentOffset + offset + entryHeader->Next);
// Add extended header info // Add extended header info
if (hasExtendedHeader) { if (hasExtendedHeader) {
@ -3164,31 +3164,28 @@ parsing_done:
pdata.offset = parentOffset + offset; pdata.offset = parentOffset + offset;
// Add tree item // Add tree item
QModelIndex varIndex = model->addItem(Types::NvramVariableNvar, subtype, name, text, info, header, body, FALSE, parsingDataToQByteArray(pdata), index); QModelIndex varIndex = model->addItem(Types::NvarEntry, subtype, name, text, info, header, body, FALSE, parsingDataToQByteArray(pdata), index);
// Show messages // Show messages
if (msgUnknownExtDataFormat) if (msgUnknownExtDataFormat) msg(QObject::tr("parseNvarStore: unknown extended data format"), varIndex);
msg(QObject::tr("parseNvarStore: unknown extended data format"), varIndex); if (msgExtHeaderTooLong) msg(QObject::tr("parseNvarStore: extended header size (%1h) is greater than body size (%2h)")
if (msgExtHeaderTooLong)
msg(QObject::tr("parseNvarStore: extended header size (%1h) is greater than body size (%2h)")
.hexarg(extendedHeaderSize).hexarg(body.size()), varIndex); .hexarg(extendedHeaderSize).hexarg(body.size()), varIndex);
if (msgExtDataTooShort) if (msgExtDataTooShort) msg(QObject::tr("parseNvarStore: extended data size (%1h) is smaller than required for timestamp and hash (0x28)")
msg(QObject::tr("parseNvarStore: extended data size (%1h) is smaller than required for timestamp and hash (0x28)")
.hexarg(extendedData.size()), varIndex); .hexarg(extendedData.size()), varIndex);
// Try parsing the variable data as NVAR storage if it begins with NVAR signature // Try parsing the entry data as NVAR storage if it begins with NVAR signature
if ((subtype == Subtypes::DataNvarVariable || subtype == Subtypes::FullNvarVariable) && if ((subtype == Subtypes::DataNvarEntry || subtype == Subtypes::FullNvarEntry)
*(const UINT32*)body.constData() == NVRAM_NVAR_VARIABLE_SIGNATURE) && *(const UINT32*)body.constData() == NVRAM_NVAR_ENTRY_SIGNATURE)
parseNvarStore(body, varIndex); parseNvarStore(body, varIndex);
// Move to next variable // Move to next exntry
offset += variableHeader->Size; offset += entryHeader->Size;
} }
return ERR_SUCCESS; return ERR_SUCCESS;
} }
STATUS FfsParser::parseStoreArea(const QByteArray & data, const QModelIndex & index) STATUS FfsParser::parseNvramVolumeBody(const QModelIndex & index)
{ {
// Sanity check // Sanity check
if (!index.isValid()) if (!index.isValid())
@ -3198,6 +3195,9 @@ STATUS FfsParser::parseStoreArea(const QByteArray & data, const QModelIndex & in
PARSING_DATA pdata = parsingDataFromQModelIndex(index); PARSING_DATA pdata = parsingDataFromQModelIndex(index);
UINT32 parentOffset = pdata.offset + model->header(index).size(); UINT32 parentOffset = pdata.offset + model->header(index).size();
// Get item data
QByteArray data = model->body(index);
// Search for first volume // Search for first volume
STATUS result; STATUS result;
UINT32 prevStoreOffset; UINT32 prevStoreOffset;
@ -3251,7 +3251,7 @@ STATUS FfsParser::parseStoreArea(const QByteArray & data, const QModelIndex & in
UINT32 storeSize = 0; UINT32 storeSize = 0;
result = getStoreSize(data, storeOffset, storeSize); result = getStoreSize(data, storeOffset, storeSize);
if (result) { if (result) {
msg(QObject::tr("parseStoreArea: getVssStoreSize failed with error \"%1\"").arg(errorCodeToQString(result)), index); msg(QObject::tr("parseNvramVolumeBody: getStoreSize failed with error \"%1\"").arg(errorCodeToQString(result)), index);
return result; return result;
} }
@ -3270,7 +3270,7 @@ STATUS FfsParser::parseStoreArea(const QByteArray & data, const QModelIndex & in
// Add tree item // Add tree item
QModelIndex paddingIndex = model->addItem(Types::Padding, getPaddingType(padding), name, QString(), info, QByteArray(), padding, TRUE, parsingDataToQByteArray(pdata), index); QModelIndex paddingIndex = model->addItem(Types::Padding, getPaddingType(padding), name, QString(), info, QByteArray(), padding, TRUE, parsingDataToQByteArray(pdata), index);
msg(QObject::tr("parseStoreArea: one of stores inside overlaps the end of data"), paddingIndex); msg(QObject::tr("parseNvramVolumeBody: one of stores inside overlaps the end of data"), paddingIndex);
// Update variables // Update variables
prevStoreOffset = storeOffset; prevStoreOffset = storeOffset;
@ -3283,7 +3283,7 @@ STATUS FfsParser::parseStoreArea(const QByteArray & data, const QModelIndex & in
QModelIndex storeIndex; QModelIndex storeIndex;
result = parseStoreHeader(store, parentOffset + storeOffset, index, storeIndex); result = parseStoreHeader(store, parentOffset + storeOffset, index, storeIndex);
if (result) { if (result) {
msg(QObject::tr("parseStoreArea: store header parsing failed with error \"%1\"").arg(errorCodeToQString(result)), index); msg(QObject::tr("parseNvramVolumeBody: store header parsing failed with error \"%1\"").arg(errorCodeToQString(result)), index);
} }
// Go to next volume // Go to next volume
@ -3307,7 +3307,7 @@ STATUS FfsParser::parseStoreArea(const QByteArray & data, const QModelIndex & in
else { else {
// Nothing is parsed yet, but the file is not empty // Nothing is parsed yet, but the file is not empty
if (!storeOffset) { if (!storeOffset) {
msg(QObject::tr("parseStoreArea: area can't be parsed as variable store"), index); msg(QObject::tr("parseNvramVolumeBody: can't be parsed as NVRAM volume"), index);
return ERR_SUCCESS; return ERR_SUCCESS;
} }
@ -3332,45 +3332,27 @@ STATUS FfsParser::parseStoreArea(const QByteArray & data, const QModelIndex & in
for (int i = 0; i < model->rowCount(index); i++) { for (int i = 0; i < model->rowCount(index); i++) {
QModelIndex current = index.child(i, 0); QModelIndex current = index.child(i, 0);
switch (model->type(current)) { switch (model->type(current)) {
case Types::NvramStoreVss: case Types::VssStore:
case Types::NvramStoreFdc: case Types::FdcStore: parseVssStoreBody(current); break;
parseVssStoreBody(current); case Types::FsysStore: parseFsysStoreBody(current); break;
break; case Types::EvsaStore: parseEvsaStoreBody(current); break;
case Types::NvramStoreFsys: case Types::FlashMapStore: parseFlashMapBody(current); break;
parseFsysStoreBody(current);
break;
case Types::NvramStoreEvsa:
parseEvsaStoreBody(current);
break;
case Types::NvramStoreFlashMap:
parseFlashMapBody(current);
break;
case Types::NvramStoreFtw:
case Types::NvramStoreCmdb:
case Types::Microcode:
case Types::SlicPubkey:
case Types::SlicMarker:
case Types::Padding:
// No parsing required
break;
default:
return ERR_UNKNOWN_ITEM_TYPE;
} }
} }
return ERR_SUCCESS; return ERR_SUCCESS;
} }
STATUS FfsParser::findNextStore(const QModelIndex & index, const QByteArray & data, const UINT32 parentOffset, const UINT32 storeOffset, UINT32 & nextStoreOffset) STATUS FfsParser::findNextStore(const QModelIndex & index, const QByteArray & volume, const UINT32 parentOffset, const UINT32 storeOffset, UINT32 & nextStoreOffset)
{ {
UINT32 dataSize = data.size(); UINT32 dataSize = volume.size();
if (dataSize < sizeof(UINT32)) if (dataSize < sizeof(UINT32))
return ERR_STORES_NOT_FOUND; return ERR_STORES_NOT_FOUND;
UINT32 offset = storeOffset; UINT32 offset = storeOffset;
for (; offset < dataSize - sizeof(UINT32); offset++) { for (; offset < dataSize - sizeof(UINT32); offset++) {
const UINT32* currentPos = (const UINT32*)(data.constData() + offset); const UINT32* currentPos = (const UINT32*)(volume.constData() + offset);
if (*currentPos == NVRAM_VSS_STORE_SIGNATURE || *currentPos == NVRAM_APPLE_SVS_STORE_SIGNATURE) { //$VSS or $SVS signatures found, perform checks if (*currentPos == NVRAM_VSS_STORE_SIGNATURE || *currentPos == NVRAM_APPLE_SVS_STORE_SIGNATURE) { //$VSS or $SVS signatures found, perform checks
const VSS_VARIABLE_STORE_HEADER* vssHeader = (const VSS_VARIABLE_STORE_HEADER*)currentPos; const VSS_VARIABLE_STORE_HEADER* vssHeader = (const VSS_VARIABLE_STORE_HEADER*)currentPos;
if (vssHeader->Format != NVRAM_VSS_VARIABLE_STORE_FORMATTED) { if (vssHeader->Format != NVRAM_VSS_VARIABLE_STORE_FORMATTED) {
@ -3420,7 +3402,7 @@ STATUS FfsParser::findNextStore(const QModelIndex & index, const QByteArray & da
break; break;
} }
else if (*currentPos == NVRAM_MAIN_STORE_VOLUME_GUID_DATA1 || *currentPos == EDKII_WORKING_BLOCK_SIGNATURE_GUID_DATA1) { //Possible FTW block signature found else if (*currentPos == NVRAM_MAIN_STORE_VOLUME_GUID_DATA1 || *currentPos == EDKII_WORKING_BLOCK_SIGNATURE_GUID_DATA1) { //Possible FTW block signature found
QByteArray guid = QByteArray(data.constData() + offset, sizeof(EFI_GUID)); QByteArray guid = QByteArray(volume.constData() + offset, sizeof(EFI_GUID));
if (guid != NVRAM_MAIN_STORE_VOLUME_GUID && guid != EDKII_WORKING_BLOCK_SIGNATURE_GUID) // Check the whole signature if (guid != NVRAM_MAIN_STORE_VOLUME_GUID && guid != EDKII_WORKING_BLOCK_SIGNATURE_GUID) // Check the whole signature
continue; continue;
@ -3446,7 +3428,7 @@ STATUS FfsParser::findNextStore(const QModelIndex & index, const QByteArray & da
break; break;
} }
else if (*currentPos == NVRAM_PHOENIX_FLASH_MAP_SIGNATURE_PART1) {// Phoenix SCT flash map else if (*currentPos == NVRAM_PHOENIX_FLASH_MAP_SIGNATURE_PART1) {// Phoenix SCT flash map
QByteArray signature = QByteArray(data.constData() + offset, NVRAM_PHOENIX_FLASH_MAP_SIGNATURE_LENGTH); QByteArray signature = QByteArray(volume.constData() + offset, NVRAM_PHOENIX_FLASH_MAP_SIGNATURE_LENGTH);
if (signature != NVRAM_PHOENIX_FLASH_MAP_SIGNATURE) // Check the whole signature if (signature != NVRAM_PHOENIX_FLASH_MAP_SIGNATURE) // Check the whole signature
continue; continue;
@ -3500,7 +3482,7 @@ STATUS FfsParser::findNextStore(const QModelIndex & index, const QByteArray & da
offset < 26) // Check full windows flag and structure size offset < 26) // Check full windows flag and structure size
continue; continue;
const OEM_ACTIVATION_MARKER* markerHeader = (const OEM_ACTIVATION_MARKER*)(data.constData() + offset - 26); const OEM_ACTIVATION_MARKER* markerHeader = (const OEM_ACTIVATION_MARKER*)(volume.constData() + offset - 26);
// Check reserved bytes // Check reserved bytes
bool reservedBytesValid = true; bool reservedBytesValid = true;
for (UINT32 i = 0; i < sizeof(markerHeader->Reserved); i++) for (UINT32 i = 0; i < sizeof(markerHeader->Reserved); i++)
@ -3626,7 +3608,7 @@ STATUS FfsParser::parseStoreHeader(const QByteArray & store, const UINT32 parent
pdata.offset = parentOffset; pdata.offset = parentOffset;
// Add tree item // Add tree item
index = model->addItem(Types::NvramStoreVss, 0, name, QString(), info, header, body, TRUE, parsingDataToQByteArray(pdata), parent); index = model->addItem(Types::VssStore, 0, name, QString(), info, header, body, TRUE, parsingDataToQByteArray(pdata), parent);
} }
else if (*signature == NVRAM_FDC_VOLUME_SIGNATURE) { else if (*signature == NVRAM_FDC_VOLUME_SIGNATURE) {
// Check dataSize // Check dataSize
@ -3694,7 +3676,7 @@ STATUS FfsParser::parseStoreHeader(const QByteArray & store, const UINT32 parent
pdata.offset = parentOffset; pdata.offset = parentOffset;
// Add tree item // Add tree item
index = model->addItem(Types::NvramStoreFdc, 0, name, QString(), info, header, body, TRUE, parsingDataToQByteArray(pdata), parent); index = model->addItem(Types::FdcStore, 0, name, QString(), info, header, body, TRUE, parsingDataToQByteArray(pdata), parent);
} }
else if (*signature == NVRAM_APPLE_FSYS_STORE_SIGNATURE || *signature == NVRAM_APPLE_GAID_STORE_SIGNATURE) { else if (*signature == NVRAM_APPLE_FSYS_STORE_SIGNATURE || *signature == NVRAM_APPLE_GAID_STORE_SIGNATURE) {
// Check dataSize // Check dataSize
@ -3743,7 +3725,7 @@ STATUS FfsParser::parseStoreHeader(const QByteArray & store, const UINT32 parent
pdata.offset = parentOffset; pdata.offset = parentOffset;
// Add tree item // Add tree item
index = model->addItem(Types::NvramStoreFsys, 0, name, QString(), info, header, body, TRUE, parsingDataToQByteArray(pdata), parent); index = model->addItem(Types::FsysStore, 0, name, QString(), info, header, body, TRUE, parsingDataToQByteArray(pdata), parent);
} }
else if (*(signature + 1) == NVRAM_EVSA_STORE_SIGNATURE) { else if (*(signature + 1) == NVRAM_EVSA_STORE_SIGNATURE) {
// Check dataSize // Check dataSize
@ -3790,7 +3772,7 @@ STATUS FfsParser::parseStoreHeader(const QByteArray & store, const UINT32 parent
pdata.offset = parentOffset; pdata.offset = parentOffset;
// Add tree item // Add tree item
index = model->addItem(Types::NvramStoreEvsa, 0, name, QString(), info, header, body, TRUE, parsingDataToQByteArray(pdata), parent); index = model->addItem(Types::EvsaStore, 0, name, QString(), info, header, body, TRUE, parsingDataToQByteArray(pdata), parent);
} }
else if (*signature == NVRAM_MAIN_STORE_VOLUME_GUID_DATA1 || *signature == EDKII_WORKING_BLOCK_SIGNATURE_GUID_DATA1) { else if (*signature == NVRAM_MAIN_STORE_VOLUME_GUID_DATA1 || *signature == EDKII_WORKING_BLOCK_SIGNATURE_GUID_DATA1) {
// Check dataSize // Check dataSize
@ -3852,7 +3834,7 @@ STATUS FfsParser::parseStoreHeader(const QByteArray & store, const UINT32 parent
pdata.offset = parentOffset; pdata.offset = parentOffset;
// Add tree item // Add tree item
index = model->addItem(Types::NvramStoreFtw, 0, name, QString(), info, header, body, TRUE, parsingDataToQByteArray(pdata), parent); index = model->addItem(Types::FtwStore, 0, name, QString(), info, header, body, TRUE, parsingDataToQByteArray(pdata), parent);
} }
else if (*signature == NVRAM_PHOENIX_FLASH_MAP_SIGNATURE_PART1) { // Phoenix SCT flash map else if (*signature == NVRAM_PHOENIX_FLASH_MAP_SIGNATURE_PART1) { // Phoenix SCT flash map
if (dataSize < sizeof(PHOENIX_FLASH_MAP_HEADER)) { if (dataSize < sizeof(PHOENIX_FLASH_MAP_HEADER)) {
@ -3891,7 +3873,7 @@ STATUS FfsParser::parseStoreHeader(const QByteArray & store, const UINT32 parent
pdata.offset = parentOffset; pdata.offset = parentOffset;
// Add tree item // Add tree item
index = model->addItem(Types::NvramStoreFlashMap, 0, name, QString(), info, header, body, TRUE, parsingDataToQByteArray(pdata), parent); index = model->addItem(Types::FlashMapStore, 0, name, QString(), info, header, body, TRUE, parsingDataToQByteArray(pdata), parent);
} }
else if (*signature == NVRAM_PHOENIX_CMDB_HEADER_SIGNATURE) { // Phoenix SCT CMDB store else if (*signature == NVRAM_PHOENIX_CMDB_HEADER_SIGNATURE) { // Phoenix SCT CMDB store
if (dataSize < sizeof(PHOENIX_CMDB_HEADER)) { if (dataSize < sizeof(PHOENIX_CMDB_HEADER)) {
@ -3929,7 +3911,7 @@ STATUS FfsParser::parseStoreHeader(const QByteArray & store, const UINT32 parent
pdata.offset = parentOffset; pdata.offset = parentOffset;
// Add tree item // Add tree item
index = model->addItem(Types::NvramStoreCmdb, 0, name, QString(), info, header, body, TRUE, parsingDataToQByteArray(pdata), parent); index = model->addItem(Types::CmdbStore, 0, name, QString(), info, header, body, TRUE, parsingDataToQByteArray(pdata), parent);
} }
else if (*(signature + 4) == OEM_ACTIVATION_PUBKEY_MAGIC) { // SLIC pubkey else if (*(signature + 4) == OEM_ACTIVATION_PUBKEY_MAGIC) { // SLIC pubkey
if (dataSize < sizeof(OEM_ACTIVATION_PUBKEY)) { if (dataSize < sizeof(OEM_ACTIVATION_PUBKEY)) {
@ -3970,7 +3952,7 @@ STATUS FfsParser::parseStoreHeader(const QByteArray & store, const UINT32 parent
pdata.offset = parentOffset; pdata.offset = parentOffset;
// Add tree item // Add tree item
index = model->addItem(Types::SlicPubkey, 0, name, QString(), info, header, QByteArray(), TRUE, parsingDataToQByteArray(pdata), parent); index = model->addItem(Types::SlicData, Subtypes::PubkeySlicData, name, QString(), info, header, QByteArray(), TRUE, parsingDataToQByteArray(pdata), parent);
} }
else if (*(const UINT64*)(store.constData() + 26) == OEM_ACTIVATION_MARKER_WINDOWS_FLAG) { // SLIC marker else if (*(const UINT64*)(store.constData() + 26) == OEM_ACTIVATION_MARKER_WINDOWS_FLAG) { // SLIC marker
if (dataSize < sizeof(OEM_ACTIVATION_MARKER)) { if (dataSize < sizeof(OEM_ACTIVATION_MARKER)) {
@ -4010,7 +3992,7 @@ STATUS FfsParser::parseStoreHeader(const QByteArray & store, const UINT32 parent
pdata.offset = parentOffset; pdata.offset = parentOffset;
// Add tree item // Add tree item
index = model->addItem(Types::SlicMarker, 0, name, QString(), info, header, QByteArray(), TRUE, parsingDataToQByteArray(pdata), parent); index = model->addItem(Types::SlicData, Subtypes::MarkerSlicData, name, QString(), info, header, QByteArray(), TRUE, parsingDataToQByteArray(pdata), parent);
} }
else if (*signature == INTEL_MICROCODE_HEADER_VERSION) { // Intel microcode, , must be checked after SLIC marker because of the same *signature values else if (*signature == INTEL_MICROCODE_HEADER_VERSION) { // Intel microcode, , must be checked after SLIC marker because of the same *signature values
if (dataSize < sizeof(INTEL_MICROCODE_HEADER)) { if (dataSize < sizeof(INTEL_MICROCODE_HEADER)) {
@ -4236,26 +4218,26 @@ STATUS FfsParser::parseVssStoreBody(const QModelIndex & index)
// Set subtype and add related info // Set subtype and add related info
if (isInvalid) if (isInvalid)
subtype = Subtypes::InvalidVssVariable; subtype = Subtypes::InvalidVssEntry;
else if (isAuthenticated) { else if (isAuthenticated) {
subtype = Subtypes::AuthVssVariable; subtype = Subtypes::AuthVssEntry;
info += QObject::tr("\nMonotonic counter: %1h\nTimestamp: %2\nPubKey index: %3") info += QObject::tr("\nMonotonic counter: %1h\nTimestamp: %2\nPubKey index: %3")
.hexarg(monotonicCounter).arg(efiTimeToQString(timestamp)).arg(pubKeyIndex); .hexarg(monotonicCounter).arg(efiTimeToQString(timestamp)).arg(pubKeyIndex);
} }
else if (isAppleCrc32) { else if (isAppleCrc32) {
subtype = Subtypes::Crc32VssVariable; subtype = Subtypes::AppleVssEntry;
info += QObject::tr("\nCRC32: %1h%2").hexarg2(storedCrc32, 8) info += QObject::tr("\nCRC32: %1h%2").hexarg2(storedCrc32, 8)
.arg(storedCrc32 == calculatedCrc32 ? QObject::tr(", valid") : QObject::tr(", invalid, should be %1h").hexarg2(calculatedCrc32,8)); .arg(storedCrc32 == calculatedCrc32 ? QObject::tr(", valid") : QObject::tr(", invalid, should be %1h").hexarg2(calculatedCrc32,8));
} }
else else
subtype = Subtypes::StandardVssVariable; subtype = Subtypes::StandardVssEntry;
// Add correct offset to parsing data // Add correct offset to parsing data
pdata.offset = parentOffset + offset; pdata.offset = parentOffset + offset;
// Add tree item // Add tree item
model->addItem(Types::NvramVariableVss, subtype, name, text, info, header, body, FALSE, parsingDataToQByteArray(pdata), index); model->addItem(Types::VssEntry, subtype, name, text, info, header, body, FALSE, parsingDataToQByteArray(pdata), index);
// Move to next variable // Move to next variable
offset += variableSize; offset += variableSize;
@ -4305,7 +4287,7 @@ STATUS FfsParser::parseFsysStoreBody(const QModelIndex & index)
pdata.offset = parentOffset + offset; pdata.offset = parentOffset + offset;
// Add EOF tree item // Add EOF tree item
model->addItem(Types::NvramEntryFsys, 0, name, QString(), info, header, QByteArray(), FALSE, parsingDataToQByteArray(pdata), index); model->addItem(Types::FsysEntry, 0, name, QString(), info, header, QByteArray(), FALSE, parsingDataToQByteArray(pdata), index);
// Add free space // Add free space
offset += header.size(); offset += header.size();
@ -4361,7 +4343,7 @@ STATUS FfsParser::parseFsysStoreBody(const QModelIndex & index)
pdata.offset = parentOffset + offset; pdata.offset = parentOffset + offset;
// Add tree item // Add tree item
model->addItem(Types::NvramEntryFsys, 0, name, QString(), info, header, body, FALSE, parsingDataToQByteArray(pdata), index); model->addItem(Types::FsysEntry, 0, name, QString(), info, header, body, FALSE, parsingDataToQByteArray(pdata), index);
// Move to next variable // Move to next variable
offset += variableSize; offset += variableSize;
@ -4537,7 +4519,7 @@ STATUS FfsParser::parseEvsaStoreBody(const QModelIndex & index)
pdata.offset = parentOffset + offset; pdata.offset = parentOffset + offset;
// Add tree item // Add tree item
model->addItem(Types::NvramEntryEvsa, subtype, name, QString(), info, header, body, FALSE, parsingDataToQByteArray(pdata), index); model->addItem(Types::EvsaEntry, subtype, name, QString(), info, header, body, FALSE, parsingDataToQByteArray(pdata), index);
// Move to next variable // Move to next variable
offset += variableSize; offset += variableSize;
@ -4653,12 +4635,12 @@ STATUS FfsParser::parseFlashMapBody(const QModelIndex & index)
subtype = Subtypes::VolumeFlashMapEntry; subtype = Subtypes::VolumeFlashMapEntry;
break; break;
case NVRAM_PHOENIX_FLASH_MAP_ENTRY_TYPE_DATA_BLOCK: case NVRAM_PHOENIX_FLASH_MAP_ENTRY_TYPE_DATA_BLOCK:
subtype = Subtypes::DataBlockFlashMapEntry; subtype = Subtypes::DataFlashMapEntry;
break; break;
} }
// Add tree item // Add tree item
model->addItem(Types::NvramEntryFlashMap, subtype, name, flashMapGuidToQString(entryHeader->Guid), info, header, QByteArray(), TRUE, parsingDataToQByteArray(pdata), index); model->addItem(Types::FlashMapEntry, subtype, name, flashMapGuidToQString(entryHeader->Guid), info, header, QByteArray(), TRUE, parsingDataToQByteArray(pdata), index);
// Move to next variable // Move to next variable
offset += sizeof(PHOENIX_FLASH_MAP_ENTRY); offset += sizeof(PHOENIX_FLASH_MAP_ENTRY);

View File

@ -59,7 +59,7 @@ private:
QModelIndex lastVtf; QModelIndex lastVtf;
UINT32 capsuleOffsetFixup; UINT32 capsuleOffsetFixup;
STATUS parseRawArea(const QByteArray & data, const QModelIndex & index); STATUS parseRawArea(const QModelIndex & index);
STATUS parseVolumeHeader(const QByteArray & volume, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index); STATUS parseVolumeHeader(const QByteArray & volume, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index);
STATUS parseVolumeBody(const QModelIndex & index); STATUS parseVolumeBody(const QModelIndex & index);
STATUS parseFileHeader(const QByteArray & file, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index); STATUS parseFileHeader(const QByteArray & file, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index);
@ -107,12 +107,22 @@ private:
STATUS addMemoryAddressesRecursive(const QModelIndex & index, const UINT32 diff); STATUS addMemoryAddressesRecursive(const QModelIndex & index, const UINT32 diff);
// NVRAM parsing // NVRAM parsing
STATUS parseNvarStore(const QByteArray & data, const QModelIndex & index); STATUS parseNvramVolumeBody(const QModelIndex & index);
STATUS findNextStore(const QModelIndex & index, const QByteArray & volume, const UINT32 parentOffset, const UINT32 storeOffset, UINT32 & nextStoreOffset);
STATUS parseStoreArea(const QByteArray & data, const QModelIndex & index);
STATUS findNextStore(const QModelIndex & index, const QByteArray & data, const UINT32 parentOffset, const UINT32 storeOffset, UINT32 & nextStoreOffset);
STATUS getStoreSize(const QByteArray & data, const UINT32 storeOffset, UINT32 & storeSize); STATUS getStoreSize(const QByteArray & data, const UINT32 storeOffset, UINT32 & storeSize);
STATUS parseStoreHeader(const QByteArray & store, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index); STATUS parseStoreHeader(const QByteArray & store, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index);
STATUS parseNvarStore(const QByteArray & data, const QModelIndex & index);
//STATUS parseVssStore(const QByteArray & data, const QModelIndex & index);
//STATUS parseFtwStore(const QByteArray & data, const QModelIndex & index);
//STATUS parseFdcStore(const QByteArray & data, const QModelIndex & index);
//STATUS parseFsysStore(const QByteArray & data, const QModelIndex & index);
//STATUS parseEvsaStore(const QByteArray & data, const QModelIndex & index);
//STATUS parseFlashMapStore(const QByteArray & data, const QModelIndex & index);
//STATUS parseCmdbStore(const QByteArray & data, const QModelIndex & index);
//STATUS parseSlicData(const QByteArray & data, const QModelIndex & index);
//STATUS parseMicrocode(const QByteArray & data, const QModelIndex & index);
STATUS parseVssStoreBody(const QModelIndex & index); STATUS parseVssStoreBody(const QModelIndex & index);
STATUS parseFsysStoreBody(const QModelIndex & index); STATUS parseFsysStoreBody(const QModelIndex & index);
STATUS parseEvsaStoreBody(const QModelIndex & index); STATUS parseEvsaStoreBody(const QModelIndex & index);

View File

@ -20,23 +20,14 @@ QString nvarAttributesToQString(const UINT8 attributes)
return QString(); return QString();
QString str; QString str;
if (attributes & NVRAM_NVAR_ENTRY_ATTRIB_RUNTIME) str += QObject::tr(", Runtime");
if (attributes & NVRAM_NVAR_VARIABLE_ATTRIB_RUNTIME) if (attributes & NVRAM_NVAR_ENTRY_ATTRIB_ASCII_NAME) str += QObject::tr(", AsciiName");
str += QObject::tr(", Runtime"); if (attributes & NVRAM_NVAR_ENTRY_ATTRIB_GUID) str += QObject::tr(", Guid");
if (attributes & NVRAM_NVAR_VARIABLE_ATTRIB_ASCII_NAME) if (attributes & NVRAM_NVAR_ENTRY_ATTRIB_DATA_ONLY) str += QObject::tr(", DataOnly");
str += QObject::tr(", AsciiName"); if (attributes & NVRAM_NVAR_ENTRY_ATTRIB_EXT_HEADER) str += QObject::tr(", ExtHeader");
if (attributes & NVRAM_NVAR_VARIABLE_ATTRIB_GUID) if (attributes & NVRAM_NVAR_ENTRY_ATTRIB_HW_ERROR_RECORD) str += QObject::tr(", HwErrorRecord");
str += QObject::tr(", Guid"); if (attributes & NVRAM_NVAR_ENTRY_ATTRIB_AUTH_WRITE) str += QObject::tr(", AuthWrite");
if (attributes & NVRAM_NVAR_VARIABLE_ATTRIB_DATA_ONLY) if (attributes & NVRAM_NVAR_ENTRY_ATTRIB_VALID) str += QObject::tr(", Valid");
str += QObject::tr(", DataOnly");
if (attributes & NVRAM_NVAR_VARIABLE_ATTRIB_EXT_HEADER)
str += QObject::tr(", ExtHeader");
if (attributes & NVRAM_NVAR_VARIABLE_ATTRIB_HW_ERROR_RECORD)
str += QObject::tr(", HwErrorRecord");
if (attributes & NVRAM_NVAR_VARIABLE_ATTRIB_AUTH_WRITE)
str += QObject::tr(", AuthWrite");
if (attributes & NVRAM_NVAR_VARIABLE_ATTRIB_VALID)
str += QObject::tr(", Valid");
return str.mid(2); // Remove first comma and space return str.mid(2); // Remove first comma and space
} }
@ -56,26 +47,21 @@ QString efiTimeToQString(const EFI_TIME & time)
QString flashMapGuidToQString(const EFI_GUID & guid) QString flashMapGuidToQString(const EFI_GUID & guid)
{ {
const QByteArray baGuid((const char*)&guid, sizeof(EFI_GUID)); const QByteArray baGuid((const char*)&guid, sizeof(EFI_GUID));
if (baGuid == NVRAM_PHOENIX_FLASH_MAP_VOLUME_HEADER) if (baGuid == NVRAM_PHOENIX_FLASH_MAP_VOLUME_HEADER) return QObject::tr("Volume header");
return QObject::tr("Volume header"); if (baGuid == NVRAM_PHOENIX_FLASH_MAP_MICROCODES_GUID) return QObject::tr("Microcodes");
if (baGuid == NVRAM_PHOENIX_FLASH_MAP_MICROCODES_GUID) if (baGuid == NVRAM_PHOENIX_FLASH_MAP_CMDB_GUID) return QObject::tr("CMDB");
return QObject::tr("Microcodes"); if (baGuid == NVRAM_PHOENIX_FLASH_MAP_PUBKEY1_GUID
if (baGuid == NVRAM_PHOENIX_FLASH_MAP_CMDB_GUID) || baGuid == NVRAM_PHOENIX_FLASH_MAP_PUBKEY2_GUID) return QObject::tr("SLIC pubkey");
return QObject::tr("CMDB"); if (baGuid == NVRAM_PHOENIX_FLASH_MAP_MARKER1_GUID
if (baGuid == NVRAM_PHOENIX_FLASH_MAP_PUBKEY1_GUID || baGuid == NVRAM_PHOENIX_FLASH_MAP_PUBKEY2_GUID) || baGuid == NVRAM_PHOENIX_FLASH_MAP_MARKER2_GUID) return QObject::tr("SLIC marker");
return QObject::tr("SLIC pubkey"); if (baGuid == NVRAM_PHOENIX_FLASH_MAP_EVSA1_GUID
if (baGuid == NVRAM_PHOENIX_FLASH_MAP_MARKER1_GUID || baGuid == NVRAM_PHOENIX_FLASH_MAP_MARKER2_GUID) || baGuid == NVRAM_PHOENIX_FLASH_MAP_EVSA2_GUID
return QObject::tr("SLIC marker"); || baGuid == NVRAM_PHOENIX_FLASH_MAP_EVSA3_GUID
if (baGuid == NVRAM_PHOENIX_FLASH_MAP_EVSA1_GUID || || baGuid == NVRAM_PHOENIX_FLASH_MAP_EVSA4_GUID
baGuid == NVRAM_PHOENIX_FLASH_MAP_EVSA2_GUID || || baGuid == NVRAM_PHOENIX_FLASH_MAP_EVSA5_GUID
baGuid == NVRAM_PHOENIX_FLASH_MAP_EVSA3_GUID || || baGuid == NVRAM_PHOENIX_FLASH_MAP_EVSA6_GUID
baGuid == NVRAM_PHOENIX_FLASH_MAP_EVSA4_GUID || || baGuid == NVRAM_PHOENIX_FLASH_MAP_EVSA7_GUID) return QObject::tr("EVSA store");
baGuid == NVRAM_PHOENIX_FLASH_MAP_EVSA5_GUID || if (baGuid == NVRAM_PHOENIX_FLASH_MAP_SELF_GUID) return QObject::tr("Flash map");
baGuid == NVRAM_PHOENIX_FLASH_MAP_EVSA6_GUID ||
baGuid == NVRAM_PHOENIX_FLASH_MAP_EVSA7_GUID)
return QObject::tr("EVSA store");
if (baGuid == NVRAM_PHOENIX_FLASH_MAP_SELF_GUID)
return QObject::tr("Flash map");
return QString(); return QString();
} }

View File

@ -23,7 +23,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#pragma pack(push, 1) #pragma pack(push, 1)
// //
// NVAR store and variables // NVAR store and entry
// //
// CEF5B9A3-476D-497F-9FDC-E98143E0422C // CEF5B9A3-476D-497F-9FDC-E98143E0422C
@ -38,33 +38,30 @@ extern QString nvarAttributesToQString(const UINT8 attributes);
extern QString efiTimeToQString(const EFI_TIME & time); extern QString efiTimeToQString(const EFI_TIME & time);
// Variable header typedef struct NVAR_ENTRY_HEADER_ {
typedef struct NVAR_VARIABLE_HEADER_ {
UINT32 Signature; // NVAR UINT32 Signature; // NVAR
UINT16 Size; // Size of the variable including header UINT16 Size; // Size of the entry including header
UINT32 Next : 24; // Offset to the next variable in a list, or empty if latest in the list UINT32 Next : 24; // Offset to the next entry in a list, or empty if latest in the list
UINT32 Attributes : 8; // Attributes UINT32 Attributes : 8; // Attributes
} NVAR_VARIABLE_HEADER; } NVAR_ENTRY_HEADER;
// NVAR signature // NVAR signature
#define NVRAM_NVAR_VARIABLE_SIGNATURE 0x5241564E #define NVRAM_NVAR_ENTRY_SIGNATURE 0x5241564E
// Attributes // Attributes
#define NVRAM_NVAR_VARIABLE_ATTRIB_RUNTIME 0x01 #define NVRAM_NVAR_ENTRY_ATTRIB_RUNTIME 0x01
#define NVRAM_NVAR_VARIABLE_ATTRIB_ASCII_NAME 0x02 #define NVRAM_NVAR_ENTRY_ATTRIB_ASCII_NAME 0x02
#define NVRAM_NVAR_VARIABLE_ATTRIB_GUID 0x04 #define NVRAM_NVAR_ENTRY_ATTRIB_GUID 0x04
#define NVRAM_NVAR_VARIABLE_ATTRIB_DATA_ONLY 0x08 #define NVRAM_NVAR_ENTRY_ATTRIB_DATA_ONLY 0x08
#define NVRAM_NVAR_VARIABLE_ATTRIB_EXT_HEADER 0x10 #define NVRAM_NVAR_ENTRY_ATTRIB_EXT_HEADER 0x10
#define NVRAM_NVAR_VARIABLE_ATTRIB_HW_ERROR_RECORD 0x20 #define NVRAM_NVAR_ENTRY_ATTRIB_HW_ERROR_RECORD 0x20
#define NVRAM_NVAR_VARIABLE_ATTRIB_AUTH_WRITE 0x40 #define NVRAM_NVAR_ENTRY_ATTRIB_AUTH_WRITE 0x40
#define NVRAM_NVAR_VARIABLE_ATTRIB_VALID 0x80 #define NVRAM_NVAR_ENTRY_ATTRIB_VALID 0x80
// Extended attributes // Extended attributes
#define NVRAM_NVAR_VARIABLE_EXT_ATTRIB_CHECKSUM 0x01 #define NVRAM_NVAR_ENTRY_EXT_ATTRIB_CHECKSUM 0x01
#define NVRAM_NVAR_VARIABLE_EXT_ATTRIB_AUTH_WRITE 0x10 #define NVRAM_NVAR_ENTRY_EXT_ATTRIB_AUTH_WRITE 0x10
#define NVRAM_NVAR_VARIABLE_EXT_ATTRIB_TIME_BASED 0x20 #define NVRAM_NVAR_ENTRY_EXT_ATTRIB_TIME_BASED 0x20
// //
// TianoCore VSS store and variables // TianoCore VSS store and variables
@ -273,7 +270,7 @@ typedef struct EVSA_DATA_ENTRY_ {
#define NVRAM_EVSA_DATA_ATTRIBUTE_EXTENDED_HEADER 0x10000000 #define NVRAM_EVSA_DATA_ATTRIBUTE_EXTENDED_HEADER 0x10000000
typedef struct EVSA_DATA_ENTRY_EXTENDED { typedef struct EVSA_DATA_ENTRY_EXTENDED_ {
EVSA_ENTRY_HEADER Header; EVSA_ENTRY_HEADER Header;
UINT16 GuidId; UINT16 GuidId;
UINT16 VarId; UINT16 VarId;

View File

@ -87,7 +87,7 @@ typedef struct NVRAM_NVAR_PARSING_DATA_ {
UINT8 attributes; UINT8 attributes;
UINT8 extendedAttributes; UINT8 extendedAttributes;
UINT64 timestamp; UINT64 timestamp;
UINT8 hash[0x20]; //SHA256 UINT8 hash[SHA256_HASH_SIZE]; //SHA256
} NVRAM_NVAR_PARSING_DATA; } NVRAM_NVAR_PARSING_DATA;
typedef struct NVRAM_PARSING_DATA_ { typedef struct NVRAM_PARSING_DATA_ {

View File

@ -19,84 +19,45 @@ QString regionTypeToQString(const UINT8 type)
{ {
switch (type) switch (type)
{ {
case Subtypes::DescriptorRegion: case Subtypes::DescriptorRegion: return QObject::tr("Descriptor");
return QObject::tr("Descriptor"); case Subtypes::BiosRegion: return QObject::tr("BIOS");
case Subtypes::BiosRegion: case Subtypes::MeRegion: return QObject::tr("ME");
return QObject::tr("BIOS"); case Subtypes::GbeRegion: return QObject::tr("GbE");
case Subtypes::MeRegion: case Subtypes::PdrRegion: return QObject::tr("PDR");
return QObject::tr("ME"); case Subtypes::Reserved1Region: return QObject::tr("Reserved1");
case Subtypes::GbeRegion: case Subtypes::Reserved2Region: return QObject::tr("Reserved2");
return QObject::tr("GbE"); case Subtypes::Reserved3Region: return QObject::tr("Reserved3");
case Subtypes::PdrRegion: case Subtypes::EcRegion: return QObject::tr("EC");
return QObject::tr("PDR"); case Subtypes::Reserved4Region: return QObject::tr("Reserved4");
case Subtypes::Reserved1Region:
return QObject::tr("Reserved1");
case Subtypes::Reserved2Region:
return QObject::tr("Reserved2");
case Subtypes::Reserved3Region:
return QObject::tr("Reserved3");
case Subtypes::EcRegion:
return QObject::tr("EC");
case Subtypes::Reserved4Region:
return QObject::tr("Reserved4");
default:
return QObject::tr("Unknown");
}; };
} }
QString itemTypeToQString(const UINT8 type) QString itemTypeToQString(const UINT8 type)
{ {
switch (type) { switch (type) {
case Types::Root: case Types::Root: return QObject::tr("Root");
return QObject::tr("Root"); case Types::Image: return QObject::tr("Image");
case Types::Image: case Types::Capsule: return QObject::tr("Capsule");
return QObject::tr("Image"); case Types::Region: return QObject::tr("Region");
case Types::Capsule: case Types::Volume: return QObject::tr("Volume");
return QObject::tr("Capsule"); case Types::Padding: return QObject::tr("Padding");
case Types::Region: case Types::File: return QObject::tr("File");
return QObject::tr("Region"); case Types::Section: return QObject::tr("Section");
case Types::Volume: case Types::FreeSpace: return QObject::tr("Free space");
return QObject::tr("Volume"); case Types::VssStore: return QObject::tr("VSS store");
case Types::Padding: case Types::FtwStore: return QObject::tr("FTW store");
return QObject::tr("Padding"); case Types::FdcStore: return QObject::tr("FDC store");
case Types::File: case Types::FsysStore: return QObject::tr("Fsys store");
return QObject::tr("File"); case Types::EvsaStore: return QObject::tr("EVSA store");
case Types::Section: case Types::CmdbStore: return QObject::tr("CMDB store");
return QObject::tr("Section"); case Types::FlashMapStore: return QObject::tr("FlashMap store");
case Types::FreeSpace: case Types::NvarEntry: return QObject::tr("NVAR entry");
return QObject::tr("Free space"); case Types::VssEntry: return QObject::tr("VSS entry");
case Types::NvramStoreVss: case Types::FsysEntry: return QObject::tr("Fsys entry");
return QObject::tr("VSS store"); case Types::EvsaEntry: return QObject::tr("EVSA entry");
case Types::NvramStoreFdc: case Types::FlashMapEntry: return QObject::tr("FlashMap entry");
return QObject::tr("FDC store"); case Types::Microcode: return QObject::tr("Microcode");
case Types::NvramStoreFsys: case Types::SlicData: return QObject::tr("SLIC data");
return QObject::tr("Fsys store");
case Types::NvramStoreEvsa:
return QObject::tr("EVSA store");
case Types::NvramStoreFtw:
return QObject::tr("FTW store");
case Types::NvramStoreCmdb:
return QObject::tr("CMDB store");
case Types::NvramStoreFlashMap:
return QObject::tr("FlashMap store");
case Types::NvramVariableNvar:
return QObject::tr("NVAR variable");
case Types::NvramVariableVss:
return QObject::tr("VSS variable");
case Types::NvramEntryFsys:
return QObject::tr("Fsys entry");
case Types::NvramEntryEvsa:
return QObject::tr("EVSA entry");
case Types::NvramEntryFlashMap:
return QObject::tr("FlashMap entry");
case Types::Microcode:
return QObject::tr("Microcode");
case Types::SlicPubkey:
return QObject::tr("SLIC pubkey");
case Types::SlicMarker:
return QObject::tr("SLIC marker");
default:
return QObject::tr("Unknown");
} }
} }
@ -105,146 +66,93 @@ QString itemSubtypeToQString(const UINT8 type, const UINT8 subtype)
switch (type) { switch (type) {
case Types::Root: case Types::Root:
case Types::FreeSpace: case Types::FreeSpace:
case Types::NvramStoreVss: case Types::VssStore:
case Types::NvramStoreFdc: case Types::FdcStore:
case Types::NvramStoreFsys: case Types::FsysStore:
case Types::NvramStoreEvsa: case Types::EvsaStore:
case Types::NvramStoreFtw: case Types::FtwStore:
case Types::NvramStoreFlashMap: case Types::FlashMapStore:
case Types::NvramStoreCmdb: case Types::CmdbStore:
case Types::NvramEntryFsys: case Types::FsysEntry:
case Types::SlicPubkey: case Types::SlicData: return QString();
case Types::SlicMarker:
return QString();
case Types::Image: case Types::Image:
if (subtype == Subtypes::IntelImage) if (subtype == Subtypes::IntelImage) return QObject::tr("Intel");
return QObject::tr("Intel"); if (subtype == Subtypes::UefiImage) return QObject::tr("UEFI");
if (Subtypes::UefiImage)
return QObject::tr("UEFI");
break; break;
case Types::Padding: case Types::Padding:
if (subtype == Subtypes::ZeroPadding) if (subtype == Subtypes::ZeroPadding) return QObject::tr("Empty (0x00)");
return QObject::tr("Empty (0x00)"); if (subtype == Subtypes::OnePadding) return QObject::tr("Empty (0xFF)");
if (subtype == Subtypes::OnePadding) if (subtype == Subtypes::DataPadding) return QObject::tr("Non-empty");
return QObject::tr("Empty (0xFF)");
if (subtype == Subtypes::DataPadding)
return QObject::tr("Non-empty");
break; break;
case Types::Volume: case Types::Volume:
if (subtype == Subtypes::UnknownVolume) if (subtype == Subtypes::UnknownVolume) return QObject::tr("Unknown");
return QObject::tr("Unknown"); if (subtype == Subtypes::Ffs2Volume) return QObject::tr("FFSv2");
if (subtype == Subtypes::Ffs2Volume) if (subtype == Subtypes::Ffs3Volume) return QObject::tr("FFSv3");
return QObject::tr("FFSv2"); if (subtype == Subtypes::NvramVolume) return QObject::tr("NVRAM");
if (subtype == Subtypes::Ffs3Volume)
return QObject::tr("FFSv3");
if (subtype == Subtypes::NvramVolume)
return QObject::tr("NVRAM");
break; break;
case Types::Capsule: case Types::Capsule:
if (subtype == Subtypes::AptioSignedCapsule) if (subtype == Subtypes::AptioSignedCapsule) return QObject::tr("Aptio signed");
return QObject::tr("Aptio signed"); if (subtype == Subtypes::AptioUnsignedCapsule) return QObject::tr("Aptio unsigned");
if (subtype == Subtypes::AptioUnsignedCapsule) if (subtype == Subtypes::UefiCapsule) return QObject::tr("UEFI 2.0");
return QObject::tr("Aptio unsigned"); if (subtype == Subtypes::ToshibaCapsule) return QObject::tr("Toshiba");
if (subtype == Subtypes::UefiCapsule)
return QObject::tr("UEFI 2.0");
if (subtype == Subtypes::ToshibaCapsule)
return QObject::tr("Toshiba");
break; break;
case Types::Region: case Types::Region: return regionTypeToQString(subtype);
return regionTypeToQString(subtype); case Types::File: return fileTypeToQString(subtype);
case Types::File: case Types::Section: return sectionTypeToQString(subtype);
return fileTypeToQString(subtype); case Types::NvarEntry:
case Types::Section: if (subtype == Subtypes::InvalidNvarEntry) return QObject::tr("Invalid");
return sectionTypeToQString(subtype); if (subtype == Subtypes::InvalidLinkNvarEntry) return QObject::tr("Invalid link");
case Types::NvramVariableNvar: if (subtype == Subtypes::LinkNvarEntry) return QObject::tr("Link");
if (subtype == Subtypes::InvalidNvarVariable) if (subtype == Subtypes::DataNvarEntry) return QObject::tr("Data");
return QObject::tr("Invalid"); if (subtype == Subtypes::FullNvarEntry) return QObject::tr("Full");
if (subtype == Subtypes::InvalidLinkNvarVariable)
return QObject::tr("Invalid link");
if (subtype == Subtypes::LinkNvarVariable)
return QObject::tr("Link");
if (subtype == Subtypes::DataNvarVariable)
return QObject::tr("Data");
if (subtype == Subtypes::FullNvarVariable)
return QObject::tr("Full");
break; break;
case Types::NvramVariableVss: case Types::VssEntry:
if (subtype == Subtypes::InvalidVssVariable) if (subtype == Subtypes::InvalidVssEntry) return QObject::tr("Invalid");
return QObject::tr("Invalid"); if (subtype == Subtypes::StandardVssEntry) return QObject::tr("Standard");
if (subtype == Subtypes::StandardVssVariable) if (subtype == Subtypes::AppleVssEntry) return QObject::tr("Apple");
return QObject::tr("Standard"); if (subtype == Subtypes::AuthVssEntry) return QObject::tr("Auth");
if (subtype == Subtypes::Crc32VssVariable)
return QObject::tr("Apple CRC32");
if (subtype == Subtypes::AuthVssVariable)
return QObject::tr("Auth");
break; break;
case Types::NvramEntryEvsa: case Types::EvsaEntry:
if (subtype == Subtypes::InvalidEvsaEntry) if (subtype == Subtypes::InvalidEvsaEntry) return QObject::tr("Invalid");
return QObject::tr("Invalid"); if (subtype == Subtypes::UnknownEvsaEntry) return QObject::tr("Unknown");
if (subtype == Subtypes::UnknownEvsaEntry) if (subtype == Subtypes::GuidEvsaEntry) return QObject::tr("GUID");
return QObject::tr("Unknown"); if (subtype == Subtypes::NameEvsaEntry) return QObject::tr("Name");
if (subtype == Subtypes::GuidEvsaEntry) if (subtype == Subtypes::DataEvsaEntry) return QObject::tr("Data");
return QObject::tr("GUID");
if (subtype == Subtypes::NameEvsaEntry)
return QObject::tr("Name");
if (subtype == Subtypes::DataEvsaEntry)
return QObject::tr("Data");
break; break;
case Types::NvramEntryFlashMap: case Types::FlashMapEntry:
if (subtype == Subtypes::VolumeFlashMapEntry) if (subtype == Subtypes::VolumeFlashMapEntry) return QObject::tr("Volume");
return QObject::tr("Volume"); if (subtype == Subtypes::DataFlashMapEntry) return QObject::tr("Data");
if (subtype == Subtypes::DataBlockFlashMapEntry)
return QObject::tr("Data block");
break; break;
case Types::Microcode: case Types::Microcode:
if (subtype == Subtypes::IntelMicrocode) if (subtype == Subtypes::IntelMicrocode) return QObject::tr("Intel");
return QObject::tr("Intel"); if (subtype == Subtypes::AmdMicrocode) return QObject::tr("AMD");
if (subtype == Subtypes::AmdMicrocode)
return QObject::tr("AMD");
break; break;
} }
return QObject::tr("Unknown subtype");
} }
QString compressionTypeToQString(const UINT8 algorithm) QString compressionTypeToQString(const UINT8 algorithm)
{ {
switch (algorithm) { switch (algorithm) {
case COMPRESSION_ALGORITHM_NONE: case COMPRESSION_ALGORITHM_NONE: return QObject::tr("None");
return QObject::tr("None"); case COMPRESSION_ALGORITHM_EFI11: return QObject::tr("EFI 1.1");
case COMPRESSION_ALGORITHM_EFI11: case COMPRESSION_ALGORITHM_TIANO: return QObject::tr("Tiano");
return QObject::tr("EFI 1.1"); case COMPRESSION_ALGORITHM_UNDECIDED: return QObject::tr("Undecided Tiano/EFI 1.1");
case COMPRESSION_ALGORITHM_TIANO: case COMPRESSION_ALGORITHM_LZMA: return QObject::tr("LZMA");
return QObject::tr("Tiano"); case COMPRESSION_ALGORITHM_IMLZMA: return QObject::tr("Intel modified LZMA");
case COMPRESSION_ALGORITHM_UNDECIDED:
return QObject::tr("Undecided Tiano/EFI 1.1");
case COMPRESSION_ALGORITHM_LZMA:
return QObject::tr("LZMA");
case COMPRESSION_ALGORITHM_IMLZMA:
return QObject::tr("Intel modified LZMA");
default:
return QObject::tr("Unknown");
} }
return QObject::tr("Unknown");
} }
QString actionTypeToQString(const UINT8 action) QString actionTypeToQString(const UINT8 action)
{ {
switch (action) { switch (action) {
case Actions::NoAction: case Actions::NoAction: return QString();
return QString(); case Actions::Create: return QObject::tr("Create");
case Actions::Create: case Actions::Insert: return QObject::tr("Insert");
return QObject::tr("Create"); case Actions::Replace: return QObject::tr("Replace");
case Actions::Insert: case Actions::Remove: return QObject::tr("Remove");
return QObject::tr("Insert"); case Actions::Rebuild: return QObject::tr("Rebuild");
case Actions::Replace: case Actions::Rebase: return QObject::tr("Rebase");
return QObject::tr("Replace");
case Actions::Remove:
return QObject::tr("Remove");
case Actions::Rebuild:
return QObject::tr("Rebuild");
case Actions::Rebase:
return QObject::tr("Rebase");
default:
return QObject::tr("Unknown");
} }
} }

View File

@ -43,21 +43,20 @@ namespace Types {
File, File,
Section, Section,
FreeSpace, FreeSpace,
NvramStoreVss, VssStore,
NvramStoreFdc, FtwStore,
NvramStoreFsys, FdcStore,
NvramStoreEvsa, FsysStore,
NvramStoreFlashMap, EvsaStore,
NvramStoreFtw, FlashMapStore,
NvramStoreCmdb, CmdbStore,
NvramVariableNvar, NvarEntry,
NvramVariableVss, VssEntry,
NvramEntryFsys, FsysEntry,
NvramEntryEvsa, EvsaEntry,
NvramEntryFlashMap, FlashMapEntry,
Microcode, Microcode,
SlicPubkey, SlicData,
SlicMarker,
}; };
} }
@ -100,22 +99,22 @@ namespace Subtypes {
DataPadding DataPadding
}; };
enum NvarVariableSubtypes { enum NvarEntrySubtypes {
InvalidNvarVariable = 130, InvalidNvarEntry = 130,
InvalidLinkNvarVariable, InvalidLinkNvarEntry,
LinkNvarVariable, LinkNvarEntry,
DataNvarVariable, DataNvarEntry,
FullNvarVariable FullNvarEntry
}; };
enum VssVariableSubtypes { enum VssEntrySubtypes {
InvalidVssVariable = 140, InvalidVssEntry = 140,
StandardVssVariable, StandardVssEntry,
Crc32VssVariable, AppleVssEntry,
AuthVssVariable AuthVssEntry
}; };
enum EvsaVariableSubtypes { enum EvsaEntrySubtypes {
InvalidEvsaEntry = 150, InvalidEvsaEntry = 150,
UnknownEvsaEntry, UnknownEvsaEntry,
GuidEvsaEntry, GuidEvsaEntry,
@ -125,13 +124,18 @@ namespace Subtypes {
enum FlashMapEntrySubtypes { enum FlashMapEntrySubtypes {
VolumeFlashMapEntry = 160, VolumeFlashMapEntry = 160,
DataBlockFlashMapEntry DataFlashMapEntry
}; };
enum MicrocodeSubtypes { enum MicrocodeSubtypes {
IntelMicrocode = 170, IntelMicrocode = 170,
AmdMicrocode AmdMicrocode
}; };
enum SlicDataSubtypes {
PubkeySlicData = 180,
MarkerSlicData
};
}; };
// *ToQString conversion routines // *ToQString conversion routines