mirror of
https://github.com/LongSoft/UEFITool.git
synced 2025-05-15 23:54:45 -04:00
Merge Qt/non-Qt codebase
- added UEFIDump tool, which is now Windows-only UEFIExtract with some limitations, made as PoC for non-Qt engine usage - ensured that Qt classes will be used, if available - checked build of UT and UE - porting of UEFIFind to non-Qt engine TBD
This commit is contained in:
parent
12029c768c
commit
9045fc6cc0
22 changed files with 612 additions and 250 deletions
|
@ -13,24 +13,24 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
|
||||
#include "ffsops.h"
|
||||
|
||||
STATUS FfsOperations::extract(const QModelIndex & index, QString & name, QByteArray & extracted, const UINT8 mode)
|
||||
USTATUS FfsOperations::extract(const UModelIndex & index, UString & name, UByteArray & extracted, const UINT8 mode)
|
||||
{
|
||||
// Sanity check
|
||||
if (!index.isValid())
|
||||
return ERR_INVALID_PARAMETER;
|
||||
return U_INVALID_PARAMETER;
|
||||
|
||||
// Get data from parsing data
|
||||
PARSING_DATA pdata = parsingDataFromQModelIndex(index);
|
||||
PARSING_DATA pdata = parsingDataFromUModelIndex(index);
|
||||
|
||||
// Construct a name for extracted data
|
||||
QString itemName = model->name(index);
|
||||
QString itemText = model->text(index);
|
||||
UString itemName = model->name(index);
|
||||
UString itemText = model->text(index);
|
||||
|
||||
// Default name
|
||||
name = itemName.replace(' ', '_').replace('/', '_').replace('-', '_');
|
||||
|
||||
switch (model->type(index)) {
|
||||
case Types::Volume: if (pdata.volume.hasExtendedHeader) name = guidToQString(pdata.volume.extendedHeaderGuid).replace('-', '_'); break;
|
||||
case Types::Volume: if (pdata.volume.hasExtendedHeader) name = guidToUString(pdata.volume.extendedHeaderGuid).replace('-', '_'); break;
|
||||
case Types::NvarEntry:
|
||||
case Types::VssEntry:
|
||||
case Types::FsysEntry:
|
||||
|
@ -39,11 +39,11 @@ STATUS FfsOperations::extract(const QModelIndex & index, QString & name, QByteAr
|
|||
case Types::File: name = itemText.isEmpty() ? itemName : itemText.replace(' ', '_').replace('-', '_'); break;
|
||||
case Types::Section: {
|
||||
// Get parent file name
|
||||
QModelIndex fileIndex = model->findParentOfType(index, Types::File);
|
||||
QString fileText = model->text(fileIndex);
|
||||
UModelIndex fileIndex = model->findParentOfType(index, Types::File);
|
||||
UString fileText = model->text(fileIndex);
|
||||
name = fileText.isEmpty() ? model->name(fileIndex) : fileText.replace(' ', '_').replace('-', '_');
|
||||
// Append section subtype name
|
||||
name += QChar('_') + itemName.replace(' ', '_');
|
||||
name += '_' + itemName.replace(' ', '_');
|
||||
} break;
|
||||
}
|
||||
|
||||
|
@ -67,9 +67,9 @@ STATUS FfsOperations::extract(const QModelIndex & index, QString & name, QByteAr
|
|||
extracted.clear();
|
||||
// There is no need to redo decompression, we can use child items
|
||||
for (int i = 0; i < model->rowCount(index); i++) {
|
||||
QModelIndex childIndex = index.child(i, 0);
|
||||
UModelIndex childIndex = index.child(i, 0);
|
||||
// Ensure 4-byte alignment of current section
|
||||
extracted.append(QByteArray('\x00', ALIGN4((UINT32)extracted.size()) - (UINT32)extracted.size()));
|
||||
extracted.append(UByteArray('\x00', ALIGN4((UINT32)extracted.size()) - (UINT32)extracted.size()));
|
||||
// Add current section header, body and tail
|
||||
extracted.append(model->header(childIndex));
|
||||
extracted.append(model->body(childIndex));
|
||||
|
@ -77,49 +77,49 @@ STATUS FfsOperations::extract(const QModelIndex & index, QString & name, QByteAr
|
|||
}
|
||||
}
|
||||
else
|
||||
return ERR_UNKNOWN_EXTRACT_MODE;
|
||||
return U_UNKNOWN_EXTRACT_MODE;
|
||||
|
||||
return ERR_SUCCESS;
|
||||
return U_SUCCESS;
|
||||
}
|
||||
|
||||
STATUS FfsOperations::replace(const QModelIndex & index, const QString & data, const UINT8 mode)
|
||||
USTATUS FfsOperations::replace(const UModelIndex & index, const UString & data, const UINT8 mode)
|
||||
{
|
||||
// Sanity check
|
||||
if (!index.isValid())
|
||||
return ERR_INVALID_PARAMETER;
|
||||
return U_INVALID_PARAMETER;
|
||||
|
||||
// Get data from parsing data
|
||||
//PARSING_DATA pdata = parsingDataFromQModelIndex(index);
|
||||
|
||||
if (mode == REPLACE_MODE_AS_IS) {
|
||||
return ERR_NOT_IMPLEMENTED;
|
||||
return U_NOT_IMPLEMENTED;
|
||||
}
|
||||
else if (mode == REPLACE_MODE_BODY) {
|
||||
return ERR_NOT_IMPLEMENTED;
|
||||
return U_NOT_IMPLEMENTED;
|
||||
}
|
||||
else
|
||||
return ERR_UNKNOWN_REPLACE_MODE;
|
||||
return U_UNKNOWN_REPLACE_MODE;
|
||||
|
||||
return ERR_NOT_IMPLEMENTED;
|
||||
return U_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
STATUS FfsOperations::remove(const QModelIndex & index)
|
||||
USTATUS FfsOperations::remove(const UModelIndex & index)
|
||||
{
|
||||
// Sanity check
|
||||
if (!index.isValid())
|
||||
return ERR_INVALID_PARAMETER;
|
||||
return U_INVALID_PARAMETER;
|
||||
|
||||
// Set remove action
|
||||
model->setAction(index, Actions::Remove);
|
||||
|
||||
return ERR_SUCCESS;
|
||||
return U_SUCCESS;
|
||||
}
|
||||
|
||||
STATUS FfsOperations::rebuild(const QModelIndex & index)
|
||||
USTATUS FfsOperations::rebuild(const UModelIndex & index)
|
||||
{
|
||||
// Sanity check
|
||||
if (!index.isValid())
|
||||
return ERR_INVALID_PARAMETER;
|
||||
return U_INVALID_PARAMETER;
|
||||
|
||||
// On insert action, set insert action for children
|
||||
//if (action == Actions::Insert)
|
||||
|
@ -130,10 +130,10 @@ STATUS FfsOperations::rebuild(const QModelIndex & index)
|
|||
model->setAction(index, Actions::Rebuild);
|
||||
|
||||
// Rebuild parent, if it has no action now
|
||||
QModelIndex parent = index.parent();
|
||||
UModelIndex parent = index.parent();
|
||||
if (parent.isValid() && model->type(parent) != Types::Root
|
||||
&& model->action(parent) == Actions::NoAction)
|
||||
rebuild(parent);
|
||||
|
||||
return ERR_SUCCESS;
|
||||
return U_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue