81 Commits

Author SHA1 Message Date
Ryan Kurtz
56252685c0 GP-6252: pyghidra_launcher.py fixes
pyghidra_launcher.py can now use an existing pyghidra
installation in an externally managed environment. Upgrading is disabled
in this scenario.

Fixed an issue with getting the package version from an arbitrary
environment
2025-12-19 07:35:45 -05:00
Ryan Kurtz
0ccff8ed76 Merge remote-tracking branch 'origin/patch' 2025-12-17 05:47:20 -05:00
Ryan Kurtz
fed6dd7864 GP-0: Fixing wrong output in pyghidra_launcher.py (Closes #8791) 2025-12-17 05:45:15 -05:00
Ryan Kurtz
2c7cae08a9 GP-6241: Formatting, README update, version bump 2025-12-17 05:08:45 -05:00
Stanley He
f93cc03f27 PyGhidra: Fix up __init__ typo for program_context 2025-12-17 04:59:22 -05:00
Ryan Kurtz
58e5c8e44c Merge remote-tracking branch 'origin/Ghidra_12.0' 2025-12-03 11:18:29 -05:00
Ryan Kurtz
5ab8d33592 GP-0: PyGhidra type hint fixes 2025-12-03 11:11:52 -05:00
Nicolas Iooss
fc0f971c39 Fix Python type annotations in PyGhidra module when using contextmanager
Verifying the type annotations used by PyGhidra with Mypy static type
checker leads to the following error:

    core.py:171: error: Argument 1 to "contextmanager" has incompatible
    type "Callable[[str | Path, str | Path, str, Any, str, str, str |
    JClass, str, Any], AbstractContextManager[Any, bool | None]]";
    expected "Callable[[str | Path, str | Path, str, Any, str, str, str
    | JClass, str, Any], Iterator[Never]]"  [arg-type]

Indeed, in Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/core.py,
function open_program was declared to return a
ContextManager["FlatProgramAPI"]. While this function indeed returns
such a type, the implementation uses decorator @contextlib.contextmanager
which expects the wrapped function to return an generator (with yield).

Use Generator["FlatProgramAPI", None, None] to fix this.

While at it, fix other locations where the type annotation of the
function wrapped with contextmanager was incorrect.
2025-12-03 10:59:05 -05:00
Ryan Kurtz
a8a07b148e Merge remote-tracking branch 'origin/Ghidra_12.0' 2025-12-03 05:43:25 -05:00
Ryan Kurtz
a93de758f7 GP-6165: Changed JPype dependency to be fixed at version 1.5.2 to avoid
a possible Windows crash on 1.6.0
2025-12-03 05:33:51 -05:00
Ryan Kurtz
5e6c16073e GP-0: Renaming pyghidra.monitor() to pyghidra.task_monitor() to avoid
naming conflict with local monitor variables (Closes #8722)
2025-12-03 05:08:49 -05:00
Ryan Kurtz
09327173a4 Merge remote-tracking branch 'origin/Ghidra_12.0' 2025-11-24 05:45:29 -05:00
Ryan Kurtz
06ae0f5660 GP-0: Removing unneeded PyGhidra print 2025-11-24 05:42:35 -05:00
Ryan Kurtz
aabf436723 Merge remote-tracking branch 'origin/Ghidra_12.0' 2025-11-19 10:50:54 -05:00
Ryan Kurtz
c32ead3c69 GP-0: Fixing user settings location in dev mode for LaunchSupport and
PyGhidra
2025-11-19 10:35:34 -05:00
Ryan Kurtz
593dacf7d0 Merge remote-tracking branch 'origin/Ghidra_12.0' 2025-11-19 06:24:39 -05:00
Ryan Kurtz
6d36df6eca GP-0: Fixing PyGhidra version check when things like "-BETA" are present 2025-11-19 06:22:44 -05:00
Ryan Kurtz
44d29b9ada Merge remote-tracking branch 'origin/Ghidra_12.0' 2025-11-18 14:19:50 -05:00
Ryan Kurtz
0d52943d1f GP-6132: Fixed a bug in the the PyGhidra headless analyzer that resulted in the wrong exception being thrown when a script tries to import a module that isn't found 2025-11-18 14:15:44 -05:00
jhq223
8148f6364f refactor(pyghidra_launcher): Improve get_package_version implementation
Refactors the `get_package_version` helper function to use the standard
`importlib.metadata` library instead of a subprocess call to `pip show`.

This change provides several benefits:
- Robustness: Avoids brittle parsing of command-line tool output.
- Performance: Eliminates the overhead of spawning a new process.
- Correctness: The return type hint is corrected to `Optional[str]` to
  accurately reflect that the function can return `None`.
- Simplicity: The unused `python_cmd` parameter has been removed,
  simplifying the function's signature.
2025-10-25 18:18:05 +08:00
Ryan Kurtz
131aa4ac9a GP-0: If pyghidra.sys.modules.restore is set, PyGhidra will restore
sys.modules each time a script is run (Closes #8529)
2025-10-02 13:10:46 -04:00
Ryan Kurtz
951f5a5daa GP-6021: PyGhidra stdout/stderr scripting console fixes 2025-09-26 12:51:32 -04:00
Ryan Kurtz
26685abc75 GP-5637: More improvements to the PyGhidra API 2025-09-12 09:15:05 -04:00
Ryan Kurtz
657ec39201 GP-5637: More improvements to the PyGhidra API 2025-09-10 12:39:57 -04:00
Ryan Kurtz
c18c7a8f50 GP-5637: More improvements to the PyGhidra API 2025-09-08 13:24:10 -04:00
Ryan Kurtz
e0a060660b GP-5961: Deprecating pyghidra.open_program() and pyghidra.run_script()
Also fixed a recent regression with calling pyghidra.run_script()
2025-08-29 13:47:18 -04:00
Ryan Kurtz
2bb237e8d0 Merge remote-tracking branch
'origin/GP-5819-dragonmacher-help-build-update--SQUASHED' (Closes #8320)
2025-07-21 13:23:15 -04:00
dragonmacher
17c28209ef GP-5819 - Help - Added validation code to check all Ghidra TOC files after help is built 2025-07-21 11:59:01 -04:00
Ryan Kurtz
295f71472a GP-5637: The ghidra_script() function now accepts an optional
"script_args" parameter
2025-07-15 07:40:07 -04:00
Ryan Kurtz
cb68d29bac GP-5637: Fixing PyGhidra usage of DomainFileIterator 2025-07-11 06:58:18 -04:00
Ryan Kurtz
f5fd0171a2 GP-5637: New PyGhidra API 2025-07-10 11:42:46 -04:00
Ryan Kurtz
d58f2ad24c Merge remote-tracking branch 'origin/patch' 2025-07-07 12:25:55 -04:00
Ryan Kurtz
bf167a3126 GP-5810: Improving CWD removal from sys.path 2025-07-07 12:23:55 -04:00
Ryan Kurtz
fe335aa946 Merge remote-tracking branch 'origin/patch' 2025-07-07 11:40:02 -04:00
Ryan Kurtz
2930b622cc GP-5810: Removing CWD from PyGhidra's sys.path (Closes #8190) 2025-07-07 11:35:57 -04:00
Ryan Kurtz
1add5a9bce GP-5737: Fixing GhidraScript PrintWriter 2025-06-09 12:14:58 -04:00
Ryan Kurtz
ec43d344ad GP-0: Giving PyGhidra access to a ProjectManager 2025-05-28 14:59:29 -04:00
Ryan Kurtz
3f8fe98862 Merge remote-tracking branch 'origin/Ghidra_11.4' 2025-05-27 13:06:32 -04:00
Ryan Kurtz
189117e7d4 GP-5677: Ghidra now writes a "lastrun" file that PyGhidra can look for
to help find the Ghidra installation dir
2025-05-27 09:09:53 -04:00
Ryan Kurtz
6f0cb9a77c GP-5415: Python scripts that do not declare a @runtime metadata comment
now default to PyGhidra instead of Jython. (Closes #7856)
2025-05-22 10:13:19 -04:00
Ryan Kurtz
8ff5444ac1 GP-5710: Fixed a bug that prevented PyGhidra from properly using the
user's already-active virtual environment
2025-05-21 09:43:29 -04:00
Ryan Kurtz
151fea46f5 GP-5627: PyGhidra can now open projects created with the Ghidra GUI by
setting the "nested_project_location" optional parameter to False
2025-04-30 09:54:57 -04:00
Ryan Kurtz
0ee0537e45 GP-5598: Rename InstallationGuide to GettingStarted; put in installation
root dir
2025-04-21 11:58:26 -04:00
Ryan Kurtz
50a0bcd050 GP-0: Removing shorthand -c and -d command line args from
pyghidra_launcher.py...they interfered with some AnalyzeHeadless args
2025-04-09 13:35:25 -04:00
Ryan Kurtz
907e5c563f GP-5521: pyghidra.open_program() now accepts a program_name parameter,
which can be used to override the program name derived from the
binary_path parameter
2025-03-25 13:44:04 -04:00
Ryan Kurtz
abb65d1b8c GP-5444: PyGhidra open_program() now handles locked projects better 2025-03-06 11:58:12 -05:00
Ryan Kurtz
034c696512 GP-5372: PyGhidra now respects the application.settingsdir property set
in Ghidra's launch.properties (Closes #7481)
2025-02-12 12:16:41 -05:00
Ryan Kurtz
84e05008ae GP-5348: Fixed a PyGhidra issue that prevented accessing Java
getters/setters as properties on non-public classes (Closes #7450)
2025-02-10 08:35:22 -05:00
Ryan Kurtz
d71dc292ca GP-5298: PyGhidra can now find modules that live in directories
specified by the Bundle Manager
2025-02-07 09:53:03 -05:00
ghidra1
1bccb8ac60 Revert "GP-5298: PyGhidra can now find modules that live in directories specified by the Bundle Manager"
This reverts commit c5d4444128.
2025-02-05 14:21:55 -05:00