Skip to content

Commit 73f8ddb

Browse files
authored
Merge pull request #1328 from gcmoreira/linux_module_mod_mem_type_cache
Linux refactory module extension object mod_mem_type cache
2 parents efe1e1e + b098596 commit 73f8ddb

File tree

1 file changed

+13
-18
lines changed
  • volatility3/framework/symbols/linux/extensions

1 file changed

+13
-18
lines changed

volatility3/framework/symbols/linux/extensions/__init__.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,24 @@
3131

3232
class module(generic.GenericIntelProcess):
3333

34-
def __init__(self, *args, **kwargs):
35-
super().__init__(*args, **kwargs)
36-
self._mod_mem_type = None # Initialize _mod_mem_type to None for memoization
37-
38-
@property
39-
def mod_mem_type(self):
34+
@functools.cached_property
35+
def mod_mem_type(self) -> Dict:
4036
"""Return the mod_mem_type enum choices if available or an empty dict if not"""
4137
# mod_mem_type and module_memory were added in kernel 6.4 which replaces
4238
# module_layout for storing the information around core_layout etc.
4339
# see commit ac3b43283923440900b4f36ca5f9f0b1ca43b70e for more information
40+
symbol_table_name = self.get_symbol_table_name()
41+
mod_mem_type_symname = symbol_table_name + constants.BANG + "mod_mem_type"
42+
symbol_space = self._context.symbol_space
43+
try:
44+
mod_mem_type = symbol_space.get_enumeration(mod_mem_type_symname).choices
45+
except exceptions.SymbolError:
46+
mod_mem_type = {}
47+
vollog.debug(
48+
"Unable to find mod_mem_type enum. This message can be ignored for kernels < 6.4"
49+
)
4450

45-
if self._mod_mem_type is None:
46-
try:
47-
self._mod_mem_type = self._context.symbol_space.get_enumeration(
48-
self.get_symbol_table_name() + constants.BANG + "mod_mem_type"
49-
).choices
50-
except exceptions.SymbolError:
51-
vollog.debug(
52-
"Unable to find mod_mem_type enum. This message can be ignored for kernels < 6.4"
53-
)
54-
# set to empty dict to show that the enum was not found, and so shouldn't be searched for again
55-
self._mod_mem_type = {}
56-
return self._mod_mem_type
51+
return mod_mem_type
5752

5853
def get_module_base(self):
5954
if self.has_member("mem"): # kernels 6.4+

0 commit comments

Comments
 (0)