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

Method get_word_from_data

pythonmemorymodule/pefile.py:6841–6853  ·  view source on GitHub ↗

Convert two bytes of data to a word (little endian) 'offset' is assumed to index into a word array. So setting it to N will return a dword out of the data starting at offset N*2. Returns None if the data can't be turned into a word.

(self, data, offset)

Source from the content-addressed store, hash-verified

6839 return struct.pack("<H", word)
6840
6841 def get_word_from_data(self, data, offset):
6842 """Convert two bytes of data to a word (little endian)
6843
6844 'offset' is assumed to index into a word array. So setting it to
6845 N will return a dword out of the data starting at offset N*2.
6846
6847 Returns None if the data can&#x27;t be turned into a word.
6848 """
6849
6850 if (offset + 1) * 2 > len(data):
6851 return None
6852
6853 return struct.unpack("<H", data[offset * 2 : (offset + 1) * 2])[0]
6854
6855 def get_word_at_rva(self, rva):
6856 """Return the word value at the given RVA.

Callers 5

parse_importsMethod · 0.95
get_word_at_rvaMethod · 0.95
get_word_from_offsetMethod · 0.95

Calls 1

unpackMethod · 0.45

Tested by

no test coverage detected