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