mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-08-23 22:52:23 +02:00
Improve enumeration support.
This commit is contained in:
@@ -223,7 +223,7 @@ class SymbolSpaceInterface(collections.abc.Mapping):
|
||||
"""Look-up a symbol name across all the contained symbol tables"""
|
||||
|
||||
@abstractmethod
|
||||
def get_enumeration(self, enum_name: str) -> Dict[str, Any]:
|
||||
def get_enumeration(self, enum_name: str) -> objects.Template:
|
||||
"""Look-up an enumeration across all the contained symbol tables"""
|
||||
|
||||
@abstractmethod
|
||||
@@ -268,14 +268,14 @@ class SymbolTableInterface(BaseSymbolTableInterface, configuration.ConfigurableI
|
||||
class NativeTableInterface(BaseSymbolTableInterface):
|
||||
"""Class to distinguish NativeSymbolLists from other symbol lists"""
|
||||
|
||||
def get_symbol(self, name: str):
|
||||
def get_symbol(self, name: str) -> objects.Template:
|
||||
raise exceptions.SymbolError("NativeTables never hold symbols")
|
||||
|
||||
@property
|
||||
def symbols(self) -> Iterable[str]:
|
||||
return []
|
||||
|
||||
def get_enumeration(self, name: str) -> Dict[str, Any]:
|
||||
def get_enumeration(self, name: str) -> objects.Template:
|
||||
raise exceptions.SymbolError("NativeTables never hold enumerations")
|
||||
|
||||
@property
|
||||
|
||||
@@ -424,8 +424,10 @@ class Enumeration(interfaces.objects.ObjectInterface, int):
|
||||
inverse_choices[v] = k
|
||||
return inverse_choices
|
||||
|
||||
def lookup(self, value: int) -> str:
|
||||
def lookup(self, value: int = None) -> str:
|
||||
"""Looks up an individual value and returns the associated name"""
|
||||
if value is None:
|
||||
return self.lookup(self)
|
||||
if value in self._inverse_choices:
|
||||
return self._inverse_choices[value]
|
||||
raise ValueError("The value of the enumeration is outside the possible choices")
|
||||
|
||||
@@ -207,10 +207,10 @@ class SymbolSpace(interfaces.symbols.SymbolSpaceInterface):
|
||||
raise exceptions.SymbolError("Unresolvable Symbol: {}".format(symbol_name))
|
||||
return retval
|
||||
|
||||
def get_enumeration(self, enum_name: str) -> Dict[str, Any]:
|
||||
def get_enumeration(self, enum_name: str) -> interfaces.objects.Template:
|
||||
"""Look-up a set of enumeration choices from a specific symbol table"""
|
||||
retval = self._weak_resolve(SymbolType.ENUM, enum_name)
|
||||
if not isinstance(retval, dict):
|
||||
if not isinstance(retval, interfaces.objects.Template):
|
||||
raise exceptions.SymbolError("Unresolvable Enumeration: {}".format(enum_name))
|
||||
return retval
|
||||
|
||||
|
||||
Reference in New Issue
Block a user