GUI: virtual module dialog in memory map
This commit is contained in:
parent
582ec7a77a
commit
091f1d5186
|
@ -11,6 +11,7 @@
|
|||
#include "MiscUtil.h"
|
||||
#include "GotoDialog.h"
|
||||
#include "WordEditDialog.h"
|
||||
#include "VirtualModDialog.h"
|
||||
|
||||
MemoryMapView::MemoryMapView(StdTable* parent)
|
||||
: StdTable(parent),
|
||||
|
@ -140,6 +141,10 @@ void MemoryMapView::setupContextMenu()
|
|||
mDumpMemory = new QAction(tr("&Dump Memory to File"), this);
|
||||
connect(mDumpMemory, SIGNAL(triggered()), this, SLOT(dumpMemory()));
|
||||
|
||||
//Add virtual module
|
||||
mAddVirtualMod = new QAction(tr("Add virtual module"), this);
|
||||
connect(mAddVirtualMod, SIGNAL(triggered()), this, SLOT(addVirtualModSlot()));
|
||||
|
||||
refreshShortcutsSlot();
|
||||
connect(Config(), SIGNAL(shortcutsUpdated()), this, SLOT(refreshShortcutsSlot()));
|
||||
}
|
||||
|
@ -160,9 +165,9 @@ void MemoryMapView::contextMenuSlot(const QPoint & pos)
|
|||
if(!DbgIsDebugging())
|
||||
return;
|
||||
QMenu wMenu(this); //create context menu
|
||||
wMenu.addAction(mDumpMemory);
|
||||
wMenu.addAction(mFollowDisassembly);
|
||||
wMenu.addAction(mFollowDump);
|
||||
wMenu.addAction(mDumpMemory);
|
||||
wMenu.addAction(mYara);
|
||||
wMenu.addAction(mEntropy);
|
||||
wMenu.addAction(mFindPattern);
|
||||
|
@ -171,6 +176,7 @@ void MemoryMapView::contextMenuSlot(const QPoint & pos)
|
|||
wMenu.addAction(mMemoryAllocate);
|
||||
wMenu.addAction(mMemoryFree);
|
||||
wMenu.addAction(mFindAddress);
|
||||
wMenu.addAction(mAddVirtualMod);
|
||||
wMenu.addSeparator();
|
||||
wMenu.addAction(mPageMemoryRights);
|
||||
wMenu.addSeparator();
|
||||
|
@ -204,6 +210,8 @@ void MemoryMapView::contextMenuSlot(const QPoint & pos)
|
|||
mMemoryRemove->setVisible(false);
|
||||
}
|
||||
|
||||
mAddVirtualMod->setVisible(!DbgFunctions()->ModBaseFromAddr(selectedAddr));
|
||||
|
||||
wMenu.exec(mapToGlobal(pos)); //execute context menu
|
||||
}
|
||||
|
||||
|
@ -582,3 +590,17 @@ void MemoryMapView::findAddressSlot()
|
|||
selectAddress(DbgValFromString(mGoto.expressionText.toUtf8().constData()));
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryMapView::addVirtualModSlot()
|
||||
{
|
||||
auto base = duint(getCellContent(getInitialSelection(), 0).toULongLong(nullptr, 16));
|
||||
auto size = duint(getCellContent(getInitialSelection(), 1).toULongLong(nullptr, 16));
|
||||
VirtualModDialog mDialog(this);
|
||||
mDialog.setData("", base, size);
|
||||
if(mDialog.exec() != QDialog::Accepted)
|
||||
return;
|
||||
QString modname;
|
||||
if(!mDialog.getData(modname, base, size))
|
||||
return;
|
||||
DbgCmdExec(QString("virtualmod \"%1\", %2, %3").arg(modname).arg(ToHexString(base)).arg(ToHexString(size)).toUtf8().constData());
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ public slots:
|
|||
void dumpMemory();
|
||||
void selectAddress(duint va);
|
||||
void findAddressSlot();
|
||||
void addVirtualModSlot();
|
||||
|
||||
private:
|
||||
QString getProtectionString(DWORD Protect);
|
||||
|
@ -68,6 +69,7 @@ private:
|
|||
QAction* mMemoryAllocate;
|
||||
QAction* mMemoryFree;
|
||||
QAction* mFindAddress;
|
||||
QAction* mAddVirtualMod;
|
||||
|
||||
duint mCipBase;
|
||||
};
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
#include "VirtualModDialog.h"
|
||||
#include "ui_VirtualModDialog.h"
|
||||
#include "StringUtil.h"
|
||||
|
||||
VirtualModDialog::VirtualModDialog(QWidget* parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::VirtualModDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setModal(true);
|
||||
setFixedSize(this->size()); //fixed size
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint | Qt::MSWindowsFixedSizeDialogHint);
|
||||
}
|
||||
|
||||
VirtualModDialog::~VirtualModDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
bool VirtualModDialog::getData(QString & modname, duint & base, duint & size)
|
||||
{
|
||||
modname = ui->editName->text();
|
||||
if(!modname.length())
|
||||
return false;
|
||||
bool ok = false;
|
||||
base = duint(ui->editBase->text().toLongLong(&ok, 16));
|
||||
if(!ok || !DbgMemIsValidReadPtr(base))
|
||||
return false;
|
||||
size = duint(ui->editSize->text().toLongLong(&ok, 16));
|
||||
if(!ok || ! size)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void VirtualModDialog::setData(const QString & modname, duint base, duint size)
|
||||
{
|
||||
ui->editName->setText(modname);
|
||||
ui->editBase->setText(ToHexString(base));
|
||||
ui->editSize->setText(ToHexString(size));
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
#ifndef VIRTUALMODDIALOG_H
|
||||
#define VIRTUALMODDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "Imports.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class VirtualModDialog;
|
||||
}
|
||||
|
||||
class VirtualModDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit VirtualModDialog(QWidget* parent = 0);
|
||||
~VirtualModDialog();
|
||||
bool getData(QString & modname, duint & base, duint & size);
|
||||
void setData(const QString & modname, duint base, duint size);
|
||||
|
||||
private:
|
||||
Ui::VirtualModDialog* ui;
|
||||
};
|
||||
|
||||
#endif // VIRTUALMODDIALOG_H
|
|
@ -0,0 +1,130 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>VirtualModDialog</class>
|
||||
<widget class="QDialog" name="VirtualModDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>101</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Virtual Module</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layoutName">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelName">
|
||||
<property name="text">
|
||||
<string>&Name:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>editName</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="editName"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layoutBaseSize">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layoutBase">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelBase">
|
||||
<property name="text">
|
||||
<string>&Base:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>editBase</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="editBase"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layoutSize">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelSize">
|
||||
<property name="text">
|
||||
<string>&Size:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>editSize</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="editSize"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layoutButtons">
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonOk">
|
||||
<property name="text">
|
||||
<string>&OK</string>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonCancel">
|
||||
<property name="text">
|
||||
<string>&Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonCancel</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>VirtualModDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>254</x>
|
||||
<y>75</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>303</x>
|
||||
<y>98</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonOk</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>VirtualModDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>136</x>
|
||||
<y>80</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>113</x>
|
||||
<y>98</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
|
@ -167,7 +167,8 @@ SOURCES += \
|
|||
Src/Gui/FavouriteTools.cpp \
|
||||
Src/Gui/BrowseDialog.cpp \
|
||||
Src/Gui/DisassemblerGraphView.cpp \
|
||||
Src/Gui/DisassemblyPopup.cpp
|
||||
Src/Gui/DisassemblyPopup.cpp \
|
||||
Src/Gui/VirtualModDialog.cpp
|
||||
|
||||
|
||||
HEADERS += \
|
||||
|
@ -271,7 +272,8 @@ HEADERS += \
|
|||
Src/Gui/BrowseDialog.h \
|
||||
Src/Gui/DisassemblerGraphView.h \
|
||||
Src/Utils/ActionHelpers.h \
|
||||
Src/Gui/DisassemblyPopup.h
|
||||
Src/Gui/DisassemblyPopup.h \
|
||||
Src/Gui/VirtualModDialog.h
|
||||
|
||||
|
||||
FORMS += \
|
||||
|
@ -306,7 +308,8 @@ FORMS += \
|
|||
Src/Gui/CodepageSelectionDialog.ui \
|
||||
Src/Gui/ColumnReorderDialog.ui \
|
||||
Src/Gui/FavouriteTools.ui \
|
||||
Src/Gui/BrowseDialog.ui
|
||||
Src/Gui/BrowseDialog.ui \
|
||||
Src/Gui/VirtualModDialog.ui
|
||||
|
||||
TRANSLATIONS = \
|
||||
Translations/x64dbg.ts
|
||||
|
|
Loading…
Reference in New Issue