diff --git a/RElicAnalysis-0.1.0 b/RElicAnalysis-0.1.0 index 689cd9d..dd2f3b5 100755 Binary files a/RElicAnalysis-0.1.0 and b/RElicAnalysis-0.1.0 differ diff --git a/RElicAnalysis/CMakeLists.txt b/RElicAnalysis/CMakeLists.txt index fb88578..6b4d5aa 100644 --- a/RElicAnalysis/CMakeLists.txt +++ b/RElicAnalysis/CMakeLists.txt @@ -40,8 +40,8 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) centralwidget.h centralwidget.cpp parsingelf.h parsingelf.cpp - dockexplorer.h dockexplorer.cpp - dockanalizing.h dockanalizing.cpp + + data.h stylesheet.h elfdata.h elfdata.cpp @@ -72,6 +72,7 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) elf/mdielfview.cpp elf/mdielfview.h dialogabout.h dialogabout.cpp + dockmenu.h dockmenu.cpp diff --git a/RElicAnalysis/CMakeLists.txt.user b/RElicAnalysis/CMakeLists.txt.user index 83e3fb4..1018f3b 100644 --- a/RElicAnalysis/CMakeLists.txt.user +++ b/RElicAnalysis/CMakeLists.txt.user @@ -1,10 +1,10 @@ - + EnvironmentId - {c1ad1696-344c-4cbf-8c9b-7903590215f2} + {7576b28b-0509-4f2e-9112-d416507c0bdd} ProjectExplorer.Project.ActiveTarget @@ -76,7 +76,7 @@ true true Builtin.DefaultTidyAndClazy - 4 + 2 true @@ -89,10 +89,10 @@ ProjectExplorer.Project.Target.0 Desktop - Desktop Qt 6.6.2 GCC 64bit - Desktop Qt 6.6.2 GCC 64bit - qt.qt6.662.gcc_64_kit - 1 + Desktop + Desktop + {4f4e56a4-b54b-4c8a-9576-1e917c71a3c7} + 0 0 0 @@ -100,16 +100,16 @@ 2 false - -DCMAKE_GENERATOR:STRING=Ninja + -DCMAKE_GENERATOR:STRING=Unix Makefiles -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake --DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} --DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} --DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} --DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} +-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} +-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} +-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} +-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} -DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} 0 - /home/gbucchino/Documents/GIT/RElicAnalysis/build-RElicAnalysis-Desktop_Qt_6_6_2_GCC_64bit-Debug + /home/geoffrey/Documents/GIT/cryptoshield/RElicAnalysis/build-RElicAnalysis-Desktop-Debug @@ -157,15 +157,15 @@ 2 false - -DCMAKE_GENERATOR:STRING=Ninja + -DCMAKE_GENERATOR:STRING=Unix Makefiles -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake --DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} --DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} --DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} --DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} +-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} +-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} +-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} +-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} -DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} - /home/gbucchino/Documents/GIT/RElicAnalysis/build-RElicAnalysis-Desktop_Qt_6_6_2_GCC_64bit-Release + /home/geoffrey/Documents/GIT/cryptoshield/RElicAnalysis/build-RElicAnalysis-Desktop-Release @@ -175,7 +175,6 @@ false true - Build CMakeProjectManager.MakeStep 1 @@ -192,7 +191,6 @@ false true - Build CMakeProjectManager.MakeStep 1 @@ -213,15 +211,15 @@ 2 false - -DCMAKE_GENERATOR:STRING=Ninja + -DCMAKE_GENERATOR:STRING=Unix Makefiles -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo -DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake --DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} --DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} --DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} --DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} +-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} +-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} +-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} +-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} -DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} - /home/gbucchino/Documents/GIT/RElicAnalysis/build-RElicAnalysis-Desktop_Qt_6_6_2_GCC_64bit-RelWithDebInfo + /home/geoffrey/Documents/GIT/cryptoshield/RElicAnalysis/build-RElicAnalysis-Desktop-RelWithDebInfo @@ -267,16 +265,16 @@ 2 false - -DCMAKE_GENERATOR:STRING=Ninja + -DCMAKE_GENERATOR:STRING=Unix Makefiles -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo -DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake --DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} --DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} --DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} --DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} +-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} +-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} +-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} +-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} -DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} 0 - /home/gbucchino/Documents/GIT/RElicAnalysis/build-RElicAnalysis-Desktop_Qt_6_6_2_GCC_64bit-Profile + /home/geoffrey/Documents/GIT/cryptoshield/RElicAnalysis/build-RElicAnalysis-Desktop-Profile @@ -322,15 +320,15 @@ 2 false - -DCMAKE_GENERATOR:STRING=Ninja + -DCMAKE_GENERATOR:STRING=Unix Makefiles -DCMAKE_BUILD_TYPE:STRING=MinSizeRel -DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake --DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} --DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} --DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} --DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} +-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} +-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} +-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} +-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} -DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} - /home/gbucchino/Documents/GIT/RElicAnalysis/build-RElicAnalysis-Desktop_Qt_6_6_2_GCC_64bit-MinSizeRel + /home/geoffrey/Documents/GIT/cryptoshield/RElicAnalysis/build-RElicAnalysis-Desktop-MinSizeRel @@ -390,18 +388,17 @@ true 0 true + 2 false - RElicAnalysis - CMakeProjectManager.CMakeRunConfiguration.RElicAnalysis - RElicAnalysis + + ProjectExplorer.CustomExecutableRunConfiguration + false true - true true - /home/gbucchino/Documents/GIT/RElicAnalysis/build-RElicAnalysis-Desktop_Qt_6_6_2_GCC_64bit-Release 1 diff --git a/RElicAnalysis/centralwidget.cpp b/RElicAnalysis/centralwidget.cpp index c521511..ca05668 100644 --- a/RElicAnalysis/centralwidget.cpp +++ b/RElicAnalysis/centralwidget.cpp @@ -3,7 +3,6 @@ CentralWidget::CentralWidget(MainWindow *mainWindow): QMdiArea() { m_mainWindow = mainWindow; - //m_mdiElfHandler = NULL; setViewMode(QMdiArea::TabbedView); setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); setAttribute(Qt::WA_Resized); @@ -20,12 +19,6 @@ CentralWidget::CentralWidget(MainWindow *mainWindow): QMdiArea() { */ //this->_addWelcomeTab(); } -/*void CentralWidget::addMdiWindowElf(ProjectElf *projectElf){ - // Create MdiELF project - m_mdiElfHandler = new MdiElfHandler(this, projectElf); - - m_mdiElfHandler->showMdiSubWindow(); -}*/ void CentralWidget::closeCurrentProject(){ } @@ -44,6 +37,4 @@ void CentralWidget::_addWelcomeTab(){ addSubWindow(window)->show(); } -CentralWidget::~CentralWidget(){ - //delete m_mdiElfHandler; -} +CentralWidget::~CentralWidget(){} diff --git a/RElicAnalysis/centralwidget.h b/RElicAnalysis/centralwidget.h index fd1f8eb..725fbc8 100644 --- a/RElicAnalysis/centralwidget.h +++ b/RElicAnalysis/centralwidget.h @@ -5,7 +5,6 @@ #include #include #include -#include "projectelf.h" #include "elf/mdielfhandler.h" @@ -15,13 +14,10 @@ class CentralWidget: public QMdiArea { public: CentralWidget(MainWindow *); ~CentralWidget(); - //void addMdiWindowElf(ProjectElf *); void closeCurrentProject(); - private: MainWindow *m_mainWindow; - //MdiElfHandler *m_mdiElfHandler; void _addWelcomeTab(); }; diff --git a/RElicAnalysis/dialogabout.cpp b/RElicAnalysis/dialogabout.cpp index 4698061..c6cf9f0 100644 --- a/RElicAnalysis/dialogabout.cpp +++ b/RElicAnalysis/dialogabout.cpp @@ -1,25 +1,81 @@ #include "dialogabout.h" DialogAbout::DialogAbout(): QDialog() { - setWindowTitle("About"); + setWindowTitle("About RElicAnalysis"); + //setStyleSheet("QDialog::border: 1px solid #afafaf;"); + QVBoxLayout *mainLayout = new QVBoxLayout; + QLabel *labelTitle = new QLabel("RElicAnalysis 0.1.0"); + QFont fontTitle; + fontTitle.setPointSize(15); + fontTitle.setBold(true); + labelTitle->setFont(fontTitle); + mainLayout->addWidget(labelTitle); + QString basedOn = "Based on Qt " + QByteArray(QT_VERSION_STR); + QLabel *labelBasedOn = new QLabel(basedOn); + mainLayout->addWidget(labelBasedOn); + + QLabel *labelAuthor = new QLabel("Author: Bucchino Geoffrey"); + mainLayout->addWidget(labelAuthor); + + QLabel *labelLicense = new QLabel("Under the licence GPL"); + mainLayout->addWidget(labelLicense); + + QLabel *labelWebsite = new QLabel("Visit https://cryptoshield.bucchino.org/ for more information"); + mainLayout->addWidget(labelWebsite); QHBoxLayout *layoutButtons = new QHBoxLayout; QPushButton *buttonQuit = new QPushButton("Close"); + buttonQuit->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); connect(buttonQuit, SIGNAL(clicked()), this, SLOT(close())); - layoutButtons->addWidget(buttonQuit); + layoutButtons->addStretch(1); + layoutButtons->addWidget(buttonQuit, 0, Qt::AlignRight); - setLayout(layoutButtons); - /* QHBoxLayout layoutButtons; - QPushButton buttonQuit; - buttonQuit.setText("Close"); - connect(&buttonQuit, SIGNAL(clicked()), this, SLOT(close())); - layoutButtons.addWidget(&buttonQuit); - setLayout(&layoutButtons);*/ + mainLayout->addLayout(layoutButtons); + mainLayout->addStretch(); + setLayout(mainLayout); } -DialogAbout::~DialogAbout(){ +/*DialogAbout::DialogAbout() : QDialog() { + QVBoxLayout *layout = new QVBoxLayout; + + // Informations + QGridLayout *layoutAbout = new QGridLayout; + QLabel *labelLeftName = new QLabel("Nom du programme"); + QLabel *labelRightName = new QLabel("Editeur LaTex"); + QLabel *labelLeftVersion = new QLabel("Version"); + QLabel *labelRightVersion = new QLabel("1.0"); + QLabel *labelLeftLicence = new QLabel("Licence"); + QLabel *labelRightLicence = new QLabel("GPL"); + QLabel *labelLeftAuthor= new QLabel("Auteur"); + QLabel *labelRightAuthor = new QLabel("BUCCHINO Geoffrey"); + QLabel *labelLeftURL = new QLabel("Adresse Internet"); + QLabel *labelRightURL = new QLabel("www.geoffreybucchino.com"); + + layoutAbout->addWidget(labelLeftName, 0,0); + layoutAbout->addWidget(labelRightName, 0,1); + layoutAbout->addWidget(labelLeftVersion,1,0); + layoutAbout->addWidget(labelRightVersion,1,1); + layoutAbout->addWidget(labelLeftLicence,2,0); + layoutAbout->addWidget(labelRightLicence,2,1); + layoutAbout->addWidget(labelLeftAuthor,3,0); + layoutAbout->addWidget(labelRightAuthor, 3,1); + layoutAbout->addWidget(labelLeftURL,4,0); + layoutAbout->addWidget(labelRightURL,4,1); + + // Button + QHBoxLayout *layoutButton = new QHBoxLayout; + layoutButton->setAlignment(Qt::AlignRight); + QPushButton *buttonOk = new QPushButton("Ok"); + connect(buttonOk, SIGNAL(clicked()), this, SLOT(close())); + + layoutButton->addWidget(buttonOk); + + layout->addLayout(layoutAbout); + layout->addLayout(layoutButton); + + setLayout(layout); +}*/ -} diff --git a/RElicAnalysis/dialogabout.h b/RElicAnalysis/dialogabout.h index 3f2f1b7..68604fd 100644 --- a/RElicAnalysis/dialogabout.h +++ b/RElicAnalysis/dialogabout.h @@ -6,12 +6,12 @@ #include #include #include +#include class DialogAbout : public QDialog { public: DialogAbout(); - ~DialogAbout(); }; diff --git a/RElicAnalysis/disasasm.cpp b/RElicAnalysis/disasasm.cpp index 473cafc..173f958 100644 --- a/RElicAnalysis/disasasm.cpp +++ b/RElicAnalysis/disasasm.cpp @@ -29,7 +29,7 @@ static int dump_asm(void *stream, const char *fmt, ...){ /* * Cf: https://github.com/bpftrace/bpftrace/blob/master/src/bfd-disasm.cpp#L49C1-L55C2 */ -static int dump_asm_styled(void *out __attribute__((unused)), enum disassembler_style s __attribute__((unused)), +/*static int dump_asm_styled(void *out __attribute__((unused)), enum disassembler_style s __attribute__((unused)), const char *fmt __attribute__((unused)), ...) { struct dataDisas *sData = (struct dataDisas*)out; @@ -54,7 +54,7 @@ static int dump_asm_styled(void *out __attribute__((unused)), enum disassembler_ memcpy(sData->s_object_asm[index].cmd, tmp, strlen(tmp)); return 0; -} +}*/ struct dataDisas *disas_asm(unsigned char *buffer, uint64_t startAddress, size_t length){ struct disassemble_info disasm_info; @@ -89,20 +89,13 @@ static int dump_asm_styled(void *out __attribute__((unused)), enum disassembler_ // TODO: Need to identify the version of the libbinutils, for old system, it's with three arguments //qDebug() << BFD_VERSION; //qDebug() << bfd_version_string(); - /* - * $ ld --version -GNU ld (GNU Binutils for Debian) 2.35.2 -Copyright (C) 2020 Free Software Foundation, Inc. -This program is free software; you may redistribute it under the terms of -the GNU General Public License version 3 or (at your option) a later version. -This program has absolutely no warranty. - */ + /* * https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?id=600b7b26c07a070d0153daa76b3806c1e52c9e00 * https://patchwork.yoctoproject.org/project/arm/patch/20220824025819.4888-1-jon.mason@arm.com/#5104 */ - init_disassemble_info (&disasm_info, sData, dump_asm, dump_asm_styled); //init_disassemble_info (&disasm_info, sData, dump_asm, dump_asm_styled); + init_disassemble_info (&disasm_info, sData, dump_asm); disasm_info.arch = bfd_arch_i386; disasm_info.mach = bfd_mach_x86_64; disasm_info.read_memory_func = buffer_read_memory; @@ -115,7 +108,7 @@ This program has absolutely no warranty. disas = disassembler(bfd_arch_i386, false, bfd_mach_x86_64, NULL); if (!disas){ - qDebug() << "Can't disassembled"; + qDebug() << "Cannot be disassembled"; return NULL; } diff --git a/RElicAnalysis/dockanalizing.cpp b/RElicAnalysis/dockanalizing.cpp deleted file mode 100644 index 17e5a83..0000000 --- a/RElicAnalysis/dockanalizing.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "dockanalizing.h" - -DockAnalizing::DockAnalizing(): QDockWidget() { - QWidget *widget = new QWidget; - QVBoxLayout *layout = new QVBoxLayout; - setFeatures(QDockWidget::NoDockWidgetFeatures); - - // Title bar - QWidget *bar = new QWidget; - bar->setMinimumHeight(20); - bar->setStyleSheet("border-bottom:1px solid #000;background-color:#656565;"); - - layout->addWidget(bar); - layout->setContentsMargins(QMargins(0,0,0,0)); // Remove all margins - - setTitleBarWidget(new QWidget); // hide the titlebar - - widget->setLayout(layout); - setWidget(widget); -} -DockAnalizing::~DockAnalizing(){ - -} diff --git a/RElicAnalysis/dockanalizing.h b/RElicAnalysis/dockanalizing.h deleted file mode 100644 index 3b1677b..0000000 --- a/RElicAnalysis/dockanalizing.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef DOCKANALIZING_H -#define DOCKANALIZING_H - -#include -#include - - -class DockAnalizing: public QDockWidget { - public: - DockAnalizing(); - ~DockAnalizing(); -}; - -#endif // DOCKANALIZING_H diff --git a/RElicAnalysis/dockexplorer.cpp b/RElicAnalysis/dockexplorer.cpp deleted file mode 100644 index b3d8052..0000000 --- a/RElicAnalysis/dockexplorer.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "dockexplorer.h" - -DockExplorer::DockExplorer(): QDockWidget() { - QWidget *widget = new QWidget; - QVBoxLayout *layout = new QVBoxLayout; - setFeatures(QDockWidget::NoDockWidgetFeatures); - - // Title bar - QWidget *bar = new QWidget; - bar->setMinimumHeight(20); - bar->setStyleSheet("border-bottom:1px solid #000;background-color:#656565;"); - - // List - m_model = new QStandardItemModel; - - m_view = new QListView; - //connect(m_view, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(itemClicked(const QModelIndex&))); - //connect(m_view, SIGNAL(clicked(const QModelIndex&)), this, SLOT(selectItem(const QModelIndex&))); - m_view->setModel(m_model); - m_view->setStyleSheet("border:none;"); - - layout->addWidget(bar); - layout->addWidget(m_view); - layout->setContentsMargins(QMargins(0,0,0,0)); // Remove all margins - - setTitleBarWidget(new QWidget); // hide the titlebar - - widget->setLayout(layout); - setWidget(widget); -} - -DockExplorer::~DockExplorer(){ - delete m_view; -} diff --git a/RElicAnalysis/dockexplorer.h b/RElicAnalysis/dockexplorer.h deleted file mode 100644 index d25201f..0000000 --- a/RElicAnalysis/dockexplorer.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef DOCKEXPLORER_H -#define DOCKEXPLORER_H - -#include -#include -#include -#include - -class DockExplorer: public QDockWidget { - public: - DockExplorer(); - ~DockExplorer(); - - private: - QStandardItemModel *m_model; - QListView *m_view; -}; - -#endif // DOCKEXPLORER_H diff --git a/RElicAnalysis/dockmenu.cpp b/RElicAnalysis/dockmenu.cpp new file mode 100644 index 0000000..f4174dc --- /dev/null +++ b/RElicAnalysis/dockmenu.cpp @@ -0,0 +1,56 @@ +#include "dockmenu.h" + +QDockMenu::QDockMenu() { + // Sidebar widget + QWidget *sidebar = new QWidget; + QVBoxLayout *layout = new QVBoxLayout(sidebar); + layout->setSpacing(10); + layout->setContentsMargins(5, 5, 5, 5); + + // Create buttons + QToolButton *btnWelcome = new QToolButton; + btnWelcome->setIcon(QIcon(":/icons/welcome.png")); // your icon + btnWelcome->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); + btnWelcome->setText("Welcome"); + + QToolButton *btnEdit = new QToolButton; + btnEdit->setIcon(QIcon(":/icons/edit.png")); + btnEdit->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); + btnEdit->setText("Edit"); + + QToolButton *btnDesign = new QToolButton; + btnDesign->setIcon(QIcon(":/icons/design.png")); + btnDesign->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); + btnDesign->setText("Design"); + + QToolButton *btnDebug = new QToolButton; + btnDebug->setIcon(QIcon(":/icons/debug.png")); + btnDebug->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); + btnDebug->setText("Debug"); + + QToolButton *btnProjects = new QToolButton; + btnProjects->setIcon(QIcon(":/icons/projects.png")); + btnProjects->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); + btnProjects->setText("Projects"); + + QToolButton *btnHelp = new QToolButton; + btnHelp->setIcon(QIcon(":/icons/help.png")); + btnHelp->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); + btnHelp->setText("Help"); + + // Add buttons to layout + layout->addWidget(btnWelcome); + layout->addWidget(btnEdit); + layout->addWidget(btnDesign); + layout->addWidget(btnDebug); + layout->addWidget(btnProjects); + layout->addWidget(btnHelp); + layout->addStretch(); // push buttons to top + + // Set sidebar as dock widget or fixed widget + //window.setCentralWidget(new QWidget); // placeholder for main area + //window.addDockWidget(Qt::LeftDockWidgetArea, new QDockWidget("Sidebar", &window)); + //window.findChild()->setWidget(sidebar); + //window.findChild()->setFeatures(QDockWidget::NoDockWidgetFeatures); // fix it + +} diff --git a/RElicAnalysis/dockmenu.h b/RElicAnalysis/dockmenu.h new file mode 100644 index 0000000..271b237 --- /dev/null +++ b/RElicAnalysis/dockmenu.h @@ -0,0 +1,15 @@ +#ifndef DOCKMENU_H +#define DOCKMENU_H + +#include +#include +#include +#include + +class QDockMenu +{ +public: + QDockMenu(); +}; + +#endif // DOCKMENU_H diff --git a/RElicAnalysis/elf/mdielf.cpp b/RElicAnalysis/elf/mdielf.cpp index 3566171..71c51dc 100644 --- a/RElicAnalysis/elf/mdielf.cpp +++ b/RElicAnalysis/elf/mdielf.cpp @@ -237,17 +237,7 @@ MdiElf::MdiElf(ProjectElf *projectElf): QMdiSubWindow() { layoutDockRight->addWidget(barHashTable); layoutDockRight->addWidget(m_treeHashTable); - - /**************************/ - /***** Analyzing part *****/ - /**************************/ - m_textAnalyzing = new QTextEdit; - m_textAnalyzing->setReadOnly(true); - m_textAnalyzing->setStyleSheet("border:none;border-top:1px solid #000;"); - m_textAnalyzing->setMaximumHeight(250); - layoutCentral->addLayout(layoutTextEdit); - layoutCentral->addWidget(m_textAnalyzing); mainLayout->addLayout(layoutDockLeft); mainLayout->addLayout(layoutCentral); diff --git a/RElicAnalysis/mainwindow.cpp b/RElicAnalysis/mainwindow.cpp index a028101..e4ad82e 100644 --- a/RElicAnalysis/mainwindow.cpp +++ b/RElicAnalysis/mainwindow.cpp @@ -5,8 +5,6 @@ MainWindow::MainWindow(): QMainWindow() { m_handleProject = new HandleProject(this); m_centralWidget = new CentralWidget(this); m_menuBar = new MenuBar(m_centralWidget, m_handleProject); - //m_dockExplorer = new DockExplorer; - //m_dockAnalyzing = new DockAnalizing; setWindowTitle("RElicAnalysis"); setWindowState(Qt::WindowMaximized); @@ -14,12 +12,7 @@ MainWindow::MainWindow(): QMainWindow() { setCentralWidget(m_centralWidget); setMenuBar(m_menuBar); - //addDockWidget(Qt::LeftDockWidgetArea, m_dockExplorer, Qt::Horizontal); - //addDockWidget(Qt::BottomDockWidgetArea, m_dockAnalyzing); } -/*void MainWindow::newProject(ProjectElf *projectElf){ - m_centralWidget->addMdiWindowElf(projectElf); -}*/ void MainWindow::closeCurrentProject(){ } @@ -29,8 +22,6 @@ CentralWidget *MainWindow::getCentralWidget(){ MainWindow::~MainWindow() { delete m_centralWidget; delete m_menuBar; - //delete m_dockExplorer; - //delete m_dockAnalyzing; if (m_project != NULL) delete m_project; } diff --git a/RElicAnalysis/mainwindow.h b/RElicAnalysis/mainwindow.h index f4022e9..9a28512 100644 --- a/RElicAnalysis/mainwindow.h +++ b/RElicAnalysis/mainwindow.h @@ -4,8 +4,6 @@ #include #include "menubar.h" #include "centralwidget.h" -#include "dockexplorer.h" -#include "dockanalizing.h" #include "projectelf.h" #include "project.h" #include "handleproject.h" @@ -17,15 +15,12 @@ class MainWindow : public QMainWindow { public: MainWindow(); ~MainWindow(); - //void newProject(ProjectElf *); void closeCurrentProject(); CentralWidget *getCentralWidget(); private: CentralWidget *m_centralWidget; MenuBar *m_menuBar; - DockExplorer *m_dockExplorer; - DockAnalizing *m_dockAnalyzing; HandleProject *m_handleProject; Project *m_project; ProjectElf *m_projectElf; diff --git a/RElicAnalysis/menubar.cpp b/RElicAnalysis/menubar.cpp index 0fa0ce2..709b36d 100644 --- a/RElicAnalysis/menubar.cpp +++ b/RElicAnalysis/menubar.cpp @@ -12,15 +12,14 @@ MenuBar::MenuBar(CentralWidget *centralWidget, HandleProject *project) { // Create menu QMenu *menuFile = new QMenu("File"); - //QMenu *menuAnalyze = new QMenu("Analyze"); QMenu *menuAbout = new QMenu("About"); // Menu file - QAction *actionOpenFile = new QAction("Open file", this); + QAction *actionOpenFile = new QAction("Open ELF file", this); actionOpenFile->setShortcut(QKeySequence("ctrl+O")); connect(actionOpenFile, SIGNAL(triggered()), this, SLOT(_openFile())); - QAction *actionCloseFile = new QAction("Close the file", this); + QAction *actionCloseFile = new QAction("Fermer le fichier", this); actionCloseFile->setShortcut(QKeySequence("ctrl+W")); connect(actionCloseFile, SIGNAL(triggered()), this, SLOT(_closeFile())); menuFile->addSeparator(); @@ -33,14 +32,6 @@ MenuBar::MenuBar(CentralWidget *centralWidget, HandleProject *project) { menuFile->addAction(actionCloseFile); menuFile->addAction(actionQuit); - // Menu analyze - /*QAction *actionShowBinary = new QAction("Show binary", this); - actionShowBinary->setShortcut(QKeySequence("ctrl+b")); - QAction *actionShowStrings = new QAction("Show strings", this); - - menuAnalyze->addAction(actionShowBinary); - menuAnalyze->addAction(actionShowStrings);*/ - // Menu about QAction *actionAbout = new QAction("A propos", this); connect(actionAbout, SIGNAL(triggered()), m_dialogAbout, SLOT(exec())); @@ -48,7 +39,6 @@ MenuBar::MenuBar(CentralWidget *centralWidget, HandleProject *project) { // add menu to menuBar addMenu(menuFile); - //addMenu(menuAnalyze); addMenu(menuAbout); } /* @@ -58,7 +48,7 @@ void MenuBar::_openFile() { // Check if we have a project open // If yes, clean it if (m_handleProject->projectOpened() == true){ - unsigned int r = QMessageBox::question(NULL, "Open ELF file", "A file is open, you should close the file first", QMessageBox::Cancel); + unsigned int r = QMessageBox::question(NULL, "Open binary file", "A file is open, you should close the file first", QMessageBox::Cancel); } else { QString path = QFileDialog::getOpenFileName(NULL, "Open binary file", "", "File (*)"); @@ -68,7 +58,7 @@ void MenuBar::_openFile() { m_handleProject->handleOpenFile(file); } else if(file.open(QIODevice::ReadOnly)) { - unsigned int r = QMessageBox::question(NULL, "Open ELF file", "The file is in read-only. Wish you to open it ?", QMessageBox::Yes | QMessageBox::No); + unsigned int r = QMessageBox::question(NULL, "Open binary file", "The file is in read-only. Wish you to open it ?", QMessageBox::Yes | QMessageBox::No); if(r == QMessageBox::Yes){ m_handleProject->handleOpenFile(file); @@ -79,7 +69,6 @@ void MenuBar::_openFile() { } } void MenuBar::_closeFile(){ - qDebug() << "Close file"; // We can close the project m_handleProject->handleCloseFile(); } diff --git a/RElicAnalysis/parsingelf.cpp b/RElicAnalysis/parsingelf.cpp index c350630..2471304 100644 --- a/RElicAnalysis/parsingelf.cpp +++ b/RElicAnalysis/parsingelf.cpp @@ -186,7 +186,7 @@ bool elf64SectionHdr(const char *buffer, ElfData *elfData, size_t offset, quint1 elfS[i].sh_info = convertFrom32bits(shdr[i].sh_info); elfS[i].sh_addralign = convertFrom32bits(shdr[i].sh_addralign); elfS[i].sh_entsize = convertFrom32bits(shdr[i].sh_entsize); - + qDebug() << elfS[i].sh_name << " " << elfS[i].sh_offset.toHex() << " " << elfS[i].sh_size.toHex(); elfData->setSectionHeader(&elfS[i]); const char *shname = b + shdr[i].sh_name; @@ -201,7 +201,6 @@ bool elf64SectionHdr(const char *buffer, ElfData *elfData, size_t offset, quint1 if (shdr[i].sh_type == 0x01 && strcmp(shname, ".text") == 0){ indexTextTab = i; - //qDebug() << "Section: " << elfS[i].sh_addr.toHex() << " " << elfS[i].sh_size.toHex(); } if (shdr[i].sh_type == 0x01 && strcmp(shname, ".fini") == 0) @@ -234,16 +233,24 @@ bool elf64SectionHdr(const char *buffer, ElfData *elfData, size_t offset, quint1 shdrtext = &shdr[indexTextTab]; shdrfini = &shdr[indexFiniTab]; + /* + * Not needed to use shdrfini->sh_offset for the range of the .text + * We can add shdrtext->sh_offset + shdrtext->sh_size + */ + /* + * We can try for each symbols, to get the section .text, .data, .rodata + * getTextSections, getRodataSections, getDataSections, etc. and push to a QList + */ + // Get all symbols res = getSymbols(buffer, elfData, shdr, indexStrTab, indexSymbolTab, shdrtext->sh_offset, shdrfini->sh_offset); if (!res) return false; // Get dynsym tab - getDynSym(buffer, elfData, shdr, indexDynSymTab, indexDynStrTab, indexHashTab); // F***CK segmentation fault + getDynSym(buffer, elfData, shdr, indexDynSymTab, indexDynStrTab, indexHashTab); // Segmentation fault // Hash table - // https://flapenguin.me/elf-dt-hash shdrhash = &shdr[indexHashTab]; return true; @@ -251,8 +258,8 @@ bool elf64SectionHdr(const char *buffer, ElfData *elfData, size_t offset, quint1 bool getDynSym(const char *buffer, ElfData *elfData, Elf64_Shdr *shdr, int indexDynSymTab, int indexDynStrTab, int indexHashTab){ Elf64_Shdr *shdrdynsym = &shdr[indexDynSymTab]; Elf64_Shdr *shdrDynStr = &shdr[indexDynStrTab]; - Elf64_Shdr *shdrhash = &shdr[indexHashTab]; - size_t dynsymnum = shdrdynsym->sh_size / shdrdynsym->sh_entsize; + //Elf64_Shdr *shdrhash = &shdr[indexHashTab]; + //size_t dynsymnum = shdrdynsym->sh_size / shdrdynsym->sh_entsize; const char *b2 = buffer + shdrDynStr->sh_offset; Elf64_Sym *symtab = (Elf64_Sym*)(buffer + shdrdynsym->sh_offset); @@ -319,6 +326,11 @@ bool getSymbols(const char *buffer, ElfData *elfData, Elf64_Shdr *shdr, int inde if (sData == NULL){ qDebug() << "Failed to get the assembly code"; + // I must freeing elfS structures + /*for (size_t i = 0; i < symtabnum; i++) + free(&elfS[i]);*/ + free(elfS); + elfS = NULL; return false; } @@ -372,11 +384,19 @@ bool getSymbols(const char *buffer, ElfData *elfData, Elf64_Shdr *shdr, int inde } elfData->setSymbol(&elfS[i]); - + //qDebug() << b2 + symtab[i].st_name << " " << symtab[i].st_value << " " << offsetText << " " << offsetFini; + //qDebug() << b2 + symtab[i].st_name << " " << symtab[i].st_value << " " << symtab[i].st_size; // We check if the symbol is in the .text section if (symtab[i].st_value >= offsetText && symtab[i].st_value <= offsetFini){ elfData->setTextSymbol(&elfS[i]); } + + /* + * We can push the symbols to the correct list + * For instance, if symtab[i].st_name == .rodata, we push to the QList + * Also, we can check with the size of the symbols + * size_t l = symtab[i].st_value + symtab[i].st_size + */ } return true;