mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-09-11 20:27:38 +02:00
refs #713 add a vad.get_size() method and fix several off-by-one issues with calculating vad size
This commit is contained in:
@@ -56,7 +56,7 @@ class Malfind(interfaces.plugins.PluginInterface):
|
||||
all_zero_page = b"\x00" * CHUNK_SIZE
|
||||
|
||||
offset = 0
|
||||
vad_length = vad.get_end() - vad.get_start()
|
||||
vad_length = vad.get_size()
|
||||
|
||||
while offset < vad_length:
|
||||
next_addr = vad.get_start() + offset
|
||||
|
||||
@@ -262,7 +262,7 @@ class Skeleton_Key_Check(interfaces.plugins.PluginInterface):
|
||||
|
||||
if isinstance(filename, str) and filename.lower().endswith("cryptdll.dll"):
|
||||
base = vad.get_start()
|
||||
return base, vad.get_end() - base
|
||||
return base, vad.get_size()
|
||||
|
||||
return None, None
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ class VadInfo(interfaces.plugins.PluginInterface):
|
||||
vollog.debug("Unable to find the starting/ending VPN member")
|
||||
return None
|
||||
|
||||
if 0 < maxsize < (vad_end - vad_start):
|
||||
if 0 < maxsize < vad.get_size():
|
||||
vollog.debug(f"Skip VAD dump {vad_start:#x}-{vad_end:#x} due to maxsize limit")
|
||||
return None
|
||||
|
||||
@@ -151,8 +151,9 @@ class VadInfo(interfaces.plugins.PluginInterface):
|
||||
file_handle = open_method(file_name)
|
||||
chunk_size = 1024 * 1024 * 10
|
||||
offset = vad_start
|
||||
while offset < vad_end:
|
||||
to_read = min(chunk_size, vad_end - offset)
|
||||
vad_size = vad.get_size()
|
||||
while offset < vad_start + vad_size:
|
||||
to_read = min(chunk_size, vad_start + vad_size - offset)
|
||||
data = proc_layer.read(offset, to_read, pad = True)
|
||||
if not data:
|
||||
break
|
||||
|
||||
@@ -82,9 +82,7 @@ class VadYaraScan(interfaces.plugins.PluginInterface):
|
||||
"""
|
||||
vad_root = task.get_vad_root()
|
||||
for vad in vad_root.traverse():
|
||||
end = vad.get_end()
|
||||
start = vad.get_start()
|
||||
yield (start, end - start)
|
||||
yield (vad.get_start(), vad.get_size())
|
||||
|
||||
def run(self):
|
||||
return renderers.TreeGrid([('Offset', format_hints.Hex), ('PID', int), ('Rule', str), ('Component', str),
|
||||
|
||||
@@ -197,8 +197,8 @@ class MMVAD_SHORT(objects.StructType):
|
||||
|
||||
raise AttributeError("Unable to find the parent member")
|
||||
|
||||
def get_start(self):
|
||||
"""Get the VAD's starting virtual address."""
|
||||
def get_start(self) -> int:
|
||||
"""Get the VAD's starting virtual address. This is the first accessible byte in the range."""
|
||||
|
||||
if self.has_member("StartingVpn"):
|
||||
|
||||
@@ -216,8 +216,8 @@ class MMVAD_SHORT(objects.StructType):
|
||||
|
||||
raise AttributeError("Unable to find the starting VPN member")
|
||||
|
||||
def get_end(self):
|
||||
"""Get the VAD's ending virtual address."""
|
||||
def get_end(self) -> int:
|
||||
"""Get the VAD's ending virtual address. This is the last accessible byte in the range."""
|
||||
|
||||
if self.has_member("EndingVpn"):
|
||||
|
||||
@@ -234,6 +234,10 @@ class MMVAD_SHORT(objects.StructType):
|
||||
|
||||
raise AttributeError("Unable to find the ending VPN member")
|
||||
|
||||
def get_size(self) -> int:
|
||||
"""Get the size of the VAD region. The OS ensures page granularity."""
|
||||
return (self.get_end() - self.get_start()) + 1
|
||||
|
||||
def get_commit_charge(self):
|
||||
"""Get the VAD's commit charge (number of committed pages)"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user