idaloader.py 文件源码

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

项目:viv-utils 作者: williballenthin 项目源码 文件源码
def get_segment_data(segstart):
    '''
    read the contents of the segment containing the given address.

    Args:
      segstart (int): start address of a segment.

    Returns:
      bytes: the bytes of the segment, filled with NULL when byte not available from database.
    '''
    bufs = []

    segend = idc.SegEnd(segstart)
    segsize = segend - segstart
    pagecount = segsize // PAGE_SIZE
    remainder = segsize - (pagecount * PAGE_SIZE)

    # read in page-sized chunks, since these should ususally be accessible together.
    for i in range(pagecount):
        bufs.append(get_data(segstart + i * PAGE_SIZE, PAGE_SIZE))

    # in a real PE, these *should* be page- or sector-aligned, but its not guaranteed, esp in IDA.
    if remainder != 0:
        bufs.append(get_data(segstart + pagecount * PAGE_SIZE, remainder))

    return b''.join(bufs)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号