Example #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
Example #2
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
Example #3
0
import functools, operator, itertools, types
import os, logging
import math, re, fnmatch

import database
import ui, internal
from internal import utils, interface, exceptions as E

import idaapi

## enumerating
__matcher__ = utils.matcher()
__matcher__.combinator(
    'regex',
    utils.fcompose(utils.fpartial(re.compile, flags=re.IGNORECASE),
                   operator.attrgetter('match')), idaapi.get_segm_name
    if hasattr(idaapi, 'get_segm_name') else idaapi.get_true_segm_name,
    utils.string.of)
__matcher__.attribute('index', 'index')
__matcher__.attribute('identifier',
                      'name'), __matcher__.attribute('id', 'name')
__matcher__.attribute('selector', 'sel')
__matcher__.combinator(
    'like',
    utils.fcompose(fnmatch.translate,
                   utils.fpartial(re.compile, flags=re.IGNORECASE),
                   operator.attrgetter('match')), idaapi.get_segm_name
    if hasattr(idaapi, 'get_segm_name') else idaapi.get_true_segm_name,
    utils.string.of)
__matcher__.boolean(