├── README.md ├── xmemorymapwidget.pri ├── xmemorymapwidget.cmake ├── LICENSE ├── dialogmemorymap.h ├── dialogmemorymap.ui ├── dialogmemorymap.cpp ├── xmemorymapwidget.h ├── xmemorymapwidget.ui └── xmemorymapwidget.cpp /README.md: -------------------------------------------------------------------------------- 1 | # XMemoryMapWidget 2 | 3 | Memory Map Widgets 4 | -------------------------------------------------------------------------------- /xmemorymapwidget.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD 2 | DEPENDPATH += $$PWD 3 | 4 | HEADERS += \ 5 | $$PWD/dialogmemorymap.h \ 6 | $$PWD/xmemorymapwidget.h 7 | 8 | SOURCES += \ 9 | $$PWD/dialogmemorymap.cpp \ 10 | $$PWD/xmemorymapwidget.cpp 11 | 12 | FORMS += \ 13 | $$PWD/dialogmemorymap.ui \ 14 | $$PWD/xmemorymapwidget.ui 15 | 16 | !contains(XCONFIG, xformats) { 17 | XCONFIG += xformats 18 | include($$PWD/../Formats/xformats.pri) 19 | } 20 | 21 | !contains(XCONFIG, xlineedithex) { 22 | XCONFIG += xlineedithex 23 | include($$PWD/../Controls/xlineedithex.pri) 24 | } 25 | 26 | !contains(XCONFIG, xhexview) { 27 | XCONFIG += xhexview 28 | include($$PWD/../XHexView/xhexview.pri) 29 | } 30 | 31 | DISTFILES += \ 32 | $$PWD/LICENSE \ 33 | $$PWD/README.md \ 34 | $$PWD/xmemorymapwidget.cmake 35 | -------------------------------------------------------------------------------- /xmemorymapwidget.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(XMEMORYMAPWIDGET_SOURCES ${XMEMORYMAPWIDGET_SOURCES} ${XFORMATS_SOURCES}) 6 | endif() 7 | if (NOT DEFINED XLINEEDITHEX_SOURCES) 8 | include(${CMAKE_CURRENT_LIST_DIR}/../Controls/xlineedithex.cmake) 9 | set(XMEMORYMAPWIDGET_SOURCES ${XMEMORYMAPWIDGET_SOURCES} ${XLINEEDITHEX_SOURCES}) 10 | endif() 11 | 12 | set(XMEMORYMAPWIDGET_SOURCES 13 | ${XMEMORYMAPWIDGET_SOURCES} 14 | ${CMAKE_CURRENT_LIST_DIR}/dialogmemorymap.cpp 15 | ${CMAKE_CURRENT_LIST_DIR}/dialogmemorymap.h 16 | ${CMAKE_CURRENT_LIST_DIR}/dialogmemorymap.ui 17 | ${CMAKE_CURRENT_LIST_DIR}/xmemorymapwidget.cpp 18 | ${CMAKE_CURRENT_LIST_DIR}/xmemorymapwidget.h 19 | ${CMAKE_CURRENT_LIST_DIR}/xmemorymapwidget.ui 20 | ) 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020-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 | -------------------------------------------------------------------------------- /dialogmemorymap.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef DIALOGMEMORYMAP_H 22 | #define DIALOGMEMORYMAP_H 23 | 24 | #include "xbinary.h" 25 | #include "xmemorymapwidget.h" 26 | #include "xshortcutsdialog.h" 27 | 28 | namespace Ui { 29 | class DialogMemoryMap; 30 | } 31 | 32 | class DialogMemoryMap : public XShortcutsDialog { 33 | Q_OBJECT 34 | 35 | public: 36 | explicit DialogMemoryMap(QWidget *pParent); 37 | DialogMemoryMap(QWidget *pParent, QIODevice *pDevice, const XMemoryMapWidget::OPTIONS &options); 38 | ~DialogMemoryMap(); 39 | 40 | void setData(QIODevice *pDevice, const XMemoryMapWidget::OPTIONS &options); 41 | void setGlobal(XShortcuts *pShortcuts, XOptions *pXOptions); 42 | 43 | private slots: 44 | void on_pushButtonClose_clicked(); 45 | 46 | private: 47 | Ui::DialogMemoryMap *ui; 48 | }; 49 | 50 | #endif // DIALOGMEMORYMAP_H 51 | -------------------------------------------------------------------------------- /dialogmemorymap.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | DialogMemoryMap 4 | 5 | 6 | Qt::ApplicationModal 7 | 8 | 9 | 10 | 0 11 | 0 12 | 763 13 | 599 14 | 15 | 16 | 17 | Memory map 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 | XMemoryMapWidget 62 | QWidget 63 |
xmemorymapwidget.h
64 | 1 65 |
66 |
67 | 68 | 69 |
70 | -------------------------------------------------------------------------------- /dialogmemorymap.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #include "dialogmemorymap.h" 22 | 23 | #include "ui_dialogmemorymap.h" 24 | 25 | DialogMemoryMap::DialogMemoryMap(QWidget *pParent) : XShortcutsDialog(pParent, true), ui(new Ui::DialogMemoryMap) 26 | { 27 | ui->setupUi(this); 28 | } 29 | 30 | DialogMemoryMap::DialogMemoryMap(QWidget *pParent, QIODevice *pDevice, const XMemoryMapWidget::OPTIONS &options) : DialogMemoryMap(pParent) 31 | { 32 | setData(pDevice, options); 33 | } 34 | 35 | DialogMemoryMap::~DialogMemoryMap() 36 | { 37 | delete ui; 38 | } 39 | 40 | void DialogMemoryMap::setData(QIODevice *pDevice, const XMemoryMapWidget::OPTIONS &options) 41 | { 42 | ui->widgetMemoryMap->setData(pDevice, options, nullptr); 43 | } 44 | 45 | void DialogMemoryMap::setGlobal(XShortcuts *pShortcuts, XOptions *pXOptions) 46 | { 47 | ui->widgetMemoryMap->setGlobal(pShortcuts, pXOptions); 48 | XShortcutsDialog::setGlobal(pShortcuts, pXOptions); 49 | } 50 | 51 | void DialogMemoryMap::on_pushButtonClose_clicked() 52 | { 53 | this->close(); 54 | } 55 | -------------------------------------------------------------------------------- /xmemorymapwidget.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2020-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #ifndef XMEMORYMAPWIDGET_H 22 | #define XMEMORYMAPWIDGET_H 23 | 24 | #include 25 | #include 26 | 27 | #include "xformats.h" 28 | #include "xlineedithex.h" 29 | #include "xshortcutswidget.h" 30 | #include "xinfodb.h" 31 | #include "dumpprocess.h" 32 | #include "xdialogprocess.h" 33 | 34 | namespace Ui { 35 | class XMemoryMapWidget; 36 | } 37 | 38 | class XMemoryMapWidget : public XShortcutsWidget { 39 | Q_OBJECT 40 | 41 | public: 42 | struct OPTIONS { 43 | XBinary::FT fileType; 44 | bool bIsSearchEnable; 45 | }; 46 | 47 | explicit XMemoryMapWidget(QWidget *pParent = nullptr); 48 | ~XMemoryMapWidget(); 49 | 50 | void setData(QIODevice *pDevice, const OPTIONS &options, XInfoDB *pXInfoDB); 51 | void setXInfoDB(XInfoDB *pXInfoDB); // TODO remove 52 | void goToOffset(qint64 nOffset); // TODO remove use setLocation 53 | virtual void setLocation(quint64 nLocation, qint32 nLocationType, qint64 nSize); 54 | void setGlobal(XShortcuts *pShortcuts, XOptions *pXOptions); 55 | virtual void adjustView(); 56 | virtual void reloadData(bool bSaveSelection); 57 | 58 | private slots: 59 | void on_comboBoxType_currentIndexChanged(int nIndex); 60 | void on_radioButtonFileOffset_toggled(bool bChecked); 61 | void on_radioButtonVirtualAddress_toggled(bool bChecked); 62 | void on_radioButtonRelativeVirtualAddress_toggled(bool bChecked); 63 | void updateMemoryMap(); 64 | void _adjust(bool bInit); 65 | void on_lineEditFileOffset_textChanged(const QString &sText); 66 | void on_lineEditVirtualAddress_textChanged(const QString &sText); 67 | void on_lineEditRelativeVirtualAddress_textChanged(const QString &sText); 68 | void on_tableViewSelection(const QItemSelection &itemSelected, const QItemSelection &itemDeselected); 69 | void _goToOffset(qint64 nOffset, qint64 nSize = 0); 70 | void onHexCursorChanged(qint64 nOffset); 71 | void on_toolButtonSave_clicked(); 72 | void on_checkBoxShowAll_stateChanged(int nValue); 73 | void on_toolButtonDumpAll_clicked(); 74 | void on_tableViewMemoryMap_customContextMenuRequested(const QPoint &pos); 75 | void dumpSection(); 76 | void on_tableViewMemoryMap_clicked(const QModelIndex &index); 77 | void viewSelection(); 78 | void on_toolButtonFileOffsetFind_clicked(); 79 | void on_toolButtonVirtualAddressFind_clicked(); 80 | void on_toolButtonRelativeVirtualAddressFind_clicked(); 81 | void on_comboBoxMapMode_currentIndexChanged(int nIndex); 82 | void on_toolButtonReload_clicked(); 83 | 84 | protected: 85 | virtual void registerShortcuts(bool bState); 86 | 87 | signals: 88 | void findValue(quint64 nValue, XBinary::ENDIAN endian); 89 | 90 | private: 91 | Ui::XMemoryMapWidget *ui; 92 | QIODevice *m_pDevice; 93 | OPTIONS m_options; 94 | XBinary::_MEMORY_MAP m_memoryMap; 95 | XLineEditValidator::MODE m_mode; 96 | bool m_bLockHex; 97 | QMap m_mapIndexes; 98 | XInfoDB *m_pXInfoDB; 99 | }; 100 | 101 | #endif // XMEMORYMAPWIDGET_H 102 | -------------------------------------------------------------------------------- /xmemorymapwidget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | XMemoryMapWidget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 971 10 | 713 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 | Qt::Vertical 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 120 43 | 0 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | Qt::Horizontal 52 | 53 | 54 | 55 | 40 56 | 20 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | Show all 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 120 73 | 0 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | Dump all 82 | 83 | 84 | 85 | 86 | 87 | 88 | Save 89 | 90 | 91 | 92 | 93 | 94 | 95 | Reload 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 320 108 | 16777215 109 | 110 | 111 | 112 | 113 | 0 114 | 115 | 116 | 0 117 | 118 | 119 | 0 120 | 121 | 122 | 0 123 | 124 | 125 | 126 | 127 | 128 | 129 | File offset 130 | 131 | 132 | true 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | Virtual address 143 | 144 | 145 | false 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | Relative virtual address 156 | 157 | 158 | false 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 24 170 | 16777215 171 | 172 | 173 | 174 | > 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 24 183 | 16777215 184 | 185 | 186 | 187 | > 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 24 196 | 16777215 197 | 198 | 199 | 200 | > 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 80 213 | 16777215 214 | 215 | 216 | 217 | Mode 218 | 219 | 220 | Qt::AlignCenter 221 | 222 | 223 | 224 | 2 225 | 226 | 227 | 2 228 | 229 | 230 | 2 231 | 232 | 233 | 2 234 | 235 | 236 | 237 | 238 | Qt::AlignCenter 239 | 240 | 241 | true 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 80 253 | 16777215 254 | 255 | 256 | 257 | Endianness 258 | 259 | 260 | Qt::AlignCenter 261 | 262 | 263 | 264 | 2 265 | 266 | 267 | 2 268 | 269 | 270 | 2 271 | 272 | 273 | 2 274 | 275 | 276 | 277 | 278 | Qt::AlignCenter 279 | 280 | 281 | true 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | Architecture 292 | 293 | 294 | Qt::AlignCenter 295 | 296 | 297 | 298 | 2 299 | 300 | 301 | 2 302 | 303 | 304 | 2 305 | 306 | 307 | 2 308 | 309 | 310 | 311 | 312 | Qt::AlignCenter 313 | 314 | 315 | true 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | Qt::Vertical 328 | 329 | 330 | 331 | 20 332 | 40 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | Qt::Vertical 341 | 342 | 343 | 344 | 20 345 | 40 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | Qt::Vertical 354 | 355 | 356 | 357 | 20 358 | 40 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | Qt::CustomContextMenu 370 | 371 | 372 | QAbstractItemView::NoEditTriggers 373 | 374 | 375 | QAbstractItemView::SingleSelection 376 | 377 | 378 | QAbstractItemView::SelectRows 379 | 380 | 381 | false 382 | 383 | 384 | false 385 | 386 | 387 | 20 388 | 389 | 390 | 20 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | Hex 401 | 402 | 403 | 404 | 0 405 | 406 | 407 | 0 408 | 409 | 410 | 0 411 | 412 | 413 | 0 414 | 415 | 416 | 417 | 418 | 0 419 | 420 | 421 | 422 | 423 | 0 424 | 425 | 426 | 0 427 | 428 | 429 | 0 430 | 431 | 432 | 0 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | XHexView 451 | QScrollArea 452 |
xhexview.h
453 | 1 454 |
455 | 456 | XTableView 457 | QTableView 458 |
xtableview.h
459 |
460 | 461 | XLineEditHEX 462 | QLineEdit 463 |
xlineedithex.h
464 |
465 |
466 | 467 | 468 |
469 | -------------------------------------------------------------------------------- /xmemorymapwidget.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2020-2025 hors 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in all 11 | * copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | #include "xmemorymapwidget.h" 22 | 23 | #include "ui_xmemorymapwidget.h" 24 | 25 | XMemoryMapWidget::XMemoryMapWidget(QWidget *pParent) : XShortcutsWidget(pParent), ui(new Ui::XMemoryMapWidget) 26 | { 27 | ui->setupUi(this); 28 | 29 | XOptions::adjustToolButton(ui->toolButtonSave, XOptions::ICONTYPE_SAVE); 30 | XOptions::adjustToolButton(ui->toolButtonDumpAll, XOptions::ICONTYPE_DUMPTOFILE); 31 | XOptions::adjustToolButton(ui->toolButtonReload, XOptions::ICONTYPE_RELOAD); 32 | XOptions::adjustToolButton(ui->toolButtonFileOffsetFind, XOptions::ICONTYPE_SEARCH, Qt::ToolButtonIconOnly); 33 | XOptions::adjustToolButton(ui->toolButtonVirtualAddressFind, XOptions::ICONTYPE_SEARCH, Qt::ToolButtonIconOnly); 34 | XOptions::adjustToolButton(ui->toolButtonRelativeVirtualAddressFind, XOptions::ICONTYPE_SEARCH, Qt::ToolButtonIconOnly); 35 | 36 | ui->toolButtonSave->setToolTip(tr("Save")); 37 | ui->toolButtonDumpAll->setToolTip(tr("Dump all")); 38 | ui->toolButtonReload->setToolTip(tr("Reload")); 39 | ui->toolButtonFileOffsetFind->setToolTip(tr("Find")); 40 | ui->toolButtonVirtualAddressFind->setToolTip(tr("Find")); 41 | ui->toolButtonRelativeVirtualAddressFind->setToolTip(tr("Find")); 42 | ui->comboBoxType->setToolTip(tr("Type")); 43 | ui->comboBoxMapMode->setToolTip(tr("Mode")); 44 | ui->lineEditArch->setToolTip(tr("Architecture")); 45 | ui->lineEditMode->setToolTip(tr("Mode")); 46 | ui->lineEditEndianness->setToolTip(tr("Endianness")); 47 | ui->checkBoxShowAll->setToolTip(tr("Show all")); 48 | ui->toolButtonDumpAll->setToolTip(tr("Dump all")); 49 | ui->tableViewMemoryMap->setToolTip(tr("Memory map")); 50 | ui->lineEditFileOffset->setToolTip(tr("File offset")); 51 | ui->lineEditVirtualAddress->setToolTip(tr("Virtual address")); 52 | ui->lineEditRelativeVirtualAddress->setToolTip(tr("Relative virtual address")); 53 | 54 | m_pDevice = nullptr; 55 | m_options = {}; 56 | m_mode = XLineEditValidator::MODE_HEX_16; 57 | m_bLockHex = false; 58 | m_memoryMap = {}; 59 | m_pXInfoDB = nullptr; 60 | 61 | ui->checkBoxShowAll->setChecked(true); 62 | } 63 | 64 | XMemoryMapWidget::~XMemoryMapWidget() 65 | { 66 | delete ui; 67 | } 68 | 69 | void XMemoryMapWidget::setData(QIODevice *pDevice, const OPTIONS &options, XInfoDB *pXInfoDB) 70 | { 71 | m_pDevice = pDevice; 72 | m_options = options; 73 | m_pXInfoDB = pXInfoDB; 74 | 75 | XBinaryView::OPTIONS hex_options = {}; // TODO Check !!! 76 | 77 | ui->widgetHex->setData(pDevice, hex_options, true, pXInfoDB); 78 | 79 | if (pDevice) { 80 | XFormats::setFileTypeComboBox(options.fileType, m_pDevice, ui->comboBoxType); 81 | XFormats::getMapModesList(options.fileType, ui->comboBoxMapMode); 82 | 83 | updateMemoryMap(); 84 | } 85 | 86 | if (options.bIsSearchEnable) { 87 | ui->toolButtonFileOffsetFind->show(); 88 | ui->toolButtonRelativeVirtualAddressFind->show(); 89 | ui->toolButtonVirtualAddressFind->show(); 90 | } else { 91 | ui->toolButtonFileOffsetFind->hide(); 92 | ui->toolButtonRelativeVirtualAddressFind->hide(); 93 | ui->toolButtonVirtualAddressFind->hide(); 94 | } 95 | } 96 | 97 | void XMemoryMapWidget::setXInfoDB(XInfoDB *pXInfoDB) 98 | { 99 | ui->widgetHex->setXInfoDB(pXInfoDB); 100 | } 101 | 102 | void XMemoryMapWidget::goToOffset(qint64 nOffset) 103 | { 104 | ui->lineEditFileOffset->setValidatorModeValue(m_mode, nOffset); 105 | } 106 | 107 | void XMemoryMapWidget::setLocation(quint64 nLocation, qint32 nLocationType, qint64 nSize) 108 | { 109 | Q_UNUSED(nSize) 110 | 111 | if (nLocationType == XBinary::LT_ADDRESS) { 112 | ui->lineEditVirtualAddress->setValidatorModeValue(m_mode, nLocation); 113 | } else if (nLocationType == XBinary::LT_OFFSET) { 114 | ui->lineEditFileOffset->setValidatorModeValue(m_mode, nLocation); 115 | } 116 | } 117 | 118 | void XMemoryMapWidget::setGlobal(XShortcuts *pShortcuts, XOptions *pXOptions) 119 | { 120 | ui->widgetHex->setGlobal(pShortcuts, pXOptions); 121 | XShortcutsWidget::setGlobal(pShortcuts, pXOptions); 122 | } 123 | 124 | void XMemoryMapWidget::adjustView() 125 | { 126 | ui->widgetHex->adjustView(); 127 | getGlobalOptions()->adjustWidget(this, XOptions::ID_VIEW_FONT_CONTROLS); 128 | getGlobalOptions()->adjustTableView(ui->tableViewMemoryMap, XOptions::ID_VIEW_FONT_TABLEVIEWS); 129 | } 130 | 131 | void XMemoryMapWidget::reloadData(bool bSaveSelection) 132 | { 133 | Q_UNUSED(bSaveSelection) 134 | updateMemoryMap(); 135 | } 136 | 137 | void XMemoryMapWidget::on_comboBoxType_currentIndexChanged(int nIndex) 138 | { 139 | Q_UNUSED(nIndex) 140 | 141 | XBinary::FT fileType = (XBinary::FT)(ui->comboBoxType->currentData().toInt()); 142 | XFormats::getMapModesList(fileType, ui->comboBoxMapMode); 143 | 144 | updateMemoryMap(); 145 | } 146 | 147 | void XMemoryMapWidget::on_radioButtonFileOffset_toggled(bool bChecked) 148 | { 149 | Q_UNUSED(bChecked) 150 | 151 | _adjust(false); 152 | } 153 | 154 | void XMemoryMapWidget::on_radioButtonVirtualAddress_toggled(bool bChecked) 155 | { 156 | Q_UNUSED(bChecked) 157 | 158 | _adjust(false); 159 | } 160 | 161 | void XMemoryMapWidget::on_radioButtonRelativeVirtualAddress_toggled(bool bChecked) 162 | { 163 | Q_UNUSED(bChecked) 164 | 165 | _adjust(false); 166 | } 167 | 168 | void XMemoryMapWidget::updateMemoryMap() 169 | { 170 | if (m_pDevice) { 171 | const bool bBlocked1 = ui->lineEditFileOffset->blockSignals(true); 172 | const bool bBlocked2 = ui->lineEditVirtualAddress->blockSignals(true); 173 | const bool bBlocked3 = ui->lineEditRelativeVirtualAddress->blockSignals(true); 174 | const bool bBlocked4 = ui->tableViewMemoryMap->blockSignals(true); 175 | const bool bBlocked5 = ui->pageHex->blockSignals(true); 176 | 177 | m_mapIndexes.clear(); 178 | 179 | XBinary::FT fileType = (XBinary::FT)(ui->comboBoxType->currentData().toInt()); 180 | XBinary::MAPMODE mapMode = (XBinary::MAPMODE)(ui->comboBoxMapMode->currentData().toInt()); 181 | 182 | m_memoryMap = XFormats::getMemoryMap(fileType, mapMode, m_pDevice); 183 | 184 | ui->lineEditArch->setText(m_memoryMap.sArch); 185 | ui->lineEditMode->setText(XBinary::modeIdToString(m_memoryMap.mode)); 186 | ui->lineEditEndianness->setText(XBinary::endianToString(m_memoryMap.endian)); 187 | 188 | ui->radioButtonFileOffset->setChecked(true); 189 | 190 | ui->lineEditFileOffset->setValue_uint32((quint32)0); 191 | 192 | XBinary::MODE _mode = XBinary::getWidthModeFromMemoryMap(&m_memoryMap); 193 | 194 | // TODO move function to XShortcutWidget !!! 195 | if (_mode == XBinary::MODE_8) m_mode = XLineEditValidator::MODE_HEX_8; 196 | else if (_mode == XBinary::MODE_16) m_mode = XLineEditValidator::MODE_HEX_16; 197 | else if (_mode == XBinary::MODE_32) m_mode = XLineEditValidator::MODE_HEX_32; 198 | else if (_mode == XBinary::MODE_64) m_mode = XLineEditValidator::MODE_HEX_64; 199 | 200 | qint32 nNumberOfRecords = 0; 201 | 202 | bool bShowAll = ui->checkBoxShowAll->isChecked(); 203 | 204 | if (bShowAll) { 205 | nNumberOfRecords = m_memoryMap.listRecords.count(); 206 | } else { 207 | nNumberOfRecords = XBinary::getNumberOfPhysicalRecords(&m_memoryMap); 208 | } 209 | 210 | QStandardItemModel *pModel = new QStandardItemModel(nNumberOfRecords, 4); 211 | 212 | pModel->setHeaderData(0, Qt::Horizontal, tr("Offset")); 213 | pModel->setHeaderData(1, Qt::Horizontal, tr("Address")); 214 | pModel->setHeaderData(2, Qt::Horizontal, tr("Size")); 215 | pModel->setHeaderData(3, Qt::Horizontal, tr("Name")); 216 | 217 | // QColor colDisabled = QWidget::palette().color(QPalette::Window); 218 | 219 | qint32 _nNumberOfRecords = m_memoryMap.listRecords.count(); 220 | 221 | for (qint32 i = 0, j = 0; i < _nNumberOfRecords; i++) { 222 | // bool bIsVirtual=m_memoryMap.listRecords.at(i).bIsVirtual; 223 | 224 | if ((!(m_memoryMap.listRecords.at(i).bIsVirtual)) || (bShowAll)) { 225 | m_mapIndexes.insert(i, j); 226 | 227 | QStandardItem *pItemOffset = new QStandardItem; 228 | 229 | pItemOffset->setData(m_memoryMap.listRecords.at(i).nOffset, Qt::UserRole + 0); 230 | pItemOffset->setData(m_memoryMap.listRecords.at(i).nAddress, Qt::UserRole + 1); 231 | pItemOffset->setData(m_memoryMap.listRecords.at(i).nSize, Qt::UserRole + 2); 232 | pItemOffset->setData(QString("%1_%2_%3.bin") 233 | .arg(XBinary::valueToHexEx(m_memoryMap.listRecords.at(i).nOffset), XBinary::valueToHexEx(m_memoryMap.listRecords.at(i).nSize), 234 | m_memoryMap.listRecords.at(i).sName), 235 | Qt::UserRole + 3); 236 | 237 | if (m_memoryMap.listRecords.at(i).nOffset != -1) { 238 | pItemOffset->setText(XLineEditHEX::getFormatString(m_mode, m_memoryMap.listRecords.at(i).nOffset)); 239 | } else { 240 | // pItemOffset->setBackground(colDisabled); 241 | } 242 | 243 | pModel->setItem(j, 0, pItemOffset); 244 | 245 | QStandardItem *pItemAddress = new QStandardItem; 246 | 247 | if (m_memoryMap.listRecords.at(i).nAddress != (quint64)-1) { 248 | pItemAddress->setText(XLineEditHEX::getFormatString(m_mode, m_memoryMap.listRecords.at(i).nAddress)); 249 | } else { 250 | // pItemAddress->setBackground(colDisabled); 251 | } 252 | 253 | pModel->setItem(j, 1, pItemAddress); 254 | 255 | QStandardItem *pItemSize = new QStandardItem; 256 | 257 | pItemSize->setText(XLineEditHEX::getFormatString(m_mode, m_memoryMap.listRecords.at(i).nSize)); 258 | 259 | pModel->setItem(j, 2, pItemSize); 260 | 261 | QStandardItem *pItemName = new QStandardItem; 262 | 263 | pItemName->setText(m_memoryMap.listRecords.at(i).sName); 264 | pModel->setItem(j, 3, pItemName); 265 | 266 | j++; 267 | } 268 | } 269 | 270 | XOptions::setModelTextAlignment(pModel, 0, Qt::AlignRight | Qt::AlignVCenter); 271 | XOptions::setModelTextAlignment(pModel, 1, Qt::AlignRight | Qt::AlignVCenter); 272 | XOptions::setModelTextAlignment(pModel, 2, Qt::AlignRight | Qt::AlignVCenter); 273 | XOptions::setModelTextAlignment(pModel, 3, Qt::AlignLeft | Qt::AlignVCenter); 274 | 275 | ui->tableViewMemoryMap->setCustomModel(pModel, true); 276 | 277 | ui->tableViewMemoryMap->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Interactive); 278 | ui->tableViewMemoryMap->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Interactive); 279 | ui->tableViewMemoryMap->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Interactive); 280 | ui->tableViewMemoryMap->horizontalHeader()->setSectionResizeMode(3, QHeaderView::Stretch); 281 | 282 | qint32 nColumnSize = XLineEditHEX::getWidthFromMode(this, m_mode); 283 | 284 | ui->tableViewMemoryMap->setColumnWidth(0, nColumnSize); 285 | ui->tableViewMemoryMap->setColumnWidth(1, nColumnSize); 286 | ui->tableViewMemoryMap->setColumnWidth(2, nColumnSize); 287 | 288 | connect(ui->tableViewMemoryMap->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, 289 | SLOT(on_tableViewSelection(QItemSelection, QItemSelection))); 290 | connect(ui->widgetHex, SIGNAL(cursorViewPosChanged(qint64)), this, SLOT(onHexCursorChanged(qint64))); 291 | 292 | _adjust(true); 293 | 294 | ui->lineEditFileOffset->blockSignals(bBlocked1); 295 | ui->lineEditVirtualAddress->blockSignals(bBlocked2); 296 | ui->lineEditRelativeVirtualAddress->blockSignals(bBlocked3); 297 | ui->tableViewMemoryMap->blockSignals(bBlocked4); 298 | ui->pageHex->blockSignals(bBlocked5); 299 | } 300 | } 301 | 302 | void XMemoryMapWidget::_adjust(bool bInit) 303 | { 304 | const bool bBlocked1 = ui->lineEditFileOffset->blockSignals(true); 305 | const bool bBlocked2 = ui->lineEditVirtualAddress->blockSignals(true); 306 | const bool bBlocked3 = ui->lineEditRelativeVirtualAddress->blockSignals(true); 307 | const bool bBlocked4 = ui->tableViewMemoryMap->blockSignals(true); 308 | const bool bBlocked5 = ui->pageHex->blockSignals(true); 309 | 310 | qint32 nTableViewIndex = -1; 311 | 312 | quint64 nFileOffset = ui->lineEditFileOffset->getValue_uint64(); 313 | XADDR nVirtualAddress = ui->lineEditVirtualAddress->getValue_uint64(); 314 | quint64 nRelativeVirtualAddress = ui->lineEditRelativeVirtualAddress->getValue_uint64(); 315 | 316 | if (ui->radioButtonFileOffset->isChecked()) { 317 | ui->lineEditFileOffset->setReadOnly(false); 318 | ui->lineEditVirtualAddress->setReadOnly(true); 319 | ui->lineEditRelativeVirtualAddress->setReadOnly(true); 320 | 321 | nVirtualAddress = XBinary::offsetToAddress(&m_memoryMap, nFileOffset); 322 | nRelativeVirtualAddress = XBinary::offsetToRelAddress(&m_memoryMap, nFileOffset); 323 | 324 | XBinary::_MEMORY_RECORD memoryRecord = XBinary::getMemoryRecordByOffset(&m_memoryMap, nFileOffset); 325 | 326 | if (memoryRecord.nSize) { 327 | nTableViewIndex = memoryRecord.nIndex; 328 | } 329 | 330 | if (bInit) { 331 | ui->lineEditFileOffset->setValidatorModeValue(m_mode, nFileOffset); 332 | } 333 | 334 | ui->lineEditVirtualAddress->setValidatorModeValue(m_mode, nVirtualAddress); 335 | ui->lineEditRelativeVirtualAddress->setValidatorModeValue(m_mode, nRelativeVirtualAddress); 336 | } else if (ui->radioButtonVirtualAddress->isChecked()) { 337 | ui->lineEditFileOffset->setReadOnly(true); 338 | ui->lineEditVirtualAddress->setReadOnly(false); 339 | ui->lineEditRelativeVirtualAddress->setReadOnly(true); 340 | 341 | nFileOffset = XBinary::addressToOffset(&m_memoryMap, nVirtualAddress); 342 | nRelativeVirtualAddress = XBinary::addressToRelAddress(&m_memoryMap, nVirtualAddress); 343 | 344 | XBinary::_MEMORY_RECORD memoryRecord = XBinary::getMemoryRecordByAddress(&m_memoryMap, nVirtualAddress); 345 | 346 | if (memoryRecord.nSize) { 347 | nTableViewIndex = memoryRecord.nIndex; 348 | } 349 | 350 | if (bInit) { 351 | ui->lineEditVirtualAddress->setValidatorModeValue(m_mode, nVirtualAddress); 352 | } 353 | 354 | ui->lineEditFileOffset->setValidatorModeValue(m_mode, nFileOffset); 355 | ui->lineEditRelativeVirtualAddress->setValidatorModeValue(m_mode, nRelativeVirtualAddress); 356 | } else if (ui->radioButtonRelativeVirtualAddress->isChecked()) { 357 | ui->lineEditFileOffset->setReadOnly(true); 358 | ui->lineEditVirtualAddress->setReadOnly(true); 359 | ui->lineEditRelativeVirtualAddress->setReadOnly(false); 360 | 361 | nFileOffset = XBinary::relAddressToOffset(&m_memoryMap, nRelativeVirtualAddress); 362 | nVirtualAddress = XBinary::relAddressToAddress(&m_memoryMap, nRelativeVirtualAddress); 363 | 364 | XBinary::_MEMORY_RECORD memoryRecord = XBinary::getMemoryRecordByRelAddress(&m_memoryMap, nRelativeVirtualAddress); 365 | 366 | if (memoryRecord.nSize) { 367 | nTableViewIndex = memoryRecord.nIndex; 368 | } 369 | 370 | if (bInit) { 371 | ui->lineEditRelativeVirtualAddress->setValidatorModeValue(m_mode, nRelativeVirtualAddress); 372 | } 373 | 374 | ui->lineEditFileOffset->setValidatorModeValue(m_mode, nFileOffset); 375 | ui->lineEditVirtualAddress->setValidatorModeValue(m_mode, nVirtualAddress); 376 | } 377 | 378 | if (nTableViewIndex != -1) { 379 | qint32 nIndex = m_mapIndexes.value(nTableViewIndex, -1); 380 | 381 | if (nIndex == -1) { 382 | QMessageBox::information(this, tr("Information"), tr("Virtual address")); 383 | nIndex = 0; 384 | } 385 | 386 | QModelIndex miCurrentIndex = ui->tableViewMemoryMap->model()->index(nIndex, 0); 387 | ui->tableViewMemoryMap->setCurrentIndex(miCurrentIndex); 388 | } 389 | 390 | _goToOffset(nFileOffset, 1); 391 | 392 | ui->lineEditFileOffset->blockSignals(bBlocked1); 393 | ui->lineEditVirtualAddress->blockSignals(bBlocked2); 394 | ui->lineEditRelativeVirtualAddress->blockSignals(bBlocked3); 395 | ui->tableViewMemoryMap->blockSignals(bBlocked4); 396 | ui->pageHex->blockSignals(bBlocked5); 397 | } 398 | 399 | void XMemoryMapWidget::on_lineEditFileOffset_textChanged(const QString &sText) 400 | { 401 | Q_UNUSED(sText) 402 | 403 | _adjust(false); 404 | } 405 | 406 | void XMemoryMapWidget::on_lineEditVirtualAddress_textChanged(const QString &sText) 407 | { 408 | Q_UNUSED(sText) 409 | 410 | _adjust(false); 411 | } 412 | 413 | void XMemoryMapWidget::on_lineEditRelativeVirtualAddress_textChanged(const QString &sText) 414 | { 415 | Q_UNUSED(sText) 416 | 417 | _adjust(false); 418 | } 419 | 420 | void XMemoryMapWidget::on_tableViewSelection(const QItemSelection &itemSelected, const QItemSelection &itemDeselected) 421 | { 422 | Q_UNUSED(itemSelected) 423 | Q_UNUSED(itemDeselected) 424 | 425 | viewSelection(); 426 | } 427 | 428 | void XMemoryMapWidget::_goToOffset(qint64 nOffset, qint64 nSize) 429 | { 430 | if (!m_bLockHex) { 431 | if (nSize == 0) { 432 | nSize = 1; 433 | } 434 | 435 | if (XBinary::isOffsetValid(&m_memoryMap, nOffset)) { 436 | ui->stackedWidgetHex->setCurrentIndex(0); 437 | 438 | ui->widgetHex->goToOffset(nOffset); 439 | ui->widgetHex->setDeviceSelection(nOffset, nSize); 440 | ui->widgetHex->reload(); 441 | } else { 442 | // Invalid offset 443 | ui->stackedWidgetHex->setCurrentIndex(1); // TODO Consts 444 | } 445 | } 446 | } 447 | 448 | void XMemoryMapWidget::onHexCursorChanged(qint64 nOffset) 449 | { 450 | m_bLockHex = true; // TODO mb use SignalBlocker 451 | 452 | if (!ui->lineEditFileOffset->isFocused()) { 453 | ui->lineEditFileOffset->setValidatorModeValue(m_mode, nOffset); 454 | } 455 | 456 | m_bLockHex = false; 457 | } 458 | 459 | void XMemoryMapWidget::registerShortcuts(bool bState) 460 | { 461 | Q_UNUSED(bState) 462 | // mb TODO 463 | } 464 | 465 | void XMemoryMapWidget::on_toolButtonSave_clicked() 466 | { 467 | XShortcutsWidget::saveTableModel(ui->tableViewMemoryMap->getProxyModel(), XBinary::getResultFileName(m_pDevice, QString("%1.txt").arg(tr("Memory map")))); 468 | } 469 | 470 | void XMemoryMapWidget::on_checkBoxShowAll_stateChanged(int nValue) 471 | { 472 | Q_UNUSED(nValue) 473 | 474 | updateMemoryMap(); 475 | } 476 | 477 | void XMemoryMapWidget::on_toolButtonDumpAll_clicked() 478 | { 479 | QString sDirectory = QFileDialog::getExistingDirectory(this, tr("Dump all"), XBinary::getDeviceDirectory(m_pDevice)); 480 | 481 | if (!sDirectory.isEmpty()) { 482 | qint32 nNumberOfRecords = ui->tableViewMemoryMap->model()->rowCount(); 483 | 484 | if (nNumberOfRecords) { 485 | QList listRecords; 486 | 487 | for (qint32 i = 0; i < nNumberOfRecords; i++) { 488 | QModelIndex index = ui->tableViewMemoryMap->model()->index(i, 0); 489 | 490 | DumpProcess::RECORD record = {}; 491 | 492 | record.nOffset = ui->tableViewMemoryMap->model()->data(index, Qt::UserRole + 0).toLongLong(); 493 | record.nSize = ui->tableViewMemoryMap->model()->data(index, Qt::UserRole + 2).toLongLong(); 494 | record.sFileName = ui->tableViewMemoryMap->model()->data(index, Qt::UserRole + 3).toString(); 495 | 496 | record.sFileName = sDirectory + QDir::separator() + QFileInfo(record.sFileName).fileName(); 497 | 498 | listRecords.append(record); 499 | } 500 | 501 | QString sJsonFileName = sDirectory + QDir::separator() + XBinary::getDeviceFileBaseName(m_pDevice) + ".patch.json"; 502 | 503 | DumpProcess dumpProcess; 504 | XDialogProcess dd(this, &dumpProcess); 505 | dd.setGlobal(getShortcuts(), getGlobalOptions()); 506 | dumpProcess.setData(m_pDevice, listRecords, DumpProcess::DT_DUMP_DEVICE_OFFSET, sJsonFileName, dd.getPdStruct()); 507 | dd.start(); 508 | dd.showDialogDelay(); 509 | } 510 | } 511 | } 512 | 513 | void XMemoryMapWidget::on_tableViewMemoryMap_customContextMenuRequested(const QPoint &pos) 514 | { 515 | qint32 nRow = ui->tableViewMemoryMap->currentIndex().row(); 516 | 517 | if (nRow != -1) { 518 | QMenu contextMenu(this); 519 | 520 | QList listMenuItems; 521 | 522 | getShortcuts()->_addMenuItem(&listMenuItems, X_ID_TABLE_SELECTION_DUMPTOFILE, this, SLOT(dumpSection()), XShortcuts::GROUPID_NONE); 523 | getShortcuts()->_addMenuItem_CopyRow(&listMenuItems, ui->tableViewMemoryMap); 524 | 525 | getShortcuts()->adjustContextMenu(&contextMenu, &listMenuItems); 526 | 527 | contextMenu.exec(ui->tableViewMemoryMap->viewport()->mapToGlobal(pos)); 528 | } 529 | } 530 | 531 | void XMemoryMapWidget::dumpSection() 532 | { 533 | qint32 nRow = ui->tableViewMemoryMap->currentIndex().row(); 534 | 535 | if (nRow != -1) { 536 | QModelIndex index = ui->tableViewMemoryMap->selectionModel()->selectedIndexes().at(0); 537 | 538 | qint64 nOffset = ui->tableViewMemoryMap->model()->data(index, Qt::UserRole + 0).toLongLong(); 539 | qint64 nSize = ui->tableViewMemoryMap->model()->data(index, Qt::UserRole + 2).toLongLong(); 540 | QString sName = ui->tableViewMemoryMap->model()->data(index, Qt::UserRole + 3).toString(); 541 | 542 | if (sName == "") { 543 | sName = tr("Dump"); 544 | } 545 | 546 | QString sSaveFileName = XBinary::getResultFileName(m_pDevice, QString("%1.bin").arg(sName)); 547 | QString sFileName = QFileDialog::getSaveFileName(this, tr("Save dump"), sSaveFileName, QString("%1 (*.bin)").arg(tr("Raw data"))); 548 | 549 | if (!sFileName.isEmpty()) { 550 | DumpProcess dumpProcess; 551 | XDialogProcess dd(this, &dumpProcess); 552 | dd.setGlobal(getShortcuts(), getGlobalOptions()); 553 | dumpProcess.setData(m_pDevice, nOffset, nSize, sFileName, DumpProcess::DT_DUMP_DEVICE_OFFSET, dd.getPdStruct()); 554 | dd.start(); 555 | dd.showDialogDelay(); 556 | } 557 | } 558 | } 559 | 560 | void XMemoryMapWidget::on_tableViewMemoryMap_clicked(const QModelIndex &index) 561 | { 562 | Q_UNUSED(index); 563 | 564 | viewSelection(); 565 | } 566 | 567 | void XMemoryMapWidget::viewSelection() 568 | { 569 | const bool bBlocked1 = ui->lineEditFileOffset->blockSignals(true); 570 | const bool bBlocked2 = ui->lineEditVirtualAddress->blockSignals(true); 571 | const bool bBlocked3 = ui->lineEditRelativeVirtualAddress->blockSignals(true); 572 | const bool bBlocked4 = ui->tableViewMemoryMap->blockSignals(true); 573 | const bool bBlocked5 = ui->pageHex->blockSignals(true); 574 | 575 | QItemSelectionModel *pSelectionModel = ui->tableViewMemoryMap->selectionModel(); 576 | 577 | if (pSelectionModel) { 578 | QModelIndexList listIndexes = pSelectionModel->selectedRows(0); 579 | 580 | if (listIndexes.count()) { 581 | qint64 nFileOffset = listIndexes.at(0).data(Qt::UserRole + 0).toLongLong(); 582 | XADDR nVirtualAddress = listIndexes.at(0).data(Qt::UserRole + 1).toLongLong(); 583 | qint64 nSize = listIndexes.at(0).data(Qt::UserRole + 2).toLongLong(); 584 | 585 | qint64 nRelativeVirtualAddress = XBinary::addressToRelAddress(&m_memoryMap, nVirtualAddress); 586 | 587 | ui->lineEditFileOffset->setValidatorModeValue(m_mode, nFileOffset); 588 | ui->lineEditVirtualAddress->setValidatorModeValue(m_mode, nVirtualAddress); 589 | ui->lineEditRelativeVirtualAddress->setValidatorModeValue(m_mode, nRelativeVirtualAddress); 590 | 591 | _goToOffset(nFileOffset, nSize); 592 | 593 | if (nFileOffset != -1) { 594 | emit currentLocationChanged(nFileOffset, XBinary::LT_OFFSET, nSize); 595 | } else if (nVirtualAddress != (XADDR)-1) { 596 | emit currentLocationChanged(nVirtualAddress, XBinary::LT_ADDRESS, nSize); 597 | } 598 | } 599 | } 600 | 601 | ui->lineEditFileOffset->blockSignals(bBlocked1); 602 | ui->lineEditVirtualAddress->blockSignals(bBlocked2); 603 | ui->lineEditRelativeVirtualAddress->blockSignals(bBlocked3); 604 | ui->tableViewMemoryMap->blockSignals(bBlocked4); 605 | ui->pageHex->blockSignals(bBlocked5); 606 | } 607 | 608 | void XMemoryMapWidget::on_toolButtonFileOffsetFind_clicked() 609 | { 610 | quint64 nValue = ui->lineEditFileOffset->getValue_uint64(); 611 | 612 | emit findValue(nValue, m_memoryMap.endian); 613 | } 614 | 615 | void XMemoryMapWidget::on_toolButtonVirtualAddressFind_clicked() 616 | { 617 | quint64 nValue = ui->lineEditVirtualAddress->getValue_uint64(); 618 | 619 | emit findValue(nValue, m_memoryMap.endian); 620 | } 621 | 622 | void XMemoryMapWidget::on_toolButtonRelativeVirtualAddressFind_clicked() 623 | { 624 | quint64 nValue = ui->lineEditRelativeVirtualAddress->getValue_uint64(); 625 | 626 | emit findValue(nValue, m_memoryMap.endian); 627 | } 628 | 629 | void XMemoryMapWidget::on_comboBoxMapMode_currentIndexChanged(int nIndex) 630 | { 631 | Q_UNUSED(nIndex) 632 | 633 | updateMemoryMap(); 634 | } 635 | 636 | void XMemoryMapWidget::on_toolButtonReload_clicked() 637 | { 638 | reloadData(true); 639 | } 640 | --------------------------------------------------------------------------------