Skip to content

Commit fe6d575

Browse files
committed
update _display_value to handle None case
1 parent ec9e738 commit fe6d575

File tree

1 file changed

+33
-16
lines changed

1 file changed

+33
-16
lines changed

volatility3/cli/volshell/generic.py

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -587,26 +587,43 @@ def _display_simple_type(
587587

588588
def _display_value(self, value: Any) -> str:
589589
try:
590+
# if value is a BaseAbsentValue they display N/A
590591
if isinstance(value, interfaces.renderers.BaseAbsentValue):
591592
return "N/A"
592-
elif isinstance(value, objects.Pointer):
593-
# show pointers in hex to match output for struct addrs
594-
# highlight null or unreadable pointers
595-
if value == 0:
596-
suffix = " (null pointer)"
597-
elif not value.is_readable():
598-
suffix = " (unreadable pointer)"
599-
else:
600-
suffix = ""
601-
return f"{hex(value)}{suffix}"
602-
elif isinstance(value, objects.PrimitiveObject):
603-
return repr(value)
604-
elif isinstance(value, objects.Array):
605-
return repr([self._display_value(val) for val in value])
606593
else:
607-
return hex(value.vol.offset)
594+
# volobject branch
595+
if isinstance(
596+
value,
597+
Union[
598+
interfaces.objects.ObjectInterface, interfaces.objects.Template
599+
],
600+
):
601+
if isinstance(value, objects.Pointer):
602+
# show pointers in hex to match output for struct addrs
603+
# highlight null or unreadable pointers
604+
if value == 0:
605+
suffix = " (null pointer)"
606+
elif not value.is_readable():
607+
suffix = " (unreadable pointer)"
608+
else:
609+
suffix = ""
610+
return f"{hex(value)}{suffix}"
611+
elif isinstance(value, objects.PrimitiveObject):
612+
return repr(value)
613+
elif isinstance(value, objects.Array):
614+
return repr([self._display_value(val) for val in value])
615+
else:
616+
return hex(value.vol.offset)
617+
else:
618+
# non volobject
619+
if value is None:
620+
return "N/A"
621+
else:
622+
return value
623+
608624
except exceptions.InvalidAddressException:
609-
return "-"
625+
# if value causes an InvalidAddressException like BaseAbsentValue then display N/A
626+
return "N/A"
610627

611628
def generate_treegrid(
612629
self, plugin: Type[interfaces.plugins.PluginInterface], **kwargs

0 commit comments

Comments
 (0)