-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path__init__.py
More file actions
31 lines (23 loc) · 1009 Bytes
/
Copy path__init__.py
File metadata and controls
31 lines (23 loc) · 1009 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from binaryninja import *
from binaryninjaui import *
from .dsc import DyldSharedCacheView
DyldSharedCacheView.register()
class DSCViewWatcher(UIContextNotification):
def __init__(self):
UIContextNotification.__init__(self)
UIContext.registerNotification(self)
def __del__(self):
UIContext.unregisterNotification(self)
def OnAfterOpenFile(self, context, file, frame):
# We only want to auto-switch DyldSharedCache views
if "DyldSharedCache" not in frame.getCurrentView():
return
# Get the current BinaryView and setup the Mach-O view so we can use it
view = frame.getCurrentBinaryView()
view.file.get_view_of_type('Mach-O')
# Switch to the Mach-O view now that the file has finished loading
mainthread.execute_on_main_thread(lambda: frame.setViewType("Linear:Mach-O"))
# Register the view watcher globally so newly-created DSC views can be
# automatically switched to Mach-O after opening. This must be a global
# variable so it is not destroyed.
watcher = DSCViewWatcher()