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
|
|
|
|
2019-02-22 16:50:45 +00:00
|
|
|
#include "core/CutterCommon.h"
|
|
|
|
#include "core/CutterDescriptions.h"
|
2019-11-17 18:44:10 +00:00
|
|
|
#include "common/BasicInstructionHighlighter.h"
|
2017-03-30 03:07:34 +00:00
|
|
|
|
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>
|
2019-08-30 15:31:30 +00:00
|
|
|
#include <QMutex>
|
2017-10-15 19:19:48 +00:00
|
|
|
|
2018-05-26 16:21:23 +00:00
|
|
|
class AsyncTaskManager;
|
2019-11-17 18:44:10 +00:00
|
|
|
class BasicInstructionHighlighter;
|
2018-06-26 07:40:08 +00:00
|
|
|
class CutterCore;
|
2019-07-15 12:08:44 +00:00
|
|
|
class Decompiler;
|
2019-10-31 09:50:08 +00:00
|
|
|
class R2Task;
|
2019-11-20 08:50:07 +00:00
|
|
|
class R2TaskDialog;
|
2019-07-15 12:08:44 +00:00
|
|
|
|
2018-06-26 07:40:08 +00:00
|
|
|
#include "plugins/CutterPlugin.h"
|
2019-02-19 18:56:59 +00:00
|
|
|
#include "common/BasicBlockHighlighter.h"
|
2019-10-31 09:50:08 +00:00
|
|
|
#include "common/R2Task.h"
|
2019-11-20 08:50:07 +00:00
|
|
|
#include "dialogs/R2TaskDialog.h"
|
2018-05-26 16:21:23 +00:00
|
|
|
|
2019-02-22 16:50:45 +00:00
|
|
|
#define Core() (CutterCore::instance())
|
|
|
|
|
2019-08-30 15:31:30 +00:00
|
|
|
class RCoreLocked;
|
2017-04-09 17:12:36 +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-04-28 13:09:40 +00:00
|
|
|
|
2019-08-30 15:31:30 +00:00
|
|
|
friend class RCoreLocked;
|
|
|
|
friend class R2Task;
|
|
|
|
|
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();
|
2019-02-11 19:05:53 +00:00
|
|
|
static CutterCore *instance();
|
2017-04-28 13:09:40 +00:00
|
|
|
|
2019-02-20 17:52:11 +00:00
|
|
|
void initialize();
|
2019-07-11 10:32:56 +00:00
|
|
|
void loadCutterRC();
|
2019-02-20 17:52:11 +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);
|
2019-10-31 09:50:08 +00:00
|
|
|
/**
|
|
|
|
* @brief send a command to radare2
|
|
|
|
* @param str the command you want to execute
|
|
|
|
* @return command output
|
|
|
|
* @note if you want to seek to an address, you should use CutterCore::seek.
|
|
|
|
*/
|
2018-11-26 22:34:34 +00:00
|
|
|
QString cmd(const char *str);
|
|
|
|
QString cmd(const QString &str) { return cmd(str.toUtf8().constData()); }
|
2019-10-31 09:50:08 +00:00
|
|
|
/**
|
|
|
|
* @brief send a command to radare2 asynchronously
|
|
|
|
* @param str the command you want to execute
|
|
|
|
* @param task a shared pointer that will be returned with the R2 command task
|
|
|
|
* @note connect to the &R2Task::finished signal to add your own logic once
|
|
|
|
* the command is finished. Use task->getResult()/getResultJson() for the
|
|
|
|
* return value.
|
2019-12-11 11:26:54 +00:00
|
|
|
* Once you have setup connections you can start the task with task->startTask()
|
2019-10-31 09:50:08 +00:00
|
|
|
* If you want to seek to an address, you should use CutterCore::seek.
|
|
|
|
*/
|
2019-12-11 11:26:54 +00:00
|
|
|
bool asyncCmd(const char *str, QSharedPointer<R2Task> &task);
|
|
|
|
bool asyncCmd(const QString &str, QSharedPointer<R2Task> &task) { return asyncCmd(str.toUtf8().constData(), task); }
|
2017-12-20 22:50:26 +00:00
|
|
|
QString cmdRaw(const QString &str);
|
2018-11-26 22:34:34 +00:00
|
|
|
QJsonDocument cmdj(const char *str);
|
|
|
|
QJsonDocument cmdj(const QString &str) { return cmdj(str.toUtf8().constData()); }
|
2019-03-23 10:54:34 +00:00
|
|
|
QStringList cmdList(const char *str) { return cmd(str).split(QLatin1Char('\n'), QString::SkipEmptyParts); }
|
2018-11-26 22:34:34 +00:00
|
|
|
QStringList cmdList(const QString &str) { return cmdList(str.toUtf8().constData()); }
|
2018-05-29 16:19:59 +00:00
|
|
|
QString cmdTask(const QString &str);
|
|
|
|
QJsonDocument cmdjTask(const QString &str);
|
2019-10-31 09:50:08 +00:00
|
|
|
/**
|
|
|
|
* @brief send a command to radare2 and check for ESIL errors
|
|
|
|
* @param command the command you want to execute
|
|
|
|
* @note If you want to seek to an address, you should use CutterCore::seek.
|
|
|
|
*/
|
2018-11-26 22:34:34 +00:00
|
|
|
void cmdEsil(const char *command);
|
|
|
|
void cmdEsil(const QString &command) { cmdEsil(command.toUtf8().constData()); }
|
2019-10-31 09:50:08 +00:00
|
|
|
/**
|
|
|
|
* @brief send a command to radare2 and check for ESIL errors
|
|
|
|
* @param command the command you want to execute
|
|
|
|
* @param task a shared pointer that will be returned with the R2 command task
|
|
|
|
* @note connect to the &R2Task::finished signal to add your own logic once
|
|
|
|
* the command is finished. Use task->getResult()/getResultJson() for the
|
|
|
|
* return value.
|
2019-12-11 11:26:54 +00:00
|
|
|
* Once you have setup connections you can start the task with task->startTask()
|
2019-10-31 09:50:08 +00:00
|
|
|
* If you want to seek to an address, you should use CutterCore::seek.
|
|
|
|
*/
|
2019-12-11 11:26:54 +00:00
|
|
|
bool asyncCmdEsil(const char *command, QSharedPointer<R2Task> &task);
|
|
|
|
bool asyncCmdEsil(const QString &command, QSharedPointer<R2Task> &task) { return asyncCmdEsil(command.toUtf8().constData(), task); }
|
2018-06-20 09:24:28 +00:00
|
|
|
QString getVersionInformation();
|
2017-12-13 14:30:00 +00:00
|
|
|
|
2018-11-26 22:34:34 +00:00
|
|
|
QJsonDocument parseJson(const char *res, const char *cmd = nullptr);
|
|
|
|
QJsonDocument parseJson(const char *res, const QString &cmd = QString())
|
|
|
|
{
|
|
|
|
return parseJson(res, cmd.isNull() ? nullptr : cmd.toLocal8Bit().constData());
|
|
|
|
}
|
2018-05-29 16:19:59 +00:00
|
|
|
|
2019-04-26 15:07:11 +00:00
|
|
|
QStringList autocomplete(const QString &cmd, RLinePromptType promptType, size_t limit = 4096);
|
|
|
|
|
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);
|
2019-05-30 08:41:14 +00:00
|
|
|
RVA getFunctionStart(RVA addr);
|
|
|
|
RVA getFunctionEnd(RVA addr);
|
|
|
|
RVA getLastFunctionInstruction(RVA addr);
|
2018-06-20 09:24:28 +00:00
|
|
|
QString cmdFunctionAt(QString addr);
|
|
|
|
QString cmdFunctionAt(RVA addr);
|
2019-09-25 13:58:58 +00:00
|
|
|
QString createFunctionAt(RVA addr);
|
2018-06-20 09:24:28 +00:00
|
|
|
QString createFunctionAt(RVA addr, QString name);
|
2019-04-22 08:43:34 +00:00
|
|
|
QStringList getDisassemblyPreview(RVA address, int num_of_lines);
|
2018-06-20 09:24:28 +00:00
|
|
|
|
|
|
|
/* 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);
|
2019-08-19 13:35:25 +00:00
|
|
|
/**
|
|
|
|
* @brief Get nearest flag at or before offset.
|
|
|
|
* @param offset search position
|
|
|
|
* @param flagOffsetOut adress of returned flag
|
|
|
|
* @return flag name
|
|
|
|
*/
|
|
|
|
QString nearestFlag(RVA offset, RVA *flagOffsetOut);
|
2018-06-20 09:24:28 +00:00
|
|
|
void triggerFlagsChanged();
|
2017-12-01 10:46:13 +00:00
|
|
|
|
2018-06-20 09:24:28 +00:00
|
|
|
/* Edition functions */
|
2018-09-14 17:20:54 +00:00
|
|
|
QString getInstructionBytes(RVA addr);
|
|
|
|
QString getInstructionOpcode(RVA addr);
|
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);
|
2019-12-18 14:26:51 +00:00
|
|
|
enum class StringTypeFormats { None, ASCII_LATIN1, UTF8 };
|
|
|
|
/**
|
|
|
|
* @brief Adds string at address
|
|
|
|
* That function calls the 'Cs' command
|
|
|
|
* \param addr The address of the array where the string will be applied
|
|
|
|
* \param size The size of string
|
|
|
|
* \param type The type of string
|
|
|
|
*/
|
|
|
|
void setAsString(RVA addr, int size = 0, StringTypeFormats type = StringTypeFormats::None);
|
|
|
|
/**
|
|
|
|
* @brief Removes string at address
|
|
|
|
* That function calls the 'Cs-' command
|
|
|
|
* \param addr The address of the array where the string will be applied
|
|
|
|
*/
|
|
|
|
void removeString(RVA addr);
|
|
|
|
/**
|
|
|
|
* @brief Gets string at address
|
|
|
|
* That function calls the 'ps' command
|
|
|
|
* \param addr The address of the first byte of the array
|
|
|
|
* @return string at requested address
|
|
|
|
*/
|
|
|
|
QString getString(RVA addr);
|
2018-08-04 18:05:56 +00:00
|
|
|
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
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @brief Changes immediate displacement to structure offset
|
2019-09-15 11:41:12 +00:00
|
|
|
* This function makes use of the "aht" command of r2 to apply structure
|
2019-02-24 17:25:38 +00:00
|
|
|
* offset to the immediate displacement used in the given instruction
|
|
|
|
* \param structureOffset The name of struct which will be applied
|
|
|
|
* \param offset The address of the instruction where the struct will be applied
|
|
|
|
*/
|
|
|
|
void applyStructureOffset(const QString &structureOffset, RVA offset = RVA_INVALID);
|
|
|
|
|
2018-08-17 11:27:07 +00:00
|
|
|
/* Classes */
|
2019-02-07 10:42:53 +00:00
|
|
|
QList<QString> getAllAnalClasses(bool sorted);
|
2019-02-01 20:40:34 +00:00
|
|
|
QList<AnalMethodDescription> getAnalClassMethods(const QString &cls);
|
|
|
|
QList<AnalBaseClassDescription> getAnalClassBaseClasses(const QString &cls);
|
|
|
|
QList<AnalVTableDescription> getAnalClassVTables(const QString &cls);
|
2019-02-07 12:40:41 +00:00
|
|
|
void createNewClass(const QString &cls);
|
|
|
|
void renameClass(const QString &oldName, const QString &newName);
|
|
|
|
void deleteClass(const QString &cls);
|
2019-02-01 20:40:34 +00:00
|
|
|
bool getAnalMethod(const QString &cls, const QString &meth, AnalMethodDescription *desc);
|
|
|
|
void renameAnalMethod(const QString &className, const QString &oldMethodName, const QString &newMethodName);
|
|
|
|
void setAnalMethod(const QString &cls, const AnalMethodDescription &meth);
|
2018-08-17 11:27:07 +00:00
|
|
|
|
2018-06-20 09:24:28 +00:00
|
|
|
/* File related methods */
|
2018-09-22 16:00:21 +00:00
|
|
|
bool loadFile(QString path, ut64 baddr = 0LL, ut64 mapaddr = 0LL, int perms = R_PERM_R,
|
2018-11-26 22:34:34 +00:00
|
|
|
int va = 0, bool loadbin = false, const QString &forceBinPlugin = QString());
|
2017-03-29 10:18:37 +00:00
|
|
|
bool tryFile(QString path, bool rw);
|
2019-02-05 19:35:54 +00:00
|
|
|
bool openFile(QString path, RVA mapaddr);
|
2018-06-20 09:24:28 +00:00
|
|
|
void loadScript(const QString &scriptname);
|
|
|
|
QJsonArray getOpenedFiles();
|
|
|
|
|
|
|
|
/* 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();
|
2018-09-06 17:32:12 +00:00
|
|
|
void updateSeek();
|
2019-07-19 19:21:12 +00:00
|
|
|
/**
|
|
|
|
* @brief Raise a memory widget showing current offset, prefer last active
|
|
|
|
* memory widget.
|
|
|
|
*/
|
|
|
|
void showMemoryWidget();
|
|
|
|
/**
|
|
|
|
* @brief Seek to \p offset and raise a memory widget showing it.
|
|
|
|
* @param offset
|
|
|
|
*/
|
|
|
|
void seekAndShow(ut64 offset);
|
|
|
|
/**
|
|
|
|
* @brief \see CutterCore::show(ut64)
|
|
|
|
* @param thing - addressable expression
|
|
|
|
*/
|
|
|
|
void seekAndShow(QString thing);
|
2017-10-16 19:00:47 +00:00
|
|
|
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
|
|
|
/* Math functions */
|
2017-03-29 10:18:37 +00:00
|
|
|
ut64 math(const QString &expr);
|
2018-08-17 11:27:07 +00:00
|
|
|
ut64 num(const QString &expr);
|
|
|
|
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 */
|
2018-11-26 22:34:34 +00:00
|
|
|
void setConfig(const char *k, const QString &v);
|
|
|
|
void setConfig(const QString &k, const QString &v) { setConfig(k.toUtf8().constData(), v); }
|
|
|
|
void setConfig(const char *k, int v);
|
|
|
|
void setConfig(const QString &k, int v) { setConfig(k.toUtf8().constData(), v); }
|
|
|
|
void setConfig(const char *k, bool v);
|
|
|
|
void setConfig(const QString &k, bool v) { setConfig(k.toUtf8().constData(), v); }
|
|
|
|
void setConfig(const char *k, const QVariant &v);
|
|
|
|
void setConfig(const QString &k, const QVariant &v) { setConfig(k.toUtf8().constData(), v); }
|
|
|
|
int getConfigi(const char *k);
|
|
|
|
int getConfigi(const QString &k) { return getConfigi(k.toUtf8().constData()); }
|
2019-01-24 22:29:56 +00:00
|
|
|
ut64 getConfigut64(const char *k);
|
|
|
|
ut64 getConfigut64(const QString &k) { return getConfigut64(k.toUtf8().constData()); }
|
2018-11-26 22:34:34 +00:00
|
|
|
bool getConfigb(const char *k);
|
|
|
|
bool getConfigb(const QString &k) { return getConfigb(k.toUtf8().constData()); }
|
|
|
|
QString getConfig(const char *k);
|
|
|
|
QString getConfig(const QString &k) { return getConfig(k.toUtf8().constData()); }
|
2018-06-20 09:24:28 +00:00
|
|
|
QList<QString> getColorThemes();
|
2017-10-01 14:36:40 +00:00
|
|
|
|
2019-04-22 08:43:34 +00:00
|
|
|
/* Assembly\Hexdump related methods */
|
2019-03-29 17:11:41 +00:00
|
|
|
QByteArray assemble(const QString &code);
|
|
|
|
QString disassemble(const QByteArray &data);
|
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);
|
2019-03-29 17:11:41 +00:00
|
|
|
|
|
|
|
static QByteArray hexStringToBytes(const QString &hex);
|
|
|
|
static QString bytesToHexString(const QByteArray &bytes);
|
2019-04-22 08:43:34 +00:00
|
|
|
enum class HexdumpFormats { Normal, Half, Word, Quad, Signed, Octal };
|
|
|
|
QString hexdump(RVA offset, int size, HexdumpFormats format);
|
|
|
|
QString getHexdumpPreview(RVA offset, int size);
|
2019-03-29 17:11:41 +00:00
|
|
|
|
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-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);
|
2018-06-12 08:43:14 +00:00
|
|
|
|
2018-10-17 06:36:41 +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);
|
2019-10-22 15:51:56 +00:00
|
|
|
void setCurrentDebugThread(int tid);
|
2019-12-09 18:43:42 +00:00
|
|
|
/**
|
|
|
|
* @brief Attach to a given pid from a debug session
|
|
|
|
*/
|
|
|
|
void setCurrentDebugProcess(int pid);
|
2018-07-23 23:13:23 +00:00
|
|
|
QJsonDocument getStack(int size = 0x100);
|
2019-10-22 15:51:56 +00:00
|
|
|
/**
|
|
|
|
* @brief Get a list of a given process's threads
|
|
|
|
* @param pid The pid of the process, -1 for the currently debugged process
|
|
|
|
* @return JSON object result of dptj
|
|
|
|
*/
|
|
|
|
QJsonDocument getProcessThreads(int pid);
|
2019-12-09 18:43:42 +00:00
|
|
|
/**
|
|
|
|
* @brief Get a list of a given process's child processes
|
|
|
|
* @param pid The pid of the process, -1 for the currently debugged process
|
|
|
|
* @return JSON object result of dptj
|
|
|
|
*/
|
|
|
|
QJsonDocument getChildProcesses(int pid);
|
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();
|
2019-11-20 08:50:07 +00:00
|
|
|
/**
|
|
|
|
* @brief attach to a remote debugger
|
|
|
|
* @param uri remote debugger uri
|
|
|
|
* @note attachedRemote(bool) signals the result
|
|
|
|
*/
|
|
|
|
void attachRemote(const QString &uri);
|
2018-07-01 21:29:38 +00:00
|
|
|
void attachDebug(int pid);
|
2018-06-12 15:42:38 +00:00
|
|
|
void stopDebug();
|
2019-10-31 09:50:08 +00:00
|
|
|
void suspendDebug();
|
2018-10-28 13:13:45 +00:00
|
|
|
void syncAndSeekProgramCounter();
|
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-30 06:55:39 +00:00
|
|
|
void stepOutDebug();
|
2019-12-20 17:02:27 +00:00
|
|
|
void addBreakpoint(QString addr);
|
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);
|
2019-12-26 20:51:55 +00:00
|
|
|
/**
|
|
|
|
* @brief Enable or disable breakpoint tracing.
|
|
|
|
* @param index - breakpoint index to modify
|
|
|
|
* @param enabled - true if tracing should be enabled
|
|
|
|
*/
|
|
|
|
void setBreakpointTrace(int index, bool enabled);
|
|
|
|
|
2018-11-26 22:34:34 +00:00
|
|
|
bool isBreakpoint(const QList<RVA> &breakpoints, RVA addr);
|
2018-08-12 16:20:16 +00:00
|
|
|
QList<RVA> getBreakpointsAddresses();
|
2019-12-19 17:58:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get all breakpoinst that are belong to a functions at this address
|
|
|
|
*/
|
|
|
|
QList<RVA> getBreakpointsInFunction(RVA funcAddr);
|
2018-06-14 11:49:22 +00:00
|
|
|
QString getActiveDebugPlugin();
|
|
|
|
QStringList getDebugPlugins();
|
|
|
|
void setDebugPlugin(QString plugin);
|
2019-10-31 09:50:08 +00:00
|
|
|
bool isDebugTaskInProgress();
|
2019-12-04 12:27:38 +00:00
|
|
|
/**
|
|
|
|
* @brief Check if we can use output/input redirection with the currently debugged process
|
|
|
|
*/
|
|
|
|
bool isRedirectableDebugee();
|
2018-06-22 15:57:15 +00:00
|
|
|
bool currentlyDebugging = false;
|
2018-07-01 21:29:38 +00:00
|
|
|
bool currentlyEmulating = false;
|
2018-07-31 17:16:05 +00:00
|
|
|
int currentlyAttachedToPID = -1;
|
|
|
|
QString currentlyOpenFile;
|
2018-06-12 08:43:14 +00:00
|
|
|
|
2019-07-15 12:08:44 +00:00
|
|
|
/* Decompilers */
|
|
|
|
QList<Decompiler *> getDecompilers();
|
|
|
|
Decompiler *getDecompilerById(const QString &id);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register a new decompiler
|
|
|
|
*
|
|
|
|
* The decompiler must have a unique id, otherwise this method will fail.
|
|
|
|
* The decompiler's parent will be set to this CutterCore instance, so it will automatically be freed later.
|
|
|
|
*
|
|
|
|
* @return whether the decompiler was registered successfully
|
|
|
|
*/
|
|
|
|
bool registerDecompiler(Decompiler *decompiler);
|
2018-09-08 07:12:08 +00:00
|
|
|
|
2017-11-28 11:56:38 +00:00
|
|
|
RVA getOffsetJump(RVA 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();
|
2018-09-30 17:46:36 +00:00
|
|
|
void setGraphEmpty(bool empty);
|
|
|
|
bool isGraphEmpty();
|
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
|
|
|
|
2019-05-16 16:03:48 +00:00
|
|
|
QByteArray ioRead(RVA addr, int len);
|
|
|
|
|
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 */
|
2018-11-26 22:34:34 +00:00
|
|
|
QList<RBinPluginDescription> getRBinPluginDescriptions(const QString &type = QString());
|
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();
|
2018-11-26 22:34:34 +00:00
|
|
|
QList<FlagDescription> getAllFlags(QString flagspace = QString());
|
2017-05-03 09:09:57 +00:00
|
|
|
QList<SectionDescription> getAllSections();
|
2018-10-20 18:20:06 +00:00
|
|
|
QList<SegmentDescription> getAllSegments();
|
2017-07-13 18:49:12 +00:00
|
|
|
QList<EntrypointDescription> getAllEntrypoint();
|
2018-08-17 11:27:07 +00:00
|
|
|
QList<BinClassDescription> getAllClassesFromBin();
|
|
|
|
QList<BinClassDescription> getAllClassesFromFlags();
|
2018-02-04 14:32:18 +00:00
|
|
|
QList<ResourcesDescription> getAllResources();
|
2018-02-26 22:26:18 +00:00
|
|
|
QList<VTableDescription> getAllVTables();
|
2019-02-01 16:11:50 +00:00
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @return all loaded types
|
2019-02-01 16:11:50 +00:00
|
|
|
*/
|
2018-03-06 17:21:48 +00:00
|
|
|
QList<TypeDescription> getAllTypes();
|
2019-02-01 16:11:50 +00:00
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @return all loaded primitive types
|
2019-02-01 16:11:50 +00:00
|
|
|
*/
|
|
|
|
QList<TypeDescription> getAllPrimitiveTypes();
|
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @return all loaded unions
|
2019-02-01 16:11:50 +00:00
|
|
|
*/
|
|
|
|
QList<TypeDescription> getAllUnions();
|
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @return all loaded structs
|
2019-02-01 16:11:50 +00:00
|
|
|
*/
|
|
|
|
QList<TypeDescription> getAllStructs();
|
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @return all loaded enums
|
2019-02-01 16:11:50 +00:00
|
|
|
*/
|
|
|
|
QList<TypeDescription> getAllEnums();
|
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @return all loaded typedefs
|
2019-02-01 16:11:50 +00:00
|
|
|
*/
|
|
|
|
QList<TypeDescription> getAllTypedefs();
|
|
|
|
|
2019-06-13 06:22:20 +00:00
|
|
|
/**
|
|
|
|
* @brief Fetching the C representation of a given Type
|
|
|
|
* @param name - the name or the type of the given Type / Struct
|
|
|
|
* @param category - the category of the given Type (Struct, Union, Enum, ...)
|
|
|
|
* @return The type decleration as C output
|
|
|
|
*/
|
|
|
|
QString getTypeAsC(QString name, QString category);
|
|
|
|
|
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @brief Adds new types
|
2019-02-11 09:34:15 +00:00
|
|
|
* It first uses the r_parse_c_string() function from radare2 API to parse the
|
|
|
|
* supplied C file (in the form of a string). If there were errors, they are displayed.
|
|
|
|
* If there were no errors, it uses sdb_query_lines() function from radare2 API
|
|
|
|
* to save the parsed types returned by r_parse_c_string()
|
|
|
|
* \param str Contains the definition of the data types
|
|
|
|
* \return returns an empty QString if there was no error, else returns the error
|
|
|
|
*/
|
|
|
|
QString addTypes(const char *str);
|
|
|
|
QString addTypes(const QString &str) { return addTypes(str.toUtf8().constData()); }
|
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @brief Checks if the given address is mapped to a region
|
|
|
|
* @param addr The address to be checked
|
|
|
|
* @return true if addr is mapped, false otherwise
|
2019-03-04 21:45:17 +00:00
|
|
|
*/
|
|
|
|
bool isAddressMapped(RVA addr);
|
|
|
|
|
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();
|
2018-12-19 08:39:23 +00:00
|
|
|
QList<VariableDescription> getVariables(RVA at);
|
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,
|
2019-07-09 18:55:07 +00:00
|
|
|
const QString &filterType = QString());
|
2017-06-07 10:56:55 +00:00
|
|
|
|
2018-05-29 16:19:59 +00:00
|
|
|
QList<StringDescription> parseStringsJson(const QJsonDocument &doc);
|
|
|
|
|
2019-02-07 10:42:53 +00:00
|
|
|
void handleREvent(int type, void *data);
|
|
|
|
|
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-08-27 11:16:48 +00:00
|
|
|
void message(const QString &msg, bool debug = false);
|
|
|
|
|
2018-11-17 19:17:16 +00:00
|
|
|
QStringList getSectionList();
|
|
|
|
|
2019-08-30 15:31:30 +00:00
|
|
|
RCoreLocked core();
|
2017-04-09 17:12:36 +00:00
|
|
|
|
2019-02-15 12:33:23 +00:00
|
|
|
static QString ansiEscapeToHtml(const QString &text);
|
2019-02-19 18:56:59 +00:00
|
|
|
BasicBlockHighlighter *getBBHighlighter();
|
2019-11-17 18:44:10 +00:00
|
|
|
BasicInstructionHighlighter *getBIHighlighter();
|
2019-02-15 12:33:23 +00:00
|
|
|
|
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();
|
2019-12-11 22:18:40 +00:00
|
|
|
/**
|
|
|
|
* @brief update all the widgets that are affected by rebasing in debug mode
|
|
|
|
*/
|
|
|
|
void codeRebased();
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2019-12-09 18:43:42 +00:00
|
|
|
void switchedThread();
|
|
|
|
void switchedProcess();
|
|
|
|
|
2019-02-07 10:42:53 +00:00
|
|
|
void classNew(const QString &cls);
|
|
|
|
void classDeleted(const QString &cls);
|
|
|
|
void classRenamed(const QString &oldName, const QString &newName);
|
|
|
|
void classAttrsChanged(const QString &cls);
|
|
|
|
|
2019-12-20 15:41:48 +00:00
|
|
|
/**
|
|
|
|
* @brief end of current debug event received
|
|
|
|
*/
|
|
|
|
void debugProcessFinished(int pid);
|
|
|
|
|
2019-11-20 08:50:07 +00:00
|
|
|
void attachedRemote(bool successfully);
|
|
|
|
|
2018-11-02 06:48:17 +00:00
|
|
|
void projectSaved(bool successfully, const QString &name);
|
2017-10-21 19:20:10 +00:00
|
|
|
|
2019-10-31 09:50:08 +00:00
|
|
|
/**
|
|
|
|
* emitted when debugTask started or finished running
|
|
|
|
*/
|
|
|
|
void debugTaskStateChanged();
|
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
2017-10-01 14:36:40 +00:00
|
|
|
* emitted when config regarding disassembly display changes
|
|
|
|
*/
|
|
|
|
void asmOptionsChanged();
|
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
2017-12-19 16:13:44 +00:00
|
|
|
* emitted when config regarding graph display changes
|
|
|
|
*/
|
|
|
|
void graphOptionsChanged();
|
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @brief seekChanged is emitted each time radare2 seek value is modified
|
|
|
|
* @param offset
|
2017-10-09 18:08:35 +00:00
|
|
|
*/
|
|
|
|
void seekChanged(RVA offset);
|
|
|
|
|
2019-12-13 17:30:55 +00:00
|
|
|
void toggleDebugView();
|
2017-11-04 11:46:29 +00:00
|
|
|
|
2018-08-27 11:16:48 +00:00
|
|
|
void newMessage(const QString &msg);
|
|
|
|
void newDebugMessage(const QString &msg);
|
|
|
|
|
2019-07-19 19:21:12 +00:00
|
|
|
void showMemoryWidgetRequested();
|
2017-11-04 11:46:29 +00:00
|
|
|
|
2019-07-19 19:21:12 +00:00
|
|
|
private:
|
2017-10-21 19:20:10 +00:00
|
|
|
QString notes;
|
2019-08-30 15:31:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal reference to the RCore.
|
|
|
|
* NEVER use this directly! Always use the CORE_LOCK(); macro and access it like core->...
|
|
|
|
*/
|
2019-02-20 17:52:11 +00:00
|
|
|
RCore *core_ = nullptr;
|
2019-08-30 15:31:30 +00:00
|
|
|
QMutex coreMutex;
|
|
|
|
int coreLockDepth = 0;
|
|
|
|
void *coreBed = nullptr;
|
|
|
|
|
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
|
|
|
|
2019-07-15 12:08:44 +00:00
|
|
|
QList<Decompiler *> decompilers;
|
|
|
|
|
2018-09-30 17:46:36 +00:00
|
|
|
bool emptyGraph = false;
|
2019-02-19 18:56:59 +00:00
|
|
|
BasicBlockHighlighter *bbHighlighter;
|
2019-11-17 18:44:10 +00:00
|
|
|
BasicInstructionHighlighter biHighlighter;
|
2019-10-31 09:50:08 +00:00
|
|
|
|
|
|
|
QSharedPointer<R2Task> debugTask;
|
2019-11-20 08:50:07 +00:00
|
|
|
R2TaskDialog *debugTaskDialog;
|
2017-03-29 10:18:37 +00:00
|
|
|
};
|
|
|
|
|
2019-08-30 15:31:30 +00:00
|
|
|
class RCoreLocked
|
|
|
|
{
|
|
|
|
CutterCore * const core;
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit RCoreLocked(CutterCore *core);
|
|
|
|
RCoreLocked(const RCoreLocked &) = delete;
|
|
|
|
RCoreLocked &operator=(const RCoreLocked &) = delete;
|
|
|
|
RCoreLocked(RCoreLocked &&);
|
|
|
|
~RCoreLocked();
|
|
|
|
operator RCore *() const;
|
|
|
|
RCore *operator->() const;
|
|
|
|
};
|
|
|
|
|
2017-09-25 12:55:41 +00:00
|
|
|
#endif // CUTTER_H
|