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

Method set_bytes_at_offset

pythonmemorymodule/pefile.py:6954–6969  ·  view source on GitHub ↗

Overwrite the bytes at the given file offset with the given string. Return True if successful, False otherwise. It can fail if the offset is outside the file's boundaries.

(self, offset, data)

Source from the content-addressed store, hash-verified

6952 return self.set_bytes_at_offset(offset, data)
6953
6954 def set_bytes_at_offset(self, offset, data):
6955 """Overwrite the bytes at the given file offset with the given string.
6956
6957 Return True if successful, False otherwise. It can fail if the
6958 offset is outside the file's boundaries.
6959 """
6960
6961 if not isinstance(data, bytes):
6962 raise TypeError("data should be of type: bytes")
6963
6964 if 0 <= offset < len(self.__data__):
6965 self.set_data_bytes(offset, data)
6966 else:
6967 return False
6968
6969 return True
6970
6971 def set_data_bytes(self, offset: int, data: bytes):
6972 if not isinstance(self.__data__, bytearray):

Callers 6

set_dword_at_offsetMethod · 0.95
set_word_at_offsetMethod · 0.95
set_qword_at_offsetMethod · 0.95
set_bytes_at_rvaMethod · 0.95
__setattr__Method · 0.80
__setattr__Method · 0.80

Calls 1

set_data_bytesMethod · 0.95

Tested by

no test coverage detected