mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-09-10 11:47:38 +02:00
Merge pull request #1314 from gcmoreira/linux_add_hlist_head_object_extension_fix_1313
Linux adds hlist_head object extension
This commit is contained in:
@@ -245,7 +245,7 @@ class Module(interfaces.context.ModuleInterface):
|
||||
"""
|
||||
if constants.BANG not in object_type:
|
||||
object_type = self.symbol_table_name + constants.BANG + object_type
|
||||
else:
|
||||
elif not object_type.startswith(self.symbol_table_name + constants.BANG):
|
||||
raise ValueError(
|
||||
"Cannot reference another module when constructing an object"
|
||||
)
|
||||
|
||||
@@ -22,6 +22,7 @@ class LinuxKernelIntermedSymbols(intermed.IntermediateSymbolTable):
|
||||
# Set-up Linux specific types
|
||||
self.set_type_class("file", extensions.struct_file)
|
||||
self.set_type_class("list_head", extensions.list_head)
|
||||
self.set_type_class("hlist_head", extensions.hlist_head)
|
||||
self.set_type_class("mm_struct", extensions.mm_struct)
|
||||
self.set_type_class("super_block", extensions.super_block)
|
||||
self.set_type_class("task_struct", extensions.task_struct)
|
||||
|
||||
@@ -887,7 +887,7 @@ class dentry(objects.StructType):
|
||||
if self.has_member("d_sib") and self.has_member("d_children"):
|
||||
# kernels >= 6.8
|
||||
walk_member = "d_sib"
|
||||
list_head_member = self.d_children.first
|
||||
list_head_member = self.d_children
|
||||
elif self.has_member("d_child") and self.has_member("d_subdirs"):
|
||||
# 2.5.0 <= kernels < 6.8
|
||||
walk_member = "d_child"
|
||||
@@ -1004,6 +1004,40 @@ class list_head(objects.StructType, collections.abc.Iterable):
|
||||
return self.to_list(self.vol.parent.vol.type_name, self.vol.member_name)
|
||||
|
||||
|
||||
class hlist_head(objects.StructType, collections.abc.Iterable):
|
||||
def to_list(
|
||||
self,
|
||||
symbol_type: str,
|
||||
member: str,
|
||||
) -> Iterator[interfaces.objects.ObjectInterface]:
|
||||
"""Returns an iterator of the entries in the list.
|
||||
|
||||
This is a doubly linked list; however, it is not circular, so the 'forward' field
|
||||
doesn't make sense. Also, the sentinel concept doesn't make sense here either;
|
||||
unlike list_head, the head and nodes each have their own distinct types. A list_head
|
||||
cannot be a node by itself.
|
||||
- The 'pprev' of the first 'hlist_node' points to the 'hlist_head', not to the last node.
|
||||
- The last element 'next' member is NULL
|
||||
|
||||
Args:
|
||||
symbol_type: Type of the list elements
|
||||
member: Name of the list_head member in the list elements
|
||||
|
||||
Yields:
|
||||
Objects of the type specified via the "symbol_type" argument.
|
||||
|
||||
"""
|
||||
vmlinux = linux.LinuxUtilities.get_module_from_volobj_type(self._context, self)
|
||||
|
||||
current = self.first
|
||||
while current and current.is_readable():
|
||||
yield linux.LinuxUtilities.container_of(
|
||||
current, symbol_type, member, vmlinux
|
||||
)
|
||||
|
||||
current = current.next
|
||||
|
||||
|
||||
class files_struct(objects.StructType):
|
||||
def get_fds(self) -> interfaces.objects.ObjectInterface:
|
||||
if self.has_member("fdt"):
|
||||
|
||||
Reference in New Issue
Block a user