1
- from PySide2 import QtCore
1
+ from PySide2 import QtCore , QtGui
2
2
from PySide2 .QtCore import Qt
3
3
from PySide2 .QtWidgets import QApplication , QHBoxLayout , QVBoxLayout , QLabel , QWidget , QPushButton , QLineEdit , QToolBar , QToolButton , QMenu , QAction
4
4
from binaryninja import execute_on_main_thread_and_wait , BinaryView
13
13
from . import AdapterSettingsDialog
14
14
from .. import binjaplug , DebugAdapter
15
15
16
+ def load_icon (fname_icon ):
17
+ path_this_file = os .path .abspath (__file__ )
18
+ path_this_dir = os .path .dirname (path_this_file )
19
+ path_icons = os .path .join (path_this_dir , '..' , 'media' , 'icons' )
20
+ path_icon = os .path .join (path_icons , fname_icon )
21
+
22
+ pixmap = QtGui .QPixmap (path_icon )
23
+
24
+ #pixmap.fill(QtGui.QColor('red'))
25
+ #pixmap.setMask(pixmap.createMaskFromColor(QtGui.QColor('black'), QtGui.Qt.MaskOutColor))
26
+
27
+ icon = QtGui .QIcon ()
28
+ icon .addPixmap (pixmap , QtGui .QIcon .Normal )
29
+ icon .addPixmap (pixmap , QtGui .QIcon .Disabled )
30
+
31
+ return icon
32
+
16
33
class DebugControlsWidget (QToolBar ):
17
34
def __init__ (self , parent , name , data , debug_state ):
18
35
if not type (data ) == BinaryView :
@@ -31,30 +48,54 @@ def __init__(self, parent, name, data, debug_state):
31
48
32
49
self .actionRun = QAction ("Run" , self )
33
50
self .actionRun .triggered .connect (lambda : self .perform_run ())
51
+ self .actionRun .setIcon (load_icon ('run.svg' ))
52
+
34
53
self .actionRestart = QAction ("Restart" , self )
35
54
self .actionRestart .triggered .connect (lambda : self .perform_restart ())
55
+ self .actionRestart .setIcon (load_icon ('restart.svg' ))
56
+
36
57
self .actionQuit = QAction ("Quit" , self )
37
58
self .actionQuit .triggered .connect (lambda : self .perform_quit ())
59
+ self .actionQuit .setIcon (load_icon ('cancel.svg' ))
60
+
38
61
self .actionAttach = QAction ("Attach" , self )
39
62
self .actionAttach .triggered .connect (lambda : self .perform_attach ())
63
+ self .actionAttach .setIcon (load_icon ('connect.svg' ))
64
+
40
65
self .actionDetach = QAction ("Detach" , self )
41
66
self .actionDetach .triggered .connect (lambda : self .perform_detach ())
67
+ self .actionDetach .setIcon (load_icon ('disconnect.svg' ))
68
+
42
69
self .actionSettings = QAction ("Settings..." , self )
43
70
self .actionSettings .triggered .connect (lambda : self .perform_settings ())
71
+
44
72
self .actionPause = QAction ("Pause" , self )
45
73
self .actionPause .triggered .connect (lambda : self .perform_pause ())
74
+ self .actionPause .setIcon (load_icon ('pause.svg' ))
75
+
46
76
self .actionResume = QAction ("Resume" , self )
47
77
self .actionResume .triggered .connect (lambda : self .perform_resume ())
78
+ self .actionResume .setIcon (load_icon ('resume.svg' ))
79
+
48
80
self .actionStepIntoAsm = QAction ("Step Into (Assembly)" , self )
49
81
self .actionStepIntoAsm .triggered .connect (lambda : self .perform_step_into_asm ())
82
+ self .actionStepIntoAsm .setIcon (load_icon ('stepinto.svg' ))
83
+
50
84
self .actionStepIntoIL = QAction ("Step Into" , self )
51
85
self .actionStepIntoIL .triggered .connect (lambda : self .perform_step_into_il ())
86
+ self .actionStepIntoIL .setIcon (load_icon ('stepinto.svg' ))
87
+
52
88
self .actionStepOverAsm = QAction ("Step Over (Assembly)" , self )
53
89
self .actionStepOverAsm .triggered .connect (lambda : self .perform_step_over_asm ())
90
+ self .actionStepOverAsm .setIcon (load_icon ('stepover.svg' ))
91
+
54
92
self .actionStepOverIL = QAction ("Step Over" , self )
55
93
self .actionStepOverIL .triggered .connect (lambda : self .perform_step_over_il ())
94
+ self .actionStepOverIL .setIcon (load_icon ('stepover.svg' ))
95
+
56
96
self .actionStepReturn = QAction ("Step Return" , self )
57
97
self .actionStepReturn .triggered .connect (lambda : self .perform_step_return ())
98
+ self .actionStepReturn .setIcon (load_icon ('stepout.svg' ))
58
99
59
100
# session control menu
60
101
self .controlMenu = QMenu ("Process Control" , self )
@@ -83,8 +124,13 @@ def __init__(self, parent, name, data, debug_state):
83
124
self .addWidget (self .btnControl )
84
125
85
126
# execution control buttons
86
- self .addAction (self .actionPause )
87
- self .addAction (self .actionResume )
127
+ self .btnPauseResume = QToolButton (self )
128
+ self .btnPauseResume .setToolButtonStyle (Qt .ToolButtonTextBesideIcon )
129
+ self .btnPauseResume .setDefaultAction (self .actionPause )
130
+ self .addWidget (self .btnPauseResume )
131
+
132
+ #self.addAction(self.actionPause)
133
+ #self.addAction(self.actionResume)
88
134
89
135
self .btnStepInto = QToolButton (self )
90
136
self .btnStepInto .setMenu (self .stepIntoMenu )
@@ -101,7 +147,12 @@ def __init__(self, parent, name, data, debug_state):
101
147
self .addWidget (self .btnStepOver )
102
148
103
149
# TODO: Step until returning from current function
104
- self .addAction (self .actionStepReturn )
150
+ self .btnStepReturn = QToolButton (self )
151
+ self .btnStepReturn .setToolButtonStyle (Qt .ToolButtonTextBesideIcon )
152
+ self .btnStepReturn .setDefaultAction (self .actionStepReturn )
153
+ self .addWidget (self .btnStepReturn )
154
+
155
+ #self.addAction(self.actionStepReturn)
105
156
106
157
self .threadMenu = QMenu ("Threads" , self )
107
158
@@ -132,7 +183,6 @@ def __del__(self):
132
183
# -------------------------------------------------------------------------
133
184
# Helpers
134
185
# -------------------------------------------------------------------------
135
-
136
186
def can_exec (self ):
137
187
return DebugAdapter .ADAPTER_TYPE .use_exec (self .debug_state .adapter_type )
138
188
@@ -439,8 +489,8 @@ def set_default_process_action(self, action):
439
489
self .btnControl .setDefaultAction (actions [action ])
440
490
441
491
def set_resume_pause_action (self , action ):
442
- self . actionResume . setVisible ( action == " Resume" )
443
- self .actionPause . setVisible ( action == "Pause" )
492
+ lookup = { ' Resume' : self . actionResume , 'Pause' : self . actionPause }
493
+ self .btnPauseResume . setDefaultAction ( lookup [ action ] )
444
494
445
495
def set_thread_list (self , threads ):
446
496
def select_thread_fn (tid ):
0 commit comments