-
Notifications
You must be signed in to change notification settings - Fork 22
/
regname_plugin.py
50 lines (36 loc) · 1.03 KB
/
regname_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
import idaapi
import sark
from oregami.reg_frame import RegFrame
from oregami.reg_utils import conf, get_reg_from_user
from oregami.reg_name import rf_rename, get_name_from_user
def regname_plugin_starter(ea):
# Get register
reg = get_reg_from_user(ea)
if reg is None:
return
# Get new name
reg_new_name = get_name_from_user(ea, reg)
if reg_new_name is None:
return
# global conf
rf = RegFrame(ea, reg, force=(not conf.cache_bool))
rf_rename(rf, reg_new_name)
class RegnamePlugin(idaapi.plugin_t):
flags = idaapi.PLUGIN_PROC
comment = "reGname"
help = "Rename registers in their usage frame - only when used " \
"as a specific variable"
wanted_name = "reGname"
wanted_hotkey = "Shift+N"
@staticmethod
def init():
return idaapi.PLUGIN_OK
@staticmethod
def term():
pass
@staticmethod
def run(arg):
start, _ = sark.get_selection()
regname_plugin_starter(start)
def PLUGIN_ENTRY():
return RegnamePlugin()