ApplicationUtilities/GhidraClassLoader jarmanifest support
See original GitHub issueIs your feature request related to a problem? Please describe. Ghidra is unable to launch when a jarmanifest is used to shorten the command line. Some IDEs use this method when launching a java project. Notably the vscode java test runner.
Describe the solution you’d like ApplicationUtilities.findPrimaryApplicationRootDir should check if the classpath returned by System.getProperty(“java.class.path”) is a jarmanifest iff classpath.length == 1.
Describe alternatives you’ve considered Opening an issue at https://github.com/microsoft/vscode-java-test for there being no option for how the command line is shortened. However, having this done here may ease difficulties with using other popular IDEs besides Eclipse.
Additional context
The local variable classpath before entering the loop is:
classpath: String[1]@43 "c:\Users\astre\AppData\Roaming\Code - Insiders\User\workspaceStorage\8b07a3b88fd3fded0d9e897a7bef724a\vscjava.vscode-java-test\1569444187407\path.jar"
Also my terminology may be horridly incorrect here. Still new to Java.
Below is an example of the changed method which I am using to make it work in the meantime. I’m not exactly sure if this is the best way to accomplish this though.
private static ResourceFile findPrimaryApplicationRootDir() {
String[] classpath = System.getProperty("java.class.path").split(File.pathSeparator);
if (classpath.length == 1 && classpath[0].endsWith(".jar")) {
try {
JarFile jar = new JarFile(new File(classpath[0]).getCanonicalPath());
Attributes attributes = jar.getManifest().getMainAttributes();
classpath = attributes.getValue("Class-Path").replace("file:///", "").split(" ");
} catch (IOException e) {
Msg.error(ApplicationUtilities.class, "Invalid Jar Manifest Class-Path", e);
}
}
for (String pathEntry : classpath) {
try {
ResourceFile pathFile = new ResourceFile(new File(pathEntry).getCanonicalPath());
while (pathFile != null && pathFile.exists()) {
if (new ResourceFile(pathFile, ApplicationProperties.PROPERTY_FILE).exists()) {
return pathFile;
}
pathFile = pathFile.getParentFile();
}
}
catch (IOException e) {
Msg.error(ApplicationUtilities.class, "Invalid class path entry: " + pathEntry, e);
}
}
return null;
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Considering this is likely unnecessary I’m going to close this.
Ok that sounds good. Just for reference here is a link to the issue. https://github.com/microsoft/vscode-java-test/issues/824