mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 10:19:23 +02:00
GP-5700: Expose module directories to scripts on request
This commit is contained in:
parent
7482131bcc
commit
f92076b936
73 changed files with 862 additions and 516 deletions
|
@ -28,19 +28,17 @@ This file CANNOT be assumed to be available on a remote target. For
|
|||
that, consider ghidratrace.setuputils.
|
||||
"""
|
||||
import os
|
||||
|
||||
home = os.getenv('GHIDRA_HOME')
|
||||
from typing import Optional
|
||||
|
||||
|
||||
def ghidra_module_pypath(name: str) -> str:
|
||||
installed = f'{home}/Ghidra/{name}/pypkg/src'
|
||||
def ghidra_module_pypath(name: Optional[str]=None) -> str:
|
||||
mod_home_name = 'MODULE_HOME' if name is None else f'MODULE_{name.replace("-","_")}_HOME'
|
||||
mod_home = os.getenv(mod_home_name)
|
||||
installed = f'{mod_home}/pypkg/src'
|
||||
if os.path.isdir(installed):
|
||||
return installed
|
||||
dev1 = f'{home}/Ghidra/{name}/build/pypkg/src'
|
||||
if os.path.isdir(dev1):
|
||||
return dev1
|
||||
dev2 = f'{home}/ghidra/Ghidra/{name}/build/pypkg/src'
|
||||
if os.path.isdir(dev2):
|
||||
return dev2
|
||||
dev = f'{mod_home}/build/pypkg/src'
|
||||
if os.path.isdir(dev):
|
||||
return dev
|
||||
raise Exception(
|
||||
f"Cannot find Python source for {name}. Try gradle assemblePyPackage?")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue