GP-693: Fixed additional issues with Ghidra and its supporting launch

scripts not being able to run correctly on Windows when an ampersand was
in the path. Also fixed an issue with svrAdmin.bat and
buildGhidraJar.bat not working if the Ghidra path contained a space.
This commit is contained in:
Ryan Kurtz
2021-02-19 10:46:20 -05:00
parent 61096c5fdf
commit 95b37d2ce1
10 changed files with 47 additions and 65 deletions

View File

@@ -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,8 @@ 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_HOME=%JAVA_HOME:"=%"
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 +122,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

View File

@@ -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="%0"
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%" %*

View File

@@ -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

View File

@@ -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

View File

@@ -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.

View File

@@ -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

View File

@@ -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"

View File

@@ -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%