structure.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:idascripts 作者: ctfhacker 项目源码 文件源码
def __repr__(self):
        '''Display all the fields within the specified structure.'''
        result = []
        mn, ms = 0, 0
        for i in xrange(len(self)):
            m = self[i]
            name,t,ofs,size,comment = m.name,m.type,m.offset,m.size,m.comment
            result.append((i,name,t,ofs,size,comment))
            mn = max((mn,len(name)))
            ms = max((ms,len("{:x}".format(size))))
        mi = len(str(len(self)))
        mo = max(map(len,map("{:x}".format, (self.baseoffset,self.baseoffset+self.owner.size))))
        return "{!r}\n{:s}".format(self.owner, '\n'.join("[{:{:d}d}] {:>{:d}x}:+{:<{:d}x} {:<{:d}s} {!r} {:s}".format(i,mi,o,mo,s,ms,"'{:s}'".format(n),mn+2,t," // {:s}".format(c) if c else '') for i,n,t,o,s,c in result))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号