mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-18 19:06:10 +00:00
Partially refactor Dashboard to API (#2930)
Also fixes missing NX and PIC bits in Dashboard.
This commit is contained in:
parent
3fc3d8d878
commit
a630a8f5bc
@ -36,23 +36,8 @@ void Dashboard::updateContents()
|
||||
CutterJson item = docu["core"];
|
||||
CutterJson item2 = docu["bin"];
|
||||
|
||||
setPlainText(this->ui->fileEdit, item["file"].toString());
|
||||
setPlainText(this->ui->formatEdit, item["format"].toString());
|
||||
setPlainText(this->ui->modeEdit, item["mode"].toString());
|
||||
setPlainText(this->ui->typeEdit, item["type"].toString());
|
||||
setPlainText(this->ui->sizeEdit, qhelpers::formatBytecount(item["size"].toUt64()));
|
||||
setPlainText(this->ui->fdEdit, QString::number(item["fd"].toUt64()));
|
||||
|
||||
setPlainText(this->ui->archEdit, item2["arch"].toString());
|
||||
setPlainText(this->ui->langEdit, item2["lang"].toString().toUpper());
|
||||
setPlainText(this->ui->classEdit, item2["class"].toString());
|
||||
setPlainText(this->ui->machineEdit, item2["machine"].toString());
|
||||
setPlainText(this->ui->osEdit, item2["os"].toString());
|
||||
setPlainText(this->ui->subsysEdit, item2["subsys"].toString());
|
||||
setPlainText(this->ui->endianEdit, item2["endian"].toString());
|
||||
setPlainText(this->ui->compilationDateEdit, item2["compiled"].toString());
|
||||
setPlainText(this->ui->compilerEdit, item2["compiler"].toString());
|
||||
setPlainText(this->ui->bitsEdit, QString::number(item2["bits"].toUt64()));
|
||||
|
||||
if (!item2["relro"].toString().isEmpty()) {
|
||||
QString relro = item2["relro"].toString().section(QLatin1Char(' '), 0, 0);
|
||||
@ -62,21 +47,37 @@ void Dashboard::updateContents()
|
||||
setPlainText(this->ui->relroEdit, "N/A");
|
||||
}
|
||||
|
||||
setPlainText(this->ui->baddrEdit, RzAddressString(item2["baddr"].toRVA()));
|
||||
|
||||
// set booleans
|
||||
setBool(this->ui->vaEdit, item2, "va");
|
||||
setBool(this->ui->canaryEdit, item2, "canary");
|
||||
setBool(this->ui->cryptoEdit, item2, "crypto");
|
||||
setBool(this->ui->nxEdit, item2, "nx");
|
||||
setBool(this->ui->picEdit, item2, "pic");
|
||||
setBool(this->ui->staticEdit, item2, "static");
|
||||
setBool(this->ui->strippedEdit, item2, "stripped");
|
||||
setBool(this->ui->relocsEdit, item2, "relocs");
|
||||
|
||||
// Add file hashes, analysis info and libraries
|
||||
RzCoreLocked core(Core());
|
||||
RzBinFile *bf = rz_bin_cur(core->bin);
|
||||
RzBinInfo *binInfo = rz_bin_get_info(core->bin);
|
||||
|
||||
setPlainText(ui->fileEdit, binInfo ? binInfo->file : "");
|
||||
setPlainText(ui->formatEdit, binInfo ? binInfo->rclass : "");
|
||||
setPlainText(ui->typeEdit, binInfo ? binInfo->type : "");
|
||||
setPlainText(ui->archEdit, binInfo ? binInfo->arch : "");
|
||||
setPlainText(ui->langEdit, binInfo ? binInfo->lang : "");
|
||||
setPlainText(ui->classEdit, binInfo ? binInfo->bclass : "");
|
||||
setPlainText(ui->machineEdit, binInfo ? binInfo->machine : "");
|
||||
setPlainText(ui->osEdit, binInfo ? binInfo->os : "");
|
||||
setPlainText(ui->subsysEdit, binInfo ? binInfo->subsystem : "");
|
||||
setPlainText(ui->compilerEdit, binInfo ? binInfo->compiler : "");
|
||||
setPlainText(ui->bitsEdit, binInfo ? QString::number(binInfo->bits) : "");
|
||||
setPlainText(ui->baddrEdit, binInfo ? RzAddressString(rz_bin_file_get_baddr(bf)) : "");
|
||||
setPlainText(ui->sizeEdit, binInfo ? qhelpers::formatBytecount(bf->size) : "");
|
||||
setPlainText(ui->fdEdit, binInfo ? QString::number(bf->fd) : "");
|
||||
|
||||
// Setting the value of "Endianness"
|
||||
const char *endian = binInfo ? (binInfo->big_endian ? "BE" : "LE") : "";
|
||||
setPlainText(this->ui->endianEdit, endian);
|
||||
|
||||
// Setting boolean values
|
||||
setRzBinInfo(binInfo);
|
||||
|
||||
// Setting the value of "static"
|
||||
int static_value = rz_bin_is_static(core->bin);
|
||||
setPlainText(ui->staticEdit, tr(setBoolText(static_value)));
|
||||
|
||||
RzList *hashes = rz_bin_file_compute_hashes(core->bin, bf, UT64_MAX);
|
||||
|
||||
// Delete hashesWidget if it isn't null to avoid duplicate components
|
||||
@ -222,19 +223,26 @@ void Dashboard::setPlainText(QLineEdit *textBox, const QString &text)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the text of a QLineEdit as True, False or N/A if it does not exist
|
||||
* @param textBox
|
||||
* @param isTrue
|
||||
* @brief Setting boolean values of binary information in dashboard
|
||||
* @param RzBinInfo
|
||||
*/
|
||||
void Dashboard::setBool(QLineEdit *textBox, const CutterJson &jsonObject, const char *key)
|
||||
void Dashboard::setRzBinInfo(RzBinInfo *binInfo)
|
||||
{
|
||||
if (jsonObject[key].valid()) {
|
||||
if (jsonObject[key].toBool()) {
|
||||
setPlainText(textBox, tr("True"));
|
||||
} else {
|
||||
setPlainText(textBox, tr("False"));
|
||||
}
|
||||
} else {
|
||||
setPlainText(textBox, tr("N/A"));
|
||||
setPlainText(ui->vaEdit, binInfo ? setBoolText(binInfo->has_va) : "");
|
||||
setPlainText(ui->canaryEdit, binInfo ? setBoolText(binInfo->has_canary) : "");
|
||||
setPlainText(ui->cryptoEdit, binInfo ? setBoolText(binInfo->has_crypto) : "");
|
||||
setPlainText(ui->nxEdit, binInfo ? setBoolText(binInfo->has_nx) : "");
|
||||
setPlainText(ui->picEdit, binInfo ? setBoolText(binInfo->has_pi) : "");
|
||||
setPlainText(ui->strippedEdit,
|
||||
binInfo ? setBoolText(RZ_BIN_DBG_STRIPPED & binInfo->dbg_info) : "");
|
||||
setPlainText(ui->relocsEdit, binInfo ? setBoolText(RZ_BIN_DBG_RELOCS & binInfo->dbg_info) : "");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the text of a QLineEdit as True, False
|
||||
* @param boolean value
|
||||
*/
|
||||
const char *Dashboard::setBoolText(bool value)
|
||||
{
|
||||
return value ? "True" : "False";
|
||||
}
|
||||
|
@ -33,7 +33,8 @@ private slots:
|
||||
private:
|
||||
std::unique_ptr<Ui::Dashboard> ui;
|
||||
void setPlainText(QLineEdit *textBox, const QString &text);
|
||||
void setBool(QLineEdit *textBox, const CutterJson &jsonObject, const char *key);
|
||||
void setRzBinInfo(RzBinInfo *binInfo);
|
||||
const char *setBoolText(bool value);
|
||||
|
||||
QWidget *hashesWidget = nullptr;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user