1
0
Fork 0

Fix the issue with column resizing (#753)

* Fix the issue with column resizing.

* Add an icon for the message box.

* UI for allocating & freeing memory

* UI for allocating & freeing memory

* Add missing "emit" statement

* Upload translation for new GUI operations
This commit is contained in:
Torusrxxx 2016-06-15 12:00:13 +00:00 committed by Duncan Ogilvie
parent 38a1626fe8
commit 4b405cd18e
5 changed files with 170 additions and 41 deletions

View File

@ -171,6 +171,7 @@ void AbstractTableView::paintEvent(QPaintEvent* event)
{
if(!mAllowPainting)
return;
if(getColumnCount()) //make sure the last column is never smaller than the window
{
int totalWidth = 0;
@ -348,11 +349,11 @@ void AbstractTableView::mouseMoveEvent(QMouseEvent* event)
case AbstractTableView::ResizeColumnState:
{
int delta = event->x() - mColResizeData.lastPosX;
bool bCanResize = (getColumnWidth(mColResizeData.index) + delta) >= 20;
bool bCanResize = (getColumnWidth(mColumnOrder[mColResizeData.index]) + delta) >= 20;
if(bCanResize)
{
int wNewSize = getColumnWidth(mColResizeData.index) + delta;
setColumnWidth(mColResizeData.index, wNewSize);
int wNewSize = getColumnWidth(mColumnOrder[mColResizeData.index]) + delta;
setColumnWidth(mColumnOrder[mColResizeData.index], wNewSize);
mColResizeData.lastPosX = event->x();
updateViewport();
}

View File

@ -45,6 +45,7 @@ void ColumnReorderDialog::on_okButton_clicked()
if(ui->listDisplayed->count() == 0)
{
QMessageBox msg(QMessageBox::Warning, tr("Error"), tr("There isn't anything to display yet!"));
msg.setWindowIcon(QIcon(":/icons/images/compile-error.png"));
msg.exec();
return;
}

View File

@ -1,4 +1,5 @@
#include <QFileDialog>
#include <QMessageBox>
#include "MemoryMapView.h"
#include "Configuration.h"
@ -7,6 +8,7 @@
#include "YaraRuleSelectionDialog.h"
#include "EntropyDialog.h"
#include "HexEditDialog.h"
#include "LineEditDialog.h"
MemoryMapView::MemoryMapView(StdTable* parent) : StdTable(parent)
{
@ -102,6 +104,16 @@ void MemoryMapView::setupContextMenu()
this->addAction(mMemoryExecuteSingleshootToggle);
connect(mMemoryExecuteSingleshootToggle, SIGNAL(triggered()), this, SLOT(memoryExecuteSingleshootToggleSlot()));
//Allocate memory
mMemoryAllocate = new QAction(tr("&Allocate memory"), this);
connect(mMemoryAllocate, SIGNAL(triggered()), this, SLOT(memoryAllocateSlot()));
this->addAction(mMemoryAllocate);
//Free memory
mMemoryFree = new QAction(tr("&Free memory"), this);
connect(mMemoryFree, SIGNAL(triggered()), this, SLOT(memoryFreeSlot()));
this->addAction(mMemoryFree);
//Entropy
mEntropy = new QAction(QIcon(":/icons/images/entropy.png"), tr("Entropy..."), this);
connect(mEntropy, SIGNAL(triggered()), this, SLOT(entropy()));
@ -141,6 +153,9 @@ void MemoryMapView::contextMenuSlot(const QPoint & pos)
wMenu.addAction(mFindPattern);
wMenu.addAction(mSwitchView);
wMenu.addSeparator();
wMenu.addAction(mMemoryAllocate);
wMenu.addAction(mMemoryFree);
wMenu.addSeparator();
wMenu.addAction(mPageMemoryRights);
wMenu.addSeparator();
wMenu.addMenu(mBreakpointMenu);
@ -440,12 +455,63 @@ void MemoryMapView::entropy()
delete[] data;
}
void MemoryMapView::memoryAllocateSlot()
{
LineEditDialog mLineEdit(this);
mLineEdit.setWindowTitle(tr("Enter the size of memory to allocate."));
if(mLineEdit.exec() == QDialog::Accepted)
{
QByteArray textUtf8 = mLineEdit.editText.toUtf8();
if(!DbgIsValidExpression(textUtf8.constData()))
{
QMessageBox msg(QMessageBox::Critical, tr("Error"), tr("The expression \"%1\" is not valid.").arg(mLineEdit.editText));
msg.setWindowIcon(QIcon(":/icons/images/compile-error.png"));
msg.exec();
return;
}
duint memsize = DbgValFromString(textUtf8.constData());
if(memsize == 0) // 1GB
{
QMessageBox msg(QMessageBox::Warning, tr("Warning"), tr("You're trying to allocate a zero-sized buffer just now."));
msg.setWindowIcon(QIcon(":/icons/images/compile-warning.png"));
msg.exec();
return;
}
if(memsize > 1024 * 1024 * 1024)
{
QMessageBox msg(QMessageBox::Critical, tr("Error"), tr("The size of buffer you're trying to allocate exceeds 1GB. Please check your expression to ensure nothing is wrong."));
msg.setWindowIcon(QIcon(":/icons/images/compile-error.png"));
msg.exec();
return;
}
DbgCmdExecDirect(QString("alloc %1").arg(ToPtrString(memsize)).toUtf8().constData());
duint addr = DbgValFromString("$result");
if(addr != 0)
{
DbgCmdExec("Dump $result");
emit showCpu();
}
else
{
QMessageBox msg(QMessageBox::Critical, tr("Error"), tr("Memory allocation failed!"));
msg.setWindowIcon(QIcon(":/icons/images/compile-error.png"));
msg.exec();
return;
}
}
}
void MemoryMapView::memoryFreeSlot()
{
DbgCmdExec(QString("free %1").arg(getCellContent(getInitialSelection(), 0)).toUtf8().constData());
}
void MemoryMapView::findPatternSlot()
{
HexEditDialog hexEdit(this);
hexEdit.showEntireBlock(true);
hexEdit.mHexEdit->setOverwriteMode(false);
hexEdit.setWindowTitle("Find Pattern...");
hexEdit.setWindowTitle(tr("Find Pattern..."));
if(hexEdit.exec() != QDialog::Accepted)
return;
duint addr = getCellContent(getInitialSelection(), 0).toULongLong(0, 16);
@ -458,7 +524,7 @@ void MemoryMapView::findPatternSlot()
void MemoryMapView::dumpMemory()
{
QString fileName = QFileDialog::getSaveFileName(this, "Save Memory Region", QDir::currentPath(), tr("All files (*.*)"));
QString fileName = QFileDialog::getSaveFileName(this, tr("Save Memory Region"), QDir::currentPath(), tr("All files (*.*)"));
if(fileName.length())
{

View File

@ -29,6 +29,8 @@ public slots:
void memoryExecuteRestoreSlot();
void memoryRemoveSlot();
void memoryExecuteSingleshootToggleSlot();
void memoryAllocateSlot();
void memoryFreeSlot();
void contextMenuSlot(const QPoint & pos);
void switchView();
void pageMemoryRights();
@ -61,6 +63,8 @@ private:
QAction* mMemoryExecuteSingleshootToggle;
QAction* mEntropy;
QAction* mFindPattern;
QAction* mMemoryAllocate;
QAction* mMemoryFree;
};
#endif // MEMORYMAPVIEW_H

View File

@ -4,8 +4,8 @@
<context>
<name>AbstractTableView</name>
<message>
<location filename="../Src/BasicView/AbstractTableView.cpp" line="445"/>
<location filename="../Src/BasicView/AbstractTableView.cpp" line="510"/>
<location filename="../Src/BasicView/AbstractTableView.cpp" line="446"/>
<location filename="../Src/BasicView/AbstractTableView.cpp" line="511"/>
<source>Edit columns</source>
<translation></translation>
</message>
@ -4103,17 +4103,17 @@ run</translation>
<message>
<location filename="../Src/Gui/MainWindow.ui" line="776"/>
<source>Trace over until condition</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
<message>
<location filename="../Src/Gui/MainWindow.ui" line="785"/>
<source>Trace into until condition</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
<message>
<location filename="../Src/Gui/MainWindow.cpp" line="60"/>
<source>x32dbg</source>
<translation>x64dbg {32d?}</translation>
<translation>x64dbg (32)</translation>
</message>
<message>
<location filename="../Src/Gui/MainWindow.cpp" line="77"/>
@ -4171,12 +4171,12 @@ run</translation>
<message>
<location filename="../Src/Gui/MainWindow.cpp" line="601"/>
<source>Enter trace into finishing condition.</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
<message>
<location filename="../Src/Gui/MainWindow.cpp" line="611"/>
<source>Enter trace over finishing condition.</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
<message>
<location filename="../Src/Gui/MainWindow.cpp" line="634"/>
@ -4239,139 +4239,196 @@ Make sure to fill in as much information as possible.</source>
<context>
<name>MemoryMapView</name>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="17"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="19"/>
<source>Address</source>
<translation></translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="18"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="20"/>
<source>Size</source>
<translation></translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="19"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="21"/>
<source>Info</source>
<translation></translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="19"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="21"/>
<source>Page Information</source>
<translation></translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="20"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="22"/>
<source>Type</source>
<translation></translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="20"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="22"/>
<source>Allocation Type</source>
<translation></translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="21"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="23"/>
<source>Protection</source>
<translation></translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="21"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="23"/>
<source>Current Protection</source>
<translation></translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="22"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="24"/>
<source>Initial</source>
<translation></translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="22"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="24"/>
<source>Allocation Protection</source>
<translation></translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="36"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="38"/>
<source>&amp;Follow in Dump</source>
<translation>(&amp;F)</translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="40"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="42"/>
<source>Follow in &amp;Disassembler</source>
<translation>(&amp;D)</translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="52"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="54"/>
<source>Set Page Memory Rights</source>
<translation></translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="56"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="58"/>
<source>&amp;Switch View</source>
<translation>(&amp;S)</translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="60"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="62"/>
<source>Memory &amp;Breakpoint</source>
<translation>(&amp;B)</translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="63"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="65"/>
<source>Access</source>
<translation></translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="64"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="74"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="84"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="66"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="76"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="86"/>
<source>&amp;Singleshoot</source>
<translation>(&amp;S)</translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="67"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="77"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="88"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="69"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="79"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="90"/>
<source>&amp;Restore</source>
<translation>(&amp;R)</translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="73"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="75"/>
<source>Write</source>
<translation></translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="83"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="85"/>
<source>Execute</source>
<translation></translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="94"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="96"/>
<source>&amp;Remove</source>
<translation>(&amp;R)</translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="106"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="108"/>
<source>&amp;Allocate memory</source>
<translation>(&amp;A)</translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="113"/>
<source>&amp;Free memory</source>
<translation>(&amp;F)</translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="118"/>
<source>Entropy...</source>
<translation>...</translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="110"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="122"/>
<source>&amp;Find Pattern...</source>
<translation>(&amp;F)...</translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="116"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="128"/>
<source>&amp;Dump Memory to File</source>
<translation>(&amp;D)</translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="147"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="162"/>
<source>&amp;Copy</source>
<translation>(&amp;C)</translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="461"/>
<source>Enter the size of memory to allocate.</source>
<translation></translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="467"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="480"/>
<location filename="../Src/Gui/MemoryMapView.cpp" line="493"/>
<source>Error</source>
<translation></translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="467"/>
<source>The expression &quot;%1&quot; is not valid.</source>
<translation>&quot;%1&quot;</translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="474"/>
<source>Warning</source>
<translation></translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="474"/>
<source>You&apos;re trying to allocate a zero-sized buffer just now.</source>
<translation></translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="480"/>
<source>The size of buffer you&apos;re trying to allocate exceeds 1GB. Please check your expression to ensure nothing is wrong.</source>
<translation>1GB</translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="493"/>
<source>Memory allocation failed!</source>
<translation></translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="510"/>
<source>Find Pattern...</source>
<translation>...</translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="523"/>
<source>All files (*.*)</source>
<translation> (*.*)</translation>
</message>
<message>
<location filename="../Src/Gui/MemoryMapView.cpp" line="523"/>
<source>Save Memory Region</source>
<translation></translation>
</message>
</context>
<context>
<name>NotesManager</name>