本文整理匯總了Python中idc.MakeNameEx方法的典型用法代碼示例。如果您正苦於以下問題:Python idc.MakeNameEx方法的具體用法?Python idc.MakeNameEx怎麽用?Python idc.MakeNameEx使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類idc
的用法示例。
在下文中一共展示了idc.MakeNameEx方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: set_ea_name
# 需要導入模塊: import idc [as 別名]
# 或者: from idc import MakeNameEx [as 別名]
def set_ea_name(ea, name, rename=False, auto=False):
"""Set the name of an address.
Arguments:
ea: The address to name.
name: The new name of the address.
Options:
rename: If rename is False, and if the address already has a name, and if that name differs
from the new name, then this function will fail. Set rename to True to rename the
address even if it already has a custom name. Default is False.
auto: If auto is True, then mark the new name as autogenerated. Default is False.
Returns:
True if the address was successfully named (or renamed).
"""
if not rename and idc.hasUserName(idc.GetFlags(ea)):
return get_ea_name(ea) == name
flags = idc.SN_CHECK
if auto:
flags |= idc.SN_AUTO
return bool(idc.MakeNameEx(ea, name, flags))
示例2: _rename_functions
# 需要導入模塊: import idc [as 別名]
# 或者: from idc import MakeNameEx [as 別名]
def _rename_functions(self):
'''Rename functions.'''
print "IPL: Started to rename functions..."
failed = 0
total = 0
for function in idautils.Functions():
total += 1
pdb_mangled_name = self.PDBLookup.lookup(function, True)
if not pdb_mangled_name:
failed += 1
print "IPL: Failed to find symbol for function: 0x{:08x}".format(function)
continue
_, mangled_function_name = pdb_mangled_name.split('!')
# https://www.hex-rays.com/products/ida/support/idadoc/203.shtml
idc.MakeNameEx(function, mangled_function_name,
idc.SN_AUTO | idc.SN_NOCHECK)
print "IPL: Total {} functions, {} failed to rename.".format(total, failed)
示例3: makeNameHard
# 需要導入模塊: import idc [as 別名]
# 或者: from idc import MakeNameEx [as 別名]
def makeNameHard(ea, name):
'''Keeps trying to name the given ea until it works, adding the optional _%d suffix'''
if using_ida7api:
return makeNameHard_ida7(ea, name)
count = 0
ret = idc.MakeNameEx(ea, name, idc.SN_PUBLIC|idc.SN_NOWARN)
m = HARD_NAME_RE.match(name)
if m is not None:
#already a name in <name>_<count> format
name, count = m.group(1,2)
count = int(count)
if ret == 0:
while (count < 100) and (ret == 0):
newName = '%s_%d' % (name, count)
ret = idc.MakeNameEx(ea, newName, idc.SN_PUBLIC|idc.SN_NOWARN)
count += 1
示例4: set_symbol_name
# 需要導入模塊: import idc [as 別名]
# 或者: from idc import MakeNameEx [as 別名]
def set_symbol_name(ea, name):
global _FORCED_NAMES
flags = idaapi.SN_PUBLIC | idaapi.SN_NOCHECK | idaapi.SN_NON_AUTO | idaapi.SN_NOWARN
_FORCED_NAMES[ea] = name
idc.MakeNameEx(ea, name, flags)
# Tries to get the name of a symbol.
示例5: rename_wrapper
# 需要導入模塊: import idc [as 別名]
# 或者: from idc import MakeNameEx [as 別名]
def rename_wrapper(name, func_addr):
if idc.MakeNameEx(func_addr, name, SN_NOWARN):
print "Function at 0x%x renamed %s" % (func_addr, idc.GetFunctionName(func_addr))
else:
print "Rename at 0x%x failed. Function %s is being used." % (func_addr, name)
return
示例6: MakeName
# 需要導入模塊: import idc [as 別名]
# 或者: from idc import MakeNameEx [as 別名]
def MakeName(self, ea, name):
if idaapi.IDA_SDK_VERSION < 700:
return idc.MakeNameEx(ea, name, 256)
else:
return idc.set_name(ea, name, 256)
示例7: make_name
# 需要導入模塊: import idc [as 別名]
# 或者: from idc import MakeNameEx [as 別名]
def make_name(addr, export_name):
""" Appends a number if a given name exists """
ret = idc.MakeNameEx(addr, export_name, idc.SN_PUBLIC | idc.SN_NOWARN)
i = 0
while ret == 0 and i < 1000:
new_name = "%s_%d" % (export_name, i)
ret = idc.MakeNameEx(addr, new_name, idc.SN_PUBLIC | idc.SN_NOWARN)
i += 1
if ret == 0:
print "[!] could not set name %s at 0x%X" % (export_name, addr)
示例8: renameDword
# 需要導入模塊: import idc [as 別名]
# 或者: from idc import MakeNameEx [as 別名]
def renameDword(self):
proc_addr = self._import_table.item(self._import_table.currentRow(), 3).text()
proc_name = str(self._import_table.item(self._import_table.currentRow(), 2).text())
renamed = 0
if proc_addr:
try:
proc_addr = int(proc_addr, 16)
proc_bin_str = " ".join([x.encode("hex") for x in struct.pack("<I", proc_addr)])
next_dword = idc.FindBinary(idc.MinEA(), idc.SEARCH_DOWN|idc.SEARCH_NEXT, proc_bin_str)
while next_dword != idc.BADADDR:
log.debug("Trying to fix-up 0x{:08x}".format(next_dword))
# DWORDs can be "inaccessible" for many reasons and it requires "breaking up" the data blobs
# and manually fixing them
# Reason 1: In a dword array in an unknown section
if idc.isUnknown(next_dword):
idc.MakeUnkn(next_dword, idc.DOUNK_EXPAND)
idc.MakeDword(next_dword)
# Reason 2: In a dword array in a data section
elif idc.isData(next_dword):
hd = idc.ItemHead(next_dword)
idc.MakeDword(hd)
idc.MakeDword(next_dword)
# Reason 3: In a dword array in a code section (validate via "dd <dword>,")
elif idc.isCode(next_dword) and idc.GetDisasm(next_dword).startswith("dd "):
hd = idc.ItemHead(next_dword)
idc.MakeDword(hd)
idc.MakeDword(next_dword)
# Only perform
if idc.Name(next_dword).startswith(("off_", "dword_")) or idc.Name(next_dword) == "":
success = idc.MakeNameEx(next_dword, proc_name, idc.SN_NOWARN|idc.SN_NON_AUTO)
i = 0
new_proc_name = proc_name
while not success and i < 10:
new_proc_name = "{}{}".format(proc_name, i)
success = idc.MakeNameEx(next_dword, new_proc_name, idc.SN_NOWARN|idc.SN_NON_AUTO)
i += 1
if success:
renamed += 1
item = self._import_table.item(self._import_table.currentRow(), 5)
item.setText("{}, {}".format(str(item.text()), new_proc_name))
log.debug("DWORD @ 0x{:08x} now has name {}".format(next_dword, new_proc_name))
else:
log.error("Unable to auto-rename successfully, terminating search")
break
else: log.debug("Value at 0x{:08x} does not meet renaming requirements".format(next_dword))
next_dword = idc.FindBinary(next_dword+4, idc.SEARCH_DOWN|idc.SEARCH_NEXT, proc_bin_str)
except Exception, e:
log.error("Error encountered: {}".format(e))
log.debug("Renamed {:d} instances of {}".format(renamed, proc_name))