diff options
| author | Glenn Smith <glenn@vector35.com> | 2025-04-07 17:28:47 -0400 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2025-04-07 17:28:47 -0400 |
| commit | 4228550369203586221653870001917263661713 (patch) | |
| tree | 9d84641d12c8c6e6ab0600e01b2f70221ccbf1be /view/sharedcache/api | |
| parent | 4080330075075115814880485153780465465408 (diff) | |
[SharedCache] Support loading from user plugins directory too
Check for the core plugin setting and, if it's disabled, look in the user directory
Diffstat (limited to 'view/sharedcache/api')
| -rw-r--r-- | view/sharedcache/api/python/_sharedcachecore_template.py | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/view/sharedcache/api/python/_sharedcachecore_template.py b/view/sharedcache/api/python/_sharedcachecore_template.py index 6b5b174f..01cf4b02 100644 --- a/view/sharedcache/api/python/_sharedcachecore_template.py +++ b/view/sharedcache/api/python/_sharedcachecore_template.py @@ -8,22 +8,37 @@ import platform core = None core_platform = platform.system() -# By the time the debugger is loaded, binaryninja has not fully initialized. -# So we cannot call binaryninja.bundled_plugin_path() -from binaryninja._binaryninjacore import BNGetBundledPluginDirectory, BNFreeString -if core_platform == "Darwin": - _base_path = BNGetBundledPluginDirectory() - core = ctypes.CDLL(os.path.join(_base_path, "libsharedcache.dylib")) +from binaryninja import Settings +if Settings().get_bool("corePlugins.view.sharedCache"): + from binaryninja._binaryninjacore import BNGetBundledPluginDirectory + if core_platform == "Darwin": + _base_path = BNGetBundledPluginDirectory() + core = ctypes.CDLL(os.path.join(_base_path, "libsharedcache.dylib")) -elif core_platform == "Linux": - _base_path = BNGetBundledPluginDirectory() - core = ctypes.CDLL(os.path.join(_base_path, "libsharedcache.so")) + elif core_platform == "Linux": + _base_path = BNGetBundledPluginDirectory() + core = ctypes.CDLL(os.path.join(_base_path, "libsharedcache.so")) -elif (core_platform == "Windows") or (core_platform.find("CYGWIN_NT") == 0): - _base_path = BNGetBundledPluginDirectory() - core = ctypes.CDLL(os.path.join(_base_path, "sharedcache.dll")) + elif (core_platform == "Windows") or (core_platform.find("CYGWIN_NT") == 0): + _base_path = BNGetBundledPluginDirectory() + core = ctypes.CDLL(os.path.join(_base_path, "sharedcache.dll")) + else: + raise Exception("OS not supported") else: - raise Exception("OS not supported") + from binaryninja._binaryninjacore import BNGetUserPluginDirectory + if core_platform == "Darwin": + _base_path = BNGetUserPluginDirectory() + core = ctypes.CDLL(os.path.join(_base_path, "libsharedcache.dylib")) + + elif core_platform == "Linux": + _base_path = BNGetUserPluginDirectory() + core = ctypes.CDLL(os.path.join(_base_path, "libsharedcache.so")) + + elif (core_platform == "Windows") or (core_platform.find("CYGWIN_NT") == 0): + _base_path = BNGetUserPluginDirectory() + core = ctypes.CDLL(os.path.join(_base_path, "sharedcache.dll")) + else: + raise Exception("OS not supported") def cstr(var) -> Optional[ctypes.c_char_p]: if var is None: |
