Merge remote-tracking branch 'origin/Ghidra_12.0'

This commit is contained in:
Ryan Kurtz 2025-09-26 12:57:42 -04:00
commit 96506554e7
2 changed files with 6 additions and 5 deletions

View file

@ -658,6 +658,7 @@ class _PyGhidraStdOut:
def __init__(self, stream): def __init__(self, stream):
self._stream = stream self._stream = stream
self.is_error = stream == sys.stderr
def _get_current_script(self) -> "PyGhidraScript": def _get_current_script(self) -> "PyGhidraScript":
for entry in inspect.stack(): for entry in inspect.stack():
@ -668,7 +669,7 @@ class _PyGhidraStdOut:
def flush(self): def flush(self):
script = self._get_current_script() script = self._get_current_script()
if script is not None: if script is not None:
writer = script._script.writer writer = script._script.errorWriter if self.is_error else script._script.writer
if writer is not None: if writer is not None:
writer.flush() writer.flush()
return return
@ -678,7 +679,7 @@ class _PyGhidraStdOut:
def write(self, s: str) -> int: def write(self, s: str) -> int:
script = self._get_current_script() script = self._get_current_script()
if script is not None: if script is not None:
writer = script._script.writer writer = script._script.errorWriter if self.is_error else script._script.writer
if writer is not None: if writer is not None:
writer.write(s) writer.write(s)
return len(s) return len(s)

View file

@ -279,11 +279,11 @@ def main() -> None:
# Launch PyGhidra # Launch PyGhidra
save_python_cmd(install_dir, python_cmd, args.dev) save_python_cmd(install_dir, python_cmd, args.dev)
py_args: List[str] = python_cmd + ['-m', 'pyghidra.ghidra_launch', '--install-dir', str(install_dir)] py_args: List[str] = python_cmd + ['-m']
if args.headless: if args.headless:
py_args += ['ghidra.app.util.headless.AnalyzeHeadless'] py_args += ['pyghidra.ghidra_launch', '--install-dir', str(install_dir), 'ghidra.app.util.headless.AnalyzeHeadless']
else: else:
py_args += ['-g', 'ghidra.GhidraRun'] py_args += ['pyghidra', '-g', '--install-dir', str(install_dir)]
if args.console: if args.console:
subprocess.call(py_args + remaining) subprocess.call(py_args + remaining)
else: else: