Last active
March 21, 2021 21:28
-
-
Save VelocityRa/3a8327d53286c8df7433ec05cf023596 to your computer and use it in GitHub Desktop.
Ghidra script made to find all Sly 2 PS2 2002 proto vtable pointers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#TODO write a description for this script | |
#@author | |
#@category _NEW_ | |
#@keybinding | |
#@menupath | |
#@toolbar | |
from ghidra.program.model.data import Pointer32DataType | |
from ghidra.program.model.util import CodeUnitInsertionException | |
from pprint import pprint | |
from inspect import getmembers | |
from types import FunctionType | |
def attributes(obj): | |
disallowed_names = { | |
name for name, value in getmembers(type(obj)) | |
if isinstance(value, FunctionType)} | |
return { | |
name: getattr(obj, name) for name in dir(obj) | |
if name[0] != '_' and name not in disallowed_names and hasattr(obj, name)} | |
def print_attributes(obj): | |
pprint(attributes(obj)) | |
glob_namespace = currentProgram.getGlobalNamespace() | |
# i gave up here lol | |
sym_str_list = ["g_vt_fcst","g_vt_viszone","g_vtaccmiss","g_vtacg","g_vtacgb","g_vtacgblp","g_vtacgblt","g_vtacgbw","g_vtacgl","g_vtacp","g_vtacpb","g_vtacpbl","g_vtacpc","g_vtacr","g_vtacrb","g_vtacrbl","g_vtacrc","g_vtacs","g_vtacsb","g_vtacsc","g_vtact","g_vtactadd","g_vtactadj","g_vtactbank","g_vtactla","g_vtactref","g_vtactseg","g_vtactval","g_vtalarm","g_vtalbrk","g_vtalo","g_vtaseg","g_vtasega","g_vtasegbl","g_vtattract","g_vtbarrier","g_vtbasic","g_vtbhg","g_vtbinoc","g_vtblipg","g_vtblot","g_vtbomb","g_vtbone","g_vtboostctr","g_vtbossctr","g_vtbreak","g_vtbrk","g_vtbrkp","g_vtbtn","g_vtbublet","g_vtbullet","g_vtburst","g_vtbutton","g_vtcall","g_vtcamera","g_vtcamsen","g_vtcan","g_vtcharm","g_vtchkmgr","g_vtchkpnt","g_vtcircler","g_vtclue","g_vtcluectr","g_vtcm","g_vtcnvo","g_vtcoin","g_vtcoinctr","g_vtcpalign","g_vtcpaseg","g_vtcplcy","g_vtcplook","g_vtcpman","g_vtcptn","g_vtcrbrain","g_vtcredit","g_vtcrfod","g_vtcrfodb","g_vtcrfodk","g_vtcrusherctr","g_vtcrv","g_vtcrvc","g_vtcrvl","g_vtctr","g_vtcycle","g_vtdablet","g_vtdart","g_vtdartgun","g_vtdebris","g_vtdebugmenu","g_vtdialog","g_vtdifficulty","g_vtdprize","g_vtdroplet","g_vtdsp","g_vtdysh","g_vtemitter","g_vtexit","g_vtexpl","g_vtexplg","g_vtexplo","g_vtexpls","g_vteyes","g_vtfireball","g_vtflake","g_vtflame","g_vtflash","g_vtfly","g_vtflying","g_vtfragile","g_vtfrzg","g_vtgame","g_vtglint","g_vtgold","g_vtgoldctr","g_vtgomer","g_vtgroundmiss","g_vthbsk","g_vthg","g_vthnd","g_vthologram","g_vthpnt","g_vthshape","g_vtikh","g_vtjack","g_vtjackb","g_vtjackf","g_vtjackn","g_vtjlo","g_vtjloc","g_vtjlovol","g_vtjmt","g_vtjoy","g_vtjp","g_vtjsg","g_vtjt","g_vtkey","g_vtkeyctr","g_vtkeyhole","g_vtlanding","g_vtlapctr","g_vtlasen","g_vtlbone","g_vtleaf","g_vtletterbox","g_vtlgn","g_vtlgnb","g_vtlgnr","g_vtlifectr","g_vtlifetkn","g_vtlight","g_vtlikh","g_vtlo","g_vtlock","g_vtlockg","g_vtlogo","g_vtlooker","g_vtloop","g_vtmap","g_vtmatch","g_vtmbg","g_vtmecha","g_vtmgc","g_vtmgv","g_vtmissile","g_vtmrkv","g_vtms","g_vtmurray","g_vtnote","g_vtorbit","g_vtpathzone","g_vtpingpong","g_vtpipe","g_vtplacectr","g_vtpnt","g_vtpnts","g_vtpntsv","g_vtpntvec","g_vtpo","g_vtprompt","g_vtproxy","g_vtprsen","g_vtpuff","g_vtpuffb","g_vtpuffc","g_vtpuffchargectr","g_vtpuffer","g_vtpufft","g_vtpuffv","g_vtrail","g_vtrat","g_vtrathole","g_vtray","g_vtrchm","g_vtremit","g_vtrip","g_vtripg","g_vtripple","g_vtrob","g_vtroc","g_vtroh","g_vtrop","g_vtrope","g_vtrose","g_vtrost","g_vtrov","g_vtrumble","g_vtrwm","g_vtsaa","g_vtscan","g_vtscentmap","g_vtsch","g_vtscores","g_vtscprize","g_vtscroller","g_vtsensor","g_vtsgg","g_vtshape","g_vtshrapnel","g_vtshuffle","g_vtsky","g_vtsm","g_vtsma","g_vtsmack","g_vtsmartguard","g_vtsmokecloud","g_vtsmoketrail","g_vtso","g_vtspark","g_vtspeaker","g_vtspire","g_vtsplmiss","g_vtsprize","g_vtsquish","g_vtstep","g_vtstepguard","g_vtstuck","g_vtsuv","g_vtsw","g_vtswp","g_vttail","g_vttank","g_vttarget","g_vttarmiss","g_vttimer","g_vttitle","g_vttn","g_vttotals","g_vttrail","g_vttrunkctr","g_vtturret","g_vttv","g_vttzp","g_vtubg","g_vtubp","g_vtubv","g_vtui","g_vtvault","g_vtvismap","g_vtvol","g_vtvolbtn","g_vtvolzp","g_vtwarp","g_vtwater","g_vtwaypoint","g_vtwipe","g_vtwm","g_vtwmc","g_vtwpsg","g_vtwr","g_vtxfm","g_vtzapbreak"] | |
fac = currentProgram.getAddressFactory() | |
# from aerosoul | |
def forcePointer(addr): | |
try: | |
createData(addr, Pointer32DataType.dataType) | |
except CodeUnitInsertionException: | |
clearListing(addr, addr.add(4)) | |
try: | |
createData(addr, Pointer32DataType.dataType) | |
except: | |
pass # idk, just don't end the script.. | |
except JavaException as e: | |
print(e) | |
for sym_str in sym_str_list: | |
sym = getSymbols(sym_str, glob_namespace)[0] | |
sym_after = getSymbolAfter(sym) | |
sym_after_addr = sym_after.address.offset | |
for offs in range(sym.address.offset, sym_after.address.offset, 4): | |
addr = fac.getAddress("0x%X" % offs) | |
forcePointer(addr) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment