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

View File

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

View File

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

View File

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