mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-09-10 11:47:38 +02:00
Remove flags as a fully-fledged object until it's been discussed
This commit is contained in:
@@ -296,30 +296,6 @@ class Enumeration(interfaces.objects.ObjectInterface, int):
|
||||
return template._vol['base_type'].size
|
||||
|
||||
|
||||
class Flags(Integer):
|
||||
"""Object that converts an integer into a set of flags based on their masks"""
|
||||
|
||||
def __init__(self, context, type_name, object_info, struct_format, choices = None):
|
||||
super().__init__(context, type_name, object_info, struct_format)
|
||||
self._check_type(choices, collections.Mapping)
|
||||
for k, v in choices.items():
|
||||
self._check_type(k, str)
|
||||
self._check_type(v, int)
|
||||
self._vol['choices'] = choices
|
||||
|
||||
@property
|
||||
def choices(self):
|
||||
return self._vol['choices']
|
||||
|
||||
@property
|
||||
def flags(self):
|
||||
result = []
|
||||
for k, v in self.choices.items():
|
||||
if self & v:
|
||||
result.append(k)
|
||||
return result
|
||||
|
||||
|
||||
class Array(interfaces.objects.ObjectInterface, collections.Sequence):
|
||||
"""Object which can contain a fixed number of an object type"""
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import collections
|
||||
|
||||
from volatility.framework import interfaces, validity
|
||||
|
||||
|
||||
class Flags(validity.ValidityRoutines):
|
||||
"""Object that converts an integer into a set of flags based on their masks"""
|
||||
|
||||
def __init__(self, choices = None):
|
||||
self._check_type(choices, collections.Mapping)
|
||||
for k, v in choices.items():
|
||||
self._check_type(k, str)
|
||||
self._check_type(v, int)
|
||||
self._choices = interfaces.objects.ReadOnlyMapping(choices)
|
||||
|
||||
@property
|
||||
def choices(self):
|
||||
return self._choices
|
||||
|
||||
def __call__(self, value):
|
||||
"""Return the appropriate Flags """
|
||||
result = []
|
||||
for k, v in self.choices.items():
|
||||
if value & v:
|
||||
result.append(k)
|
||||
return result
|
||||
Reference in New Issue
Block a user