Skip to content
Permalink
Browse files

QHexView integration

  • Loading branch information...
Dax89 committed Dec 21, 2018
1 parent b2de2c9 commit 7c9b69f61991c5df58b328a410aa907d98cffa35
@@ -1,6 +1,6 @@
[submodule "QHexEdit"]
path = QHexEdit
url = https://github.com/Dax89/QHexEdit.git
[submodule "LibREDasm"]
path = LibREDasm
url = https://github.com/REDasmOrg/REDasm-Library.git
[submodule "QHexView"]
path = QHexView
url = https://github.com/Dax89/QHexView.git
@@ -40,7 +40,7 @@ set(REDASM_BUILD_VERSION "${REDASM_BUILD_TIMESTAMP}.${REDASM_GIT_VERSION}")
add_definitions(-DREDASM_VERSION="${REDASM_BUILD_VERSION}")

add_subdirectory(LibREDasm)
add_subdirectory(QHexEdit)
add_subdirectory(QHexView)

if(CMAKE_BUILD_TYPE MATCHES Debug)
add_subdirectory(unittest)
@@ -49,7 +49,7 @@ endif()
QT5_WRAP_UI(UI_HDRS ${UI_FILES})

SET(SOURCES
${QHEXEDIT_SOURCES}
${QHEXVIEW_SOURCES}
${REDASM_TEST_SOURCES}
main.cpp
mainwindow.cpp
@@ -83,7 +83,7 @@ SET(SOURCES
widgets/disassemblerlistingview/disassemblercolumnview.cpp)

SET(HEADERS
${QHEXEDIT_HEADERS}
${QHEXVIEW_HEADERS}
${REDASM_TEST_HEADERS}
mainwindow.h
widgets/disassemblerview/disassemblerview.h
Submodule QHexEdit deleted from 065f00
Submodule QHexView added at 2df3c1
@@ -2,6 +2,7 @@
#include "ui_disassemblerview.h"
#include "../../dialogs/referencesdialog.h"
#include "../../themeprovider.h"
#include <QHexView/document/buffer/qmemoryrefbuffer.h>
#include <QMessageBox>
#include <QPushButton>

@@ -23,8 +24,8 @@ DisassemblerView::DisassemblerView(QPushButton *pbstatus, QLineEdit *lefilter, Q
m_disassemblerlistingview = new DisassemblerListingView(ui->stackedWidget);
m_disassemblergraphview = new DisassemblerGraphView(ui->stackedWidget);

ui->hexEdit->setReadOnly(true);
ui->hexEdit->setFrameShape(QFrame::NoFrame);
ui->hexView->setReadOnly(true);
ui->hexView->setFrameShape(QFrame::NoFrame);

ui->stackedWidget->addWidget(m_disassemblerlistingview);
ui->stackedWidget->addWidget(m_disassemblergraphview);
@@ -144,10 +145,6 @@ void DisassemblerView::setDisassembler(REDasm::Disassembler *disassembler)
REDasm::log(QString("Found format '%1' with '%2' instruction set").arg(S_TO_QS(disassembler->format()->name()),
S_TO_QS(disassembler->assembler()->name())).toStdString());

const REDasm::Buffer& buffer = disassembler->format()->buffer();
m_hexdocument = QHexDocument::fromMemory(static_cast<const char*>(buffer), buffer.size());
m_hexdocument->setParent(this);

m_functionsmodel->setDisassembler(disassembler);
m_importsmodel->setDisassembler(disassembler);
m_exportsmodel->setDisassembler(disassembler);
@@ -156,9 +153,11 @@ void DisassemblerView::setDisassembler(REDasm::Disassembler *disassembler)
m_callgraphmodel->setDisassembler(disassembler);
m_referencesmodel->setDisassembler(disassembler);

ui->hexEdit->setDocument(m_hexdocument);
ui->disassemblerMap->setDisassembler(disassembler);
REDasm::Buffer& buffer = disassembler->format()->buffer();
m_hexdocument = QHexDocument::fromMemory<QMemoryRefBuffer>(reinterpret_cast<char*>(buffer.data()), buffer.size(), ui->hexView);
ui->hexView->setDocument(m_hexdocument);

ui->disassemblerMap->setDisassembler(disassembler);
m_disassemblerlistingview->setDisassembler(disassembler);
m_disassemblergraphview->setDisassembler(disassembler);

@@ -484,8 +483,8 @@ void DisassemblerView::clearFilter()
void DisassemblerView::selectToHexDump(address_t address, u64 len)
{
offset_t offset = m_disassembler->format()->offset(address);
QHexCursor* cursor = ui->hexEdit->document()->cursor();
cursor->setSelectionRange(offset, len);
QHexCursor* cursor = ui->hexView->document()->cursor();
cursor->selectOffset(offset, len);
ui->tabView->setCurrentWidget(ui->tabHexDump);
}

@@ -532,8 +531,8 @@ void DisassemblerView::syncHexEdit()
len = m_disassembler->format()->addressWidth();
}

QHexCursor* cursor = ui->hexEdit->document()->cursor();
cursor->setSelectionRange(offset, len);
QHexCursor* cursor = ui->hexView->document()->cursor();
cursor->selectOffset(offset, len);
}

void DisassemblerView::createActions()
@@ -4,9 +4,8 @@
#include <QWidget>
#include <QLineEdit>
#include <QMenu>
#include <qhexedit.h>
#include <qhexedit.h>
#include <redasm/disassembler/disassembler.h>
#include <QHexView/qhexview.h>
#include "../../models/callgraphmodel.h"
#include "../../models/listingfiltermodel.h"
#include "../../models/symboltablemodel.h"
@@ -15,6 +14,7 @@
#include "../../dialogs/gotodialog.h"
#include "../disassemblergraphview/disassemblergraphview.h"
#include "../disassemblerlistingview/disassemblerlistingview.h"
#include "themeprovider.h"

namespace Ui {
class DisassemblerView;
@@ -306,7 +306,7 @@
<number>0</number>
</property>
<item>
<widget class="QHexEdit" name="hexEdit" native="true"/>
<widget class="QHexView" name="hexView" native="true"/>
</item>
</layout>
</widget>
@@ -526,15 +526,15 @@
</widget>
<customwidgets>
<customwidget>
<class>ListingMap</class>
<class>QHexView</class>
<extends>QWidget</extends>
<header>widgets/listingmap.h</header>
<header>QHexView/qhexview.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QHexEdit</class>
<class>ListingMap</class>
<extends>QWidget</extends>
<header location="global">qhexedit.h</header>
<header>widgets/listingmap.h</header>
<container>1</container>
</customwidget>
</customwidgets>

0 comments on commit 7c9b69f

Please sign in to comment.
You can’t perform that action at this time.