-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDP_SetRomTable.py
53 lines (46 loc) · 1.33 KB
/
DP_SetRomTable.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
#Set Dino Planet ROM table pointers.
#@author
#@category StarFox
#@keybinding
#@menupath
#@toolbar
from ghidra.program.model.listing import ParameterImpl
from ghidra.program.model.symbol import SourceType
TABLE_ADDR = 0xb00a4970
TABLE_SIZE = 76
FILE_BASE = TABLE_ADDR + (TABLE_SIZE * 4)
FILE_IDS = {
0x24: 'TEX1_BIN',
0x27: 'TEX0_BIN',
0x33: 'ANIM_TAB',
0x34: 'ANIM_BIN',
0x46: 'DLLS_BIN',
}
AF = currentProgram.getAddressFactory()
listing = currentProgram.getListing()
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
def addrToInt(addr):
return int(str(addr), 16)
def intToAddr(addr):
return AF.getAddress("0x%08X" % addr)
table = listing.getDataAt(intToAddr(TABLE_ADDR))
for i in range(1, TABLE_SIZE):
offs = addrToInt(table.getComponent(i).value) + FILE_BASE
name = FILE_IDS.get(i-1, 'FILE_%02X' % (i-1))
addr = intToAddr(offs)
removeLabels(addr, addr.add(3))
createLabel(addr, 'ROM_'+name, False)