mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-14 00:38:42 +00:00
Add QRCore::cmdj, Use iij to fix crash when import name contains spaces (#133)
* Fix crash when import name contains spaces * QRCore::cmdj, Get imports with iij
This commit is contained in:
parent
008962df03
commit
3ac59f02f5
@ -1,6 +1,9 @@
|
||||
#include "qrcore.h"
|
||||
#include "sdb.h"
|
||||
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
|
||||
#define DB this->db
|
||||
|
||||
RCoreLocked::RCoreLocked(RCore *core)
|
||||
@ -215,6 +218,16 @@ QString QRCore::cmd(const QString &str)
|
||||
return o;
|
||||
}
|
||||
|
||||
QJsonDocument QRCore::cmdj(const QString &str)
|
||||
{
|
||||
CORE_LOCK();
|
||||
QByteArray cmd = str.toUtf8();
|
||||
char *res = r_core_cmd_str(this->core_, cmd.constData());
|
||||
QJsonDocument doc = res ? QJsonDocument::fromJson(QByteArray(res)) : QJsonDocument();
|
||||
r_mem_free(res);
|
||||
return doc;
|
||||
}
|
||||
|
||||
bool QRCore::loadFile(QString path, uint64_t loadaddr = 0LL, uint64_t mapaddr = 0LL, bool rw = false, int va = 0, int bits = 0, int idx, bool loadbin)
|
||||
{
|
||||
QNOTUSED(loadaddr);
|
||||
@ -453,21 +466,23 @@ QList<QString> QRCore::getList(const QString &type, const QString &subtype)
|
||||
}
|
||||
else if (subtype == "imports")
|
||||
{
|
||||
QJsonArray importsArray = cmdj("iij").array();
|
||||
|
||||
QStringList lines = this->cmd("ii").split("\n");
|
||||
foreach (QString line, lines)
|
||||
foreach(QJsonValue value, importsArray)
|
||||
{
|
||||
QStringList tmp = line.split(" ");
|
||||
if (tmp.length() > 2)
|
||||
{
|
||||
QString final;
|
||||
foreach (QString field, tmp)
|
||||
{
|
||||
QString value = field.split("=")[1];
|
||||
final.append(value + ",");
|
||||
}
|
||||
ret << final;
|
||||
}
|
||||
QJsonObject importObject = value.toObject();
|
||||
unsigned long plt = (unsigned long)importObject["plt"].toVariant().toULongLong();
|
||||
int ordinal = importObject["ordinal"].toInt();
|
||||
|
||||
QString final = QString("%1,%2,%3,%4,%5,").arg(
|
||||
QString::asprintf("%#o", ordinal),
|
||||
QString::asprintf("%#010lx", plt),
|
||||
importObject["bind"].toString(),
|
||||
importObject["type"].toString(),
|
||||
importObject["name"].toString());
|
||||
|
||||
|
||||
ret << final;
|
||||
}
|
||||
}
|
||||
else if (subtype == "entrypoints")
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
#include <QMessageBox>
|
||||
#include <QJsonDocument>
|
||||
|
||||
//Workaround for compile errors on Windows
|
||||
#ifdef _WIN32
|
||||
@ -58,6 +59,7 @@ public:
|
||||
int fcnBasicBlockCount(ut64 addr);
|
||||
int fcnEndBbs(QString addr);
|
||||
QString cmd(const QString &str);
|
||||
QJsonDocument cmdj(const QString &str);
|
||||
void renameFunction(QString prev_name, QString new_name);
|
||||
void setComment(QString addr, QString cmt);
|
||||
void delComment(ut64 addr);
|
||||
|
Loading…
Reference in New Issue
Block a user