Created
June 18, 2020 05:18
-
-
Save SciresM/5f8fd6e245f5177094657e3e08f96595 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from idautils import * | |
from idaapi import * | |
from idc import * | |
from ida_hexrays import * | |
START_100 = 0x7100770C10 | |
END_100 = 0x710077FC60 | |
START_110 = 0x7100770E30 | |
END_110 = 0x710077FE80 | |
START_120 = 0x7100771370 | |
END_120 = 0x7100780650 | |
# To go from 1.1.0 to 1.2.0, two new functions are added to the pml accessor library | |
# 1.1.0 will have 199 functions, 1.2.0 will have 201 functions | |
# A getter for the new Battle Version field at block C + 0x37 is inserted at index 102 (after GetBlockB_40), | |
# and a setter for the new Battle Version field is inserted at index 189 (after SetBlockA_49). | |
MAPPING = { | |
# Generate this in your old IDB, then apply edits described above as needed | |
} | |
V100, V110, V120 = range(3) | |
VERSION = V120 | |
if VERSION == V100: | |
FUNCRANGE = (START_100, END_100) | |
GENERATE = True | |
elif VERSION == V110: | |
FUNCRANGE = (START_110, END_110) | |
GENERATE = True | |
elif VERSION == V120: | |
FUNCRANGE = (START_120, END_120) | |
GENERATE = False | |
else: | |
raise ValueError() | |
def is_pml_func(ea): | |
return FUNCRANGE[0] <= ea and ea <= FUNCRANGE[1] | |
# Iterate over all segments | |
COUNT = 0 | |
for segea in Segments(): | |
for funcea in Functions(segea, get_segm_end(segea)): | |
func_name = idc.get_func_name(funcea) | |
func_type = idc.get_type(funcea) | |
if is_pml_func(funcea): | |
if GENERATE: | |
print '%d: (\'%s\', \'%s\'),' % (COUNT, func_name, func_type) | |
else: | |
name, type = MAPPING[COUNT] | |
idc.set_name(funcea, name, SN_CHECK) | |
idc.SetType(funcea, type.replace('(', ' a(')+';') | |
COUNT += 1 | |
print 'Total: %d' % COUNT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment