2018-05-01 18:53:14 +00:00
|
|
|
#include "VersionInfoDialog.h"
|
|
|
|
#include "ui_VersionInfoDialog.h"
|
|
|
|
|
2018-10-17 07:55:53 +00:00
|
|
|
#include "common/Helpers.h"
|
2018-05-01 18:53:14 +00:00
|
|
|
|
|
|
|
#include <QJsonArray>
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QJsonObject>
|
|
|
|
#include <QJsonDocument>
|
|
|
|
#include <QTreeWidget>
|
|
|
|
|
2021-01-24 14:50:13 +00:00
|
|
|
VersionInfoDialog::VersionInfoDialog(QWidget *parent)
|
|
|
|
: QDialog(parent), ui(new Ui::VersionInfoDialog), core(Core())
|
2018-05-01 18:53:14 +00:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
|
|
|
|
|
|
|
// Get version information
|
|
|
|
fillVersionInfo();
|
|
|
|
}
|
|
|
|
|
|
|
|
VersionInfoDialog::~VersionInfoDialog() {}
|
|
|
|
|
2018-09-30 20:00:53 +00:00
|
|
|
void VersionInfoDialog::fillVersionInfo()
|
|
|
|
{
|
2018-05-01 18:53:14 +00:00
|
|
|
|
2022-03-14 08:04:49 +00:00
|
|
|
CutterJson doc = Core()->getFileVersionInfo();
|
2018-05-01 18:53:14 +00:00
|
|
|
|
|
|
|
// Case ELF
|
2022-03-14 08:04:49 +00:00
|
|
|
if (doc["verneed"].valid()) {
|
|
|
|
CutterJson verneed = doc["verneed"].first();
|
|
|
|
CutterJson versym = doc["versym"].first();
|
2018-05-01 18:53:14 +00:00
|
|
|
|
|
|
|
// Set labels
|
|
|
|
ui->leftLabel->setText("Version symbols");
|
|
|
|
ui->rightLabel->setText("Version need");
|
|
|
|
|
2021-01-24 14:50:13 +00:00
|
|
|
// Left tree
|
2018-05-01 18:53:14 +00:00
|
|
|
QTreeWidgetItem *secNameItemL = new QTreeWidgetItem();
|
|
|
|
secNameItemL->setText(0, "Section name:");
|
|
|
|
secNameItemL->setText(1, versym["section_name"].toString());
|
|
|
|
ui->leftTreeWidget->addTopLevelItem(secNameItemL);
|
|
|
|
|
|
|
|
QTreeWidgetItem *addrItemL = new QTreeWidgetItem();
|
|
|
|
addrItemL->setText(0, "Address:");
|
2022-03-14 08:04:49 +00:00
|
|
|
addrItemL->setText(1, RzAddressString(versym["address"].toRVA()));
|
2018-05-01 18:53:14 +00:00
|
|
|
ui->leftTreeWidget->addTopLevelItem(addrItemL);
|
|
|
|
|
|
|
|
QTreeWidgetItem *offItemL = new QTreeWidgetItem();
|
|
|
|
offItemL->setText(0, "Offset:");
|
2022-03-14 08:04:49 +00:00
|
|
|
offItemL->setText(1, RzAddressString(versym["offset"].toRVA()));
|
2018-05-01 18:53:14 +00:00
|
|
|
ui->leftTreeWidget->addTopLevelItem(offItemL);
|
|
|
|
|
|
|
|
QTreeWidgetItem *linkItemL = new QTreeWidgetItem();
|
|
|
|
linkItemL->setText(0, "Link:");
|
2022-03-14 08:04:49 +00:00
|
|
|
linkItemL->setText(1, QString::number(versym["link"].toRVA()));
|
2018-05-01 18:53:14 +00:00
|
|
|
ui->leftTreeWidget->addTopLevelItem(linkItemL);
|
|
|
|
|
|
|
|
QTreeWidgetItem *linkNameItemL = new QTreeWidgetItem();
|
|
|
|
linkNameItemL->setText(0, "Link section name:");
|
|
|
|
linkNameItemL->setText(1, versym["link_section_name"].toString());
|
|
|
|
ui->leftTreeWidget->addTopLevelItem(linkNameItemL);
|
|
|
|
|
|
|
|
QTreeWidgetItem *entriesItemL = new QTreeWidgetItem();
|
|
|
|
entriesItemL->setText(0, "Entries:");
|
2022-03-14 08:04:49 +00:00
|
|
|
for (CutterJson obj : versym["entries"]) {
|
2018-05-01 18:53:14 +00:00
|
|
|
QTreeWidgetItem *tempItem = new QTreeWidgetItem();
|
2022-03-14 08:04:49 +00:00
|
|
|
tempItem->setText(0, RzAddressString(obj["idx"].toRVA()));
|
2018-05-01 18:53:14 +00:00
|
|
|
tempItem->setText(1, obj["value"].toString());
|
|
|
|
entriesItemL->addChild(tempItem);
|
|
|
|
}
|
|
|
|
ui->leftTreeWidget->addTopLevelItem(entriesItemL);
|
|
|
|
|
|
|
|
// Adjust columns to content
|
|
|
|
qhelpers::adjustColumns(ui->leftTreeWidget, 0);
|
|
|
|
|
|
|
|
// Right tree
|
|
|
|
QTreeWidgetItem *secNameItemR = new QTreeWidgetItem();
|
|
|
|
secNameItemR->setText(0, "Section name:");
|
|
|
|
secNameItemR->setText(1, verneed["section_name"].toString());
|
|
|
|
ui->rightTreeWidget->addTopLevelItem(secNameItemR);
|
|
|
|
|
|
|
|
QTreeWidgetItem *addrItemR = new QTreeWidgetItem();
|
|
|
|
addrItemR->setText(0, "Address:");
|
2022-03-14 08:04:49 +00:00
|
|
|
addrItemR->setText(1, RzAddressString(verneed["address"].toRVA()));
|
2018-05-01 18:53:14 +00:00
|
|
|
ui->rightTreeWidget->addTopLevelItem(addrItemR);
|
|
|
|
|
|
|
|
QTreeWidgetItem *offItemR = new QTreeWidgetItem();
|
|
|
|
offItemR->setText(0, "Offset:");
|
2022-03-14 08:04:49 +00:00
|
|
|
offItemR->setText(1, RzAddressString(verneed["offset"].toRVA()));
|
2018-05-01 18:53:14 +00:00
|
|
|
ui->rightTreeWidget->addTopLevelItem(offItemR);
|
|
|
|
|
|
|
|
QTreeWidgetItem *linkItemR = new QTreeWidgetItem();
|
|
|
|
linkItemR->setText(0, "Link:");
|
2022-03-14 08:04:49 +00:00
|
|
|
linkItemR->setText(1, QString::number(verneed["link"].toSt64()));
|
2018-05-01 18:53:14 +00:00
|
|
|
ui->rightTreeWidget->addTopLevelItem(linkItemR);
|
|
|
|
|
|
|
|
QTreeWidgetItem *linkNameItemR = new QTreeWidgetItem();
|
|
|
|
linkNameItemR->setText(0, "Link section name:");
|
|
|
|
linkNameItemR->setText(1, verneed["link_section_name"].toString());
|
|
|
|
ui->rightTreeWidget->addTopLevelItem(linkNameItemR);
|
|
|
|
|
|
|
|
QTreeWidgetItem *entriesItemR = new QTreeWidgetItem();
|
|
|
|
entriesItemR->setText(0, "Entries:");
|
2022-03-14 08:04:49 +00:00
|
|
|
for (CutterJson parentObj : verneed["entries"]) {
|
2018-05-01 18:53:14 +00:00
|
|
|
QTreeWidgetItem *parentItem = new QTreeWidgetItem();
|
|
|
|
QString parentString;
|
2022-03-14 08:04:49 +00:00
|
|
|
parentItem->setText(0, RzAddressString(parentObj["idx"].toRVA()));
|
|
|
|
parentString.append("Version: " + QString::number(parentObj["vn_version"].toSt64())
|
2021-01-24 14:50:13 +00:00
|
|
|
+ "\t");
|
2018-05-01 18:53:14 +00:00
|
|
|
parentString.append("File: " + parentObj["file_name"].toString());
|
|
|
|
parentItem->setText(1, parentString);
|
|
|
|
|
2022-03-14 08:04:49 +00:00
|
|
|
for (CutterJson childObj : parentObj["vernaux"]) {
|
2018-05-01 18:53:14 +00:00
|
|
|
QTreeWidgetItem *childItem = new QTreeWidgetItem();
|
|
|
|
QString childString;
|
2022-03-14 08:04:49 +00:00
|
|
|
childItem->setText(0, RzAddressString(childObj["idx"].toRVA()));
|
2018-05-01 18:53:14 +00:00
|
|
|
childString.append("Name: " + childObj["name"].toString() + "\t");
|
|
|
|
childString.append("Flags: " + childObj["flags"].toString() + "\t");
|
2022-03-14 08:04:49 +00:00
|
|
|
childString.append("Version: " + QString::number(childObj["version"].toSt64()));
|
2018-05-01 18:53:14 +00:00
|
|
|
childItem->setText(1, childString);
|
|
|
|
parentItem->addChild(childItem);
|
|
|
|
}
|
|
|
|
entriesItemR->addChild(parentItem);
|
|
|
|
}
|
|
|
|
ui->rightTreeWidget->addTopLevelItem(entriesItemR);
|
|
|
|
|
|
|
|
// Adjust columns to content
|
|
|
|
qhelpers::adjustColumns(ui->rightTreeWidget, 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Case PE
|
2022-03-14 08:04:49 +00:00
|
|
|
else if (doc["VS_FIXEDFILEINFO"].valid()) {
|
|
|
|
CutterJson vs = doc["VS_FIXEDFILEINFO"];
|
|
|
|
CutterJson strings = doc["StringTable"];
|
2018-05-01 18:53:14 +00:00
|
|
|
|
|
|
|
// Set labels
|
|
|
|
ui->leftLabel->setText("VS Fixed file info");
|
|
|
|
ui->rightLabel->setText("String table");
|
|
|
|
|
|
|
|
// Left tree
|
2022-03-14 08:04:49 +00:00
|
|
|
for (CutterJson property : vs) {
|
2018-05-01 18:53:14 +00:00
|
|
|
QTreeWidgetItem *tempItem = new QTreeWidgetItem();
|
2022-03-14 08:04:49 +00:00
|
|
|
tempItem->setText(0, property.key());
|
|
|
|
if (property.type() == RZ_JSON_INTEGER)
|
|
|
|
tempItem->setText(1, RzHexString(property.toRVA()));
|
2018-05-01 18:53:14 +00:00
|
|
|
else
|
2022-03-14 08:04:49 +00:00
|
|
|
tempItem->setText(1, property.toString());
|
2018-05-01 18:53:14 +00:00
|
|
|
ui->leftTreeWidget->addTopLevelItem(tempItem);
|
|
|
|
|
|
|
|
// Adjust columns to content
|
|
|
|
qhelpers::adjustColumns(ui->leftTreeWidget, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Right tree
|
2022-03-14 08:04:49 +00:00
|
|
|
for (CutterJson property : strings) {
|
2018-05-01 18:53:14 +00:00
|
|
|
QTreeWidgetItem *tempItem = new QTreeWidgetItem();
|
2022-03-14 08:04:49 +00:00
|
|
|
tempItem->setText(0, property.key());
|
|
|
|
tempItem->setText(1, property.toString());
|
2018-05-01 18:53:14 +00:00
|
|
|
ui->rightTreeWidget->addTopLevelItem(tempItem);
|
|
|
|
|
|
|
|
// Adjust columns to content
|
|
|
|
qhelpers::adjustColumns(ui->rightTreeWidget, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|