From 54678823f85e831ca0a9cc60d9e092e699be0b70 Mon Sep 17 00:00:00 2001 From: Mike Auty Date: Sun, 18 Dec 2016 16:12:08 +0000 Subject: [PATCH] Refactor BitField subtype to base_type to match enums (and fix a minor enum typo too). --- volatility/framework/objects/__init__.py | 18 +++++++++--------- volatility/framework/symbols/intermed.py | 2 +- volatility/framework/symbols/native.py | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/volatility/framework/objects/__init__.py b/volatility/framework/objects/__init__.py index d665fcc62..d553879e6 100644 --- a/volatility/framework/objects/__init__.py +++ b/volatility/framework/objects/__init__.py @@ -213,25 +213,25 @@ class Pointer(Integer): class BitField(PrimitiveObject, int): """Object containing a field which is made up of bits rather than whole bytes""" - def __new__(cls, context, type_name, object_info, struct_format, subtype = None, start_bit = 0, end_bit = 0, + def __new__(cls, context, type_name, object_info, struct_format, base_type = None, start_bit = 0, end_bit = 0, **kwargs): - cls._check_type(subtype, Integer) - value = subtype(context = context, - type_name = type_name, - object_info = object_info, - struct_format = struct_format) + cls._check_type(base_type, Integer) + value = base_type(context = context, + type_name = type_name, + object_info = object_info, + struct_format = struct_format) return cls._struct_type.__new__(cls, (value >> start_bit) & ((1 << end_bit) - 1)) - def __init__(self, context, type_name, object_info, struct_format, subtype = None, start_bit = 0, end_bit = 0): + def __init__(self, context, type_name, object_info, struct_format, base_type = None, start_bit = 0, end_bit = 0): super().__init__(context, type_name, object_info, struct_format) - self._vol['subtype'] = subtype + self._vol['subtype'] = base_type self._vol['start_bit'] = start_bit self._vol['end_bit'] = end_bit @classmethod def _template_children(cls, template): """Returns the subtype""" - if 'subtype' in template.vol: + if 'base_type' in template.vol: return [template.vol.subtype] return [] diff --git a/volatility/framework/symbols/intermed.py b/volatility/framework/symbols/intermed.py index f4845f220..0f726d0d6 100644 --- a/volatility/framework/symbols/intermed.py +++ b/volatility/framework/symbols/intermed.py @@ -203,7 +203,7 @@ class Version1Format(ISFormatTable): update = self._lookup_enum(dictionary['name']) elif type_name == 'bitfield': update = {'start_bit': dictionary['bit_position'], 'end_bit': dictionary['bit_length']} - update['subtype'] = self._interdict_to_template(dictionary['type']) + update['base_type'] = self._interdict_to_template(dictionary['type']) native_template.update_vol(**update) # pylint: disable=W0142 return native_template diff --git a/volatility/framework/symbols/native.py b/volatility/framework/symbols/native.py index ae8cde197..c25b86a65 100644 --- a/volatility/framework/symbols/native.py +++ b/volatility/framework/symbols/native.py @@ -46,10 +46,10 @@ class NativeTable(interfaces.symbols.NativeTableInterface): additional = {"count": 0, "subtype": self.get_type('void')} elif type_name == 'enum': obj = objects.Enumeration - additional = {"subtype": self.get_type('int'), "choices": {}} + additional = {"base_type": self.get_type('int'), "choices": {}} elif type_name == 'bitfield': obj = objects.BitField - additional = {"start_bit": 0, "end_bit": 0} + additional = {"start_bit": 0, "end_bit": 0, "base_type": self.get_type('int')} elif type_name == 'string': obj = objects.String additional = {"max_length": 0}