mirror of
https://github.com/rizinorg/cutter.git
synced 2025-02-07 07:22:15 +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 "qrcore.h"
|
||||||
#include "sdb.h"
|
#include "sdb.h"
|
||||||
|
|
||||||
|
#include <QJsonArray>
|
||||||
|
#include <QJsonObject>
|
||||||
|
|
||||||
#define DB this->db
|
#define DB this->db
|
||||||
|
|
||||||
RCoreLocked::RCoreLocked(RCore *core)
|
RCoreLocked::RCoreLocked(RCore *core)
|
||||||
@ -215,6 +218,16 @@ QString QRCore::cmd(const QString &str)
|
|||||||
return o;
|
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)
|
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);
|
QNOTUSED(loadaddr);
|
||||||
@ -453,23 +466,25 @@ QList<QString> QRCore::getList(const QString &type, const QString &subtype)
|
|||||||
}
|
}
|
||||||
else if (subtype == "imports")
|
else if (subtype == "imports")
|
||||||
{
|
{
|
||||||
|
QJsonArray importsArray = cmdj("iij").array();
|
||||||
|
|
||||||
QStringList lines = this->cmd("ii").split("\n");
|
foreach(QJsonValue value, importsArray)
|
||||||
foreach (QString line, lines)
|
|
||||||
{
|
{
|
||||||
QStringList tmp = line.split(" ");
|
QJsonObject importObject = value.toObject();
|
||||||
if (tmp.length() > 2)
|
unsigned long plt = (unsigned long)importObject["plt"].toVariant().toULongLong();
|
||||||
{
|
int ordinal = importObject["ordinal"].toInt();
|
||||||
QString final;
|
|
||||||
foreach (QString field, tmp)
|
QString final = QString("%1,%2,%3,%4,%5,").arg(
|
||||||
{
|
QString::asprintf("%#o", ordinal),
|
||||||
QString value = field.split("=")[1];
|
QString::asprintf("%#010lx", plt),
|
||||||
final.append(value + ",");
|
importObject["bind"].toString(),
|
||||||
}
|
importObject["type"].toString(),
|
||||||
|
importObject["name"].toString());
|
||||||
|
|
||||||
|
|
||||||
ret << final;
|
ret << final;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (subtype == "entrypoints")
|
else if (subtype == "entrypoints")
|
||||||
{
|
{
|
||||||
if (math("entry0") != 0)
|
if (math("entry0") != 0)
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
|
||||||
//Workaround for compile errors on Windows
|
//Workaround for compile errors on Windows
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -58,6 +59,7 @@ public:
|
|||||||
int fcnBasicBlockCount(ut64 addr);
|
int fcnBasicBlockCount(ut64 addr);
|
||||||
int fcnEndBbs(QString addr);
|
int fcnEndBbs(QString addr);
|
||||||
QString cmd(const QString &str);
|
QString cmd(const QString &str);
|
||||||
|
QJsonDocument cmdj(const QString &str);
|
||||||
void renameFunction(QString prev_name, QString new_name);
|
void renameFunction(QString prev_name, QString new_name);
|
||||||
void setComment(QString addr, QString cmt);
|
void setComment(QString addr, QString cmt);
|
||||||
void delComment(ut64 addr);
|
void delComment(ut64 addr);
|
||||||
|
Loading…
Reference in New Issue
Block a user