2019-07-15 12:08:44 +00:00
|
|
|
#ifndef DECOMPILER_H
|
|
|
|
#define DECOMPILER_H
|
|
|
|
|
|
|
|
#include "CutterCommon.h"
|
2019-08-28 17:01:12 +00:00
|
|
|
#include "R2Task.h"
|
2020-06-08 21:29:26 +00:00
|
|
|
#include <r_util/r_annotated_code.h>
|
2019-07-15 12:08:44 +00:00
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements a decompiler that can be registered using CutterCore::registerDecompiler()
|
|
|
|
*/
|
|
|
|
class Decompiler: public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private:
|
|
|
|
const QString id;
|
|
|
|
const QString name;
|
|
|
|
|
|
|
|
public:
|
|
|
|
Decompiler(const QString &id, const QString &name, QObject *parent = nullptr);
|
|
|
|
virtual ~Decompiler() = default;
|
|
|
|
|
2020-06-08 21:29:26 +00:00
|
|
|
static RAnnotatedCode *makeWarning(QString warningMessage);
|
|
|
|
|
2019-08-28 17:01:12 +00:00
|
|
|
QString getId() const { return id; }
|
|
|
|
QString getName() const { return name; }
|
|
|
|
virtual bool isRunning() { return false; }
|
|
|
|
virtual bool isCancelable() { return false; }
|
2019-07-15 12:08:44 +00:00
|
|
|
|
2019-08-28 17:01:12 +00:00
|
|
|
virtual void decompileAt(RVA addr) =0;
|
|
|
|
virtual void cancel() {}
|
|
|
|
|
|
|
|
signals:
|
2020-06-08 21:29:26 +00:00
|
|
|
void finished(RAnnotatedCode *codeDecompiled);
|
2019-07-15 12:08:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class R2DecDecompiler: public Decompiler
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2019-08-28 17:01:12 +00:00
|
|
|
private:
|
|
|
|
R2Task *task;
|
|
|
|
|
2019-07-15 12:08:44 +00:00
|
|
|
public:
|
|
|
|
explicit R2DecDecompiler(QObject *parent = nullptr);
|
2019-08-28 17:01:12 +00:00
|
|
|
void decompileAt(RVA addr) override;
|
|
|
|
|
|
|
|
bool isRunning() override { return task != nullptr; }
|
2019-07-15 12:08:44 +00:00
|
|
|
|
|
|
|
static bool isAvailable();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif //DECOMPILER_H
|