Пример #1
0
 def typeid(self):
     '''Return the `.tid` of the member's type.'''
     opinfo = idaapi.opinfo_t()
     if idaapi.__version__ < 7.0:
         res = idaapi.retrieve_member_info(self.ptr, opinfo)
         return None if res is None else res.tid if res.tid != idaapi.BADADDR else None
     else:
         res = idaapi.retrieve_member_info(opinfo, self.ptr)
     return None if opinfo.tid == idaapi.BADADDR else opinfo.tid
Пример #2
0
    def check_field(self, sid, ftype, strid, offset, size, name):
        if ftype is None:
            for i in range(offset, offset + size):
                self.assertIsNone(idc.GetMemberName(sid, i))
                self.assertEqual(idc.GetMemberFlag(sid, i), -1)
            return

        try:
            self.assertNotEqual(idc.GetMemberName(sid, offset - 1), name)
        except:
            pass
        for k in range(offset, offset + size):
            self.assertEqual(idc.GetMemberName(sid, k), name)
            self.assertEqual(idc.GetMemberSize(sid, k), size)
            self.assertEqual(idc.GetMemberFlag(sid, k) & idaapi.DT_TYPE, ftype & 0xFFFFFFFF)
            if strid != -1:
                st = idaapi.get_struc(sid)
                mb = idaapi.get_member(st, offset)
                op = idaapi.opinfo_t()
                idaapi.retrieve_member_info(op, mb)
                self.assertEqual(op.tid, strid)
        self.assertNotEqual(idc.GetMemberName(sid, offset + size), name)
Пример #3
0
    def struc_member_created(self, sptr, mptr):
        extra = {}

        sname = idaapi.get_struc_name(sptr.id)
        fieldname = idaapi.get_member_name2(mptr.id)
        offset = 0 if mptr.unimem() else mptr.soff
        flag = mptr.flag
        nbytes = mptr.eoff if mptr.unimem() else mptr.eoff - mptr.soff
        mt = idaapi.opinfo_t()
        is_not_data = idaapi.retrieve_member_info(mt, mptr)
        if is_not_data:
            if idaapi.isOff0(flag) or idaapi.isOff1(flag):
                extra['target'] = mt.ri.target
                extra['base'] = mt.ri.base
                extra['tdelta'] = mt.ri.tdelta
                extra['flags'] = mt.ri.flags
                self._send_event(
                    StrucMemberCreatedEvent(sname, fieldname, offset, flag,
                                            nbytes, extra))
            # Is it really possible to create an enum?
            elif idaapi.isEnum0(flag):
                extra['serial'] = mt.ec.serial
                self._send_event(
                    StrucMemberCreatedEvent(sname, fieldname, offset, flag,
                                            nbytes, extra))
            elif idaapi.isStruct(flag):
                extra['id'] = mt.tid
                self._send_event(
                    StrucMemberCreatedEvent(sname, fieldname, offset, flag,
                                            nbytes, extra))
            elif idaapi.isASCII(flag):
                extra['strtype'] = mt.strtype
                self._send_event(
                    StrucMemberCreatedEvent(sname, fieldname, offset, flag,
                                            nbytes, extra))
        else:
            self._send_event(
                StrucMemberCreatedEvent(sname, fieldname, offset, flag, nbytes,
                                        extra))
        return 0
Пример #4
0
    def struc_member_changed(self, sptr, mptr):
        extra = {}

        soff = 0 if mptr.unimem() else mptr.soff
        flag = mptr.flag
        mt = idaapi.opinfo_t()
        is_not_data = idaapi.retrieve_member_info(mt, mptr)
        if is_not_data:
            if idaapi.isOff0(flag) or idaapi.isOff1(flag):
                extra['target'] = mt.ri.target
                extra['base'] = mt.ri.base
                extra['tdelta'] = mt.ri.tdelta
                extra['flags'] = mt.ri.flags
                self._send_event(StrucMemberChangedEvent(sptr.id, soff,
                                                         mptr.eoff, flag,
                                                         extra))
            # Is it really possible to create an enum?
            elif idaapi.isEnum0(flag):
                extra['serial'] = mt.ec.serial
                self._send_event(StrucMemberChangedEvent(sptr.id, soff,
                                                         mptr.eoff, flag,
                                                         extra))
            elif idaapi.isStruct(flag):
                extra['id'] = mt.tid
                self._send_event(StrucMemberChangedEvent(sptr.id, soff,
                                                         mptr.eoff, flag,
                                                         extra))
            elif idaapi.isASCII(flag):
                extra['strtype'] = mt.strtype
                self._send_event(StrucMemberChangedEvent(sptr.id, soff,
                                                         mptr.eoff, flag,
                                                         extra))
        else:
            self._send_event(StrucMemberChangedEvent(sptr.id, soff,
                                                     mptr.eoff, flag,
                                                     extra))
        return 0
Пример #5
0
 def typeid(self):
     opinfo = idaapi.opinfo_t()
     res = idaapi.retrieve_member_info(self.ptr, opinfo)
     return None if res is None else res.tid if res.tid != idaapi.BADADDR else None