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)
评论列表
文章目录