-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtweak-installer.py
67 lines (47 loc) · 1.81 KB
/
tweak-installer.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import os
import sys
from PyQt5 import QtCore, QtWidgets, QtGui
#sys.path.append('/home/neil/bin/binaryninja/python/')
import binaryninja as binja
import UITweaks as Tweaks
import BinjaUI as ui
from BinjaUI import Util
enabled = []
enabledTweaks = []
installedTweaks = []
done = False
# open the .tweaks file to get config
path = os.path.join(binja.user_plugin_path, ".tweaks")
try:
f = open(path, 'r')
for x in f:
x = x.strip()
if x[0] == '#':
continue
enabled.append(x)
except:
done = True
if len(enabled) == 0:
done = True
if not done:
def StackedWidgetEventFilter(obj, evt):
if obj == stackedWidget:
if (evt.type() == QtCore.QEvent.ChildAdded) and (evt.child().isWidgetType()) and (evt.child().metaObject().className() == 'ViewFrame'):
# Make sure we're setup.
Tweaks.Util.InitUtils()
# Install the view modification
for tweak in enabledTweaks:
new_tweak = tweak()
wi = ui.WidgetInjector(lambda :new_tweak.install(evt.child()))
if wi.inject():
installedTweaks.append(new_tweak)
tabWidgets = [w for w in ui._app().allWidgets() if w.__class__ is QtWidgets.QTabWidget]
mainTabWidget = [w for w in tabWidgets if w.parent().__class__ is QtWidgets.QMainWindow][0]
stackedWidget = [w for w in mainTabWidget.children() if w.__class__ is QtWidgets.QStackedWidget][0]
ui.Util.EventFilterManager.InstallOnObject(stackedWidget, StackedWidgetEventFilter)
for tweak in Tweaks.Available:
if tweak.name in enabled:
enabledTweaks.append(tweak)
binja.PluginCommand.register_for_function("__leakFunction", "", Tweaks.Util.__LeakFunction)
else:
print 'No tweaks enabled.'