def read(self, addr, size): if addr < self.pe.OPTIONAL_HEADER.ImageBase or \ addr > self.pe.OPTIONAL_HEADER.ImageBase + self.pe.OPTIONAL_HEADER.SizeOfImage: # invalid VA print 'Reader.read(): Address 0x%x is outside of executable image' % addr raise REIL.ReadError(addr) # convert VA to RVA addr -= self.pe.OPTIONAL_HEADER.ImageBase try: return self.pe.get_data(rva=addr, length=size) except e, why: print 'Reader.read(): Exception:', str(why) raise REIL.ReadError(addr)
def read(self, addr, size): for sec in self.bfd.sections.values(): # lookup for image section by address if addr >= sec.vma and addr < sec.vma + sec.size: # return section data addr -= sec.vma return sec.content[addr : addr + size] # invalid VA print 'Reader.read(): Address 0x%x is outside of executable image' % addr raise REIL.ReadError(addr)