Skip to content

Commit 684ed5e

Browse files
committed
Merge remote-tracking branch 'origin/patch'
2 parents 23d6530 + cd15acd commit 684ed5e

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
##
16-
__version__ = "2.0.0"
16+
__version__ = "2.0.1"
1717

1818
# stub for documentation and typing
1919
# this is mostly to hide the function parameter

Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/launcher.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,22 @@ def create_module(self, spec):
109109
def exec_module(self, fullname):
110110
pass
111111

112+
class _GhidraBundleFinder(importlib.machinery.PathFinder):
113+
""" (internal) Used to find modules in Ghidra bundle locations """
114+
115+
def find_spec(self, fullname, path=None, target=None):
116+
from ghidra.framework import Application
117+
from ghidra.app.script import GhidraScriptUtil
118+
if Application.isInitialized():
119+
GhidraScriptUtil.acquireBundleHostReference()
120+
try:
121+
for directory in GhidraScriptUtil.getEnabledScriptSourceDirectories():
122+
spec = super().find_spec(fullname, [directory.absolutePath], target)
123+
if spec is not None:
124+
return spec
125+
finally:
126+
GhidraScriptUtil.releaseBundleHostReference()
127+
return None
112128

113129
@contextlib.contextmanager
114130
def _plugin_lock():
@@ -390,8 +406,9 @@ def _setup_java(self, **jpype_kwargs):
390406
**jpype_kwargs
391407
)
392408

393-
# Install hook into python importlib
409+
# Install hooks into python importlib
394410
sys.meta_path.append(_PyGhidraImportLoader())
411+
sys.meta_path.append(_GhidraBundleFinder())
395412

396413
imports.registerDomain("ghidra")
397414

0 commit comments

Comments
 (0)