Пример #1
0
def load_dumps(regex=""):
    """
    >>> D = load_dumps()         #doctest: +ELLIPSIS
    Input files:
    ...
    >>> D
    [Dump of test-0xff000000.bin]
    """
    bins, loadaddrs, idcs = GetInputFiles(regex)
    D = {}
    for b,a in loadaddrs.iteritems():
        D[b] = Dump(bin=b, RAWASM = disasm_dump(b,a))
        D[b].loadaddr = a

    for b in bins:
        D[b].FUNCS = {}
        D[b].FUNCENDS = {}
        D[b].WHICHFUNC = {}
        D[b].A2N = {}
        D[b].N2A = {}

    for b,i in idcs.iteritems(): # this needs cleanup
        D[b].A2N, D[b].N2A, D[b].FUNCS = cache.access(i, idc.parse)
        D[b].update_func_indexes()
        D[b].idc = i


    for b,a in loadaddrs.iteritems():
        D[b]._loadednames = {}
        D[b]._loadednames.update(D[b].N2A)
        D[b].ROM, D[b].MNEF, D[b].ARGS, refs, D[b].DISASM = cache.access(b, lambda b: parse_disasm(D[b]))
        D[b].minaddr = min(D[b].ROM)
        D[b].maxaddr = max(D[b].ROM)
        D[b].REFLIST = list(refs.iteritems())
        D[b].A2REFS, D[b].REF2AS = cache.access(b, lambda b: index_refs(refs, D[b].ROM))
        
    for b,a in loadaddrs.iteritems():
        D[b].STRINGS # compute them
        remove_autogen_string_names(D[b])

    cache.save()
    
    if len(D) == 1:
        print "Auto-selecting dump %s" % D[bins[0]].bin
        idapy.select_dump(D[bins[0]])

    return sorted(D.values(), key=lambda x: x.bin)
Пример #2
0
 def MakeFunction(dump,start,end=None,name=None):
     """
     >>> d = load_dumps()[0]   #doctest: +ELLIPSIS
     Input files:
     ...
     >>> d.MakeFunction(1, 10, "myfun")
     >>> d.MakeFunction(1, 10, "myfun")
     Overwriting name myfun
     """
     if end is None:
         idapy.select_dump(dump)
         end = cache.access(start, emusym.GuessFunction)
         if end is None:
             print "Could not guess end address for function %x => skipping" % start
             return 
         end += 4
     f,e = start,end
     n = funcname(dump,f)
     dump.FUNCS[f] = e
     dump.FUNCENDS[e] = f
     for a in range(f,e-3):
         dump.WHICHFUNC[a] = f
     if name:
         dump.MakeName(f,name)