-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathtyperegter_plugin.py
60 lines (44 loc) · 1.42 KB
/
typeregter_plugin.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
from oregami.reg_utils import *
from oregami.reg_type import rf_settype, get_type_from_user
from oregami.reg_frame import RegFrame
class TyperegterPlugin(idaapi.plugin_t):
flags = idaapi.PLUGIN_PROC
comment = "TypeREGter"
help = "Set type for regs in their usage frame - only when " \
"used as a specific variable"
wanted_name = "TypeREGter"
wanted_hotkey = "Shift+T"
@staticmethod
def init():
return idaapi.PLUGIN_OK
@staticmethod
def term():
pass
@staticmethod
def run(arg):
start, _ = sark.get_selection()
typeregter_plugin_starter(start)
def PLUGIN_ENTRY():
return TyperegterPlugin()
def typeregter_plugin_starter(orig_ea):
canon_list = conf.proc.get_reg_list()
# print canon_list
reg = get_reg_from_cursor(orig_ea, canon_list)
if reg is None:
# Ask for user input - may be used to look for a reg influencing
# the line - even if it doesn't exist on the line
reg_idx = RegChoose(orig_ea, canon_list).Show(True)
if reg_idx >= 0:
reg = canon_list[reg_idx]
else:
return
reg = RegName(orig_ea, canon_list).canon(reg)
if reg is None:
return
# Get type name
type_name = get_type_from_user()
if type_name is None:
return
# global conf
rf = RegFrame(orig_ea, reg, force=(not conf.cache_bool))
rf_settype(rf, type_name)