├── README.md ├── xextractorwidget.pri ├── LICENSE ├── dialogxextractor.h ├── dialogxextractor.ui ├── dialogxextractor.cpp ├── xextractorwidget.cmake ├── xextractorwidget.h ├── xextractorwidget.ui └── xextractorwidget.cpp /README.md: -------------------------------------------------------------------------------- 1 | # XExtractorWidget 2 | -------------------------------------------------------------------------------- /xextractorwidget.pri: -------------------------------------------------------------------------------- 1 | QT += concurrent 2 | 3 | INCLUDEPATH += $$PWD 4 | DEPENDPATH += $$PWD 5 | 6 | HEADERS += \ 7 | $$PWD/dialogxextractor.h \ 8 | $$PWD/xextractorwidget.h 9 | 10 | SOURCES += \ 11 | $$PWD/dialogxextractor.cpp \ 12 | $$PWD/xextractorwidget.cpp 13 | 14 | FORMS += \ 15 | $$PWD/dialogxextractor.ui \ 16 | $$PWD/xextractorwidget.ui 17 | 18 | !contains(XCONFIG, xextractor) { 19 | XCONFIG += xextractor 20 | include($$PWD/../XExtractor/xextractor.pri) 21 | } 22 | 23 | !contains(XCONFIG, xdialogprocess) { 24 | XCONFIG += xdialogprocess 25 | include($$PWD/../FormatDialogs/xdialogprocess.pri) 26 | } 27 | 28 | !contains(XCONFIG, dialogdump) { 29 | XCONFIG += dialogdump 30 | include($$PWD/../FormatDialogs/dialogdump.pri) 31 | } 32 | 33 | !contains(XCONFIG, xcomboboxex) { 34 | XCONFIG += xcomboboxex 35 | include($$PWD/../Controls/xcomboboxex.pri) 36 | } 37 | 38 | DISTFILES += \ 39 | $$PWD/LICENSE \ 40 | $$PWD/README.md \ 41 | $$PWD/xextractorwidget.cmake 42 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022-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 | -------------------------------------------------------------------------------- /dialogxextractor.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2022-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 DIALOGXEXTRACTOR_H 22 | #define DIALOGXEXTRACTOR_H 23 | 24 | #include "xshortcutsdialog.h" 25 | #include "xextractorwidget.h" 26 | 27 | namespace Ui { 28 | class DialogXExtractor; 29 | } 30 | 31 | class DialogXExtractor : public XShortcutsDialog { 32 | Q_OBJECT 33 | 34 | public: 35 | explicit DialogXExtractor(QWidget *pParent = nullptr); 36 | ~DialogXExtractor(); 37 | 38 | void setData(QIODevice *pDevice, XInfoDB *pXInfoDB); 39 | virtual void adjustView(); 40 | 41 | private slots: 42 | void on_pushButtonClose_clicked(); 43 | 44 | private: 45 | Ui::DialogXExtractor *ui; 46 | }; 47 | 48 | #endif // DIALOGXEXTRACTOR_H 49 | -------------------------------------------------------------------------------- /dialogxextractor.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | DialogXExtractor 4 | 5 | 6 | 7 | 0 8 | 0 9 | 784 10 | 346 11 | 12 | 13 | 14 | Extractor 15 | 16 | 17 | 18 | 19 | 20 | 21 | 0 22 | 0 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | Qt::Horizontal 33 | 34 | 35 | 36 | 40 37 | 20 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | Close 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | XExtractorWidget 56 | QWidget 57 |
xextractorwidget.h
58 | 1 59 |
60 |
61 | 62 | 63 |
64 | -------------------------------------------------------------------------------- /dialogxextractor.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2022-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 "dialogxextractor.h" 22 | 23 | #include "ui_dialogxextractor.h" 24 | 25 | DialogXExtractor::DialogXExtractor(QWidget *pParent) : XShortcutsDialog(pParent, true), ui(new Ui::DialogXExtractor) 26 | { 27 | ui->setupUi(this); 28 | } 29 | 30 | DialogXExtractor::~DialogXExtractor() 31 | { 32 | delete ui; 33 | } 34 | 35 | void DialogXExtractor::setData(QIODevice *pDevice, XInfoDB *pXInfoDB) 36 | { 37 | ui->widgetExtractor->setData(pDevice, pXInfoDB, XExtractor::getDefaultOptions(), true); 38 | } 39 | 40 | void DialogXExtractor::adjustView() 41 | { 42 | ui->widgetExtractor->adjustView(); 43 | } 44 | 45 | void DialogXExtractor::on_pushButtonClose_clicked() 46 | { 47 | this->close(); 48 | } 49 | -------------------------------------------------------------------------------- /xextractorwidget.cmake: -------------------------------------------------------------------------------- 1 | include_directories(${CMAKE_CURRENT_LIST_DIR}) 2 | 3 | if (NOT DEFINED XEXTRACTOR_SOURCES) 4 | include(${CMAKE_CURRENT_LIST_DIR}/../XExtractor/xextractor.cmake) 5 | set(XEXTRACTORWIDGET_SOURCES ${XEXTRACTORWIDGET_SOURCES} ${XEXTRACTOR_SOURCES}) 6 | endif() 7 | if (NOT DEFINED XDIALOGPROCESS_SOURCES) 8 | include(${CMAKE_CURRENT_LIST_DIR}/../FormatDialogs/xdialogprocess.cmake) 9 | set(XEXTRACTORWIDGET_SOURCES ${XEXTRACTORWIDGET_SOURCES} ${XDIALOGPROCESS_SOURCES}) 10 | endif() 11 | if (NOT DEFINED DIALOGDUMP_SOURCES) 12 | include(${CMAKE_CURRENT_LIST_DIR}/../FormatDialogs/dialogdump.cmake) 13 | set(XEXTRACTORWIDGET_SOURCES ${XEXTRACTORWIDGET_SOURCES} ${DIALOGDUMP_SOURCES}) 14 | endif() 15 | if (NOT DEFINED XDIALOGPROCESS_SOURCES) 16 | include(${CMAKE_CURRENT_LIST_DIR}/../FormatDialogs/dialogdump.cmake) 17 | set(XEXTRACTORWIDGET_SOURCES ${DIALOGDUMP_SOURCES} ${DIALOGDUMP_SOURCES}) 18 | endif() 19 | if (NOT DEFINED XCOMBOBOXEX_SOURCES) 20 | include(${CMAKE_CURRENT_LIST_DIR}/../Controls/xcomboboxex.cmake) 21 | set(XEXTRACTORWIDGET_SOURCES ${XEXTRACTORWIDGET_SOURCES} ${XCOMBOBOXEX_SOURCES}) 22 | endif() 23 | if (NOT DEFINED XTABLEVIEW_SOURCES) 24 | include(${CMAKE_CURRENT_LIST_DIR}/../Controls/xtableview.cmake) 25 | set(XEXTRACTORWIDGET_SOURCES ${XEXTRACTORWIDGET_SOURCES} ${XTABLEVIEW_SOURCES}) 26 | endif() 27 | if (NOT DEFINED XOPTIONSWIDGET_SOURCES) 28 | include(${CMAKE_CURRENT_LIST_DIR}/../XOptions/xoptionswidget.cmake) 29 | set(XEXTRACTORWIDGET_SOURCES ${XEXTRACTORWIDGET_SOURCES} ${XOPTIONSWIDGET_SOURCES}) 30 | endif() 31 | if (NOT DEFINED XHEXVIEW_SOURCES) 32 | include(${CMAKE_CURRENT_LIST_DIR}/../XHexView/xhexview.cmake) 33 | set(XEXTRACTORWIDGET_SOURCES ${XEXTRACTORWIDGET_SOURCES} ${XHEXVIEW_SOURCES}) 34 | endif() 35 | 36 | set(XEXTRACTORWIDGET_SOURCES 37 | ${XEXTRACTORWIDGET_SOURCES} 38 | ${CMAKE_CURRENT_LIST_DIR}/xextractorwidget.cpp 39 | ${CMAKE_CURRENT_LIST_DIR}/xextractorwidget.h 40 | ${CMAKE_CURRENT_LIST_DIR}/xextractorwidget.ui 41 | ${CMAKE_CURRENT_LIST_DIR}/dialogxextractor.cpp 42 | ${CMAKE_CURRENT_LIST_DIR}/dialogxextractor.h 43 | ${CMAKE_CURRENT_LIST_DIR}/dialogxextractor.ui 44 | ) 45 | -------------------------------------------------------------------------------- /xextractorwidget.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2022-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 XEXTRACTORWIDGET_H 22 | #define XEXTRACTORWIDGET_H 23 | 24 | #include "dumpprocess.h" 25 | #include "xdialogprocess.h" 26 | #include "xextractor.h" 27 | #include "xmodel_extractor.h" 28 | #include "xshortcutswidget.h" 29 | #include "xinfodb.h" 30 | 31 | namespace Ui { 32 | class XExtractorWidget; 33 | } 34 | 35 | class XExtractorWidget : public XShortcutsWidget { 36 | Q_OBJECT 37 | 38 | public: 39 | explicit XExtractorWidget(QWidget *pParent = nullptr); 40 | ~XExtractorWidget(); 41 | 42 | void setData(QIODevice *pDevice, XInfoDB *pXInfoDB, const XExtractor::OPTIONS &options, bool bAuto); 43 | void reload(); 44 | DumpProcess::RECORD getDumpProcessRecord(QModelIndex index); 45 | virtual void adjustView(); 46 | virtual void reloadData(bool bSaveSelection); 47 | void setGlobal(XShortcuts *pShortcuts, XOptions *pXOptions); 48 | 49 | private slots: 50 | void on_toolButtonScan_clicked(); 51 | void on_toolButtonSave_clicked(); 52 | void on_toolButtonDumpAll_clicked(); 53 | void on_tableViewResult_customContextMenuRequested(const QPoint &pos); 54 | void dumpToFile(); 55 | void _hexSlot(); 56 | void on_comboBoxType_currentIndexChanged(int nIndex); 57 | void on_comboBoxMapMode_currentIndexChanged(int nIndex); 58 | void viewSelection(); 59 | void on_tableViewResult_clicked(const QModelIndex &index); 60 | void on_tableViewSelection(const QItemSelection &itemSelected, const QItemSelection &itemDeselected); 61 | void on_comboBoxExtractorMode_currentIndexChanged(int index); 62 | void on_checkBoxAllTypes_checkStateChanged(const Qt::CheckState &checkState); 63 | 64 | protected: 65 | virtual void registerShortcuts(bool bState); 66 | 67 | private: 68 | Ui::XExtractorWidget *ui; 69 | QIODevice *m_pDevice; 70 | XInfoDB *m_pXInfoDB; 71 | XExtractor::OPTIONS m_options; 72 | XExtractor::DATA m_extractor_data; 73 | }; 74 | 75 | #endif // XEXTRACTORWIDGET_H 76 | -------------------------------------------------------------------------------- /xextractorwidget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | XExtractorWidget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 720 10 | 556 11 | 12 | 13 | 14 | Extract 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 | 120 46 | 0 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 100 56 | 0 57 | 58 | 59 | 60 | 61 | 62 | 63 | Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter 64 | 65 | 66 | 67 | 68 | 69 | 70 | Qt::Orientation::Horizontal 71 | 72 | 73 | 74 | 40 75 | 20 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 0 85 | 0 86 | 87 | 88 | 89 | Dump all 90 | 91 | 92 | Qt::ToolButtonStyle::ToolButtonTextBesideIcon 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 0 101 | 0 102 | 103 | 104 | 105 | Save 106 | 107 | 108 | Qt::ToolButtonStyle::ToolButtonTextBesideIcon 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 0 117 | 0 118 | 119 | 120 | 121 | Scan 122 | 123 | 124 | Qt::ToolButtonStyle::ToolButtonTextBesideIcon 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 120 137 | 0 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | All 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 0 154 | 0 155 | 156 | 157 | 158 | 159 | 200 160 | 0 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | Qt::Orientation::Horizontal 169 | 170 | 171 | 172 | 0 173 | 0 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | Deep scan 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | Qt::Orientation::Vertical 191 | 192 | 193 | 194 | Qt::ContextMenuPolicy::CustomContextMenu 195 | 196 | 197 | QAbstractItemView::EditTrigger::NoEditTriggers 198 | 199 | 200 | QAbstractItemView::SelectionMode::SingleSelection 201 | 202 | 203 | QAbstractItemView::SelectionBehavior::SelectRows 204 | 205 | 206 | true 207 | 208 | 209 | true 210 | 211 | 212 | false 213 | 214 | 215 | 20 216 | 217 | 218 | 20 219 | 220 | 221 | false 222 | 223 | 224 | false 225 | 226 | 227 | 228 | 229 | 230 | 0 231 | 0 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | XHexViewEx 242 | QScrollArea 243 |
xhexviewex.h
244 | 1 245 |
246 | 247 | XComboBoxEx 248 | QComboBox 249 |
xcomboboxex.h
250 |
251 | 252 | XTableView 253 | QTableView 254 |
xtableview.h
255 |
256 |
257 | 258 | 259 |
260 | -------------------------------------------------------------------------------- /xextractorwidget.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2022-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 "xextractorwidget.h" 22 | 23 | #include "ui_xextractorwidget.h" 24 | 25 | XExtractorWidget::XExtractorWidget(QWidget *pParent) : XShortcutsWidget(pParent), ui(new Ui::XExtractorWidget) 26 | { 27 | ui->setupUi(this); 28 | 29 | XOptions::adjustToolButton(ui->toolButtonScan, XOptions::ICONTYPE_SCAN); 30 | XOptions::adjustToolButton(ui->toolButtonSave, XOptions::ICONTYPE_SAVE); 31 | XOptions::adjustToolButton(ui->toolButtonDumpAll, XOptions::ICONTYPE_DUMPTOFILE); 32 | 33 | ui->comboBoxType->setToolTip(tr("Type")); 34 | ui->comboBoxMapMode->setToolTip(tr("Mode")); 35 | ui->comboBoxOptions->setToolTip(tr("Options")); 36 | ui->checkBoxDeepScan->setToolTip(tr("Deep scan")); 37 | // ui->checkBoxHeuristicScan->setToolTip(tr("Heuristic scan")); 38 | ui->toolButtonScan->setToolTip(tr("Scan")); 39 | ui->toolButtonSave->setToolTip(tr("Save")); 40 | ui->toolButtonDumpAll->setToolTip(tr("Dump all")); 41 | ui->labelSize->setToolTip(tr("Size")); 42 | ui->comboBoxExtractorMode->setToolTip(tr("Mode")); 43 | 44 | m_pDevice = nullptr; 45 | m_pXInfoDB = nullptr; 46 | m_options = {}; 47 | } 48 | 49 | XExtractorWidget::~XExtractorWidget() 50 | { 51 | delete ui; 52 | } 53 | 54 | void XExtractorWidget::setData(QIODevice *pDevice, XInfoDB *pXInfoDB, const XExtractor::OPTIONS &options, bool bAuto) 55 | { 56 | m_pDevice = pDevice; 57 | m_pXInfoDB = pXInfoDB; 58 | m_options = options; 59 | 60 | ui->checkBoxDeepScan->setChecked(options.bDeepScan); 61 | // ui->checkBoxHeuristicScan->setChecked(options.bHeuristicScan); 62 | 63 | XBinary::FT fileType = XFormats::setFileTypeComboBox(options.fileType, m_pDevice, ui->comboBoxType); 64 | XFormats::getMapModesList(fileType, ui->comboBoxMapMode); 65 | 66 | bool bFormat = XExtractor::isFormatModeAvailable(fileType); 67 | bool bUnpack = XExtractor::isUnpackModeAvailable(fileType); 68 | 69 | { 70 | bool bBlock = ui->comboBoxExtractorMode->blockSignals(true); 71 | 72 | ui->comboBoxExtractorMode->clear(); 73 | ui->comboBoxExtractorMode->addItem(XExtractor::extractorModeToString(XExtractor::EMODE_HEURISTIC), XExtractor::EMODE_HEURISTIC); 74 | 75 | if (bFormat) { 76 | ui->comboBoxExtractorMode->addItem(XExtractor::extractorModeToString(XExtractor::EMODE_FORMAT), XExtractor::EMODE_FORMAT); 77 | } 78 | 79 | ui->comboBoxExtractorMode->addItem(XExtractor::extractorModeToString(XExtractor::EMODE_RAW), XExtractor::EMODE_RAW); 80 | 81 | XFormats::setComboBoxCurrent(ui->comboBoxExtractorMode, options.emode); 82 | 83 | ui->comboBoxExtractorMode->blockSignals(bBlock); 84 | } 85 | 86 | { 87 | XExtractor::EMODE emode = (XExtractor::EMODE)(ui->comboBoxExtractorMode->currentData().toInt()); 88 | 89 | if (emode == XExtractor::EMODE_HEURISTIC) { 90 | if (bFormat) { 91 | emode = XExtractor::EMODE_FORMAT; 92 | } else { 93 | emode = XExtractor::EMODE_RAW; 94 | } 95 | } 96 | 97 | QList listCustomFlags; 98 | 99 | QList listFileTypes = XExtractor::getAvailableFileTypes(emode); 100 | 101 | qint32 nNumberOfRecords = listFileTypes.count(); 102 | 103 | for (qint32 i = 0; i < nNumberOfRecords; i++) { 104 | XComboBoxEx::_addCustomFlag(&listCustomFlags, listFileTypes.at(i), XFormats::getFileFormatExtsString(listFileTypes.at(i)), false); 105 | } 106 | 107 | ui->comboBoxOptions->clear(); 108 | ui->comboBoxOptions->addCustomFlags(tr("Options"), listCustomFlags); 109 | } 110 | { 111 | qint32 nNumberOfRecords = options.listFileTypes.count(); 112 | 113 | for (qint32 i = 0; i < nNumberOfRecords; i++) { 114 | ui->comboBoxOptions->setCustomFlag(options.listFileTypes.at(i)); 115 | } 116 | } 117 | 118 | ui->checkBoxAllTypes->setChecked(options.bAllTypes); 119 | 120 | XBinaryView::OPTIONS hex_options = {}; 121 | 122 | ui->widgetHex->setData(pDevice, hex_options, true, m_pXInfoDB); 123 | 124 | if (bAuto) { 125 | reload(); 126 | } 127 | } 128 | 129 | void XExtractorWidget::reload() 130 | { 131 | ui->labelSize->setText(XBinary::valueToHexEx(m_pDevice->size())); 132 | 133 | m_extractor_data = {}; 134 | 135 | QList listFlags = ui->comboBoxOptions->getCustomFlags(); 136 | 137 | qint32 nNumberOfRecords = listFlags.count(); 138 | 139 | for (qint32 i = 0; i < nNumberOfRecords; i++) { 140 | m_extractor_data.options.listFileTypes.append((XBinary::FT)listFlags.at(i)); 141 | } 142 | 143 | m_extractor_data.options.fileType = (XBinary::FT)(ui->comboBoxType->currentData().toULongLong()); 144 | m_extractor_data.options.bDeepScan = ui->checkBoxDeepScan->isChecked(); 145 | m_extractor_data.options.bAnalyze = true; 146 | m_extractor_data.options.emode = (XExtractor::EMODE)(ui->comboBoxExtractorMode->currentData().toInt()); 147 | // extractor_data.options.bHeuristicScan = ui->checkBoxHeuristicScan->isChecked(); 148 | 149 | m_extractor_data.memoryMap = XFormats::getMemoryMap((XBinary::FT)(ui->comboBoxType->currentData().toULongLong()), 150 | (XBinary::MAPMODE)(ui->comboBoxMapMode->currentData().toULongLong()), m_pDevice, false, -1); 151 | 152 | XExtractor xextractor; 153 | XDialogProcess dep(XOptions::getMainWidget(this), &xextractor); 154 | dep.setGlobal(getShortcuts(), getGlobalOptions()); 155 | xextractor.setData(m_pDevice, &m_extractor_data, dep.getPdStruct()); 156 | dep.start(); 157 | dep.showDialogDelay(); 158 | 159 | if (dep.isSuccess()) { 160 | XModel_Extractor *pModel = new XModel_Extractor(&m_extractor_data, this); 161 | 162 | ui->tableViewResult->setCustomModel(pModel, true); 163 | 164 | connect(ui->tableViewResult->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, 165 | SLOT(on_tableViewSelection(QItemSelection, QItemSelection))); 166 | 167 | if (m_pXInfoDB) { 168 | qint32 nNumberOfRecords = m_extractor_data.listRecords.count(); 169 | 170 | for (qint32 i = 0; i < nNumberOfRecords; i++) { 171 | bool bAdd = true; 172 | 173 | if ((m_extractor_data.listRecords.at(i).nOffset == 0) && 174 | ((XBinary::FT)(ui->comboBoxType->currentData().toULongLong()) == m_extractor_data.listRecords.at(i).fileType)) { 175 | bAdd = false; 176 | } 177 | 178 | if (bAdd) { 179 | QString sComment = m_extractor_data.listRecords.at(i).sString; 180 | 181 | XInfoDB::BOOKMARKRECORD record = {}; 182 | record.sUUID = XBinary::generateUUID(); 183 | record.sColorBackground = QColor(Qt::yellow).name(); 184 | record.nLocation = m_extractor_data.listRecords.at(i).nOffset; 185 | record.locationType = XBinary::LT_OFFSET; 186 | record.nSize = m_extractor_data.listRecords.at(i).nSize; 187 | record.sComment = sComment; 188 | 189 | m_pXInfoDB->_addBookmarkRecord(record); 190 | } 191 | } 192 | 193 | if (nNumberOfRecords) { 194 | m_pXInfoDB->reloadView(); 195 | } 196 | } 197 | } 198 | } 199 | 200 | DumpProcess::RECORD XExtractorWidget::getDumpProcessRecord(QModelIndex index) 201 | { 202 | DumpProcess::RECORD result = {}; 203 | 204 | result.nOffset = ui->tableViewResult->model()->data(index, Qt::UserRole + XModel::USERROLE_OFFSET).toLongLong(); 205 | result.nSize = ui->tableViewResult->model()->data(index, Qt::UserRole + XModel::USERROLE_SIZE).toLongLong(); 206 | QString sExt = ui->tableViewResult->model()->data(index, Qt::UserRole + XModel::USERROLE_STRING2).toString(); 207 | 208 | QString sName = QString("%1_%2").arg(XBinary::valueToHexEx(result.nOffset), XBinary::valueToHexEx(result.nSize)); 209 | 210 | result.sFileName = XBinary::getResultFileName(m_pDevice, QString("%1.%2").arg(sName, sExt)); 211 | 212 | return result; 213 | } 214 | 215 | void XExtractorWidget::adjustView() 216 | { 217 | getGlobalOptions()->adjustWidget(this, XOptions::ID_VIEW_FONT_CONTROLS); 218 | getGlobalOptions()->adjustTableView(ui->tableViewResult, XOptions::ID_VIEW_FONT_TABLEVIEWS); 219 | 220 | ui->widgetHex->adjustView(); 221 | } 222 | 223 | void XExtractorWidget::reloadData(bool bSaveSelection) 224 | { 225 | Q_UNUSED(bSaveSelection) 226 | 227 | reload(); 228 | } 229 | 230 | void XExtractorWidget::setGlobal(XShortcuts *pShortcuts, XOptions *pXOptions) 231 | { 232 | XShortcutsWidget::setGlobal(pShortcuts, pXOptions); 233 | 234 | ui->widgetHex->setGlobal(pShortcuts, pXOptions); 235 | } 236 | 237 | void XExtractorWidget::registerShortcuts(bool bState) 238 | { 239 | XShortcutsWidget::registerShortcuts(bState); 240 | ui->widgetHex->registerShortcuts(bState); 241 | } 242 | 243 | void XExtractorWidget::on_toolButtonScan_clicked() 244 | { 245 | reload(); 246 | } 247 | 248 | void XExtractorWidget::on_toolButtonSave_clicked() 249 | { 250 | XShortcutsWidget::saveTableModel(ui->tableViewResult->getProxyModel(), XBinary::getResultFileName(m_pDevice, QString("%1.txt").arg(tr("Extract")))); 251 | } 252 | 253 | void XExtractorWidget::on_toolButtonDumpAll_clicked() 254 | { 255 | QString sDirectory = QFileDialog::getExistingDirectory(this, tr("Dump all"), XBinary::getDeviceDirectory(m_pDevice)); 256 | 257 | if (!sDirectory.isEmpty()) { 258 | qint32 nNumberOfRecords = ui->tableViewResult->model()->rowCount(); 259 | 260 | if (nNumberOfRecords) { 261 | QList listRecords; 262 | 263 | for (qint32 i = 0; i < nNumberOfRecords; i++) { 264 | QModelIndex index = ui->tableViewResult->model()->index(i, 0); 265 | 266 | DumpProcess::RECORD record = getDumpProcessRecord(index); 267 | 268 | record.sFileName = sDirectory + QDir::separator() + QFileInfo(record.sFileName).fileName(); 269 | 270 | listRecords.append(record); 271 | } 272 | 273 | QString sJsonFileName = sDirectory + QDir::separator() + XBinary::getDeviceFileBaseName(m_pDevice) + ".patch.json"; 274 | 275 | DumpProcess dumpProcess; 276 | XDialogProcess dd(this, &dumpProcess); 277 | dd.setGlobal(getShortcuts(), getGlobalOptions()); 278 | dumpProcess.setData(m_pDevice, listRecords, DumpProcess::DT_DUMP_DEVICE_OFFSET, sJsonFileName, dd.getPdStruct()); 279 | dd.start(); 280 | dd.showDialogDelay(); 281 | } 282 | } 283 | } 284 | 285 | void XExtractorWidget::on_tableViewResult_customContextMenuRequested(const QPoint &pos) 286 | { 287 | qint32 nRow = ui->tableViewResult->currentIndex().row(); 288 | 289 | if (nRow != -1) { 290 | QMenu contextMenu(this); 291 | 292 | QList listMenuItems; 293 | 294 | getShortcuts()->_addMenuItem(&listMenuItems, X_ID_TABLE_SELECTION_DUMPTOFILE, this, SLOT(dumpToFile()), XShortcuts::GROUPID_NONE); 295 | getShortcuts()->_addMenuItem_CopyRow(&listMenuItems, ui->tableViewResult); 296 | 297 | if (m_options.bMenu_Hex) { 298 | getShortcuts()->_addMenuItem(&listMenuItems, X_ID_TABLE_FOLLOWIN_HEX, this, SLOT(_hexSlot()), XShortcuts::GROUPID_FOLLOWIN); 299 | } 300 | 301 | getShortcuts()->adjustContextMenu(&contextMenu, &listMenuItems); 302 | 303 | contextMenu.exec(ui->tableViewResult->viewport()->mapToGlobal(pos)); 304 | } 305 | } 306 | 307 | void XExtractorWidget::dumpToFile() 308 | { 309 | qint32 nRow = ui->tableViewResult->currentIndex().row(); 310 | 311 | if (nRow != -1) { 312 | QModelIndex index = ui->tableViewResult->selectionModel()->selectedIndexes().at(0); 313 | 314 | DumpProcess::RECORD record = getDumpProcessRecord(index); 315 | 316 | record.sFileName = QFileDialog::getSaveFileName(this, tr("Save dump"), record.sFileName); 317 | 318 | if (!record.sFileName.isEmpty()) { 319 | DumpProcess dumpProcess; 320 | XDialogProcess dd(this, &dumpProcess); 321 | dd.setGlobal(getShortcuts(), getGlobalOptions()); 322 | dumpProcess.setData(m_pDevice, record, DumpProcess::DT_DUMP_DEVICE_OFFSET, dd.getPdStruct()); 323 | dd.start(); 324 | dd.showDialogDelay(); 325 | } 326 | } 327 | } 328 | 329 | void XExtractorWidget::_hexSlot() 330 | { 331 | if (m_options.bMenu_Hex) { 332 | qint32 nRow = ui->tableViewResult->currentIndex().row(); 333 | 334 | if (nRow != -1) { 335 | QModelIndex index = ui->tableViewResult->selectionModel()->selectedIndexes().at(0); 336 | 337 | DumpProcess::RECORD record = getDumpProcessRecord(index); 338 | 339 | emit followLocation(record.nOffset, XBinary::LT_OFFSET, record.nSize, XOptions::WIDGETTYPE_HEX); 340 | } 341 | } 342 | } 343 | 344 | void XExtractorWidget::on_comboBoxType_currentIndexChanged(int nIndex) 345 | { 346 | Q_UNUSED(nIndex) 347 | 348 | XBinary::FT fileType = (XBinary::FT)(ui->comboBoxType->currentData().toInt()); 349 | XFormats::getMapModesList(fileType, ui->comboBoxMapMode); 350 | 351 | reload(); 352 | } 353 | 354 | void XExtractorWidget::on_comboBoxMapMode_currentIndexChanged(int nIndex) 355 | { 356 | Q_UNUSED(nIndex) 357 | 358 | reload(); 359 | } 360 | 361 | void XExtractorWidget::viewSelection() 362 | { 363 | QItemSelectionModel *pSelectionModel = ui->tableViewResult->selectionModel(); 364 | 365 | if (pSelectionModel) { 366 | QModelIndexList listIndexes = pSelectionModel->selectedIndexes(); 367 | 368 | if (listIndexes.count()) { 369 | QModelIndex indexNumber = listIndexes.at(0); 370 | 371 | DumpProcess::RECORD record = getDumpProcessRecord(indexNumber); 372 | 373 | if (record.nOffset != -1) { 374 | emit currentLocationChanged(record.nOffset, XBinary::LT_OFFSET, record.nSize); // TODO mb remove, use signals from widgetHex 375 | 376 | ui->widgetHex->goToLocation(record.nOffset, XBinary::LT_OFFSET); 377 | ui->widgetHex->setLocationOffset(record.nOffset, XBinary::LT_OFFSET, record.nSize); 378 | } 379 | } 380 | } 381 | } 382 | 383 | void XExtractorWidget::on_tableViewResult_clicked(const QModelIndex &index) 384 | { 385 | Q_UNUSED(index) 386 | 387 | viewSelection(); 388 | } 389 | 390 | void XExtractorWidget::on_tableViewSelection(const QItemSelection &itemSelected, const QItemSelection &itemDeselected) 391 | { 392 | Q_UNUSED(itemSelected) 393 | Q_UNUSED(itemDeselected) 394 | 395 | viewSelection(); 396 | } 397 | 398 | void XExtractorWidget::on_comboBoxExtractorMode_currentIndexChanged(int index) 399 | { 400 | // TODO 401 | } 402 | 403 | void XExtractorWidget::on_checkBoxAllTypes_checkStateChanged(const Qt::CheckState &checkState) 404 | { 405 | Q_UNUSED(checkState) 406 | 407 | ui->comboBoxType->setEnabled(!ui->checkBoxAllTypes->isChecked()); 408 | } 409 | --------------------------------------------------------------------------------