mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-09-09 11:17:38 +02:00
Add and make use of free_table_name for symbol_spaces.
This commit is contained in:
@@ -585,12 +585,7 @@ class SymbolRequirement(ConstructableRequirementInterface):
|
||||
def construct(self, context, config_path):
|
||||
"""Constructs the symbol space within the context based on the subrequirements"""
|
||||
# Determine the space name
|
||||
name = self.name
|
||||
if name in context.symbol_space:
|
||||
index = 2
|
||||
while name in context.symbol_space:
|
||||
name = self.name + str(index)
|
||||
index += 1
|
||||
name = context.symbol_space.free_table_name(self.name)
|
||||
|
||||
config_path = path_join(config_path, self.name)
|
||||
args = {"context": context,
|
||||
|
||||
@@ -51,6 +51,9 @@ class Symbol(validity.ValidityRoutines):
|
||||
class SymbolSpaceInterface(collections.abc.Mapping):
|
||||
"""An interface for the container that holds all the symbol-containing tables for use within a context"""
|
||||
|
||||
def free_table_name(self, prefix = "layer"):
|
||||
"""Returns an unused table name to ensure no collision occurs when inserting a symbol table"""
|
||||
|
||||
@abstractmethod
|
||||
def get_symbols_by_type(self, type_name):
|
||||
"""Returns all symbols based on the type of the symbol"""
|
||||
|
||||
@@ -3,7 +3,7 @@ import collections.abc
|
||||
import enum
|
||||
import logging
|
||||
|
||||
from volatility.framework import constants, exceptions, interfaces, objects
|
||||
from volatility.framework import constants, exceptions, interfaces, objects, validity
|
||||
from volatility.framework.symbols import native, windows, linux
|
||||
|
||||
vollog = logging.getLogger(__name__)
|
||||
@@ -15,7 +15,7 @@ class SymbolType(enum.Enum):
|
||||
ENUM = 3
|
||||
|
||||
|
||||
class SymbolSpace(interfaces.symbols.SymbolSpaceInterface):
|
||||
class SymbolSpace(interfaces.symbols.SymbolSpaceInterface, validity.ValidityRoutines):
|
||||
"""Handles an ordered collection of SymbolTables
|
||||
|
||||
This collection is ordered so that resolution of symbols can
|
||||
@@ -23,10 +23,20 @@ class SymbolSpace(interfaces.symbols.SymbolSpaceInterface):
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._dict = collections.OrderedDict()
|
||||
# Permanently cache all resolved symbols
|
||||
self._resolved = {}
|
||||
|
||||
def free_table_name(self, prefix = "layer"):
|
||||
"""Returns an unused table name to ensure no collision occurs when inserting a symbol table"""
|
||||
self._check_type(prefix, str)
|
||||
|
||||
count = 1
|
||||
while prefix + str(count) in self:
|
||||
count += 1
|
||||
return prefix + str(count)
|
||||
|
||||
### Symbol functions
|
||||
|
||||
def get_symbols_by_type(self, type_name):
|
||||
|
||||
Reference in New Issue
Block a user