mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-07-30 07:18:37 -09:00
GP-0: Fixing PyGhidra application name on Linux, and a couple of other
PyGhidra tweaks (Closes #8362)
This commit is contained in:
@@ -575,6 +575,7 @@ __3.2.0__
|
||||
* PyGhidra now depends on `JPype >=1.5.2, != 1.6.0, != 1.7.0`.
|
||||
* Using `typing_extensions` to properly deprecate [`pyghidra.open_program()`](#pyghidraopen_program)
|
||||
and [`pyghidra.run_script()`](#pyghidrarun_script).
|
||||
* Fixed the PyGhidra WM_CLASS/application name on Linux (requires Ghidra 12.2 or later).
|
||||
|
||||
__3.1.0__
|
||||
* PyGhidra will now, by default, restore `sys.modules` to its prior state after a PyGhidra script is
|
||||
|
||||
@@ -21,7 +21,7 @@ import platform
|
||||
import sys
|
||||
import traceback
|
||||
from typing import List, NoReturn
|
||||
import warnings
|
||||
from typing_extensions import deprecated
|
||||
|
||||
import pyghidra
|
||||
|
||||
@@ -153,11 +153,7 @@ def gui(install_dir: Path = None, vm_args: List[str] = None):
|
||||
launcher.vm_args += vm_args
|
||||
launcher.start()
|
||||
|
||||
|
||||
@deprecated("get_current_interpreter has been moved. Please use pyghidra.get_current_interpreter.")
|
||||
def get_current_interpreter():
|
||||
warnings.warn(
|
||||
"get_current_interpreter has been moved. Please use pyghidra.get_current_interpreter",
|
||||
DeprecationWarning
|
||||
)
|
||||
return pyghidra.get_current_interpreter()
|
||||
|
||||
|
||||
@@ -746,6 +746,10 @@ class GuiPyGhidraLauncher(PyGhidraLauncher):
|
||||
stdout = _PyGhidraStdOut(sys.stdout)
|
||||
stderr = _PyGhidraStdOut(sys.stderr)
|
||||
with contextlib.redirect_stdout(stdout), contextlib.redirect_stderr(stderr):
|
||||
try:
|
||||
Ghidra.setLinuxApplicationName()
|
||||
except AttributeError:
|
||||
pass # Ghidra 12.2 and later
|
||||
Thread(lambda: Ghidra.main(["ghidra.GhidraRun", *self.args])).start()
|
||||
is_exiting = threading.Event()
|
||||
Runtime.getRuntime().addShutdownHook(Thread(is_exiting.set))
|
||||
|
||||
@@ -280,14 +280,14 @@ def get_current_interpreter():
|
||||
try:
|
||||
from ghidra.util import SystemUtilities
|
||||
from ghidra.framework.main import AppInfo
|
||||
from ghidra.pyghidra import PyGhidraScriptProvider
|
||||
|
||||
global _headless_interpreter
|
||||
|
||||
if SystemUtilities.isInHeadlessMode():
|
||||
if _headless_interpreter is None:
|
||||
# one hasn't been created yet so make one now
|
||||
PyGhidraScriptProvider = JClass("ghidra.pyghidra.PyGhidraScriptProvider")
|
||||
_headless_interpreter = PyGhidraScriptProvider.PyGhidraHeadlessScript()
|
||||
_headless_interpreter = PyGhidraScriptProvider().getScriptInstance(None, None) # type: ignore
|
||||
return _headless_interpreter
|
||||
|
||||
project = AppInfo.getActiveProject()
|
||||
|
||||
Reference in New Issue
Block a user