From 24cee30359d7da61bd86098ebf7ee1d34d2f1a03 Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Mon, 7 Apr 2025 18:08:23 -0400 Subject: Also update kernelcache template. Fixes #6586, but for this plugin as well. --- .../api/python/_kernelcachecore_template.py | 45 ++++++++++++++-------- 1 file changed, 30 insertions(+), 15 deletions(-) (limited to 'view/kernelcache/api') diff --git a/view/kernelcache/api/python/_kernelcachecore_template.py b/view/kernelcache/api/python/_kernelcachecore_template.py index c1f05e72..ecbcb35d 100644 --- a/view/kernelcache/api/python/_kernelcachecore_template.py +++ b/view/kernelcache/api/python/_kernelcachecore_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, "libkernelcache.dylib")) - -elif core_platform == "Linux": - _base_path = BNGetBundledPluginDirectory() - core = ctypes.CDLL(os.path.join(_base_path, "libkernelcache.so")) - -elif (core_platform == "Windows") or (core_platform.find("CYGWIN_NT") == 0): - _base_path = BNGetBundledPluginDirectory() - core = ctypes.CDLL(os.path.join(_base_path, "kernelcache.dll")) +from binaryninja import Settings +if Settings().get_bool("corePlugins.view.kernelCache"): + from binaryninja._binaryninjacore import BNGetBundledPluginDirectory + if core_platform == "Darwin": + _base_path = BNGetBundledPluginDirectory() + core = ctypes.CDLL(os.path.join(_base_path, "libkernelcache.dylib")) + + elif core_platform == "Linux": + _base_path = BNGetBundledPluginDirectory() + core = ctypes.CDLL(os.path.join(_base_path, "libkernelcache.so")) + + elif (core_platform == "Windows") or (core_platform.find("CYGWIN_NT") == 0): + _base_path = BNGetBundledPluginDirectory() + core = ctypes.CDLL(os.path.join(_base_path, "kernelcache.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, "libkernelcache.dylib")) + + elif core_platform == "Linux": + _base_path = BNGetUserPluginDirectory() + core = ctypes.CDLL(os.path.join(_base_path, "libkernelcache.so")) + + elif (core_platform == "Windows") or (core_platform.find("CYGWIN_NT") == 0): + _base_path = BNGetUserPluginDirectory() + core = ctypes.CDLL(os.path.join(_base_path, "kernelcache.dll")) + else: + raise Exception("OS not supported") def cstr(var) -> Optional[ctypes.c_char_p]: if var is None: -- cgit v1.3.1