def name_handlers(ea_from, ea_to):
global COUNT
addr = ea_from
print "from: 0x%08x to: 0x%08x" % (addr, ea_to)
while (addr < ea_to):
func_to_name_ea = idc.Dword(addr) & 0xFFFFFFFE
log_msg_ptr = idc.Dword(addr + 12)
log_msg = idc.GetString(log_msg_ptr)
#is that a function already?
#There were 0 cases of this for our case
if not idaapi.get_func(func_to_name_ea):
print "There is no function at 0x%08x!" % func_to_name_ea
idc.MakeFunction(func_to_name_ea)
if "sms_Decode" in idc.GetFunctionName(func_to_name_ea) or "mm_Decode" in idc.GetFunctionName(func_to_name_ea) or "cc_Decode" in idc.GetFunctionName(func_to_name_ea) or "gmm_Decode" in idc.GetFunctionName(func_to_name_ea):
print "Already named appropriately, don't overwrite"
else:
print "Naming %s based on %s as %s" % (idc.GetFunctionName(func_to_name_ea), log_msg, create_name(log_msg))
COUNT += 1
name = create_name(log_msg)
# TODO: enable below naming
ret = idc.LocByName(name)
count = 1
while (ret != 0xffffffff):
count += 1
ret = idc.LocByName(name + "__" + "%d" % count)
idc.MakeName(func_to_name_ea, name + ("__%d" % count)*(count > 1))
addr += 16
评论列表
文章目录