File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
Ghidra/Features/PyGhidra/src/main/py/src/pyghidra Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff 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
114130def _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
You can’t perform that action at this time.
0 commit comments