mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 09:49:23 +02:00
Merge remote-tracking branch 'origin/patch'
This commit is contained in:
commit
684ed5ec6c
2 changed files with 19 additions and 2 deletions
|
@ -13,7 +13,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
##
|
||||
__version__ = "2.0.0"
|
||||
__version__ = "2.0.1"
|
||||
|
||||
# stub for documentation and typing
|
||||
# this is mostly to hide the function parameter
|
||||
|
|
|
@ -109,6 +109,22 @@ class _PyGhidraImportLoader:
|
|||
def exec_module(self, fullname):
|
||||
pass
|
||||
|
||||
class _GhidraBundleFinder(importlib.machinery.PathFinder):
|
||||
""" (internal) Used to find modules in Ghidra bundle locations """
|
||||
|
||||
def find_spec(self, fullname, path=None, target=None):
|
||||
from ghidra.framework import Application
|
||||
from ghidra.app.script import GhidraScriptUtil
|
||||
if Application.isInitialized():
|
||||
GhidraScriptUtil.acquireBundleHostReference()
|
||||
try:
|
||||
for directory in GhidraScriptUtil.getEnabledScriptSourceDirectories():
|
||||
spec = super().find_spec(fullname, [directory.absolutePath], target)
|
||||
if spec is not None:
|
||||
return spec
|
||||
finally:
|
||||
GhidraScriptUtil.releaseBundleHostReference()
|
||||
return None
|
||||
|
||||
@contextlib.contextmanager
|
||||
def _plugin_lock():
|
||||
|
@ -390,8 +406,9 @@ class PyGhidraLauncher:
|
|||
**jpype_kwargs
|
||||
)
|
||||
|
||||
# Install hook into python importlib
|
||||
# Install hooks into python importlib
|
||||
sys.meta_path.append(_PyGhidraImportLoader())
|
||||
sys.meta_path.append(_GhidraBundleFinder())
|
||||
|
||||
imports.registerDomain("ghidra")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue