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,47 +113,49 @@ void AssembleDialog::textChangedSlot(QString text)
void AssembleDialog::instructionChangedSlot(dsint sizeDifference, QString error)
{
if(ui->checkBoxKeepSize->isChecked())
{
// If there was an error
if(error.length())
{
this->setKeepSizeLabel(tr("<font color='orange'><b>Instruction decoding error : %1</b></font>").arg(error));
return;
setKeepSizeLabel(tr("<font color='orange'><b>Instruction encoding error : %1</b></font>").arg(error));
setOkButtonEnabled(false);
}
// No error
else
else if(ui->checkBoxKeepSize->isChecked())
{
// SizeDifference > 0 <=> Typed instruction is bigger
if(sizeDifference > 0)
{
QString message = tr("<font color='red'><b>Instruction bigger by %1 %2</b></font>")
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);
setKeepSizeLabel(message);
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>")
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);
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>");
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);
}
}
@ -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">
@ -46,28 +37,10 @@
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>3</number>
</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 name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QCheckBox" name="checkBoxKeepSize">
@ -78,39 +51,34 @@
</sizepolicy>
</property>
<property name="text">
<string>Keep Size</string>
<string>Keep &amp;Size</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxFillWithNops">
<property name="text">
<string>Fill with NOP's</string>
<string>&amp;Fill with NOP's</string>
</property>
</widget>
</item>
</layout>
<item>
<widget class="QRadioButton" name="radioXEDParse">
<property name="text">
<string>&amp;XEDParse</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<widget class="QRadioButton" name="radioKeystone">
<property name="text">
<string>&amp;Keystone</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>3</number>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
@ -146,8 +114,6 @@
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="labelKeepSize">
<property name="sizePolicy">
@ -170,7 +136,18 @@
</property>
</widget>
</item>
</layout>
<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>