Esempio n. 1
0
 def __call__(self):
     mt = idaapi.opinfo_t()
     if idaapi.isStruct(self.flag):
         mt.tid = self.extra['id']
     if idaapi.isOff0(self.flag) or idaapi.isOff1(self.flag):
         mt.ri = idaapi.refinfo_t(self.extra['flags'], self.extra['base'],
                                  self.extra['target'],
                                  self.extra['tdelta'])
     if idaapi.isASCII(self.flag):
         mt.strtype = self.extra['strtype']
     sptr = idaapi.get_struc(self.sid)
     idaapi.set_member_type(sptr, self.soff, self.flag, mt,
                            self.eoff - self.soff)
Esempio n. 2
0
 def __call__(self):
     mt = idaapi.opinfo_t()
     if idaapi.isStruct(self.flag):
         mt.tid = self.extra['id']
     if idaapi.isOff0(self.flag) or idaapi.isOff1(self.flag):
         mt.ri = idaapi.refinfo_t(self.extra['flags'], self.extra['base'],
                                  self.extra['target'],
                                  self.extra['tdelta'])
     if idaapi.isASCII(self.flag):
         mt.strtype = self.extra['strtype']
     sptr = idaapi.get_struc(self.sid)
     idaapi.add_struc_member(sptr, self.fieldname.encode('utf-8'),
                             self.offset, self.flag, mt, self.nbytes)
Esempio n. 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
Esempio n. 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