mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-09-08 18:57:38 +02:00
Add in translate method for TranslationLayers.
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user