diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/modules/DebuggerStaticMappingServicePlugin.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/modules/DebuggerStaticMappingServicePlugin.java index f34be8d5a9..d22dd12a4e 100644 --- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/modules/DebuggerStaticMappingServicePlugin.java +++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/modules/DebuggerStaticMappingServicePlugin.java @@ -15,6 +15,7 @@ */ package ghidra.app.plugin.core.debug.service.modules; +import java.io.FileNotFoundException; import java.net.URL; import java.util.*; import java.util.Map.Entry; @@ -971,6 +972,9 @@ public class DebuggerStaticMappingServicePlugin extends Plugin try { Program program = ProgramURLUtils.openHackedUpGhidraURL(programManager, tool.getProject(), url, ProgramManager.OPEN_VISIBLE); + if (program == null) { + failures.add(new FileNotFoundException(url.toString())); + } result.add(program); } catch (Exception e) { diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/modules/ProgramModuleIndexer.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/modules/ProgramModuleIndexer.java index d1996c38b8..b7d0302d1e 100644 --- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/modules/ProgramModuleIndexer.java +++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/modules/ProgramModuleIndexer.java @@ -373,6 +373,7 @@ public class ProgramModuleIndexer implements DomainFolderChangeAdapter { .stream() .map(m -> ProgramURLUtils.getFileForHackedUpGhidraURL(project, m.getStaticProgramURL())) + .filter(Objects::nonNull) .collect(Collectors.toSet()); Set libraries = DebuggerStaticMappingUtils.collectLibraries(alreadyMapped); alreadyMapped.stream() diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/utils/ProgramURLUtils.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/utils/ProgramURLUtils.java index ea5c0df68d..135cf01d76 100644 --- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/utils/ProgramURLUtils.java +++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/utils/ProgramURLUtils.java @@ -61,11 +61,12 @@ public enum ProgramURLUtils { String asString = ghidraURL.toExternalForm(); int bangLoc = asString.indexOf('!'); if (bangLoc == -1) { - ProjectData projectData = project.getProjectData(ghidraURL); + ProjectData projectData = + project.getProjectData(GhidraURL.getProjectURL(ghidraURL)); if (projectData == null) { return null; } - return projectData.getFile(ghidraURL.getPath()); + return projectData.getFile(GhidraURL.getProjectPathname(ghidraURL)); } URL localProjURL = new URL(asString.substring(0, bangLoc)); ProjectData projectData = project.getProjectData(localProjURL); @@ -84,6 +85,9 @@ public enum ProgramURLUtils { public static Program openHackedUpGhidraURL(ProgramManager programManager, Project project, URL ghidraURL, int state) { DomainFile file = getFileForHackedUpGhidraURL(project, ghidraURL); + if (file == null) { + return null; + } return programManager.openProgram(file, DomainFile.DEFAULT_VERSION, state); } } diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/project/DefaultProject.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/project/DefaultProject.java index 71b72a1790..8e07f60a12 100644 --- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/project/DefaultProject.java +++ b/Ghidra/Framework/Project/src/main/java/ghidra/framework/project/DefaultProject.java @@ -76,8 +76,8 @@ public class DefaultProject implements Project { * * @param projectManager the manager of this project * @param projectLocator location and name of project - * @param repository shared repository associated with the new project. Can - * be null for non-shared projects + * @param repository shared repository associated with the new project. Can be null for + * non-shared projects * @throws IOException if I/O error occurs. * @throws LockException if unable to establish project lock */ @@ -684,7 +684,17 @@ public class DefaultProject implements Project { if (projectLocator.getURL().equals(url)) { return fileMgr; } - return otherViews.get(url); + URL remoteURL = getProjectData().getRootFolder().getSharedProjectURL(); + if (remoteURL != null) { + remoteURL = GhidraURL.getProjectURL(url); + } + if (remoteURL.equals(url)) { + return fileMgr; + } + + synchronized (otherViews) { + return otherViews.get(url); + } } @Override