diff --git a/Ghidra/Features/Base/ghidra_scripts/BuildGhidraJarScript.java b/Ghidra/Features/Base/ghidra_scripts/BuildGhidraJarScript.java index b6a3f8e809..675904cb82 100644 --- a/Ghidra/Features/Base/ghidra_scripts/BuildGhidraJarScript.java +++ b/Ghidra/Features/Base/ghidra_scripts/BuildGhidraJarScript.java @@ -17,10 +17,9 @@ //@category Examples import java.io.File; -import java.util.*; +import java.util.List; import generic.jar.ApplicationModule; -import generic.jar.ResourceFile; import ghidra.app.script.GhidraScript; import ghidra.framework.Application; import ghidra.util.GhidraJarBuilder; @@ -32,8 +31,7 @@ public class BuildGhidraJarScript extends GhidraScript { @Override public void run() throws Exception { - GhidraJarBuilder builder = - new GhidraJarBuilder(toFiles(Application.getApplicationRootDirectories())); + GhidraJarBuilder builder = new GhidraJarBuilder(Application.getApplicationLayout()); builder.setMainClass("ghidra.JarRun"); // default is ghidra.JarRun, only here if you want // to change it to something else. @@ -69,12 +67,4 @@ public class BuildGhidraJarScript extends GhidraScript { // uncomment the following line to create a src zip for debugging. // builder.buildSrcZip(new File(installDir, "GhidraSrc.zip"), monitor); } - - private List toFiles(Collection resourceFiles) { - List fileList = new ArrayList<>(); - for (ResourceFile resourceFile : resourceFiles) { - fileList.add(resourceFile.getFile(true)); - } - return fileList; - } } diff --git a/Ghidra/Features/Base/src/main/java/ghidra/util/GhidraJarBuilder.java b/Ghidra/Features/Base/src/main/java/ghidra/util/GhidraJarBuilder.java index 7ded06d9a2..5dd1622017 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/util/GhidraJarBuilder.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/util/GhidraJarBuilder.java @@ -25,28 +25,24 @@ import java.util.zip.*; import generic.jar.*; import ghidra.GhidraApplicationLayout; import ghidra.GhidraLaunchable; -import ghidra.framework.Application; -import ghidra.framework.HeadlessGhidraApplicationConfiguration; +import ghidra.framework.*; import ghidra.framework.plugintool.dialog.ExtensionUtils; import ghidra.util.classfinder.ClassFinder; import ghidra.util.classfinder.ClassSearcher; import ghidra.util.exception.AssertException; import ghidra.util.exception.CancelledException; import ghidra.util.task.TaskMonitor; -import ghidra.util.task.TaskMonitorAdapter; import utilities.util.FileUtilities; +import utility.application.ApplicationLayout; import utility.module.ModuleUtilities; public class GhidraJarBuilder implements GhidraLaunchable { private static final String ROOT = "_Root/"; private static final String ROOT_GHIDRA = "_Root/Ghidra/"; - private static final String LIBS_FILE_MODULE_KEY = "Module: "; // this is set in the buildGhidraJar batch/script files - private static final String GHIDRA_DIR = "Ghidra.Install.Root.Dir"; private static final String INVOCATION_NAME_PROPERTY = "GhidraJarBuilder.Name"; - private static HashMap> libsMap = new HashMap<>(); private List rootGhidraDirs = new ArrayList<>(); private List allModules; private Set includedModules = new HashSet<>(); @@ -57,19 +53,18 @@ public class GhidraJarBuilder implements GhidraLaunchable { private Pattern extensionPointSuffixPattern; private List extensionPointClasses = new ArrayList<>(); private ClassLoader classLoader; - private boolean inGradleMode = false; private Set processedJars = new HashSet<>(); public GhidraJarBuilder() { // Required for GhidraLaunchable } - public GhidraJarBuilder(List rootDirs) throws IOException { - for (File file : rootDirs) { - File rgd = file.getCanonicalFile(); + public GhidraJarBuilder(ApplicationLayout layout) throws IOException { + for (ResourceFile file : layout.getApplicationRootDirs()) { + File rgd = file.getFile(false).getCanonicalFile(); rootGhidraDirs.add(rgd); } - allModules = findAllModules(); + allModules = findAllModules(layout); Collections.sort(allModules); for (ApplicationModule module : allModules) { if (includeByDefault(module)) { @@ -203,7 +198,7 @@ public class GhidraJarBuilder implements GhidraLaunchable { for (ApplicationModule module : moduleList) { writeModuleClassesAndResources(jar, module); - if (!excludeHelp && !inGradleMode) { + if (!excludeHelp) { writeModuleHelp(jar, module); } } @@ -360,16 +355,6 @@ public class GhidraJarBuilder implements GhidraLaunchable { private void writeModuleClassesAndResources(Jar jar, ApplicationModule module) throws CancelledException, IOException { - if (inGradleMode) { - File gradleBuildFileForModule = - new File(module.getModuleDir(), "build/libs/" + module.getName() + ".jar"); - processJarFile(jar, gradleBuildFileForModule, module); - File gradleBuildFileForGPLModule = - new File(module.getModuleDir(), "build/data/lib/" + module.getName() + ".jar"); - processJarFile(jar, gradleBuildFileForGPLModule, module); - processExternalLibs(jar, module); - return; - } // NOTE: This only works in a distribution where the 3rd party jars live in each // module's libs directory File binDir = new File(module.getModuleDir(), "bin/main"); @@ -380,18 +365,6 @@ public class GhidraJarBuilder implements GhidraLaunchable { processLibDir(jar, module); } - private void processExternalLibs(Jar jar, ApplicationModule module) - throws CancelledException, IOException { - List list = libsMap.get(module.getName()); - if (list == null) { - return; - } - for (String libPath : list) { - File file = new File(libPath); - processJarFile(jar, file, module); - } - } - private void processLibDir(Jar jar, ApplicationModule module) throws CancelledException, IOException { File libDir = new File(module.getModuleDir(), "lib"); @@ -585,16 +558,34 @@ public class GhidraJarBuilder implements GhidraLaunchable { } return manifest; } - - private List findAllModules() { + + private List findAllModules(ApplicationLayout layout) throws IOException { List modules = new ArrayList<>(); - for (File appRoot : rootGhidraDirs) { - findModules(appRoot, appRoot, modules); - findModules(appRoot, new File(appRoot, "../GPL"), modules); - + + for (GModule module : layout.getModules().values()) { + File moduleDir = module.getModuleRoot().getFile(false).getCanonicalFile(); + File rootDir = getModuleRootDir(moduleDir); + modules.add(new ApplicationModule(rootDir, moduleDir)); } + return modules; } + + private File getModuleRootDir(File moduleDir) { + // Look in GPL directories too + List rootDirs = new ArrayList<>(rootGhidraDirs); + for (File rootDir : rootGhidraDirs) { + rootDirs.add(new File(rootDir.getParentFile(), "GPL")); + } + + // Check each root directory to see if it contains the module + for (File rootDir : rootDirs) { + if (FileUtilities.isPathContainedWithin(rootDir, moduleDir)) { + return rootDir; + } + } + throw new AssertException("Module root directory could not be determined: " + moduleDir); + } private String getPathFromRoot(String rootPath, File file) { String filePath = file.getAbsolutePath(); @@ -604,23 +595,6 @@ public class GhidraJarBuilder implements GhidraLaunchable { return filePath.substring(rootPath.length() + 1); } - private void findModules(File rootAppDir, File dir, List modules) { - File moduleManifest = new File(dir, "Module.manifest"); - if (moduleManifest.exists()) { - ApplicationModule module = new ApplicationModule(rootAppDir, dir); - modules.add(module); - return; // modules can't live in other modules; - } - File[] listFiles = dir.listFiles(); - if (listFiles != null) { - for (File file : listFiles) { - if (file.isDirectory()) { - findModules(rootAppDir, file, modules); - } - } - } - } - private void checkExtensionPointClass(String path, InputStream inputStream) { // remove .class path = path.substring(0, path.length() - 6); @@ -931,44 +905,15 @@ public class GhidraJarBuilder implements GhidraLaunchable { } } - private static void parseLibsFile(String libsFilePath) { - try { - List lines = FileUtilities.getLines(new File(libsFilePath)); - - List libPaths = new ArrayList<>(); - String currentModule = null; - for (String line : lines) { - if (line.startsWith(LIBS_FILE_MODULE_KEY)) { - if (currentModule != null) { - libsMap.put(currentModule, libPaths); - libPaths = new ArrayList<>(); - } - currentModule = line.substring(LIBS_FILE_MODULE_KEY.length()).trim(); - } - else { - libPaths.add(line.trim()); - } - } - } - catch (IOException e) { - System.err.println("Could not read lib paths file: " + libsFilePath); - System.exit(0); - } - } - private static void usage(String[] args) { for (int i = 0; i < args.length; i++) { System.err.println("arg " + i + ": " + args[i]); } String invocationName = System.getProperty(INVOCATION_NAME_PROPERTY); - String property = System.getProperty(GHIDRA_DIR); StringBuffer buf = new StringBuffer(); buf.append("\nUsage: "); - buf.append(invocationName != null ? invocationName : "GhidraJarBuilder "); - if (property == null) { - buf.append(" [ ...] "); - } + buf.append(invocationName != null ? invocationName : "GhidraJarBuilder"); buf.append( " [-output ] [-srczip ] [-bin ] [-main ]\n"); System.err.println(buf.toString()); @@ -992,17 +937,10 @@ public class GhidraJarBuilder implements GhidraLaunchable { usage(args); } - List ghidraDirs = new ArrayList<>(); File outputFile = null; File srczip = null; File extraBinDir = null; String mainClassArg = null; - boolean usingGradle = false; - - String property = System.getProperty(GHIDRA_DIR); - if (property != null) { - ghidraDirs.add(new File(property)); - } for (int i = 0; i < args.length; i++) { String arg = args[i]; @@ -1030,28 +968,14 @@ public class GhidraJarBuilder implements GhidraLaunchable { } mainClassArg = args[++i]; } - else if (arg.equals("-gradle")) { - if (i == args.length - 1) { - usage(args); - } - usingGradle = true; - parseLibsFile(args[++i]); - } - else if (arg.startsWith("-")) { + else { usage(args); } - else { - ghidraDirs.add(new File(arg)); - } - } - if (ghidraDirs.isEmpty()) { - usage(args); } if (outputFile == null) { outputFile = new File("ghidra.jar"); } - System.out.println("Ghidra dirs = " + ghidraDirs); System.out.println("Output file = " + outputFile); if (srczip != null) { System.out.println("Source Zip File = " + srczip); @@ -1061,13 +985,10 @@ public class GhidraJarBuilder implements GhidraLaunchable { } try { - GhidraJarBuilder builder = new GhidraJarBuilder(ghidraDirs); + GhidraJarBuilder builder = new GhidraJarBuilder(layout); if (mainClassArg != null) { builder.setMainClass(mainClassArg); } - if (usingGradle) { - builder.setGradleMode(); - } builder.addExcludedFileExtension(".pdf"); // builder.addExcludedFileExtension(".htm"); @@ -1082,10 +1003,10 @@ public class GhidraJarBuilder implements GhidraLaunchable { System.out.println("Exclude " + module.getName()); } - builder.buildJar(outputFile, extraBinDir, TaskMonitorAdapter.DUMMY_MONITOR); + builder.buildJar(outputFile, extraBinDir, TaskMonitor.DUMMY); if (srczip != null) { - builder.buildSrcZip(srczip, TaskMonitorAdapter.DUMMY_MONITOR); + builder.buildSrcZip(srczip, TaskMonitor.DUMMY); } } catch (Exception e) { @@ -1099,8 +1020,4 @@ public class GhidraJarBuilder implements GhidraLaunchable { return new File(ghidraRootDir, "application.properties"); } - private void setGradleMode() { - inGradleMode = true; - } - } diff --git a/Ghidra/Features/GhidraServer/src/main/java/ghidra/server/ServerAdmin.java b/Ghidra/Features/GhidraServer/src/main/java/ghidra/server/ServerAdmin.java index f5f3580822..5905018f95 100644 --- a/Ghidra/Features/GhidraServer/src/main/java/ghidra/server/ServerAdmin.java +++ b/Ghidra/Features/GhidraServer/src/main/java/ghidra/server/ServerAdmin.java @@ -52,7 +52,7 @@ public class ServerAdmin implements GhidraLaunchable { * The following properties may be set: *
 	 *   UserAdmin.invocation - identifies the name of the application used when displaying usage text.
-	 *   UserAdmin.serverDir - identifies the server directory instead of passing on command line.
+	 *   UserAdmin.config - identifies the config file instead of passing on command line.
 	 * 
* @param args command line arguments */ @@ -75,22 +75,18 @@ public class ServerAdmin implements GhidraLaunchable { * The following properties may be set: *
 	 *   UserAdmin.invocation - identifies the name of the application used when displaying usage text.
-	 *   UserAdmin.serverDir - identifies the server directory instead of passing on command line.
+	 *   UserAdmin.config - identifies the config file instead of passing on command line.
 	 * 
* @param args command line arguments */ public void execute(String[] args) { - File serverDir = null; - int ix = 0; - if (args.length != 0 && !args[0].startsWith("-")) { - serverDir = new File(args[ix++]); - } - else { - serverDir = getServerDirFromConfig(); - } + String configFilePath = args.length != 0 && !args[0].startsWith("-") ? args[ix++] + : System.getProperty(CONFIG_FILE_PROPERTY); + + File serverDir = getServerDirFromConfig(configFilePath); if (serverDir == null || (args.length - ix) == 0) { displayUsage(""); System.exit(-1); @@ -105,9 +101,7 @@ public class ServerAdmin implements GhidraLaunchable { System.exit(-1); } - if (propertyUsed) { - System.out.println("Using server directory: " + serverDir); - } + System.out.println("Using server directory: " + serverDir); File userFile = new File(serverDir, UserManager.USER_PASSWORD_FILE); if (!serverDir.isDirectory() || !userFile.isFile()) { @@ -423,13 +417,14 @@ public class ServerAdmin implements GhidraLaunchable { } } - private File getServerDirFromConfig() { - String p = System.getProperty(CONFIG_FILE_PROPERTY); - if (p == null) { + private File getServerDirFromConfig(String configFilePath) { + System.out.println("Using config file: " + configFilePath); + + if (configFilePath == null) { return null; } - propertyUsed = true; - File configFile = new File(p); + + File configFile = new File(configFilePath); if (!configFile.exists()) { System.out.println("Config file not found: " + configFile.getAbsolutePath()); @@ -455,8 +450,9 @@ public class ServerAdmin implements GhidraLaunchable { } } - p = config.getProperty(SERVER_DIR_CONFIG_PROPERTY); + String p = config.getProperty(SERVER_DIR_CONFIG_PROPERTY); if (p == null) { + System.out.println("Failed to find property: " + SERVER_DIR_CONFIG_PROPERTY); return null; } File dir = new File(p); @@ -482,8 +478,8 @@ public class ServerAdmin implements GhidraLaunchable { } String invocationName = System.getProperty(INVOCATION_NAME_PROPERTY); System.err.println("Usage: " + - (invocationName != null ? invocationName : "java " + UserAdmin.class.getName()) + - (propertyUsed ? "" : " ") + " [] [] ..."); + (invocationName != null ? invocationName : "java " + ServerAdmin.class.getName()) + + (invocationName != null ? "" : " ") + " [] [] ..."); System.err.println("\nSupported commands:"); System.err.println(" -add [--p]"); System.err.println( diff --git a/Ghidra/RuntimeScripts/Linux/server/svrAdmin b/Ghidra/RuntimeScripts/Linux/server/svrAdmin index 702ca83c49..deb47eec9d 100755 --- a/Ghidra/RuntimeScripts/Linux/server/svrAdmin +++ b/Ghidra/RuntimeScripts/Linux/server/svrAdmin @@ -45,8 +45,8 @@ fi OWNER="$(grep '^wrapper.app.account=' "${CONFIG}" | sed -e 's/^.*=\(.*\)\s*.*$/\1/')" if [ -z "${OWNER}" -o "${OWNER}" = "$(whoami)" ]; then - VMARGS="-DUserAdmin.invocation=$(basename "${SCRIPT_FILE}") -DUserAdmin.config=\"${CONFIG}\"" - "${SCRIPT_DIR}"/../support/launch.sh fg svrAdmin "${MAXMEM}" "$VMARGS" ghidra.server.ServerAdmin "$@" + VMARGS="-DUserAdmin.invocation=$(basename "${SCRIPT_FILE}")" + "${SCRIPT_DIR}"/../support/launch.sh fg svrAdmin "${MAXMEM}" "$VMARGS" ghidra.server.ServerAdmin "${CONFIG}" "$@" else echo "Running svrAdmin with $SUDO as ${OWNER} ..." $SUDO -u $OWNER "$0" "$@" diff --git a/Ghidra/RuntimeScripts/Linux/support/buildGhidraJar b/Ghidra/RuntimeScripts/Linux/support/buildGhidraJar index 66b87cb0c2..c378218c75 100755 --- a/Ghidra/RuntimeScripts/Linux/support/buildGhidraJar +++ b/Ghidra/RuntimeScripts/Linux/support/buildGhidraJar @@ -25,7 +25,7 @@ if [ ! -d "${GHIDRA_ROOT_DIR}" ]; then fi # Set required VMARGS for jar builder application -APP_VMARGS="-DGhidraJarBuilder.Name=$(basename "${SCRIPT_FILE}") -DGhidra.Install.Root.Dir=\"${GHIDRA_ROOT_DIR}\" " +APP_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 "$@" diff --git a/Ghidra/RuntimeScripts/Windows/server/ghidraSvr.bat b/Ghidra/RuntimeScripts/Windows/server/ghidraSvr.bat index 98a2bc2310..09a4979711 100644 --- a/Ghidra/RuntimeScripts/Windows/server/ghidraSvr.bat +++ b/Ghidra/RuntimeScripts/Windows/server/ghidraSvr.bat @@ -11,7 +11,7 @@ rem runtime which has been configured into the system PATH ahead of other Java rem it may be necessary to explicitly specify the path to the installation by setting JAVA_HOME rem below: -rem set JAVA_HOME= +rem set "JAVA_HOME=" setlocal enabledelayedexpansion @@ -50,7 +50,7 @@ if "%IS_ADMIN%"=="NO" ( rem Find the script directory rem %~dsp0 is location of current script under NT -set _REALPATH=%~dp0 +set "_REALPATH=%~dp0" set APP_NAME=ghidraSvr set APP_LONG_NAME=Ghidra Server @@ -64,26 +64,26 @@ if exist "%_REALPATH%..\Ghidra\" goto normal rem NOTE: If adjusting JAVA command assignment - do not attempt to add parameters (e.g., -d64, -version:1.7, etc.) rem Development Environment -set GHIDRA_HOME=%_REALPATH%..\..\..\.. -set WRAPPER_CONF=%_REALPATH%..\..\Common\server\server.conf -set DATA_DIR=%GHIDRA_HOME%\%MODULE_DIR%\build\data -set CLASSPATH_FRAG=%GHIDRA_HOME%\%MODULE_DIR%\build\dev-meta\classpath.frag -set LS_CPATH=%GHIDRA_HOME%\GhidraBuild\LaunchSupport\bin\main +set "GHIDRA_HOME=%_REALPATH%..\..\..\.." +set "WRAPPER_CONF=%_REALPATH%..\..\Common\server\server.conf" +set "DATA_DIR=%GHIDRA_HOME%\%MODULE_DIR%\build\data" +set "CLASSPATH_FRAG=%GHIDRA_HOME%\%MODULE_DIR%\build\dev-meta\classpath.frag" +set "LS_CPATH=%GHIDRA_HOME%\GhidraBuild\LaunchSupport\bin\main" goto lab1 :normal -set GHIDRA_HOME=%_REALPATH%.. -set WRAPPER_CONF=%_REALPATH%server.conf -set DATA_DIR=%GHIDRA_HOME%\%MODULE_DIR%\data -set CLASSPATH_FRAG=%GHIDRA_HOME%\%MODULE_DIR%\data\classpath.frag -set LS_CPATH=%GHIDRA_HOME%\support\LaunchSupport.jar +set "GHIDRA_HOME=%_REALPATH%.." +set "WRAPPER_CONF=%_REALPATH%server.conf" +set "DATA_DIR=%GHIDRA_HOME%\%MODULE_DIR%\data" +set "CLASSPATH_FRAG=%GHIDRA_HOME%\%MODULE_DIR%\data\classpath.frag" +set "LS_CPATH=%GHIDRA_HOME%\support\LaunchSupport.jar" :lab1 rem set WRAPPER_HOME to unpacked yajsw location (crazy FOR syntax to set variable from command output) for /F "usebackq delims=" %%p in (`dir "%DATA_DIR%" /ad /b ^| findstr "^%WRAPPER_NAME_PREFIX%"`) do set WRAPPER_DIRNAME=%%p -set WRAPPER_HOME=%DATA_DIR%\%WRAPPER_DIRNAME% +set "WRAPPER_HOME=%DATA_DIR%\%WRAPPER_DIRNAME%" if not exist "%WRAPPER_HOME%\" ( echo. @@ -104,8 +104,7 @@ set ERROR=ERROR: JAVA_HOME is not set and no 'java' command could be found in yo goto reportError :findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA=%JAVA_HOME%\bin\java.exe +set "JAVA=%JAVA_HOME%\bin\java.exe" if exist "%JAVA%" goto lab2 set ERROR=ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -122,15 +121,7 @@ if "%JAVA_HOME%" == "" ( ) rem reestablish JAVA path based upon final JAVA_HOME -set JAVA=%JAVA_HOME%\bin\java.exe - -set OS_NAME=win32 -"%JAVA%" -version 2>&1 | findstr /I " 64-Bit " >NUL -if errorlevel 0 ( - set OS_NAME=win64 -) - -set OS_DIR=%GHIDRA_HOME%\%MODULE_DIR%\os\%OS_NAME% +set "JAVA=%JAVA_HOME%\bin\java.exe" :: set DEBUG=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=*:18888 diff --git a/Ghidra/RuntimeScripts/Windows/server/svrAdmin.bat b/Ghidra/RuntimeScripts/Windows/server/svrAdmin.bat index ea7993ca45..1f8de1281e 100644 --- a/Ghidra/RuntimeScripts/Windows/server/svrAdmin.bat +++ b/Ghidra/RuntimeScripts/Windows/server/svrAdmin.bat @@ -31,18 +31,18 @@ set MAXMEM=128M :: '% ~' dereferences the value in param 0 :: 'd' - drive :: 'p' - path (without filename) -set SCRIPT_DIR=%~dp0 +set "SCRIPT_DIR=%~dp0" :: Production Environment -set CONFIG=%SCRIPT_DIR%.\server.conf +set "CONFIG=%SCRIPT_DIR%.\server.conf" if exist "%CONFIG%" goto continue :: Development Environment -set CONFIG=%SCRIPT_DIR%..\..\Common\server\server.conf +set "CONFIG=%SCRIPT_DIR%..\..\Common\server\server.conf" :continue -set VMARGS=-DUserAdmin.invocation="%0" -DUserAdmin.config="%CONFIG%" +set VMARGS=-DUserAdmin.invocation=%~n0 -call "%~dp0\..\support\launch.bat" fg svrAdmin "%MAXMEM%" "%VMARGS%" ghidra.server.ServerAdmin %* +call "%~dp0\..\support\launch.bat" fg svrAdmin "%MAXMEM%" "%VMARGS%" ghidra.server.ServerAdmin "%CONFIG%" %* diff --git a/Ghidra/RuntimeScripts/Windows/server/svrInstall.bat b/Ghidra/RuntimeScripts/Windows/server/svrInstall.bat index 1314f8a174..2df9605318 100644 --- a/Ghidra/RuntimeScripts/Windows/server/svrInstall.bat +++ b/Ghidra/RuntimeScripts/Windows/server/svrInstall.bat @@ -3,7 +3,7 @@ setlocal rem Find the script directory rem %~dsp0 is location of current script under NT -set _REALPATH=%~dp0 +set "_REALPATH=%~dp0" call "%_REALPATH%\ghidraSvr" install diff --git a/Ghidra/RuntimeScripts/Windows/server/svrUninstall.bat b/Ghidra/RuntimeScripts/Windows/server/svrUninstall.bat index 75e1905064..ac5131418b 100644 --- a/Ghidra/RuntimeScripts/Windows/server/svrUninstall.bat +++ b/Ghidra/RuntimeScripts/Windows/server/svrUninstall.bat @@ -3,7 +3,7 @@ setlocal rem Find the script directory rem %~dsp0 is location of current script under NT -set _REALPATH=%~dp0 +set "_REALPATH=%~dp0" call "%_REALPATH%\ghidraSvr" uninstall diff --git a/Ghidra/RuntimeScripts/Windows/support/analyzeHeadless.bat b/Ghidra/RuntimeScripts/Windows/support/analyzeHeadless.bat index aa4545b18b..e972b07cae 100644 --- a/Ghidra/RuntimeScripts/Windows/support/analyzeHeadless.bat +++ b/Ghidra/RuntimeScripts/Windows/support/analyzeHeadless.bat @@ -24,7 +24,7 @@ set VMARG_LIST=-XX:ParallelGCThreads=2 set VMARG_LIST=%VMARG_LIST% -XX:CICompilerCount=2 :: store current path -set filepath=%~dp0 +set "filepath=%~dp0" :: Loop through parameters (if there aren't any, just continue) and store :: in params variable. diff --git a/Ghidra/RuntimeScripts/Windows/support/buildGhidraJar.bat b/Ghidra/RuntimeScripts/Windows/support/buildGhidraJar.bat index 1e618fa944..07f1c4dddc 100644 --- a/Ghidra/RuntimeScripts/Windows/support/buildGhidraJar.bat +++ b/Ghidra/RuntimeScripts/Windows/support/buildGhidraJar.bat @@ -8,9 +8,9 @@ setlocal set LAUNCH_MODE=fg :: Sets SCRIPT_DIR to the directory that contains this file (ends with '\') -set SCRIPT_DIR=%~dp0 +set "SCRIPT_DIR=%~dp0" -set GHIDRA_ROOT_DIR=%SCRIPT_DIR%..\Ghidra +set "GHIDRA_ROOT_DIR=%SCRIPT_DIR%..\Ghidra" if exist "%GHIDRA_ROOT_DIR%" goto continue echo This script does not support development mode use @@ -18,6 +18,6 @@ exit /B 1 :continue -set APP_VMARGS=-DGhidraJarBuilder.Name=%0 -DGhidra.Install.Root.Dir=%GHIDRA_ROOT_DIR% +set APP_VMARGS=-DGhidraJarBuilder.Name=%~n0 call "%~dp0launch.bat" %LAUNCH_MODE% Ghidra "" "%APP_VMARGS%" ghidra.util.GhidraJarBuilder -main ghidra.JarRun %* diff --git a/Ghidra/RuntimeScripts/Windows/support/createPdbXmlFiles.bat b/Ghidra/RuntimeScripts/Windows/support/createPdbXmlFiles.bat index 44826dd39e..10a7c7d8f0 100644 --- a/Ghidra/RuntimeScripts/Windows/support/createPdbXmlFiles.bat +++ b/Ghidra/RuntimeScripts/Windows/support/createPdbXmlFiles.bat @@ -11,16 +11,16 @@ setlocal REM Get parent of current folder -set SCRIPT_DIR=%~dp0 +set "SCRIPT_DIR=%~dp0" -set GHIDRA_DIR=%SCRIPT_DIR%..\Ghidra +set "GHIDRA_DIR=%SCRIPT_DIR%..\Ghidra" set OS_DIR=os REM Production Environment if exist "%GHIDRA_DIR%" goto continue REM Development Environment -set GHIDRA_DIR=%SCRIPT_DIR%..\..\.. +set "GHIDRA_DIR=%SCRIPT_DIR%..\..\.." set OS_DIR=build\os :continue @@ -35,7 +35,7 @@ if exist "%PROGRAMFILES(X86)%" ( set OS_TYPE=win32 ) -set PDB_EXE=%GHIDRA_DIR%\Features\PDB\%OS_DIR%\%OS_TYPE%\pdb.exe +set "PDB_EXE=%GHIDRA_DIR%\Features\PDB\%OS_DIR%\%OS_TYPE%\pdb.exe" if not exist "%PDB_EXE%" ( echo "%PDB_EXE% not found" diff --git a/Ghidra/RuntimeScripts/Windows/support/launch.bat b/Ghidra/RuntimeScripts/Windows/support/launch.bat index 9bee1566cf..5621f4e895 100644 --- a/Ghidra/RuntimeScripts/Windows/support/launch.bat +++ b/Ghidra/RuntimeScripts/Windows/support/launch.bat @@ -36,7 +36,7 @@ for /f "tokens=2" %%# in ("%cmdcmdline%") do if /i "%%#" equ "/c" set DOUBLE_CLI :: '% ~' dereferences the value in param 0 :: 'd' - drive :: 'p' - path (without filename) -set SUPPORT_DIR=%~dp0 +set "SUPPORT_DIR=%~dp0" :: :: Parse arguments @@ -63,20 +63,20 @@ goto showUsage :: :: Production Environment :: -set INSTALL_DIR=%SUPPORT_DIR%..\ -set CPATH=%INSTALL_DIR%Ghidra\Framework\Utility\lib\Utility.jar -set LS_CPATH=%SUPPORT_DIR%LaunchSupport.jar -set DEBUG_LOG4J=%SUPPORT_DIR%debug.log4j.xml +set "INSTALL_DIR=%SUPPORT_DIR%..\" +set "CPATH=%INSTALL_DIR%Ghidra\Framework\Utility\lib\Utility.jar" +set "LS_CPATH=%SUPPORT_DIR%LaunchSupport.jar" +set "DEBUG_LOG4J=%SUPPORT_DIR%debug.log4j.xml" if exist "%INSTALL_DIR%Ghidra" goto continue2 :: :: Development Environment :: -set INSTALL_DIR=%INSTALL_DIR%..\..\..\ -set CPATH=%INSTALL_DIR%Ghidra\Framework\Utility\bin\main -set LS_CPATH=%INSTALL_DIR%GhidraBuild\LaunchSupport\bin\main -set DEBUG_LOG4J=%INSTALL_DIR%Ghidra\RuntimeScripts\Common\support\debug.log4j.xml +set "INSTALL_DIR=%INSTALL_DIR%..\..\..\" +set "CPATH=%INSTALL_DIR%Ghidra\Framework\Utility\bin\main" +set "LS_CPATH=%INSTALL_DIR%GhidraBuild\LaunchSupport\bin\main" +set "DEBUG_LOG4J=%INSTALL_DIR%Ghidra\RuntimeScripts\Common\support\debug.log4j.xml" :continue2 @@ -108,7 +108,7 @@ if "%JAVA_HOME%" == "" ( goto exit1 ) ) -set JAVA_CMD=%JAVA_HOME%\bin\java +set "JAVA_CMD=%JAVA_HOME%\bin\java" :: Get the configurable VM arguments from the launch properties for /f "delims=*" %%i in ('java -cp "%LS_CPATH%" LaunchSupport "%INSTALL_DIR%\" -vmargs') do set VMARG_LIST=%VMARG_LIST% %%i diff --git a/Ghidra/RuntimeScripts/Windows/support/pythonRun.bat b/Ghidra/RuntimeScripts/Windows/support/pythonRun.bat index bc934c12a1..650e9f172b 100644 --- a/Ghidra/RuntimeScripts/Windows/support/pythonRun.bat +++ b/Ghidra/RuntimeScripts/Windows/support/pythonRun.bat @@ -26,6 +26,6 @@ set VMARG_LIST=-XX:ParallelGCThreads=2 set VMARG_LIST=%VMARG_LIST% -XX:CICompilerCount=2 :: store current path -set filepath=%~dp0 +set "filepath=%~dp0" call "%filepath%launch.bat" %LAUNCH_MODE% Ghidra-Python "%MAXMEM%" "%VMARG_LIST%" ghidra.python.PythonRun %params%