Add in translate method for TranslationLayers.

This commit is contained in:
Mike Auty
2017-08-08 17:45:36 +01:00
parent 2caeeb275e
commit f0d7dbdf68
+14
View File
@@ -9,6 +9,7 @@ import multiprocessing
from abc import ABCMeta, abstractmethod
from volatility.framework import constants, exceptions, validity
from volatility.framework.exceptions import InvalidAddressException
from volatility.framework.interfaces import configuration, context
vollog = logging.getLogger(__name__)
@@ -254,6 +255,19 @@ class TranslationLayerInterface(DataLayerInterface, metaclass = ABCMeta):
"""Returns a list of layer names that this layer translates onto"""
return []
### Translation layer convenience function
def translate(self, offset, ignore_errors = False):
mapping = self.mapping(offset, 0, ignore_errors)
if mapping:
_, mapped_offset, _, layer = list(mapping)[0]
else:
if ignore_errors:
# We should only hit this if we ignored errors, but check anyway
return None, None
raise InvalidAddressException("Cannot translate {} in layer {}".format(offset, self.name))
return mapped_offset, layer
# ## Read/Write functions for mapped pages
def read(self, offset, length, pad = False):