diff --git a/.gitmodules b/.gitmodules index 5389fd4..f049b05 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "binexport"] path = binexport - url = https://github.com/google/binexport.git + url = https://github.com/abd3lraouf-studios/binexport-ghidra-12.git diff --git a/binexport b/binexport index 17c4363..1f8511e 160000 --- a/binexport +++ b/binexport @@ -1 +1 @@ -Subproject commit 17c4363b7d2ece44161a0ebced60f4e66d309af8 +Subproject commit 1f8511e7dc9f4c194b5d730ba7b3ebfd9d5c9aa5 diff --git a/src/main/java/bindiffhelper/BinDiffHelperPlugin.java b/src/main/java/bindiffhelper/BinDiffHelperPlugin.java index 41813d7..2cba868 100644 --- a/src/main/java/bindiffhelper/BinDiffHelperPlugin.java +++ b/src/main/java/bindiffhelper/BinDiffHelperPlugin.java @@ -105,13 +105,16 @@ public BinDiffHelperPlugin(PluginTool tool) { } - if (System.getProperty("os.name").toLowerCase().contains("win")) { + String os = System.getProperty("os.name").toLowerCase(); + if (os.contains("win")) { defaultBinPath = "C:\\Program Files\\BinDiff\\bin\\bindiff.exe"; defaultDiffCommand = "notepad++ -multiInst -nosession -lc -pluginMessage=compare \"$file1\" \"$file2\""; - } - if (System.getProperty("os.name").toLowerCase().contains("nix")) { - // defaultBinPath = "/opt/bindiff/bin/bindiff"; - defaultDiffCommand = "x-terminal-emulator -e 'diff -u \"$file1\" \"$file2\"'"; + } else if (os.contains("mac")) { + defaultBinPath = "/Applications/BinDiff/BinDiff.app/Contents/MacOS/bin/bindiff"; + defaultDiffCommand = "opendiff \"$file1\" \"$file2\""; + } else { // Linux/BSD + defaultBinPath = "/opt/bindiff/bin/bindiff"; + defaultDiffCommand = "meld \"$file1\" \"$file2\""; } binDiffBinary = Preferences.getProperty(BDBINPROPERTY, defaultBinPath); @@ -311,7 +314,7 @@ public void updateEnableNamespace(boolean enable) public void updateDiffCommand(String cmd) { - diffCommand = cmd == null || cmd.isEmpty() ? defaultDiffCommand : cmd; + diffCommand = cmd == null || cmd.isBlank() ? defaultDiffCommand : cmd; Preferences.setProperty(DIFFCOMMAND, cmd); } diff --git a/src/main/java/bindiffhelper/BinDiffHelperProvider.java b/src/main/java/bindiffhelper/BinDiffHelperProvider.java index 95f5a85..485e53d 100644 --- a/src/main/java/bindiffhelper/BinDiffHelperProvider.java +++ b/src/main/java/bindiffhelper/BinDiffHelperProvider.java @@ -447,7 +447,14 @@ public void mousePressed(MouseEvent e) { String command = plugin.diffCommand.replace("$file1", path1.toString()).replace("$file2", path2.toString()); - Runtime.getRuntime().exec(command); + + if (System.getProperty("os.name").toLowerCase().contains("win")) { + String[] shellCommand = { "cmd.exe", "/c", command }; + Runtime.getRuntime().exec(shellCommand); + } else { + String[] shellCommand = { "/bin/sh", "-c", command }; + Runtime.getRuntime().exec(shellCommand); + } } catch (Exception ex) { Msg.showError(this, getComponent(), "Error", ex.getMessage()); } diff --git a/src/main/java/bindiffhelper/DiffWizard.java b/src/main/java/bindiffhelper/DiffWizard.java index 970949f..ef0792c 100644 --- a/src/main/java/bindiffhelper/DiffWizard.java +++ b/src/main/java/bindiffhelper/DiffWizard.java @@ -346,17 +346,13 @@ public boolean isValid() { if (tp == null || tp.getSelectedItemCount() != 1) return false; - if (tp.getSelectedDomainFolder() != null) - return false; - var df = tp.getSelectedDomainFile(); return df != null; } @Override public boolean canFinish(DiffWizardData data) { - // TODO Auto-generated method stub - return false; + return isValid(); } @Override @@ -408,28 +404,31 @@ public void initialize(DiffWizardData data) { this.panel.add(cb); this.panel.add(tp); + cb.addActionListener(e -> notifyStatusChanged()); + tp.addTreeSelectionListener(new GTreeSelectionListener() { + @Override + public void valueChanged(GTreeSelectionEvent e) { + notifyStatusChanged(); + } + }); } @Override public boolean isValid() { - if (!cb.isSelected()) + if (cb == null || !cb.isSelected()) return true; if (tp == null || tp.getSelectedItemCount() != 1) return false; - if (tp.getSelectedDomainFolder() != null) - return false; - var df = tp.getSelectedDomainFile(); return df != null; } @Override public boolean canFinish(DiffWizardData data) { - // TODO Auto-generated method stub - return false; + return isValid(); } @Override @@ -439,7 +438,7 @@ public void populateData(DiffWizardData data) { @Override public boolean apply(DiffWizardData data) { - if (cb.isSelected()) { + if (data.useProgram2) { try { data.program2Df = tp.getSelectedDomainFile(); Tool newTool = plugin.getTool().getToolServices().launchDefaultTool(Collections.singletonList(data.program2Df)); @@ -458,7 +457,7 @@ public boolean apply(DiffWizardData data) { public JComponent getComponent() { return this.panel; } - + @Override public boolean isApplicable(DiffWizardData data) { return !data.isFromProject;