mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-21 23:48:22 +08:00
Updated code to support newer Qt versions (#237)
This commit is contained in:
parent
d1e47539fc
commit
34c8ad8dcc
2
.gitignore
vendored
2
.gitignore
vendored
@ -248,3 +248,5 @@ DerivedData
|
||||
compile_commands.json
|
||||
CMakeScripts
|
||||
UEFITool/qrc_uefitool.cpp
|
||||
XcodeQT5
|
||||
XcodeQT6
|
||||
|
@ -29,7 +29,12 @@ USTATUS FfsFinder::findHexPattern(const UModelIndex & index, const UByteArray &
|
||||
|
||||
bool hasChildren = (model->rowCount(index) > 0);
|
||||
for (int i = 0; i < model->rowCount(index); i++) {
|
||||
#if ((QT_VERSION_MAJOR == 5) && (QT_VERSION_MINOR < 6)) || (QT_VERSION_MAJOR < 5)
|
||||
findHexPattern(index.child(i, index.column()), hexPattern, mode);
|
||||
#else
|
||||
findHexPattern(index.model()->index(i, index.column(), index), hexPattern, mode);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
UByteArray data;
|
||||
@ -49,9 +54,22 @@ USTATUS FfsFinder::findHexPattern(const UModelIndex & index, const UByteArray &
|
||||
}
|
||||
|
||||
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) {
|
||||
#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.
|
||||
@ -64,7 +82,12 @@ USTATUS FfsFinder::findHexPattern(const UModelIndex & index, const UByteArray &
|
||||
index);
|
||||
}
|
||||
}
|
||||
|
||||
#if QT_VERSION_MAJOR >= 6
|
||||
offset += 1;
|
||||
#else
|
||||
offset = regexp.indexIn(hexBody, offset + 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
return U_SUCCESS;
|
||||
@ -80,7 +103,11 @@ USTATUS FfsFinder::findGuidPattern(const UModelIndex & index, const UByteArray &
|
||||
|
||||
bool hasChildren = (model->rowCount(index) > 0);
|
||||
for (int i = 0; i < model->rowCount(index); i++) {
|
||||
#if ((QT_VERSION_MAJOR == 5) && (QT_VERSION_MINOR < 6)) || (QT_VERSION_MAJOR < 5)
|
||||
findGuidPattern(index.child(i, index.column()), guidPattern, mode);
|
||||
#else
|
||||
findGuidPattern(index.model()->index(i, index.column(), index), guidPattern, mode);
|
||||
#endif
|
||||
}
|
||||
|
||||
UByteArray data;
|
||||
@ -121,8 +148,19 @@ USTATUS FfsFinder::findGuidPattern(const UModelIndex & index, const UByteArray &
|
||||
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)
|
||||
@ -132,7 +170,12 @@ USTATUS FfsFinder::findGuidPattern(const UModelIndex & index, const UByteArray &
|
||||
+ 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
|
||||
}
|
||||
|
||||
return U_SUCCESS;
|
||||
@ -148,7 +191,11 @@ USTATUS FfsFinder::findTextPattern(const UModelIndex & index, const UString & pa
|
||||
|
||||
bool hasChildren = (model->rowCount(index) > 0);
|
||||
for (int i = 0; i < model->rowCount(index); i++) {
|
||||
#if ((QT_VERSION_MAJOR == 5) && (QT_VERSION_MINOR < 6)) || (QT_VERSION_MAJOR < 5)
|
||||
findTextPattern(index.child(i, index.column()), pattern, mode, unicode, caseSensitive);
|
||||
#else
|
||||
findTextPattern(index.model()->index(i, index.column(), index), pattern, mode, unicode, caseSensitive);
|
||||
#endif
|
||||
}
|
||||
|
||||
UByteArray body;
|
||||
@ -167,12 +214,16 @@ USTATUS FfsFinder::findTextPattern(const UModelIndex & index, const UString & pa
|
||||
|
||||
UString data;
|
||||
if (unicode)
|
||||
data = UString::fromUtf16((const ushort*)body.constData(), body.length() / 2);
|
||||
#if QT_VERSION_MAJOR >= 6
|
||||
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 = data.indexOf(pattern, offset + 1, caseSensitive)) >= 0) {
|
||||
while ((offset = (int)data.indexOf(pattern, (int)(offset + 1), caseSensitive)) >= 0) {
|
||||
|
||||
msg((unicode ? UString("Unicode") : UString("ASCII")) + UString(" text \"") + UString(pattern)
|
||||
+ UString("\" in ") + model->name(model->parent(index))
|
||||
|
@ -15,7 +15,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#define FFSFINDER_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#if QT_VERSION_MAJOR >= 6
|
||||
#include <QRegularExpression>
|
||||
#else
|
||||
#include <QRegExp>
|
||||
#endif
|
||||
|
||||
#include "../common/ubytearray.h"
|
||||
#include "../common/ustring.h"
|
||||
|
@ -15,7 +15,11 @@
|
||||
#include <QDebug>
|
||||
|
||||
HexSpinBox::HexSpinBox(QWidget *parent) :
|
||||
#if QT_VERSION_MAJOR >= 6
|
||||
QSpinBox(parent), validator(QRegularExpression("0x([0-9a-fA-F]){1,8}"))
|
||||
#else
|
||||
QSpinBox(parent), validator(QRegExp("0x([0-9a-fA-F]){1,8}"))
|
||||
#endif
|
||||
{
|
||||
this->setRange(INT_MIN, INT_MAX);
|
||||
this->setPrefix("0x");
|
||||
|
@ -15,7 +15,12 @@
|
||||
#define HEXSPINBOX_H
|
||||
|
||||
#include <QSpinBox>
|
||||
|
||||
#if QT_VERSION_MAJOR >= 6
|
||||
#include <QRegularExpressionValidator>
|
||||
#else
|
||||
#include <QRegExpValidator>
|
||||
#endif
|
||||
|
||||
class HexSpinBox : public QSpinBox
|
||||
{
|
||||
@ -30,7 +35,11 @@ protected:
|
||||
QString textFromValue(int value) const;
|
||||
|
||||
private:
|
||||
#if QT_VERSION_MAJOR >= 6
|
||||
QRegularExpressionValidator validator;
|
||||
#else
|
||||
QRegExpValidator validator;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // HEXSPINBOX_H
|
||||
|
Binary file not shown.
@ -95,11 +95,11 @@ QByteArray Chunks::data(qint64 pos, qint64 maxSize, QByteArray *highlighted)
|
||||
count = maxSize;
|
||||
if (count > 0)
|
||||
{
|
||||
buffer += chunk.data.mid(chunkOfs, (int)count);
|
||||
buffer += chunk.data.mid((int)chunkOfs, (int)count);
|
||||
maxSize -= count;
|
||||
pos += count;
|
||||
if (highlighted)
|
||||
*highlighted += chunk.dataChanged.mid(chunkOfs, (int)count);
|
||||
*highlighted += chunk.dataChanged.mid((int)chunkOfs, (int)count);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -176,7 +176,7 @@ qint64 Chunks::indexOf(const QByteArray &ba, qint64 from)
|
||||
for (qint64 pos=from; (pos < _size) && (result < 0); pos += BUFFER_SIZE)
|
||||
{
|
||||
buffer = data(pos, BUFFER_SIZE + ba.size() - 1);
|
||||
int findPos = buffer.indexOf(ba);
|
||||
int findPos = (int)buffer.indexOf(ba);
|
||||
if (findPos >= 0)
|
||||
result = pos + (qint64)findPos;
|
||||
}
|
||||
@ -194,7 +194,7 @@ qint64 Chunks::lastIndexOf(const QByteArray &ba, qint64 from)
|
||||
if (sPos < 0)
|
||||
sPos = 0;
|
||||
buffer = data(sPos, pos - sPos);
|
||||
int findPos = buffer.lastIndexOf(ba);
|
||||
int findPos = (int)buffer.lastIndexOf(ba);
|
||||
if (findPos >= 0)
|
||||
result = sPos + (qint64)findPos;
|
||||
}
|
||||
@ -214,8 +214,8 @@ bool Chunks::insert(qint64 pos, char b)
|
||||
else
|
||||
chunkIdx = getChunkIndex(pos);
|
||||
qint64 posInBa = pos - _chunks[chunkIdx].absPos;
|
||||
_chunks[chunkIdx].data.insert(posInBa, b);
|
||||
_chunks[chunkIdx].dataChanged.insert(posInBa, char(1));
|
||||
_chunks[chunkIdx].data.insert((int)posInBa, b);
|
||||
_chunks[chunkIdx].dataChanged.insert((int)posInBa, char(1));
|
||||
for (int idx=chunkIdx+1; idx < _chunks.size(); idx++)
|
||||
_chunks[idx].absPos += 1;
|
||||
_size += 1;
|
||||
@ -241,8 +241,8 @@ bool Chunks::removeAt(qint64 pos)
|
||||
return false;
|
||||
int chunkIdx = getChunkIndex(pos);
|
||||
qint64 posInBa = pos - _chunks[chunkIdx].absPos;
|
||||
_chunks[chunkIdx].data.remove(posInBa, 1);
|
||||
_chunks[chunkIdx].dataChanged.remove(posInBa, 1);
|
||||
_chunks[chunkIdx].data.remove((int)posInBa, 1);
|
||||
_chunks[chunkIdx].dataChanged.remove((int)posInBa, 1);
|
||||
for (int idx=chunkIdx+1; idx < _chunks.size(); idx++)
|
||||
_chunks[idx].absPos -= 1;
|
||||
_size -= 1;
|
||||
|
@ -408,7 +408,13 @@ QString QHexEdit::selectionToReadableString()
|
||||
void QHexEdit::setFont(const QFont &font)
|
||||
{
|
||||
QWidget::setFont(font);
|
||||
|
||||
#if ((QT_VERSION_MINOR >= 11) && (QT_VERSION_MAJOR == 5)) || (QT_VERSION_MAJOR >= 6)
|
||||
_pxCharWidth = fontMetrics().horizontalAdvance('2');
|
||||
#else
|
||||
_pxCharWidth = fontMetrics().width(QLatin1Char('2'));
|
||||
#endif
|
||||
|
||||
_pxCharHeight = fontMetrics().height();
|
||||
_pxGapAdr = _pxCharWidth / 2;
|
||||
_pxGapAdrHex = _pxCharWidth;
|
||||
@ -573,7 +579,7 @@ void QHexEdit::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
QByteArray ba = _chunks->data(getSelectionBegin(), getSelectionEnd() - getSelectionBegin()).toHex();
|
||||
for (qint64 idx = 32; idx < ba.size(); idx +=33)
|
||||
ba.insert(idx, "\n");
|
||||
ba.insert((int)idx, "\n");
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
clipboard->setText(ba);
|
||||
if (_overwriteMode)
|
||||
@ -596,7 +602,7 @@ void QHexEdit::keyPressEvent(QKeyEvent *event)
|
||||
QByteArray ba = QByteArray().fromHex(clipboard->text().toLatin1());
|
||||
if (_overwriteMode)
|
||||
{
|
||||
ba = ba.left(std::min<qint64>(ba.size(), (_chunks->size() - _bPosCurrent)));
|
||||
ba = ba.left((int)std::min<qint64>(ba.size(), (_chunks->size() - _bPosCurrent)));
|
||||
replace(_bPosCurrent, ba.size(), ba);
|
||||
}
|
||||
else
|
||||
@ -746,7 +752,7 @@ void QHexEdit::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
QByteArray ba = _chunks->data(getSelectionBegin(), getSelectionEnd() - getSelectionBegin()).toHex();
|
||||
for (qint64 idx = 32; idx < ba.size(); idx += 33)
|
||||
ba.insert(idx, "\n");
|
||||
ba.insert((int)idx, "\n");
|
||||
if(_upperCase)
|
||||
ba = ba.toUpper();
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
@ -875,7 +881,7 @@ void QHexEdit::paintEvent(QPaintEvent *event)
|
||||
else
|
||||
r.setRect(pxPosX - _pxCharWidth, pxPosY - _pxCharHeight + _pxSelectionSub, 3*_pxCharWidth, _pxCharHeight);
|
||||
painter.fillRect(r, c);
|
||||
hex = _hexDataShown.mid((bPosLine + colIdx) * 2, 2);
|
||||
hex = _hexDataShown.mid((int)((bPosLine + colIdx) * 2), 2);
|
||||
|
||||
// upper or lower case
|
||||
if (_upperCase)
|
||||
@ -887,7 +893,7 @@ void QHexEdit::paintEvent(QPaintEvent *event)
|
||||
// render ascii value
|
||||
if (_asciiArea)
|
||||
{
|
||||
int ch = (uchar)_dataShown.at(bPosLine + colIdx);
|
||||
int ch = (uchar)_dataShown.at((int)(bPosLine + colIdx));
|
||||
if ( ch < 0x20 )
|
||||
ch = '.';
|
||||
r.setRect(pxPosAsciiX2, pxPosY - _pxCharHeight + _pxSelectionSub, _pxCharWidth, _pxCharHeight);
|
||||
@ -977,12 +983,12 @@ void QHexEdit::setSelection(qint64 pos)
|
||||
|
||||
int QHexEdit::getSelectionBegin()
|
||||
{
|
||||
return _bSelectionBegin;
|
||||
return (int)_bSelectionBegin;
|
||||
}
|
||||
|
||||
int QHexEdit::getSelectionEnd()
|
||||
{
|
||||
return _bSelectionEnd;
|
||||
return (int)_bSelectionEnd;
|
||||
}
|
||||
|
||||
// ********************************************************************** Private utility functions
|
||||
|
@ -16,8 +16,13 @@
|
||||
SearchDialog::SearchDialog(QWidget *parent) :
|
||||
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint),
|
||||
ui(new Ui::SearchDialog),
|
||||
#if QT_VERSION_MAJOR >= 6
|
||||
hexValidator(QRegularExpression("([0-9a-fA-F\\. ])*")),
|
||||
guidValidator(QRegularExpression("[0-9a-fA-F\\.]{8}-[0-9a-fA-F\\.]{4}-[0-9a-fA-F\\.]{4}-[0-9a-fA-F\\.]{4}-[0-9a-fA-F\\.]{12}"))
|
||||
#else
|
||||
hexValidator(QRegExp("([0-9a-fA-F\\. ])*")),
|
||||
guidValidator(QRegExp("[0-9a-fA-F\\.]{8}-[0-9a-fA-F\\.]{4}-[0-9a-fA-F\\.]{4}-[0-9a-fA-F\\.]{4}-[0-9a-fA-F\\.]{12}"))
|
||||
#endif
|
||||
{
|
||||
// Create UI
|
||||
ui->setupUi(this);
|
||||
|
@ -15,7 +15,13 @@
|
||||
#define SEARCHDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#if QT_VERSION_MAJOR >= 6
|
||||
#include <QRegularExpressionValidator>
|
||||
#else
|
||||
#include <QRegExpValidator>
|
||||
#endif
|
||||
|
||||
#include "ui_searchdialog.h"
|
||||
|
||||
class SearchDialog : public QDialog
|
||||
@ -31,8 +37,13 @@ private slots:
|
||||
void setEditFocus(int index);
|
||||
|
||||
private:
|
||||
#if QT_VERSION_MAJOR >= 6
|
||||
QRegularExpressionValidator hexValidator;
|
||||
QRegularExpressionValidator guidValidator;
|
||||
#else
|
||||
QRegExpValidator hexValidator;
|
||||
QRegExpValidator guidValidator;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // SEARCHDIALOG_H
|
||||
|
@ -390,7 +390,12 @@ void UEFITool::goToData()
|
||||
}
|
||||
|
||||
for (int j = i + 1; j < model->rowCount(parent); j++) {
|
||||
#if ((QT_VERSION_MAJOR == 5) && (QT_VERSION_MINOR < 6)) || (QT_VERSION_MAJOR < 5)
|
||||
QModelIndex currentIndex = parent.child(j, 0);
|
||||
#else
|
||||
QModelIndex currentIndex = parent.model()->index(j, 0, parent);
|
||||
#endif
|
||||
|
||||
if (model->hasEmptyParsingData(currentIndex))
|
||||
continue;
|
||||
|
||||
@ -788,8 +793,14 @@ void UEFITool::showParserMessages()
|
||||
return;
|
||||
|
||||
std::vector<std::pair<QString, QModelIndex> > messages = ffsParser->getMessages();
|
||||
|
||||
#if QT_VERSION_MAJOR < 6
|
||||
std::pair<QString, QModelIndex> msg;
|
||||
|
||||
foreach (msg, messages) {
|
||||
#else
|
||||
for (const auto &msg : messages) {
|
||||
#endif
|
||||
QListWidgetItem* item = new QListWidgetItem(msg.first, NULL, 0);
|
||||
item->setData(Qt::UserRole, QByteArray((const char*)&msg.second, sizeof(msg.second)));
|
||||
ui->parserMessagesListWidget->addItem(item);
|
||||
@ -806,8 +817,14 @@ void UEFITool::showFinderMessages()
|
||||
return;
|
||||
|
||||
std::vector<std::pair<QString, QModelIndex> > messages = ffsFinder->getMessages();
|
||||
|
||||
#if QT_VERSION_MAJOR < 6
|
||||
std::pair<QString, QModelIndex> msg;
|
||||
|
||||
foreach (msg, messages) {
|
||||
#else
|
||||
for (const auto &msg : messages) {
|
||||
#endif
|
||||
QListWidgetItem* item = new QListWidgetItem(msg.first, NULL, 0);
|
||||
item->setData(Qt::UserRole, QByteArray((const char*)&msg.second, sizeof(msg.second)));;
|
||||
ui->finderMessagesListWidget->addItem(item);
|
||||
@ -825,8 +842,14 @@ void UEFITool::showBuilderMessages()
|
||||
return;
|
||||
|
||||
std::vector<std::pair<QString, QModelIndex> > messages = ffsBuilder->getMessages();
|
||||
|
||||
#if QT_VERSION_MAJOR < 6
|
||||
std::pair<QString, QModelIndex> msg;
|
||||
|
||||
foreach (msg, messages) {
|
||||
#else
|
||||
for (const auto &msg : messages) {
|
||||
#endif
|
||||
QListWidgetItem* item = new QListWidgetItem(msg.first, NULL, 0);
|
||||
item->setData(Qt::UserRole, QByteArray((const char*)&msg.second, sizeof(msg.second)));
|
||||
ui->builderMessagesListWidget->addItem(item);
|
||||
|
20
UEFITool/uefitool.entitlements
Normal file
20
UEFITool/uefitool.entitlements
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
<key>com.apple.security.assets.movies.read-write</key>
|
||||
<true/>
|
||||
<key>com.apple.security.assets.music.read-write</key>
|
||||
<true/>
|
||||
<key>com.apple.security.assets.pictures.read-write</key>
|
||||
<true/>
|
||||
<key>com.apple.security.files.downloads.read-write</key>
|
||||
<true/>
|
||||
<key>com.apple.security.files.user-selected.read-write</key>
|
||||
<true/>
|
||||
<key>com.apple.security.print</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
@ -697,9 +697,9 @@ int CBString::find (const CBString& b, int pos) const {
|
||||
int CBString::find (const char * b, int pos) const {
|
||||
int ii, j;
|
||||
unsigned char c0;
|
||||
register int i, l;
|
||||
register unsigned char cx;
|
||||
register unsigned char * pdata;
|
||||
int i, l;
|
||||
unsigned char cx;
|
||||
unsigned char * pdata;
|
||||
|
||||
if (NULL == b) {
|
||||
#ifdef BSTRLIB_THROWS_EXCEPTIONS
|
||||
|
@ -92,7 +92,12 @@ USTATUS FfsBuilder::buildCapsule(const UModelIndex & index, UByteArray & capsule
|
||||
}
|
||||
|
||||
// Build image
|
||||
#if ((QT_VERSION_MAJOR == 5) && (QT_VERSION_MINOR < 6)) || (QT_VERSION_MAJOR < 5)
|
||||
UModelIndex imageIndex = index.child(0, 0);
|
||||
#else
|
||||
UModelIndex imageIndex = index.model()->index(0, 0, index);
|
||||
#endif
|
||||
|
||||
UByteArray imageData;
|
||||
|
||||
// Check image type
|
||||
@ -123,8 +128,8 @@ USTATUS FfsBuilder::buildCapsule(const UModelIndex & index, UByteArray & capsule
|
||||
}
|
||||
|
||||
// Check size of reconstructed capsule body, it must remain the same
|
||||
UINT32 newSize = capsule.size();
|
||||
UINT32 oldSize = model->body(index).size();
|
||||
UINT32 newSize = (UINT32)capsule.size();
|
||||
UINT32 oldSize = (UINT32)model->body(index).size();
|
||||
if (newSize > oldSize) {
|
||||
msg(usprintf("buildCapsule: new capsule size %Xh (%u) is bigger than the original %Xh (%u)", newSize, newSize, oldSize, oldSize), index);
|
||||
return U_INVALID_CAPSULE;
|
||||
@ -165,11 +170,19 @@ USTATUS FfsBuilder::buildIntelImage(const UModelIndex & index, UByteArray & inte
|
||||
// Rebuild
|
||||
else if (model->action(index) == Actions::Rebuild) {
|
||||
// First child will always be descriptor for this type of image, and it's read only for now
|
||||
#if ((QT_VERSION_MAJOR == 5) && (QT_VERSION_MINOR < 6)) || (QT_VERSION_MAJOR < 5)
|
||||
intelImage = model->header(index.child(0, 0)) + model->body(index.child(0, 0)) + model->tail(index.child(0, 0));
|
||||
#else
|
||||
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));
|
||||
#endif
|
||||
|
||||
// Process other regions
|
||||
for (int i = 1; i < model->rowCount(index); i++) {
|
||||
#if ((QT_VERSION_MAJOR == 5) && (QT_VERSION_MINOR < 6)) || (QT_VERSION_MAJOR < 5)
|
||||
UModelIndex currentRegion = index.child(i, 0);
|
||||
#else
|
||||
UModelIndex currentRegion = index.model()->index(i, 0, index);
|
||||
#endif
|
||||
|
||||
// Skip regions with Remove action
|
||||
if (model->action(currentRegion) == Actions::Remove)
|
||||
@ -222,8 +235,8 @@ USTATUS FfsBuilder::buildIntelImage(const UModelIndex & index, UByteArray & inte
|
||||
}
|
||||
|
||||
// Check size of new image, it must be same as old one
|
||||
UINT32 newSize = intelImage.size();
|
||||
UINT32 oldSize = model->body(index).size();
|
||||
UINT32 newSize = (UINT32)intelImage.size();
|
||||
UINT32 oldSize = (UINT32)model->body(index).size();
|
||||
if (newSize > oldSize) {
|
||||
msg(usprintf("buildIntelImage: new image size %Xh (%u) is bigger than the original %Xh (%u)", newSize, newSize, oldSize, oldSize), index);
|
||||
return U_INVALID_IMAGE;
|
||||
@ -269,7 +282,13 @@ USTATUS FfsBuilder::buildRawArea(const UModelIndex & index, UByteArray & rawArea
|
||||
// Build children
|
||||
for (int i = 0; i < model->rowCount(index); i++) {
|
||||
USTATUS result = U_SUCCESS;
|
||||
|
||||
#if ((QT_VERSION_MAJOR == 5) && (QT_VERSION_MINOR < 6)) || (QT_VERSION_MAJOR < 5)
|
||||
UModelIndex currentChild = index.child(i, 0);
|
||||
#else
|
||||
UModelIndex currentChild = index.model()->index(i, 0, index);
|
||||
#endif
|
||||
|
||||
UByteArray currentData;
|
||||
// Check child type
|
||||
if (model->type(currentChild) == Types::Volume) {
|
||||
@ -292,8 +311,8 @@ USTATUS FfsBuilder::buildRawArea(const UModelIndex & index, UByteArray & rawArea
|
||||
}
|
||||
|
||||
// Check size of new raw area, it must be same as original one
|
||||
UINT32 newSize = rawArea.size();
|
||||
UINT32 oldSize = model->body(index).size();
|
||||
UINT32 newSize = (UINT32)rawArea.size();
|
||||
UINT32 oldSize = (UINT32)model->body(index).size();
|
||||
if (newSize > oldSize) {
|
||||
msg(usprintf("buildRawArea: new area size %Xh (%u) is bigger than the original %Xh (%u)", newSize, newSize, oldSize, oldSize), index);
|
||||
return U_INVALID_RAW_AREA;
|
||||
|
@ -44,7 +44,12 @@ USTATUS FfsOperations::extract(const UModelIndex & index, UString & name, UByteA
|
||||
extracted.clear();
|
||||
// There is no need to redo decompression, we can use child items
|
||||
for (int i = 0; i < model->rowCount(index); i++) {
|
||||
#if ((QT_VERSION_MAJOR == 5) && (QT_VERSION_MINOR < 6)) || (QT_VERSION_MAJOR < 5)
|
||||
UModelIndex childIndex = index.child(i, 0);
|
||||
#else
|
||||
UModelIndex childIndex = index.model()->index(i, 0, index);
|
||||
#endif
|
||||
|
||||
// Ensure 4-byte alignment of current section
|
||||
extracted += UByteArray(ALIGN4((UINT32)extracted.size()) - (UINT32)extracted.size(), '\x00');
|
||||
// Add current section header, body and tail
|
||||
|
@ -478,7 +478,7 @@ USTATUS FfsParser::parseIntelImage(const UByteArray & intelImage, const UINT32 l
|
||||
// Check for padding after the last region
|
||||
if ((UINT64)regions.back().offset + (UINT64)regions.back().length < (UINT64)intelImage.size()) {
|
||||
region.offset = regions.back().offset + regions.back().length;
|
||||
region.length = intelImage.size() - region.offset;
|
||||
region.length = (UINT32)(intelImage.size() - region.offset);
|
||||
region.data = intelImage.mid(region.offset, region.length);
|
||||
region.type = getPaddingType(region.data);
|
||||
regions.push_back(region);
|
||||
@ -718,10 +718,10 @@ USTATUS FfsParser::parseMeRegion(const UByteArray & me, const UINT32 localOffset
|
||||
}
|
||||
else {
|
||||
// Search for new signature
|
||||
INT32 versionOffset = me.indexOf(ME_VERSION_SIGNATURE2);
|
||||
INT32 versionOffset = (INT32)me.indexOf(ME_VERSION_SIGNATURE2);
|
||||
if (versionOffset < 0){ // New signature not found
|
||||
// Search for old signature
|
||||
versionOffset = me.indexOf(ME_VERSION_SIGNATURE);
|
||||
versionOffset = (INT32)me.indexOf(ME_VERSION_SIGNATURE);
|
||||
if (versionOffset < 0){
|
||||
info += ("\nVersion: unknown");
|
||||
versionFound = false;
|
||||
@ -848,7 +848,7 @@ USTATUS FfsParser::parseRawArea(const UModelIndex & index)
|
||||
|
||||
// Get item data
|
||||
UByteArray data = model->body(index);
|
||||
UINT32 headerSize = model->header(index).size();
|
||||
UINT32 headerSize = (UINT32)model->header(index).size();
|
||||
|
||||
USTATUS result;
|
||||
UString name;
|
||||
@ -919,7 +919,7 @@ USTATUS FfsParser::parseRawArea(const UModelIndex & index)
|
||||
|
||||
// Update variables
|
||||
prevItemOffset = itemOffset;
|
||||
prevItemSize = padding.size();
|
||||
prevItemSize = (UINT32)padding.size();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -992,7 +992,12 @@ USTATUS FfsParser::parseRawArea(const UModelIndex & index)
|
||||
|
||||
// Parse bodies
|
||||
for (int i = 0; i < model->rowCount(index); i++) {
|
||||
#if ((QT_VERSION_MAJOR == 5) && (QT_VERSION_MINOR < 6)) || (QT_VERSION_MAJOR < 5)
|
||||
UModelIndex current = index.child(i, 0);
|
||||
#else
|
||||
UModelIndex current = index.model()->index(i, 0, index);
|
||||
#endif
|
||||
|
||||
switch (model->type(current)) {
|
||||
case Types::Volume:
|
||||
parseVolumeBody(current);
|
||||
@ -1122,7 +1127,7 @@ USTATUS FfsParser::parseVolumeHeader(const UByteArray & volume, const UINT32 loc
|
||||
|
||||
// Check for AppleCRC32 and UsedSpace in ZeroVector
|
||||
bool hasAppleCrc32 = false;
|
||||
UINT32 volumeSize = volume.size();
|
||||
UINT32 volumeSize = (UINT32)volume.size();
|
||||
UINT32 appleCrc32 = *(UINT32*)(volume.constData() + 8);
|
||||
UINT32 usedSpace = *(UINT32*)(volume.constData() + 12);
|
||||
if (appleCrc32 != 0) {
|
||||
@ -1295,7 +1300,7 @@ BOOLEAN FfsParser::microcodeHeaderValid(const INTEL_MICROCODE_HEADER* ucodeHeade
|
||||
USTATUS FfsParser::findNextRawAreaItem(const UModelIndex & index, const UINT32 localOffset, UINT8 & nextItemType, UINT32 & nextItemOffset, UINT32 & nextItemSize, UINT32 & nextItemAlternativeSize)
|
||||
{
|
||||
UByteArray data = model->body(index);
|
||||
UINT32 dataSize = data.size();
|
||||
UINT32 dataSize = (UINT32)data.size();
|
||||
|
||||
if (dataSize < sizeof(UINT32))
|
||||
return U_STORES_NOT_FOUND;
|
||||
@ -1435,7 +1440,7 @@ USTATUS FfsParser::parseVolumeBody(const UModelIndex & index)
|
||||
|
||||
// Get volume header size and body
|
||||
UByteArray volumeBody = model->body(index);
|
||||
UINT32 volumeHeaderSize = model->header(index).size();
|
||||
UINT32 volumeHeaderSize = (UINT32)model->header(index).size();
|
||||
|
||||
// Parse VSS NVRAM volumes with a dedicated function
|
||||
if (model->subtype(index) == Subtypes::NvramVolume) {
|
||||
@ -1466,7 +1471,7 @@ USTATUS FfsParser::parseVolumeBody(const UModelIndex & index)
|
||||
}
|
||||
|
||||
// Search for and parse all files
|
||||
UINT32 volumeBodySize = volumeBody.size();
|
||||
UINT32 volumeBodySize = (UINT32)volumeBody.size();
|
||||
UINT32 fileOffset = 0;
|
||||
|
||||
while (fileOffset < volumeBodySize) {
|
||||
@ -1496,7 +1501,7 @@ USTATUS FfsParser::parseVolumeBody(const UModelIndex & index)
|
||||
if (freeSpace.count(emptyByte) != freeSpace.size()) {
|
||||
// Search for the first non-empty byte
|
||||
UINT32 i;
|
||||
UINT32 size = freeSpace.size();
|
||||
UINT32 size = (UINT32)freeSpace.size();
|
||||
const UINT8* current = (UINT8*)freeSpace.constData();
|
||||
for (i = 0; i < size; i++) {
|
||||
if (*current++ != emptyByte) {
|
||||
@ -1559,7 +1564,12 @@ USTATUS FfsParser::parseVolumeBody(const UModelIndex & index)
|
||||
|
||||
// Check for duplicate GUIDs
|
||||
for (int i = 0; i < model->rowCount(index); i++) {
|
||||
#if ((QT_VERSION_MAJOR == 5) && (QT_VERSION_MINOR < 6)) || (QT_VERSION_MAJOR < 5)
|
||||
UModelIndex current = index.child(i, 0);
|
||||
#else
|
||||
UModelIndex current = index.model()->index(i, 0, index);
|
||||
#endif
|
||||
|
||||
// Skip non-file entries and pad files
|
||||
if (model->type(current) != Types::File || model->subtype(current) == EFI_FV_FILETYPE_PAD) {
|
||||
continue;
|
||||
@ -1570,7 +1580,11 @@ USTATUS FfsParser::parseVolumeBody(const UModelIndex & index)
|
||||
|
||||
// Check files after current for having an equal GUID
|
||||
for (int j = i + 1; j < model->rowCount(index); j++) {
|
||||
#if ((QT_VERSION_MAJOR == 5) && (QT_VERSION_MINOR < 6)) || (QT_VERSION_MAJOR < 5)
|
||||
UModelIndex another = index.child(j, 0);
|
||||
#else
|
||||
UModelIndex another = index.model()->index(j, 0, index);
|
||||
#endif
|
||||
|
||||
// Skip non-file entries
|
||||
if (model->type(another) != Types::File) {
|
||||
@ -1589,7 +1603,12 @@ USTATUS FfsParser::parseVolumeBody(const UModelIndex & index)
|
||||
|
||||
// Parse bodies
|
||||
for (int i = 0; i < model->rowCount(index); i++) {
|
||||
#if ((QT_VERSION_MAJOR == 5) && (QT_VERSION_MINOR < 6)) || (QT_VERSION_MAJOR < 5)
|
||||
UModelIndex current = index.child(i, 0);
|
||||
#else
|
||||
UModelIndex current = index.model()->index(i, 0, index);
|
||||
#endif
|
||||
|
||||
switch (model->type(current)) {
|
||||
case Types::File:
|
||||
parseFileBody(current);
|
||||
@ -1704,7 +1723,7 @@ USTATUS FfsParser::parseFileHeader(const UByteArray & file, const UINT32 localOf
|
||||
}
|
||||
|
||||
// Check header checksum
|
||||
UINT8 calculatedHeader = 0x100 - (calculateSum8((const UINT8*)header.constData(), header.size()) - fileHeader->IntegrityCheck.Checksum.Header - fileHeader->IntegrityCheck.Checksum.File - fileHeader->State);
|
||||
UINT8 calculatedHeader = 0x100 - (calculateSum8((const UINT8*)header.constData(), (UINT32)header.size()) - fileHeader->IntegrityCheck.Checksum.Header - fileHeader->IntegrityCheck.Checksum.File - fileHeader->State);
|
||||
bool msgInvalidHeaderChecksum = false;
|
||||
if (fileHeader->IntegrityCheck.Checksum.Header != calculatedHeader) {
|
||||
msgInvalidHeaderChecksum = true;
|
||||
@ -1715,7 +1734,7 @@ USTATUS FfsParser::parseFileHeader(const UByteArray & file, const UINT32 localOf
|
||||
bool msgInvalidDataChecksum = false;
|
||||
UINT8 calculatedData = 0;
|
||||
if (fileHeader->Attributes & FFS_ATTRIB_CHECKSUM) {
|
||||
calculatedData = calculateChecksum8((const UINT8*)body.constData(), body.size());
|
||||
calculatedData = calculateChecksum8((const UINT8*)body.constData(), (UINT32)body.size());
|
||||
}
|
||||
// Data checksum must be one of predefined values
|
||||
else if (volumeRevision == 1) {
|
||||
@ -1907,7 +1926,7 @@ USTATUS FfsParser::parsePadFileBody(const UModelIndex & index)
|
||||
|
||||
// Search for the first non-empty byte
|
||||
UINT32 nonEmptyByteOffset;
|
||||
UINT32 size = body.size();
|
||||
UINT32 size = (UINT32)body.size();
|
||||
const UINT8* current = (const UINT8*)body.constData();
|
||||
for (nonEmptyByteOffset = 0; nonEmptyByteOffset < size; nonEmptyByteOffset++) {
|
||||
if (*current++ != emptyByte)
|
||||
@ -1915,7 +1934,7 @@ USTATUS FfsParser::parsePadFileBody(const UModelIndex & index)
|
||||
}
|
||||
|
||||
// Add all bytes before as free space...
|
||||
UINT32 headerSize = model->header(index).size();
|
||||
UINT32 headerSize = (UINT32)model->header(index).size();
|
||||
if (nonEmptyByteOffset >= 8) {
|
||||
// Align free space to 8 bytes boundary
|
||||
if (nonEmptyByteOffset != ALIGN8(nonEmptyByteOffset))
|
||||
@ -1959,8 +1978,8 @@ USTATUS FfsParser::parseSections(const UByteArray & sections, const UModelIndex
|
||||
return U_INVALID_PARAMETER;
|
||||
|
||||
// Search for and parse all sections
|
||||
UINT32 bodySize = sections.size();
|
||||
UINT32 headerSize = model->header(index).size();
|
||||
UINT32 bodySize = (UINT32)sections.size();
|
||||
UINT32 headerSize = (UINT32)model->header(index).size();
|
||||
UINT32 sectionOffset = 0;
|
||||
USTATUS result = U_SUCCESS;
|
||||
|
||||
@ -2019,7 +2038,12 @@ USTATUS FfsParser::parseSections(const UByteArray & sections, const UModelIndex
|
||||
|
||||
// Parse bodies, will be skipped if insertIntoTree is not required
|
||||
for (int i = 0; i < model->rowCount(index); i++) {
|
||||
#if ((QT_VERSION_MAJOR == 5) && (QT_VERSION_MINOR < 6)) || (QT_VERSION_MAJOR < 5)
|
||||
UModelIndex current = index.child(i, 0);
|
||||
#else
|
||||
UModelIndex current = index.model()->index(i, 0, index);
|
||||
#endif
|
||||
|
||||
switch (model->type(current)) {
|
||||
case Types::Section:
|
||||
parseSectionBody(current);
|
||||
@ -2278,7 +2302,7 @@ USTATUS FfsParser::parseGuidedSectionHeader(const UByteArray & section, const UI
|
||||
UINT32 crc = *(UINT32*)(section.constData() + headerSize);
|
||||
additionalInfo += UString("\nChecksum type: CRC32");
|
||||
// Calculate CRC32 of section data
|
||||
UINT32 calculated = (UINT32)crc32(0, (const UINT8*)section.constData() + dataOffset, section.size() - dataOffset);
|
||||
UINT32 calculated = (UINT32)crc32(0, (const UINT8*)section.constData() + dataOffset, (uInt)(section.size() - dataOffset));
|
||||
if (crc == calculated) {
|
||||
additionalInfo += usprintf("\nChecksum: %08Xh, valid", crc);
|
||||
}
|
||||
@ -2656,7 +2680,7 @@ USTATUS FfsParser::parseCompressedSectionBody(const UModelIndex & index)
|
||||
|
||||
// Obtain required information from parsing data
|
||||
UINT8 compressionType = EFI_NOT_COMPRESSED;
|
||||
UINT32 uncompressedSize = model->body(index).size();
|
||||
UINT32 uncompressedSize = (UINT32)model->body(index).size();
|
||||
if (model->hasEmptyParsingData(index) == false) {
|
||||
UByteArray data = model->parsingData(index);
|
||||
const COMPRESSED_SECTION_PARSING_DATA* pdata = (const COMPRESSED_SECTION_PARSING_DATA*)data.constData();
|
||||
@ -2846,7 +2870,11 @@ USTATUS FfsParser::parseVersionSectionBody(const UModelIndex & index)
|
||||
return U_INVALID_PARAMETER;
|
||||
|
||||
// Add info
|
||||
#if QT_VERSION_MAJOR >= 6
|
||||
model->addInfo(index, UString("\nVersion string: ") + UString::fromUtf16((const char16_t*)model->body(index).constData()));
|
||||
#else
|
||||
model->addInfo(index, UString("\nVersion string: ") + UString::fromUtf16((const CHAR16*)model->body(index).constData()));
|
||||
#endif
|
||||
|
||||
return U_SUCCESS;
|
||||
}
|
||||
@ -2981,7 +3009,11 @@ USTATUS FfsParser::parseUiSectionBody(const UModelIndex & index)
|
||||
if (!index.isValid())
|
||||
return U_INVALID_PARAMETER;
|
||||
|
||||
#if QT_VERSION_MAJOR >= 6
|
||||
UString text = UString::fromUtf16((const char16_t*)model->body(index).constData());
|
||||
#else
|
||||
UString text = UString::fromUtf16((const CHAR16*)model->body(index).constData());
|
||||
#endif
|
||||
|
||||
// Add info
|
||||
model->addInfo(index, UString("\nText: ") + text);
|
||||
@ -2999,7 +3031,7 @@ USTATUS FfsParser::parseAprioriRawSection(const UByteArray & body, UString & par
|
||||
msg(usprintf("%s: apriori file has size is not a multiple of 16", __FUNCTION__));
|
||||
}
|
||||
parsed.clear();
|
||||
UINT32 count = body.size() / sizeof(EFI_GUID);
|
||||
UINT32 count = (UINT32)(body.size() / sizeof(EFI_GUID));
|
||||
if (count > 0) {
|
||||
for (UINT32 i = 0; i < count; i++) {
|
||||
const EFI_GUID* guid = (const EFI_GUID*)body.constData() + i;
|
||||
@ -3207,7 +3239,7 @@ USTATUS FfsParser::performSecondPass(const UModelIndex & index)
|
||||
}
|
||||
|
||||
// Calculate address difference
|
||||
const UINT32 vtfSize = model->header(lastVtf).size() + model->body(lastVtf).size() + model->tail(lastVtf).size();
|
||||
const UINT32 vtfSize = (const UINT32)(model->header(lastVtf).size() + model->body(lastVtf).size() + model->tail(lastVtf).size());
|
||||
addressDiff = 0xFFFFFFFFULL - model->base(lastVtf) - vtfSize + 1;
|
||||
|
||||
// Parse reset vector data
|
||||
@ -3280,7 +3312,7 @@ USTATUS FfsParser::checkTeImageBase(const UModelIndex & index)
|
||||
if (originalImageBase != 0 || adjustedImageBase != 0) {
|
||||
// Check data memory address to be equal to either OriginalImageBase or AdjustedImageBase
|
||||
UINT64 address = addressDiff + model->base(index);
|
||||
UINT32 base = (UINT32)address + model->header(index).size();
|
||||
UINT32 base = (UINT32)(address + model->header(index).size());
|
||||
|
||||
if (originalImageBase == base) {
|
||||
imageBaseType = EFI_IMAGE_TE_BASE_ORIGINAL;
|
||||
@ -3318,7 +3350,11 @@ USTATUS FfsParser::checkTeImageBase(const UModelIndex & index)
|
||||
|
||||
// Process child items
|
||||
for (int i = 0; i < model->rowCount(index); i++) {
|
||||
#if ((QT_VERSION_MAJOR == 5) && (QT_VERSION_MINOR < 6)) || (QT_VERSION_MAJOR < 5)
|
||||
checkTeImageBase(index.child(i, 0));
|
||||
#else
|
||||
checkTeImageBase(index.model()->index(i, 0, index));
|
||||
#endif
|
||||
}
|
||||
|
||||
return U_SUCCESS;
|
||||
@ -3339,7 +3375,7 @@ USTATUS FfsParser::addInfoRecursive(const UModelIndex & index)
|
||||
// Add physical address of the whole item or it's header and data portions separately
|
||||
UINT64 address = addressDiff + model->base(index);
|
||||
if (address <= 0xFFFFFFFFUL) {
|
||||
UINT32 headerSize = model->header(index).size();
|
||||
UINT32 headerSize = (UINT32)model->header(index).size();
|
||||
if (headerSize) {
|
||||
model->addInfo(index, usprintf("Data address: %08Xh\n", address + headerSize),false);
|
||||
model->addInfo(index, usprintf("Header address: %08Xh\n", address), false);
|
||||
@ -3355,7 +3391,11 @@ USTATUS FfsParser::addInfoRecursive(const UModelIndex & index)
|
||||
|
||||
// Process child items
|
||||
for (int i = 0; i < model->rowCount(index); i++) {
|
||||
#if ((QT_VERSION_MAJOR == 5) && (QT_VERSION_MINOR < 6)) || (QT_VERSION_MAJOR < 5)
|
||||
addInfoRecursive(index.child(i, 0));
|
||||
#else
|
||||
addInfoRecursive(index.model()->index(i, 0, index));
|
||||
#endif
|
||||
}
|
||||
|
||||
return U_SUCCESS;
|
||||
@ -3443,7 +3483,7 @@ USTATUS FfsParser::checkProtectedRanges(const UModelIndex & index)
|
||||
else
|
||||
{
|
||||
bgProtectedRanges[i].Offset = model->base(dxeRootVolumeIndex);
|
||||
bgProtectedRanges[i].Size = model->header(dxeRootVolumeIndex).size() + model->body(dxeRootVolumeIndex).size() + model->tail(dxeRootVolumeIndex).size();
|
||||
bgProtectedRanges[i].Size = (UINT32)(model->header(dxeRootVolumeIndex).size() + model->body(dxeRootVolumeIndex).size() + model->tail(dxeRootVolumeIndex).size());
|
||||
protectedParts = openedImage.mid(bgProtectedRanges[i].Offset, bgProtectedRanges[i].Size);
|
||||
|
||||
UByteArray digest(SHA256_DIGEST_SIZE, '\x00');
|
||||
@ -3534,7 +3574,7 @@ USTATUS FfsParser::markProtectedRangeRecursive(const UModelIndex & index, const
|
||||
// Mark normal items
|
||||
else {
|
||||
UINT32 currentOffset = model->base(index);
|
||||
UINT32 currentSize = model->header(index).size() + model->body(index).size() + model->tail(index).size();
|
||||
UINT32 currentSize = (UINT32)(model->header(index).size() + model->body(index).size() + model->tail(index).size());
|
||||
|
||||
if (std::min(currentOffset + currentSize, range.Offset + range.Size) > std::max(currentOffset, range.Offset)) {
|
||||
if (range.Offset <= currentOffset && currentOffset + currentSize <= range.Offset + range.Size) { // Mark as fully in range
|
||||
@ -3552,7 +3592,11 @@ USTATUS FfsParser::markProtectedRangeRecursive(const UModelIndex & index, const
|
||||
}
|
||||
|
||||
for (int i = 0; i < model->rowCount(index); i++) {
|
||||
#if ((QT_VERSION_MAJOR == 5) && (QT_VERSION_MINOR < 6)) || (QT_VERSION_MAJOR < 5)
|
||||
markProtectedRangeRecursive(index.child(i, 0), range);
|
||||
#else
|
||||
markProtectedRangeRecursive(index.model()->index(i, 0, index), range);
|
||||
#endif
|
||||
}
|
||||
|
||||
return U_SUCCESS;
|
||||
@ -3856,7 +3900,12 @@ void FfsParser::findFitRecursive(const UModelIndex & index, UModelIndex & found,
|
||||
|
||||
// Process child items
|
||||
for (int i = 0; i < model->rowCount(index); i++) {
|
||||
#if ((QT_VERSION_MAJOR == 5) && (QT_VERSION_MINOR < 6)) || (QT_VERSION_MAJOR < 5)
|
||||
findFitRecursive(index.child(i, 0), found, fitOffset);
|
||||
#else
|
||||
findFitRecursive(index.model()->index(i, 0, index), found, fitOffset);
|
||||
#endif
|
||||
|
||||
if (found.isValid())
|
||||
return;
|
||||
}
|
||||
@ -3864,11 +3913,11 @@ void FfsParser::findFitRecursive(const UModelIndex & index, UModelIndex & found,
|
||||
// Check for all FIT signatures in item's body
|
||||
UByteArray lastVtfBody = model->body(lastVtf);
|
||||
UINT32 storedFitAddress = *(const UINT32*)(lastVtfBody.constData() + lastVtfBody.size() - FIT_POINTER_OFFSET);
|
||||
for (INT32 offset = model->body(index).indexOf(FIT_SIGNATURE);
|
||||
for (INT32 offset = (INT32)model->body(index).indexOf(FIT_SIGNATURE);
|
||||
offset >= 0;
|
||||
offset = model->body(index).indexOf(FIT_SIGNATURE, offset + 1)) {
|
||||
offset = (INT32)model->body(index).indexOf(FIT_SIGNATURE, offset + 1)) {
|
||||
// FIT candidate found, calculate it's physical address
|
||||
UINT32 fitAddress = model->base(index) + (UINT32)addressDiff + model->header(index).size() + (UINT32)offset;
|
||||
UINT32 fitAddress = (UINT32)(model->base(index) + (UINT32)addressDiff + model->header(index).size() + (UINT32)offset);
|
||||
|
||||
// Check FIT address to be stored in the last VTF
|
||||
if (fitAddress == storedFitAddress) {
|
||||
@ -4062,7 +4111,7 @@ USTATUS FfsParser::parseFitEntryBootGuardKeyManifest(const UByteArray & keyManif
|
||||
|
||||
USTATUS FfsParser::findNextBootGuardBootPolicyElement(const UByteArray & bootPolicy, const UINT32 elementOffset, UINT32 & nextElementOffset, UINT32 & nextElementSize)
|
||||
{
|
||||
UINT32 dataSize = bootPolicy.size();
|
||||
UINT32 dataSize = (UINT32)bootPolicy.size();
|
||||
if (dataSize < sizeof(UINT64)) {
|
||||
return U_ELEMENTS_NOT_FOUND;
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ 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(), data.size());
|
||||
UINT32 crc = (UINT32)crc32(0, (const UINT8*)data.constData(), (uInt)data.size());
|
||||
|
||||
// Information on current item
|
||||
UString text = model->text(index);
|
||||
@ -68,7 +68,11 @@ USTATUS FfsReport::generateRecursive(std::vector<UString> & report, const UModel
|
||||
|
||||
// Information on child items
|
||||
for (int i = 0; i < model->rowCount(index); i++) {
|
||||
#if ((QT_VERSION_MAJOR == 5) && (QT_VERSION_MINOR < 6)) || (QT_VERSION_MAJOR < 5)
|
||||
generateRecursive(report, index.child(i,0), level + 1);
|
||||
#else
|
||||
generateRecursive(report, index.model()->index(i,0,index), level + 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
return U_SUCCESS;
|
||||
|
@ -40,7 +40,12 @@ USTATUS findFileRecursive(TreeModel *model, const UModelIndex index, const UStri
|
||||
|
||||
bool hasChildren = (model->rowCount(index) > 0);
|
||||
for (int i = 0; i < model->rowCount(index); i++) {
|
||||
#if ((QT_VERSION_MAJOR == 5) && (QT_VERSION_MINOR < 6)) || (QT_VERSION_MAJOR < 5)
|
||||
findFileRecursive(model, index.child(i, index.column()), hexPattern, mode, files);
|
||||
#else
|
||||
findFileRecursive(model, index.model()->index(i, index.column(), index), hexPattern, mode, files);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
UByteArray data;
|
||||
|
@ -116,7 +116,12 @@ GuidDatabase guidDatabaseFromTreeRecursive(TreeModel * model, const UModelIndex
|
||||
return db;
|
||||
|
||||
for (int i = 0; i < model->rowCount(index); i++) {
|
||||
#if ((QT_VERSION_MAJOR == 5) && (QT_VERSION_MINOR < 6)) || (QT_VERSION_MAJOR < 5)
|
||||
GuidDatabase tmpDb = guidDatabaseFromTreeRecursive(model, index.child(i, index.column()));
|
||||
#else
|
||||
GuidDatabase tmpDb = guidDatabaseFromTreeRecursive(model, index.model()->index(i, index.column(), index));
|
||||
#endif
|
||||
|
||||
db.insert(tmpDb.begin(), tmpDb.end());
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ USTATUS MeParser::parseFptRegion(const UByteArray & region, const UModelIndex &
|
||||
|
||||
// Add partition table entries
|
||||
std::vector<FPT_PARTITION_INFO> partitions;
|
||||
UINT32 offset = header.size();
|
||||
UINT32 offset = (UINT32)header.size();
|
||||
const FPT_HEADER_ENTRY* firstPtEntry = (const FPT_HEADER_ENTRY*)(region.constData() + offset);
|
||||
for (UINT8 i = 0; i < ptHeader->NumEntries; i++) {
|
||||
// Populate entry header
|
||||
@ -265,7 +265,7 @@ make_partition_table_consistent:
|
||||
// Check for padding after the last region
|
||||
if ((UINT32)partitions.back().ptEntry.Offset + (UINT32)partitions.back().ptEntry.Size < (UINT32)region.size()) {
|
||||
padding.ptEntry.Offset = partitions.back().ptEntry.Offset + partitions.back().ptEntry.Size;
|
||||
padding.ptEntry.Size = region.size() - padding.ptEntry.Offset;
|
||||
padding.ptEntry.Size = (UINT32)(region.size() - padding.ptEntry.Offset);
|
||||
padding.type = Types::Padding;
|
||||
partitions.push_back(padding);
|
||||
}
|
||||
@ -422,7 +422,7 @@ make_partition_table_consistent:
|
||||
// Check for padding after the last region
|
||||
if ((UINT32)partitions.back().ptEntry.Offset + (UINT32)partitions.back().ptEntry.Size < (UINT32)region.size()) {
|
||||
padding.ptEntry.Offset = partitions.back().ptEntry.Offset + partitions.back().ptEntry.Size;
|
||||
padding.ptEntry.Size = region.size() - padding.ptEntry.Offset;
|
||||
padding.ptEntry.Size = (UINT32)(region.size() - padding.ptEntry.Offset);
|
||||
padding.type = Types::Padding;
|
||||
partitions.push_back(padding);
|
||||
}
|
||||
@ -604,7 +604,7 @@ make_partition_table_consistent:
|
||||
// Check for padding after the last region
|
||||
if ((UINT32)partitions.back().ptEntry.Offset + (UINT32)partitions.back().ptEntry.Size < (UINT32)region.size()) {
|
||||
padding.ptEntry.Offset = partitions.back().ptEntry.Offset + partitions.back().ptEntry.Size;
|
||||
padding.ptEntry.Size = region.size() - padding.ptEntry.Offset;
|
||||
padding.ptEntry.Size = (UINT32)(region.size() - padding.ptEntry.Offset);
|
||||
padding.type = Types::Padding;
|
||||
partitions.push_back(padding);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ USTATUS NvramParser::parseNvarStore(const UModelIndex & index)
|
||||
}
|
||||
|
||||
// Get local offset
|
||||
UINT32 localOffset = model->header(index).size();
|
||||
UINT32 localOffset = (UINT32)model->header(index).size();
|
||||
|
||||
// Get item data
|
||||
const UByteArray data = model->body(index);
|
||||
@ -121,7 +121,7 @@ USTATUS NvramParser::parseNvarStore(const UModelIndex & index)
|
||||
guidArea.size(), guidArea.size(),
|
||||
guidsInStore);
|
||||
// Add tree item
|
||||
model->addItem(localOffset + offset + padding.size(), Types::Padding, getPaddingType(guidArea), name, UString(), info, UByteArray(), guidArea, UByteArray(), Fixed, index);
|
||||
model->addItem((UINT32)(localOffset + offset + padding.size()), Types::Padding, getPaddingType(guidArea), name, UString(), info, UByteArray(), guidArea, UByteArray(), Fixed, index);
|
||||
|
||||
return U_SUCCESS;
|
||||
}
|
||||
@ -230,7 +230,12 @@ USTATUS NvramParser::parseNvarStore(const UModelIndex & index)
|
||||
// Search previously added entries for a link to this variable
|
||||
// WARNING: O(n^2), may be very slow
|
||||
for (int i = model->rowCount(index) - 1; i >= 0; i--) {
|
||||
#if ((QT_VERSION_MAJOR == 5) && (QT_VERSION_MINOR < 6)) || (QT_VERSION_MAJOR < 5)
|
||||
nvarIndex = index.child(i, 0);
|
||||
#else
|
||||
nvarIndex = index.model()->index(i, 0, index);
|
||||
#endif
|
||||
|
||||
if (model->hasEmptyParsingData(nvarIndex) == false) {
|
||||
UByteArray nvarData = model->parsingData(nvarIndex);
|
||||
const NVAR_ENTRY_PARSING_DATA nvarPdata = readUnaligned((const NVAR_ENTRY_PARSING_DATA*)nvarData.constData());
|
||||
@ -261,11 +266,16 @@ USTATUS NvramParser::parseNvarStore(const UModelIndex & index)
|
||||
UINT32 nameSize = 0;
|
||||
if (entryHeader->Attributes & NVRAM_NVAR_ENTRY_ASCII_NAME) { // Name is stored as ASCII string of CHAR8s
|
||||
text = UString(namePtr);
|
||||
nameSize = text.length() + 1;
|
||||
nameSize = (UINT32)(text.length() + 1);
|
||||
}
|
||||
else { // Name is stored as UCS2 string of CHAR16s
|
||||
#if QT_VERSION_MAJOR >= 6
|
||||
text = UString::fromUtf16((char16_t*)namePtr);
|
||||
#else
|
||||
text = UString::fromUtf16((CHAR16*)namePtr);
|
||||
nameSize = (text.length() + 1) * 2;
|
||||
#endif
|
||||
|
||||
nameSize = (UINT32)((text.length() + 1) * 2);
|
||||
}
|
||||
|
||||
// Get entry GUID
|
||||
@ -388,7 +398,7 @@ USTATUS NvramParser::parseNvramVolumeBody(const UModelIndex & index)
|
||||
}
|
||||
|
||||
// Get local offset
|
||||
UINT32 localOffset = model->header(index).size();
|
||||
UINT32 localOffset = (UINT32)model->header(index).size();
|
||||
|
||||
// Get item data
|
||||
UByteArray data = model->body(index);
|
||||
@ -455,7 +465,7 @@ USTATUS NvramParser::parseNvramVolumeBody(const UModelIndex & index)
|
||||
|
||||
// Update variables
|
||||
prevStoreOffset = storeOffset;
|
||||
prevStoreSize = padding.size();
|
||||
prevStoreSize = (UINT32)padding.size();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -497,7 +507,12 @@ USTATUS NvramParser::parseNvramVolumeBody(const UModelIndex & index)
|
||||
|
||||
// Parse bodies
|
||||
for (int i = 0; i < model->rowCount(index); i++) {
|
||||
#if ((QT_VERSION_MAJOR == 5) && (QT_VERSION_MINOR < 6)) || (QT_VERSION_MAJOR < 5)
|
||||
UModelIndex current = index.child(i, 0);
|
||||
#else
|
||||
UModelIndex current = index.model()->index(i, 0, index);
|
||||
#endif
|
||||
|
||||
switch (model->type(current)) {
|
||||
case Types::FdcStore:
|
||||
parseFdcStoreBody(current);
|
||||
@ -528,7 +543,7 @@ USTATUS NvramParser::parseNvramVolumeBody(const UModelIndex & index)
|
||||
|
||||
USTATUS NvramParser::findNextStore(const UModelIndex & index, const UByteArray & volume, const UINT32 localOffset, const UINT32 storeOffset, UINT32 & nextStoreOffset)
|
||||
{
|
||||
UINT32 dataSize = volume.size();
|
||||
UINT32 dataSize = (UINT32)volume.size();
|
||||
|
||||
if (dataSize < sizeof(UINT32))
|
||||
return U_STORES_NOT_FOUND;
|
||||
@ -1286,7 +1301,7 @@ USTATUS NvramParser::parseFdcStoreBody(const UModelIndex & index)
|
||||
const UByteArray data = model->body(index);
|
||||
|
||||
// Get local offset
|
||||
UINT32 localOffset = model->header(index).size();
|
||||
UINT32 localOffset = (UINT32)model->header(index).size();
|
||||
|
||||
// The body is a firmware volume with either a VSS or VSS2 store
|
||||
UModelIndex volumeIndex;
|
||||
@ -1300,14 +1315,14 @@ USTATUS NvramParser::parseFdcStoreBody(const UModelIndex & index)
|
||||
UByteArray store = model->body(volumeIndex);
|
||||
if ((UINT32)store.size() >= sizeof(UINT32) && *(const UINT32*)store.constData() == NVRAM_VSS_STORE_SIGNATURE) {
|
||||
UModelIndex vssIndex;
|
||||
status = parseVssStoreHeader(store, localOffset + model->header(volumeIndex).size(), true, volumeIndex, vssIndex);
|
||||
status = parseVssStoreHeader(store, (UINT32)(localOffset + model->header(volumeIndex).size()), true, volumeIndex, vssIndex);
|
||||
if (status)
|
||||
return status;
|
||||
return parseVssStoreBody(vssIndex, 0);
|
||||
}
|
||||
else if ((UINT32)store.size() >= sizeof(EFI_GUID) && store.left(sizeof(EFI_GUID)) == NVRAM_FDC_STORE_GUID) {
|
||||
UModelIndex vss2Index;
|
||||
status = parseVss2StoreHeader(store, localOffset + model->header(volumeIndex).size(), true, volumeIndex, vss2Index);
|
||||
status = parseVss2StoreHeader(store, (UINT32)(localOffset + model->header(volumeIndex).size()), true, volumeIndex, vss2Index);
|
||||
if (status)
|
||||
return status;
|
||||
return parseVssStoreBody(vss2Index, 0);
|
||||
@ -1335,7 +1350,7 @@ USTATUS NvramParser::parseVssStoreBody(const UModelIndex & index, UINT8 alignmen
|
||||
}
|
||||
|
||||
// Get local offset
|
||||
UINT32 localOffset = model->header(index).size();
|
||||
UINT32 localOffset = (UINT32)model->header(index).size();
|
||||
|
||||
// Get item data
|
||||
const UByteArray data = model->body(index);
|
||||
@ -1396,7 +1411,7 @@ USTATUS NvramParser::parseVssStoreBody(const UModelIndex & index, UINT8 alignmen
|
||||
|
||||
// Calculate CRC32 of the variable data
|
||||
storedCrc32 = appleVariableHeader->DataCrc32;
|
||||
calculatedCrc32 = (UINT32)crc32(0, (const UINT8*)body.constData(), body.size());
|
||||
calculatedCrc32 = (UINT32)crc32(0, (const UINT8*)body.constData(), (uInt)body.size());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1501,7 +1516,12 @@ USTATUS NvramParser::parseVssStoreBody(const UModelIndex & index, UINT8 alignmen
|
||||
else { // Add GUID and text for valid variables
|
||||
name = guidToUString(readUnaligned(variableGuid));
|
||||
info += UString("Variable GUID: ") + guidToUString(readUnaligned(variableGuid), false) + UString("\n");
|
||||
|
||||
#if QT_VERSION_MAJOR >= 6
|
||||
text = UString::fromUtf16((char16_t *)variableName);
|
||||
#else
|
||||
text = UString::fromUtf16(variableName);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Add info
|
||||
@ -1555,7 +1575,7 @@ USTATUS NvramParser::parseFsysStoreBody(const UModelIndex & index)
|
||||
return U_INVALID_PARAMETER;
|
||||
|
||||
// Get local offset
|
||||
UINT32 localOffset = model->header(index).size();
|
||||
UINT32 localOffset = (UINT32)model->header(index).size();
|
||||
|
||||
// Get item data
|
||||
const UByteArray data = model->body(index);
|
||||
@ -1658,7 +1678,7 @@ USTATUS NvramParser::parseEvsaStoreBody(const UModelIndex & index)
|
||||
}
|
||||
|
||||
// Get local offset
|
||||
UINT32 localOffset = model->header(index).size();
|
||||
UINT32 localOffset = (UINT32)model->header(index).size();
|
||||
|
||||
// Get item data
|
||||
const UByteArray data = model->body(index);
|
||||
@ -1732,7 +1752,13 @@ USTATUS NvramParser::parseEvsaStoreBody(const UModelIndex & index)
|
||||
const EVSA_NAME_ENTRY* nameHeader = (const EVSA_NAME_ENTRY*)entryHeader;
|
||||
header = data.mid(offset, sizeof(EVSA_NAME_ENTRY));
|
||||
body = data.mid(offset + sizeof(EVSA_NAME_ENTRY), nameHeader->Header.Size - sizeof(EVSA_NAME_ENTRY));
|
||||
|
||||
#if QT_VERSION_MAJOR >= 6
|
||||
name = UString::fromUtf16((const char16_t *)body.constData());
|
||||
#else
|
||||
name = UString::fromUtf16((const CHAR16*)body.constData());
|
||||
#endif
|
||||
|
||||
info = UString("Name: ") + name + usprintf("\nFull size: %Xh (%u)\nHeader size %Xh (%u)\nBody size: %Xh (%u)\nType: %02Xh\nChecksum: %02Xh",
|
||||
variableSize, variableSize,
|
||||
header.size(), header.size(),
|
||||
@ -1805,7 +1831,12 @@ USTATUS NvramParser::parseEvsaStoreBody(const UModelIndex & index)
|
||||
|
||||
// Reparse all data variables to detect invalid ones and assign name and test to valid ones
|
||||
for (int i = 0; i < model->rowCount(index); i++) {
|
||||
#if ((QT_VERSION_MAJOR == 5) && (QT_VERSION_MINOR < 6)) || (QT_VERSION_MAJOR < 5)
|
||||
UModelIndex current = index.child(i, 0);
|
||||
#else
|
||||
UModelIndex current = index.model()->index(i, 0, index);
|
||||
#endif
|
||||
|
||||
if (model->subtype(current) == Subtypes::DataEvsaEntry) {
|
||||
UByteArray header = model->header(current);
|
||||
const EVSA_DATA_ENTRY* dataHeader = (const EVSA_DATA_ENTRY*)header.constData();
|
||||
@ -1857,7 +1888,7 @@ USTATUS NvramParser::parseFlashMapBody(const UModelIndex & index)
|
||||
return U_INVALID_PARAMETER;
|
||||
|
||||
// Get parsing data for the current item
|
||||
UINT32 localOffset = model->header(index).size();
|
||||
UINT32 localOffset = (UINT32)model->header(index).size();
|
||||
const UByteArray data = model->body(index);
|
||||
|
||||
|
||||
|
@ -109,8 +109,8 @@ static void sha256_compress(struct sha256_state *md, unsigned char *buf)
|
||||
}
|
||||
/* Compress */
|
||||
#define RND(a,b,c,d,e,f,g,h,i) \
|
||||
t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \
|
||||
t1 = Sigma0(a) + Maj(a, b, c); \
|
||||
t0 = (uint32_t)(h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]); \
|
||||
t1 = (uint32_t)(Sigma0(a) + Maj(a, b, c)); \
|
||||
d += t0; \
|
||||
h = t0 + t1;
|
||||
for (i = 0; i < 64; ++i) {
|
||||
|
@ -43,7 +43,7 @@ QVariant TreeModel::data(const UModelIndex &index, int role) const
|
||||
Qt::ItemFlags TreeModel::flags(const UModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return 0;
|
||||
return Qt::NoItemFlags;
|
||||
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||
}
|
||||
@ -559,9 +559,14 @@ UModelIndex TreeModel::findByBase(UINT32 base) const
|
||||
goDeeper:
|
||||
int n = rowCount(parentIndex);
|
||||
for (int i = 0; i < n; i++) {
|
||||
#if ((QT_VERSION_MAJOR == 5) && (QT_VERSION_MINOR < 6)) || (QT_VERSION_MAJOR < 5)
|
||||
UModelIndex currentIndex = parentIndex.child(i, 0);
|
||||
#else
|
||||
UModelIndex currentIndex = parentIndex.model()->index(i, 0, parentIndex);
|
||||
#endif
|
||||
|
||||
UINT32 currentBase = this->base(currentIndex);
|
||||
UINT32 fullSize = header(currentIndex).size() + body(currentIndex).size() + tail(currentIndex).size();
|
||||
UINT32 fullSize = (UINT32)(header(currentIndex).size() + body(currentIndex).size() + tail(currentIndex).size());
|
||||
if ((compressed(currentIndex) == false || (compressed(currentIndex) == true && compressed(currentIndex.parent()) == false)) // Base is meaningful only for true uncompressed items
|
||||
&& currentBase <= base && base < currentBase + fullSize) { // Base must be in range [currentBase, currentBase + fullSize)
|
||||
// Found a better candidate
|
||||
|
@ -86,7 +86,6 @@ private:
|
||||
#if defined(QT_CORE_LIB)
|
||||
class TreeModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
TreeItem *rootItem;
|
||||
bool markingEnabledFlag;
|
||||
|
@ -45,14 +45,14 @@ public:
|
||||
UByteArray toUpper() { std::basic_string<char> s = d; std::transform(s.begin(), s.end(), s.begin(), ::toupper); return UByteArray(s); }
|
||||
uint32_t toUInt(bool* ok = NULL, const uint8_t base = 10) { return (uint32_t)strtoul(d.c_str(), NULL, base); }
|
||||
|
||||
int32_t size() const { return d.size(); }
|
||||
int32_t count(char ch) const { return std::count(d.begin(), d.end(), ch); }
|
||||
int32_t size() const { return (int32_t)d.size(); }
|
||||
int32_t count(char ch) const { return (int32_t)std::count(d.begin(), d.end(), ch); }
|
||||
char at(uint32_t i) const { return d.at(i); }
|
||||
char operator[](uint32_t i) const { return d[i]; }
|
||||
char& operator[](uint32_t i) { return d[i]; }
|
||||
|
||||
bool startsWith(const UByteArray & ba) const { return 0 == d.find(ba.d, 0); }
|
||||
int indexOf(const UByteArray & ba, int from = 0) const { return d.find(ba.d, from); }
|
||||
int indexOf(const UByteArray & ba, int from = 0) const { return (int)d.find(ba.d, from); }
|
||||
int lastIndexOf(const UByteArray & ba, int from = 0) const {
|
||||
size_t old_index = d.npos;
|
||||
size_t index = d.find(ba.d, from);
|
||||
@ -60,7 +60,7 @@ public:
|
||||
old_index = index;
|
||||
index = d.find(ba.d, index + 1);
|
||||
}
|
||||
return old_index;
|
||||
return (int)old_index;
|
||||
}
|
||||
|
||||
UByteArray left(int32_t len) const { return d.substr(0, len); }
|
||||
|
@ -19,7 +19,13 @@ UString usprintf(const char* fmt, ...)
|
||||
UString msg;
|
||||
va_list vl;
|
||||
va_start(vl, fmt);
|
||||
|
||||
#if ((QT_VERSION_MAJOR == 5) && (QT_VERSION_MINOR < 6)) || (QT_VERSION_MAJOR < 5)
|
||||
msg.vsprintf(fmt, vl);
|
||||
#else
|
||||
msg = msg.vasprintf(fmt, vl);
|
||||
#endif
|
||||
|
||||
va_end(vl);
|
||||
return msg;
|
||||
};
|
||||
|
@ -102,7 +102,7 @@ UString uniqueItemName(const UModelIndex & index)
|
||||
'<', '>', ':', '\"', '\\', '|', '?', '*', // Banned in Windows
|
||||
' ' // Provides better readability
|
||||
};
|
||||
int nameLength = name.length(); // Note: Qt uses int for whatever reason.
|
||||
int nameLength = (int)name.length(); // Note: Qt uses int for whatever reason.
|
||||
for (int i = 0; i < nameLength; i++) {
|
||||
for (size_t j = 0; j < sizeof(table); j++) {
|
||||
if (name[i] == table[j]) {
|
||||
@ -200,7 +200,7 @@ USTATUS decompress(const UByteArray & compressedData, const UINT8 compressionTyp
|
||||
|
||||
// Get buffer sizes
|
||||
data = (UINT8*)compressedData.data();
|
||||
dataSize = compressedData.size();
|
||||
dataSize = (UINT32)compressedData.size();
|
||||
|
||||
// Check header to be valid
|
||||
header = (const EFI_TIANO_HEADER*)data;
|
||||
@ -260,7 +260,7 @@ USTATUS decompress(const UByteArray & compressedData, const UINT8 compressionTyp
|
||||
|
||||
// Get buffer sizes
|
||||
data = (const UINT8*)compressedData.constData();
|
||||
dataSize = compressedData.size();
|
||||
dataSize = (UINT32)compressedData.size();
|
||||
|
||||
// Get info as normal LZMA section
|
||||
if (U_SUCCESS != LzmaGetInfo(data, dataSize, &decompressedSize)) {
|
||||
@ -305,7 +305,7 @@ USTATUS decompress(const UByteArray & compressedData, const UINT8 compressionTyp
|
||||
|
||||
// Get buffer sizes
|
||||
data = (const UINT8*)compressedData.constData();
|
||||
dataSize = compressedData.size();
|
||||
dataSize = (UINT32)compressedData.size();
|
||||
|
||||
// Get info as normal LZMA section
|
||||
if (U_SUCCESS != LzmaGetInfo(data, dataSize, &decompressedSize)) {
|
||||
@ -498,7 +498,7 @@ USTATUS gzipDecompress(const UByteArray & input, UByteArray & output)
|
||||
|
||||
z_stream stream;
|
||||
stream.next_in = (z_const Bytef *)input.data();
|
||||
stream.avail_in = input.size();
|
||||
stream.avail_in = (uInt)input.size();
|
||||
stream.zalloc = Z_NULL;
|
||||
stream.zfree = Z_NULL;
|
||||
stream.opaque = Z_NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user