NE Alpha 36

This commit is contained in:
Cr4sh 2016-12-04 01:36:01 +03:00
parent 4160a6a580
commit 0e60013311
7 changed files with 52 additions and 20 deletions

View File

@ -37,7 +37,7 @@ void HexViewDialog::setFont(const QFont &font)
hexView->setFont(font);
}
void HexViewDialog::setItem(const UModelIndex & index)
void HexViewDialog::setItem(const UModelIndex & index, bool bodyOnly)
{
const TreeModel * model = (const TreeModel*)index.model();
@ -47,6 +47,8 @@ void HexViewDialog::setItem(const UModelIndex & index)
setWindowTitle(UString("Hex view: ") + (itemText.isEmpty() ? itemName : itemName + " | " + itemText));
// Set hex data
QByteArray data = model->header(index) + model->body(index) + model->tail(index);
QByteArray data;
if (bodyOnly) data = model->body(index);
else data = model->header(index) + model->body(index) + model->tail(index);
hexView->setData(data);
}

View File

@ -28,7 +28,7 @@ public:
~HexViewDialog();
Ui::HexViewDialog* ui;
void setItem(const UModelIndex & index);
void setItem(const UModelIndex & index, bool bodyOnly);
void setFont(const QFont &font);
private:

View File

@ -18,7 +18,7 @@
UEFITool::UEFITool(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::UEFITool),
version(tr("NE Alpha35"))
version(tr("NE Alpha36"))
{
clipboard = QApplication::clipboard();
@ -39,6 +39,7 @@ version(tr("NE Alpha35"))
connect(ui->actionSaveImageFile, SIGNAL(triggered()), this, SLOT(saveImageFile()));
connect(ui->actionSearch, SIGNAL(triggered()), this, SLOT(search()));
connect(ui->actionHexView, SIGNAL(triggered()), this, SLOT(hexView()));
connect(ui->actionBodyHexView, SIGNAL(triggered()), this, SLOT(bodyHexView()));
connect(ui->actionExtract, SIGNAL(triggered()), this, SLOT(extractAsIs()));
connect(ui->actionExtractBody, SIGNAL(triggered()), this, SLOT(extractBody()));
connect(ui->actionExtractBodyUncompressed, SIGNAL(triggered()), this, SLOT(extractBodyUncompressed()));
@ -198,6 +199,7 @@ void UEFITool::populateUi(const QModelIndex &current)
// Enable actions
ui->actionHexView->setDisabled(model->hasEmptyHeader(current) && model->hasEmptyBody(current) && model->hasEmptyTail(current));
ui->actionBodyHexView->setDisabled(model->hasEmptyBody(current));
ui->actionExtract->setDisabled(model->hasEmptyHeader(current) && model->hasEmptyBody(current) && model->hasEmptyTail(current));
ui->actionGoToData->setEnabled(type == Types::NvarEntry && subtype == Subtypes::LinkNvarEntry);
@ -309,7 +311,17 @@ void UEFITool::hexView()
if (!index.isValid())
return;
hexViewDialog->setItem(index);
hexViewDialog->setItem(index, false);
hexViewDialog->exec();
}
void UEFITool::bodyHexView()
{
QModelIndex index = ui->structureTreeView->selectionModel()->currentIndex();
if (!index.isValid())
return;
hexViewDialog->setItem(index, true);
hexViewDialog->exec();
}
@ -364,7 +376,7 @@ void UEFITool::goToData()
void UEFITool::insert(const UINT8 mode)
{
U_UNUSED_PARAMETER(mode);
/*QModelIndex index = ui->structureTreeView->selectionModel()->currentIndex();
if (!index.isValid())
return;

View File

@ -78,6 +78,7 @@ private slots:
void goToOffset();
void hexView();
void bodyHexView();
void goToData();
void extract(const UINT8 mode);

View File

@ -305,6 +305,7 @@
<string>&amp;Capsule</string>
</property>
<addaction name="actionHexView"/>
<addaction name="actionBodyHexView"/>
<addaction name="separator"/>
<addaction name="actionExtract"/>
<addaction name="actionExtractBody"/>
@ -354,6 +355,7 @@
<string>&amp;Volume</string>
</property>
<addaction name="actionHexView"/>
<addaction name="actionBodyHexView"/>
<addaction name="separator"/>
<addaction name="actionExtract"/>
<addaction name="actionExtractBody"/>
@ -373,6 +375,7 @@
<string>&amp;File</string>
</property>
<addaction name="actionHexView"/>
<addaction name="actionBodyHexView"/>
<addaction name="separator"/>
<addaction name="actionExtract"/>
<addaction name="actionExtractBody"/>
@ -396,6 +399,7 @@
<string>&amp;Section</string>
</property>
<addaction name="actionHexView"/>
<addaction name="actionBodyHexView"/>
<addaction name="separator"/>
<addaction name="actionExtract"/>
<addaction name="actionExtractBody"/>
@ -432,6 +436,7 @@
<string>Variable</string>
</property>
<addaction name="actionHexView"/>
<addaction name="actionBodyHexView"/>
<addaction name="separator"/>
<addaction name="actionGoToData"/>
<addaction name="separator"/>
@ -456,6 +461,7 @@
<string>S&amp;tore</string>
</property>
<addaction name="actionHexView"/>
<addaction name="actionBodyHexView"/>
<addaction name="separator"/>
<addaction name="actionExtract"/>
<addaction name="actionExtractBody"/>
@ -771,6 +777,17 @@
<string>Ctrl+G</string>
</property>
</action>
<action name="actionBodyHexView">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Body hex vie&amp;w...</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+D</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>

View File

@ -1063,7 +1063,7 @@ USTATUS FfsParser::parseVolumeHeader(const UByteArray & volume, const UINT32 loc
}
index = model->addItem(model->offset(parent) + localOffset, Types::Volume, subtype, name, text, info, header, body, UByteArray(), Fixed, parent);
// Set parsing data for created item
// Set parsing data for created volume
VOLUME_PARSING_DATA pdata;
pdata.emptyByte = emptyByte;
pdata.ffsVersion = ffsVersion;
@ -1488,6 +1488,8 @@ USTATUS FfsParser::parseFileHeader(const UByteArray & file, const UINT32 localOf
FILE_PARSING_DATA pdata;
pdata.emptyByte = (fileHeader->State & EFI_FILE_ERASE_POLARITY) ? 0xFF : 0x00;
pdata.guid = fileHeader->Name;
model->setParsingData(index, UByteArray((const char*)&pdata, sizeof(pdata)));
// Override lastVtf index, if needed
if (isVtf) {
@ -2904,6 +2906,7 @@ USTATUS FfsParser::parseFit(const UModelIndex & index, const UINT32 diff)
UString info;
for (UINT32 i = 1; i < fitHeader->Size; i++) {
currentStrings.clear();
info.clear();
const FIT_ENTRY* currentEntry = fitHeader + i;
UINT32 currentEntrySize = currentEntry->Size;
@ -2916,13 +2919,13 @@ USTATUS FfsParser::parseFit(const UModelIndex & index, const UINT32 diff)
case FIT_TYPE_EMPTY:
break;
case FIT_TYPE_MICROCODE:
case FIT_TYPE_MICROCODE: {
//TODO: refactor into function with error reporting
if (currentEntry->Address > diff && currentEntry->Address < 0xFFFFFFFFUL) {
UINT32 offset = currentEntry->Address - diff;
UModelIndex mcIndex = model->findByOffset(offset);
UByteArray mcFile = model->header(mcIndex) + model->body(mcIndex) + model->tail(mcIndex);
UINT32 mcOffset = offset - model->offset(mcIndex);
if (mcOffset + sizeof(INTEL_MICROCODE_HEADER) <= (UINT32)mcFile.size()) {
const INTEL_MICROCODE_HEADER* header = (const INTEL_MICROCODE_HEADER*)(mcFile.constData() + mcOffset);
@ -2936,7 +2939,7 @@ USTATUS FfsParser::parseFit(const UModelIndex & index, const UINT32 diff)
if (reservedBytesValid) {
UINT32 mcSize = header->TotalSize;
if (mcOffset + mcSize <= (UINT32)mcFile.size()) {
info = usprintf("LocalOffset %08Xh, CPUID %Xh, Revision %Xh, Date %08Xh",
info = usprintf("LocalOffset %08Xh, CPUID %08Xh, Revision %08Xh, Date %08Xh",
mcOffset,
header->CpuSignature,
header->Revision,
@ -2948,7 +2951,7 @@ USTATUS FfsParser::parseFit(const UModelIndex & index, const UINT32 diff)
}
}
}
break;
} break;
case FIT_TYPE_BIOS_AC_MODULE:
case FIT_TYPE_BIOS_INIT_MODULE:

View File

@ -57,7 +57,6 @@ USTATUS NvramParser::parseNvarStore(const UModelIndex & index)
bool isInvalid = false;
bool isInvalidLink = false;
//bool isDataOnly = false;
bool hasExtendedHeader = false;
bool hasChecksum = false;
bool hasTimestamp = false;
@ -113,7 +112,7 @@ USTATUS NvramParser::parseNvarStore(const UModelIndex & index)
// Add GUID store area
UByteArray guidArea = data.right(guidAreaSize);
// Get info
name = UString("GUID store area");
name = UString("GUID store");
info = usprintf("Full size: %Xh (%u)\nGUIDs in store: %u",
guidArea.size(), guidArea.size(),
guidsInStore);
@ -412,8 +411,7 @@ USTATUS NvramParser::parseNvramVolumeBody(const UModelIndex & index)
UINT32 storeOffset = prevStoreOffset;
UINT32 prevStoreSize = 0;
while (!result)
{
while (!result) {
// Padding between stores
if (storeOffset > prevStoreOffset + prevStoreSize) {
UINT32 paddingOffset = prevStoreOffset + prevStoreSize;
@ -476,7 +474,6 @@ USTATUS NvramParser::parseNvramVolumeBody(const UModelIndex & index)
info = usprintf("Full size: %Xh (%u)", padding.size(), padding.size());
if (padding.count(emptyByte) == padding.size()) { // Free space
// Add tree item
model->addItem(localOffset + storeOffset, Types::FreeSpace, 0, UString("Free space"), UString(), info, UByteArray(), padding, UByteArray(), Movable, index);
}
@ -781,7 +778,7 @@ USTATUS NvramParser::parseFtwStoreHeader(const UByteArray & store, const UINT32
if (parentVolumeIndex.isValid() && model->hasEmptyParsingData(parentVolumeIndex) == false) {
UByteArray data = model->parsingData(parentVolumeIndex);
const VOLUME_PARSING_DATA* pdata = (const VOLUME_PARSING_DATA*)data.constData();
emptyByte = pdata->ffsVersion;
emptyByte = pdata->emptyByte;
}
// Get FTW block headers
@ -1185,7 +1182,7 @@ USTATUS NvramParser::parseIntelMicrocodeHeader(const UByteArray & store, const U
// Add info
UString name("Intel microcode");
UString info = usprintf("\nFull size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\n"
UString info = usprintf("Full size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\n"
"Date: %08Xh\nCPU signature: %08Xh\nRevision: %08Xh\nChecksum: %08Xh\nLoader revision: %08Xh\nCPU flags: %08Xh",
ucodeHeader->TotalSize, ucodeHeader->TotalSize,
header.size(), header.size(),
@ -1262,7 +1259,7 @@ USTATUS NvramParser::parseVssStoreBody(const UModelIndex & index)
if (parentVolumeIndex.isValid() && model->hasEmptyParsingData(parentVolumeIndex) == false) {
UByteArray data = model->parsingData(parentVolumeIndex);
const VOLUME_PARSING_DATA* pdata = (const VOLUME_PARSING_DATA*)data.constData();
emptyByte = pdata->ffsVersion;
emptyByte = pdata->emptyByte;
}
// Get local offset
@ -1553,7 +1550,7 @@ USTATUS NvramParser::parseEvsaStoreBody(const UModelIndex & index)
if (parentVolumeIndex.isValid() && model->hasEmptyParsingData(parentVolumeIndex) == false) {
UByteArray data = model->parsingData(parentVolumeIndex);
const VOLUME_PARSING_DATA* pdata = (const VOLUME_PARSING_DATA*)data.constData();
emptyByte = pdata->ffsVersion;
emptyByte = pdata->emptyByte;
}
// Get local offset