Get the file offset corresponding to this RVA. Given a RVA , this method will find the section where the data lies and return the offset within the file.
(self, rva)
| 5937 | return s.get_rva_from_offset(offset) |
| 5938 | |
| 5939 | def get_offset_from_rva(self, rva): |
| 5940 | """Get the file offset corresponding to this RVA. |
| 5941 | |
| 5942 | Given a RVA , this method will find the section where the |
| 5943 | data lies and return the offset within the file. |
| 5944 | """ |
| 5945 | |
| 5946 | s = self.get_section_by_rva(rva) |
| 5947 | if not s: |
| 5948 | |
| 5949 | # If not found within a section assume it might |
| 5950 | # point to overlay data or otherwise data present |
| 5951 | # but not contained in any section. In those |
| 5952 | # cases the RVA should equal the offset |
| 5953 | if rva < len(self.__data__): |
| 5954 | return rva |
| 5955 | |
| 5956 | raise PEFormatError(f"data at RVA 0x{rva:x} can't be fetched") |
| 5957 | |
| 5958 | return s.get_offset_from_rva(rva) |
| 5959 | |
| 5960 | def get_string_at_rva(self, rva, max_length=MAX_STRING_LENGTH): |
| 5961 | """Get an ASCII string located at the given address.""" |
no test coverage detected