示例#1
0
def enum_member_iterate_const(enum_id):
    const_value = idc.GetFirstConst(enum_id, -1)
    while const_value != idc.BADADDR:
        serial = 0
        const_id = idc.GetConstEx(enum_id, const_value, serial, -1)
        while const_id != idc.BADADDR:
            yield (const_id, const_value, None)

            serial += 1
            const_id = idc.GetConstEx(enum_id, const_value, serial, -1)
        const_value = idc.GetNextConst(enum_id, const_value, -1)
示例#2
0
def enum_member_iterate_bitfield(enum_id):
    # bitfield
    bmask = idc.GetFirstBmask(enum_id)
    while bmask != idc.BADADDR:
        const_value = idc.GetFirstConst(enum_id, bmask)
        while const_value != idc.BADADDR:
            # TODO must implement serial for bitfield
            const_id = idc.GetConstEx(enum_id, const_value, 0, bmask)
            yield (const_id, const_value, bmask)

            const_value = idc.GetNextConst(enum_id, const_value, bmask)
        bmask = idc.GetNextBmask(enum_id, bmask)
示例#3
0
def enum_member_iterate_all(enum_id):
    const_value = idc.GetFirstConst(enum_id, -1)
    while const_value != idc.BADADDR:
        serial = 0
        const_id = idc.GetConstEx(enum_id, const_value, serial, -1)
        while const_id != idc.BADADDR:
            yield (const_id, const_value, idc.BADADDR)

            serial += 1
            const_id = idc.GetConstEx(enum_id, const_value, serial, -1)
        const_value = idc.GetNextConst(enum_id, const_value, -1)
    enum_member_iterate_bitfield(enum_id)

    bmask = idc.GetFirstBmask(enum_id)
    while bmask != idc.BADADDR:
        const_value = idc.GetFirstConst(enum_id, bmask)
        while const_value != idc.BADADDR:
            # TODO must implement serial for bitfield
            const_id = idc.GetConstEx(enum_id, const_value, 0, bmask)
            yield (const_id, const_value, bmask)

            const_value = idc.GetNextConst(enum_id, const_value, bmask)
        bmask = idc.GetNextBmask(enum_id, bmask)
示例#4
0
 def getConsts(self, reload=False):
     if self._vals and not reload:
         return self._vals
     res = {}
     bm = idc.GetFirstBmask(self.id)
     while True:
         if bm not in res:
             res[bm] = {}
         c = idc.GetFirstConst(self.id, bm)
         while c != idc.BADADDR:
             cid = idc.GetConstEx(self.id, c, 0, bm)
             res[bm][c] = cid
             c = idc.GetNextConst(self.id, c, bm)
         if bm == idc.BADADDR:
             self._vals = res
             return res
         bm = idc.GetNextBmask(self.id, bm)
示例#5
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)
示例#6
0
文件: checkida.py 项目: tmcmil/YaCo
 def get_enums(bmask):
     value = idc.GetFirstConst(eid, bmask)
     while value != idaapi.BADADDR:
         yield value, bmask
         value = idc.GetNextConst(eid, value, bmask)