2017-09-27 20:23:18 +00:00
|
|
|
#ifndef CUTTER_H
|
2017-09-25 12:55:41 +00:00
|
|
|
#define CUTTER_H
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
#include "r_core.h"
|
|
|
|
|
2017-10-03 12:42:31 +00:00
|
|
|
// Workaround for compile errors on Windows
|
2017-03-30 03:07:34 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#undef min
|
2017-10-03 12:42:31 +00:00
|
|
|
#undef max
|
2017-03-30 03:07:34 +00:00
|
|
|
#endif //_WIN32
|
|
|
|
|
2017-10-15 19:19:48 +00:00
|
|
|
#include <QMap>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QJsonDocument>
|
2018-07-27 12:00:23 +00:00
|
|
|
#include <QErrorMessage>
|
2017-10-15 19:19:48 +00:00
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
#define HAVE_LATEST_LIBR2 false
|
|
|
|
|
2017-09-25 17:51:49 +00:00
|
|
|
#define CutterRListForeach(list, it, type, x) \
|
2017-03-29 10:18:37 +00:00
|
|
|
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-09-25 12:55:41 +00:00
|
|
|
#define APPNAME "Cutter"
|
2018-07-13 18:37:18 +00:00
|
|
|
#define CUTTER_VERSION "1.6"
|
2017-09-25 12:55:41 +00:00
|
|
|
|
2017-10-14 09:35:49 +00:00
|
|
|
#define Core() (CutterCore::getInstance())
|
|
|
|
|
2018-04-13 10:13:57 +00:00
|
|
|
/*!
|
|
|
|
* \brief Type to be used for all kinds of addresses/offsets in r2 address space.
|
|
|
|
*/
|
2017-10-03 18:38:34 +00:00
|
|
|
typedef ut64 RVA;
|
2018-04-13 10:13:57 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Maximum value of RVA. Do NOT use this for specifying invalid values, use RVA_INVALID instead.
|
|
|
|
*/
|
|
|
|
#define RVA_MAX UT64_MAX
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Value for specifying an invalid RVA.
|
|
|
|
*/
|
|
|
|
#define RVA_INVALID RVA_MAX
|
2017-10-03 18:38:34 +00:00
|
|
|
|
2018-05-26 16:21:23 +00:00
|
|
|
class AsyncTaskManager;
|
2018-06-26 07:40:08 +00:00
|
|
|
class CutterCore;
|
|
|
|
#include "plugins/CutterPlugin.h"
|
2018-05-26 16:21:23 +00:00
|
|
|
|
2017-04-09 18:42:45 +00:00
|
|
|
class RCoreLocked
|
2017-04-09 17:12:36 +00:00
|
|
|
{
|
2017-04-09 19:55:06 +00:00
|
|
|
RCore *core;
|
2017-04-09 18:42:45 +00:00
|
|
|
|
|
|
|
public:
|
2017-04-09 19:55:06 +00:00
|
|
|
explicit RCoreLocked(RCore *core);
|
|
|
|
RCoreLocked(const RCoreLocked &) = delete;
|
|
|
|
RCoreLocked &operator=(const RCoreLocked &) = delete;
|
|
|
|
RCoreLocked(RCoreLocked &&);
|
2017-04-09 17:12:36 +00:00
|
|
|
~RCoreLocked();
|
2017-04-09 19:55:06 +00:00
|
|
|
operator RCore *() const;
|
|
|
|
RCore *operator->() const;
|
2017-10-03 18:38:34 +00:00
|
|
|
RVA seek(RVA offset);
|
|
|
|
RVA getSeek();
|
2017-04-09 17:12:36 +00:00
|
|
|
};
|
|
|
|
|
2017-04-28 13:09:40 +00:00
|
|
|
inline QString RAddressString(RVA addr)
|
|
|
|
{
|
|
|
|
return QString::asprintf("%#010llx", addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline QString RSizeString(RVA size)
|
|
|
|
{
|
|
|
|
return QString::asprintf("%lld", size);
|
|
|
|
}
|
|
|
|
|
2018-05-01 18:53:14 +00:00
|
|
|
inline QString RHexString(RVA size)
|
|
|
|
{
|
|
|
|
return QString::asprintf("%#llx", size);
|
|
|
|
}
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
struct FunctionDescription {
|
2017-04-28 13:09:40 +00:00
|
|
|
RVA offset;
|
|
|
|
RVA size;
|
2018-04-10 18:34:11 +00:00
|
|
|
RVA nargs;
|
|
|
|
RVA nbbs;
|
|
|
|
RVA nlocals;
|
|
|
|
RVA cc;
|
|
|
|
QString calltype;
|
2017-04-28 13:09:40 +00:00
|
|
|
QString name;
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
bool contains(RVA addr) const
|
|
|
|
{
|
|
|
|
return addr >= offset && addr < offset + size;
|
|
|
|
}
|
2017-04-28 13:09:40 +00:00
|
|
|
};
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
struct ImportDescription {
|
2017-04-28 13:09:40 +00:00
|
|
|
RVA plt;
|
|
|
|
int ordinal;
|
|
|
|
QString bind;
|
|
|
|
QString type;
|
|
|
|
QString name;
|
|
|
|
};
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
struct ExportDescription {
|
2017-05-19 07:45:26 +00:00
|
|
|
RVA vaddr;
|
|
|
|
RVA paddr;
|
|
|
|
RVA size;
|
|
|
|
QString type;
|
|
|
|
QString name;
|
|
|
|
QString flag_name;
|
|
|
|
};
|
|
|
|
|
2018-05-21 17:34:41 +00:00
|
|
|
struct HeaderDescription
|
|
|
|
{
|
|
|
|
RVA vaddr;
|
|
|
|
RVA paddr;
|
|
|
|
QString value;
|
|
|
|
QString name;
|
|
|
|
};
|
|
|
|
|
2018-05-24 15:37:37 +00:00
|
|
|
struct ZignatureDescription
|
|
|
|
{
|
|
|
|
QString name;
|
|
|
|
QString bytes;
|
|
|
|
RVA cc;
|
|
|
|
RVA nbbs;
|
|
|
|
RVA edges;
|
|
|
|
RVA ebbs;
|
|
|
|
RVA offset;
|
|
|
|
QStringList refs;
|
|
|
|
};
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
struct TypeDescription {
|
2018-03-06 17:21:48 +00:00
|
|
|
QString type;
|
|
|
|
int size;
|
|
|
|
QString format;
|
|
|
|
};
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
struct SearchDescription {
|
2018-03-08 12:24:15 +00:00
|
|
|
RVA offset;
|
|
|
|
int size;
|
|
|
|
QString code;
|
|
|
|
QString data;
|
|
|
|
};
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
struct SymbolDescription {
|
2017-04-28 13:09:40 +00:00
|
|
|
RVA vaddr;
|
|
|
|
QString bind;
|
|
|
|
QString type;
|
|
|
|
QString name;
|
|
|
|
};
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
struct CommentDescription {
|
2017-04-28 13:09:40 +00:00
|
|
|
RVA offset;
|
|
|
|
QString name;
|
|
|
|
};
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
struct RelocDescription {
|
2017-04-28 13:09:40 +00:00
|
|
|
RVA vaddr;
|
|
|
|
RVA paddr;
|
|
|
|
QString type;
|
|
|
|
QString name;
|
|
|
|
};
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
struct StringDescription {
|
2017-04-28 13:09:40 +00:00
|
|
|
RVA vaddr;
|
|
|
|
QString string;
|
2018-02-10 17:16:16 +00:00
|
|
|
QString type;
|
2018-02-09 14:22:45 +00:00
|
|
|
ut32 length;
|
|
|
|
ut32 size;
|
2017-04-28 13:09:40 +00:00
|
|
|
};
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
struct FlagspaceDescription {
|
2017-05-03 09:09:57 +00:00
|
|
|
QString name;
|
|
|
|
};
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
struct FlagDescription {
|
2017-05-03 09:09:57 +00:00
|
|
|
RVA offset;
|
|
|
|
RVA size;
|
|
|
|
QString name;
|
|
|
|
};
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
struct SectionDescription {
|
2017-05-03 09:09:57 +00:00
|
|
|
RVA vaddr;
|
|
|
|
RVA paddr;
|
|
|
|
RVA size;
|
|
|
|
RVA vsize;
|
|
|
|
QString name;
|
|
|
|
QString flags;
|
2018-05-05 10:11:44 +00:00
|
|
|
QString entropy;
|
2017-05-03 09:09:57 +00:00
|
|
|
};
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
struct EntrypointDescription {
|
2017-07-13 18:49:12 +00:00
|
|
|
RVA vaddr;
|
|
|
|
RVA paddr;
|
|
|
|
RVA baddr;
|
|
|
|
RVA laddr;
|
|
|
|
RVA haddr;
|
|
|
|
QString type;
|
|
|
|
};
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
struct XrefDescription {
|
2017-06-07 10:56:55 +00:00
|
|
|
RVA from;
|
2017-11-27 16:05:10 +00:00
|
|
|
QString from_str;
|
2017-06-07 10:56:55 +00:00
|
|
|
RVA to;
|
2017-11-27 16:05:10 +00:00
|
|
|
QString to_str;
|
2017-06-07 10:56:55 +00:00
|
|
|
QString type;
|
|
|
|
};
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
struct RBinPluginDescription {
|
2017-09-29 11:32:53 +00:00
|
|
|
QString name;
|
|
|
|
QString description;
|
|
|
|
QString license;
|
|
|
|
QString type;
|
|
|
|
};
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
struct RIOPluginDescription {
|
2018-03-09 15:05:40 +00:00
|
|
|
QString name;
|
|
|
|
QString description;
|
|
|
|
QString license;
|
|
|
|
QString permissions;
|
|
|
|
};
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
struct RCorePluginDescription {
|
2018-03-09 15:05:40 +00:00
|
|
|
QString name;
|
|
|
|
QString description;
|
|
|
|
};
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
struct RAsmPluginDescription {
|
2018-03-11 08:39:31 +00:00
|
|
|
QString name;
|
|
|
|
QString architecture;
|
|
|
|
QString author;
|
|
|
|
QString version;
|
|
|
|
QString cpus;
|
|
|
|
QString description;
|
|
|
|
QString license;
|
|
|
|
};
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
struct DisassemblyLine {
|
2017-12-13 14:30:00 +00:00
|
|
|
RVA offset;
|
|
|
|
QString text;
|
|
|
|
};
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
struct ClassMethodDescription {
|
2017-12-23 16:42:42 +00:00
|
|
|
QString name;
|
|
|
|
RVA addr;
|
|
|
|
};
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
struct ClassFieldDescription {
|
2017-12-23 16:42:42 +00:00
|
|
|
QString name;
|
|
|
|
RVA addr;
|
|
|
|
};
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
struct ClassDescription {
|
2017-12-23 16:42:42 +00:00
|
|
|
QString name;
|
|
|
|
RVA addr;
|
|
|
|
ut64 index;
|
|
|
|
QList<ClassMethodDescription> methods;
|
|
|
|
QList<ClassFieldDescription> fields;
|
|
|
|
};
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
struct ResourcesDescription {
|
2018-02-09 13:19:36 +00:00
|
|
|
int name;
|
2018-02-04 14:32:18 +00:00
|
|
|
RVA vaddr;
|
|
|
|
ut64 index;
|
|
|
|
QString type;
|
|
|
|
ut64 size;
|
|
|
|
QString lang;
|
|
|
|
};
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
struct VTableDescription {
|
2018-02-26 22:26:18 +00:00
|
|
|
RVA addr;
|
|
|
|
QList<ClassMethodDescription> methods;
|
|
|
|
};
|
|
|
|
|
2018-06-29 10:34:01 +00:00
|
|
|
struct BlockDescription {
|
|
|
|
RVA addr;
|
|
|
|
RVA size;
|
|
|
|
int flags;
|
|
|
|
int functions;
|
2018-07-01 12:29:01 +00:00
|
|
|
int inFunctions;
|
2018-06-29 10:34:01 +00:00
|
|
|
int comments;
|
|
|
|
int symbols;
|
|
|
|
int strings;
|
|
|
|
ut8 rwx;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct BlockStatistics {
|
|
|
|
RVA from;
|
|
|
|
RVA to;
|
|
|
|
RVA blocksize;
|
|
|
|
QList<BlockDescription> blocks;
|
|
|
|
};
|
|
|
|
|
2018-06-12 08:43:14 +00:00
|
|
|
struct MemoryMapDescription {
|
|
|
|
RVA addrStart;
|
|
|
|
RVA addrEnd;
|
|
|
|
QString name;
|
|
|
|
QString fileName;
|
|
|
|
QString type;
|
|
|
|
QString permission;
|
|
|
|
};
|
|
|
|
|
2018-06-22 08:45:00 +00:00
|
|
|
struct BreakpointDescription {
|
|
|
|
RVA addr;
|
|
|
|
int size;
|
|
|
|
QString permission;
|
|
|
|
bool hw;
|
|
|
|
bool trace;
|
|
|
|
bool enabled;
|
|
|
|
};
|
|
|
|
|
2018-07-01 21:29:38 +00:00
|
|
|
struct ProcessDescription {
|
|
|
|
int pid;
|
|
|
|
int uid;
|
|
|
|
QString status;
|
|
|
|
QString path;
|
|
|
|
};
|
|
|
|
|
2018-07-19 14:35:46 +00:00
|
|
|
struct RegisterRefDescription {
|
|
|
|
QString reg;
|
|
|
|
QString value;
|
|
|
|
QString ref;
|
|
|
|
};
|
|
|
|
|
2017-04-28 13:09:40 +00:00
|
|
|
Q_DECLARE_METATYPE(FunctionDescription)
|
|
|
|
Q_DECLARE_METATYPE(ImportDescription)
|
2017-05-19 07:45:26 +00:00
|
|
|
Q_DECLARE_METATYPE(ExportDescription)
|
2017-04-28 13:09:40 +00:00
|
|
|
Q_DECLARE_METATYPE(SymbolDescription)
|
|
|
|
Q_DECLARE_METATYPE(CommentDescription)
|
|
|
|
Q_DECLARE_METATYPE(RelocDescription)
|
|
|
|
Q_DECLARE_METATYPE(StringDescription)
|
2017-05-03 09:09:57 +00:00
|
|
|
Q_DECLARE_METATYPE(FlagspaceDescription)
|
|
|
|
Q_DECLARE_METATYPE(FlagDescription)
|
2017-06-07 19:35:38 +00:00
|
|
|
Q_DECLARE_METATYPE(XrefDescription)
|
2017-07-13 18:49:12 +00:00
|
|
|
Q_DECLARE_METATYPE(EntrypointDescription)
|
2017-09-29 11:32:53 +00:00
|
|
|
Q_DECLARE_METATYPE(RBinPluginDescription)
|
2018-03-09 15:05:40 +00:00
|
|
|
Q_DECLARE_METATYPE(RIOPluginDescription)
|
|
|
|
Q_DECLARE_METATYPE(RCorePluginDescription)
|
2018-03-11 08:39:31 +00:00
|
|
|
Q_DECLARE_METATYPE(RAsmPluginDescription)
|
2017-12-23 16:42:42 +00:00
|
|
|
Q_DECLARE_METATYPE(ClassMethodDescription)
|
|
|
|
Q_DECLARE_METATYPE(ClassFieldDescription)
|
|
|
|
Q_DECLARE_METATYPE(ClassDescription)
|
|
|
|
Q_DECLARE_METATYPE(const ClassDescription *)
|
|
|
|
Q_DECLARE_METATYPE(const ClassMethodDescription *)
|
|
|
|
Q_DECLARE_METATYPE(const ClassFieldDescription *)
|
2018-02-09 13:19:36 +00:00
|
|
|
Q_DECLARE_METATYPE(ResourcesDescription)
|
2018-02-26 22:26:18 +00:00
|
|
|
Q_DECLARE_METATYPE(VTableDescription)
|
2018-03-06 17:21:48 +00:00
|
|
|
Q_DECLARE_METATYPE(TypeDescription)
|
2018-05-21 17:34:41 +00:00
|
|
|
Q_DECLARE_METATYPE(HeaderDescription)
|
2018-05-24 15:37:37 +00:00
|
|
|
Q_DECLARE_METATYPE(ZignatureDescription)
|
2018-03-08 12:24:15 +00:00
|
|
|
Q_DECLARE_METATYPE(SearchDescription)
|
2018-05-03 07:52:30 +00:00
|
|
|
Q_DECLARE_METATYPE(SectionDescription)
|
2018-06-12 08:43:14 +00:00
|
|
|
Q_DECLARE_METATYPE(MemoryMapDescription)
|
2018-06-22 08:45:00 +00:00
|
|
|
Q_DECLARE_METATYPE(BreakpointDescription)
|
2018-07-01 21:29:38 +00:00
|
|
|
Q_DECLARE_METATYPE(ProcessDescription)
|
2018-07-19 14:35:46 +00:00
|
|
|
Q_DECLARE_METATYPE(RegisterRefDescription)
|
2017-04-28 13:09:40 +00:00
|
|
|
|
2017-09-25 12:55:41 +00:00
|
|
|
class CutterCore: public QObject
|
2017-03-29 10:18:37 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2017-10-09 18:08:35 +00:00
|
|
|
friend class ccClass;
|
2017-04-28 13:09:40 +00:00
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
public:
|
2018-05-04 07:58:32 +00:00
|
|
|
explicit CutterCore(QObject *parent = nullptr);
|
2017-09-25 12:55:41 +00:00
|
|
|
~CutterCore();
|
2017-11-03 17:22:54 +00:00
|
|
|
static CutterCore *getInstance();
|
2017-04-28 13:09:40 +00:00
|
|
|
|
2018-05-26 18:09:20 +00:00
|
|
|
AsyncTaskManager *getAsyncTaskManager() { return asyncTaskManager; }
|
|
|
|
|
|
|
|
RVA getOffset() const { return core_->offset; }
|
2017-12-20 23:22:59 +00:00
|
|
|
|
2018-06-20 09:24:28 +00:00
|
|
|
/* Core functions (commands) */
|
2017-10-09 18:08:35 +00:00
|
|
|
static QString sanitizeStringForCommand(QString s);
|
2017-03-29 10:18:37 +00:00
|
|
|
QString cmd(const QString &str);
|
2017-12-20 22:50:26 +00:00
|
|
|
QString cmdRaw(const QString &str);
|
2017-04-18 08:33:35 +00:00
|
|
|
QJsonDocument cmdj(const QString &str);
|
2018-03-21 20:32:32 +00:00
|
|
|
QStringList cmdList(const QString &str)
|
|
|
|
{
|
|
|
|
auto l = cmd(str).split("\n");
|
|
|
|
l.removeAll("");
|
|
|
|
return l;
|
|
|
|
}
|
2018-05-29 16:19:59 +00:00
|
|
|
QString cmdTask(const QString &str);
|
|
|
|
QJsonDocument cmdjTask(const QString &str);
|
2018-07-27 12:00:23 +00:00
|
|
|
void cmdEsil(QString command);
|
2018-06-20 09:24:28 +00:00
|
|
|
QString getVersionInformation();
|
2017-12-13 14:30:00 +00:00
|
|
|
|
2018-05-29 16:19:59 +00:00
|
|
|
QJsonDocument parseJson(const char *res, const QString &cmd = QString());
|
|
|
|
|
2018-06-20 09:24:28 +00:00
|
|
|
/* Functions methods */
|
2017-12-20 22:50:26 +00:00
|
|
|
void renameFunction(const QString &oldName, const QString &newName);
|
2017-12-11 13:07:12 +00:00
|
|
|
void delFunction(RVA addr);
|
2017-11-27 08:22:52 +00:00
|
|
|
void renameFlag(QString old_name, QString new_name);
|
2018-06-20 09:24:28 +00:00
|
|
|
RAnalFunction *functionAt(ut64 addr);
|
|
|
|
QString cmdFunctionAt(QString addr);
|
|
|
|
QString cmdFunctionAt(RVA addr);
|
|
|
|
QString createFunctionAt(RVA addr, QString name);
|
|
|
|
void markString(RVA addr);
|
|
|
|
|
|
|
|
/* Flags */
|
2017-12-11 13:07:12 +00:00
|
|
|
void delFlag(RVA addr);
|
2018-03-11 16:40:52 +00:00
|
|
|
void delFlag(const QString &name);
|
2018-06-20 09:24:28 +00:00
|
|
|
void addFlag(RVA offset, QString name, RVA size);
|
|
|
|
void triggerFlagsChanged();
|
2017-12-01 10:46:13 +00:00
|
|
|
|
2018-06-20 09:24:28 +00:00
|
|
|
/* Edition functions */
|
2018-02-12 20:12:13 +00:00
|
|
|
void editInstruction(RVA addr, const QString &inst);
|
2018-03-05 14:20:55 +00:00
|
|
|
void nopInstruction(RVA addr);
|
2018-03-10 07:27:09 +00:00
|
|
|
void jmpReverse(RVA addr);
|
2018-02-12 20:12:13 +00:00
|
|
|
void editBytes(RVA addr, const QString &inst);
|
2018-07-24 23:15:38 +00:00
|
|
|
void editBytesEndian(RVA addr, const QString &bytes);
|
2018-02-12 20:12:13 +00:00
|
|
|
|
2018-08-04 18:05:56 +00:00
|
|
|
/* Code/Data */
|
|
|
|
void setToCode(RVA addr);
|
|
|
|
void setToData(RVA addr, int size, int repeat = 1);
|
|
|
|
int sizeofDataMeta(RVA addr);
|
|
|
|
|
2018-06-20 09:24:28 +00:00
|
|
|
/* Comments */
|
2017-12-01 10:46:13 +00:00
|
|
|
void setComment(RVA addr, const QString &cmt);
|
2017-12-11 13:07:12 +00:00
|
|
|
void delComment(RVA addr);
|
2017-11-28 13:13:22 +00:00
|
|
|
void setImmediateBase(const QString &r2BaseName, RVA offset = RVA_INVALID);
|
2018-02-12 09:48:06 +00:00
|
|
|
void setCurrentBits(int bits, RVA offset = RVA_INVALID);
|
2017-12-03 11:47:26 +00:00
|
|
|
|
2018-06-20 09:24:28 +00:00
|
|
|
/* File related methods */
|
2018-05-05 13:20:14 +00:00
|
|
|
bool loadFile(QString path, ut64 baddr = 0LL, ut64 mapaddr = 0LL, int perms = R_IO_READ,
|
|
|
|
int va = 0, bool loadbin = false, const QString &forceBinPlugin = nullptr);
|
2017-03-29 10:18:37 +00:00
|
|
|
bool tryFile(QString path, bool rw);
|
2018-06-20 09:24:28 +00:00
|
|
|
void openFile(QString path, RVA mapaddr);
|
|
|
|
void loadScript(const QString &scriptname);
|
|
|
|
QJsonArray getOpenedFiles();
|
|
|
|
|
|
|
|
/* Analysis functions */
|
2017-07-24 11:05:28 +00:00
|
|
|
void analyze(int level, QList<QString> advanced);
|
2017-10-16 19:00:47 +00:00
|
|
|
|
2018-06-20 09:24:28 +00:00
|
|
|
/* Seek functions */
|
2018-04-13 08:55:54 +00:00
|
|
|
void seek(QString thing);
|
2017-04-28 13:09:40 +00:00
|
|
|
void seek(ut64 offset);
|
2017-10-16 19:00:47 +00:00
|
|
|
void seekPrev();
|
|
|
|
void seekNext();
|
|
|
|
RVA getOffset();
|
2017-11-02 06:48:32 +00:00
|
|
|
RVA prevOpAddr(RVA startAddr, int count);
|
|
|
|
RVA nextOpAddr(RVA startAddr, int count);
|
|
|
|
|
2018-06-20 09:24:28 +00:00
|
|
|
/* Disassembly/Graph/Hexdump/Pseudocode view priority */
|
2017-12-06 23:19:14 +00:00
|
|
|
enum class MemoryWidgetType { Disassembly, Graph, Hexdump, Pseudocode };
|
2018-03-21 20:32:32 +00:00
|
|
|
MemoryWidgetType getMemoryWidgetPriority() const
|
|
|
|
{
|
|
|
|
return memoryWidgetPriority;
|
|
|
|
}
|
|
|
|
void setMemoryWidgetPriority(MemoryWidgetType type)
|
|
|
|
{
|
|
|
|
memoryWidgetPriority = type;
|
|
|
|
}
|
|
|
|
void triggerRaisePrioritizedMemoryWidget()
|
|
|
|
{
|
|
|
|
emit raisePrioritizedMemoryWidget(memoryWidgetPriority);
|
|
|
|
}
|
2017-10-22 10:21:44 +00:00
|
|
|
|
2018-06-20 09:24:28 +00:00
|
|
|
/* Math functions */
|
2017-03-29 10:18:37 +00:00
|
|
|
ut64 math(const QString &expr);
|
2017-04-09 19:55:06 +00:00
|
|
|
QString itoa(ut64 num, int rdx = 16);
|
2017-10-01 14:36:40 +00:00
|
|
|
|
2018-06-20 09:24:28 +00:00
|
|
|
/* Config functions */
|
2017-10-01 14:36:40 +00:00
|
|
|
void setConfig(const QString &k, const QString &v);
|
|
|
|
void setConfig(const QString &k, int v);
|
|
|
|
void setConfig(const QString &k, bool v);
|
2018-03-22 08:42:54 +00:00
|
|
|
void setConfig(const QString &k, const char *v) { setConfig(k, QString(v)); }
|
|
|
|
void setConfig(const QString &k, const QVariant &v);
|
2017-09-02 08:17:48 +00:00
|
|
|
int getConfigi(const QString &k);
|
2017-10-01 14:36:40 +00:00
|
|
|
bool getConfigb(const QString &k);
|
2017-09-02 08:17:48 +00:00
|
|
|
QString getConfig(const QString &k);
|
2018-06-20 09:24:28 +00:00
|
|
|
QList<QString> getColorThemes();
|
2017-10-01 14:36:40 +00:00
|
|
|
|
2018-06-20 09:24:28 +00:00
|
|
|
/* Assembly related methods */
|
2017-03-29 10:18:37 +00:00
|
|
|
QString assemble(const QString &code);
|
2017-04-12 20:44:05 +00:00
|
|
|
QString disassemble(const QString &hex);
|
2017-06-07 15:48:36 +00:00
|
|
|
QString disassembleSingleInstruction(RVA addr);
|
2018-06-20 09:24:28 +00:00
|
|
|
QList<DisassemblyLine> disassembleLines(RVA offset, int lines);
|
2018-05-05 13:20:14 +00:00
|
|
|
void setCPU(QString arch, QString cpu, int bits);
|
2018-01-20 10:35:31 +00:00
|
|
|
void setEndianness(bool big);
|
2018-03-07 12:02:39 +00:00
|
|
|
void setBBSize(int size);
|
2018-03-21 20:32:32 +00:00
|
|
|
|
2017-10-09 18:08:35 +00:00
|
|
|
/* SDB */
|
2017-03-29 10:18:37 +00:00
|
|
|
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);
|
2018-06-12 08:43:14 +00:00
|
|
|
|
|
|
|
// Debug
|
2018-04-18 09:13:08 +00:00
|
|
|
QJsonDocument getRegistersInfo();
|
2018-06-06 11:05:20 +00:00
|
|
|
QJsonDocument getRegisterValues();
|
|
|
|
QString getRegisterName(QString registerRole);
|
2018-06-22 15:57:15 +00:00
|
|
|
RVA getProgramCounterValue();
|
2018-06-06 11:05:20 +00:00
|
|
|
void setRegister(QString regName, QString regValue);
|
2018-07-23 23:13:23 +00:00
|
|
|
QJsonDocument getStack(int size = 0x100);
|
2018-06-06 11:05:20 +00:00
|
|
|
QJsonDocument getBacktrace();
|
2018-06-12 08:43:14 +00:00
|
|
|
void startDebug();
|
2018-07-01 21:29:38 +00:00
|
|
|
void startEmulation();
|
|
|
|
void attachDebug(int pid);
|
2018-06-12 15:42:38 +00:00
|
|
|
void stopDebug();
|
2018-06-12 08:43:14 +00:00
|
|
|
void continueDebug();
|
2018-06-13 23:02:16 +00:00
|
|
|
void continueUntilCall();
|
|
|
|
void continueUntilSyscall();
|
2018-06-12 08:43:14 +00:00
|
|
|
void continueUntilDebug(QString offset);
|
|
|
|
void stepDebug();
|
|
|
|
void stepOverDebug();
|
2018-07-17 07:26:20 +00:00
|
|
|
void toggleBreakpoint(RVA addr);
|
|
|
|
void toggleBreakpoint(QString addr);
|
2018-06-22 08:45:00 +00:00
|
|
|
void delBreakpoint(RVA addr);
|
|
|
|
void delAllBreakpoints();
|
|
|
|
void enableBreakpoint(RVA addr);
|
|
|
|
void disableBreakpoint(RVA addr);
|
2018-08-12 16:20:16 +00:00
|
|
|
bool isBreakpoint(QList<RVA> breakpoints, RVA addr);
|
|
|
|
QList<RVA> getBreakpointsAddresses();
|
2018-06-14 11:49:22 +00:00
|
|
|
QString getActiveDebugPlugin();
|
|
|
|
QStringList getDebugPlugins();
|
|
|
|
void setDebugPlugin(QString plugin);
|
2018-06-22 15:57:15 +00:00
|
|
|
bool currentlyDebugging = false;
|
2018-07-01 21:29:38 +00:00
|
|
|
bool currentlyEmulating = false;
|
2018-06-12 08:43:14 +00:00
|
|
|
|
2017-11-28 11:56:38 +00:00
|
|
|
RVA getOffsetJump(RVA addr);
|
2017-12-06 23:19:14 +00:00
|
|
|
QString getDecompiledCode(RVA addr);
|
2017-03-29 10:18:37 +00:00
|
|
|
QString getDecompiledCode(QString addr);
|
2018-02-10 22:31:15 +00:00
|
|
|
QJsonDocument getFileInfo();
|
2018-05-05 12:58:26 +00:00
|
|
|
QJsonDocument getSignatureInfo();
|
2018-05-01 18:53:14 +00:00
|
|
|
QJsonDocument getFileVersionInfo();
|
2017-03-29 10:18:37 +00:00
|
|
|
QStringList getStats();
|
|
|
|
QString getSimpleGraph(QString function);
|
2017-12-20 23:22:59 +00:00
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
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-09-27 20:23:18 +00:00
|
|
|
void loadPDB(const QString &file);
|
2017-04-28 13:09:40 +00:00
|
|
|
|
|
|
|
QList<RVA> getSeekHistory();
|
2017-05-03 09:09:57 +00:00
|
|
|
|
2018-06-20 09:24:28 +00:00
|
|
|
/* Plugins */
|
2017-05-03 09:09:57 +00:00
|
|
|
QStringList getAsmPluginNames();
|
|
|
|
QStringList getAnalPluginNames();
|
|
|
|
|
2018-06-20 09:24:28 +00:00
|
|
|
/* Projects */
|
2017-05-13 18:09:36 +00:00
|
|
|
QStringList getProjectNames();
|
2017-10-21 19:20:10 +00:00
|
|
|
void openProject(const QString &name);
|
|
|
|
void saveProject(const QString &name);
|
2018-04-23 07:54:24 +00:00
|
|
|
void deleteProject(const QString &name);
|
2017-10-21 19:20:10 +00:00
|
|
|
static bool isProjectNameValid(const QString &name);
|
|
|
|
|
2018-06-20 09:24:28 +00:00
|
|
|
/* Widgets */
|
2017-09-29 11:32:53 +00:00
|
|
|
QList<RBinPluginDescription> getRBinPluginDescriptions(const QString &type = nullptr);
|
2018-03-09 15:05:40 +00:00
|
|
|
QList<RIOPluginDescription> getRIOPluginDescriptions();
|
|
|
|
QList<RCorePluginDescription> getRCorePluginDescriptions();
|
2018-03-11 08:39:31 +00:00
|
|
|
QList<RAsmPluginDescription> getRAsmPluginDescriptions();
|
2017-04-28 13:09:40 +00:00
|
|
|
QList<FunctionDescription> getAllFunctions();
|
|
|
|
QList<ImportDescription> getAllImports();
|
2017-05-19 07:45:26 +00:00
|
|
|
QList<ExportDescription> getAllExports();
|
2017-04-28 13:09:40 +00:00
|
|
|
QList<SymbolDescription> getAllSymbols();
|
2018-05-21 17:34:41 +00:00
|
|
|
QList<HeaderDescription> getAllHeaders();
|
2018-05-24 15:37:37 +00:00
|
|
|
QList<ZignatureDescription> getAllZignatures();
|
2017-04-28 13:38:01 +00:00
|
|
|
QList<CommentDescription> getAllComments(const QString &filterType);
|
2017-04-28 13:09:40 +00:00
|
|
|
QList<RelocDescription> getAllRelocs();
|
|
|
|
QList<StringDescription> getAllStrings();
|
2017-05-03 09:09:57 +00:00
|
|
|
QList<FlagspaceDescription> getAllFlagspaces();
|
|
|
|
QList<FlagDescription> getAllFlags(QString flagspace = NULL);
|
|
|
|
QList<SectionDescription> getAllSections();
|
2017-07-13 18:49:12 +00:00
|
|
|
QList<EntrypointDescription> getAllEntrypoint();
|
2018-03-11 11:13:08 +00:00
|
|
|
QList<ClassDescription> getAllClassesFromBin();
|
|
|
|
QList<ClassDescription> getAllClassesFromFlags();
|
2018-02-04 14:32:18 +00:00
|
|
|
QList<ResourcesDescription> getAllResources();
|
2018-02-26 22:26:18 +00:00
|
|
|
QList<VTableDescription> getAllVTables();
|
2018-03-06 17:21:48 +00:00
|
|
|
QList<TypeDescription> getAllTypes();
|
2018-06-12 08:43:14 +00:00
|
|
|
QList<MemoryMapDescription> getMemoryMap();
|
2018-03-08 12:24:15 +00:00
|
|
|
QList<SearchDescription> getAllSearch(QString search_for, QString space);
|
2018-06-29 10:34:01 +00:00
|
|
|
BlockStatistics getBlockStatistics(unsigned int blocksCount);
|
2018-06-22 08:45:00 +00:00
|
|
|
QList<BreakpointDescription> getBreakpoints();
|
2018-07-01 21:29:38 +00:00
|
|
|
QList<ProcessDescription> getAllProcesses();
|
2018-07-19 14:35:46 +00:00
|
|
|
QList<RegisterRefDescription> getRegisterRefs();
|
2018-07-25 22:17:58 +00:00
|
|
|
QJsonObject getRegisterJson();
|
2017-04-28 13:09:40 +00:00
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
QList<XrefDescription> getXRefs(RVA addr, bool to, bool whole_function,
|
|
|
|
const QString &filterType = QString::null);
|
2017-06-07 10:56:55 +00:00
|
|
|
|
2018-05-29 16:19:59 +00:00
|
|
|
QList<StringDescription> parseStringsJson(const QJsonDocument &doc);
|
2018-06-25 19:28:34 +00:00
|
|
|
QList<FunctionDescription> parseFunctionsJson(const QJsonDocument &doc);
|
2018-05-29 16:19:59 +00:00
|
|
|
|
2018-06-20 09:24:28 +00:00
|
|
|
/* Signals related */
|
2017-11-30 21:30:51 +00:00
|
|
|
void triggerVarsChanged();
|
|
|
|
void triggerFunctionRenamed(const QString &prevName, const QString &newName);
|
2017-11-19 12:56:10 +00:00
|
|
|
void triggerRefreshAll();
|
2017-10-01 14:36:40 +00:00
|
|
|
void triggerAsmOptionsChanged();
|
2017-12-19 16:13:44 +00:00
|
|
|
void triggerGraphOptionsChanged();
|
2017-10-01 14:36:40 +00:00
|
|
|
|
2018-06-26 07:40:08 +00:00
|
|
|
void setCutterPlugins(QList<CutterPlugin*> plugins);
|
|
|
|
QList<CutterPlugin*> getCutterPlugins();
|
|
|
|
|
2017-04-09 17:12:36 +00:00
|
|
|
RCoreLocked core() const;
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
signals:
|
2017-11-19 12:56:10 +00:00
|
|
|
void refreshAll();
|
|
|
|
|
2017-12-20 22:50:26 +00:00
|
|
|
void functionRenamed(const QString &prev_name, const QString &new_name);
|
2017-11-30 21:30:51 +00:00
|
|
|
void varsChanged();
|
2017-12-11 13:07:12 +00:00
|
|
|
void functionsChanged();
|
2017-07-11 11:05:42 +00:00
|
|
|
void flagsChanged();
|
|
|
|
void commentsChanged();
|
2018-06-12 08:43:14 +00:00
|
|
|
void registersChanged();
|
2017-11-28 13:13:22 +00:00
|
|
|
void instructionChanged(RVA offset);
|
2018-06-22 08:45:00 +00:00
|
|
|
void breakpointsChanged();
|
2018-07-01 21:29:38 +00:00
|
|
|
void refreshCodeViews();
|
2018-07-24 23:15:38 +00:00
|
|
|
void stackChanged();
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2017-10-21 19:20:10 +00:00
|
|
|
void notesChanged(const QString ¬es);
|
|
|
|
void projectSaved(const QString &name);
|
|
|
|
|
2017-10-01 14:36:40 +00:00
|
|
|
/*!
|
|
|
|
* emitted when config regarding disassembly display changes
|
|
|
|
*/
|
|
|
|
void asmOptionsChanged();
|
|
|
|
|
2017-12-19 16:13:44 +00:00
|
|
|
/*!
|
|
|
|
* emitted when config regarding graph display changes
|
|
|
|
*/
|
|
|
|
void graphOptionsChanged();
|
|
|
|
|
2017-10-09 18:08:35 +00:00
|
|
|
/*!
|
|
|
|
* \brief seekChanged is emitted each time radare2 seek value is modified
|
|
|
|
* \param offset
|
|
|
|
*/
|
|
|
|
void seekChanged(RVA offset);
|
|
|
|
|
2017-11-04 11:46:29 +00:00
|
|
|
void raisePrioritizedMemoryWidget(CutterCore::MemoryWidgetType type);
|
2018-06-12 15:42:38 +00:00
|
|
|
void changeDefinedView();
|
|
|
|
void changeDebugView();
|
2017-11-04 11:46:29 +00:00
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
public slots:
|
|
|
|
|
|
|
|
private:
|
2017-11-04 11:46:29 +00:00
|
|
|
MemoryWidgetType memoryWidgetPriority;
|
|
|
|
|
2017-10-21 19:20:10 +00:00
|
|
|
QString notes;
|
2017-04-09 17:12:36 +00:00
|
|
|
RCore *core_;
|
2018-05-26 16:21:23 +00:00
|
|
|
AsyncTaskManager *asyncTaskManager;
|
2018-06-13 21:36:29 +00:00
|
|
|
RVA offsetPriorDebugging = RVA_INVALID;
|
2018-07-27 12:00:23 +00:00
|
|
|
QErrorMessage msgBox;
|
2018-06-26 07:40:08 +00:00
|
|
|
|
|
|
|
QList<CutterPlugin*> plugins;
|
2017-03-29 10:18:37 +00:00
|
|
|
};
|
|
|
|
|
2017-10-09 18:08:35 +00:00
|
|
|
class ccClass : public CutterCore
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
2017-09-25 12:55:41 +00:00
|
|
|
#endif // CUTTER_H
|