mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-25 09:28:22 +08:00
41fb0cbbf5
Refactoring of engine and UI code to use model instead of items directly. WARNING: this code is untested yet and commited not for release purposes
101 lines
4.7 KiB
C++
101 lines
4.7 KiB
C++
/* ffsengine.h
|
|
|
|
Copyright (c) 2013, 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.
|
|
*/
|
|
|
|
#ifndef __FFSENGINE_H__
|
|
#define __FFSENGINE_H__
|
|
|
|
#include <QObject>
|
|
#include <QModelIndex>
|
|
#include <QByteArray>
|
|
#include <QQueue>
|
|
|
|
#include "basetypes.h"
|
|
#include "treemodel.h"
|
|
#include "messagelistitem.h"
|
|
|
|
class TreeModel;
|
|
|
|
class FfsEngine : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
// Default constructor and destructor
|
|
FfsEngine(QObject *parent = 0);
|
|
~FfsEngine(void);
|
|
|
|
// Returns model for Qt view classes
|
|
TreeModel* treeModel() const;
|
|
|
|
// Returns message items queue
|
|
QQueue<MessageListItem> messages() const;
|
|
|
|
// Clears message items queue
|
|
void clearMessages();
|
|
|
|
// Firmware image parsing
|
|
UINT8 parseInputFile(const QByteArray & buffer);
|
|
UINT8 parseIntelImage(const QByteArray & flashImage, QModelIndex & index, const QModelIndex & parent = QModelIndex());
|
|
UINT8 parseGbeRegion(const QByteArray & gbe, QModelIndex & index, const QModelIndex & parent);
|
|
UINT8 parseMeRegion(const QByteArray & me, QModelIndex & index, const QModelIndex & parent);
|
|
UINT8 parseBiosRegion(const QByteArray & bios, QModelIndex & index, const QModelIndex & parent);
|
|
UINT8 parsePdrRegion(const QByteArray & pdr, QModelIndex & index, const QModelIndex & parent);
|
|
UINT8 parseBios(const QByteArray & bios, const QModelIndex & parent = QModelIndex());
|
|
UINT8 findNextVolume(const QByteArray & bios, const UINT32 volumeOffset, UINT32 & nextVolumeOffset);
|
|
UINT8 getVolumeSize(const QByteArray & bios, const UINT32 volumeOffset, UINT32 & volumeSize);
|
|
UINT8 parseVolume(const QByteArray & volume, QModelIndex & index, const QModelIndex & parent = QModelIndex(), const UINT8 mode = CREATE_MODE_APPEND);
|
|
UINT8 getFileSize(const QByteArray & volume, const UINT32 fileOffset, UINT32 & fileSize);
|
|
UINT8 parseFile(const QByteArray & file, QModelIndex & index, const UINT8 erasePolarity = ERASE_POLARITY_UNKNOWN, const QModelIndex & parent = QModelIndex(), const UINT8 mode = CREATE_MODE_APPEND);
|
|
UINT8 getSectionSize(const QByteArray & file, const UINT32 sectionOffset, UINT32 & sectionSize);
|
|
UINT8 parseSections(const QByteArray & body, const QModelIndex & parent = QModelIndex());
|
|
UINT8 parseSection(const QByteArray & section, QModelIndex & index, const QModelIndex & parent = QModelIndex(), const UINT8 mode = CREATE_MODE_APPEND);
|
|
|
|
// Compression routines
|
|
UINT8 decompress(const QByteArray & compressed, const UINT8 compressionType, QByteArray & decompressedData, UINT8 * algorithm = NULL);
|
|
UINT8 compress(const QByteArray & data, const UINT8 algorithm, QByteArray & compressedData);
|
|
|
|
// Construction routines
|
|
UINT8 reconstructImage(QByteArray & reconstructed);
|
|
UINT8 constructPadFile(const UINT32 size, const UINT8 revision, const UINT8 erasePolarity, QByteArray & pad);
|
|
UINT8 reconstruct(const QModelIndex & index, QQueue<QByteArray> & queue, const UINT8 revision = 2, const UINT8 erasePolarity = ERASE_POLARITY_UNKNOWN);
|
|
UINT8 growVolume(QByteArray & header, const UINT32 size, UINT32 & newSize);
|
|
|
|
// Operations on tree items
|
|
UINT8 extract(const QModelIndex & index, QByteArray & extracted, const UINT8 mode);
|
|
|
|
UINT8 create(const QModelIndex & index, const UINT8 type, const QByteArray & header, const QByteArray & body, const UINT8 mode, const UINT8 action, const UINT8 algorithm = COMPRESSION_ALGORITHM_NONE);
|
|
UINT8 insert(const QModelIndex & index, const QByteArray & object, const UINT8 mode);
|
|
UINT8 replace(const QModelIndex & index, const QByteArray & object, const UINT8 mode);
|
|
|
|
UINT8 remove(const QModelIndex & index);
|
|
|
|
UINT8 rebuild(const QModelIndex & index);
|
|
|
|
// Search routines
|
|
UINT8 findHexPattern(const QByteArray & pattern, const UINT8 mode);
|
|
UINT8 findHexPatternIn(const QModelIndex & index, const QByteArray & pattern, const UINT8 mode);
|
|
UINT8 findTextPattern(const QString & pattern, const bool unicode, const Qt::CaseSensitivity caseSensitive);
|
|
UINT8 findTextPatternIn(const QModelIndex & index, const QString & pattern, const bool unicode, const Qt::CaseSensitivity caseSensitive);
|
|
|
|
private:
|
|
TreeModel *model;
|
|
|
|
// Message helper
|
|
QQueue<MessageListItem> messageItems;
|
|
void msg(const QString & message, const QModelIndex index = QModelIndex());
|
|
|
|
// Internal operations
|
|
bool hasIntersection(const UINT32 begin1, const UINT32 end1, const UINT32 begin2, const UINT32 end2);
|
|
};
|
|
|
|
#endif
|