-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathobjc_hotkeys.py
49 lines (35 loc) · 1.19 KB
/
objc_hotkeys.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
"""
Add Ctrl+4 Hotkey for accessing the code reference to the current selector
License: LGPLv3
https://github.com/doronz88/ida-scripts/blob/main/objc_hotkeys.py
"""
import ida_kernwin
import idautils
import idc
__author__ = 'https://github.com/doronz88'
SELECTOR_XREF_HOTKEY = 'Ctrl+4'
IGNORED_SECTIONS = ('__objc_const',)
def print_ea(ea: int) -> None:
func_name = idc.get_func_name(ea)
func_address = idc.get_name_ea_simple(func_name)
if ea == func_address:
name = func_name
else:
name = f'{func_name} + {ea - func_address}'
print(f'0x{ea:08x} {name}')
def locate_selector_xrefs() -> None:
current_ea = idc.get_screen_ea()
func_name = idc.get_func_name(current_ea)
try:
selector = func_name.split(' ')[1].split(']')[0]
except IndexError:
print('Failed to find current selector')
return
print(f'looking for references to: {selector}')
for ea in idautils.XrefsTo(idc.get_name_ea_simple(f'_objc_msgSend${selector}')):
print_ea(ea.frm)
def main() -> None:
ida_kernwin.del_idc_hotkey(SELECTOR_XREF_HOTKEY)
ida_kernwin.add_hotkey(SELECTOR_XREF_HOTKEY, locate_selector_xrefs)
if __name__ == '__main__':
main()