Skip to content

Commit 295f714

Browse files
committed
GP-5637: The ghidra_script() function now accepts an optional
"script_args" parameter
1 parent 7d26a65 commit 295f714

File tree

1 file changed

+4
-1
lines changed
  • Ghidra/Features/PyGhidra/src/main/py/src/pyghidra

1 file changed

+4
-1
lines changed

Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/api.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
##
1616
import sys
1717
import contextlib
18-
from typing import Union, TYPE_CHECKING, Tuple, Callable, Any
18+
from typing import Union, TYPE_CHECKING, Tuple, List, Callable, Any
1919

2020
from pyghidra.converters import * # pylint: disable=wildcard-import, unused-wildcard-import
2121

@@ -155,6 +155,7 @@ def ghidra_script(
155155
path: Union[str, Path],
156156
project: "Project",
157157
program: "Program" = None,
158+
script_args: List[str] = [],
158159
echo_stdout = True,
159160
echo_stderr = True
160161
) -> Tuple[str, str]:
@@ -164,6 +165,7 @@ def ghidra_script(
164165
:param path: The GhidraScript's path.
165166
:param project: The Ghidra project to run the GhidraScript in.
166167
:param program: An optional Ghidra program that the GhidraScript will see as its "currentProgram".
168+
:param script_args An optional list of arguments to pass to the GhidraScript.
167169
:param echo_stdout: Whether or not to echo the GhidraScript's standard output.
168170
:param echo_stderr: Whether or not to echo the GhidraScript's standard error.
169171
:return: A 2 element tuple consisting of the GhidraScript's standard output and standard error.
@@ -192,6 +194,7 @@ def ghidra_script(
192194
PrintWriter(stderr_string_writer, True),
193195
dummy_monitor()
194196
)
197+
script.setScriptArgs(script_args)
195198
script.execute(state, controls)
196199
stdout_str = str(stdout_string_writer)
197200
stderr_str = str(stderr_string_writer)

0 commit comments

Comments
 (0)