Rework external editor interface (formerly IDA interface)

1. External editor is supported for sections, not files
2. External editor is not visible when it is unspecified in prefs
This commit is contained in:
vit9696 2018-09-15 19:17:59 +03:00
parent 67fb2a23ee
commit 77d771d452
4 changed files with 58 additions and 61 deletions

View File

@ -39,7 +39,8 @@ version(tr(PROGRAM_VERSION))
connect(ui->actionOpenImageFile, SIGNAL(triggered()), this, SLOT(openImageFile()));
connect(ui->actionOpenImageFileInNewWindow, SIGNAL(triggered()), this, SLOT(openImageFileInNewWindow()));
connect(ui->actionSaveImageFile, SIGNAL(triggered()), this, SLOT(saveImageFile()));
connect(ui->actionSpecifyPathIDA, SIGNAL(triggered()), this, SLOT(specifyPathIDA()));
connect(ui->actionSpecifyPathExternal32, SIGNAL(triggered()), this, SLOT(specifyPathExternalEditor32()));
connect(ui->actionSpecifyPathExternal64, SIGNAL(triggered()), this, SLOT(specifyPathExternalEditor64()));
connect(ui->actionSearch, SIGNAL(triggered()), this, SLOT(search()));
connect(ui->actionHexView, SIGNAL(triggered()), this, SLOT(hexView()));
connect(ui->actionBodyHexView, SIGNAL(triggered()), this, SLOT(bodyHexView()));
@ -53,8 +54,8 @@ version(tr(PROGRAM_VERSION))
connect(ui->actionReplaceBody, SIGNAL(triggered()), this, SLOT(replaceBody()));
connect(ui->actionRemove, SIGNAL(triggered()), this, SLOT(remove()));
connect(ui->actionRebuild, SIGNAL(triggered()), this, SLOT(rebuild()));
connect(ui->actionInspectBodyIDA, SIGNAL(triggered()), this, SLOT(inspectIDA32()));
connect(ui->actionInspectBodyIDA64, SIGNAL(triggered()), this, SLOT(inspectIDA64()));
connect(ui->actionInspectExternal32, SIGNAL(triggered()), this, SLOT(inspectExternalEditor32()));
connect(ui->actionInspectExternal64, SIGNAL(triggered()), this, SLOT(inspectExternalEditor64()));
connect(ui->actionMessagesCopy, SIGNAL(triggered()), this, SLOT(copyMessage()));
connect(ui->actionMessagesCopyAll, SIGNAL(triggered()), this, SLOT(copyAllMessages()));
connect(ui->actionMessagesClear, SIGNAL(triggered()), this, SLOT(clearMessages()));
@ -234,8 +235,8 @@ void UEFITool::populateUi(const UModelIndex &current)
ui->actionExtractBody->setDisabled(model->hasEmptyBody(current));
ui->actionExtractBodyUncompressed->setEnabled(enableExtractBodyUncompressed(current));
ui->actionInspectBodyIDA->setDisabled(model->hasEmptyBody(current));
ui->actionInspectBodyIDA64->setDisabled(model->hasEmptyBody(current));
ui->actionInspectExternal32->setVisible(type == Types::Section && !externalEditorPath32.isEmpty());
ui->actionInspectExternal64->setVisible(type == Types::Section && !externalEditorPath64.isEmpty());
ui->actionRemove->setEnabled(type == Types::Volume || type == Types::File || type == Types::Section);
//ui->actionInsertInto->setEnabled((type == Types::Volume && subtype != Subtypes::UnknownVolume) ||
@ -728,26 +729,26 @@ void UEFITool::extract(const UINT8 mode, UString* pathOut)
}
}
void UEFITool::inspectIDA32()
void UEFITool::inspectExternalEditor32()
{
if(idaPath32.trimmed().isEmpty())
specifyPathIDA32();
if(externalEditorPath32.trimmed().isEmpty())
specifyPathExternalEditor32();
inspect(INSPECT_MODE_IDA32);
inspect(INSPECT_MODE_EXTERNAL32);
}
void UEFITool::inspectIDA64()
void UEFITool::inspectExternalEditor64()
{
if(idaPath64.trimmed().isEmpty())
specifyPathIDA64();
if(externalEditorPath64.trimmed().isEmpty())
specifyPathExternalEditor64();
inspect(INSPECT_MODE_IDA64);
inspect(INSPECT_MODE_EXTERNAL64);
}
void UEFITool::inspect(const UINT8 mode)
{
if((mode == INSPECT_MODE_IDA32 && idaPath32.trimmed().isEmpty()) ||
(mode == INSPECT_MODE_IDA64 && idaPath64.trimmed().isEmpty()))
if((mode == INSPECT_MODE_EXTERNAL32 && externalEditorPath32.trimmed().isEmpty()) ||
(mode == INSPECT_MODE_EXTERNAL64 && externalEditorPath64.trimmed().isEmpty()))
return;
UString filePath;
@ -759,8 +760,8 @@ void UEFITool::inspect(const UINT8 mode)
QStringList arg;
arg << filePath;
if(!QProcess::startDetached(mode == INSPECT_MODE_IDA32 ? idaPath32 : idaPath64, arg)) {
QMessageBox::critical(this, tr("Inspect failed"), tr("Can't start IDA process"), QMessageBox::Ok);
if(!QProcess::startDetached(mode == INSPECT_MODE_EXTERNAL32 ? externalEditorPath32 : externalEditorPath64, arg)) {
QMessageBox::critical(this, tr("Inspect failed"), tr("Can't start external editor process"), QMessageBox::Ok);
return;
}
}
@ -919,41 +920,30 @@ void UEFITool::openImageFile(UString path)
currentPath = path;
}
void UEFITool::specifyPathIDA()
{
specifyPathIDA32();
specifyPathIDA64();
}
void UEFITool::specifyPathIDA32()
void UEFITool::specifyPathExternalEditor32()
{
UString path;
#if defined Q_OS_WIN
path = QFileDialog::getOpenFileName(this, tr("Specify path to ida.exe"), "ida.exe", tr("IDA Pro executable (ida.exe);;All files (*)"));
path = QFileDialog::getOpenFileName(this, tr("Specify path to 32-bit external editor executable"), "C:", tr("External editor executable (*.exe);;All files (*)"));
#else
path = QFileDialog::getOpenFileName(this, tr("Specify path to ida binary"), "ida", tr("IDA Pro executable (ida);;All files (*)"));
path = QFileDialog::getOpenFileName(this, tr("Specify path to 32-bit external editor binary"), "/", tr("All files (*)"));
#endif
if (path.trimmed().isEmpty())
return;
idaPath32 = path;
externalEditorPath32 = path;
}
void UEFITool::specifyPathIDA64()
void UEFITool::specifyPathExternalEditor64()
{
UString path;
#if defined Q_OS_WIN
path = QFileDialog::getOpenFileName(this, tr("Specify path to ida64.exe"), "ida64.exe", tr("IDA Pro 64 executable (ida64.exe);;All files (*)"));
path = QFileDialog::getOpenFileName(this, tr("Specify path to 64-bit external editor executable"), "C:", tr("External editor executable (*.exe);;All files (*)"));
#else
path = QFileDialog::getOpenFileName(this, tr("Specify path to ida64 binary"), "ida64", tr("IDA Pro 64 executable (ida64);;All files (*)"));
path = QFileDialog::getOpenFileName(this, tr("Specify path to 64-bit external editor binary"), "/", tr("All files (*)"));
#endif
if (path.trimmed().isEmpty())
return;
idaPath64 = path;
externalEditorPath64 = path;
}
void UEFITool::enableMessagesCopyActions(QListWidgetItem* item)
@ -1170,9 +1160,9 @@ void UEFITool::readSettings()
markingEnabled = settings.value("tree/markingEnabled", true).toBool();
ui->actionToggleBootGuardMarking->setChecked(markingEnabled);
// Get IDA Path
idaPath32 = settings.value("idaPath32").toString();
idaPath64 = settings.value("idaPath64").toString();
// Get external editor path
externalEditorPath32 = settings.value("externalEditorPath32").toString();
externalEditorPath64 = settings.value("externalEditorPath64").toString();
// Set monospace font for some controls
UString fontName;
@ -1218,8 +1208,8 @@ void UEFITool::writeSettings()
settings.setValue("tree/markingEnabled", markingEnabled);
settings.setValue("mainWindow/fontName", currentFont.family());
settings.setValue("mainWindow/fontSize", currentFont.pointSize());
settings.setValue("idaPath32", idaPath32);
settings.setValue("idaPath64", idaPath64);
settings.setValue("externalEditorPath32", externalEditorPath32);
settings.setValue("externalEditorPath64", externalEditorPath64);
}
void UEFITool::showFitTable()

View File

@ -77,9 +77,8 @@ private slots:
void openImageFileInNewWindow();
void saveImageFile();
void specifyPathIDA();
void specifyPathIDA32();
void specifyPathIDA64();
void specifyPathExternalEditor32();
void specifyPathExternalEditor64();
void search();
void goToOffset();
@ -107,8 +106,8 @@ private slots:
void remove();
void inspectIDA32();
void inspectIDA64();
void inspectExternalEditor32();
void inspectExternalEditor64();
void inspect(const UINT8 mode);
void copyMessage();
@ -147,8 +146,8 @@ private:
QString currentDir;
QString currentPath;
QString currentProgramPath;
QString idaPath32;
QString idaPath64;
QString externalEditorPath32;
QString externalEditorPath64;
QFont currentFont;
const QString version;
bool markingEnabled;

View File

@ -328,7 +328,8 @@
<addaction name="actionLoadDefaultGuidDatabase"/>
<addaction name="actionUnloadGuidDatabase"/>
<addaction name="separator"/>
<addaction name="actionSpecifyPathIDA"/>
<addaction name="actionSpecifyPathExternal32"/>
<addaction name="actionSpecifyPathExternal64"/>
<addaction name="separator"/>
<addaction name="actionQuit"/>
</widget>
@ -426,9 +427,6 @@
<addaction name="actionExtract"/>
<addaction name="actionExtractBody"/>
<addaction name="separator"/>
<addaction name="actionInspectBodyIDA"/>
<addaction name="actionInspectBodyIDA64"/>
<addaction name="separator"/>
<addaction name="actionRebuild"/>
<addaction name="separator"/>
<addaction name="actionInsertInto"/>
@ -449,6 +447,8 @@
</property>
<addaction name="actionHexView"/>
<addaction name="actionBodyHexView"/>
<addaction name="actionInspectExternal32"/>
<addaction name="actionInspectExternal64"/>
<addaction name="separator"/>
<addaction name="actionExtract"/>
<addaction name="actionExtractBody"/>
@ -912,28 +912,36 @@
<string>Ctrl+Alt+D</string>
</property>
</action>
<action name="actionSpecifyPathIDA">
<action name="actionSpecifyPathExternal32">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Specify path to IDA Pro</string>
<string>Specify external editor path (32-bit)</string>
</property>
</action>
<action name="actionInspectBodyIDA">
<action name="actionSpecifyPathExternal64">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Specify external editor path (64-bit)</string>
</property>
</action>
<action name="actionInspectExternal32">
<property name="visible">
<bool>false</bool>
</property>
<property name="text">
<string>Inspect body with IDA</string>
<string>External editor view (32-bit)</string>
</property>
</action>
<action name="actionInspectBodyIDA64">
<property name="enabled">
<action name="actionInspectExternal64">
<property name="visible">
<bool>false</bool>
</property>
<property name="text">
<string>Inspect body with IDA64</string>
<string>External editor view (64-bit)</string>
</property>
</action>
</widget>

View File

@ -138,8 +138,8 @@ typedef ptrdiff_t INTN;
#define EXTRACT_MODE_BODY_UNCOMPRESSED 2
// Item inspect modes
#define INSPECT_MODE_IDA32 0
#define INSPECT_MODE_IDA64 1
#define INSPECT_MODE_EXTERNAL32 0
#define INSPECT_MODE_EXTERNAL64 1
// Item replace modes
#define REPLACE_MODE_AS_IS 0