-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathImportSymbolList.py
More file actions
46 lines (39 loc) · 1.28 KB
/
Copy pathImportSymbolList.py
File metadata and controls
46 lines (39 loc) · 1.28 KB
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
#Imports a file with lines in the form of 0xADDRESS "symbolName"
#Should work both in Ghidra and IDA, at least hasn't broke yet
#@category Data
#@tomsons26
#test
#for name in vars().keys():
# print(name)
def Is_IDA():
return 'IDA_SDK_VERSION' in globals()
def Ask_File():
if Is_IDA():
return AskFile(0, "*.symlist", "Select Symbol List file to read")
else:
return askFile("Select Symbol List file to read", "Process File")
def Set_Function_Name(address, name):
if Is_IDA():
MakeNameEx(int(address, 16), name, False)
else:
from ghidra.program.model.symbol.SourceType import USER_DEFINED
from ghidra.program.model.symbol import SymbolUtilities
addr = toAddr(long(address, 16))
name = SymbolUtilities.replaceInvalidChars(name, True)
if getFunctionAt(addr):
getFunctionAt(addr).setName(name, USER_DEFINED)
else:
createLabel(addr, name, True)
f = Ask_File()
if f:
if Is_IDA():
path = f
else:
path = f.absolutePath
for line in file(path):
entry = line.split("\"", 2)
address = entry[0]
name = entry[1]
#print "Creating Symbol", name, "at Address", address
Set_Function_Name(address, name)
print "Importing Done\n"