1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
|
/*
Copyright (C) 2006 - 2015 Evan Teran
evan.teran@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANALYZER_H_20080630_
#define ANALYZER_H_20080630_
#include "BasicBlock.h"
#include "IAnalyzer.h"
#include "IPlugin.h"
#include "IRegion.h"
#include "Symbol.h"
#include "Types.h"
#include <QHash>
#include <QList>
#include <QMap>
#include <QSet>
#include <QVector>
class QMenu;
namespace AnalyzerPlugin {
class AnalyzerWidget;
class Analyzer final : public QObject, public IAnalyzer, public IPlugin {
Q_OBJECT
Q_PLUGIN_METADATA(IID "edb.IPlugin/1.0")
Q_INTERFACES(IPlugin)
Q_CLASSINFO("author", "Evan Teran")
Q_CLASSINFO("url", "http://www.codef00.com")
private:
struct RegionData;
public:
explicit Analyzer(QObject *parent = nullptr);
public:
QMenu *menu(QWidget *parent = nullptr) override;
QList<QAction *> cpuContextMenu() override;
private:
void privateInit() override;
QWidget *optionsPage() override;
public:
AddressCategory category(edb::address_t address) const override;
FunctionMap functions(const std::shared_ptr<IRegion> ®ion) const override;
FunctionMap functions() const override;
QSet<edb::address_t> specifiedFunctions() const override { return specifiedFunctions_; }
Result<edb::address_t, QString> findContainingFunction(edb::address_t address) const override;
void analyze(const std::shared_ptr<IRegion> ®ion) override;
void invalidateAnalysis() override;
void invalidateAnalysis(const std::shared_ptr<IRegion> ®ion) override;
bool forFuncsInRange(edb::address_t start, edb::address_t end, std::function<bool(const Function *)> functor) const override;
private:
bool findContainingFunction(edb::address_t address, Function *function) const;
void bonusEntryPoint(RegionData *data) const;
void bonusMain(RegionData *data) const;
void bonusMarkedFunctions(RegionData *data);
void bonusSymbols(RegionData *data);
void collectFunctions(RegionData *data);
void collectFuzzyFunctions(RegionData *data);
void doAnalysis(const std::shared_ptr<IRegion> ®ion);
void identHeader(Analyzer::RegionData *data);
void invalidateDynamicAnalysis(const std::shared_ptr<IRegion> ®ion);
Q_SIGNALS:
void updateProgress(int);
public Q_SLOTS:
void doIpAnalysis();
void doViewAnalysis();
void gotoFunctionStart();
void gotoFunctionEnd();
void markFunctionStart();
void showXrefs();
void showSpecified();
private:
struct RegionData {
QSet<edb::address_t> knownFunctions;
QSet<edb::address_t> fuzzyFunctions;
FunctionMap functions;
QHash<edb::address_t, BasicBlock> basicBlocks;
QByteArray md5;
bool fuzzy;
std::shared_ptr<IRegion> region;
// a copy of the whole region
QVector<uint8_t> memory;
};
QMenu *menu_ = nullptr;
AnalyzerWidget *analyzerWidget_ = nullptr;
QHash<edb::address_t, RegionData> analysisInfo_;
QSet<edb::address_t> specifiedFunctions_;
};
}
#endif
|