MCPcopy
hub / github.com/volatilityfoundation/volatility3 / read

Method read

volatility3/framework/layers/physical.py:155–179  ·  view source on GitHub ↗

Reads from the file at offset for length.

(self, offset: int, length: int, pad: bool = False)

Source from the content-addressed store, hash-verified

153 )
154
155 def read(self, offset: int, length: int, pad: bool = False) -> bytes:
156 """Reads from the file at offset for length."""
157 if not self.is_valid(offset, length):
158 invalid_address = offset
159 if self.minimum_address < offset <= self.maximum_address:
160 invalid_address = self.maximum_address + 1
161 raise exceptions.InvalidAddressException(
162 self.name, invalid_address, "Offset outside of the buffer boundaries"
163 )
164
165 # TODO: implement locking for multi-threading
166 with self._lock:
167 self._file.seek(offset)
168 data = self._file.read(length)
169
170 if len(data) < length:
171 if pad:
172 data += b"\x00" * (length - len(data))
173 else:
174 raise exceptions.InvalidAddressException(
175 self.name,
176 offset + len(data),
177 "Could not read sufficient bytes from the " + self.name + " file",
178 )
179 return data
180
181 def write(self, offset: int, data: bytes) -> None:
182 """Writes to the file.

Callers 15

process_rpmMethod · 0.45
process_debMethod · 0.45
seekreadFunction · 0.45
setupFunction · 0.45
_unmarshallMethod · 0.45
_get_raw_valueMethod · 0.45
_get_valid_tableMethod · 0.45
_check_headerMethod · 0.45

Calls 2

is_validMethod · 0.95
seekMethod · 0.45