MCPcopy Create free account
hub / github.com/ELMERIKH/PyinMemoryPE / get_offset_from_rva

Method get_offset_from_rva

pythonmemorymodule/pefile.py:5939–5958  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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."""

Calls 2

get_section_by_rvaMethod · 0.95
PEFormatErrorClass · 0.85

Tested by

no test coverage detected