diff --git a/Ghidra/Features/Base/.launch/Ghidra Code Coverage.launch b/Ghidra/Features/Base/.launch/Ghidra Code Coverage.launch index ae77165044..1585aae0a1 100644 --- a/Ghidra/Features/Base/.launch/Ghidra Code Coverage.launch +++ b/Ghidra/Features/Base/.launch/Ghidra Code Coverage.launch @@ -1,7 +1,7 @@ - + @@ -11,21 +11,24 @@ - + + + - - + + + - + diff --git a/Ghidra/Features/Base/.launch/Ghidra.launch b/Ghidra/Features/Base/.launch/Ghidra.launch index c619ef5bd6..97d3a694ae 100644 --- a/Ghidra/Features/Base/.launch/Ghidra.launch +++ b/Ghidra/Features/Base/.launch/Ghidra.launch @@ -2,7 +2,7 @@ - + @@ -18,17 +18,18 @@ + - - + + - + diff --git a/Ghidra/Features/Base/src/main/java/ghidra/framework/GhidraApplicationConfiguration.java b/Ghidra/Features/Base/src/main/java/ghidra/framework/GhidraApplicationConfiguration.java index c4febcf51e..5108d2523a 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/framework/GhidraApplicationConfiguration.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/framework/GhidraApplicationConfiguration.java @@ -69,20 +69,6 @@ public class GhidraApplicationConfiguration extends HeadlessGhidraApplicationCon taskbar.setIconImage(ApplicationInformationDisplayFactory.getLargestWindowIcon()); } } - - // Set the application title for Linux. - // This should not be necessary...hopefully in a future version of Java it will just work. - Class toolkitClass = Toolkit.getDefaultToolkit().getClass(); - if (toolkitClass.getName().equals("sun.awt.X11.XToolkit")) { - try { - final Field awtAppClassName = toolkitClass.getDeclaredField("awtAppClassName"); - awtAppClassName.setAccessible(true); - awtAppClassName.set(null, "Ghidra"); - } - catch (Exception e) { - // Not sure what went wrong. Oh well, we tried. - } - } } private static void showUserAgreement() { diff --git a/Ghidra/Framework/SoftwareModeling/Sleigh.launch b/Ghidra/Framework/SoftwareModeling/Sleigh.launch index 0582eb91e3..f9d25c7739 100644 --- a/Ghidra/Framework/SoftwareModeling/Sleigh.launch +++ b/Ghidra/Framework/SoftwareModeling/Sleigh.launch @@ -1,7 +1,7 @@ - + @@ -14,18 +14,21 @@ + + - - + + + - + diff --git a/Ghidra/Framework/SoftwareModeling/certification.manifest b/Ghidra/Framework/SoftwareModeling/certification.manifest index 7cbd0c11ee..a71019b2c1 100644 --- a/Ghidra/Framework/SoftwareModeling/certification.manifest +++ b/Ghidra/Framework/SoftwareModeling/certification.manifest @@ -6,7 +6,6 @@ Module.manifest||GHIDRA||||END| Sleigh.launch||GHIDRA||||END| data/ExtensionPoint.manifest||GHIDRA||||END| data/charset_info.xml||GHIDRA||||END| -data/languages/Steps to creation of Format Opinion.txt||GHIDRA||||END| data/languages/compiler_spec.rxg||GHIDRA||||END| data/languages/format_opinions.rxg||GHIDRA||||END| data/languages/language_common.rxg||GHIDRA||||END| diff --git a/Ghidra/Framework/Utility/src/main/java/ghidra/Ghidra.java b/Ghidra/Framework/Utility/src/main/java/ghidra/Ghidra.java new file mode 100644 index 0000000000..8fd5235332 --- /dev/null +++ b/Ghidra/Framework/Utility/src/main/java/ghidra/Ghidra.java @@ -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.awt.Taskbar; + +/** + * Ghidra entry point that forwards the command line arguments to {@link GhidraLaunchable}. + *

+ * This class was introduced so Ghidra's application name can be set to "ghidra-Ghidra" on Linux, + * rather than "ghidra-GhidraLauncher". + * @see JDK-6528430 + */ +public class Ghidra { + + /** + * Launches the given {@link GhidraLaunchable} specified in the first command line argument + * + * @param args The first argument is the name of the {@link GhidraLaunchable} to launch. + * The remaining args get passed through to the class's {@link GhidraLaunchable#launch} + * method. + * @throws Exception If there was a problem launching. See the exception's message for more + * details on what went wrong. + */ + public static void main(String[] args) throws Exception { + + // Poke the Taskbar class in order to set the Linux application name to this class's + // fully qualified class name (with . replaced by -). If we don't do this here, the next + // time it gets done is in a new thread, which results in the application name being set to + // "java-lang-thread". + Taskbar.isTaskbarSupported(); + + // Forward args to GhidraLauncher, which will perform the launch + GhidraLauncher.launch(args); + } +} diff --git a/Ghidra/Framework/Utility/src/main/java/ghidra/GhidraLauncher.java b/Ghidra/Framework/Utility/src/main/java/ghidra/GhidraLauncher.java index 66a818b7c3..3d1b5296c1 100644 --- a/Ghidra/Framework/Utility/src/main/java/ghidra/GhidraLauncher.java +++ b/Ghidra/Framework/Utility/src/main/java/ghidra/GhidraLauncher.java @@ -42,7 +42,7 @@ public class GhidraLauncher { * @throws Exception If there was a problem launching. See the exception's message for more * details on what went wrong. */ - public static void main(String[] args) throws Exception { + public static void launch(String[] args) throws Exception { // Initialize the Ghidra environment GhidraApplicationLayout layout = initializeGhidraEnvironment(); @@ -59,6 +59,21 @@ public class GhidraLauncher { launchable.launch(layout, Arrays.copyOfRange(args, 1, args.length)); } + /** + * Launches the given {@link GhidraLaunchable} specified in the first command line argument + * + * @param args The first argument is the name of the {@link GhidraLaunchable} to launch. + * The remaining args get passed through to the class's {@link GhidraLaunchable#launch} + * method. + * @throws Exception If there was a problem launching. See the exception's message for more + * details on what went wrong. + * @deprecated Use {@link Ghidra#main(String[])} instead + */ + @Deprecated(since = "10.1", forRemoval = true) + public static void main(String[] args) throws Exception { + launch(args); + } + /** * Initializes the Ghidra environment by discovering its {@link GhidraApplicationLayout layout} * and adding all relevant modules and libraries to the classpath diff --git a/Ghidra/RuntimeScripts/Common/support/launch.properties b/Ghidra/RuntimeScripts/Common/support/launch.properties index 735d476abb..c820dd6da1 100644 --- a/Ghidra/RuntimeScripts/Common/support/launch.properties +++ b/Ghidra/RuntimeScripts/Common/support/launch.properties @@ -74,7 +74,6 @@ VMARGS=--add-opens java.base/java.lang=ALL-UNNAMED VMARGS=--add-opens java.base/java.util=ALL-UNNAMED VMARGS=--add-opens java.base/java.net=ALL-UNNAMED VMARGS=--add-opens java.desktop/sun.awt.image=ALL-UNNAMED -VMARGS_LINUX=--add-opens java.desktop/sun.awt.X11=ALL-UNNAMED # Persistent cache directory used by the application. This directory will be used to store # persistent application caches for all users. The default location for Mac/Linux is the same as diff --git a/Ghidra/RuntimeScripts/Linux/support/launch.sh b/Ghidra/RuntimeScripts/Linux/support/launch.sh index 84388eb590..3bd3a568f7 100755 --- a/Ghidra/RuntimeScripts/Linux/support/launch.sh +++ b/Ghidra/RuntimeScripts/Linux/support/launch.sh @@ -180,7 +180,7 @@ else fi if [ "${BACKGROUND}" = true ]; then - eval "\"${JAVA_CMD}\" ${VMARG_LIST} -showversion -cp \"${CPATH}\" ghidra.GhidraLauncher ${CLASSNAME} ${ARGS[@]}" &>/dev/null & + eval "\"${JAVA_CMD}\" ${VMARG_LIST} -showversion -cp \"${CPATH}\" ghidra.Ghidra ${CLASSNAME} ${ARGS[@]}" &>/dev/null & # If our process dies immediately, output something so the user knows to run in debug mode. # Otherwise they'll never see any error output from background mode. @@ -193,7 +193,7 @@ if [ "${BACKGROUND}" = true ]; then fi exit 0 else - eval "\"${JAVA_CMD}\" ${VMARG_LIST} -showversion -cp \"${CPATH}\" ghidra.GhidraLauncher ${CLASSNAME} ${ARGS[@]}" + eval "\"${JAVA_CMD}\" ${VMARG_LIST} -showversion -cp \"${CPATH}\" ghidra.Ghidra ${CLASSNAME} ${ARGS[@]}" exit $? fi diff --git a/Ghidra/RuntimeScripts/Windows/support/launch.bat b/Ghidra/RuntimeScripts/Windows/support/launch.bat index 5f3069f770..0706b597a9 100644 --- a/Ghidra/RuntimeScripts/Windows/support/launch.bat +++ b/Ghidra/RuntimeScripts/Windows/support/launch.bat @@ -170,7 +170,7 @@ exit /B 1 :continue3 -set CMD_ARGS=%FORCE_JAVA_VERSION% %JAVA_USER_HOME_DIR_OVERRIDE% %VMARG_LIST% -cp "%CPATH%" ghidra.GhidraLauncher %CLASSNAME% %ARGS% +set CMD_ARGS=%FORCE_JAVA_VERSION% %JAVA_USER_HOME_DIR_OVERRIDE% %VMARG_LIST% -cp "%CPATH%" ghidra.Ghidra %CLASSNAME% %ARGS% if "%BACKGROUND%"=="y" ( set JAVA_CMD=!JAVA_CMD!w 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 ed7309fe23..5658d564a9 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 @@ -130,6 +130,9 @@ 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. * * @param wc The launch configuration working copy to modify. * @return The modified working copy.