IDA: Optimize function creation (#75)
This commit is contained in:
@@ -8,7 +8,7 @@ from ghidra.program.model.symbol import SourceType
|
||||
def SetName(addr, name):
|
||||
createLabel(toAddr(addr), name, True)
|
||||
|
||||
def MakeFunction(start, name=None):
|
||||
def MakeFunction(start, name=None, addrMax=None):
|
||||
addr = toAddr(start)
|
||||
# Don't override existing functions
|
||||
fn = getFunctionAt(addr)
|
||||
|
||||
@@ -7,8 +7,16 @@ def SetName(addr, name):
|
||||
new_name = name + '_' + str(addr)
|
||||
ret = idc.set_name(addr, new_name, SN_NOWARN | SN_NOCHECK)
|
||||
|
||||
def MakeFunction(start):
|
||||
def MakeFunction(start, name=None, addrMax=None):
|
||||
ida_funcs.add_func(start)
|
||||
#limit end function to maxAddr if any
|
||||
if addrMax is None:
|
||||
return
|
||||
addrEnd = idc.get_func_attr(start,FUNCATTR_END)
|
||||
if addrEnd == idaapi.BADADDR:
|
||||
return
|
||||
if addrEnd > addrMax:
|
||||
idc.set_func_end(start,addrMax)
|
||||
|
||||
def MakeArray(addr, numItems, cppType):
|
||||
SetType(addr, cppType)
|
||||
|
||||
@@ -97,8 +97,17 @@ def ProcessJSON(jsonData):
|
||||
|
||||
# Function boundaries
|
||||
print('Processing function boundaries')
|
||||
for d in jsonData['functionAddresses']:
|
||||
MakeFunction(int(d, 0))
|
||||
functionAddresses = jsonData['functionAddresses']
|
||||
functionAddresses.sort()
|
||||
count = len(functionAddresses)
|
||||
for i in range(count):
|
||||
addrStart = int(functionAddresses[i],0)
|
||||
if addrStart == 0:
|
||||
continue
|
||||
addrNext = None
|
||||
if i != count -1:
|
||||
addrNext = int(functionAddresses[i+1],0)
|
||||
MakeFunction(addrStart,None,addrNext)
|
||||
|
||||
# IL2CPP type metadata
|
||||
print('Processing IL2CPP type metadata')
|
||||
|
||||
Reference in New Issue
Block a user