mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-19 03:16:10 +00:00
Clean up Hexdump sidebar a bit more #121
This commit is contained in:
parent
4f1007a0cb
commit
40a3928ab6
@ -78,7 +78,7 @@ HexdumpWidget::HexdumpWidget(QWidget *parent, Qt::WindowFlags flags) :
|
||||
refresh(Core()->getOffset());
|
||||
});
|
||||
|
||||
fillPlugins();
|
||||
initParsing();
|
||||
selectHexPreview();
|
||||
}
|
||||
|
||||
@ -476,10 +476,12 @@ void HexdumpWidget::updateHeaders()
|
||||
* Content management functions
|
||||
*/
|
||||
|
||||
void HexdumpWidget::fillPlugins()
|
||||
void HexdumpWidget::initParsing()
|
||||
{
|
||||
// Fill the plugins combo for the hexdump sidebar
|
||||
ui->hexArchComboBox_2->insertItems(0, Core()->getAsmPluginNames());
|
||||
ui->parseArchComboBox->insertItems(0, Core()->getAsmPluginNames());
|
||||
|
||||
ui->parseEndianComboBox->setCurrentIndex(Core()->getConfigb("cfg.bigendian") ? 1 : 0);
|
||||
}
|
||||
|
||||
std::array<QString, 3> HexdumpWidget::fetchHexdump(RVA offset, RVA bytes)
|
||||
@ -555,14 +557,11 @@ void HexdumpWidget::adjustHexdumpLines()
|
||||
|
||||
void HexdumpWidget::on_hexHexText_selectionChanged()
|
||||
{
|
||||
// Get selected partsing type
|
||||
QString parsing = ui->codeCombo_2->currentText();
|
||||
// Get selected text
|
||||
QTextCursor cursor(ui->hexHexText->textCursor());
|
||||
QString sel_text = cursor.selectedText();
|
||||
|
||||
sel_text = sel_text.simplified().remove(" ");
|
||||
//eprintf ("-- (((%s))) --\n", sel_text.toUtf8().constData());
|
||||
sel_text = sel_text.simplified().remove(' ');
|
||||
|
||||
if (sel_text == "")
|
||||
{
|
||||
@ -570,81 +569,82 @@ void HexdumpWidget::on_hexHexText_selectionChanged()
|
||||
ui->bytesEntropy->setText("");
|
||||
ui->bytesMD5->setText("");
|
||||
ui->bytesSHA1->setText("");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (parsing == "Dissasembly")
|
||||
|
||||
// Get selected combos
|
||||
QString arch = ui->parseArchComboBox->currentText();
|
||||
QString bits = ui->parseBitsComboBox->currentText();
|
||||
bool bigEndian = ui->parseEndianComboBox->currentIndex() == 1;
|
||||
|
||||
{ // scope for TempConfig
|
||||
TempConfig tempConfig;
|
||||
tempConfig
|
||||
.set("asm.arch", arch)
|
||||
.set("asm.bits", bits)
|
||||
.set("cfg.bigendian", bigEndian);
|
||||
|
||||
switch(ui->parseTypeComboBox->currentIndex())
|
||||
{
|
||||
QString dText = QString(sel_text);
|
||||
dText.replace(" ", "");
|
||||
if (dText.length() % 2 != 0) {
|
||||
return;
|
||||
case 0: // Disassembly
|
||||
{
|
||||
QStringRef disasBytes = sel_text.leftRef((sel_text.length() / 2) * 2);
|
||||
QString str = "";
|
||||
if (disasBytes.length() > 0)
|
||||
{
|
||||
QString cmd = "pad ";
|
||||
str = Core()->cmd(cmd.append(disasBytes));
|
||||
}
|
||||
ui->hexDisasTextEdit->setPlainText(str);
|
||||
}
|
||||
// Get selected combos
|
||||
QString arch = ui->hexArchComboBox_2->currentText();
|
||||
QString bits = ui->hexBitsComboBox_2->currentText();
|
||||
|
||||
QString oarch = Core()->getConfig("asm.arch");
|
||||
QString obits = Core()->getConfig("asm.bits");
|
||||
|
||||
Core()->setConfig("asm.arch", arch);
|
||||
Core()->setConfig("asm.bits", bits);
|
||||
QString str = Core()->cmd("pad " + dText);
|
||||
ui->hexDisasTextEdit->setPlainText(str);
|
||||
Core()->setConfig("asm.arch", oarch);
|
||||
Core()->setConfig("asm.bits", obits);
|
||||
//qDebug() << "Selected Arch: " << arch;
|
||||
//qDebug() << "Selected Bits: " << bits;
|
||||
//qDebug() << "Selected Text: " << sel_text;
|
||||
break;
|
||||
case 1: // String
|
||||
ui->hexDisasTextEdit->setPlainText(Core()->cmd("pcs@x:" + sel_text));
|
||||
break;
|
||||
case 2: // Assembler
|
||||
ui->hexDisasTextEdit->setPlainText(Core()->cmd("pca@x:" + sel_text));
|
||||
break;
|
||||
case 3: // C byte array
|
||||
ui->hexDisasTextEdit->setPlainText(Core()->cmd("pc@x:" + sel_text));
|
||||
break;
|
||||
case 4: // C half-word
|
||||
ui->hexDisasTextEdit->setPlainText(Core()->cmd("pch@x:" + sel_text));
|
||||
break;
|
||||
case 5: // C word
|
||||
ui->hexDisasTextEdit->setPlainText(Core()->cmd("pcw@x:" + sel_text));
|
||||
break;
|
||||
case 6: // C dword
|
||||
ui->hexDisasTextEdit->setPlainText(Core()->cmd("pcd@x:" + sel_text));
|
||||
break;
|
||||
case 7: // Python
|
||||
ui->hexDisasTextEdit->setPlainText(Core()->cmd("pcp@x:" + sel_text));
|
||||
break;
|
||||
case 8: // JSON
|
||||
ui->hexDisasTextEdit->setPlainText(Core()->cmd("pcj@x:" + sel_text));
|
||||
break;
|
||||
case 9: // JavaScript
|
||||
ui->hexDisasTextEdit->setPlainText(Core()->cmd("pcJ@x:" + sel_text));
|
||||
break;
|
||||
default:
|
||||
ui->hexDisasTextEdit->setPlainText("");
|
||||
}
|
||||
// TODO: update on selection changes.. use cmd("pc "+len+"@"+off)
|
||||
else if (parsing == "C byte array")
|
||||
{
|
||||
ui->hexDisasTextEdit->setPlainText(Core()->cmd("pc@x:" + sel_text));
|
||||
}
|
||||
else if (parsing == "C dword array")
|
||||
{
|
||||
ui->hexDisasTextEdit->setPlainText(Core()->cmd("pcw@x:" + sel_text));
|
||||
}
|
||||
else if (parsing == "C qword array")
|
||||
{
|
||||
ui->hexDisasTextEdit->setPlainText(Core()->cmd("pcq@x:" + sel_text));
|
||||
}
|
||||
else if (parsing == "Assembler")
|
||||
{
|
||||
ui->hexDisasTextEdit->setPlainText(Core()->cmd("pca@x:" + sel_text));
|
||||
}
|
||||
else if (parsing == "String")
|
||||
{
|
||||
ui->hexDisasTextEdit->setPlainText(Core()->cmd("pcs@x:" + sel_text));
|
||||
}
|
||||
else if (parsing == "JSON")
|
||||
{
|
||||
ui->hexDisasTextEdit->setPlainText(Core()->cmd("pcj@x:" + sel_text));
|
||||
}
|
||||
else if (parsing == "Javascript")
|
||||
{
|
||||
ui->hexDisasTextEdit->setPlainText(Core()->cmd("pcJ@x:" + sel_text));
|
||||
}
|
||||
else if (parsing == "Python")
|
||||
{
|
||||
ui->hexDisasTextEdit->setPlainText(Core()->cmd("pcp@x:" + sel_text));
|
||||
}
|
||||
|
||||
// Fill the information tab hashes and entropy
|
||||
ui->bytesMD5->setText(Core()->cmd("ph md5@x:" + sel_text).trimmed());
|
||||
ui->bytesSHA1->setText(Core()->cmd("ph sha1@x:" + sel_text).trimmed());
|
||||
ui->bytesEntropy->setText(Core()->cmd("ph entropy@x:" + sel_text).trimmed());
|
||||
ui->bytesMD5->setCursorPosition(0);
|
||||
ui->bytesSHA1->setCursorPosition(0);
|
||||
}
|
||||
|
||||
// Fill the information tab hashes and entropy
|
||||
ui->bytesMD5->setText(Core()->cmd("ph md5@x:" + sel_text).trimmed());
|
||||
ui->bytesSHA1->setText(Core()->cmd("ph sha1@x:" + sel_text).trimmed());
|
||||
ui->bytesEntropy->setText(Core()->cmd("ph entropy@x:" + sel_text).trimmed());
|
||||
ui->bytesMD5->setCursorPosition(0);
|
||||
ui->bytesSHA1->setCursorPosition(0);
|
||||
|
||||
}
|
||||
|
||||
void HexdumpWidget::on_hexArchComboBox_2_currentTextChanged(const QString &/*arg1*/)
|
||||
void HexdumpWidget::on_parseArchComboBox_currentTextChanged(const QString &/*arg1*/)
|
||||
{
|
||||
on_hexHexText_selectionChanged();
|
||||
}
|
||||
void HexdumpWidget::on_hexBitsComboBox_2_currentTextChanged(const QString &/*arg1*/)
|
||||
|
||||
void HexdumpWidget::on_parseBitsComboBox_currentTextChanged(const QString &/*arg1*/)
|
||||
{
|
||||
on_hexHexText_selectionChanged();
|
||||
}
|
||||
@ -808,9 +808,9 @@ void HexdumpWidget::on_action1column_triggered()
|
||||
refresh();
|
||||
}
|
||||
|
||||
void HexdumpWidget::on_codeCombo_2_currentTextChanged(const QString &arg1)
|
||||
void HexdumpWidget::on_parseTypeComboBox_currentTextChanged(const QString &arg1)
|
||||
{
|
||||
if (arg1 == "Dissasembly")
|
||||
if (ui->parseTypeComboBox->currentIndex() == 0)
|
||||
{
|
||||
ui->hexSideFrame_2->show();
|
||||
}
|
||||
@ -821,6 +821,11 @@ void HexdumpWidget::on_codeCombo_2_currentTextChanged(const QString &arg1)
|
||||
on_hexHexText_selectionChanged();
|
||||
}
|
||||
|
||||
void HexdumpWidget::on_parseEndianComboBox_currentTextChanged(const QString &arg1)
|
||||
{
|
||||
on_hexHexText_selectionChanged();
|
||||
}
|
||||
|
||||
QString HexdumpWidget::normalize_addr(QString addr)
|
||||
{
|
||||
QString base = Core()->cmd("s").split("0x")[1].trimmed();
|
||||
@ -949,15 +954,15 @@ void HexdumpWidget::selectHexPreview()
|
||||
QString bits = Core()->cmd("e asm.bits").trimmed();
|
||||
|
||||
//int arch_index = ui->hexArchComboBox_2->findText(arch);
|
||||
if (ui->hexArchComboBox_2->findText(arch) != -1)
|
||||
if (ui->parseArchComboBox->findText(arch) != -1)
|
||||
{
|
||||
ui->hexArchComboBox_2->setCurrentIndex(ui->hexArchComboBox_2->findText(arch));
|
||||
ui->parseArchComboBox->setCurrentIndex(ui->parseArchComboBox->findText(arch));
|
||||
}
|
||||
|
||||
//int bits_index = ui->hexBitsComboBox_2->findText(bits);
|
||||
if (ui->hexBitsComboBox_2->findText(bits) != -1)
|
||||
if (ui->parseBitsComboBox->findText(bits) != -1)
|
||||
{
|
||||
ui->hexBitsComboBox_2->setCurrentIndex(ui->hexBitsComboBox_2->findText(bits));
|
||||
ui->parseBitsComboBox->setCurrentIndex(ui->parseBitsComboBox->findText(bits));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
// void fontChanged(QFont font);
|
||||
|
||||
public slots:
|
||||
void fillPlugins();
|
||||
void initParsing();
|
||||
|
||||
QString normalize_addr(QString addr);
|
||||
|
||||
@ -90,8 +90,11 @@ private slots:
|
||||
void showHexASCIIContextMenu(const QPoint &pt);
|
||||
|
||||
void on_hexHexText_selectionChanged();
|
||||
void on_hexArchComboBox_2_currentTextChanged(const QString &arg1);
|
||||
void on_hexBitsComboBox_2_currentTextChanged(const QString &arg1);
|
||||
|
||||
void on_parseArchComboBox_currentTextChanged(const QString &arg1);
|
||||
void on_parseBitsComboBox_currentTextChanged(const QString &arg1);
|
||||
void on_parseTypeComboBox_currentTextChanged(const QString &arg1);
|
||||
void on_parseEndianComboBox_currentTextChanged(const QString &arg1);
|
||||
|
||||
void on_action1column_triggered();
|
||||
void on_action2columns_triggered();
|
||||
@ -106,7 +109,6 @@ private slots:
|
||||
void fontsUpdated();
|
||||
void colorsUpdatedSlot();
|
||||
|
||||
void on_codeCombo_2_currentTextChanged(const QString &arg1);
|
||||
void on_hexSideTab_2_currentChanged(int index);
|
||||
void on_memSideToolButton_clicked();
|
||||
void on_copyMD5_clicked();
|
||||
|
@ -361,7 +361,7 @@ QToolTip {
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QComboBox" name="codeCombo_2">
|
||||
<widget class="QComboBox" name="parseTypeComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
@ -369,11 +369,11 @@ QToolTip {
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string>Dissasembly</string>
|
||||
<string>Disassembly</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Dissasembly</string>
|
||||
<string>Disassembly</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
@ -388,17 +388,22 @@ QToolTip {
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>C byte array</string>
|
||||
<string>C bytes</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>C dword array</string>
|
||||
<string>C half-words (2 byte)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>C qword array</string>
|
||||
<string>C words (4 byte)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>C dwords (8 byte)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
@ -413,7 +418,7 @@ QToolTip {
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Javascript</string>
|
||||
<string>JavaScript</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
@ -432,7 +437,7 @@ QToolTip {
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_2">
|
||||
<widget class="QComboBox" name="parseEndianComboBox">
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
|
||||
</property>
|
||||
@ -503,7 +508,7 @@ QToolTip {
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="hexArchComboBox_2">
|
||||
<widget class="QComboBox" name="parseArchComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
@ -532,7 +537,7 @@ QToolTip {
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="hexBitsComboBox_2">
|
||||
<widget class="QComboBox" name="parseBitsComboBox">
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
|
||||
</property>
|
||||
@ -654,36 +659,6 @@ QToolTip {
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>SHA1:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Entropy:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="bytesEntropy">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frame">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||
<property name="spacing">
|
||||
@ -758,6 +733,13 @@ QToolTip {
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>SHA1:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||
<property name="spacing">
|
||||
@ -832,14 +814,43 @@ QToolTip {
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Entropy:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="bytesEntropy">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frame">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_22">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</layout>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
Loading…
Reference in New Issue
Block a user