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