def members(id): """Yields the members of the structure identified by ``id``. Each iteration yields the ((offset,size),(name,comment,repeatable-comment)) of each member. """ st = idaapi.get_struc(id) if not st: # empty structure return size = idaapi.get_struc_size(st) offset = 0 for i in range(st.memqty): m = st.get_member(i) ms = idaapi.get_member_size(m) left, right = m.soff, m.eoff if offset < left: yield (offset, left - offset), (idaapi.get_member_name(m.id), idaapi.get_member_cmt(m.id, 0), idaapi.get_member_cmt(m.id, 1)) offset = left yield (offset, ms), (idaapi.get_member_name(m.id), idaapi.get_member_cmt(m.id, 0), idaapi.get_member_cmt(m.id, 1)) offset += ms return
def __getstate__(self): t = (self.flag, None if self.typeid is None else instance(self.typeid), self.size) cmtt = idaapi.get_member_cmt(self.id, True) cmtf = idaapi.get_member_cmt(self.id, False) ofs = self.offset - self.__owner.members.baseoffset return (self.__owner.name, self.__index, self.name, (cmtt, cmtf), ofs, t)
def handle_structs(delta, segs): for idx in range(idaapi.get_struc_qty()): tid = idaapi.get_struc_by_idx(idx) for cmt_type in (True, False): cmt = idaapi.get_struc_cmt(tid, cmt_type) if cmt: new_cmt = rebase_comment(segs, delta, cmt) if new_cmt: idaapi.set_struc_cmt(tid, new_cmt, cmt_type) s = idaapi.get_struc(tid) for midx in range(s.memqty): m = s.get_member(midx) for cmt_type in (True, False): cmt = idaapi.get_member_cmt(m.id, cmt_type) if cmt: new_cmt = rebase_comment(segs, delta, cmt) if new_cmt: idaapi.set_member_cmt(m, new_cmt, cmt_type)
def members(id): st = idaapi.get_struc(id) if not st: # empty structure return size = idaapi.get_struc_size(st) offset = 0 for i in range(st.memqty): m = st.get_member(i) ms = idaapi.get_member_size(m) left,right = m.soff,m.eoff if offset < left: yield (offset,left-offset), (None,None) offset = left yield (offset,ms),(idaapi.get_member_name(m.id), idaapi.get_member_cmt(m.id, 1)) offset += ms return
def members(id): """Return the ((offset,size),(name,comment)) of each member within the specified structure""" st = idaapi.get_struc(id) if not st: # empty structure return size = idaapi.get_struc_size(st) offset = 0 for i in range(st.memqty): m = st.get_member(i) ms = idaapi.get_member_size(m) left, right = m.soff, m.eoff if offset < left: yield (offset, left - offset), (None, None) offset = left yield (offset, ms), (idaapi.get_member_name(m.id), idaapi.get_member_cmt(m.id, 1)) offset += ms return
def comment(self): return idaapi.get_member_cmt(self.id, True)
def comment(self): '''Return the member's repeable comment.''' return idaapi.get_member_cmt(self.id, True) or idaapi.get_member_cmt( self.id, False)