Candidate release of source code.

This commit is contained in:
Dan
2019-03-26 13:45:32 -04:00
parent db81e6b3b0
commit 79d8f164f8
12449 changed files with 2800756 additions and 16 deletions

View File

@@ -0,0 +1,15 @@
:: Ghidra launch
@echo off
setlocal
:: Maximum heap memory size
:: Default for Windows 32-bit is 768M and 64-bit is 1024M
:: Raising the value too high may cause a silent failure where
:: Ghidra fails to launch.
:: Uncomment MAXMEM setting if non-default value is needed
::set MAXMEM=768M
call "%~dp0support\launch.bat" bg Ghidra "%MAXMEM%" "" ghidra.GhidraRun %*

View File

@@ -0,0 +1,185 @@
@echo off
rem ---------------------------------------------------------------------------------------
rem Ghidra Server Script (see svrREADME.html for usage details)
rem Usage: ghidraSvr [ console | status | install | uninstall | start | stop | restart ]
rem ---------------------------------------------------------------------------------------
rem The Java 11 (or later) runtime installation must either be on the system path or identified
rem by setting the JAVA_HOME environment variable. If not using a formally installed Java
rem runtime which has been configured into the system PATH ahead of other Java installations
rem it may be necessary to explicitly specify the path to the installation by setting JAVA_HOME
rem below:
rem JAVA_HOME=
setlocal enabledelayedexpansion
set OPTION=%1
goto lab0
:usage
echo.
echo Usage: %0 { console ^| start ^| stop ^| restart ^| status }
echo.
set DOUBLE_CLICKED=n
for /f "tokens=2" %%# in ("%cmdcmdline%") do if /i "%%#" equ "/c" set DOUBLE_CLICKED=y
if "!DOUBLE_CLICKED!"=="y" (
pause
)
exit /B 1
:lab0
if "%OPTION%"=="" (
goto usage
)
set IS_ADMIN=NO
whoami /groups | findstr "S-1-16-12288 " >NUL && set IS_ADMIN=YES
if "%IS_ADMIN%"=="NO" (
rem The following command options require admin
if "%OPTION%"=="start" goto adminFail
if "%OPTION%"=="stop" goto adminFail
if "%OPTION%"=="install" goto adminFail
if "%OPTION%"=="uninstall" goto adminFail
if "%OPTION%"=="restart" goto adminFail
)
rem Find the script directory
rem %~dsp0 is location of current script under NT
set _REALPATH=%~dp0
set APP_NAME=ghidraSvr
set APP_LONG_NAME=Ghidra Server
set MODULE_DIR=Ghidra\Features\GhidraServer
set WRAPPER_NAME_PREFIX=yajsw
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
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
: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%
if not exist "%WRAPPER_HOME%\" (
echo.
echo %WRAPPER_NAME_PREFIX% not found
echo.
exit /B 1
)
echo Using service wrapper: %WRAPPER_DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA=java.exe
%JAVA% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto lab2
set ERROR=ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
goto reportError
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
set ERROR=ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
goto reportError
:lab2
:: Make sure some kind of java is on the path. It's required to run the LaunchSupport program.
java -version >nul 2>nul
if not %ERRORLEVEL% == 0 (
set ERROR=Java runtime not found. Please refer to the Ghidra Installation Guide's Troubleshooting section.
goto reportError
)
:: Get the java that will be used to launch GhidraServer
set JAVA_HOME=
for /f "delims=*" %%i in ('java -cp "%LS_CPATH%" LaunchSupport "%GHIDRA_HOME%" -java_home') do set JAVA_HOME=%%i
if "%JAVA_HOME%" == "" (
set ERROR=Failed to find a supported Java runtime. Please refer to the Ghidra Installation Guide's Troubleshooting section.
goto reportError
)
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 DEBUG=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=*:18888
if "%OPTION%"=="console" (
start "%APP_LONG_NAME%" "%JAVA%" %DEBUG% -jar "%WRAPPER_HOME%/wrapper.jar" -c "%WRAPPER_CONF%"
echo Use Ctrl-C in Ghidra Console to terminate...
) else if "%OPTION%"=="status" (
"%JAVA%" -jar "%WRAPPER_HOME%/wrapper.jar" -q "%WRAPPER_CONF%"
) else if "%OPTION%"=="start" (
"%JAVA%" %DEBUG% -jar "%WRAPPER_HOME%/wrapper.jar" -t "%WRAPPER_CONF%"
) else if "%OPTION%"=="stop" (
"%JAVA%" -jar "%WRAPPER_HOME%/wrapper.jar" -p "%WRAPPER_CONF%"
) else if "%OPTION%"=="restart" (
"%JAVA%" -jar "%WRAPPER_HOME%/wrapper.jar" -p "%WRAPPER_CONF%"
"%JAVA%" -jar "%WRAPPER_HOME%/wrapper.jar" -t "%WRAPPER_CONF%"
) else if "%OPTION%"=="install" (
"%JAVA%" -jar "%WRAPPER_HOME%/wrapper.jar" -i "%WRAPPER_CONF%"
"%JAVA%" -jar "%WRAPPER_HOME%/wrapper.jar" -t "%WRAPPER_CONF%"
) else if "%OPTION%"=="uninstall" (
"%JAVA%" -jar "%WRAPPER_HOME%/wrapper.jar" -r "%WRAPPER_CONF%"
) else (
goto usage
)
goto eof
:adminFail
echo.
echo Command option "%OPTION%" must be run as an Administrator (using Administrator CMD shell - see svrREADME.txt)
echo.
exit /B 1
:reportError
echo.
echo %ERROR%
echo.
echo %ERROR% >> %GHIDRA_HOME%\wrapper.log
exit /B 1
:eof

View File

@@ -0,0 +1,74 @@
@echo off
:: ***********************************************************
:: ** Arguments (each argument set may be repeated):
:: ** [-add <sid>] [-remove <sid>] [-reset <sid>] [-dn <sid> "<x500_distinguished_name>"]
:: ** [-admin <sid> "<repository-name>"] [-list] [-migrate "<repository-name>"] [-migrate-all]
:: **
:: ** add - add a new user to the server with the default password 'changeme'
:: ** remove - remove an existing user from the server
:: ** reset - reset an existing user's password to 'changeme'
:: ** dn - set a user's distinguished name for PKI authentication
:: ** admin - set the specified existing user as an admin of the specified repository
:: ** list - list all existing named repositories
:: ** migrate - migrate the specified named repository to an indexed data storage
:: ** migrate-all - migrate all named repositories to index data storage
:: ***********************************************************
setlocal
:: Sets SCRIPT_DIR to the directory that contains this file
::
:: '% ~' dereferences the value in param 0
:: 'd' - drive
:: 'p' - path (without filename)
set SCRIPT_DIR=%~dp0
:: Uncomment and set the value below as necessary
:: set SCRIPT_DIR=<full Ghidra installation server directory path>
if not exist "%SCRIPT_DIR%" (
echo Unable to set the Ghidra server script directory.
echo.
echo To run Ghidra in this mode you must set the
echo value of SCRIPT_DIR in this file to be
echo the full path containing this batch file
goto :eof
)
:: Production Environment
set CONFIG=%SCRIPT_DIR%.\server.conf
set GHIDRA_DIR=%SCRIPT_DIR%..\Ghidra
set CPATH=%GHIDRA_DIR%\Features\GhidraServer\lib\GhidraServer.jar;%GHIDRA_DIR%\Framework\FileSystem\lib\FileSystem.jar;%GHIDRA_DIR%\Framework\DB\lib\DB.jar;%GHIDRA_DIR%\Framework\Generic\lib\Generic.jar;%GHIDRA_DIR%\Framework\Utility\lib\Utility.jar;%GHIDRA_DIR%\Framework\Generic\lib\log4j-core-2.8.1.jar;%GHIDRA_DIR%\Framework\Generic\lib\log4j-api-2.8.1.jar
set LS_CPATH=%GHIDRA_DIR%\..\support\LaunchSupport.jar
if exist "%GHIDRA_DIR%" goto continue
:: Development Environment - assumes suitable java in command path
set CONFIG=%SCRIPT_DIR%..\..\Common\server\server.conf
set GHIDRA_DIR=%SCRIPT_DIR%..\..\..
set GHIDRA_BIN_HOME=%GHIDRA_DIR%\..\..\ghidra.bin
set CPATH=%GHIDRA_DIR%\Features\GhidraServer\bin\main;%GHIDRA_DIR%\Framework\FileSystem\bin\main;%GHIDRA_DIR%\Framework\DB\bin\main;%GHIDRA_DIR%\Framework\Generic\bin\main;%GHIDRA_DIR%\Framework\Utility\bin\main;%GHIDRA_BIN_HOME%\ExternalLibraries\libsForRuntime\log4j-core-2.8.1.jar;%GHIDRA_BIN_HOME%\ExternalLibraries\libsForRuntime\log4j-api-2.8.1.jar
set LS_CPATH=%GHIDRA_DIR%\..\GhidraBuild\LaunchSupport\bin\main
:continue
:: Make sure some kind of java is on the path. It's required to run the LaunchSupport program.
java -version >nul 2>nul
if not %ERRORLEVEL% == 0 (
echo Java runtime not found. Please refer to the Ghidra Installation Guide's Troubleshooting section.
exit /B 1
)
:: Get the java that will be used to launch GhidraServer
set JAVA_HOME=
for /f "delims=*" %%i in ('java -cp "%LS_CPATH%" LaunchSupport "%GHIDRA_DIR%\.." -java_home') do set JAVA_HOME=%%i
if "%JAVA_HOME%" == "" (
echo Failed to find a supported Java runtime. Please refer to the Ghidra Installation Guide's Troubleshooting section.
exit /B 1
)
set JAVA=%JAVA_HOME%\bin\java.exe
set VMARGS=-DUserAdmin.invocation="%0" -DUserAdmin.config="%CONFIG%" -Djava.net.preferIPv4Stack=true
"%JAVA%" %VMARGS% -cp "%CPATH%" ghidra.server.UserAdmin %*

View File

@@ -0,0 +1,10 @@
@echo off
setlocal
rem Find the script directory
rem %~dsp0 is location of current script under NT
set _REALPATH=%~dp0
call "%_REALPATH%\ghidraSvr" install
pause

View File

@@ -0,0 +1,11 @@
@echo off
setlocal
rem Find the script directory
rem %~dsp0 is location of current script under NT
set _REALPATH=%~dp0
call "%_REALPATH%\ghidraSvr" uninstall
pause

View File

@@ -0,0 +1,30 @@
README_createPdbXmlFiles.txt
The createPdbXmlFiles.bat script included in the Ghidra distribution's /support folder can be used
to create *.PDB.XML files from *.PDB files. *.PDB.XML files can be used to load and apply symbols to
Microsoft-compiled programs in Ghidra when the user is not on a Windows machine.
Before running the createPdbXmlFiles.bat script, you will need to ensure that the runtime libarry
dependencies of pdb.exe are satisfied on your Windows system. To do so, please follow the instructions
in the docs/README_PDB.html file.
Once you have verified that the DIA SDK is installed, use a command window to navigate to the <ghidra
install root>/support folder and run the script with either a single PDB file or a directory that
contains PDB files as its argument. The script will recursively traverse all subdirectories of a given
directory to find PDB files.
For example:
createPdbXmlFiles.bat C:\Symbols\samplePdb.pdb
createPdbXmlFiles.bat C:\Symbols
A created .PDB.XML file will be placed in the same location as the corresponding original .PDB file.
_NOTES_
* There is also a Ghidra GUI-based version of createPdbXmlFiles.bat. It is available from the GUI's
Script Manager (see the "Load PDB File" section of Ghidra Help for more details).
* The createPdbXmlFiles.bat script may not work when operating on files that are located on a mounted
drive or remote server. For best results, please make sure the PDB files or directories you are using
as the argument to the script are local to the script.

View File

@@ -0,0 +1,54 @@
:: Ghidra Headless Analyzer launch (see analyzeHeadlessREADME.html)
@echo off
setlocal EnableDelayedExpansion
:: Maximum heap memory size. For headless, it is recommended to not use the default value
:: because garbage collection could take too long on systems with a large amount of physical
:: memory.
set MAXMEM=2G
:: Launch mode can be changed to one of the following:
:: fg, debug, debug-suspend
set LAUNCH_MODE=fg
:: Set the debug address to listen on.
:: NOTE: This variable is ignored if not launching in a debugging mode.
set DEBUG_ADDRESS=127.0.0.1:13002
:: Limit the # of garbage collection and JIT compiler threads in case many headless
:: instances are run in parallel. By default, Java will assign one thread per core
:: which does not scale well on servers with many cores.
set VMARG_LIST=-XX:ParallelGCThreads=2
set VMARG_LIST=%VMARG_LIST% -XX:CICompilerCount=2
:: store current path
set filepath=%~dp0
:: Loop through parameters (if there aren't any, just continue) and store
:: in params variable.
set params=
:Loop
if "%~1" == "" goto cont
:: If -import is found and Windows has not done proper wildcard expansion, force
:: this to happen and save expansion to params variable.
if "%~1" == "-import" (
set params=!params! -import
for %%f in ("%~2") DO (
call set params=!params! "%%~ff"
)
SHIFT
) else (
set params=!params! "%~1"
)
shift
goto Loop
:cont
call "%filepath%launch.bat" %LAUNCH_MODE% Ghidra-Headless "%MAXMEM%" "%VMARG_LIST%" ghidra.app.util.headless.AnalyzeHeadless %params%

View File

@@ -0,0 +1,23 @@
:: Ghidra Jar Builder launch
@echo off
setlocal
:: launch mode can be changed to one of the following:
:: fg, debug, debug-suspend
set LAUNCH_MODE=fg
:: Sets SCRIPT_DIR to the directory that contains this file (ends with '\')
set SCRIPT_DIR=%~dp0
set GHIDRA_ROOT_DIR=%SCRIPT_DIR%..\Ghidra
if exist "%GHIDRA_ROOT_DIR%" goto continue
echo This script does not support development mode use
exit /B 1
:continue
set APP_VMARGS=-DGhidraJarBuilder.Name=%0 -DGhidra.Install.Root.Dir=%GHIDRA_ROOT_DIR%
call "%~dp0launch.bat" %LAUNCH_MODE% Ghidra "" "%APP_VMARGS%" ghidra.util.GhidraJarBuilder -main ghidra.JarRun %*

View File

@@ -0,0 +1,9 @@
:: Ghidra Filesystem Conversion launch
@echo off
setlocal
:: maximum heap memory may be change if inadequate
set MAXMEM=128M
call "%~dp0launch.bat" fg ConvertStorage "%MAXMEM%" "" ghidra.framework.data.ConvertFileSystem %*

View File

@@ -0,0 +1,75 @@
:: Script that takes either a single .pdb file or a directory
:: that contains .pdb files (search for files is recursive).
::
:: Parses each .pdb file and creates a corresponding .pdb.xml
:: file in the same location as the original file.
::
:: The .pdb.xml files can be used to apply debugging information
:: when running Ghidra on non-Windows systems.
@echo off
setlocal
if "%~1" == "" (
echo "Usage: createPdbXmlFiles.bat <path to .pdb file|path to directory of .pdb files>"
Exit /B 0
)
REM Get parent of current folder
for %%A in (%~dp0\.) do set ghidraPath=%%~dpA
REM Production Environment
if exist "%ghidraPath%Ghidra" goto continue
REM Development Environment
set ghidraPath="%ghidraPath%..\..\..\..\ghidra.bin\"
:continue
set arg1="%~1"
REM Determine if 64-bit or 32-bit
if exist "%PROGRAMFILES(X86)%" (
set osType=win64
) else (
set osType=win32
)
set /a count=0
REM Recursively traverse through the given directory
REM Create the .pdb.xml file in the same directory as the .pdb file
for /f "tokens=* delims=" %%a in ('dir %arg1% /s /b') do (
REM Check if we are dealing with a file
if not exist %%a\ (
REM Run pdb.exe on found .pdb file
if %%~xa equ .pdb (
setlocal enableDelayedExpansion
(
echo "Processing file: %%a"
START /B /WAIT "" "%ghidraPath%Ghidra\Features\PDB\os\%ostype%\pdb.exe" %%a > "%%a.xml"
REM Exit if executable returned non-zero error code (signifies that there is a problem).
if !errorlevel! neq 0 (
REM Delete empty XML file that was just created
del "%%a.xml"
if !count! geq 1 (
echo "Error detected. Created !count! .pdb.xml file(s) before exiting"
) else (
echo Error detected. Exiting...
)
Exit /B 0
)
)
set /a count+=1
)
)
)
echo Created %count% .pdb.xml file(s).

View File

@@ -0,0 +1,18 @@
:: Ghidra Debug Thread Dumper launch
::
:: This script will only work if Ghidra is running in debug mode (i.e., launched from
:: ghidraDebug batch file or shell script).
::
@echo off
setlocal
:: maximum heap memory may be change if inadequate
set MAXMEM=64M
:: Assumes application is utilizing debug port 18001 (change if needed)
:: NOTE: By default, ghidraDebug uses debug port 18001 and analyzeHeadless uses 13002
call "%~dp0launch.bat" fg ThreadDump "%MAXMEM%" "" util.DebugThreadDumper 18001
pause

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

View File

@@ -0,0 +1,22 @@
:: Ghidra debug launch
@echo off
setlocal
:: Maximum heap memory size
:: Default for Windows 32-bit is 768M and 64-bit is 1024M
:: Raising the value too high may cause a silent failure where
:: Ghidra fails to launch.
:: Uncomment MAXMEM setting if non-default value is needed
::set MAXMEM=768M
:: Debug launch mode can be changed to one of the following:
:: debug, debug-suspend
set LAUNCH_MODE=debug
:: Set the debug address to listen on.
:: 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 %*

View File

@@ -0,0 +1,188 @@
@echo off
goto continue
:showUsage
echo Usage: %0 ^<mode^> ^<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 ^<name^>: application name used for naming console window
echo ^<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. On
echo 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 ^<app-args^>...: arguments to be passed to the application
echo.
echo Example:
echo %0 debug Ghidra 768M "" ghidra.GhidraRun
exit /B 1
:continue
:: Delay the expansion of our loop items below since the value is being updated as the loop works
setlocal enabledelayedexpansion
:: See if we were doubled clicked or run from a command prompt
set DOUBLE_CLICKED=n
for /f "tokens=2" %%# in ("%cmdcmdline%") do if /i "%%#" equ "/c" set DOUBLE_CLICKED=y
:: Sets SUPPORT_DIR to the directory that contains this file (ends with '\')
::
:: '% ~' dereferences the value in param 0
:: 'd' - drive
:: 'p' - path (without filename)
set SUPPORT_DIR=%~dp0
::
:: Parse arguments
::
set VMARG_LIST=
set ARGS=
set INDEX=0
for %%A in (%*) do (
set /A INDEX=!INDEX!+1
if "!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 set ARGS=!ARGS! %%A
)
if %INDEX% geq 5 goto continue1
echo Incorrect launch usage - missing argument^(s^)
goto showUsage
:continue1
::
:: 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
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
:continue2
:: This is to force Java to use the USERPROFILE directory for user.home
if exist "%USERPROFILE%" (
set VMARG_LIST=%VMARG_LIST% -Duser.home="%USERPROFILE%"
)
:: Make sure some kind of java is on the path. It's required to run the LaunchSupport program.
java -version >nul 2>nul
if not %ERRORLEVEL% == 0 (
echo Java runtime not found. Please refer to the Ghidra Installation Guide's Troubleshooting section.
goto exit1
)
:: Get the JDK that will be used to launch Ghidra
set JAVA_HOME=
for /f "delims=*" %%i in ('java -cp "%LS_CPATH%" LaunchSupport "%INSTALL_DIR%\" -jdk_home -save') do set JAVA_HOME=%%i
if "%JAVA_HOME%" == "" (
:: No JDK has been setup yet. Let the user choose one.
java -cp "%LS_CPATH%" LaunchSupport "%INSTALL_DIR%\" -jdk_home -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
if "!JAVA_HOME!" == "" (
echo.
echo Failed to find a supported JDK. Please refer to the Ghidra Installation Guide's Troubleshooting section.
set ERRORLEVEL=1
goto exit1
)
)
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
:: Set Max Heap Size if specified
if not "%MAXMEM%"=="" (
set VMARG_LIST=%VMARG_LIST% -Xmx%MAXMEM%
)
set BACKGROUND=n
set DEBUG=n
set SUSPEND=n
if "%MODE%"=="debug" (
set DEBUG=y
)
if "%MODE%"=="debug-suspend" (
set DEBUG=y
set SUSPEND=y
)
if "%DEBUG%"=="y" (
if "%DEBUG_ADDRESS%"=="" (
set DEBUG_ADDRESS=127.0.0.1:18001
)
set VMARG_LIST=!VMARG_LIST! -Xdebug
set VMARG_LIST=!VMARG_LIST! -Xnoagent
set VMARG_LIST=!VMARG_LIST! -Djava.compiler=NONE
set VMARG_LIST=!VMARG_LIST! -Dlog4j.configuration="!DEBUG_LOG4J!"
set VMARG_LIST=!VMARG_LIST! -Xrunjdwp:transport=dt_socket,server=y,suspend=!SUSPEND!,address=!DEBUG_ADDRESS!
goto continue3
)
if "%MODE%"=="fg" (
goto continue3
)
if "%MODE%"=="bg" (
set BACKGROUND=y
goto continue3
)
echo "Incorrect launch usage - invalid launch mode: %MODE%"
exit /B 1
:continue3
set CMD_ARGS=%FORCE_JAVA_VERSION% %JAVA_USER_HOME_DIR_OVERRIDE% %VMARG_LIST% -cp "%CPATH%" ghidra.GhidraLauncher %CLASSNAME% %ARGS%
if "%BACKGROUND%"=="y" (
set JAVA_CMD=!JAVA_CMD!w
start "%APPNAME%" /I /B "!JAVA_CMD!" %CMD_ARGS%
REM If our process dies immediately, output something so the user knows to run in debug mode.
REM Otherwise they'll never see any error output from background mode.
REM NOTE: The below check isn't perfect because they might have other javaw's running, but
REM without the PID of the thing we launched, it's the best we can do (maybe use WMI?).
REM Worst case, they just won't see the error message.
timeout /NOBREAK 1 > NUL
tasklist | find "javaw" > NUL
if not "!ERRORLEVEL!"=="0" (
echo Exited with error. Run in foreground ^(fg^) mode for more details.
)
) else (
"%JAVA_CMD%" %CMD_ARGS%
)
:exit1
if not %ERRORLEVEL% == 0 (
if "%DOUBLE_CLICKED%"=="y" (
pause
)
)
exit /B %ERRORLEVEL%

View File

@@ -0,0 +1,31 @@
:: Ghidra python launch
@echo off
setlocal EnableDelayedExpansion
:: Maximum heap memory size
:: Default for Windows 32-bit is 768M and 64-bit is 1024M
:: Raising the value too high may cause a silent failure where
:: Ghidra fails to launch.
:: Uncomment MAXMEM setting if non-default value is needed
::set MAXMEM=768M
:: Launch mode can be changed to one of the following:
:: fg, debug, debug-suspend
set LAUNCH_MODE=fg
:: Set the debug address to listen on.
:: NOTE: This variable is ignored if not launching in a debugging mode.
set DEBUG_ADDRESS=127.0.0.1:13002
:: Limit the # of garbage collection and JIT compiler threads in case many headless
:: instances are run in parallel. By default, Java will assign one thread per core
:: which does not scale well on servers with many cores.
set VMARG_LIST=-XX:ParallelGCThreads=2
set VMARG_LIST=%VMARG_LIST% -XX:CICompilerCount=2
:: store current path
set filepath=%~dp0
call "%filepath%launch.bat" %LAUNCH_MODE% Ghidra-Python "%MAXMEM%" "%VMARG_LIST%" ghidra.python.PythonRun %params%

View File

@@ -0,0 +1,9 @@
:: Ghidra Sleigh language compiler launch
@echo off
setlocal
:: maximum heap memory may be change if inadequate
set MAXMEM=256M
call "%~dp0launch.bat" fg Sleigh "%MAXMEM%" "" ghidra.pcodeCPort.slgh_compile.SleighCompileLauncher %*