Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-1016: Fixing single jar mode exception

Ryan Kurtz2eea089265db
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/util/GhidraJarBuilder.java b/Ghidra/Features/Base/src/main/java/ghidra/util/GhidraJarBuilder.java
index c06c7302c4..b2d66b414c 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/util/GhidraJarBuilder.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/util/GhidraJarBuilder.java
@@ -86,6 +86,10 @@ public class GhidraJarBuilder implements GhidraLaunchable {
// include features unless they have been excluded via the module.manifest file.
return !module.excludeFromGhidraJar();
}
+ if (module.isDebug()) {
+ // include debug modules unless they have been excluded via the module.manifest file.
+ return !module.excludeFromGhidraJar();
+ }
if (module.isGPL()) {
// include features unless they have been excluded via the module.manifest file.
return !module.excludeFromGhidraJar();
@@ -335,8 +339,8 @@ public class GhidraJarBuilder implements GhidraLaunchable {
}
}
if (wroteToZip) {
- System.out.println(
- "Can't create source zip! Has source been downloaded and installed?");
+ System.out
+ .println("Can't create source zip! Has source been downloaded and installed?");
// zip.close reports error if nothing has been written to it
zip.close();
}
@@ -396,6 +400,7 @@ public class GhidraJarBuilder implements GhidraLaunchable {
Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) {
JarEntry jarEntry = entries.nextElement();
+ String jarName = jarEntry.getName();
// Special case for Log4j:
//
@@ -415,7 +420,7 @@ public class GhidraJarBuilder implements GhidraLaunchable {
// point, even though it doesn't now. As such, we may want to try to merge
// all the .dat files together at some point.
//
- if (jarEntry.getName().contains("Log4j2Plugins.dat")) {
+ if (jarName.contains("Log4j2Plugins.dat")) {
if (jarFile.getName().contains("log4j-core")) {
jar.addJarEntry(jarFile, jarEntry, module);
}
@@ -424,6 +429,10 @@ public class GhidraJarBuilder implements GhidraLaunchable {
}
}
+ if (jarName.endsWith(".SF") || jarName.endsWith(".DSA") || jarName.endsWith(".RSA")) {
+ continue;
+ }
+
jar.addJarEntry(jarFile, jarEntry, module);
}
}
@@ -562,26 +571,26 @@ public class GhidraJarBuilder implements GhidraLaunchable {
}
return manifest;
}
-
+
private List<ApplicationModule> findAllModules(ApplicationLayout layout) throws IOException {
List<ApplicationModule> modules = new ArrayList<>();
-
+
for (GModule module : layout.getModules().values()) {
File moduleDir = module.getModuleRoot().getFile(false).getCanonicalFile();
File rootDir = getModuleRootDir(moduleDir);
modules.add(new ApplicationModule(rootDir, moduleDir));
}
-
+
return modules;
}
-
+
private File getModuleRootDir(File moduleDir) {
// Look in GPL directories too
List<File> rootDirs = new ArrayList<>(rootGhidraDirs);
for (File rootDir : rootGhidraDirs) {
rootDirs.add(new File(rootDir.getParentFile(), "GPL"));
}
-
+
// Check each root directory to see if it contains the module
for (File rootDir : rootDirs) {
if (FileUtilities.isPathContainedWithin(rootDir, moduleDir)) {
diff --git a/Ghidra/Framework/Generic/src/main/java/generic/jar/ApplicationModule.java b/Ghidra/Framework/Generic/src/main/java/generic/jar/ApplicationModule.java
index 671e350861..19e6752af7 100644
--- a/Ghidra/Framework/Generic/src/main/java/generic/jar/ApplicationModule.java
+++ b/Ghidra/Framework/Generic/src/main/java/generic/jar/ApplicationModule.java
@@ -65,6 +65,10 @@ public class ApplicationModule implements Comparable<ApplicationModule> {
return moduleDir.getParentFile().getName().equalsIgnoreCase("Framework");
}
+ public boolean isDebug() {
+ return moduleDir.getParentFile().getName().equalsIgnoreCase("Debug");
+ }
+
public boolean isProcessor() {
return moduleDir.getParentFile().getName().equalsIgnoreCase("Processors");
}
diff --git a/Ghidra/Framework/Utility/src/main/java/ghidra/GhidraLauncher.java b/Ghidra/Framework/Utility/src/main/java/ghidra/GhidraLauncher.java
index 8db165297e..14d45a207a 100644
--- a/Ghidra/Framework/Utility/src/main/java/ghidra/GhidraLauncher.java
+++ b/Ghidra/Framework/Utility/src/main/java/ghidra/GhidraLauncher.java
@@ -232,10 +232,11 @@ public class GhidraLauncher {
typePriorityMap.put("Framework", 0);
typePriorityMap.put("Configurations", 1);
typePriorityMap.put("Features", 2);
- typePriorityMap.put("Processors", 3);
- typePriorityMap.put("GPL", 4);
- typePriorityMap.put("Extensions", 5);
- typePriorityMap.put("Test", 6);
+ typePriorityMap.put("Debug", 3);
+ typePriorityMap.put("Processors", 4);
+ typePriorityMap.put("GPL", 5);
+ typePriorityMap.put("Extensions", 6);
+ typePriorityMap.put("Test", 7);
String type1 = module1.getModuleRoot().getParentFile().getName();
String type2 = module2.getModuleRoot().getParentFile().getName();