From c562fbad6703d9f79fc2f9582bd69c8b31cd0605 Mon Sep 17 00:00:00 2001 From: Dan <46821332+nsadeveloper789@users.noreply.github.com> Date: Mon, 14 Aug 2023 13:19:18 -0400 Subject: [PATCH] GP-0: Fix DummyProc.which --- .../java/ghidra/dbg/testutil/DummyProc.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/Ghidra/Debug/Framework-Debugging/src/test/java/ghidra/dbg/testutil/DummyProc.java b/Ghidra/Debug/Framework-Debugging/src/test/java/ghidra/dbg/testutil/DummyProc.java index aca4cb236a..272faf5f16 100644 --- a/Ghidra/Debug/Framework-Debugging/src/test/java/ghidra/dbg/testutil/DummyProc.java +++ b/Ghidra/Debug/Framework-Debugging/src/test/java/ghidra/dbg/testutil/DummyProc.java @@ -35,22 +35,29 @@ public class DummyProc implements AutoCloseable { return Application.getOSFile(cmd).getAbsolutePath(); } catch (Exception e) { + // probably Application is not initialized // just try next strategy } // Try the build/exe// and build/exe/// directory - for (ResourceFile modRoot : Application.getModuleRootDirectories()) { - ResourceFile exe = new ResourceFile(modRoot, "build/exe/" + cmd + "/" + cmd); - if (exe.exists() && exe.getFile(false).canExecute()) { - return exe.getAbsolutePath(); - } - ResourceFile platformExe = new ResourceFile(modRoot, - "build/exe/" + cmd + "/" + Platform.CURRENT_PLATFORM.getDirectoryName() + "/" + - cmd); - if (platformExe.exists() && platformExe.getFile(false).canExecute()) { - return platformExe.getAbsolutePath(); + try { + for (ResourceFile modRoot : Application.getModuleRootDirectories()) { + ResourceFile exe = new ResourceFile(modRoot, "build/exe/" + cmd + "/" + cmd); + if (exe.exists() && exe.getFile(false).canExecute()) { + return exe.getAbsolutePath(); + } + ResourceFile platformExe = new ResourceFile(modRoot, + "build/exe/" + cmd + "/" + Platform.CURRENT_PLATFORM.getDirectoryName() + "/" + + cmd); + if (platformExe.exists() && platformExe.getFile(false).canExecute()) { + return platformExe.getAbsolutePath(); + } } } + catch (Exception e) { + // probably Application is not initialized + // just try next strategy + } // Try the current directory if (new File(cmd).canExecute()) {