@@ -53,6 +53,15 @@ def get_processor(current_program):
53
53
54
54
55
55
def find_function (current_program , function_name ):
56
+ """
57
+ Find a function, by name, in the current program.
58
+
59
+ :param current_program: Current program loaded in Ghidra.
60
+ :type current_program: ghidra.program.model.listing.Program
61
+
62
+ :param function_name: Function to search for.
63
+ :type function_name: str
64
+ """
56
65
listing = current_program .getListing ()
57
66
if listing :
58
67
return listing .getGlobalFunctions (function_name )
@@ -70,3 +79,21 @@ def address_to_int(address):
70
79
:rtype: int
71
80
"""
72
81
return int (address .toString (), 16 )
82
+
83
+
84
+ def allowed_processors (current_program , processor_list ):
85
+ """
86
+ Function to prevent scripts from running against unsupported processors.
87
+
88
+ :param current_program: Current program loaded in Ghidra.
89
+ :type current_program: ghidra.program.model.listing.Program
90
+
91
+ :param processor_list: List of supported processors.
92
+ :type processor_list: list(str)
93
+ """
94
+ curr_processor = get_processor (current_program )
95
+
96
+ if curr_processor not in processor_list :
97
+ print '%s is not a valid processor for this script. Supported ' \
98
+ 'processors are: %s' % (curr_processor , processor_list )
99
+ exit (1 )
0 commit comments