2015-03-13 14:48:53 +08:00
|
|
|
/* ffsparser.h
|
|
|
|
|
2016-02-02 09:08:08 +08:00
|
|
|
Copyright (c) 2016, Nikolaj Schlej. All rights reserved.
|
2015-03-13 14:48:53 +08:00
|
|
|
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 __FFSPARSER_H__
|
|
|
|
#define __FFSPARSER_H__
|
|
|
|
|
2016-03-01 15:20:44 +08:00
|
|
|
#include <vector>
|
|
|
|
|
2015-03-13 14:48:53 +08:00
|
|
|
#include <QObject>
|
|
|
|
#include <QModelIndex>
|
|
|
|
#include <QByteArray>
|
|
|
|
|
|
|
|
#include "basetypes.h"
|
|
|
|
#include "treemodel.h"
|
|
|
|
#include "utility.h"
|
|
|
|
#include "peimage.h"
|
2015-04-02 16:04:37 +08:00
|
|
|
#include "parsingdata.h"
|
2016-02-02 09:08:08 +08:00
|
|
|
#include "types.h"
|
|
|
|
#include "treemodel.h"
|
|
|
|
#include "descriptor.h"
|
|
|
|
#include "ffs.h"
|
|
|
|
#include "gbe.h"
|
|
|
|
#include "me.h"
|
|
|
|
#include "fit.h"
|
2016-03-21 06:59:03 +08:00
|
|
|
#include "nvram.h"
|
2015-03-13 14:48:53 +08:00
|
|
|
|
|
|
|
class TreeModel;
|
|
|
|
|
2016-03-01 15:20:44 +08:00
|
|
|
class FfsParser
|
2015-03-13 14:48:53 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Default constructor and destructor
|
2016-03-01 15:20:44 +08:00
|
|
|
FfsParser(TreeModel* treeModel);
|
2015-04-02 16:04:37 +08:00
|
|
|
~FfsParser();
|
2015-03-13 14:48:53 +08:00
|
|
|
|
2015-04-02 16:04:37 +08:00
|
|
|
// Returns messages
|
2016-03-01 15:20:44 +08:00
|
|
|
std::vector<std::pair<QString, QModelIndex> > getMessages() const;
|
2015-04-02 16:04:37 +08:00
|
|
|
// Clears messages
|
2015-03-13 14:48:53 +08:00
|
|
|
void clearMessages();
|
|
|
|
|
|
|
|
// Firmware image parsing
|
2016-02-02 09:08:08 +08:00
|
|
|
STATUS parse(const QByteArray &buffer);
|
2016-03-01 15:20:44 +08:00
|
|
|
|
2015-07-07 21:57:41 +08:00
|
|
|
// Retuns index of the last VTF after parsing is done
|
|
|
|
const QModelIndex getLastVtf() {return lastVtf;};
|
|
|
|
|
2015-03-13 14:48:53 +08:00
|
|
|
private:
|
|
|
|
TreeModel *model;
|
2016-03-01 15:20:44 +08:00
|
|
|
std::vector<std::pair<QString, QModelIndex> > messagesVector;
|
2015-06-20 02:26:45 +08:00
|
|
|
QModelIndex lastVtf;
|
2015-09-13 23:32:22 +08:00
|
|
|
UINT32 capsuleOffsetFixup;
|
2015-03-13 14:48:53 +08:00
|
|
|
|
2016-03-01 15:20:44 +08:00
|
|
|
STATUS parseRawArea(const QByteArray & data, const QModelIndex & index);
|
|
|
|
STATUS parseVolumeHeader(const QByteArray & volume, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index);
|
|
|
|
STATUS parseVolumeBody(const QModelIndex & index);
|
|
|
|
STATUS parseFileHeader(const QByteArray & file, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index);
|
|
|
|
STATUS parseFileBody(const QModelIndex & index);
|
|
|
|
STATUS parseSectionHeader(const QByteArray & section, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index, const bool preparse = false);
|
|
|
|
STATUS parseSectionBody(const QModelIndex & index);
|
|
|
|
|
2015-07-09 05:05:48 +08:00
|
|
|
STATUS parseIntelImage(const QByteArray & intelImage, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & root);
|
2015-03-13 14:48:53 +08:00
|
|
|
STATUS parseGbeRegion(const QByteArray & gbe, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index);
|
|
|
|
STATUS parseMeRegion(const QByteArray & me, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index);
|
|
|
|
STATUS parseBiosRegion(const QByteArray & bios, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index);
|
|
|
|
STATUS parsePdrRegion(const QByteArray & pdr, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index);
|
2016-02-02 09:08:08 +08:00
|
|
|
STATUS parseGeneralRegion(const UINT8 subtype, const QByteArray & region, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index);
|
2015-03-13 14:48:53 +08:00
|
|
|
|
|
|
|
STATUS parsePadFileBody(const QModelIndex & index);
|
2015-09-19 16:08:26 +08:00
|
|
|
STATUS parseVolumeNonUefiData(const QByteArray & data, const UINT32 parentOffset, const QModelIndex & index);
|
2015-03-13 14:48:53 +08:00
|
|
|
|
2016-03-01 15:20:44 +08:00
|
|
|
STATUS parseSections(const QByteArray & sections, const QModelIndex & index, const bool preparse = false);
|
2016-02-09 19:00:14 +08:00
|
|
|
STATUS parseCommonSectionHeader(const QByteArray & section, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index, const bool preparse);
|
|
|
|
STATUS parseCompressedSectionHeader(const QByteArray & section, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index, const bool preparse);
|
|
|
|
STATUS parseGuidedSectionHeader(const QByteArray & section, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index, const bool preparse);
|
|
|
|
STATUS parseFreeformGuidedSectionHeader(const QByteArray & section, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index, const bool preparse);
|
|
|
|
STATUS parseVersionSectionHeader(const QByteArray & section, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index, const bool preparse);
|
|
|
|
STATUS parsePostcodeSectionHeader(const QByteArray & section, const UINT32 parentOffset, const QModelIndex & parent, QModelIndex & index, const bool preparse);
|
2015-03-13 14:48:53 +08:00
|
|
|
|
|
|
|
STATUS parseCompressedSectionBody(const QModelIndex & index);
|
|
|
|
STATUS parseGuidedSectionBody(const QModelIndex & index);
|
|
|
|
STATUS parseVersionSectionBody(const QModelIndex & index);
|
|
|
|
STATUS parseDepexSectionBody(const QModelIndex & index);
|
|
|
|
STATUS parseUiSectionBody(const QModelIndex & index);
|
|
|
|
STATUS parseRawSectionBody(const QModelIndex & index);
|
2015-06-20 02:26:45 +08:00
|
|
|
STATUS parsePeImageSectionBody(const QModelIndex & index);
|
|
|
|
STATUS parseTeImageSectionBody(const QModelIndex & index);
|
2015-03-13 14:48:53 +08:00
|
|
|
|
2015-04-02 16:04:37 +08:00
|
|
|
UINT8 getPaddingType(const QByteArray & padding);
|
2015-03-13 14:48:53 +08:00
|
|
|
STATUS parseAprioriRawSection(const QByteArray & body, QString & parsed);
|
2016-02-02 09:08:08 +08:00
|
|
|
STATUS findNextVolume(const QModelIndex & index, const QByteArray & bios, const UINT32 parentOffset, const UINT32 volumeOffset, UINT32 & nextVolumeOffset);
|
2015-03-13 14:48:53 +08:00
|
|
|
STATUS getVolumeSize(const QByteArray & bios, const UINT32 volumeOffset, UINT32 & volumeSize, UINT32 & bmVolumeSize);
|
|
|
|
UINT32 getFileSize(const QByteArray & volume, const UINT32 fileOffset, const UINT8 ffsVersion);
|
|
|
|
UINT32 getSectionSize(const QByteArray & file, const UINT32 sectionOffset, const UINT8 ffsVersion);
|
|
|
|
|
2016-02-02 09:08:08 +08:00
|
|
|
STATUS performFirstPass(const QByteArray & imageFile, QModelIndex & index);
|
2015-07-05 12:20:03 +08:00
|
|
|
STATUS performSecondPass(const QModelIndex & index);
|
2016-01-28 07:21:51 +08:00
|
|
|
STATUS addOffsetsRecursive(const QModelIndex & index);
|
2015-06-20 02:26:45 +08:00
|
|
|
STATUS addMemoryAddressesRecursive(const QModelIndex & index, const UINT32 diff);
|
|
|
|
|
2016-03-21 06:59:03 +08:00
|
|
|
// NVRAM parsing
|
|
|
|
STATUS parseNvarStorage(const QByteArray & data, const QModelIndex & index);
|
|
|
|
|
2015-03-13 14:48:53 +08:00
|
|
|
// Message helper
|
|
|
|
void msg(const QString & message, const QModelIndex &index = QModelIndex());
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|