1
0
Fork 0

GUI: updated AssembleDialog for Keystone support

This commit is contained in:
mrexodia 2016-06-11 19:54:15 +02:00
parent 5c10c9591d
commit 2930e88f55
No known key found for this signature in database
GPG Key ID: D72F9A4FAA0073B4
3 changed files with 156 additions and 157 deletions

View File

@ -10,19 +10,23 @@ AssembleDialog::AssembleDialog(QWidget* parent) :
{
ui->setupUi(this);
setModal(true);
setFixedSize(this->size()); //fixed size
setFixedSize(size()); //fixed size
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint | Qt::MSWindowsFixedSizeDialogHint);
mSelectedInstrVa = 0;
bKeepSizeChecked = false;
bFillWithNopsChecked = false;
this->setKeepSizeLabel("");
setKeepSizeLabel("");
mValidateThread = new ValidateExpressionThread(this);
mValidateThread->setOnExpressionChangedCallback(std::bind(&AssembleDialog::validateInstruction, this, std::placeholders::_1));
connect(ui->lineEdit, SIGNAL(textEdited(QString)), this, SLOT(textChangedSlot(QString)));
connect(mValidateThread, SIGNAL(instructionChanged(dsint, QString)), this, SLOT(instructionChangedSlot(dsint, QString)));
duint setting;
if(BridgeSettingGetUint("Engine", "Assembler", &setting) && setting == 1)
ui->radioKeystone->setChecked(true);
}
AssembleDialog::~AssembleDialog()
@ -34,6 +38,7 @@ void AssembleDialog::setTextEditValue(const QString & text)
{
ui->lineEdit->setText(text);
ui->lineEdit->selectAll();
validateInstruction(text);
}
void AssembleDialog::setKeepSizeChecked(bool checked)
@ -55,7 +60,7 @@ void AssembleDialog::setFillWithNopsChecked(bool checked)
void AssembleDialog::setSelectedInstrVa(const duint va)
{
this->mSelectedInstrVa = va;
mSelectedInstrVa = va;
}
@ -79,7 +84,7 @@ void AssembleDialog::validateInstruction(QString expression)
selectedInstructionSize = basicInstrInfo.size;
// Get typed in instruction size
if(!DbgFunctions()->Assemble(this->mSelectedInstrVa, NULL, &typedInstructionSize, editText.toUtf8().constData(), error.data()) || selectedInstructionSize == 0)
if(!DbgFunctions()->Assemble(mSelectedInstrVa, NULL, &typedInstructionSize, editText.toUtf8().constData(), error.data()) || selectedInstructionSize == 0)
{
emit mValidateThread->emitInstructionChanged(0, QString(error));
return;
@ -108,48 +113,50 @@ void AssembleDialog::textChangedSlot(QString text)
void AssembleDialog::instructionChangedSlot(dsint sizeDifference, QString error)
{
if(ui->checkBoxKeepSize->isChecked())
// If there was an error
if(error.length())
{
// If there was an error
if(error.length())
setKeepSizeLabel(tr("<font color='orange'><b>Instruction encoding error : %1</b></font>").arg(error));
setOkButtonEnabled(false);
}
else if(ui->checkBoxKeepSize->isChecked())
{
// SizeDifference > 0 <=> Typed instruction is bigger
if(sizeDifference > 0)
{
this->setKeepSizeLabel(tr("<font color='orange'><b>Instruction decoding error : %1</b></font>").arg(error));
return;
QString message = tr("<font color='red'><b>Instruction bigger by %1 %2...</b></font>")
.arg(sizeDifference)
.arg(sizeDifference == 1 ? tr("byte") : tr("bytes"));
setKeepSizeLabel(message);
setOkButtonEnabled(false);
}
// No error
// SizeDifference < 0 <=> Typed instruction is smaller
else if(sizeDifference < 0)
{
QString message = tr("<font color='#00cc00'><b>Instruction smaller by %1 %2...</b></font>")
.arg(-sizeDifference)
.arg(sizeDifference == -1 ? tr("byte") : tr("bytes"));
setKeepSizeLabel(message);
setOkButtonEnabled(true);
}
// SizeDifference == 0 <=> Both instruction have same size
else
{
QString message = tr("<font color='#00cc00'><b>Instruction is same size!</b></font>");
// SizeDifference > 0 <=> Typed instruction is bigger
if(sizeDifference > 0)
{
QString message = tr("<font color='red'><b>Instruction bigger by %1 %2</b></font>")
.arg(sizeDifference)
.arg(sizeDifference == 1 ? tr("byte") : tr("bytes"));
this->setKeepSizeLabel(message);
this->setOkButtonEnabled(false);
}
// SizeDifference < 0 <=> Typed instruction is smaller
else if(sizeDifference < 0)
{
QString message = tr("<font color='#00cc00'><b>Instruction smaller by %1 %2</b></font>")
.arg(-sizeDifference)
.arg(sizeDifference == -1 ? tr("byte") : tr("bytes"));
this->setKeepSizeLabel(message);
this->setOkButtonEnabled(true);
}
// SizeDifference == 0 <=> Both instruction have same size
else
{
QString message = tr("<font color='#00cc00'><b>Instruction is same size</b></font>");
this->setKeepSizeLabel(message);
this->setOkButtonEnabled(true);
}
setKeepSizeLabel(message);
setOkButtonEnabled(true);
}
}
else
{
QString message = tr("<font color='#00cc00'><b>Instruction encoded successfully!</b></font>");
setKeepSizeLabel(message);
setOkButtonEnabled(true);
}
}
void AssembleDialog::on_lineEdit_textChanged(const QString & arg1)
@ -181,3 +188,17 @@ void AssembleDialog::on_checkBoxFillWithNops_clicked(bool checked)
{
bFillWithNopsChecked = checked;
}
void AssembleDialog::on_radioXEDParse_clicked()
{
BridgeSettingSetUint("Engine", "Assembler", 0);
DbgSettingsUpdated();
validateInstruction(ui->lineEdit->text());
}
void AssembleDialog::on_radioKeystone_clicked()
{
BridgeSettingSetUint("Engine", "Assembler", 1);
DbgSettingsUpdated();
validateInstruction(ui->lineEdit->text());
}

View File

@ -41,12 +41,13 @@ private slots:
void on_lineEdit_textChanged(const QString & arg1);
void on_checkBoxKeepSize_clicked(bool checked);
void on_checkBoxFillWithNops_clicked(bool checked);
void on_radioXEDParse_clicked();
void on_radioKeystone_clicked();
private:
Ui::AssembleDialog* ui;
duint mSelectedInstrVa;
ValidateExpressionThread* mValidateThread;
};
#endif // ASSEMBLEDIALOG_H

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>481</width>
<height>84</height>
<width>501</width>
<height>85</height>
</rect>
</property>
<property name="windowTitle">
@ -17,18 +17,9 @@
<iconset resource="../../resource.qrc">
<normaloff>:/icons/images/ui-combo-box-edit.png</normaloff>:/icons/images/ui-combo-box-edit.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>4</number>
</property>
<property name="leftMargin">
<number>8</number>
</property>
<property name="rightMargin">
<number>8</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="bottomMargin">
<number>6</number>
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="lineEdit">
@ -47,115 +38,62 @@
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>3</number>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>3</number>
</property>
<item>
<widget class="QCheckBox" name="checkBoxKeepSize">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Keep Size</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxFillWithNops">
<property name="text">
<string>Fill with NOP's</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>3</number>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButtonOk">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonCancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="labelKeepSize">
<widget class="QCheckBox" name="checkBoxKeepSize">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<sizepolicy hsizetype="Fixed" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Keep &amp;Size</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxFillWithNops">
<property name="text">
<string>&amp;Fill with NOP's</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioXEDParse">
<property name="text">
<string>&amp;XEDParse</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioKeystone">
<property name="text">
<string>&amp;Keystone</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButtonOk">
<property name="minimumSize">
<size>
<width>0</width>
@ -163,15 +101,54 @@
</size>
</property>
<property name="text">
<string>&lt;font color='orange'&gt;&lt;b&gt;Instruction decoding error&lt;/b&gt;&lt;/font&gt;</string>
<string>OK</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonCancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="labelKeepSize">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>&lt;font color='orange'&gt;&lt;b&gt;Instruction decoding error&lt;/b&gt;&lt;/font&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources>