Ghidra is a software reverse engineering (SRE) framework
GP-2301: Each launch script can now specify if they require a JDK or JRE to run. Allows svrAdmin to run with just a JRE, like the GhidraServer.
Ryan Kurtz4491a0fd6ef0
diff --git a/Ghidra/RuntimeScripts/Linux/ghidraRun b/Ghidra/RuntimeScripts/Linux/ghidraRunindex 0bd85b9931..82ebb197a6 100755--- a/Ghidra/RuntimeScripts/Linux/ghidraRun+++ b/Ghidra/RuntimeScripts/Linux/ghidraRun@@ -16,4 +16,4 @@ SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echoSCRIPT_DIR="${SCRIPT_FILE%/*}"# Launch Ghidra-"${SCRIPT_DIR}"/support/launch.sh bg Ghidra "${MAXMEM}" "" ghidra.GhidraRun "$@"+"${SCRIPT_DIR}"/support/launch.sh bg jdk Ghidra "${MAXMEM}" "" ghidra.GhidraRun "$@"diff --git a/Ghidra/RuntimeScripts/Linux/server/svrAdmin b/Ghidra/RuntimeScripts/Linux/server/svrAdminindex deb47eec9d..41ebb345b4 100755--- a/Ghidra/RuntimeScripts/Linux/server/svrAdmin+++ b/Ghidra/RuntimeScripts/Linux/server/svrAdmin@@ -46,7 +46,7 @@ OWNER="$(grep '^wrapper.app.account=' "${CONFIG}" | sed -e 's/^.*=\(.*\)\s*.*$/\if [ -z "${OWNER}" -o "${OWNER}" = "$(whoami)" ]; thenVMARGS="-DUserAdmin.invocation=$(basename "${SCRIPT_FILE}")"- "${SCRIPT_DIR}"/../support/launch.sh fg svrAdmin "${MAXMEM}" "$VMARGS" ghidra.server.ServerAdmin "${CONFIG}" "$@"+ "${SCRIPT_DIR}"/../support/launch.sh fg jre svrAdmin "${MAXMEM}" "$VMARGS" ghidra.server.ServerAdmin "${CONFIG}" "$@"elseecho "Running svrAdmin with $SUDO as ${OWNER} ..."$SUDO -u $OWNER "$0" "$@"diff --git a/Ghidra/RuntimeScripts/Linux/support/analyzeHeadless b/Ghidra/RuntimeScripts/Linux/support/analyzeHeadlessindex abd6681c23..f7d05f8d59 100755--- a/Ghidra/RuntimeScripts/Linux/support/analyzeHeadless+++ b/Ghidra/RuntimeScripts/Linux/support/analyzeHeadless@@ -33,4 +33,4 @@ SCRIPT_DIR="${SCRIPT_FILE%/*}"# Launch HeadlessAnalyzer.# DEBUG_ADDRESS set via environment for launch.sh-DEBUG_ADDRESS=${DEBUG_ADDRESS} "${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" Ghidra-Headless "${MAXMEM}" "${VMARG_LIST}" ghidra.app.util.headless.AnalyzeHeadless "$@"+DEBUG_ADDRESS=${DEBUG_ADDRESS} "${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" jdk Ghidra-Headless "${MAXMEM}" "${VMARG_LIST}" ghidra.app.util.headless.AnalyzeHeadless "$@"diff --git a/Ghidra/RuntimeScripts/Linux/support/buildGhidraJar b/Ghidra/RuntimeScripts/Linux/support/buildGhidraJarindex c378218c75..ad6bafa91b 100755--- a/Ghidra/RuntimeScripts/Linux/support/buildGhidraJar+++ b/Ghidra/RuntimeScripts/Linux/support/buildGhidraJar@@ -28,4 +28,4 @@ fiAPP_VMARGS="-DGhidraJarBuilder.Name=$(basename "${SCRIPT_FILE}")"# Launch jar builder-"${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" Ghidra "${MAXMEM}" "${APP_VMARGS}" ghidra.util.GhidraJarBuilder -main ghidra.JarRun "$@"+"${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" jdk Ghidra "${MAXMEM}" "${APP_VMARGS}" ghidra.util.GhidraJarBuilder -main ghidra.JarRun "$@"diff --git a/Ghidra/RuntimeScripts/Linux/support/convertStorage b/Ghidra/RuntimeScripts/Linux/support/convertStorageindex f261e9e5d6..010a72e50c 100755--- a/Ghidra/RuntimeScripts/Linux/support/convertStorage+++ b/Ghidra/RuntimeScripts/Linux/support/convertStorage@@ -16,4 +16,4 @@ SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echoSCRIPT_DIR="${SCRIPT_FILE%/*}"# Launch Filesystem Conversion-"${SCRIPT_DIR}"/launch.sh fg ConvertStorage "${MAXMEM}" "" ghidra.framework.data.ConvertFileSystem "$@"+"${SCRIPT_DIR}"/launch.sh fg jdk ConvertStorage "${MAXMEM}" "" ghidra.framework.data.ConvertFileSystem "$@"diff --git a/Ghidra/RuntimeScripts/Linux/support/ghidraDebug b/Ghidra/RuntimeScripts/Linux/support/ghidraDebugindex c32240e5d3..ae96c89b02 100755--- a/Ghidra/RuntimeScripts/Linux/support/ghidraDebug+++ b/Ghidra/RuntimeScripts/Linux/support/ghidraDebug@@ -24,4 +24,4 @@ SCRIPT_DIR="${SCRIPT_FILE%/*}"# Launch Ghidra in debug mode# DEBUG_ADDRESS set via environment for launch.sh-DEBUG_ADDRESS=${DEBUG_ADDRESS} "${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" Ghidra "${MAXMEM}" "" ghidra.GhidraRun "$@"+DEBUG_ADDRESS=${DEBUG_ADDRESS} "${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" jdk Ghidra "${MAXMEM}" "" ghidra.GhidraRun "$@"diff --git a/Ghidra/RuntimeScripts/Linux/support/launch.sh b/Ghidra/RuntimeScripts/Linux/support/launch.shindex 381673c04b..3340dfeef3 100755--- a/Ghidra/RuntimeScripts/Linux/support/launch.sh+++ b/Ghidra/RuntimeScripts/Linux/support/launch.sh@@ -19,24 +19,26 @@ umask 027function showUsage() {- echo "Usage: $0 <mode> <name> <max-memory> \"<vmarg-list>\" <app-classname> <app-args>... "+ echo "Usage: $0 <mode> <java-type> <name> <max-memory> \"<vmarg-list>\" <app-classname> <app-args>... "echo " <mode>: fg run as foreground process in current shell"echo " bg run as background process in new shell"echo " debug run as foreground process in current shell in debug mode (suspend=n)"echo " debug-suspend run as foreground process in current shell in debug mode (suspend=y)"echo " NOTE: for all debug modes environment variable DEBUG_ADDRESS may be set to "echo " override default debug address of 127.0.0.1:18001"+ echo " <java-type>: jdk requires JDK to run"+ echo " jre JRE is sufficient to run (JDK works too)"echo " <name>: application name used for naming console window"echo " <max-memory>: maximum memory heap size in MB (e.g., 768M or 2G). Use empty \"\" if default"- echo " should be used. This will generally be upto 1/4 of the physical memory available"- echo " to the OS."+ echo " should be used. This will generally be upto 1/4 of the physical memory available"+ echo " to the OS."echo " <vmarg-list>: pass-thru args (e.g., \"-Xmx512M -Dmyvar=1 -DanotherVar=2\") - use"- echo " empty \"\" if vmargs not needed"+ echo " empty \"\" if vmargs not needed"echo " <app-classname>: application classname (e.g., ghidra.GhidraRun )"echo " <app-args>...: arguments to be passed to the application"echo " "echo " Example:"- echo " $0 debug Ghidra 768M \"\" ghidra.GhidraRun"+ echo " \"$0\" debug jdk Ghidra 4G \"\" ghidra.GhidraRun"exit 1}@@ -56,17 +58,24 @@ doMODE=$AA;;2)- APPNAME=$AA+ if [ "$AA" = "jre" ]; then+ JAVA_TYPE_ARG="-java_home"+ else+ JAVA_TYPE_ARG="-jdk_home"+ fi;;3)- MAXMEM=$AA+ APPNAME=$AA;;4)+ MAXMEM=$AA+ ;;+ 5)if [ "$AA" != "" ]; thenVMARG_LIST=$AAfi;;- 5)+ 6)CLASSNAME=$AA;;*)@@ -80,7 +89,7 @@ dodone# Verify that required number of args were provided-if [[ ${INDEX} -lt 5 ]]; then+if [[ ${INDEX} -lt 6 ]]; thenecho "Incorrect launch usage - missing argument(s)"showUsageexit 1@@ -122,13 +131,13 @@ if ! [ -x "$(command -v java)" ] ; thenfi# Get the JDK that will be used to launch Ghidra-JAVA_HOME="$(java -cp "${LS_CPATH}" LaunchSupport "${INSTALL_DIR}" -jdk_home -save)"+JAVA_HOME="$(java -cp "${LS_CPATH}" LaunchSupport "${INSTALL_DIR}" ${JAVA_TYPE_ARG} -save)"if [ ! $? -eq 0 ]; then# No JDK has been setup yet. Let the user choose one.- java -cp "${LS_CPATH}" LaunchSupport "${INSTALL_DIR}" -jdk_home -ask+ java -cp "${LS_CPATH}" LaunchSupport "${INSTALL_DIR}" ${JAVA_TYPE_ARG} -ask# Now that the user chose one, try again to get the JDK that will be used to launch Ghidra- JAVA_HOME="$(java -cp "${LS_CPATH}" LaunchSupport "${INSTALL_DIR}" -jdk_home -save)"+ JAVA_HOME="$(java -cp "${LS_CPATH}" LaunchSupport "${INSTALL_DIR}" ${JAVA_TYPE_ARG} -save)"if [ ! $? -eq 0 ]; thenechoecho "Failed to find a supported JDK. Please refer to the Ghidra Installation Guide's Troubleshooting section."diff --git a/Ghidra/RuntimeScripts/Linux/support/pythonRun b/Ghidra/RuntimeScripts/Linux/support/pythonRunindex e30c1e8485..53d157bbe2 100755--- a/Ghidra/RuntimeScripts/Linux/support/pythonRun+++ b/Ghidra/RuntimeScripts/Linux/support/pythonRun@@ -33,4 +33,4 @@ SCRIPT_DIR="${SCRIPT_FILE%/*}"# Launch Ghidra Python# DEBUG_ADDRESS set via environment for launch.sh-DEBUG_ADDRESS=${DEBUG_ADDRESS} "${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" "Ghidra-Python" "${MAXMEM}" "${VMARG_LIST}" ghidra.python.PythonRun "$@"+DEBUG_ADDRESS=${DEBUG_ADDRESS} "${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" jdk "Ghidra-Python" "${MAXMEM}" "${VMARG_LIST}" ghidra.python.PythonRun "$@"diff --git a/Ghidra/RuntimeScripts/Linux/support/sleigh b/Ghidra/RuntimeScripts/Linux/support/sleighindex 77e15a0b50..2f3ba1097d 100755--- a/Ghidra/RuntimeScripts/Linux/support/sleigh+++ b/Ghidra/RuntimeScripts/Linux/support/sleigh@@ -15,4 +15,4 @@SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")"SCRIPT_DIR="${SCRIPT_FILE%/*}"-"${SCRIPT_DIR}"/launch.sh fg Sleigh "$MAXMEM" "" ghidra.pcodeCPort.slgh_compile.SleighCompileLauncher "$@"+"${SCRIPT_DIR}"/launch.sh fg jdk Sleigh "$MAXMEM" "" ghidra.pcodeCPort.slgh_compile.SleighCompileLauncher "$@"diff --git a/Ghidra/RuntimeScripts/Windows/ghidraRun.bat b/Ghidra/RuntimeScripts/Windows/ghidraRun.batindex d9ebaad7f2..36bcb0227a 100644--- a/Ghidra/RuntimeScripts/Windows/ghidraRun.bat+++ b/Ghidra/RuntimeScripts/Windows/ghidraRun.bat@@ -7,5 +7,5 @@ setlocal:: the physical memory available to the OS. Uncomment MAXMEM setting if non-default value is needed.::set MAXMEM=2G-call "%~dp0support\launch.bat" bg Ghidra "%MAXMEM%" "" ghidra.GhidraRun %*+call "%~dp0support\launch.bat" bg jdk Ghidra "%MAXMEM%" "" ghidra.GhidraRun %*diff --git a/Ghidra/RuntimeScripts/Windows/server/svrAdmin.bat b/Ghidra/RuntimeScripts/Windows/server/svrAdmin.batindex 1f8de1281e..debb9b3503 100644--- a/Ghidra/RuntimeScripts/Windows/server/svrAdmin.bat+++ b/Ghidra/RuntimeScripts/Windows/server/svrAdmin.bat@@ -45,4 +45,4 @@ set "CONFIG=%SCRIPT_DIR%..\..\Common\server\server.conf"set VMARGS=-DUserAdmin.invocation=%~n0-call "%~dp0\..\support\launch.bat" fg svrAdmin "%MAXMEM%" "%VMARGS%" ghidra.server.ServerAdmin "%CONFIG%" %*+call "%~dp0\..\support\launch.bat" fg jre svrAdmin "%MAXMEM%" "%VMARGS%" ghidra.server.ServerAdmin "%CONFIG%" %*diff --git a/Ghidra/RuntimeScripts/Windows/support/analyzeHeadless.bat b/Ghidra/RuntimeScripts/Windows/support/analyzeHeadless.batindex 5fc98282a7..2df715a609 100644--- a/Ghidra/RuntimeScripts/Windows/support/analyzeHeadless.bat+++ b/Ghidra/RuntimeScripts/Windows/support/analyzeHeadless.bat@@ -56,4 +56,4 @@ goto Loopsetlocal DisableDelayedExpansion-call "%SCRIPT_DIR%launch.bat" %LAUNCH_MODE% Ghidra-Headless "%MAXMEM%" "%VMARG_LIST%" ghidra.app.util.headless.AnalyzeHeadless %params%+call "%SCRIPT_DIR%launch.bat" %LAUNCH_MODE% jdk Ghidra-Headless "%MAXMEM%" "%VMARG_LIST%" ghidra.app.util.headless.AnalyzeHeadless %params%diff --git a/Ghidra/RuntimeScripts/Windows/support/buildGhidraJar.bat b/Ghidra/RuntimeScripts/Windows/support/buildGhidraJar.batindex 1d58bad254..4ae026640e 100644--- a/Ghidra/RuntimeScripts/Windows/support/buildGhidraJar.bat+++ b/Ghidra/RuntimeScripts/Windows/support/buildGhidraJar.bat@@ -27,4 +27,4 @@ exit /B 1set APP_VMARGS=-DGhidraJarBuilder.Name=%~n0-call "%SUPPORT_DIR%\launch.bat" %LAUNCH_MODE% Ghidra "" "%APP_VMARGS%" ghidra.util.GhidraJarBuilder -main ghidra.JarRun %*+call "%SUPPORT_DIR%\launch.bat" %LAUNCH_MODE% jdk Ghidra "" "%APP_VMARGS%" ghidra.util.GhidraJarBuilder -main ghidra.JarRun %*diff --git a/Ghidra/RuntimeScripts/Windows/support/convertStorage.bat b/Ghidra/RuntimeScripts/Windows/support/convertStorage.batindex e38cbad730..7e6a894651 100644--- a/Ghidra/RuntimeScripts/Windows/support/convertStorage.bat+++ b/Ghidra/RuntimeScripts/Windows/support/convertStorage.bat@@ -6,4 +6,4 @@ setlocal:: maximum heap memory may be change if inadequateset MAXMEM=128M-call "%~dp0launch.bat" fg ConvertStorage "%MAXMEM%" "" ghidra.framework.data.ConvertFileSystem %*+call "%~dp0launch.bat" fg jdk ConvertStorage "%MAXMEM%" "" ghidra.framework.data.ConvertFileSystem %*diff --git a/Ghidra/RuntimeScripts/Windows/support/ghidraDebug.bat b/Ghidra/RuntimeScripts/Windows/support/ghidraDebug.batindex 0cb441162d..5b335a0fb5 100644--- a/Ghidra/RuntimeScripts/Windows/support/ghidraDebug.bat+++ b/Ghidra/RuntimeScripts/Windows/support/ghidraDebug.bat@@ -15,4 +15,4 @@ set LAUNCH_MODE=debug:: NOTE: This variable is ignored if not launching in a debugging mode.set DEBUG_ADDRESS=127.0.0.1:18001-call "%~dp0launch.bat" %LAUNCH_MODE% Ghidra "%MAXMEM%" "" ghidra.GhidraRun %*+call "%~dp0launch.bat" %LAUNCH_MODE% jdk Ghidra "%MAXMEM%" "" ghidra.GhidraRun %*diff --git a/Ghidra/RuntimeScripts/Windows/support/launch.bat b/Ghidra/RuntimeScripts/Windows/support/launch.batindex 639e29141c..4ab672582a 100644--- a/Ghidra/RuntimeScripts/Windows/support/launch.bat+++ b/Ghidra/RuntimeScripts/Windows/support/launch.bat@@ -2,24 +2,26 @@goto continue:showUsage-echo Usage: %0 ^<mode^> ^<name^> ^<max-memory^> "<vmarg-list>" ^<app-classname^> ^<app-args^>...+echo Usage: %0 ^<mode^> ^<java-type^> ^<name^> ^<max-memory^> "<vmarg-list>" ^<app-classname^> ^<app-args^>...echo ^<mode^>: fg run as foreground process in current shell-echo bg run as background process in new shell-echo debug run as foreground process in current shell in debug mode ^(suspend=n^)-echo debug-suspend run as foreground process in current shell in debug mode ^(suspend=y^)-echo NOTE: for all debug modes environment variable DEBUG_ADDRESS may be set to-echo override default debug address of 127.0.0.1:18001+echo bg run as background process in new shell+echo debug run as foreground process in current shell in debug mode ^(suspend=n^)+echo debug-suspend run as foreground process in current shell in debug mode ^(suspend=y^)+echo NOTE: for all debug modes environment variable DEBUG_ADDRESS may be set to+echo override default debug address of 127.0.0.1:18001+echo ^<java-type^>: jdk requires JDK to run+echo jre JRE is sufficient to run (JDK works too)echo ^<name^>: application name used for naming console windowecho ^<max-memory^>: maximum memory heap size in MB ^(e.g., 768M or 2G^). Use "" if default should be used.echo This will generally be upto 1/4 of the physical memory available to the OS. Onecho some systems the default could be much less (particularly for 32-bit OS).echo ^<vmarg-list^>: pass-thru args ^(e.g., "-Xmx512M -Dmyvar=1 -DanotherVar=2"^) - use-echo empty "" if vmargs not needed-echo ^<app-classname^>: application classname ^(e.g., ghidra.GhidraRun ^)+echo empty "" if vmargs not needed+echo ^<app-classame^>: application classname ^(e.g., ghidra.GhidraRun ^)echo ^<app-args^>...: arguments to be passed to the applicationecho.echo Example:-echo %0 debug Ghidra 768M "" ghidra.GhidraRun+echo %0 debug jdk Ghidra 4G "" ghidra.GhidraRunexit /B 1:continue@@ -57,14 +59,15 @@ set INDEX=0for %%A in (%*) do (set /A INDEX=!INDEX!+1if "!INDEX!"=="1" ( set MODE=%%A- ) else if "!INDEX!"=="2" ( set APPNAME=%%A- ) else if "!INDEX!"=="3" ( set MAXMEM=%%~A- ) else if "!INDEX!"=="4" ( if not "%%~A"=="" set VMARG_LIST=%%~A- ) else if "!INDEX!"=="5" ( set CLASSNAME=%%~A+ ) else if "!INDEX!"=="2" ( if %%~A == jre (set JAVA_TYPE_ARG=-java_home) else (set JAVA_TYPE_ARG=-jdk_home)+ ) else if "!INDEX!"=="3" ( set APPNAME=%%A+ ) else if "!INDEX!"=="4" ( set MAXMEM=%%~A+ ) else if "!INDEX!"=="5" ( if not "%%~A"=="" set VMARG_LIST=%%~A+ ) else if "!INDEX!"=="6" ( set CLASSNAME=%%~A) else set ARGS=!ARGS! %%A)-if %INDEX% geq 5 goto continue1+if %INDEX% geq 6 goto continue1echo Incorrect launch usage - missing argument^(s^)goto showUsage@@ -109,13 +112,13 @@ if not %ERRORLEVEL% == 0 (:: Get the JDK that will be used to launch Ghidraset JAVA_HOME=-for /f "delims=*" %%i in ('java -cp "%LS_CPATH%" LaunchSupport "%INSTALL_DIR%" -jdk_home -save') do set JAVA_HOME=%%i+for /f "delims=*" %%i in ('java -cp "%LS_CPATH%" LaunchSupport "%INSTALL_DIR%" %JAVA_TYPE_ARG% -save') do set JAVA_HOME=%%iif "%JAVA_HOME%" == "" (:: No JDK has been setup yet. Let the user choose one.- java -cp "%LS_CPATH%" LaunchSupport "%INSTALL_DIR%" -jdk_home -ask+ java -cp "%LS_CPATH%" LaunchSupport "%INSTALL_DIR%" %JAVA_TYPE_ARG% -ask:: Now that the user chose one, try again to get the JDK that will be used to launch Ghidra- for /f "delims=*" %%i in ('java -cp "%LS_CPATH%" LaunchSupport "%INSTALL_DIR%" -jdk_home -save') do set JAVA_HOME=%%i+ for /f "delims=*" %%i in ('java -cp "%LS_CPATH%" LaunchSupport "%INSTALL_DIR%" %JAVA_TYPE_ARG% -save') do set JAVA_HOME=%%iif "!JAVA_HOME!" == "" (echo.echo Failed to find a supported JDK. Please refer to the Ghidra Installation Guide's Troubleshooting section.diff --git a/Ghidra/RuntimeScripts/Windows/support/pythonRun.bat b/Ghidra/RuntimeScripts/Windows/support/pythonRun.batindex 3622672d2b..bbfede632c 100644--- a/Ghidra/RuntimeScripts/Windows/support/pythonRun.bat+++ b/Ghidra/RuntimeScripts/Windows/support/pythonRun.bat@@ -24,4 +24,4 @@ set DEBUG_ADDRESS=127.0.0.1:13002set VMARG_LIST=-XX:ParallelGCThreads=2set VMARG_LIST=%VMARG_LIST% -XX:CICompilerCount=2-call "%~dp0launch.bat" %LAUNCH_MODE% Ghidra-Python "%MAXMEM%" "%VMARG_LIST%" ghidra.python.PythonRun %params%+call "%~dp0launch.bat" %LAUNCH_MODE% jdk Ghidra-Python "%MAXMEM%" "%VMARG_LIST%" ghidra.python.PythonRun %params%diff --git a/Ghidra/RuntimeScripts/Windows/support/sleigh.bat b/Ghidra/RuntimeScripts/Windows/support/sleigh.batindex 038ecaa270..8b602f8024 100644--- a/Ghidra/RuntimeScripts/Windows/support/sleigh.bat+++ b/Ghidra/RuntimeScripts/Windows/support/sleigh.bat@@ -6,4 +6,4 @@ setlocal:: maximum heap memory may be change if inadequateset MAXMEM=256M-call "%~dp0launch.bat" fg Sleigh "%MAXMEM%" "" ghidra.pcodeCPort.slgh_compile.SleighCompileLauncher %*+call "%~dp0launch.bat" fg jdk Sleigh "%MAXMEM%" "" ghidra.pcodeCPort.slgh_compile.SleighCompileLauncher %*