├── README.md ├── xfileinfowidget.pri ├── xfileinfowidget.cmake ├── xfileinfo.pri ├── LICENSE ├── xfileinfo.cmake ├── dialogxfileinfo.h ├── dialogxfileinfo.cpp ├── xfileinfoitem.h ├── dialogxfileinfo.ui ├── xfileinfowidget.h ├── xfileinfoitem.cpp ├── xfileinfomodel.h ├── xfileinfo.h ├── xfileinfowidget.ui ├── xfileinfowidget.cpp ├── xfileinfomodel.cpp └── xfileinfo.cpp /README.md: -------------------------------------------------------------------------------- 1 | # XFileInfo -------------------------------------------------------------------------------- /xfileinfowidget.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD 2 | DEPENDPATH += $$PWD 3 | 4 | HEADERS += \ 5 | $$PWD/dialogxfileinfo.h \ 6 | $$PWD/xfileinfowidget.h 7 | 8 | SOURCES += \ 9 | $$PWD/dialogxfileinfo.cpp \ 10 | $$PWD/xfileinfowidget.cpp 11 | 12 | FORMS += \ 13 | $$PWD/dialogxfileinfo.ui \ 14 | $$PWD/xfileinfowidget.ui 15 | 16 | !contains(XCONFIG, xfileinfo) { 17 | XCONFIG += xfileinfo 18 | include($$PWD/xfileinfo.pri) 19 | } 20 | 21 | !contains(XCONFIG, xdialogprocess) { 22 | XCONFIG += xdialogprocess 23 | include($$PWD/../FormatDialogs/xdialogprocess.pri) 24 | } 25 | 26 | DISTFILES += \ 27 | $$PWD/LICENSE \ 28 | $$PWD/README.md \ 29 | $$PWD/xfileinfowidget.cmake 30 | -------------------------------------------------------------------------------- /xfileinfowidget.cmake: -------------------------------------------------------------------------------- 1 | include_directories(${CMAKE_CURRENT_LIST_DIR}) 2 | 3 | if (NOT DEFINED XFILEINFO_SOURCES) 4 | include(${CMAKE_CURRENT_LIST_DIR}/xfileinfo.cmake) 5 | set(XFILEINFOWIDGET_SOURCES ${XFILEINFOWIDGET_SOURCES} ${XFILEINFO_SOURCES}) 6 | endif() 7 | if (NOT DEFINED XDIALOGPROCESS_SOURCES) 8 | include(${CMAKE_CURRENT_LIST_DIR}/../FormatDialogs/xdialogprocess.cmake) 9 | set(XFILEINFOWIDGET_SOURCES ${XFILEINFOWIDGET_SOURCES} ${XDIALOGPROCESS_SOURCES}) 10 | endif() 11 | 12 | set(XFILEINFOWIDGET_SOURCES 13 | ${XFILEINFOWIDGET_SOURCES} 14 | ${CMAKE_CURRENT_LIST_DIR}/xfileinfowidget.cpp 15 | ${CMAKE_CURRENT_LIST_DIR}/xfileinfowidget.h 16 | ${CMAKE_CURRENT_LIST_DIR}/xfileinfowidget.ui 17 | ${CMAKE_CURRENT_LIST_DIR}/dialogxfileinfo.cpp 18 | ${CMAKE_CURRENT_LIST_DIR}/dialogxfileinfo.h 19 | ${CMAKE_CURRENT_LIST_DIR}/dialogxfileinfo.ui 20 | ) 21 | -------------------------------------------------------------------------------- /xfileinfo.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD 2 | DEPENDPATH += $$PWD 3 | 4 | HEADERS += \ 5 | $$PWD/xfileinfo.h \ 6 | $$PWD/xfileinfoitem.h \ 7 | $$PWD/xfileinfomodel.h 8 | 9 | SOURCES += \ 10 | $$PWD/xfileinfo.cpp \ 11 | $$PWD/xfileinfoitem.cpp \ 12 | $$PWD/xfileinfomodel.cpp 13 | 14 | !contains(XCONFIG, xformats) { 15 | XCONFIG += xformats 16 | include($$PWD/../Formats/xformats.pri) 17 | } 18 | 19 | contains(XCONFIG, use_capstone_x86) { 20 | !contains(XCONFIG, xcapstone_x86) { 21 | XCONFIG += xcapstone_x86 22 | include($$PWD/../XCapstone/xcapstone_x86.pri) 23 | } 24 | } 25 | 26 | !contains(XCONFIG, use_capstone_x86) { 27 | !contains(XCONFIG, xcapstone) { 28 | XCONFIG += xcapstone 29 | include($$PWD/../XCapstone/xcapstone.pri) 30 | } 31 | } 32 | 33 | DISTFILES += \ 34 | $$PWD/LICENSE \ 35 | $$PWD/README.md \ 36 | $$PWD/xfileinfo.cmake 37 | 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021-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 | -------------------------------------------------------------------------------- /xfileinfo.cmake: -------------------------------------------------------------------------------- 1 | include_directories(${CMAKE_CURRENT_LIST_DIR}) 2 | 3 | if (NOT DEFINED XFORMATS_SOURCES) 4 | include(${CMAKE_CURRENT_LIST_DIR}/../Formats/xformats.cmake) 5 | set(XFILEINFO_SOURCES ${XFILEINFO_SOURCES} ${XFORMATS_SOURCES}) 6 | endif() 7 | if (NOT DEFINED XDEX_SOURCES) 8 | include(${CMAKE_CURRENT_LIST_DIR}/../XDEX/xdex.cmake) 9 | set(XFILEINFO_SOURCES ${XFILEINFO_SOURCES} ${XDEX_SOURCES}) 10 | endif() 11 | if (NOT DEFINED XPDF_SOURCES) 12 | include(${CMAKE_CURRENT_LIST_DIR}/../XPDF/xpdf.cmake) 13 | set(XFILEINFO_SOURCES ${XFILEINFO_SOURCES} ${XPDF_SOURCES}) 14 | endif() 15 | if (NOT DEFINED XARCHIVES_SOURCES) 16 | include(${CMAKE_CURRENT_LIST_DIR}/../XArchive/xarchives.cmake) 17 | set(XFILEINFO_SOURCES ${XFILEINFO_SOURCES} ${XARCHIVES_SOURCES}) 18 | endif() 19 | if (NOT DEFINED XDISASMCORE_SOURCES) 20 | include(${CMAKE_CURRENT_LIST_DIR}/../XDisasmCore/xdisasmcore.cmake) 21 | set(XFILEINFO_SOURCES ${XFILEINFO_SOURCES} ${XDISASMCORE_SOURCES}) 22 | endif() 23 | if (NOT DEFINED XOPTIONS_SOURCES) 24 | include(${CMAKE_CURRENT_LIST_DIR}/../XOptions/xoptions.cmake) 25 | set(XFILEINFO_SOURCES ${XFILEINFO_SOURCES} ${XOPTIONS_SOURCES}) 26 | endif() 27 | 28 | set(XFILEINFO_SOURCES 29 | ${XFILEINFO_SOURCES} 30 | ${CMAKE_CURRENT_LIST_DIR}/xfileinfo.cpp 31 | ${CMAKE_CURRENT_LIST_DIR}/xfileinfo.h 32 | ${CMAKE_CURRENT_LIST_DIR}/xfileinfoitem.cpp 33 | ${CMAKE_CURRENT_LIST_DIR}/xfileinfoitem.h 34 | ${CMAKE_CURRENT_LIST_DIR}/xfileinfomodel.cpp 35 | ${CMAKE_CURRENT_LIST_DIR}/xfileinfomodel.h 36 | ) 37 | -------------------------------------------------------------------------------- /dialogxfileinfo.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021-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 11 | * all 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 DIALOGXFILEINFO_H 22 | #define DIALOGXFILEINFO_H 23 | 24 | #include "xfileinfowidget.h" 25 | #include "xshortcutsdialog.h" 26 | 27 | namespace Ui { 28 | class DialogXFileInfo; 29 | } 30 | 31 | class DialogXFileInfo : public XShortcutsDialog { 32 | Q_OBJECT 33 | 34 | public: 35 | explicit DialogXFileInfo(QWidget *pParent = nullptr); 36 | ~DialogXFileInfo(); 37 | 38 | virtual void setGlobal(XShortcuts *pShortcuts, XOptions *pXOptions); 39 | void setData(QIODevice *pDevice, XBinary::FT fileType, const QString &sString, bool bAuto = false); 40 | 41 | private slots: 42 | void on_pushButtonClose_clicked(); 43 | 44 | private: 45 | Ui::DialogXFileInfo *ui; 46 | }; 47 | 48 | #endif // DIALOGXFILEINFO_H 49 | -------------------------------------------------------------------------------- /dialogxfileinfo.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021-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 11 | * all 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 "dialogxfileinfo.h" 22 | 23 | #include "ui_dialogxfileinfo.h" 24 | 25 | DialogXFileInfo::DialogXFileInfo(QWidget *pParent) : XShortcutsDialog(pParent, true), ui(new Ui::DialogXFileInfo) 26 | { 27 | ui->setupUi(this); 28 | } 29 | 30 | DialogXFileInfo::~DialogXFileInfo() 31 | { 32 | delete ui; 33 | } 34 | 35 | void DialogXFileInfo::setGlobal(XShortcuts *pShortcuts, XOptions *pXOptions) 36 | { 37 | ui->widget->setGlobal(pShortcuts, pXOptions); 38 | } 39 | 40 | void DialogXFileInfo::setData(QIODevice *pDevice, XBinary::FT fileType, const QString &sString, bool bAuto) 41 | { 42 | ui->widget->setData(pDevice, fileType, sString, bAuto); 43 | } 44 | 45 | void DialogXFileInfo::on_pushButtonClose_clicked() 46 | { 47 | this->close(); 48 | } 49 | -------------------------------------------------------------------------------- /xfileinfoitem.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021-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 11 | * all 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 XFILEINFOITEM_H 22 | #define XFILEINFOITEM_H 23 | 24 | #include 25 | 26 | class XFileInfoItem { 27 | public: 28 | XFileInfoItem(const QString &sName, const QVariant &varValue, XFileInfoItem *pParentItem = nullptr); 29 | ~XFileInfoItem(); 30 | 31 | void appendChild(XFileInfoItem *pItemChild); 32 | XFileInfoItem *child(int nRow); 33 | int childCount() const; 34 | int columnCount() const; 35 | QVariant data(int nColumn) const; 36 | QString getName(); 37 | QVariant getValue(); 38 | int row() const; 39 | XFileInfoItem *getParentItem(); 40 | 41 | private: 42 | QList m_listChildItems; 43 | QString m_sName; 44 | QVariant m_varValue; 45 | XFileInfoItem *m_pParentItem; 46 | }; 47 | 48 | #endif // XFILEINFOITEM_H 49 | -------------------------------------------------------------------------------- /dialogxfileinfo.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | DialogXFileInfo 4 | 5 | 6 | Qt::ApplicationModal 7 | 8 | 9 | 10 | 0 11 | 0 12 | 816 13 | 488 14 | 15 | 16 | 17 | Info 18 | 19 | 20 | true 21 | 22 | 23 | 24 | 25 | 26 | 27 | 0 28 | 0 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | Qt::Horizontal 39 | 40 | 41 | 42 | 40 43 | 20 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | Close 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | XFileInfoWidget 62 | QWidget 63 |
xfileinfowidget.h
64 | 1 65 |
66 |
67 | 68 | 69 |
70 | -------------------------------------------------------------------------------- /xfileinfowidget.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021-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 11 | * all 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 XFILEINFOWIDGET_H 22 | #define XFILEINFOWIDGET_H 23 | 24 | #include 25 | 26 | #include "xdialogprocess.h" 27 | #include "xfileinfo.h" 28 | #include "xfileinfo.h" 29 | #include "xshortcutswidget.h" 30 | 31 | namespace Ui { 32 | class XFileInfoWidget; 33 | } 34 | 35 | class XFileInfoWidget : public XShortcutsWidget { 36 | Q_OBJECT 37 | 38 | enum SM { 39 | SM_TEXT = 0, 40 | SM_JSON, 41 | SM_XML 42 | // mb CSV, TSV 43 | }; 44 | 45 | public: 46 | explicit XFileInfoWidget(QWidget *pParent = nullptr); 47 | ~XFileInfoWidget(); 48 | 49 | void setData(QIODevice *pDevice, XBinary::FT fileType, const QString &sString, bool bAuto = false); 50 | void reload(); 51 | virtual void adjustView(); 52 | virtual void reloadData(bool bSaveSelection); 53 | 54 | protected: 55 | virtual void registerShortcuts(bool bState); 56 | 57 | private slots: 58 | void on_toolButtonSave_clicked(); 59 | void on_toolButtonReload_clicked(); 60 | void on_checkBoxComment_toggled(bool bChecked); 61 | void on_comboBoxType_currentIndexChanged(int nIndex); 62 | void on_comboBoxMethod_currentIndexChanged(int nIndex); 63 | void reloadType(); 64 | void on_comboBoxOutput_currentIndexChanged(int nIndex); 65 | 66 | private: 67 | Ui::XFileInfoWidget *ui; 68 | QIODevice *m_pDevice; 69 | qint64 m_nOffset; 70 | qint64 m_nSize; 71 | }; 72 | 73 | #endif // XFILEINFOWIDGET_H 74 | -------------------------------------------------------------------------------- /xfileinfoitem.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021-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 11 | * all 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 "xfileinfoitem.h" 22 | 23 | XFileInfoItem::XFileInfoItem(const QString &sName, const QVariant &varValue, XFileInfoItem *pParentItem) 24 | { 25 | this->m_pParentItem = pParentItem; 26 | this->m_sName = sName; 27 | this->m_varValue = varValue; 28 | } 29 | 30 | XFileInfoItem::~XFileInfoItem() 31 | { 32 | qDeleteAll(m_listChildItems); 33 | } 34 | 35 | void XFileInfoItem::appendChild(XFileInfoItem *pItemChild) 36 | { 37 | m_listChildItems.append(pItemChild); 38 | } 39 | 40 | XFileInfoItem *XFileInfoItem::child(int nRow) 41 | { 42 | return m_listChildItems.value(nRow); 43 | } 44 | 45 | int XFileInfoItem::childCount() const 46 | { 47 | return m_listChildItems.count(); 48 | } 49 | 50 | int XFileInfoItem::columnCount() const 51 | { 52 | return 1; 53 | } 54 | 55 | QVariant XFileInfoItem::data(int nColumn) const 56 | { 57 | QVariant result; 58 | 59 | if (nColumn == 0) { 60 | result = m_sName; 61 | } 62 | 63 | return result; 64 | } 65 | 66 | QString XFileInfoItem::getName() 67 | { 68 | return m_sName; 69 | } 70 | 71 | QVariant XFileInfoItem::getValue() 72 | { 73 | return m_varValue; 74 | } 75 | 76 | int XFileInfoItem::row() const 77 | { 78 | int nResult = 0; 79 | 80 | if (m_pParentItem) { 81 | nResult = m_pParentItem->m_listChildItems.indexOf(const_cast(this)); 82 | } 83 | 84 | return nResult; 85 | } 86 | 87 | XFileInfoItem *XFileInfoItem::getParentItem() 88 | { 89 | return m_pParentItem; 90 | } 91 | -------------------------------------------------------------------------------- /xfileinfomodel.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021-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 11 | * all 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 XFILEINFOMODEL_H 22 | #define XFILEINFOMODEL_H 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "xfileinfoitem.h" 31 | 32 | class XFileInfoModel : public QAbstractItemModel { 33 | Q_OBJECT 34 | public: 35 | explicit XFileInfoModel(QObject *pParent = nullptr); 36 | ~XFileInfoModel() override; 37 | 38 | QVariant headerData(int nSection, Qt::Orientation orientation, int nRole = Qt::DisplayRole) const override; 39 | QModelIndex index(int nRow, int nColumn, const QModelIndex &parent = QModelIndex()) const override; 40 | QModelIndex parent(const QModelIndex &index) const override; 41 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; 42 | int columnCount(const QModelIndex &parent = QModelIndex()) const override; 43 | QVariant data(const QModelIndex &index, int nRole = Qt::DisplayRole) const override; 44 | Qt::ItemFlags flags(const QModelIndex &index) const override; 45 | void appendChild(XFileInfoItem *pItemChild); 46 | 47 | QString toXML(); 48 | QString toJSON(); 49 | QString toCSV(); 50 | QString toTSV(); 51 | QString toFormattedString(); 52 | 53 | private: 54 | void _toXML(QXmlStreamWriter *pXml, XFileInfoItem *pItem, qint32 nLevel); 55 | void _toJSON(QJsonObject *pJsonObject, XFileInfoItem *pItem, qint32 nLevel); 56 | void _toCSV(QString *pString, XFileInfoItem *pItem, qint32 nLevel); 57 | void _toTSV(QString *pString, XFileInfoItem *pItem, qint32 nLevel); 58 | void _toFormattedString(QString *pString, XFileInfoItem *pItem, qint32 nLevel); 59 | 60 | private: 61 | XFileInfoItem *m_pRootItem; 62 | }; 63 | 64 | #endif // XFILEINFOMODEL_H 65 | -------------------------------------------------------------------------------- /xfileinfo.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021-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 11 | * all 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 XFILEINFO_H 22 | #define XFILEINFO_H 23 | 24 | #include "xdisasmcore.h" 25 | #include "xfileinfomodel.h" 26 | #include "xformats.h" 27 | #include "xthreadobject.h" 28 | 29 | class XFileInfo : public XThreadObject { 30 | Q_OBJECT 31 | 32 | public: 33 | struct OPTIONS { 34 | XBinary::FT fileType; 35 | bool bComment; 36 | QString sString; 37 | }; 38 | 39 | explicit XFileInfo(QObject *pParent = nullptr); 40 | 41 | void setData(QIODevice *pDevice, XFileInfoModel *pModel, const OPTIONS &options, XBinary::PDSTRUCT *pPdStruct); 42 | static bool processFile(const QString &sFileName, XFileInfoModel *pModel, const OPTIONS &options); 43 | static QList getMethodNames(XBinary::FT fileType); 44 | 45 | private: 46 | XFileInfoItem *appendRecord(XFileInfoItem *pItemParent, const QString &sName, QVariant varData); 47 | void setCurrentStatus(const QString &sStatus); 48 | bool check(const QString &sString, const QString &sExtra1 = QString(), const QString &sExtra2 = QString(), const QString &sExtra3 = QString(), 49 | const QString &sExtra4 = QString()); 50 | QString addFlags(XBinary::MODE mode, quint64 nValue, QMap mapFlags, XBinary::VL_TYPE vlType); 51 | QString addDateTime(XBinary::MODE mode, XBinary::DT_TYPE dtType, quint64 nValue); 52 | static void _addMethod(QList *pListMethods, const QString &sName); 53 | 54 | void _entryPoint(XBinary *pBinary, XBinary::_MEMORY_MAP *pMemoryMap); 55 | void _IMAGE_DOS_HEADER(XMSDOS *pMSDOS, bool bExtra); 56 | void _Elf_Ehdr(XELF *pELF, bool bIs64); 57 | void _mach_header(XMACH *pMACH, bool bIs64); // TODO remove 58 | void PE_IMAGE_NT_HEADERS(XPE *pPE, bool bIs64); // TODO remove 59 | void PE_IMAGE_SECTION_HEADER(XPE *pPE); // TODO remove 60 | void PE_IMAGE_RESOURCE_DIRECTORY(XPE *pPE); // TODO remove 61 | void PE_IMAGE_EXPORT_DIRECTORY(XPE *pPE); // TODO remove 62 | void NE_IMAGE_OS2_HEADER(XNE *pNE); // TODO remove 63 | void DEX_HEADER(XDEX *pDEX); // TODO remove 64 | void ELF_Shdr(XELF *pELF); // TODO remove 65 | void process(); 66 | 67 | private: 68 | const qint32 N_SIGNATURECOUNT = 10; // TODO Set/Get 69 | QIODevice *m_pDevice; 70 | XFileInfoModel *m_pModel; 71 | OPTIONS m_options; 72 | XBinary::PDSTRUCT *m_pPdStruct; 73 | qint32 m_nFreeIndex; 74 | }; 75 | 76 | #endif // XFILEINFO_H 77 | -------------------------------------------------------------------------------- /xfileinfowidget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | XFileInfoWidget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 895 10 | 474 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 | 41 | 42 | 43 | 44 | 45 | 300 46 | 0 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | Comment 55 | 56 | 57 | 58 | 59 | 60 | 61 | Qt::Horizontal 62 | 63 | 64 | 65 | 40 66 | 20 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 90 76 | 0 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 0 86 | 0 87 | 88 | 89 | 90 | Reload 91 | 92 | 93 | Qt::ToolButtonTextBesideIcon 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 0 102 | 0 103 | 104 | 105 | 106 | Save 107 | 108 | 109 | Qt::ToolButtonTextBesideIcon 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | Qt::ScrollBarAsNeeded 119 | 120 | 121 | QPlainTextEdit::NoWrap 122 | 123 | 124 | true 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | -------------------------------------------------------------------------------- /xfileinfowidget.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021-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 11 | * all 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 "xfileinfowidget.h" 22 | 23 | #include "ui_xfileinfowidget.h" 24 | 25 | XFileInfoWidget::XFileInfoWidget(QWidget *pParent) : XShortcutsWidget(pParent), ui(new Ui::XFileInfoWidget) 26 | { 27 | ui->setupUi(this); 28 | 29 | XOptions::adjustToolButton(ui->toolButtonReload, XOptions::ICONTYPE_RELOAD); 30 | XOptions::adjustToolButton(ui->toolButtonSave, XOptions::ICONTYPE_SAVE); 31 | 32 | ui->comboBoxType->setToolTip(tr("Type")); 33 | ui->comboBoxMethod->setToolTip(tr("Method")); 34 | ui->comboBoxOutput->setToolTip(tr("Output")); 35 | ui->checkBoxComment->setToolTip(tr("Comment")); 36 | 37 | m_pDevice = nullptr; 38 | m_nOffset = 0; 39 | m_nSize = 0; 40 | 41 | ui->checkBoxComment->setChecked(true); 42 | 43 | const bool bBlocked1 = ui->comboBoxOutput->blockSignals(true); 44 | 45 | // TODO move 46 | ui->comboBoxOutput->addItem(tr("Text"), SM_TEXT); 47 | ui->comboBoxOutput->addItem(QString("JSON"), SM_JSON); 48 | ui->comboBoxOutput->addItem(QString("XML"), SM_XML); 49 | 50 | ui->comboBoxOutput->blockSignals(bBlocked1); 51 | } 52 | 53 | XFileInfoWidget::~XFileInfoWidget() 54 | { 55 | delete ui; 56 | } 57 | 58 | void XFileInfoWidget::setData(QIODevice *pDevice, XBinary::FT fileType, const QString &sString, bool bAuto) 59 | { 60 | Q_UNUSED(sString) 61 | // TODO sString !!! 62 | this->m_pDevice = pDevice; 63 | m_nOffset = 0; 64 | m_nSize = pDevice->size(); 65 | 66 | if (this->m_nSize == -1) { // TODO Check 67 | this->m_nSize = (pDevice->size()) - (this->m_nOffset); 68 | } 69 | 70 | XFormats::setFileTypeComboBox(fileType, m_pDevice, ui->comboBoxType); 71 | 72 | reloadType(); 73 | 74 | if (bAuto) { 75 | reload(); 76 | } 77 | } 78 | 79 | void XFileInfoWidget::reload() 80 | { 81 | if (m_pDevice) { 82 | XFileInfo::OPTIONS options = {}; 83 | options.fileType = (XBinary::FT)(ui->comboBoxType->currentData().toInt()); 84 | // options.mapMode = (XBinary::MAPMODE)(ui->comboBoxMapMode->currentData().toInt()); 85 | // options.bShowAll=ui->checkBoxShowAll->isChecked(); 86 | options.bComment = ui->checkBoxComment->isChecked(); 87 | options.sString = (ui->comboBoxMethod->currentData().toString()); 88 | 89 | XFileInfoModel *pModel = new XFileInfoModel; 90 | 91 | XFileInfo fileInfo; 92 | XDialogProcess dip(XOptions::getMainWidget(this), &fileInfo); 93 | dip.setGlobal(getShortcuts(), getGlobalOptions()); 94 | fileInfo.setData(m_pDevice, pModel, options, dip.getPdStruct()); 95 | dip.start(); 96 | dip.showDialogDelay(); 97 | 98 | if (dip.isSuccess()) { 99 | QString sText; 100 | 101 | SM showMode = (SM)(ui->comboBoxOutput->currentData().toInt()); 102 | 103 | if (showMode == SM_TEXT) { 104 | sText = pModel->toFormattedString(); 105 | } else if (showMode == SM_JSON) { 106 | sText = pModel->toJSON(); 107 | } else if (showMode == SM_XML) { 108 | sText = pModel->toXML(); 109 | } 110 | 111 | ui->plainTextEditFileInfo->setPlainText(sText); 112 | } 113 | 114 | delete pModel; // mb TODO in thread 115 | } 116 | } 117 | 118 | void XFileInfoWidget::adjustView() 119 | { 120 | getGlobalOptions()->adjustWidget(this, XOptions::ID_VIEW_FONT_CONTROLS); 121 | getGlobalOptions()->adjustWidget(ui->plainTextEditFileInfo, XOptions::ID_VIEW_FONT_TEXTEDITS); 122 | } 123 | 124 | void XFileInfoWidget::reloadData(bool bSaveSelection) 125 | { 126 | Q_UNUSED(bSaveSelection) 127 | 128 | reload(); 129 | } 130 | 131 | void XFileInfoWidget::registerShortcuts(bool bState) 132 | { 133 | Q_UNUSED(bState) 134 | // TODO !!! 135 | } 136 | 137 | void XFileInfoWidget::on_toolButtonSave_clicked() 138 | { 139 | QString sFileName = XBinary::getResultFileName(m_pDevice, QString("%1.txt").arg(tr("Info"))); 140 | sFileName = QFileDialog::getSaveFileName(this, tr("Save file"), sFileName, QString("%1 (*.txt);;%2 (*)").arg(tr("Text files"), tr("All files"))); 141 | 142 | if (!sFileName.isEmpty()) { 143 | XOptions::savePlainTextEdit(ui->plainTextEditFileInfo, sFileName); 144 | } 145 | } 146 | 147 | void XFileInfoWidget::on_toolButtonReload_clicked() 148 | { 149 | reload(); 150 | } 151 | 152 | void XFileInfoWidget::on_checkBoxComment_toggled(bool bChecked) 153 | { 154 | Q_UNUSED(bChecked) 155 | 156 | reload(); 157 | } 158 | 159 | void XFileInfoWidget::on_comboBoxType_currentIndexChanged(int nIndex) 160 | { 161 | Q_UNUSED(nIndex) 162 | 163 | reloadType(); 164 | 165 | reload(); 166 | } 167 | 168 | void XFileInfoWidget::on_comboBoxMethod_currentIndexChanged(int nIndex) 169 | { 170 | Q_UNUSED(nIndex) 171 | 172 | reload(); 173 | } 174 | 175 | void XFileInfoWidget::reloadType() 176 | { 177 | XBinary::FT fileType = (XBinary::FT)(ui->comboBoxType->currentData().toInt()); 178 | 179 | QList listMethods = XFileInfo::getMethodNames(fileType); 180 | 181 | const bool bBlocked1 = ui->comboBoxMethod->blockSignals(true); 182 | 183 | ui->comboBoxMethod->clear(); 184 | 185 | qint32 nNumberOfMethods = listMethods.count(); 186 | 187 | for (qint32 i = 0; i < nNumberOfMethods; i++) { 188 | ui->comboBoxMethod->addItem(listMethods.at(i), listMethods.at(i)); // TODO Translate here 189 | } 190 | 191 | ui->comboBoxMethod->blockSignals(bBlocked1); 192 | } 193 | 194 | void XFileInfoWidget::on_comboBoxOutput_currentIndexChanged(int nIndex) 195 | { 196 | Q_UNUSED(nIndex) 197 | 198 | reload(); 199 | } 200 | -------------------------------------------------------------------------------- /xfileinfomodel.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021-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 11 | * all 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 "xfileinfomodel.h" 22 | 23 | XFileInfoModel::XFileInfoModel(QObject *pParent) : QAbstractItemModel(pParent) 24 | { 25 | m_pRootItem = new XFileInfoItem("data", ""); 26 | } 27 | 28 | XFileInfoModel::~XFileInfoModel() 29 | { 30 | delete m_pRootItem; 31 | } 32 | 33 | QVariant XFileInfoModel::headerData(int nSection, Qt::Orientation orientation, int nRole) const 34 | { 35 | QVariant result; 36 | 37 | if ((orientation == Qt::Horizontal) && (nRole == Qt::DisplayRole)) { 38 | result = m_pRootItem->data(nSection); 39 | } 40 | 41 | return result; 42 | } 43 | 44 | QModelIndex XFileInfoModel::index(int nRow, int nColumn, const QModelIndex &parent) const 45 | { 46 | QModelIndex result; 47 | 48 | if (hasIndex(nRow, nColumn, parent)) { 49 | XFileInfoItem *pItemParent = nullptr; 50 | 51 | if (!parent.isValid()) { 52 | pItemParent = m_pRootItem; 53 | } else { 54 | pItemParent = static_cast(parent.internalPointer()); 55 | } 56 | 57 | XFileInfoItem *pItemChild = pItemParent->child(nRow); 58 | 59 | if (pItemChild) { 60 | result = createIndex(nRow, nColumn, pItemChild); 61 | } 62 | } 63 | 64 | return result; 65 | } 66 | 67 | QModelIndex XFileInfoModel::parent(const QModelIndex &index) const 68 | { 69 | QModelIndex result; 70 | 71 | if (index.isValid()) { 72 | XFileInfoItem *pItemChild = static_cast(index.internalPointer()); 73 | XFileInfoItem *pParentItem = pItemChild->getParentItem(); 74 | 75 | if (pParentItem != m_pRootItem) { 76 | result = createIndex(pParentItem->row(), 0, pParentItem); 77 | } 78 | } 79 | 80 | return result; 81 | } 82 | 83 | int XFileInfoModel::rowCount(const QModelIndex &parent) const 84 | { 85 | int nResult = 0; 86 | 87 | if (parent.column() <= 0) { 88 | XFileInfoItem *pParentItem = nullptr; 89 | 90 | if (!parent.isValid()) { 91 | pParentItem = m_pRootItem; 92 | } else { 93 | pParentItem = static_cast(parent.internalPointer()); 94 | } 95 | 96 | nResult = pParentItem->childCount(); 97 | } 98 | 99 | return nResult; 100 | } 101 | 102 | int XFileInfoModel::columnCount(const QModelIndex &parent) const 103 | { 104 | int nResult = 0; 105 | 106 | if (parent.isValid()) { 107 | nResult = static_cast(parent.internalPointer())->columnCount(); 108 | } else { 109 | nResult = m_pRootItem->columnCount(); 110 | } 111 | 112 | return nResult; 113 | } 114 | 115 | QVariant XFileInfoModel::data(const QModelIndex &index, int nRole) const 116 | { 117 | QVariant result; 118 | 119 | if (index.isValid()) { 120 | XFileInfoItem *pItem = static_cast(index.internalPointer()); 121 | 122 | if (nRole == Qt::DisplayRole) { 123 | result = pItem->data(index.column()); 124 | } 125 | } 126 | 127 | return result; 128 | } 129 | 130 | Qt::ItemFlags XFileInfoModel::flags(const QModelIndex &index) const 131 | { 132 | Qt::ItemFlags result = Qt::NoItemFlags; 133 | 134 | if (index.isValid()) { 135 | result = QAbstractItemModel::flags(index); 136 | } 137 | 138 | return result; 139 | } 140 | 141 | void XFileInfoModel::appendChild(XFileInfoItem *pItemChild) 142 | { 143 | m_pRootItem->appendChild(pItemChild); 144 | } 145 | 146 | QString XFileInfoModel::toXML() 147 | { 148 | QString sResult; 149 | QXmlStreamWriter xml(&sResult); 150 | 151 | xml.setAutoFormatting(true); 152 | 153 | _toXML(&xml, m_pRootItem, 0); 154 | 155 | return sResult; 156 | } 157 | 158 | QString XFileInfoModel::toJSON() 159 | { 160 | QString sResult; 161 | 162 | QJsonObject jsonResult; 163 | 164 | _toJSON(&jsonResult, m_pRootItem, 0); 165 | 166 | QJsonDocument saveFormat(jsonResult); 167 | 168 | QByteArray baData = saveFormat.toJson(QJsonDocument::Indented); 169 | 170 | sResult = baData.data(); 171 | 172 | return sResult; 173 | } 174 | 175 | QString XFileInfoModel::toCSV() 176 | { 177 | QString sResult; 178 | 179 | _toCSV(&sResult, m_pRootItem, 0); 180 | 181 | return sResult; 182 | } 183 | 184 | QString XFileInfoModel::toTSV() 185 | { 186 | QString sResult; 187 | 188 | _toTSV(&sResult, m_pRootItem, 0); 189 | 190 | return sResult; 191 | } 192 | 193 | QString XFileInfoModel::toFormattedString() 194 | { 195 | QString sResult; 196 | 197 | _toFormattedString(&sResult, m_pRootItem, 0); 198 | 199 | return sResult; 200 | } 201 | 202 | void XFileInfoModel::_toXML(QXmlStreamWriter *pXml, XFileInfoItem *pItem, qint32 nLevel) 203 | { 204 | if (nLevel) { 205 | pXml->writeStartElement("record"); 206 | pXml->writeAttribute("name", pItem->getName()); 207 | 208 | if (!(pItem->childCount())) { 209 | pXml->writeAttribute("value", pItem->getValue().toString()); 210 | } 211 | } else { 212 | pXml->writeStartElement("data"); 213 | } 214 | 215 | qint32 nNumberOfChildren = pItem->childCount(); 216 | 217 | for (qint32 i = 0; i < nNumberOfChildren; i++) { 218 | _toXML(pXml, pItem->child(i), nLevel + 1); 219 | } 220 | 221 | pXml->writeEndElement(); 222 | } 223 | 224 | void XFileInfoModel::_toJSON(QJsonObject *pJsonObject, XFileInfoItem *pItem, qint32 nLevel) 225 | { 226 | // if(nLevel) 227 | // { 228 | // pJsonObject->insert(pItem->getName(),pItem->getValue().toString()); 229 | // } 230 | 231 | // if(pItem->childCount()) 232 | // { 233 | // if(nLevel) 234 | // { 235 | // QJsonArray jsArray; 236 | 237 | // qint32 nNumberOfChildren=pItem->childCount(); 238 | 239 | // for(qint32 i=0;ichild(i),nLevel+1); 244 | 245 | // jsArray.append(jsRecord); 246 | // } 247 | 248 | // pJsonObject->insert("records",jsArray); 249 | // } 250 | // else 251 | // { 252 | // qint32 nNumberOfChildren=pItem->childCount(); 253 | 254 | // for(qint32 i=0;ichild(i),nLevel+1); 257 | // } 258 | // } 259 | // } 260 | if (pItem->childCount()) { 261 | QJsonObject jsObject; 262 | 263 | qint32 nNumberOfChildren = pItem->childCount(); 264 | 265 | for (qint32 i = 0; i < nNumberOfChildren; i++) { 266 | _toJSON(&jsObject, pItem->child(i), nLevel + 1); 267 | } 268 | 269 | pJsonObject->insert(pItem->getName(), jsObject); 270 | } else { 271 | pJsonObject->insert(pItem->getName(), pItem->getValue().toString()); 272 | } 273 | } 274 | 275 | void XFileInfoModel::_toCSV(QString *pString, XFileInfoItem *pItem, qint32 nLevel) 276 | { 277 | if (nLevel) { 278 | pString->append(QString("%1;%2\n").arg(pItem->getName(), pItem->getValue().toString())); 279 | } 280 | 281 | qint32 nNumberOfChildren = pItem->childCount(); 282 | 283 | for (qint32 i = 0; i < nNumberOfChildren; i++) { 284 | _toCSV(pString, pItem->child(i), nLevel + 1); 285 | } 286 | } 287 | 288 | void XFileInfoModel::_toTSV(QString *pString, XFileInfoItem *pItem, qint32 nLevel) 289 | { 290 | if (nLevel) { 291 | pString->append(QString("%1\t%2\n").arg(pItem->getName(), pItem->getValue().toString())); 292 | } 293 | 294 | qint32 nNumberOfChildren = pItem->childCount(); 295 | 296 | for (qint32 i = 0; i < nNumberOfChildren; i++) { 297 | _toTSV(pString, pItem->child(i), nLevel + 1); 298 | } 299 | } 300 | 301 | void XFileInfoModel::_toFormattedString(QString *pString, XFileInfoItem *pItem, qint32 nLevel) 302 | { 303 | if (nLevel) { 304 | QString sResult; 305 | sResult = sResult.leftJustified(4 * (nLevel - 1), ' '); // TODO a function !!! 306 | sResult.append(QString("%1: %2\n").arg(pItem->getName(), pItem->getValue().toString())); 307 | pString->append(sResult); 308 | } 309 | 310 | qint32 nNumberOfChildren = pItem->childCount(); 311 | 312 | for (qint32 i = 0; i < nNumberOfChildren; i++) { 313 | _toFormattedString(pString, pItem->child(i), nLevel + 1); 314 | } 315 | } 316 | -------------------------------------------------------------------------------- /xfileinfo.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021-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 11 | * all 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 "xfileinfo.h" 22 | 23 | XFileInfo::XFileInfo(QObject *pParent) : XThreadObject(pParent) 24 | { 25 | m_pModel = nullptr; 26 | m_pDevice = nullptr; 27 | m_pPdStruct = nullptr; 28 | m_options = {}; 29 | m_nFreeIndex = -1; 30 | } 31 | 32 | void XFileInfo::setData(QIODevice *pDevice, XFileInfoModel *pModel, const OPTIONS &options, XBinary::PDSTRUCT *pPdStruct) 33 | { 34 | this->m_pDevice = pDevice; 35 | this->m_pModel = pModel; 36 | this->m_options = options; 37 | this->m_pPdStruct = pPdStruct; 38 | } 39 | 40 | bool XFileInfo::processFile(const QString &sFileName, XFileInfoModel *pModel, const OPTIONS &options) 41 | { 42 | bool bResult = false; 43 | 44 | QFile file; 45 | file.setFileName(sFileName); 46 | 47 | if (file.open(QIODevice::ReadOnly)) { 48 | XFileInfo fileInfo; 49 | XBinary::PDSTRUCT pdStruct = XBinary::createPdStruct(); 50 | fileInfo.setData(&file, pModel, options, &pdStruct); 51 | fileInfo.process(); 52 | file.close(); 53 | bResult = true; 54 | } 55 | 56 | return bResult; 57 | } 58 | 59 | QList XFileInfo::getMethodNames(XBinary::FT fileType) 60 | { 61 | QList listResult; 62 | 63 | _addMethod(&listResult, "Info"); 64 | _addMethod(&listResult, "Hash"); 65 | _addMethod(&listResult, "Entropy"); 66 | _addMethod(&listResult, "Check format"); 67 | 68 | if (XBinary::checkFileType(XBinary::FT_ELF, fileType)) { 69 | _addMethod(&listResult, "Entry point"); 70 | _addMethod(&listResult, "Elf_Ehdr"); 71 | } else if (XBinary::checkFileType(XBinary::FT_MACHO, fileType)) { 72 | _addMethod(&listResult, "Entry point"); 73 | _addMethod(&listResult, "Header"); 74 | } else if (XBinary::checkFileType(XBinary::FT_MACHOFAT, fileType)) { 75 | // TODO !!! 76 | // Header 77 | // Archs 78 | } else if (XBinary::checkFileType(XBinary::FT_PE, fileType)) { 79 | _addMethod(&listResult, "Entry point"); 80 | _addMethod(&listResult, "IMAGE_DOS_HEADER"); 81 | _addMethod(&listResult, "IMAGE_NT_HEADERS"); 82 | _addMethod(&listResult, "IMAGE_SECTION_HEADER"); 83 | _addMethod(&listResult, "IMAGE_RESOURCE_DIRECTORY"); 84 | // _addMethod(&listResult, "IMAGE_IMPORT_DESCRIPTOR"); 85 | _addMethod(&listResult, "IMAGE_EXPORT_DIRECTORY"); 86 | // TODO !!! 87 | } else if (XBinary::checkFileType(XBinary::FT_NE, fileType)) { 88 | _addMethod(&listResult, "Entry point"); 89 | _addMethod(&listResult, "IMAGE_DOS_HEADER"); 90 | _addMethod(&listResult, "IMAGE_OS2_HEADER"); 91 | // TODO !!! 92 | } else if (XBinary::checkFileType(XBinary::FT_LE, fileType)) { 93 | _addMethod(&listResult, "Entry point"); 94 | _addMethod(&listResult, "IMAGE_DOS_HEADER"); 95 | // TODO !!! 96 | } else if (XBinary::checkFileType(XBinary::FT_MSDOS, fileType)) { 97 | _addMethod(&listResult, "Entry point"); 98 | _addMethod(&listResult, "IMAGE_DOS_HEADER"); 99 | } else if (XBinary::checkFileType(XBinary::FT_DEX, fileType)) { 100 | _addMethod(&listResult, "Header"); 101 | // TODO 102 | } else if (XBinary::checkFileType(XBinary::FT_COM, fileType)) { 103 | _addMethod(&listResult, "Entry point"); 104 | // TODO 105 | } 106 | // else if(XBinary::checkFileType(XBinary::FT_PDF,fileType)) 107 | // { 108 | // _addMethod(&listResult,"Header"),"Header"); 109 | // } 110 | 111 | return listResult; 112 | } 113 | 114 | XFileInfoItem *XFileInfo::appendRecord(XFileInfoItem *pItemParent, const QString &sName, QVariant varData) 115 | { 116 | XFileInfoItem *pResult = new XFileInfoItem(sName, varData); 117 | 118 | if (pItemParent) { 119 | pItemParent->appendChild(pResult); 120 | } else { 121 | m_pModel->appendChild(pResult); 122 | } 123 | 124 | return pResult; 125 | } 126 | 127 | void XFileInfo::setCurrentStatus(const QString &sStatus) 128 | { 129 | XBinary::setPdStructStatus(m_pPdStruct, m_nFreeIndex, sStatus); 130 | } 131 | 132 | bool XFileInfo::check(const QString &sString, const QString &sExtra1, const QString &sExtra2, const QString &sExtra3, const QString &sExtra4) 133 | { 134 | QString sCurrentString = sString; 135 | 136 | bool bResult = true; 137 | 138 | if (sExtra1 != "") { 139 | sCurrentString += "#" + sExtra1; 140 | } 141 | 142 | if (sExtra2 != "") { 143 | sCurrentString += "#" + sExtra2; 144 | } 145 | 146 | if (sExtra3 != "") { 147 | sCurrentString += "#" + sExtra3; 148 | } 149 | 150 | if (sExtra4 != "") { 151 | sCurrentString += "#" + sExtra4; 152 | } 153 | 154 | qint32 nNumberOfSections = m_options.sString.count("#") + 1; 155 | 156 | for (qint32 i = 0; i < nNumberOfSections; i++) { 157 | QString sOptionString = m_options.sString.section("#", i, i).toUpper(); 158 | QString _sString = sCurrentString.section("#", i, i).toUpper(); 159 | if ((sOptionString != _sString) && (_sString != "")) { 160 | bResult = false; 161 | } 162 | } 163 | 164 | if (bResult) { 165 | setCurrentStatus(sCurrentString); 166 | } 167 | 168 | return bResult; 169 | } 170 | 171 | QString XFileInfo::addFlags(XBinary::MODE mode, quint64 nValue, QMap mapFlags, XBinary::VL_TYPE vlType) 172 | { 173 | QString sResult = XBinary::valueToHex(mode, nValue); 174 | 175 | if (m_options.bComment) { 176 | sResult += QString("(%1)").arg(XBinary::valueToFlagsString(nValue, mapFlags, vlType)); 177 | } 178 | 179 | return sResult; 180 | } 181 | 182 | QString XFileInfo::addDateTime(XBinary::MODE mode, XBinary::DT_TYPE dtType, quint64 nValue) 183 | { 184 | QString sResult = XBinary::valueToHex(mode, nValue); 185 | 186 | if (m_options.bComment) { 187 | sResult += QString("(%1)").arg(XBinary::valueToTimeString(nValue, dtType)); 188 | } 189 | 190 | return sResult; 191 | } 192 | 193 | void XFileInfo::_addMethod(QList *pListMethods, const QString &sName) 194 | { 195 | pListMethods->append(sName); 196 | } 197 | 198 | void XFileInfo::_entryPoint(XBinary *pBinary, XBinary::_MEMORY_MAP *pMemoryMap) 199 | { 200 | QString sGroup = "Entry point"; 201 | if (check(sGroup)) { 202 | XFileInfoItem *pItemParent = appendRecord(0, sGroup, ""); 203 | { 204 | QString sRecord = "Address"; 205 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHexEx(pBinary->getEntryPointAddress(pMemoryMap))); 206 | } 207 | { 208 | QString sRecord = "Offset"; 209 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHexEx(pBinary->getEntryPointOffset(pMemoryMap))); 210 | } 211 | { 212 | QString sRecord = "Relative address"; 213 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHexEx(pBinary->getEntryPointRVA(pMemoryMap))); 214 | } 215 | 216 | XDisasmCore disasmCore; 217 | disasmCore.setMode(XBinary::getDisasmMode(pMemoryMap)); 218 | { 219 | QString sRecord = "Bytes"; 220 | if (check(sGroup, sRecord)) 221 | appendRecord(pItemParent, sRecord, 222 | disasmCore.getSignature(m_pDevice, pMemoryMap, pMemoryMap->nEntryPointAddress, XDisasmCore::ST_FULL, N_SIGNATURECOUNT)); 223 | } 224 | { 225 | QString sRecord = "Signature"; 226 | if (check(sGroup, sRecord)) 227 | appendRecord(pItemParent, sRecord, 228 | disasmCore.getSignature(m_pDevice, pMemoryMap, pMemoryMap->nEntryPointAddress, XDisasmCore::ST_MASK, N_SIGNATURECOUNT)); 229 | } 230 | { 231 | QString sRecord = QString("%1(rel)").arg("Signature"); 232 | if (check(sGroup, sRecord)) 233 | appendRecord(pItemParent, sRecord, disasmCore.getSignature(m_pDevice, pMemoryMap, pMemoryMap->nEntryPointAddress, XDisasmCore::ST_REL, N_SIGNATURECOUNT)); 234 | } 235 | } 236 | } 237 | 238 | void XFileInfo::_IMAGE_DOS_HEADER(XMSDOS *pMSDOS, bool bExtra) 239 | { 240 | QString sGroup = "IMAGE_DOS_HEADER"; 241 | if (check(sGroup)) { 242 | XFileInfoItem *pItemParent = appendRecord(0, sGroup, ""); 243 | { 244 | { 245 | QString sRecord = "e_magic"; 246 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pMSDOS->get_e_magic())); 247 | } 248 | { 249 | QString sRecord = "e_cblp"; 250 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pMSDOS->get_e_cblp())); 251 | } 252 | { 253 | QString sRecord = "e_cp"; 254 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pMSDOS->get_e_cp())); 255 | } 256 | { 257 | QString sRecord = "e_crlc"; 258 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pMSDOS->get_e_crlc())); 259 | } 260 | { 261 | QString sRecord = "e_cparhdr"; 262 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pMSDOS->get_e_cparhdr())); 263 | } 264 | { 265 | QString sRecord = "e_minalloc"; 266 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pMSDOS->get_e_minalloc())); 267 | } 268 | { 269 | QString sRecord = "e_maxalloc"; 270 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pMSDOS->get_e_maxalloc())); 271 | } 272 | { 273 | QString sRecord = "e_ss"; 274 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pMSDOS->get_e_ss())); 275 | } 276 | { 277 | QString sRecord = "e_sp"; 278 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pMSDOS->get_e_sp())); 279 | } 280 | { 281 | QString sRecord = "e_csum"; 282 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pMSDOS->get_e_csum())); 283 | } 284 | { 285 | QString sRecord = "e_ip"; 286 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pMSDOS->get_e_ip())); 287 | } 288 | { 289 | QString sRecord = "e_cs"; 290 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pMSDOS->get_e_cs())); 291 | } 292 | { 293 | QString sRecord = "e_lfarlc"; 294 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pMSDOS->get_e_lfarlc())); 295 | } 296 | { 297 | QString sRecord = "e_ovno"; 298 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pMSDOS->get_e_ovno())); 299 | } 300 | if (bExtra) { 301 | // { 302 | // QString sRecord = "e_res"; 303 | // if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pMSDOS->get_e_res())); 304 | // } 305 | { 306 | QString sRecord = "e_oemid"; 307 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pMSDOS->get_e_oemid())); 308 | } 309 | { 310 | QString sRecord = "e_oeminfo"; 311 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pMSDOS->get_e_oeminfo())); 312 | } 313 | // { 314 | // QString sRecord = "e_res2"; 315 | // if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pMSDOS->get_e_res2())); 316 | // } 317 | { 318 | QString sRecord = "e_lfanew"; 319 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pMSDOS->get_e_lfanew())); 320 | } 321 | } 322 | } 323 | } 324 | } 325 | 326 | void XFileInfo::_Elf_Ehdr(XELF *pELF, bool bIs64) 327 | { 328 | QString sGroup = "Elf_Ehdr"; 329 | if (check(sGroup)) { 330 | XFileInfoItem *pItemParent = appendRecord(0, sGroup, ""); 331 | { 332 | QString sSubGroup = "e_ident"; 333 | if (check(sGroup, sSubGroup)) { 334 | XFileInfoItem *pItemSub = appendRecord(pItemParent, sSubGroup, ""); 335 | { 336 | QString sRecord = "ei_mag"; 337 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pELF->getIdent_mag_LE())); 338 | } 339 | { 340 | QString sRecord = "ei_class"; 341 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pELF->getIdent_class())); 342 | } 343 | { 344 | QString sRecord = "ei_data"; 345 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pELF->getIdent_data())); 346 | } 347 | { 348 | QString sRecord = "ei_version"; 349 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pELF->getIdent_version())); 350 | } 351 | { 352 | QString sRecord = "ei_osabi"; 353 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pELF->getIdent_osabi())); 354 | } 355 | { 356 | QString sRecord = "ei_abiversion"; 357 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pELF->getIdent_abiversion())); 358 | } 359 | } 360 | } 361 | { 362 | if (!bIs64) { 363 | { 364 | QString sRecord = "type"; 365 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pELF->getHdr32_type())); 366 | } 367 | { 368 | QString sRecord = "machine"; 369 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pELF->getHdr32_machine())); 370 | } 371 | { 372 | QString sRecord = "version"; 373 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pELF->getHdr32_version())); 374 | } 375 | { 376 | QString sRecord = "entry"; 377 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pELF->getHdr32_entry())); 378 | } 379 | { 380 | QString sRecord = "phoff"; 381 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pELF->getHdr32_phoff())); 382 | } 383 | { 384 | QString sRecord = "shoff"; 385 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pELF->getHdr32_shoff())); 386 | } 387 | { 388 | QString sRecord = "flags"; 389 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pELF->getHdr32_flags())); 390 | } 391 | { 392 | QString sRecord = "ehsize"; 393 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pELF->getHdr32_ehsize())); 394 | } 395 | { 396 | QString sRecord = "phentsize"; 397 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pELF->getHdr32_phentsize())); 398 | } 399 | { 400 | QString sRecord = "phnum"; 401 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pELF->getHdr32_phnum())); 402 | } 403 | { 404 | QString sRecord = "shentsize"; 405 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pELF->getHdr32_shentsize())); 406 | } 407 | { 408 | QString sRecord = "shnum"; 409 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pELF->getHdr32_shnum())); 410 | } 411 | { 412 | QString sRecord = "shstrndx"; 413 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pELF->getHdr32_shstrndx())); 414 | } 415 | } else { 416 | { 417 | QString sRecord = "type"; 418 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pELF->getHdr64_type())); 419 | } 420 | { 421 | QString sRecord = "machine"; 422 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pELF->getHdr64_machine())); 423 | } 424 | { 425 | QString sRecord = "version"; 426 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pELF->getHdr64_version())); 427 | } 428 | { 429 | QString sRecord = "entry"; 430 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pELF->getHdr64_entry())); 431 | } 432 | { 433 | QString sRecord = "phoff"; 434 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pELF->getHdr64_phoff())); 435 | } 436 | { 437 | QString sRecord = "shoff"; 438 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pELF->getHdr64_shoff())); 439 | } 440 | { 441 | QString sRecord = "flags"; 442 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pELF->getHdr64_flags())); 443 | } 444 | { 445 | QString sRecord = "ehsize"; 446 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pELF->getHdr64_ehsize())); 447 | } 448 | { 449 | QString sRecord = "phentsize"; 450 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pELF->getHdr64_phentsize())); 451 | } 452 | { 453 | QString sRecord = "phnum"; 454 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pELF->getHdr64_phnum())); 455 | } 456 | { 457 | QString sRecord = "shentsize"; 458 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pELF->getHdr64_shentsize())); 459 | } 460 | { 461 | QString sRecord = "shnum"; 462 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pELF->getHdr64_shnum())); 463 | } 464 | { 465 | QString sRecord = "shstrndx"; 466 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pELF->getHdr64_shstrndx())); 467 | } 468 | } 469 | } 470 | } 471 | } 472 | 473 | void XFileInfo::_mach_header(XMACH *pMACH, bool bIs64) 474 | { 475 | QString sGroup = "Header"; 476 | if (check(sGroup)) { 477 | XFileInfoItem *pItemParent = appendRecord(0, sGroup, ""); 478 | { 479 | { 480 | QString sRecord = "magic"; 481 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pMACH->getHeader_magic())); 482 | } 483 | { 484 | QString sRecord = "cputype"; 485 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pMACH->getHeader_cputype())); 486 | } 487 | { 488 | QString sRecord = "cpusubtype"; 489 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pMACH->getHeader_cpusubtype())); 490 | } 491 | { 492 | QString sRecord = "filetype"; 493 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pMACH->getHeader_filetype())); 494 | } 495 | { 496 | QString sRecord = "ncmds"; 497 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pMACH->getHeader_ncmds())); 498 | } 499 | { 500 | QString sRecord = "sizeofcmds"; 501 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pMACH->getHeader_sizeofcmds())); 502 | } 503 | { 504 | QString sRecord = "flags"; 505 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pMACH->getHeader_flags())); 506 | } 507 | if (bIs64) { 508 | QString sRecord = "reserved"; 509 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pMACH->getHeader_reserved())); 510 | } 511 | } 512 | } 513 | } 514 | 515 | void XFileInfo::PE_IMAGE_NT_HEADERS(XPE *pPE, bool bIs64) 516 | { 517 | QString sGroup = "IMAGE_NT_HEADERS"; 518 | if (check(sGroup)) { 519 | XFileInfoItem *pItemParent = appendRecord(0, sGroup, ""); 520 | { 521 | QString sRecord = "Signature"; 522 | if (check(sGroup, sRecord)) 523 | appendRecord(pItemParent, sRecord, addFlags(XBinary::MODE_16, pPE->getNtHeaders_Signature(), XPE::getImageNtHeadersSignatures(), XBinary::VL_TYPE_LIST)); 524 | } 525 | { 526 | QString sSubGroup = "IMAGE_FILE_HEADER"; 527 | if (check(sGroup, sSubGroup)) { 528 | XFileInfoItem *pItemSub = appendRecord(pItemParent, sSubGroup, ""); 529 | { 530 | QString sRecord = "Machine"; 531 | if (check(sGroup, sSubGroup, sRecord)) 532 | appendRecord(pItemSub, sRecord, 533 | addFlags(XBinary::MODE_16, pPE->getFileHeader_Machine(), XPE::getImageFileHeaderMachines(), XBinary::VL_TYPE_LIST)); 534 | } 535 | { 536 | QString sRecord = "NumberOfSections"; 537 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pPE->getFileHeader_NumberOfSections())); 538 | } 539 | { 540 | QString sRecord = "TimeDateStamp"; 541 | if (check(sGroup, sSubGroup, sRecord)) 542 | appendRecord(pItemSub, sRecord, addDateTime(XBinary::MODE_32, XBinary::DT_TYPE_POSIX, pPE->getFileHeader_TimeDateStamp())); 543 | } 544 | { 545 | QString sRecord = "PointerToSymbolTable"; 546 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pPE->getFileHeader_PointerToSymbolTable())); 547 | } 548 | { 549 | QString sRecord = "NumberOfSymbols"; 550 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pPE->getFileHeader_NumberOfSymbols())); 551 | } 552 | { 553 | QString sRecord = "SizeOfOptionalHeader"; 554 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pPE->getFileHeader_SizeOfOptionalHeader())); 555 | } 556 | { 557 | QString sRecord = "Characteristics"; 558 | if (check(sGroup, sSubGroup, sRecord)) 559 | appendRecord(pItemSub, sRecord, 560 | addFlags(XBinary::MODE_16, pPE->getFileHeader_Characteristics(), XPE::getImageFileHeaderCharacteristics(), XBinary::VL_TYPE_FLAGS)); 561 | } 562 | } 563 | } 564 | { 565 | QString sSubGroup = "IMAGE_OPTIONAL_HEADER"; 566 | if (check(sGroup, sSubGroup)) { 567 | XFileInfoItem *pItemSub = appendRecord(pItemParent, sSubGroup, ""); 568 | { 569 | QString sRecord = "Magic"; 570 | if (check(sGroup, sSubGroup, sRecord)) 571 | appendRecord(pItemSub, sRecord, 572 | addFlags(XBinary::MODE_16, pPE->getOptionalHeader_Magic(), XPE::getImageOptionalHeaderMagic(), XBinary::VL_TYPE_LIST)); 573 | } 574 | { 575 | QString sRecord = "MajorLinkerVersion"; 576 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pPE->getOptionalHeader_MajorLinkerVersion())); 577 | } 578 | { 579 | QString sRecord = "MinorLinkerVersion"; 580 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pPE->getOptionalHeader_MinorLinkerVersion())); 581 | } 582 | { 583 | QString sRecord = "SizeOfCode"; 584 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pPE->getOptionalHeader_SizeOfCode())); 585 | } 586 | { 587 | QString sRecord = "SizeOfInitializedData"; 588 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pPE->getOptionalHeader_SizeOfInitializedData())); 589 | } 590 | { 591 | QString sRecord = "SizeOfUninitializedData"; 592 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pPE->getOptionalHeader_SizeOfUninitializedData())); 593 | } 594 | { 595 | QString sRecord = "AddressOfEntryPoint"; 596 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pPE->getOptionalHeader_AddressOfEntryPoint())); 597 | } 598 | { 599 | QString sRecord = "BaseOfCode"; 600 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pPE->getOptionalHeader_BaseOfCode())); 601 | } 602 | 603 | if (!bIs64) { 604 | { 605 | QString sRecord = "BaseOfData"; 606 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pPE->getOptionalHeader_BaseOfData())); 607 | } 608 | { 609 | QString sRecord = "ImageBase"; 610 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex((quint32)pPE->getOptionalHeader_ImageBase())); 611 | } 612 | } else { 613 | { 614 | QString sRecord = "ImageBase"; 615 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex((quint64)pPE->getOptionalHeader_ImageBase())); 616 | } 617 | } 618 | 619 | { 620 | QString sRecord = "SectionAlignment"; 621 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pPE->getOptionalHeader_SectionAlignment())); 622 | } 623 | { 624 | QString sRecord = "FileAlignment"; 625 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pPE->getOptionalHeader_FileAlignment())); 626 | } 627 | { 628 | QString sRecord = "MajorOperatingSystemVersion"; 629 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pPE->getOptionalHeader_MajorOperatingSystemVersion())); 630 | } 631 | { 632 | QString sRecord = "MinorOperatingSystemVersion"; 633 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pPE->getOptionalHeader_MinorOperatingSystemVersion())); 634 | } 635 | { 636 | QString sRecord = "MajorImageVersion"; 637 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pPE->getOptionalHeader_MajorImageVersion())); 638 | } 639 | { 640 | QString sRecord = "MinorImageVersion"; 641 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pPE->getOptionalHeader_MinorImageVersion())); 642 | } 643 | { 644 | QString sRecord = "MajorSubsystemVersion"; 645 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pPE->getOptionalHeader_MajorSubsystemVersion())); 646 | } 647 | { 648 | QString sRecord = "MinorSubsystemVersion"; 649 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pPE->getOptionalHeader_MinorSubsystemVersion())); 650 | } 651 | { 652 | QString sRecord = "Win32VersionValue"; 653 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pPE->getOptionalHeader_Win32VersionValue())); 654 | } 655 | { 656 | QString sRecord = "SizeOfImage"; 657 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pPE->getOptionalHeader_SizeOfImage())); 658 | } 659 | { 660 | QString sRecord = "SizeOfHeaders"; 661 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pPE->getOptionalHeader_SizeOfHeaders())); 662 | } 663 | { 664 | QString sRecord = "CheckSum"; 665 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pPE->getOptionalHeader_CheckSum())); 666 | } 667 | { 668 | QString sRecord = "Subsystem"; 669 | if (check(sGroup, sSubGroup, sRecord)) 670 | appendRecord(pItemSub, sRecord, 671 | addFlags(XBinary::MODE_16, pPE->getOptionalHeader_Subsystem(), XPE::getImageOptionalHeaderSubsystem(), XBinary::VL_TYPE_LIST)); 672 | } 673 | { 674 | QString sRecord = "DllCharacteristics"; 675 | if (check(sGroup, sSubGroup, sRecord)) 676 | appendRecord(pItemSub, sRecord, 677 | addFlags(XBinary::MODE_16, pPE->getOptionalHeader_DllCharacteristics(), XPE::getImageOptionalHeaderDllCharacteristics(), 678 | XBinary::VL_TYPE_FLAGS)); 679 | } 680 | 681 | if (!bIs64) { 682 | { 683 | QString sRecord = "SizeOfStackReserve"; 684 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex((quint32)pPE->getOptionalHeader_SizeOfStackReserve())); 685 | } 686 | { 687 | QString sRecord = "SizeOfStackCommit"; 688 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex((quint32)pPE->getOptionalHeader_SizeOfStackCommit())); 689 | } 690 | { 691 | QString sRecord = "SizeOfHeapReserve"; 692 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex((quint32)pPE->getOptionalHeader_SizeOfHeapReserve())); 693 | } 694 | { 695 | QString sRecord = "SizeOfHeapCommit"; 696 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex((quint32)pPE->getOptionalHeader_SizeOfHeapCommit())); 697 | } 698 | } else { 699 | { 700 | QString sRecord = "SizeOfStackReserve"; 701 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex((quint64)pPE->getOptionalHeader_SizeOfStackReserve())); 702 | } 703 | { 704 | QString sRecord = "SizeOfStackCommit"; 705 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex((quint64)pPE->getOptionalHeader_SizeOfStackCommit())); 706 | } 707 | { 708 | QString sRecord = "SizeOfHeapReserve"; 709 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex((quint64)pPE->getOptionalHeader_SizeOfHeapReserve())); 710 | } 711 | { 712 | QString sRecord = "SizeOfHeapCommit"; 713 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex((quint64)pPE->getOptionalHeader_SizeOfHeapCommit())); 714 | } 715 | } 716 | { 717 | QString sRecord = "LoaderFlags"; 718 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pPE->getOptionalHeader_LoaderFlags())); 719 | } 720 | { 721 | QString sRecord = "NumberOfRvaAndSizes"; 722 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(pPE->getOptionalHeader_NumberOfRvaAndSizes())); 723 | } 724 | QString sSubGroup2 = "IMAGE_DATA_DIRECTORY"; 725 | if (check(sGroup, sSubGroup, sSubGroup2)) { 726 | XFileInfoItem *pItemSub2 = appendRecord(pItemSub, sSubGroup2, ""); 727 | { 728 | QMap mapDD = XPE::getImageOptionalHeaderDataDirectory(); 729 | 730 | qint32 nCount = qMin(pPE->getOptionalHeader_NumberOfRvaAndSizes(), (quint32)16); 731 | 732 | for (qint32 i = 0; (i < nCount) && XBinary::isPdStructNotCanceled(m_pPdStruct); i++) { 733 | QString sSubGroup3 = mapDD.value(i); 734 | if (check(sGroup, sSubGroup, sSubGroup2, sSubGroup3)) { 735 | XFileInfoItem *pItemSub3 = appendRecord(pItemSub2, sSubGroup3, ""); 736 | { 737 | { 738 | QString sRecord = "VirtualAddress"; 739 | if (check(sGroup, sSubGroup, sSubGroup2, sSubGroup3, sRecord)) 740 | appendRecord(pItemSub3, sRecord, XBinary::valueToHex(pPE->getOptionalHeader_DataDirectory(i).VirtualAddress)); 741 | } 742 | { 743 | QString sRecord = "Size"; 744 | if (check(sGroup, sSubGroup, sSubGroup2, sSubGroup3, sRecord)) 745 | appendRecord(pItemSub3, sRecord, XBinary::valueToHex(pPE->getOptionalHeader_DataDirectory(i).Size)); 746 | } 747 | } 748 | } 749 | } 750 | } 751 | } 752 | } 753 | } 754 | } 755 | } 756 | 757 | void XFileInfo::PE_IMAGE_SECTION_HEADER(XPE *pPE) 758 | { 759 | QString sGroup = "IMAGE_SECTION_HEADER"; 760 | if (check(sGroup)) { 761 | QList listISH = pPE->getSectionHeaders(m_pPdStruct); 762 | qint32 nNumberOfSections = listISH.count(); 763 | 764 | if (nNumberOfSections > 0) { 765 | XFileInfoItem *pItemParent = appendRecord(0, sGroup, ""); 766 | 767 | for (qint32 i = 0; i < nNumberOfSections; i++) { 768 | QString sSectionName = QString("%1").arg(i + 1); 769 | 770 | QString sSubGroup = sSectionName; 771 | if (check(sGroup, sSubGroup)) { 772 | XFileInfoItem *pItemSub = appendRecord(pItemParent, sSubGroup, ""); 773 | { 774 | { 775 | QString sRecord = "Name"; 776 | if (check(sGroup, sSubGroup, sRecord)) { 777 | QString _sName = QString((char *)listISH.at(i).Name); 778 | _sName.resize(qMin(_sName.length(), XPE_DEF::S_IMAGE_SIZEOF_SHORT_NAME)); 779 | 780 | appendRecord(pItemSub, sRecord, _sName); 781 | } 782 | } 783 | { 784 | QString sRecord = "VirtualSize"; 785 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(listISH.at(i).Misc.VirtualSize)); 786 | } 787 | { 788 | QString sRecord = "VirtualAddress"; 789 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(listISH.at(i).VirtualAddress)); 790 | } 791 | { 792 | QString sRecord = "SizeOfRawData"; 793 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(listISH.at(i).SizeOfRawData)); 794 | } 795 | { 796 | QString sRecord = "PointerToRawData"; 797 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(listISH.at(i).PointerToRawData)); 798 | } 799 | { 800 | QString sRecord = "PointerToRelocations"; 801 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(listISH.at(i).PointerToRelocations)); 802 | } 803 | { 804 | QString sRecord = "PointerToLinenumbers"; 805 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(listISH.at(i).PointerToLinenumbers)); 806 | } 807 | { 808 | QString sRecord = "NumberOfRelocations"; 809 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(listISH.at(i).NumberOfRelocations)); 810 | } 811 | { 812 | QString sRecord = "NumberOfLinenumbers"; 813 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(listISH.at(i).NumberOfLinenumbers)); 814 | } 815 | { 816 | QString sRecord = "Characteristics"; 817 | if (check(sGroup, sSubGroup, sRecord)) 818 | appendRecord(pItemSub, sRecord, 819 | addFlags(XBinary::MODE_32, listISH.at(i).Characteristics, XPE::getImageSectionHeaderFlags(), XBinary::VL_TYPE_FLAGS)); 820 | } 821 | } 822 | } 823 | } 824 | } 825 | } 826 | } 827 | 828 | void XFileInfo::PE_IMAGE_RESOURCE_DIRECTORY(XPE *pPE) 829 | { 830 | QString sGroup = "IMAGE_RESOURCE_DIRECTORY"; 831 | if (check(sGroup)) { 832 | qint64 nResourceOffset = pPE->getDataDirectoryOffset(XPE_DEF::S_IMAGE_DIRECTORY_ENTRY_RESOURCE); 833 | 834 | if (nResourceOffset != -1) { 835 | XPE_DEF::IMAGE_RESOURCE_DIRECTORY ird = pPE->read_IMAGE_RESOURCE_DIRECTORY(nResourceOffset); 836 | XFileInfoItem *pItemParent = appendRecord(0, sGroup, ""); 837 | { 838 | QString sRecord = "Characteristics"; 839 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(ird.Characteristics)); 840 | } 841 | { 842 | QString sRecord = "TimeDateStamp"; 843 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(ird.TimeDateStamp)); 844 | } 845 | { 846 | QString sRecord = "MajorVersion"; 847 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(ird.MajorVersion)); 848 | } 849 | { 850 | QString sRecord = "MinorVersion"; 851 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(ird.MinorVersion)); 852 | } 853 | { 854 | QString sRecord = "NumberOfNamedEntries"; 855 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(ird.NumberOfNamedEntries)); 856 | } 857 | { 858 | QString sRecord = "NumberOfIdEntries"; 859 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(ird.NumberOfIdEntries)); 860 | } 861 | } 862 | } 863 | } 864 | 865 | void XFileInfo::PE_IMAGE_EXPORT_DIRECTORY(XPE *pPE) 866 | { 867 | QString sGroup = "IMAGE_EXPORT_DIRECTORY"; 868 | if (check(sGroup)) { 869 | qint64 nExportOffset = pPE->getDataDirectoryOffset(XPE_DEF::S_IMAGE_DIRECTORY_ENTRY_EXPORT); 870 | 871 | if (nExportOffset != -1) { 872 | XPE_DEF::IMAGE_EXPORT_DIRECTORY ied = pPE->read_IMAGE_EXPORT_DIRECTORY(nExportOffset); 873 | XFileInfoItem *pItemParent = appendRecord(0, sGroup, ""); 874 | { 875 | QString sRecord = "Characteristics"; 876 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(ied.Characteristics)); 877 | } 878 | { 879 | QString sRecord = "TimeDateStamp"; 880 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(ied.TimeDateStamp)); 881 | } 882 | { 883 | QString sRecord = "MajorVersion"; 884 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(ied.MajorVersion)); 885 | } 886 | { 887 | QString sRecord = "MinorVersion"; 888 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(ied.MinorVersion)); 889 | } 890 | { 891 | QString sRecord = "Name"; 892 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(ied.Name)); 893 | } 894 | { 895 | QString sRecord = "Base"; 896 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(ied.Base)); 897 | } 898 | { 899 | QString sRecord = "NumberOfFunctions"; 900 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(ied.NumberOfFunctions)); 901 | } 902 | { 903 | QString sRecord = "NumberOfNames"; 904 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(ied.NumberOfNames)); 905 | } 906 | { 907 | QString sRecord = "AddressOfFunctions"; 908 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(ied.AddressOfFunctions)); 909 | } 910 | { 911 | QString sRecord = "AddressOfNames"; 912 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(ied.AddressOfNames)); 913 | } 914 | { 915 | QString sRecord = "AddressOfNameOrdinals"; 916 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(ied.AddressOfNameOrdinals)); 917 | } 918 | } 919 | } 920 | } 921 | 922 | void XFileInfo::NE_IMAGE_OS2_HEADER(XNE *pNE) 923 | { 924 | QString sGroup = "IMAGE_OS2_HEADER"; 925 | if (check(sGroup)) { 926 | XFileInfoItem *pItemParent = appendRecord(0, sGroup, ""); 927 | { 928 | { 929 | QString sRecord = "ne_magic"; 930 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pNE->getImageOS2Header_magic())); 931 | } 932 | { 933 | QString sRecord = "ne_ver"; 934 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pNE->getImageOS2Header_ver())); 935 | } 936 | { 937 | QString sRecord = "ne_rev"; 938 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pNE->getImageOS2Header_rev())); 939 | } 940 | { 941 | QString sRecord = "ne_enttab"; 942 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pNE->getImageOS2Header_enttab())); 943 | } 944 | { 945 | QString sRecord = "ne_cbenttab"; 946 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pNE->getImageOS2Header_cbenttab())); 947 | } 948 | { 949 | QString sRecord = "ne_crc"; 950 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pNE->getImageOS2Header_crc())); 951 | } 952 | { 953 | QString sRecord = "ne_flags"; 954 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pNE->getImageOS2Header_flags())); 955 | } 956 | { 957 | QString sRecord = "ne_autodata"; 958 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pNE->getImageOS2Header_autodata())); 959 | } 960 | { 961 | QString sRecord = "ne_heap"; 962 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pNE->getImageOS2Header_heap())); 963 | } 964 | { 965 | QString sRecord = "ne_stack"; 966 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pNE->getImageOS2Header_stack())); 967 | } 968 | { 969 | QString sRecord = "ne_csip"; 970 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pNE->getImageOS2Header_csip())); 971 | } 972 | { 973 | QString sRecord = "ne_sssp"; 974 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pNE->getImageOS2Header_sssp())); 975 | } 976 | { 977 | QString sRecord = "ne_cseg"; 978 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pNE->getImageOS2Header_cseg())); 979 | } 980 | { 981 | QString sRecord = "ne_cmod"; 982 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pNE->getImageOS2Header_cmod())); 983 | } 984 | { 985 | QString sRecord = "ne_cbnrestab"; 986 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pNE->getImageOS2Header_cbnrestab())); 987 | } 988 | { 989 | QString sRecord = "ne_segtab"; 990 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pNE->getImageOS2Header_segtab())); 991 | } 992 | { 993 | QString sRecord = "ne_rsrctab"; 994 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pNE->getImageOS2Header_rsrctab())); 995 | } 996 | { 997 | QString sRecord = "ne_restab"; 998 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pNE->getImageOS2Header_restab())); 999 | } 1000 | { 1001 | QString sRecord = "ne_modtab"; 1002 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pNE->getImageOS2Header_modtab())); 1003 | } 1004 | { 1005 | QString sRecord = "ne_imptab"; 1006 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pNE->getImageOS2Header_imptab())); 1007 | } 1008 | { 1009 | QString sRecord = "ne_nrestab"; 1010 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pNE->getImageOS2Header_nrestab())); 1011 | } 1012 | { 1013 | QString sRecord = "ne_cmovent"; 1014 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pNE->getImageOS2Header_cmovent())); 1015 | } 1016 | { 1017 | QString sRecord = "ne_align"; 1018 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pNE->getImageOS2Header_align())); 1019 | } 1020 | { 1021 | QString sRecord = "ne_cres"; 1022 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pNE->getImageOS2Header_cres())); 1023 | } 1024 | { 1025 | QString sRecord = "ne_exetyp"; 1026 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pNE->getImageOS2Header_exetyp())); 1027 | } 1028 | { 1029 | QString sRecord = "ne_flagsothers"; 1030 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pNE->getImageOS2Header_flagsothers())); 1031 | } 1032 | { 1033 | QString sRecord = "ne_pretthunks"; 1034 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pNE->getImageOS2Header_pretthunks())); 1035 | } 1036 | { 1037 | QString sRecord = "ne_psegrefbytes"; 1038 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pNE->getImageOS2Header_psegrefbytes())); 1039 | } 1040 | { 1041 | QString sRecord = "ne_swaparea"; 1042 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pNE->getImageOS2Header_swaparea())); 1043 | } 1044 | { 1045 | QString sRecord = "ne_expver"; 1046 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pNE->getImageOS2Header_expver())); 1047 | } 1048 | } 1049 | } 1050 | } 1051 | 1052 | void XFileInfo::DEX_HEADER(XDEX *pDEX) 1053 | { 1054 | QString sGroup = "Header"; 1055 | if (check(sGroup)) { 1056 | XFileInfoItem *pItemParent = appendRecord(0, sGroup, ""); 1057 | { 1058 | { 1059 | QString sRecord = "magic"; 1060 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pDEX->getHeader_magic())); 1061 | } 1062 | { 1063 | QString sRecord = "version"; 1064 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pDEX->getHeader_version())); 1065 | } 1066 | { 1067 | QString sRecord = "checksum"; 1068 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pDEX->getHeader_checksum())); 1069 | } 1070 | { 1071 | QString sRecord = "signature"; 1072 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, pDEX->getHeader_signature().toHex()); 1073 | } 1074 | { 1075 | QString sRecord = "file_size"; 1076 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pDEX->getHeader_file_size())); 1077 | } 1078 | { 1079 | QString sRecord = "header_size"; 1080 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pDEX->getHeader_header_size())); 1081 | } 1082 | { 1083 | QString sRecord = "endian_tag"; 1084 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pDEX->getHeader_endian_tag())); 1085 | } 1086 | { 1087 | QString sRecord = "link_size"; 1088 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pDEX->getHeader_link_size())); 1089 | } 1090 | { 1091 | QString sRecord = "link_off"; 1092 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pDEX->getHeader_link_off())); 1093 | } 1094 | { 1095 | QString sRecord = "map_off"; 1096 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pDEX->getHeader_map_off())); 1097 | } 1098 | { 1099 | QString sRecord = "string_ids_size"; 1100 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pDEX->getHeader_string_ids_size())); 1101 | } 1102 | { 1103 | QString sRecord = "string_ids_off"; 1104 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pDEX->getHeader_string_ids_off())); 1105 | } 1106 | { 1107 | QString sRecord = "type_ids_size"; 1108 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pDEX->getHeader_type_ids_size())); 1109 | } 1110 | { 1111 | QString sRecord = "type_ids_off"; 1112 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pDEX->getHeader_type_ids_off())); 1113 | } 1114 | { 1115 | QString sRecord = "proto_ids_size"; 1116 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pDEX->getHeader_proto_ids_size())); 1117 | } 1118 | { 1119 | QString sRecord = "proto_ids_off"; 1120 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pDEX->getHeader_proto_ids_off())); 1121 | } 1122 | { 1123 | QString sRecord = "field_ids_size"; 1124 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pDEX->getHeader_field_ids_size())); 1125 | } 1126 | { 1127 | QString sRecord = "field_ids_off"; 1128 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pDEX->getHeader_field_ids_off())); 1129 | } 1130 | { 1131 | QString sRecord = "method_ids_size"; 1132 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pDEX->getHeader_method_ids_size())); 1133 | } 1134 | { 1135 | QString sRecord = "method_ids_size"; 1136 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pDEX->getHeader_method_ids_size())); 1137 | } 1138 | { 1139 | QString sRecord = "method_ids_off"; 1140 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pDEX->getHeader_method_ids_off())); 1141 | } 1142 | { 1143 | QString sRecord = "class_defs_size"; 1144 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pDEX->getHeader_class_defs_size())); 1145 | } 1146 | { 1147 | QString sRecord = "class_defs_off"; 1148 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pDEX->getHeader_class_defs_off())); 1149 | } 1150 | { 1151 | QString sRecord = "data_size"; 1152 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pDEX->getHeader_data_size())); 1153 | } 1154 | { 1155 | QString sRecord = "data_off"; 1156 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::valueToHex(pDEX->getHeader_data_off())); 1157 | } 1158 | } 1159 | } 1160 | } 1161 | 1162 | void XFileInfo::ELF_Shdr(XELF *pELF) 1163 | { 1164 | QString sGroup = "Section header"; 1165 | if (check(sGroup)) { 1166 | QList listSH = pELF->getElf_ShdrList(100); 1167 | qint32 nNumberOfSections = listSH.count(); 1168 | 1169 | if (nNumberOfSections > 0) { 1170 | XFileInfoItem *pItemParent = appendRecord(0, sGroup, ""); 1171 | 1172 | for (qint32 i = 0; i < nNumberOfSections; i++) { 1173 | QString sSectionName = QString("%1").arg(i); 1174 | 1175 | QString sSubGroup = sSectionName; 1176 | if (check(sGroup, sSubGroup)) { 1177 | XFileInfoItem *pItemSub = appendRecord(pItemParent, sSubGroup, ""); 1178 | { 1179 | { 1180 | QString sRecord = "sh_name"; 1181 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(listSH.at(i).sh_name)); 1182 | } 1183 | // { 1184 | // QString sRecord = "sh_type"; 1185 | // if (check(sGroup, sSubGroup, sRecord)) 1186 | // appendRecord(pItemSub, sRecord, 1187 | // addFlags(XBinary::MODE_32, listSH.at(i).sh_type, XELF::getSectionHeaderType(), XBinary::VL_TYPE_LIST)); 1188 | // } 1189 | // { 1190 | // QString sRecord = "sh_flags"; 1191 | // if (check(sGroup, sSubGroup, sRecord)) 1192 | // appendRecord(pItemSub, sRecord, 1193 | // addFlags(XBinary::MODE_32, listSH.at(i).sh_flags, XELF::getSectionHeaderFlags(), XBinary::VL_TYPE_FLAGS)); 1194 | // } 1195 | { 1196 | QString sRecord = "sh_addr"; 1197 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(listSH.at(i).sh_addr)); 1198 | } 1199 | { 1200 | QString sRecord = "sh_offset"; 1201 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(listSH.at(i).sh_offset)); 1202 | } 1203 | { 1204 | QString sRecord = "sh_size"; 1205 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(listSH.at(i).sh_size)); 1206 | } 1207 | { 1208 | QString sRecord = "sh_link"; 1209 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(listSH.at(i).sh_link)); 1210 | } 1211 | { 1212 | QString sRecord = "sh_info"; 1213 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(listSH.at(i).sh_info)); 1214 | } 1215 | { 1216 | QString sRecord = "sh_addralign"; 1217 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(listSH.at(i).sh_addralign)); 1218 | } 1219 | { 1220 | QString sRecord = "sh_entsize"; 1221 | if (check(sGroup, sSubGroup, sRecord)) appendRecord(pItemSub, sRecord, XBinary::valueToHex(listSH.at(i).sh_entsize)); 1222 | } 1223 | } 1224 | } 1225 | } 1226 | } 1227 | } 1228 | } 1229 | 1230 | void XFileInfo::process() 1231 | { 1232 | m_nFreeIndex = XBinary::getFreeIndex(m_pPdStruct); 1233 | XBinary::setPdStructInit(m_pPdStruct, m_nFreeIndex, 0); 1234 | 1235 | XBinary::FT fileType = m_options.fileType; 1236 | 1237 | if (fileType == XBinary::FT_UNKNOWN) { 1238 | fileType = XBinary::getPrefFileType(m_pDevice); 1239 | } 1240 | 1241 | { 1242 | QString sGroup = "Info"; 1243 | if (check(sGroup)) { 1244 | XFileInfoItem *pItemParent = appendRecord(0, sGroup, ""); 1245 | { 1246 | QString sRecord = "File name"; 1247 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::getDeviceFileName(m_pDevice)); 1248 | } 1249 | 1250 | XBinary::FILEFORMATINFO fileFormatInfo = XFormats::getFileFormatInfo(fileType, m_pDevice, true, -1, m_pPdStruct); 1251 | { 1252 | QString sRecord = "Size"; 1253 | if (check(sGroup, sRecord)) { 1254 | qint64 nSize = m_pDevice->size(); 1255 | QString sSize = QString::number(nSize); 1256 | 1257 | if (m_options.bComment) { 1258 | sSize += QString("(%1)").arg(XBinary::bytesCountToString(nSize)); 1259 | } 1260 | 1261 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, sSize); 1262 | } 1263 | } 1264 | { 1265 | QString sRecord = "File type"; 1266 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::fileTypeIdToString(fileFormatInfo.fileType)); 1267 | } 1268 | { 1269 | QString sRecord = "String"; 1270 | QString sString = XBinary::getFileFormatString(&fileFormatInfo); 1271 | if (check(sGroup, sRecord) && (sString != "")) { 1272 | appendRecord(pItemParent, sRecord, sString); 1273 | } 1274 | } 1275 | { 1276 | QString sRecord = "Extension"; 1277 | if (check(sGroup, sRecord) && (fileFormatInfo.sExt != "")) { 1278 | appendRecord(pItemParent, sRecord, fileFormatInfo.sExt); 1279 | } 1280 | } 1281 | { 1282 | QString sRecord = "Version"; 1283 | if (check(sGroup, sRecord) && (fileFormatInfo.sVersion != "")) { 1284 | appendRecord(pItemParent, sRecord, fileFormatInfo.sVersion); 1285 | } 1286 | } 1287 | { 1288 | QString sRecord = "Info"; 1289 | if (check(sGroup, sRecord) && (fileFormatInfo.sInfo != "")) { 1290 | appendRecord(pItemParent, sRecord, fileFormatInfo.sInfo); 1291 | } 1292 | } 1293 | { 1294 | QString sRecord = "MIME"; 1295 | if (check(sGroup, sRecord) && (fileFormatInfo.sMIME != "")) { 1296 | appendRecord(pItemParent, sRecord, fileFormatInfo.sMIME); 1297 | } 1298 | } 1299 | 1300 | if (XBinary::checkFileType(XBinary::FT_ELF, fileType) || XBinary::checkFileType(XBinary::FT_PE, fileType) || 1301 | XBinary::checkFileType(XBinary::FT_MACHO, fileType) || XBinary::checkFileType(XBinary::FT_MSDOS, fileType) || 1302 | XBinary::checkFileType(XBinary::FT_NE, fileType) || XBinary::checkFileType(XBinary::FT_LE, fileType) || 1303 | XBinary::checkFileType(XBinary::FT_MACHOFAT, fileType) || XBinary::checkFileType(XBinary::FT_AMIGAHUNK, fileType)) { 1304 | { 1305 | QString sRecord = "Operation system"; 1306 | if (check(sGroup, sRecord)) { 1307 | QString sOperationSystem = XBinary::osNameIdToString(fileFormatInfo.osName); 1308 | 1309 | if (fileFormatInfo.sOsVersion != "") { 1310 | sOperationSystem += QString("(%1)").arg(fileFormatInfo.sOsVersion); 1311 | } 1312 | 1313 | appendRecord(pItemParent, sRecord, sOperationSystem); 1314 | } 1315 | } 1316 | { 1317 | QString sRecord = "Architecture"; 1318 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, fileFormatInfo.sArch); 1319 | } 1320 | { 1321 | QString sRecord = "Mode"; 1322 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::modeIdToString(fileFormatInfo.mode)); 1323 | } 1324 | { 1325 | QString sRecord = "Type"; 1326 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, fileFormatInfo.sType); 1327 | } 1328 | { 1329 | QString sRecord = "Endianness"; 1330 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::endianToString(fileFormatInfo.endian)); 1331 | } 1332 | } 1333 | } 1334 | } 1335 | { 1336 | QString sGroup = "Hash"; 1337 | if (check(sGroup)) { 1338 | XFileInfoItem *pItemParent = appendRecord(0, sGroup, ""); 1339 | { 1340 | QString sRecord = "MD4"; 1341 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::getHash(XBinary::HASH_MD4, m_pDevice, m_pPdStruct)); 1342 | } 1343 | { 1344 | QString sRecord = "MD5"; 1345 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::getHash(XBinary::HASH_MD5, m_pDevice, m_pPdStruct)); 1346 | } 1347 | { 1348 | QString sRecord = "SHA1"; 1349 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::getHash(XBinary::HASH_SHA1, m_pDevice, m_pPdStruct)); 1350 | } 1351 | #ifndef QT_CRYPTOGRAPHICHASH_ONLY_SHA1 1352 | #if (QT_VERSION_MAJOR > 4) 1353 | { 1354 | QString sRecord = "SHA224"; 1355 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::getHash(XBinary::HASH_SHA224, m_pDevice, m_pPdStruct)); 1356 | } 1357 | { 1358 | QString sRecord = "SHA256"; 1359 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::getHash(XBinary::HASH_SHA256, m_pDevice, m_pPdStruct)); 1360 | } 1361 | { 1362 | QString sRecord = "SHA384"; 1363 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::getHash(XBinary::HASH_SHA384, m_pDevice, m_pPdStruct)); 1364 | } 1365 | { 1366 | QString sRecord = "SHA512"; 1367 | if (check(sGroup, sRecord)) appendRecord(pItemParent, sRecord, XBinary::getHash(XBinary::HASH_SHA512, m_pDevice, m_pPdStruct)); 1368 | } 1369 | #endif 1370 | #endif 1371 | } 1372 | } 1373 | { 1374 | QString sRecord = "Entropy"; 1375 | if (check(sRecord)) { 1376 | XBinary binary(m_pDevice); 1377 | 1378 | double dEntropy = binary.getBinaryStatus(XBinary::BSTATUS_ENTROPY, 0, -1, m_pPdStruct); 1379 | QString sEntropy = QString::number(dEntropy); 1380 | 1381 | if (m_options.bComment) { 1382 | sEntropy += QString("(%1)").arg(binary.isPacked(dEntropy) ? ("packed") : ("not packed")); 1383 | } 1384 | 1385 | appendRecord(0, sRecord, sEntropy); 1386 | } 1387 | } 1388 | { 1389 | QString sRecord = "Check format"; 1390 | if (check(sRecord)) { 1391 | QList listFileFormatMessages; 1392 | 1393 | if (XBinary::checkFileType(XBinary::FT_PE, fileType)) { 1394 | XPE pe(m_pDevice); 1395 | 1396 | if (pe.isValid(m_pPdStruct)) { 1397 | listFileFormatMessages = pe.checkFileFormat(true, m_pPdStruct); 1398 | } 1399 | 1400 | QList listResult = XBinary::getFileFormatMessages(&listFileFormatMessages); 1401 | 1402 | qint32 nNumberOfMessages = listResult.count(); 1403 | 1404 | for (qint32 i = 0; i < nNumberOfMessages; i++) { 1405 | QString sString = listResult.at(i); 1406 | appendRecord(0, QString::number(i), sString); 1407 | } 1408 | } 1409 | } 1410 | } 1411 | { 1412 | QString sRecord = "Format"; 1413 | if (check(sRecord)) { 1414 | // XFormats::getDaraRefs(m_pDevice, m_pPdStruct, true); 1415 | } 1416 | } 1417 | 1418 | if (XBinary::isPdStructNotCanceled(m_pPdStruct)) { 1419 | if (XBinary::checkFileType(XBinary::FT_BINARY, fileType)) { 1420 | XBinary binary(m_pDevice); 1421 | 1422 | if (binary.isValid(m_pPdStruct)) { 1423 | if (XBinary::isPdStructNotCanceled(m_pPdStruct)) { 1424 | { 1425 | // TODO 1426 | } 1427 | } 1428 | } 1429 | } else if (XBinary::checkFileType(XBinary::FT_ELF, fileType)) { 1430 | XELF elf(m_pDevice); 1431 | 1432 | if (elf.isValid(m_pPdStruct)) { 1433 | if (XBinary::isPdStructNotCanceled(m_pPdStruct)) { 1434 | bool bIs64 = elf.is64(); 1435 | 1436 | // XBinary::_MEMORY_MAP memoryMap = elf.getMemoryMap(m_options.mapMode, m_pPdStruct); 1437 | XBinary::_MEMORY_MAP memoryMap = elf.getMemoryMap(XBinary::MAPMODE_SEGMENTS, m_pPdStruct); 1438 | 1439 | _entryPoint(&elf, &memoryMap); 1440 | _Elf_Ehdr(&elf, bIs64); 1441 | // TODO 1442 | // TODO Sections 1443 | // TODO Programs 1444 | // TODO rels 1445 | // TODO libraries 1446 | // TODO symbols 1447 | // TODO dynamic 1448 | // TODO notes 1449 | // TODO version 1450 | // TODO verneed 1451 | // TODO verdef 1452 | // TODO gnuhash 1453 | // TODO hash 1454 | // TODO sysvhash 1455 | // TODO relocations 1456 | // TODO relocationsaddend 1457 | // TODO relocationsrel 1458 | // TODO relocationsrela 1459 | // TODO relocationsplt 1460 | // TODO relocationspltrel 1461 | } 1462 | } 1463 | } else if (XBinary::checkFileType(XBinary::FT_MACHO, fileType)) { 1464 | XMACH mach(m_pDevice); 1465 | 1466 | if (mach.isValid(m_pPdStruct)) { 1467 | if (XBinary::isPdStructNotCanceled(m_pPdStruct)) { 1468 | bool bIs64 = mach.is64(); 1469 | 1470 | // XBinary::_MEMORY_MAP memoryMap = mach.getMemoryMap(m_options.mapMode, m_pPdStruct); 1471 | XBinary::_MEMORY_MAP memoryMap = mach.getMemoryMap(XBinary::MAPMODE_SEGMENTS, m_pPdStruct); 1472 | 1473 | _entryPoint(&mach, &memoryMap); 1474 | _mach_header(&mach, bIs64); 1475 | // TODO 1476 | } 1477 | } 1478 | } else if (XBinary::checkFileType(XBinary::FT_MACHOFAT, fileType)) { 1479 | XMACHOFat machofat(m_pDevice); 1480 | 1481 | if (machofat.isValid(m_pPdStruct)) { 1482 | if (XBinary::isPdStructNotCanceled(m_pPdStruct)) { 1483 | // TODO 1484 | } 1485 | } 1486 | } else if (XBinary::checkFileType(XBinary::FT_PE, fileType)) { 1487 | XPE pe(m_pDevice); 1488 | 1489 | if (pe.isValid(m_pPdStruct)) { 1490 | if (XBinary::isPdStructNotCanceled(m_pPdStruct)) { 1491 | // XBinary::_MEMORY_MAP memoryMap = pe.getMemoryMap(m_options.mapMode, m_pPdStruct); 1492 | XBinary::_MEMORY_MAP memoryMap = pe.getMemoryMap(XBinary::MAPMODE_UNKNOWN, m_pPdStruct); 1493 | bool bIs64 = pe.is64(); 1494 | 1495 | _entryPoint(&pe, &memoryMap); 1496 | _IMAGE_DOS_HEADER(&pe, true); 1497 | PE_IMAGE_NT_HEADERS(&pe, bIs64); 1498 | 1499 | if (pe.getFileHeader_NumberOfSections()) { 1500 | PE_IMAGE_SECTION_HEADER(&pe); 1501 | } 1502 | 1503 | if (pe.isResourcesPresent()) { 1504 | PE_IMAGE_RESOURCE_DIRECTORY(&pe); 1505 | } 1506 | 1507 | if (pe.isExportPresent()) { 1508 | PE_IMAGE_EXPORT_DIRECTORY(&pe); 1509 | } 1510 | 1511 | // TODO 1512 | // Sizes !!! 1513 | // Resources 1514 | // Import 1515 | // Export 1516 | // Relocs 1517 | // Exceptions 1518 | // Debug 1519 | // TLS 1520 | // LoadConfig 1521 | // BoundImport 1522 | // DelayImport 1523 | // NET 1524 | // Overlay 1525 | // Rich 1526 | // Sign 1527 | } 1528 | } 1529 | } else if (XBinary::checkFileType(XBinary::FT_NE, fileType)) { 1530 | XNE ne(m_pDevice); 1531 | 1532 | if (ne.isValid(m_pPdStruct)) { 1533 | if (XBinary::isPdStructNotCanceled(m_pPdStruct)) { 1534 | // XBinary::_MEMORY_MAP memoryMap = ne.getMemoryMap(m_options.mapMode, m_pPdStruct); 1535 | XBinary::_MEMORY_MAP memoryMap = ne.getMemoryMap(XBinary::MAPMODE_UNKNOWN, m_pPdStruct); 1536 | 1537 | _entryPoint(&ne, &memoryMap); 1538 | _IMAGE_DOS_HEADER(&ne, true); 1539 | } 1540 | } 1541 | } else if (XBinary::checkFileType(XBinary::FT_LE, fileType)) { 1542 | XLE le(m_pDevice); 1543 | 1544 | if (le.isValid(m_pPdStruct)) { 1545 | if (XBinary::isPdStructNotCanceled(m_pPdStruct)) { 1546 | // XBinary::_MEMORY_MAP memoryMap = le.getMemoryMap(m_options.mapMode, m_pPdStruct); 1547 | XBinary::_MEMORY_MAP memoryMap = le.getMemoryMap(XBinary::MAPMODE_UNKNOWN, m_pPdStruct); 1548 | 1549 | _entryPoint(&le, &memoryMap); 1550 | _IMAGE_DOS_HEADER(&le, true); 1551 | 1552 | // TODO 1553 | } 1554 | } 1555 | } else if (XBinary::checkFileType(XBinary::FT_MSDOS, fileType)) { 1556 | XMSDOS msdos(m_pDevice); 1557 | 1558 | if (msdos.isValid()) { 1559 | if (XBinary::isPdStructNotCanceled(m_pPdStruct)) { 1560 | // XBinary::_MEMORY_MAP memoryMap = msdos.getMemoryMap(m_options.mapMode, m_pPdStruct); 1561 | XBinary::_MEMORY_MAP memoryMap = msdos.getMemoryMap(XBinary::MAPMODE_UNKNOWN, m_pPdStruct); 1562 | 1563 | _entryPoint(&msdos, &memoryMap); 1564 | _IMAGE_DOS_HEADER(&msdos, false); 1565 | 1566 | // TODO 1567 | } 1568 | } 1569 | } else if (XBinary::checkFileType(XBinary::FT_COM, fileType)) { 1570 | XCOM xcom(m_pDevice); 1571 | 1572 | if (xcom.isValid(m_pPdStruct)) { 1573 | if (XBinary::isPdStructNotCanceled(m_pPdStruct)) { 1574 | // XBinary::_MEMORY_MAP memoryMap = xcom.getMemoryMap(m_options.mapMode, m_pPdStruct); 1575 | XBinary::_MEMORY_MAP memoryMap = xcom.getMemoryMap(XBinary::MAPMODE_UNKNOWN, m_pPdStruct); 1576 | 1577 | _entryPoint(&xcom, &memoryMap); 1578 | // TODO 1579 | } 1580 | } 1581 | } else if (XBinary::checkFileType(XBinary::FT_DEX, fileType)) { 1582 | XDEX dex(m_pDevice); 1583 | 1584 | if (dex.isValid(m_pPdStruct)) { 1585 | if (XBinary::isPdStructNotCanceled(m_pPdStruct)) { 1586 | DEX_HEADER(&dex); 1587 | } 1588 | } 1589 | } else if (XBinary::checkFileType(XBinary::FT_PDF, fileType)) { 1590 | XPDF pdf(m_pDevice); 1591 | 1592 | if (pdf.isValid(m_pPdStruct)) { 1593 | if (check("File type")) appendRecord(0, "File type", XBinary::fileTypeIdToString(pdf.getFileType())); 1594 | // if(check("Version","Version")) 1595 | // appendRecord(0,"Version"),pdf.getVersion()); 1596 | // TODO 1597 | } 1598 | } else if (XBinary::checkFileType(XBinary::FT_MACHOFAT, fileType)) { 1599 | XMACHOFat machofat(m_pDevice); 1600 | 1601 | if (machofat.isValid(m_pPdStruct)) { 1602 | // TODO 1603 | } 1604 | } else { 1605 | // TODO 1606 | } 1607 | } 1608 | 1609 | XBinary::setPdStructFinished(m_pPdStruct, m_nFreeIndex); 1610 | } 1611 | --------------------------------------------------------------------------------