From fea6e0820a97f78d88acd99a21b7b762f2cb300c Mon Sep 17 00:00:00 2001 From: Mike Auty Date: Sun, 22 May 2016 15:26:31 +0100 Subject: [PATCH] Convert to using a BANG variable for the symbol name delimiter. Whilst it's easy to do now (because we don't yet use it many places) convert the ! delimiter into a variable. --- volatility/framework/constants.py | 1 + volatility/framework/interfaces/symbols.py | 4 +++- volatility/framework/symbols/__init__.py | 4 ++-- volatility/framework/symbols/vtypes.py | 6 +++--- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/volatility/framework/constants.py b/volatility/framework/constants.py index f79a773b5..1656c225d 100644 --- a/volatility/framework/constants.py +++ b/volatility/framework/constants.py @@ -6,3 +6,4 @@ This includes default scanning block sizes, etc.""" import os.path PLUGINS_PATH = [os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "plugins"))] +BANG = "!" diff --git a/volatility/framework/interfaces/symbols.py b/volatility/framework/interfaces/symbols.py index 76dfb5f6b..9c0d562d0 100644 --- a/volatility/framework/interfaces/symbols.py +++ b/volatility/framework/interfaces/symbols.py @@ -4,13 +4,15 @@ Created on 4 May 2013 @author: mike """ -from volatility.framework import validity, exceptions +from volatility.framework import validity, exceptions, constants from volatility.framework.interfaces import configuration class Symbol(validity.ValidityRoutines): def __init__(self, name, offset, type_name = None): self._name = self._check_type(name, str) + if constants.BANG in self._name: + raise ValueError("Symbol names cannot contain the symbol differentiator (" + constants.BANG + ")") self._location = None self._offset = self._check_type(offset, int) if type_name is None: diff --git a/volatility/framework/symbols/__init__.py b/volatility/framework/symbols/__init__.py index c05852fb4..3e21bc61c 100644 --- a/volatility/framework/symbols/__init__.py +++ b/volatility/framework/symbols/__init__.py @@ -8,7 +8,7 @@ import collections import collections.abc import warnings -from volatility.framework import objects, interfaces, exceptions +from volatility.framework import objects, interfaces, exceptions, constants from volatility.framework.symbols import native, vtypes, windows @@ -80,7 +80,7 @@ class SymbolSpace(collections.abc.Mapping): else: raise ValueError("Weak_resolve called without a proper SymbolType.") - name_array = name.split("!") + name_array = name.split(constants.BANG) if len(name_array) == 2: table_name = name_array[0] component_name = name_array[1] diff --git a/volatility/framework/symbols/vtypes.py b/volatility/framework/symbols/vtypes.py index 8a115998c..19affc3eb 100644 --- a/volatility/framework/symbols/vtypes.py +++ b/volatility/framework/symbols/vtypes.py @@ -6,7 +6,7 @@ Created on 10 Apr 2013 import copy -from volatility.framework import exceptions, objects, interfaces +from volatility.framework import exceptions, objects, interfaces, constants # ## TODO @@ -86,7 +86,7 @@ class VTypeSymbolTable(interfaces.symbols.SymbolTableInterface): if len(dictionary) > 1: raise exceptions.SymbolSpaceError("Unknown vtype format: " + repr(dictionary)) - return objects.templates.ReferenceTemplate(type_name = self.name + "!" + type_name) + return objects.templates.ReferenceTemplate(type_name = self.name + constants.BANG + type_name) @property def types(self): @@ -104,7 +104,7 @@ class VTypeSymbolTable(interfaces.symbols.SymbolTableInterface): member = (relative_offset, self._vtypedict_to_template(vtypedict)) members[member_name] = member object_class = self.get_type_class(type_name) - return objects.templates.ObjectTemplate(type_name = self.name + "!" + type_name, + return objects.templates.ObjectTemplate(type_name = self.name + constants.BANG + type_name, object_class = object_class, size = size, members = members)