mirror of
https://github.com/ran-j/PS2Recomp.git
synced 2026-09-28 01:15:04 -04:00
d7306d2095
* feat: pin dependencies * feat: dwarf parse * fix duplicated functions * feat: small code cleanup * feat: crash prevent * feat: modernize code * feat: split m_libFunctions from m_knownLibNames * feat: added ghidra loader * feat: auto bootstrap name for recompiler
44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
# Exports function addresses and names to CSV for PS2Recomp
|
|
# @category PS2Recomp
|
|
|
|
import csv
|
|
import os
|
|
|
|
from ghidra.program.model.symbol import SourceType
|
|
|
|
def run():
|
|
f = askFile("Choose output CSV file", "Save")
|
|
|
|
if f is None:
|
|
return
|
|
|
|
with open(f.getAbsolutePath(), 'w') as csvfile:
|
|
writer = csv.writer(csvfile)
|
|
writer.writerow(['Name', 'Start', 'End', 'Size'])
|
|
|
|
fm = currentProgram.getFunctionManager()
|
|
functions = fm.getFunctions(True) # True iterates forward wtf kkkkk
|
|
|
|
count = 0
|
|
for func in functions:
|
|
name = func.getName()
|
|
start = func.getEntryPoint().getOffset()
|
|
|
|
body = func.getBody()
|
|
max_addr = body.getMaxAddress().getOffset()
|
|
|
|
size = body.getNumAddresses()
|
|
|
|
writer.writerow([
|
|
name,
|
|
"0x{:08X}".format(start),
|
|
"0x{:08X}".format(max_addr + 1), # End address is exclusive
|
|
size
|
|
])
|
|
count += 1
|
|
|
|
print("Exported {} functions to {}".format(count, f.getAbsolutePath()))
|
|
|
|
if __name__ == "__main__":
|
|
run()
|