Esempio n. 1
0
def list(**type):
    '''List all of the enumerations within the database that match the keyword specified by `type`.'''
    res = [item for item in iterate(**type)]

    maxindex = max(builtins.map(idaapi.get_enum_idx, res) if res else [1])
    maxname = max(
        builtins.map(utils.fcompose(idaapi.get_enum_name, len), res
                     ) if res else [0])
    maxsize = max(builtins.map(size, res) if res else [0])
    cindex = math.ceil(math.log(maxindex or 1) / math.log(10))
    try:
        cmask = max(
            builtins.map(
                utils.fcompose(
                    mask,
                    utils.fcondition(utils.fpartial(operator.eq, 0))
                    (utils.fconstant(1), utils.fidentity), math.
                    log, functools.partial(operator.mul, 1.0 /
                                           math.log(8)), math.ceil), res
            ) if res else [database.config.bits() / 4.0])
    except:
        cmask = 0

    for item in res:
        name = idaapi.get_enum_name(item)
        six.print_(
            u"[{:{:d}d}] {:>{:d}s} & {:<{:d}x} ({:d} members){:s}".format(
                idaapi.get_enum_idx(item), int(cindex), utils.string.of(name),
                maxname, mask(item), int(cmask),
                len(builtins.list(members(item))),
                u" // {:s}".format(comment(item)) if comment(item) else ''))
    return
def __iterate__(**type):
    '''Iterate through each segment defined in the database that match the keywords specified by `type`.'''
    def newsegment(index):
        seg = idaapi.getnseg(index)
        seg.index, _ = index, ui.navigation.set(interface.range.start(seg))
        return seg

    iterable = (newsegment(index)
                for index in builtins.range(idaapi.get_segm_qty()))
    for key, value in (type or {'predicate': utils.fconstant(True)}).items():
        iterable = (item for item in __matcher__.match(key, value, iterable))
    for item in iterable:
        yield item
Esempio n. 3
0
def __iterate__(**type):
    '''Iterate through each segment defined in the database that match the keywords specified by `type`.'''
    def newsegment(index):
        seg = idaapi.getnseg(index)
        seg.index, _ = index, ui.navigation.set(interface.range.start(seg))
        return seg

    iterable = itertools.imap(newsegment,
                              six.moves.range(idaapi.get_segm_qty()))
    for key, value in six.iteritems(
            type or builtins.dict(predicate=utils.fconstant(True))):
        iterable = builtins.list(__matcher__.match(key, value, iterable))
    for item in iterable:
        yield item
Esempio n. 4
0
def list(**type):
    '''List all of the enumerations within the database that match the keyword specified by `type`.'''
    res = builtins.list(iterate(**type))

    maxindex = max(builtins.map(idaapi.get_enum_idx, res) or [1])
    maxname = max(builtins.map(utils.fcompose(idaapi.get_enum_name, len), res) or [0])
    maxsize = max(builtins.map(size, res) or [0])
    cindex = math.ceil(math.log(maxindex or 1)/math.log(10))
    try: cmask = max(builtins.map(utils.fcompose(mask, utils.fcondition(utils.fpartial(operator.eq, 0))(utils.fconstant(1), utils.fidentity), math.log, functools.partial(operator.mul, 1.0/math.log(8)), math.ceil), res) or [database.config.bits()/4.0])
    except: cmask = 0

    for n in res:
        name = idaapi.get_enum_name(n)
        six.print_(u"[{:{:d}d}] {:>{:d}s} & {:<{:d}x} ({:d} members){:s}".format(idaapi.get_enum_idx(n), int(cindex), utils.string.of(name), maxname, mask(n), int(cmask), len(builtins.list(members(n))), u" // {:s}".format(comment(n)) if comment(n) else ''))
    return