From 67a2f8880326aa0cba411f8c837e080b743642b7 Mon Sep 17 00:00:00 2001 From: Ryan Kurtz Date: Tue, 27 Aug 2024 11:11:53 -0400 Subject: [PATCH] GP-3490: GhidraDev run config fixes --- .../utils/GhidraLaunchUtils.java | 21 +++++++++++++------ .../utils/GhidraModuleUtils.java | 2 +- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/src/main/java/ghidradev/ghidraprojectcreator/utils/GhidraLaunchUtils.java b/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/src/main/java/ghidradev/ghidraprojectcreator/utils/GhidraLaunchUtils.java index e70f7c7a60..73791e259e 100644 --- a/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/src/main/java/ghidradev/ghidraprojectcreator/utils/GhidraLaunchUtils.java +++ b/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/src/main/java/ghidradev/ghidraprojectcreator/utils/GhidraLaunchUtils.java @@ -29,7 +29,7 @@ import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.launching.*; -import ghidra.GhidraLauncher; +import ghidra.Ghidra; /** * Utility methods for working with Ghidra launchers in Eclipse. @@ -134,10 +134,7 @@ public class GhidraLaunchUtils { /** * Sets the main type name attribute in the provided working copy. For Ghidra projects, this - * should be {@link GhidraLauncher}. - *

- * TODO: {@link GhidraLauncher#main(String[])} is deprecated. Fix in future version of - * GhidraDev when we are ready to break backwards compatibility with Ghidra. + * should be {@link Ghidra}. * * @param wc The launch configuration working copy to modify. * @return The modified working copy. @@ -145,7 +142,7 @@ public class GhidraLaunchUtils { public static ILaunchConfigurationWorkingCopy setMainTypeName( ILaunchConfigurationWorkingCopy wc) { wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, - GhidraLauncher.class.getName()); + Ghidra.class.getName()); return wc; } @@ -216,6 +213,18 @@ public class GhidraLaunchUtils { List newList = new ArrayList<>(); IJavaProject javaProject = JavaRuntime.getJavaProject(wc); if (javaProject != null) { + + // Add current project (might need to add dependent projects later) + newList.add(JavaRuntime.newProjectRuntimeClasspathEntry(javaProject).getMemento()); + + // Add JDK + newList.add(JavaRuntime + .newRuntimeContainerClasspathEntry( + JavaRuntime.newJREContainerPath(JavaRuntime.getVMInstall(javaProject)), + IRuntimeClasspathEntry.STANDARD_CLASSES) + .getMemento()); + + // Add Ghidra jar source for (IClasspathEntry entry : javaProject.getRawClasspath()) { IPath sourcePath = entry.getSourceAttachmentPath(); if (sourcePath != null) { diff --git a/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/src/main/java/ghidradev/ghidraprojectcreator/utils/GhidraModuleUtils.java b/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/src/main/java/ghidradev/ghidraprojectcreator/utils/GhidraModuleUtils.java index 5a83376d9c..f4d93a2297 100644 --- a/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/src/main/java/ghidradev/ghidraprojectcreator/utils/GhidraModuleUtils.java +++ b/GhidraBuild/EclipsePlugins/GhidraDev/GhidraDevPlugin/src/main/java/ghidradev/ghidraprojectcreator/utils/GhidraModuleUtils.java @@ -110,7 +110,7 @@ public class GhidraModuleUtils { sourceFolderInfos.add(new SourceFolderInfo(project.getFolder("ghidra_scripts"), project.getFolder("bin/scripts"))); for (SourceFolderInfo sourceFolderInfo : sourceFolderInfos) { - GhidraProjectUtils.createFolder(sourceFolderInfo.outputFolder(), monitor); + GhidraProjectUtils.createFolder(sourceFolderInfo.sourceFolder(), monitor); } // Put the source directories in the project's classpath