mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-18 19:06:10 +00:00
Add CutterCore::getBlockStatistics()
This commit is contained in:
parent
1553ac30e2
commit
1a0f307dcb
@ -1540,6 +1540,47 @@ QList<SearchDescription> CutterCore::getAllSearch(QString search_for, QString sp
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BlockStatistics CutterCore::getBlockStatistics(unsigned int blocksCount)
|
||||||
|
{
|
||||||
|
QJsonObject statsObj = cmdj("p- " + QString::number(blocksCount)).object();
|
||||||
|
|
||||||
|
BlockStatistics ret;
|
||||||
|
ret.from = statsObj["from"].toVariant().toULongLong();
|
||||||
|
ret.to = statsObj["to"].toVariant().toULongLong();
|
||||||
|
ret.blocksize = statsObj["blocksize"].toVariant().toULongLong();
|
||||||
|
|
||||||
|
QJsonArray blocksArray = statsObj["blocks"].toArray();
|
||||||
|
for (QJsonValue value : blocksArray) {
|
||||||
|
QJsonObject blockObj = value.toObject();
|
||||||
|
BlockDescription block;
|
||||||
|
block.addr = blockObj["offset"].toVariant().toULongLong();
|
||||||
|
block.size = blockObj["size"].toVariant().toULongLong();
|
||||||
|
block.flags = blockObj["flags"].toInt(0);
|
||||||
|
block.functions = blockObj["functions"].toInt(0);
|
||||||
|
block.comments = blockObj["comments"].toInt(0);
|
||||||
|
block.symbols = blockObj["symbols"].toInt(0);
|
||||||
|
block.strings = blockObj["strings"].toInt(0);
|
||||||
|
|
||||||
|
block.rwx = 0;
|
||||||
|
QString rwxStr = blockObj["rwx"].toString();
|
||||||
|
if (rwxStr.length() == 3) {
|
||||||
|
if (rwxStr[0] == 'r') {
|
||||||
|
block.rwx |= (1 << 0);
|
||||||
|
}
|
||||||
|
if (rwxStr[1] == 'w') {
|
||||||
|
block.rwx |= (1 << 1);
|
||||||
|
}
|
||||||
|
if (rwxStr[2] == 'x') {
|
||||||
|
block.rwx |= (1 << 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ret.blocks << block;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
QList<XrefDescription> CutterCore::getXRefs(RVA addr, bool to, bool whole_function,
|
QList<XrefDescription> CutterCore::getXRefs(RVA addr, bool to, bool whole_function,
|
||||||
const QString &filterType)
|
const QString &filterType)
|
||||||
{
|
{
|
||||||
|
19
src/Cutter.h
19
src/Cutter.h
@ -275,6 +275,24 @@ struct VTableDescription {
|
|||||||
QList<ClassMethodDescription> methods;
|
QList<ClassMethodDescription> methods;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct BlockDescription {
|
||||||
|
RVA addr;
|
||||||
|
RVA size;
|
||||||
|
int flags;
|
||||||
|
int functions;
|
||||||
|
int comments;
|
||||||
|
int symbols;
|
||||||
|
int strings;
|
||||||
|
ut8 rwx;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BlockStatistics {
|
||||||
|
RVA from;
|
||||||
|
RVA to;
|
||||||
|
RVA blocksize;
|
||||||
|
QList<BlockDescription> blocks;
|
||||||
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(FunctionDescription)
|
Q_DECLARE_METATYPE(FunctionDescription)
|
||||||
Q_DECLARE_METATYPE(ImportDescription)
|
Q_DECLARE_METATYPE(ImportDescription)
|
||||||
Q_DECLARE_METATYPE(ExportDescription)
|
Q_DECLARE_METATYPE(ExportDescription)
|
||||||
@ -490,6 +508,7 @@ public:
|
|||||||
QList<VTableDescription> getAllVTables();
|
QList<VTableDescription> getAllVTables();
|
||||||
QList<TypeDescription> getAllTypes();
|
QList<TypeDescription> getAllTypes();
|
||||||
QList<SearchDescription> getAllSearch(QString search_for, QString space);
|
QList<SearchDescription> getAllSearch(QString search_for, QString space);
|
||||||
|
BlockStatistics getBlockStatistics(unsigned int blocksCount);
|
||||||
|
|
||||||
QList<XrefDescription> getXRefs(RVA addr, bool to, bool whole_function,
|
QList<XrefDescription> getXRefs(RVA addr, bool to, bool whole_function,
|
||||||
const QString &filterType = QString::null);
|
const QString &filterType = QString::null);
|
||||||
|
Loading…
Reference in New Issue
Block a user