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); ui->setupUi(this);
setModal(true); setModal(true);
setFixedSize(this->size()); //fixed size setFixedSize(size()); //fixed size
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint | Qt::MSWindowsFixedSizeDialogHint); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint | Qt::MSWindowsFixedSizeDialogHint);
mSelectedInstrVa = 0; mSelectedInstrVa = 0;
bKeepSizeChecked = false; bKeepSizeChecked = false;
bFillWithNopsChecked = false; bFillWithNopsChecked = false;
this->setKeepSizeLabel(""); setKeepSizeLabel("");
mValidateThread = new ValidateExpressionThread(this); mValidateThread = new ValidateExpressionThread(this);
mValidateThread->setOnExpressionChangedCallback(std::bind(&AssembleDialog::validateInstruction, this, std::placeholders::_1)); mValidateThread->setOnExpressionChangedCallback(std::bind(&AssembleDialog::validateInstruction, this, std::placeholders::_1));
connect(ui->lineEdit, SIGNAL(textEdited(QString)), this, SLOT(textChangedSlot(QString))); connect(ui->lineEdit, SIGNAL(textEdited(QString)), this, SLOT(textChangedSlot(QString)));
connect(mValidateThread, SIGNAL(instructionChanged(dsint, QString)), this, SLOT(instructionChangedSlot(dsint, 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() AssembleDialog::~AssembleDialog()
@ -34,6 +38,7 @@ void AssembleDialog::setTextEditValue(const QString & text)
{ {
ui->lineEdit->setText(text); ui->lineEdit->setText(text);
ui->lineEdit->selectAll(); ui->lineEdit->selectAll();
validateInstruction(text);
} }
void AssembleDialog::setKeepSizeChecked(bool checked) void AssembleDialog::setKeepSizeChecked(bool checked)
@ -55,7 +60,7 @@ void AssembleDialog::setFillWithNopsChecked(bool checked)
void AssembleDialog::setSelectedInstrVa(const duint va) void AssembleDialog::setSelectedInstrVa(const duint va)
{ {
this->mSelectedInstrVa = va; mSelectedInstrVa = va;
} }
@ -79,7 +84,7 @@ void AssembleDialog::validateInstruction(QString expression)
selectedInstructionSize = basicInstrInfo.size; selectedInstructionSize = basicInstrInfo.size;
// Get typed in instruction 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)); emit mValidateThread->emitInstructionChanged(0, QString(error));
return; return;
@ -107,48 +112,50 @@ void AssembleDialog::textChangedSlot(QString text)
} }
void AssembleDialog::instructionChangedSlot(dsint sizeDifference, QString error) void AssembleDialog::instructionChangedSlot(dsint sizeDifference, QString error)
{
if(ui->checkBoxKeepSize->isChecked())
{ {
// If there was an error // If there was an error
if(error.length()) if(error.length())
{ {
this->setKeepSizeLabel(tr("<font color='orange'><b>Instruction decoding error : %1</b></font>").arg(error)); setKeepSizeLabel(tr("<font color='orange'><b>Instruction encoding error : %1</b></font>").arg(error));
return; setOkButtonEnabled(false);
} }
// No error else if(ui->checkBoxKeepSize->isChecked())
else
{ {
// SizeDifference > 0 <=> Typed instruction is bigger // SizeDifference > 0 <=> Typed instruction is bigger
if(sizeDifference > 0) 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)
.arg(sizeDifference == 1 ? tr("byte") : tr("bytes")); .arg(sizeDifference == 1 ? tr("byte") : tr("bytes"));
this->setKeepSizeLabel(message); setKeepSizeLabel(message);
this->setOkButtonEnabled(false); setOkButtonEnabled(false);
} }
// SizeDifference < 0 <=> Typed instruction is smaller // SizeDifference < 0 <=> Typed instruction is smaller
else if(sizeDifference < 0) 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)
.arg(sizeDifference == -1 ? tr("byte") : tr("bytes")); .arg(sizeDifference == -1 ? tr("byte") : tr("bytes"));
this->setKeepSizeLabel(message); setKeepSizeLabel(message);
this->setOkButtonEnabled(true); setOkButtonEnabled(true);
} }
// SizeDifference == 0 <=> Both instruction have same size // SizeDifference == 0 <=> Both instruction have same size
else 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); setKeepSizeLabel(message);
this->setOkButtonEnabled(true); 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; 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_lineEdit_textChanged(const QString & arg1);
void on_checkBoxKeepSize_clicked(bool checked); void on_checkBoxKeepSize_clicked(bool checked);
void on_checkBoxFillWithNops_clicked(bool checked); void on_checkBoxFillWithNops_clicked(bool checked);
void on_radioXEDParse_clicked();
void on_radioKeystone_clicked();
private: private:
Ui::AssembleDialog* ui; Ui::AssembleDialog* ui;
duint mSelectedInstrVa; duint mSelectedInstrVa;
ValidateExpressionThread* mValidateThread; ValidateExpressionThread* mValidateThread;
}; };
#endif // ASSEMBLEDIALOG_H #endif // ASSEMBLEDIALOG_H

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>481</width> <width>501</width>
<height>84</height> <height>85</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -17,18 +17,9 @@
<iconset resource="../../resource.qrc"> <iconset resource="../../resource.qrc">
<normaloff>:/icons/images/ui-combo-box-edit.png</normaloff>:/icons/images/ui-combo-box-edit.png</iconset> <normaloff>:/icons/images/ui-combo-box-edit.png</normaloff>:/icons/images/ui-combo-box-edit.png</iconset>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>4</number>
</property>
<property name="leftMargin">
<number>8</number>
</property>
<property name="rightMargin">
<number>8</number>
</property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>6</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QLineEdit" name="lineEdit"> <widget class="QLineEdit" name="lineEdit">
@ -46,28 +37,10 @@
</property> </property>
</widget> </widget>
</item> </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> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing"> <property name="sizeConstraint">
<number>3</number> <enum>QLayout::SetDefaultConstraint</enum>
</property> </property>
<item> <item>
<widget class="QCheckBox" name="checkBoxKeepSize"> <widget class="QCheckBox" name="checkBoxKeepSize">
@ -78,39 +51,34 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Keep Size</string> <string>Keep &amp;Size</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="checkBoxFillWithNops"> <widget class="QCheckBox" name="checkBoxFillWithNops">
<property name="text"> <property name="text">
<string>Fill with NOP's</string> <string>&amp;Fill with NOP's</string>
</property> </property>
</widget> </widget>
</item> </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>
<item> <item>
<spacer name="verticalSpacer"> <widget class="QRadioButton" name="radioKeystone">
<property name="orientation"> <property name="text">
<enum>Qt::Vertical</enum> <string>&amp;Keystone</string>
</property> </property>
<property name="sizeHint" stdset="0"> </widget>
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item> </item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>3</number>
</property>
<item> <item>
<spacer name="horizontalSpacer"> <spacer name="horizontalSpacer">
<property name="orientation"> <property name="orientation">
@ -146,8 +114,6 @@
</item> </item>
</layout> </layout>
</item> </item>
</layout>
</item>
<item> <item>
<widget class="QLabel" name="labelKeepSize"> <widget class="QLabel" name="labelKeepSize">
<property name="sizePolicy"> <property name="sizePolicy">
@ -170,7 +136,18 @@
</property> </property>
</widget> </widget>
</item> </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> </item>
</layout> </layout>
</widget> </widget>