mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-24 05:45:27 +00:00
[WIP] Some cleanup (#958)
* Some cleanup * Some more * Some more * Some more
This commit is contained in:
parent
33d16dda3e
commit
3096d24998
@ -99,7 +99,7 @@ void AnalTask::runTask()
|
|||||||
|
|
||||||
if (!options.analCmd.empty()) {
|
if (!options.analCmd.empty()) {
|
||||||
log(tr("Analyzing..."));
|
log(tr("Analyzing..."));
|
||||||
for (QString cmd : options.analCmd) {
|
for (const QString &cmd : options.analCmd) {
|
||||||
if (isInterrupted()) {
|
if (isInterrupted()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
232
src/Cutter.cpp
232
src/Cutter.cpp
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
Q_GLOBAL_STATIC(ccClass, uniqueInstance)
|
Q_GLOBAL_STATIC(ccClass, uniqueInstance)
|
||||||
|
|
||||||
#define R_JSON_KEY(name) static const QLatin1String name = QLatin1Literal(#name)
|
#define R_JSON_KEY(name) static const QString name = QStringLiteral(#name)
|
||||||
|
|
||||||
namespace RJsonKey {
|
namespace RJsonKey {
|
||||||
R_JSON_KEY(addr);
|
R_JSON_KEY(addr);
|
||||||
@ -50,6 +50,7 @@ namespace RJsonKey {
|
|||||||
R_JSON_KEY(hw);
|
R_JSON_KEY(hw);
|
||||||
R_JSON_KEY(in_functions);
|
R_JSON_KEY(in_functions);
|
||||||
R_JSON_KEY(index);
|
R_JSON_KEY(index);
|
||||||
|
R_JSON_KEY(jump);
|
||||||
R_JSON_KEY(laddr);
|
R_JSON_KEY(laddr);
|
||||||
R_JSON_KEY(lang);
|
R_JSON_KEY(lang);
|
||||||
R_JSON_KEY(len);
|
R_JSON_KEY(len);
|
||||||
@ -228,7 +229,7 @@ CutterCore::~CutterCore()
|
|||||||
QString CutterCore::sanitizeStringForCommand(QString s)
|
QString CutterCore::sanitizeStringForCommand(QString s)
|
||||||
{
|
{
|
||||||
static const QRegExp regexp(";|@");
|
static const QRegExp regexp(";|@");
|
||||||
return s.replace(regexp, "_");
|
return s.replace(regexp, QStringLiteral("_"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -237,14 +238,13 @@ QString CutterCore::sanitizeStringForCommand(QString s)
|
|||||||
* Note that if you want to seek to an address, you should use CutterCore::seek
|
* Note that if you want to seek to an address, you should use CutterCore::seek
|
||||||
* @return command output
|
* @return command output
|
||||||
*/
|
*/
|
||||||
QString CutterCore::cmd(const QString &str)
|
QString CutterCore::cmd(const char *str)
|
||||||
{
|
{
|
||||||
CORE_LOCK();
|
CORE_LOCK();
|
||||||
|
|
||||||
RVA offset = core_->offset;
|
RVA offset = core_->offset;
|
||||||
QByteArray cmd = str.toUtf8();
|
|
||||||
r_core_task_sync_begin(core_);
|
r_core_task_sync_begin(core_);
|
||||||
char *res = r_core_cmd_str(this->core_, cmd.constData());
|
char *res = r_core_cmd_str(this->core_, str);
|
||||||
r_core_task_sync_end(core_);
|
r_core_task_sync_end(core_);
|
||||||
QString o = QString(res ? res : "");
|
QString o = QString(res ? res : "");
|
||||||
r_mem_free(res);
|
r_mem_free(res);
|
||||||
@ -257,17 +257,16 @@ QString CutterCore::cmd(const QString &str)
|
|||||||
QString CutterCore::cmdRaw(const QString &str)
|
QString CutterCore::cmdRaw(const QString &str)
|
||||||
{
|
{
|
||||||
QString cmdStr = str;
|
QString cmdStr = str;
|
||||||
cmdStr.replace('\"', "\\\"");
|
cmdStr.replace('\"', QStringLiteral("\\\""));
|
||||||
return cmd("\"" + cmdStr + "\"");
|
return cmd(cmdStr.prepend('\"').append('\"'));
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonDocument CutterCore::cmdj(const QString &str)
|
QJsonDocument CutterCore::cmdj(const char *str)
|
||||||
{
|
{
|
||||||
CORE_LOCK();
|
CORE_LOCK();
|
||||||
QByteArray cmd = str.toUtf8();
|
|
||||||
|
|
||||||
r_core_task_sync_begin(core_);
|
r_core_task_sync_begin(core_);
|
||||||
char *res = r_core_cmd_str(this->core_, cmd.constData());
|
char *res = r_core_cmd_str(this->core_, str);
|
||||||
r_core_task_sync_end(core_);
|
r_core_task_sync_end(core_);
|
||||||
QJsonDocument doc = parseJson(res, str);
|
QJsonDocument doc = parseJson(res, str);
|
||||||
r_mem_free(res);
|
r_mem_free(res);
|
||||||
@ -291,25 +290,25 @@ QJsonDocument CutterCore::cmdjTask(const QString &str)
|
|||||||
return parseJson(task.getResultRaw(), str);
|
return parseJson(task.getResultRaw(), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonDocument CutterCore::parseJson(const char *res, const QString &cmd)
|
QJsonDocument CutterCore::parseJson(const char *res, const char *cmd)
|
||||||
{
|
{
|
||||||
QString resString = QString(res);
|
QByteArray json(res);
|
||||||
|
|
||||||
if (resString.isEmpty()) {
|
if (json.isEmpty()) {
|
||||||
return QJsonDocument();
|
return QJsonDocument();
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonParseError jsonError;
|
QJsonParseError jsonError;
|
||||||
QJsonDocument doc = res ? QJsonDocument::fromJson(resString.toUtf8(), &jsonError) : QJsonDocument();
|
QJsonDocument doc = QJsonDocument::fromJson(json, &jsonError);
|
||||||
|
|
||||||
if (jsonError.error != QJsonParseError::NoError) {
|
if (jsonError.error != QJsonParseError::NoError) {
|
||||||
if (!cmd.isNull()) {
|
if (cmd) {
|
||||||
eprintf("Failed to parse JSON for command \"%s\": %s\n", cmd.toLocal8Bit().constData(),
|
eprintf("Failed to parse JSON for command \"%s\": %s\n", cmd,
|
||||||
jsonError.errorString().toLocal8Bit().constData());
|
jsonError.errorString().toLocal8Bit().constData());
|
||||||
} else {
|
} else {
|
||||||
eprintf("Failed to parse JSON: %s\n", jsonError.errorString().toLocal8Bit().constData());
|
eprintf("Failed to parse JSON: %s\n", jsonError.errorString().toLocal8Bit().constData());
|
||||||
}
|
}
|
||||||
eprintf("%s\n", resString.toLocal8Bit().constData());
|
eprintf("%s\n", json.constData());
|
||||||
}
|
}
|
||||||
|
|
||||||
return doc;
|
return doc;
|
||||||
@ -617,35 +616,34 @@ ut64 CutterCore::math(const QString &expr)
|
|||||||
return r_num_math(this->core_ ? this->core_->num : NULL, expr.toUtf8().constData());
|
return r_num_math(this->core_ ? this->core_->num : NULL, expr.toUtf8().constData());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CutterCore::setConfig(const QString &k, const QString &v)
|
void CutterCore::setConfig(const char *k, const QString &v)
|
||||||
{
|
{
|
||||||
CORE_LOCK();
|
CORE_LOCK();
|
||||||
r_config_set(core_->config, k.toUtf8().constData(), v.toUtf8().constData());
|
r_config_set(core_->config, k, v.toUtf8().constData());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CutterCore::setConfig(const QString &k, int v)
|
void CutterCore::setConfig(const char *k, int v)
|
||||||
{
|
{
|
||||||
CORE_LOCK();
|
CORE_LOCK();
|
||||||
r_config_set_i(core_->config, k.toUtf8().constData(), static_cast<ut64>(v));
|
r_config_set_i(core_->config, k, static_cast<ut64>(v));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CutterCore::setConfig(const QString &k, bool v)
|
void CutterCore::setConfig(const char *k, bool v)
|
||||||
{
|
{
|
||||||
CORE_LOCK();
|
CORE_LOCK();
|
||||||
r_config_set_i(core_->config, k.toUtf8().constData(), v ? 1 : 0);
|
r_config_set_i(core_->config, k, v ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CutterCore::getConfigi(const QString &k)
|
int CutterCore::getConfigi(const char *k)
|
||||||
{
|
{
|
||||||
CORE_LOCK();
|
CORE_LOCK();
|
||||||
QByteArray key = k.toUtf8();
|
return static_cast<int>(r_config_get_i(core_->config, k));
|
||||||
return static_cast<int>(r_config_get_i(core_->config, key.constData()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CutterCore::getConfigb(const QString &k)
|
bool CutterCore::getConfigb(const char *k)
|
||||||
{
|
{
|
||||||
CORE_LOCK();
|
CORE_LOCK();
|
||||||
return r_config_get_i(core_->config, k.toUtf8().constData()) != 0;
|
return r_config_get_i(core_->config, k) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CutterCore::triggerRefreshAll()
|
void CutterCore::triggerRefreshAll()
|
||||||
@ -675,14 +673,13 @@ void CutterCore::message(const QString &msg, bool debug)
|
|||||||
emit newMessage(msg);
|
emit newMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CutterCore::getConfig(const QString &k)
|
QString CutterCore::getConfig(const char *k)
|
||||||
{
|
{
|
||||||
CORE_LOCK();
|
CORE_LOCK();
|
||||||
QByteArray key = k.toUtf8();
|
return QString(r_config_get(core_->config, k));
|
||||||
return QString(r_config_get(core_->config, key.constData()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CutterCore::setConfig(const QString &k, const QVariant &v)
|
void CutterCore::setConfig(const char *k, const QVariant &v)
|
||||||
{
|
{
|
||||||
switch (v.type()) {
|
switch (v.type()) {
|
||||||
case QVariant::Type::Bool:
|
case QVariant::Type::Bool:
|
||||||
@ -762,17 +759,18 @@ QString CutterCore::cmdFunctionAt(RVA addr)
|
|||||||
return cmdFunctionAt(QString::number(addr));
|
return cmdFunctionAt(QString::number(addr));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CutterCore::cmdEsil(QString command)
|
void CutterCore::cmdEsil(const char *command)
|
||||||
{
|
{
|
||||||
QString res = cmd(command);
|
QString res = cmd(command);
|
||||||
if (res.contains("[ESIL] Stopped execution in an invalid instruction")) {
|
if (res.contains(QStringLiteral("[ESIL] Stopped execution in an invalid instruction"))) {
|
||||||
msgBox.showMessage("Stopped when attempted to run an invalid instruction. You can disable this in Preferences");
|
msgBox.showMessage("Stopped when attempted to run an invalid instruction. You can disable this in Preferences");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CutterCore::createFunctionAt(RVA addr, QString name)
|
QString CutterCore::createFunctionAt(RVA addr, QString name)
|
||||||
{
|
{
|
||||||
name.remove(QRegExp("[^a-zA-Z0-9_]"));
|
static const QRegExp regExp("[^a-zA-Z0-9_]");
|
||||||
|
name.remove(regExp);
|
||||||
QString command = "af " + name + " " + RAddressString(addr);
|
QString command = "af " + name + " " + RAddressString(addr);
|
||||||
QString ret = cmd(command);
|
QString ret = cmd(command);
|
||||||
emit functionsChanged();
|
emit functionsChanged();
|
||||||
@ -788,7 +786,7 @@ RVA CutterCore::getOffsetJump(RVA addr)
|
|||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
RVA value = cmdj("aoj @" + QString::number(
|
RVA value = cmdj("aoj @" + QString::number(
|
||||||
addr)).array().first().toObject().value("jump").toVariant().toULongLong(&ok);
|
addr)).array().first().toObject().value(RJsonKey::jump).toVariant().toULongLong(&ok);
|
||||||
|
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
return RVA_INVALID;
|
return RVA_INVALID;
|
||||||
@ -804,7 +802,7 @@ QString CutterCore::getDecompiledCodePDC(RVA addr)
|
|||||||
|
|
||||||
bool CutterCore::getR2DecAvailable()
|
bool CutterCore::getR2DecAvailable()
|
||||||
{
|
{
|
||||||
return cmd("e cmd.pdc=?").split('\n').contains("r2dec");
|
return cmd("e cmd.pdc=?").split('\n').contains(QStringLiteral("r2dec"));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CutterCore::getDecompiledCodeR2Dec(RVA addr)
|
QString CutterCore::getDecompiledCodeR2Dec(RVA addr)
|
||||||
@ -843,7 +841,7 @@ QList<RegisterRefDescription> CutterCore::getRegisterRefs()
|
|||||||
QList<RegisterRefDescription> ret;
|
QList<RegisterRefDescription> ret;
|
||||||
QJsonArray registerRefArray = cmdj("drrj").array();
|
QJsonArray registerRefArray = cmdj("drrj").array();
|
||||||
|
|
||||||
for (QJsonValue value : registerRefArray) {
|
for (const QJsonValue &value : registerRefArray) {
|
||||||
QJsonObject regRefObject = value.toObject();
|
QJsonObject regRefObject = value.toObject();
|
||||||
|
|
||||||
RegisterRefDescription regRef;
|
RegisterRefDescription regRef;
|
||||||
@ -862,12 +860,15 @@ QJsonObject CutterCore::getRegisterJson()
|
|||||||
{
|
{
|
||||||
QJsonArray registerRefArray = cmdj("drrj").array();
|
QJsonArray registerRefArray = cmdj("drrj").array();
|
||||||
QJsonObject registerJson;
|
QJsonObject registerJson;
|
||||||
for (QJsonValue value : registerRefArray) {
|
|
||||||
|
for (const QJsonValue &value : registerRefArray) {
|
||||||
QJsonObject regRefObject = value.toObject();
|
QJsonObject regRefObject = value.toObject();
|
||||||
|
|
||||||
QJsonObject registers;
|
QJsonObject registers;
|
||||||
|
|
||||||
registers.insert(RJsonKey::value, regRefObject[RJsonKey::value]);
|
registers.insert(RJsonKey::value, regRefObject[RJsonKey::value]);
|
||||||
registers.insert(RJsonKey::ref, regRefObject[RJsonKey::ref]);
|
registers.insert(RJsonKey::ref, regRefObject[RJsonKey::ref]);
|
||||||
|
|
||||||
registerJson.insert(regRefObject[RJsonKey::reg].toString(), registers);
|
registerJson.insert(regRefObject[RJsonKey::reg].toString(), registers);
|
||||||
}
|
}
|
||||||
return registerJson;
|
return registerJson;
|
||||||
@ -1067,9 +1068,11 @@ QStringList CutterCore::getDebugPlugins()
|
|||||||
QStringList plugins;
|
QStringList plugins;
|
||||||
QJsonArray pluginArray = cmdj("dLj").array();
|
QJsonArray pluginArray = cmdj("dLj").array();
|
||||||
|
|
||||||
for (QJsonValue value : pluginArray) {
|
for (const QJsonValue &value : pluginArray) {
|
||||||
QJsonObject pluginObject = value.toObject();
|
QJsonObject pluginObject = value.toObject();
|
||||||
|
|
||||||
QString plugin = pluginObject[RJsonKey::name].toString();
|
QString plugin = pluginObject[RJsonKey::name].toString();
|
||||||
|
|
||||||
plugins << plugin;
|
plugins << plugin;
|
||||||
}
|
}
|
||||||
return plugins;
|
return plugins;
|
||||||
@ -1131,13 +1134,13 @@ QList<BreakpointDescription> CutterCore::getBreakpoints()
|
|||||||
QList<BreakpointDescription> ret;
|
QList<BreakpointDescription> ret;
|
||||||
QJsonArray breakpointArray = cmdj("dbj").array();
|
QJsonArray breakpointArray = cmdj("dbj").array();
|
||||||
|
|
||||||
for (QJsonValue value : breakpointArray) {
|
for (const QJsonValue &value : breakpointArray) {
|
||||||
QJsonObject bpObject = value.toObject();
|
QJsonObject bpObject = value.toObject();
|
||||||
|
|
||||||
BreakpointDescription bp;
|
BreakpointDescription bp;
|
||||||
|
|
||||||
bp.addr = bpObject[RJsonKey::addr].toVariant().toULongLong();
|
bp.addr = bpObject[RJsonKey::addr].toVariant().toULongLong();
|
||||||
bp.size = bpObject[RJsonKey::size].toVariant().toInt();
|
bp.size = bpObject[RJsonKey::size].toInt();
|
||||||
bp.permission = bpObject[RJsonKey::prot].toString();
|
bp.permission = bpObject[RJsonKey::prot].toString();
|
||||||
bp.hw = bpObject[RJsonKey::hw].toBool();
|
bp.hw = bpObject[RJsonKey::hw].toBool();
|
||||||
bp.trace = bpObject[RJsonKey::trace].toBool();
|
bp.trace = bpObject[RJsonKey::trace].toBool();
|
||||||
@ -1152,17 +1155,15 @@ QList<BreakpointDescription> CutterCore::getBreakpoints()
|
|||||||
|
|
||||||
QList<RVA> CutterCore::getBreakpointsAddresses()
|
QList<RVA> CutterCore::getBreakpointsAddresses()
|
||||||
{
|
{
|
||||||
QList<BreakpointDescription> bps = getBreakpoints();
|
|
||||||
BreakpointDescription bp;
|
|
||||||
QList<RVA> bpAddresses;
|
QList<RVA> bpAddresses;
|
||||||
foreach (bp, bps) {
|
for (const BreakpointDescription &bp : getBreakpoints()) {
|
||||||
bpAddresses << bp.addr;
|
bpAddresses << bp.addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return bpAddresses;
|
return bpAddresses;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CutterCore::isBreakpoint(QList<RVA> breakpoints, RVA addr)
|
bool CutterCore::isBreakpoint(const QList<RVA> &breakpoints, RVA addr)
|
||||||
{
|
{
|
||||||
return breakpoints.contains(addr);
|
return breakpoints.contains(addr);
|
||||||
}
|
}
|
||||||
@ -1175,15 +1176,15 @@ QJsonDocument CutterCore::getBacktrace()
|
|||||||
QList<ProcessDescription> CutterCore::getAllProcesses()
|
QList<ProcessDescription> CutterCore::getAllProcesses()
|
||||||
{
|
{
|
||||||
QList<ProcessDescription> ret;
|
QList<ProcessDescription> ret;
|
||||||
QJsonArray ProcessArray = cmdj("dplj").array();
|
QJsonArray processArray = cmdj("dplj").array();
|
||||||
|
|
||||||
for (QJsonValue value : ProcessArray) {
|
for (const QJsonValue &value : processArray) {
|
||||||
QJsonObject procObject = value.toObject();
|
QJsonObject procObject = value.toObject();
|
||||||
|
|
||||||
ProcessDescription proc;
|
ProcessDescription proc;
|
||||||
|
|
||||||
proc.pid = procObject[RJsonKey::pid].toVariant().toInt();
|
proc.pid = procObject[RJsonKey::pid].toInt();
|
||||||
proc.uid = procObject[RJsonKey::uid].toVariant().toInt();
|
proc.uid = procObject[RJsonKey::uid].toInt();
|
||||||
proc.status = procObject[RJsonKey::status].toString();
|
proc.status = procObject[RJsonKey::status].toString();
|
||||||
proc.path = procObject[RJsonKey::path].toString();
|
proc.path = procObject[RJsonKey::path].toString();
|
||||||
|
|
||||||
@ -1198,7 +1199,7 @@ QList<MemoryMapDescription> CutterCore::getMemoryMap()
|
|||||||
QList<MemoryMapDescription> ret;
|
QList<MemoryMapDescription> ret;
|
||||||
QJsonArray memoryMapArray = cmdj("dmj").array();
|
QJsonArray memoryMapArray = cmdj("dmj").array();
|
||||||
|
|
||||||
for (QJsonValue value : memoryMapArray) {
|
for (const QJsonValue &value : memoryMapArray) {
|
||||||
QJsonObject memMapObject = value.toObject();
|
QJsonObject memMapObject = value.toObject();
|
||||||
|
|
||||||
MemoryMapDescription memMap;
|
MemoryMapDescription memMap;
|
||||||
@ -1289,7 +1290,7 @@ QList<RVA> CutterCore::getSeekHistory()
|
|||||||
QList<RVA> ret;
|
QList<RVA> ret;
|
||||||
|
|
||||||
QJsonArray jsonArray = cmdj("sj").array();
|
QJsonArray jsonArray = cmdj("sj").array();
|
||||||
for (QJsonValue value : jsonArray)
|
for (const QJsonValue &value : jsonArray)
|
||||||
ret << value.toVariant().toULongLong();
|
ret << value.toVariant().toULongLong();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -1329,7 +1330,7 @@ QStringList CutterCore::getProjectNames()
|
|||||||
QStringList ret;
|
QStringList ret;
|
||||||
|
|
||||||
QJsonArray jsonArray = cmdj("Pj").array();
|
QJsonArray jsonArray = cmdj("Pj").array();
|
||||||
for (QJsonValue value : jsonArray)
|
for (const QJsonValue &value : jsonArray)
|
||||||
ret.append(value.toString());
|
ret.append(value.toString());
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -1346,13 +1347,16 @@ QList<RBinPluginDescription> CutterCore::getRBinPluginDescriptions(const QString
|
|||||||
|
|
||||||
QJsonArray pluginArray = jsonRoot[key].toArray();
|
QJsonArray pluginArray = jsonRoot[key].toArray();
|
||||||
|
|
||||||
for (const auto &pluginValue : pluginArray) {
|
for (const QJsonValue &pluginValue : pluginArray) {
|
||||||
QJsonObject pluginObject = pluginValue.toObject();
|
QJsonObject pluginObject = pluginValue.toObject();
|
||||||
|
|
||||||
RBinPluginDescription desc;
|
RBinPluginDescription desc;
|
||||||
|
|
||||||
desc.name = pluginObject[RJsonKey::name].toString();
|
desc.name = pluginObject[RJsonKey::name].toString();
|
||||||
desc.description = pluginObject[RJsonKey::description].toString();
|
desc.description = pluginObject[RJsonKey::description].toString();
|
||||||
desc.license = pluginObject[RJsonKey::license].toString();
|
desc.license = pluginObject[RJsonKey::license].toString();
|
||||||
desc.type = key;
|
desc.type = key;
|
||||||
|
|
||||||
ret.append(desc);
|
ret.append(desc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1365,8 +1369,9 @@ QList<RIOPluginDescription> CutterCore::getRIOPluginDescriptions()
|
|||||||
QList<RIOPluginDescription> ret;
|
QList<RIOPluginDescription> ret;
|
||||||
|
|
||||||
QJsonArray plugins = cmdj("oLj").object()["IO_Plugins"].toArray();
|
QJsonArray plugins = cmdj("oLj").object()["IO_Plugins"].toArray();
|
||||||
for (QJsonValueRef pluginValue : plugins) {
|
for (const QJsonValue &pluginValue : plugins) {
|
||||||
QJsonObject pluginObject = pluginValue.toObject();
|
QJsonObject pluginObject = pluginValue.toObject();
|
||||||
|
|
||||||
RIOPluginDescription plugin;
|
RIOPluginDescription plugin;
|
||||||
|
|
||||||
plugin.name = pluginObject["Name"].toString();
|
plugin.name = pluginObject["Name"].toString();
|
||||||
@ -1385,8 +1390,9 @@ QList<RCorePluginDescription> CutterCore::getRCorePluginDescriptions()
|
|||||||
QList<RCorePluginDescription> ret;
|
QList<RCorePluginDescription> ret;
|
||||||
|
|
||||||
QJsonArray plugins = cmdj("Lsj").array();
|
QJsonArray plugins = cmdj("Lsj").array();
|
||||||
for (QJsonValueRef pluginValue : plugins) {
|
for (const QJsonValue &pluginValue : plugins) {
|
||||||
QJsonObject pluginObject = pluginValue.toObject();
|
QJsonObject pluginObject = pluginValue.toObject();
|
||||||
|
|
||||||
RCorePluginDescription plugin;
|
RCorePluginDescription plugin;
|
||||||
|
|
||||||
plugin.name = pluginObject["Name"].toString();
|
plugin.name = pluginObject["Name"].toString();
|
||||||
@ -1434,7 +1440,7 @@ QList<ImportDescription> CutterCore::getAllImports()
|
|||||||
|
|
||||||
QJsonArray importsArray = cmdj("iij").array();
|
QJsonArray importsArray = cmdj("iij").array();
|
||||||
|
|
||||||
for (QJsonValue value : importsArray) {
|
for (const QJsonValue &value : importsArray) {
|
||||||
QJsonObject importObject = value.toObject();
|
QJsonObject importObject = value.toObject();
|
||||||
|
|
||||||
ImportDescription import;
|
ImportDescription import;
|
||||||
@ -1456,19 +1462,19 @@ QList<ExportDescription> CutterCore::getAllExports()
|
|||||||
CORE_LOCK();
|
CORE_LOCK();
|
||||||
QList<ExportDescription> ret;
|
QList<ExportDescription> ret;
|
||||||
|
|
||||||
QJsonArray importsArray = cmdj("iEj").array();
|
QJsonArray exportsArray = cmdj("iEj").array();
|
||||||
|
|
||||||
for (QJsonValue value : importsArray) {
|
for (const QJsonValue &value : exportsArray) {
|
||||||
QJsonObject importObject = value.toObject();
|
QJsonObject exportObject = value.toObject();
|
||||||
|
|
||||||
ExportDescription exp;
|
ExportDescription exp;
|
||||||
|
|
||||||
exp.vaddr = importObject[RJsonKey::vaddr].toVariant().toULongLong();
|
exp.vaddr = exportObject[RJsonKey::vaddr].toVariant().toULongLong();
|
||||||
exp.paddr = importObject[RJsonKey::paddr].toVariant().toULongLong();
|
exp.paddr = exportObject[RJsonKey::paddr].toVariant().toULongLong();
|
||||||
exp.size = importObject[RJsonKey::size].toVariant().toULongLong();
|
exp.size = exportObject[RJsonKey::size].toVariant().toULongLong();
|
||||||
exp.type = importObject[RJsonKey::type].toString();
|
exp.type = exportObject[RJsonKey::type].toString();
|
||||||
exp.name = importObject[RJsonKey::name].toString();
|
exp.name = exportObject[RJsonKey::name].toString();
|
||||||
exp.flag_name = importObject[RJsonKey::flagname].toString();
|
exp.flag_name = exportObject[RJsonKey::flagname].toString();
|
||||||
|
|
||||||
ret << exp;
|
ret << exp;
|
||||||
}
|
}
|
||||||
@ -1518,7 +1524,7 @@ QList<HeaderDescription> CutterCore::getAllHeaders()
|
|||||||
|
|
||||||
QJsonArray headersArray = cmdj("ihj").array();
|
QJsonArray headersArray = cmdj("ihj").array();
|
||||||
|
|
||||||
for (QJsonValue value : headersArray) {
|
for (const QJsonValue &value : headersArray) {
|
||||||
QJsonObject headerObject = value.toObject();
|
QJsonObject headerObject = value.toObject();
|
||||||
|
|
||||||
HeaderDescription header;
|
HeaderDescription header;
|
||||||
@ -1541,7 +1547,7 @@ QList<ZignatureDescription> CutterCore::getAllZignatures()
|
|||||||
|
|
||||||
QJsonArray zignaturesArray = cmdj("zj").array();
|
QJsonArray zignaturesArray = cmdj("zj").array();
|
||||||
|
|
||||||
for (QJsonValue value : zignaturesArray) {
|
for (const QJsonValue &value : zignaturesArray) {
|
||||||
QJsonObject zignatureObject = value.toObject();
|
QJsonObject zignatureObject = value.toObject();
|
||||||
|
|
||||||
ZignatureDescription zignature;
|
ZignatureDescription zignature;
|
||||||
@ -1549,7 +1555,7 @@ QList<ZignatureDescription> CutterCore::getAllZignatures()
|
|||||||
zignature.name = zignatureObject[RJsonKey::name].toString();
|
zignature.name = zignatureObject[RJsonKey::name].toString();
|
||||||
zignature.bytes = zignatureObject[RJsonKey::bytes].toString();
|
zignature.bytes = zignatureObject[RJsonKey::bytes].toString();
|
||||||
zignature.offset = zignatureObject[RJsonKey::offset].toVariant().toULongLong();
|
zignature.offset = zignatureObject[RJsonKey::offset].toVariant().toULongLong();
|
||||||
for (QJsonValue ref : zignatureObject[RJsonKey::refs].toArray()) {
|
for (const QJsonValue &ref : zignatureObject[RJsonKey::refs].toArray()) {
|
||||||
zignature.refs << ref.toString();
|
zignature.refs << ref.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1571,7 +1577,7 @@ QList<CommentDescription> CutterCore::getAllComments(const QString &filterType)
|
|||||||
QList<CommentDescription> ret;
|
QList<CommentDescription> ret;
|
||||||
|
|
||||||
QJsonArray commentsArray = cmdj("CCj").array();
|
QJsonArray commentsArray = cmdj("CCj").array();
|
||||||
for (QJsonValue value : commentsArray) {
|
for (const QJsonValue &value : commentsArray) {
|
||||||
QJsonObject commentObject = value.toObject();
|
QJsonObject commentObject = value.toObject();
|
||||||
|
|
||||||
QString type = commentObject[RJsonKey::type].toString();
|
QString type = commentObject[RJsonKey::type].toString();
|
||||||
@ -1624,10 +1630,11 @@ QList<StringDescription> CutterCore::parseStringsJson(const QJsonDocument &doc)
|
|||||||
QList<StringDescription> ret;
|
QList<StringDescription> ret;
|
||||||
|
|
||||||
QJsonArray stringsArray = doc.array();
|
QJsonArray stringsArray = doc.array();
|
||||||
for (QJsonValue value : stringsArray) {
|
for (const QJsonValue &value : stringsArray) {
|
||||||
QJsonObject stringObject = value.toObject();
|
QJsonObject stringObject = value.toObject();
|
||||||
|
|
||||||
StringDescription string;
|
StringDescription string;
|
||||||
|
|
||||||
string.string = QString(QByteArray::fromBase64(stringObject[RJsonKey::string].toVariant().toByteArray()));
|
string.string = QString(QByteArray::fromBase64(stringObject[RJsonKey::string].toVariant().toByteArray()));
|
||||||
string.vaddr = stringObject[RJsonKey::vaddr].toVariant().toULongLong();
|
string.vaddr = stringObject[RJsonKey::vaddr].toVariant().toULongLong();
|
||||||
string.type = stringObject[RJsonKey::type].toString();
|
string.type = stringObject[RJsonKey::type].toString();
|
||||||
@ -1646,23 +1653,23 @@ QList<FunctionDescription> CutterCore::parseFunctionsJson(const QJsonDocument &d
|
|||||||
QList<FunctionDescription> ret;
|
QList<FunctionDescription> ret;
|
||||||
QJsonArray jsonArray = doc.array();
|
QJsonArray jsonArray = doc.array();
|
||||||
|
|
||||||
for (QJsonValue value : jsonArray) {
|
for (const QJsonValue &value : jsonArray) {
|
||||||
QJsonObject jsonObject = value.toObject();
|
QJsonObject jsonObject = value.toObject();
|
||||||
|
|
||||||
FunctionDescription function;
|
FunctionDescription function;
|
||||||
|
|
||||||
function.offset = (RVA)jsonObject[RJsonKey::offset].toVariant().toULongLong();
|
function.offset = jsonObject[RJsonKey::offset].toVariant().toULongLong();
|
||||||
function.size = (RVA)jsonObject[RJsonKey::size].toVariant().toULongLong();
|
function.size = jsonObject[RJsonKey::size].toVariant().toULongLong();
|
||||||
function.nargs = (RVA)jsonObject[RJsonKey::nargs].toVariant().toULongLong();
|
function.nargs = jsonObject[RJsonKey::nargs].toVariant().toULongLong();
|
||||||
function.nbbs = (RVA)jsonObject[RJsonKey::nbbs].toVariant().toULongLong();
|
function.nbbs = jsonObject[RJsonKey::nbbs].toVariant().toULongLong();
|
||||||
function.nlocals = (RVA)jsonObject[RJsonKey::nlocals].toVariant().toULongLong();
|
function.nlocals = jsonObject[RJsonKey::nlocals].toVariant().toULongLong();
|
||||||
function.cc = (RVA)jsonObject[RJsonKey::cc].toVariant().toULongLong();
|
function.cc = jsonObject[RJsonKey::cc].toVariant().toULongLong();
|
||||||
function.calltype = jsonObject[RJsonKey::calltype].toString();
|
function.calltype = jsonObject[RJsonKey::calltype].toString();
|
||||||
function.name = jsonObject[RJsonKey::name].toString();
|
function.name = jsonObject[RJsonKey::name].toString();
|
||||||
function.edges = (RVA)jsonObject[RJsonKey::edges].toVariant().toULongLong();
|
function.edges = jsonObject[RJsonKey::edges].toVariant().toULongLong();
|
||||||
function.cost = (RVA)jsonObject[RJsonKey::cost].toVariant().toULongLong();
|
function.cost = jsonObject[RJsonKey::cost].toVariant().toULongLong();
|
||||||
function.calls = (RVA)jsonObject[RJsonKey::outdegree].toVariant().toULongLong();
|
function.calls = jsonObject[RJsonKey::outdegree].toVariant().toULongLong();
|
||||||
function.stackframe = (RVA)jsonObject[RJsonKey::stackframe].toVariant().toULongLong();
|
function.stackframe = jsonObject[RJsonKey::stackframe].toVariant().toULongLong();
|
||||||
|
|
||||||
ret << function;
|
ret << function;
|
||||||
}
|
}
|
||||||
@ -1676,10 +1683,11 @@ QList<FlagspaceDescription> CutterCore::getAllFlagspaces()
|
|||||||
QList<FlagspaceDescription> ret;
|
QList<FlagspaceDescription> ret;
|
||||||
|
|
||||||
QJsonArray flagspacesArray = cmdj("fsj").array();
|
QJsonArray flagspacesArray = cmdj("fsj").array();
|
||||||
for (QJsonValue value : flagspacesArray) {
|
for (const QJsonValue &value : flagspacesArray) {
|
||||||
QJsonObject flagspaceObject = value.toObject();
|
QJsonObject flagspaceObject = value.toObject();
|
||||||
|
|
||||||
FlagspaceDescription flagspace;
|
FlagspaceDescription flagspace;
|
||||||
|
|
||||||
flagspace.name = flagspaceObject[RJsonKey::name].toString();
|
flagspace.name = flagspaceObject[RJsonKey::name].toString();
|
||||||
|
|
||||||
ret << flagspace;
|
ret << flagspace;
|
||||||
@ -1698,10 +1706,11 @@ QList<FlagDescription> CutterCore::getAllFlags(QString flagspace)
|
|||||||
cmd("fs *");
|
cmd("fs *");
|
||||||
|
|
||||||
QJsonArray flagsArray = cmdj("fj").array();
|
QJsonArray flagsArray = cmdj("fj").array();
|
||||||
for (QJsonValue value : flagsArray) {
|
for (const QJsonValue &value : flagsArray) {
|
||||||
QJsonObject flagObject = value.toObject();
|
QJsonObject flagObject = value.toObject();
|
||||||
|
|
||||||
FlagDescription flag;
|
FlagDescription flag;
|
||||||
|
|
||||||
flag.offset = flagObject[RJsonKey::offset].toVariant().toULongLong();
|
flag.offset = flagObject[RJsonKey::offset].toVariant().toULongLong();
|
||||||
flag.size = flagObject[RJsonKey::size].toVariant().toULongLong();
|
flag.size = flagObject[RJsonKey::size].toVariant().toULongLong();
|
||||||
flag.name = flagObject[RJsonKey::name].toString();
|
flag.name = flagObject[RJsonKey::name].toString();
|
||||||
@ -1720,7 +1729,7 @@ QList<SectionDescription> CutterCore::getAllSections()
|
|||||||
QJsonObject sectionsObj = sectionsDoc.object();
|
QJsonObject sectionsObj = sectionsDoc.object();
|
||||||
QJsonArray sectionsArray = sectionsObj[RJsonKey::sections].toArray();
|
QJsonArray sectionsArray = sectionsObj[RJsonKey::sections].toArray();
|
||||||
|
|
||||||
for (QJsonValue value : sectionsArray) {
|
for (const QJsonValue &value : sectionsArray) {
|
||||||
QJsonObject sectionObject = value.toObject();
|
QJsonObject sectionObject = value.toObject();
|
||||||
|
|
||||||
QString name = sectionObject[RJsonKey::name].toString();
|
QString name = sectionObject[RJsonKey::name].toString();
|
||||||
@ -1747,7 +1756,7 @@ QStringList CutterCore::getSectionList()
|
|||||||
QStringList ret;
|
QStringList ret;
|
||||||
|
|
||||||
QJsonArray sectionsArray = cmdj("iSj").array();
|
QJsonArray sectionsArray = cmdj("iSj").array();
|
||||||
for (QJsonValue value : sectionsArray) {
|
for (const QJsonValue &value : sectionsArray) {
|
||||||
ret << value.toObject()[RJsonKey::name].toString();
|
ret << value.toObject()[RJsonKey::name].toString();
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -1760,7 +1769,7 @@ QList<SegmentDescription> CutterCore::getAllSegments()
|
|||||||
|
|
||||||
QJsonArray segments = cmdj("iSSj").array();
|
QJsonArray segments = cmdj("iSSj").array();
|
||||||
|
|
||||||
for (QJsonValue value : segments) {
|
for (const QJsonValue &value : segments) {
|
||||||
QJsonObject segmentObject = value.toObject();
|
QJsonObject segmentObject = value.toObject();
|
||||||
|
|
||||||
QString name = segmentObject[RJsonKey::name].toString();
|
QString name = segmentObject[RJsonKey::name].toString();
|
||||||
@ -1786,10 +1795,11 @@ QList<EntrypointDescription> CutterCore::getAllEntrypoint()
|
|||||||
QList<EntrypointDescription> ret;
|
QList<EntrypointDescription> ret;
|
||||||
|
|
||||||
QJsonArray entrypointsArray = cmdj("iej").array();
|
QJsonArray entrypointsArray = cmdj("iej").array();
|
||||||
for (QJsonValue value : entrypointsArray) {
|
for (const QJsonValue &value : entrypointsArray) {
|
||||||
QJsonObject entrypointObject = value.toObject();
|
QJsonObject entrypointObject = value.toObject();
|
||||||
|
|
||||||
EntrypointDescription entrypoint;
|
EntrypointDescription entrypoint;
|
||||||
|
|
||||||
entrypoint.vaddr = entrypointObject[RJsonKey::vaddr].toVariant().toULongLong();
|
entrypoint.vaddr = entrypointObject[RJsonKey::vaddr].toVariant().toULongLong();
|
||||||
entrypoint.paddr = entrypointObject[RJsonKey::paddr].toVariant().toULongLong();
|
entrypoint.paddr = entrypointObject[RJsonKey::paddr].toVariant().toULongLong();
|
||||||
entrypoint.baddr = entrypointObject[RJsonKey::baddr].toVariant().toULongLong();
|
entrypoint.baddr = entrypointObject[RJsonKey::baddr].toVariant().toULongLong();
|
||||||
@ -1808,29 +1818,34 @@ QList<ClassDescription> CutterCore::getAllClassesFromBin()
|
|||||||
QList<ClassDescription> ret;
|
QList<ClassDescription> ret;
|
||||||
|
|
||||||
QJsonArray classesArray = cmdj("icj").array();
|
QJsonArray classesArray = cmdj("icj").array();
|
||||||
for (QJsonValueRef value : classesArray) {
|
for (const QJsonValue &value : classesArray) {
|
||||||
QJsonObject classObject = value.toObject();
|
QJsonObject classObject = value.toObject();
|
||||||
|
|
||||||
ClassDescription cls;
|
ClassDescription cls;
|
||||||
|
|
||||||
cls.name = classObject[RJsonKey::classname].toString();
|
cls.name = classObject[RJsonKey::classname].toString();
|
||||||
cls.addr = classObject[RJsonKey::addr].toVariant().toULongLong();
|
cls.addr = classObject[RJsonKey::addr].toVariant().toULongLong();
|
||||||
cls.index = classObject[RJsonKey::index].toVariant().toULongLong();
|
cls.index = classObject[RJsonKey::index].toVariant().toULongLong();
|
||||||
|
|
||||||
for (QJsonValueRef value2 : classObject[RJsonKey::methods].toArray()) {
|
for (const QJsonValue &value2 : classObject[RJsonKey::methods].toArray()) {
|
||||||
QJsonObject methObject = value2.toObject();
|
QJsonObject methObject = value2.toObject();
|
||||||
|
|
||||||
ClassMethodDescription meth;
|
ClassMethodDescription meth;
|
||||||
|
|
||||||
meth.name = methObject[RJsonKey::name].toString();
|
meth.name = methObject[RJsonKey::name].toString();
|
||||||
meth.addr = methObject[RJsonKey::addr].toVariant().toULongLong();
|
meth.addr = methObject[RJsonKey::addr].toVariant().toULongLong();
|
||||||
|
|
||||||
cls.methods << meth;
|
cls.methods << meth;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (QJsonValueRef value2 : classObject[RJsonKey::fields].toArray()) {
|
for (const QJsonValue &value2 : classObject[RJsonKey::fields].toArray()) {
|
||||||
QJsonObject fieldObject = value2.toObject();
|
QJsonObject fieldObject = value2.toObject();
|
||||||
|
|
||||||
ClassFieldDescription field;
|
ClassFieldDescription field;
|
||||||
|
|
||||||
field.name = fieldObject[RJsonKey::name].toString();
|
field.name = fieldObject[RJsonKey::name].toString();
|
||||||
field.addr = fieldObject[RJsonKey::addr].toVariant().toULongLong();
|
field.addr = fieldObject[RJsonKey::addr].toVariant().toULongLong();
|
||||||
|
|
||||||
cls.fields << field;
|
cls.fields << field;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1851,8 +1866,9 @@ QList<ClassDescription> CutterCore::getAllClassesFromFlags()
|
|||||||
QMap<QString, ClassDescription *> classesCache;
|
QMap<QString, ClassDescription *> classesCache;
|
||||||
|
|
||||||
QJsonArray flagsArray = cmdj("fj@F:classes").array();
|
QJsonArray flagsArray = cmdj("fj@F:classes").array();
|
||||||
for (QJsonValueRef value : flagsArray) {
|
for (const QJsonValue &value : flagsArray) {
|
||||||
QJsonObject flagObject = value.toObject();
|
QJsonObject flagObject = value.toObject();
|
||||||
|
|
||||||
QString flagName = flagObject[RJsonKey::name].toString();
|
QString flagName = flagObject[RJsonKey::name].toString();
|
||||||
|
|
||||||
QRegularExpressionMatch match = classFlagRegExp.match(flagName);
|
QRegularExpressionMatch match = classFlagRegExp.match(flagName);
|
||||||
@ -1908,10 +1924,11 @@ QList<ResourcesDescription> CutterCore::getAllResources()
|
|||||||
QList<ResourcesDescription> ret;
|
QList<ResourcesDescription> ret;
|
||||||
|
|
||||||
QJsonArray resourcesArray = cmdj("iRj").array();
|
QJsonArray resourcesArray = cmdj("iRj").array();
|
||||||
for (QJsonValueRef value : resourcesArray) {
|
for (const QJsonValue &value : resourcesArray) {
|
||||||
QJsonObject resourceObject = value.toObject();
|
QJsonObject resourceObject = value.toObject();
|
||||||
|
|
||||||
ResourcesDescription res;
|
ResourcesDescription res;
|
||||||
|
|
||||||
res.name = resourceObject[RJsonKey::name].toInt();
|
res.name = resourceObject[RJsonKey::name].toInt();
|
||||||
res.vaddr = resourceObject[RJsonKey::vaddr].toVariant().toULongLong();
|
res.vaddr = resourceObject[RJsonKey::vaddr].toVariant().toULongLong();
|
||||||
res.index = resourceObject[RJsonKey::index].toVariant().toULongLong();
|
res.index = resourceObject[RJsonKey::index].toVariant().toULongLong();
|
||||||
@ -1930,17 +1947,19 @@ QList<VTableDescription> CutterCore::getAllVTables()
|
|||||||
QList<VTableDescription> ret;
|
QList<VTableDescription> ret;
|
||||||
|
|
||||||
QJsonArray vTablesArray = cmdj("avj").array();
|
QJsonArray vTablesArray = cmdj("avj").array();
|
||||||
for (QJsonValueRef vTableValue : vTablesArray) {
|
for (const QJsonValue &vTableValue : vTablesArray) {
|
||||||
QJsonObject vTableObject = vTableValue.toObject();
|
QJsonObject vTableObject = vTableValue.toObject();
|
||||||
|
|
||||||
VTableDescription res;
|
VTableDescription res;
|
||||||
|
|
||||||
res.addr = vTableObject[RJsonKey::offset].toVariant().toULongLong();
|
res.addr = vTableObject[RJsonKey::offset].toVariant().toULongLong();
|
||||||
QJsonArray methodArray = vTableObject[RJsonKey::methods].toArray();
|
QJsonArray methodArray = vTableObject[RJsonKey::methods].toArray();
|
||||||
|
|
||||||
for (QJsonValueRef methodValue : methodArray) {
|
for (const QJsonValue &methodValue : methodArray) {
|
||||||
QJsonObject methodObject = methodValue.toObject();
|
QJsonObject methodObject = methodValue.toObject();
|
||||||
|
|
||||||
ClassMethodDescription method;
|
ClassMethodDescription method;
|
||||||
|
|
||||||
method.addr = methodObject[RJsonKey::offset].toVariant().toULongLong();
|
method.addr = methodObject[RJsonKey::offset].toVariant().toULongLong();
|
||||||
method.name = methodObject[RJsonKey::name].toString();
|
method.name = methodObject[RJsonKey::name].toString();
|
||||||
|
|
||||||
@ -1959,7 +1978,7 @@ QList<TypeDescription> CutterCore::getAllTypes()
|
|||||||
|
|
||||||
QJsonArray typesArray = cmdj("tj").array();
|
QJsonArray typesArray = cmdj("tj").array();
|
||||||
|
|
||||||
for (QJsonValue value : typesArray) {
|
for (const QJsonValue &value : typesArray) {
|
||||||
QJsonObject typeObject = value.toObject();
|
QJsonObject typeObject = value.toObject();
|
||||||
|
|
||||||
TypeDescription exp;
|
TypeDescription exp;
|
||||||
@ -1982,11 +2001,13 @@ QList<SearchDescription> CutterCore::getAllSearch(QString search_for, QString sp
|
|||||||
QJsonArray searchArray = cmdj(space + QString(" ") + search_for).array();
|
QJsonArray searchArray = cmdj(space + QString(" ") + search_for).array();
|
||||||
|
|
||||||
if (space == "/Rj") {
|
if (space == "/Rj") {
|
||||||
for (QJsonValue value : searchArray) {
|
for (const QJsonValue &value : searchArray) {
|
||||||
QJsonObject searchObject = value.toObject();
|
QJsonObject searchObject = value.toObject();
|
||||||
|
|
||||||
SearchDescription exp;
|
SearchDescription exp;
|
||||||
|
|
||||||
exp.code = QString("");
|
exp.code = QString("");
|
||||||
for (QJsonValue value2 : searchObject[RJsonKey::opcodes].toArray()) {
|
for (const QJsonValue &value2 : searchObject[RJsonKey::opcodes].toArray()) {
|
||||||
QJsonObject gadget = value2.toObject();
|
QJsonObject gadget = value2.toObject();
|
||||||
exp.code += gadget[RJsonKey::opcode].toString() + "; ";
|
exp.code += gadget[RJsonKey::opcode].toString() + "; ";
|
||||||
}
|
}
|
||||||
@ -1998,8 +2019,9 @@ QList<SearchDescription> CutterCore::getAllSearch(QString search_for, QString sp
|
|||||||
ret << exp;
|
ret << exp;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (QJsonValue value : searchArray) {
|
for (const QJsonValue &value : searchArray) {
|
||||||
QJsonObject searchObject = value.toObject();
|
QJsonObject searchObject = value.toObject();
|
||||||
|
|
||||||
SearchDescription exp;
|
SearchDescription exp;
|
||||||
|
|
||||||
exp.offset = searchObject[RJsonKey::offset].toVariant().toULongLong();
|
exp.offset = searchObject[RJsonKey::offset].toVariant().toULongLong();
|
||||||
@ -2031,7 +2053,9 @@ BlockStatistics CutterCore::getBlockStatistics(unsigned int blocksCount)
|
|||||||
|
|
||||||
for (const QJsonValue &value : blocksArray) {
|
for (const QJsonValue &value : blocksArray) {
|
||||||
QJsonObject blockObj = value.toObject();
|
QJsonObject blockObj = value.toObject();
|
||||||
|
|
||||||
BlockDescription block;
|
BlockDescription block;
|
||||||
|
|
||||||
block.addr = blockObj[RJsonKey::offset].toVariant().toULongLong();
|
block.addr = blockObj[RJsonKey::offset].toVariant().toULongLong();
|
||||||
block.size = blockObj[RJsonKey::size].toVariant().toULongLong();
|
block.size = blockObj[RJsonKey::size].toVariant().toULongLong();
|
||||||
block.flags = blockObj[RJsonKey::flags].toInt(0);
|
block.flags = blockObj[RJsonKey::flags].toInt(0);
|
||||||
@ -2074,10 +2098,11 @@ QList<XrefDescription> CutterCore::getXRefs(RVA addr, bool to, bool whole_functi
|
|||||||
xrefsArray = cmdj("axfj@" + QString::number(addr)).array();
|
xrefsArray = cmdj("axfj@" + QString::number(addr)).array();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (QJsonValue value : xrefsArray) {
|
for (const QJsonValue &value : xrefsArray) {
|
||||||
QJsonObject xrefObject = value.toObject();
|
QJsonObject xrefObject = value.toObject();
|
||||||
|
|
||||||
XrefDescription xref;
|
XrefDescription xref;
|
||||||
|
|
||||||
xref.type = xrefObject[RJsonKey::type].toString();
|
xref.type = xrefObject[RJsonKey::type].toString();
|
||||||
|
|
||||||
if (!filterType.isNull() && filterType != xref.type)
|
if (!filterType.isNull() && filterType != xref.type)
|
||||||
@ -2151,7 +2176,7 @@ void CutterCore::saveProject(const QString &name)
|
|||||||
{
|
{
|
||||||
const QString &rv = cmd("Ps " + name.trimmed()).trimmed();
|
const QString &rv = cmd("Ps " + name.trimmed()).trimmed();
|
||||||
const bool ok = rv == name.trimmed();
|
const bool ok = rv == name.trimmed();
|
||||||
cmd("Pnj " + notes.toUtf8().toBase64());
|
cmd(QString("Pnj ") + notes.toUtf8().toBase64());
|
||||||
emit projectSaved(ok, name);
|
emit projectSaved(ok, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2173,10 +2198,11 @@ QList<DisassemblyLine> CutterCore::disassembleLines(RVA offset, int lines)
|
|||||||
offset)).array();
|
offset)).array();
|
||||||
QList<DisassemblyLine> r;
|
QList<DisassemblyLine> r;
|
||||||
|
|
||||||
for (QJsonValue value : array) {
|
for (const QJsonValue &value : array) {
|
||||||
QJsonObject object = value.toObject();
|
QJsonObject object = value.toObject();
|
||||||
|
|
||||||
DisassemblyLine line;
|
DisassemblyLine line;
|
||||||
|
|
||||||
line.offset = object[RJsonKey::offset].toVariant().toULongLong();
|
line.offset = object[RJsonKey::offset].toVariant().toULongLong();
|
||||||
line.text = object[RJsonKey::text].toString();
|
line.text = object[RJsonKey::text].toString();
|
||||||
|
|
||||||
@ -2245,7 +2271,7 @@ QList<QString> CutterCore::getColorThemes()
|
|||||||
{
|
{
|
||||||
QList<QString> r;
|
QList<QString> r;
|
||||||
QJsonDocument themes = cmdj("ecoj");
|
QJsonDocument themes = cmdj("ecoj");
|
||||||
for (auto s : themes.array()) {
|
for (const QJsonValue &s : themes.array()) {
|
||||||
r << s.toString();
|
r << s.toString();
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
|
55
src/Cutter.h
55
src/Cutter.h
@ -18,7 +18,7 @@
|
|||||||
#include <QErrorMessage>
|
#include <QErrorMessage>
|
||||||
|
|
||||||
#define CutterRListForeach(list, it, type, x) \
|
#define CutterRListForeach(list, it, type, x) \
|
||||||
if (list) for (it = list->head; it && ((x=(type*)it->data)); it = it->n)
|
if (list) for (it = list->head; it && ((x=static_cast<type*>(it->data))); it = it->n)
|
||||||
|
|
||||||
#define APPNAME "Cutter"
|
#define APPNAME "Cutter"
|
||||||
|
|
||||||
@ -382,21 +382,24 @@ public:
|
|||||||
|
|
||||||
/* Core functions (commands) */
|
/* Core functions (commands) */
|
||||||
static QString sanitizeStringForCommand(QString s);
|
static QString sanitizeStringForCommand(QString s);
|
||||||
QString cmd(const QString &str);
|
QString cmd(const char *str);
|
||||||
|
QString cmd(const QString &str) { return cmd(str.toUtf8().constData()); }
|
||||||
QString cmdRaw(const QString &str);
|
QString cmdRaw(const QString &str);
|
||||||
QJsonDocument cmdj(const QString &str);
|
QJsonDocument cmdj(const char *str);
|
||||||
QStringList cmdList(const QString &str)
|
QJsonDocument cmdj(const QString &str) { return cmdj(str.toUtf8().constData()); }
|
||||||
{
|
QStringList cmdList(const char *str) { return cmd(str).split('\n', QString::SkipEmptyParts); }
|
||||||
auto l = cmd(str).split("\n");
|
QStringList cmdList(const QString &str) { return cmdList(str.toUtf8().constData()); }
|
||||||
l.removeAll("");
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
QString cmdTask(const QString &str);
|
QString cmdTask(const QString &str);
|
||||||
QJsonDocument cmdjTask(const QString &str);
|
QJsonDocument cmdjTask(const QString &str);
|
||||||
void cmdEsil(QString command);
|
void cmdEsil(const char *command);
|
||||||
|
void cmdEsil(const QString &command) { cmdEsil(command.toUtf8().constData()); }
|
||||||
QString getVersionInformation();
|
QString getVersionInformation();
|
||||||
|
|
||||||
QJsonDocument parseJson(const char *res, const QString &cmd = QString());
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
/* Functions methods */
|
/* Functions methods */
|
||||||
void renameFunction(const QString &oldName, const QString &newName);
|
void renameFunction(const QString &oldName, const QString &newName);
|
||||||
@ -436,7 +439,7 @@ public:
|
|||||||
|
|
||||||
/* File related methods */
|
/* File related methods */
|
||||||
bool loadFile(QString path, ut64 baddr = 0LL, ut64 mapaddr = 0LL, int perms = R_PERM_R,
|
bool loadFile(QString path, ut64 baddr = 0LL, ut64 mapaddr = 0LL, int perms = R_PERM_R,
|
||||||
int va = 0, bool loadbin = false, const QString &forceBinPlugin = nullptr);
|
int va = 0, bool loadbin = false, const QString &forceBinPlugin = QString());
|
||||||
bool tryFile(QString path, bool rw);
|
bool tryFile(QString path, bool rw);
|
||||||
void openFile(QString path, RVA mapaddr);
|
void openFile(QString path, RVA mapaddr);
|
||||||
void loadScript(const QString &scriptname);
|
void loadScript(const QString &scriptname);
|
||||||
@ -471,14 +474,20 @@ public:
|
|||||||
ut64 math(const QString &expr);
|
ut64 math(const QString &expr);
|
||||||
|
|
||||||
/* Config functions */
|
/* Config functions */
|
||||||
void setConfig(const QString &k, const QString &v);
|
void setConfig(const char *k, const QString &v);
|
||||||
void setConfig(const QString &k, int v);
|
void setConfig(const QString &k, const QString &v) { setConfig(k.toUtf8().constData(), v); }
|
||||||
void setConfig(const QString &k, bool v);
|
void setConfig(const char *k, int v);
|
||||||
void setConfig(const QString &k, const char *v) { setConfig(k, QString(v)); }
|
void setConfig(const QString &k, int v) { setConfig(k.toUtf8().constData(), v); }
|
||||||
void setConfig(const QString &k, const QVariant &v);
|
void setConfig(const char *k, bool v);
|
||||||
int getConfigi(const QString &k);
|
void setConfig(const QString &k, bool v) { setConfig(k.toUtf8().constData(), v); }
|
||||||
bool getConfigb(const QString &k);
|
void setConfig(const char *k, const QVariant &v);
|
||||||
QString getConfig(const QString &k);
|
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()); }
|
||||||
|
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()); }
|
||||||
QList<QString> getColorThemes();
|
QList<QString> getColorThemes();
|
||||||
|
|
||||||
/* Assembly related methods */
|
/* Assembly related methods */
|
||||||
@ -521,7 +530,7 @@ public:
|
|||||||
void delAllBreakpoints();
|
void delAllBreakpoints();
|
||||||
void enableBreakpoint(RVA addr);
|
void enableBreakpoint(RVA addr);
|
||||||
void disableBreakpoint(RVA addr);
|
void disableBreakpoint(RVA addr);
|
||||||
bool isBreakpoint(QList<RVA> breakpoints, RVA addr);
|
bool isBreakpoint(const QList<RVA> &breakpoints, RVA addr);
|
||||||
QList<RVA> getBreakpointsAddresses();
|
QList<RVA> getBreakpointsAddresses();
|
||||||
QString getActiveDebugPlugin();
|
QString getActiveDebugPlugin();
|
||||||
QStringList getDebugPlugins();
|
QStringList getDebugPlugins();
|
||||||
@ -565,7 +574,7 @@ public:
|
|||||||
static bool isProjectNameValid(const QString &name);
|
static bool isProjectNameValid(const QString &name);
|
||||||
|
|
||||||
/* Widgets */
|
/* Widgets */
|
||||||
QList<RBinPluginDescription> getRBinPluginDescriptions(const QString &type = nullptr);
|
QList<RBinPluginDescription> getRBinPluginDescriptions(const QString &type = QString());
|
||||||
QList<RIOPluginDescription> getRIOPluginDescriptions();
|
QList<RIOPluginDescription> getRIOPluginDescriptions();
|
||||||
QList<RCorePluginDescription> getRCorePluginDescriptions();
|
QList<RCorePluginDescription> getRCorePluginDescriptions();
|
||||||
QList<RAsmPluginDescription> getRAsmPluginDescriptions();
|
QList<RAsmPluginDescription> getRAsmPluginDescriptions();
|
||||||
@ -579,7 +588,7 @@ public:
|
|||||||
QList<RelocDescription> getAllRelocs();
|
QList<RelocDescription> getAllRelocs();
|
||||||
QList<StringDescription> getAllStrings();
|
QList<StringDescription> getAllStrings();
|
||||||
QList<FlagspaceDescription> getAllFlagspaces();
|
QList<FlagspaceDescription> getAllFlagspaces();
|
||||||
QList<FlagDescription> getAllFlags(QString flagspace = NULL);
|
QList<FlagDescription> getAllFlags(QString flagspace = QString());
|
||||||
QList<SectionDescription> getAllSections();
|
QList<SectionDescription> getAllSections();
|
||||||
QList<SegmentDescription> getAllSegments();
|
QList<SegmentDescription> getAllSegments();
|
||||||
QList<EntrypointDescription> getAllEntrypoint();
|
QList<EntrypointDescription> getAllEntrypoint();
|
||||||
|
@ -42,7 +42,7 @@ CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc
|
|||||||
|
|
||||||
QString langPrefix;
|
QString langPrefix;
|
||||||
if (language != "en") {
|
if (language != "en") {
|
||||||
for (auto &it : allLocales) {
|
for (const QLocale &it : allLocales) {
|
||||||
langPrefix = it.bcp47Name();
|
langPrefix = it.bcp47Name();
|
||||||
if (langPrefix == language) {
|
if (langPrefix == language) {
|
||||||
const QString &cutterTranslationPath = QCoreApplication::applicationDirPath() + QDir::separator()
|
const QString &cutterTranslationPath = QCoreApplication::applicationDirPath() + QDir::separator()
|
||||||
|
@ -39,7 +39,7 @@ ColorSchemeFileSaver::ColorSchemeFileSaver(QObject *parent) : QObject (parent)
|
|||||||
dirs.removeOne(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation));
|
dirs.removeOne(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation));
|
||||||
standardR2ThemesLocationPath = "";
|
standardR2ThemesLocationPath = "";
|
||||||
|
|
||||||
for (auto &it : dirs) {
|
for (const QString &it : dirs) {
|
||||||
currDir = QDir(it).filePath("radare2");
|
currDir = QDir(it).filePath("radare2");
|
||||||
if (currDir.exists()) {
|
if (currDir.exists()) {
|
||||||
break;
|
break;
|
||||||
@ -90,7 +90,7 @@ QFile::FileError ColorSchemeFileSaver::copy(const QString &srcThemeName,
|
|||||||
Core()->cmd(QString("eco %1").arg(theme));
|
Core()->cmd(QString("eco %1").arg(theme));
|
||||||
QColor back = Config()->getColor(standardBackgroundOptionName);
|
QColor back = Config()->getColor(standardBackgroundOptionName);
|
||||||
_obj[standardBackgroundOptionName] = QJsonArray({back.red(), back.green(), back.blue()});
|
_obj[standardBackgroundOptionName] = QJsonArray({back.red(), back.green(), back.blue()});
|
||||||
for (auto &it : _obj.keys()) {
|
for (const QString &it : _obj.keys()) {
|
||||||
QJsonArray rgb = _obj[it].toArray();
|
QJsonArray rgb = _obj[it].toArray();
|
||||||
if (rgb.size() != 3) {
|
if (rgb.size() != 3) {
|
||||||
continue;
|
continue;
|
||||||
@ -103,7 +103,7 @@ QFile::FileError ColorSchemeFileSaver::copy(const QString &srcThemeName,
|
|||||||
}
|
}
|
||||||
|
|
||||||
QStringList tmp;
|
QStringList tmp;
|
||||||
for (auto &it : src) {
|
for (const QString &it : src) {
|
||||||
if (it.isEmpty()) {
|
if (it.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -117,7 +117,7 @@ QFile::FileError ColorSchemeFileSaver::copy(const QString &srcThemeName,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &it : options) {
|
for (const QString &it : options) {
|
||||||
if (cutterSpecificOptions.contains(it)) {
|
if (cutterSpecificOptions.contains(it)) {
|
||||||
fOut.write("#~");
|
fOut.write("#~");
|
||||||
} else {
|
} else {
|
||||||
@ -146,7 +146,7 @@ QFile::FileError ColorSchemeFileSaver::save(const QString &scheme, const QString
|
|||||||
|
|
||||||
bool ColorSchemeFileSaver::isCustomScheme(const QString &schemeName) const
|
bool ColorSchemeFileSaver::isCustomScheme(const QString &schemeName) const
|
||||||
{
|
{
|
||||||
for (auto &it : QDir(customR2ThemesLocationPath).entryInfoList())
|
for (const QFileInfo &it : QDir(customR2ThemesLocationPath).entryInfoList())
|
||||||
if (it.fileName() == schemeName)
|
if (it.fileName() == schemeName)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
@ -166,7 +166,7 @@ QMap<QString, QColor> ColorSchemeFileSaver::getCutterSpecific() const
|
|||||||
|
|
||||||
QMap<QString, QColor> ret;
|
QMap<QString, QColor> ret;
|
||||||
QStringList data = QString(f.readAll()).split('\n');
|
QStringList data = QString(f.readAll()).split('\n');
|
||||||
for (auto &it : data) {
|
for (const QString &it : data) {
|
||||||
if (it.length() > 2 && it.left(2) == "#~") {
|
if (it.length() > 2 && it.left(2) == "#~") {
|
||||||
QStringList currLine = it.split(' ');
|
QStringList currLine = it.split(' ');
|
||||||
if (currLine.size() > 1) {
|
if (currLine.size() > 1) {
|
||||||
|
@ -322,14 +322,14 @@ void Configuration::setColorTheme(QString theme)
|
|||||||
|
|
||||||
void Configuration::resetToDefaultAsmOptions()
|
void Configuration::resetToDefaultAsmOptions()
|
||||||
{
|
{
|
||||||
for (auto it = asmOptions.begin(); it != asmOptions.end(); it++) {
|
for (auto it = asmOptions.cbegin(); it != asmOptions.cend(); it++) {
|
||||||
setConfig(it.key(), it.value());
|
setConfig(it.key(), it.value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Configuration::applySavedAsmOptions()
|
void Configuration::applySavedAsmOptions()
|
||||||
{
|
{
|
||||||
for (auto it = asmOptions.begin(); it != asmOptions.end(); it++) {
|
for (auto it = asmOptions.cbegin(); it != asmOptions.cend(); it++) {
|
||||||
Core()->setConfig(it.key(), s.value(it.key(), it.value()));
|
Core()->setConfig(it.key(), s.value(it.key(), it.value()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ JsonTreeItem *JsonTreeItem::load(const QJsonValue &value, JsonTreeItem *parent)
|
|||||||
if ( value.isObject()) {
|
if ( value.isObject()) {
|
||||||
|
|
||||||
//Get all QJsonValue childs
|
//Get all QJsonValue childs
|
||||||
for (QString key : value.toObject().keys()) {
|
for (const QString &key : value.toObject().keys()) {
|
||||||
QJsonValue v = value.toObject().value(key);
|
QJsonValue v = value.toObject().value(key);
|
||||||
JsonTreeItem *child = load(v, rootItem);
|
JsonTreeItem *child = load(v, rootItem);
|
||||||
child->setKey(key);
|
child->setKey(key);
|
||||||
@ -87,7 +87,7 @@ JsonTreeItem *JsonTreeItem::load(const QJsonValue &value, JsonTreeItem *parent)
|
|||||||
} else if ( value.isArray()) {
|
} else if ( value.isArray()) {
|
||||||
//Get all QJsonValue childs
|
//Get all QJsonValue childs
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (QJsonValue v : value.toArray()) {
|
for (const QJsonValue &v : value.toArray()) {
|
||||||
|
|
||||||
JsonTreeItem *child = load(v, rootItem);
|
JsonTreeItem *child = load(v, rootItem);
|
||||||
child->setKey(QString::number(index));
|
child->setKey(QString::number(index));
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
TempConfig::~TempConfig()
|
TempConfig::~TempConfig()
|
||||||
{
|
{
|
||||||
for (auto i = resetValues.begin(); i != resetValues.end(); i++) {
|
for (auto i = resetValues.constBegin(); i != resetValues.constEnd(); i++) {
|
||||||
switch (i.value().type()) {
|
switch (i.value().type()) {
|
||||||
case QVariant::String:
|
case QVariant::String:
|
||||||
Core()->setConfig(i.key(), i.value().toString());
|
Core()->setConfig(i.key(), i.value().toString());
|
||||||
|
@ -24,7 +24,7 @@ InitialOptionsDialog::InitialOptionsDialog(MainWindow *main):
|
|||||||
|
|
||||||
// Fill the plugins combo
|
// Fill the plugins combo
|
||||||
asm_plugins = core->getAsmPluginNames();
|
asm_plugins = core->getAsmPluginNames();
|
||||||
for (auto plugin : asm_plugins)
|
for (const auto &plugin : asm_plugins)
|
||||||
ui->archComboBox->addItem(plugin, plugin);
|
ui->archComboBox->addItem(plugin, plugin);
|
||||||
ui->archComboBox->setToolTip(core->cmd("e? asm.arch").trimmed());
|
ui->archComboBox->setToolTip(core->cmd("e? asm.arch").trimmed());
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ InitialOptionsDialog::InitialOptionsDialog(MainWindow *main):
|
|||||||
|
|
||||||
ui->entry_analbb->setToolTip(core->cmd("e? anal.bb.maxsize").trimmed());
|
ui->entry_analbb->setToolTip(core->cmd("e? anal.bb.maxsize").trimmed());
|
||||||
|
|
||||||
for (auto plugin : core->getRBinPluginDescriptions("bin"))
|
for (const auto &plugin : core->getRBinPluginDescriptions("bin"))
|
||||||
ui->formatComboBox->addItem(plugin.name, QVariant::fromValue(plugin));
|
ui->formatComboBox->addItem(plugin.name, QVariant::fromValue(plugin));
|
||||||
|
|
||||||
ui->hideFrame->setVisible(false);
|
ui->hideFrame->setVisible(false);
|
||||||
|
@ -323,7 +323,7 @@ void NewFileDialog::fillIOPluginsList()
|
|||||||
|
|
||||||
int index = 1;
|
int index = 1;
|
||||||
QList<RIOPluginDescription> ioPlugins = Core()->getRIOPluginDescriptions();
|
QList<RIOPluginDescription> ioPlugins = Core()->getRIOPluginDescriptions();
|
||||||
for (RIOPluginDescription plugin : ioPlugins) {
|
for (const RIOPluginDescription &plugin : ioPlugins) {
|
||||||
// Hide debug plugins
|
// Hide debug plugins
|
||||||
if (plugin.permissions.contains('d')) {
|
if (plugin.permissions.contains('d')) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -10,7 +10,7 @@ R2PluginsDialog::R2PluginsDialog(QWidget *parent) :
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
for (auto plugin : Core()->getRBinPluginDescriptions()) {
|
for (const auto &plugin : Core()->getRBinPluginDescriptions()) {
|
||||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||||
item->setText(0, plugin.name);
|
item->setText(0, plugin.name);
|
||||||
item->setText(1, plugin.description);
|
item->setText(1, plugin.description);
|
||||||
@ -20,7 +20,7 @@ R2PluginsDialog::R2PluginsDialog(QWidget *parent) :
|
|||||||
}
|
}
|
||||||
qhelpers::adjustColumns(ui->RBinTreeWidget, 0);
|
qhelpers::adjustColumns(ui->RBinTreeWidget, 0);
|
||||||
|
|
||||||
for (auto plugin : Core()->getRIOPluginDescriptions()) {
|
for (const auto &plugin : Core()->getRIOPluginDescriptions()) {
|
||||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||||
item->setText(0, plugin.name);
|
item->setText(0, plugin.name);
|
||||||
item->setText(1, plugin.description);
|
item->setText(1, plugin.description);
|
||||||
@ -30,7 +30,7 @@ R2PluginsDialog::R2PluginsDialog(QWidget *parent) :
|
|||||||
}
|
}
|
||||||
qhelpers::adjustColumns(ui->RIOTreeWidget, 0);
|
qhelpers::adjustColumns(ui->RIOTreeWidget, 0);
|
||||||
|
|
||||||
for (auto plugin : Core()->getRCorePluginDescriptions()) {
|
for (const auto &plugin : Core()->getRCorePluginDescriptions()) {
|
||||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||||
item->setText(0, plugin.name);
|
item->setText(0, plugin.name);
|
||||||
item->setText(1, plugin.description);
|
item->setText(1, plugin.description);
|
||||||
@ -38,7 +38,7 @@ R2PluginsDialog::R2PluginsDialog(QWidget *parent) :
|
|||||||
}
|
}
|
||||||
qhelpers::adjustColumns(ui->RCoreTreeWidget, 0);
|
qhelpers::adjustColumns(ui->RCoreTreeWidget, 0);
|
||||||
|
|
||||||
for (auto plugin : Core()->getRAsmPluginDescriptions()) {
|
for (const auto &plugin : Core()->getRAsmPluginDescriptions()) {
|
||||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||||
item->setText(0, plugin.name);
|
item->setText(0, plugin.name);
|
||||||
item->setText(1, plugin.architecture);
|
item->setText(1, plugin.architecture);
|
||||||
|
@ -75,7 +75,7 @@ void SetFunctionVarTypes::on_OkPressed()
|
|||||||
.arg(ui->selectedTypeForVar->currentText()));
|
.arg(ui->selectedTypeForVar->currentText()));
|
||||||
|
|
||||||
Core()->cmd(QString("afvn %1 %2")
|
Core()->cmd(QString("afvn %1 %2")
|
||||||
.arg(ui->newVarName->text().replace(" ", "_"))
|
.arg(ui->newVarName->text().replace(' ', '_'))
|
||||||
.arg(ui->dropdownLocalVars->currentText()));
|
.arg(ui->dropdownLocalVars->currentText()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,29 +89,24 @@ void SetFunctionVarTypes::populateTypesComboBox()
|
|||||||
{
|
{
|
||||||
//gets all loaded types, structures and enums and puts them in a list
|
//gets all loaded types, structures and enums and puts them in a list
|
||||||
|
|
||||||
QString res;
|
|
||||||
QStringList userStructures;
|
QStringList userStructures;
|
||||||
QStringList userEnumerations;
|
QStringList userEnumerations;
|
||||||
QList<TypeDescription> primitiveTypesTypeList;
|
QList<TypeDescription> primitiveTypesTypeList;
|
||||||
|
|
||||||
res = Core()->cmd(QString("ts"));
|
userStructures = Core()->cmdList("ts");
|
||||||
userStructures = res.split("\n");
|
|
||||||
userStructures.removeAll(QString(""));
|
|
||||||
ui->selectedTypeForVar->addItems(userStructures);
|
ui->selectedTypeForVar->addItems(userStructures);
|
||||||
ui->selectedTypeForVar->insertSeparator(ui->selectedTypeForVar->count());
|
ui->selectedTypeForVar->insertSeparator(ui->selectedTypeForVar->count());
|
||||||
|
|
||||||
primitiveTypesTypeList = Core()->getAllTypes();
|
primitiveTypesTypeList = Core()->getAllTypes();
|
||||||
|
|
||||||
for (TypeDescription thisType : primitiveTypesTypeList) {
|
for (const TypeDescription &thisType : primitiveTypesTypeList) {
|
||||||
ui->selectedTypeForVar->addItem(thisType.type);
|
ui->selectedTypeForVar->addItem(thisType.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->selectedTypeForVar->insertSeparator(ui->selectedTypeForVar->count());
|
ui->selectedTypeForVar->insertSeparator(ui->selectedTypeForVar->count());
|
||||||
|
|
||||||
res = Core()->cmd(QString("te"));
|
userEnumerations = Core()->cmdList("te");
|
||||||
userStructures = res.split("\n");
|
ui->selectedTypeForVar->addItems(userEnumerations);
|
||||||
userStructures.removeAll(QString(""));
|
|
||||||
ui->selectedTypeForVar->addItems(userStructures);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ static const QHash<QString, ColorFlags> kRelevantSchemes = {
|
|||||||
{ "onedark", DarkFlag },
|
{ "onedark", DarkFlag },
|
||||||
{ "solarized", DarkFlag },
|
{ "solarized", DarkFlag },
|
||||||
{ "zenburn", DarkFlag },
|
{ "zenburn", DarkFlag },
|
||||||
{ "cutter", LightFlag },
|
{ "cutter", LightFlag },
|
||||||
{ "dark", LightFlag },
|
{ "dark", LightFlag },
|
||||||
{ "matrix", LightFlag },
|
{ "matrix", LightFlag },
|
||||||
{ "tango", LightFlag },
|
{ "tango", LightFlag },
|
||||||
@ -103,7 +103,7 @@ void AppearanceOptionsWidget::updateThemeFromConfig()
|
|||||||
for (auto &it : kCutterQtThemesList) {
|
for (auto &it : kCutterQtThemesList) {
|
||||||
ui->themeComboBox->addItem(it.name);
|
ui->themeComboBox->addItem(it.name);
|
||||||
}
|
}
|
||||||
uint curQtThemeIndex = Config()->getTheme();
|
int curQtThemeIndex = Config()->getTheme();
|
||||||
if (curQtThemeIndex >= kCutterQtThemesList.size()) {
|
if (curQtThemeIndex >= kCutterQtThemesList.size()) {
|
||||||
curQtThemeIndex = 0;
|
curQtThemeIndex = 0;
|
||||||
Config()->setTheme(curQtThemeIndex);
|
Config()->setTheme(curQtThemeIndex);
|
||||||
@ -161,7 +161,7 @@ void AppearanceOptionsWidget::on_colorComboBox_currentIndexChanged(int index)
|
|||||||
{
|
{
|
||||||
QString theme = ui->colorComboBox->itemText(index);
|
QString theme = ui->colorComboBox->itemText(index);
|
||||||
|
|
||||||
uint curQtThemeIndex = Config()->getTheme();
|
int curQtThemeIndex = Config()->getTheme();
|
||||||
if (curQtThemeIndex >= kCutterQtThemesList.size()) {
|
if (curQtThemeIndex >= kCutterQtThemesList.size()) {
|
||||||
curQtThemeIndex = 0;
|
curQtThemeIndex = 0;
|
||||||
Config()->setTheme(curQtThemeIndex);
|
Config()->setTheme(curQtThemeIndex);
|
||||||
|
@ -9,10 +9,12 @@
|
|||||||
#include "common/Helpers.h"
|
#include "common/Helpers.h"
|
||||||
#include "common/Configuration.h"
|
#include "common/Configuration.h"
|
||||||
|
|
||||||
AsmOptionsWidget::AsmOptionsWidget(PreferencesDialog */*dialog*/, QWidget *parent)
|
AsmOptionsWidget::AsmOptionsWidget(PreferencesDialog *dialog, QWidget *parent)
|
||||||
: QDialog(parent),
|
: QDialog(parent),
|
||||||
ui(new Ui::AsmOptionsWidget)
|
ui(new Ui::AsmOptionsWidget)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(dialog)
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
ui->syntaxComboBox->blockSignals(true);
|
ui->syntaxComboBox->blockSignals(true);
|
||||||
|
@ -29,7 +29,7 @@ void DebugOptionsWidget::updateDebugPlugin()
|
|||||||
SLOT(on_pluginComboBox_currentIndexChanged(const QString &)));
|
SLOT(on_pluginComboBox_currentIndexChanged(const QString &)));
|
||||||
|
|
||||||
QStringList plugins = Core()->getDebugPlugins();
|
QStringList plugins = Core()->getDebugPlugins();
|
||||||
for (QString str : plugins)
|
for (const QString &str : plugins)
|
||||||
ui->pluginComboBox->addItem(str);
|
ui->pluginComboBox->addItem(str);
|
||||||
|
|
||||||
QString plugin = Core()->getActiveDebugPlugin();
|
QString plugin = Core()->getActiveDebugPlugin();
|
||||||
|
@ -9,10 +9,12 @@
|
|||||||
#include "common/Helpers.h"
|
#include "common/Helpers.h"
|
||||||
#include "common/Configuration.h"
|
#include "common/Configuration.h"
|
||||||
|
|
||||||
GraphOptionsWidget::GraphOptionsWidget(PreferencesDialog */*dialog*/, QWidget *parent)
|
GraphOptionsWidget::GraphOptionsWidget(PreferencesDialog *dialog, QWidget *parent)
|
||||||
: QDialog(parent),
|
: QDialog(parent),
|
||||||
ui(new Ui::GraphOptionsWidget)
|
ui(new Ui::GraphOptionsWidget)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(dialog)
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
updateOptionsFromVars();
|
updateOptionsFromVars();
|
||||||
|
@ -39,7 +39,7 @@ void BacktraceWidget::setBacktraceGrid()
|
|||||||
{
|
{
|
||||||
QJsonArray backtraceValues = Core()->getBacktrace().array();
|
QJsonArray backtraceValues = Core()->getBacktrace().array();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (QJsonValueRef value : backtraceValues) {
|
for (const QJsonValue &value : backtraceValues) {
|
||||||
QJsonObject backtraceItem = value.toObject();
|
QJsonObject backtraceItem = value.toObject();
|
||||||
QString progCounter = RAddressString(backtraceItem["pc"].toVariant().toULongLong());
|
QString progCounter = RAddressString(backtraceItem["pc"].toVariant().toULongLong());
|
||||||
QString stackPointer = RAddressString(backtraceItem["sp"].toVariant().toULongLong());
|
QString stackPointer = RAddressString(backtraceItem["sp"].toVariant().toULongLong());
|
||||||
|
@ -183,8 +183,8 @@ void BreakpointWidget::addBreakpointDialog()
|
|||||||
if (dialog->exec()) {
|
if (dialog->exec()) {
|
||||||
QString bps = dialog->getBreakpoints();
|
QString bps = dialog->getBreakpoints();
|
||||||
if (!bps.isEmpty()) {
|
if (!bps.isEmpty()) {
|
||||||
QStringList bpList = bps.split(" ", QString::SkipEmptyParts);
|
QStringList bpList = bps.split(' ', QString::SkipEmptyParts);
|
||||||
for ( QString bp : bpList) {
|
for (const QString &bp : bpList) {
|
||||||
Core()->toggleBreakpoint(bp);
|
Core()->toggleBreakpoint(bp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,14 +69,17 @@ public:
|
|||||||
|
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||||
|
|
||||||
void setColor(const QString &option,
|
void setColor(const QString &option, const QColor &color);
|
||||||
const QColor &color);
|
|
||||||
|
|
||||||
QColor getBackroundColor() const;
|
QColor getBackroundColor() const;
|
||||||
|
|
||||||
QColor getTextColor() const;
|
QColor getTextColor() const;
|
||||||
|
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override { return m_data.size(); }
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override
|
||||||
|
{
|
||||||
|
Q_UNUSED(parent)
|
||||||
|
return m_data.size();
|
||||||
|
}
|
||||||
|
|
||||||
void updateScheme();
|
void updateScheme();
|
||||||
|
|
||||||
|
@ -327,7 +327,7 @@ void CommentsWidget::refreshTree()
|
|||||||
|
|
||||||
comments = Core()->getAllComments("CCu");
|
comments = Core()->getAllComments("CCu");
|
||||||
nestedComments.clear();
|
nestedComments.clear();
|
||||||
for (CommentDescription comment : comments) {
|
for (const CommentDescription &comment : comments) {
|
||||||
QString fcnName = Core()->cmdFunctionAt(comment.offset);
|
QString fcnName = Core()->cmdFunctionAt(comment.offset);
|
||||||
nestedComments[fcnName].append(comment);
|
nestedComments[fcnName].append(comment);
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ void Dashboard::updateContents()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (QString lib : lines) {
|
for (const QString &lib : lines) {
|
||||||
QLabel *label = new QLabel(this);
|
QLabel *label = new QLabel(this);
|
||||||
label->setText(lib);
|
label->setText(lib);
|
||||||
label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||||
|
@ -218,8 +218,8 @@ void DisassemblerGraphView::loadCurrentGraph()
|
|||||||
RVA entry = func["offset"].toVariant().toULongLong();
|
RVA entry = func["offset"].toVariant().toULongLong();
|
||||||
|
|
||||||
setEntry(entry);
|
setEntry(entry);
|
||||||
for (QJsonValueRef blockRef : func["blocks"].toArray()) {
|
for (const QJsonValue &value : func["blocks"].toArray()) {
|
||||||
QJsonObject block = blockRef.toObject();
|
QJsonObject block = value.toObject();
|
||||||
RVA block_entry = block["offset"].toVariant().toULongLong();
|
RVA block_entry = block["offset"].toVariant().toULongLong();
|
||||||
RVA block_size = block["size"].toVariant().toULongLong();
|
RVA block_size = block["size"].toVariant().toULongLong();
|
||||||
RVA block_fail = block["fail"].toVariant().toULongLong();
|
RVA block_fail = block["fail"].toVariant().toULongLong();
|
||||||
@ -450,7 +450,7 @@ void DisassemblerGraphView::drawBlock(QPainter &p, GraphView::GraphBlock &block)
|
|||||||
// Draw different background for selected instruction
|
// Draw different background for selected instruction
|
||||||
if (selected_instruction != RVA_INVALID) {
|
if (selected_instruction != RVA_INVALID) {
|
||||||
int y = block.y + (2 * charWidth) + (db.header_text.lines.size() * charHeight);
|
int y = block.y + (2 * charWidth) + (db.header_text.lines.size() * charHeight);
|
||||||
for (Instr &instr : db.instrs) {
|
for (const Instr &instr : db.instrs) {
|
||||||
if (instr.addr > selected_instruction) {
|
if (instr.addr > selected_instruction) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -489,7 +489,7 @@ void DisassemblerGraphView::drawBlock(QPainter &p, GraphView::GraphBlock &block)
|
|||||||
int y = block.y + (2 * charWidth) + (db.header_text.lines.size() * charHeight);
|
int y = block.y + (2 * charWidth) + (db.header_text.lines.size() * charHeight);
|
||||||
int tokenWidth = mFontMetrics->width(highlight_token->content);
|
int tokenWidth = mFontMetrics->width(highlight_token->content);
|
||||||
|
|
||||||
for (Instr &instr : db.instrs) {
|
for (const Instr &instr : db.instrs) {
|
||||||
int pos = -1;
|
int pos = -1;
|
||||||
|
|
||||||
while ((pos = instr.plainText.indexOf(highlight_token->content, pos + 1)) != -1) {
|
while ((pos = instr.plainText.indexOf(highlight_token->content, pos + 1)) != -1) {
|
||||||
@ -521,7 +521,7 @@ void DisassemblerGraphView::drawBlock(QPainter &p, GraphView::GraphBlock &block)
|
|||||||
// highlight program counter
|
// highlight program counter
|
||||||
if (PCInBlock) {
|
if (PCInBlock) {
|
||||||
int y = block.y + (2 * charWidth) + (db.header_text.lines.size() * charHeight);
|
int y = block.y + (2 * charWidth) + (db.header_text.lines.size() * charHeight);
|
||||||
for (Instr &instr : db.instrs) {
|
for (const Instr &instr : db.instrs) {
|
||||||
if (instr.addr > PCAddr) {
|
if (instr.addr > PCAddr) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -541,7 +541,7 @@ void DisassemblerGraphView::drawBlock(QPainter &p, GraphView::GraphBlock &block)
|
|||||||
RichTextPainter::paintRichText(&p, x, y, block.width, charHeight, 0, line, mFontMetrics);
|
RichTextPainter::paintRichText(&p, x, y, block.width, charHeight, 0, line, mFontMetrics);
|
||||||
y += charHeight;
|
y += charHeight;
|
||||||
}
|
}
|
||||||
for (Instr &instr : db.instrs) {
|
for (const Instr &instr : db.instrs) {
|
||||||
if (Core()->isBreakpoint(breakpoints, instr.addr)) {
|
if (Core()->isBreakpoint(breakpoints, instr.addr)) {
|
||||||
p.fillRect(QRect(block.x + charWidth, y, block.width - (10 + 2 * charWidth),
|
p.fillRect(QRect(block.x + charWidth, y, block.width - (10 + 2 * charWidth),
|
||||||
int(instr.text.lines.size()) * charHeight), ConfigColor("gui.breakpoint_background"));
|
int(instr.text.lines.size()) * charHeight), ConfigColor("gui.breakpoint_background"));
|
||||||
@ -663,7 +663,7 @@ DisassemblerGraphView::DisassemblyBlock *DisassemblerGraphView::blockForAddress(
|
|||||||
{
|
{
|
||||||
for (auto &blockIt : disassembly_blocks) {
|
for (auto &blockIt : disassembly_blocks) {
|
||||||
DisassemblyBlock &db = blockIt.second;
|
DisassemblyBlock &db = blockIt.second;
|
||||||
for (Instr i : db.instrs) {
|
for (const Instr &i : db.instrs) {
|
||||||
if (i.addr == RVA_INVALID || i.size == RVA_INVALID) {
|
if (i.addr == RVA_INVALID || i.size == RVA_INVALID) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -46,8 +46,8 @@ class DisassemblerGraphView : public GraphView
|
|||||||
QString ToQString() const
|
QString ToQString() const
|
||||||
{
|
{
|
||||||
QString result;
|
QString result;
|
||||||
for (auto &line : lines) {
|
for (const auto &line : lines) {
|
||||||
for (auto &t : line) {
|
for (const auto &t : line) {
|
||||||
result += t.text;
|
result += t.text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,7 @@ void DisassemblyWidget::refreshDisasm(RVA offset)
|
|||||||
mDisasTextEdit->document()->clear();
|
mDisasTextEdit->document()->clear();
|
||||||
QTextCursor cursor(mDisasTextEdit->document());
|
QTextCursor cursor(mDisasTextEdit->document());
|
||||||
QTextBlockFormat regular = cursor.blockFormat();
|
QTextBlockFormat regular = cursor.blockFormat();
|
||||||
for (DisassemblyLine line : disassemblyLines) {
|
for (const DisassemblyLine &line : disassemblyLines) {
|
||||||
if (line.offset < topOffset) { // overflow
|
if (line.offset < topOffset) { // overflow
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ EntrypointWidget::~EntrypointWidget() {}
|
|||||||
void EntrypointWidget::fillEntrypoint()
|
void EntrypointWidget::fillEntrypoint()
|
||||||
{
|
{
|
||||||
ui->entrypointTreeWidget->clear();
|
ui->entrypointTreeWidget->clear();
|
||||||
for (auto i : Core()->getAllEntrypoint()) {
|
for (const EntrypointDescription &i : Core()->getAllEntrypoint()) {
|
||||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||||
item->setText(0, RAddressString(i.vaddr));
|
item->setText(0, RAddressString(i.vaddr));
|
||||||
item->setText(1, i.type);
|
item->setText(1, i.type);
|
||||||
|
@ -221,7 +221,7 @@ void FlagsWidget::refreshFlagspaces()
|
|||||||
ui->flagspaceCombo->clear();
|
ui->flagspaceCombo->clear();
|
||||||
ui->flagspaceCombo->addItem(tr("(all)"));
|
ui->flagspaceCombo->addItem(tr("(all)"));
|
||||||
|
|
||||||
for (auto i : Core()->getAllFlagspaces()) {
|
for (const FlagspaceDescription &i : Core()->getAllFlagspaces()) {
|
||||||
ui->flagspaceCombo->addItem(i.name, QVariant::fromValue(i));
|
ui->flagspaceCombo->addItem(i.name, QVariant::fromValue(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,7 +250,7 @@ void FlagsWidget::refreshFlags()
|
|||||||
|
|
||||||
// TODO: this is not a very good place for the following:
|
// TODO: this is not a very good place for the following:
|
||||||
QStringList flagNames;
|
QStringList flagNames;
|
||||||
for (auto i : flags)
|
for (const FlagDescription &i : flags)
|
||||||
flagNames.append(i.name);
|
flagNames.append(i.name);
|
||||||
main->refreshOmniBar(flagNames);
|
main->refreshOmniBar(flagNames);
|
||||||
}
|
}
|
||||||
|
@ -564,7 +564,7 @@ void FunctionsWidget::refreshTree()
|
|||||||
this->functions = functions;
|
this->functions = functions;
|
||||||
|
|
||||||
importAddresses.clear();
|
importAddresses.clear();
|
||||||
for (ImportDescription import : Core()->getAllImports()) {
|
for (const ImportDescription &import : Core()->getAllImports()) {
|
||||||
importAddresses.insert(import.plt);
|
importAddresses.insert(import.plt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ void SdbDock::reload(QString _path)
|
|||||||
QList<QString> keys;
|
QList<QString> keys;
|
||||||
/* key-values */
|
/* key-values */
|
||||||
keys = Core()->sdbListKeys(path);
|
keys = Core()->sdbListKeys(path);
|
||||||
for (QString key : keys) {
|
for (const QString &key : keys) {
|
||||||
QTreeWidgetItem *tempItem = new QTreeWidgetItem();
|
QTreeWidgetItem *tempItem = new QTreeWidgetItem();
|
||||||
tempItem->setText(0, key);
|
tempItem->setText(0, key);
|
||||||
tempItem->setText(1, Core()->sdbGet(path, key));
|
tempItem->setText(1, Core()->sdbGet(path, key));
|
||||||
@ -45,7 +45,7 @@ void SdbDock::reload(QString _path)
|
|||||||
/* namespaces */
|
/* namespaces */
|
||||||
keys = Core()->sdbList(path);
|
keys = Core()->sdbList(path);
|
||||||
keys.append("..");
|
keys.append("..");
|
||||||
for (QString key : keys) {
|
for (const QString &key : keys) {
|
||||||
QTreeWidgetItem *tempItem = new QTreeWidgetItem();
|
QTreeWidgetItem *tempItem = new QTreeWidgetItem();
|
||||||
tempItem->setText(0, key + "/");
|
tempItem->setText(0, key + "/");
|
||||||
tempItem->setText(1, "");
|
tempItem->setText(1, "");
|
||||||
|
@ -184,7 +184,7 @@ void SidebarWidget::fillOffsetInfo(QString off)
|
|||||||
ui->offsetTreeWidget->clear();
|
ui->offsetTreeWidget->clear();
|
||||||
QString raw = Core()->cmd(QString("ao@") + off).trimmed();
|
QString raw = Core()->cmd(QString("ao@") + off).trimmed();
|
||||||
QList<QString> lines = raw.split("\n", QString::SkipEmptyParts);
|
QList<QString> lines = raw.split("\n", QString::SkipEmptyParts);
|
||||||
for (QString line : lines) {
|
for (const QString &line : lines) {
|
||||||
QList<QString> eles = line.split(":", QString::SkipEmptyParts);
|
QList<QString> eles = line.split(":", QString::SkipEmptyParts);
|
||||||
if (eles.length() < 2) {
|
if (eles.length() < 2) {
|
||||||
continue;
|
continue;
|
||||||
@ -225,11 +225,11 @@ void SidebarWidget::fillRegistersInfo()
|
|||||||
ui->regInfoTreeWidget->clear();
|
ui->regInfoTreeWidget->clear();
|
||||||
|
|
||||||
QJsonObject jsonRoot = Core()->getRegistersInfo().object();
|
QJsonObject jsonRoot = Core()->getRegistersInfo().object();
|
||||||
for (QString key : jsonRoot.keys()) {
|
for (const QString &key : jsonRoot.keys()) {
|
||||||
QTreeWidgetItem *tempItem = new QTreeWidgetItem();
|
QTreeWidgetItem *tempItem = new QTreeWidgetItem();
|
||||||
QString tempString;
|
QString tempString;
|
||||||
tempItem->setText(0, key.toUpper());
|
tempItem->setText(0, key.toUpper());
|
||||||
for (QJsonValue value : jsonRoot[key].toArray()) {
|
for (const QJsonValue &value : jsonRoot[key].toArray()) {
|
||||||
tempString.append(value.toString() + " ");
|
tempString.append(value.toString() + " ");
|
||||||
}
|
}
|
||||||
tempItem->setText(1, tempString);
|
tempItem->setText(1, tempString);
|
||||||
|
@ -51,7 +51,7 @@ void StackWidget::setStackGrid()
|
|||||||
{
|
{
|
||||||
QJsonArray stackValues = Core()->getStack().array();
|
QJsonArray stackValues = Core()->getStack().array();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (QJsonValueRef value : stackValues) {
|
for (const QJsonValue &value : stackValues) {
|
||||||
QJsonObject stackItem = value.toObject();
|
QJsonObject stackItem = value.toObject();
|
||||||
QString addr = RAddressString(stackItem["addr"].toVariant().toULongLong());
|
QString addr = RAddressString(stackItem["addr"].toVariant().toULongLong());
|
||||||
QString valueStack = RAddressString(stackItem["value"].toVariant().toULongLong());
|
QString valueStack = RAddressString(stackItem["value"].toVariant().toULongLong());
|
||||||
|
@ -223,7 +223,7 @@ void StringsWidget::refreshSectionCombo()
|
|||||||
combo->clear();
|
combo->clear();
|
||||||
combo->addItem(tr("(all)"));
|
combo->addItem(tr("(all)"));
|
||||||
|
|
||||||
for (QString §ion : Core()->getSectionList()) {
|
for (const QString §ion : Core()->getSectionList()) {
|
||||||
combo->addItem(section, section);
|
combo->addItem(section, section);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,7 +241,7 @@ void VisualNavbar::mouseMoveEvent(QMouseEvent *event)
|
|||||||
|
|
||||||
RVA VisualNavbar::localXToAddress(double x)
|
RVA VisualNavbar::localXToAddress(double x)
|
||||||
{
|
{
|
||||||
for (auto x2a : xToAddress) {
|
for (const XToAddress &x2a : xToAddress) {
|
||||||
if ((x2a.x_start <= x) && (x <= x2a.x_end)) {
|
if ((x2a.x_start <= x) && (x <= x2a.x_end)) {
|
||||||
double offset = (x - x2a.x_start) / (x2a.x_end - x2a.x_start);
|
double offset = (x - x2a.x_start) / (x2a.x_end - x2a.x_start);
|
||||||
double size = x2a.address_to - x2a.address_from;
|
double size = x2a.address_to - x2a.address_from;
|
||||||
@ -253,7 +253,7 @@ RVA VisualNavbar::localXToAddress(double x)
|
|||||||
|
|
||||||
double VisualNavbar::addressToLocalX(RVA address)
|
double VisualNavbar::addressToLocalX(RVA address)
|
||||||
{
|
{
|
||||||
for (auto x2a : xToAddress) {
|
for (const XToAddress &x2a : xToAddress) {
|
||||||
if ((x2a.address_from <= address) && (address < x2a.address_to)) {
|
if ((x2a.address_from <= address) && (address < x2a.address_to)) {
|
||||||
double offset = (double)(address - x2a.address_from) / (double)(x2a.address_to - x2a.address_from);
|
double offset = (double)(address - x2a.address_from) / (double)(x2a.address_to - x2a.address_from);
|
||||||
double size = x2a.x_end - x2a.x_start;
|
double size = x2a.x_end - x2a.x_start;
|
||||||
@ -267,7 +267,7 @@ QList<QString> VisualNavbar::sectionsForAddress(RVA address)
|
|||||||
{
|
{
|
||||||
QList<QString> ret;
|
QList<QString> ret;
|
||||||
QList<SectionDescription> sections = Core()->getAllSections();
|
QList<SectionDescription> sections = Core()->getAllSections();
|
||||||
for (const auto §ion : sections) {
|
for (const SectionDescription §ion : sections) {
|
||||||
if (address >= section.vaddr && address < section.vaddr + section.vsize) {
|
if (address >= section.vaddr && address < section.vaddr + section.vsize) {
|
||||||
ret << section.name;
|
ret << section.name;
|
||||||
}
|
}
|
||||||
@ -282,7 +282,7 @@ QString VisualNavbar::toolTipForAddress(RVA address)
|
|||||||
if (sections.count()) {
|
if (sections.count()) {
|
||||||
ret += "\nSections: \n";
|
ret += "\nSections: \n";
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (auto section : sections) {
|
for (const QString §ion : sections) {
|
||||||
if (!first) {
|
if (!first) {
|
||||||
ret += "\n";
|
ret += "\n";
|
||||||
} else {
|
} else {
|
||||||
|
@ -48,7 +48,7 @@ QVariant ZignaturesModel::data(const QModelIndex &index, int role) const
|
|||||||
"\n Edges: " + RSizeString(zignature.edges) +
|
"\n Edges: " + RSizeString(zignature.edges) +
|
||||||
"\n Ebbs: " + RSizeString(zignature.ebbs) +
|
"\n Ebbs: " + RSizeString(zignature.ebbs) +
|
||||||
"\n\nRefs:\n");
|
"\n\nRefs:\n");
|
||||||
for (QString ref : zignature.refs) {
|
for (const QString &ref : zignature.refs) {
|
||||||
tmp.append("\n " + ref);
|
tmp.append("\n " + ref);
|
||||||
}
|
}
|
||||||
return tmp;
|
return tmp;
|
||||||
|
Loading…
Reference in New Issue
Block a user