(self)
| 661 | return self._headersaddr + IMAGE_NT_HEADERS.OptionalHeader.offset + self.FILE_HEADER.SizeOfOptionalHeader |
| 662 | |
| 663 | def copy_sections(self): |
| 664 | codebase = self._codebaseaddr |
| 665 | sectionaddr = self.IMAGE_FIRST_SECTION() |
| 666 | numSections = self.pythonmemorymodule.contents.headers.contents.FileHeader.NumberOfSections |
| 667 | |
| 668 | for i in range(0, numSections): |
| 669 | if self.sections[i].SizeOfRawData == 0: |
| 670 | size = self.OPTIONAL_HEADER.SectionAlignment |
| 671 | if size > 0: |
| 672 | destBaseAddr = codebase + self.sections[i].VirtualAddress |
| 673 | dest = VirtualAlloc(destBaseAddr, size, MEM_COMMIT, PAGE_READWRITE ) |
| 674 | self.sections[i].Misc_PhysicalAddress = dest |
| 675 | memset(dest, 0, size) |
| 676 | continue |
| 677 | size = self.sections[i].SizeOfRawData |
| 678 | dest = VirtualAlloc(codebase + self.sections[i].VirtualAddress, size, MEM_COMMIT, PAGE_READWRITE ) |
| 679 | if dest <=0: |
| 680 | raise WindowsError('Error copying section no. %s to address: 0x%x',self.sections[i].Name.decode('utf-8'),dest) |
| 681 | self.sections[i].Misc_PhysicalAddress = dest |
| 682 | tmpdata = create_unsigned_buffer(size, self.__data__[self.sections[i].PointerToRawData:(self.sections[i].PointerToRawData+size)]) |
| 683 | if not memmove(dest, tmpdata, size): |
| 684 | raise RuntimeError('memmove failed') |
| 685 | del tmpdata |
| 686 | self.dbg('Copied section no. %s to address: 0x%x', self.sections[i].Name.decode('utf-8'), dest) |
| 687 | i += 1 |
| 688 | |
| 689 | |
| 690 | def ExecuteTLS(self): |
no test coverage detected