mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-22 07:58:22 +08:00
Merge pull request #279 from LongSoft/PR/make_format_strings_sane_again
Make format strings sane again
This commit is contained in:
commit
67c568daf8
@ -1,15 +1,15 @@
|
|||||||
/* fssfinder.cpp
|
/* fssfinder.cpp
|
||||||
|
|
||||||
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
|
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
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 "ffsfinder.h"
|
#include "ffsfinder.h"
|
||||||
|
|
||||||
@ -22,22 +22,22 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
USTATUS FfsFinder::findHexPattern(const UModelIndex & index, const UByteArray & hexPattern, const UINT8 mode)
|
USTATUS FfsFinder::findHexPattern(const UModelIndex & index, const UByteArray & hexPattern, const UINT8 mode)
|
||||||
{
|
{
|
||||||
//TODO: use FfsUtils.
|
//TODO: use FfsUtils.
|
||||||
|
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return U_SUCCESS;
|
return U_SUCCESS;
|
||||||
|
|
||||||
if (hexPattern.isEmpty())
|
if (hexPattern.isEmpty())
|
||||||
return U_INVALID_PARAMETER;
|
return U_INVALID_PARAMETER;
|
||||||
|
|
||||||
// Check for "all substrings" pattern
|
// Check for "all substrings" pattern
|
||||||
if (hexPattern.count('.') == hexPattern.length())
|
if (hexPattern.count('.') == hexPattern.length())
|
||||||
return U_SUCCESS;
|
return U_SUCCESS;
|
||||||
|
|
||||||
bool hasChildren = (model->rowCount(index) > 0);
|
bool hasChildren = (model->rowCount(index) > 0);
|
||||||
for (int i = 0; i < model->rowCount(index); i++) {
|
for (int i = 0; i < model->rowCount(index); i++) {
|
||||||
findHexPattern(index.model()->index(i, index.column(), index), hexPattern, mode);
|
findHexPattern(index.model()->index(i, index.column(), index), hexPattern, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
UByteArray data;
|
UByteArray data;
|
||||||
if (hasChildren) {
|
if (hasChildren) {
|
||||||
if (mode == SEARCH_MODE_HEADER)
|
if (mode == SEARCH_MODE_HEADER)
|
||||||
@ -53,177 +53,177 @@ USTATUS FfsFinder::findHexPattern(const UModelIndex & index, const UByteArray &
|
|||||||
else
|
else
|
||||||
data = model->header(index) + model->body(index);
|
data = model->header(index) + model->body(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
UString hexBody = UString(data.toHex());
|
UString hexBody = UString(data.toHex());
|
||||||
#if QT_VERSION_MAJOR >= 6
|
#if QT_VERSION_MAJOR >= 6
|
||||||
QRegularExpression regexp = QRegularExpression(UString(hexPattern));
|
QRegularExpression regexp = QRegularExpression(UString(hexPattern));
|
||||||
regexp.setPatternOptions((QRegularExpression::PatternOptions)0x1);
|
regexp.setPatternOptions((QRegularExpression::PatternOptions)0x1);
|
||||||
QRegularExpressionMatch regexpmatch;
|
QRegularExpressionMatch regexpmatch;
|
||||||
|
|
||||||
INT32 offset = 0;
|
INT32 offset = 0;
|
||||||
while ((offset = (INT32)hexBody.indexOf(regexp, (qsizetype)offset, ®expmatch)) != -1)
|
while ((offset = (INT32)hexBody.indexOf(regexp, (qsizetype)offset, ®expmatch)) != -1)
|
||||||
{
|
{
|
||||||
#else
|
#else
|
||||||
QRegExp regexp = QRegExp(UString(hexPattern), Qt::CaseInsensitive);
|
QRegExp regexp = QRegExp(UString(hexPattern), Qt::CaseInsensitive);
|
||||||
|
|
||||||
INT32 offset = regexp.indexIn(hexBody);
|
INT32 offset = regexp.indexIn(hexBody);
|
||||||
|
|
||||||
while (offset >= 0) {
|
while (offset >= 0) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (offset % 2 == 0) {
|
if (offset % 2 == 0) {
|
||||||
// For patterns that cross header|body boundary, skip patterns entirely located in body, since
|
// For patterns that cross header|body boundary, skip patterns entirely located in body, since
|
||||||
// children search above has already found them.
|
// children search above has already found them.
|
||||||
if (!(hasChildren && mode == SEARCH_MODE_ALL && offset/2 >= model->header(index).size())) {
|
if (!(hasChildren && mode == SEARCH_MODE_ALL && offset/2 >= model->header(index).size())) {
|
||||||
msg(UString("Hex pattern \"") + UString(hexPattern)
|
msg(UString("Hex pattern \"") + UString(hexPattern)
|
||||||
|
+ UString("\" found as \"") + hexBody.mid(offset, hexPattern.length()).toUpper()
|
||||||
|
+ UString("\" in ") + model->name(model->parent(index))
|
||||||
|
+ UString("/") + model->name(index)
|
||||||
|
+ usprintf(" at %s-offset %02Xh", mode == SEARCH_MODE_BODY ? "body" : "header", offset / 2),
|
||||||
|
index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if QT_VERSION_MAJOR >= 6
|
||||||
|
offset += 1;
|
||||||
|
#else
|
||||||
|
offset = regexp.indexIn(hexBody, offset + 1);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return U_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
USTATUS FfsFinder::findGuidPattern(const UModelIndex & index, const UByteArray & guidPattern, const UINT8 mode)
|
||||||
|
{
|
||||||
|
if (guidPattern.isEmpty())
|
||||||
|
return U_INVALID_PARAMETER;
|
||||||
|
|
||||||
|
if (!index.isValid())
|
||||||
|
return U_SUCCESS;
|
||||||
|
|
||||||
|
bool hasChildren = (model->rowCount(index) > 0);
|
||||||
|
for (int i = 0; i < model->rowCount(index); i++) {
|
||||||
|
findGuidPattern(index.model()->index(i, index.column(), index), guidPattern, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
UByteArray data;
|
||||||
|
if (hasChildren) {
|
||||||
|
if (mode != SEARCH_MODE_BODY)
|
||||||
|
data = model->header(index);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (mode == SEARCH_MODE_HEADER)
|
||||||
|
data.append(model->header(index));
|
||||||
|
else if (mode == SEARCH_MODE_BODY)
|
||||||
|
data.append(model->body(index));
|
||||||
|
else
|
||||||
|
data.append(model->header(index)).append(model->body(index));
|
||||||
|
}
|
||||||
|
|
||||||
|
UString hexBody = UString(data.toHex());
|
||||||
|
QList<UByteArray> list = guidPattern.split('-');
|
||||||
|
if (list.count() != 5)
|
||||||
|
return U_INVALID_PARAMETER;
|
||||||
|
|
||||||
|
UByteArray hexPattern;
|
||||||
|
// Reverse first GUID block
|
||||||
|
hexPattern.append(list.at(0).mid(6, 2));
|
||||||
|
hexPattern.append(list.at(0).mid(4, 2));
|
||||||
|
hexPattern.append(list.at(0).mid(2, 2));
|
||||||
|
hexPattern.append(list.at(0).mid(0, 2));
|
||||||
|
// Reverse second GUID block
|
||||||
|
hexPattern.append(list.at(1).mid(2, 2));
|
||||||
|
hexPattern.append(list.at(1).mid(0, 2));
|
||||||
|
// Reverse third GUID block
|
||||||
|
hexPattern.append(list.at(2).mid(2, 2));
|
||||||
|
hexPattern.append(list.at(2).mid(0, 2));
|
||||||
|
// Append fourth and fifth GUID blocks as is
|
||||||
|
hexPattern.append(list.at(3)).append(list.at(4));
|
||||||
|
|
||||||
|
// Check for "all substrings" pattern
|
||||||
|
if (hexPattern.count('.') == hexPattern.length())
|
||||||
|
return U_SUCCESS;
|
||||||
|
|
||||||
|
#if QT_VERSION_MAJOR >= 6
|
||||||
|
QRegularExpression regexp((QString)UString(hexPattern));
|
||||||
|
regexp.setPatternOptions((QRegularExpression::PatternOptions)0x1);
|
||||||
|
QRegularExpressionMatch regexpmatch;
|
||||||
|
|
||||||
|
INT32 offset = 0;
|
||||||
|
offset = (INT32)hexBody.indexOf(regexp, (qsizetype)offset, ®expmatch);
|
||||||
|
#else
|
||||||
|
QRegExp regexp(UString(hexPattern), Qt::CaseInsensitive);
|
||||||
|
|
||||||
|
INT32 offset = regexp.indexIn(hexBody);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
while (offset >= 0) {
|
||||||
|
if (offset % 2 == 0) {
|
||||||
|
msg(UString("GUID pattern \"") + UString(guidPattern)
|
||||||
+ UString("\" found as \"") + hexBody.mid(offset, hexPattern.length()).toUpper()
|
+ UString("\" found as \"") + hexBody.mid(offset, hexPattern.length()).toUpper()
|
||||||
+ UString("\" in ") + model->name(model->parent(index))
|
+ UString("\" in ") + model->name(model->parent(index))
|
||||||
+ UString("/") + model->name(index)
|
+ UString("/") + model->name(index)
|
||||||
+ usprintf(" at %s-offset %02Xh", mode == SEARCH_MODE_BODY ? "body" : "header", offset / 2),
|
+ usprintf(" at %s-offset %02Xh", mode == SEARCH_MODE_BODY ? "body" : "header", offset / 2),
|
||||||
index);
|
index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_VERSION_MAJOR >= 6
|
||||||
|
offset = (INT32)hexBody.indexOf(regexp, (qsizetype)offset + 1, ®expmatch);
|
||||||
|
#else
|
||||||
|
offset = regexp.indexIn(hexBody, offset + 1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QT_VERSION_MAJOR >= 6
|
|
||||||
offset += 1;
|
|
||||||
#else
|
|
||||||
offset = regexp.indexIn(hexBody, offset + 1);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
return U_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
USTATUS FfsFinder::findGuidPattern(const UModelIndex & index, const UByteArray & guidPattern, const UINT8 mode)
|
|
||||||
{
|
|
||||||
if (guidPattern.isEmpty())
|
|
||||||
return U_INVALID_PARAMETER;
|
|
||||||
|
|
||||||
if (!index.isValid())
|
|
||||||
return U_SUCCESS;
|
return U_SUCCESS;
|
||||||
|
|
||||||
bool hasChildren = (model->rowCount(index) > 0);
|
|
||||||
for (int i = 0; i < model->rowCount(index); i++) {
|
|
||||||
findGuidPattern(index.model()->index(i, index.column(), index), guidPattern, mode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UByteArray data;
|
USTATUS FfsFinder::findTextPattern(const UModelIndex & index, const UString & pattern, const UINT8 mode, const bool unicode, const Qt::CaseSensitivity caseSensitive)
|
||||||
if (hasChildren) {
|
{
|
||||||
if (mode != SEARCH_MODE_BODY)
|
if (pattern.isEmpty())
|
||||||
data = model->header(index);
|
return U_INVALID_PARAMETER;
|
||||||
}
|
|
||||||
else {
|
if (!index.isValid())
|
||||||
if (mode == SEARCH_MODE_HEADER)
|
return U_SUCCESS;
|
||||||
data.append(model->header(index));
|
|
||||||
else if (mode == SEARCH_MODE_BODY)
|
bool hasChildren = (model->rowCount(index) > 0);
|
||||||
data.append(model->body(index));
|
for (int i = 0; i < model->rowCount(index); i++) {
|
||||||
else
|
findTextPattern(index.model()->index(i, index.column(), index), pattern, mode, unicode, caseSensitive);
|
||||||
data.append(model->header(index)).append(model->body(index));
|
|
||||||
}
|
|
||||||
|
|
||||||
UString hexBody = UString(data.toHex());
|
|
||||||
QList<UByteArray> list = guidPattern.split('-');
|
|
||||||
if (list.count() != 5)
|
|
||||||
return U_INVALID_PARAMETER;
|
|
||||||
|
|
||||||
UByteArray hexPattern;
|
|
||||||
// Reverse first GUID block
|
|
||||||
hexPattern.append(list.at(0).mid(6, 2));
|
|
||||||
hexPattern.append(list.at(0).mid(4, 2));
|
|
||||||
hexPattern.append(list.at(0).mid(2, 2));
|
|
||||||
hexPattern.append(list.at(0).mid(0, 2));
|
|
||||||
// Reverse second GUID block
|
|
||||||
hexPattern.append(list.at(1).mid(2, 2));
|
|
||||||
hexPattern.append(list.at(1).mid(0, 2));
|
|
||||||
// Reverse third GUID block
|
|
||||||
hexPattern.append(list.at(2).mid(2, 2));
|
|
||||||
hexPattern.append(list.at(2).mid(0, 2));
|
|
||||||
// Append fourth and fifth GUID blocks as is
|
|
||||||
hexPattern.append(list.at(3)).append(list.at(4));
|
|
||||||
|
|
||||||
// Check for "all substrings" pattern
|
|
||||||
if (hexPattern.count('.') == hexPattern.length())
|
|
||||||
return U_SUCCESS;
|
|
||||||
|
|
||||||
#if QT_VERSION_MAJOR >= 6
|
|
||||||
QRegularExpression regexp((QString)UString(hexPattern));
|
|
||||||
regexp.setPatternOptions((QRegularExpression::PatternOptions)0x1);
|
|
||||||
QRegularExpressionMatch regexpmatch;
|
|
||||||
|
|
||||||
INT32 offset = 0;
|
|
||||||
offset = (INT32)hexBody.indexOf(regexp, (qsizetype)offset, ®expmatch);
|
|
||||||
#else
|
|
||||||
QRegExp regexp(UString(hexPattern), Qt::CaseInsensitive);
|
|
||||||
|
|
||||||
INT32 offset = regexp.indexIn(hexBody);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
while (offset >= 0) {
|
|
||||||
if (offset % 2 == 0) {
|
|
||||||
msg(UString("GUID pattern \"") + UString(guidPattern)
|
|
||||||
+ UString("\" found as \"") + hexBody.mid(offset, hexPattern.length()).toUpper()
|
|
||||||
+ UString("\" in ") + model->name(model->parent(index))
|
|
||||||
+ UString("/") + model->name(index)
|
|
||||||
+ usprintf(" at %s-offset %02Xh", mode == SEARCH_MODE_BODY ? "body" : "header", offset / 2),
|
|
||||||
index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UByteArray body;
|
||||||
|
if (hasChildren) {
|
||||||
|
if (mode != SEARCH_MODE_BODY)
|
||||||
|
body = model->header(index);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (mode == SEARCH_MODE_HEADER)
|
||||||
|
body.append(model->header(index));
|
||||||
|
else if (mode == SEARCH_MODE_BODY)
|
||||||
|
body.append(model->body(index));
|
||||||
|
else
|
||||||
|
body.append(model->header(index)).append(model->body(index));
|
||||||
|
}
|
||||||
|
|
||||||
|
UString data;
|
||||||
|
if (unicode)
|
||||||
#if QT_VERSION_MAJOR >= 6
|
#if QT_VERSION_MAJOR >= 6
|
||||||
offset = (INT32)hexBody.indexOf(regexp, (qsizetype)offset + 1, ®expmatch);
|
data = UString::fromUtf16((const char16_t*)body.constData(), (int)(body.length() / 2));
|
||||||
#else
|
|
||||||
offset = regexp.indexIn(hexBody, offset + 1);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
return U_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
USTATUS FfsFinder::findTextPattern(const UModelIndex & index, const UString & pattern, const UINT8 mode, const bool unicode, const Qt::CaseSensitivity caseSensitive)
|
|
||||||
{
|
|
||||||
if (pattern.isEmpty())
|
|
||||||
return U_INVALID_PARAMETER;
|
|
||||||
|
|
||||||
if (!index.isValid())
|
|
||||||
return U_SUCCESS;
|
|
||||||
|
|
||||||
bool hasChildren = (model->rowCount(index) > 0);
|
|
||||||
for (int i = 0; i < model->rowCount(index); i++) {
|
|
||||||
findTextPattern(index.model()->index(i, index.column(), index), pattern, mode, unicode, caseSensitive);
|
|
||||||
}
|
|
||||||
|
|
||||||
UByteArray body;
|
|
||||||
if (hasChildren) {
|
|
||||||
if (mode != SEARCH_MODE_BODY)
|
|
||||||
body = model->header(index);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (mode == SEARCH_MODE_HEADER)
|
|
||||||
body.append(model->header(index));
|
|
||||||
else if (mode == SEARCH_MODE_BODY)
|
|
||||||
body.append(model->body(index));
|
|
||||||
else
|
|
||||||
body.append(model->header(index)).append(model->body(index));
|
|
||||||
}
|
|
||||||
|
|
||||||
UString data;
|
|
||||||
if (unicode)
|
|
||||||
#if QT_VERSION_MAJOR >= 6
|
|
||||||
data = UString::fromUtf16((const char16_t*)body.constData(), (int)(body.length() / 2));
|
|
||||||
#else
|
#else
|
||||||
data = UString::fromUtf16((const ushort*)body.constData(), (int)(body.length() / 2));
|
data = UString::fromUtf16((const ushort*)body.constData(), (int)(body.length() / 2));
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
data = UString::fromLatin1((const char*)body.constData(), body.length());
|
data = UString::fromLatin1((const char*)body.constData(), body.length());
|
||||||
|
|
||||||
int offset = -1;
|
int offset = -1;
|
||||||
while ((offset = (int)data.indexOf(pattern, (int)(offset + 1), caseSensitive)) >= 0) {
|
while ((offset = (int)data.indexOf(pattern, (int)(offset + 1), caseSensitive)) >= 0) {
|
||||||
|
|
||||||
msg((unicode ? UString("Unicode") : UString("ASCII")) + UString(" text \"") + UString(pattern)
|
msg((unicode ? UString("Unicode") : UString("ASCII")) + UString(" text \"") + UString(pattern)
|
||||||
+ UString("\" in ") + model->name(model->parent(index))
|
+ UString("\" in ") + model->name(model->parent(index))
|
||||||
+ UString("/") + model->name(index)
|
+ UString("/") + model->name(index)
|
||||||
+ usprintf(" at %s-offset %02Xh", mode == SEARCH_MODE_BODY ? "body" : "header", (unicode ? offset * 2 : offset)),
|
+ usprintf(" at %s-offset %02Xh", mode == SEARCH_MODE_BODY ? "body" : "header", (unicode ? offset * 2 : offset)),
|
||||||
index);
|
index);
|
||||||
|
}
|
||||||
|
|
||||||
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return U_SUCCESS;
|
|
||||||
}
|
|
||||||
|
@ -1,25 +1,25 @@
|
|||||||
/* guidlineedit.cpp
|
/* guidlineedit.cpp
|
||||||
|
|
||||||
Copyright (c) 2014, Nikolaj Schlej. All rights reserved.
|
Copyright (c) 2014, Nikolaj Schlej. All rights reserved.
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
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 "guidlineedit.h"
|
#include "guidlineedit.h"
|
||||||
|
|
||||||
GuidLineEdit::GuidLineEdit(QWidget * parent)
|
GuidLineEdit::GuidLineEdit(QWidget * parent)
|
||||||
:QLineEdit(parent)
|
:QLineEdit(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
GuidLineEdit::GuidLineEdit(const QString & contents, QWidget * parent)
|
GuidLineEdit::GuidLineEdit(const QString & contents, QWidget * parent)
|
||||||
:QLineEdit(contents, parent)
|
:QLineEdit(contents, parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,23 +39,24 @@ void GuidLineEdit::keyPressEvent(QKeyEvent * event)
|
|||||||
|
|
||||||
QString txt = text();
|
QString txt = text();
|
||||||
QString selected = selectedText();
|
QString selected = selectedText();
|
||||||
|
|
||||||
if (!selected.isEmpty()) {
|
if (!selected.isEmpty()) {
|
||||||
pos = QLineEdit::selectionStart();
|
pos = QLineEdit::selectionStart();
|
||||||
for (int i = pos; i < pos + selected.count(); i++)
|
for (int i = pos; i < pos + selected.length(); i++)
|
||||||
if (txt[i] != QChar('-'))
|
if (txt[i] != QChar('-'))
|
||||||
txt[i] = QChar('.');
|
txt[i] = QChar('.');
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
txt[pos] = QChar('.');
|
txt[pos] = QChar('.');
|
||||||
|
}
|
||||||
|
|
||||||
setCursorPosition(0);
|
setCursorPosition(0);
|
||||||
insert(txt);
|
insert(txt);
|
||||||
setCursorPosition(pos);
|
setCursorPosition(pos);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call original event handler
|
// Call original event handler
|
||||||
QLineEdit::keyPressEvent(event);
|
QLineEdit::keyPressEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
/* hexspinbox.cpp
|
/* hexspinbox.cpp
|
||||||
|
|
||||||
Copyright (c) 2016, Nikolaj Schlej. All rights reserved.
|
Copyright (c) 2016, Nikolaj Schlej. All rights reserved.
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
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 "hexspinbox.h"
|
#include "hexspinbox.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
/* hexviewdialog.cpp
|
/* hexviewdialog.cpp
|
||||||
|
|
||||||
Copyright (c) 2016, Nikolaj Schlej. All rights reserved.
|
Copyright (c) 2016, Nikolaj Schlej. All rights reserved.
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
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 "hexviewdialog.h"
|
#include "hexviewdialog.h"
|
||||||
|
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
/* searchdialog.cpp
|
/* searchdialog.cpp
|
||||||
|
|
||||||
Copyright (c) 2014, Nikolaj Schlej. All rights reserved.
|
Copyright (c) 2014, Nikolaj Schlej. All rights reserved.
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
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 "searchdialog.h"
|
#include "searchdialog.h"
|
||||||
|
|
||||||
@ -28,10 +28,10 @@ guidValidator(QRegExp("[0-9a-fA-F\\.]{8}-[0-9a-fA-F\\.]{4}-[0-9a-fA-F\\.]{4}-[0-
|
|||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->hexEdit->setValidator(&hexValidator);
|
ui->hexEdit->setValidator(&hexValidator);
|
||||||
ui->guidEdit->setValidator(&guidValidator);
|
ui->guidEdit->setValidator(&guidValidator);
|
||||||
|
|
||||||
// Connect
|
// Connect
|
||||||
connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(setEditFocus(int)));
|
connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(setEditFocus(int)));
|
||||||
|
|
||||||
// Set initial focus
|
// Set initial focus
|
||||||
setEditFocus(ui->tabWidget->currentIndex());
|
setEditFocus(ui->tabWidget->currentIndex());
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,15 +1,15 @@
|
|||||||
/* uefitool_main.cpp
|
/* uefitool_main.cpp
|
||||||
|
|
||||||
Copyright (c) 2018, LongSoft. All rights reserved.
|
Copyright (c) 2018, LongSoft. All rights reserved.
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
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 <QApplication>
|
#include <QApplication>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@ -18,10 +18,10 @@
|
|||||||
class UEFIToolApplication : public QApplication
|
class UEFIToolApplication : public QApplication
|
||||||
{
|
{
|
||||||
UEFITool* tool;
|
UEFITool* tool;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UEFIToolApplication(int &argc, char **argv)
|
UEFIToolApplication(int &argc, char **argv)
|
||||||
: QApplication(argc, argv)
|
: QApplication(argc, argv)
|
||||||
{
|
{
|
||||||
setOrganizationName("LongSoft");
|
setOrganizationName("LongSoft");
|
||||||
setOrganizationDomain("longsoft.org");
|
setOrganizationDomain("longsoft.org");
|
||||||
@ -40,7 +40,7 @@ public:
|
|||||||
QFileOpenEvent *openEvent = static_cast<QFileOpenEvent *>(event);
|
QFileOpenEvent *openEvent = static_cast<QFileOpenEvent *>(event);
|
||||||
tool->openImageFile(openEvent->file());
|
tool->openImageFile(openEvent->file());
|
||||||
}
|
}
|
||||||
|
|
||||||
return QApplication::event(event);
|
return QApplication::event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
/* descriptor.cpp
|
/* descriptor.cpp
|
||||||
|
|
||||||
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
|
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
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 "descriptor.h"
|
#include "descriptor.h"
|
||||||
|
|
||||||
@ -44,207 +44,207 @@ UString jedecIdToUString(UINT8 vendorId, UINT8 deviceId0, UINT8 deviceId1)
|
|||||||
{
|
{
|
||||||
UINT32 jedecId = (UINT32)deviceId1 + ((UINT32)deviceId0 << 8) + ((UINT32)vendorId << 16);
|
UINT32 jedecId = (UINT32)deviceId1 + ((UINT32)deviceId0 << 8) + ((UINT32)vendorId << 16);
|
||||||
switch (jedecId) {
|
switch (jedecId) {
|
||||||
// Winbond
|
// Winbond
|
||||||
case 0xEF3010: return UString("Winbond W25X05");
|
case 0xEF3010: return UString("Winbond W25X05");
|
||||||
case 0xEF3011: return UString("Winbond W25X10");
|
case 0xEF3011: return UString("Winbond W25X10");
|
||||||
case 0xEF3012: return UString("Winbond W25X20");
|
case 0xEF3012: return UString("Winbond W25X20");
|
||||||
case 0xEF3013: return UString("Winbond W25X40");
|
case 0xEF3013: return UString("Winbond W25X40");
|
||||||
case 0xEF3014: return UString("Winbond W25X80");
|
case 0xEF3014: return UString("Winbond W25X80");
|
||||||
case 0xEF3015: return UString("Winbond W25X16");
|
case 0xEF3015: return UString("Winbond W25X16");
|
||||||
case 0xEF3016: return UString("Winbond W25X32");
|
case 0xEF3016: return UString("Winbond W25X32");
|
||||||
case 0xEF3017: return UString("Winbond W25X64");
|
case 0xEF3017: return UString("Winbond W25X64");
|
||||||
case 0xEF4012: return UString("Winbond W25Q20");
|
case 0xEF4012: return UString("Winbond W25Q20");
|
||||||
case 0xEF4013: return UString("Winbond W25Q40");
|
case 0xEF4013: return UString("Winbond W25Q40");
|
||||||
case 0xEF4014: return UString("Winbond W25Q80");
|
case 0xEF4014: return UString("Winbond W25Q80");
|
||||||
case 0xEF4015: return UString("Winbond W25Q16");
|
case 0xEF4015: return UString("Winbond W25Q16");
|
||||||
case 0xEF4016: return UString("Winbond W25Q32");
|
case 0xEF4016: return UString("Winbond W25Q32");
|
||||||
case 0xEF4017: return UString("Winbond W25Q64");
|
case 0xEF4017: return UString("Winbond W25Q64");
|
||||||
case 0xEF4018: return UString("Winbond W25Q128");
|
case 0xEF4018: return UString("Winbond W25Q128");
|
||||||
case 0xEF4019: return UString("Winbond W25Q256");
|
case 0xEF4019: return UString("Winbond W25Q256");
|
||||||
case 0xEF6011: return UString("Winbond W25Q10");
|
case 0xEF6011: return UString("Winbond W25Q10");
|
||||||
case 0xEF6012: return UString("Winbond W25Q20");
|
case 0xEF6012: return UString("Winbond W25Q20");
|
||||||
case 0xEF6013: return UString("Winbond W25Q40");
|
case 0xEF6013: return UString("Winbond W25Q40");
|
||||||
case 0xEF6014: return UString("Winbond W25Q80");
|
case 0xEF6014: return UString("Winbond W25Q80");
|
||||||
case 0xEF6015: return UString("Winbond W25Q16");
|
case 0xEF6015: return UString("Winbond W25Q16");
|
||||||
case 0xEF6016: return UString("Winbond W25Q32");
|
case 0xEF6016: return UString("Winbond W25Q32");
|
||||||
case 0xEF6017: return UString("Winbond W25Q64");
|
case 0xEF6017: return UString("Winbond W25Q64");
|
||||||
case 0xEF6018: return UString("Winbond W25Q128");
|
case 0xEF6018: return UString("Winbond W25Q128");
|
||||||
case 0xEF6019: return UString("Winbond W25Q256");
|
case 0xEF6019: return UString("Winbond W25Q256");
|
||||||
case 0xEF7118: return UString("Winbond W25M256");
|
case 0xEF7118: return UString("Winbond W25M256");
|
||||||
case 0xEF7119: return UString("Winbond W25M512");
|
case 0xEF7119: return UString("Winbond W25M512");
|
||||||
|
|
||||||
// Macronix
|
// Macronix
|
||||||
case 0xC22013: return UString("Macronix MX25L40");
|
case 0xC22013: return UString("Macronix MX25L40");
|
||||||
case 0xC22014: return UString("Macronix MX25L80");
|
case 0xC22014: return UString("Macronix MX25L80");
|
||||||
case 0xC22015: return UString("Macronix MX25L16");
|
case 0xC22015: return UString("Macronix MX25L16");
|
||||||
case 0xC22016: return UString("Macronix MX25U16");
|
case 0xC22016: return UString("Macronix MX25U16");
|
||||||
case 0xC22017: return UString("Macronix MX25L64");
|
case 0xC22017: return UString("Macronix MX25L64");
|
||||||
case 0xC22018: return UString("Macronix MX25L128");
|
case 0xC22018: return UString("Macronix MX25L128");
|
||||||
case 0xC22019: return UString("Macronix MX25L256");
|
case 0xC22019: return UString("Macronix MX25L256");
|
||||||
case 0xC2201A: return UString("Macronix MX66L512");
|
case 0xC2201A: return UString("Macronix MX66L512");
|
||||||
case 0xC22415: return UString("Macronix MX25L16");
|
case 0xC22415: return UString("Macronix MX25L16");
|
||||||
case 0xC22515: return UString("Macronix MX25L16");
|
case 0xC22515: return UString("Macronix MX25L16");
|
||||||
case 0xC22534: return UString("Macronix MX25U80");
|
case 0xC22534: return UString("Macronix MX25U80");
|
||||||
case 0xC22535: return UString("Macronix MX25U16");
|
case 0xC22535: return UString("Macronix MX25U16");
|
||||||
case 0xC22536: return UString("Macronix MX25U32");
|
case 0xC22536: return UString("Macronix MX25U32");
|
||||||
case 0xC22537: return UString("Macronix MX25U64");
|
case 0xC22537: return UString("Macronix MX25U64");
|
||||||
case 0xC22538: return UString("Macronix MX25U128");
|
case 0xC22538: return UString("Macronix MX25U128");
|
||||||
case 0xC22539: return UString("Macronix MX25U256");
|
case 0xC22539: return UString("Macronix MX25U256");
|
||||||
case 0xC2253A: return UString("Macronix MX25U512");
|
case 0xC2253A: return UString("Macronix MX25U512");
|
||||||
case 0xC22617: return UString("Macronix MX25L64");
|
case 0xC22617: return UString("Macronix MX25L64");
|
||||||
case 0xC22618: return UString("Macronix MX25L128");
|
case 0xC22618: return UString("Macronix MX25L128");
|
||||||
case 0xC25E16: return UString("Macronix MX25L32");
|
case 0xC25E16: return UString("Macronix MX25L32");
|
||||||
case 0xC29517: return UString("Macronix MX25L64");
|
case 0xC29517: return UString("Macronix MX25L64");
|
||||||
|
|
||||||
// Micron
|
// Micron
|
||||||
case 0x202014: return UString("Micron M25P80");
|
case 0x202014: return UString("Micron M25P80");
|
||||||
case 0x202015: return UString("Micron M25P16");
|
case 0x202015: return UString("Micron M25P16");
|
||||||
case 0x202016: return UString("Micron M25P32");
|
case 0x202016: return UString("Micron M25P32");
|
||||||
case 0x202017: return UString("Micron M25P64");
|
case 0x202017: return UString("Micron M25P64");
|
||||||
case 0x202018: return UString("Micron M25P128");
|
case 0x202018: return UString("Micron M25P128");
|
||||||
case 0x204011: return UString("Micron M45PE10");
|
case 0x204011: return UString("Micron M45PE10");
|
||||||
case 0x204012: return UString("Micron M45PE20");
|
case 0x204012: return UString("Micron M45PE20");
|
||||||
case 0x204013: return UString("Micron M45PE40");
|
case 0x204013: return UString("Micron M45PE40");
|
||||||
case 0x204014: return UString("Micron M45PE80");
|
case 0x204014: return UString("Micron M45PE80");
|
||||||
case 0x204015: return UString("Micron M45PE16");
|
case 0x204015: return UString("Micron M45PE16");
|
||||||
case 0x204017: return UString("Micron XM25QH64C");
|
case 0x204017: return UString("Micron XM25QH64C");
|
||||||
case 0x204018: return UString("Micron XM25QH128C");
|
case 0x204018: return UString("Micron XM25QH128C");
|
||||||
case 0x204019: return UString("Micron XM25QH256C");
|
case 0x204019: return UString("Micron XM25QH256C");
|
||||||
case 0x207114: return UString("Micron M25PX80");
|
case 0x207114: return UString("Micron M25PX80");
|
||||||
case 0x207115: return UString("Micron M25PX16");
|
case 0x207115: return UString("Micron M25PX16");
|
||||||
case 0x207116: return UString("Micron M25PX32");
|
case 0x207116: return UString("Micron M25PX32");
|
||||||
case 0x207117: return UString("Micron M25PX64");
|
case 0x207117: return UString("Micron M25PX64");
|
||||||
case 0x208011: return UString("Micron M25PE10");
|
case 0x208011: return UString("Micron M25PE10");
|
||||||
case 0x208012: return UString("Micron M25PE20");
|
case 0x208012: return UString("Micron M25PE20");
|
||||||
case 0x208013: return UString("Micron M25PE40");
|
case 0x208013: return UString("Micron M25PE40");
|
||||||
case 0x208014: return UString("Micron M25PE80");
|
case 0x208014: return UString("Micron M25PE80");
|
||||||
case 0x208015: return UString("Micron M25PE16");
|
case 0x208015: return UString("Micron M25PE16");
|
||||||
case 0x20BA15: return UString("Micron N25Q016");
|
case 0x20BA15: return UString("Micron N25Q016");
|
||||||
case 0x20BA16: return UString("Micron N25Q032");
|
case 0x20BA16: return UString("Micron N25Q032");
|
||||||
case 0x20BA17: return UString("Micron N25Q064");
|
case 0x20BA17: return UString("Micron N25Q064");
|
||||||
case 0x20BA18: return UString("Micron N25Q128");
|
case 0x20BA18: return UString("Micron N25Q128");
|
||||||
case 0x20BA19: return UString("Micron N25Q256");
|
case 0x20BA19: return UString("Micron N25Q256");
|
||||||
case 0x20BA20: return UString("Micron N25Q512");
|
case 0x20BA20: return UString("Micron N25Q512");
|
||||||
case 0x20BA21: return UString("Micron N25Q00A");
|
case 0x20BA21: return UString("Micron N25Q00A");
|
||||||
case 0x20BB15: return UString("Micron N25Q016");
|
case 0x20BB15: return UString("Micron N25Q016");
|
||||||
case 0x20BB16: return UString("Micron N25Q032");
|
case 0x20BB16: return UString("Micron N25Q032");
|
||||||
case 0x20BB17: return UString("Micron N25Q064");
|
case 0x20BB17: return UString("Micron N25Q064");
|
||||||
case 0x20BB18: return UString("Micron MT25Q128");
|
case 0x20BB18: return UString("Micron MT25Q128");
|
||||||
case 0x20BB19: return UString("Micron MT25Q256");
|
case 0x20BB19: return UString("Micron MT25Q256");
|
||||||
case 0x20BB20: return UString("Micron MT25Q512");
|
case 0x20BB20: return UString("Micron MT25Q512");
|
||||||
|
|
||||||
// Intel
|
// Intel
|
||||||
case 0x898911: return UString("Intel 25F160S33B8");
|
case 0x898911: return UString("Intel 25F160S33B8");
|
||||||
case 0x898912: return UString("Intel 25F320S33B8");
|
case 0x898912: return UString("Intel 25F320S33B8");
|
||||||
case 0x898913: return UString("Intel 25F640S33B8");
|
case 0x898913: return UString("Intel 25F640S33B8");
|
||||||
case 0x898915: return UString("Intel 25F160S33T8");
|
case 0x898915: return UString("Intel 25F160S33T8");
|
||||||
case 0x898916: return UString("Intel 25F320S33T8");
|
case 0x898916: return UString("Intel 25F320S33T8");
|
||||||
case 0x898917: return UString("Intel 25F640S33T8");
|
case 0x898917: return UString("Intel 25F640S33T8");
|
||||||
|
|
||||||
// Atmel / Adesto
|
// Atmel / Adesto
|
||||||
case 0x1F3217: return UString("Atmel AT25SF641");
|
case 0x1F3217: return UString("Atmel AT25SF641");
|
||||||
case 0x1F4216: return UString("Atmel AT25SL321");
|
case 0x1F4216: return UString("Atmel AT25SL321");
|
||||||
case 0x1F4218: return UString("Atmel AT25SL128A");
|
case 0x1F4218: return UString("Atmel AT25SL128A");
|
||||||
case 0x1F4317: return UString("Atmel AT25SL641");
|
case 0x1F4317: return UString("Atmel AT25SL641");
|
||||||
case 0x1F4500: return UString("Atmel AT26DF081");
|
case 0x1F4500: return UString("Atmel AT26DF081");
|
||||||
case 0x1F4501: return UString("Atmel AT26DF081A");
|
case 0x1F4501: return UString("Atmel AT26DF081A");
|
||||||
case 0x1F4502: return UString("Atmel AT25DF081");
|
case 0x1F4502: return UString("Atmel AT25DF081");
|
||||||
case 0x1F4600: return UString("Atmel AT26DF161");
|
case 0x1F4600: return UString("Atmel AT26DF161");
|
||||||
case 0x1F4601: return UString("Atmel AT26DF161A");
|
case 0x1F4601: return UString("Atmel AT26DF161A");
|
||||||
case 0x1F4602: return UString("Atmel AT25DF161");
|
case 0x1F4602: return UString("Atmel AT25DF161");
|
||||||
case 0x1F4700: return UString("Atmel AT25DF321");
|
case 0x1F4700: return UString("Atmel AT25DF321");
|
||||||
case 0x1F4701: return UString("Atmel AT25DF321A");
|
case 0x1F4701: return UString("Atmel AT25DF321A");
|
||||||
case 0x1F4800: return UString("Atmel AT25DF641");
|
case 0x1F4800: return UString("Atmel AT25DF641");
|
||||||
case 0x1F7018: return UString("Atmel AT25QF128");
|
case 0x1F7018: return UString("Atmel AT25QF128");
|
||||||
case 0x1F8600: return UString("Atmel AT25DQ161");
|
case 0x1F8600: return UString("Atmel AT25DQ161");
|
||||||
case 0x1F8800: return UString("Atmel AT25DQ641");
|
case 0x1F8800: return UString("Atmel AT25DQ641");
|
||||||
|
|
||||||
// Microchip
|
// Microchip
|
||||||
case 0xBF2541: return UString("Microchip SST25VF016B");
|
case 0xBF2541: return UString("Microchip SST25VF016B");
|
||||||
case 0xBF254A: return UString("Microchip SST25VF032B");
|
case 0xBF254A: return UString("Microchip SST25VF032B");
|
||||||
case 0xBF258D: return UString("Microchip SST25VF040B");
|
case 0xBF258D: return UString("Microchip SST25VF040B");
|
||||||
case 0xBF258E: return UString("Microchip SST25VF080B");
|
case 0xBF258E: return UString("Microchip SST25VF080B");
|
||||||
case 0xBF254B: return UString("Microchip SST25VF064C");
|
case 0xBF254B: return UString("Microchip SST25VF064C");
|
||||||
|
|
||||||
// EON / ESMT
|
// EON / ESMT
|
||||||
case 0x1C3013: return UString("EON EN25Q40");
|
case 0x1C3013: return UString("EON EN25Q40");
|
||||||
case 0x1C3014: return UString("EON EN25Q80");
|
case 0x1C3014: return UString("EON EN25Q80");
|
||||||
case 0x1C3015: return UString("EON EN25Q16");
|
case 0x1C3015: return UString("EON EN25Q16");
|
||||||
case 0x1C3016: return UString("EON EN25Q32");
|
case 0x1C3016: return UString("EON EN25Q32");
|
||||||
case 0x1C3017: return UString("EON EN25Q64");
|
case 0x1C3017: return UString("EON EN25Q64");
|
||||||
case 0x1C3018: return UString("EON EN25Q128");
|
case 0x1C3018: return UString("EON EN25Q128");
|
||||||
case 0x1C3114: return UString("EON EN25F80");
|
case 0x1C3114: return UString("EON EN25F80");
|
||||||
case 0x1C3115: return UString("EON EN25F16");
|
case 0x1C3115: return UString("EON EN25F16");
|
||||||
case 0x1C3116: return UString("EON EN25F32");
|
case 0x1C3116: return UString("EON EN25F32");
|
||||||
case 0x1C3117: return UString("EON EN25F64");
|
case 0x1C3117: return UString("EON EN25F64");
|
||||||
case 0x1C3811: return UString("EON EN25S10");
|
case 0x1C3811: return UString("EON EN25S10");
|
||||||
case 0x1C3812: return UString("EON EN25S20");
|
case 0x1C3812: return UString("EON EN25S20");
|
||||||
case 0x1C3813: return UString("EON EN25S40");
|
case 0x1C3813: return UString("EON EN25S40");
|
||||||
case 0x1C3814: return UString("EON EN25S80");
|
case 0x1C3814: return UString("EON EN25S80");
|
||||||
case 0x1C3815: return UString("EON EN25S16");
|
case 0x1C3815: return UString("EON EN25S16");
|
||||||
case 0x1C3816: return UString("EON EN25S32");
|
case 0x1C3816: return UString("EON EN25S32");
|
||||||
case 0x1C3817: return UString("EON EN25S64");
|
case 0x1C3817: return UString("EON EN25S64");
|
||||||
case 0x1C7014: return UString("EON EN25QH80");
|
case 0x1C7014: return UString("EON EN25QH80");
|
||||||
case 0x1C7015: return UString("EON EN25QH16");
|
case 0x1C7015: return UString("EON EN25QH16");
|
||||||
case 0x1C7016: return UString("EON EN25QH32");
|
case 0x1C7016: return UString("EON EN25QH32");
|
||||||
case 0x1C7017: return UString("EON EN25QH64");
|
case 0x1C7017: return UString("EON EN25QH64");
|
||||||
case 0x1C7018: return UString("EON EN25QH128");
|
case 0x1C7018: return UString("EON EN25QH128");
|
||||||
case 0x1C7019: return UString("EON EN25QH256");
|
case 0x1C7019: return UString("EON EN25QH256");
|
||||||
|
|
||||||
// GigaDevice
|
// GigaDevice
|
||||||
case 0xC84014: return UString("GigaDevice GD25x80");
|
case 0xC84014: return UString("GigaDevice GD25x80");
|
||||||
case 0xC84015: return UString("GigaDevice GD25x16");
|
case 0xC84015: return UString("GigaDevice GD25x16");
|
||||||
case 0xC84016: return UString("GigaDevice GD25x32");
|
case 0xC84016: return UString("GigaDevice GD25x32");
|
||||||
case 0xC84017: return UString("GigaDevice GD25x64");
|
case 0xC84017: return UString("GigaDevice GD25x64");
|
||||||
case 0xC84018: return UString("GigaDevice GD25x128");
|
case 0xC84018: return UString("GigaDevice GD25x128");
|
||||||
case 0xC84019: return UString("GigaDevice GD25x256C");
|
case 0xC84019: return UString("GigaDevice GD25x256C");
|
||||||
case 0xC86015: return UString("GigaDevice GD25LQ16V");
|
case 0xC86015: return UString("GigaDevice GD25LQ16V");
|
||||||
case 0xC86017: return UString("GigaDevice GD25Lx64");
|
case 0xC86017: return UString("GigaDevice GD25Lx64");
|
||||||
case 0xC86018: return UString("GigaDevice GD25Lx128");
|
case 0xC86018: return UString("GigaDevice GD25Lx128");
|
||||||
case 0xC86019: return UString("GigaDevice GD25LQ256C");
|
case 0xC86019: return UString("GigaDevice GD25LQ256C");
|
||||||
|
|
||||||
// Fidelix
|
// Fidelix
|
||||||
case 0xF83215: return UString("Fidelix FM25Q16");
|
case 0xF83215: return UString("Fidelix FM25Q16");
|
||||||
case 0xF83216: return UString("Fidelix FM25Q32");
|
case 0xF83216: return UString("Fidelix FM25Q32");
|
||||||
case 0xF83217: return UString("Fidelix FM25Q64");
|
case 0xF83217: return UString("Fidelix FM25Q64");
|
||||||
case 0xF83218: return UString("Fidelix FM25Q128");
|
case 0xF83218: return UString("Fidelix FM25Q128");
|
||||||
|
|
||||||
// Spansion
|
// Spansion
|
||||||
case 0x014015: return UString("Spansion S25FL116K");
|
case 0x014015: return UString("Spansion S25FL116K");
|
||||||
case 0x014016: return UString("Spansion S25FL132K");
|
case 0x014016: return UString("Spansion S25FL132K");
|
||||||
case 0x014017: return UString("Spansion S25FL164K");
|
case 0x014017: return UString("Spansion S25FL164K");
|
||||||
|
|
||||||
// AMIC Technology
|
// AMIC Technology
|
||||||
case 0x373015: return UString("AMIC A25L016");
|
case 0x373015: return UString("AMIC A25L016");
|
||||||
case 0x373016: return UString("AMIC A25L032");
|
case 0x373016: return UString("AMIC A25L032");
|
||||||
case 0x374015: return UString("AMIC A25LQ16");
|
case 0x374015: return UString("AMIC A25LQ16");
|
||||||
case 0x374016: return UString("AMIC A25LQ32A");
|
case 0x374016: return UString("AMIC A25LQ32A");
|
||||||
|
|
||||||
// PMC
|
// PMC
|
||||||
case 0x9DF713: return UString("PMC Pm25LV080B");
|
case 0x9DF713: return UString("PMC Pm25LV080B");
|
||||||
case 0x9DF714: return UString("PMC Pm25LV016B");
|
case 0x9DF714: return UString("PMC Pm25LV016B");
|
||||||
case 0x9DF744: return UString("PMC Pm25LQ080C");
|
case 0x9DF744: return UString("PMC Pm25LQ080C");
|
||||||
case 0x9DF745: return UString("PMC Pm25LQ016C");
|
case 0x9DF745: return UString("PMC Pm25LQ016C");
|
||||||
case 0x9DF746: return UString("PMC Pm25LQ032C");
|
case 0x9DF746: return UString("PMC Pm25LQ032C");
|
||||||
case 0x9DF77B: return UString("PMC Pm25LV512A");
|
case 0x9DF77B: return UString("PMC Pm25LV512A");
|
||||||
case 0x9DF77C: return UString("PMC Pm25LV010A");
|
case 0x9DF77C: return UString("PMC Pm25LV010A");
|
||||||
case 0x9DF77D: return UString("PMC Pm25LV020");
|
case 0x9DF77D: return UString("PMC Pm25LV020");
|
||||||
case 0x9DF77E: return UString("PMC Pm25LV040");
|
case 0x9DF77E: return UString("PMC Pm25LV040");
|
||||||
|
|
||||||
// ISSI
|
// ISSI
|
||||||
case 0x9D6014: return UString("ISSI Ix25LP080");
|
case 0x9D6014: return UString("ISSI Ix25LP080");
|
||||||
case 0x9D6015: return UString("ISSI Ix25LP016");
|
case 0x9D6015: return UString("ISSI Ix25LP016");
|
||||||
case 0x9D6016: return UString("ISSI Ix25LP032");
|
case 0x9D6016: return UString("ISSI Ix25LP032");
|
||||||
case 0x9D6017: return UString("ISSI Ix25LP064");
|
case 0x9D6017: return UString("ISSI Ix25LP064");
|
||||||
case 0x9D6018: return UString("ISSI Ix25LP128");
|
case 0x9D6018: return UString("ISSI Ix25LP128");
|
||||||
case 0x9D6019: return UString("ISSI Ix25LP256");
|
case 0x9D6019: return UString("ISSI Ix25LP256");
|
||||||
case 0x9D7014: return UString("ISSI Ix25WP080");
|
case 0x9D7014: return UString("ISSI Ix25WP080");
|
||||||
case 0x9D7015: return UString("ISSI Ix25WP016");
|
case 0x9D7015: return UString("ISSI Ix25WP016");
|
||||||
case 0x9D7016: return UString("ISSI Ix25WP032");
|
case 0x9D7016: return UString("ISSI Ix25WP032");
|
||||||
case 0x9D7017: return UString("ISSI Ix25WP064");
|
case 0x9D7017: return UString("ISSI Ix25WP064");
|
||||||
case 0x9D7018: return UString("ISSI Ix25WP128");
|
case 0x9D7018: return UString("ISSI Ix25WP128");
|
||||||
case 0x9D7019: return UString("ISSI Ix25WP256");
|
case 0x9D7019: return UString("ISSI Ix25WP256");
|
||||||
}
|
}
|
||||||
|
|
||||||
return UString("Unknown");
|
return UString("Unknown");
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
/* ffs.cpp
|
/* ffs.cpp
|
||||||
|
|
||||||
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
|
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
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 <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
@ -58,19 +58,19 @@ UString guidToUString(const EFI_GUID & guid, bool convertToString)
|
|||||||
if (!readableName.isEmpty())
|
if (!readableName.isEmpty())
|
||||||
return readableName;
|
return readableName;
|
||||||
}
|
}
|
||||||
|
|
||||||
return usprintf("%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
|
return usprintf("%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
|
||||||
guid.Data1,
|
guid.Data1,
|
||||||
guid.Data2,
|
guid.Data2,
|
||||||
guid.Data3,
|
guid.Data3,
|
||||||
guid.Data4[0],
|
guid.Data4[0],
|
||||||
guid.Data4[1],
|
guid.Data4[1],
|
||||||
guid.Data4[2],
|
guid.Data4[2],
|
||||||
guid.Data4[3],
|
guid.Data4[3],
|
||||||
guid.Data4[4],
|
guid.Data4[4],
|
||||||
guid.Data4[5],
|
guid.Data4[5],
|
||||||
guid.Data4[6],
|
guid.Data4[6],
|
||||||
guid.Data4[7]);
|
guid.Data4[7]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -78,12 +78,12 @@ bool ustringToGuid(const UString & str, EFI_GUID & guid)
|
|||||||
{
|
{
|
||||||
unsigned long p0;
|
unsigned long p0;
|
||||||
unsigned p1, p2, p3, p4, p5, p6, p7, p8, p9, p10;
|
unsigned p1, p2, p3, p4, p5, p6, p7, p8, p9, p10;
|
||||||
|
|
||||||
int err = std::sscanf(str.toLocal8Bit(), "%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
|
int err = std::sscanf(str.toLocal8Bit(), "%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
|
||||||
&p0, &p1, &p2, &p3, &p4, &p5, &p6, &p7, &p8, &p9, &p10);
|
&p0, &p1, &p2, &p3, &p4, &p5, &p6, &p7, &p8, &p9, &p10);
|
||||||
if (err == 0)
|
if (err == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
guid.Data1 = (UINT32)p0;
|
guid.Data1 = (UINT32)p0;
|
||||||
guid.Data2 = (UINT16)p1;
|
guid.Data2 = (UINT16)p1;
|
||||||
guid.Data3 = (UINT16)p2;
|
guid.Data3 = (UINT16)p2;
|
||||||
@ -95,7 +95,7 @@ bool ustringToGuid(const UString & str, EFI_GUID & guid)
|
|||||||
guid.Data4[5] = (UINT8)p8;
|
guid.Data4[5] = (UINT8)p8;
|
||||||
guid.Data4[6] = (UINT8)p9;
|
guid.Data4[6] = (UINT8)p9;
|
||||||
guid.Data4[7] = (UINT8)p10;
|
guid.Data4[7] = (UINT8)p10;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
/* fssbuilder.cpp
|
/* fssbuilder.cpp
|
||||||
|
|
||||||
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
|
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
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 "ffsbuilder.h"
|
#include "ffsbuilder.h"
|
||||||
|
|
||||||
#include "descriptor.h"
|
#include "descriptor.h"
|
||||||
@ -25,7 +25,7 @@ USTATUS FfsBuilder::erase(const UModelIndex & index, UByteArray & erased)
|
|||||||
// Sanity check
|
// Sanity check
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return U_INVALID_PARAMETER;
|
return U_INVALID_PARAMETER;
|
||||||
|
|
||||||
// Try to get emptyByte value from item's parsing data
|
// Try to get emptyByte value from item's parsing data
|
||||||
UINT8 emptyByte = 0xFF;
|
UINT8 emptyByte = 0xFF;
|
||||||
if (!model->hasEmptyParsingData(index)) {
|
if (!model->hasEmptyParsingData(index)) {
|
||||||
@ -38,9 +38,9 @@ USTATUS FfsBuilder::erase(const UModelIndex & index, UByteArray & erased)
|
|||||||
emptyByte = pdata.emptyByte;
|
emptyByte = pdata.emptyByte;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
erased = UByteArray(model->header(index).size() + model->body(index).size() + model->tail(index).size(), emptyByte);
|
erased = UByteArray(model->header(index).size() + model->body(index).size() + model->tail(index).size(), emptyByte);
|
||||||
|
|
||||||
return U_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ USTATUS FfsBuilder::build(const UModelIndex & root, UByteArray & image)
|
|||||||
// Sanity check
|
// Sanity check
|
||||||
if (!root.isValid())
|
if (!root.isValid())
|
||||||
return U_INVALID_PARAMETER;
|
return U_INVALID_PARAMETER;
|
||||||
|
|
||||||
if (model->type(root) == Types::Capsule) {
|
if (model->type(root) == Types::Capsule) {
|
||||||
return buildCapsule(root, image);
|
return buildCapsule(root, image);
|
||||||
}
|
}
|
||||||
@ -61,7 +61,7 @@ USTATUS FfsBuilder::build(const UModelIndex & root, UByteArray & image)
|
|||||||
return buildRawArea(root, image);
|
return buildRawArea(root, image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return U_NOT_IMPLEMENTED;
|
return U_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,27 +70,27 @@ USTATUS FfsBuilder::buildCapsule(const UModelIndex & index, UByteArray & capsule
|
|||||||
// Sanity check
|
// Sanity check
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return U_INVALID_PARAMETER;
|
return U_INVALID_PARAMETER;
|
||||||
|
|
||||||
// No action
|
// No action
|
||||||
if (model->action(index) == Actions::NoAction) {
|
if (model->action(index) == Actions::NoAction) {
|
||||||
// Use original item data
|
// Use original item data
|
||||||
capsule = model->header(index) + model->body(index) + model->tail(index);
|
capsule = model->header(index) + model->body(index) + model->tail(index);
|
||||||
return U_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rebuild or Replace
|
// Rebuild or Replace
|
||||||
else if (model->action(index) == Actions::Rebuild
|
else if (model->action(index) == Actions::Rebuild
|
||||||
|| model->action(index) == Actions::Replace) {
|
|| model->action(index) == Actions::Replace) {
|
||||||
if (model->rowCount(index)) {
|
if (model->rowCount(index)) {
|
||||||
// Clear the supplied UByteArray
|
// Clear the supplied UByteArray
|
||||||
capsule.clear();
|
capsule.clear();
|
||||||
|
|
||||||
// Right now there is only one capsule image element supported
|
// Right now there is only one capsule image element supported
|
||||||
if (model->rowCount(index) != 1) {
|
if (model->rowCount(index) != 1) {
|
||||||
msg(usprintf("buildCapsule: building of capsules with %d items is not yet supported", model->rowCount(index)), index);
|
msg(usprintf("buildCapsule: building of capsules with %d items is not yet supported", model->rowCount(index)), index);
|
||||||
return U_NOT_IMPLEMENTED;
|
return U_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build image
|
// Build image
|
||||||
UModelIndex imageIndex = index.model()->index(0, 0, index);
|
UModelIndex imageIndex = index.model()->index(0, 0, index);
|
||||||
UByteArray imageData;
|
UByteArray imageData;
|
||||||
@ -136,12 +136,12 @@ USTATUS FfsBuilder::buildCapsule(const UModelIndex & index, UByteArray & capsule
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
capsule = model->body(index);
|
capsule = model->body(index);
|
||||||
|
|
||||||
// Build successful, append header and tail
|
// Build successful, append header and tail
|
||||||
capsule = model->header(index) + capsule + model->tail(index);
|
capsule = model->header(index) + capsule + model->tail(index);
|
||||||
return U_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg(UString("buildCapsule: unexpected action " + actionTypeToUString(model->action(index))), index);
|
msg(UString("buildCapsule: unexpected action " + actionTypeToUString(model->action(index))), index);
|
||||||
return U_NOT_IMPLEMENTED;
|
return U_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
@ -166,15 +166,15 @@ USTATUS FfsBuilder::buildIntelImage(const UModelIndex & index, UByteArray & inte
|
|||||||
else if (model->action(index) == Actions::Rebuild) {
|
else if (model->action(index) == Actions::Rebuild) {
|
||||||
// First child will always be descriptor for this type of image, and it's read only for now
|
// First child will always be descriptor for this type of image, and it's read only for now
|
||||||
intelImage = model->header(index.model()->index(0, 0, index)) + model->body(index.model()->index(0, 0, index)) + model->tail(index.model()->index(0, 0, index));
|
intelImage = model->header(index.model()->index(0, 0, index)) + model->body(index.model()->index(0, 0, index)) + model->tail(index.model()->index(0, 0, index));
|
||||||
|
|
||||||
// Process other regions
|
// Process other regions
|
||||||
for (int i = 1; i < model->rowCount(index); i++) {
|
for (int i = 1; i < model->rowCount(index); i++) {
|
||||||
UModelIndex currentRegion = index.model()->index(i, 0, index);
|
UModelIndex currentRegion = index.model()->index(i, 0, index);
|
||||||
|
|
||||||
// Skip regions with Remove action
|
// Skip regions with Remove action
|
||||||
if (model->action(currentRegion) == Actions::Remove)
|
if (model->action(currentRegion) == Actions::Remove)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Check item type to be either region or padding
|
// Check item type to be either region or padding
|
||||||
UINT8 type = model->type(currentRegion);
|
UINT8 type = model->type(currentRegion);
|
||||||
if (type == Types::Padding) {
|
if (type == Types::Padding) {
|
||||||
@ -182,41 +182,41 @@ USTATUS FfsBuilder::buildIntelImage(const UModelIndex & index, UByteArray & inte
|
|||||||
intelImage += model->header(currentRegion) + model->body(currentRegion) + model->tail(currentRegion);
|
intelImage += model->header(currentRegion) + model->body(currentRegion) + model->tail(currentRegion);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check region subtype
|
// Check region subtype
|
||||||
USTATUS result;
|
USTATUS result;
|
||||||
UByteArray region;
|
UByteArray region;
|
||||||
UINT8 regionType = model->subtype(currentRegion);
|
UINT8 regionType = model->subtype(currentRegion);
|
||||||
switch (regionType) {
|
switch (regionType) {
|
||||||
case Subtypes::BiosRegion:
|
case Subtypes::BiosRegion:
|
||||||
case Subtypes::PdrRegion:
|
case Subtypes::PdrRegion:
|
||||||
result = buildRawArea(currentRegion, region);
|
result = buildRawArea(currentRegion, region);
|
||||||
if (result) {
|
if (result) {
|
||||||
msg(UString("buildIntelImage: building of region ") + regionTypeToUString(regionType) + UString(" failed with error ") + errorCodeToUString(result), currentRegion);
|
msg(UString("buildIntelImage: building of region ") + regionTypeToUString(regionType) + UString(" failed with error ") + errorCodeToUString(result), currentRegion);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Subtypes::MeRegion:
|
case Subtypes::MeRegion:
|
||||||
case Subtypes::GbeRegion:
|
case Subtypes::GbeRegion:
|
||||||
case Subtypes::DevExp1Region:
|
case Subtypes::DevExp1Region:
|
||||||
case Subtypes::Bios2Region:
|
case Subtypes::Bios2Region:
|
||||||
case Subtypes::MicrocodeRegion:
|
case Subtypes::MicrocodeRegion:
|
||||||
case Subtypes::EcRegion:
|
case Subtypes::EcRegion:
|
||||||
case Subtypes::DevExp2Region:
|
case Subtypes::DevExp2Region:
|
||||||
case Subtypes::IeRegion:
|
case Subtypes::IeRegion:
|
||||||
case Subtypes::Tgbe1Region:
|
case Subtypes::Tgbe1Region:
|
||||||
case Subtypes::Tgbe2Region:
|
case Subtypes::Tgbe2Region:
|
||||||
case Subtypes::Reserved1Region:
|
case Subtypes::Reserved1Region:
|
||||||
case Subtypes::Reserved2Region:
|
case Subtypes::Reserved2Region:
|
||||||
case Subtypes::PttRegion:
|
case Subtypes::PttRegion:
|
||||||
// Add region as is
|
// Add region as is
|
||||||
region = model->header(currentRegion) + model->body(currentRegion);
|
region = model->header(currentRegion) + model->body(currentRegion);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
msg(UString("buildIntelImage: unknown region type"), currentRegion);
|
msg(UString("buildIntelImage: unknown region type"), currentRegion);
|
||||||
return U_UNKNOWN_ITEM_TYPE;
|
return U_UNKNOWN_ITEM_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append the resulting region
|
// Append the resulting region
|
||||||
intelImage += region;
|
intelImage += region;
|
||||||
}
|
}
|
||||||
@ -232,12 +232,12 @@ USTATUS FfsBuilder::buildIntelImage(const UModelIndex & index, UByteArray & inte
|
|||||||
msg(usprintf("buildIntelImage: new image size %Xh (%u) is smaller than the original %Xh (%u)", newSize, newSize, oldSize, oldSize), index);
|
msg(usprintf("buildIntelImage: new image size %Xh (%u) is smaller than the original %Xh (%u)", newSize, newSize, oldSize, oldSize), index);
|
||||||
return U_INVALID_IMAGE;
|
return U_INVALID_IMAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build successful, append header and tail
|
// Build successful, append header and tail
|
||||||
intelImage = model->header(index) + intelImage + model->tail(index);
|
intelImage = model->header(index) + intelImage + model->tail(index);
|
||||||
return U_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg(UString("buildIntelImage: unexpected action " + actionTypeToUString(model->action(index))), index);
|
msg(UString("buildIntelImage: unexpected action " + actionTypeToUString(model->action(index))), index);
|
||||||
return U_NOT_IMPLEMENTED;
|
return U_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
@ -247,7 +247,7 @@ USTATUS FfsBuilder::buildRawArea(const UModelIndex & index, UByteArray & rawArea
|
|||||||
// Sanity check
|
// Sanity check
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return U_INVALID_PARAMETER;
|
return U_INVALID_PARAMETER;
|
||||||
|
|
||||||
// No action required
|
// No action required
|
||||||
if (model->action(index) == Actions::NoAction) {
|
if (model->action(index) == Actions::NoAction) {
|
||||||
rawArea = model->header(index) + model->body(index) + model->tail(index);
|
rawArea = model->header(index) + model->body(index) + model->tail(index);
|
||||||
@ -260,12 +260,12 @@ USTATUS FfsBuilder::buildRawArea(const UModelIndex & index, UByteArray & rawArea
|
|||||||
}
|
}
|
||||||
// Rebuild or Replace
|
// Rebuild or Replace
|
||||||
else if (model->action(index) == Actions::Rebuild
|
else if (model->action(index) == Actions::Rebuild
|
||||||
|| model->action(index) == Actions::Replace) {
|
|| model->action(index) == Actions::Replace) {
|
||||||
// Rebuild if there is at least 1 child
|
// Rebuild if there is at least 1 child
|
||||||
if (model->rowCount(index)) {
|
if (model->rowCount(index)) {
|
||||||
// Clear the supplied UByteArray
|
// Clear the supplied UByteArray
|
||||||
rawArea.clear();
|
rawArea.clear();
|
||||||
|
|
||||||
// Build children
|
// Build children
|
||||||
for (int i = 0; i < model->rowCount(index); i++) {
|
for (int i = 0; i < model->rowCount(index); i++) {
|
||||||
USTATUS result = U_SUCCESS;
|
USTATUS result = U_SUCCESS;
|
||||||
@ -291,7 +291,7 @@ USTATUS FfsBuilder::buildRawArea(const UModelIndex & index, UByteArray & rawArea
|
|||||||
// Append current data
|
// Append current data
|
||||||
rawArea += currentData;
|
rawArea += currentData;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check size of new raw area, it must be same as original one
|
// Check size of new raw area, it must be same as original one
|
||||||
UINT32 newSize = (UINT32)rawArea.size();
|
UINT32 newSize = (UINT32)rawArea.size();
|
||||||
UINT32 oldSize = (UINT32)model->body(index).size();
|
UINT32 oldSize = (UINT32)model->body(index).size();
|
||||||
@ -308,12 +308,12 @@ USTATUS FfsBuilder::buildRawArea(const UModelIndex & index, UByteArray & rawArea
|
|||||||
else {
|
else {
|
||||||
rawArea = model->body(index);
|
rawArea = model->body(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build successful, add header if needed
|
// Build successful, add header if needed
|
||||||
rawArea = model->header(index) + rawArea + model->tail(index);
|
rawArea = model->header(index) + rawArea + model->tail(index);
|
||||||
return U_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg(UString("buildRawArea: unexpected action " + actionTypeToUString(model->action(index))), index);
|
msg(UString("buildRawArea: unexpected action " + actionTypeToUString(model->action(index))), index);
|
||||||
return U_NOT_IMPLEMENTED;
|
return U_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
@ -323,7 +323,7 @@ USTATUS FfsBuilder::buildPadding(const UModelIndex & index, UByteArray & padding
|
|||||||
// Sanity check
|
// Sanity check
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return U_INVALID_PARAMETER;
|
return U_INVALID_PARAMETER;
|
||||||
|
|
||||||
// No action required
|
// No action required
|
||||||
if (model->action(index) == Actions::NoAction) {
|
if (model->action(index) == Actions::NoAction) {
|
||||||
padding = model->header(index) + model->body(index) + model->tail(index);
|
padding = model->header(index) + model->body(index) + model->tail(index);
|
||||||
@ -338,7 +338,7 @@ USTATUS FfsBuilder::buildPadding(const UModelIndex & index, UByteArray & padding
|
|||||||
else if (model->action(index) == Actions::Erase) {
|
else if (model->action(index) == Actions::Erase) {
|
||||||
return erase(index, padding);
|
return erase(index, padding);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg(UString("buildPadding: unexpected action " + actionTypeToUString(model->action(index))), index);
|
msg(UString("buildPadding: unexpected action " + actionTypeToUString(model->action(index))), index);
|
||||||
return U_NOT_IMPLEMENTED;
|
return U_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
@ -348,7 +348,7 @@ USTATUS FfsBuilder::buildNonUefiData(const UModelIndex & index, UByteArray & dat
|
|||||||
// Sanity check
|
// Sanity check
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return U_INVALID_PARAMETER;
|
return U_INVALID_PARAMETER;
|
||||||
|
|
||||||
// No action required
|
// No action required
|
||||||
if (model->action(index) == Actions::NoAction) {
|
if (model->action(index) == Actions::NoAction) {
|
||||||
data = model->header(index) + model->body(index) + model->tail(index);
|
data = model->header(index) + model->body(index) + model->tail(index);
|
||||||
@ -363,9 +363,9 @@ USTATUS FfsBuilder::buildNonUefiData(const UModelIndex & index, UByteArray & dat
|
|||||||
else if (model->action(index) == Actions::Erase) {
|
else if (model->action(index) == Actions::Erase) {
|
||||||
return erase(index, data);
|
return erase(index, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: rebuild properly
|
// TODO: rebuild properly
|
||||||
|
|
||||||
msg(UString("buildNoUefiData: unexpected action " + actionTypeToUString(model->action(index))), index);
|
msg(UString("buildNoUefiData: unexpected action " + actionTypeToUString(model->action(index))), index);
|
||||||
return U_NOT_IMPLEMENTED;
|
return U_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
@ -375,7 +375,7 @@ USTATUS FfsBuilder::buildFreeSpace(const UModelIndex & index, UByteArray & freeS
|
|||||||
// Sanity check
|
// Sanity check
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return U_INVALID_PARAMETER;
|
return U_INVALID_PARAMETER;
|
||||||
|
|
||||||
// No actions possible for free space
|
// No actions possible for free space
|
||||||
freeSpace = model->header(index) + model->body(index) + model->tail(index);
|
freeSpace = model->header(index) + model->body(index) + model->tail(index);
|
||||||
return U_SUCCESS;
|
return U_SUCCESS;
|
||||||
@ -385,7 +385,7 @@ USTATUS FfsBuilder::buildVolume(const UModelIndex & index, UByteArray & volume)
|
|||||||
{
|
{
|
||||||
U_UNUSED_PARAMETER(index);
|
U_UNUSED_PARAMETER(index);
|
||||||
U_UNUSED_PARAMETER(volume);
|
U_UNUSED_PARAMETER(volume);
|
||||||
|
|
||||||
return U_NOT_IMPLEMENTED;
|
return U_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,7 +393,7 @@ USTATUS FfsBuilder::buildPadFile(const UModelIndex & index, UByteArray & padFile
|
|||||||
{
|
{
|
||||||
U_UNUSED_PARAMETER(index);
|
U_UNUSED_PARAMETER(index);
|
||||||
U_UNUSED_PARAMETER(padFile);
|
U_UNUSED_PARAMETER(padFile);
|
||||||
|
|
||||||
return U_NOT_IMPLEMENTED;
|
return U_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,7 +401,7 @@ USTATUS FfsBuilder::buildFile(const UModelIndex & index, UByteArray & file)
|
|||||||
{
|
{
|
||||||
U_UNUSED_PARAMETER(index);
|
U_UNUSED_PARAMETER(index);
|
||||||
U_UNUSED_PARAMETER(file);
|
U_UNUSED_PARAMETER(file);
|
||||||
|
|
||||||
return U_NOT_IMPLEMENTED;
|
return U_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -409,7 +409,7 @@ USTATUS FfsBuilder::buildSection(const UModelIndex & index, UByteArray & section
|
|||||||
{
|
{
|
||||||
U_UNUSED_PARAMETER(index);
|
U_UNUSED_PARAMETER(index);
|
||||||
U_UNUSED_PARAMETER(section);
|
U_UNUSED_PARAMETER(section);
|
||||||
|
|
||||||
return U_NOT_IMPLEMENTED;
|
return U_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
/* fssops.cpp
|
/* fssops.cpp
|
||||||
|
|
||||||
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
|
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
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 "ffsops.h"
|
#include "ffsops.h"
|
||||||
#include "ffs.h"
|
#include "ffs.h"
|
||||||
@ -20,10 +20,10 @@ USTATUS FfsOperations::extract(const UModelIndex & index, UString & name, UByteA
|
|||||||
// Sanity check
|
// Sanity check
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return U_INVALID_PARAMETER;
|
return U_INVALID_PARAMETER;
|
||||||
|
|
||||||
// Default name
|
// Default name
|
||||||
name = uniqueItemName(index);
|
name = uniqueItemName(index);
|
||||||
|
|
||||||
// Get extracted data
|
// Get extracted data
|
||||||
if (mode == EXTRACT_MODE_AS_IS) {
|
if (mode == EXTRACT_MODE_AS_IS) {
|
||||||
// Extract as is, with header body and tail
|
// Extract as is, with header body and tail
|
||||||
@ -45,18 +45,18 @@ USTATUS FfsOperations::extract(const UModelIndex & index, UString & name, UByteA
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
return U_UNKNOWN_EXTRACT_MODE;
|
return U_UNKNOWN_EXTRACT_MODE;
|
||||||
|
|
||||||
return U_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
USTATUS FfsOperations::replace(const UModelIndex & index, UByteArray & data, const UINT8 mode)
|
USTATUS FfsOperations::replace(const UModelIndex & index, UByteArray & data, const UINT8 mode)
|
||||||
{
|
{
|
||||||
U_UNUSED_PARAMETER(data);
|
U_UNUSED_PARAMETER(data);
|
||||||
|
|
||||||
// Sanity check
|
// Sanity check
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return U_INVALID_PARAMETER;
|
return U_INVALID_PARAMETER;
|
||||||
|
|
||||||
if (mode == REPLACE_MODE_AS_IS) {
|
if (mode == REPLACE_MODE_AS_IS) {
|
||||||
return U_NOT_IMPLEMENTED;
|
return U_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ USTATUS FfsOperations::replace(const UModelIndex & index, UByteArray & data, con
|
|||||||
return U_NOT_IMPLEMENTED;
|
return U_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
return U_UNKNOWN_REPLACE_MODE;
|
return U_UNKNOWN_REPLACE_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
USTATUS FfsOperations::remove(const UModelIndex & index)
|
USTATUS FfsOperations::remove(const UModelIndex & index)
|
||||||
@ -72,10 +72,10 @@ USTATUS FfsOperations::remove(const UModelIndex & index)
|
|||||||
// Sanity check
|
// Sanity check
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return U_INVALID_PARAMETER;
|
return U_INVALID_PARAMETER;
|
||||||
|
|
||||||
// Set remove action
|
// Set remove action
|
||||||
model->setAction(index, Actions::Remove);
|
model->setAction(index, Actions::Remove);
|
||||||
|
|
||||||
return U_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,20 +84,20 @@ USTATUS FfsOperations::rebuild(const UModelIndex & index)
|
|||||||
// Sanity check
|
// Sanity check
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return U_INVALID_PARAMETER;
|
return U_INVALID_PARAMETER;
|
||||||
|
|
||||||
// On insert action, set insert action for children
|
// On insert action, set insert action for children
|
||||||
//if (action == Actions::Insert)
|
//if (action == Actions::Insert)
|
||||||
// for (int i = 0; i < item->childCount(); i++)
|
// for (int i = 0; i < item->childCount(); i++)
|
||||||
// setAction(index.child(i, 0), Actions::Insert);
|
// setAction(index.child(i, 0), Actions::Insert);
|
||||||
|
|
||||||
// Set rebuild action
|
// Set rebuild action
|
||||||
model->setAction(index, Actions::Rebuild);
|
model->setAction(index, Actions::Rebuild);
|
||||||
|
|
||||||
// Rebuild parent, if it has no action now
|
// Rebuild parent, if it has no action now
|
||||||
UModelIndex parent = index.parent();
|
UModelIndex parent = index.parent();
|
||||||
if (parent.isValid() && model->type(parent) != Types::Root
|
if (parent.isValid() && model->type(parent) != Types::Root
|
||||||
&& model->action(parent) == Actions::NoAction)
|
&& model->action(parent) == Actions::NoAction)
|
||||||
rebuild(parent);
|
rebuild(parent);
|
||||||
|
|
||||||
return U_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
2276
common/ffsparser.cpp
2276
common/ffsparser.cpp
File diff suppressed because it is too large
Load Diff
@ -1,15 +1,15 @@
|
|||||||
/* fssreport.cpp
|
/* fssreport.cpp
|
||||||
|
|
||||||
Copyright (c) 2016, Nikolaj Schlej. All rights reserved.
|
Copyright (c) 2016, Nikolaj Schlej. All rights reserved.
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
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 "ffsreport.h"
|
#include "ffsreport.h"
|
||||||
#include "ffs.h"
|
#include "ffs.h"
|
||||||
@ -25,21 +25,21 @@ std::vector<UString> FfsReport::generate()
|
|||||||
report.push_back(usprintf("%s: invalid model pointer provided", __FUNCTION__));
|
report.push_back(usprintf("%s: invalid model pointer provided", __FUNCTION__));
|
||||||
return report;
|
return report;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check root index to be valid
|
// Check root index to be valid
|
||||||
UModelIndex root = model->index(0,0);
|
UModelIndex root = model->index(0,0);
|
||||||
if (!root.isValid()) {
|
if (!root.isValid()) {
|
||||||
report.push_back(usprintf("%s: model root index is invalid", __FUNCTION__));
|
report.push_back(usprintf("%s: model root index is invalid", __FUNCTION__));
|
||||||
return report;
|
return report;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate report recursive
|
// Generate report recursive
|
||||||
report.push_back(UString(" Type | Subtype | Base | Size | CRC32 | Name "));
|
report.push_back(UString(" Type | Subtype | Base | Size | CRC32 | Name "));
|
||||||
USTATUS result = generateRecursive(report, root);
|
USTATUS result = generateRecursive(report, root);
|
||||||
if (result) {
|
if (result) {
|
||||||
report.push_back(usprintf("%s: generateRecursive returned ", __FUNCTION__) + errorCodeToUString(result));
|
report.push_back(usprintf("%s: generateRecursive returned ", __FUNCTION__) + errorCodeToUString(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
return report;
|
return report;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,27 +51,27 @@ USTATUS FfsReport::generateRecursive(std::vector<UString> & report, const UModel
|
|||||||
// Calculate item CRC32
|
// Calculate item CRC32
|
||||||
UByteArray data = model->header(index) + model->body(index) + model->tail(index);
|
UByteArray data = model->header(index) + model->body(index) + model->tail(index);
|
||||||
UINT32 crc = (UINT32)crc32(0, (const UINT8*)data.constData(), (uInt)data.size());
|
UINT32 crc = (UINT32)crc32(0, (const UINT8*)data.constData(), (uInt)data.size());
|
||||||
|
|
||||||
// Information on current item
|
// Information on current item
|
||||||
UString text = model->text(index);
|
UString text = model->text(index);
|
||||||
UString offset = "| N/A ";
|
UString offset = "| N/A ";
|
||||||
if ((!model->compressed(index)) || (index.parent().isValid() && !model->compressed(index.parent()))) {
|
if ((!model->compressed(index)) || (index.parent().isValid() && !model->compressed(index.parent()))) {
|
||||||
offset = usprintf("| %08X ", model->base(index));
|
offset = usprintf("| %08X ", model->base(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
report.push_back(
|
report.push_back(
|
||||||
UString(" ") + itemTypeToUString(model->type(index)).leftJustified(16)
|
UString(" ") + itemTypeToUString(model->type(index)).leftJustified(16)
|
||||||
+ UString("| ") + itemSubtypeToUString(model->type(index), model->subtype(index)).leftJustified(22)
|
+ UString("| ") + itemSubtypeToUString(model->type(index), model->subtype(index)).leftJustified(22)
|
||||||
+ offset
|
+ offset
|
||||||
+ usprintf("| %08" PRIXQ " | %08X | ", data.size(), crc)
|
+ usprintf("| %08X | %08X | ", (UINT32)data.size(), crc)
|
||||||
+ urepeated('-', level) + UString(" ") + model->name(index) + (text.isEmpty() ? UString() : UString(" | ") + text)
|
+ urepeated('-', level) + UString(" ") + model->name(index) + (text.isEmpty() ? UString() : UString(" | ") + text)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Information on child items
|
// Information on child items
|
||||||
for (int i = 0; i < model->rowCount(index); i++) {
|
for (int i = 0; i < model->rowCount(index); i++) {
|
||||||
generateRecursive(report, index.model()->index(i,0,index), level + 1);
|
generateRecursive(report, index.model()->index(i,0,index), level + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return U_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
/* ffsutils.cpp
|
/* ffsutils.cpp
|
||||||
|
|
||||||
Copyright (c) 2019, LongSoft. All rights reserved.
|
Copyright (c) 2019, LongSoft. All rights reserved.
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
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 "ffsutils.h"
|
#include "ffsutils.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
@ -21,15 +21,15 @@ USTATUS findFileRecursive(TreeModel *model, const UModelIndex index, const UStri
|
|||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return U_SUCCESS;
|
return U_SUCCESS;
|
||||||
|
|
||||||
if (hexPattern.isEmpty())
|
if (hexPattern.isEmpty())
|
||||||
return U_INVALID_PARAMETER;
|
return U_INVALID_PARAMETER;
|
||||||
|
|
||||||
const char *hexPatternRaw = hexPattern.toLocal8Bit();
|
const char *hexPatternRaw = hexPattern.toLocal8Bit();
|
||||||
std::vector<UINT8> pattern, patternMask;
|
std::vector<UINT8> pattern, patternMask;
|
||||||
if (!makePattern(hexPatternRaw, pattern, patternMask))
|
if (!makePattern(hexPatternRaw, pattern, patternMask))
|
||||||
return U_INVALID_PARAMETER;
|
return U_INVALID_PARAMETER;
|
||||||
|
|
||||||
// Check for "all substrings" pattern
|
// Check for "all substrings" pattern
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
for (size_t i = 0; i < patternMask.size(); i++)
|
for (size_t i = 0; i < patternMask.size(); i++)
|
||||||
@ -37,12 +37,12 @@ USTATUS findFileRecursive(TreeModel *model, const UModelIndex index, const UStri
|
|||||||
count++;
|
count++;
|
||||||
if (count == patternMask.size())
|
if (count == patternMask.size())
|
||||||
return U_SUCCESS;
|
return U_SUCCESS;
|
||||||
|
|
||||||
bool hasChildren = (model->rowCount(index) > 0);
|
bool hasChildren = (model->rowCount(index) > 0);
|
||||||
for (int i = 0; i < model->rowCount(index); i++) {
|
for (int i = 0; i < model->rowCount(index); i++) {
|
||||||
findFileRecursive(model, index.model()->index(i, index.column(), index), hexPattern, mode, files);
|
findFileRecursive(model, index.model()->index(i, index.column(), index), hexPattern, mode, files);
|
||||||
}
|
}
|
||||||
|
|
||||||
UByteArray data;
|
UByteArray data;
|
||||||
if (hasChildren) {
|
if (hasChildren) {
|
||||||
if (mode == SEARCH_MODE_HEADER)
|
if (mode == SEARCH_MODE_HEADER)
|
||||||
@ -58,16 +58,16 @@ USTATUS findFileRecursive(TreeModel *model, const UModelIndex index, const UStri
|
|||||||
else
|
else
|
||||||
data = model->header(index) + model->body(index);
|
data = model->header(index) + model->body(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
const UINT8 *rawData = reinterpret_cast<const UINT8 *>(data.constData());
|
const UINT8 *rawData = reinterpret_cast<const UINT8 *>(data.constData());
|
||||||
INTN offset = findPattern(pattern.data(), patternMask.data(), pattern.size(), rawData, data.size(), 0);
|
INTN offset = findPattern(pattern.data(), patternMask.data(), pattern.size(), rawData, data.size(), 0);
|
||||||
|
|
||||||
// For patterns that cross header|body boundary, skip patterns entirely located in body, since
|
// For patterns that cross header|body boundary, skip patterns entirely located in body, since
|
||||||
// children search above has already found them.
|
// children search above has already found them.
|
||||||
if (hasChildren && mode == SEARCH_MODE_ALL && offset >= model->header(index).size()) {
|
if (hasChildren && mode == SEARCH_MODE_ALL && offset >= model->header(index).size()) {
|
||||||
offset = -1;
|
offset = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset >= 0) {
|
if (offset >= 0) {
|
||||||
if (model->type(index) != Types::File) {
|
if (model->type(index) != Types::File) {
|
||||||
UModelIndex ffs = model->findParentOfType(index, Types::File);
|
UModelIndex ffs = model->findParentOfType(index, Types::File);
|
||||||
@ -79,9 +79,9 @@ USTATUS findFileRecursive(TreeModel *model, const UModelIndex index, const UStri
|
|||||||
else {
|
else {
|
||||||
files.insert(std::pair<UModelIndex, UModelIndex>(index, UModelIndex()));
|
files.insert(std::pair<UModelIndex, UModelIndex>(index, UModelIndex()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return U_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
/* guiddatabase.cpp
|
/* guiddatabase.cpp
|
||||||
|
|
||||||
Copyright (c) 2017, LongSoft. All rights reserved.
|
Copyright (c) 2017, LongSoft. All rights reserved.
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
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 "guiddatabase.h"
|
#include "guiddatabase.h"
|
||||||
#include "ubytearray.h"
|
#include "ubytearray.h"
|
||||||
@ -53,17 +53,17 @@ static std::string readGuidDatabase(const UString &path) {
|
|||||||
void initGuidDatabase(const UString & path, UINT32* numEntries)
|
void initGuidDatabase(const UString & path, UINT32* numEntries)
|
||||||
{
|
{
|
||||||
gLocalGuidDatabase.clear();
|
gLocalGuidDatabase.clear();
|
||||||
|
|
||||||
std::stringstream file(readGuidDatabase(path));
|
std::stringstream file(readGuidDatabase(path));
|
||||||
|
|
||||||
while (!file.eof()) {
|
while (!file.eof()) {
|
||||||
std::string line;
|
std::string line;
|
||||||
std::getline(file, line);
|
std::getline(file, line);
|
||||||
|
|
||||||
// Use sharp symbol as commentary
|
// Use sharp symbol as commentary
|
||||||
if (line.size() == 0 || line[0] == '#')
|
if (line.size() == 0 || line[0] == '#')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// GUID and name are comma-separated
|
// GUID and name are comma-separated
|
||||||
std::vector<UString> lineParts;
|
std::vector<UString> lineParts;
|
||||||
std::string::size_type prev = 0, curr = 0;
|
std::string::size_type prev = 0, curr = 0;
|
||||||
@ -73,17 +73,17 @@ void initGuidDatabase(const UString & path, UINT32* numEntries)
|
|||||||
prev = ++curr;
|
prev = ++curr;
|
||||||
}
|
}
|
||||||
lineParts.push_back(UString(line.substr(prev, curr-prev).c_str()));
|
lineParts.push_back(UString(line.substr(prev, curr-prev).c_str()));
|
||||||
|
|
||||||
if (lineParts.size() < 2)
|
if (lineParts.size() < 2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
EFI_GUID guid;
|
EFI_GUID guid;
|
||||||
if (!ustringToGuid(lineParts[0], guid))
|
if (!ustringToGuid(lineParts[0], guid))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
gLocalGuidDatabase[guid] = lineParts[1];
|
gLocalGuidDatabase[guid] = lineParts[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numEntries)
|
if (numEntries)
|
||||||
*numEntries = (UINT32)gLocalGuidDatabase.size();
|
*numEntries = (UINT32)gLocalGuidDatabase.size();
|
||||||
}
|
}
|
||||||
@ -111,19 +111,19 @@ UString guidDatabaseLookup(const EFI_GUID & guid)
|
|||||||
GuidDatabase guidDatabaseFromTreeRecursive(TreeModel * model, const UModelIndex index)
|
GuidDatabase guidDatabaseFromTreeRecursive(TreeModel * model, const UModelIndex index)
|
||||||
{
|
{
|
||||||
GuidDatabase db;
|
GuidDatabase db;
|
||||||
|
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return db;
|
return db;
|
||||||
|
|
||||||
for (int i = 0; i < model->rowCount(index); i++) {
|
for (int i = 0; i < model->rowCount(index); i++) {
|
||||||
GuidDatabase tmpDb = guidDatabaseFromTreeRecursive(model, index.model()->index(i, index.column(), index));
|
GuidDatabase tmpDb = guidDatabaseFromTreeRecursive(model, index.model()->index(i, index.column(), index));
|
||||||
|
|
||||||
db.insert(tmpDb.begin(), tmpDb.end());
|
db.insert(tmpDb.begin(), tmpDb.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model->type(index) == Types::File && !model->text(index).isEmpty())
|
if (model->type(index) == Types::File && !model->text(index).isEmpty())
|
||||||
db[readUnaligned((const EFI_GUID*)model->header(index).left(16).constData())] = model->text(index);
|
db[readUnaligned((const EFI_GUID*)model->header(index).left(16).constData())] = model->text(index);
|
||||||
|
|
||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,6 +137,6 @@ USTATUS guidDatabaseExportToFile(const UString & outPath, GuidDatabase & db)
|
|||||||
std::string name(it->second.toLocal8Bit());
|
std::string name(it->second.toLocal8Bit());
|
||||||
outputFile << guid << ',' << name << '\n';
|
outputFile << guid << ',' << name << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
return U_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
/* meparser.cpp
|
/* meparser.cpp
|
||||||
|
|
||||||
Copyright (c) 2019, Nikolaj Schlej. All rights reserved.
|
Copyright (c) 2019, Nikolaj Schlej. All rights reserved.
|
||||||
|
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php.
|
http://opensource.org/licenses/bsd-license.php.
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
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 <map>
|
#include <map>
|
||||||
|
|
||||||
@ -42,30 +42,30 @@ USTATUS MeParser::parseMeRegionBody(const UModelIndex & index)
|
|||||||
// Sanity check
|
// Sanity check
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return U_INVALID_PARAMETER;
|
return U_INVALID_PARAMETER;
|
||||||
|
|
||||||
// Obtain ME region
|
// Obtain ME region
|
||||||
UByteArray meRegion = model->body(index);
|
UByteArray meRegion = model->body(index);
|
||||||
|
|
||||||
// Check region size
|
// Check region size
|
||||||
if ((UINT32)meRegion.size() < ME_ROM_BYPASS_VECTOR_SIZE + sizeof(UINT32)) {
|
if ((UINT32)meRegion.size() < ME_ROM_BYPASS_VECTOR_SIZE + sizeof(UINT32)) {
|
||||||
msg(usprintf("%s: ME region too small to fit ROM bypass vector", __FUNCTION__), index);
|
msg(usprintf("%s: ME region too small to fit ROM bypass vector", __FUNCTION__), index);
|
||||||
return U_INVALID_ME_PARTITION_TABLE;
|
return U_INVALID_ME_PARTITION_TABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check ME signature to determine it's version
|
// Check ME signature to determine it's version
|
||||||
// ME v11 and older layout
|
// ME v11 and older layout
|
||||||
if (meRegion.left(sizeof(UINT32)) == FPT_HEADER_SIGNATURE || meRegion.mid(ME_ROM_BYPASS_VECTOR_SIZE, sizeof(UINT32)) == FPT_HEADER_SIGNATURE) {
|
if (meRegion.left(sizeof(UINT32)) == FPT_HEADER_SIGNATURE || meRegion.mid(ME_ROM_BYPASS_VECTOR_SIZE, sizeof(UINT32)) == FPT_HEADER_SIGNATURE) {
|
||||||
UModelIndex ptIndex;
|
UModelIndex ptIndex;
|
||||||
return parseFptRegion(meRegion, index, ptIndex);
|
return parseFptRegion(meRegion, index, ptIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// IFWI 1.6
|
// IFWI 1.6
|
||||||
// Check region size
|
// Check region size
|
||||||
if ((UINT32)meRegion.size() < sizeof(IFWI_16_LAYOUT_HEADER)) {
|
if ((UINT32)meRegion.size() < sizeof(IFWI_16_LAYOUT_HEADER)) {
|
||||||
msg(usprintf("%s: ME region too small to fit IFWI 1.6 layout header", __FUNCTION__), index);
|
msg(usprintf("%s: ME region too small to fit IFWI 1.6 layout header", __FUNCTION__), index);
|
||||||
return U_INVALID_ME_PARTITION_TABLE;
|
return U_INVALID_ME_PARTITION_TABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
const IFWI_16_LAYOUT_HEADER* ifwi16Header = (const IFWI_16_LAYOUT_HEADER*)meRegion.constData();
|
const IFWI_16_LAYOUT_HEADER* ifwi16Header = (const IFWI_16_LAYOUT_HEADER*)meRegion.constData();
|
||||||
// Check region size
|
// Check region size
|
||||||
if ((UINT32)meRegion.size() < ifwi16Header->DataPartition.Offset + sizeof(UINT32)) {
|
if ((UINT32)meRegion.size() < ifwi16Header->DataPartition.Offset + sizeof(UINT32)) {
|
||||||
@ -77,7 +77,7 @@ USTATUS MeParser::parseMeRegionBody(const UModelIndex & index)
|
|||||||
UModelIndex ptIndex;
|
UModelIndex ptIndex;
|
||||||
return parseIfwi16Region(meRegion, index, ptIndex);
|
return parseIfwi16Region(meRegion, index, ptIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// IFWI 1.7
|
// IFWI 1.7
|
||||||
if ((UINT32)meRegion.size() < sizeof(IFWI_17_LAYOUT_HEADER)) {
|
if ((UINT32)meRegion.size() < sizeof(IFWI_17_LAYOUT_HEADER)) {
|
||||||
msg(usprintf("%s: ME region too small to fit IFWI 1.7 layout header", __FUNCTION__), index);
|
msg(usprintf("%s: ME region too small to fit IFWI 1.7 layout header", __FUNCTION__), index);
|
||||||
@ -95,7 +95,7 @@ USTATUS MeParser::parseMeRegionBody(const UModelIndex & index)
|
|||||||
UModelIndex ptIndex;
|
UModelIndex ptIndex;
|
||||||
return parseIfwi17Region(meRegion, index, ptIndex);
|
return parseIfwi17Region(meRegion, index, ptIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Something else entirely
|
// Something else entirely
|
||||||
msg(usprintf("%s: unknown ME region format", __FUNCTION__), index);
|
msg(usprintf("%s: unknown ME region format", __FUNCTION__), index);
|
||||||
return U_INVALID_ME_PARTITION_TABLE;
|
return U_INVALID_ME_PARTITION_TABLE;
|
||||||
@ -137,42 +137,42 @@ USTATUS MeParser::parseFptRegion(const UByteArray & region, const UModelIndex &
|
|||||||
if (ptHeader->HeaderVersion == FPT_HEADER_VERSION_21) {
|
if (ptHeader->HeaderVersion == FPT_HEADER_VERSION_21) {
|
||||||
const FPT_HEADER_21* ptHeader21 = (const FPT_HEADER_21*)ptHeader;
|
const FPT_HEADER_21* ptHeader21 = (const FPT_HEADER_21*)ptHeader;
|
||||||
|
|
||||||
info = usprintf("Full size: %Xh (%u)\nHeader size: %" PRIXQ "h (%" PRIuQ ")\nBody size: %Xh (%u)\nROM bypass vector: %s\nNumber of entries: %u\nHeader version: %02Xh\nEntry version: %02Xh\n"
|
info = usprintf("Full size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nROM bypass vector: %s\nNumber of entries: %u\nHeader version: %02Xh\nEntry version: %02Xh\n"
|
||||||
"Header length: %02Xh\nFlags: %Xh\nTicks to add: %04Xh\nTokens to add: %04Xh\nSPS Flags: %Xh\nFITC version: %u.%u.%u.%u\nCRC32 Checksum: %08Xh",
|
"Header length: %02Xh\nFlags: %Xh\nTicks to add: %04Xh\nTokens to add: %04Xh\nSPS Flags: %Xh\nFITC version: %u.%u.%u.%u\nCRC32 Checksum: %08Xh",
|
||||||
ptSize, ptSize,
|
ptSize, ptSize,
|
||||||
header.size(), header.size(),
|
(UINT32)header.size(), (UINT32)header.size(),
|
||||||
ptBodySize, ptBodySize,
|
ptBodySize, ptBodySize,
|
||||||
(romBypassVectorSize ? "present" : "absent"),
|
(romBypassVectorSize ? "present" : "absent"),
|
||||||
ptHeader21->NumEntries,
|
ptHeader21->NumEntries,
|
||||||
ptHeader21->HeaderVersion,
|
ptHeader21->HeaderVersion,
|
||||||
ptHeader21->EntryVersion,
|
ptHeader21->EntryVersion,
|
||||||
ptHeader21->HeaderLength,
|
ptHeader21->HeaderLength,
|
||||||
ptHeader21->Flags,
|
ptHeader21->Flags,
|
||||||
ptHeader21->TicksToAdd,
|
ptHeader21->TicksToAdd,
|
||||||
ptHeader21->TokensToAdd,
|
ptHeader21->TokensToAdd,
|
||||||
ptHeader21->SPSFlags,
|
ptHeader21->SPSFlags,
|
||||||
ptHeader21->FitcMajor, ptHeader21->FitcMinor, ptHeader21->FitcHotfix, ptHeader21->FitcBuild,
|
ptHeader21->FitcMajor, ptHeader21->FitcMinor, ptHeader21->FitcHotfix, ptHeader21->FitcBuild,
|
||||||
ptHeader21->HeaderCrc32);
|
ptHeader21->HeaderCrc32);
|
||||||
// TODO: verify header crc32
|
// TODO: verify header crc32
|
||||||
}
|
}
|
||||||
// Default handling for all other versions, may be too generic in some corner cases
|
// Default handling for all other versions, may be too generic in some corner cases
|
||||||
else {
|
else {
|
||||||
info = usprintf("Full size: %Xh (%u)\nHeader size: %" PRIXQ "h (%" PRIuQ ")\nBody size: %Xh (%u)\nROM bypass vector: %s\nNumber of entries: %u\nHeader version: %02Xh\nEntry version: %02Xh\n"
|
info = usprintf("Full size: %Xh (%u)\nHeader size: %Xh (%u)\nBody size: %Xh (%u)\nROM bypass vector: %s\nNumber of entries: %u\nHeader version: %02Xh\nEntry version: %02Xh\n"
|
||||||
"Header length: %02Xh\nFlash cycle life: %04Xh\nFlash cycle limit: %04Xh\nUMA size: %Xh\nFlags: %Xh\nFITC version: %u.%u.%u.%u\nChecksum: %02Xh",
|
"Header length: %02Xh\nFlash cycle life: %04Xh\nFlash cycle limit: %04Xh\nUMA size: %Xh\nFlags: %Xh\nFITC version: %u.%u.%u.%u\nChecksum: %02Xh",
|
||||||
ptSize, ptSize,
|
ptSize, ptSize,
|
||||||
header.size(), header.size(),
|
(UINT32)header.size(), (UINT32)header.size(),
|
||||||
ptBodySize, ptBodySize,
|
ptBodySize, ptBodySize,
|
||||||
(romBypassVectorSize ? "present" : "absent"),
|
(romBypassVectorSize ? "present" : "absent"),
|
||||||
ptHeader->NumEntries,
|
ptHeader->NumEntries,
|
||||||
ptHeader->HeaderVersion,
|
ptHeader->HeaderVersion,
|
||||||
ptHeader->EntryVersion,
|
ptHeader->EntryVersion,
|
||||||
ptHeader->HeaderLength,
|
ptHeader->HeaderLength,
|
||||||
ptHeader->FlashCycleLife,
|
ptHeader->FlashCycleLife,
|
||||||
ptHeader->FlashCycleLimit,
|
ptHeader->FlashCycleLimit,
|
||||||
ptHeader->UmaSize,
|
ptHeader->UmaSize,
|
||||||
ptHeader->Flags,
|
ptHeader->Flags,
|
||||||
ptHeader->FitcMajor, ptHeader->FitcMinor, ptHeader->FitcHotfix, ptHeader->FitcBuild,
|
ptHeader->FitcMajor, ptHeader->FitcMinor, ptHeader->FitcHotfix, ptHeader->FitcBuild,
|
||||||
ptHeader->HeaderChecksum);
|
ptHeader->HeaderChecksum);
|
||||||
// TODO: verify header checksum8
|
// TODO: verify header checksum8
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,7 +213,7 @@ USTATUS MeParser::parseFptRegion(const UByteArray & region, const UModelIndex &
|
|||||||
partitions.push_back(partition);
|
partitions.push_back(partition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
make_partition_table_consistent:
|
make_partition_table_consistent:
|
||||||
// Sort partitions by offset
|
// Sort partitions by offset
|
||||||
std::sort(partitions.begin(), partitions.end());
|
std::sort(partitions.begin(), partitions.end());
|
||||||
@ -251,7 +251,7 @@ make_partition_table_consistent:
|
|||||||
partitions[i].ptEntry.Size = (UINT32)region.size() - (UINT32)partitions[i].ptEntry.Offset;
|
partitions[i].ptEntry.Size = (UINT32)region.size() - (UINT32)partitions[i].ptEntry.Offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for intersection with previous partition
|
// Check for intersection with previous partition
|
||||||
if (partitions[i].ptEntry.Offset < previousPartitionEnd) {
|
if (partitions[i].ptEntry.Offset < previousPartitionEnd) {
|
||||||
// Check if current partition is located inside previous one
|
// Check if current partition is located inside previous one
|
||||||
@ -294,10 +294,10 @@ make_partition_table_consistent:
|
|||||||
UModelIndex partitionIndex;
|
UModelIndex partitionIndex;
|
||||||
// Get info
|
// Get info
|
||||||
name = visibleAsciiOrHex((UINT8*) partitions[i].ptEntry.Name, 4);
|
name = visibleAsciiOrHex((UINT8*) partitions[i].ptEntry.Name, 4);
|
||||||
info = usprintf("Full size: %" PRIXQ "h (%" PRIuQ ")\nPartition type: %02Xh\n",
|
info = usprintf("Full size: %Xh (%u)\nPartition type: %02Xh\n",
|
||||||
partition.size(), partition.size(),
|
(UINT32)partition.size(), (UINT32)partition.size(),
|
||||||
partitions[i].ptEntry.Type);
|
partitions[i].ptEntry.Type);
|
||||||
|
|
||||||
// Add tree item
|
// Add tree item
|
||||||
UINT8 type = Subtypes::CodeFptPartition + partitions[i].ptEntry.Type;
|
UINT8 type = Subtypes::CodeFptPartition + partitions[i].ptEntry.Type;
|
||||||
partitionIndex = model->addItem(partitions[i].ptEntry.Offset, Types::FptPartition, type, name, UString(), info, UByteArray(), partition, UByteArray(), Fixed, parent);
|
partitionIndex = model->addItem(partitions[i].ptEntry.Offset, Types::FptPartition, type, name, UString(), info, UByteArray(), partition, UByteArray(), Fixed, parent);
|
||||||
@ -310,7 +310,7 @@ make_partition_table_consistent:
|
|||||||
else if (partitions[i].type == Types::Padding) {
|
else if (partitions[i].type == Types::Padding) {
|
||||||
// Get info
|
// Get info
|
||||||
name = UString("Padding");
|
name = UString("Padding");
|
||||||
info = usprintf("Full size: %" PRIXQ "h (%" PRIuQ ")", partition.size(), partition.size());
|
info = usprintf("Full size: %Xh (%u)", (UINT32)partition.size(), (UINT32)partition.size());
|
||||||
|
|
||||||
// Add tree item
|
// Add tree item
|
||||||
model->addItem(partitions[i].ptEntry.Offset, Types::Padding, getPaddingType(partition), name, UString(), info, UByteArray(), partition, UByteArray(), Fixed, parent);
|
model->addItem(partitions[i].ptEntry.Offset, Types::Padding, getPaddingType(partition), name, UString(), info, UByteArray(), partition, UByteArray(), Fixed, parent);
|
||||||
@ -335,7 +335,7 @@ USTATUS MeParser::parseIfwi16Region(const UByteArray & region, const UModelIndex
|
|||||||
UByteArray header = region.left(ptSize);
|
UByteArray header = region.left(ptSize);
|
||||||
|
|
||||||
UString name = UString("IFWI 1.6 header");
|
UString name = UString("IFWI 1.6 header");
|
||||||
UString info = usprintf("Full size: %" PRIXQ "h (%" PRIuQ ")\n"
|
UString info = usprintf("Full size: %Xh (%u)\n"
|
||||||
"Data partition offset: %Xh\nData partition size: %Xh\n"
|
"Data partition offset: %Xh\nData partition size: %Xh\n"
|
||||||
"Boot1 partition offset: %Xh\nBoot1 partition size: %Xh\n"
|
"Boot1 partition offset: %Xh\nBoot1 partition size: %Xh\n"
|
||||||
"Boot2 partition offset: %Xh\nBoot2 partition size: %Xh\n"
|
"Boot2 partition offset: %Xh\nBoot2 partition size: %Xh\n"
|
||||||
@ -343,7 +343,7 @@ USTATUS MeParser::parseIfwi16Region(const UByteArray & region, const UModelIndex
|
|||||||
"Boot4 partition offset: %Xh\nBoot4 partition size: %Xh\n"
|
"Boot4 partition offset: %Xh\nBoot4 partition size: %Xh\n"
|
||||||
"Boot5 partition offset: %Xh\nBoot5 partition size: %Xh\n"
|
"Boot5 partition offset: %Xh\nBoot5 partition size: %Xh\n"
|
||||||
"Checksum: %llXh",
|
"Checksum: %llXh",
|
||||||
header.size(), header.size(),
|
(UINT32)header.size(), (UINT32)header.size(),
|
||||||
ifwiHeader->DataPartition.Offset, ifwiHeader->DataPartition.Size,
|
ifwiHeader->DataPartition.Offset, ifwiHeader->DataPartition.Size,
|
||||||
ifwiHeader->BootPartition[0].Offset, ifwiHeader->BootPartition[0].Size,
|
ifwiHeader->BootPartition[0].Offset, ifwiHeader->BootPartition[0].Size,
|
||||||
ifwiHeader->BootPartition[1].Offset, ifwiHeader->BootPartition[1].Size,
|
ifwiHeader->BootPartition[1].Offset, ifwiHeader->BootPartition[1].Size,
|
||||||
@ -373,7 +373,7 @@ USTATUS MeParser::parseIfwi16Region(const UByteArray & region, const UModelIndex
|
|||||||
partitions.push_back(partition);
|
partitions.push_back(partition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
make_partition_table_consistent:
|
make_partition_table_consistent:
|
||||||
// Sort partitions by offset
|
// Sort partitions by offset
|
||||||
std::sort(partitions.begin(), partitions.end());
|
std::sort(partitions.begin(), partitions.end());
|
||||||
@ -457,8 +457,7 @@ make_partition_table_consistent:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get info
|
// Get info
|
||||||
info = usprintf("Full size: %" PRIXQ "h (%" PRIuQ ")\n",
|
info = usprintf("Full size: %Xh (%u)\n", (UINT32)partition.size(), (UINT32)partition.size());
|
||||||
partition.size(), partition.size());
|
|
||||||
|
|
||||||
// Add tree item
|
// Add tree item
|
||||||
partitionIndex = model->addItem(partitions[i].ptEntry.Offset, partitions[i].type, partitions[i].subtype, name, UString(), info, UByteArray(), partition, UByteArray(), Fixed, parent);
|
partitionIndex = model->addItem(partitions[i].ptEntry.Offset, partitions[i].type, partitions[i].subtype, name, UString(), info, UByteArray(), partition, UByteArray(), Fixed, parent);
|
||||||
@ -477,13 +476,13 @@ make_partition_table_consistent:
|
|||||||
else if (partitions[i].type == Types::Padding) {
|
else if (partitions[i].type == Types::Padding) {
|
||||||
// Get info
|
// Get info
|
||||||
name = UString("Padding");
|
name = UString("Padding");
|
||||||
info = usprintf("Full size: %" PRIXQ "h (%" PRIuQ ")", partition.size(), partition.size());
|
info = usprintf("Full size: %Xh (%u)", (UINT32)partition.size(), (UINT32)partition.size());
|
||||||
|
|
||||||
// Add tree item
|
// Add tree item
|
||||||
model->addItem(partitions[i].ptEntry.Offset, Types::Padding, getPaddingType(partition), name, UString(), info, UByteArray(), partition, UByteArray(), Fixed, parent);
|
model->addItem(partitions[i].ptEntry.Offset, Types::Padding, getPaddingType(partition), name, UString(), info, UByteArray(), partition, UByteArray(), Fixed, parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return U_SUCCESS;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -503,7 +502,7 @@ USTATUS MeParser::parseIfwi17Region(const UByteArray & region, const UModelIndex
|
|||||||
UByteArray header = region.left(ptSize);
|
UByteArray header = region.left(ptSize);
|
||||||
|
|
||||||
UString name = UString("IFWI 1.7 header");
|
UString name = UString("IFWI 1.7 header");
|
||||||
UString info = usprintf("Full size: %" PRIXQ "h (%" PRIuQ ")\n"
|
UString info = usprintf("Full size: %Xh (%u)\n"
|
||||||
"Flags: %02Xh\n"
|
"Flags: %02Xh\n"
|
||||||
"Reserved: %02Xh\n"
|
"Reserved: %02Xh\n"
|
||||||
"Checksum: %Xh\n"
|
"Checksum: %Xh\n"
|
||||||
@ -514,7 +513,7 @@ USTATUS MeParser::parseIfwi17Region(const UByteArray & region, const UModelIndex
|
|||||||
"Boot4 partition offset: %Xh\nBoot4 partition size: %Xh\n"
|
"Boot4 partition offset: %Xh\nBoot4 partition size: %Xh\n"
|
||||||
"Boot5 partition offset: %Xh\nBoot5 partition size: %Xh\n"
|
"Boot5 partition offset: %Xh\nBoot5 partition size: %Xh\n"
|
||||||
"Temp page offset: %Xh\nTemp page size: %Xh\n",
|
"Temp page offset: %Xh\nTemp page size: %Xh\n",
|
||||||
header.size(), header.size(),
|
(UINT32)header.size(), (UINT32)header.size(),
|
||||||
ifwiHeader->Flags,
|
ifwiHeader->Flags,
|
||||||
ifwiHeader->Reserved,
|
ifwiHeader->Reserved,
|
||||||
ifwiHeader->Checksum,
|
ifwiHeader->Checksum,
|
||||||
@ -643,8 +642,7 @@ make_partition_table_consistent:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get info
|
// Get info
|
||||||
info = usprintf("Full size: %" PRIXQ "h (%" PRIuQ ")\n",
|
info = usprintf("Full size: %Xh (%u)\n", (UINT32)partition.size(), (UINT32)partition.size());
|
||||||
partition.size(), partition.size());
|
|
||||||
|
|
||||||
// Add tree item
|
// Add tree item
|
||||||
partitionIndex = model->addItem(partitions[i].ptEntry.Offset, partitions[i].type, partitions[i].subtype, name, UString(), info, UByteArray(), partition, UByteArray(), Fixed, parent);
|
partitionIndex = model->addItem(partitions[i].ptEntry.Offset, partitions[i].type, partitions[i].subtype, name, UString(), info, UByteArray(), partition, UByteArray(), Fixed, parent);
|
||||||
@ -663,7 +661,7 @@ make_partition_table_consistent:
|
|||||||
else if (partitions[i].type == Types::Padding) {
|
else if (partitions[i].type == Types::Padding) {
|
||||||
// Get info
|
// Get info
|
||||||
name = UString("Padding");
|
name = UString("Padding");
|
||||||
info = usprintf("Full size: %" PRIXQ "h (%" PRIuQ ")", partition.size(), partition.size());
|
info = usprintf("Full size: %Xh (%u)", (UINT32)partition.size(), (UINT32)partition.size());
|
||||||
|
|
||||||
// Add tree item
|
// Add tree item
|
||||||
model->addItem(partitions[i].ptEntry.Offset, Types::Padding, getPaddingType(partition), name, UString(), info, UByteArray(), partition, UByteArray(), Fixed, parent);
|
model->addItem(partitions[i].ptEntry.Offset, Types::Padding, getPaddingType(partition), name, UString(), info, UByteArray(), partition, UByteArray(), Fixed, parent);
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
/* nvram.cpp
|
/* nvram.cpp
|
||||||
Copyright (c) 2016, Nikolaj Schlej. All rights reserved.
|
Copyright (c) 2016, Nikolaj Schlej. All rights reserved.
|
||||||
|
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php.
|
http://opensource.org/licenses/bsd-license.php.
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
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 "nvram.h"
|
#include "nvram.h"
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ UString nvarAttributesToUString(const UINT8 attributes)
|
|||||||
{
|
{
|
||||||
if (attributes == 0x00 || attributes == 0xFF)
|
if (attributes == 0x00 || attributes == 0xFF)
|
||||||
return UString();
|
return UString();
|
||||||
|
|
||||||
UString str;
|
UString str;
|
||||||
if (attributes & NVRAM_NVAR_ENTRY_RUNTIME) str += UString(", Runtime");
|
if (attributes & NVRAM_NVAR_ENTRY_RUNTIME) str += UString(", Runtime");
|
||||||
if (attributes & NVRAM_NVAR_ENTRY_ASCII_NAME) str += UString(", AsciiName");
|
if (attributes & NVRAM_NVAR_ENTRY_ASCII_NAME) str += UString(", AsciiName");
|
||||||
@ -39,7 +39,7 @@ UString nvarExtendedAttributesToUString(const UINT8 attributes)
|
|||||||
if (attributes & NVRAM_NVAR_ENTRY_EXT_AUTH_WRITE) str += UString(", AuthWrite");
|
if (attributes & NVRAM_NVAR_ENTRY_EXT_AUTH_WRITE) str += UString(", AuthWrite");
|
||||||
if (attributes & NVRAM_NVAR_ENTRY_EXT_TIME_BASED) str += UString(", TimeBasedAuthWrite");
|
if (attributes & NVRAM_NVAR_ENTRY_EXT_TIME_BASED) str += UString(", TimeBasedAuthWrite");
|
||||||
if (attributes & NVRAM_NVAR_ENTRY_EXT_UNKNOWN_MASK) str += UString(", Unknown");
|
if (attributes & NVRAM_NVAR_ENTRY_EXT_UNKNOWN_MASK) str += UString(", Unknown");
|
||||||
|
|
||||||
str.remove(0, 2); // Remove first comma and space
|
str.remove(0, 2); // Remove first comma and space
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
@ -56,7 +56,7 @@ extern UString vssAttributesToUString(const UINT32 attributes)
|
|||||||
if (attributes & NVRAM_VSS_VARIABLE_APPEND_WRITE) str += UString(", AppendWrite");
|
if (attributes & NVRAM_VSS_VARIABLE_APPEND_WRITE) str += UString(", AppendWrite");
|
||||||
if (attributes & NVRAM_VSS_VARIABLE_APPLE_DATA_CHECKSUM) str += UString(", AppleChecksum");
|
if (attributes & NVRAM_VSS_VARIABLE_APPLE_DATA_CHECKSUM) str += UString(", AppleChecksum");
|
||||||
if (attributes & NVRAM_VSS_VARIABLE_UNKNOWN_MASK) str += UString(", Unknown");
|
if (attributes & NVRAM_VSS_VARIABLE_UNKNOWN_MASK) str += UString(", Unknown");
|
||||||
|
|
||||||
str.remove(0, 2); // Remove first comma and space
|
str.remove(0, 2); // Remove first comma and space
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
@ -73,7 +73,7 @@ UString evsaAttributesToUString(const UINT32 attributes)
|
|||||||
if (attributes & NVRAM_EVSA_DATA_APPEND_WRITE) str += UString(", AppendWrite");
|
if (attributes & NVRAM_EVSA_DATA_APPEND_WRITE) str += UString(", AppendWrite");
|
||||||
if (attributes & NVRAM_EVSA_DATA_EXTENDED_HEADER) str += UString(", ExtendedHeader");
|
if (attributes & NVRAM_EVSA_DATA_EXTENDED_HEADER) str += UString(", ExtendedHeader");
|
||||||
if (attributes & NVRAM_EVSA_DATA_UNKNOWN_MASK) str += UString(", Unknown");
|
if (attributes & NVRAM_EVSA_DATA_UNKNOWN_MASK) str += UString(", Unknown");
|
||||||
|
|
||||||
str.remove(0, 2); // Remove first comma and space
|
str.remove(0, 2); // Remove first comma and space
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
@ -81,13 +81,13 @@ UString evsaAttributesToUString(const UINT32 attributes)
|
|||||||
UString efiTimeToUString(const EFI_TIME & time)
|
UString efiTimeToUString(const EFI_TIME & time)
|
||||||
{
|
{
|
||||||
return usprintf("%04u-%02u-%02uT%02u:%02u:%02u.%u",
|
return usprintf("%04u-%02u-%02uT%02u:%02u:%02u.%u",
|
||||||
time.Year,
|
time.Year,
|
||||||
time.Month,
|
time.Month,
|
||||||
time.Day,
|
time.Day,
|
||||||
time.Hour,
|
time.Hour,
|
||||||
time.Minute,
|
time.Minute,
|
||||||
time.Second,
|
time.Second,
|
||||||
time.Nanosecond);
|
time.Nanosecond);
|
||||||
}
|
}
|
||||||
|
|
||||||
UString flashMapGuidToUString(const EFI_GUID & guid)
|
UString flashMapGuidToUString(const EFI_GUID & guid)
|
||||||
@ -96,9 +96,9 @@ UString flashMapGuidToUString(const EFI_GUID & guid)
|
|||||||
if (baGuid == NVRAM_PHOENIX_FLASH_MAP_VOLUME_HEADER) return UString("Volume header");
|
if (baGuid == NVRAM_PHOENIX_FLASH_MAP_VOLUME_HEADER) return UString("Volume header");
|
||||||
if (baGuid == NVRAM_PHOENIX_FLASH_MAP_MICROCODES_GUID) return UString("Microcodes");
|
if (baGuid == NVRAM_PHOENIX_FLASH_MAP_MICROCODES_GUID) return UString("Microcodes");
|
||||||
if (baGuid == NVRAM_PHOENIX_FLASH_MAP_CMDB_GUID) return UString("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 UString("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 UString("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
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,35 +1,35 @@
|
|||||||
/* peimage.cpp
|
/* peimage.cpp
|
||||||
|
|
||||||
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
|
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php.
|
http://opensource.org/licenses/bsd-license.php.
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
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 "peimage.h"
|
#include "peimage.h"
|
||||||
|
|
||||||
UString machineTypeToUString(UINT16 machineType)
|
UString machineTypeToUString(UINT16 machineType)
|
||||||
{
|
{
|
||||||
switch (machineType) {
|
switch (machineType) {
|
||||||
case EFI_IMAGE_FILE_MACHINE_AMD64: return UString("x86-64");
|
case EFI_IMAGE_FILE_MACHINE_AMD64: return UString("x86-64");
|
||||||
case EFI_IMAGE_FILE_MACHINE_ARM: return UString("ARM");
|
case EFI_IMAGE_FILE_MACHINE_ARM: return UString("ARM");
|
||||||
case EFI_IMAGE_FILE_MACHINE_ARMNT: return UString("ARMv7");
|
case EFI_IMAGE_FILE_MACHINE_ARMNT: return UString("ARMv7");
|
||||||
case EFI_IMAGE_FILE_MACHINE_APPLE_ARM: return UString("Apple ARM");
|
case EFI_IMAGE_FILE_MACHINE_APPLE_ARM: return UString("Apple ARM");
|
||||||
case EFI_IMAGE_FILE_MACHINE_AARCH64: return UString("AArch64");
|
case EFI_IMAGE_FILE_MACHINE_AARCH64: return UString("AArch64");
|
||||||
case EFI_IMAGE_FILE_MACHINE_EBC: return UString("EBC");
|
case EFI_IMAGE_FILE_MACHINE_EBC: return UString("EBC");
|
||||||
case EFI_IMAGE_FILE_MACHINE_I386: return UString("x86");
|
case EFI_IMAGE_FILE_MACHINE_I386: return UString("x86");
|
||||||
case EFI_IMAGE_FILE_MACHINE_IA64: return UString("IA64");
|
case EFI_IMAGE_FILE_MACHINE_IA64: return UString("IA64");
|
||||||
case EFI_IMAGE_FILE_MACHINE_POWERPC: return UString("PowerPC");
|
case EFI_IMAGE_FILE_MACHINE_POWERPC: return UString("PowerPC");
|
||||||
case EFI_IMAGE_FILE_MACHINE_POWERPCFP: return UString("PowerPC FP");
|
case EFI_IMAGE_FILE_MACHINE_POWERPCFP: return UString("PowerPC FP");
|
||||||
case EFI_IMAGE_FILE_MACHINE_THUMB: return UString("ARM Thumb");
|
case EFI_IMAGE_FILE_MACHINE_THUMB: return UString("ARM Thumb");
|
||||||
case EFI_IMAGE_FILE_MACHINE_RISCV32: return UString("RISC-V 32-bit");
|
case EFI_IMAGE_FILE_MACHINE_RISCV32: return UString("RISC-V 32-bit");
|
||||||
case EFI_IMAGE_FILE_MACHINE_RISCV64: return UString("RISC-V 64-bit");
|
case EFI_IMAGE_FILE_MACHINE_RISCV64: return UString("RISC-V 64-bit");
|
||||||
case EFI_IMAGE_FILE_MACHINE_RISCV128: return UString("RISC-V 128-bit");
|
case EFI_IMAGE_FILE_MACHINE_RISCV128: return UString("RISC-V 128-bit");
|
||||||
default: return usprintf("Unknown (%04Xh)", machineType);
|
default: return usprintf("Unknown (%04Xh)", machineType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,38 +1,38 @@
|
|||||||
/* treeitem.cpp
|
/* treeitem.cpp
|
||||||
|
|
||||||
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
|
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
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 "treeitem.h"
|
#include "treeitem.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
TreeItem::TreeItem(const UINT32 offset, const UINT8 type, const UINT8 subtype,
|
TreeItem::TreeItem(const UINT32 offset, const UINT8 type, const UINT8 subtype,
|
||||||
const UString & name, const UString & text, const UString & info,
|
const UString & name, const UString & text, const UString & info,
|
||||||
const UByteArray & header, const UByteArray & body, const UByteArray & tail,
|
const UByteArray & header, const UByteArray & body, const UByteArray & tail,
|
||||||
const bool fixed, const bool compressed,
|
const bool fixed, const bool compressed,
|
||||||
TreeItem *parent) :
|
TreeItem *parent) :
|
||||||
itemOffset(offset),
|
itemOffset(offset),
|
||||||
itemAction(Actions::NoAction),
|
itemAction(Actions::NoAction),
|
||||||
itemType(type),
|
itemType(type),
|
||||||
itemSubtype(subtype),
|
itemSubtype(subtype),
|
||||||
itemMarking(0),
|
itemMarking(0),
|
||||||
itemName(name),
|
itemName(name),
|
||||||
itemText(text),
|
itemText(text),
|
||||||
itemInfo(info),
|
itemInfo(info),
|
||||||
itemHeader(header),
|
itemHeader(header),
|
||||||
itemBody(body),
|
itemBody(body),
|
||||||
itemTail(tail),
|
itemTail(tail),
|
||||||
itemFixed(fixed),
|
itemFixed(fixed),
|
||||||
itemCompressed(compressed),
|
itemCompressed(compressed),
|
||||||
parentItem(parent)
|
parentItem(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,18 +66,18 @@ UString TreeItem::data(int column) const
|
|||||||
{
|
{
|
||||||
switch (column)
|
switch (column)
|
||||||
{
|
{
|
||||||
case 0: // Name
|
case 0: // Name
|
||||||
return itemName;
|
return itemName;
|
||||||
case 1: // Action
|
case 1: // Action
|
||||||
return actionTypeToUString(itemAction);
|
return actionTypeToUString(itemAction);
|
||||||
case 2: // Type
|
case 2: // Type
|
||||||
return itemTypeToUString(itemType);
|
return itemTypeToUString(itemType);
|
||||||
case 3: // Subtype
|
case 3: // Subtype
|
||||||
return itemSubtypeToUString(itemType, itemSubtype);
|
return itemSubtypeToUString(itemType, itemSubtype);
|
||||||
case 4: // Text
|
case 4: // Text
|
||||||
return itemText;
|
return itemText;
|
||||||
default:
|
default:
|
||||||
return UString();
|
return UString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,4 +98,4 @@ TreeItem* TreeItem::child(int row)
|
|||||||
std::list<TreeItem*>::iterator child = childItems.begin();
|
std::list<TreeItem*>::iterator child = childItems.begin();
|
||||||
std::advance(child, row);
|
std::advance(child, row);
|
||||||
return *child;
|
return *child;
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
/* treemodel.cpp
|
/* treemodel.cpp
|
||||||
|
|
||||||
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
|
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
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 "treemodel.h"
|
#include "treemodel.h"
|
||||||
|
|
||||||
@ -20,9 +20,9 @@ QVariant TreeModel::data(const UModelIndex &index, int role) const
|
|||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||||
|
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
return item->data(index.column()).toLocal8Bit();
|
return item->data(index.column()).toLocal8Bit();
|
||||||
}
|
}
|
||||||
@ -36,7 +36,7 @@ QVariant TreeModel::data(const UModelIndex &index, int role) const
|
|||||||
else if (role == Qt::UserRole) {
|
else if (role == Qt::UserRole) {
|
||||||
return item->info().toLocal8Bit();
|
return item->info().toLocal8Bit();
|
||||||
}
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,23 +44,23 @@ Qt::ItemFlags TreeModel::flags(const UModelIndex &index) const
|
|||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return Qt::NoItemFlags;
|
return Qt::NoItemFlags;
|
||||||
|
|
||||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant TreeModel::headerData(int section, Qt::Orientation orientation,
|
QVariant TreeModel::headerData(int section, Qt::Orientation orientation,
|
||||||
int role) const
|
int role) const
|
||||||
{
|
{
|
||||||
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
|
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
|
||||||
switch (section) {
|
switch (section) {
|
||||||
case 0: return tr("Name");
|
case 0: return tr("Name");
|
||||||
case 1: return tr("Action");
|
case 1: return tr("Action");
|
||||||
case 2: return tr("Type");
|
case 2: return tr("Type");
|
||||||
case 3: return tr("Subtype");
|
case 3: return tr("Subtype");
|
||||||
case 4: return tr("Text");
|
case 4: return tr("Text");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -68,12 +68,12 @@ UString TreeModel::data(const UModelIndex &index, int role) const
|
|||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return UString();
|
return UString();
|
||||||
|
|
||||||
if (role != 0 && role != 0x0100)
|
if (role != 0 && role != 0x0100)
|
||||||
return UString();
|
return UString();
|
||||||
|
|
||||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||||
|
|
||||||
if (role == 0)
|
if (role == 0)
|
||||||
return item->data(index.column());
|
return item->data(index.column());
|
||||||
else
|
else
|
||||||
@ -81,19 +81,19 @@ UString TreeModel::data(const UModelIndex &index, int role) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
UString TreeModel::headerData(int section, int orientation,
|
UString TreeModel::headerData(int section, int orientation,
|
||||||
int role) const
|
int role) const
|
||||||
{
|
{
|
||||||
if (orientation == 1 && role == 0) {
|
if (orientation == 1 && role == 0) {
|
||||||
switch (section)
|
switch (section)
|
||||||
{
|
{
|
||||||
case 0: return UString("Name");
|
case 0: return UString("Name");
|
||||||
case 1: return UString("Action");
|
case 1: return UString("Action");
|
||||||
case 2: return UString("Type");
|
case 2: return UString("Type");
|
||||||
case 3: return UString("Subtype");
|
case 3: return UString("Subtype");
|
||||||
case 4: return UString("Text");
|
case 4: return UString("Text");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return UString();
|
return UString();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -110,14 +110,14 @@ UModelIndex TreeModel::index(int row, int column, const UModelIndex &parent) con
|
|||||||
{
|
{
|
||||||
if (!hasIndex(row, column, parent))
|
if (!hasIndex(row, column, parent))
|
||||||
return UModelIndex();
|
return UModelIndex();
|
||||||
|
|
||||||
TreeItem *parentItem;
|
TreeItem *parentItem;
|
||||||
|
|
||||||
if (!parent.isValid())
|
if (!parent.isValid())
|
||||||
parentItem = rootItem;
|
parentItem = rootItem;
|
||||||
else
|
else
|
||||||
parentItem = static_cast<TreeItem*>(parent.internalPointer());
|
parentItem = static_cast<TreeItem*>(parent.internalPointer());
|
||||||
|
|
||||||
TreeItem *childItem = parentItem->child(row);
|
TreeItem *childItem = parentItem->child(row);
|
||||||
if (childItem)
|
if (childItem)
|
||||||
return createIndex(row, column, childItem);
|
return createIndex(row, column, childItem);
|
||||||
@ -129,16 +129,16 @@ UModelIndex TreeModel::parent(const UModelIndex &index) const
|
|||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return UModelIndex();
|
return UModelIndex();
|
||||||
|
|
||||||
TreeItem *childItem = static_cast<TreeItem*>(index.internalPointer());
|
TreeItem *childItem = static_cast<TreeItem*>(index.internalPointer());
|
||||||
if (childItem == rootItem)
|
if (childItem == rootItem)
|
||||||
return UModelIndex();
|
return UModelIndex();
|
||||||
|
|
||||||
TreeItem *parentItem = childItem->parent();
|
TreeItem *parentItem = childItem->parent();
|
||||||
|
|
||||||
if (parentItem == rootItem)
|
if (parentItem == rootItem)
|
||||||
return UModelIndex();
|
return UModelIndex();
|
||||||
|
|
||||||
return createIndex(parentItem->row(), 0, parentItem);
|
return createIndex(parentItem->row(), 0, parentItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,12 +147,12 @@ int TreeModel::rowCount(const UModelIndex &parent) const
|
|||||||
TreeItem *parentItem;
|
TreeItem *parentItem;
|
||||||
if (parent.column() > 0)
|
if (parent.column() > 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!parent.isValid())
|
if (!parent.isValid())
|
||||||
parentItem = rootItem;
|
parentItem = rootItem;
|
||||||
else
|
else
|
||||||
parentItem = static_cast<TreeItem*>(parent.internalPointer());
|
parentItem = static_cast<TreeItem*>(parent.internalPointer());
|
||||||
|
|
||||||
return parentItem->childCount();
|
return parentItem->childCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ UINT32 TreeModel::base(const UModelIndex ¤t) const
|
|||||||
// TODO: rewrite this as loop if we ever see an image that is too deep for this naive implementation
|
// TODO: rewrite this as loop if we ever see an image that is too deep for this naive implementation
|
||||||
if (!current.isValid())
|
if (!current.isValid())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
UModelIndex parent = current.parent();
|
UModelIndex parent = current.parent();
|
||||||
if (!parent.isValid())
|
if (!parent.isValid())
|
||||||
return offset(current);
|
return offset(current);
|
||||||
@ -302,24 +302,24 @@ void TreeModel::setFixed(const UModelIndex &index, const bool fixed)
|
|||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||||
item->setFixed(fixed);
|
item->setFixed(fixed);
|
||||||
|
|
||||||
if (!item->parent())
|
if (!item->parent())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (fixed) {
|
if (fixed) {
|
||||||
// Special handling for uncompressed to compressed boundary
|
// Special handling for uncompressed to compressed boundary
|
||||||
if (item->compressed() && item->parent()->compressed() == FALSE) {
|
if (item->compressed() && item->parent()->compressed() == FALSE) {
|
||||||
item->setFixed(item->parent()->fixed());
|
item->setFixed(item->parent()->fixed());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Propagate fixed flag until root
|
// Propagate fixed flag until root
|
||||||
setFixed(index.parent(), true);
|
setFixed(index.parent(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,10 +327,10 @@ void TreeModel::setCompressed(const UModelIndex &index, const bool compressed)
|
|||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||||
item->setCompressed(compressed);
|
item->setCompressed(compressed);
|
||||||
|
|
||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,10 +345,10 @@ void TreeModel::setMarking(const UModelIndex &index, const UINT8 marking)
|
|||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||||
item->setMarking(marking);
|
item->setMarking(marking);
|
||||||
|
|
||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,7 +356,7 @@ void TreeModel::setOffset(const UModelIndex &index, const UINT32 offset)
|
|||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||||
item->setOffset(offset);
|
item->setOffset(offset);
|
||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
@ -366,7 +366,7 @@ void TreeModel::setType(const UModelIndex &index, const UINT8 data)
|
|||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||||
item->setType(data);
|
item->setType(data);
|
||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
@ -376,7 +376,7 @@ void TreeModel::setSubtype(const UModelIndex & index, const UINT8 subtype)
|
|||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||||
item->setSubtype(subtype);
|
item->setSubtype(subtype);
|
||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
@ -386,7 +386,7 @@ void TreeModel::setName(const UModelIndex &index, const UString &data)
|
|||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||||
item->setName(data);
|
item->setName(data);
|
||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
@ -396,7 +396,7 @@ void TreeModel::setText(const UModelIndex &index, const UString &data)
|
|||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||||
item->setText(data);
|
item->setText(data);
|
||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
@ -406,7 +406,7 @@ void TreeModel::setInfo(const UModelIndex &index, const UString &data)
|
|||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||||
item->setInfo(data);
|
item->setInfo(data);
|
||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
@ -416,7 +416,7 @@ void TreeModel::addInfo(const UModelIndex &index, const UString &data, const boo
|
|||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||||
item->addInfo(data, append);
|
item->addInfo(data, append);
|
||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
@ -426,7 +426,7 @@ void TreeModel::setAction(const UModelIndex &index, const UINT8 action)
|
|||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||||
item->setAction(action);
|
item->setAction(action);
|
||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
@ -436,7 +436,7 @@ UByteArray TreeModel::parsingData(const UModelIndex &index) const
|
|||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return UByteArray();
|
return UByteArray();
|
||||||
|
|
||||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||||
return item->parsingData();
|
return item->parsingData();
|
||||||
}
|
}
|
||||||
@ -445,7 +445,7 @@ bool TreeModel::hasEmptyParsingData(const UModelIndex &index) const
|
|||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||||
return item->hasEmptyParsingData();
|
return item->hasEmptyParsingData();
|
||||||
}
|
}
|
||||||
@ -454,7 +454,7 @@ void TreeModel::setParsingData(const UModelIndex &index, const UByteArray &data)
|
|||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||||
item->setParsingData(data);
|
item->setParsingData(data);
|
||||||
emit dataChanged(this->index(0, 0), index);
|
emit dataChanged(this->index(0, 0), index);
|
||||||
@ -464,7 +464,7 @@ UByteArray TreeModel::uncompressedData(const UModelIndex &index) const
|
|||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return UByteArray();
|
return UByteArray();
|
||||||
|
|
||||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||||
return item->uncompressedData();
|
return item->uncompressedData();
|
||||||
}
|
}
|
||||||
@ -473,7 +473,7 @@ bool TreeModel::hasEmptyUncompressedData(const UModelIndex &index) const
|
|||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||||
return item->hasEmptyUncompressedData();
|
return item->hasEmptyUncompressedData();
|
||||||
}
|
}
|
||||||
@ -482,22 +482,22 @@ void TreeModel::setUncompressedData(const UModelIndex &index, const UByteArray &
|
|||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||||
item->setUncompressedData(data);
|
item->setUncompressedData(data);
|
||||||
emit dataChanged(this->index(0, 0), index);
|
emit dataChanged(this->index(0, 0), index);
|
||||||
}
|
}
|
||||||
|
|
||||||
UModelIndex TreeModel::addItem(const UINT32 offset, const UINT8 type, const UINT8 subtype,
|
UModelIndex TreeModel::addItem(const UINT32 offset, const UINT8 type, const UINT8 subtype,
|
||||||
const UString & name, const UString & text, const UString & info,
|
const UString & name, const UString & text, const UString & info,
|
||||||
const UByteArray & header, const UByteArray & body, const UByteArray & tail,
|
const UByteArray & header, const UByteArray & body, const UByteArray & tail,
|
||||||
const ItemFixedState fixed,
|
const ItemFixedState fixed,
|
||||||
const UModelIndex & parent, const UINT8 mode)
|
const UModelIndex & parent, const UINT8 mode)
|
||||||
{
|
{
|
||||||
TreeItem *item = 0;
|
TreeItem *item = 0;
|
||||||
TreeItem *parentItem = 0;
|
TreeItem *parentItem = 0;
|
||||||
int parentColumn = 0;
|
int parentColumn = 0;
|
||||||
|
|
||||||
if (!parent.isValid())
|
if (!parent.isValid())
|
||||||
parentItem = rootItem;
|
parentItem = rootItem;
|
||||||
else
|
else
|
||||||
@ -512,9 +512,9 @@ UModelIndex TreeModel::addItem(const UINT32 offset, const UINT8 type, const UINT
|
|||||||
parentColumn = parent.column();
|
parentColumn = parent.column();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeItem *newItem = new TreeItem(offset, type, subtype, name, text, info, header, body, tail, Movable, this->compressed(parent), parentItem);
|
TreeItem *newItem = new TreeItem(offset, type, subtype, name, text, info, header, body, tail, Movable, this->compressed(parent), parentItem);
|
||||||
|
|
||||||
if (mode == CREATE_MODE_APPEND) {
|
if (mode == CREATE_MODE_APPEND) {
|
||||||
emit layoutAboutToBeChanged();
|
emit layoutAboutToBeChanged();
|
||||||
parentItem->appendChild(newItem);
|
parentItem->appendChild(newItem);
|
||||||
@ -535,9 +535,9 @@ UModelIndex TreeModel::addItem(const UINT32 offset, const UINT8 type, const UINT
|
|||||||
delete newItem;
|
delete newItem;
|
||||||
return UModelIndex();
|
return UModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
emit layoutChanged();
|
emit layoutChanged();
|
||||||
|
|
||||||
UModelIndex created = createIndex(newItem->row(), parentColumn, newItem);
|
UModelIndex created = createIndex(newItem->row(), parentColumn, newItem);
|
||||||
setFixed(created, (bool)fixed); // Non-trivial logic requires additional call
|
setFixed(created, (bool)fixed); // Non-trivial logic requires additional call
|
||||||
return created;
|
return created;
|
||||||
@ -547,17 +547,17 @@ UModelIndex TreeModel::findParentOfType(const UModelIndex& index, UINT8 type) co
|
|||||||
{
|
{
|
||||||
if (!index.isValid() || !index.parent().isValid())
|
if (!index.isValid() || !index.parent().isValid())
|
||||||
return UModelIndex();
|
return UModelIndex();
|
||||||
|
|
||||||
TreeItem *item;
|
TreeItem *item;
|
||||||
UModelIndex parent = index.parent();
|
UModelIndex parent = index.parent();
|
||||||
|
|
||||||
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;
|
||||||
item = static_cast<TreeItem*>(parent.internalPointer()))
|
item = static_cast<TreeItem*>(parent.internalPointer()))
|
||||||
parent = parent.parent();
|
parent = parent.parent();
|
||||||
if (item != NULL && item != rootItem)
|
if (item != NULL && item != rootItem)
|
||||||
return parent;
|
return parent;
|
||||||
|
|
||||||
return UModelIndex();
|
return UModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -565,30 +565,30 @@ UModelIndex TreeModel::findLastParentOfType(const UModelIndex& index, UINT8 type
|
|||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return UModelIndex();
|
return UModelIndex();
|
||||||
|
|
||||||
UModelIndex lastParentOfType = findParentOfType(index, type);
|
UModelIndex lastParentOfType = findParentOfType(index, type);
|
||||||
|
|
||||||
if (!lastParentOfType.isValid())
|
if (!lastParentOfType.isValid())
|
||||||
return UModelIndex();
|
return UModelIndex();
|
||||||
|
|
||||||
UModelIndex currentParentOfType = findParentOfType(lastParentOfType, type);
|
UModelIndex currentParentOfType = findParentOfType(lastParentOfType, type);
|
||||||
while (currentParentOfType.isValid()) {
|
while (currentParentOfType.isValid()) {
|
||||||
lastParentOfType = currentParentOfType;
|
lastParentOfType = currentParentOfType;
|
||||||
currentParentOfType = findParentOfType(lastParentOfType, type);
|
currentParentOfType = findParentOfType(lastParentOfType, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
return lastParentOfType;
|
return lastParentOfType;
|
||||||
}
|
}
|
||||||
|
|
||||||
UModelIndex TreeModel::findByBase(UINT32 base) const
|
UModelIndex TreeModel::findByBase(UINT32 base) const
|
||||||
{
|
{
|
||||||
UModelIndex parentIndex = index(0,0);
|
UModelIndex parentIndex = index(0,0);
|
||||||
|
|
||||||
goDeeper:
|
goDeeper:
|
||||||
int n = rowCount(parentIndex);
|
int n = rowCount(parentIndex);
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
UModelIndex currentIndex = parentIndex.model()->index(i, 0, parentIndex);
|
UModelIndex currentIndex = parentIndex.model()->index(i, 0, parentIndex);
|
||||||
|
|
||||||
UINT32 currentBase = this->base(currentIndex);
|
UINT32 currentBase = this->base(currentIndex);
|
||||||
UINT32 fullSize = (UINT32)(header(currentIndex).size() + body(currentIndex).size() + tail(currentIndex).size());
|
UINT32 fullSize = (UINT32)(header(currentIndex).size() + body(currentIndex).size() + tail(currentIndex).size());
|
||||||
if ((compressed(currentIndex) == false || (compressed(currentIndex) == true && compressed(currentIndex.parent()) == false)) // Base is meaningful only for true uncompressed items
|
if ((compressed(currentIndex) == false || (compressed(currentIndex) == true && compressed(currentIndex.parent()) == false)) // Base is meaningful only for true uncompressed items
|
||||||
@ -598,6 +598,6 @@ goDeeper:
|
|||||||
goto goDeeper;
|
goto goDeeper;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (parentIndex == index(0, 0) ? UModelIndex() : parentIndex);
|
return (parentIndex == index(0, 0) ? UModelIndex() : parentIndex);
|
||||||
}
|
}
|
||||||
|
344
common/types.cpp
344
common/types.cpp
@ -1,14 +1,14 @@
|
|||||||
/* types.cpp
|
/* types.cpp
|
||||||
|
|
||||||
Copyright (c) 2016, Nikolaj Schlej. All rights reserved.
|
Copyright (c) 2016, Nikolaj Schlej. All rights reserved.
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
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 "ustring.h"
|
#include "ustring.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
@ -18,202 +18,202 @@ WITHWARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
UString regionTypeToUString(const UINT8 type)
|
UString regionTypeToUString(const UINT8 type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Subtypes::DescriptorRegion: return UString("Descriptor");
|
case Subtypes::DescriptorRegion: return UString("Descriptor");
|
||||||
case Subtypes::BiosRegion: return UString("BIOS");
|
case Subtypes::BiosRegion: return UString("BIOS");
|
||||||
case Subtypes::MeRegion: return UString("ME");
|
case Subtypes::MeRegion: return UString("ME");
|
||||||
case Subtypes::GbeRegion: return UString("GbE");
|
case Subtypes::GbeRegion: return UString("GbE");
|
||||||
case Subtypes::PdrRegion: return UString("PDR");
|
case Subtypes::PdrRegion: return UString("PDR");
|
||||||
case Subtypes::DevExp1Region: return UString("DevExp1");
|
case Subtypes::DevExp1Region: return UString("DevExp1");
|
||||||
case Subtypes::Bios2Region: return UString("BIOS2");
|
case Subtypes::Bios2Region: return UString("BIOS2");
|
||||||
case Subtypes::MicrocodeRegion: return UString("Microcode");
|
case Subtypes::MicrocodeRegion: return UString("Microcode");
|
||||||
case Subtypes::EcRegion: return UString("EC");
|
case Subtypes::EcRegion: return UString("EC");
|
||||||
case Subtypes::DevExp2Region: return UString("DevExp2");
|
case Subtypes::DevExp2Region: return UString("DevExp2");
|
||||||
case Subtypes::IeRegion: return UString("IE");
|
case Subtypes::IeRegion: return UString("IE");
|
||||||
case Subtypes::Tgbe1Region: return UString("10GbE1");
|
case Subtypes::Tgbe1Region: return UString("10GbE1");
|
||||||
case Subtypes::Tgbe2Region: return UString("10GbE2");
|
case Subtypes::Tgbe2Region: return UString("10GbE2");
|
||||||
case Subtypes::Reserved1Region: return UString("Reserved1");
|
case Subtypes::Reserved1Region: return UString("Reserved1");
|
||||||
case Subtypes::Reserved2Region: return UString("Reserved2");
|
case Subtypes::Reserved2Region: return UString("Reserved2");
|
||||||
case Subtypes::PttRegion: return UString("PTT");
|
case Subtypes::PttRegion: return UString("PTT");
|
||||||
};
|
};
|
||||||
|
|
||||||
return UString("Unknown");
|
return UString("Unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
UString itemTypeToUString(const UINT8 type)
|
UString itemTypeToUString(const UINT8 type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Types::Root: return UString("Root");
|
case Types::Root: return UString("Root");
|
||||||
case Types::Image: return UString("Image");
|
case Types::Image: return UString("Image");
|
||||||
case Types::Capsule: return UString("Capsule");
|
case Types::Capsule: return UString("Capsule");
|
||||||
case Types::Region: return UString("Region");
|
case Types::Region: return UString("Region");
|
||||||
case Types::Volume: return UString("Volume");
|
case Types::Volume: return UString("Volume");
|
||||||
case Types::Padding: return UString("Padding");
|
case Types::Padding: return UString("Padding");
|
||||||
case Types::File: return UString("File");
|
case Types::File: return UString("File");
|
||||||
case Types::Section: return UString("Section");
|
case Types::Section: return UString("Section");
|
||||||
case Types::FreeSpace: return UString("Free space");
|
case Types::FreeSpace: return UString("Free space");
|
||||||
case Types::VssStore: return UString("VSS store");
|
case Types::VssStore: return UString("VSS store");
|
||||||
case Types::Vss2Store: return UString("VSS2 store");
|
case Types::Vss2Store: return UString("VSS2 store");
|
||||||
case Types::FtwStore: return UString("FTW store");
|
case Types::FtwStore: return UString("FTW store");
|
||||||
case Types::FdcStore: return UString("FDC store");
|
case Types::FdcStore: return UString("FDC store");
|
||||||
case Types::FsysStore: return UString("Fsys store");
|
case Types::FsysStore: return UString("Fsys store");
|
||||||
case Types::EvsaStore: return UString("EVSA store");
|
case Types::EvsaStore: return UString("EVSA store");
|
||||||
case Types::CmdbStore: return UString("CMDB store");
|
case Types::CmdbStore: return UString("CMDB store");
|
||||||
case Types::FlashMapStore: return UString("FlashMap store");
|
case Types::FlashMapStore: return UString("FlashMap store");
|
||||||
case Types::NvarEntry: return UString("NVAR entry");
|
case Types::NvarEntry: return UString("NVAR entry");
|
||||||
case Types::VssEntry: return UString("VSS entry");
|
case Types::VssEntry: return UString("VSS entry");
|
||||||
case Types::FsysEntry: return UString("Fsys entry");
|
case Types::FsysEntry: return UString("Fsys entry");
|
||||||
case Types::EvsaEntry: return UString("EVSA entry");
|
case Types::EvsaEntry: return UString("EVSA entry");
|
||||||
case Types::FlashMapEntry: return UString("FlashMap entry");
|
case Types::FlashMapEntry: return UString("FlashMap entry");
|
||||||
case Types::Microcode: return UString("Microcode");
|
case Types::Microcode: return UString("Microcode");
|
||||||
case Types::SlicData: return UString("SLIC data");
|
case Types::SlicData: return UString("SLIC data");
|
||||||
// ME-specific
|
// ME-specific
|
||||||
case Types::FptStore: return UString("FPT store");
|
case Types::FptStore: return UString("FPT store");
|
||||||
case Types::FptEntry: return UString("FPT entry");
|
case Types::FptEntry: return UString("FPT entry");
|
||||||
case Types::IfwiHeader: return UString("IFWI header");
|
case Types::IfwiHeader: return UString("IFWI header");
|
||||||
case Types::IfwiPartition: return UString("IFWI partition");
|
case Types::IfwiPartition: return UString("IFWI partition");
|
||||||
case Types::FptPartition: return UString("FPT partition");
|
case Types::FptPartition: return UString("FPT partition");
|
||||||
case Types::BpdtStore: return UString("BPDT store");
|
case Types::BpdtStore: return UString("BPDT store");
|
||||||
case Types::BpdtEntry: return UString("BPDT entry");
|
case Types::BpdtEntry: return UString("BPDT entry");
|
||||||
case Types::BpdtPartition: return UString("BPDT partition");
|
case Types::BpdtPartition: return UString("BPDT partition");
|
||||||
case Types::CpdStore: return UString("CPD store");
|
case Types::CpdStore: return UString("CPD store");
|
||||||
case Types::CpdEntry: return UString("CPD entry");
|
case Types::CpdEntry: return UString("CPD entry");
|
||||||
case Types::CpdPartition: return UString("CPD partition");
|
case Types::CpdPartition: return UString("CPD partition");
|
||||||
case Types::CpdExtension: return UString("CPD extension");
|
case Types::CpdExtension: return UString("CPD extension");
|
||||||
case Types::CpdSpiEntry: return UString("CPD SPI entry");
|
case Types::CpdSpiEntry: return UString("CPD SPI entry");
|
||||||
}
|
}
|
||||||
|
|
||||||
return UString("Unknown");
|
return UString("Unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
UString itemSubtypeToUString(const UINT8 type, const UINT8 subtype)
|
UString itemSubtypeToUString(const UINT8 type, const UINT8 subtype)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Types::Image:
|
case Types::Image:
|
||||||
if (subtype == Subtypes::IntelImage) return UString("Intel");
|
if (subtype == Subtypes::IntelImage) return UString("Intel");
|
||||||
if (subtype == Subtypes::UefiImage) return UString("UEFI");
|
if (subtype == Subtypes::UefiImage) return UString("UEFI");
|
||||||
break;
|
break;
|
||||||
case Types::Padding:
|
case Types::Padding:
|
||||||
if (subtype == Subtypes::ZeroPadding) return UString("Empty (0x00)");
|
if (subtype == Subtypes::ZeroPadding) return UString("Empty (0x00)");
|
||||||
if (subtype == Subtypes::OnePadding) return UString("Empty (0xFF)");
|
if (subtype == Subtypes::OnePadding) return UString("Empty (0xFF)");
|
||||||
if (subtype == Subtypes::DataPadding) return UString("Non-empty");
|
if (subtype == Subtypes::DataPadding) return UString("Non-empty");
|
||||||
break;
|
break;
|
||||||
case Types::Volume:
|
case Types::Volume:
|
||||||
if (subtype == Subtypes::UnknownVolume) return UString("Unknown");
|
if (subtype == Subtypes::UnknownVolume) return UString("Unknown");
|
||||||
if (subtype == Subtypes::Ffs2Volume) return UString("FFSv2");
|
if (subtype == Subtypes::Ffs2Volume) return UString("FFSv2");
|
||||||
if (subtype == Subtypes::Ffs3Volume) return UString("FFSv3");
|
if (subtype == Subtypes::Ffs3Volume) return UString("FFSv3");
|
||||||
if (subtype == Subtypes::NvramVolume) return UString("NVRAM");
|
if (subtype == Subtypes::NvramVolume) return UString("NVRAM");
|
||||||
if (subtype == Subtypes::MicrocodeVolume) return UString("Microcode");
|
if (subtype == Subtypes::MicrocodeVolume) return UString("Microcode");
|
||||||
break;
|
break;
|
||||||
case Types::Capsule:
|
case Types::Capsule:
|
||||||
if (subtype == Subtypes::AptioSignedCapsule) return UString("Aptio signed");
|
if (subtype == Subtypes::AptioSignedCapsule) return UString("Aptio signed");
|
||||||
if (subtype == Subtypes::AptioUnsignedCapsule) return UString("Aptio unsigned");
|
if (subtype == Subtypes::AptioUnsignedCapsule) return UString("Aptio unsigned");
|
||||||
if (subtype == Subtypes::UefiCapsule) return UString("UEFI 2.0");
|
if (subtype == Subtypes::UefiCapsule) return UString("UEFI 2.0");
|
||||||
if (subtype == Subtypes::ToshibaCapsule) return UString("Toshiba");
|
if (subtype == Subtypes::ToshibaCapsule) return UString("Toshiba");
|
||||||
break;
|
break;
|
||||||
case Types::Region: return regionTypeToUString(subtype);
|
case Types::Region: return regionTypeToUString(subtype);
|
||||||
case Types::File: return fileTypeToUString(subtype);
|
case Types::File: return fileTypeToUString(subtype);
|
||||||
case Types::Section: return sectionTypeToUString(subtype);
|
case Types::Section: return sectionTypeToUString(subtype);
|
||||||
case Types::NvarEntry:
|
case Types::NvarEntry:
|
||||||
if (subtype == Subtypes::InvalidNvarEntry) return UString("Invalid");
|
if (subtype == Subtypes::InvalidNvarEntry) return UString("Invalid");
|
||||||
if (subtype == Subtypes::InvalidLinkNvarEntry) return UString("Invalid link");
|
if (subtype == Subtypes::InvalidLinkNvarEntry) return UString("Invalid link");
|
||||||
if (subtype == Subtypes::LinkNvarEntry) return UString("Link");
|
if (subtype == Subtypes::LinkNvarEntry) return UString("Link");
|
||||||
if (subtype == Subtypes::DataNvarEntry) return UString("Data");
|
if (subtype == Subtypes::DataNvarEntry) return UString("Data");
|
||||||
if (subtype == Subtypes::FullNvarEntry) return UString("Full");
|
if (subtype == Subtypes::FullNvarEntry) return UString("Full");
|
||||||
break;
|
break;
|
||||||
case Types::VssEntry:
|
case Types::VssEntry:
|
||||||
if (subtype == Subtypes::InvalidVssEntry) return UString("Invalid");
|
if (subtype == Subtypes::InvalidVssEntry) return UString("Invalid");
|
||||||
if (subtype == Subtypes::StandardVssEntry) return UString("Standard");
|
if (subtype == Subtypes::StandardVssEntry) return UString("Standard");
|
||||||
if (subtype == Subtypes::AppleVssEntry) return UString("Apple");
|
if (subtype == Subtypes::AppleVssEntry) return UString("Apple");
|
||||||
if (subtype == Subtypes::AuthVssEntry) return UString("Auth");
|
if (subtype == Subtypes::AuthVssEntry) return UString("Auth");
|
||||||
if (subtype == Subtypes::IntelVssEntry) return UString("Intel");
|
if (subtype == Subtypes::IntelVssEntry) return UString("Intel");
|
||||||
break;
|
break;
|
||||||
case Types::FsysEntry:
|
case Types::FsysEntry:
|
||||||
if (subtype == Subtypes::InvalidFsysEntry) return UString("Invalid");
|
if (subtype == Subtypes::InvalidFsysEntry) return UString("Invalid");
|
||||||
if (subtype == Subtypes::NormalFsysEntry) return UString("Normal");
|
if (subtype == Subtypes::NormalFsysEntry) return UString("Normal");
|
||||||
break;
|
break;
|
||||||
case Types::EvsaEntry:
|
case Types::EvsaEntry:
|
||||||
if (subtype == Subtypes::InvalidEvsaEntry) return UString("Invalid");
|
if (subtype == Subtypes::InvalidEvsaEntry) return UString("Invalid");
|
||||||
if (subtype == Subtypes::UnknownEvsaEntry) return UString("Unknown");
|
if (subtype == Subtypes::UnknownEvsaEntry) return UString("Unknown");
|
||||||
if (subtype == Subtypes::GuidEvsaEntry) return UString("GUID");
|
if (subtype == Subtypes::GuidEvsaEntry) return UString("GUID");
|
||||||
if (subtype == Subtypes::NameEvsaEntry) return UString("Name");
|
if (subtype == Subtypes::NameEvsaEntry) return UString("Name");
|
||||||
if (subtype == Subtypes::DataEvsaEntry) return UString("Data");
|
if (subtype == Subtypes::DataEvsaEntry) return UString("Data");
|
||||||
break;
|
break;
|
||||||
case Types::FlashMapEntry:
|
case Types::FlashMapEntry:
|
||||||
if (subtype == Subtypes::VolumeFlashMapEntry) return UString("Volume");
|
if (subtype == Subtypes::VolumeFlashMapEntry) return UString("Volume");
|
||||||
if (subtype == Subtypes::DataFlashMapEntry) return UString("Data");
|
if (subtype == Subtypes::DataFlashMapEntry) return UString("Data");
|
||||||
break;
|
break;
|
||||||
case Types::Microcode:
|
case Types::Microcode:
|
||||||
if (subtype == Subtypes::IntelMicrocode) return UString("Intel");
|
if (subtype == Subtypes::IntelMicrocode) return UString("Intel");
|
||||||
if (subtype == Subtypes::AmdMicrocode) return UString("AMD");
|
if (subtype == Subtypes::AmdMicrocode) return UString("AMD");
|
||||||
break;
|
break;
|
||||||
// ME-specific
|
// ME-specific
|
||||||
case Types::FptEntry:
|
case Types::FptEntry:
|
||||||
if (subtype == Subtypes::ValidFptEntry) return UString("Valid");
|
if (subtype == Subtypes::ValidFptEntry) return UString("Valid");
|
||||||
if (subtype == Subtypes::InvalidFptEntry) return UString("Invalid");
|
if (subtype == Subtypes::InvalidFptEntry) return UString("Invalid");
|
||||||
break;
|
break;
|
||||||
case Types::FptPartition:
|
case Types::FptPartition:
|
||||||
if (subtype == Subtypes::CodeFptPartition) return UString("Code");
|
if (subtype == Subtypes::CodeFptPartition) return UString("Code");
|
||||||
if (subtype == Subtypes::DataFptPartition) return UString("Data");
|
if (subtype == Subtypes::DataFptPartition) return UString("Data");
|
||||||
if (subtype == Subtypes::GlutFptPartition) return UString("GLUT");
|
if (subtype == Subtypes::GlutFptPartition) return UString("GLUT");
|
||||||
break;
|
break;
|
||||||
case Types::IfwiPartition:
|
case Types::IfwiPartition:
|
||||||
if (subtype == Subtypes::BootIfwiPartition) return UString("Boot");
|
if (subtype == Subtypes::BootIfwiPartition) return UString("Boot");
|
||||||
if (subtype == Subtypes::DataIfwiPartition) return UString("Data");
|
if (subtype == Subtypes::DataIfwiPartition) return UString("Data");
|
||||||
break;
|
break;
|
||||||
case Types::CpdPartition:
|
case Types::CpdPartition:
|
||||||
if (subtype == Subtypes::ManifestCpdPartition) return UString("Manifest");
|
if (subtype == Subtypes::ManifestCpdPartition) return UString("Manifest");
|
||||||
if (subtype == Subtypes::MetadataCpdPartition) return UString("Metadata");
|
if (subtype == Subtypes::MetadataCpdPartition) return UString("Metadata");
|
||||||
if (subtype == Subtypes::KeyCpdPartition) return UString("Key");
|
if (subtype == Subtypes::KeyCpdPartition) return UString("Key");
|
||||||
if (subtype == Subtypes::CodeCpdPartition) return UString("Code");
|
if (subtype == Subtypes::CodeCpdPartition) return UString("Code");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return UString();
|
return UString();
|
||||||
}
|
}
|
||||||
|
|
||||||
UString compressionTypeToUString(const UINT8 algorithm)
|
UString compressionTypeToUString(const UINT8 algorithm)
|
||||||
{
|
{
|
||||||
switch (algorithm) {
|
switch (algorithm) {
|
||||||
case COMPRESSION_ALGORITHM_NONE: return UString("None");
|
case COMPRESSION_ALGORITHM_NONE: return UString("None");
|
||||||
case COMPRESSION_ALGORITHM_EFI11: return UString("EFI 1.1");
|
case COMPRESSION_ALGORITHM_EFI11: return UString("EFI 1.1");
|
||||||
case COMPRESSION_ALGORITHM_TIANO: return UString("Tiano");
|
case COMPRESSION_ALGORITHM_TIANO: return UString("Tiano");
|
||||||
case COMPRESSION_ALGORITHM_UNDECIDED: return UString("Undecided Tiano/EFI 1.1");
|
case COMPRESSION_ALGORITHM_UNDECIDED: return UString("Undecided Tiano/EFI 1.1");
|
||||||
case COMPRESSION_ALGORITHM_LZMA: return UString("LZMA");
|
case COMPRESSION_ALGORITHM_LZMA: return UString("LZMA");
|
||||||
case COMPRESSION_ALGORITHM_LZMA_INTEL_LEGACY: return UString("Intel legacy LZMA");
|
case COMPRESSION_ALGORITHM_LZMA_INTEL_LEGACY: return UString("Intel legacy LZMA");
|
||||||
}
|
}
|
||||||
|
|
||||||
return UString("Unknown");
|
return UString("Unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
UString actionTypeToUString(const UINT8 action)
|
UString actionTypeToUString(const UINT8 action)
|
||||||
{
|
{
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case Actions::NoAction: return UString();
|
case Actions::NoAction: return UString();
|
||||||
case Actions::Create: return UString("Create");
|
case Actions::Create: return UString("Create");
|
||||||
case Actions::Insert: return UString("Insert");
|
case Actions::Insert: return UString("Insert");
|
||||||
case Actions::Replace: return UString("Replace");
|
case Actions::Replace: return UString("Replace");
|
||||||
case Actions::Remove: return UString("Remove");
|
case Actions::Remove: return UString("Remove");
|
||||||
case Actions::Rebuild: return UString("Rebuild");
|
case Actions::Rebuild: return UString("Rebuild");
|
||||||
case Actions::Rebase: return UString("Rebase");
|
case Actions::Rebase: return UString("Rebase");
|
||||||
}
|
}
|
||||||
|
|
||||||
return UString("Unknown");
|
return UString("Unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
UString fitEntryTypeToUString(const UINT8 type)
|
UString fitEntryTypeToUString(const UINT8 type)
|
||||||
{
|
{
|
||||||
switch (type & 0x7F) {
|
switch (type & 0x7F) {
|
||||||
case FIT_TYPE_HEADER: return UString("FIT Header");
|
case FIT_TYPE_HEADER: return UString("FIT Header");
|
||||||
case FIT_TYPE_MICROCODE: return UString("Microcode");
|
case FIT_TYPE_MICROCODE: return UString("Microcode");
|
||||||
case FIT_TYPE_BIOS_AC_MODULE: return UString("BIOS ACM");
|
case FIT_TYPE_BIOS_AC_MODULE: return UString("BIOS ACM");
|
||||||
case FIT_TYPE_BIOS_INIT_MODULE: return UString("BIOS Init");
|
case FIT_TYPE_BIOS_INIT_MODULE: return UString("BIOS Init");
|
||||||
case FIT_TYPE_TPM_POLICY: return UString("TPM Policy");
|
case FIT_TYPE_TPM_POLICY: return UString("TPM Policy");
|
||||||
case FIT_TYPE_BIOS_POLICY_DATA: return UString("BIOS Policy Data");
|
case FIT_TYPE_BIOS_POLICY_DATA: return UString("BIOS Policy Data");
|
||||||
case FIT_TYPE_TXT_CONF_POLICY: return UString("TXT Configuration Policy");
|
case FIT_TYPE_TXT_CONF_POLICY: return UString("TXT Configuration Policy");
|
||||||
case FIT_TYPE_AC_KEY_MANIFEST: return UString("BootGuard Key Manifest");
|
case FIT_TYPE_AC_KEY_MANIFEST: return UString("BootGuard Key Manifest");
|
||||||
case FIT_TYPE_AC_BOOT_POLICY: return UString("BootGuard Boot Policy");
|
case FIT_TYPE_AC_BOOT_POLICY: return UString("BootGuard Boot Policy");
|
||||||
case FIT_TYPE_EMPTY: return UString("Empty");
|
case FIT_TYPE_EMPTY: return UString("Empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
return UString("Unknown");
|
return UString("Unknown");
|
||||||
}
|
}
|
||||||
|
@ -16,25 +16,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
// A workaround for compilers not supporting c++11 and c11
|
// A workaround for compilers not supporting c++11 and c11
|
||||||
// for using PRIX64.
|
// for using PRIX64.
|
||||||
#define __STDC_FORMAT_MACROS
|
#define __STDC_FORMAT_MACROS
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#if QT_VERSION_MAJOR >= 6
|
|
||||||
# define PRIdQ __PRI_64_LENGTH_MODIFIER__ "d"
|
|
||||||
# define PRIiQ __PRI_64_LENGTH_MODIFIER__ "i"
|
|
||||||
# define PRIoQ __PRI_64_LENGTH_MODIFIER__ "o"
|
|
||||||
# define PRIuQ __PRI_64_LENGTH_MODIFIER__ "u"
|
|
||||||
# define PRIxQ __PRI_64_LENGTH_MODIFIER__ "x"
|
|
||||||
# define PRIXQ __PRI_64_LENGTH_MODIFIER__ "X"
|
|
||||||
#else
|
|
||||||
# define PRIdQ "d"
|
|
||||||
# define PRIiQ "i"
|
|
||||||
# define PRIoQ "o"
|
|
||||||
# define PRIuQ "u"
|
|
||||||
# define PRIxQ "x"
|
|
||||||
# define PRIXQ "X"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__clang__) || defined(__GNUC__)
|
#if defined(__clang__) || defined(__GNUC__)
|
||||||
#define ATTRIBUTE_FORMAT_(t,f,a) __attribute__((format(t, f, a)))
|
#define ATTRIBUTE_FORMAT_(t,f,a) __attribute__((format(t, f, a)))
|
||||||
#else
|
#else
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
/* ustring.cpp
|
/* ustring.cpp
|
||||||
|
|
||||||
Copyright (c) 2016, Nikolaj Schlej. All rights reserved.
|
Copyright (c) 2016, Nikolaj Schlej. All rights reserved.
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
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 "ustring.h"
|
#include "ustring.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@ -19,9 +19,9 @@ UString usprintf(const char* fmt, ...)
|
|||||||
UString msg;
|
UString msg;
|
||||||
va_list vl;
|
va_list vl;
|
||||||
va_start(vl, fmt);
|
va_start(vl, fmt);
|
||||||
|
|
||||||
msg = msg.vasprintf(fmt, vl);
|
msg = msg.vasprintf(fmt, vl);
|
||||||
|
|
||||||
va_end(vl);
|
va_end(vl);
|
||||||
return msg;
|
return msg;
|
||||||
};
|
};
|
||||||
@ -37,16 +37,16 @@ UString urepeated(char c, int len)
|
|||||||
#else
|
#else
|
||||||
#ifdef BSTRLIB_NOVSNP
|
#ifdef BSTRLIB_NOVSNP
|
||||||
/* This is just a hack. If you are using a system without a vsnprintf, it is
|
/* This is just a hack. If you are using a system without a vsnprintf, it is
|
||||||
not recommended that bformat be used at all. */
|
not recommended that bformat be used at all. */
|
||||||
#define exvsnprintf(r,b,n,f,a) {vsprintf (b,f,a); r = -1;}
|
#define exvsnprintf(r,b,n,f,a) {vsprintf (b,f,a); r = -1;}
|
||||||
#define START_VSNBUFF (256)
|
#define START_VSNBUFF (256)
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#if defined (__GNUC__) && !defined (__PPC__) && !defined(__WIN32__)
|
#if defined (__GNUC__) && !defined (__PPC__) && !defined(__WIN32__)
|
||||||
/* Something is making gcc complain about this prototype not being here, so
|
/* Something is making gcc complain about this prototype not being here, so
|
||||||
I've just gone ahead and put it in. */
|
I've just gone ahead and put it in. */
|
||||||
extern "C" {
|
extern "C" {
|
||||||
extern int vsnprintf(char *buf, size_t count, const char *format, va_list arg);
|
extern int vsnprintf(char *buf, size_t count, const char *format, va_list arg);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -64,12 +64,12 @@ UString usprintf(const char* fmt, ...)
|
|||||||
bstring b;
|
bstring b;
|
||||||
va_list arglist;
|
va_list arglist;
|
||||||
int r, n;
|
int r, n;
|
||||||
|
|
||||||
if (fmt == NULL) {
|
if (fmt == NULL) {
|
||||||
msg = "<NULL>";
|
msg = "<NULL>";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
if ((b = bfromcstr("")) == NULL) {
|
if ((b = bfromcstr("")) == NULL) {
|
||||||
msg = "<NULL>";
|
msg = "<NULL>";
|
||||||
}
|
}
|
||||||
@ -80,14 +80,14 @@ UString usprintf(const char* fmt, ...)
|
|||||||
b = bformat("<NULL>");
|
b = bformat("<NULL>");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
va_start(arglist, fmt);
|
va_start(arglist, fmt);
|
||||||
exvsnprintf(r, (char *)b->data, n + 1, fmt, arglist);
|
exvsnprintf(r, (char *)b->data, n + 1, fmt, arglist);
|
||||||
va_end(arglist);
|
va_end(arglist);
|
||||||
|
|
||||||
b->data[n] = '\0';
|
b->data[n] = '\0';
|
||||||
b->slen = (int)(strlen)((char *)b->data);
|
b->slen = (int)(strlen)((char *)b->data);
|
||||||
|
|
||||||
if (b->slen < n) break;
|
if (b->slen < n) break;
|
||||||
if (r > n) n = r; else n += n;
|
if (r > n) n = r; else n += n;
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ UString usprintf(const char* fmt, ...)
|
|||||||
bdestroy(b);
|
bdestroy(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
/* utility.cpp
|
/* utility.cpp
|
||||||
|
|
||||||
Copyright (c) 2016, Nikolaj Schlej. All rights reserved.
|
Copyright (c) 2016, Nikolaj Schlej. All rights reserved.
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
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 <cstdio>
|
#include <cstdio>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
@ -40,7 +40,7 @@ UString visibleAsciiOrHex(UINT8* bytes, UINT32 length)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ascii) {
|
if (ascii) {
|
||||||
// No need to continue iterating over every symbol, we did it already
|
// No need to continue iterating over every symbol, we did it already
|
||||||
break;
|
break;
|
||||||
@ -49,7 +49,7 @@ UString visibleAsciiOrHex(UINT8* bytes, UINT32 length)
|
|||||||
else if (bytes[i] < '\x20' || bytes[i] > '\x7E') { // Explicit ascii codes to avoid locale dependency
|
else if (bytes[i] < '\x20' || bytes[i] > '\x7E') { // Explicit ascii codes to avoid locale dependency
|
||||||
ascii = false;
|
ascii = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ascii) {
|
if (ascii) {
|
||||||
asciiString += usprintf("%c", bytes[i]);
|
asciiString += usprintf("%c", bytes[i]);
|
||||||
}
|
}
|
||||||
@ -68,48 +68,48 @@ UString uniqueItemName(const UModelIndex & index)
|
|||||||
// Sanity check
|
// Sanity check
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return UString("Invalid_index");
|
return UString("Invalid_index");
|
||||||
|
|
||||||
// Get model from index
|
// Get model from index
|
||||||
const TreeModel* model = (const TreeModel*)index.model();
|
const TreeModel* model = (const TreeModel*)index.model();
|
||||||
|
|
||||||
// Construct the name
|
// Construct the name
|
||||||
UString itemName = model->name(index);
|
UString itemName = model->name(index);
|
||||||
UString itemText = model->text(index);
|
UString itemText = model->text(index);
|
||||||
|
|
||||||
// Default name
|
// Default name
|
||||||
UString name = itemName;
|
UString name = itemName;
|
||||||
switch (model->type(index)) {
|
switch (model->type(index)) {
|
||||||
case Types::NvarEntry:
|
case Types::NvarEntry:
|
||||||
case Types::VssEntry:
|
case Types::VssEntry:
|
||||||
case Types::FsysEntry:
|
case Types::FsysEntry:
|
||||||
case Types::EvsaEntry:
|
case Types::EvsaEntry:
|
||||||
case Types::FlashMapEntry:
|
case Types::FlashMapEntry:
|
||||||
case Types::File:
|
case Types::File:
|
||||||
name = itemText.isEmpty() ? itemName : itemName + '_' + itemText;
|
name = itemText.isEmpty() ? itemName : itemName + '_' + itemText;
|
||||||
break;
|
break;
|
||||||
case Types::Section: {
|
case Types::Section: {
|
||||||
// Get parent file name
|
// Get parent file name
|
||||||
UModelIndex fileIndex = model->findParentOfType(index, Types::File);
|
UModelIndex fileIndex = model->findParentOfType(index, Types::File);
|
||||||
UString fileText = model->text(fileIndex);
|
UString fileText = model->text(fileIndex);
|
||||||
name = fileText.isEmpty() ? model->name(fileIndex) : model->name(fileIndex) + '_' + fileText;
|
name = fileText.isEmpty() ? model->name(fileIndex) : model->name(fileIndex) + '_' + fileText;
|
||||||
|
|
||||||
// Special case of GUIDed sections
|
// Special case of GUIDed sections
|
||||||
if (model->subtype(index) == EFI_SECTION_GUID_DEFINED || model->subtype(index) == EFI_SECTION_FREEFORM_SUBTYPE_GUID) {
|
if (model->subtype(index) == EFI_SECTION_GUID_DEFINED || model->subtype(index) == EFI_SECTION_FREEFORM_SUBTYPE_GUID) {
|
||||||
name = model->name(index) +'_' + name;
|
name = model->name(index) +'_' + name;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populate subtypeString
|
// Populate subtypeString
|
||||||
UString subtypeString = itemSubtypeToUString(model->type(index), model->subtype(index));
|
UString subtypeString = itemSubtypeToUString(model->type(index), model->subtype(index));
|
||||||
|
|
||||||
// Create final name
|
// Create final name
|
||||||
name = itemTypeToUString(model->type(index))
|
name = itemTypeToUString(model->type(index))
|
||||||
+ (subtypeString.length() ? ('_' + subtypeString) : UString())
|
+ (subtypeString.length() ? ('_' + subtypeString) : UString())
|
||||||
+ '_' + name;
|
+ '_' + name;
|
||||||
|
|
||||||
fixFileName(name, true);
|
fixFileName(name, true);
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,10 +127,10 @@ void fixFileName(UString &name, bool replaceSpaces)
|
|||||||
name[i] < (char)0x20 || // ASCII control characters, banned in Windows, hard to work with in *nix
|
name[i] < (char)0x20 || // ASCII control characters, banned in Windows, hard to work with in *nix
|
||||||
name[i] > (char)0x7f || // high ASCII characters
|
name[i] > (char)0x7f || // high ASCII characters
|
||||||
(replaceSpaces && name[i] == ' ') // Provides better readability
|
(replaceSpaces && name[i] == ' ') // Provides better readability
|
||||||
) {
|
) {
|
||||||
name[i] = '_';
|
name[i] = '_';
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (size_t j = 0; j < sizeof(table); j++) {
|
for (size_t j = 0; j < sizeof(table); j++) {
|
||||||
if (name[i] == table[j]) {
|
if (name[i] == table[j]) {
|
||||||
name[i] = '_';
|
name[i] = '_';
|
||||||
@ -147,57 +147,57 @@ void fixFileName(UString &name, bool replaceSpaces)
|
|||||||
UString errorCodeToUString(USTATUS errorCode)
|
UString errorCodeToUString(USTATUS errorCode)
|
||||||
{
|
{
|
||||||
switch (errorCode) {
|
switch (errorCode) {
|
||||||
case U_SUCCESS: return UString("Success");
|
case U_SUCCESS: return UString("Success");
|
||||||
case U_NOT_IMPLEMENTED: return UString("Not implemented");
|
case U_NOT_IMPLEMENTED: return UString("Not implemented");
|
||||||
case U_INVALID_PARAMETER: return UString("Function called with invalid parameter");
|
case U_INVALID_PARAMETER: return UString("Function called with invalid parameter");
|
||||||
case U_BUFFER_TOO_SMALL: return UString("Buffer too small");
|
case U_BUFFER_TOO_SMALL: return UString("Buffer too small");
|
||||||
case U_OUT_OF_RESOURCES: return UString("Out of resources");
|
case U_OUT_OF_RESOURCES: return UString("Out of resources");
|
||||||
case U_OUT_OF_MEMORY: return UString("Out of memory");
|
case U_OUT_OF_MEMORY: return UString("Out of memory");
|
||||||
case U_FILE_OPEN: return UString("File can't be opened");
|
case U_FILE_OPEN: return UString("File can't be opened");
|
||||||
case U_FILE_READ: return UString("File can't be read");
|
case U_FILE_READ: return UString("File can't be read");
|
||||||
case U_FILE_WRITE: return UString("File can't be written");
|
case U_FILE_WRITE: return UString("File can't be written");
|
||||||
case U_ITEM_NOT_FOUND: return UString("Item not found");
|
case U_ITEM_NOT_FOUND: return UString("Item not found");
|
||||||
case U_UNKNOWN_ITEM_TYPE: return UString("Unknown item type");
|
case U_UNKNOWN_ITEM_TYPE: return UString("Unknown item type");
|
||||||
case U_INVALID_FLASH_DESCRIPTOR: return UString("Invalid flash descriptor");
|
case U_INVALID_FLASH_DESCRIPTOR: return UString("Invalid flash descriptor");
|
||||||
case U_INVALID_REGION: return UString("Invalid region");
|
case U_INVALID_REGION: return UString("Invalid region");
|
||||||
case U_EMPTY_REGION: return UString("Empty region");
|
case U_EMPTY_REGION: return UString("Empty region");
|
||||||
case U_BIOS_REGION_NOT_FOUND: return UString("BIOS region not found");
|
case U_BIOS_REGION_NOT_FOUND: return UString("BIOS region not found");
|
||||||
case U_VOLUMES_NOT_FOUND: return UString("UEFI volumes not found");
|
case U_VOLUMES_NOT_FOUND: return UString("UEFI volumes not found");
|
||||||
case U_INVALID_VOLUME: return UString("Invalid UEFI volume");
|
case U_INVALID_VOLUME: return UString("Invalid UEFI volume");
|
||||||
case U_VOLUME_REVISION_NOT_SUPPORTED: return UString("Volume revision not supported");
|
case U_VOLUME_REVISION_NOT_SUPPORTED: return UString("Volume revision not supported");
|
||||||
//case U_VOLUME_GROW_FAILED: return UString("Volume grow failed");
|
//case U_VOLUME_GROW_FAILED: return UString("Volume grow failed");
|
||||||
case U_UNKNOWN_FFS: return UString("Unknown file system");
|
case U_UNKNOWN_FFS: return UString("Unknown file system");
|
||||||
case U_INVALID_FILE: return UString("Invalid file");
|
case U_INVALID_FILE: return UString("Invalid file");
|
||||||
case U_INVALID_SECTION: return UString("Invalid section");
|
case U_INVALID_SECTION: return UString("Invalid section");
|
||||||
case U_UNKNOWN_SECTION: return UString("Unknown section");
|
case U_UNKNOWN_SECTION: return UString("Unknown section");
|
||||||
case U_STANDARD_COMPRESSION_FAILED: return UString("Standard compression failed");
|
case U_STANDARD_COMPRESSION_FAILED: return UString("Standard compression failed");
|
||||||
case U_CUSTOMIZED_COMPRESSION_FAILED: return UString("Customized compression failed");
|
case U_CUSTOMIZED_COMPRESSION_FAILED: return UString("Customized compression failed");
|
||||||
case U_STANDARD_DECOMPRESSION_FAILED: return UString("Standard decompression failed");
|
case U_STANDARD_DECOMPRESSION_FAILED: return UString("Standard decompression failed");
|
||||||
case U_CUSTOMIZED_DECOMPRESSION_FAILED: return UString("Customized decompression failed");
|
case U_CUSTOMIZED_DECOMPRESSION_FAILED: return UString("Customized decompression failed");
|
||||||
case U_UNKNOWN_COMPRESSION_TYPE: return UString("Unknown compression type");
|
case U_UNKNOWN_COMPRESSION_TYPE: return UString("Unknown compression type");
|
||||||
case U_UNKNOWN_EXTRACT_MODE: return UString("Unknown extract mode");
|
case U_UNKNOWN_EXTRACT_MODE: return UString("Unknown extract mode");
|
||||||
case U_UNKNOWN_REPLACE_MODE: return UString("Unknown replace mode");
|
case U_UNKNOWN_REPLACE_MODE: return UString("Unknown replace mode");
|
||||||
//case U_UNKNOWN_INSERT_MODE: return UString("Unknown insert mode");
|
//case U_UNKNOWN_INSERT_MODE: return UString("Unknown insert mode");
|
||||||
case U_UNKNOWN_IMAGE_TYPE: return UString("Unknown executable image type");
|
case U_UNKNOWN_IMAGE_TYPE: return UString("Unknown executable image type");
|
||||||
case U_UNKNOWN_PE_OPTIONAL_HEADER_TYPE: return UString("Unknown PE optional header type");
|
case U_UNKNOWN_PE_OPTIONAL_HEADER_TYPE: return UString("Unknown PE optional header type");
|
||||||
case U_UNKNOWN_RELOCATION_TYPE: return UString("Unknown relocation type");
|
case U_UNKNOWN_RELOCATION_TYPE: return UString("Unknown relocation type");
|
||||||
//case U_GENERIC_CALL_NOT_SUPPORTED: return UString("Generic call not supported");
|
//case U_GENERIC_CALL_NOT_SUPPORTED: return UString("Generic call not supported");
|
||||||
//case U_VOLUME_BASE_NOT_FOUND: return UString("Volume base address not found");
|
//case U_VOLUME_BASE_NOT_FOUND: return UString("Volume base address not found");
|
||||||
//case U_PEI_CORE_ENTRY_POINT_NOT_FOUND: return UString("PEI core entry point not found");
|
//case U_PEI_CORE_ENTRY_POINT_NOT_FOUND: return UString("PEI core entry point not found");
|
||||||
case U_COMPLEX_BLOCK_MAP: return UString("Block map structure too complex for correct analysis");
|
case U_COMPLEX_BLOCK_MAP: return UString("Block map structure too complex for correct analysis");
|
||||||
case U_DIR_ALREADY_EXIST: return UString("Directory already exists");
|
case U_DIR_ALREADY_EXIST: return UString("Directory already exists");
|
||||||
case U_DIR_CREATE: return UString("Directory can't be created");
|
case U_DIR_CREATE: return UString("Directory can't be created");
|
||||||
case U_DIR_CHANGE: return UString("Change directory failed");
|
case U_DIR_CHANGE: return UString("Change directory failed");
|
||||||
//case U_UNKNOWN_PATCH_TYPE: return UString("Unknown patch type");
|
//case U_UNKNOWN_PATCH_TYPE: return UString("Unknown patch type");
|
||||||
//case U_PATCH_OFFSET_OUT_OF_BOUNDS: return UString("Patch offset out of bounds");
|
//case U_PATCH_OFFSET_OUT_OF_BOUNDS: return UString("Patch offset out of bounds");
|
||||||
//case U_INVALID_SYMBOL: return UString("Invalid symbol");
|
//case U_INVALID_SYMBOL: return UString("Invalid symbol");
|
||||||
//case U_NOTHING_TO_PATCH: return UString("Nothing to patch");
|
//case U_NOTHING_TO_PATCH: return UString("Nothing to patch");
|
||||||
case U_DEPEX_PARSE_FAILED: return UString("Dependency expression parsing failed");
|
case U_DEPEX_PARSE_FAILED: return UString("Dependency expression parsing failed");
|
||||||
case U_TRUNCATED_IMAGE: return UString("Image is truncated");
|
case U_TRUNCATED_IMAGE: return UString("Image is truncated");
|
||||||
case U_INVALID_CAPSULE: return UString("Invalid capsule");
|
case U_INVALID_CAPSULE: return UString("Invalid capsule");
|
||||||
case U_STORES_NOT_FOUND: return UString("Stores not found");
|
case U_STORES_NOT_FOUND: return UString("Stores not found");
|
||||||
case U_INVALID_STORE_SIZE: return UString("Invalid store size");
|
case U_INVALID_STORE_SIZE: return UString("Invalid store size");
|
||||||
default: return usprintf("Unknown error %02lX", errorCode);
|
default: return usprintf("Unknown error %02lX", errorCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,169 +212,169 @@ USTATUS decompress(const UByteArray & compressedData, const UINT8 compressionTyp
|
|||||||
UINT8* scratch;
|
UINT8* scratch;
|
||||||
UINT32 scratchSize = 0;
|
UINT32 scratchSize = 0;
|
||||||
const EFI_TIANO_HEADER* header;
|
const EFI_TIANO_HEADER* header;
|
||||||
|
|
||||||
// For all but LZMA dictionary size is 0
|
// For all but LZMA dictionary size is 0
|
||||||
dictionarySize = 0;
|
dictionarySize = 0;
|
||||||
|
|
||||||
switch (compressionType)
|
switch (compressionType)
|
||||||
{
|
{
|
||||||
case EFI_NOT_COMPRESSED: {
|
case EFI_NOT_COMPRESSED: {
|
||||||
decompressedData = compressedData;
|
decompressedData = compressedData;
|
||||||
algorithm = COMPRESSION_ALGORITHM_NONE;
|
algorithm = COMPRESSION_ALGORITHM_NONE;
|
||||||
return U_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;
|
||||||
|
|
||||||
// Get buffer sizes
|
// Get buffer sizes
|
||||||
data = (UINT8*)compressedData.data();
|
data = (UINT8*)compressedData.data();
|
||||||
dataSize = (UINT32)compressedData.size();
|
dataSize = (UINT32)compressedData.size();
|
||||||
|
|
||||||
// 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 U_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 (U_SUCCESS != EfiTianoGetInfo(data, dataSize, &decompressedSize, &scratchSize))
|
if (U_SUCCESS != EfiTianoGetInfo(data, dataSize, &decompressedSize, &scratchSize))
|
||||||
return U_STANDARD_DECOMPRESSION_FAILED;
|
return U_STANDARD_DECOMPRESSION_FAILED;
|
||||||
|
|
||||||
// Allocate memory
|
// Allocate memory
|
||||||
decompressed = (UINT8*)malloc(decompressedSize);
|
decompressed = (UINT8*)malloc(decompressedSize);
|
||||||
efiDecompressed = (UINT8*)malloc(decompressedSize);
|
efiDecompressed = (UINT8*)malloc(decompressedSize);
|
||||||
scratch = (UINT8*)malloc(scratchSize);
|
scratch = (UINT8*)malloc(scratchSize);
|
||||||
if (!decompressed || !efiDecompressed || !scratch) {
|
if (!decompressed || !efiDecompressed || !scratch) {
|
||||||
|
free(decompressed);
|
||||||
|
free(efiDecompressed);
|
||||||
|
free(scratch);
|
||||||
|
return U_STANDARD_DECOMPRESSION_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decompress section data using both algorithms
|
||||||
|
USTATUS result = U_SUCCESS;
|
||||||
|
// Try Tiano
|
||||||
|
USTATUS TianoResult = TianoDecompress(data, dataSize, decompressed, decompressedSize, scratch, scratchSize);
|
||||||
|
// Try EFI 1.1
|
||||||
|
USTATUS EfiResult = EfiDecompress(data, dataSize, efiDecompressed, decompressedSize, scratch, scratchSize);
|
||||||
|
|
||||||
|
if (decompressedSize > INT32_MAX) {
|
||||||
|
result = U_STANDARD_DECOMPRESSION_FAILED;
|
||||||
|
}
|
||||||
|
else if (EfiResult == U_SUCCESS && TianoResult == U_SUCCESS) { // Both decompressions are OK
|
||||||
|
algorithm = COMPRESSION_ALGORITHM_UNDECIDED;
|
||||||
|
decompressedData = UByteArray((const char*)decompressed, (int)decompressedSize);
|
||||||
|
efiDecompressedData = UByteArray((const char*)efiDecompressed, (int)decompressedSize);
|
||||||
|
}
|
||||||
|
else if (TianoResult == U_SUCCESS) { // Only Tiano is OK
|
||||||
|
algorithm = COMPRESSION_ALGORITHM_TIANO;
|
||||||
|
decompressedData = UByteArray((const char*)decompressed, (int)decompressedSize);
|
||||||
|
}
|
||||||
|
else if (EfiResult == U_SUCCESS) { // Only EFI 1.1 is OK
|
||||||
|
algorithm = COMPRESSION_ALGORITHM_EFI11;
|
||||||
|
decompressedData = UByteArray((const char*)efiDecompressed, (int)decompressedSize);
|
||||||
|
}
|
||||||
|
else { // Both decompressions failed
|
||||||
|
result = U_STANDARD_DECOMPRESSION_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
free(decompressed);
|
free(decompressed);
|
||||||
free(efiDecompressed);
|
free(efiDecompressed);
|
||||||
free(scratch);
|
free(scratch);
|
||||||
return U_STANDARD_DECOMPRESSION_FAILED;
|
return result;
|
||||||
}
|
}
|
||||||
|
case EFI_CUSTOMIZED_COMPRESSION: {
|
||||||
// Decompress section data using both algorithms
|
// Set default algorithm to unknown
|
||||||
USTATUS result = U_SUCCESS;
|
algorithm = COMPRESSION_ALGORITHM_UNKNOWN;
|
||||||
// Try Tiano
|
|
||||||
USTATUS TianoResult = TianoDecompress(data, dataSize, decompressed, decompressedSize, scratch, scratchSize);
|
// Get buffer sizes
|
||||||
// Try EFI 1.1
|
data = (const UINT8*)compressedData.constData();
|
||||||
USTATUS EfiResult = EfiDecompress(data, dataSize, efiDecompressed, decompressedSize, scratch, scratchSize);
|
dataSize = (UINT32)compressedData.size();
|
||||||
|
|
||||||
if (decompressedSize > INT32_MAX) {
|
// Get info as normal LZMA section
|
||||||
result = U_STANDARD_DECOMPRESSION_FAILED;
|
if (U_SUCCESS != LzmaGetInfo(data, dataSize, &decompressedSize)) {
|
||||||
}
|
// Get info as Intel legacy LZMA section
|
||||||
else if (EfiResult == U_SUCCESS && TianoResult == U_SUCCESS) { // Both decompressions are OK
|
data += sizeof(UINT32);
|
||||||
algorithm = COMPRESSION_ALGORITHM_UNDECIDED;
|
if (U_SUCCESS != LzmaGetInfo(data, dataSize, &decompressedSize)) {
|
||||||
|
return U_CUSTOMIZED_DECOMPRESSION_FAILED;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
algorithm = COMPRESSION_ALGORITHM_LZMA_INTEL_LEGACY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
algorithm = COMPRESSION_ALGORITHM_LZMA;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allocate memory
|
||||||
|
decompressed = (UINT8*)malloc(decompressedSize);
|
||||||
|
if (!decompressed) {
|
||||||
|
return U_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decompress section data
|
||||||
|
if (U_SUCCESS != LzmaDecompress(data, dataSize, decompressed)) {
|
||||||
|
free(decompressed);
|
||||||
|
return U_CUSTOMIZED_DECOMPRESSION_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (decompressedSize > INT32_MAX) {
|
||||||
|
free(decompressed);
|
||||||
|
return U_CUSTOMIZED_DECOMPRESSION_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
dictionarySize = readUnaligned((UINT32*)(data + 1)); // LZMA dictionary size is stored in bytes 1-4 of LZMA properties header
|
||||||
decompressedData = UByteArray((const char*)decompressed, (int)decompressedSize);
|
decompressedData = UByteArray((const char*)decompressed, (int)decompressedSize);
|
||||||
efiDecompressedData = UByteArray((const char*)efiDecompressed, (int)decompressedSize);
|
free(decompressed);
|
||||||
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
else if (TianoResult == U_SUCCESS) { // Only Tiano is OK
|
case EFI_CUSTOMIZED_COMPRESSION_LZMAF86: {
|
||||||
algorithm = COMPRESSION_ALGORITHM_TIANO;
|
// Set default algorithm to unknown
|
||||||
decompressedData = UByteArray((const char*)decompressed, (int)decompressedSize);
|
algorithm = COMPRESSION_ALGORITHM_UNKNOWN;
|
||||||
}
|
|
||||||
else if (EfiResult == U_SUCCESS) { // Only EFI 1.1 is OK
|
// Get buffer sizes
|
||||||
algorithm = COMPRESSION_ALGORITHM_EFI11;
|
data = (const UINT8*)compressedData.constData();
|
||||||
decompressedData = UByteArray((const char*)efiDecompressed, (int)decompressedSize);
|
dataSize = (UINT32)compressedData.size();
|
||||||
}
|
|
||||||
else { // Both decompressions failed
|
// Get info as normal LZMA section
|
||||||
result = U_STANDARD_DECOMPRESSION_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
free(decompressed);
|
|
||||||
free(efiDecompressed);
|
|
||||||
free(scratch);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
case EFI_CUSTOMIZED_COMPRESSION: {
|
|
||||||
// Set default algorithm to unknown
|
|
||||||
algorithm = COMPRESSION_ALGORITHM_UNKNOWN;
|
|
||||||
|
|
||||||
// Get buffer sizes
|
|
||||||
data = (const UINT8*)compressedData.constData();
|
|
||||||
dataSize = (UINT32)compressedData.size();
|
|
||||||
|
|
||||||
// Get info as normal LZMA section
|
|
||||||
if (U_SUCCESS != LzmaGetInfo(data, dataSize, &decompressedSize)) {
|
|
||||||
// Get info as Intel legacy LZMA section
|
|
||||||
data += sizeof(UINT32);
|
|
||||||
if (U_SUCCESS != LzmaGetInfo(data, dataSize, &decompressedSize)) {
|
if (U_SUCCESS != LzmaGetInfo(data, dataSize, &decompressedSize)) {
|
||||||
return U_CUSTOMIZED_DECOMPRESSION_FAILED;
|
return U_CUSTOMIZED_DECOMPRESSION_FAILED;
|
||||||
}
|
}
|
||||||
else {
|
algorithm = COMPRESSION_ALGORITHM_LZMAF86;
|
||||||
algorithm = COMPRESSION_ALGORITHM_LZMA_INTEL_LEGACY;
|
|
||||||
|
// Allocate memory
|
||||||
|
decompressed = (UINT8*)malloc(decompressedSize);
|
||||||
|
if (!decompressed) {
|
||||||
|
return U_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
// Decompress section data
|
||||||
algorithm = COMPRESSION_ALGORITHM_LZMA;
|
if (U_SUCCESS != LzmaDecompress(data, dataSize, decompressed)) {
|
||||||
}
|
free(decompressed);
|
||||||
|
return U_CUSTOMIZED_DECOMPRESSION_FAILED;
|
||||||
// Allocate memory
|
}
|
||||||
decompressed = (UINT8*)malloc(decompressedSize);
|
|
||||||
if (!decompressed) {
|
if (decompressedSize > INT32_MAX) {
|
||||||
return U_OUT_OF_MEMORY;
|
free(decompressed);
|
||||||
}
|
return U_CUSTOMIZED_DECOMPRESSION_FAILED;
|
||||||
|
}
|
||||||
// Decompress section data
|
|
||||||
if (U_SUCCESS != LzmaDecompress(data, dataSize, decompressed)) {
|
// After LZMA decompression, the data need to be converted to the raw data.
|
||||||
|
UINT32 state = 0;
|
||||||
|
const UINT8 x86LookAhead = 4;
|
||||||
|
if (decompressedSize != x86LookAhead + x86_Convert(decompressed, decompressedSize, 0, &state, 0)) {
|
||||||
|
free(decompressed);
|
||||||
|
return U_CUSTOMIZED_DECOMPRESSION_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
dictionarySize = readUnaligned((UINT32*)(data + 1)); // LZMA dictionary size is stored in bytes 1-4 of LZMA properties header
|
||||||
|
decompressedData = UByteArray((const char*)decompressed, (int)decompressedSize);
|
||||||
free(decompressed);
|
free(decompressed);
|
||||||
return U_CUSTOMIZED_DECOMPRESSION_FAILED;
|
return U_SUCCESS;
|
||||||
}
|
}
|
||||||
|
default: {
|
||||||
if (decompressedSize > INT32_MAX) {
|
algorithm = COMPRESSION_ALGORITHM_UNKNOWN;
|
||||||
free(decompressed);
|
return U_UNKNOWN_COMPRESSION_TYPE;
|
||||||
return U_CUSTOMIZED_DECOMPRESSION_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
dictionarySize = readUnaligned((UINT32*)(data + 1)); // LZMA dictionary size is stored in bytes 1-4 of LZMA properties header
|
|
||||||
decompressedData = UByteArray((const char*)decompressed, (int)decompressedSize);
|
|
||||||
free(decompressed);
|
|
||||||
return U_SUCCESS;
|
|
||||||
}
|
|
||||||
case EFI_CUSTOMIZED_COMPRESSION_LZMAF86: {
|
|
||||||
// Set default algorithm to unknown
|
|
||||||
algorithm = COMPRESSION_ALGORITHM_UNKNOWN;
|
|
||||||
|
|
||||||
// Get buffer sizes
|
|
||||||
data = (const UINT8*)compressedData.constData();
|
|
||||||
dataSize = (UINT32)compressedData.size();
|
|
||||||
|
|
||||||
// Get info as normal LZMA section
|
|
||||||
if (U_SUCCESS != LzmaGetInfo(data, dataSize, &decompressedSize)) {
|
|
||||||
return U_CUSTOMIZED_DECOMPRESSION_FAILED;
|
|
||||||
}
|
|
||||||
algorithm = COMPRESSION_ALGORITHM_LZMAF86;
|
|
||||||
|
|
||||||
// Allocate memory
|
|
||||||
decompressed = (UINT8*)malloc(decompressedSize);
|
|
||||||
if (!decompressed) {
|
|
||||||
return U_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decompress section data
|
|
||||||
if (U_SUCCESS != LzmaDecompress(data, dataSize, decompressed)) {
|
|
||||||
free(decompressed);
|
|
||||||
return U_CUSTOMIZED_DECOMPRESSION_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (decompressedSize > INT32_MAX) {
|
|
||||||
free(decompressed);
|
|
||||||
return U_CUSTOMIZED_DECOMPRESSION_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
// After LZMA decompression, the data need to be converted to the raw data.
|
|
||||||
UINT32 state = 0;
|
|
||||||
const UINT8 x86LookAhead = 4;
|
|
||||||
if (decompressedSize != x86LookAhead + x86_Convert(decompressed, decompressedSize, 0, &state, 0)) {
|
|
||||||
free(decompressed);
|
|
||||||
return U_CUSTOMIZED_DECOMPRESSION_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
dictionarySize = readUnaligned((UINT32*)(data + 1)); // LZMA dictionary size is stored in bytes 1-4 of LZMA properties header
|
|
||||||
decompressedData = UByteArray((const char*)decompressed, (int)decompressedSize);
|
|
||||||
free(decompressed);
|
|
||||||
return U_SUCCESS;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
algorithm = COMPRESSION_ALGORITHM_UNKNOWN;
|
|
||||||
return U_UNKNOWN_COMPRESSION_TYPE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -386,12 +386,12 @@ UINT8 calculateSum8(const UINT8* buffer, UINT32 bufferSize)
|
|||||||
{
|
{
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
UINT8 counter = 0;
|
UINT8 counter = 0;
|
||||||
|
|
||||||
while (bufferSize--)
|
while (bufferSize--)
|
||||||
counter += buffer[bufferSize];
|
counter += buffer[bufferSize];
|
||||||
|
|
||||||
return counter;
|
return counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -400,7 +400,7 @@ UINT8 calculateChecksum8(const UINT8* buffer, UINT32 bufferSize)
|
|||||||
{
|
{
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return (UINT8)(0x100U - calculateSum8(buffer, bufferSize));
|
return (UINT8)(0x100U - calculateSum8(buffer, bufferSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -409,16 +409,16 @@ UINT16 calculateChecksum16(const UINT16* buffer, UINT32 bufferSize)
|
|||||||
{
|
{
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
UINT16 counter = 0;
|
UINT16 counter = 0;
|
||||||
UINT32 index = 0;
|
UINT32 index = 0;
|
||||||
|
|
||||||
bufferSize /= sizeof(UINT16);
|
bufferSize /= sizeof(UINT16);
|
||||||
|
|
||||||
for (; index < bufferSize; index++) {
|
for (; index < bufferSize; index++) {
|
||||||
counter = (UINT16)(counter + buffer[index]);
|
counter = (UINT16)(counter + buffer[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (UINT16)(0x10000 - counter);
|
return (UINT16)(0x10000 - counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -462,11 +462,11 @@ static inline int char2hex(char c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
INTN findPattern(const UINT8 *pattern, const UINT8 *patternMask, UINTN patternSize,
|
INTN findPattern(const UINT8 *pattern, const UINT8 *patternMask, UINTN patternSize,
|
||||||
const UINT8 *data, UINTN dataSize, UINTN dataOff)
|
const UINT8 *data, UINTN dataSize, UINTN dataOff)
|
||||||
{
|
{
|
||||||
if (patternSize == 0 || dataSize == 0 || dataOff >= dataSize || dataSize - dataOff < patternSize)
|
if (patternSize == 0 || dataSize == 0 || dataOff >= dataSize || dataSize - dataOff < patternSize)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
while (dataOff + patternSize < dataSize) {
|
while (dataOff + patternSize < dataSize) {
|
||||||
BOOLEAN matches = TRUE;
|
BOOLEAN matches = TRUE;
|
||||||
for (UINTN i = 0; i < patternSize; i++) {
|
for (UINTN i = 0; i < patternSize; i++) {
|
||||||
@ -475,78 +475,78 @@ INTN findPattern(const UINT8 *pattern, const UINT8 *patternMask, UINTN patternSi
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matches)
|
if (matches)
|
||||||
return static_cast<INTN>(dataOff);
|
return static_cast<INTN>(dataOff);
|
||||||
|
|
||||||
dataOff++;
|
dataOff++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN makePattern(const CHAR8 *textPattern, std::vector<UINT8> &pattern, std::vector<UINT8> &patternMask)
|
BOOLEAN makePattern(const CHAR8 *textPattern, std::vector<UINT8> &pattern, std::vector<UINT8> &patternMask)
|
||||||
{
|
{
|
||||||
UINTN len = std::strlen(textPattern);
|
UINTN len = std::strlen(textPattern);
|
||||||
|
|
||||||
if (len == 0 || len % 2 != 0)
|
if (len == 0 || len % 2 != 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
len /= 2;
|
len /= 2;
|
||||||
|
|
||||||
pattern.resize(len);
|
pattern.resize(len);
|
||||||
patternMask.resize(len);
|
patternMask.resize(len);
|
||||||
|
|
||||||
for (UINTN i = 0; i < len; i++) {
|
for (UINTN i = 0; i < len; i++) {
|
||||||
int v1 = char2hex(std::toupper(textPattern[i * 2]));
|
int v1 = char2hex(std::toupper(textPattern[i * 2]));
|
||||||
int v2 = char2hex(std::toupper(textPattern[i * 2 + 1]));
|
int v2 = char2hex(std::toupper(textPattern[i * 2 + 1]));
|
||||||
|
|
||||||
if (v1 == -1 || v2 == -1)
|
if (v1 == -1 || v2 == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (v1 != -2) {
|
if (v1 != -2) {
|
||||||
patternMask[i] = 0xF0;
|
patternMask[i] = 0xF0;
|
||||||
pattern[i] = static_cast<UINT8>(v1) << 4;
|
pattern[i] = static_cast<UINT8>(v1) << 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v2 != -2) {
|
if (v2 != -2) {
|
||||||
patternMask[i] |= 0x0F;
|
patternMask[i] |= 0x0F;
|
||||||
pattern[i] |= static_cast<UINT8>(v2);
|
pattern[i] |= static_cast<UINT8>(v2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
USTATUS gzipDecompress(const UByteArray & input, UByteArray & output)
|
USTATUS gzipDecompress(const UByteArray & input, UByteArray & output)
|
||||||
{
|
{
|
||||||
output.clear();
|
output.clear();
|
||||||
|
|
||||||
if (input.size() == 0)
|
if (input.size() == 0)
|
||||||
return U_SUCCESS;
|
return U_SUCCESS;
|
||||||
|
|
||||||
z_stream stream;
|
z_stream stream;
|
||||||
stream.next_in = (z_const Bytef *)input.data();
|
stream.next_in = (z_const Bytef *)input.data();
|
||||||
stream.avail_in = (uInt)input.size();
|
stream.avail_in = (uInt)input.size();
|
||||||
stream.zalloc = Z_NULL;
|
stream.zalloc = Z_NULL;
|
||||||
stream.zfree = Z_NULL;
|
stream.zfree = Z_NULL;
|
||||||
stream.opaque = Z_NULL;
|
stream.opaque = Z_NULL;
|
||||||
|
|
||||||
// 15 for the maximum history buffer, 16 for gzip only input.
|
// 15 for the maximum history buffer, 16 for gzip only input.
|
||||||
int ret = inflateInit2(&stream, 15U | 16U);
|
int ret = inflateInit2(&stream, 15U | 16U);
|
||||||
if (ret != Z_OK)
|
if (ret != Z_OK)
|
||||||
return U_GZIP_DECOMPRESSION_FAILED;
|
return U_GZIP_DECOMPRESSION_FAILED;
|
||||||
|
|
||||||
while (ret == Z_OK) {
|
while (ret == Z_OK) {
|
||||||
Bytef out[4096];
|
Bytef out[4096];
|
||||||
stream.next_out = out;
|
stream.next_out = out;
|
||||||
stream.avail_out = sizeof(out);
|
stream.avail_out = sizeof(out);
|
||||||
|
|
||||||
ret = inflate(&stream, Z_NO_FLUSH);
|
ret = inflate(&stream, Z_NO_FLUSH);
|
||||||
if ((ret == Z_OK || ret == Z_STREAM_END) && stream.avail_out != sizeof(out))
|
if ((ret == Z_OK || ret == Z_STREAM_END) && stream.avail_out != sizeof(out))
|
||||||
output += UByteArray((char *)out, sizeof(out) - stream.avail_out);
|
output += UByteArray((char *)out, sizeof(out) - stream.avail_out);
|
||||||
}
|
}
|
||||||
|
|
||||||
inflateEnd(&stream);
|
inflateEnd(&stream);
|
||||||
return ret == Z_STREAM_END ? U_SUCCESS : U_GZIP_DECOMPRESSION_FAILED;
|
return ret == Z_STREAM_END ? U_SUCCESS : U_GZIP_DECOMPRESSION_FAILED;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user