mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-08-31 12:19:42 +02:00
Support passing through functions from specific to generic template.
This commit is contained in:
@@ -174,6 +174,7 @@ class ObjectInterface(metaclass = ABCMeta):
|
||||
Each method also takes a template since the templates may contain the necessary data about the
|
||||
yet-to-be-constructed object. It allows objects to control how their templates respond without needing to write
|
||||
new templates for each and every potental object type."""
|
||||
_methods = []
|
||||
|
||||
@classmethod
|
||||
@abc.abstractmethod
|
||||
|
||||
@@ -451,6 +451,7 @@ class Enumeration(interfaces.objects.ObjectInterface, int):
|
||||
raise NotImplementedError("Writing to Enumerations is not yet implemented")
|
||||
|
||||
class VolTemplateProxy(interfaces.objects.ObjectInterface.VolTemplateProxy):
|
||||
_methods = ['lookup']
|
||||
|
||||
@classmethod
|
||||
def lookup(cls, template: interfaces.objects.Template, value: int) -> str:
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the
|
||||
# specific language governing rights and limitations under the License.
|
||||
#
|
||||
import functools
|
||||
import logging
|
||||
from typing import Any, ClassVar, Dict, List, Type
|
||||
|
||||
@@ -40,11 +41,9 @@ class ObjectTemplate(interfaces.objects.Template):
|
||||
super().__init__(type_name = type_name, **arguments)
|
||||
self._arguments['object_class'] = object_class
|
||||
|
||||
# proxy_cls = self.vol.object_class.VolTemplateProxy
|
||||
# for method_name in dir(proxy_cls):
|
||||
# if (method_name not in dir(interfaces.objects.ObjectInterface.VolTemplateProxy)
|
||||
# and callable(getattr(proxy_cls, method_name)) and not method_name.startswith('_')):
|
||||
# setattr(self, method_name, functools.partial(getattr(proxy_cls, method_name), self))
|
||||
proxy_cls = self.vol.object_class.VolTemplateProxy
|
||||
for method_name in proxy_cls._methods:
|
||||
setattr(self, method_name, functools.partial(getattr(proxy_cls, method_name), self))
|
||||
|
||||
@property
|
||||
def size(self) -> int:
|
||||
|
||||
Reference in New Issue
Block a user