2017-03-29 10:18:37 +00:00
|
|
|
#ifndef QRCORE_H
|
|
|
|
#define QRCORE_H
|
|
|
|
|
|
|
|
#include <QMap>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QMessageBox>
|
2017-03-30 03:07:34 +00:00
|
|
|
|
|
|
|
//Workaround for compile errors on Windows
|
|
|
|
#ifdef _WIN32
|
|
|
|
#include <r2hacks.h>
|
|
|
|
#endif //_WIN32
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
#include "r_core.h"
|
|
|
|
|
2017-03-30 03:07:34 +00:00
|
|
|
//Workaround for compile errors on Windows.
|
|
|
|
#ifdef _WIN32
|
|
|
|
#undef min
|
|
|
|
#endif //_WIN32
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
#define HAVE_LATEST_LIBR2 false
|
|
|
|
|
|
|
|
#define QRListForeach(list, it, type, x) \
|
|
|
|
if (list) for (it = list->head; it && ((x=(type*)it->data)); it = it->n)
|
|
|
|
|
|
|
|
#define __alert(x) QMessageBox::question (this, "Alert", QString(x), QMessageBox::Ok)
|
|
|
|
#define __question(x) (QMessageBox::Yes==QMessageBox::question (this, "Alert", QString(x), QMessageBox::Yes| QMessageBox::No))
|
|
|
|
|
2017-04-09 17:12:36 +00:00
|
|
|
struct RCoreLocked
|
|
|
|
{
|
|
|
|
explicit RCoreLocked(RCore* core);
|
|
|
|
RCoreLocked(const RCoreLocked&) = delete;
|
|
|
|
RCoreLocked& operator=(const RCoreLocked&) = delete;
|
|
|
|
RCoreLocked(RCoreLocked&&);
|
|
|
|
~RCoreLocked();
|
|
|
|
operator RCore*() const;
|
|
|
|
RCore* operator->() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
RCore* core;
|
|
|
|
};
|
|
|
|
|
2017-04-09 17:09:35 +00:00
|
|
|
#define QNOTUSED(x) do { (void)(x); } while ( 0 );
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
class QRCore : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
QString projectPath;
|
|
|
|
explicit QRCore(QObject *parent = 0);
|
|
|
|
~QRCore();
|
|
|
|
QList<QString> getFunctionXrefs(ut64 addr);
|
|
|
|
QList<QString> getFunctionRefs(ut64 addr, char type);
|
|
|
|
int getCycloComplex(ut64 addr);
|
|
|
|
int getFcnSize(ut64 addr);
|
|
|
|
int fcnCyclomaticComplexity(ut64 addr);
|
|
|
|
int fcnBasicBlockCount(ut64 addr);
|
|
|
|
int fcnEndBbs(QString addr);
|
|
|
|
QString cmd(const QString &str);
|
|
|
|
void renameFunction(QString prev_name, QString new_name);
|
|
|
|
void setComment(QString addr, QString cmt);
|
|
|
|
void delComment(ut64 addr);
|
|
|
|
QList<QList<QString>> getComments();
|
|
|
|
QMap<QString, QList<QList<QString> > > getNestedComments();
|
|
|
|
void setOptions(QString key);
|
2017-03-30 21:49:51 +00:00
|
|
|
bool loadFile(QString path, uint64_t loadaddr, uint64_t mapaddr, bool rw, int va, int bits, int idx=0, bool loadbin=false);
|
2017-03-29 10:18:37 +00:00
|
|
|
bool tryFile(QString path, bool rw);
|
|
|
|
void analyze(int level);
|
|
|
|
void seek(QString addr);
|
|
|
|
void seek(ut64 addr);
|
|
|
|
ut64 math(const QString &expr);
|
|
|
|
QString itoa(ut64 num, int rdx=16);
|
|
|
|
QString config(const QString &k, const QString &v=NULL);
|
|
|
|
int config(const QString &k, int v);
|
2017-03-30 22:33:29 +00:00
|
|
|
QList<QString> getList(const QString & type, const QString & subtype="");
|
2017-03-29 10:18:37 +00:00
|
|
|
QString assemble(const QString &code);
|
|
|
|
QString disassemble(const QString &code);
|
|
|
|
void setDefaultCPU();
|
|
|
|
void setCPU(QString arch, QString cpu, int bits, bool temporary);
|
|
|
|
RAnalFunction* functionAt(ut64 addr);
|
|
|
|
QString cmdFunctionAt(QString addr);
|
|
|
|
/* sdb */
|
|
|
|
QList<QString> sdbList(QString path);
|
|
|
|
QList<QString> sdbListKeys(QString path);
|
|
|
|
QString sdbGet(QString path, QString key);
|
|
|
|
bool sdbSet(QString path, QString key, QString val);
|
|
|
|
int get_size();
|
|
|
|
ulong get_baddr();
|
|
|
|
QList<QList<QString>> get_exec_sections();
|
|
|
|
QString getOffsetInfo(QString addr);
|
|
|
|
QString getOffsetJump(QString addr);
|
|
|
|
QString getDecompiledCode(QString addr);
|
|
|
|
QString getFileInfo();
|
|
|
|
QStringList getStats();
|
|
|
|
QString getSimpleGraph(QString function);
|
|
|
|
QString binStart;
|
|
|
|
QString binEnd;
|
|
|
|
void getOpcodes();
|
|
|
|
QList<QString> opcodes;
|
|
|
|
QList<QString> regs;
|
2017-03-30 16:47:50 +00:00
|
|
|
void setSettings();
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2017-04-09 17:12:36 +00:00
|
|
|
RCoreLocked core() const;
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
/* fields */
|
2017-04-09 17:12:36 +00:00
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
Sdb *db;
|
|
|
|
signals:
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString default_arch;
|
|
|
|
QString default_cpu;
|
|
|
|
int default_bits;
|
2017-04-09 17:12:36 +00:00
|
|
|
|
|
|
|
RCore *core_;
|
2017-03-29 10:18:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // QRCORE_H
|