Python idc.MakeNameEx() Examples
The following are 8
code examples of idc.MakeNameEx().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
idc
, or try the search function
.
Example #1
Source File: ida_utilities.py From ida_kernelcache with MIT License | 6 votes |
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))
Example #2
Source File: main.py From ida_pdb_loader with MIT License | 6 votes |
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)
Example #3
Source File: jayutils.py From flare-ida with Apache License 2.0 | 6 votes |
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
Example #4
Source File: util.py From mcsema with Apache License 2.0 | 5 votes |
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.
Example #5
Source File: 13_注释和重命名.py From IDAPython_Note with MIT License | 5 votes |
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
Example #6
Source File: IdaProxy.py From apiscout with BSD 2-Clause "Simplified" License | 5 votes |
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)
Example #7
Source File: dsc_fix.py From dsc_fix with GNU General Public License v3.0 | 5 votes |
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)
Example #8
Source File: imports.py From idataco with GNU General Public License v3.0 | 4 votes |
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))