Ejemplo n.º 1
0
def _iter_bitmasks(eid):
    """Iterate all bitmasks in a given enum.

    Note that while 0xFFFFFFFF indicates no-more-bitmasks, it is also a
    valid bitmask value. The only way to tell if it exists is when iterating
    the serials.
    """
    bitmask = idaapi.get_first_bmask(eid)

    yield bitmask

    while bitmask != 0xFFFFFFFF:
        bitmask = idaapi.get_next_bmask(eid, bitmask)
        yield bitmask
Ejemplo n.º 2
0
    def __init__(self, id):
        self.id = id
        self.members = []

        bmask = idaapi.get_first_bmask(id)

        while True:
            val = idc.GetFirstConst(id, bmask)
            
            ##for_all_enum_members is unusable in IDAPython
            ##according to Igor, who recommended this.
            ##
            ##This manner of iterating through constants
            ##does not support multiple with the same value.
            ##Since I don't even know how to create those,
            ##I'm just plain not supporting them.
            ##
            ##Also, while the docs say to pass -1 for the bmask
            ##in the IDC const functions, this produces an
            ##overflow error. Igor said to use idaapi.BADADDR
            ##instead
            ##
            ##Also, the docks said it would return -1 when done,
            ##but it actually returned BADADDR. It seems that
            ##BADADDR is -1, but unsigned -- it all makes sense now
            ndone = 0
            while val != -1 and val != idaapi.BADADDR:
                cid = util.get_const_id(id, val, bmask)
                self.members.append(enum_member_node(cid, val))
                val = idc.GetNextConst(id, val, bmask)
                ndone += 1

            if bmask == idaapi.BADADDR:
                break
            else:
                bmask = idaapi.get_next_bmask(id, bmask)
Ejemplo n.º 3
0
    def __init__(self, id):
        self.id = id
        self.members = []

        bmask = idaapi.get_first_bmask(id)

        while True:
            val = idc.GetFirstConst(id, bmask)

            ##for_all_enum_members is unusable in IDAPython
            ##according to Igor, who recommended this.
            ##
            ##This manner of iterating through constants
            ##does not support multiple with the same value.
            ##Since I don't even know how to create those,
            ##I'm just plain not supporting them.
            ##
            ##Also, while the docs say to pass -1 for the bmask
            ##in the IDC const functions, this produces an
            ##overflow error. Igor said to use idaapi.BADADDR
            ##instead
            ##
            ##Also, the docks said it would return -1 when done,
            ##but it actually returned BADADDR. It seems that
            ##BADADDR is -1, but unsigned -- it all makes sense now
            ndone = 0
            while val != -1 and val != idaapi.BADADDR:
                cid = util.get_const_id(id, val, bmask)
                self.members.append(enum_member_node(cid, val))
                val = idc.GetNextConst(id, val, bmask)
                ndone += 1

            if bmask == idaapi.BADADDR:
                break
            else:
                bmask = idaapi.get_next_bmask(id, bmask)