Skip to content

Commit

Permalink
Fix: 2022-11-10
Browse files Browse the repository at this point in the history
  • Loading branch information
horsicq committed Nov 10, 2022
1 parent 145f828 commit 6a5b713
Show file tree
Hide file tree
Showing 109 changed files with 6,750 additions and 15,647 deletions.
78 changes: 31 additions & 47 deletions Binary/binarywidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,22 @@

#include "ui_binarywidget.h"

BinaryWidget::BinaryWidget(QWidget *pParent)
: FormatWidget(pParent), ui(new Ui::BinaryWidget) {
BinaryWidget::BinaryWidget(QWidget *pParent) : FormatWidget(pParent), ui(new Ui::BinaryWidget) {
ui->setupUi(this);

initWidget();
}

BinaryWidget::BinaryWidget(QIODevice *pDevice, FW_DEF::OPTIONS options,
QWidget *pParent)
: BinaryWidget(pParent) {
BinaryWidget::BinaryWidget(QIODevice *pDevice, FW_DEF::OPTIONS options, QWidget *pParent) : BinaryWidget(pParent) {
ui->setupUi(this);

BinaryWidget::setData(pDevice, options, 0, 0, 0);
BinaryWidget::reload();
}

BinaryWidget::~BinaryWidget() { delete ui; }
BinaryWidget::~BinaryWidget() {
delete ui;
}

void BinaryWidget::clear() {
setTreeItem(ui->treeWidgetNavi, 0);
Expand All @@ -52,7 +51,8 @@ void BinaryWidget::clear() {
ui->treeWidgetNavi->clear();
}

void BinaryWidget::cleanup() {}
void BinaryWidget::cleanup() {
}

void BinaryWidget::reload() {
// TODO Hex
Expand All @@ -65,26 +65,16 @@ void BinaryWidget::reload() {
if (binary.isValid()) {
setFileType(binary.getFileType());

ui->treeWidgetNavi->addTopLevelItem(
createNewItem(SBINARY::TYPE_INFO, tr("Info")));
ui->treeWidgetNavi->addTopLevelItem(
createNewItem(SBINARY::TYPE_VIRUSTOTAL, "VirusTotal"));
ui->treeWidgetNavi->addTopLevelItem(
createNewItem(SBINARY::TYPE_HEX, tr("Hex")));
ui->treeWidgetNavi->addTopLevelItem(
createNewItem(SBINARY::TYPE_DISASM, tr("Disasm")));
ui->treeWidgetNavi->addTopLevelItem(
createNewItem(SBINARY::TYPE_HASH, tr("Hash")));
ui->treeWidgetNavi->addTopLevelItem(
createNewItem(SBINARY::TYPE_STRINGS, tr("Strings")));
ui->treeWidgetNavi->addTopLevelItem(
createNewItem(SBINARY::TYPE_SIGNATURES, tr("Signatures")));
ui->treeWidgetNavi->addTopLevelItem(
createNewItem(SBINARY::TYPE_MEMORYMAP, tr("Memory map")));
ui->treeWidgetNavi->addTopLevelItem(
createNewItem(SBINARY::TYPE_ENTROPY, tr("Entropy")));
ui->treeWidgetNavi->addTopLevelItem(
createNewItem(SBINARY::TYPE_HEURISTICSCAN, tr("Heuristic scan")));
ui->treeWidgetNavi->addTopLevelItem(createNewItem(SBINARY::TYPE_INFO, tr("Info")));
ui->treeWidgetNavi->addTopLevelItem(createNewItem(SBINARY::TYPE_VIRUSTOTAL, "VirusTotal"));
ui->treeWidgetNavi->addTopLevelItem(createNewItem(SBINARY::TYPE_HEX, tr("Hex")));
ui->treeWidgetNavi->addTopLevelItem(createNewItem(SBINARY::TYPE_DISASM, tr("Disasm")));
ui->treeWidgetNavi->addTopLevelItem(createNewItem(SBINARY::TYPE_HASH, tr("Hash")));
ui->treeWidgetNavi->addTopLevelItem(createNewItem(SBINARY::TYPE_STRINGS, tr("Strings")));
ui->treeWidgetNavi->addTopLevelItem(createNewItem(SBINARY::TYPE_SIGNATURES, tr("Signatures")));
ui->treeWidgetNavi->addTopLevelItem(createNewItem(SBINARY::TYPE_MEMORYMAP, tr("Memory map")));
ui->treeWidgetNavi->addTopLevelItem(createNewItem(SBINARY::TYPE_ENTROPY, tr("Entropy")));
ui->treeWidgetNavi->addTopLevelItem(createNewItem(SBINARY::TYPE_HEURISTICSCAN, tr("Heuristic scan")));

ui->treeWidgetNavi->expandAll();

Expand All @@ -94,9 +84,7 @@ void BinaryWidget::reload() {
}
}

FormatWidget::SV BinaryWidget::_setValue(QVariant vValue, int nStype,
int nNdata, int nVtype, int nPosition,
qint64 nOffset) {
FormatWidget::SV BinaryWidget::_setValue(QVariant vValue, int nStype, int nNdata, int nVtype, int nPosition, qint64 nOffset) {
Q_UNUSED(vValue)
Q_UNUSED(nStype)
Q_UNUSED(nNdata)
Expand Down Expand Up @@ -124,7 +112,9 @@ void BinaryWidget::setReadonly(bool bState) {
ui->widgetStrings->setReadonly(bState);
}

void BinaryWidget::blockSignals(bool bState) { Q_UNUSED(bState) }
void BinaryWidget::blockSignals(bool bState) {
Q_UNUSED(bState)
}

void BinaryWidget::adjustHeaderTable(int nType, QTableWidget *pTableWidget) {
Q_UNUSED(nType)
Expand Down Expand Up @@ -153,9 +143,7 @@ void BinaryWidget::_showInHexWindow(qint64 nOffset, qint64 nSize) {
}

void BinaryWidget::reloadData() {
qint32 nType = ui->treeWidgetNavi->currentItem()
->data(0, Qt::UserRole + FW_DEF::SECTION_DATA_TYPE)
.toInt();
qint32 nType = ui->treeWidgetNavi->currentItem()->data(0, Qt::UserRole + FW_DEF::SECTION_DATA_TYPE).toInt();

QString sInit = getInitString(ui->treeWidgetNavi->currentItem());

Expand All @@ -166,8 +154,7 @@ void BinaryWidget::reloadData() {
if (binary.isValid()) {
if (nType == SBINARY::TYPE_INFO) {
if (!isInitPresent(sInit)) {
ui->widgetInfo->setData(getDevice(), binary.getFileType(),
"Info", true);
ui->widgetInfo->setData(getDevice(), binary.getFileType(), "Info", true);
}
} else if (nType == SBINARY::TYPE_VIRUSTOTAL) {
if (!isInitPresent(sInit)) {
Expand Down Expand Up @@ -200,8 +187,7 @@ void BinaryWidget::reloadData() {
}
} else if (nType == SBINARY::TYPE_HASH) {
if (!isInitPresent(sInit)) {
ui->widgetHash->setData(getDevice(), binary.getFileType(), 0,
-1, true);
ui->widgetHash->setData(getDevice(), binary.getFileType(), 0, -1, true);
}
} else if (nType == SBINARY::TYPE_STRINGS) {
if (!isInitPresent(sInit)) {
Expand All @@ -220,22 +206,19 @@ void BinaryWidget::reloadData() {
SearchSignaturesWidget::OPTIONS signaturesOptions = {};
signaturesOptions.bMenu_Hex = true;

ui->widgetSignatures->setData(getDevice(), binary.getFileType(),
signaturesOptions, false);
ui->widgetSignatures->setData(getDevice(), binary.getFileType(), signaturesOptions, false);
}
} else if (nType == SBINARY::TYPE_MEMORYMAP) {
if (!isInitPresent(sInit)) {
ui->widgetMemoryMap->setData(getDevice(), binary.getFileType());
}
} else if (nType == SBINARY::TYPE_ENTROPY) {
if (!isInitPresent(sInit)) {
ui->widgetEntropy->setData(getDevice(), 0, getDevice()->size(),
binary.getFileType(), true);
ui->widgetEntropy->setData(getDevice(), 0, getDevice()->size(), binary.getFileType(), true);
}
} else if (nType == SBINARY::TYPE_HEURISTICSCAN) {
if (!isInitPresent(sInit)) {
ui->widgetHeuristicScan->setData(getDevice(), true,
binary.getFileType());
ui->widgetHeuristicScan->setData(getDevice(), true, binary.getFileType());
}
}

Expand Down Expand Up @@ -263,7 +246,9 @@ void BinaryWidget::on_pushButtonReload_clicked() {
QTimer::singleShot(1000, this, SLOT(enableButton()));
}

void BinaryWidget::enableButton() { ui->pushButtonReload->setEnabled(true); }
void BinaryWidget::enableButton() {
ui->pushButtonReload->setEnabled(true);
}

void BinaryWidget::on_toolButtonPrev_clicked() {
setAddPageEnabled(false);
Expand Down Expand Up @@ -301,8 +286,7 @@ void BinaryWidget::on_pushButtonMemoryMap_clicked() {
setTreeItem(ui->treeWidgetNavi, SBINARY::TYPE_MEMORYMAP);
}

void BinaryWidget::on_treeWidgetNavi_currentItemChanged(
QTreeWidgetItem *pItemCurrent, QTreeWidgetItem *pItemPrevious) {
void BinaryWidget::on_treeWidgetNavi_currentItemChanged(QTreeWidgetItem *pItemCurrent, QTreeWidgetItem *pItemPrevious) {
Q_UNUSED(pItemPrevious)

if (pItemCurrent) {
Expand Down
17 changes: 7 additions & 10 deletions Binary/binarywidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,17 @@ class BinaryWidget;
class BinaryWidget : public FormatWidget {
Q_OBJECT

public:
public:
BinaryWidget(QWidget *pParent = nullptr);
BinaryWidget(QIODevice *pDevice, FW_DEF::OPTIONS options,
QWidget *pParent = nullptr);
BinaryWidget(QIODevice *pDevice, FW_DEF::OPTIONS options, QWidget *pParent = nullptr);
~BinaryWidget();

virtual void clear();
virtual void cleanup();
virtual void reload();

protected:
virtual SV _setValue(QVariant vValue, int nStype, int nNdata, int nVtype,
int nPosition, qint64 nOffset);
protected:
virtual SV _setValue(QVariant vValue, int nStype, int nNdata, int nVtype, int nPosition, qint64 nOffset);
virtual void setReadonly(bool bState);
virtual void blockSignals(bool bState);
virtual void adjustHeaderTable(int nType, QTableWidget *pTableWidget);
Expand All @@ -52,7 +50,7 @@ class BinaryWidget : public FormatWidget {
virtual void _showInMemoryMapWindowOffset(qint64 nOffset);
virtual void _showInHexWindow(qint64 nOffset, qint64 nSize);

private slots:
private slots:
virtual void reloadData();
void widgetValueChanged(quint64 nValue);
void on_checkBoxReadonly_toggled(bool bChecked);
Expand All @@ -66,10 +64,9 @@ class BinaryWidget : public FormatWidget {
void on_pushButtonEntropy_clicked();
void on_pushButtonHeuristicScan_clicked();
void on_pushButtonMemoryMap_clicked();
void on_treeWidgetNavi_currentItemChanged(QTreeWidgetItem *pItemCurrent,
QTreeWidgetItem *pItemPrevious);
void on_treeWidgetNavi_currentItemChanged(QTreeWidgetItem *pItemCurrent, QTreeWidgetItem *pItemPrevious);

private:
private:
Ui::BinaryWidget *ui;
};

Expand Down
7 changes: 4 additions & 3 deletions Binary/dialogbinary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@

#include "ui_dialogbinary.h"

DialogBinary::DialogBinary(QWidget *pParent)
: XShortcutsDialog(pParent), ui(new Ui::DialogBinary) {
DialogBinary::DialogBinary(QWidget *pParent) : XShortcutsDialog(pParent), ui(new Ui::DialogBinary) {
ui->setupUi(this);

setWindowFlags(Qt::Window);
}

DialogBinary::~DialogBinary() { delete ui; }
DialogBinary::~DialogBinary() {
delete ui;
}

void DialogBinary::setData(QIODevice *pDevice, FW_DEF::OPTIONS options) {
ui->widget->setData(pDevice, options, 0, 0, 0);
Expand Down
4 changes: 2 additions & 2 deletions Binary/dialogbinary.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ class DialogBinary;
class DialogBinary : public XShortcutsDialog {
Q_OBJECT

public:
public:
explicit DialogBinary(QWidget *pParent = nullptr);
~DialogBinary();

void setData(QIODevice *pDevice, FW_DEF::OPTIONS options);
void setGlobal(XShortcuts *pShortcuts, XOptions *pXOptions);

private:
private:
Ui::DialogBinary *ui;
};

Expand Down
95 changes: 29 additions & 66 deletions DEX/dex_defs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,73 +22,38 @@

namespace N_DEX_HEADER {
const FW_DEF::HEADER_RECORD records[] = {
{magic, "magic", offsetof(XDEX_DEF::HEADER, magic), 4, "uint32 LE",
FW_DEF::VAL_TYPE_DATA},
{version, "version", offsetof(XDEX_DEF::HEADER, version), 4, "uint32 LE",
FW_DEF::VAL_TYPE_DATA},
{checksum, "checksum", offsetof(XDEX_DEF::HEADER, checksum), 4, "uint32",
FW_DEF::VAL_TYPE_DATA},
{signature, "signature", offsetof(XDEX_DEF::HEADER, signature), 20, "array",
FW_DEF::VAL_TYPE_DATA},
{file_size, "file_size", offsetof(XDEX_DEF::HEADER, file_size), 4, "uint32",
FW_DEF::VAL_TYPE_SIZE},
{header_size, "header_size", offsetof(XDEX_DEF::HEADER, header_size), 4,
"uint32", FW_DEF::VAL_TYPE_SIZE},
{endian_tag, "endian_tag", offsetof(XDEX_DEF::HEADER, endian_tag), 4,
"uint32", FW_DEF::VAL_TYPE_DATA},
{link_size, "link_size", offsetof(XDEX_DEF::HEADER, link_size), 4, "uint32",
FW_DEF::VAL_TYPE_SIZE},
{link_off, "link_off", offsetof(XDEX_DEF::HEADER, link_off), 4, "uint32",
FW_DEF::VAL_TYPE_OFFSET},
{map_off, "map_off", offsetof(XDEX_DEF::HEADER, map_off), 4, "uint32",
FW_DEF::VAL_TYPE_OFFSET},
{string_ids_size, "string_ids_size",
offsetof(XDEX_DEF::HEADER, string_ids_size), 4, "uint32",
FW_DEF::VAL_TYPE_SIZE},
{string_ids_off, "string_ids_off",
offsetof(XDEX_DEF::HEADER, string_ids_off), 4, "uint32",
FW_DEF::VAL_TYPE_OFFSET},
{type_ids_size, "type_ids_size", offsetof(XDEX_DEF::HEADER, type_ids_size),
4, "uint32", FW_DEF::VAL_TYPE_SIZE},
{type_ids_off, "type_ids_off", offsetof(XDEX_DEF::HEADER, type_ids_off), 4,
"uint32", FW_DEF::VAL_TYPE_OFFSET},
{proto_ids_size, "proto_ids_size",
offsetof(XDEX_DEF::HEADER, proto_ids_size), 4, "uint32",
FW_DEF::VAL_TYPE_SIZE},
{proto_ids_off, "proto_ids_off", offsetof(XDEX_DEF::HEADER, proto_ids_off),
4, "uint32", FW_DEF::VAL_TYPE_OFFSET},
{field_ids_size, "field_ids_size",
offsetof(XDEX_DEF::HEADER, field_ids_size), 4, "uint32",
FW_DEF::VAL_TYPE_SIZE},
{field_ids_off, "field_ids_off", offsetof(XDEX_DEF::HEADER, field_ids_off),
4, "uint32", FW_DEF::VAL_TYPE_OFFSET},
{method_ids_size, "method_ids_size",
offsetof(XDEX_DEF::HEADER, method_ids_size), 4, "uint32",
FW_DEF::VAL_TYPE_SIZE},
{method_ids_off, "method_ids_off",
offsetof(XDEX_DEF::HEADER, method_ids_off), 4, "uint32",
FW_DEF::VAL_TYPE_OFFSET},
{class_defs_size, "class_defs_size",
offsetof(XDEX_DEF::HEADER, class_defs_size), 4, "uint32",
FW_DEF::VAL_TYPE_SIZE},
{class_defs_off, "class_defs_off",
offsetof(XDEX_DEF::HEADER, class_defs_off), 4, "uint32",
FW_DEF::VAL_TYPE_OFFSET},
{data_size, "data_size", offsetof(XDEX_DEF::HEADER, data_size), 4, "uint32",
FW_DEF::VAL_TYPE_SIZE},
{data_off, "data_off", offsetof(XDEX_DEF::HEADER, data_off), 4, "uint32",
FW_DEF::VAL_TYPE_OFFSET},
{magic, "magic", offsetof(XDEX_DEF::HEADER, magic), 4, "uint32 LE", FW_DEF::VAL_TYPE_DATA},
{version, "version", offsetof(XDEX_DEF::HEADER, version), 4, "uint32 LE", FW_DEF::VAL_TYPE_DATA},
{checksum, "checksum", offsetof(XDEX_DEF::HEADER, checksum), 4, "uint32", FW_DEF::VAL_TYPE_DATA},
{signature, "signature", offsetof(XDEX_DEF::HEADER, signature), 20, "array", FW_DEF::VAL_TYPE_DATA},
{file_size, "file_size", offsetof(XDEX_DEF::HEADER, file_size), 4, "uint32", FW_DEF::VAL_TYPE_SIZE},
{header_size, "header_size", offsetof(XDEX_DEF::HEADER, header_size), 4, "uint32", FW_DEF::VAL_TYPE_SIZE},
{endian_tag, "endian_tag", offsetof(XDEX_DEF::HEADER, endian_tag), 4, "uint32", FW_DEF::VAL_TYPE_DATA},
{link_size, "link_size", offsetof(XDEX_DEF::HEADER, link_size), 4, "uint32", FW_DEF::VAL_TYPE_SIZE},
{link_off, "link_off", offsetof(XDEX_DEF::HEADER, link_off), 4, "uint32", FW_DEF::VAL_TYPE_OFFSET},
{map_off, "map_off", offsetof(XDEX_DEF::HEADER, map_off), 4, "uint32", FW_DEF::VAL_TYPE_OFFSET},
{string_ids_size, "string_ids_size", offsetof(XDEX_DEF::HEADER, string_ids_size), 4, "uint32", FW_DEF::VAL_TYPE_SIZE},
{string_ids_off, "string_ids_off", offsetof(XDEX_DEF::HEADER, string_ids_off), 4, "uint32", FW_DEF::VAL_TYPE_OFFSET},
{type_ids_size, "type_ids_size", offsetof(XDEX_DEF::HEADER, type_ids_size), 4, "uint32", FW_DEF::VAL_TYPE_SIZE},
{type_ids_off, "type_ids_off", offsetof(XDEX_DEF::HEADER, type_ids_off), 4, "uint32", FW_DEF::VAL_TYPE_OFFSET},
{proto_ids_size, "proto_ids_size", offsetof(XDEX_DEF::HEADER, proto_ids_size), 4, "uint32", FW_DEF::VAL_TYPE_SIZE},
{proto_ids_off, "proto_ids_off", offsetof(XDEX_DEF::HEADER, proto_ids_off), 4, "uint32", FW_DEF::VAL_TYPE_OFFSET},
{field_ids_size, "field_ids_size", offsetof(XDEX_DEF::HEADER, field_ids_size), 4, "uint32", FW_DEF::VAL_TYPE_SIZE},
{field_ids_off, "field_ids_off", offsetof(XDEX_DEF::HEADER, field_ids_off), 4, "uint32", FW_DEF::VAL_TYPE_OFFSET},
{method_ids_size, "method_ids_size", offsetof(XDEX_DEF::HEADER, method_ids_size), 4, "uint32", FW_DEF::VAL_TYPE_SIZE},
{method_ids_off, "method_ids_off", offsetof(XDEX_DEF::HEADER, method_ids_off), 4, "uint32", FW_DEF::VAL_TYPE_OFFSET},
{class_defs_size, "class_defs_size", offsetof(XDEX_DEF::HEADER, class_defs_size), 4, "uint32", FW_DEF::VAL_TYPE_SIZE},
{class_defs_off, "class_defs_off", offsetof(XDEX_DEF::HEADER, class_defs_off), 4, "uint32", FW_DEF::VAL_TYPE_OFFSET},
{data_size, "data_size", offsetof(XDEX_DEF::HEADER, data_size), 4, "uint32", FW_DEF::VAL_TYPE_SIZE},
{data_off, "data_off", offsetof(XDEX_DEF::HEADER, data_off), 4, "uint32", FW_DEF::VAL_TYPE_OFFSET},
};
}

namespace N_DEX_MAP_ITEM {
const FW_DEF::HEADER_RECORD records[] = {
{type, QObject::tr("Type"), offsetof(XDEX_DEF::MAP_ITEM, nType), 2,
"uint16", FW_DEF::VAL_TYPE_DATA},
{count, QObject::tr("Count"), offsetof(XDEX_DEF::MAP_ITEM, nCount), 4,
"uint32", FW_DEF::VAL_TYPE_DATA},
{offset, QObject::tr("Offset"), offsetof(XDEX_DEF::MAP_ITEM, nOffset), 4,
"uint32", FW_DEF::VAL_TYPE_OFFSET},
{type, QObject::tr("Type"), offsetof(XDEX_DEF::MAP_ITEM, nType), 2, "uint16", FW_DEF::VAL_TYPE_DATA},
{count, QObject::tr("Count"), offsetof(XDEX_DEF::MAP_ITEM, nCount), 4, "uint32", FW_DEF::VAL_TYPE_DATA},
{offset, QObject::tr("Offset"), offsetof(XDEX_DEF::MAP_ITEM, nOffset), 4, "uint32", FW_DEF::VAL_TYPE_OFFSET},
};
}

Expand Down Expand Up @@ -141,10 +106,8 @@ const FW_DEF::HEADER_RECORD records[] = {
{superclass_idx, "superclass_idx", 0, 4, "uint32", FW_DEF::VAL_TYPE_DATA},
{interfaces_off, "interfaces_off", 0, 4, "uint32", FW_DEF::VAL_TYPE_OFFSET},
{source_file_idx, "source_file_idx", 0, 4, "uint32", FW_DEF::VAL_TYPE_DATA},
{annotations_off, "annotations_off", 0, 4, "uint32",
FW_DEF::VAL_TYPE_OFFSET},
{annotations_off, "annotations_off", 0, 4, "uint32", FW_DEF::VAL_TYPE_OFFSET},
{class_data_off, "class_data_off", 0, 4, "uint32", FW_DEF::VAL_TYPE_OFFSET},
{static_values_off, "static_values_off", 0, 4, "uint32",
FW_DEF::VAL_TYPE_OFFSET},
{static_values_off, "static_values_off", 0, 4, "uint32", FW_DEF::VAL_TYPE_OFFSET},
};
}
12 changes: 1 addition & 11 deletions DEX/dex_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,7 @@ extern const FW_DEF::HEADER_RECORD records[__data_size];
} // namespace N_DEX_METHOD_ID

namespace N_DEX_CLASS_ITEM_DEF {
enum DATA {
class_idx = 0,
access_flags,
superclass_idx,
interfaces_off,
source_file_idx,
annotations_off,
class_data_off,
static_values_off,
__data_size
};
enum DATA { class_idx = 0, access_flags, superclass_idx, interfaces_off, source_file_idx, annotations_off, class_data_off, static_values_off, __data_size };

extern const FW_DEF::HEADER_RECORD records[__data_size];
} // namespace N_DEX_CLASS_ITEM_DEF
Expand Down
Loading

0 comments on commit 6a5b713

Please sign in to comment.