diff --git a/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/api.py b/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/api.py index 2baf062526..723342c353 100644 --- a/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/api.py +++ b/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/api.py @@ -15,7 +15,7 @@ ## import sys import contextlib -from typing import Union, TYPE_CHECKING, Tuple, Callable, Any +from typing import Union, TYPE_CHECKING, Tuple, List, Callable, Any from pyghidra.converters import * # pylint: disable=wildcard-import, unused-wildcard-import @@ -155,6 +155,7 @@ def ghidra_script( path: Union[str, Path], project: "Project", program: "Program" = None, + script_args: List[str] = [], echo_stdout = True, echo_stderr = True ) -> Tuple[str, str]: @@ -164,6 +165,7 @@ def ghidra_script( :param path: The GhidraScript's path. :param project: The Ghidra project to run the GhidraScript in. :param program: An optional Ghidra program that the GhidraScript will see as its "currentProgram". + :param script_args An optional list of arguments to pass to the GhidraScript. :param echo_stdout: Whether or not to echo the GhidraScript's standard output. :param echo_stderr: Whether or not to echo the GhidraScript's standard error. :return: A 2 element tuple consisting of the GhidraScript's standard output and standard error. @@ -192,6 +194,7 @@ def ghidra_script( PrintWriter(stderr_string_writer, True), dummy_monitor() ) + script.setScriptArgs(script_args) script.execute(state, controls) stdout_str = str(stdout_string_writer) stderr_str = str(stderr_string_writer)