(self, data_rva, rva, size)
| 3934 | return relocations |
| 3935 | |
| 3936 | def parse_relocations(self, data_rva, rva, size): |
| 3937 | """""" |
| 3938 | |
| 3939 | try: |
| 3940 | data = self.get_data(data_rva, size) |
| 3941 | file_offset = self.get_offset_from_rva(data_rva) |
| 3942 | except PEFormatError: |
| 3943 | self.__warnings.append(f"Bad RVA in relocation data: 0x{data_rva:x}") |
| 3944 | return [] |
| 3945 | |
| 3946 | entries = [] |
| 3947 | offsets_and_type = [] |
| 3948 | for idx in range(int(len(data) / 2)): |
| 3949 | |
| 3950 | entry = self.__unpack_data__( |
| 3951 | self.__IMAGE_BASE_RELOCATION_ENTRY_format__, |
| 3952 | data[idx * 2 : (idx + 1) * 2], |
| 3953 | file_offset=file_offset, |
| 3954 | ) |
| 3955 | |
| 3956 | if not entry: |
| 3957 | break |
| 3958 | word = entry.Data |
| 3959 | |
| 3960 | reloc_type = word >> 12 |
| 3961 | reloc_offset = word & 0x0FFF |
| 3962 | if (reloc_offset, reloc_type) in offsets_and_type: |
| 3963 | self.__warnings.append( |
| 3964 | "Overlapping offsets in relocation data " |
| 3965 | "at RVA: 0x%x" % (reloc_offset + rva) |
| 3966 | ) |
| 3967 | break |
| 3968 | if len(offsets_and_type) >= 1000: |
| 3969 | offsets_and_type.pop() |
| 3970 | offsets_and_type.insert(0, (reloc_offset, reloc_type)) |
| 3971 | |
| 3972 | entries.append( |
| 3973 | RelocationData( |
| 3974 | struct=entry, type=reloc_type, base_rva=rva, rva=reloc_offset + rva |
| 3975 | ) |
| 3976 | ) |
| 3977 | file_offset += entry.sizeof() |
| 3978 | |
| 3979 | return entries |
| 3980 | |
| 3981 | def parse_debug_directory(self, rva, size): |
| 3982 | """""" |
no test coverage detected