Beispiel #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)
Beispiel #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)
Beispiel #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
Beispiel #4
0
def get_prim_unit_size(flags):
    if idaapi.isByte(flags):
        return 1
    elif idaapi.isWord(flags):
        return 2
    elif idaapi.isDwrd(flags):
        return 4
    elif idaapi.isQwrd(flags):
        return 8
    elif idaapi.isOwrd(flags):
        return 16
    elif idaapi.isTbyt(flags):
        return 10
    elif idaapi.isFloat(flags):
        return 4
    elif idaapi.isDouble(flags):
        return 8
    #elif idaapi.isPackReal(flags):
    elif idaapi.isASCII(flags):
        return 1
    elif idaapi.isStruct(flags):
        raise "Struct sent to get_prim_size"
Beispiel #5
0
def get_prim_unit_size(flags):
    if idaapi.isByte(flags):
        return 1
    elif idaapi.isWord(flags):
        return 2
    elif idaapi.isDwrd(flags):
        return 4
    elif idaapi.isQwrd(flags):
        return 8
    elif idaapi.isOwrd(flags):
        return 16
    elif idaapi.isTbyt(flags):
        return 10
    elif idaapi.isFloat(flags):
        return 4
    elif idaapi.isDouble(flags):
        return 8
    #elif idaapi.isPackReal(flags):
    elif idaapi.isASCII(flags):
        return 1
    elif idaapi.isStruct(flags):
        raise "Struct sent to get_prim_size"
Beispiel #6
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