Add Endianness Option

This commit is contained in:
Florian Märkl 2018-01-20 11:35:31 +01:00
parent 3af89d5f94
commit f71c21ae10
6 changed files with 76 additions and 3 deletions

View File

@ -92,6 +92,11 @@ void AnalThread::run()
core->loadPDB(ui->pdbLineEdit->text());
}
if (optionsDialog->getSelectedEndianness() != OptionsDialog::Endianness::Auto)
{
core->setEndianness(optionsDialog->getSelectedEndianness() == OptionsDialog::Endianness::Big);
}
// use prj.simple as default as long as regular projects are broken
core->setConfig("prj.simple", true);

View File

@ -559,6 +559,11 @@ void CutterCore::setCPU(QString arch, QString cpu, int bits, bool temporary)
}
}
void CutterCore::setEndianness(bool big)
{
setConfig("cfg.bigendian", big);
}
void CutterCore::setDefaultCPU()
{
if (!default_arch.isEmpty())

View File

@ -283,6 +283,7 @@ public:
QString disassembleSingleInstruction(RVA addr);
void setDefaultCPU();
void setCPU(QString arch, QString cpu, int bits, bool temporary = false);
void setEndianness(bool big);
RAnalFunction *functionAt(ut64 addr);
QString cmdFunctionAt(QString addr);
QString cmdFunctionAt(RVA addr);

View File

@ -120,6 +120,19 @@ int OptionsDialog::getSelectedBits()
return 0;
}
OptionsDialog::Endianness OptionsDialog::getSelectedEndianness()
{
switch(ui->endiannessComboBox->currentIndex())
{
case 1:
return Endianness::Little;
case 2:
return Endianness::Big;
default:
return Endianness::Auto;
}
}
QString OptionsDialog::getSelectedOS()
{
QVariant os = ui->kernelComboBox->currentData();

View File

@ -53,10 +53,14 @@ private:
void setInteractionEnabled(bool enabled);
public:
enum class Endianness { Auto, Little, Big };
std::unique_ptr<Ui::OptionsDialog> ui;
QString getSelectedArch();
QString getSelectedCPU();
int getSelectedBits();
Endianness getSelectedEndianness();
QString getSelectedOS();
QTimer analTimer;
QElapsedTimer analElapsedTimer;

View File

@ -225,9 +225,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>564</width>
<height>805</height>
<y>-611</y>
<width>565</width>
<height>856</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
@ -601,6 +601,13 @@
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="bitsLabel">
<property name="sizePolicy">
@ -643,6 +650,44 @@
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="endiannessLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Endianness: </string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="endiannessComboBox">
<property name="editable">
<bool>false</bool>
</property>
<property name="currentText">
<string notr="true">Auto</string>
</property>
<item>
<property name="text">
<string>Auto</string>
</property>
</item>
<item>
<property name="text">
<string>Little</string>
</property>
</item>
<item>
<property name="text">
<string>Big</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>