Skip to content

Commit 24cee30

Browse files
committed
Also update kernelcache template.
Fixes Vector35#6586, but for this plugin as well.
1 parent bfa7fe3 commit 24cee30

File tree

1 file changed

+30
-15
lines changed

1 file changed

+30
-15
lines changed

view/kernelcache/api/python/_kernelcachecore_template.py

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,37 @@
88
core = None
99
core_platform = platform.system()
1010

11-
# By the time the debugger is loaded, binaryninja has not fully initialized.
12-
# So we cannot call binaryninja.bundled_plugin_path()
13-
from binaryninja._binaryninjacore import BNGetBundledPluginDirectory, BNFreeString
14-
if core_platform == "Darwin":
15-
_base_path = BNGetBundledPluginDirectory()
16-
core = ctypes.CDLL(os.path.join(_base_path, "libkernelcache.dylib"))
17-
18-
elif core_platform == "Linux":
19-
_base_path = BNGetBundledPluginDirectory()
20-
core = ctypes.CDLL(os.path.join(_base_path, "libkernelcache.so"))
21-
22-
elif (core_platform == "Windows") or (core_platform.find("CYGWIN_NT") == 0):
23-
_base_path = BNGetBundledPluginDirectory()
24-
core = ctypes.CDLL(os.path.join(_base_path, "kernelcache.dll"))
11+
from binaryninja import Settings
12+
if Settings().get_bool("corePlugins.view.kernelCache"):
13+
from binaryninja._binaryninjacore import BNGetBundledPluginDirectory
14+
if core_platform == "Darwin":
15+
_base_path = BNGetBundledPluginDirectory()
16+
core = ctypes.CDLL(os.path.join(_base_path, "libkernelcache.dylib"))
17+
18+
elif core_platform == "Linux":
19+
_base_path = BNGetBundledPluginDirectory()
20+
core = ctypes.CDLL(os.path.join(_base_path, "libkernelcache.so"))
21+
22+
elif (core_platform == "Windows") or (core_platform.find("CYGWIN_NT") == 0):
23+
_base_path = BNGetBundledPluginDirectory()
24+
core = ctypes.CDLL(os.path.join(_base_path, "kernelcache.dll"))
25+
else:
26+
raise Exception("OS not supported")
2527
else:
26-
raise Exception("OS not supported")
28+
from binaryninja._binaryninjacore import BNGetUserPluginDirectory
29+
if core_platform == "Darwin":
30+
_base_path = BNGetUserPluginDirectory()
31+
core = ctypes.CDLL(os.path.join(_base_path, "libkernelcache.dylib"))
32+
33+
elif core_platform == "Linux":
34+
_base_path = BNGetUserPluginDirectory()
35+
core = ctypes.CDLL(os.path.join(_base_path, "libkernelcache.so"))
36+
37+
elif (core_platform == "Windows") or (core_platform.find("CYGWIN_NT") == 0):
38+
_base_path = BNGetUserPluginDirectory()
39+
core = ctypes.CDLL(os.path.join(_base_path, "kernelcache.dll"))
40+
else:
41+
raise Exception("OS not supported")
2742

2843
def cstr(var) -> Optional[ctypes.c_char_p]:
2944
if var is None:

0 commit comments

Comments
 (0)