mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-22 16:08:23 +08:00
LessQt, part 1
- added wrappers over Qt classes for seamless replacement if Qt is not available - added bstrlib as submodule - only UEFIExtract works with this changes for now, others will followa bit later
This commit is contained in:
parent
71ce2a07b2
commit
bf8632c063
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "bstrlib"]
|
||||||
|
path = bstrlib
|
||||||
|
url = https://github.com/websnarf/bstrlib
|
@ -22,48 +22,48 @@ FfsDumper::~FfsDumper()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
STATUS FfsDumper::dump(const QModelIndex & root, const QString & path, const bool dumpAll, const QString & guid)
|
USTATUS FfsDumper::dump(const UModelIndex & root, const UString & path, const bool dumpAll, const UString & guid)
|
||||||
{
|
{
|
||||||
dumped = false;
|
dumped = false;
|
||||||
UINT8 result = recursiveDump(root, path, dumpAll, guid);
|
UINT8 result = recursiveDump(root, path, dumpAll, guid);
|
||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
else if (!dumped)
|
else if (!dumped)
|
||||||
return ERR_ITEM_NOT_FOUND;
|
return U_ITEM_NOT_FOUND;
|
||||||
return ERR_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATUS FfsDumper::recursiveDump(const QModelIndex & index, const QString & path, const bool dumpAll, const QString & guid)
|
USTATUS FfsDumper::recursiveDump(const UModelIndex & index, const UString & path, const bool dumpAll, const UString & guid)
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return ERR_INVALID_PARAMETER;
|
return U_INVALID_PARAMETER;
|
||||||
|
|
||||||
QDir dir;
|
QDir dir;
|
||||||
if (guid.isEmpty() ||
|
if (guid.isEmpty() ||
|
||||||
guidToQString(*(const EFI_GUID*)model->header(index).constData()) == guid ||
|
guidToUString(*(const EFI_GUID*)model->header(index).constData()) == guid ||
|
||||||
guidToQString(*(const EFI_GUID*)model->header(model->findParentOfType(index, Types::File)).constData()) == guid) {
|
guidToUString(*(const EFI_GUID*)model->header(model->findParentOfType(index, Types::File)).constData()) == guid) {
|
||||||
|
|
||||||
if (dir.cd(path))
|
if (dir.cd(path))
|
||||||
return ERR_DIR_ALREADY_EXIST;
|
return U_DIR_ALREADY_EXIST;
|
||||||
|
|
||||||
if (!dir.mkpath(path))
|
if (!dir.mkpath(path))
|
||||||
return ERR_DIR_CREATE;
|
return U_DIR_CREATE;
|
||||||
|
|
||||||
QFile file;
|
QFile file;
|
||||||
if (dumpAll || model->rowCount(index) == 0) { // Dump if leaf item or dumpAll is true
|
if (dumpAll || model->rowCount(index) == 0) { // Dump if leaf item or dumpAll is true
|
||||||
if (!model->header(index).isEmpty()) {
|
if (!model->header(index).isEmpty()) {
|
||||||
file.setFileName(QObject::tr("%1/header.bin").arg(path));
|
file.setFileName(path + UString("/header.bin"));
|
||||||
if (!file.open(QFile::WriteOnly))
|
if (!file.open(QFile::WriteOnly))
|
||||||
return ERR_FILE_OPEN;
|
return U_FILE_OPEN;
|
||||||
|
|
||||||
file.write(model->header(index));
|
file.write(model->header(index));
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!model->body(index).isEmpty()) {
|
if (!model->body(index).isEmpty()) {
|
||||||
file.setFileName(QObject::tr("%1/body.bin").arg(path));
|
file.setFileName(path + UString("/body.bin"));
|
||||||
if (!file.open(QFile::WriteOnly))
|
if (!file.open(QFile::WriteOnly))
|
||||||
return ERR_FILE_OPEN;
|
return U_FILE_OPEN;
|
||||||
|
|
||||||
file.write(model->body(index));
|
file.write(model->body(index));
|
||||||
file.close();
|
file.close();
|
||||||
@ -71,14 +71,13 @@ STATUS FfsDumper::recursiveDump(const QModelIndex & index, const QString & path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Always dump info
|
// Always dump info
|
||||||
QString info = QObject::tr("Type: %1\nSubtype: %2\n%3%4\n")
|
UString info = UString("Type: ") + itemTypeToUString(model->type(index)) + UString("\n")
|
||||||
.arg(itemTypeToQString(model->type(index)))
|
+ UString("Subtype: ") + itemSubtypeToUString(model->type(index), model->subtype(index)) + UString("\n")
|
||||||
.arg(itemSubtypeToQString(model->type(index), model->subtype(index)))
|
+ (model->text(index).isEmpty() ? UString("") : UString("Text: ") + model->text(index) + UString("\n"))
|
||||||
.arg(model->text(index).isEmpty() ? QObject::tr("") : QObject::tr("Text: %1\n").arg(model->text(index)))
|
+ model->info(index) + UString("\n");
|
||||||
.arg(model->info(index));
|
file.setFileName(path + UString("/info.txt"));
|
||||||
file.setFileName(QObject::tr("%1/info.txt").arg(path));
|
|
||||||
if (!file.open(QFile::Text | QFile::WriteOnly))
|
if (!file.open(QFile::Text | QFile::WriteOnly))
|
||||||
return ERR_FILE_OPEN;
|
return U_FILE_OPEN;
|
||||||
|
|
||||||
file.write(info.toLatin1());
|
file.write(info.toLatin1());
|
||||||
file.close();
|
file.close();
|
||||||
@ -87,16 +86,16 @@ STATUS FfsDumper::recursiveDump(const QModelIndex & index, const QString & path,
|
|||||||
|
|
||||||
UINT8 result;
|
UINT8 result;
|
||||||
for (int i = 0; i < model->rowCount(index); i++) {
|
for (int i = 0; i < model->rowCount(index); i++) {
|
||||||
QModelIndex childIndex = index.child(i, 0);
|
UModelIndex childIndex = index.child(i, 0);
|
||||||
bool useText = FALSE;
|
bool useText = FALSE;
|
||||||
if (model->type(childIndex) != Types::Volume)
|
if (model->type(childIndex) != Types::Volume)
|
||||||
useText = !model->text(childIndex).isEmpty();
|
useText = !model->text(childIndex).isEmpty();
|
||||||
|
|
||||||
QString childPath = QString("%1/%2 %3").arg(path).arg(i).arg(useText ? model->text(childIndex) : model->name(childIndex));
|
UString childPath = path + usprintf("/%u ", i) + (useText ? model->text(childIndex) : model->name(childIndex));
|
||||||
result = recursiveDump(childIndex, childPath, dumpAll, guid);
|
result = recursiveDump(childIndex, childPath, dumpAll, guid);
|
||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERR_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -14,12 +14,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
#ifndef FFSDUMPER_H
|
#ifndef FFSDUMPER_H
|
||||||
#define FFSDUMPER_H
|
#define FFSDUMPER_H
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QDir>
|
|
||||||
#include <QByteArray>
|
|
||||||
#include <QString>
|
|
||||||
#include <QModelIndex>
|
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
#include "../common/ubytearray.h"
|
||||||
|
#include "../common/ustring.h"
|
||||||
|
#include "../common/umodelindex.h"
|
||||||
#include "../common/basetypes.h"
|
#include "../common/basetypes.h"
|
||||||
#include "../common/treemodel.h"
|
#include "../common/treemodel.h"
|
||||||
#include "../common/ffs.h"
|
#include "../common/ffs.h"
|
||||||
@ -30,10 +29,10 @@ public:
|
|||||||
explicit FfsDumper(TreeModel * treeModel);
|
explicit FfsDumper(TreeModel * treeModel);
|
||||||
~FfsDumper();
|
~FfsDumper();
|
||||||
|
|
||||||
STATUS dump(const QModelIndex & root, const QString & path, const bool dumpAll = false, const QString & guid = QString());
|
USTATUS dump(const UModelIndex & root, const UString & path, const bool dumpAll = false, const UString & guid = UString());
|
||||||
|
|
||||||
private:
|
private:
|
||||||
STATUS recursiveDump(const QModelIndex & root, const QString & path, const bool dumpAll, const QString & guid);
|
USTATUS recursiveDump(const UModelIndex & root, const UString & path, const bool dumpAll, const UString & guid);
|
||||||
TreeModel* model;
|
TreeModel* model;
|
||||||
bool dumped;
|
bool dumped;
|
||||||
};
|
};
|
||||||
|
@ -6,7 +6,8 @@ TEMPLATE = app
|
|||||||
CONFIG += console
|
CONFIG += console
|
||||||
CONFIG -= app_bundle
|
CONFIG -= app_bundle
|
||||||
|
|
||||||
SOURCES += uefiextract_main.cpp \
|
SOURCES += \
|
||||||
|
uefiextract_main.cpp \
|
||||||
ffsdumper.cpp \
|
ffsdumper.cpp \
|
||||||
../common/types.cpp \
|
../common/types.cpp \
|
||||||
../common/descriptor.cpp \
|
../common/descriptor.cpp \
|
||||||
@ -22,8 +23,12 @@ SOURCES += uefiextract_main.cpp \
|
|||||||
../common/LZMA/LzmaDecompress.c \
|
../common/LZMA/LzmaDecompress.c \
|
||||||
../common/LZMA/SDK/C/LzmaDec.c \
|
../common/LZMA/SDK/C/LzmaDec.c \
|
||||||
../common/Tiano/EfiTianoDecompress.c \
|
../common/Tiano/EfiTianoDecompress.c \
|
||||||
|
../common/ustring.cpp \
|
||||||
|
../bstrlib/bstrlib.c \
|
||||||
|
../bstrlib/bstrwrap.cpp
|
||||||
|
|
||||||
HEADERS += ffsdumper.h \
|
HEADERS += \
|
||||||
|
ffsdumper.h \
|
||||||
../common/basetypes.h \
|
../common/basetypes.h \
|
||||||
../common/descriptor.h \
|
../common/descriptor.h \
|
||||||
../common/gbe.h \
|
../common/gbe.h \
|
||||||
@ -39,5 +44,10 @@ HEADERS += ffsdumper.h \
|
|||||||
../common/treemodel.h \
|
../common/treemodel.h \
|
||||||
../common/utility.h \
|
../common/utility.h \
|
||||||
../common/LZMA/LzmaDecompress.h \
|
../common/LZMA/LzmaDecompress.h \
|
||||||
../common/Tiano/EfiTianoDecompress.h
|
../common/Tiano/EfiTianoDecompress.h \
|
||||||
|
../common/umodelindex.h \
|
||||||
|
../common/ubytearray.h \
|
||||||
|
../common/ustring.h \
|
||||||
|
../bstrlib/bstrlib.h \
|
||||||
|
../bstrlib/bstrwrap.cpp
|
||||||
|
|
||||||
|
@ -11,11 +11,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QString>
|
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <../common/ustring.h>
|
||||||
#include "../common/ffsparser.h"
|
#include "../common/ffsparser.h"
|
||||||
#include "../common/ffsreport.h"
|
#include "../common/ffsreport.h"
|
||||||
#include "../common/fitparser.h"
|
#include "../common/fitparser.h"
|
||||||
@ -35,51 +34,51 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (a.arguments().length() > 1) {
|
if (a.arguments().length() > 1) {
|
||||||
// Check that input file exists
|
// Check that input file exists
|
||||||
QString path = a.arguments().at(1);
|
UString path = a.arguments().at(1);
|
||||||
QFileInfo fileInfo(path);
|
QFileInfo fileInfo(path);
|
||||||
if (!fileInfo.exists())
|
if (!fileInfo.exists())
|
||||||
return ERR_FILE_OPEN;
|
return U_FILE_OPEN;
|
||||||
|
|
||||||
// Open the input file
|
// Open the input file
|
||||||
QFile inputFile;
|
QFile inputFile;
|
||||||
inputFile.setFileName(path);
|
inputFile.setFileName(path);
|
||||||
if (!inputFile.open(QFile::ReadOnly))
|
if (!inputFile.open(QFile::ReadOnly))
|
||||||
return ERR_FILE_OPEN;
|
return U_FILE_OPEN;
|
||||||
|
|
||||||
// Read and close the file
|
// Read and close the file
|
||||||
QByteArray buffer = inputFile.readAll();
|
UByteArray buffer = inputFile.readAll();
|
||||||
inputFile.close();
|
inputFile.close();
|
||||||
|
|
||||||
// Create model and ffsParser
|
// Create model and ffsParser
|
||||||
TreeModel model;
|
TreeModel model;
|
||||||
FfsParser ffsParser(&model);
|
FfsParser ffsParser(&model);
|
||||||
// Parse input buffer
|
// Parse input buffer
|
||||||
STATUS result = ffsParser.parse(buffer);
|
USTATUS result = ffsParser.parse(buffer);
|
||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
// Show ffsParser's messages
|
// Show ffsParser's messages
|
||||||
std::vector<std::pair<QString, QModelIndex> > messages = ffsParser.getMessages();
|
std::vector<std::pair<UString, UModelIndex> > messages = ffsParser.getMessages();
|
||||||
for (size_t i = 0; i < messages.size(); i++) {
|
for (size_t i = 0; i < messages.size(); i++) {
|
||||||
std::cout << messages[i].first.toLatin1().constData() << std::endl;
|
std::cout << messages[i].first.toLatin1().constData() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get last VTF
|
// Get last VTF
|
||||||
QModelIndex lastVtf = ffsParser.getLastVtf();
|
UModelIndex lastVtf = ffsParser.getLastVtf();
|
||||||
if (lastVtf.isValid()) {
|
if (lastVtf.isValid()) {
|
||||||
// Create fitParser
|
// Create fitParser
|
||||||
FitParser fitParser(&model);
|
FitParser fitParser(&model);
|
||||||
// Find and parse FIT table
|
// Find and parse FIT table
|
||||||
result = fitParser.parse(model.index(0, 0), lastVtf);
|
result = fitParser.parse(model.index(0, 0), lastVtf);
|
||||||
if (ERR_SUCCESS == result) {
|
if (U_SUCCESS == result) {
|
||||||
// Show fitParser's messages
|
// Show fitParser's messages
|
||||||
std::vector<std::pair<QString, QModelIndex> > fitMessages = fitParser.getMessages();
|
std::vector<std::pair<UString, UModelIndex> > fitMessages = fitParser.getMessages();
|
||||||
for (size_t i = 0; i < fitMessages.size(); i++) {
|
for (size_t i = 0; i < fitMessages.size(); i++) {
|
||||||
std::cout << fitMessages[i].first.toLatin1().constData() << std::endl;
|
std::cout << fitMessages[i].first.toLatin1().constData() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show FIT table
|
// Show FIT table
|
||||||
std::vector<std::vector<QString> > fitTable = fitParser.getFitTable();
|
std::vector<std::vector<UString> > fitTable = fitParser.getFitTable();
|
||||||
if (fitTable.size()) {
|
if (fitTable.size()) {
|
||||||
std::cout << "-------------------------------------------------------------------" << std::endl;
|
std::cout << "-------------------------------------------------------------------" << std::endl;
|
||||||
std::cout << " Address | Size | Ver | Type | CS " << std::endl;
|
std::cout << " Address | Size | Ver | Type | CS " << std::endl;
|
||||||
@ -97,7 +96,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Create ffsReport
|
// Create ffsReport
|
||||||
FfsReport ffsReport(&model);
|
FfsReport ffsReport(&model);
|
||||||
std::vector<QString> report = ffsReport.generate();
|
std::vector<UString> report = ffsReport.generate();
|
||||||
if (report.size()) {
|
if (report.size()) {
|
||||||
QFile file;
|
QFile file;
|
||||||
file.setFileName(fileInfo.fileName().append(".report.txt"));
|
file.setFileName(fileInfo.fileName().append(".report.txt"));
|
||||||
@ -114,12 +113,12 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Dump all non-leaf elements
|
// Dump all non-leaf elements
|
||||||
if (a.arguments().length() == 2) {
|
if (a.arguments().length() == 2) {
|
||||||
return (ffsDumper.dump(model.index(0, 0), fileInfo.fileName().append(".dump")) != ERR_SUCCESS);
|
return (ffsDumper.dump(model.index(0, 0), fileInfo.fileName().append(".dump")) != U_SUCCESS);
|
||||||
}
|
}
|
||||||
else if (a.arguments().length() == 3 && a.arguments().at(2) == QString("all")) { // Dump everything
|
else if (a.arguments().length() == 3 && a.arguments().at(2) == UString("all")) { // Dump everything
|
||||||
return (ffsDumper.dump(model.index(0, 0), fileInfo.fileName().append(".dump"), true) != ERR_SUCCESS);
|
return (ffsDumper.dump(model.index(0, 0), fileInfo.fileName().append(".dump"), true) != U_SUCCESS);
|
||||||
}
|
}
|
||||||
else if (a.arguments().length() == 3 && a.arguments().at(2) == QString("none")) { // Skip dumping
|
else if (a.arguments().length() == 3 && a.arguments().at(2) == UString("none")) { // Skip dumping
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else { // Dump specific files
|
else { // Dump specific files
|
||||||
|
@ -100,7 +100,7 @@ UINT32 *DestinationSize
|
|||||||
DecodedSize = GetDecodedSizeOfBuf((UINT8*)Source);
|
DecodedSize = GetDecodedSizeOfBuf((UINT8*)Source);
|
||||||
|
|
||||||
*DestinationSize = (UINT32)DecodedSize;
|
*DestinationSize = (UINT32)DecodedSize;
|
||||||
return ERR_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -151,9 +151,9 @@ VOID *Destination
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (LzmaResult == SZ_OK) {
|
if (LzmaResult == SZ_OK) {
|
||||||
return ERR_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return ERR_INVALID_PARAMETER;
|
return U_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,48 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
typedef uint8_t USTATUS;
|
||||||
|
#define U_SUCCESS 0
|
||||||
|
#define U_INVALID_PARAMETER 1
|
||||||
|
#define U_BUFFER_TOO_SMALL 2
|
||||||
|
#define U_OUT_OF_RESOURCES 3
|
||||||
|
#define U_OUT_OF_MEMORY 4
|
||||||
|
#define U_FILE_OPEN 5
|
||||||
|
#define U_FILE_READ 6
|
||||||
|
#define U_FILE_WRITE 7
|
||||||
|
#define U_ITEM_NOT_FOUND 8
|
||||||
|
#define U_UNKNOWN_ITEM_TYPE 9
|
||||||
|
#define U_INVALID_FLASH_DESCRIPTOR 10
|
||||||
|
#define U_INVALID_REGION 11
|
||||||
|
#define U_EMPTY_REGION 12
|
||||||
|
#define U_BIOS_REGION_NOT_FOUND 13
|
||||||
|
#define U_VOLUMES_NOT_FOUND 14
|
||||||
|
#define U_INVALID_VOLUME 15
|
||||||
|
#define U_VOLUME_REVISION_NOT_SUPPORTED 16
|
||||||
|
#define U_COMPLEX_BLOCK_MAP 17
|
||||||
|
#define U_UNKNOWN_FFS 18
|
||||||
|
#define U_INVALID_FILE 19
|
||||||
|
#define U_INVALID_SECTION 20
|
||||||
|
#define U_UNKNOWN_SECTION 21
|
||||||
|
#define U_STANDARD_COMPRESSION_FAILED 22
|
||||||
|
#define U_CUSTOMIZED_COMPRESSION_FAILED 23
|
||||||
|
#define U_STANDARD_DECOMPRESSION_FAILED 24
|
||||||
|
#define U_CUSTOMIZED_DECOMPRESSION_FAILED 25
|
||||||
|
#define U_UNKNOWN_COMPRESSION_TYPE 26
|
||||||
|
#define U_DEPEX_PARSE_FAILED 27
|
||||||
|
#define U_UNKNOWN_EXTRACT_MODE 28
|
||||||
|
#define U_UNKNOWN_REPLACE_MODE 29
|
||||||
|
#define U_UNKNOWN_IMAGE_TYPE 30
|
||||||
|
#define U_UNKNOWN_PE_OPTIONAL_HEADER_TYPE 31
|
||||||
|
#define U_UNKNOWN_RELOCATION_TYPE 32
|
||||||
|
#define U_DIR_ALREADY_EXIST 33
|
||||||
|
#define U_DIR_CREATE 34
|
||||||
|
#define U_TRUNCATED_IMAGE 35
|
||||||
|
#define U_INVALID_CAPSULE 36
|
||||||
|
#define U_STORES_NOT_FOUND 37
|
||||||
|
#define U_NOT_IMPLEMENTED 0xFF
|
||||||
|
|
||||||
|
// UDK porting definitions
|
||||||
typedef uint8_t BOOLEAN;
|
typedef uint8_t BOOLEAN;
|
||||||
typedef int8_t INT8;
|
typedef int8_t INT8;
|
||||||
typedef uint8_t UINT8;
|
typedef uint8_t UINT8;
|
||||||
@ -42,56 +84,14 @@ typedef unsigned int UINTN;
|
|||||||
#define FALSE ((BOOLEAN)(0==1))
|
#define FALSE ((BOOLEAN)(0==1))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef UINT8 STATUS;
|
|
||||||
#define ERR_SUCCESS 0
|
|
||||||
#define ERR_INVALID_PARAMETER 1
|
|
||||||
#define ERR_BUFFER_TOO_SMALL 2
|
|
||||||
#define ERR_OUT_OF_RESOURCES 3
|
|
||||||
#define ERR_OUT_OF_MEMORY 4
|
|
||||||
#define ERR_FILE_OPEN 5
|
|
||||||
#define ERR_FILE_READ 6
|
|
||||||
#define ERR_FILE_WRITE 7
|
|
||||||
#define ERR_ITEM_NOT_FOUND 8
|
|
||||||
#define ERR_UNKNOWN_ITEM_TYPE 9
|
|
||||||
#define ERR_INVALID_FLASH_DESCRIPTOR 10
|
|
||||||
#define ERR_INVALID_REGION 11
|
|
||||||
#define ERR_EMPTY_REGION 12
|
|
||||||
#define ERR_BIOS_REGION_NOT_FOUND 13
|
|
||||||
#define ERR_VOLUMES_NOT_FOUND 14
|
|
||||||
#define ERR_INVALID_VOLUME 15
|
|
||||||
#define ERR_VOLUME_REVISION_NOT_SUPPORTED 16
|
|
||||||
#define ERR_COMPLEX_BLOCK_MAP 17
|
|
||||||
#define ERR_UNKNOWN_FFS 18
|
|
||||||
#define ERR_INVALID_FILE 19
|
|
||||||
#define ERR_INVALID_SECTION 20
|
|
||||||
#define ERR_UNKNOWN_SECTION 21
|
|
||||||
#define ERR_STANDARD_COMPRESSION_FAILED 22
|
|
||||||
#define ERR_CUSTOMIZED_COMPRESSION_FAILED 23
|
|
||||||
#define ERR_STANDARD_DECOMPRESSION_FAILED 24
|
|
||||||
#define ERR_CUSTOMIZED_DECOMPRESSION_FAILED 25
|
|
||||||
#define ERR_UNKNOWN_COMPRESSION_TYPE 26
|
|
||||||
#define ERR_DEPEX_PARSE_FAILED 27
|
|
||||||
#define ERR_UNKNOWN_EXTRACT_MODE 28
|
|
||||||
#define ERR_UNKNOWN_REPLACE_MODE 29
|
|
||||||
#define ERR_UNKNOWN_IMAGE_TYPE 30
|
|
||||||
#define ERR_UNKNOWN_PE_OPTIONAL_HEADER_TYPE 31
|
|
||||||
#define ERR_UNKNOWN_RELOCATION_TYPE 32
|
|
||||||
#define ERR_DIR_ALREADY_EXIST 33
|
|
||||||
#define ERR_DIR_CREATE 34
|
|
||||||
#define ERR_TRUNCATED_IMAGE 35
|
|
||||||
#define ERR_INVALID_CAPSULE 36
|
|
||||||
#define ERR_STORES_NOT_FOUND 37
|
|
||||||
#define ERR_NOT_IMPLEMENTED 0xFF
|
|
||||||
|
|
||||||
// UDK porting definitions
|
|
||||||
#define IN
|
#define IN
|
||||||
#define OUT
|
#define OUT
|
||||||
#define EFIAPI
|
#define EFIAPI
|
||||||
#define EFI_STATUS UINTN
|
#define EFI_STATUS UINTN
|
||||||
#define EFI_SUCCESS ERR_SUCCESS
|
#define EFI_SUCCESS U_SUCCESS
|
||||||
#define EFI_INVALID_PARAMETER ERR_INVALID_PARAMETER
|
#define EFI_INVALID_PARAMETER U_INVALID_PARAMETER
|
||||||
#define EFI_OUT_OF_RESOURCES ERR_OUT_OF_RESOURCES
|
#define EFI_OUT_OF_RESOURCES U_OUT_OF_RESOURCES
|
||||||
#define EFI_BUFFER_TOO_SMALL ERR_BUFFER_TOO_SMALL
|
#define EFI_BUFFER_TOO_SMALL U_BUFFER_TOO_SMALL
|
||||||
#define EFI_ERROR(X) (X)
|
#define EFI_ERROR(X) (X)
|
||||||
|
|
||||||
// Compression algorithms
|
// Compression algorithms
|
||||||
@ -162,10 +162,6 @@ typedef struct EFI_TIME_ {
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#define ASSERT(x) assert(x)
|
#define ASSERT(x) assert(x)
|
||||||
|
|
||||||
//Hexarg macros
|
|
||||||
#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())
|
|
||||||
|
|
||||||
// SHA256 hash size in bytes
|
// SHA256 hash size in bytes
|
||||||
#define SHA256_HASH_SIZE 0x20
|
#define SHA256_HASH_SIZE 0x20
|
||||||
|
|
||||||
|
104
common/ffs.cpp
104
common/ffs.cpp
@ -10,11 +10,11 @@ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|||||||
WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QObject>
|
#include "ustring.h"
|
||||||
#include "ffs.h"
|
#include "ffs.h"
|
||||||
|
|
||||||
// This is a workaround for the lack of static std::vector initializer before C++11
|
// This is a workaround for the lack of static std::vector initializer before C++11
|
||||||
const QByteArray FFSv2VolumesInt[] = {
|
const UByteArray FFSv2VolumesInt[] = {
|
||||||
EFI_FIRMWARE_FILE_SYSTEM_GUID,
|
EFI_FIRMWARE_FILE_SYSTEM_GUID,
|
||||||
EFI_FIRMWARE_FILE_SYSTEM2_GUID,
|
EFI_FIRMWARE_FILE_SYSTEM2_GUID,
|
||||||
EFI_APPLE_BOOT_VOLUME_FILE_SYSTEM_GUID,
|
EFI_APPLE_BOOT_VOLUME_FILE_SYSTEM_GUID,
|
||||||
@ -25,9 +25,9 @@ const QByteArray FFSv2VolumesInt[] = {
|
|||||||
};
|
};
|
||||||
// This number must be updated if the array above is grown
|
// This number must be updated if the array above is grown
|
||||||
#define FFSv2VolumesIntSize 7
|
#define FFSv2VolumesIntSize 7
|
||||||
const std::vector<QByteArray> FFSv2Volumes(FFSv2VolumesInt, FFSv2VolumesInt + FFSv2VolumesIntSize);
|
const std::vector<UByteArray> FFSv2Volumes(FFSv2VolumesInt, FFSv2VolumesInt + FFSv2VolumesIntSize);
|
||||||
// Luckily, FFSv3Volumes now only has 1 element
|
// Luckily, FFSv3Volumes now only has 1 element
|
||||||
const std::vector<QByteArray> FFSv3Volumes(1, EFI_FIRMWARE_FILE_SYSTEM3_GUID);
|
const std::vector<UByteArray> FFSv3Volumes(1, EFI_FIRMWARE_FILE_SYSTEM3_GUID);
|
||||||
|
|
||||||
const UINT8 ffsAlignmentTable[] =
|
const UINT8 ffsAlignmentTable[] =
|
||||||
{ 0, 4, 7, 9, 10, 12, 15, 16 };
|
{ 0, 4, 7, 9, 10, 12, 15, 16 };
|
||||||
@ -44,66 +44,66 @@ UINT32 uint24ToUint32(const UINT8* ffsSize)
|
|||||||
return *(UINT32*)ffsSize & 0x00FFFFFF;
|
return *(UINT32*)ffsSize & 0x00FFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString guidToQString(const EFI_GUID & guid)
|
UString guidToUString(const EFI_GUID & guid)
|
||||||
{
|
{
|
||||||
return QString("%1-%2-%3-%4%5-%6%7%8%9%10%11")
|
return usprintf("%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
|
||||||
.arg(*(const UINT32*)&guid.Data[0], 8, 16, QChar('0'))
|
*(const UINT32*)&guid.Data[0],
|
||||||
.arg(*(const UINT16*)&guid.Data[4], 4, 16, QChar('0'))
|
*(const UINT16*)&guid.Data[4],
|
||||||
.arg(*(const UINT16*)&guid.Data[6], 4, 16, QChar('0'))
|
*(const UINT16*)&guid.Data[6],
|
||||||
.arg(guid.Data[8], 2, 16, QChar('0'))
|
guid.Data[8],
|
||||||
.arg(guid.Data[9], 2, 16, QChar('0'))
|
guid.Data[9],
|
||||||
.arg(guid.Data[10], 2, 16, QChar('0'))
|
guid.Data[10],
|
||||||
.arg(guid.Data[11], 2, 16, QChar('0'))
|
guid.Data[11],
|
||||||
.arg(guid.Data[12], 2, 16, QChar('0'))
|
guid.Data[12],
|
||||||
.arg(guid.Data[13], 2, 16, QChar('0'))
|
guid.Data[13],
|
||||||
.arg(guid.Data[14], 2, 16, QChar('0'))
|
guid.Data[14],
|
||||||
.arg(guid.Data[15], 2, 16, QChar('0')).toUpper();
|
guid.Data[15]);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString fileTypeToQString(const UINT8 type)
|
UString fileTypeToUString(const UINT8 type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case EFI_FV_FILETYPE_RAW: return QObject::tr("Raw");
|
case EFI_FV_FILETYPE_RAW: return UString("Raw");
|
||||||
case EFI_FV_FILETYPE_FREEFORM: return QObject::tr("Freeform");
|
case EFI_FV_FILETYPE_FREEFORM: return UString("Freeform");
|
||||||
case EFI_FV_FILETYPE_SECURITY_CORE: return QObject::tr("SEC core");
|
case EFI_FV_FILETYPE_SECURITY_CORE: return UString("SEC core");
|
||||||
case EFI_FV_FILETYPE_PEI_CORE: return QObject::tr("PEI core");
|
case EFI_FV_FILETYPE_PEI_CORE: return UString("PEI core");
|
||||||
case EFI_FV_FILETYPE_DXE_CORE: return QObject::tr("DXE core");
|
case EFI_FV_FILETYPE_DXE_CORE: return UString("DXE core");
|
||||||
case EFI_FV_FILETYPE_PEIM: return QObject::tr("PEI module");
|
case EFI_FV_FILETYPE_PEIM: return UString("PEI module");
|
||||||
case EFI_FV_FILETYPE_DRIVER: return QObject::tr("DXE driver");
|
case EFI_FV_FILETYPE_DRIVER: return UString("DXE driver");
|
||||||
case EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER: return QObject::tr("Combined PEI/DXE");
|
case EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER: return UString("Combined PEI/DXE");
|
||||||
case EFI_FV_FILETYPE_APPLICATION: return QObject::tr("Application");
|
case EFI_FV_FILETYPE_APPLICATION: return UString("Application");
|
||||||
case EFI_FV_FILETYPE_SMM: return QObject::tr("SMM module");
|
case EFI_FV_FILETYPE_SMM: return UString("SMM module");
|
||||||
case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE: return QObject::tr("Volume image");
|
case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE: return UString("Volume image");
|
||||||
case EFI_FV_FILETYPE_COMBINED_SMM_DXE: return QObject::tr("Combined SMM/DXE");
|
case EFI_FV_FILETYPE_COMBINED_SMM_DXE: return UString("Combined SMM/DXE");
|
||||||
case EFI_FV_FILETYPE_SMM_CORE: return QObject::tr("SMM core");
|
case EFI_FV_FILETYPE_SMM_CORE: return UString("SMM core");
|
||||||
case EFI_FV_FILETYPE_PAD: return QObject::tr("Pad");
|
case EFI_FV_FILETYPE_PAD: return UString("Pad");
|
||||||
default: return QObject::tr("Unknown");
|
default: return UString("Unknown");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
QString sectionTypeToQString(const UINT8 type)
|
UString sectionTypeToUString(const UINT8 type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case EFI_SECTION_COMPRESSION: return QObject::tr("Compressed");
|
case EFI_SECTION_COMPRESSION: return UString("Compressed");
|
||||||
case EFI_SECTION_GUID_DEFINED: return QObject::tr("GUID defined");
|
case EFI_SECTION_GUID_DEFINED: return UString("GUID defined");
|
||||||
case EFI_SECTION_DISPOSABLE: return QObject::tr("Disposable");
|
case EFI_SECTION_DISPOSABLE: return UString("Disposable");
|
||||||
case EFI_SECTION_PE32: return QObject::tr("PE32 image");
|
case EFI_SECTION_PE32: return UString("PE32 image");
|
||||||
case EFI_SECTION_PIC: return QObject::tr("PIC image");
|
case EFI_SECTION_PIC: return UString("PIC image");
|
||||||
case EFI_SECTION_TE: return QObject::tr("TE image");
|
case EFI_SECTION_TE: return UString("TE image");
|
||||||
case EFI_SECTION_DXE_DEPEX: return QObject::tr("DXE dependency");
|
case EFI_SECTION_DXE_DEPEX: return UString("DXE dependency");
|
||||||
case EFI_SECTION_VERSION: return QObject::tr("Version");
|
case EFI_SECTION_VERSION: return UString("Version");
|
||||||
case EFI_SECTION_USER_INTERFACE: return QObject::tr("UI");
|
case EFI_SECTION_USER_INTERFACE: return UString("UI");
|
||||||
case EFI_SECTION_COMPATIBILITY16: return QObject::tr("16-bit image");
|
case EFI_SECTION_COMPATIBILITY16: return UString("16-bit image");
|
||||||
case EFI_SECTION_FIRMWARE_VOLUME_IMAGE: return QObject::tr("Volume image");
|
case EFI_SECTION_FIRMWARE_VOLUME_IMAGE: return UString("Volume image");
|
||||||
case EFI_SECTION_FREEFORM_SUBTYPE_GUID: return QObject::tr("Freeform subtype GUID");
|
case EFI_SECTION_FREEFORM_SUBTYPE_GUID: return UString("Freeform subtype GUID");
|
||||||
case EFI_SECTION_RAW: return QObject::tr("Raw");
|
case EFI_SECTION_RAW: return UString("Raw");
|
||||||
case EFI_SECTION_PEI_DEPEX: return QObject::tr("PEI dependency");
|
case EFI_SECTION_PEI_DEPEX: return UString("PEI dependency");
|
||||||
case EFI_SECTION_SMM_DEPEX: return QObject::tr("SMM dependency");
|
case EFI_SECTION_SMM_DEPEX: return UString("SMM dependency");
|
||||||
case INSYDE_SECTION_POSTCODE: return QObject::tr("Insyde postcode");
|
case INSYDE_SECTION_POSTCODE: return UString("Insyde postcode");
|
||||||
case PHOENIX_SECTION_POSTCODE: return QObject::tr("Phoenix postcode");
|
case PHOENIX_SECTION_POSTCODE: return UString("Phoenix postcode");
|
||||||
default: return QObject::tr("Unknown");
|
default: return UString("Unknown");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
64
common/ffs.h
64
common/ffs.h
@ -15,16 +15,16 @@ WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <QByteArray>
|
#include "ubytearray.h"
|
||||||
#include <QString>
|
#include "ustring.h"
|
||||||
#include "basetypes.h"
|
#include "basetypes.h"
|
||||||
|
|
||||||
// Make sure we use right packing rules
|
// Make sure we use right packing rules
|
||||||
#pragma pack(push,1)
|
#pragma pack(push,1)
|
||||||
|
|
||||||
extern QString guidToQString(const EFI_GUID& guid);
|
extern UString guidToUString(const EFI_GUID& guid);
|
||||||
extern QString fileTypeToQString(const UINT8 type);
|
extern UString fileTypeToUString(const UINT8 type);
|
||||||
extern QString sectionTypeToQString(const UINT8 type);
|
extern UString sectionTypeToUString(const UINT8 type);
|
||||||
|
|
||||||
//*****************************************************************************
|
//*****************************************************************************
|
||||||
// EFI Capsule
|
// EFI Capsule
|
||||||
@ -43,19 +43,19 @@ typedef struct EFI_CAPSULE_HEADER_ {
|
|||||||
#define EFI_CAPSULE_HEADER_FLAG_POPULATE_SYSTEM_TABLE 0x00020000
|
#define EFI_CAPSULE_HEADER_FLAG_POPULATE_SYSTEM_TABLE 0x00020000
|
||||||
|
|
||||||
// Standard EFI capsule GUID
|
// Standard EFI capsule GUID
|
||||||
const QByteArray EFI_CAPSULE_GUID
|
const UByteArray EFI_CAPSULE_GUID
|
||||||
("\xBD\x86\x66\x3B\x76\x0D\x30\x40\xB7\x0E\xB5\x51\x9E\x2F\xC5\xA0", 16);
|
("\xBD\x86\x66\x3B\x76\x0D\x30\x40\xB7\x0E\xB5\x51\x9E\x2F\xC5\xA0", 16);
|
||||||
|
|
||||||
// Intel capsule GUID
|
// Intel capsule GUID
|
||||||
const QByteArray INTEL_CAPSULE_GUID
|
const UByteArray INTEL_CAPSULE_GUID
|
||||||
("\xB9\x82\x91\x53\xB5\xAB\x91\x43\xB6\x9A\xE3\xA9\x43\xF7\x2F\xCC", 16);
|
("\xB9\x82\x91\x53\xB5\xAB\x91\x43\xB6\x9A\xE3\xA9\x43\xF7\x2F\xCC", 16);
|
||||||
|
|
||||||
// Lenovo capsule GUID
|
// Lenovo capsule GUID
|
||||||
const QByteArray LENOVO_CAPSULE_GUID
|
const UByteArray LENOVO_CAPSULE_GUID
|
||||||
("\xD3\xAF\x0B\xE2\x14\x99\x4F\x4F\x95\x37\x31\x29\xE0\x90\xEB\x3C", 16);
|
("\xD3\xAF\x0B\xE2\x14\x99\x4F\x4F\x95\x37\x31\x29\xE0\x90\xEB\x3C", 16);
|
||||||
|
|
||||||
// Another Lenovo capsule GUID
|
// Another Lenovo capsule GUID
|
||||||
const QByteArray LENOVO2_CAPSULE_GUID
|
const UByteArray LENOVO2_CAPSULE_GUID
|
||||||
("\x76\xFE\xB5\x25\x43\x82\x5C\x4A\xA9\xBD\x7E\xE3\x24\x61\x98\xB5", 16);
|
("\x76\xFE\xB5\x25\x43\x82\x5C\x4A\xA9\xBD\x7E\xE3\x24\x61\x98\xB5", 16);
|
||||||
|
|
||||||
// Toshiba EFI Capsule header
|
// Toshiba EFI Capsule header
|
||||||
@ -67,7 +67,7 @@ typedef struct TOSHIBA_CAPSULE_HEADER_ {
|
|||||||
} TOSHIBA_CAPSULE_HEADER;
|
} TOSHIBA_CAPSULE_HEADER;
|
||||||
|
|
||||||
// Toshiba capsule GUID
|
// Toshiba capsule GUID
|
||||||
const QByteArray TOSHIBA_CAPSULE_GUID
|
const UByteArray TOSHIBA_CAPSULE_GUID
|
||||||
("\x62\x70\xE0\x3B\x51\x1D\xD2\x45\x83\x2B\xF0\x93\x25\x7E\xD4\x61", 16);
|
("\x62\x70\xE0\x3B\x51\x1D\xD2\x45\x83\x2B\xF0\x93\x25\x7E\xD4\x61", 16);
|
||||||
|
|
||||||
// AMI Aptio extended capsule header
|
// AMI Aptio extended capsule header
|
||||||
@ -80,11 +80,11 @@ typedef struct APTIO_CAPSULE_HEADER_ {
|
|||||||
} APTIO_CAPSULE_HEADER;
|
} APTIO_CAPSULE_HEADER;
|
||||||
|
|
||||||
// AMI Aptio signed extended capsule GUID
|
// AMI Aptio signed extended capsule GUID
|
||||||
const QByteArray APTIO_SIGNED_CAPSULE_GUID
|
const UByteArray APTIO_SIGNED_CAPSULE_GUID
|
||||||
("\x8B\xA6\x3C\x4A\x23\x77\xFB\x48\x80\x3D\x57\x8C\xC1\xFE\xC4\x4D", 16);
|
("\x8B\xA6\x3C\x4A\x23\x77\xFB\x48\x80\x3D\x57\x8C\xC1\xFE\xC4\x4D", 16);
|
||||||
|
|
||||||
// AMI Aptio unsigned extended capsule GUID
|
// AMI Aptio unsigned extended capsule GUID
|
||||||
const QByteArray APTIO_UNSIGNED_CAPSULE_GUID
|
const UByteArray APTIO_UNSIGNED_CAPSULE_GUID
|
||||||
("\x90\xBB\xEE\x14\x0A\x89\xDB\x43\xAE\xD1\x5D\x3C\x45\x88\xA4\x18", 16);
|
("\x90\xBB\xEE\x14\x0A\x89\xDB\x43\xAE\xD1\x5D\x3C\x45\x88\xA4\x18", 16);
|
||||||
|
|
||||||
//*****************************************************************************
|
//*****************************************************************************
|
||||||
@ -113,38 +113,38 @@ typedef struct EFI_FIRMWARE_VOLUME_HEADER_ {
|
|||||||
} EFI_FIRMWARE_VOLUME_HEADER;
|
} EFI_FIRMWARE_VOLUME_HEADER;
|
||||||
|
|
||||||
// Standard file system GUIDs
|
// Standard file system GUIDs
|
||||||
const QByteArray EFI_FIRMWARE_FILE_SYSTEM_GUID
|
const UByteArray EFI_FIRMWARE_FILE_SYSTEM_GUID
|
||||||
("\xD9\x54\x93\x7A\x68\x04\x4A\x44\x81\xCE\x0B\xF6\x17\xD8\x90\xDF", 16);
|
("\xD9\x54\x93\x7A\x68\x04\x4A\x44\x81\xCE\x0B\xF6\x17\xD8\x90\xDF", 16);
|
||||||
const QByteArray EFI_FIRMWARE_FILE_SYSTEM2_GUID
|
const UByteArray EFI_FIRMWARE_FILE_SYSTEM2_GUID
|
||||||
("\x78\xE5\x8C\x8C\x3D\x8A\x1C\x4F\x99\x35\x89\x61\x85\xC3\x2D\xD3", 16);
|
("\x78\xE5\x8C\x8C\x3D\x8A\x1C\x4F\x99\x35\x89\x61\x85\xC3\x2D\xD3", 16);
|
||||||
// Vendor-specific file system GUIDs
|
// Vendor-specific file system GUIDs
|
||||||
const QByteArray EFI_APPLE_BOOT_VOLUME_FILE_SYSTEM_GUID
|
const UByteArray EFI_APPLE_BOOT_VOLUME_FILE_SYSTEM_GUID
|
||||||
("\xAD\xEE\xAD\x04\xFF\x61\x31\x4D\xB6\xBA\x64\xF8\xBF\x90\x1F\x5A", 16);
|
("\xAD\xEE\xAD\x04\xFF\x61\x31\x4D\xB6\xBA\x64\xF8\xBF\x90\x1F\x5A", 16);
|
||||||
const QByteArray EFI_APPLE_BOOT_VOLUME_FILE_SYSTEM2_GUID
|
const UByteArray EFI_APPLE_BOOT_VOLUME_FILE_SYSTEM2_GUID
|
||||||
("\x8C\x1B\x00\xBD\x71\x6A\x7B\x48\xA1\x4F\x0C\x2A\x2D\xCF\x7A\x5D", 16);
|
("\x8C\x1B\x00\xBD\x71\x6A\x7B\x48\xA1\x4F\x0C\x2A\x2D\xCF\x7A\x5D", 16);
|
||||||
|
|
||||||
// AD3FFFFF-D28B-44C4-9F13-9EA98A97F9F0 // Intel 1
|
// AD3FFFFF-D28B-44C4-9F13-9EA98A97F9F0 // Intel 1
|
||||||
const QByteArray EFI_INTEL_FILE_SYSTEM_GUID
|
const UByteArray EFI_INTEL_FILE_SYSTEM_GUID
|
||||||
("\xFF\xFF\x3F\xAD\x8B\xD2\xC4\x44\x9F\x13\x9E\xA9\x8A\x97\xF9\xF0", 16);
|
("\xFF\xFF\x3F\xAD\x8B\xD2\xC4\x44\x9F\x13\x9E\xA9\x8A\x97\xF9\xF0", 16);
|
||||||
// D6A1CD70-4B33-4994-A6EA-375F2CCC5437 // Intel 2
|
// D6A1CD70-4B33-4994-A6EA-375F2CCC5437 // Intel 2
|
||||||
const QByteArray EFI_INTEL_FILE_SYSTEM2_GUID
|
const UByteArray EFI_INTEL_FILE_SYSTEM2_GUID
|
||||||
("\x70\xCD\xA1\xD6\x33\x4B\x94\x49\xA6\xEA\x37\x5F\x2C\xCC\x54\x37", 16);
|
("\x70\xCD\xA1\xD6\x33\x4B\x94\x49\xA6\xEA\x37\x5F\x2C\xCC\x54\x37", 16);
|
||||||
// 4F494156-AED6-4D64-A537-B8A5557BCEEC // Sony 1
|
// 4F494156-AED6-4D64-A537-B8A5557BCEEC // Sony 1
|
||||||
const QByteArray EFI_SONY_FILE_SYSTEM_GUID
|
const UByteArray EFI_SONY_FILE_SYSTEM_GUID
|
||||||
("\x56\x41\x49\x4F\xD6\xAE\x64\x4D\xA5\x37\xB8\xA5\x55\x7B\xCE\xEC", 16);
|
("\x56\x41\x49\x4F\xD6\xAE\x64\x4D\xA5\x37\xB8\xA5\x55\x7B\xCE\xEC", 16);
|
||||||
|
|
||||||
|
|
||||||
// Vector of volume GUIDs with FFSv2-compatible files
|
// Vector of volume GUIDs with FFSv2-compatible files
|
||||||
extern const std::vector<QByteArray> FFSv2Volumes;
|
extern const std::vector<UByteArray> FFSv2Volumes;
|
||||||
|
|
||||||
const QByteArray EFI_FIRMWARE_FILE_SYSTEM3_GUID // 5473C07A-3DCB-4DCA-BD6F-1E9689E7349A
|
const UByteArray EFI_FIRMWARE_FILE_SYSTEM3_GUID // 5473C07A-3DCB-4DCA-BD6F-1E9689E7349A
|
||||||
("\x7A\xC0\x73\x54\xCB\x3D\xCA\x4D\xBD\x6F\x1E\x96\x89\xE7\x34\x9A", 16);
|
("\x7A\xC0\x73\x54\xCB\x3D\xCA\x4D\xBD\x6F\x1E\x96\x89\xE7\x34\x9A", 16);
|
||||||
|
|
||||||
// Vector of volume GUIDs with FFSv3-compatible files
|
// Vector of volume GUIDs with FFSv3-compatible files
|
||||||
extern const std::vector<QByteArray> FFSv3Volumes;
|
extern const std::vector<UByteArray> FFSv3Volumes;
|
||||||
|
|
||||||
// Firmware volume signature
|
// Firmware volume signature
|
||||||
const QByteArray EFI_FV_SIGNATURE("_FVH", 4);
|
const UByteArray EFI_FV_SIGNATURE("_FVH", 4);
|
||||||
#define EFI_FV_SIGNATURE_OFFSET 0x28
|
#define EFI_FV_SIGNATURE_OFFSET 0x28
|
||||||
|
|
||||||
// Firmware volume attributes
|
// Firmware volume attributes
|
||||||
@ -338,19 +338,19 @@ extern const UINT8 ffsAlignmentTable[];
|
|||||||
#define EFI_FILE_HEADER_INVALID 0x20
|
#define EFI_FILE_HEADER_INVALID 0x20
|
||||||
|
|
||||||
// PEI apriori file
|
// PEI apriori file
|
||||||
const QByteArray EFI_PEI_APRIORI_FILE_GUID
|
const UByteArray EFI_PEI_APRIORI_FILE_GUID
|
||||||
("\x0A\xCC\x45\x1B\x6A\x15\x8A\x42\xAF\x62\x49\x86\x4D\xA0\xE6\xE6", 16);
|
("\x0A\xCC\x45\x1B\x6A\x15\x8A\x42\xAF\x62\x49\x86\x4D\xA0\xE6\xE6", 16);
|
||||||
|
|
||||||
// DXE apriori file
|
// DXE apriori file
|
||||||
const QByteArray EFI_DXE_APRIORI_FILE_GUID
|
const UByteArray EFI_DXE_APRIORI_FILE_GUID
|
||||||
("\xE7\x0E\x51\xFC\xDC\xFF\xD4\x11\xBD\x41\x00\x80\xC7\x3C\x88\x81", 16);
|
("\xE7\x0E\x51\xFC\xDC\xFF\xD4\x11\xBD\x41\x00\x80\xC7\x3C\x88\x81", 16);
|
||||||
|
|
||||||
// Volume top file
|
// Volume top file
|
||||||
const QByteArray EFI_FFS_VOLUME_TOP_FILE_GUID
|
const UByteArray EFI_FFS_VOLUME_TOP_FILE_GUID
|
||||||
("\x2E\x06\xA0\x1B\x79\xC7\x82\x45\x85\x66\x33\x6A\xE8\xF7\x8F\x09", 16);
|
("\x2E\x06\xA0\x1B\x79\xC7\x82\x45\x85\x66\x33\x6A\xE8\xF7\x8F\x09", 16);
|
||||||
|
|
||||||
// Pad file GUID
|
// Pad file GUID
|
||||||
const QByteArray EFI_FFS_PAD_FILE_GUID
|
const UByteArray EFI_FFS_PAD_FILE_GUID
|
||||||
("\x85\x65\x53\xE4\x09\x79\x60\x4A\xB5\xC6\xEC\xDE\xA6\xEB\xFB\x54", 16);
|
("\x85\x65\x53\xE4\x09\x79\x60\x4A\xB5\xC6\xEC\xDE\xA6\xEB\xFB\x54", 16);
|
||||||
|
|
||||||
// FFS size conversion routines
|
// FFS size conversion routines
|
||||||
@ -445,16 +445,16 @@ typedef struct EFI_GUID_DEFINED_SECTION_APPLE_ {
|
|||||||
#define EFI_GUIDED_SECTION_AUTH_STATUS_VALID 0x02
|
#define EFI_GUIDED_SECTION_AUTH_STATUS_VALID 0x02
|
||||||
|
|
||||||
// GUIDs of GUID-defined sections
|
// GUIDs of GUID-defined sections
|
||||||
const QByteArray EFI_GUIDED_SECTION_CRC32 // FC1BCDB0-7D31-49AA-936A-A4600D9DD083
|
const UByteArray EFI_GUIDED_SECTION_CRC32 // FC1BCDB0-7D31-49AA-936A-A4600D9DD083
|
||||||
("\xB0\xCD\x1B\xFC\x31\x7D\xAA\x49\x93\x6A\xA4\x60\x0D\x9D\xD0\x83", 16);
|
("\xB0\xCD\x1B\xFC\x31\x7D\xAA\x49\x93\x6A\xA4\x60\x0D\x9D\xD0\x83", 16);
|
||||||
|
|
||||||
const QByteArray EFI_GUIDED_SECTION_TIANO // A31280AD-481E-41B6-95E8-127F4C984779
|
const UByteArray EFI_GUIDED_SECTION_TIANO // A31280AD-481E-41B6-95E8-127F4C984779
|
||||||
("\xAD\x80\x12\xA3\x1E\x48\xB6\x41\x95\xE8\x12\x7F\x4C\x98\x47\x79", 16);
|
("\xAD\x80\x12\xA3\x1E\x48\xB6\x41\x95\xE8\x12\x7F\x4C\x98\x47\x79", 16);
|
||||||
|
|
||||||
const QByteArray EFI_GUIDED_SECTION_LZMA // EE4E5898-3914-4259-9D6E-DC7BD79403CF
|
const UByteArray EFI_GUIDED_SECTION_LZMA // EE4E5898-3914-4259-9D6E-DC7BD79403CF
|
||||||
("\x98\x58\x4E\xEE\x14\x39\x59\x42\x9D\x6E\xDC\x7B\xD7\x94\x03\xCF", 16);
|
("\x98\x58\x4E\xEE\x14\x39\x59\x42\x9D\x6E\xDC\x7B\xD7\x94\x03\xCF", 16);
|
||||||
|
|
||||||
const QByteArray EFI_FIRMWARE_CONTENTS_SIGNED_GUID // 0F9D89E8-9259-4F76-A5AF-0C89E34023DF
|
const UByteArray EFI_FIRMWARE_CONTENTS_SIGNED_GUID // 0F9D89E8-9259-4F76-A5AF-0C89E34023DF
|
||||||
("\xE8\x89\x9D\x0F\x59\x92\x76\x4F\xA5\xAF\x0C\x89\xE3\x40\x23\xDF", 16);
|
("\xE8\x89\x9D\x0F\x59\x92\x76\x4F\xA5\xAF\x0C\x89\xE3\x40\x23\xDF", 16);
|
||||||
|
|
||||||
//#define WIN_CERT_TYPE_PKCS_SIGNED_DATA 0x0002
|
//#define WIN_CERT_TYPE_PKCS_SIGNED_DATA 0x0002
|
||||||
@ -474,7 +474,7 @@ typedef struct WIN_CERTIFICATE_UEFI_GUID_ {
|
|||||||
} WIN_CERTIFICATE_UEFI_GUID;
|
} WIN_CERTIFICATE_UEFI_GUID;
|
||||||
|
|
||||||
// WIN_CERTIFICATE_UEFI_GUID.CertType
|
// WIN_CERTIFICATE_UEFI_GUID.CertType
|
||||||
const QByteArray EFI_CERT_TYPE_RSA2048_SHA256_GUID
|
const UByteArray EFI_CERT_TYPE_RSA2048_SHA256_GUID
|
||||||
("\x14\x74\x71\xA7\x16\xC6\x77\x49\x94\x20\x84\x47\x12\xA7\x35\xBF");
|
("\x14\x74\x71\xA7\x16\xC6\x77\x49\x94\x20\x84\x47\x12\xA7\x35\xBF");
|
||||||
|
|
||||||
// WIN_CERTIFICATE_UEFI_GUID.CertData
|
// WIN_CERTIFICATE_UEFI_GUID.CertData
|
||||||
|
2484
common/ffsparser.cpp
2484
common/ffsparser.cpp
File diff suppressed because it is too large
Load Diff
@ -15,10 +15,9 @@ WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <QObject>
|
#include "ustring.h"
|
||||||
#include <QModelIndex>
|
#include "ubytearray.h"
|
||||||
#include <QByteArray>
|
#include "umodelindex.h"
|
||||||
|
|
||||||
#include "basetypes.h"
|
#include "basetypes.h"
|
||||||
#include "treemodel.h"
|
#include "treemodel.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
@ -43,95 +42,95 @@ public:
|
|||||||
~FfsParser() {}
|
~FfsParser() {}
|
||||||
|
|
||||||
// Returns messages
|
// Returns messages
|
||||||
std::vector<std::pair<QString, QModelIndex> > getMessages() const { return messagesVector; }
|
std::vector<std::pair<UString, UModelIndex> > getMessages() const { return messagesVector; }
|
||||||
// Clears messages
|
// Clears messages
|
||||||
void clearMessages() { messagesVector.clear(); }
|
void clearMessages() { messagesVector.clear(); }
|
||||||
|
|
||||||
// Firmware image parsing
|
// Firmware image parsing
|
||||||
STATUS parse(const QByteArray &buffer);
|
USTATUS parse(const UByteArray &buffer);
|
||||||
|
|
||||||
// Retuns index of the last VTF after parsing is done
|
// Retuns index of the last VTF after parsing is done
|
||||||
const QModelIndex getLastVtf() {return lastVtf;};
|
const UModelIndex getLastVtf() {return lastVtf;};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TreeModel *model;
|
TreeModel *model;
|
||||||
std::vector<std::pair<QString, QModelIndex> > messagesVector;
|
std::vector<std::pair<UString, UModelIndex> > messagesVector;
|
||||||
void msg(const QString & message, const QModelIndex &index = QModelIndex()) {
|
void msg(const UString message, const UModelIndex index = UModelIndex()) {
|
||||||
messagesVector.push_back(std::pair<QString, QModelIndex>(message, index));
|
messagesVector.push_back(std::pair<UString, UModelIndex>(message, index));
|
||||||
};
|
};
|
||||||
|
|
||||||
QModelIndex lastVtf;
|
UModelIndex lastVtf;
|
||||||
UINT32 capsuleOffsetFixup;
|
UINT32 capsuleOffsetFixup;
|
||||||
|
|
||||||
STATUS parseRawArea(const QModelIndex & index);
|
USTATUS parseRawArea(const UModelIndex & index);
|
||||||
STATUS parseVolumeHeader(const QByteArray & volume, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index);
|
USTATUS parseVolumeHeader(const UByteArray & volume, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
|
||||||
STATUS parseVolumeBody(const QModelIndex & index);
|
USTATUS parseVolumeBody(const UModelIndex & index);
|
||||||
STATUS parseFileHeader(const QByteArray & file, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index);
|
USTATUS parseFileHeader(const UByteArray & file, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
|
||||||
STATUS parseFileBody(const QModelIndex & index);
|
USTATUS parseFileBody(const UModelIndex & index);
|
||||||
STATUS parseSectionHeader(const QByteArray & section, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index, const bool preparse = false);
|
USTATUS parseSectionHeader(const UByteArray & section, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index, const bool preparse = false);
|
||||||
STATUS parseSectionBody(const QModelIndex & index);
|
USTATUS parseSectionBody(const UModelIndex & index);
|
||||||
|
|
||||||
STATUS parseIntelImage(const QByteArray & intelImage, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & root);
|
USTATUS parseIntelImage(const UByteArray & intelImage, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & root);
|
||||||
STATUS parseGbeRegion(const QByteArray & gbe, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index);
|
USTATUS parseGbeRegion(const UByteArray & gbe, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
|
||||||
STATUS parseMeRegion(const QByteArray & me, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index);
|
USTATUS parseMeRegion(const UByteArray & me, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
|
||||||
STATUS parseBiosRegion(const QByteArray & bios, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index);
|
USTATUS parseBiosRegion(const UByteArray & bios, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
|
||||||
STATUS parsePdrRegion(const QByteArray & pdr, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index);
|
USTATUS parsePdrRegion(const UByteArray & pdr, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
|
||||||
STATUS parseGeneralRegion(const UINT8 subtype, const QByteArray & region, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index);
|
USTATUS parseGeneralRegion(const UINT8 subtype, const UByteArray & region, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
|
||||||
|
|
||||||
STATUS parsePadFileBody(const QModelIndex & index);
|
USTATUS parsePadFileBody(const UModelIndex & index);
|
||||||
STATUS parseVolumeNonUefiData(const QByteArray & data, const UINT32 parentOffset, const QModelIndex & index);
|
USTATUS parseVolumeNonUefiData(const UByteArray & data, const UINT32 parentOffset, const UModelIndex & index);
|
||||||
|
|
||||||
STATUS parseSections(const QByteArray & sections, const QModelIndex & index, const bool preparse = false);
|
USTATUS parseSections(const UByteArray & sections, const UModelIndex & index, const bool preparse = false);
|
||||||
STATUS parseCommonSectionHeader(const QByteArray & section, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index, const bool preparse);
|
USTATUS parseCommonSectionHeader(const UByteArray & section, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index, const bool preparse);
|
||||||
STATUS parseCompressedSectionHeader(const QByteArray & section, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index, const bool preparse);
|
USTATUS parseCompressedSectionHeader(const UByteArray & section, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index, const bool preparse);
|
||||||
STATUS parseGuidedSectionHeader(const QByteArray & section, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index, const bool preparse);
|
USTATUS parseGuidedSectionHeader(const UByteArray & section, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index, const bool preparse);
|
||||||
STATUS parseFreeformGuidedSectionHeader(const QByteArray & section, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index, const bool preparse);
|
USTATUS parseFreeformGuidedSectionHeader(const UByteArray & section, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index, const bool preparse);
|
||||||
STATUS parseVersionSectionHeader(const QByteArray & section, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index, const bool preparse);
|
USTATUS parseVersionSectionHeader(const UByteArray & section, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index, const bool preparse);
|
||||||
STATUS parsePostcodeSectionHeader(const QByteArray & section, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index, const bool preparse);
|
USTATUS parsePostcodeSectionHeader(const UByteArray & section, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index, const bool preparse);
|
||||||
|
|
||||||
STATUS parseCompressedSectionBody(const QModelIndex & index);
|
USTATUS parseCompressedSectionBody(const UModelIndex & index);
|
||||||
STATUS parseGuidedSectionBody(const QModelIndex & index);
|
USTATUS parseGuidedSectionBody(const UModelIndex & index);
|
||||||
STATUS parseVersionSectionBody(const QModelIndex & index);
|
USTATUS parseVersionSectionBody(const UModelIndex & index);
|
||||||
STATUS parseDepexSectionBody(const QModelIndex & index);
|
USTATUS parseDepexSectionBody(const UModelIndex & index);
|
||||||
STATUS parseUiSectionBody(const QModelIndex & index);
|
USTATUS parseUiSectionBody(const UModelIndex & index);
|
||||||
STATUS parseRawSectionBody(const QModelIndex & index);
|
USTATUS parseRawSectionBody(const UModelIndex & index);
|
||||||
STATUS parsePeImageSectionBody(const QModelIndex & index);
|
USTATUS parsePeImageSectionBody(const UModelIndex & index);
|
||||||
STATUS parseTeImageSectionBody(const QModelIndex & index);
|
USTATUS parseTeImageSectionBody(const UModelIndex & index);
|
||||||
|
|
||||||
UINT8 getPaddingType(const QByteArray & padding);
|
UINT8 getPaddingType(const UByteArray & padding);
|
||||||
STATUS parseAprioriRawSection(const QByteArray & body, QString & parsed);
|
USTATUS parseAprioriRawSection(const UByteArray & body, UString & parsed);
|
||||||
STATUS findNextVolume(const QModelIndex & index, const QByteArray & bios, const UINT32 parentOffset, const UINT32 volumeOffset, UINT32 & nextVolumeOffset);
|
USTATUS findNextVolume(const UModelIndex & index, const UByteArray & bios, const UINT32 parentOffset, const UINT32 volumeOffset, UINT32 & nextVolumeOffset);
|
||||||
STATUS getVolumeSize(const QByteArray & bios, const UINT32 volumeOffset, UINT32 & volumeSize, UINT32 & bmVolumeSize);
|
USTATUS getVolumeSize(const UByteArray & bios, const UINT32 volumeOffset, UINT32 & volumeSize, UINT32 & bmVolumeSize);
|
||||||
UINT32 getFileSize(const QByteArray & volume, const UINT32 fileOffset, const UINT8 ffsVersion);
|
UINT32 getFileSize(const UByteArray & volume, const UINT32 fileOffset, const UINT8 ffsVersion);
|
||||||
UINT32 getSectionSize(const QByteArray & file, const UINT32 sectionOffset, const UINT8 ffsVersion);
|
UINT32 getSectionSize(const UByteArray & file, const UINT32 sectionOffset, const UINT8 ffsVersion);
|
||||||
|
|
||||||
STATUS performFirstPass(const QByteArray & imageFile, QModelIndex & index);
|
USTATUS performFirstPass(const UByteArray & imageFile, UModelIndex & index);
|
||||||
STATUS performSecondPass(const QModelIndex & index);
|
USTATUS performSecondPass(const UModelIndex & index);
|
||||||
STATUS addOffsetsRecursive(const QModelIndex & index);
|
USTATUS addOffsetsRecursive(const UModelIndex & index);
|
||||||
STATUS addMemoryAddressesRecursive(const QModelIndex & index, const UINT32 diff);
|
USTATUS addMemoryAddressesRecursive(const UModelIndex & index, const UINT32 diff);
|
||||||
|
|
||||||
// NVRAM parsing
|
// NVRAM parsing
|
||||||
STATUS parseNvramVolumeBody(const QModelIndex & index);
|
USTATUS parseNvramVolumeBody(const UModelIndex & index);
|
||||||
STATUS findNextStore(const QModelIndex & index, const QByteArray & volume, const UINT32 parentOffset, const UINT32 storeOffset, UINT32 & nextStoreOffset);
|
USTATUS findNextStore(const UModelIndex & index, const UByteArray & volume, const UINT32 parentOffset, const UINT32 storeOffset, UINT32 & nextStoreOffset);
|
||||||
STATUS getStoreSize(const QByteArray & data, const UINT32 storeOffset, UINT32 & storeSize);
|
USTATUS getStoreSize(const UByteArray & data, const UINT32 storeOffset, UINT32 & storeSize);
|
||||||
STATUS parseStoreHeader(const QByteArray & store, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index);
|
USTATUS parseStoreHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
|
||||||
|
|
||||||
STATUS parseNvarStore(const QModelIndex & index);
|
USTATUS parseNvarStore(const UModelIndex & index);
|
||||||
STATUS parseVssStoreHeader(const QByteArray & store, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index);
|
USTATUS parseVssStoreHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
|
||||||
STATUS parseFtwStoreHeader(const QByteArray & store, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index);
|
USTATUS parseFtwStoreHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
|
||||||
STATUS parseFdcStoreHeader(const QByteArray & store, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index);
|
USTATUS parseFdcStoreHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
|
||||||
STATUS parseFsysStoreHeader(const QByteArray & store, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index);
|
USTATUS parseFsysStoreHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
|
||||||
STATUS parseEvsaStoreHeader(const QByteArray & store, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index);
|
USTATUS parseEvsaStoreHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
|
||||||
STATUS parseFlashMapStoreHeader(const QByteArray & store, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index);
|
USTATUS parseFlashMapStoreHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
|
||||||
STATUS parseCmdbStoreHeader(const QByteArray & store, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index);
|
USTATUS parseCmdbStoreHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
|
||||||
STATUS parseSlicPubkeyHeader(const QByteArray & store, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index);
|
USTATUS parseSlicPubkeyHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
|
||||||
STATUS parseSlicMarkerHeader(const QByteArray & store, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index);
|
USTATUS parseSlicMarkerHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
|
||||||
STATUS parseIntelMicrocodeHeader(const QByteArray & store, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index);
|
USTATUS parseIntelMicrocodeHeader(const UByteArray & store, const UINT32 parentOffset, const UModelIndex & parent, UModelIndex & index);
|
||||||
|
|
||||||
STATUS parseVssStoreBody(const QModelIndex & index);
|
USTATUS parseVssStoreBody(const UModelIndex & index);
|
||||||
STATUS parseFsysStoreBody(const QModelIndex & index);
|
USTATUS parseFsysStoreBody(const UModelIndex & index);
|
||||||
STATUS parseEvsaStoreBody(const QModelIndex & index);
|
USTATUS parseEvsaStoreBody(const UModelIndex & index);
|
||||||
STATUS parseFlashMapBody(const QModelIndex & index);
|
USTATUS parseFlashMapBody(const UModelIndex & index);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FFSPARSER_H
|
#endif // FFSPARSER_H
|
||||||
|
@ -13,53 +13,49 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
|
|
||||||
#include "ffsreport.h"
|
#include "ffsreport.h"
|
||||||
|
|
||||||
std::vector<QString> FfsReport::generate()
|
std::vector<UString> FfsReport::generate()
|
||||||
{
|
{
|
||||||
std::vector<QString> report;
|
std::vector<UString> report;
|
||||||
|
|
||||||
// Check model pointer
|
// Check model pointer
|
||||||
if (!model) {
|
if (!model) {
|
||||||
report.push_back(QObject::tr("ERROR: Invalid model pointer provided."));
|
report.push_back(UString("ERROR: Invalid model pointer provided"));
|
||||||
return report;
|
return report;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check root index to be valid
|
// Check root index to be valid
|
||||||
QModelIndex root = model->index(0,0);
|
UModelIndex root = model->index(0,0);
|
||||||
if (!root.isValid()) {
|
if (!root.isValid()) {
|
||||||
report.push_back(QObject::tr("ERROR: Model root index is invalid."));
|
report.push_back(UString("ERROR: Model root index is invalid"));
|
||||||
return report;
|
return report;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate report recursive
|
// Generate report recursive
|
||||||
report.push_back(QObject::tr(" Type | Subtype | Size | CRC32 | Name "));
|
report.push_back(UString(" Type | Subtype | Size | CRC32 | Name "));
|
||||||
STATUS result = generateRecursive(report, root);
|
USTATUS result = generateRecursive(report, root);
|
||||||
if (result) {
|
if (result) {
|
||||||
report.push_back(QObject::tr("ERROR: generateRecursive returned %1.")
|
report.push_back(UString("ERROR: generateRecursive returned ") + errorCodeToUString(result));
|
||||||
.arg(errorCodeToQString(result)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return report;
|
return report;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATUS FfsReport::generateRecursive(std::vector<QString> & report, QModelIndex index, UINT32 level)
|
USTATUS FfsReport::generateRecursive(std::vector<UString> & report, UModelIndex index, UINT32 level)
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return ERR_SUCCESS; //Nothing to report for invalid index
|
return U_SUCCESS; //Nothing to report for invalid index
|
||||||
|
|
||||||
// Calculate item CRC32
|
// Calculate item CRC32
|
||||||
QByteArray data = model->header(index) + model->body(index) + model->tail(index);
|
UByteArray data = model->header(index) + model->body(index) + model->tail(index);
|
||||||
UINT32 crc = crc32(0, (const UINT8*)data.constData(), data.size());
|
UINT32 crc = crc32(0, (const UINT8*)data.constData(), data.size());
|
||||||
|
|
||||||
// Information on current item
|
// Information on current item
|
||||||
QString text = model->text(index);
|
UString text = model->text(index);
|
||||||
report.push_back(QObject::tr("%1 | %2 | %3 | %4 | %5 %6 %7")
|
report.push_back(
|
||||||
.arg(itemTypeToQString(model->type(index)), 16, QChar(' '))
|
UString(" ") + itemTypeToUString(model->type(index)).leftJustified(16)
|
||||||
.arg(itemSubtypeToQString(model->type(index), model->subtype(index)), 24, QChar(' '))
|
+ UString("| ") + itemSubtypeToUString(model->type(index), model->subtype(index)).leftJustified(22)
|
||||||
.hexarg2(data.size(), 8)
|
+ usprintf("| %08X | %08X | ", data.size(), crc)
|
||||||
.hexarg2(crc, 8)
|
+ UString(level, '-') + UString(" ") + model->name(index) + (text.isEmpty() ? UString("") : UString(" | ") + text)
|
||||||
.arg(' ', level, QChar('-'))
|
|
||||||
.arg(model->name(index))
|
|
||||||
.arg(text.isEmpty() ? "" : text.prepend("| "))
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Information on child items
|
// Information on child items
|
||||||
@ -67,5 +63,5 @@ STATUS FfsReport::generateRecursive(std::vector<QString> & report, QModelIndex i
|
|||||||
generateRecursive(report, index.child(i,0), level + 1);
|
generateRecursive(report, index.child(i,0), level + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERR_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <QObject>
|
#include "../common/ubytearray.h"
|
||||||
#include <QByteArray>
|
#include "../common/ustring.h"
|
||||||
#include <QString>
|
#include "../common/umodelindex.h"
|
||||||
#include <QModelIndex>
|
|
||||||
|
|
||||||
#include "basetypes.h"
|
#include "basetypes.h"
|
||||||
#include "treemodel.h"
|
#include "treemodel.h"
|
||||||
#include "ffs.h"
|
#include "ffs.h"
|
||||||
@ -33,12 +31,12 @@ public:
|
|||||||
FfsReport(TreeModel * treeModel) : model(treeModel) {}
|
FfsReport(TreeModel * treeModel) : model(treeModel) {}
|
||||||
~FfsReport() {};
|
~FfsReport() {};
|
||||||
|
|
||||||
std::vector<QString> generate();
|
std::vector<UString> generate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TreeModel* model;
|
TreeModel* model;
|
||||||
|
|
||||||
STATUS generateRecursive(std::vector<QString> & report, QModelIndex index, UINT32 level = 0);
|
USTATUS generateRecursive(std::vector<UString> & report, UModelIndex index, UINT32 level = 0);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
*/
|
*/
|
||||||
#include "fitparser.h"
|
#include "fitparser.h"
|
||||||
|
|
||||||
STATUS FitParser::parse(const QModelIndex & index, const QModelIndex & lastVtfIndex)
|
USTATUS FitParser::parse(const UModelIndex & index, const UModelIndex & lastVtfIndex)
|
||||||
{
|
{
|
||||||
// Check sanity
|
// Check sanity
|
||||||
if (!index.isValid() || !lastVtfIndex.isValid())
|
if (!index.isValid() || !lastVtfIndex.isValid())
|
||||||
@ -21,15 +21,15 @@ STATUS FitParser::parse(const QModelIndex & index, const QModelIndex & lastVtfIn
|
|||||||
lastVtf = lastVtfIndex;
|
lastVtf = lastVtfIndex;
|
||||||
|
|
||||||
// Search for FIT
|
// Search for FIT
|
||||||
QModelIndex fitIndex;
|
UModelIndex fitIndex;
|
||||||
UINT32 fitOffset;
|
UINT32 fitOffset;
|
||||||
STATUS result = findFitRecursive(index, fitIndex, fitOffset);
|
USTATUS result = findFitRecursive(index, fitIndex, fitOffset);
|
||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
// FIT not found
|
// FIT not found
|
||||||
if (!fitIndex.isValid())
|
if (!fitIndex.isValid())
|
||||||
return ERR_SUCCESS;
|
return U_SUCCESS;
|
||||||
|
|
||||||
// Explicitly set the item as fixed
|
// Explicitly set the item as fixed
|
||||||
model->setFixed(index, true);
|
model->setFixed(index, true);
|
||||||
@ -41,27 +41,27 @@ STATUS FitParser::parse(const QModelIndex & index, const QModelIndex & lastVtfIn
|
|||||||
UINT32 fitSize = (fitHeader->Size & 0xFFFFFF) << 4;
|
UINT32 fitSize = (fitHeader->Size & 0xFFFFFF) << 4;
|
||||||
if (fitHeader->Type & 0x80) {
|
if (fitHeader->Type & 0x80) {
|
||||||
// Calculate FIT entry checksum
|
// Calculate FIT entry checksum
|
||||||
QByteArray tempFIT = model->body(fitIndex).mid(fitOffset, fitSize);
|
UByteArray tempFIT = model->body(fitIndex).mid(fitOffset, fitSize);
|
||||||
FIT_ENTRY* tempFitHeader = (FIT_ENTRY*)tempFIT.data();
|
FIT_ENTRY* tempFitHeader = (FIT_ENTRY*)tempFIT.data();
|
||||||
tempFitHeader->Checksum = 0;
|
tempFitHeader->Checksum = 0;
|
||||||
UINT8 calculated = calculateChecksum8((const UINT8*)tempFitHeader, fitSize);
|
UINT8 calculated = calculateChecksum8((const UINT8*)tempFitHeader, fitSize);
|
||||||
if (calculated != fitHeader->Checksum) {
|
if (calculated != fitHeader->Checksum) {
|
||||||
msg(QObject::tr("Invalid FIT table checksum %1h, should be %2h").hexarg2(fitHeader->Checksum, 2).hexarg2(calculated, 2), fitIndex);
|
msg(usprintf("Invalid FIT table checksum %02Xh, should be %02Xh", fitHeader->Checksum, calculated), fitIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check fit header type
|
// Check fit header type
|
||||||
if ((fitHeader->Type & 0x7F) != FIT_TYPE_HEADER) {
|
if ((fitHeader->Type & 0x7F) != FIT_TYPE_HEADER) {
|
||||||
msg(QObject::tr("Invalid FIT header type"), fitIndex);
|
msg(("Invalid FIT header type"), fitIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add FIT header to fitTable
|
// Add FIT header to fitTable
|
||||||
std::vector<QString> currentStrings;
|
std::vector<UString> currentStrings;
|
||||||
currentStrings.push_back(QObject::tr("_FIT_ "));
|
currentStrings.push_back(UString("_FIT_ "));
|
||||||
currentStrings.push_back(QObject::tr("%1").hexarg2(fitSize, 8));
|
currentStrings.push_back(usprintf("%08X",fitSize));
|
||||||
currentStrings.push_back(QObject::tr("%1").hexarg2(fitHeader->Version, 4));
|
currentStrings.push_back(usprintf("%04X",fitHeader->Version));
|
||||||
currentStrings.push_back(fitEntryTypeToQString(fitHeader->Type));
|
currentStrings.push_back(fitEntryTypeToUString(fitHeader->Type));
|
||||||
currentStrings.push_back(QObject::tr("%1").hexarg2(fitHeader->Checksum, 2));
|
currentStrings.push_back(usprintf("%02X",fitHeader->Checksum));
|
||||||
fitTable.push_back(currentStrings);
|
fitTable.push_back(currentStrings);
|
||||||
|
|
||||||
// Process all other entries
|
// Process all other entries
|
||||||
@ -73,7 +73,7 @@ STATUS FitParser::parse(const QModelIndex & index, const QModelIndex & lastVtfIn
|
|||||||
// Check entry type
|
// Check entry type
|
||||||
switch (currentEntry->Type & 0x7F) {
|
switch (currentEntry->Type & 0x7F) {
|
||||||
case FIT_TYPE_HEADER:
|
case FIT_TYPE_HEADER:
|
||||||
msg(QObject::tr("Second FIT header found, the table is damaged"), fitIndex);
|
msg(UString("Second FIT header found, the table is damaged"), fitIndex);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FIT_TYPE_EMPTY:
|
case FIT_TYPE_EMPTY:
|
||||||
@ -93,52 +93,52 @@ STATUS FitParser::parse(const QModelIndex & index, const QModelIndex & lastVtfIn
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add entry to fitTable
|
// Add entry to fitTable
|
||||||
currentStrings.push_back(QObject::tr("%1").hexarg2(currentEntry->Address, 16));
|
currentStrings.push_back(usprintf("%016X",currentEntry->Address));
|
||||||
currentStrings.push_back(QObject::tr("%1").hexarg2(currentEntry->Size, 8));
|
currentStrings.push_back(usprintf("%08X", currentEntry->Size));
|
||||||
currentStrings.push_back(QObject::tr("%1").hexarg2(currentEntry->Version, 4));
|
currentStrings.push_back(usprintf("%04X", currentEntry->Version));
|
||||||
currentStrings.push_back(fitEntryTypeToQString(currentEntry->Type));
|
currentStrings.push_back(fitEntryTypeToUString(currentEntry->Type));
|
||||||
currentStrings.push_back(QObject::tr("%1").hexarg2(currentEntry->Checksum, 2));
|
currentStrings.push_back(usprintf("%02X", currentEntry->Checksum));
|
||||||
fitTable.push_back(currentStrings);
|
fitTable.push_back(currentStrings);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msgModifiedImageMayNotWork)
|
if (msgModifiedImageMayNotWork)
|
||||||
msg(QObject::tr("Opened image may not work after any modification"));
|
msg(("Opened image may not work after any modification"));
|
||||||
|
|
||||||
return ERR_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString FitParser::fitEntryTypeToQString(UINT8 type)
|
UString FitParser::fitEntryTypeToUString(UINT8 type)
|
||||||
{
|
{
|
||||||
switch (type & 0x7F) {
|
switch (type & 0x7F) {
|
||||||
case FIT_TYPE_HEADER: return QObject::tr("Header ");
|
case FIT_TYPE_HEADER: return ("Header ");
|
||||||
case FIT_TYPE_MICROCODE: return QObject::tr("Microcode ");
|
case FIT_TYPE_MICROCODE: return ("Microcode ");
|
||||||
case FIT_TYPE_BIOS_AC_MODULE: return QObject::tr("BIOS ACM ");
|
case FIT_TYPE_BIOS_AC_MODULE: return ("BIOS ACM ");
|
||||||
case FIT_TYPE_BIOS_INIT_MODULE: return QObject::tr("BIOS Init ");
|
case FIT_TYPE_BIOS_INIT_MODULE: return ("BIOS Init ");
|
||||||
case FIT_TYPE_TPM_POLICY: return QObject::tr("TPM Policy ");
|
case FIT_TYPE_TPM_POLICY: return ("TPM Policy ");
|
||||||
case FIT_TYPE_BIOS_POLICY_DATA: return QObject::tr("BIOS Policy Data ");
|
case FIT_TYPE_BIOS_POLICY_DATA: return ("BIOS Policy Data ");
|
||||||
case FIT_TYPE_TXT_CONF_POLICY: return QObject::tr("TXT Configuration Policy");
|
case FIT_TYPE_TXT_CONF_POLICY: return ("TXT Configuration Policy");
|
||||||
case FIT_TYPE_AC_KEY_MANIFEST: return QObject::tr("BootGuard Key Manifest ");
|
case FIT_TYPE_AC_KEY_MANIFEST: return ("BootGuard Key Manifest ");
|
||||||
case FIT_TYPE_AC_BOOT_POLICY: return QObject::tr("BootGuard Boot Policy ");
|
case FIT_TYPE_AC_BOOT_POLICY: return ("BootGuard Boot Policy ");
|
||||||
case FIT_TYPE_EMPTY: return QObject::tr("Empty ");
|
case FIT_TYPE_EMPTY: return ("Empty ");
|
||||||
default: return QObject::tr("Unknown ");
|
default: return ("Unknown ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
STATUS FitParser::findFitRecursive(const QModelIndex & index, QModelIndex & found, UINT32 & fitOffset)
|
USTATUS FitParser::findFitRecursive(const UModelIndex & index, UModelIndex & found, UINT32 & fitOffset)
|
||||||
{
|
{
|
||||||
// Sanity check
|
// Sanity check
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return ERR_SUCCESS;
|
return U_SUCCESS;
|
||||||
|
|
||||||
// Process child items
|
// Process child items
|
||||||
for (int i = 0; i < model->rowCount(index); i++) {
|
for (int i = 0; i < model->rowCount(index); i++) {
|
||||||
findFitRecursive(index.child(i, 0), found, fitOffset);
|
findFitRecursive(index.child(i, 0), found, fitOffset);
|
||||||
if (found.isValid())
|
if (found.isValid())
|
||||||
return ERR_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get parsing data for the current item
|
// Get parsing data for the current item
|
||||||
PARSING_DATA pdata = parsingDataFromQModelIndex(index);
|
PARSING_DATA pdata = parsingDataFromUModelIndex(index);
|
||||||
|
|
||||||
// Check for all FIT signatures in item's body
|
// Check for all FIT signatures in item's body
|
||||||
for (INT32 offset = model->body(index).indexOf(FIT_SIGNATURE);
|
for (INT32 offset = model->body(index).indexOf(FIT_SIGNATURE);
|
||||||
@ -148,16 +148,16 @@ STATUS FitParser::findFitRecursive(const QModelIndex & index, QModelIndex & foun
|
|||||||
UINT32 fitAddress = pdata.address + model->header(index).size() + (UINT32)offset;
|
UINT32 fitAddress = pdata.address + model->header(index).size() + (UINT32)offset;
|
||||||
|
|
||||||
// Check FIT address to be in the last VTF
|
// Check FIT address to be in the last VTF
|
||||||
QByteArray lastVtfBody = model->body(lastVtf);
|
UByteArray lastVtfBody = model->body(lastVtf);
|
||||||
if (*(const UINT32*)(lastVtfBody.constData() + lastVtfBody.size() - FIT_POINTER_OFFSET) == fitAddress) {
|
if (*(const UINT32*)(lastVtfBody.constData() + lastVtfBody.size() - FIT_POINTER_OFFSET) == fitAddress) {
|
||||||
found = index;
|
found = index;
|
||||||
fitOffset = offset;
|
fitOffset = offset;
|
||||||
msg(QObject::tr("Real FIT table found at physical address %1h").hexarg(fitAddress), found);
|
msg(usprintf("Real FIT table found at physical address %Xh", fitAddress), found);
|
||||||
return ERR_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
else if (model->rowCount(index) == 0) // Show messages only to leaf items
|
else if (model->rowCount(index) == 0) // Show messages only to leaf items
|
||||||
msg(QObject::tr("FIT table candidate found, but not referenced from the last VTF"), index);
|
msg(("FIT table candidate found, but not referenced from the last VTF"), index);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERR_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
@ -15,10 +15,9 @@ WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <QObject>
|
#include "ustring.h"
|
||||||
#include <QModelIndex>
|
#include "ubytearray.h"
|
||||||
#include <QByteArray>
|
#include "umodelindex.h"
|
||||||
|
|
||||||
#include "treemodel.h"
|
#include "treemodel.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
#include "parsingdata.h"
|
#include "parsingdata.h"
|
||||||
@ -36,25 +35,25 @@ public:
|
|||||||
~FitParser() {}
|
~FitParser() {}
|
||||||
|
|
||||||
// Returns messages
|
// Returns messages
|
||||||
std::vector<std::pair<QString, QModelIndex> > getMessages() const { return messagesVector; };
|
std::vector<std::pair<UString, UModelIndex> > getMessages() const { return messagesVector; };
|
||||||
// Clears messages
|
// Clears messages
|
||||||
void clearMessages() { messagesVector.clear(); }
|
void clearMessages() { messagesVector.clear(); }
|
||||||
|
|
||||||
STATUS parse(const QModelIndex & index, const QModelIndex & lastVtf);
|
USTATUS parse(const UModelIndex & index, const UModelIndex & lastVtf);
|
||||||
std::vector<std::vector<QString> > getFitTable() const { return fitTable; }
|
std::vector<std::vector<UString> > getFitTable() const { return fitTable; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TreeModel *model;
|
TreeModel *model;
|
||||||
std::vector<std::pair<QString, QModelIndex> > messagesVector;
|
std::vector<std::pair<UString, UModelIndex> > messagesVector;
|
||||||
QModelIndex lastVtf;
|
UModelIndex lastVtf;
|
||||||
std::vector<std::vector<QString> > fitTable;
|
std::vector<std::vector<UString> > fitTable;
|
||||||
|
|
||||||
STATUS findFitRecursive(const QModelIndex & index, QModelIndex & found, UINT32 & fitOffset);
|
USTATUS findFitRecursive(const UModelIndex & index, UModelIndex & found, UINT32 & fitOffset);
|
||||||
QString fitEntryTypeToQString(UINT8 type);
|
UString fitEntryTypeToUString(UINT8 type);
|
||||||
|
|
||||||
// Message helper
|
// Message helper
|
||||||
void msg(const QString & message, const QModelIndex &index = QModelIndex()) {
|
void msg(const UString & message, const UModelIndex &index = UModelIndex()) {
|
||||||
messagesVector.push_back(std::pair<QString, QModelIndex>(message, index));
|
messagesVector.push_back(std::pair<UString, UModelIndex>(message, index));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -18,8 +18,8 @@ WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
// Make sure we use right packing rules
|
// Make sure we use right packing rules
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
|
|
||||||
const QByteArray ME_VERSION_SIGNATURE("\x24\x4D\x41\x4E", 4); //$MAN
|
const UByteArray ME_VERSION_SIGNATURE("\x24\x4D\x41\x4E", 4); //$MAN
|
||||||
const QByteArray ME_VERSION_SIGNATURE2("\x24\x4D\x4E\x32", 4); //$MN2
|
const UByteArray ME_VERSION_SIGNATURE2("\x24\x4D\x4E\x32", 4); //$MN2
|
||||||
|
|
||||||
typedef struct ME_VERSION_ {
|
typedef struct ME_VERSION_ {
|
||||||
UINT32 signature;
|
UINT32 signature;
|
||||||
|
117
common/nvram.cpp
117
common/nvram.cpp
@ -11,100 +11,99 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include "nvram.h"
|
#include "nvram.h"
|
||||||
|
|
||||||
QString nvarAttributesToQString(const UINT8 attributes)
|
UString nvarAttributesToUString(const UINT8 attributes)
|
||||||
{
|
{
|
||||||
if (attributes == 0x00 || attributes == 0xFF)
|
if (attributes == 0x00 || attributes == 0xFF)
|
||||||
return QString();
|
return UString();
|
||||||
|
|
||||||
QString str;
|
UString str;
|
||||||
if (attributes & NVRAM_NVAR_ENTRY_RUNTIME) str += QObject::tr(", Runtime");
|
if (attributes & NVRAM_NVAR_ENTRY_RUNTIME) str += UString(", Runtime");
|
||||||
if (attributes & NVRAM_NVAR_ENTRY_ASCII_NAME) str += QObject::tr(", AsciiName");
|
if (attributes & NVRAM_NVAR_ENTRY_ASCII_NAME) str += UString(", AsciiName");
|
||||||
if (attributes & NVRAM_NVAR_ENTRY_GUID) str += QObject::tr(", Guid");
|
if (attributes & NVRAM_NVAR_ENTRY_GUID) str += UString(", Guid");
|
||||||
if (attributes & NVRAM_NVAR_ENTRY_DATA_ONLY) str += QObject::tr(", DataOnly");
|
if (attributes & NVRAM_NVAR_ENTRY_DATA_ONLY) str += UString(", DataOnly");
|
||||||
if (attributes & NVRAM_NVAR_ENTRY_EXT_HEADER) str += QObject::tr(", ExtHeader");
|
if (attributes & NVRAM_NVAR_ENTRY_EXT_HEADER) str += UString(", ExtHeader");
|
||||||
if (attributes & NVRAM_NVAR_ENTRY_HW_ERROR_RECORD) str += QObject::tr(", HwErrorRecord");
|
if (attributes & NVRAM_NVAR_ENTRY_HW_ERROR_RECORD) str += UString(", HwErrorRecord");
|
||||||
if (attributes & NVRAM_NVAR_ENTRY_AUTH_WRITE) str += QObject::tr(", AuthWrite");
|
if (attributes & NVRAM_NVAR_ENTRY_AUTH_WRITE) str += UString(", AuthWrite");
|
||||||
if (attributes & NVRAM_NVAR_ENTRY_VALID) str += QObject::tr(", Valid");
|
if (attributes & NVRAM_NVAR_ENTRY_VALID) str += UString(", Valid");
|
||||||
|
|
||||||
return str.mid(2); // Remove first comma and space
|
return str.mid(2); // Remove first comma and space
|
||||||
}
|
}
|
||||||
|
|
||||||
QString nvarExtendedAttributesToQString(const UINT8 attributes)
|
UString nvarExtendedAttributesToUString(const UINT8 attributes)
|
||||||
{
|
{
|
||||||
QString str;
|
UString str;
|
||||||
if (attributes & NVRAM_NVAR_ENTRY_EXT_CHECKSUM) str += QObject::tr(", Checksum");
|
if (attributes & NVRAM_NVAR_ENTRY_EXT_CHECKSUM) str += UString(", Checksum");
|
||||||
if (attributes & NVRAM_NVAR_ENTRY_EXT_AUTH_WRITE) str += QObject::tr(", AuthWrite");
|
if (attributes & NVRAM_NVAR_ENTRY_EXT_AUTH_WRITE) str += UString(", AuthWrite");
|
||||||
if (attributes & NVRAM_NVAR_ENTRY_EXT_TIME_BASED) str += QObject::tr(", TimeBasedAuthWrite");
|
if (attributes & NVRAM_NVAR_ENTRY_EXT_TIME_BASED) str += UString(", TimeBasedAuthWrite");
|
||||||
if (attributes & NVRAM_NVAR_ENTRY_EXT_UNKNOWN_MASK) str += QObject::tr(", Unknown");
|
if (attributes & NVRAM_NVAR_ENTRY_EXT_UNKNOWN_MASK) str += UString(", Unknown");
|
||||||
|
|
||||||
return str.mid(2); // Remove first comma and space
|
return str.mid(2); // Remove first comma and space
|
||||||
}
|
}
|
||||||
|
|
||||||
extern QString vssAttributesToQString(const UINT32 attributes)
|
extern UString vssAttributesToUString(const UINT32 attributes)
|
||||||
{
|
{
|
||||||
QString str;
|
UString str;
|
||||||
if (attributes & NVRAM_VSS_VARIABLE_NON_VOLATILE) str += QObject::tr(", NonVolatile");
|
if (attributes & NVRAM_VSS_VARIABLE_NON_VOLATILE) str += UString(", NonVolatile");
|
||||||
if (attributes & NVRAM_VSS_VARIABLE_BOOTSERVICE_ACCESS) str += QObject::tr(", BootService");
|
if (attributes & NVRAM_VSS_VARIABLE_BOOTSERVICE_ACCESS) str += UString(", BootService");
|
||||||
if (attributes & NVRAM_VSS_VARIABLE_RUNTIME_ACCESS) str += QObject::tr(", Runtime");
|
if (attributes & NVRAM_VSS_VARIABLE_RUNTIME_ACCESS) str += UString(", Runtime");
|
||||||
if (attributes & NVRAM_VSS_VARIABLE_HARDWARE_ERROR_RECORD) str += QObject::tr(", HwErrorRecord");
|
if (attributes & NVRAM_VSS_VARIABLE_HARDWARE_ERROR_RECORD) str += UString(", HwErrorRecord");
|
||||||
if (attributes & NVRAM_VSS_VARIABLE_AUTHENTICATED_WRITE_ACCESS) str += QObject::tr(", AuthWrite");
|
if (attributes & NVRAM_VSS_VARIABLE_AUTHENTICATED_WRITE_ACCESS) str += UString(", AuthWrite");
|
||||||
if (attributes & NVRAM_VSS_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) str += QObject::tr(", TimeBasedAuthWrite");
|
if (attributes & NVRAM_VSS_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) str += UString(", TimeBasedAuthWrite");
|
||||||
if (attributes & NVRAM_VSS_VARIABLE_APPEND_WRITE) str += QObject::tr(", AppendWrite");
|
if (attributes & NVRAM_VSS_VARIABLE_APPEND_WRITE) str += UString(", AppendWrite");
|
||||||
if (attributes & NVRAM_VSS_VARIABLE_APPLE_DATA_CHECKSUM) str += QObject::tr(", AppleChecksum");
|
if (attributes & NVRAM_VSS_VARIABLE_APPLE_DATA_CHECKSUM) str += UString(", AppleChecksum");
|
||||||
if (attributes & NVRAM_VSS_VARIABLE_UNKNOWN_MASK) str += QObject::tr(", Unknown");
|
if (attributes & NVRAM_VSS_VARIABLE_UNKNOWN_MASK) str += UString(", Unknown");
|
||||||
|
|
||||||
return str.mid(2); // Remove first comma and space
|
return str.mid(2); // Remove first comma and space
|
||||||
}
|
}
|
||||||
|
|
||||||
QString evsaAttributesToQString(const UINT32 attributes)
|
UString evsaAttributesToUString(const UINT32 attributes)
|
||||||
{
|
{
|
||||||
QString str;
|
UString str;
|
||||||
if (attributes & NVRAM_EVSA_DATA_NON_VOLATILE) str += QObject::tr(", NonVolatile");
|
if (attributes & NVRAM_EVSA_DATA_NON_VOLATILE) str += UString(", NonVolatile");
|
||||||
if (attributes & NVRAM_EVSA_DATA_BOOTSERVICE_ACCESS) str += QObject::tr(", BootService");
|
if (attributes & NVRAM_EVSA_DATA_BOOTSERVICE_ACCESS) str += UString(", BootService");
|
||||||
if (attributes & NVRAM_EVSA_DATA_RUNTIME_ACCESS) str += QObject::tr(", Runtime");
|
if (attributes & NVRAM_EVSA_DATA_RUNTIME_ACCESS) str += UString(", Runtime");
|
||||||
if (attributes & NVRAM_EVSA_DATA_HARDWARE_ERROR_RECORD) str += QObject::tr(", HwErrorRecord");
|
if (attributes & NVRAM_EVSA_DATA_HARDWARE_ERROR_RECORD) str += UString(", HwErrorRecord");
|
||||||
if (attributes & NVRAM_EVSA_DATA_AUTHENTICATED_WRITE_ACCESS) str += QObject::tr(", AuthWrite");
|
if (attributes & NVRAM_EVSA_DATA_AUTHENTICATED_WRITE_ACCESS) str += UString(", AuthWrite");
|
||||||
if (attributes & NVRAM_EVSA_DATA_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) str += QObject::tr(", TimeBasedAuthWrite");
|
if (attributes & NVRAM_EVSA_DATA_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) str += UString(", TimeBasedAuthWrite");
|
||||||
if (attributes & NVRAM_EVSA_DATA_APPEND_WRITE) str += QObject::tr(", AppendWrite");
|
if (attributes & NVRAM_EVSA_DATA_APPEND_WRITE) str += UString(", AppendWrite");
|
||||||
if (attributes & NVRAM_EVSA_DATA_EXTENDED_HEADER) str += QObject::tr(", ExtendedHeader");
|
if (attributes & NVRAM_EVSA_DATA_EXTENDED_HEADER) str += UString(", ExtendedHeader");
|
||||||
if (attributes & NVRAM_EVSA_DATA_UNKNOWN_MASK) str += QObject::tr(", Unknown");
|
if (attributes & NVRAM_EVSA_DATA_UNKNOWN_MASK) str += UString(", Unknown");
|
||||||
|
|
||||||
return str.mid(2); // Remove first comma and space
|
return str.mid(2); // Remove first comma and space
|
||||||
}
|
}
|
||||||
|
|
||||||
QString efiTimeToQString(const EFI_TIME & time)
|
UString efiTimeToUString(const EFI_TIME & time)
|
||||||
{
|
{
|
||||||
return QObject::tr("%1-%2-%3T%4:%5:%6.%7")
|
return usprintf("%04u-%02u-%02uT%02u:%02u:%02u.%u",
|
||||||
.arg(time.Year, 4, 10, QLatin1Char('0'))
|
time.Year,
|
||||||
.arg(time.Month, 2, 10, QLatin1Char('0'))
|
time.Month,
|
||||||
.arg(time.Day, 2, 10, QLatin1Char('0'))
|
time.Day,
|
||||||
.arg(time.Hour, 2, 10, QLatin1Char('0'))
|
time.Hour,
|
||||||
.arg(time.Minute, 2, 10, QLatin1Char('0'))
|
time.Minute,
|
||||||
.arg(time.Second, 2, 10, QLatin1Char('0'))
|
time.Second,
|
||||||
.arg(time.Nanosecond);
|
time.Nanosecond);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString flashMapGuidToQString(const EFI_GUID & guid)
|
UString flashMapGuidToUString(const EFI_GUID & guid)
|
||||||
{
|
{
|
||||||
const QByteArray baGuid((const char*)&guid, sizeof(EFI_GUID));
|
const UByteArray baGuid((const char*)&guid, sizeof(EFI_GUID));
|
||||||
if (baGuid == NVRAM_PHOENIX_FLASH_MAP_VOLUME_HEADER) return QObject::tr("Volume header");
|
if (baGuid == NVRAM_PHOENIX_FLASH_MAP_VOLUME_HEADER) return UString("Volume header");
|
||||||
if (baGuid == NVRAM_PHOENIX_FLASH_MAP_MICROCODES_GUID) return QObject::tr("Microcodes");
|
if (baGuid == NVRAM_PHOENIX_FLASH_MAP_MICROCODES_GUID) return UString("Microcodes");
|
||||||
if (baGuid == NVRAM_PHOENIX_FLASH_MAP_CMDB_GUID) return QObject::tr("CMDB");
|
if (baGuid == NVRAM_PHOENIX_FLASH_MAP_CMDB_GUID) return UString("CMDB");
|
||||||
if (baGuid == NVRAM_PHOENIX_FLASH_MAP_PUBKEY1_GUID
|
if (baGuid == NVRAM_PHOENIX_FLASH_MAP_PUBKEY1_GUID
|
||||||
|| baGuid == NVRAM_PHOENIX_FLASH_MAP_PUBKEY2_GUID) return QObject::tr("SLIC pubkey");
|
|| baGuid == NVRAM_PHOENIX_FLASH_MAP_PUBKEY2_GUID) return UString("SLIC pubkey");
|
||||||
if (baGuid == NVRAM_PHOENIX_FLASH_MAP_MARKER1_GUID
|
if (baGuid == NVRAM_PHOENIX_FLASH_MAP_MARKER1_GUID
|
||||||
|| baGuid == NVRAM_PHOENIX_FLASH_MAP_MARKER2_GUID) return QObject::tr("SLIC marker");
|
|| baGuid == NVRAM_PHOENIX_FLASH_MAP_MARKER2_GUID) return UString("SLIC marker");
|
||||||
if (baGuid == NVRAM_PHOENIX_FLASH_MAP_EVSA1_GUID
|
if (baGuid == NVRAM_PHOENIX_FLASH_MAP_EVSA1_GUID
|
||||||
|| baGuid == NVRAM_PHOENIX_FLASH_MAP_EVSA2_GUID
|
|| baGuid == NVRAM_PHOENIX_FLASH_MAP_EVSA2_GUID
|
||||||
|| baGuid == NVRAM_PHOENIX_FLASH_MAP_EVSA3_GUID
|
|| baGuid == NVRAM_PHOENIX_FLASH_MAP_EVSA3_GUID
|
||||||
|| baGuid == NVRAM_PHOENIX_FLASH_MAP_EVSA4_GUID
|
|| baGuid == NVRAM_PHOENIX_FLASH_MAP_EVSA4_GUID
|
||||||
|| baGuid == NVRAM_PHOENIX_FLASH_MAP_EVSA5_GUID
|
|| baGuid == NVRAM_PHOENIX_FLASH_MAP_EVSA5_GUID
|
||||||
|| baGuid == NVRAM_PHOENIX_FLASH_MAP_EVSA6_GUID
|
|| baGuid == NVRAM_PHOENIX_FLASH_MAP_EVSA6_GUID
|
||||||
|| baGuid == NVRAM_PHOENIX_FLASH_MAP_EVSA7_GUID) return QObject::tr("EVSA store");
|
|| baGuid == NVRAM_PHOENIX_FLASH_MAP_EVSA7_GUID) return UString("EVSA store");
|
||||||
if (baGuid == NVRAM_PHOENIX_FLASH_MAP_SELF_GUID) return QObject::tr("Flash map");
|
if (baGuid == NVRAM_PHOENIX_FLASH_MAP_SELF_GUID) return UString("Flash map");
|
||||||
return QString();
|
return UString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,8 +15,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
#ifndef NVRAM_H
|
#ifndef NVRAM_H
|
||||||
#define NVRAM_H
|
#define NVRAM_H
|
||||||
|
|
||||||
#include <QByteArray>
|
#include "ubytearray.h"
|
||||||
#include <QString>
|
#include "ustring.h"
|
||||||
#include "basetypes.h"
|
#include "basetypes.h"
|
||||||
|
|
||||||
// Make sure we use right packing rules
|
// Make sure we use right packing rules
|
||||||
@ -27,16 +27,16 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
//
|
//
|
||||||
|
|
||||||
// CEF5B9A3-476D-497F-9FDC-E98143E0422C
|
// CEF5B9A3-476D-497F-9FDC-E98143E0422C
|
||||||
const QByteArray NVRAM_NVAR_STORE_FILE_GUID
|
const UByteArray NVRAM_NVAR_STORE_FILE_GUID
|
||||||
("\xA3\xB9\xF5\xCE\x6D\x47\x7F\x49\x9F\xDC\xE9\x81\x43\xE0\x42\x2C", 16);
|
("\xA3\xB9\xF5\xCE\x6D\x47\x7F\x49\x9F\xDC\xE9\x81\x43\xE0\x42\x2C", 16);
|
||||||
|
|
||||||
// 9221315B-30BB-46B5-813E-1B1BF4712BD3
|
// 9221315B-30BB-46B5-813E-1B1BF4712BD3
|
||||||
const QByteArray NVRAM_NVAR_EXTERNAL_DEFAULTS_FILE_GUID
|
const UByteArray NVRAM_NVAR_EXTERNAL_DEFAULTS_FILE_GUID
|
||||||
("\x5B\x31\x21\x92\xBB\x30\xB5\x46\x81\x3E\x1B\x1B\xF4\x71\x2B\xD3", 16);
|
("\x5B\x31\x21\x92\xBB\x30\xB5\x46\x81\x3E\x1B\x1B\xF4\x71\x2B\xD3", 16);
|
||||||
|
|
||||||
extern QString nvarAttributesToQString(const UINT8 attributes);
|
extern UString nvarAttributesToUString(const UINT8 attributes);
|
||||||
extern QString nvarExtendedAttributesToQString(const UINT8 attributes);
|
extern UString nvarExtendedAttributesToUString(const UINT8 attributes);
|
||||||
extern QString efiTimeToQString(const EFI_TIME & time);
|
extern UString efiTimeToUString(const EFI_TIME & time);
|
||||||
|
|
||||||
typedef struct NVAR_ENTRY_HEADER_ {
|
typedef struct NVAR_ENTRY_HEADER_ {
|
||||||
UINT32 Signature; // NVAR
|
UINT32 Signature; // NVAR
|
||||||
@ -68,11 +68,11 @@ typedef struct NVAR_ENTRY_HEADER_ {
|
|||||||
//
|
//
|
||||||
|
|
||||||
// FFF12B8D-7696-4C8B-A985-2747075B4F50
|
// FFF12B8D-7696-4C8B-A985-2747075B4F50
|
||||||
const QByteArray NVRAM_MAIN_STORE_VOLUME_GUID
|
const UByteArray NVRAM_MAIN_STORE_VOLUME_GUID
|
||||||
("\x8D\x2B\xF1\xFF\x96\x76\x8B\x4C\xA9\x85\x27\x47\x07\x5B\x4F\x50", 16);
|
("\x8D\x2B\xF1\xFF\x96\x76\x8B\x4C\xA9\x85\x27\x47\x07\x5B\x4F\x50", 16);
|
||||||
|
|
||||||
// 00504624-8A59-4EEB-BD0F-6B36E96128E0
|
// 00504624-8A59-4EEB-BD0F-6B36E96128E0
|
||||||
const QByteArray NVRAM_ADDITIONAL_STORE_VOLUME_GUID
|
const UByteArray NVRAM_ADDITIONAL_STORE_VOLUME_GUID
|
||||||
("\x24\x46\x50\x00\x59\x8A\xEB\x4E\xBD\x0F\x6B\x36\xE9\x61\x28\xE0", 16);
|
("\x24\x46\x50\x00\x59\x8A\xEB\x4E\xBD\x0F\x6B\x36\xE9\x61\x28\xE0", 16);
|
||||||
|
|
||||||
#define NVRAM_VSS_STORE_SIGNATURE 0x53535624 // $VSS
|
#define NVRAM_VSS_STORE_SIGNATURE 0x53535624 // $VSS
|
||||||
@ -156,7 +156,7 @@ typedef struct VSS_AUTH_VARIABLE_HEADER_ {
|
|||||||
#define NVRAM_VSS_VARIABLE_APPLE_DATA_CHECKSUM 0x80000000
|
#define NVRAM_VSS_VARIABLE_APPLE_DATA_CHECKSUM 0x80000000
|
||||||
#define NVRAM_VSS_VARIABLE_UNKNOWN_MASK 0x7FFFFF80
|
#define NVRAM_VSS_VARIABLE_UNKNOWN_MASK 0x7FFFFF80
|
||||||
|
|
||||||
extern QString vssAttributesToQString(const UINT32 attributes);
|
extern UString vssAttributesToUString(const UINT32 attributes);
|
||||||
|
|
||||||
//
|
//
|
||||||
// _FDC region
|
// _FDC region
|
||||||
@ -179,7 +179,7 @@ typedef struct FDC_VOLUME_HEADER_ {
|
|||||||
#define EFI_FAULT_TOLERANT_WORKING_BLOCK_INVALID 0x2
|
#define EFI_FAULT_TOLERANT_WORKING_BLOCK_INVALID 0x2
|
||||||
|
|
||||||
// 9E58292B-7C68-497D-0ACE6500FD9F1B95
|
// 9E58292B-7C68-497D-0ACE6500FD9F1B95
|
||||||
const QByteArray EDKII_WORKING_BLOCK_SIGNATURE_GUID
|
const UByteArray EDKII_WORKING_BLOCK_SIGNATURE_GUID
|
||||||
("\x2B\x29\x58\x9E\x68\x7C\x7D\x49\x0A\xCE\x65\x00\xFD\x9F\x1B\x95", 16);
|
("\x2B\x29\x58\x9E\x68\x7C\x7D\x49\x0A\xCE\x65\x00\xFD\x9F\x1B\x95", 16);
|
||||||
|
|
||||||
#define NVRAM_MAIN_STORE_VOLUME_GUID_DATA1 0xFFF12B8D
|
#define NVRAM_MAIN_STORE_VOLUME_GUID_DATA1 0xFFF12B8D
|
||||||
@ -292,7 +292,7 @@ typedef struct EVSA_DATA_ENTRY_EXTENDED_ {
|
|||||||
//UINT8 Data[];
|
//UINT8 Data[];
|
||||||
} EVSA_DATA_ENTRY_EXTENDED;
|
} EVSA_DATA_ENTRY_EXTENDED;
|
||||||
|
|
||||||
extern QString evsaAttributesToQString(const UINT32 attributes);
|
extern UString evsaAttributesToUString(const UINT32 attributes);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Phoenix SCT Flash Map
|
// Phoenix SCT Flash Map
|
||||||
@ -302,7 +302,7 @@ extern QString evsaAttributesToQString(const UINT32 attributes);
|
|||||||
#define NVRAM_PHOENIX_FLASH_MAP_SIGNATURE_LENGTH 10
|
#define NVRAM_PHOENIX_FLASH_MAP_SIGNATURE_LENGTH 10
|
||||||
|
|
||||||
// _FLASH_MAP
|
// _FLASH_MAP
|
||||||
const QByteArray NVRAM_PHOENIX_FLASH_MAP_SIGNATURE
|
const UByteArray NVRAM_PHOENIX_FLASH_MAP_SIGNATURE
|
||||||
("\x5F\x46\x4C\x41\x53\x48\x5F\x4D\x41\x50", 10);
|
("\x5F\x46\x4C\x41\x53\x48\x5F\x4D\x41\x50", 10);
|
||||||
|
|
||||||
typedef struct PHOENIX_FLASH_MAP_HEADER_ {
|
typedef struct PHOENIX_FLASH_MAP_HEADER_ {
|
||||||
@ -323,66 +323,66 @@ typedef struct PHOENIX_FLASH_MAP_ENTRY_ {
|
|||||||
#define NVRAM_PHOENIX_FLASH_MAP_ENTRY_TYPE_VOLUME 0x0000
|
#define NVRAM_PHOENIX_FLASH_MAP_ENTRY_TYPE_VOLUME 0x0000
|
||||||
#define NVRAM_PHOENIX_FLASH_MAP_ENTRY_TYPE_DATA_BLOCK 0x0001
|
#define NVRAM_PHOENIX_FLASH_MAP_ENTRY_TYPE_DATA_BLOCK 0x0001
|
||||||
|
|
||||||
extern QString flashMapGuidToQString(const EFI_GUID & guid);
|
extern UString flashMapGuidToUString(const EFI_GUID & guid);
|
||||||
|
|
||||||
// B091E7D2-05A0-4198-94F0-74B7B8C55459
|
// B091E7D2-05A0-4198-94F0-74B7B8C55459
|
||||||
const QByteArray NVRAM_PHOENIX_FLASH_MAP_VOLUME_HEADER
|
const UByteArray NVRAM_PHOENIX_FLASH_MAP_VOLUME_HEADER
|
||||||
("\xD2\xE7\x91\xB0\xA0\x05\x98\x41\x94\xF0\x74\xB7\xB8\xC5\x54\x59", 16);
|
("\xD2\xE7\x91\xB0\xA0\x05\x98\x41\x94\xF0\x74\xB7\xB8\xC5\x54\x59", 16);
|
||||||
|
|
||||||
// FD3F690E-B4B0-4D68-89DB-19A1A3318F90
|
// FD3F690E-B4B0-4D68-89DB-19A1A3318F90
|
||||||
const QByteArray NVRAM_PHOENIX_FLASH_MAP_MICROCODES_GUID
|
const UByteArray NVRAM_PHOENIX_FLASH_MAP_MICROCODES_GUID
|
||||||
("\x0E\x69\x3F\xFD\xB0\xB4\x68\x4D\x89\xDB\x19\xA1\xA3\x31\x8F\x90", 16);
|
("\x0E\x69\x3F\xFD\xB0\xB4\x68\x4D\x89\xDB\x19\xA1\xA3\x31\x8F\x90", 16);
|
||||||
|
|
||||||
// 46310243-7B03-4132-BE44-2243FACA7CDD
|
// 46310243-7B03-4132-BE44-2243FACA7CDD
|
||||||
const QByteArray NVRAM_PHOENIX_FLASH_MAP_CMDB_GUID
|
const UByteArray NVRAM_PHOENIX_FLASH_MAP_CMDB_GUID
|
||||||
("\x43\x02\x31\x46\x03\x7B\x32\x41\xBE\x44\x22\x43\xFA\xCA\x7C\xDD", 16);
|
("\x43\x02\x31\x46\x03\x7B\x32\x41\xBE\x44\x22\x43\xFA\xCA\x7C\xDD", 16);
|
||||||
|
|
||||||
// 1B2C4952-D778-4B64-BDA1-15A36F5FA545
|
// 1B2C4952-D778-4B64-BDA1-15A36F5FA545
|
||||||
const QByteArray NVRAM_PHOENIX_FLASH_MAP_PUBKEY1_GUID
|
const UByteArray NVRAM_PHOENIX_FLASH_MAP_PUBKEY1_GUID
|
||||||
("\x52\x49\x2C\x1B\x78\xD7\x64\x4B\xBD\xA1\x15\xA3\x6F\x5F\xA5\x45", 16);
|
("\x52\x49\x2C\x1B\x78\xD7\x64\x4B\xBD\xA1\x15\xA3\x6F\x5F\xA5\x45", 16);
|
||||||
|
|
||||||
// 127C1C4E-9135-46E3-B006-F9808B0559A5
|
// 127C1C4E-9135-46E3-B006-F9808B0559A5
|
||||||
const QByteArray NVRAM_PHOENIX_FLASH_MAP_MARKER1_GUID
|
const UByteArray NVRAM_PHOENIX_FLASH_MAP_MARKER1_GUID
|
||||||
("\x4E\x1C\x7C\x12\x35\x91\xE3\x46\xB0\x06\xF9\x80\x8B\x05\x59\xA5", 16);
|
("\x4E\x1C\x7C\x12\x35\x91\xE3\x46\xB0\x06\xF9\x80\x8B\x05\x59\xA5", 16);
|
||||||
|
|
||||||
// 7CE75114-8272-45AF-B536-761BD38852CE
|
// 7CE75114-8272-45AF-B536-761BD38852CE
|
||||||
const QByteArray NVRAM_PHOENIX_FLASH_MAP_PUBKEY2_GUID
|
const UByteArray NVRAM_PHOENIX_FLASH_MAP_PUBKEY2_GUID
|
||||||
("\x14\x51\xE7\x7C\x72\x82\xAF\x45\xB5\x36\x76\x1B\xD3\x88\x52\xCE", 16);
|
("\x14\x51\xE7\x7C\x72\x82\xAF\x45\xB5\x36\x76\x1B\xD3\x88\x52\xCE", 16);
|
||||||
|
|
||||||
// 071A3DBE-CFF4-4B73-83F0-598C13DCFDD5
|
// 071A3DBE-CFF4-4B73-83F0-598C13DCFDD5
|
||||||
const QByteArray NVRAM_PHOENIX_FLASH_MAP_MARKER2_GUID
|
const UByteArray NVRAM_PHOENIX_FLASH_MAP_MARKER2_GUID
|
||||||
("\xBE\x3D\x1A\x07\xF4\xCF\x73\x4B\x83\xF0\x59\x8C\x13\xDC\xFD\xD5", 16);
|
("\xBE\x3D\x1A\x07\xF4\xCF\x73\x4B\x83\xF0\x59\x8C\x13\xDC\xFD\xD5", 16);
|
||||||
|
|
||||||
// FACFB110-7BFD-4EFB-873E-88B6B23B97EA
|
// FACFB110-7BFD-4EFB-873E-88B6B23B97EA
|
||||||
const QByteArray NVRAM_PHOENIX_FLASH_MAP_EVSA1_GUID
|
const UByteArray NVRAM_PHOENIX_FLASH_MAP_EVSA1_GUID
|
||||||
("\x10\xB1\xCF\xFA\xFD\x7B\xFB\x4E\x87\x3E\x88\xB6\xB2\x3B\x97\xEA", 16);
|
("\x10\xB1\xCF\xFA\xFD\x7B\xFB\x4E\x87\x3E\x88\xB6\xB2\x3B\x97\xEA", 16);
|
||||||
|
|
||||||
// E68DC11A-A5F4-4AC3-AA2E-29E298BFF645
|
// E68DC11A-A5F4-4AC3-AA2E-29E298BFF645
|
||||||
const QByteArray NVRAM_PHOENIX_FLASH_MAP_EVSA2_GUID
|
const UByteArray NVRAM_PHOENIX_FLASH_MAP_EVSA2_GUID
|
||||||
("\x1A\xC1\x8D\xE6\xF4\xA5\xC3\x4A\xAA\x2E\x29\xE2\x98\xBF\xF6\x45", 16);
|
("\x1A\xC1\x8D\xE6\xF4\xA5\xC3\x4A\xAA\x2E\x29\xE2\x98\xBF\xF6\x45", 16);
|
||||||
|
|
||||||
// 4B3828AE-0ACE-45B6-8CDB-DAFC28BBF8C5
|
// 4B3828AE-0ACE-45B6-8CDB-DAFC28BBF8C5
|
||||||
const QByteArray NVRAM_PHOENIX_FLASH_MAP_EVSA3_GUID
|
const UByteArray NVRAM_PHOENIX_FLASH_MAP_EVSA3_GUID
|
||||||
("\xAE\x28\x38\x4B\xCE\x0A\xB6\x45\x8C\xDB\xDA\xFC\x28\xBB\xF8\xC5", 16);
|
("\xAE\x28\x38\x4B\xCE\x0A\xB6\x45\x8C\xDB\xDA\xFC\x28\xBB\xF8\xC5", 16);
|
||||||
|
|
||||||
// C22E6B8A-8159-49A3-B353-E84B79DF19C0
|
// C22E6B8A-8159-49A3-B353-E84B79DF19C0
|
||||||
const QByteArray NVRAM_PHOENIX_FLASH_MAP_EVSA4_GUID
|
const UByteArray NVRAM_PHOENIX_FLASH_MAP_EVSA4_GUID
|
||||||
("\x8A\x6B\x2E\xC2\x59\x81\xA3\x49\xB3\x53\xE8\x4B\x79\xDF\x19\xC0", 16);
|
("\x8A\x6B\x2E\xC2\x59\x81\xA3\x49\xB3\x53\xE8\x4B\x79\xDF\x19\xC0", 16);
|
||||||
|
|
||||||
// B6B5FAB9-75C4-4AAE-8314-7FFFA7156EAA
|
// B6B5FAB9-75C4-4AAE-8314-7FFFA7156EAA
|
||||||
const QByteArray NVRAM_PHOENIX_FLASH_MAP_EVSA5_GUID
|
const UByteArray NVRAM_PHOENIX_FLASH_MAP_EVSA5_GUID
|
||||||
("\xB9\xFA\xB5\xB6\xC4\x75\xAE\x4A\x83\x14\x7F\xFF\xA7\x15\x6E\xAA", 16);
|
("\xB9\xFA\xB5\xB6\xC4\x75\xAE\x4A\x83\x14\x7F\xFF\xA7\x15\x6E\xAA", 16);
|
||||||
|
|
||||||
// 919B9699-8DD0-4376-AA0B-0E54CCA47D8F
|
// 919B9699-8DD0-4376-AA0B-0E54CCA47D8F
|
||||||
const QByteArray NVRAM_PHOENIX_FLASH_MAP_EVSA6_GUID
|
const UByteArray NVRAM_PHOENIX_FLASH_MAP_EVSA6_GUID
|
||||||
("\x99\x96\x9B\x91\xD0\x8D\x76\x43\xAA\x0B\x0E\x54\xCC\xA4\x7D\x8F", 16);
|
("\x99\x96\x9B\x91\xD0\x8D\x76\x43\xAA\x0B\x0E\x54\xCC\xA4\x7D\x8F", 16);
|
||||||
|
|
||||||
// 58A90A52-929F-44F8-AC35-A7E1AB18AC91
|
// 58A90A52-929F-44F8-AC35-A7E1AB18AC91
|
||||||
const QByteArray NVRAM_PHOENIX_FLASH_MAP_EVSA7_GUID
|
const UByteArray NVRAM_PHOENIX_FLASH_MAP_EVSA7_GUID
|
||||||
("\x52\x0A\xA9\x58\x9F\x92\xF8\x44\xAC\x35\xA7\xE1\xAB\x18\xAC\x91", 16);
|
("\x52\x0A\xA9\x58\x9F\x92\xF8\x44\xAC\x35\xA7\xE1\xAB\x18\xAC\x91", 16);
|
||||||
|
|
||||||
// 8CB71915-531F-4AF5-82BF-A09140817BAA
|
// 8CB71915-531F-4AF5-82BF-A09140817BAA
|
||||||
const QByteArray NVRAM_PHOENIX_FLASH_MAP_SELF_GUID
|
const UByteArray NVRAM_PHOENIX_FLASH_MAP_SELF_GUID
|
||||||
("\x15\x19\xB7\x8C\x1F\x53\xF5\x4A\x82\xBF\xA0\x91\x40\x81\x7B\xAA", 16);
|
("\x15\x19\xB7\x8C\x1F\x53\xF5\x4A\x82\xBF\xA0\x91\x40\x81\x7B\xAA", 16);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -11,27 +11,25 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
#include "peimage.h"
|
#include "peimage.h"
|
||||||
|
|
||||||
QString machineTypeToQString(UINT16 machineType)
|
UString machineTypeToUString(UINT16 machineType)
|
||||||
{
|
{
|
||||||
switch (machineType) {
|
switch (machineType) {
|
||||||
case EFI_IMAGE_FILE_MACHINE_AMD64: return QObject::tr("x86-64");
|
case EFI_IMAGE_FILE_MACHINE_AMD64: return UString("x86-64");
|
||||||
case EFI_IMAGE_FILE_MACHINE_ARM: return QObject::tr("ARM");
|
case EFI_IMAGE_FILE_MACHINE_ARM: return UString("ARM");
|
||||||
case EFI_IMAGE_FILE_MACHINE_ARMNT: return QObject::tr("ARMv7");
|
case EFI_IMAGE_FILE_MACHINE_ARMNT: return UString("ARMv7");
|
||||||
case EFI_IMAGE_FILE_MACHINE_APPLE_ARM: return QObject::tr("Apple ARM");
|
case EFI_IMAGE_FILE_MACHINE_APPLE_ARM: return UString("Apple ARM");
|
||||||
case EFI_IMAGE_FILE_MACHINE_AARCH64: return QObject::tr("AARCH64");
|
case EFI_IMAGE_FILE_MACHINE_AARCH64: return UString("AARCH64");
|
||||||
case EFI_IMAGE_FILE_MACHINE_EBC: return QObject::tr("EBC");
|
case EFI_IMAGE_FILE_MACHINE_EBC: return UString("EBC");
|
||||||
case EFI_IMAGE_FILE_MACHINE_I386: return QObject::tr("x86");
|
case EFI_IMAGE_FILE_MACHINE_I386: return UString("x86");
|
||||||
case EFI_IMAGE_FILE_MACHINE_IA64: return QObject::tr("IA64");
|
case EFI_IMAGE_FILE_MACHINE_IA64: return UString("IA64");
|
||||||
case EFI_IMAGE_FILE_MACHINE_POWERPC: return QObject::tr("PowerPC");
|
case EFI_IMAGE_FILE_MACHINE_POWERPC: return UString("PowerPC");
|
||||||
case EFI_IMAGE_FILE_MACHINE_POWERPCFP: return QObject::tr("PowerPC FP");
|
case EFI_IMAGE_FILE_MACHINE_POWERPCFP: return UString("PowerPC FP");
|
||||||
case EFI_IMAGE_FILE_MACHINE_THUMB: return QObject::tr("ARM Thumb");
|
case EFI_IMAGE_FILE_MACHINE_THUMB: return UString("ARM Thumb");
|
||||||
case EFI_IMAGE_FILE_MACHINE_RISCV32: return QObject::tr("RISC-V 32-bit");
|
case EFI_IMAGE_FILE_MACHINE_RISCV32: return UString("RISC-V 32-bit");
|
||||||
case EFI_IMAGE_FILE_MACHINE_RISCV64: return QObject::tr("RISC-V 64-bit");
|
case EFI_IMAGE_FILE_MACHINE_RISCV64: return UString("RISC-V 64-bit");
|
||||||
case EFI_IMAGE_FILE_MACHINE_RISCV128: return QObject::tr("RISC-V 128-bit");
|
case EFI_IMAGE_FILE_MACHINE_RISCV128: return UString("RISC-V 128-bit");
|
||||||
default: return QObject::tr("Unknown %1h").hexarg2(machineType, 4);
|
default: return usprintf("Unknown (%04Xh)", machineType);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -16,10 +16,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
#ifndef PEIMAGE_H
|
#ifndef PEIMAGE_H
|
||||||
#define PEIMAGE_H
|
#define PEIMAGE_H
|
||||||
|
|
||||||
#include <QString>
|
#include "ustring.h"
|
||||||
#include "basetypes.h"
|
#include "basetypes.h"
|
||||||
|
|
||||||
extern QString machineTypeToQString(UINT16 machineType);
|
extern UString machineTypeToUString(UINT16 machineType);
|
||||||
|
|
||||||
// Make sure we use right packing rules
|
// Make sure we use right packing rules
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
@ -49,6 +49,7 @@ extern QString machineTypeToQString(UINT16 machineType);
|
|||||||
#define EFI_IMAGE_FILE_MACHINE_RISCV32 0x5032 // RISC-V 32-bit
|
#define EFI_IMAGE_FILE_MACHINE_RISCV32 0x5032 // RISC-V 32-bit
|
||||||
#define EFI_IMAGE_FILE_MACHINE_RISCV64 0x5064 // RISC-V 64-bit
|
#define EFI_IMAGE_FILE_MACHINE_RISCV64 0x5064 // RISC-V 64-bit
|
||||||
#define EFI_IMAGE_FILE_MACHINE_RISCV128 0x5128 // RISC-V 128-bit
|
#define EFI_IMAGE_FILE_MACHINE_RISCV128 0x5128 // RISC-V 128-bit
|
||||||
|
|
||||||
//
|
//
|
||||||
// EXE file formats
|
// EXE file formats
|
||||||
//
|
//
|
||||||
@ -471,6 +472,7 @@ typedef struct {
|
|||||||
#define EFI_IMAGE_REL_BASED_RISCV_LO12I 0x0007
|
#define EFI_IMAGE_REL_BASED_RISCV_LO12I 0x0007
|
||||||
#define EFI_IMAGE_REL_BASED_RISCV_LO12S 0x0008
|
#define EFI_IMAGE_REL_BASED_RISCV_LO12S 0x0008
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Based relocation format
|
// Based relocation format
|
||||||
//
|
//
|
||||||
|
@ -11,14 +11,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include "treeitem.h"
|
#include "treeitem.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
TreeItem::TreeItem(const UINT8 type, const UINT8 subtype,
|
TreeItem::TreeItem(const UINT8 type, const UINT8 subtype,
|
||||||
const QString & name, const QString & text, const QString & info,
|
const UString & name, const UString & text, const UString & info,
|
||||||
const QByteArray & header, const QByteArray & body, const QByteArray & tail,
|
const UByteArray & header, const UByteArray & body, const UByteArray & tail,
|
||||||
const BOOLEAN fixed, const BOOLEAN compressed, const QByteArray & parsingData,
|
const BOOLEAN fixed, const BOOLEAN compressed, const UByteArray & parsingData,
|
||||||
TreeItem *parent) :
|
TreeItem *parent) :
|
||||||
itemAction(Actions::NoAction),
|
itemAction(Actions::NoAction),
|
||||||
itemType(type),
|
itemType(type),
|
||||||
@ -41,18 +40,18 @@ UINT8 TreeItem::insertChildBefore(TreeItem *item, TreeItem *newItem)
|
|||||||
{
|
{
|
||||||
int index = childItems.indexOf(item);
|
int index = childItems.indexOf(item);
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
return ERR_ITEM_NOT_FOUND;
|
return U_ITEM_NOT_FOUND;
|
||||||
childItems.insert(index, newItem);
|
childItems.insert(index, newItem);
|
||||||
return ERR_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT8 TreeItem::insertChildAfter(TreeItem *item, TreeItem *newItem)
|
UINT8 TreeItem::insertChildAfter(TreeItem *item, TreeItem *newItem)
|
||||||
{
|
{
|
||||||
int index = childItems.indexOf(item);
|
int index = childItems.indexOf(item);
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
return ERR_ITEM_NOT_FOUND;
|
return U_ITEM_NOT_FOUND;
|
||||||
childItems.insert(index + 1, newItem);
|
childItems.insert(index + 1, newItem);
|
||||||
return ERR_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant TreeItem::data(int column) const
|
QVariant TreeItem::data(int column) const
|
||||||
@ -62,11 +61,11 @@ QVariant TreeItem::data(int column) const
|
|||||||
case 0: // Name
|
case 0: // Name
|
||||||
return itemName;
|
return itemName;
|
||||||
case 1: // Action
|
case 1: // Action
|
||||||
return actionTypeToQString(itemAction);
|
return actionTypeToUString(itemAction);
|
||||||
case 2: // Type
|
case 2: // Type
|
||||||
return itemTypeToQString(itemType);
|
return itemTypeToUString(itemType);
|
||||||
case 3: // Subtype
|
case 3: // Subtype
|
||||||
return itemSubtypeToQString(itemType, itemSubtype);
|
return itemSubtypeToUString(itemType, itemSubtype);
|
||||||
case 4: // Text
|
case 4: // Text
|
||||||
return itemText;
|
return itemText;
|
||||||
default:
|
default:
|
||||||
|
@ -14,19 +14,19 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
#ifndef TREEITEM_H
|
#ifndef TREEITEM_H
|
||||||
#define TREEITEM_H
|
#define TREEITEM_H
|
||||||
|
|
||||||
#include <QByteArray>
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QString>
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
|
#include "ubytearray.h"
|
||||||
|
#include "ustring.h"
|
||||||
#include "basetypes.h"
|
#include "basetypes.h"
|
||||||
|
|
||||||
class TreeItem
|
class TreeItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TreeItem(const UINT8 type, const UINT8 subtype, const QString &name, const QString &text, const QString &info,
|
TreeItem(const UINT8 type, const UINT8 subtype, const UString &name, const UString &text, const UString &info,
|
||||||
const QByteArray & header, const QByteArray & body, const QByteArray & tail,
|
const UByteArray & header, const UByteArray & body, const UByteArray & tail,
|
||||||
const BOOLEAN fixed, const BOOLEAN compressed, const QByteArray & parsingData,
|
const BOOLEAN fixed, const BOOLEAN compressed, const UByteArray & parsingData,
|
||||||
TreeItem *parent = 0);
|
TreeItem *parent = 0);
|
||||||
~TreeItem() { qDeleteAll(childItems); }
|
~TreeItem() { qDeleteAll(childItems); }
|
||||||
|
|
||||||
@ -45,8 +45,8 @@ public:
|
|||||||
TreeItem *parent() { return parentItem; }
|
TreeItem *parent() { return parentItem; }
|
||||||
|
|
||||||
// Reading operations for item parameters
|
// Reading operations for item parameters
|
||||||
QString name() const { return itemName; }
|
UString name() const { return itemName; }
|
||||||
void setName(const QString &text) { itemName = text; }
|
void setName(const UString &text) { itemName = text; }
|
||||||
|
|
||||||
UINT8 type() const { return itemType; }
|
UINT8 type() const { return itemType; }
|
||||||
void setType(const UINT8 type) { itemType = type; }
|
void setType(const UINT8 type) { itemType = type; }
|
||||||
@ -54,25 +54,25 @@ public:
|
|||||||
UINT8 subtype() const { return itemSubtype; }
|
UINT8 subtype() const { return itemSubtype; }
|
||||||
void setSubtype(const UINT8 subtype) { itemSubtype = subtype; }
|
void setSubtype(const UINT8 subtype) { itemSubtype = subtype; }
|
||||||
|
|
||||||
QString text() const { return itemText; }
|
UString text() const { return itemText; }
|
||||||
void setText(const QString &text) { itemText = text; }
|
void setText(const UString &text) { itemText = text; }
|
||||||
|
|
||||||
QByteArray header() const { return itemHeader; }
|
UByteArray header() const { return itemHeader; }
|
||||||
bool hasEmptyHeader() const { return itemHeader.isEmpty(); }
|
bool hasEmptyHeader() const { return itemHeader.isEmpty(); }
|
||||||
|
|
||||||
QByteArray body() const { return itemBody; };
|
UByteArray body() const { return itemBody; };
|
||||||
bool hasEmptyBody() const { return itemBody.isEmpty(); }
|
bool hasEmptyBody() const { return itemBody.isEmpty(); }
|
||||||
|
|
||||||
QByteArray tail() const { return itemTail; };
|
UByteArray tail() const { return itemTail; };
|
||||||
bool hasEmptyTail() const { return itemTail.isEmpty(); }
|
bool hasEmptyTail() const { return itemTail.isEmpty(); }
|
||||||
|
|
||||||
QByteArray parsingData() const { return itemParsingData; }
|
UByteArray parsingData() const { return itemParsingData; }
|
||||||
bool hasEmptyParsingData() const { return itemParsingData.isEmpty(); }
|
bool hasEmptyParsingData() const { return itemParsingData.isEmpty(); }
|
||||||
void setParsingData(const QByteArray & data) { itemParsingData = data; }
|
void setParsingData(const UByteArray & data) { itemParsingData = data; }
|
||||||
|
|
||||||
QString info() const { return itemInfo; }
|
UString info() const { return itemInfo; }
|
||||||
void addInfo(const QString &info, const BOOLEAN append) { if (append) itemInfo.append(info); else itemInfo.prepend(info); }
|
void addInfo(const UString &info, const BOOLEAN append) { if (append) itemInfo.append(info); else itemInfo.prepend(info); }
|
||||||
void setInfo(const QString &info) { itemInfo = info; }
|
void setInfo(const UString &info) { itemInfo = info; }
|
||||||
|
|
||||||
UINT8 action() const {return itemAction; }
|
UINT8 action() const {return itemAction; }
|
||||||
void setAction(const UINT8 action) { itemAction = action; }
|
void setAction(const UINT8 action) { itemAction = action; }
|
||||||
@ -88,13 +88,13 @@ private:
|
|||||||
UINT8 itemAction;
|
UINT8 itemAction;
|
||||||
UINT8 itemType;
|
UINT8 itemType;
|
||||||
UINT8 itemSubtype;
|
UINT8 itemSubtype;
|
||||||
QString itemName;
|
UString itemName;
|
||||||
QString itemText;
|
UString itemText;
|
||||||
QString itemInfo;
|
UString itemInfo;
|
||||||
QByteArray itemHeader;
|
UByteArray itemHeader;
|
||||||
QByteArray itemBody;
|
UByteArray itemBody;
|
||||||
QByteArray itemTail;
|
UByteArray itemTail;
|
||||||
QByteArray itemParsingData;
|
UByteArray itemParsingData;
|
||||||
bool itemFixed;
|
bool itemFixed;
|
||||||
bool itemCompressed;
|
bool itemCompressed;
|
||||||
TreeItem* parentItem;
|
TreeItem* parentItem;
|
||||||
|
@ -17,7 +17,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
TreeModel::TreeModel(QObject *parent)
|
TreeModel::TreeModel(QObject *parent)
|
||||||
: QAbstractItemModel(parent)
|
: QAbstractItemModel(parent)
|
||||||
{
|
{
|
||||||
rootItem = new TreeItem(Types::Root, 0, QString(), QString(), QString(), QByteArray(), QByteArray(), QByteArray(), TRUE, FALSE, QByteArray());
|
rootItem = new TreeItem(Types::Root, 0, UString(), UString(), UString(), UByteArray(), UByteArray(), UByteArray(), TRUE, FALSE, UByteArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeModel::~TreeModel()
|
TreeModel::~TreeModel()
|
||||||
@ -25,7 +25,7 @@ TreeModel::~TreeModel()
|
|||||||
delete rootItem;
|
delete rootItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TreeModel::columnCount(const QModelIndex &parent) const
|
int TreeModel::columnCount(const UModelIndex &parent) const
|
||||||
{
|
{
|
||||||
if (parent.isValid())
|
if (parent.isValid())
|
||||||
return static_cast<TreeItem*>(parent.internalPointer())->columnCount();
|
return static_cast<TreeItem*>(parent.internalPointer())->columnCount();
|
||||||
@ -33,7 +33,7 @@ int TreeModel::columnCount(const QModelIndex &parent) const
|
|||||||
return rootItem->columnCount();
|
return rootItem->columnCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant TreeModel::data(const QModelIndex &index, int role) const
|
QVariant TreeModel::data(const UModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@ -49,7 +49,7 @@ QVariant TreeModel::data(const QModelIndex &index, int role) const
|
|||||||
return item->info();
|
return item->info();
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::ItemFlags TreeModel::flags(const QModelIndex &index) const
|
Qt::ItemFlags TreeModel::flags(const UModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return 0;
|
return 0;
|
||||||
@ -79,10 +79,10 @@ QVariant TreeModel::headerData(int section, Qt::Orientation orientation,
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent) const
|
UModelIndex TreeModel::index(int row, int column, const UModelIndex &parent) const
|
||||||
{
|
{
|
||||||
if (!hasIndex(row, column, parent))
|
if (!hasIndex(row, column, parent))
|
||||||
return QModelIndex();
|
return UModelIndex();
|
||||||
|
|
||||||
TreeItem *parentItem;
|
TreeItem *parentItem;
|
||||||
|
|
||||||
@ -95,27 +95,27 @@ QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent) con
|
|||||||
if (childItem)
|
if (childItem)
|
||||||
return createIndex(row, column, childItem);
|
return createIndex(row, column, childItem);
|
||||||
else
|
else
|
||||||
return QModelIndex();
|
return UModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex TreeModel::parent(const QModelIndex &index) const
|
UModelIndex TreeModel::parent(const UModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QModelIndex();
|
return UModelIndex();
|
||||||
|
|
||||||
TreeItem *childItem = static_cast<TreeItem*>(index.internalPointer());
|
TreeItem *childItem = static_cast<TreeItem*>(index.internalPointer());
|
||||||
if (childItem == rootItem)
|
if (childItem == rootItem)
|
||||||
return QModelIndex();
|
return UModelIndex();
|
||||||
|
|
||||||
TreeItem *parentItem = childItem->parent();
|
TreeItem *parentItem = childItem->parent();
|
||||||
|
|
||||||
if (parentItem == rootItem)
|
if (parentItem == rootItem)
|
||||||
return QModelIndex();
|
return UModelIndex();
|
||||||
|
|
||||||
return createIndex(parentItem->row(), 0, parentItem);
|
return createIndex(parentItem->row(), 0, parentItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
int TreeModel::rowCount(const QModelIndex &parent) const
|
int TreeModel::rowCount(const UModelIndex &parent) const
|
||||||
{
|
{
|
||||||
TreeItem *parentItem;
|
TreeItem *parentItem;
|
||||||
if (parent.column() > 0)
|
if (parent.column() > 0)
|
||||||
@ -129,7 +129,7 @@ int TreeModel::rowCount(const QModelIndex &parent) const
|
|||||||
return parentItem->childCount();
|
return parentItem->childCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT8 TreeModel::type(const QModelIndex &index) const
|
UINT8 TreeModel::type(const UModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return 0;
|
return 0;
|
||||||
@ -137,7 +137,7 @@ UINT8 TreeModel::type(const QModelIndex &index) const
|
|||||||
return item->type();
|
return item->type();
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT8 TreeModel::subtype(const QModelIndex &index) const
|
UINT8 TreeModel::subtype(const UModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return 0;
|
return 0;
|
||||||
@ -145,15 +145,15 @@ UINT8 TreeModel::subtype(const QModelIndex &index) const
|
|||||||
return item->subtype();
|
return item->subtype();
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray TreeModel::header(const QModelIndex &index) const
|
UByteArray TreeModel::header(const UModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QByteArray();
|
return UByteArray();
|
||||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||||
return item->header();
|
return item->header();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TreeModel::hasEmptyHeader(const QModelIndex &index) const
|
bool TreeModel::hasEmptyHeader(const UModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return true;
|
return true;
|
||||||
@ -161,15 +161,15 @@ bool TreeModel::hasEmptyHeader(const QModelIndex &index) const
|
|||||||
return item->hasEmptyHeader();
|
return item->hasEmptyHeader();
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray TreeModel::body(const QModelIndex &index) const
|
UByteArray TreeModel::body(const UModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QByteArray();
|
return UByteArray();
|
||||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||||
return item->body();
|
return item->body();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TreeModel::hasEmptyBody(const QModelIndex &index) const
|
bool TreeModel::hasEmptyBody(const UModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return true;
|
return true;
|
||||||
@ -177,15 +177,15 @@ bool TreeModel::hasEmptyBody(const QModelIndex &index) const
|
|||||||
return item->hasEmptyBody();
|
return item->hasEmptyBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray TreeModel::tail(const QModelIndex &index) const
|
UByteArray TreeModel::tail(const UModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QByteArray();
|
return UByteArray();
|
||||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||||
return item->tail();
|
return item->tail();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TreeModel::hasEmptyTail(const QModelIndex &index) const
|
bool TreeModel::hasEmptyTail(const UModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return true;
|
return true;
|
||||||
@ -193,15 +193,15 @@ bool TreeModel::hasEmptyTail(const QModelIndex &index) const
|
|||||||
return item->hasEmptyTail();
|
return item->hasEmptyTail();
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray TreeModel::parsingData(const QModelIndex &index) const
|
UByteArray TreeModel::parsingData(const UModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QByteArray();
|
return UByteArray();
|
||||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||||
return item->parsingData();
|
return item->parsingData();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TreeModel::hasEmptyParsingData(const QModelIndex &index) const
|
bool TreeModel::hasEmptyParsingData(const UModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return true;
|
return true;
|
||||||
@ -209,31 +209,31 @@ bool TreeModel::hasEmptyParsingData(const QModelIndex &index) const
|
|||||||
return item->hasEmptyParsingData();
|
return item->hasEmptyParsingData();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TreeModel::name(const QModelIndex &index) const
|
UString TreeModel::name(const UModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QString();
|
return UString();
|
||||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||||
return item->name();
|
return item->name();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TreeModel::text(const QModelIndex &index) const
|
UString TreeModel::text(const UModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QString();
|
return UString();
|
||||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||||
return item->text();
|
return item->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TreeModel::info(const QModelIndex &index) const
|
UString TreeModel::info(const UModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QString();
|
return UString();
|
||||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||||
return item->info();
|
return item->info();
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT8 TreeModel::action(const QModelIndex &index) const
|
UINT8 TreeModel::action(const UModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return Actions::NoAction;
|
return Actions::NoAction;
|
||||||
@ -241,7 +241,7 @@ UINT8 TreeModel::action(const QModelIndex &index) const
|
|||||||
return item->action();
|
return item->action();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TreeModel::fixed(const QModelIndex &index) const
|
bool TreeModel::fixed(const UModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return false;
|
return false;
|
||||||
@ -249,7 +249,7 @@ bool TreeModel::fixed(const QModelIndex &index) const
|
|||||||
return item->fixed();
|
return item->fixed();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TreeModel::compressed(const QModelIndex &index) const
|
bool TreeModel::compressed(const UModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return false;
|
return false;
|
||||||
@ -257,7 +257,7 @@ bool TreeModel::compressed(const QModelIndex &index) const
|
|||||||
return item->compressed();
|
return item->compressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TreeModel::setFixed(const QModelIndex &index, const bool fixed)
|
void TreeModel::setFixed(const UModelIndex &index, const bool fixed)
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
@ -281,7 +281,7 @@ void TreeModel::setFixed(const QModelIndex &index, const bool fixed)
|
|||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TreeModel::setCompressed(const QModelIndex &index, const bool compressed)
|
void TreeModel::setCompressed(const UModelIndex &index, const bool compressed)
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
@ -293,7 +293,7 @@ void TreeModel::setCompressed(const QModelIndex &index, const bool compressed)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TreeModel::setSubtype(const QModelIndex & index, const UINT8 subtype)
|
void TreeModel::setSubtype(const UModelIndex & index, const UINT8 subtype)
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
@ -303,7 +303,7 @@ void TreeModel::setSubtype(const QModelIndex & index, const UINT8 subtype)
|
|||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TreeModel::setName(const QModelIndex &index, const QString &data)
|
void TreeModel::setName(const UModelIndex &index, const UString &data)
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
@ -313,7 +313,7 @@ void TreeModel::setName(const QModelIndex &index, const QString &data)
|
|||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TreeModel::setType(const QModelIndex &index, const UINT8 data)
|
void TreeModel::setType(const UModelIndex &index, const UINT8 data)
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
@ -323,7 +323,7 @@ void TreeModel::setType(const QModelIndex &index, const UINT8 data)
|
|||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TreeModel::setText(const QModelIndex &index, const QString &data)
|
void TreeModel::setText(const UModelIndex &index, const UString &data)
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
@ -333,7 +333,7 @@ void TreeModel::setText(const QModelIndex &index, const QString &data)
|
|||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TreeModel::setInfo(const QModelIndex &index, const QString &data)
|
void TreeModel::setInfo(const UModelIndex &index, const UString &data)
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
@ -343,7 +343,7 @@ void TreeModel::setInfo(const QModelIndex &index, const QString &data)
|
|||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TreeModel::addInfo(const QModelIndex &index, const QString &data, const bool append)
|
void TreeModel::addInfo(const UModelIndex &index, const UString &data, const bool append)
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
@ -353,7 +353,7 @@ void TreeModel::addInfo(const QModelIndex &index, const QString &data, const boo
|
|||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TreeModel::setAction(const QModelIndex &index, const UINT8 action)
|
void TreeModel::setAction(const UModelIndex &index, const UINT8 action)
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
@ -363,7 +363,7 @@ void TreeModel::setAction(const QModelIndex &index, const UINT8 action)
|
|||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TreeModel::setParsingData(const QModelIndex &index, const QByteArray &data)
|
void TreeModel::setParsingData(const UModelIndex &index, const UByteArray &data)
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
@ -373,11 +373,11 @@ void TreeModel::setParsingData(const QModelIndex &index, const QByteArray &data)
|
|||||||
emit dataChanged(this->index(0, 0), index);
|
emit dataChanged(this->index(0, 0), index);
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex TreeModel::addItem(const UINT8 type, const UINT8 subtype,
|
UModelIndex TreeModel::addItem(const UINT8 type, const UINT8 subtype,
|
||||||
const QString & name, const QString & text, const QString & info,
|
const UString & name, const UString & text, const UString & info,
|
||||||
const QByteArray & header, const QByteArray & body, const QByteArray & tail,
|
const UByteArray & header, const UByteArray & body, const UByteArray & tail,
|
||||||
const bool fixed, const QByteArray & parsingData,
|
const bool fixed, const UByteArray & parsingData,
|
||||||
const QModelIndex & parent, const UINT8 mode)
|
const UModelIndex & parent, const UINT8 mode)
|
||||||
{
|
{
|
||||||
TreeItem *item = 0;
|
TreeItem *item = 0;
|
||||||
TreeItem *parentItem = 0;
|
TreeItem *parentItem = 0;
|
||||||
@ -418,23 +418,23 @@ QModelIndex TreeModel::addItem(const UINT8 type, const UINT8 subtype,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
delete newItem;
|
delete newItem;
|
||||||
return QModelIndex();
|
return UModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
emit layoutChanged();
|
emit layoutChanged();
|
||||||
|
|
||||||
QModelIndex created = createIndex(newItem->row(), parentColumn, newItem);
|
UModelIndex created = createIndex(newItem->row(), parentColumn, newItem);
|
||||||
setFixed(created, fixed); // Non-trivial logic requires additional call
|
setFixed(created, fixed); // Non-trivial logic requires additional call
|
||||||
return created;
|
return created;
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex TreeModel::findParentOfType(const QModelIndex& index, UINT8 type) const
|
UModelIndex TreeModel::findParentOfType(const UModelIndex& index, UINT8 type) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QModelIndex();
|
return UModelIndex();
|
||||||
|
|
||||||
TreeItem *item;
|
TreeItem *item;
|
||||||
QModelIndex parent = index;
|
UModelIndex parent = index;
|
||||||
|
|
||||||
for (item = static_cast<TreeItem*>(parent.internalPointer());
|
for (item = static_cast<TreeItem*>(parent.internalPointer());
|
||||||
item != NULL && item != rootItem && item->type() != type;
|
item != NULL && item != rootItem && item->type() != type;
|
||||||
@ -443,5 +443,5 @@ QModelIndex TreeModel::findParentOfType(const QModelIndex& index, UINT8 type) co
|
|||||||
if (item != NULL && item != rootItem)
|
if (item != NULL && item != rootItem)
|
||||||
return parent;
|
return parent;
|
||||||
|
|
||||||
return QModelIndex();
|
return UModelIndex();
|
||||||
}
|
}
|
@ -15,12 +15,14 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
#define TREEMODEL_H
|
#define TREEMODEL_H
|
||||||
|
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
#include <QModelIndex>
|
|
||||||
#include <QString>
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "ustring.h"
|
||||||
|
#include "ubytearray.h"
|
||||||
#include "basetypes.h"
|
#include "basetypes.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
#include "umodelindex.h"
|
||||||
|
|
||||||
class TreeItem;
|
class TreeItem;
|
||||||
|
|
||||||
@ -32,52 +34,52 @@ public:
|
|||||||
TreeModel(QObject *parent = 0);
|
TreeModel(QObject *parent = 0);
|
||||||
~TreeModel();
|
~TreeModel();
|
||||||
|
|
||||||
QVariant data(const QModelIndex &index, int role) const;
|
QVariant data(const UModelIndex &index, int role) const;
|
||||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
Qt::ItemFlags flags(const UModelIndex &index) const;
|
||||||
QVariant headerData(int section, Qt::Orientation orientation,
|
QVariant headerData(int section, Qt::Orientation orientation,
|
||||||
int role = Qt::DisplayRole) const;
|
int role = Qt::DisplayRole) const;
|
||||||
QModelIndex index(int row, int column,
|
UModelIndex index(int row, int column,
|
||||||
const QModelIndex &parent = QModelIndex()) const;
|
const UModelIndex &parent = UModelIndex()) const;
|
||||||
QModelIndex parent(const QModelIndex &index) const;
|
UModelIndex parent(const UModelIndex &index) const;
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
int rowCount(const UModelIndex &parent = UModelIndex()) const;
|
||||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
int columnCount(const UModelIndex &parent = UModelIndex()) const;
|
||||||
|
|
||||||
void setAction(const QModelIndex &index, const UINT8 action);
|
void setAction(const UModelIndex &index, const UINT8 action);
|
||||||
void setType(const QModelIndex &index, const UINT8 type);
|
void setType(const UModelIndex &index, const UINT8 type);
|
||||||
void setSubtype(const QModelIndex &index, const UINT8 subtype);
|
void setSubtype(const UModelIndex &index, const UINT8 subtype);
|
||||||
void setName(const QModelIndex &index, const QString &name);
|
void setName(const UModelIndex &index, const UString &name);
|
||||||
void setText(const QModelIndex &index, const QString &text);
|
void setText(const UModelIndex &index, const UString &text);
|
||||||
void setInfo(const QModelIndex &index, const QString &info);
|
void setInfo(const UModelIndex &index, const UString &info);
|
||||||
void addInfo(const QModelIndex &index, const QString &info, const bool append = TRUE);
|
void addInfo(const UModelIndex &index, const UString &info, const bool append = TRUE);
|
||||||
void setParsingData(const QModelIndex &index, const QByteArray &data);
|
void setParsingData(const UModelIndex &index, const UByteArray &data);
|
||||||
void setFixed(const QModelIndex &index, const bool fixed);
|
void setFixed(const UModelIndex &index, const bool fixed);
|
||||||
void setCompressed(const QModelIndex &index, const bool compressed);
|
void setCompressed(const UModelIndex &index, const bool compressed);
|
||||||
|
|
||||||
QString name(const QModelIndex &index) const;
|
UString name(const UModelIndex &index) const;
|
||||||
QString text(const QModelIndex &index) const;
|
UString text(const UModelIndex &index) const;
|
||||||
QString info(const QModelIndex &index) const;
|
UString info(const UModelIndex &index) const;
|
||||||
UINT8 type(const QModelIndex &index) const;
|
UINT8 type(const UModelIndex &index) const;
|
||||||
UINT8 subtype(const QModelIndex &index) const;
|
UINT8 subtype(const UModelIndex &index) const;
|
||||||
QByteArray header(const QModelIndex &index) const;
|
UByteArray header(const UModelIndex &index) const;
|
||||||
bool hasEmptyHeader(const QModelIndex &index) const;
|
bool hasEmptyHeader(const UModelIndex &index) const;
|
||||||
QByteArray body(const QModelIndex &index) const;
|
UByteArray body(const UModelIndex &index) const;
|
||||||
bool hasEmptyBody(const QModelIndex &index) const;
|
bool hasEmptyBody(const UModelIndex &index) const;
|
||||||
QByteArray tail(const QModelIndex &index) const;
|
UByteArray tail(const UModelIndex &index) const;
|
||||||
bool hasEmptyTail(const QModelIndex &index) const;
|
bool hasEmptyTail(const UModelIndex &index) const;
|
||||||
QByteArray parsingData(const QModelIndex &index) const;
|
UByteArray parsingData(const UModelIndex &index) const;
|
||||||
bool hasEmptyParsingData(const QModelIndex &index) const;
|
bool hasEmptyParsingData(const UModelIndex &index) const;
|
||||||
UINT8 action(const QModelIndex &index) const;
|
UINT8 action(const UModelIndex &index) const;
|
||||||
bool fixed(const QModelIndex &index) const;
|
bool fixed(const UModelIndex &index) const;
|
||||||
|
|
||||||
bool compressed(const QModelIndex &index) const;
|
bool compressed(const UModelIndex &index) const;
|
||||||
|
|
||||||
QModelIndex addItem(const UINT8 type, const UINT8 subtype,
|
UModelIndex addItem(const UINT8 type, const UINT8 subtype,
|
||||||
const QString & name, const QString & text, const QString & info,
|
const UString & name, const UString & text, const UString & info,
|
||||||
const QByteArray & header, const QByteArray & body, const QByteArray & tail,
|
const UByteArray & header, const UByteArray & body, const UByteArray & tail,
|
||||||
const bool fixed, const QByteArray & parsingData = QByteArray(),
|
const bool fixed, const UByteArray & parsingData = UByteArray(),
|
||||||
const QModelIndex & parent = QModelIndex(), const UINT8 mode = CREATE_MODE_APPEND);
|
const UModelIndex & parent = UModelIndex(), const UINT8 mode = CREATE_MODE_APPEND);
|
||||||
|
|
||||||
QModelIndex findParentOfType(const QModelIndex & index, UINT8 type) const;
|
UModelIndex findParentOfType(const UModelIndex & index, UINT8 type) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TreeItem *rootItem;
|
TreeItem *rootItem;
|
||||||
|
200
common/types.cpp
200
common/types.cpp
@ -10,62 +10,60 @@ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|||||||
WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QObject>
|
#include "ustring.h"
|
||||||
#include <QString>
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "ffs.h"
|
#include "ffs.h"
|
||||||
|
|
||||||
QString regionTypeToQString(const UINT8 type)
|
UString regionTypeToUString(const UINT8 type)
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case Subtypes::DescriptorRegion: return QObject::tr("Descriptor");
|
|
||||||
case Subtypes::BiosRegion: return QObject::tr("BIOS");
|
|
||||||
case Subtypes::MeRegion: return QObject::tr("ME");
|
|
||||||
case Subtypes::GbeRegion: return QObject::tr("GbE");
|
|
||||||
case Subtypes::PdrRegion: return QObject::tr("PDR");
|
|
||||||
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");
|
|
||||||
};
|
|
||||||
|
|
||||||
return QObject::tr("Unknown");
|
|
||||||
}
|
|
||||||
|
|
||||||
QString itemTypeToQString(const UINT8 type)
|
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Types::Root: return QObject::tr("Root");
|
case Subtypes::DescriptorRegion: return UString("Descriptor");
|
||||||
case Types::Image: return QObject::tr("Image");
|
case Subtypes::BiosRegion: return UString("BIOS");
|
||||||
case Types::Capsule: return QObject::tr("Capsule");
|
case Subtypes::MeRegion: return UString("ME");
|
||||||
case Types::Region: return QObject::tr("Region");
|
case Subtypes::GbeRegion: return UString("GbE");
|
||||||
case Types::Volume: return QObject::tr("Volume");
|
case Subtypes::PdrRegion: return UString("PDR");
|
||||||
case Types::Padding: return QObject::tr("Padding");
|
case Subtypes::Reserved1Region: return UString("Reserved1");
|
||||||
case Types::File: return QObject::tr("File");
|
case Subtypes::Reserved2Region: return UString("Reserved2");
|
||||||
case Types::Section: return QObject::tr("Section");
|
case Subtypes::Reserved3Region: return UString("Reserved3");
|
||||||
case Types::FreeSpace: return QObject::tr("Free space");
|
case Subtypes::EcRegion: return UString("EC");
|
||||||
case Types::VssStore: return QObject::tr("VSS store");
|
case Subtypes::Reserved4Region: return UString("Reserved4");
|
||||||
case Types::FtwStore: return QObject::tr("FTW store");
|
};
|
||||||
case Types::FdcStore: return QObject::tr("FDC store");
|
|
||||||
case Types::FsysStore: return QObject::tr("Fsys store");
|
|
||||||
case Types::EvsaStore: return QObject::tr("EVSA store");
|
|
||||||
case Types::CmdbStore: return QObject::tr("CMDB store");
|
|
||||||
case Types::FlashMapStore: return QObject::tr("FlashMap store");
|
|
||||||
case Types::NvarEntry: return QObject::tr("NVAR entry");
|
|
||||||
case Types::VssEntry: return QObject::tr("VSS entry");
|
|
||||||
case Types::FsysEntry: return QObject::tr("Fsys entry");
|
|
||||||
case Types::EvsaEntry: return QObject::tr("EVSA entry");
|
|
||||||
case Types::FlashMapEntry: return QObject::tr("FlashMap entry");
|
|
||||||
case Types::Microcode: return QObject::tr("Microcode");
|
|
||||||
case Types::SlicData: return QObject::tr("SLIC data");
|
|
||||||
}
|
|
||||||
|
|
||||||
return QObject::tr("Unknown");
|
return UString("Unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString itemSubtypeToQString(const UINT8 type, const UINT8 subtype)
|
UString itemTypeToUString(const UINT8 type)
|
||||||
|
{
|
||||||
|
switch (type) {
|
||||||
|
case Types::Root: return UString("Root");
|
||||||
|
case Types::Image: return UString("Image");
|
||||||
|
case Types::Capsule: return UString("Capsule");
|
||||||
|
case Types::Region: return UString("Region");
|
||||||
|
case Types::Volume: return UString("Volume");
|
||||||
|
case Types::Padding: return UString("Padding");
|
||||||
|
case Types::File: return UString("File");
|
||||||
|
case Types::Section: return UString("Section");
|
||||||
|
case Types::FreeSpace: return UString("Free space");
|
||||||
|
case Types::VssStore: return UString("VSS store");
|
||||||
|
case Types::FtwStore: return UString("FTW store");
|
||||||
|
case Types::FdcStore: return UString("FDC store");
|
||||||
|
case Types::FsysStore: return UString("Fsys store");
|
||||||
|
case Types::EvsaStore: return UString("EVSA store");
|
||||||
|
case Types::CmdbStore: return UString("CMDB store");
|
||||||
|
case Types::FlashMapStore: return UString("FlashMap store");
|
||||||
|
case Types::NvarEntry: return UString("NVAR entry");
|
||||||
|
case Types::VssEntry: return UString("VSS entry");
|
||||||
|
case Types::FsysEntry: return UString("Fsys entry");
|
||||||
|
case Types::EvsaEntry: return UString("EVSA entry");
|
||||||
|
case Types::FlashMapEntry: return UString("FlashMap entry");
|
||||||
|
case Types::Microcode: return UString("Microcode");
|
||||||
|
case Types::SlicData: return UString("SLIC data");
|
||||||
|
}
|
||||||
|
|
||||||
|
return UString("Unknown");
|
||||||
|
}
|
||||||
|
|
||||||
|
UString itemSubtypeToUString(const UINT8 type, const UINT8 subtype)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Types::Root:
|
case Types::Root:
|
||||||
@ -78,89 +76,89 @@ QString itemSubtypeToQString(const UINT8 type, const UINT8 subtype)
|
|||||||
case Types::FlashMapStore:
|
case Types::FlashMapStore:
|
||||||
case Types::CmdbStore:
|
case Types::CmdbStore:
|
||||||
case Types::FsysEntry:
|
case Types::FsysEntry:
|
||||||
case Types::SlicData: return QString();
|
case Types::SlicData: return UString();
|
||||||
case Types::Image:
|
case Types::Image:
|
||||||
if (subtype == Subtypes::IntelImage) return QObject::tr("Intel");
|
if (subtype == Subtypes::IntelImage) return UString("Intel");
|
||||||
if (subtype == Subtypes::UefiImage) return QObject::tr("UEFI");
|
if (subtype == Subtypes::UefiImage) return UString("UEFI");
|
||||||
break;
|
break;
|
||||||
case Types::Padding:
|
case Types::Padding:
|
||||||
if (subtype == Subtypes::ZeroPadding) return QObject::tr("Empty (0x00)");
|
if (subtype == Subtypes::ZeroPadding) return UString("Empty (0x00)");
|
||||||
if (subtype == Subtypes::OnePadding) return QObject::tr("Empty (0xFF)");
|
if (subtype == Subtypes::OnePadding) return UString("Empty (0xFF)");
|
||||||
if (subtype == Subtypes::DataPadding) return QObject::tr("Non-empty");
|
if (subtype == Subtypes::DataPadding) return UString("Non-empty");
|
||||||
break;
|
break;
|
||||||
case Types::Volume:
|
case Types::Volume:
|
||||||
if (subtype == Subtypes::UnknownVolume) return QObject::tr("Unknown");
|
if (subtype == Subtypes::UnknownVolume) return UString("Unknown");
|
||||||
if (subtype == Subtypes::Ffs2Volume) return QObject::tr("FFSv2");
|
if (subtype == Subtypes::Ffs2Volume) return UString("FFSv2");
|
||||||
if (subtype == Subtypes::Ffs3Volume) return QObject::tr("FFSv3");
|
if (subtype == Subtypes::Ffs3Volume) return UString("FFSv3");
|
||||||
if (subtype == Subtypes::NvramVolume) return QObject::tr("NVRAM");
|
if (subtype == Subtypes::NvramVolume) return UString("NVRAM");
|
||||||
break;
|
break;
|
||||||
case Types::Capsule:
|
case Types::Capsule:
|
||||||
if (subtype == Subtypes::AptioSignedCapsule) return QObject::tr("Aptio signed");
|
if (subtype == Subtypes::AptioSignedCapsule) return UString("Aptio signed");
|
||||||
if (subtype == Subtypes::AptioUnsignedCapsule) return QObject::tr("Aptio unsigned");
|
if (subtype == Subtypes::AptioUnsignedCapsule) return UString("Aptio unsigned");
|
||||||
if (subtype == Subtypes::UefiCapsule) return QObject::tr("UEFI 2.0");
|
if (subtype == Subtypes::UefiCapsule) return UString("UEFI 2.0");
|
||||||
if (subtype == Subtypes::ToshibaCapsule) return QObject::tr("Toshiba");
|
if (subtype == Subtypes::ToshibaCapsule) return UString("Toshiba");
|
||||||
break;
|
break;
|
||||||
case Types::Region: return regionTypeToQString(subtype);
|
case Types::Region: return regionTypeToUString(subtype);
|
||||||
case Types::File: return fileTypeToQString(subtype);
|
case Types::File: return fileTypeToUString(subtype);
|
||||||
case Types::Section: return sectionTypeToQString(subtype);
|
case Types::Section: return sectionTypeToUString(subtype);
|
||||||
case Types::NvarEntry:
|
case Types::NvarEntry:
|
||||||
if (subtype == Subtypes::InvalidNvarEntry) return QObject::tr("Invalid");
|
if (subtype == Subtypes::InvalidNvarEntry) return UString("Invalid");
|
||||||
if (subtype == Subtypes::InvalidLinkNvarEntry) return QObject::tr("Invalid link");
|
if (subtype == Subtypes::InvalidLinkNvarEntry) return UString("Invalid link");
|
||||||
if (subtype == Subtypes::LinkNvarEntry) return QObject::tr("Link");
|
if (subtype == Subtypes::LinkNvarEntry) return UString("Link");
|
||||||
if (subtype == Subtypes::DataNvarEntry) return QObject::tr("Data");
|
if (subtype == Subtypes::DataNvarEntry) return UString("Data");
|
||||||
if (subtype == Subtypes::FullNvarEntry) return QObject::tr("Full");
|
if (subtype == Subtypes::FullNvarEntry) return UString("Full");
|
||||||
break;
|
break;
|
||||||
case Types::VssEntry:
|
case Types::VssEntry:
|
||||||
if (subtype == Subtypes::InvalidVssEntry) return QObject::tr("Invalid");
|
if (subtype == Subtypes::InvalidVssEntry) return UString("Invalid");
|
||||||
if (subtype == Subtypes::StandardVssEntry) return QObject::tr("Standard");
|
if (subtype == Subtypes::StandardVssEntry) return UString("Standard");
|
||||||
if (subtype == Subtypes::AppleVssEntry) return QObject::tr("Apple");
|
if (subtype == Subtypes::AppleVssEntry) return UString("Apple");
|
||||||
if (subtype == Subtypes::AuthVssEntry) return QObject::tr("Auth");
|
if (subtype == Subtypes::AuthVssEntry) return UString("Auth");
|
||||||
break;
|
break;
|
||||||
case Types::EvsaEntry:
|
case Types::EvsaEntry:
|
||||||
if (subtype == Subtypes::InvalidEvsaEntry) return QObject::tr("Invalid");
|
if (subtype == Subtypes::InvalidEvsaEntry) return UString("Invalid");
|
||||||
if (subtype == Subtypes::UnknownEvsaEntry) return QObject::tr("Unknown");
|
if (subtype == Subtypes::UnknownEvsaEntry) return UString("Unknown");
|
||||||
if (subtype == Subtypes::GuidEvsaEntry) return QObject::tr("GUID");
|
if (subtype == Subtypes::GuidEvsaEntry) return UString("GUID");
|
||||||
if (subtype == Subtypes::NameEvsaEntry) return QObject::tr("Name");
|
if (subtype == Subtypes::NameEvsaEntry) return UString("Name");
|
||||||
if (subtype == Subtypes::DataEvsaEntry) return QObject::tr("Data");
|
if (subtype == Subtypes::DataEvsaEntry) return UString("Data");
|
||||||
break;
|
break;
|
||||||
case Types::FlashMapEntry:
|
case Types::FlashMapEntry:
|
||||||
if (subtype == Subtypes::VolumeFlashMapEntry) return QObject::tr("Volume");
|
if (subtype == Subtypes::VolumeFlashMapEntry) return UString("Volume");
|
||||||
if (subtype == Subtypes::DataFlashMapEntry) return QObject::tr("Data");
|
if (subtype == Subtypes::DataFlashMapEntry) return UString("Data");
|
||||||
break;
|
break;
|
||||||
case Types::Microcode:
|
case Types::Microcode:
|
||||||
if (subtype == Subtypes::IntelMicrocode) return QObject::tr("Intel");
|
if (subtype == Subtypes::IntelMicrocode) return UString("Intel");
|
||||||
if (subtype == Subtypes::AmdMicrocode) return QObject::tr("AMD");
|
if (subtype == Subtypes::AmdMicrocode) return UString("AMD");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QObject::tr("Unknown");
|
return UString("Unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString compressionTypeToQString(const UINT8 algorithm)
|
UString compressionTypeToUString(const UINT8 algorithm)
|
||||||
{
|
{
|
||||||
switch (algorithm) {
|
switch (algorithm) {
|
||||||
case COMPRESSION_ALGORITHM_NONE: return QObject::tr("None");
|
case COMPRESSION_ALGORITHM_NONE: return UString("None");
|
||||||
case COMPRESSION_ALGORITHM_EFI11: return QObject::tr("EFI 1.1");
|
case COMPRESSION_ALGORITHM_EFI11: return UString("EFI 1.1");
|
||||||
case COMPRESSION_ALGORITHM_TIANO: return QObject::tr("Tiano");
|
case COMPRESSION_ALGORITHM_TIANO: return UString("Tiano");
|
||||||
case COMPRESSION_ALGORITHM_UNDECIDED: return QObject::tr("Undecided Tiano/EFI 1.1");
|
case COMPRESSION_ALGORITHM_UNDECIDED: return UString("Undecided Tiano/EFI 1.1");
|
||||||
case COMPRESSION_ALGORITHM_LZMA: return QObject::tr("LZMA");
|
case COMPRESSION_ALGORITHM_LZMA: return UString("LZMA");
|
||||||
case COMPRESSION_ALGORITHM_IMLZMA: return QObject::tr("Intel modified LZMA");
|
case COMPRESSION_ALGORITHM_IMLZMA: return UString("Intel modified LZMA");
|
||||||
}
|
}
|
||||||
|
|
||||||
return QObject::tr("Unknown");
|
return UString("Unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString actionTypeToQString(const UINT8 action)
|
UString actionTypeToUString(const UINT8 action)
|
||||||
{
|
{
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case Actions::NoAction: return QString();
|
case Actions::NoAction: return UString();
|
||||||
case Actions::Create: return QObject::tr("Create");
|
case Actions::Create: return UString("Create");
|
||||||
case Actions::Insert: return QObject::tr("Insert");
|
case Actions::Insert: return UString("Insert");
|
||||||
case Actions::Replace: return QObject::tr("Replace");
|
case Actions::Replace: return UString("Replace");
|
||||||
case Actions::Remove: return QObject::tr("Remove");
|
case Actions::Remove: return UString("Remove");
|
||||||
case Actions::Rebuild: return QObject::tr("Rebuild");
|
case Actions::Rebuild: return UString("Rebuild");
|
||||||
case Actions::Rebase: return QObject::tr("Rebase");
|
case Actions::Rebase: return UString("Rebase");
|
||||||
}
|
}
|
||||||
|
|
||||||
return QObject::tr("Unknown");
|
return UString("Unknown");
|
||||||
}
|
}
|
@ -138,11 +138,11 @@ namespace Subtypes {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// *ToQString conversion routines
|
// *ToUString conversion routines
|
||||||
extern QString actionTypeToQString(const UINT8 action);
|
extern UString actionTypeToUString(const UINT8 action);
|
||||||
extern QString itemTypeToQString(const UINT8 type);
|
extern UString itemTypeToUString(const UINT8 type);
|
||||||
extern QString itemSubtypeToQString(const UINT8 type, const UINT8 subtype);
|
extern UString itemSubtypeToUString(const UINT8 type, const UINT8 subtype);
|
||||||
extern QString compressionTypeToQString(const UINT8 algorithm);
|
extern UString compressionTypeToUString(const UINT8 algorithm);
|
||||||
extern QString regionTypeToQString(const UINT8 type);
|
extern UString regionTypeToUString(const UINT8 type);
|
||||||
|
|
||||||
#endif // TYPES_H
|
#endif // TYPES_H
|
||||||
|
67
common/ubytearray.h
Normal file
67
common/ubytearray.h
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
/* ubytearray.h
|
||||||
|
|
||||||
|
Copyright (c) 2016, Nikolaj Schlej. All rights reserved.
|
||||||
|
This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef UBYTEARRAY_H
|
||||||
|
#define UBYTEARRAY_H
|
||||||
|
|
||||||
|
#ifdef QT_CORE_LIB
|
||||||
|
// Use Qt class, if Qt is available
|
||||||
|
#include <QByteArray>
|
||||||
|
#define UByteArray QByteArray
|
||||||
|
#else
|
||||||
|
// Use own implementation
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class UByteArray
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
UByteArray() : d() {}
|
||||||
|
UByteArray(const UByteArray & ba) : d(ba.d) {}
|
||||||
|
UByteArray(const std::basic_string<char> & bs) : d(bs) {}
|
||||||
|
UByteArray(const std::vector<char> & bc) : d(bc.data(), bc.size()) {}
|
||||||
|
UByteArray(const char* bytes, int32_t size) : d(bytes, size) {}
|
||||||
|
~UByteArray() {}
|
||||||
|
|
||||||
|
bool isEmpty() const { return d.length() == 0; }
|
||||||
|
|
||||||
|
char* data() { return &(d.front()); /* Feels dirty, but works for all basic_string implementations I know, is fully OK in C++11 and later*/ }
|
||||||
|
const char* data() const { return d.c_str(); }
|
||||||
|
const char* constData() const { return d.c_str(); }
|
||||||
|
void clear() { d.clear(); }
|
||||||
|
|
||||||
|
int32_t size() const { return d.size(); }
|
||||||
|
int32_t count(char ch) const { return std::count(d.cbegin(), d.cend(), ch); }
|
||||||
|
char at(uint32_t i) const { return d.at(i); }
|
||||||
|
char operator[](uint32_t i) const { return d[i]; }
|
||||||
|
char& operator[](uint32_t i) { return d[i]; }
|
||||||
|
|
||||||
|
bool startsWith(const UByteArray & ba) const { return 0 == d.find(ba.d, 0); }
|
||||||
|
int indexOf(const UByteArray & ba, int from = 0) const { return d.find(ba.d, from); }
|
||||||
|
int lastIndexOf(const UByteArray & ba, int from = 0) const { return d.rfind(ba.d, from); }
|
||||||
|
|
||||||
|
UByteArray left(int32_t len) const { return d.substr(0, len); }
|
||||||
|
UByteArray right(int32_t len) const { return d.substr(d.size() - 1 - len, len); };
|
||||||
|
UByteArray mid(int32_t pos, int32_t len = -1) const { return d.substr(pos, len); };
|
||||||
|
|
||||||
|
UByteArray &operator=(const UByteArray & ba) { d = ba.d; return *this; }
|
||||||
|
bool operator== (const UByteArray & ba) const { return d == ba.d; }
|
||||||
|
bool operator!= (const UByteArray & ba) const { return d != ba.d; }
|
||||||
|
inline void swap(UByteArray &other) { std::swap(d, other.d); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::basic_string<char> d;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // QT_CORE_LIB
|
||||||
|
#endif // UBYTEARRAY_H
|
23
common/umodelindex.h
Normal file
23
common/umodelindex.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/* umodelindex.h
|
||||||
|
|
||||||
|
Copyright (c) 2016, Nikolaj Schlej. All rights reserved.
|
||||||
|
This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef UMODELINDEX_H
|
||||||
|
#define UMODELINDEX_H
|
||||||
|
|
||||||
|
#ifdef QT_CORE_LIB
|
||||||
|
// Use Qt class, if Qt is available
|
||||||
|
#include <QModelIndex>
|
||||||
|
#define UModelIndex QModelIndex
|
||||||
|
#else
|
||||||
|
// Use own implementation
|
||||||
|
#endif // QT_CORE_LIB
|
||||||
|
#endif // UMODELINDEX_H
|
25
common/ustring.cpp
Normal file
25
common/ustring.cpp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/* ustring.cpp
|
||||||
|
|
||||||
|
Copyright (c) 2016, Nikolaj Schlej. All rights reserved.
|
||||||
|
This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ustring.h"
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
UString usprintf(const char* fmt, ...)
|
||||||
|
{
|
||||||
|
UString msg;
|
||||||
|
va_list vl;
|
||||||
|
va_start(vl, fmt);
|
||||||
|
msg = msg.vsprintf(fmt, vl);
|
||||||
|
va_end(vl);
|
||||||
|
return msg;
|
||||||
|
};
|
||||||
|
|
34
common/ustring.h
Normal file
34
common/ustring.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/* ustring.h
|
||||||
|
|
||||||
|
Copyright (c) 2016, Nikolaj Schlej. All rights reserved.
|
||||||
|
This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef USTRING_H
|
||||||
|
#define USTRING_H
|
||||||
|
|
||||||
|
//TODO: modify properly
|
||||||
|
|
||||||
|
#ifdef QT_CORE_LIB
|
||||||
|
// Use Qt class, if Qt is available
|
||||||
|
#include <QString>
|
||||||
|
#define UString QString
|
||||||
|
#else
|
||||||
|
// Use own implementation
|
||||||
|
#include "../bstrlib/bstrwrap.h"
|
||||||
|
class UString : public CBString {
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // QT_CORE_LIB
|
||||||
|
|
||||||
|
UString usprintf(const char* fmt, ...);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // USTRING_H
|
@ -10,7 +10,7 @@ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
#include <QObject>
|
|
||||||
#include "treemodel.h"
|
#include "treemodel.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
#include "ffs.h"
|
#include "ffs.h"
|
||||||
@ -20,7 +20,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
#include "LZMA/LzmaDecompress.h"
|
#include "LZMA/LzmaDecompress.h"
|
||||||
|
|
||||||
// Returns either new parsing data instance or obtains it from index
|
// Returns either new parsing data instance or obtains it from index
|
||||||
PARSING_DATA parsingDataFromQModelIndex(const QModelIndex & index)
|
PARSING_DATA parsingDataFromUModelIndex(const UModelIndex & index)
|
||||||
{
|
{
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
TreeModel* model = (TreeModel*)index.model();
|
TreeModel* model = (TreeModel*)index.model();
|
||||||
@ -39,64 +39,64 @@ PARSING_DATA parsingDataFromQModelIndex(const QModelIndex & index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Converts parsing data to byte array
|
// Converts parsing data to byte array
|
||||||
QByteArray parsingDataToQByteArray(const PARSING_DATA & pdata)
|
UByteArray parsingDataToUByteArray(const PARSING_DATA & pdata)
|
||||||
{
|
{
|
||||||
return QByteArray((const char*)&pdata, sizeof(PARSING_DATA));
|
return UByteArray((const char*)&pdata, sizeof(PARSING_DATA));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns text representation of error code
|
// Returns text representation of error code
|
||||||
QString errorCodeToQString(UINT8 errorCode)
|
UString errorCodeToUString(UINT8 errorCode)
|
||||||
{
|
{
|
||||||
switch (errorCode) {
|
switch (errorCode) {
|
||||||
case ERR_SUCCESS: return QObject::tr("Success");
|
case U_SUCCESS: return UString("Success");
|
||||||
case ERR_NOT_IMPLEMENTED: return QObject::tr("Not implemented");
|
case U_NOT_IMPLEMENTED: return UString("Not implemented");
|
||||||
case ERR_INVALID_PARAMETER: return QObject::tr("Function called with invalid parameter");
|
case U_INVALID_PARAMETER: return UString("Function called with invalid parameter");
|
||||||
case ERR_BUFFER_TOO_SMALL: return QObject::tr("Buffer too small");
|
case U_BUFFER_TOO_SMALL: return UString("Buffer too small");
|
||||||
case ERR_OUT_OF_RESOURCES: return QObject::tr("Out of resources");
|
case U_OUT_OF_RESOURCES: return UString("Out of resources");
|
||||||
case ERR_OUT_OF_MEMORY: return QObject::tr("Out of memory");
|
case U_OUT_OF_MEMORY: return UString("Out of memory");
|
||||||
case ERR_FILE_OPEN: return QObject::tr("File can't be opened");
|
case U_FILE_OPEN: return UString("File can't be opened");
|
||||||
case ERR_FILE_READ: return QObject::tr("File can't be read");
|
case U_FILE_READ: return UString("File can't be read");
|
||||||
case ERR_FILE_WRITE: return QObject::tr("File can't be written");
|
case U_FILE_WRITE: return UString("File can't be written");
|
||||||
case ERR_ITEM_NOT_FOUND: return QObject::tr("Item not found");
|
case U_ITEM_NOT_FOUND: return UString("Item not found");
|
||||||
case ERR_UNKNOWN_ITEM_TYPE: return QObject::tr("Unknown item type");
|
case U_UNKNOWN_ITEM_TYPE: return UString("Unknown item type");
|
||||||
case ERR_INVALID_FLASH_DESCRIPTOR: return QObject::tr("Invalid flash descriptor");
|
case U_INVALID_FLASH_DESCRIPTOR: return UString("Invalid flash descriptor");
|
||||||
case ERR_INVALID_REGION: return QObject::tr("Invalid region");
|
case U_INVALID_REGION: return UString("Invalid region");
|
||||||
case ERR_EMPTY_REGION: return QObject::tr("Empty region");
|
case U_EMPTY_REGION: return UString("Empty region");
|
||||||
case ERR_BIOS_REGION_NOT_FOUND: return QObject::tr("BIOS region not found");
|
case U_BIOS_REGION_NOT_FOUND: return UString("BIOS region not found");
|
||||||
case ERR_VOLUMES_NOT_FOUND: return QObject::tr("UEFI volumes not found");
|
case U_VOLUMES_NOT_FOUND: return UString("UEFI volumes not found");
|
||||||
case ERR_INVALID_VOLUME: return QObject::tr("Invalid UEFI volume");
|
case U_INVALID_VOLUME: return UString("Invalid UEFI volume");
|
||||||
case ERR_VOLUME_REVISION_NOT_SUPPORTED: return QObject::tr("Volume revision not supported");
|
case U_VOLUME_REVISION_NOT_SUPPORTED: return UString("Volume revision not supported");
|
||||||
//case ERR_VOLUME_GROW_FAILED: return QObject::tr("Volume grow failed");
|
//case U_VOLUME_GROW_FAILED: return UString("Volume grow failed");
|
||||||
case ERR_UNKNOWN_FFS: return QObject::tr("Unknown file system");
|
case U_UNKNOWN_FFS: return UString("Unknown file system");
|
||||||
case ERR_INVALID_FILE: return QObject::tr("Invalid file");
|
case U_INVALID_FILE: return UString("Invalid file");
|
||||||
case ERR_INVALID_SECTION: return QObject::tr("Invalid section");
|
case U_INVALID_SECTION: return UString("Invalid section");
|
||||||
case ERR_UNKNOWN_SECTION: return QObject::tr("Unknown section");
|
case U_UNKNOWN_SECTION: return UString("Unknown section");
|
||||||
case ERR_STANDARD_COMPRESSION_FAILED: return QObject::tr("Standard compression failed");
|
case U_STANDARD_COMPRESSION_FAILED: return UString("Standard compression failed");
|
||||||
case ERR_CUSTOMIZED_COMPRESSION_FAILED: return QObject::tr("Customized compression failed");
|
case U_CUSTOMIZED_COMPRESSION_FAILED: return UString("Customized compression failed");
|
||||||
case ERR_STANDARD_DECOMPRESSION_FAILED: return QObject::tr("Standard decompression failed");
|
case U_STANDARD_DECOMPRESSION_FAILED: return UString("Standard decompression failed");
|
||||||
case ERR_CUSTOMIZED_DECOMPRESSION_FAILED: return QObject::tr("Customized decompression failed");
|
case U_CUSTOMIZED_DECOMPRESSION_FAILED: return UString("Customized decompression failed");
|
||||||
case ERR_UNKNOWN_COMPRESSION_TYPE: return QObject::tr("Unknown compression type");
|
case U_UNKNOWN_COMPRESSION_TYPE: return UString("Unknown compression type");
|
||||||
case ERR_UNKNOWN_EXTRACT_MODE: return QObject::tr("Unknown extract mode");
|
case U_UNKNOWN_EXTRACT_MODE: return UString("Unknown extract mode");
|
||||||
case ERR_UNKNOWN_REPLACE_MODE: return QObject::tr("Unknown replace mode");
|
case U_UNKNOWN_REPLACE_MODE: return UString("Unknown replace mode");
|
||||||
//case ERR_UNKNOWN_INSERT_MODE: return QObject::tr("Unknown insert mode");
|
//case U_UNKNOWN_INSERT_MODE: return UString("Unknown insert mode");
|
||||||
case ERR_UNKNOWN_IMAGE_TYPE: return QObject::tr("Unknown executable image type");
|
case U_UNKNOWN_IMAGE_TYPE: return UString("Unknown executable image type");
|
||||||
case ERR_UNKNOWN_PE_OPTIONAL_HEADER_TYPE: return QObject::tr("Unknown PE optional header type");
|
case U_UNKNOWN_PE_OPTIONAL_HEADER_TYPE: return UString("Unknown PE optional header type");
|
||||||
case ERR_UNKNOWN_RELOCATION_TYPE: return QObject::tr("Unknown relocation type");
|
case U_UNKNOWN_RELOCATION_TYPE: return UString("Unknown relocation type");
|
||||||
//case ERR_GENERIC_CALL_NOT_SUPPORTED: return QObject::tr("Generic call not supported");
|
//case U_GENERIC_CALL_NOT_SUPPORTED: return UString("Generic call not supported");
|
||||||
//case ERR_VOLUME_BASE_NOT_FOUND: return QObject::tr("Volume base address not found");
|
//case U_VOLUME_BASE_NOT_FOUND: return UString("Volume base address not found");
|
||||||
//case ERR_PEI_CORE_ENTRY_POINT_NOT_FOUND: return QObject::tr("PEI core entry point not found");
|
//case U_PEI_CORE_ENTRY_POINT_NOT_FOUND: return UString("PEI core entry point not found");
|
||||||
case ERR_COMPLEX_BLOCK_MAP: return QObject::tr("Block map structure too complex for correct analysis");
|
case U_COMPLEX_BLOCK_MAP: return UString("Block map structure too complex for correct analysis");
|
||||||
case ERR_DIR_ALREADY_EXIST: return QObject::tr("Directory already exists");
|
case U_DIR_ALREADY_EXIST: return UString("Directory already exists");
|
||||||
case ERR_DIR_CREATE: return QObject::tr("Directory can't be created");
|
case U_DIR_CREATE: return UString("Directory can't be created");
|
||||||
//case ERR_UNKNOWN_PATCH_TYPE: return QObject::tr("Unknown patch type");
|
//case U_UNKNOWN_PATCH_TYPE: return UString("Unknown patch type");
|
||||||
//case ERR_PATCH_OFFSET_OUT_OF_BOUNDS: return QObject::tr("Patch offset out of bounds");
|
//case U_PATCH_OFFSET_OUT_OF_BOUNDS: return UString("Patch offset out of bounds");
|
||||||
//case ERR_INVALID_SYMBOL: return QObject::tr("Invalid symbol");
|
//case U_INVALID_SYMBOL: return UString("Invalid symbol");
|
||||||
//case ERR_NOTHING_TO_PATCH: return QObject::tr("Nothing to patch");
|
//case U_NOTHING_TO_PATCH: return UString("Nothing to patch");
|
||||||
case ERR_DEPEX_PARSE_FAILED: return QObject::tr("Dependency expression parsing failed");
|
case U_DEPEX_PARSE_FAILED: return UString("Dependency expression parsing failed");
|
||||||
case ERR_TRUNCATED_IMAGE: return QObject::tr("Image is truncated");
|
case U_TRUNCATED_IMAGE: return UString("Image is truncated");
|
||||||
case ERR_INVALID_CAPSULE: return QObject::tr("Invalid capsule");
|
case U_INVALID_CAPSULE: return UString("Invalid capsule");
|
||||||
case ERR_STORES_NOT_FOUND: return QObject::tr("Stores not found");
|
case U_STORES_NOT_FOUND: return UString("Stores not found");
|
||||||
default: return QObject::tr("Unknown error %1").arg(errorCode);
|
default: return usprintf("Unknown error %02X", errorCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ UINT32 crc32(UINT32 initial, const UINT8* buffer, const UINT32 length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Compression routines
|
// Compression routines
|
||||||
STATUS decompress(const QByteArray & compressedData, UINT8 & algorithm, QByteArray & decompressedData, QByteArray & efiDecompressedData)
|
USTATUS decompress(const UByteArray & compressedData, UINT8 & algorithm, UByteArray & decompressedData, UByteArray & efiDecompressedData)
|
||||||
{
|
{
|
||||||
const UINT8* data;
|
const UINT8* data;
|
||||||
UINT32 dataSize;
|
UINT32 dataSize;
|
||||||
@ -168,7 +168,7 @@ STATUS decompress(const QByteArray & compressedData, UINT8 & algorithm, QByteArr
|
|||||||
case EFI_NOT_COMPRESSED:
|
case EFI_NOT_COMPRESSED:
|
||||||
decompressedData = compressedData;
|
decompressedData = compressedData;
|
||||||
algorithm = COMPRESSION_ALGORITHM_NONE;
|
algorithm = COMPRESSION_ALGORITHM_NONE;
|
||||||
return ERR_SUCCESS;
|
return U_SUCCESS;
|
||||||
case EFI_STANDARD_COMPRESSION: {
|
case EFI_STANDARD_COMPRESSION: {
|
||||||
// Set default algorithm to unknown
|
// Set default algorithm to unknown
|
||||||
algorithm = COMPRESSION_ALGORITHM_UNKNOWN;
|
algorithm = COMPRESSION_ALGORITHM_UNKNOWN;
|
||||||
@ -180,11 +180,11 @@ STATUS decompress(const QByteArray & compressedData, UINT8 & algorithm, QByteArr
|
|||||||
// Check header to be valid
|
// Check header to be valid
|
||||||
header = (const EFI_TIANO_HEADER*)data;
|
header = (const EFI_TIANO_HEADER*)data;
|
||||||
if (header->CompSize + sizeof(EFI_TIANO_HEADER) != dataSize)
|
if (header->CompSize + sizeof(EFI_TIANO_HEADER) != dataSize)
|
||||||
return ERR_STANDARD_DECOMPRESSION_FAILED;
|
return U_STANDARD_DECOMPRESSION_FAILED;
|
||||||
|
|
||||||
// Get info function is the same for both algorithms
|
// Get info function is the same for both algorithms
|
||||||
if (ERR_SUCCESS != EfiTianoGetInfo(data, dataSize, &decompressedSize, &scratchSize))
|
if (U_SUCCESS != EfiTianoGetInfo(data, dataSize, &decompressedSize, &scratchSize))
|
||||||
return ERR_STANDARD_DECOMPRESSION_FAILED;
|
return U_STANDARD_DECOMPRESSION_FAILED;
|
||||||
|
|
||||||
// Allocate memory
|
// Allocate memory
|
||||||
decompressed = (UINT8*)malloc(decompressedSize);
|
decompressed = (UINT8*)malloc(decompressedSize);
|
||||||
@ -194,31 +194,31 @@ STATUS decompress(const QByteArray & compressedData, UINT8 & algorithm, QByteArr
|
|||||||
if (decompressed) free(decompressed);
|
if (decompressed) free(decompressed);
|
||||||
if (efiDecompressed) free(efiDecompressed);
|
if (efiDecompressed) free(efiDecompressed);
|
||||||
if (scratch) free(scratch);
|
if (scratch) free(scratch);
|
||||||
return ERR_STANDARD_DECOMPRESSION_FAILED;
|
return U_STANDARD_DECOMPRESSION_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decompress section data using both algorithms
|
// Decompress section data using both algorithms
|
||||||
STATUS result = ERR_SUCCESS;
|
USTATUS result = U_SUCCESS;
|
||||||
// Try Tiano
|
// Try Tiano
|
||||||
STATUS TianoResult = TianoDecompress(data, dataSize, decompressed, decompressedSize, scratch, scratchSize);
|
USTATUS TianoResult = TianoDecompress(data, dataSize, decompressed, decompressedSize, scratch, scratchSize);
|
||||||
// Try EFI 1.1
|
// Try EFI 1.1
|
||||||
STATUS EfiResult = EfiDecompress(data, dataSize, efiDecompressed, decompressedSize, scratch, scratchSize);
|
USTATUS EfiResult = EfiDecompress(data, dataSize, efiDecompressed, decompressedSize, scratch, scratchSize);
|
||||||
|
|
||||||
if (EfiResult == ERR_SUCCESS && TianoResult == ERR_SUCCESS) { // Both decompressions are OK
|
if (EfiResult == U_SUCCESS && TianoResult == U_SUCCESS) { // Both decompressions are OK
|
||||||
algorithm = COMPRESSION_ALGORITHM_UNDECIDED;
|
algorithm = COMPRESSION_ALGORITHM_UNDECIDED;
|
||||||
decompressedData = QByteArray((const char*)decompressed, decompressedSize);
|
decompressedData = UByteArray((const char*)decompressed, decompressedSize);
|
||||||
efiDecompressedData = QByteArray((const char*)efiDecompressed, decompressedSize);
|
efiDecompressedData = UByteArray((const char*)efiDecompressed, decompressedSize);
|
||||||
}
|
}
|
||||||
else if (TianoResult == ERR_SUCCESS) { // Only Tiano is OK
|
else if (TianoResult == U_SUCCESS) { // Only Tiano is OK
|
||||||
algorithm = COMPRESSION_ALGORITHM_TIANO;
|
algorithm = COMPRESSION_ALGORITHM_TIANO;
|
||||||
decompressedData = QByteArray((const char*)decompressed, decompressedSize);
|
decompressedData = UByteArray((const char*)decompressed, decompressedSize);
|
||||||
}
|
}
|
||||||
else if (EfiResult == ERR_SUCCESS) { // Only EFI 1.1 is OK
|
else if (EfiResult == U_SUCCESS) { // Only EFI 1.1 is OK
|
||||||
algorithm = COMPRESSION_ALGORITHM_EFI11;
|
algorithm = COMPRESSION_ALGORITHM_EFI11;
|
||||||
decompressedData = QByteArray((const char*)efiDecompressed, decompressedSize);
|
decompressedData = UByteArray((const char*)efiDecompressed, decompressedSize);
|
||||||
}
|
}
|
||||||
else { // Both decompressions failed
|
else { // Both decompressions failed
|
||||||
result = ERR_STANDARD_DECOMPRESSION_FAILED;
|
result = U_STANDARD_DECOMPRESSION_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(decompressed);
|
free(decompressed);
|
||||||
@ -235,47 +235,47 @@ STATUS decompress(const QByteArray & compressedData, UINT8 & algorithm, QByteArr
|
|||||||
dataSize = compressedData.size();
|
dataSize = compressedData.size();
|
||||||
|
|
||||||
// Get info
|
// Get info
|
||||||
if (ERR_SUCCESS != LzmaGetInfo(data, dataSize, &decompressedSize))
|
if (U_SUCCESS != LzmaGetInfo(data, dataSize, &decompressedSize))
|
||||||
return ERR_CUSTOMIZED_DECOMPRESSION_FAILED;
|
return U_CUSTOMIZED_DECOMPRESSION_FAILED;
|
||||||
|
|
||||||
// Allocate memory
|
// Allocate memory
|
||||||
decompressed = (UINT8*)malloc(decompressedSize);
|
decompressed = (UINT8*)malloc(decompressedSize);
|
||||||
if (!decompressed) {
|
if (!decompressed) {
|
||||||
return ERR_STANDARD_DECOMPRESSION_FAILED;
|
return U_STANDARD_DECOMPRESSION_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decompress section data
|
// Decompress section data
|
||||||
if (ERR_SUCCESS != LzmaDecompress(data, dataSize, decompressed)) {
|
if (U_SUCCESS != LzmaDecompress(data, dataSize, decompressed)) {
|
||||||
// Intel modified LZMA workaround
|
// Intel modified LZMA workaround
|
||||||
// Decompress section data once again
|
// Decompress section data once again
|
||||||
data += sizeof(UINT32);
|
data += sizeof(UINT32);
|
||||||
|
|
||||||
// Get info again
|
// Get info again
|
||||||
if (ERR_SUCCESS != LzmaGetInfo(data, dataSize, &decompressedSize)) {
|
if (U_SUCCESS != LzmaGetInfo(data, dataSize, &decompressedSize)) {
|
||||||
free(decompressed);
|
free(decompressed);
|
||||||
return ERR_CUSTOMIZED_DECOMPRESSION_FAILED;
|
return U_CUSTOMIZED_DECOMPRESSION_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decompress section data again
|
// Decompress section data again
|
||||||
if (ERR_SUCCESS != LzmaDecompress(data, dataSize, decompressed)) {
|
if (U_SUCCESS != LzmaDecompress(data, dataSize, decompressed)) {
|
||||||
free(decompressed);
|
free(decompressed);
|
||||||
return ERR_CUSTOMIZED_DECOMPRESSION_FAILED;
|
return U_CUSTOMIZED_DECOMPRESSION_FAILED;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
algorithm = COMPRESSION_ALGORITHM_IMLZMA;
|
algorithm = COMPRESSION_ALGORITHM_IMLZMA;
|
||||||
decompressedData = QByteArray((const char*)decompressed, decompressedSize);
|
decompressedData = UByteArray((const char*)decompressed, decompressedSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
algorithm = COMPRESSION_ALGORITHM_LZMA;
|
algorithm = COMPRESSION_ALGORITHM_LZMA;
|
||||||
decompressedData = QByteArray((const char*)decompressed, decompressedSize);
|
decompressedData = UByteArray((const char*)decompressed, decompressedSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(decompressed);
|
free(decompressed);
|
||||||
return ERR_SUCCESS;
|
return U_SUCCESS;
|
||||||
default:
|
default:
|
||||||
algorithm = COMPRESSION_ALGORITHM_UNKNOWN;
|
algorithm = COMPRESSION_ALGORITHM_UNKNOWN;
|
||||||
return ERR_UNKNOWN_COMPRESSION_TYPE;
|
return U_UNKNOWN_COMPRESSION_TYPE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,25 +14,25 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
#ifndef UTILITY_H
|
#ifndef UTILITY_H
|
||||||
#define UTILITY_H
|
#define UTILITY_H
|
||||||
|
|
||||||
#include <QString>
|
#include "ustring.h"
|
||||||
#include <QModelIndex>
|
#include "umodelindex.h"
|
||||||
#include "basetypes.h"
|
#include "basetypes.h"
|
||||||
#include "parsingdata.h"
|
#include "parsingdata.h"
|
||||||
|
|
||||||
// Returns either new parsing data instance or obtains it from index
|
// Returns either new parsing data instance or obtains it from index
|
||||||
PARSING_DATA parsingDataFromQModelIndex(const QModelIndex & index);
|
PARSING_DATA parsingDataFromUModelIndex(const UModelIndex & index);
|
||||||
|
|
||||||
// Converts parsing data to byte array
|
// Converts parsing data to byte array
|
||||||
QByteArray parsingDataToQByteArray(const PARSING_DATA & pdata);
|
UByteArray parsingDataToUByteArray(const PARSING_DATA & pdata);
|
||||||
|
|
||||||
// Converts error code to QString
|
// Converts error code to UString
|
||||||
extern QString errorCodeToQString(UINT8 errorCode);
|
extern UString errorCodeToUString(UINT8 errorCode);
|
||||||
|
|
||||||
// Decompression routine
|
// Decompression routine
|
||||||
extern STATUS decompress(const QByteArray & compressed, UINT8 & algorithm, QByteArray & decompressed, QByteArray & efiDecompressed);
|
extern USTATUS decompress(const UByteArray & compressed, UINT8 & algorithm, UByteArray & decompressed, UByteArray & efiDecompressed);
|
||||||
|
|
||||||
// Compression routine
|
// Compression routine
|
||||||
//STATUS compress(const QByteArray & decompressed, QByteArray & compressed, const UINT8 & algorithm);
|
//USTATUS compress(const UByteArray & decompressed, UByteArray & compressed, const UINT8 & algorithm);
|
||||||
|
|
||||||
// CRC32 calculation routine
|
// CRC32 calculation routine
|
||||||
extern UINT32 crc32(UINT32 initial, const UINT8* buffer, const UINT32 length);
|
extern UINT32 crc32(UINT32 initial, const UINT8* buffer, const UINT32 length);
|
||||||
|
Loading…
Reference in New Issue
Block a user