├── README.md ├── formstaticscan.cmake ├── heurwidget.cmake ├── staticscan.cmake ├── formstaticscan.pri ├── dialogstaticscan.pri ├── staticscan.pri ├── heurwidget.pri ├── dialogstaticscanprocess.cmake ├── dialogstaticscanprocess.pri ├── formresult.cmake ├── LICENSE ├── formresult.pri ├── dialogstaticscan.h ├── staticscanoptionswidget.h ├── formstaticscan.h ├── heurwidget.h ├── formresult.h ├── staticscanitem.h ├── dialogstaticscandirectory.h ├── dialogstaticscanprocess.h ├── formstaticscan.cpp ├── dialogstaticscan.cpp ├── staticscanitem.cpp ├── formresult.ui ├── formstaticscan.ui ├── formresult.cpp ├── staticscanitemmodel.h ├── staticscanoptionswidget.cpp ├── dialogstaticscanprocess.cpp ├── staticscanoptionswidget.ui ├── staticscan.h ├── dialogstaticscan.ui ├── dialogstaticscandirectory.cpp ├── heurwidget.cpp ├── heurwidget.ui ├── dialogstaticscandirectory.ui ├── staticscan.cpp └── staticscanitemmodel.cpp /README.md: -------------------------------------------------------------------------------- 1 | # 2 | 3 | Static scan for Nauz File Detector. 4 | -------------------------------------------------------------------------------- /formstaticscan.cmake: -------------------------------------------------------------------------------- 1 | include_directories(${CMAKE_CURRENT_LIST_DIR}) 2 | -------------------------------------------------------------------------------- /heurwidget.cmake: -------------------------------------------------------------------------------- 1 | include_directories(${CMAKE_CURRENT_LIST_DIR}) 2 | 3 | include(${CMAKE_CURRENT_LIST_DIR}/formresult.cmake) 4 | 5 | set(HEURWIDGET_SOURCES 6 | ${FORMRESULT_SOURCES} 7 | ${CMAKE_CURRENT_LIST_DIR}/heurwidget.cpp 8 | ) 9 | -------------------------------------------------------------------------------- /staticscan.cmake: -------------------------------------------------------------------------------- 1 | include_directories(${CMAKE_CURRENT_LIST_DIR}) 2 | 3 | include(${CMAKE_CURRENT_LIST_DIR}/../SpecAbstract/specabstract.cmake) 4 | 5 | set(STATICSCAN_SOURCES 6 | ${SPECABSTRACT_SOURCES} 7 | ${CMAKE_CURRENT_LIST_DIR}/staticscan.cpp 8 | ) 9 | -------------------------------------------------------------------------------- /formstaticscan.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD 2 | DEPENDPATH += $$PWD 3 | 4 | HEADERS += \ 5 | $$PWD/formstaticscan.h 6 | 7 | SOURCES += \ 8 | $$PWD/formstaticscan.cpp 9 | 10 | FORMS += \ 11 | $$PWD/formstaticscan.ui 12 | 13 | !contains(XCONFIG, formresult) { 14 | XCONFIG += formresult 15 | include($$PWD/formresult.pri) 16 | } 17 | -------------------------------------------------------------------------------- /dialogstaticscan.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD 2 | DEPENDPATH += $$PWD 3 | 4 | HEADERS += \ 5 | $$PWD/dialogstaticscan.h 6 | 7 | SOURCES += \ 8 | $$PWD/dialogstaticscan.cpp 9 | 10 | FORMS += \ 11 | $$PWD/dialogstaticscan.ui 12 | 13 | !contains(XCONFIG, staticscan) { 14 | XCONFIG += staticscan 15 | include($$PWD/staticscan.pri) 16 | } 17 | -------------------------------------------------------------------------------- /staticscan.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD 2 | DEPENDPATH += $$PWD 3 | 4 | HEADERS += \ 5 | $$PWD/staticscan.h 6 | 7 | SOURCES += \ 8 | $$PWD/staticscan.cpp 9 | 10 | !contains(XCONFIG, specabstract) { 11 | XCONFIG += specabstract 12 | include($$PWD/../SpecAbstract/specabstract.pri) 13 | } 14 | 15 | DISTFILES += \ 16 | $$PWD/LICENSE \ 17 | $$PWD/README.md \ 18 | $$PWD/staticscan.cmake 19 | -------------------------------------------------------------------------------- /heurwidget.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD 2 | DEPENDPATH += $$PWD 3 | 4 | HEADERS += \ 5 | $$PWD/heurwidget.h 6 | 7 | SOURCES += \ 8 | $$PWD/heurwidget.cpp 9 | 10 | FORMS += \ 11 | $$PWD/heurwidget.ui 12 | 13 | !contains(XCONFIG, formresult) { 14 | XCONFIG += formresult 15 | include($$PWD/formresult.pri) 16 | } 17 | 18 | DISTFILES += \ 19 | $$PWD/LICENSE \ 20 | $$PWD/README.md \ 21 | $$PWD/heurwidget.cmake 22 | -------------------------------------------------------------------------------- /dialogstaticscanprocess.cmake: -------------------------------------------------------------------------------- 1 | include_directories(${CMAKE_CURRENT_LIST_DIR}) 2 | 3 | include(${CMAKE_CURRENT_LIST_DIR}/staticscan.cmake) 4 | include(${CMAKE_CURRENT_LIST_DIR}/../XOptions/xoptionswidget.cmake) 5 | include(${CMAKE_CURRENT_LIST_DIR}/../FormatDialogs/xdialogprocess.cmake) 6 | 7 | set(DIALOGSTATICSCANPROCESS_SOURCES 8 | ${STATICSCAN_SOURCES} 9 | ${XOPTIONSWIDGET_SOURCES} 10 | ${XDIALOGPROCESS_SOURCES} 11 | ${CMAKE_CURRENT_LIST_DIR}/dialogstaticscanprocess.cpp 12 | ) 13 | -------------------------------------------------------------------------------- /dialogstaticscanprocess.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD 2 | DEPENDPATH += $$PWD 3 | 4 | HEADERS += \ 5 | $$PWD/dialogstaticscanprocess.h 6 | 7 | SOURCES += \ 8 | $$PWD/dialogstaticscanprocess.cpp 9 | 10 | !contains(XCONFIG, staticscan) { 11 | XCONFIG += staticscan 12 | include($$PWD/staticscan.pri) 13 | } 14 | 15 | !contains(XCONFIG, xoptionswidget) { 16 | XCONFIG += xoptionswidget 17 | include($$PWD/../XOptions/xoptionswidget.pri) 18 | } 19 | 20 | !contains(XCONFIG, xdialogprocess) { 21 | XCONFIG += xdialogprocess 22 | include($$PWD/../FormatDialogs/xdialogprocess.pri) 23 | } 24 | 25 | DISTFILES += \ 26 | $$PWD/LICENSE \ 27 | $$PWD/README.md \ 28 | $$PWD/dialogstaticscanprocess.cmake 29 | -------------------------------------------------------------------------------- /formresult.cmake: -------------------------------------------------------------------------------- 1 | include_directories(${CMAKE_CURRENT_LIST_DIR}) 2 | 3 | include(${CMAKE_CURRENT_LIST_DIR}/dialogstaticscanprocess.cmake) 4 | include(${CMAKE_CURRENT_LIST_DIR}/../FormatDialogs/dialogtextinfo.cmake) 5 | include(${CMAKE_CURRENT_LIST_DIR}/../XShortcuts/xshortcuts.cmake) 6 | 7 | set(FORMRESULT_SOURCES 8 | ${DIALOGSTATICSCANPROCESS_SOURCES} 9 | ${DIALOGTEXTINFO_SOURCES} 10 | ${XSHORTCUTS_SOURCES} 11 | ${CMAKE_CURRENT_LIST_DIR}/dialogstaticscan.cpp 12 | ${CMAKE_CURRENT_LIST_DIR}/dialogstaticscan.ui 13 | ${CMAKE_CURRENT_LIST_DIR}/dialogstaticscandirectory.cpp 14 | ${CMAKE_CURRENT_LIST_DIR}/dialogstaticscandirectory.ui 15 | ${CMAKE_CURRENT_LIST_DIR}/formresult.cpp 16 | ${CMAKE_CURRENT_LIST_DIR}/formresult.ui 17 | ${CMAKE_CURRENT_LIST_DIR}/staticscanoptionswidget.cpp 18 | ${CMAKE_CURRENT_LIST_DIR}/staticscanoptionswidget.ui 19 | ) 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017-2025 hors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /formresult.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD 2 | DEPENDPATH += $$PWD 3 | 4 | HEADERS += \ 5 | $$PWD/dialogstaticscan.h \ 6 | $$PWD/dialogstaticscandirectory.h \ 7 | $$PWD/formresult.h \ 8 | $$PWD/staticscanoptionswidget.h 9 | 10 | SOURCES += \ 11 | $$PWD/dialogstaticscan.cpp \ 12 | $$PWD/dialogstaticscandirectory.cpp \ 13 | $$PWD/formresult.cpp \ 14 | $$PWD/staticscanoptionswidget.cpp 15 | 16 | FORMS += \ 17 | $$PWD/dialogstaticscan.ui \ 18 | $$PWD/dialogstaticscandirectory.ui \ 19 | $$PWD/formresult.ui \ 20 | $$PWD/staticscanoptionswidget.ui 21 | 22 | !contains(XCONFIG, dialogstaticscanprocess) { 23 | XCONFIG += dialogstaticscanprocess 24 | include($$PWD/dialogstaticscanprocess.pri) 25 | } 26 | 27 | !contains(XCONFIG, dialogtextinfo) { 28 | XCONFIG += dialogtextinfo 29 | include($$PWD/../FormatDialogs/dialogtextinfo.pri) 30 | } 31 | 32 | !contains(XCONFIG, xshortcuts) { 33 | XCONFIG += xshortcuts 34 | include($$PWD/../XShortcuts/xshortcuts.pri) 35 | } 36 | 37 | DISTFILES += \ 38 | $$PWD/LICENSE \ 39 | $$PWD/README.md \ 40 | $$PWD/formresult.cmake 41 | -------------------------------------------------------------------------------- /dialogstaticscan.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef DIALOGSTATICSCAN_H 22 | #define DIALOGSTATICSCAN_H 23 | 24 | #include "dialogstaticscanprocess.h" 25 | #include "xoptions.h" 26 | 27 | namespace Ui { 28 | class DialogStaticScan; 29 | } 30 | 31 | class DialogStaticScan : public QDialog { 32 | Q_OBJECT 33 | 34 | public: 35 | explicit DialogStaticScan(QWidget *pParent); 36 | ~DialogStaticScan(); 37 | 38 | void setData(QIODevice *pDevice, bool bAuto = false); 39 | 40 | private slots: 41 | void on_pushButtonClose_clicked(); 42 | void on_pushButtonScan_clicked(); 43 | void scan(); 44 | 45 | private: 46 | Ui::DialogStaticScan *ui; 47 | QIODevice *g_pDevice; 48 | }; 49 | 50 | #endif // DIALOGSTATICSCAN_H 51 | -------------------------------------------------------------------------------- /staticscanoptionswidget.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef STATICSCANOPTIONSWIDGET_H 22 | #define STATICSCANOPTIONSWIDGET_H 23 | 24 | #include 25 | 26 | #include "xoptions.h" 27 | 28 | namespace Ui { 29 | class StaticScanOptionsWidget; 30 | } 31 | 32 | class StaticScanOptionsWidget : public QWidget { 33 | Q_OBJECT 34 | 35 | public: 36 | explicit StaticScanOptionsWidget(QWidget *pParent = nullptr); 37 | ~StaticScanOptionsWidget(); 38 | 39 | void setOptions(XOptions *pOptions); 40 | 41 | static void setDefaultValues(XOptions *pOptions); 42 | 43 | public slots: 44 | void save(); 45 | void reload(); 46 | 47 | private: 48 | Ui::StaticScanOptionsWidget *ui; 49 | XOptions *g_pOptions; 50 | }; 51 | 52 | #endif // STATICSCANOPTIONSWIDGET_H 53 | -------------------------------------------------------------------------------- /formstaticscan.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2019-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef FORMSTATICSCAN_H 22 | #define FORMSTATICSCAN_H 23 | 24 | #include 25 | 26 | #include "dialogstaticscan.h" 27 | #include "formresult.h" 28 | 29 | namespace Ui { 30 | class FormStaticScan; 31 | } 32 | 33 | class FormStaticScan : public QWidget { 34 | Q_OBJECT 35 | 36 | public: 37 | struct OPTIONS { 38 | bool bHideRecursive; 39 | bool bScanAfterOpen; 40 | bool bIsImage; 41 | }; 42 | 43 | explicit FormStaticScan(QWidget *parent = nullptr); 44 | ~FormStaticScan(); 45 | void setData(QIODevice *pDevice, OPTIONS *pOptions); 46 | 47 | private slots: 48 | void on_pushButtonScan_clicked(); 49 | void scan(); 50 | 51 | private: 52 | Ui::FormStaticScan *ui; 53 | QIODevice *pDevice; 54 | OPTIONS *pOptions; 55 | }; 56 | 57 | #endif // FORMSTATICSCAN_H 58 | -------------------------------------------------------------------------------- /heurwidget.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2020-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef HEURWIDGET_H 22 | #define HEURWIDGET_H 23 | 24 | #include "dialogstaticscanprocess.h" 25 | #include "xshortcutswidget.h" 26 | 27 | namespace Ui { 28 | class HeurWidget; 29 | } 30 | 31 | class HeurWidget : public XShortcutsWidget { 32 | Q_OBJECT 33 | 34 | public: 35 | explicit HeurWidget(QWidget *pParent = nullptr); 36 | ~HeurWidget(); 37 | 38 | void setData(QIODevice *pDevice, bool bAuto, XBinary::FT fileType); 39 | // TODO setFileName 40 | // TODO Memory scan 41 | 42 | private slots: 43 | void on_pushButtonScan_clicked(); 44 | void on_pushButtonSave_clicked(); 45 | void on_comboBoxType_currentIndexChanged(int nIndex); 46 | void scan(); 47 | 48 | protected: 49 | virtual void registerShortcuts(bool bState); 50 | 51 | private: 52 | Ui::HeurWidget *ui; 53 | QIODevice *g_pDevice; 54 | XBinary::FT g_fileType; 55 | }; 56 | 57 | #endif // HEURWIDGET_H 58 | -------------------------------------------------------------------------------- /formresult.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef FORMRESULT_H 22 | #define FORMRESULT_H 23 | 24 | #include 25 | 26 | #include "dialogstaticscanprocess.h" 27 | #include "dialogtextinfo.h" 28 | 29 | // TODO rename class 30 | // TODO XShortcutsWidget 31 | namespace Ui { 32 | class FormResult; 33 | } 34 | 35 | class FormResult : public QWidget { 36 | Q_OBJECT 37 | 38 | public: 39 | explicit FormResult(QWidget *pParent = nullptr); 40 | ~FormResult(); 41 | 42 | void setData(XScanEngine::SCAN_OPTIONS scanOptions, XScanEngine::SCAN_RESULT scanResult, const QString &sSaveFileName); 43 | 44 | private slots: 45 | void on_pushButtonClear_clicked(); 46 | void on_pushButtonSave_clicked(); 47 | void on_pushButtonExtraInformation_clicked(); 48 | 49 | private: 50 | Ui::FormResult *ui; 51 | XScanEngine::SCAN_RESULT g_scanResult; 52 | QString g_sSaveFileName; 53 | QAbstractItemModel *g_pModel; 54 | }; 55 | 56 | #endif // FORMRESULT_H 57 | -------------------------------------------------------------------------------- /staticscanitem.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2021 hors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | // SOFTWARE. 20 | // 21 | #ifndef STATICSCANITEM_H 22 | #define STATICSCANITEM_H 23 | 24 | #include "staticscan.h" 25 | 26 | class StaticScanItem 27 | { 28 | public: 29 | StaticScanItem(const QString &sString,StaticScanItem *pParentItem=nullptr,qint32 nNumberOfColumns=1); 30 | ~StaticScanItem(); 31 | 32 | void appendChild(StaticScanItem *pChild); 33 | StaticScanItem *child(int nRow); 34 | int childCount() const; 35 | int columnCount() const; 36 | QVariant data(int nColumn) const; 37 | void setScanStruct(const SpecAbstract::SCAN_STRUCT &scanStruct); 38 | SpecAbstract::SCAN_STRUCT scanStruct() const; 39 | int row() const; 40 | StaticScanItem *getParentItem(); 41 | 42 | private: 43 | QList g_listChildItems; 44 | QString g_sString; 45 | StaticScanItem *g_pParentItem; 46 | qint32 g_nNumberOfColumns; 47 | SpecAbstract::SCAN_STRUCT g_scanStruct; 48 | }; 49 | 50 | #endif // STATICSCANITEM_H 51 | -------------------------------------------------------------------------------- /dialogstaticscandirectory.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2018-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef DIALOGSTATICSCANDIRECTORY_H 22 | #define DIALOGSTATICSCANDIRECTORY_H 23 | 24 | #include 25 | #include 26 | 27 | #include "dialogstaticscanprocess.h" 28 | #include "xoptions.h" 29 | #include "xshortcutsdialog.h" 30 | 31 | namespace Ui { 32 | class DialogStaticScanDirectory; 33 | } 34 | 35 | class DialogStaticScanDirectory : public XShortcutsDialog { 36 | Q_OBJECT 37 | 38 | public: 39 | explicit DialogStaticScanDirectory(QWidget *pParent, const QString &sDirName); 40 | ~DialogStaticScanDirectory(); 41 | 42 | private slots: 43 | void on_pushButtonOpenDirectory_clicked(); 44 | void on_pushButtonScan_clicked(); 45 | void scanDirectory(const QString &sDirectoryName); 46 | void scanResult(XScanEngine::SCAN_RESULT scanResult); 47 | void appendResult(const QString &sResult); 48 | void on_pushButtonOK_clicked(); 49 | void on_pushButtonClear_clicked(); 50 | void on_pushButtonSave_clicked(); 51 | 52 | signals: 53 | void resultSignal(QString sText); 54 | 55 | private: 56 | Ui::DialogStaticScanDirectory *ui; 57 | SpecAbstract::SCAN_OPTIONS g_scanOptions; 58 | }; 59 | 60 | #endif // DIALOGSTATICSCANDIRECTORY_H 61 | -------------------------------------------------------------------------------- /dialogstaticscanprocess.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef DIALOGSTATICSCANPROCESS_H 22 | #define DIALOGSTATICSCANPROCESS_H 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "scanitemmodel.h" 31 | #include "staticscan.h" 32 | #include "xdialogprocess.h" 33 | 34 | class DialogStaticScanProcess : public XDialogProcess { 35 | Q_OBJECT 36 | 37 | public: 38 | explicit DialogStaticScanProcess(QWidget *pParent = nullptr); 39 | ~DialogStaticScanProcess(); 40 | 41 | void setData(const QString &sFileName, XScanEngine::SCAN_OPTIONS *pOptions, XScanEngine::SCAN_RESULT *pScanResult); 42 | void setData(QIODevice *pDevice, XScanEngine::SCAN_OPTIONS *pOptions, XScanEngine::SCAN_RESULT *pScanResult); 43 | void setData(const QString &sDirectoryName, XScanEngine::SCAN_OPTIONS *pOptions); 44 | static bool saveResult(QWidget *pParent, ScanItemModel *pModel, const QString &sResultFileName); // TODO move to scanitemmodel.h 45 | 46 | signals: 47 | void scanFileStarted(QString sFileName); 48 | void scanResult(XScanEngine::SCAN_RESULT scanResult); 49 | 50 | private: 51 | StaticScan *g_pScan; 52 | QThread *g_pThread; 53 | }; 54 | 55 | #endif // DIALOGSTATICSCANPROCESS_H 56 | -------------------------------------------------------------------------------- /formstaticscan.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2019-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #include "formstaticscan.h" 22 | 23 | #include "ui_formstaticscan.h" 24 | 25 | FormStaticScan::FormStaticScan(QWidget *parent) : QWidget(parent), ui(new Ui::FormStaticScan) 26 | { 27 | ui->setupUi(this); 28 | 29 | ui->checkBoxDeepScan->setChecked(true); 30 | ui->checkBoxRecursive->setChecked(true); 31 | } 32 | 33 | FormStaticScan::~FormStaticScan() 34 | { 35 | delete ui; 36 | } 37 | 38 | void FormStaticScan::setData(QIODevice *pDevice, FormStaticScan::OPTIONS *pOptions) 39 | { 40 | this->pDevice = pDevice; 41 | this->pOptions = pOptions; 42 | 43 | if (pOptions->bHideRecursive) { 44 | ui->checkBoxRecursive->setChecked(false); 45 | ui->checkBoxRecursive->hide(); 46 | } 47 | 48 | if (pOptions->bScanAfterOpen) { 49 | scan(); 50 | } 51 | } 52 | 53 | void FormStaticScan::on_pushButtonScan_clicked() 54 | { 55 | scan(); 56 | } 57 | 58 | void FormStaticScan::scan() 59 | { 60 | SpecAbstract::SCAN_RESULT scanResult; 61 | 62 | SpecAbstract::SCAN_OPTIONS options = {0}; 63 | options.bRecursiveScan = ui->checkBoxRecursive->isChecked(); 64 | options.bDeepScan = ui->checkBoxDeepScan->isChecked(); 65 | options.bIsImage = pOptions->bIsImage; 66 | 67 | DialogStaticScanProcess ds(this); 68 | ds.setData(pDevice, &options, &scanResult); 69 | ds.exec(); 70 | 71 | ui->widgetResult->setData(scanResult, ""); 72 | } 73 | -------------------------------------------------------------------------------- /dialogstaticscan.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #include "dialogstaticscan.h" 22 | 23 | #include "ui_dialogstaticscan.h" 24 | 25 | DialogStaticScan::DialogStaticScan(QWidget *pParent) : QDialog(pParent), ui(new Ui::DialogStaticScan) 26 | { 27 | ui->setupUi(this); 28 | 29 | g_pDevice = nullptr; 30 | 31 | setWindowFlags(Qt::Window); 32 | } 33 | 34 | DialogStaticScan::~DialogStaticScan() 35 | { 36 | delete ui; 37 | } 38 | 39 | void DialogStaticScan::setData(QIODevice *pDevice, bool bAuto) 40 | { 41 | this->g_pDevice = pDevice; 42 | 43 | if (bAuto) { 44 | scan(); 45 | } 46 | } 47 | 48 | void DialogStaticScan::on_pushButtonClose_clicked() 49 | { 50 | this->close(); 51 | } 52 | 53 | void DialogStaticScan::on_pushButtonScan_clicked() 54 | { 55 | scan(); 56 | } 57 | 58 | void DialogStaticScan::scan() 59 | { 60 | XScanEngine::SCAN_RESULT scanResult = {}; 61 | 62 | XScanEngine::SCAN_OPTIONS scanOptions = {}; 63 | 64 | scanOptions.bIsRecursiveScan = ui->checkBoxRecursiveScan->isChecked(); 65 | scanOptions.bIsDeepScan = ui->checkBoxDeepScan->isChecked(); 66 | scanOptions.bIsHeuristicScan = ui->checkBoxHeuristicScan->isChecked(); 67 | scanOptions.bIsVerbose = ui->checkBoxVerbose->isChecked(); 68 | scanOptions.bIsAllTypesScan = ui->checkBoxAllTypesScan->isChecked(); 69 | 70 | DialogStaticScanProcess ds(XOptions::getMainWidget(this)); 71 | ds.setData(g_pDevice, &scanOptions, &scanResult); 72 | ds.showDialogDelay(); // TODO const 73 | 74 | QString sSaveFileName = XBinary::getResultFileName(g_pDevice, QString("%1.txt").arg(tr("Result"))); 75 | ui->widgetResult->setData(scanOptions, scanResult, sSaveFileName); 76 | } 77 | -------------------------------------------------------------------------------- /staticscanitem.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2021 hors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | // SOFTWARE. 20 | // 21 | #include "staticscanitem.h" 22 | 23 | StaticScanItem::StaticScanItem(const QString &sString, StaticScanItem *pParentItem, qint32 nNumberOfColumns) 24 | { 25 | this->g_pParentItem=pParentItem; 26 | this->g_sString=sString; 27 | this->g_nNumberOfColumns=nNumberOfColumns; 28 | } 29 | 30 | StaticScanItem::~StaticScanItem() 31 | { 32 | qDeleteAll(g_listChildItems); 33 | } 34 | 35 | void StaticScanItem::appendChild(StaticScanItem *pChild) 36 | { 37 | g_listChildItems.append(pChild); 38 | } 39 | 40 | StaticScanItem *StaticScanItem::child(int nRow) 41 | { 42 | return g_listChildItems.value(nRow); 43 | } 44 | 45 | int StaticScanItem::childCount() const 46 | { 47 | return g_listChildItems.count(); 48 | } 49 | 50 | int StaticScanItem::columnCount() const 51 | { 52 | return g_nNumberOfColumns; 53 | } 54 | 55 | QVariant StaticScanItem::data(int nColumn) const 56 | { 57 | QVariant result; 58 | 59 | if(nColumn==0) 60 | { 61 | result=g_sString; 62 | } 63 | 64 | return result; 65 | } 66 | 67 | void StaticScanItem::setScanStruct(const SpecAbstract::SCAN_STRUCT &scanStruct) 68 | { 69 | this->g_scanStruct=scanStruct; 70 | } 71 | 72 | SpecAbstract::SCAN_STRUCT StaticScanItem::scanStruct() const 73 | { 74 | return g_scanStruct; 75 | } 76 | 77 | int StaticScanItem::row() const 78 | { 79 | int nResult=0; 80 | 81 | if(g_pParentItem) 82 | { 83 | nResult=g_pParentItem->g_listChildItems.indexOf(const_cast(this)); 84 | } 85 | 86 | return nResult; 87 | } 88 | 89 | StaticScanItem *StaticScanItem::getParentItem() 90 | { 91 | return g_pParentItem; 92 | } 93 | -------------------------------------------------------------------------------- /formresult.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | FormResult 4 | 5 | 6 | 7 | 0 8 | 0 9 | 540 10 | 295 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 0 19 | 20 | 21 | 0 22 | 23 | 24 | 0 25 | 26 | 27 | 0 28 | 29 | 30 | 31 | 32 | false 33 | 34 | 35 | true 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | Clear 45 | 46 | 47 | 48 | 49 | 50 | 51 | Save 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 25 60 | 16777215 61 | 62 | 63 | 64 | > 65 | 66 | 67 | 68 | 69 | 70 | 71 | Qt::Horizontal 72 | 73 | 74 | 75 | 40 76 | 20 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 60 86 | 0 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /formstaticscan.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | FormStaticScan 4 | 5 | 6 | 7 | 0 8 | 0 9 | 680 10 | 396 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 0 19 | 20 | 21 | 0 22 | 23 | 24 | 0 25 | 26 | 27 | 0 28 | 29 | 30 | 31 | 32 | 33 | 34 | Recursive 35 | 36 | 37 | true 38 | 39 | 40 | 41 | 42 | 43 | 44 | Deep scan 45 | 46 | 47 | true 48 | 49 | 50 | 51 | 52 | 53 | 54 | Qt::Horizontal 55 | 56 | 57 | 58 | 40 59 | 20 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 75 69 | true 70 | 71 | 72 | 73 | Scan 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 0 84 | 0 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | FormResult 94 | QWidget 95 |
formresult.h
96 | 1 97 |
98 |
99 | 100 | 101 |
102 | -------------------------------------------------------------------------------- /formresult.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #include "formresult.h" 22 | 23 | #include "ui_formresult.h" 24 | 25 | FormResult::FormResult(QWidget *pParent) : QWidget(pParent), ui(new Ui::FormResult) 26 | { 27 | ui->setupUi(this); 28 | 29 | g_pModel = nullptr; 30 | g_scanResult = {}; 31 | } 32 | 33 | FormResult::~FormResult() 34 | { 35 | delete ui; 36 | } 37 | 38 | void FormResult::setData(XScanEngine::SCAN_OPTIONS scanOptions, XScanEngine::SCAN_RESULT scanResult, const QString &sSaveFileName) 39 | { 40 | this->g_scanResult = scanResult; 41 | this->g_sSaveFileName = sSaveFileName; 42 | 43 | ui->labelElapsedTime->clear(); 44 | 45 | QAbstractItemModel *pOldModel = ui->treeViewResult->model(); 46 | 47 | g_pModel = new ScanItemModel(&scanOptions, &(scanResult.listRecords), 1); 48 | ui->treeViewResult->setModel(g_pModel); 49 | ui->treeViewResult->expandAll(); 50 | 51 | delete pOldModel; // TODO Thread 52 | 53 | ui->labelElapsedTime->setText(QString("%1 %2").arg(QString::number(g_scanResult.nScanTime), tr("msec"))); 54 | } 55 | 56 | void FormResult::on_pushButtonClear_clicked() 57 | { 58 | QAbstractItemModel *pOldModel = ui->treeViewResult->model(); 59 | 60 | ui->treeViewResult->setModel(nullptr); 61 | 62 | delete pOldModel; // TODO Thread 63 | 64 | ui->labelElapsedTime->clear(); 65 | } 66 | 67 | void FormResult::on_pushButtonSave_clicked() 68 | { 69 | QAbstractItemModel *pModel = ui->treeViewResult->model(); 70 | 71 | if (pModel) { 72 | DialogStaticScanProcess::saveResult(this, (ScanItemModel *)pModel, g_sSaveFileName); 73 | } 74 | } 75 | 76 | void FormResult::on_pushButtonExtraInformation_clicked() 77 | { 78 | if (g_pModel) { 79 | DialogTextInfo dialogTextInfo(this); 80 | 81 | QString sText = ((ScanItemModel *)g_pModel)->toFormattedString(); 82 | 83 | dialogTextInfo.setText(sText); 84 | 85 | dialogTextInfo.exec(); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /staticscanitemmodel.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2021 hors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | // SOFTWARE. 20 | // 21 | #ifndef STATICSCANITEMMODEL_H 22 | #define STATICSCANITEMMODEL_H 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #ifdef QT_GUI_LIB 30 | #include 31 | #include 32 | #include 33 | #endif 34 | #include "staticscanitem.h" 35 | 36 | class StaticScanItemModel : public QAbstractItemModel 37 | { 38 | Q_OBJECT 39 | 40 | public: 41 | explicit StaticScanItemModel(QList *pListScanStructs,QObject *pParent=nullptr,int nNumberOfColumns=1); 42 | ~StaticScanItemModel() override; 43 | 44 | QVariant headerData(int nSection,Qt::Orientation orientation,int nRole=Qt::DisplayRole) const override; 45 | QModelIndex index(int nRow,int nColumn,const QModelIndex &parent=QModelIndex()) const override; 46 | QModelIndex parent(const QModelIndex &index) const override; 47 | int rowCount(const QModelIndex &parent=QModelIndex()) const override; 48 | int columnCount(const QModelIndex &parent=QModelIndex()) const override; 49 | QVariant data(const QModelIndex &index,int nRole=Qt::DisplayRole) const override; 50 | Qt::ItemFlags flags(const QModelIndex &index) const override; 51 | QString toXML(); 52 | QString toJSON(); 53 | QString toCSV(); 54 | QString toTSV(); 55 | QString toFormattedString(); 56 | QString toString(SpecAbstract::SCAN_OPTIONS *pScanOptions); 57 | StaticScanItem *rootItem(); 58 | 59 | private: 60 | void _toXML(QXmlStreamWriter *pXml,StaticScanItem *pItem); 61 | void _toJSON(QJsonObject *pJsonObject,StaticScanItem *pItem); 62 | void _toCSV(QString *pString,StaticScanItem *pItem); 63 | void _toTSV(QString *pString,StaticScanItem *pItem); 64 | void _toString(QString *pString,StaticScanItem *pItem,qint32 nLevel); 65 | 66 | private: 67 | StaticScanItem *g_pRootItem; 68 | }; 69 | 70 | #endif // STATICSCANITEMMODEL_H 71 | -------------------------------------------------------------------------------- /staticscanoptionswidget.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #include "staticscanoptionswidget.h" 22 | 23 | #include "ui_staticscanoptionswidget.h" 24 | 25 | StaticScanOptionsWidget::StaticScanOptionsWidget(QWidget *pParent) : QWidget(pParent), ui(new Ui::StaticScanOptionsWidget) 26 | { 27 | ui->setupUi(this); 28 | 29 | g_pOptions = nullptr; 30 | 31 | setProperty("GROUPID", XOptions::GROUPID_SCAN); 32 | } 33 | 34 | StaticScanOptionsWidget::~StaticScanOptionsWidget() 35 | { 36 | delete ui; 37 | } 38 | 39 | void StaticScanOptionsWidget::setOptions(XOptions *pOptions) 40 | { 41 | g_pOptions = pOptions; 42 | 43 | reload(); 44 | } 45 | 46 | void StaticScanOptionsWidget::save() 47 | { 48 | g_pOptions->getCheckBox(ui->checkBoxDeepScan, XOptions::ID_SCAN_SCANAFTEROPEN); 49 | g_pOptions->getCheckBox(ui->checkBoxScanAfterOpen, XOptions::ID_SCAN_FLAG_RECURSIVE); 50 | g_pOptions->getCheckBox(ui->checkBoxRecursiveScan, XOptions::ID_SCAN_FLAG_DEEP); 51 | g_pOptions->getCheckBox(ui->checkBoxHeuristicScan, XOptions::ID_SCAN_FLAG_HEURISTIC); 52 | g_pOptions->getCheckBox(ui->checkBoxVerbose, XOptions::ID_SCAN_FLAG_VERBOSE); 53 | g_pOptions->getCheckBox(ui->checkBoxAllTypesScan, XOptions::ID_SCAN_FLAG_ALLTYPES); 54 | } 55 | 56 | void StaticScanOptionsWidget::setDefaultValues(XOptions *pOptions) 57 | { 58 | pOptions->addID(XOptions::ID_SCAN_SCANAFTEROPEN, true); 59 | pOptions->addID(XOptions::ID_SCAN_FLAG_RECURSIVE, true); 60 | pOptions->addID(XOptions::ID_SCAN_FLAG_DEEP, true); 61 | pOptions->addID(XOptions::ID_SCAN_FLAG_HEURISTIC, false); 62 | pOptions->addID(XOptions::ID_SCAN_FLAG_VERBOSE, false); 63 | pOptions->addID(XOptions::ID_SCAN_FLAG_ALLTYPES, false); 64 | } 65 | 66 | void StaticScanOptionsWidget::reload() 67 | { 68 | g_pOptions->setCheckBox(ui->checkBoxScanAfterOpen, XOptions::ID_SCAN_SCANAFTEROPEN); 69 | g_pOptions->setCheckBox(ui->checkBoxRecursiveScan, XOptions::ID_SCAN_FLAG_RECURSIVE); 70 | g_pOptions->setCheckBox(ui->checkBoxDeepScan, XOptions::ID_SCAN_FLAG_DEEP); 71 | g_pOptions->setCheckBox(ui->checkBoxHeuristicScan, XOptions::ID_SCAN_FLAG_HEURISTIC); 72 | g_pOptions->setCheckBox(ui->checkBoxVerbose, XOptions::ID_SCAN_FLAG_VERBOSE); 73 | g_pOptions->setCheckBox(ui->checkBoxAllTypesScan, XOptions::ID_SCAN_FLAG_ALLTYPES); 74 | } 75 | -------------------------------------------------------------------------------- /dialogstaticscanprocess.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #include "dialogstaticscanprocess.h" 22 | 23 | DialogStaticScanProcess::DialogStaticScanProcess(QWidget *pParent) : XDialogProcess(pParent) 24 | { 25 | g_pScan = new StaticScan; 26 | g_pThread = new QThread; 27 | 28 | g_pScan->moveToThread(g_pThread); 29 | 30 | connect(g_pThread, SIGNAL(started()), g_pScan, SLOT(process())); 31 | connect(g_pScan, SIGNAL(completed(qint64)), this, SLOT(onCompleted(qint64))); 32 | connect(g_pScan, SIGNAL(scanFileStarted(QString)), this, SIGNAL(scanFileStarted(QString)), Qt::DirectConnection); 33 | connect(g_pScan, SIGNAL(scanResult(XScanEngine::SCAN_RESULT)), this, SIGNAL(scanResult(XScanEngine::SCAN_RESULT)), Qt::DirectConnection); 34 | } 35 | 36 | void DialogStaticScanProcess::setData(const QString &sFileName, XScanEngine::SCAN_OPTIONS *pOptions, XScanEngine::SCAN_RESULT *pScanResult) 37 | { 38 | g_pScan->setData(sFileName, pOptions, pScanResult, getPdStruct()); 39 | g_pThread->start(); 40 | } 41 | 42 | void DialogStaticScanProcess::setData(QIODevice *pDevice, XScanEngine::SCAN_OPTIONS *pOptions, XScanEngine::SCAN_RESULT *pScanResult) 43 | { 44 | g_pScan->setData(pDevice, pOptions, pScanResult, getPdStruct()); 45 | g_pThread->start(); 46 | } 47 | 48 | void DialogStaticScanProcess::setData(const QString &sDirectoryName, XScanEngine::SCAN_OPTIONS *pOptions) 49 | { 50 | g_pScan->setData(sDirectoryName, pOptions, getPdStruct()); 51 | g_pThread->start(); 52 | } 53 | 54 | DialogStaticScanProcess::~DialogStaticScanProcess() 55 | { 56 | stop(); 57 | waitForFinished(); 58 | 59 | g_pThread->quit(); 60 | g_pThread->wait(); 61 | 62 | // g_pThread->deleteLater(); // TODO 63 | // g_pScan->deleteLater(); // TODO 64 | 65 | delete g_pThread; 66 | delete g_pScan; 67 | } 68 | 69 | bool DialogStaticScanProcess::saveResult(QWidget *pParent, ScanItemModel *pModel, const QString &sResultFileName) 70 | { 71 | bool bResult = false; 72 | 73 | if (pModel) { 74 | QString sFilter; 75 | sFilter += QString("%1 (*.txt)").arg(tr("Text documents")); 76 | QString sFileName = QFileDialog::getSaveFileName(pParent, tr("Save result"), sResultFileName, sFilter); 77 | 78 | if (!sFileName.isEmpty()) { 79 | QFile file; 80 | file.setFileName(sFileName); 81 | 82 | if (file.open(QIODevice::ReadWrite)) { 83 | QString sText = pModel->toFormattedString(); 84 | 85 | file.write(sText.toUtf8().data()); 86 | 87 | file.close(); 88 | 89 | bResult = true; 90 | } 91 | } 92 | } 93 | 94 | return bResult; 95 | } 96 | -------------------------------------------------------------------------------- /staticscanoptionswidget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | StaticScanOptionsWidget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 0 19 | 20 | 21 | 0 22 | 23 | 24 | 0 25 | 26 | 27 | 0 28 | 29 | 30 | 31 | 32 | QFrame::NoFrame 33 | 34 | 35 | QFrame::Plain 36 | 37 | 38 | true 39 | 40 | 41 | 42 | 43 | 0 44 | 0 45 | 400 46 | 300 47 | 48 | 49 | 50 | 51 | 0 52 | 53 | 54 | 0 55 | 56 | 57 | 0 58 | 59 | 60 | 0 61 | 62 | 63 | 64 | 65 | Scan after open 66 | 67 | 68 | 69 | 70 | 71 | 72 | Recursive scan 73 | 74 | 75 | 76 | 77 | 78 | 79 | Deep scan 80 | 81 | 82 | 83 | 84 | 85 | 86 | Heuristic scan 87 | 88 | 89 | 90 | 91 | 92 | 93 | Verbose 94 | 95 | 96 | 97 | 98 | 99 | 100 | All types 101 | 102 | 103 | 104 | 105 | 106 | 107 | Qt::Vertical 108 | 109 | 110 | 111 | 20 112 | 149 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /staticscan.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef STATICSCAN_H 22 | #define STATICSCAN_H 23 | 24 | #include 25 | #include 26 | 27 | #include "specabstract.h" 28 | 29 | #define SSE_VERSION __DATE__ 30 | 31 | class StaticScan : public QObject { 32 | Q_OBJECT 33 | 34 | public: 35 | explicit StaticScan(QObject *pParent = nullptr); 36 | 37 | void setData(const QString &sFileName, XScanEngine::SCAN_OPTIONS *pOptions, XScanEngine::SCAN_RESULT *pScanResult, XBinary::PDSTRUCT *pPdStruct); 38 | void setData(QIODevice *pDevice, XScanEngine::SCAN_OPTIONS *pOptions, XScanEngine::SCAN_RESULT *pScanResult, XBinary::PDSTRUCT *pPdStruct); 39 | void setData(char *pData, qint32 nDataSize, XScanEngine::SCAN_OPTIONS *pOptions, XScanEngine::SCAN_RESULT *pScanResult, XBinary::PDSTRUCT *pPdStruct); 40 | void setData(const QString &sDirectoryName, XScanEngine::SCAN_OPTIONS *pOptions, XBinary::PDSTRUCT *pPdStruct); 41 | 42 | static XScanEngine::SCAN_RESULT processDevice(QIODevice *pDevice, SpecAbstract::SCAN_OPTIONS *pOptions, XBinary::PDSTRUCT *pPdStruct = nullptr); 43 | static XScanEngine::SCAN_RESULT processFile(const QString &sFileName, SpecAbstract::SCAN_OPTIONS *pOptions, XBinary::PDSTRUCT *pPdStruct = nullptr); 44 | static XScanEngine::SCAN_RESULT processMemory(char *pData, qint32 nDataSize, SpecAbstract::SCAN_OPTIONS *pOptions, XBinary::PDSTRUCT *pPdStruct = nullptr); 45 | static XScanEngine::SCAN_RESULT processSubdevice(QIODevice *pDevice, qint64 nOffset, qint64 nSize, SpecAbstract::SCAN_OPTIONS *pOptions, 46 | XBinary::PDSTRUCT *pPdStruct = nullptr); 47 | 48 | static QString getEngineVersion(); 49 | 50 | private: 51 | enum SCAN_TYPE { 52 | SCAN_TYPE_UNKNOWN = 0, 53 | SCAN_TYPE_DEVICE, 54 | SCAN_TYPE_DIRECTORY, 55 | SCAN_TYPE_FILE, 56 | SCAN_TYPE_MEMORY 57 | // TODO mb More 58 | }; 59 | 60 | void _process(QIODevice *pDevice, XScanEngine::SCAN_RESULT *pScanResult, qint64 nOffset, qint64 nSize, XScanEngine::SCANID parentId, 61 | SpecAbstract::SCAN_OPTIONS *pOptions, XBinary::PDSTRUCT *pPdStruct = nullptr); 62 | XScanEngine::SCAN_RESULT scanFile(const QString &sFileName, XBinary::PDSTRUCT *pPdStruct = nullptr); 63 | XScanEngine::SCAN_RESULT scanDevice(QIODevice *pDevice, XBinary::PDSTRUCT *pPdStruct = nullptr); 64 | XScanEngine::SCAN_RESULT scanMemory(char *pData, qint32 nSize, XBinary::PDSTRUCT *pPdStruct = nullptr); 65 | 66 | signals: 67 | // TODO error and info signals !!! 68 | void scanFileStarted(QString sFileName); 69 | void completed(qint64 nElapsedTime); 70 | void scanResult(XScanEngine::SCAN_RESULT scanResult); 71 | 72 | public slots: 73 | void process(); 74 | 75 | private: 76 | QString g_sFileName; 77 | QString g_sDirectoryName; 78 | QIODevice *g_pDevice; 79 | char *g_pData; 80 | qint32 g_nDataSize; 81 | XScanEngine::SCAN_OPTIONS *g_pOptions; 82 | XScanEngine::SCAN_RESULT *g_pScanResult; 83 | SCAN_TYPE g_scanType; 84 | XBinary::PDSTRUCT *g_pPdStruct; 85 | }; 86 | 87 | #endif // STATICSCAN_H 88 | -------------------------------------------------------------------------------- /dialogstaticscan.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | DialogStaticScan 4 | 5 | 6 | Qt::ApplicationModal 7 | 8 | 9 | 10 | 0 11 | 0 12 | 557 13 | 315 14 | 15 | 16 | 17 | Scan 18 | 19 | 20 | true 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | Recursive scan 29 | 30 | 31 | true 32 | 33 | 34 | 35 | 36 | 37 | 38 | Deep scan 39 | 40 | 41 | true 42 | 43 | 44 | 45 | 46 | 47 | 48 | Heuristic scan 49 | 50 | 51 | false 52 | 53 | 54 | 55 | 56 | 57 | 58 | Verbose 59 | 60 | 61 | false 62 | 63 | 64 | 65 | 66 | 67 | 68 | Qt::Horizontal 69 | 70 | 71 | 72 | 40 73 | 20 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | All types 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | true 90 | 91 | 92 | 93 | Scan 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 0 104 | 0 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | Qt::Horizontal 115 | 116 | 117 | 118 | 40 119 | 20 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | Close 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | FormResult 138 | QWidget 139 |
formresult.h
140 | 1 141 |
142 |
143 | 144 | 145 |
146 | -------------------------------------------------------------------------------- /dialogstaticscandirectory.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2018-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #include "dialogstaticscandirectory.h" 22 | 23 | #include "ui_dialogstaticscandirectory.h" 24 | 25 | DialogStaticScanDirectory::DialogStaticScanDirectory(QWidget *pParent, const QString &sDirName) : XShortcutsDialog(pParent), ui(new Ui::DialogStaticScanDirectory) 26 | { 27 | ui->setupUi(this); 28 | 29 | g_scanOptions = {}; 30 | 31 | setWindowFlags(windowFlags() | Qt::WindowMinMaxButtonsHint); // Qt::WindowTitleHint 32 | 33 | connect(this, SIGNAL(resultSignal(QString)), this, SLOT(appendResult(QString))); 34 | 35 | ui->checkBoxScanSubdirectories->setChecked(true); 36 | 37 | if (sDirName != "") { 38 | ui->lineEditDirectoryName->setText(sDirName); 39 | } 40 | } 41 | 42 | DialogStaticScanDirectory::~DialogStaticScanDirectory() 43 | { 44 | delete ui; 45 | } 46 | 47 | void DialogStaticScanDirectory::on_pushButtonOpenDirectory_clicked() 48 | { 49 | QString sInitDirectory = ui->lineEditDirectoryName->text(); 50 | 51 | QString sDirectoryName = QFileDialog::getExistingDirectory(this, tr("Open directory") + QString("..."), sInitDirectory, QFileDialog::ShowDirsOnly); 52 | 53 | if (!sDirectoryName.isEmpty()) { 54 | ui->lineEditDirectoryName->setText(QDir().toNativeSeparators(sDirectoryName)); 55 | } 56 | } 57 | 58 | void DialogStaticScanDirectory::on_pushButtonScan_clicked() 59 | { 60 | QString sDirectoryName = ui->lineEditDirectoryName->text().trimmed(); 61 | 62 | scanDirectory(sDirectoryName); 63 | 64 | getGlobalOptions()->setLastDirectory(sDirectoryName); 65 | } 66 | 67 | void DialogStaticScanDirectory::scanDirectory(const QString &sDirectoryName) 68 | { 69 | if (sDirectoryName != "") { 70 | ui->textBrowserResult->clear(); 71 | 72 | g_scanOptions.bIsRecursiveScan = ui->checkBoxRecursiveScan->isChecked(); 73 | g_scanOptions.bIsDeepScan = ui->checkBoxDeepScan->isChecked(); 74 | g_scanOptions.bIsHeuristicScan = ui->checkBoxHeuristicScan->isChecked(); 75 | g_scanOptions.bIsVerbose = ui->checkBoxVerbose->isChecked(); 76 | g_scanOptions.bSubdirectories = ui->checkBoxScanSubdirectories->isChecked(); 77 | g_scanOptions.bIsAllTypesScan = ui->checkBoxAllTypesScan->isChecked(); 78 | // TODO Filter options 79 | // |flags|x all| 80 | 81 | DialogStaticScanProcess ds(this); 82 | connect(&ds, SIGNAL(scanResult(XScanEngine::SCAN_RESULT)), this, SLOT(scanResult(XScanEngine::SCAN_RESULT)), Qt::DirectConnection); 83 | ds.setData(sDirectoryName, &g_scanOptions); 84 | ds.showDialogDelay(); 85 | } 86 | } 87 | 88 | void DialogStaticScanDirectory::scanResult(XScanEngine::SCAN_RESULT scanResult) 89 | { 90 | QString sResult = QString("%1 %2 %3").arg(QDir().toNativeSeparators(scanResult.sFileName), QString::number(scanResult.nScanTime), tr("msec")); 91 | sResult += "\r\n"; // TODO Linux 92 | 93 | ScanItemModel model(&g_scanOptions, &(scanResult.listRecords), 1); 94 | 95 | sResult += model.toString(XBinary::FORMATTYPE_TEXT).toUtf8().data(); 96 | 97 | emit resultSignal(sResult); 98 | } 99 | 100 | void DialogStaticScanDirectory::appendResult(const QString &sResult) 101 | { 102 | ui->textBrowserResult->append(sResult); 103 | } 104 | 105 | void DialogStaticScanDirectory::on_pushButtonOK_clicked() 106 | { 107 | this->close(); 108 | } 109 | 110 | void DialogStaticScanDirectory::on_pushButtonClear_clicked() 111 | { 112 | ui->textBrowserResult->clear(); 113 | } 114 | 115 | void DialogStaticScanDirectory::on_pushButtonSave_clicked() 116 | { 117 | QString sFilter; 118 | sFilter += QString("%1 (*.txt)").arg(tr("Text documents")); 119 | QString sSaveFileName = ui->lineEditDirectoryName->text() + QDir::separator() + "result"; 120 | QString sFileName = QFileDialog::getSaveFileName(this, tr("Save result"), sSaveFileName, sFilter); 121 | 122 | if (!sFileName.isEmpty()) { 123 | QFile file; 124 | file.setFileName(sFileName); 125 | 126 | if (file.open(QIODevice::ReadWrite)) { 127 | QString sText = ui->textBrowserResult->toPlainText(); 128 | file.write(sText.toUtf8().data()); 129 | 130 | file.close(); 131 | } 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /heurwidget.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2020-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #include "heurwidget.h" 22 | 23 | #include "ui_heurwidget.h" 24 | 25 | HeurWidget::HeurWidget(QWidget *pParent) : XShortcutsWidget(pParent), ui(new Ui::HeurWidget) 26 | { 27 | ui->setupUi(this); 28 | 29 | this->g_pDevice = nullptr; 30 | this->g_fileType = XBinary::FT_UNKNOWN; 31 | 32 | ui->checkBoxDeepScan->setChecked(true); 33 | ui->checkBoxRecursiveScan->setChecked(true); 34 | ui->checkBoxHeuristicScan->setChecked(false); 35 | ui->checkBoxVerbose->setChecked(false); 36 | ui->checkBoxAllTypesScan->setChecked(false); 37 | } 38 | 39 | HeurWidget::~HeurWidget() 40 | { 41 | delete ui; 42 | } 43 | 44 | void HeurWidget::setData(QIODevice *pDevice, bool bAuto, XBinary::FT fileType) 45 | { 46 | this->g_pDevice = pDevice; 47 | this->g_fileType = fileType; 48 | 49 | XFormats::setFileTypeComboBox(fileType, pDevice, ui->comboBoxType); 50 | 51 | if (bAuto) { 52 | scan(); 53 | } 54 | } 55 | 56 | void HeurWidget::on_pushButtonScan_clicked() 57 | { 58 | scan(); 59 | } 60 | 61 | void HeurWidget::registerShortcuts(bool bState) 62 | { 63 | Q_UNUSED(bState) 64 | } 65 | 66 | void HeurWidget::on_pushButtonSave_clicked() 67 | { 68 | QAbstractItemModel *pModel = ui->treeViewScan->model(); 69 | 70 | if (pModel) { 71 | QString sSaveFileName = XBinary::getResultFileName(g_pDevice, QString("%1.txt").arg(tr("Result"))); 72 | 73 | DialogStaticScanProcess::saveResult(this, (ScanItemModel *)pModel, sSaveFileName); 74 | } 75 | } 76 | 77 | void HeurWidget::on_comboBoxType_currentIndexChanged(int nIndex) 78 | { 79 | Q_UNUSED(nIndex) 80 | 81 | scan(); 82 | } 83 | 84 | void HeurWidget::scan() 85 | { 86 | SpecAbstract::SCAN_RESULT scanResult = {}; 87 | SpecAbstract::SCAN_OPTIONS options = {}; 88 | 89 | options.bRecursiveScan = ui->checkBoxRecursiveScan->isChecked(); 90 | options.bDeepScan = ui->checkBoxDeepScan->isChecked(); 91 | options.bHeuristicScan = ui->checkBoxHeuristicScan->isChecked(); 92 | options.bVerbose = ui->checkBoxVerbose->isChecked(); 93 | options.bAllTypesScan = ui->checkBoxAllTypesScan->isChecked(); 94 | options.bShowDetects = true; 95 | options.fileType = (XBinary::FT)(ui->comboBoxType->currentData().toInt()); 96 | 97 | DialogStaticScanProcess dialogStaticScanProcess(this); 98 | dialogStaticScanProcess.setData(g_pDevice, &options, &scanResult); 99 | dialogStaticScanProcess.showDialogDelay(); 100 | 101 | QAbstractItemModel *pOldTreeModel = ui->treeViewScan->model(); 102 | 103 | QList _listRecords = SpecAbstract::convert(&(scanResult.listRecords)); 104 | 105 | ScanItemModel *pModel = new ScanItemModel(&_listRecords, 1); 106 | ui->treeViewScan->setModel(pModel); 107 | ui->treeViewScan->expandAll(); 108 | 109 | deleteOldAbstractModel(&pOldTreeModel); 110 | 111 | qint32 nNumberOfHeurs = scanResult.listHeurs.count(); 112 | 113 | QAbstractItemModel *pOldTableModel = ui->tableViewHeur->model(); 114 | 115 | QStandardItemModel *pHeurModel = new QStandardItemModel(nNumberOfHeurs, 3, this); 116 | 117 | pHeurModel->setHeaderData(0, Qt::Horizontal, tr("Type")); 118 | pHeurModel->setHeaderData(1, Qt::Horizontal, tr("Name")); 119 | pHeurModel->setHeaderData(2, Qt::Horizontal, tr("Value")); 120 | 121 | for (qint32 i = 0; i < nNumberOfHeurs; i++) { 122 | QStandardItem *pItemHeurType = new QStandardItem; 123 | pItemHeurType->setText(SpecAbstract::heurTypeIdToString(scanResult.listHeurs.at(i).detectType)); 124 | pHeurModel->setItem(i, 0, pItemHeurType); 125 | 126 | QStandardItem *pItemName = new QStandardItem; 127 | pItemName->setText( 128 | QString("%1(%2)[%3]") 129 | .arg(SpecAbstract::recordNameIdToString(scanResult.listHeurs.at(i).name), scanResult.listHeurs.at(i).sVersion, scanResult.listHeurs.at(i).sInfo)); 130 | pHeurModel->setItem(i, 1, pItemName); 131 | 132 | QStandardItem *pItemValue = new QStandardItem; 133 | pItemValue->setText(scanResult.listHeurs.at(i).sValue); 134 | pHeurModel->setItem(i, 2, pItemValue); 135 | } 136 | 137 | ui->tableViewHeur->setModel(pHeurModel); 138 | 139 | ui->tableViewHeur->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Interactive); 140 | ui->tableViewHeur->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Interactive); 141 | ui->tableViewHeur->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch); 142 | 143 | deleteOldAbstractModel(&pOldTableModel); 144 | } 145 | -------------------------------------------------------------------------------- /heurwidget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | HeurWidget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 858 10 | 479 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 0 19 | 20 | 21 | 0 22 | 23 | 24 | 0 25 | 26 | 27 | 0 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 120 36 | 0 37 | 38 | 39 | 40 | Type 41 | 42 | 43 | 44 | 0 45 | 46 | 47 | 0 48 | 49 | 50 | 0 51 | 52 | 53 | 0 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | Recursive scan 65 | 66 | 67 | true 68 | 69 | 70 | 71 | 72 | 73 | 74 | Deep scan 75 | 76 | 77 | true 78 | 79 | 80 | 81 | 82 | 83 | 84 | Heuristic scan 85 | 86 | 87 | true 88 | 89 | 90 | 91 | 92 | 93 | 94 | Verbose 95 | 96 | 97 | true 98 | 99 | 100 | 101 | 102 | 103 | 104 | Qt::Horizontal 105 | 106 | 107 | 108 | 40 109 | 20 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | All types 118 | 119 | 120 | 121 | 122 | 123 | 124 | Save 125 | 126 | 127 | 128 | 129 | 130 | 131 | Scan 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | Heuristic 144 | 145 | 146 | 147 | 0 148 | 149 | 150 | 0 151 | 152 | 153 | 0 154 | 155 | 156 | 0 157 | 158 | 159 | 160 | 161 | QAbstractItemView::NoEditTriggers 162 | 163 | 164 | QAbstractItemView::SingleSelection 165 | 166 | 167 | QAbstractItemView::SelectRows 168 | 169 | 170 | false 171 | 172 | 173 | 20 174 | 175 | 176 | 20 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | -------------------------------------------------------------------------------- /dialogstaticscandirectory.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | DialogStaticScanDirectory 4 | 5 | 6 | Qt::ApplicationModal 7 | 8 | 9 | 10 | 0 11 | 0 12 | 725 13 | 478 14 | 15 | 16 | 17 | Directory scan 18 | 19 | 20 | true 21 | 22 | 23 | 24 | 25 | 26 | Directory 27 | 28 | 29 | Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter 30 | 31 | 32 | 33 | 1 34 | 35 | 36 | 1 37 | 38 | 39 | 1 40 | 41 | 42 | 1 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | Subdirectories 55 | 56 | 57 | true 58 | 59 | 60 | 61 | 62 | 63 | 64 | Recursive scan 65 | 66 | 67 | true 68 | 69 | 70 | 71 | 72 | 73 | 74 | Deep scan 75 | 76 | 77 | true 78 | 79 | 80 | 81 | 82 | 83 | 84 | Heuristic scan 85 | 86 | 87 | true 88 | 89 | 90 | 91 | 92 | 93 | 94 | Verbose 95 | 96 | 97 | true 98 | 99 | 100 | 101 | 102 | 103 | 104 | All types 105 | 106 | 107 | 108 | 109 | 110 | 111 | Qt::Horizontal 112 | 113 | 114 | 115 | 158 116 | 20 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | true 132 | 133 | 134 | 135 | ... 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | true 144 | 145 | 146 | 147 | Scan 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | false 160 | 161 | 162 | true 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | Clear 172 | 173 | 174 | 175 | 176 | 177 | 178 | Save 179 | 180 | 181 | 182 | 183 | 184 | 185 | Qt::Horizontal 186 | 187 | 188 | 189 | 40 190 | 20 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | OK 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | -------------------------------------------------------------------------------- /staticscan.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #include "staticscan.h" 22 | 23 | StaticScan::StaticScan(QObject *pParent) : QObject(pParent) 24 | { 25 | g_pOptions = nullptr; 26 | g_pScanResult = nullptr; 27 | g_scanType = SCAN_TYPE_UNKNOWN; 28 | g_pDevice = nullptr; 29 | g_pData = nullptr; 30 | g_pPdStruct = nullptr; 31 | } 32 | 33 | void StaticScan::setData(const QString &sFileName, XScanEngine::SCAN_OPTIONS *pOptions, XScanEngine::SCAN_RESULT *pScanResult, XBinary::PDSTRUCT *pPdStruct) 34 | { 35 | g_sFileName = sFileName; 36 | g_pOptions = pOptions; 37 | g_pScanResult = pScanResult; 38 | g_pPdStruct = pPdStruct; 39 | 40 | g_scanType = SCAN_TYPE_FILE; 41 | } 42 | 43 | void StaticScan::setData(QIODevice *pDevice, XScanEngine::SCAN_OPTIONS *pOptions, XScanEngine::SCAN_RESULT *pScanResult, XBinary::PDSTRUCT *pPdStruct) 44 | { 45 | g_pDevice = pDevice; 46 | g_pOptions = pOptions; 47 | g_pScanResult = pScanResult; 48 | g_pPdStruct = pPdStruct; 49 | 50 | g_scanType = SCAN_TYPE_DEVICE; 51 | } 52 | 53 | void StaticScan::setData(char *pData, qint32 nDataSize, XScanEngine::SCAN_OPTIONS *pOptions, XScanEngine::SCAN_RESULT *pScanResult, XBinary::PDSTRUCT *pPdStruct) 54 | { 55 | g_pData = pData; 56 | g_nDataSize = nDataSize; 57 | g_pOptions = pOptions; 58 | g_pScanResult = pScanResult; 59 | g_pPdStruct = pPdStruct; 60 | 61 | g_scanType = SCAN_TYPE_MEMORY; 62 | } 63 | 64 | void StaticScan::setData(const QString &sDirectoryName, XScanEngine::SCAN_OPTIONS *pOptions, XBinary::PDSTRUCT *pPdStruct) 65 | { 66 | g_sDirectoryName = sDirectoryName; 67 | g_pOptions = pOptions; 68 | g_pPdStruct = pPdStruct; 69 | 70 | g_scanType = SCAN_TYPE_DIRECTORY; 71 | } 72 | 73 | void StaticScan::process() 74 | { 75 | XBinary::PDSTRUCT pdStructEmpty = XBinary::createPdStruct(); 76 | XBinary::PDSTRUCT *pPdStruct = g_pPdStruct; 77 | 78 | if (!pPdStruct) { 79 | pPdStruct = &pdStructEmpty; 80 | } 81 | 82 | QElapsedTimer scanTimer; 83 | scanTimer.start(); 84 | 85 | qint32 _nFreeIndex = XBinary::getFreeIndex(pPdStruct); 86 | XBinary::setPdStructInit(pPdStruct, _nFreeIndex, 0); 87 | 88 | if (g_scanType == SCAN_TYPE_FILE) { 89 | if ((g_pScanResult) && (g_sFileName != "")) { 90 | XBinary::setPdStructStatus(pPdStruct, _nFreeIndex, tr("File scan")); 91 | 92 | emit scanFileStarted(g_sFileName); 93 | 94 | *g_pScanResult = scanFile(g_sFileName, pPdStruct); 95 | 96 | emit scanResult(*g_pScanResult); 97 | } 98 | } else if (g_scanType == SCAN_TYPE_DEVICE) { 99 | if (g_pDevice) { 100 | XBinary::setPdStructStatus(pPdStruct, _nFreeIndex, tr("Device scan")); 101 | 102 | *g_pScanResult = scanDevice(g_pDevice, pPdStruct); 103 | 104 | emit scanResult(*g_pScanResult); 105 | } 106 | } else if (g_scanType == SCAN_TYPE_MEMORY) { 107 | XBinary::setPdStructStatus(pPdStruct, _nFreeIndex, tr("Memory scan")); 108 | 109 | *g_pScanResult = scanMemory(g_pData, g_nDataSize, pPdStruct); 110 | 111 | emit scanResult(*g_pScanResult); 112 | } else if (g_scanType == SCAN_TYPE_DIRECTORY) { 113 | if (g_sDirectoryName != "") { 114 | XBinary::setPdStructStatus(pPdStruct, _nFreeIndex, tr("Directory scan")); 115 | QList listFileNames; 116 | 117 | XBinary::findFiles(g_sDirectoryName, &listFileNames, g_pOptions->bSubdirectories, 0, pPdStruct); 118 | 119 | qint32 _nFreeIndexFiles = XBinary::getFreeIndex(pPdStruct); 120 | 121 | qint32 nTotal = listFileNames.count(); 122 | 123 | XBinary::setPdStructInit(pPdStruct, _nFreeIndexFiles, nTotal); 124 | 125 | for (qint32 i = 0; (i < nTotal) && (!(pPdStruct->bIsStop)); i++) { 126 | QString sFileName = listFileNames.at(i); 127 | 128 | XBinary::setPdStructCurrent(pPdStruct, _nFreeIndexFiles, i); 129 | XBinary::setPdStructStatus(pPdStruct, _nFreeIndexFiles, sFileName); 130 | 131 | emit scanFileStarted(sFileName); 132 | 133 | XScanEngine::SCAN_RESULT _scanResult = scanFile(sFileName, pPdStruct); 134 | 135 | emit scanResult(_scanResult); 136 | } 137 | 138 | XBinary::setPdStructFinished(pPdStruct, _nFreeIndexFiles); 139 | } 140 | } 141 | 142 | XBinary::setPdStructFinished(pPdStruct, _nFreeIndex); 143 | 144 | emit completed(scanTimer.elapsed()); 145 | } 146 | 147 | XScanEngine::SCAN_RESULT StaticScan::processDevice(QIODevice *pDevice, SpecAbstract::SCAN_OPTIONS *pOptions, XBinary::PDSTRUCT *pPdStruct) 148 | { 149 | XScanEngine::SCAN_RESULT result = {}; 150 | StaticScan scan; 151 | scan.setData(pDevice, pOptions, &result, pPdStruct); 152 | scan.process(); 153 | 154 | return result; 155 | } 156 | 157 | XScanEngine::SCAN_RESULT StaticScan::processFile(const QString &sFileName, SpecAbstract::SCAN_OPTIONS *pOptions, XBinary::PDSTRUCT *pPdStruct) 158 | { 159 | XScanEngine::SCAN_RESULT result = {}; 160 | StaticScan scan; 161 | scan.setData(sFileName, pOptions, &result, pPdStruct); 162 | scan.process(); 163 | 164 | return result; 165 | } 166 | 167 | XScanEngine::SCAN_RESULT StaticScan::processMemory(char *pData, qint32 nDataSize, SpecAbstract::SCAN_OPTIONS *pOptions, XBinary::PDSTRUCT *pPdStruct) 168 | { 169 | XScanEngine::SCAN_RESULT result = {}; 170 | StaticScan scan; 171 | scan.setData(pData, nDataSize, pOptions, &result, pPdStruct); 172 | scan.process(); 173 | 174 | return result; 175 | } 176 | 177 | XScanEngine::SCAN_RESULT StaticScan::processSubdevice(QIODevice *pDevice, qint64 nOffset, qint64 nSize, SpecAbstract::SCAN_OPTIONS *pOptions, 178 | XBinary::PDSTRUCT *pPdStruct) 179 | { 180 | XScanEngine::SCAN_RESULT result = {}; 181 | 182 | if (XBinary::isOffsetAndSizeValid(pDevice, nOffset, nSize)) { 183 | SubDevice sd(pDevice, nOffset, nSize); 184 | 185 | if (sd.open(QIODevice::ReadOnly)) { 186 | StaticScan scan; 187 | scan.setData(&sd, pOptions, &result, pPdStruct); 188 | scan.process(); 189 | 190 | sd.close(); 191 | } 192 | } 193 | 194 | return result; 195 | } 196 | 197 | QString StaticScan::getEngineVersion() 198 | { 199 | return SSE_VERSION; 200 | } 201 | 202 | // StaticScan::STATS StaticScan::getCurrentStats() 203 | //{ 204 | // if(g_pElapsedTimer) 205 | // { 206 | // if(g_pElapsedTimer->isValid()) 207 | // { 208 | // g_currentStats.nElapsed=g_pElapsedTimer->elapsed(); 209 | // } 210 | // else 211 | // { 212 | // g_currentStats.nElapsed=0; 213 | // } 214 | // } 215 | 216 | // if(g_pOptions) 217 | // { 218 | // g_currentStats.sStatus2=g_pOptions->sStatus; 219 | // } 220 | 221 | // return g_currentStats; 222 | //} 223 | 224 | void StaticScan::_process(QIODevice *pDevice, XScanEngine::SCAN_RESULT *pScanResult, qint64 nOffset, qint64 nSize, XScanEngine::SCANID parentId, 225 | SpecAbstract::SCAN_OPTIONS *pOptions, XBinary::PDSTRUCT *pPdStruct) 226 | { 227 | XBinary::PDSTRUCT pdStructEmpty = XBinary::createPdStruct(); 228 | 229 | if (!pPdStruct) { 230 | pPdStruct = &pdStructEmpty; 231 | } 232 | 233 | SpecAbstract().scanProcess(pDevice, pScanResult, nOffset, nSize, parentId, pOptions, true, pPdStruct); 234 | } 235 | 236 | XScanEngine::SCAN_RESULT StaticScan::scanFile(const QString &sFileName, XBinary::PDSTRUCT *pPdStruct) 237 | { 238 | XScanEngine::SCAN_RESULT result = {}; 239 | 240 | if (sFileName != "") { 241 | QFile file; 242 | file.setFileName(sFileName); 243 | 244 | if (file.open(QIODevice::ReadOnly)) { 245 | result = scanDevice(&file, pPdStruct); 246 | 247 | file.close(); 248 | } 249 | } 250 | 251 | return result; 252 | } 253 | 254 | XScanEngine::SCAN_RESULT StaticScan::scanDevice(QIODevice *pDevice, XBinary::PDSTRUCT *pPdStruct) 255 | { 256 | XScanEngine::SCAN_RESULT result = {}; 257 | 258 | XScanEngine::SCANID parentId = {}; 259 | parentId.fileType = XBinary::FT_UNKNOWN; 260 | 261 | if (g_pOptions->initFilePart == XBinary::FILEPART_UNKNOWN) { 262 | parentId.filePart = XBinary::FILEPART_HEADER; 263 | } else { 264 | parentId.filePart = g_pOptions->initFilePart; 265 | } 266 | 267 | _process(pDevice, &result, 0, pDevice->size(), parentId, g_pOptions, pPdStruct); 268 | 269 | return result; 270 | } 271 | 272 | XScanEngine::SCAN_RESULT StaticScan::scanMemory(char *pData, qint32 nSize, XBinary::PDSTRUCT *pPdStruct) 273 | { 274 | XScanEngine::SCAN_RESULT result = {}; 275 | 276 | QBuffer buffer; 277 | 278 | buffer.setData(pData, nSize); 279 | 280 | if (buffer.open(QIODevice::ReadOnly)) { 281 | result = scanDevice(&buffer, pPdStruct); 282 | 283 | buffer.close(); 284 | } 285 | 286 | return result; 287 | } 288 | -------------------------------------------------------------------------------- /staticscanitemmodel.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2021 hors 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | // SOFTWARE. 20 | // 21 | #include "staticscanitemmodel.h" 22 | 23 | StaticScanItemModel::StaticScanItemModel(QList *pListScanStructs, QObject *pParent, int nNumberOfColumns) 24 | : QAbstractItemModel(pParent) 25 | { 26 | g_pRootItem=new StaticScanItem(tr("Result"),nullptr,nNumberOfColumns); 27 | SpecAbstract::SCAN_STRUCT emptySS={}; 28 | g_pRootItem->setScanStruct(emptySS); 29 | 30 | QMap mapParents; 31 | 32 | qint32 nNumberOfDetects=pListScanStructs->count(); 33 | 34 | for(qint32 i=0;iat(i).id.sUuid)) 37 | { 38 | StaticScanItem *_itemParent; 39 | 40 | if(pListScanStructs->at(i).parentId.sUuid=="") 41 | { 42 | _itemParent=g_pRootItem; 43 | } 44 | else 45 | { 46 | _itemParent=mapParents.value(pListScanStructs->at(i).parentId.sUuid); 47 | } 48 | 49 | QString sParent=SpecAbstract::createTypeString(&pListScanStructs->at(i)); 50 | 51 | StaticScanItem *pItemParent=new StaticScanItem(sParent,_itemParent,nNumberOfColumns); 52 | SpecAbstract::SCAN_STRUCT ss=SpecAbstract::createHeaderScanStruct(&pListScanStructs->at(i)); 53 | pItemParent->setScanStruct(ss); 54 | _itemParent->appendChild(pItemParent); 55 | 56 | mapParents.insert(pListScanStructs->at(i).id.sUuid,pItemParent); 57 | } 58 | 59 | StaticScanItem *pItemParent=mapParents.value(pListScanStructs->at(i).id.sUuid); 60 | 61 | QString sItem=SpecAbstract::createResultString2(&pListScanStructs->at(i)); 62 | StaticScanItem *pItem=new StaticScanItem(sItem,pItemParent,nNumberOfColumns); 63 | pItem->setScanStruct(pListScanStructs->at(i)); 64 | pItemParent->appendChild(pItem); 65 | } 66 | } 67 | 68 | StaticScanItemModel::~StaticScanItemModel() 69 | { 70 | delete g_pRootItem; 71 | } 72 | 73 | QVariant StaticScanItemModel::headerData(int nSection, Qt::Orientation orientation, int nRole) const 74 | { 75 | QVariant result; 76 | 77 | if((orientation==Qt::Horizontal)&&(nRole==Qt::DisplayRole)) 78 | { 79 | result=g_pRootItem->data(nSection); 80 | } 81 | 82 | return result; 83 | } 84 | 85 | QModelIndex StaticScanItemModel::index(int nRow, int nColumn, const QModelIndex &parent) const 86 | { 87 | QModelIndex result; 88 | 89 | if(hasIndex(nRow, nColumn, parent)) 90 | { 91 | StaticScanItem *pParentItem=nullptr; 92 | 93 | if(!parent.isValid()) 94 | { 95 | pParentItem=g_pRootItem; 96 | } 97 | else 98 | { 99 | pParentItem=static_cast(parent.internalPointer()); 100 | } 101 | 102 | StaticScanItem *pChildItem=pParentItem->child(nRow); 103 | 104 | if(pChildItem) 105 | { 106 | result=createIndex(nRow, nColumn, pChildItem); 107 | } 108 | } 109 | 110 | return result; 111 | } 112 | 113 | QModelIndex StaticScanItemModel::parent(const QModelIndex &index) const 114 | { 115 | QModelIndex result; 116 | 117 | if(index.isValid()) 118 | { 119 | StaticScanItem *pChildItem=static_cast(index.internalPointer()); 120 | StaticScanItem *pParentItem=pChildItem->getParentItem(); 121 | 122 | if(pParentItem!=g_pRootItem) 123 | { 124 | result=createIndex(pParentItem->row(),0,pParentItem); 125 | } 126 | } 127 | 128 | return result; 129 | } 130 | 131 | int StaticScanItemModel::rowCount(const QModelIndex &parent) const 132 | { 133 | int nResult=0; 134 | 135 | if(parent.column()<=0) 136 | { 137 | StaticScanItem *pParentItem=nullptr; 138 | 139 | if(!parent.isValid()) 140 | { 141 | pParentItem=g_pRootItem; 142 | } 143 | else 144 | { 145 | pParentItem=static_cast(parent.internalPointer()); 146 | } 147 | 148 | nResult=pParentItem->childCount(); 149 | } 150 | 151 | return nResult; 152 | } 153 | 154 | int StaticScanItemModel::columnCount(const QModelIndex &parent) const 155 | { 156 | int nResult=0; 157 | 158 | if(parent.isValid()) 159 | { 160 | nResult=static_cast(parent.internalPointer())->columnCount(); 161 | } 162 | else 163 | { 164 | nResult=g_pRootItem->columnCount(); 165 | } 166 | 167 | return nResult; 168 | } 169 | 170 | QVariant StaticScanItemModel::data(const QModelIndex &index, int nRole) const 171 | { 172 | QVariant result; 173 | 174 | if(index.isValid()) 175 | { 176 | StaticScanItem *pItem=static_cast(index.internalPointer()); 177 | 178 | if(nRole==Qt::DisplayRole) 179 | { 180 | result=pItem->data(index.column()); 181 | } 182 | #ifdef QT_GUI_LIB 183 | else if(nRole==Qt::ForegroundRole) 184 | { 185 | SpecAbstract::RECORD_TYPE rt=pItem->scanStruct().type; 186 | 187 | // TODO more 188 | if( (rt==SpecAbstract::RECORD_TYPE_INSTALLER)|| 189 | (rt==SpecAbstract::RECORD_TYPE_SFX)) 190 | { 191 | result=QVariant(QColor(Qt::blue)); 192 | } 193 | else if((rt==SpecAbstract::RECORD_TYPE_PROTECTOR)|| 194 | (rt==SpecAbstract::RECORD_TYPE_APKOBFUSCATOR)|| 195 | (rt==SpecAbstract::RECORD_TYPE_JAROBFUSCATOR)|| 196 | (rt==SpecAbstract::RECORD_TYPE_NETOBFUSCATOR)|| 197 | (rt==SpecAbstract::RECORD_TYPE_NETCOMPRESSOR)|| 198 | (rt==SpecAbstract::RECORD_TYPE_DONGLEPROTECTION)|| 199 | (rt==SpecAbstract::RECORD_TYPE_JOINER)|| 200 | (rt==SpecAbstract::RECORD_TYPE_PACKER)) 201 | { 202 | result=QVariant(QColor(Qt::red)); 203 | } 204 | else if((rt==SpecAbstract::RECORD_TYPE_PETOOL)|| 205 | (rt==SpecAbstract::RECORD_TYPE_APKTOOL)) 206 | { 207 | result=QVariant(QColor(Qt::green)); 208 | } 209 | else if((rt==SpecAbstract::RECORD_TYPE_OPERATIONSYSTEM)|| 210 | (rt==SpecAbstract::RECORD_TYPE_VIRTUALMACHINE)) 211 | { 212 | result=QVariant(QColor(Qt::darkYellow)); 213 | } 214 | else if(rt==SpecAbstract::RECORD_TYPE_SIGNTOOL) 215 | { 216 | result=QVariant(QColor(Qt::darkMagenta)); 217 | } 218 | else if(rt==SpecAbstract::RECORD_TYPE_LANGUAGE) 219 | { 220 | result=QVariant(QColor(Qt::darkCyan)); 221 | } 222 | else 223 | { 224 | result=QVariant(QApplication::palette().text().color()); 225 | } 226 | } 227 | #endif 228 | } 229 | 230 | return result; 231 | } 232 | 233 | Qt::ItemFlags StaticScanItemModel::flags(const QModelIndex &index) const 234 | { 235 | Qt::ItemFlags result=Qt::NoItemFlags; 236 | 237 | if(index.isValid()) 238 | { 239 | result=QAbstractItemModel::flags(index); 240 | } 241 | 242 | return result; 243 | } 244 | 245 | QString StaticScanItemModel::toXML() 246 | { 247 | QString sResult; 248 | QXmlStreamWriter xml(&sResult); 249 | 250 | xml.setAutoFormatting(true); 251 | 252 | _toXML(&xml,g_pRootItem); 253 | 254 | return sResult; 255 | } 256 | 257 | QString StaticScanItemModel::toJSON() 258 | { 259 | QString sResult; 260 | 261 | QJsonObject jsonResult; 262 | 263 | _toJSON(&jsonResult,g_pRootItem); 264 | 265 | QJsonDocument saveFormat(jsonResult); 266 | 267 | sResult=saveFormat.toJson(QJsonDocument::Indented).data(); 268 | 269 | return sResult; 270 | } 271 | 272 | QString StaticScanItemModel::toCSV() 273 | { 274 | QString sResult; 275 | 276 | _toCSV(&sResult,g_pRootItem); 277 | 278 | return sResult; 279 | } 280 | 281 | QString StaticScanItemModel::toTSV() 282 | { 283 | QString sResult; 284 | 285 | _toTSV(&sResult,g_pRootItem); 286 | 287 | return sResult; 288 | } 289 | 290 | QString StaticScanItemModel::toFormattedString() 291 | { 292 | QString sResult; 293 | 294 | _toString(&sResult,g_pRootItem,0); 295 | 296 | return sResult; 297 | } 298 | 299 | QString StaticScanItemModel::toString(SpecAbstract::SCAN_OPTIONS *pScanOptions) 300 | { 301 | QString sResult; 302 | 303 | if(pScanOptions->bResultAsXML) 304 | { 305 | sResult=toXML(); 306 | } 307 | else if(pScanOptions->bResultAsJSON) 308 | { 309 | sResult=toJSON(); 310 | } 311 | else if(pScanOptions->bResultAsCSV) 312 | { 313 | sResult=toCSV(); 314 | } 315 | else if(pScanOptions->bResultAsTSV) 316 | { 317 | sResult=toTSV(); 318 | } 319 | else 320 | { 321 | sResult=toFormattedString(); 322 | } 323 | 324 | return sResult; 325 | } 326 | 327 | StaticScanItem *StaticScanItemModel::rootItem() 328 | { 329 | return this->g_pRootItem; 330 | } 331 | 332 | void StaticScanItemModel::_toXML(QXmlStreamWriter *pXml, StaticScanItem *pItem) 333 | { 334 | if(pItem->childCount()) 335 | { 336 | pXml->writeStartElement(pItem->data(0).toString()); 337 | 338 | qint32 nNumberOfChildren=pItem->childCount(); 339 | 340 | for(qint32 i=0;ichild(i)); 343 | } 344 | 345 | pXml->writeEndElement(); 346 | } 347 | else 348 | { 349 | SpecAbstract::SCAN_STRUCT ss=pItem->scanStruct(); 350 | 351 | pXml->writeStartElement("detect"); 352 | pXml->writeAttribute("type",SpecAbstract::recordTypeIdToString(ss.type)); 353 | pXml->writeAttribute("name",SpecAbstract::recordNameIdToString(ss.name)); 354 | pXml->writeAttribute("version",ss.sVersion); 355 | pXml->writeAttribute("info",ss.sInfo); 356 | pXml->writeCharacters(pItem->data(0).toString()); 357 | pXml->writeEndElement(); 358 | } 359 | } 360 | 361 | void StaticScanItemModel::_toJSON(QJsonObject *pJsonObject, StaticScanItem *pItem) 362 | { 363 | if(pItem->childCount()) 364 | { 365 | SpecAbstract::SCAN_STRUCT ss=pItem->scanStruct(); 366 | 367 | QString sArrayName="detects"; 368 | 369 | if(ss.id.filePart!=XBinary::FILEPART_UNKNOWN) 370 | { 371 | pJsonObject->insert("parentfilepart",XBinary::recordFilePartIdToString(ss.parentId.filePart)); 372 | pJsonObject->insert("filetype",XBinary::fileTypeIdToString(ss.id.fileType)); 373 | 374 | sArrayName="values"; 375 | } 376 | 377 | QJsonArray jsArray; 378 | 379 | qint32 nNumberOfChildren=pItem->childCount(); 380 | 381 | for(qint32 i=0;ichild(i)); 386 | 387 | jsArray.append(jsRecord); 388 | } 389 | 390 | pJsonObject->insert(sArrayName,jsArray); 391 | } 392 | else 393 | { 394 | SpecAbstract::SCAN_STRUCT ss=pItem->scanStruct(); 395 | 396 | pJsonObject->insert("type",SpecAbstract::recordTypeIdToString(ss.type)); 397 | pJsonObject->insert("name",SpecAbstract::recordNameIdToString(ss.name)); 398 | pJsonObject->insert("version",ss.sVersion); 399 | pJsonObject->insert("info",ss.sInfo); 400 | pJsonObject->insert("string",pItem->data(0).toString()); 401 | } 402 | } 403 | 404 | void StaticScanItemModel::_toCSV(QString *pString, StaticScanItem *pItem) 405 | { 406 | if(pItem->childCount()) 407 | { 408 | qint32 nNumberOfChildren=pItem->childCount(); 409 | 410 | for(qint32 i=0;ichild(i)); 413 | } 414 | } 415 | else 416 | { 417 | SpecAbstract::SCAN_STRUCT ss=pItem->scanStruct(); 418 | 419 | QString sResult=QString("%1;%2;%3;%4;%5\n") 420 | .arg(SpecAbstract::recordTypeIdToString(ss.type), 421 | SpecAbstract::recordNameIdToString(ss.name), 422 | ss.sVersion, 423 | ss.sInfo, 424 | pItem->data(0).toString()); 425 | 426 | pString->append(sResult); 427 | } 428 | } 429 | 430 | void StaticScanItemModel::_toTSV(QString *pString, StaticScanItem *pItem) 431 | { 432 | if(pItem->childCount()) 433 | { 434 | qint32 nNumberOfChildren=pItem->childCount(); 435 | 436 | for(qint32 i=0;ichild(i)); 439 | } 440 | } 441 | else 442 | { 443 | SpecAbstract::SCAN_STRUCT ss=pItem->scanStruct(); 444 | 445 | QString sResult=QString("%1\t%2\t%3\t%4\t%5\n").arg( 446 | SpecAbstract::recordTypeIdToString(ss.type), 447 | SpecAbstract::recordNameIdToString(ss.name), 448 | ss.sVersion, 449 | ss.sInfo, 450 | pItem->data(0).toString() 451 | ); 452 | 453 | pString->append(sResult); 454 | } 455 | } 456 | 457 | void StaticScanItemModel::_toString(QString *pString, StaticScanItem *pItem, qint32 nLevel) 458 | { 459 | if(nLevel) 460 | { 461 | QString sResult; 462 | sResult=sResult.leftJustified(4*(nLevel-1),' '); // TODO function 463 | sResult.append(QString("%1\n").arg(pItem->data(0).toString())); 464 | pString->append(sResult); 465 | } 466 | 467 | if(pItem->childCount()) 468 | { 469 | qint32 nNumberOfChildren=pItem->childCount(); 470 | 471 | for(qint32 i=0;ichild(i),nLevel+1); 474 | } 475 | } 476 | } 477 | --------------------------------------------------------------------------------