Skip to content

Commit

Permalink
Update file(s): 2024-07-09
Browse files Browse the repository at this point in the history
  • Loading branch information
horsicq committed Jul 9, 2024
1 parent f8af39d commit d38bffc
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 35 deletions.
3 changes: 2 additions & 1 deletion dialognfdscandirectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,14 @@ void DialogNFDScanDirectory::scanDirectory(const QString &sDirectoryName)
if (sDirectoryName != "") {
ui->textBrowserResult->clear();

SpecAbstract::SCAN_OPTIONS options = {};
XBinary::SCAN_OPTIONS options = {};
options.bIsRecursiveScan = ui->checkBoxRecursiveScan->isChecked();
options.bIsDeepScan = ui->checkBoxDeepScan->isChecked();
options.bIsHeuristicScan = ui->checkBoxHeuristicScan->isChecked();
options.bIsVerbose = ui->checkBoxVerbose->isChecked();
options.bSubdirectories = ui->checkBoxScanSubdirectories->isChecked();
options.bAllTypesScan = ui->checkBoxAllTypesScan->isChecked();
options.nBufferSize = getGlobalOptions()->getValue(XOptions::ID_SCAN_BUFFERSIZE).toULongLong();
// TODO Filter options
// |flags|x all|

Expand Down
8 changes: 4 additions & 4 deletions dialognfdscanprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ DialogNFDScanProcess::DialogNFDScanProcess(QWidget *pParent) : XDialogProcess(pP
connect(g_pThread, SIGNAL(started()), g_pScan, SLOT(process()));
connect(g_pScan, SIGNAL(completed(qint64)), this, SLOT(onCompleted(qint64)));
connect(g_pScan, SIGNAL(scanFileStarted(QString)), this, SIGNAL(scanFileStarted(QString)), Qt::DirectConnection);
connect(g_pScan, SIGNAL(scanResult(SpecAbstract::SCAN_RESULT)), this, SIGNAL(scanResult(SpecAbstract::SCAN_RESULT)), Qt::DirectConnection);
connect(g_pScan, SIGNAL(scanResult(XBinary::SCAN_RESULT)), this, SIGNAL(scanResult(XBinary::SCAN_RESULT)), Qt::DirectConnection);
}

void DialogNFDScanProcess::setData(const QString &sFileName, SpecAbstract::SCAN_OPTIONS *pOptions, SpecAbstract::SCAN_RESULT *pScanResult)
void DialogNFDScanProcess::setData(const QString &sFileName, XBinary::SCAN_OPTIONS *pOptions, XBinary::SCAN_RESULT *pScanResult)
{
g_pScan->setData(sFileName, pOptions, pScanResult, getPdStruct());
g_pThread->start();
}

void DialogNFDScanProcess::setData(QIODevice *pDevice, SpecAbstract::SCAN_OPTIONS *pOptions, SpecAbstract::SCAN_RESULT *pScanResult)
void DialogNFDScanProcess::setData(QIODevice *pDevice, XBinary::SCAN_OPTIONS *pOptions, XBinary::SCAN_RESULT *pScanResult)
{
g_pScan->setData(pDevice, pOptions, pScanResult, getPdStruct());
g_pThread->start();
}

void DialogNFDScanProcess::setData(const QString &sDirectoryName, SpecAbstract::SCAN_OPTIONS *pOptions)
void DialogNFDScanProcess::setData(const QString &sDirectoryName, XBinary::SCAN_OPTIONS *pOptions)
{
g_pScan->setData(sDirectoryName, pOptions, getPdStruct());
g_pThread->start();
Expand Down
8 changes: 4 additions & 4 deletions dialognfdscanprocess.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ class DialogNFDScanProcess : public XDialogProcess {
explicit DialogNFDScanProcess(QWidget *pParent = nullptr);
~DialogNFDScanProcess();

void setData(const QString &sFileName, SpecAbstract::SCAN_OPTIONS *pOptions, SpecAbstract::SCAN_RESULT *pScanResult);
void setData(QIODevice *pDevice, SpecAbstract::SCAN_OPTIONS *pOptions, SpecAbstract::SCAN_RESULT *pScanResult);
void setData(const QString &sDirectoryName, SpecAbstract::SCAN_OPTIONS *pOptions);
void setData(const QString &sFileName, XBinary::SCAN_OPTIONS *pOptions, XBinary::SCAN_RESULT *pScanResult);
void setData(QIODevice *pDevice, XBinary::SCAN_OPTIONS *pOptions, XBinary::SCAN_RESULT *pScanResult);
void setData(const QString &sDirectoryName, XBinary::SCAN_OPTIONS *pOptions);
static bool saveResult(QWidget *pParent, ScanItemModel *pModel, const QString &sResultFileName); // TODO move to scanitemmodel.h

signals:
void scanFileStarted(const QString &sFileName);
void scanResult(const SpecAbstract::SCAN_RESULT &scanResult);
void scanResult(const XBinary::SCAN_RESULT &scanResult);

private:
StaticScan *g_pScan;
Expand Down
2 changes: 1 addition & 1 deletion dialognfdwidgetadvanced.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ DialogNFDWidgetAdvanced::~DialogNFDWidgetAdvanced()
delete ui;
}

void DialogNFDWidgetAdvanced::setData(const QString &sFileName, SpecAbstract::SCAN_OPTIONS options, bool bScan)
void DialogNFDWidgetAdvanced::setData(const QString &sFileName, XBinary::SCAN_OPTIONS options, bool bScan)
{
ui->widgetScan->setData(sFileName, options, bScan);
}
Expand Down
2 changes: 1 addition & 1 deletion dialognfdwidgetadvanced.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class DialogNFDWidgetAdvanced : public XShortcutsDialog {
{
}

void setData(const QString &sFileName, SpecAbstract::SCAN_OPTIONS options, bool bScan);
void setData(const QString &sFileName, XBinary::SCAN_OPTIONS options, bool bScan);

private slots:
void on_pushButtonClose_clicked();
Expand Down
5 changes: 2 additions & 3 deletions nfd_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ void NFD_Widget::process()
g_scanOptions.bIsVerbose = ui->checkBoxVerbose->isChecked();
g_scanOptions.bAllTypesScan = ui->checkBoxAllTypesScan->isChecked();
g_scanOptions.fileType = g_fileType;
g_scanOptions.nBufferSize = getGlobalOptions()->getValue(XOptions::ID_SCAN_BUFFERSIZE).toULongLong();
// scanOptions.bDebug=true;

getGlobalOptions()->setValue(XOptions::ID_SCAN_ALLTYPES, g_scanOptions.bAllTypesScan);
Expand Down Expand Up @@ -162,9 +163,7 @@ void NFD_Widget::on_scanFinished()

QAbstractItemModel *pOldModel = ui->treeViewResult->model();

QList<XBinary::SCANSTRUCT> _listRecords = SpecAbstract::convert(&(g_scanResult.listRecords));

ScanItemModel *pModel = new ScanItemModel(&_listRecords, 1, getGlobalOptions()->getValue(XOptions::ID_SCAN_HIGHLIGHT).toBool());
ScanItemModel *pModel = new ScanItemModel(&(g_scanResult.listRecords), 1, getGlobalOptions()->getValue(XOptions::ID_SCAN_HIGHLIGHT).toBool());
ui->treeViewResult->setModel(pModel);
ui->treeViewResult->expandAll();

Expand Down
4 changes: 2 additions & 2 deletions nfd_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ private slots:
Ui::NFD_Widget *ui;
ST g_scanType;
StaticScan g_staticScan;
SpecAbstract::SCAN_OPTIONS g_scanOptions;
SpecAbstract::SCAN_RESULT g_scanResult;
XBinary::SCAN_OPTIONS g_scanOptions;
XBinary::SCAN_RESULT g_scanResult;
QFutureWatcher<void> watcher;
QString sFileName;
XBinary::FT g_fileType;
Expand Down
3 changes: 3 additions & 0 deletions nfdoptionswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ void NFDOptionsWidget::save()
g_pOptions->getCheckBox(ui->checkBoxVerbose, XOptions::ID_SCAN_VERBOSE);
g_pOptions->getCheckBox(ui->checkBoxAllTypesScan, XOptions::ID_SCAN_ALLTYPES);
g_pOptions->getCheckBox(ui->checkBoxHighlight, XOptions::ID_SCAN_HIGHLIGHT);
g_pOptions->getComboBox(ui->comboBoxBufferSize, XOptions::ID_SCAN_BUFFERSIZE);
}

void NFDOptionsWidget::setDefaultValues(XOptions *pOptions)
Expand All @@ -68,6 +69,7 @@ void NFDOptionsWidget::setDefaultValues(XOptions *pOptions)
pOptions->addID(XOptions::ID_SCAN_VERBOSE, false);
pOptions->addID(XOptions::ID_SCAN_ALLTYPES, false);
pOptions->addID(XOptions::ID_SCAN_HIGHLIGHT, true);
pOptions->addID(XOptions::ID_SCAN_BUFFERSIZE, 2 * 1024 * 1024);
}

void NFDOptionsWidget::reload()
Expand All @@ -79,4 +81,5 @@ void NFDOptionsWidget::reload()
g_pOptions->setCheckBox(ui->checkBoxVerbose, XOptions::ID_SCAN_VERBOSE);
g_pOptions->setCheckBox(ui->checkBoxAllTypesScan, XOptions::ID_SCAN_ALLTYPES);
g_pOptions->setCheckBox(ui->checkBoxHighlight, XOptions::ID_SCAN_HIGHLIGHT);
g_pOptions->setComboBox(ui->comboBoxBufferSize, XOptions::ID_SCAN_BUFFERSIZE);
}
46 changes: 40 additions & 6 deletions nfdoptionswidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
<width>565</width>
<height>518</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -42,8 +42,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
<width>565</width>
<height>518</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
Expand Down Expand Up @@ -108,15 +108,49 @@
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxBufferSize">
<property name="title">
<string>Buffer size</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="QComboBox" name="comboBoxBufferSize">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>149</height>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
Expand Down
21 changes: 9 additions & 12 deletions nfdwidgetadvanced.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void NFDWidgetAdvanced::setData(QIODevice *pDevice, bool bScan, XBinary::FT file
}
}

void NFDWidgetAdvanced::setData(const QString &sFileName, SpecAbstract::SCAN_OPTIONS options, bool bScan)
void NFDWidgetAdvanced::setData(const QString &sFileName, XBinary::SCAN_OPTIONS options, bool bScan)
{
this->g_sFileName = sFileName;
this->g_fileType = options.fileType;
Expand Down Expand Up @@ -124,8 +124,8 @@ void NFDWidgetAdvanced::on_comboBoxType_currentIndexChanged(int nIndex)

void NFDWidgetAdvanced::process()
{
SpecAbstract::SCAN_RESULT scanResult = {};
SpecAbstract::SCAN_OPTIONS options = {};
XBinary::SCAN_RESULT scanResult = {};
XBinary::SCAN_OPTIONS options = {};

options.bIsRecursiveScan = ui->checkBoxRecursiveScan->isChecked();
options.bIsDeepScan = ui->checkBoxDeepScan->isChecked();
Expand All @@ -134,6 +134,7 @@ void NFDWidgetAdvanced::process()
options.bAllTypesScan = ui->checkBoxAllTypesScan->isChecked();
options.bShowDetects = true;
options.fileType = (XBinary::FT)(ui->comboBoxType->currentData().toInt());
options.nBufferSize = getGlobalOptions()->getValue(XOptions::ID_SCAN_BUFFERSIZE).toULongLong();

DialogNFDScanProcess dialogStaticScanProcess(this);
dialogStaticScanProcess.setGlobal(getShortcuts(), getGlobalOptions());
Expand All @@ -147,15 +148,13 @@ void NFDWidgetAdvanced::process()

QAbstractItemModel *pOldTreeModel = ui->treeViewScan->model();

QList<XBinary::SCANSTRUCT> _listRecords = SpecAbstract::convert(&(scanResult.listRecords));

ScanItemModel *pModel = new ScanItemModel(&_listRecords, 1, getGlobalOptions()->getValue(XOptions::ID_SCAN_HIGHLIGHT).toBool());
ScanItemModel *pModel = new ScanItemModel(&(scanResult.listRecords), 1, getGlobalOptions()->getValue(XOptions::ID_SCAN_HIGHLIGHT).toBool());
ui->treeViewScan->setModel(pModel);
ui->treeViewScan->expandAll();

deleteOldAbstractModel(&pOldTreeModel);

qint32 nNumberOfHeurs = scanResult.listHeurs.count();
qint32 nNumberOfHeurs = scanResult.listDebugRecords.count();

QAbstractItemModel *pOldTableModel = ui->tableViewHeur->model();

Expand All @@ -167,17 +166,15 @@ void NFDWidgetAdvanced::process()

for (qint32 i = 0; i < nNumberOfHeurs; i++) {
QStandardItem *pItemHeurType = new QStandardItem;
pItemHeurType->setText(SpecAbstract::heurTypeIdToString(scanResult.listHeurs.at(i).detectType));
pItemHeurType->setText(scanResult.listDebugRecords.at(i).sType);
pHeurModel->setItem(i, 0, pItemHeurType);

QStandardItem *pItemName = new QStandardItem;
pItemName->setText(
QString("%1(%2)[%3]")
.arg(SpecAbstract::recordNameIdToString(scanResult.listHeurs.at(i).name), scanResult.listHeurs.at(i).sVersion, scanResult.listHeurs.at(i).sInfo));
pItemName->setText(scanResult.listDebugRecords.at(i).sName);
pHeurModel->setItem(i, 1, pItemName);

QStandardItem *pItemValue = new QStandardItem;
pItemValue->setText(scanResult.listHeurs.at(i).sValue);
pItemValue->setText(scanResult.listDebugRecords.at(i).sValue);
pHeurModel->setItem(i, 2, pItemValue);
}

Expand Down
2 changes: 1 addition & 1 deletion nfdwidgetadvanced.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class NFDWidgetAdvanced : public XShortcutsWidget {
~NFDWidgetAdvanced();

void setData(QIODevice *pDevice, bool bScan, XBinary::FT fileType);
void setData(const QString &sFileName, SpecAbstract::SCAN_OPTIONS options, bool bScan);
void setData(const QString &sFileName, XBinary::SCAN_OPTIONS options, bool bScan);
// TODO Memory scan

virtual void adjustView();
Expand Down

0 comments on commit d38bffc

Please sign in to comment.