question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ApplicationUtilities/GhidraClassLoader jarmanifest support

See original GitHub issue

Is 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:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
astrelskycommented, Oct 22, 2019

Considering this is likely unnecessary I’m going to close this.

0reactions
astrelskycommented, Sep 27, 2019

Ah ok, i understand. Let’s see what the vscode-java-test people say about it and go from there.

Ok that sounds good. Just for reference here is a link to the issue. https://github.com/microsoft/vscode-java-test/issues/824

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to load JAR files dynamically at Runtime? - Stack Overflow
system.class.loader=com.example.MyCustomClassLoader seems not reflected for the compile time dependency jars in the application jar manifest.
Read more >
Tampering and Reverse Engineering on Android
In order to extract strings from native code used in an Android application, you can use GUI tools such as Ghidra or Cutter...
Read more >
Java Basics - CS6038/CS5138 Malware Analysis, UC by ckane
There are a number of tools that work to analyze Java, and Ghidra is ... jar application also add a META-INF folder containing...
Read more >
General Info - ANY.RUN
https://ghidra-sre.org/ghidra_9.0_PUBLIC_20190228.zip ... 3552, "C:\Program Files\Google\Chrome\Application\chrome.exe" --type=utility ...
Read more >
port security/ghidra - OpenBSD Ports Readme
Ghidra is a software reverse engineering (SRE) framework created and maintained by the ... Ghidra supports a wide variety of processor instruction sets...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found