-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFixFidConflictLabels.py
56 lines (52 loc) · 1.79 KB
/
FixFidConflictLabels.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
#Restore labels to the ones before FID conflict bullshit
#@author Rena
#@category Functions
#@keybinding
#@menupath
#@toolbar
import jarray
import struct
AF = currentProgram.getAddressFactory()
mem = currentProgram.getMemory()
SymTab = currentProgram.symbolTable
listing = currentProgram.getListing()
def addrToInt(addr):
return int(str(addr), 16)
def removeLabels(addrStart, addrEnd):
addressSetView = AF.getAddressSet(addrStart, addrEnd)
clearListing(addressSetView,
False, #code
True, #symbols
False, #comments
False, #properties
False, #functions
False, #registers
False, #equates
False, #userReferences
False, #analysisReferences
False, #importReferences
False, #defaultReferences
False) #bookmarks
funcs = list(listing.getFunctions(True))
monitor.initialize(len(funcs))
monitor.setMessage("Fixing...")
nFuncs = 0
for func in funcs:
history = SymTab.getLabelHistory(func.body.minAddress)
for i, item in enumerate(history):
if item.labelString.startswith('FID_conflict:'):
lol = history[i-1].labelString.split(' ')[0]
print(func, lol)
removeLabels(func.body.minAddress, func.body.minAddress.add(3))
func.setName(lol, ghidra.program.model.symbol.SourceType.USER_DEFINED)
break
elif 'FID_conflict:' in item.labelString:
fuckMakingSense = item.labelString.split(' to ')[0]
print(func, fuckMakingSense)
removeLabels(func.body.minAddress, func.body.minAddress.add(3))
func.setName(fuckMakingSense, ghidra.program.model.symbol.SourceType.USER_DEFINED)
break
nFuncs += 1
monitor.checkCanceled()
monitor.incrementProgress(1)
print("Checked %d functions" % nFuncs)