GP-4876: JShell launcher for Ghidra

This commit is contained in:
Dan 2024-08-28 11:19:29 -04:00
parent db28b29dab
commit 42b73252f1
6 changed files with 116 additions and 0 deletions

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<stringAttribute key="bad_container_name" value="/_Ghidra Support/eclipse"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/Framework Utility/src/main/java/ghidra/Ghidra.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<mapAttribute key="org.eclipse.debug.core.preferred_launchers">
<mapEntry key="[debug]" value="org.eclipse.jdt.launching.localJavaApplication"/>
<mapEntry key="[run]" value="org.eclipse.jdt.launching.localJavaApplication"/>
</mapAttribute>
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/>
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;sourceLookupDirector&gt;&#10;&lt;sourceContainers duplicates=&quot;false&quot;&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;classpathContainer path=&amp;quot;org.eclipse.jdt.launching.JRE_CONTAINER&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.classpathContainer&quot;/&gt;&#10;&lt;/sourceContainers&gt;&#10;&lt;/sourceLookupDirector&gt;&#10;"/>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
</listAttribute>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_SHOW_CODEDETAILS_IN_EXCEPTION_MESSAGES" value="true"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_CLASSPATH_ONLY_JAR" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry path=&quot;5&quot; projectName=&quot;Framework Utility&quot; type=&quot;1&quot;/&gt;&#10;"/>
</listAttribute>
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="ghidra.Ghidra"/>
<listAttribute key="org.eclipse.jdt.launching.MODULEPATH"/>
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="Framework Utility"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="ghidra.JShellRun"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="Framework Utility"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-XX:+IgnoreUnrecognizedVMOptions&#13;&#10;-Djava.system.class.loader=ghidra.GhidraClassLoader&#13;&#10;-Xshare:off&#13;&#10;-Dfile.encoding=UTF8&#13;&#10;-Duser.country=US&#13;&#10;-Duser.language=en&#13;&#10;-Dsun.java2d.pmoffscreen=false&#13;&#10;-Dsun.java2d.xrender=true&#13;&#10;-Dsun.java2d.d3d=false&#13;&#10;-Xdock:name=&quot;Ghidra&quot;&#13;&#10;-Dvisualvm.display.name=Ghidra&#13;&#10;-Dpython.console.encoding=UTF-8"/>
</launchConfiguration>

View File

@ -12,6 +12,7 @@
.launch/Ghidra Code Coverage.launch||GHIDRA||||END|
.launch/Ghidra.launch||GHIDRA||||END|
.launch/Headless.launch||GHIDRA||||END|
.launch/JShell.launch||GHIDRA||||END|
Module.manifest||GHIDRA||||END|
data/ElfFunctionsThatDoNotReturn||GHIDRA||||END|
data/ExtensionPoint.manifest||GHIDRA||||END|

View File

@ -0,0 +1,49 @@
/* ###
* IP: GHIDRA
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ghidra;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.stream.Stream;
import ghidra.framework.*;
import jdk.jshell.tool.JavaShellToolBuilder;
public class JShellRun implements GhidraLaunchable {
@Override
public void launch(GhidraApplicationLayout layout, String[] args) throws Exception {
if (Stream.of(args).anyMatch(a -> a.startsWith("--execution"))) {
System.err.println("Ignoring --execution option. Overridden to local");
}
ArrayList<String> fullArgs = new ArrayList<>();
fullArgs.addAll(Arrays.asList(args));
ApplicationConfiguration configuration;
if (fullArgs.remove("--headless")) {
configuration = new HeadlessGhidraApplicationConfiguration();
}
else {
GhidraApplicationConfiguration gac = new GhidraApplicationConfiguration();
gac.setShowSplashScreen(false);
configuration = gac;
}
Application.initializeApplication(layout, configuration);
fullArgs.add("--execution=local");
JavaShellToolBuilder.builder().start(fullArgs.toArray(String[]::new));
}
}

View File

@ -0,0 +1,19 @@
#!/usr/bin/env bash
#----------------------------------------
# Ghidra JShell launch
#----------------------------------------
# Maximum heap memory may be changed if default is inadequate. This will generally be up to 1/4 of
# the physical memory available to the OS. Uncomment MAXMEM setting if non-default value is needed.
#MAXMEM=2G
# Resolve symbolic link if present and get the directory this script lives in.
# NOTE: "readlink -f" is best but works on Linux only, "readlink" will only work if your PWD
# contains the link you are calling (which is the best we can do on macOS), and the "echo" is the
# fallback, which doesn't attempt to do anything with links.
SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")"
SCRIPT_DIR="${SCRIPT_FILE%/*}"
# Launch Ghidra
"${SCRIPT_DIR}"/launch.sh fg jdk Ghidra-JShell "${MAXMEM}" "" ghidra.JShellRun "$@"

View File

@ -0,0 +1,11 @@
:: Ghidra JShell launch
@echo off
setlocal
:: Maximum heap memory may be changed if default is inadequate. This will generally be up to 1/4 of
:: the physical memory available to the OS. Uncomment MAXMEM setting if non-default value is needed.
::set MAXMEM=2G
call "%~dp0launch.bat" fg jdk Ghidra-JShell "%MAXMEM%" "" ghidra.JShellRun %*

View File

@ -26,6 +26,7 @@ Linux/support/convertStorage||GHIDRA||||END|
Linux/support/gdbGADPServerRun||GHIDRA||||END|
Linux/support/ghidraClean||GHIDRA||||END|
Linux/support/ghidraDebug||GHIDRA||||END|
Linux/support/jshellRun||GHIDRA||||END|
Linux/support/pythonRun||GHIDRA||||END|
Linux/support/sleigh||GHIDRA||||END|
Windows/ghidraRun.bat||GHIDRA||||END|
@ -45,6 +46,7 @@ Windows/support/dbgmodelGADPServerRun.bat||GHIDRA||||END|
Windows/support/ghidra.ico||GHIDRA||||END|
Windows/support/ghidraClean.bat||GHIDRA||||END|
Windows/support/ghidraDebug.bat||GHIDRA||||END|
Windows/support/jshellRun.bat||GHIDRA||||END|
Windows/support/launch.bat||GHIDRA||||END|
Windows/support/pythonRun.bat||GHIDRA||||END|
Windows/support/sleigh.bat||GHIDRA||||END|