mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-08-17 20:35:40 +02:00
Initial work on adding a LayerData renderer type
This commit is contained in:
@@ -9,8 +9,10 @@ renderer interface which can interact with a TreeGrid to produce
|
||||
suitable output.
|
||||
"""
|
||||
|
||||
from dataclasses import dataclass
|
||||
import datetime
|
||||
from abc import abstractmethod, ABCMeta
|
||||
from volatility3.framework import interfaces
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from collections import abc
|
||||
from typing import (
|
||||
Any,
|
||||
@@ -20,9 +22,9 @@ from typing import (
|
||||
List,
|
||||
NamedTuple,
|
||||
Optional,
|
||||
TypeVar,
|
||||
Type,
|
||||
Tuple,
|
||||
Type,
|
||||
TypeVar,
|
||||
Union,
|
||||
)
|
||||
|
||||
@@ -124,6 +126,13 @@ class Disassembly:
|
||||
self.offset = offset
|
||||
|
||||
|
||||
@dataclass
|
||||
class LayerData(object):
|
||||
layer_name: str
|
||||
offset: int
|
||||
length: int
|
||||
|
||||
|
||||
# We don't class these off a shared base, because the BaseTypes must only
|
||||
# contain the types that the validator will accept (which would not include the base)
|
||||
|
||||
@@ -136,6 +145,7 @@ BaseTypes = Union[
|
||||
Type[datetime.datetime],
|
||||
Type[BaseAbsentValue],
|
||||
Type[Disassembly],
|
||||
Type[LayerData],
|
||||
]
|
||||
ColumnsType = List[Tuple[str, BaseTypes]]
|
||||
VisitorSignature = Callable[[TreeNode, _Type], _Type]
|
||||
@@ -163,7 +173,12 @@ class TreeGrid(metaclass=ABCMeta):
|
||||
Disassembly,
|
||||
)
|
||||
|
||||
def __init__(self, columns: ColumnsType, generator: Generator) -> None:
|
||||
def __init__(
|
||||
self,
|
||||
columns: ColumnsType,
|
||||
generator: Generator,
|
||||
context: Optional[interfaces.context.ContextInterface] = None,
|
||||
) -> None:
|
||||
"""Constructs a TreeGrid object using a specific set of columns.
|
||||
|
||||
The TreeGrid itself is a root element, that can have children but no values.
|
||||
@@ -174,6 +189,15 @@ class TreeGrid(metaclass=ABCMeta):
|
||||
columns: A list of column tuples made up of (name, type).
|
||||
generator: An iterable containing row for a tree grid, each row contains a indent level followed by the values for each column in order.
|
||||
"""
|
||||
self._context = context
|
||||
|
||||
@property
|
||||
def context(self) -> Optional[interfaces.context.ContextInterface]:
|
||||
"""Returns the context value for the tree grid (to retrieve data items)
|
||||
|
||||
This is a property to ensure the renderers don't try changing the context for any reason
|
||||
"""
|
||||
return self._context
|
||||
|
||||
@staticmethod
|
||||
@abstractmethod
|
||||
|
||||
Reference in New Issue
Block a user