Allow VolTemplateProxies to include additional useful methods.

This commit is contained in:
Mike Auty
2019-04-17 23:53:36 +01:00
parent e5d6cd3d16
commit 8c76a25b2d
3 changed files with 15 additions and 5 deletions
-1
View File
@@ -413,7 +413,6 @@ class Enumeration(interfaces.objects.ObjectInterface, int):
self._vol['base_type'] = base_type
@classmethod
@functools.lru_cache(maxsize = 128)
def _generate_inverse_choices(cls, choices: Dict[str, int]) -> Dict[int, str]:
"""Generates the inverse choices for the object"""
inverse_choices = {} # type: Dict[int, str]
+7 -1
View File
@@ -17,7 +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
@@ -41,6 +41,12 @@ 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))
@property
def size(self) -> int:
"""Returns the children of the templated object (see :class:`~volatility.framework.interfaces.objects.ObjectInterface.VolTemplateProxy`)"""