當前位置: 首頁>>代碼示例>>Python>>正文


Python idc.MakeNameEx方法代碼示例

本文整理匯總了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)) 
開發者ID:bazad,項目名稱:ida_kernelcache,代碼行數:24,代碼來源:ida_utilities.py

示例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) 
開發者ID:ax330d,項目名稱:ida_pdb_loader,代碼行數:21,代碼來源:main.py

示例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 
開發者ID:fireeye,項目名稱:flare-ida,代碼行數:18,代碼來源:jayutils.py

示例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. 
開發者ID:lifting-bits,項目名稱:mcsema,代碼行數:10,代碼來源:util.py

示例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 
開發者ID:ExpLife0011,項目名稱:IDAPython_Note,代碼行數:8,代碼來源:13_注釋和重命名.py

示例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) 
開發者ID:danielplohmann,項目名稱:apiscout,代碼行數:7,代碼來源:IdaProxy.py

示例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) 
開發者ID:deepinstinct,項目名稱:dsc_fix,代碼行數:13,代碼來源:dsc_fix.py

示例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)) 
開發者ID:jjo-sec,項目名稱:idataco,代碼行數:53,代碼來源:imports.py


注:本文中的idc.MakeNameEx方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。