diff --git a/Ghidra/RuntimeScripts/Common/support/launch.properties b/Ghidra/RuntimeScripts/Common/support/launch.properties
index 14f0096465..aaf0472b08 100644
--- a/Ghidra/RuntimeScripts/Common/support/launch.properties
+++ b/Ghidra/RuntimeScripts/Common/support/launch.properties
@@ -24,6 +24,9 @@ VMARGS_LINUX=-Dsun.java2d.uiScale=1
VMARGS_LINUX=-Dawt.useSystemAAFontSettings=on
VMARGS_WINDOWS=-Dsun.java2d.d3d=false
+# Fix blank windows on non-parenting windows managers such as XMonad and Sway
+#ENVVARS_LINUX=_JAVA_AWT_WM_NONREPARENTING=1
+
# The Ghidra application establishes the default SSLContext for all
# secure client connections based upon Java's default TLS protocol enablement.
# Setting this property will restrict the enabled TLS protocol versions for
@@ -42,7 +45,7 @@ VMARGS=-Djdk.tls.client.protocols=TLSv1.2,TLSv1.3
# SSL/TLS connections. This VMARG should only be uncommented while actively troubleshooting
# since it will log a significant amount of data.
#
-# See the "Troubleshoting JSSE" section of the following internet hosted document:
+# See the "Troubleshooting JSSE" section of the following internet hosted document:
# https://docs.oracle.com/en/java/javase/17/security/java-secure-socket-extension-jsse-reference-guide.html
#
# NOTE: When this debug logging is enabled be sure to launch Ghidra with debugGhidra instead of
diff --git a/Ghidra/RuntimeScripts/Linux/support/launch.sh b/Ghidra/RuntimeScripts/Linux/support/launch.sh
index 167835405d..5a8ec3c514 100755
--- a/Ghidra/RuntimeScripts/Linux/support/launch.sh
+++ b/Ghidra/RuntimeScripts/Linux/support/launch.sh
@@ -43,9 +43,9 @@ function showUsage() {
exit 1
}
-VMARGS_FROM_CALLER= # Passed in from the outer script as one long string, no spaces
-VMARGS_FROM_LAUNCH_SH=() # Defined in this script, added to array
-VMARGS_FROM_LAUNCH_PROPS=() # Retrieved from LaunchSupport, added to array
+VMARGS_FROM_CALLER= # Passed in from the outer script as one long string, no spaces
+VMARGS_FROM_LAUNCH_SH=() # Defined in this script, added to array
+VMARGS_FROM_LAUNCH_PROPS=() # Retrieved from LaunchSupport, added to array
ARGS=()
INDEX=0
@@ -169,6 +169,15 @@ if [ ! $? -eq 0 ]; then
fi
JAVA_CMD="${LS_JAVA_HOME}/bin/java"
+# Get the configurable environment variables from the launch properties
+# Only set them if they are currently unset or empty
+while IFS=$'\r\n' read -r line; do
+ IFS='=' read -r key value <<< "$line"
+ if [ -z ${!key} ]; then
+ export $key=$value
+ fi
+done < <("${JAVA_CMD}" -cp "${LS_CPATH}" LaunchSupport "${INSTALL_DIR}" -envvars)
+
# Get the configurable VM arguments from the launch properties
while IFS=$'\r\n' read -r line; do
VMARGS_FROM_LAUNCH_PROPS+=("$line")
diff --git a/Ghidra/RuntimeScripts/Windows/support/launch.bat b/Ghidra/RuntimeScripts/Windows/support/launch.bat
index 92f5ffddbb..f317f53dd4 100644
--- a/Ghidra/RuntimeScripts/Windows/support/launch.bat
+++ b/Ghidra/RuntimeScripts/Windows/support/launch.bat
@@ -168,6 +168,16 @@ if "%LS_JAVA_HOME%" == "" (
)
set "JAVA_CMD=%LS_JAVA_HOME%\bin\java"
+:: Get the configurable environment variables from the launch properties
+:: Only set them if they are currently undefined
+for /f "delims=*" %%i in ('call "%JAVA_CMD%" -cp "%LS_CPATH%" LaunchSupport "%INSTALL_DIR%" -envvars') do (
+ for /f "tokens=1* delims==" %%a in ("%%i") do (
+ if not defined %%a (
+ set %%a=%%b
+ )
+ )
+)
+
:: Get the configurable VM arguments from the launch properties
for /f "delims=*" %%i in ('call "%JAVA_CMD%" -cp "%LS_CPATH%" LaunchSupport "%INSTALL_DIR%" -vmargs') do set VMARG_LIST=!VMARG_LIST! %%i
diff --git a/GhidraBuild/LaunchSupport/src/main/java/LaunchSupport.java b/GhidraBuild/LaunchSupport/src/main/java/LaunchSupport.java
index 414e70fb03..bca5dea6e6 100644
--- a/GhidraBuild/LaunchSupport/src/main/java/LaunchSupport.java
+++ b/GhidraBuild/LaunchSupport/src/main/java/LaunchSupport.java
@@ -44,6 +44,7 @@ public class LaunchSupport {
*
-jdk_home_check: Verify that the specified Java home directory contains a
* supported version of java. No output is produced.
* -vmargs: Get JVM arguments and output on stdout (one per line).
+ * -envvars: Get environment variables and output on stdout (one per line).
*
* Optional arguments supported by -java_home and -jdk_home:
*
@@ -114,6 +115,9 @@ public class LaunchSupport {
case "-vmargs":
exitCode = handleVmArgs(appConfig);
break;
+ case "-envvars":
+ exitCode = handleEnvVars(appConfig);
+ break;
default:
System.err.println("LaunchSupport received illegal argument: " + mode);
break;
@@ -351,4 +355,24 @@ public class LaunchSupport {
appConfig.getLaunchProperties().getVmArgList().forEach(e -> System.out.print(e + "\r\n"));
return EXIT_SUCCESS;
}
+
+ /**
+ * Handles getting the environment variables. If they are successfully determined, they are
+ * printed to STDOUT as a new-line delimited string that can be parsed and added to the
+ * environment, and an exit code that indicates success is returned.
+
+ * @param appConfig The appConfig configuration that defines what we support.
+ * @return A suggested exit code based on whether or not the environment variables were
+ * successfully gotten.
+ */
+ private static int handleEnvVars(AppConfig appConfig) {
+ if (appConfig.getLaunchProperties() == null) {
+ System.err.println("Launch properties file was not specified!");
+ return EXIT_FAILURE;
+ }
+
+ // Force newline style to make cross-platform parsing consistent
+ appConfig.getLaunchProperties().getEnvVarList().forEach(e -> System.out.print(e + "\r\n"));
+ return EXIT_SUCCESS;
+ }
}
diff --git a/GhidraBuild/LaunchSupport/src/main/java/ghidra/launch/LaunchProperties.java b/GhidraBuild/LaunchSupport/src/main/java/ghidra/launch/LaunchProperties.java
index efac026caf..f0b25fd987 100644
--- a/GhidraBuild/LaunchSupport/src/main/java/ghidra/launch/LaunchProperties.java
+++ b/GhidraBuild/LaunchSupport/src/main/java/ghidra/launch/LaunchProperties.java
@@ -46,6 +46,16 @@ public class LaunchProperties {
*/
public static String VMARGS_PLATFORM = "VMARGS_" + JavaFinder.getCurrentPlatform();
+ /**
+ * The environment variables to use to launch (all platforms).
+ */
+ public static String ENVVARS = "ENVVARS";
+
+ /**
+ * The environment variables to use to launch (current platform only).
+ */
+ public static String ENVVARS_PLATFORM = "ENVVARS_" + JavaFinder.getCurrentPlatform();
+
private Map> propertyMap;
private File launchPropertiesFile;
@@ -132,6 +142,26 @@ public class LaunchProperties {
return ret;
}
+ /**
+ * Gets a {@link List} of environment variables to use for the launch for the current
+ * {@link Platform platform}.
+ *
+ * @return A {@link List} of environment variables to use for the launch for the current
+ * {@link Platform}
+ */
+ public List getEnvVarList() {
+ List ret = new ArrayList<>();
+ List envVarList = propertyMap.get(ENVVARS);
+ if (envVarList != null) {
+ ret.addAll(envVarList);
+ }
+ List envVarPlatformList = propertyMap.get(ENVVARS_PLATFORM);
+ if (envVarPlatformList != null) {
+ ret.addAll(envVarPlatformList);
+ }
+ return ret;
+ }
+
/**
* Parses and gets the launch properties from the given launch properties file.
*
diff --git a/GhidraDocs/GettingStarted.md b/GhidraDocs/GettingStarted.md
index b16663fae5..9c8e0871c7 100644
--- a/GhidraDocs/GettingStarted.md
+++ b/GhidraDocs/GettingStarted.md
@@ -1,5 +1,5 @@
# Getting Started with Ghidra
-The information provided in this document is effective as of Ghidra 12.0 and is subject to change
+The information provided in this document is effective as of Ghidra 12.1 and is subject to change
with future releases.
## Table of Contents
@@ -458,9 +458,10 @@ There are several ways you can get help with using Ghidra:
* GUI icons may not render correctly in some configurations of Linux. Setting
`VMARGS=-Dsun.java2d.opengl` to `true` in `/support/launch.properties` may fix
this issue.
-* Non-reparenting window managers such as Xmonad and Sway may render Ghidra windows as blank. This
- is a known java issue (https://bugs.openjdk.org/browse/JDK-8058197) which can only be addressed
- by setting the environment variable `_JAVA_AWT_WM_NONREPARENTING=1` prior to launching Ghidra.
+* Non-reparenting window managers such as XMonad and Sway may render Ghidra windows as blank. This
+ is a known java issue (https://bugs.openjdk.org/browse/JDK-8058197) which can be addressed by
+ uncommenting `#ENVVARS_LINUX=_JAVA_AWT_WM_NONREPARENTING=1` in
+ `/support/launch.properties`.
### macOS
* Building new Ghidra module extensions on macOS (OS X) using a network drive (including a