mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-08-30 19:59:46 +02:00
Remove the error checking in dlllist, we need to be throwing exceptions and handling them.
This commit is contained in:
@@ -13,12 +13,16 @@ class _ETHREAD(objects.Struct):
|
||||
"""Return the EPROCESS that owns this thread"""
|
||||
return self.ThreadsProcess.dereference(kernel_layer)
|
||||
|
||||
|
||||
class _UNICODE_STRING(objects.Struct):
|
||||
@property
|
||||
def String(self):
|
||||
if not self._context.memory[self.vol.layer_name].is_valid(self.Buffer):
|
||||
return ""
|
||||
return self.Buffer.dereference().cast("string", max_length = self.Length, errors = "replace", encoding = "utf16")
|
||||
# We explicitly do *not* catch errors here, we allow an exception to be thrown
|
||||
# (otherwise there's no way to determine anything went wrong)
|
||||
# It's up to the user of this method to catch exceptions
|
||||
return self.Buffer.dereference().cast("string", max_length = self.Length, errors = "replace",
|
||||
encoding = "utf16")
|
||||
|
||||
|
||||
class _EPROCESS(objects.Struct):
|
||||
def add_process_layer(self, context, config_prefix = None, preferred_name = None):
|
||||
@@ -66,14 +70,16 @@ class _EPROCESS(objects.Struct):
|
||||
|
||||
proc_layer = self._context.memory[proc_layer_name]
|
||||
if not proc_layer.is_valid(self.Peb):
|
||||
raise StopIteration
|
||||
raise StopIteration
|
||||
|
||||
sym_table = self.vol.type_name.split("!")[0]
|
||||
peb = self._context.object("{}!_PEB".format(sym_table), layer_name = proc_layer_name, offset = self.Peb)
|
||||
|
||||
for entry in peb.Ldr.InLoadOrderModuleList.to_list("{}!_LDR_DATA_TABLE_ENTRY".format(sym_table), "InLoadOrderLinks"):
|
||||
for entry in peb.Ldr.InLoadOrderModuleList.to_list("{}!_LDR_DATA_TABLE_ENTRY".format(sym_table),
|
||||
"InLoadOrderLinks"):
|
||||
yield entry
|
||||
|
||||
|
||||
class _LIST_ENTRY(objects.Struct, collections.abc.Iterable):
|
||||
def to_list(self, symbol_type, member, forward = True, sentinel = True, layer = None):
|
||||
"""Returns an iterator of the entries in the list"""
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import volatility.framework.interfaces.plugins as plugins
|
||||
import volatility.plugins.windows.pslist as pslist
|
||||
from volatility.framework.configuration import requirements
|
||||
from volatility.framework import exceptions
|
||||
from volatility.framework import renderers
|
||||
from volatility.framework.configuration import requirements
|
||||
from volatility.framework.renderers import format_hints
|
||||
|
||||
|
||||
class DllList(plugins.PluginInterface):
|
||||
@classmethod
|
||||
def get_requirements(cls):
|
||||
@@ -19,22 +21,30 @@ class DllList(plugins.PluginInterface):
|
||||
|
||||
for proc in procs:
|
||||
|
||||
for entry in proc.load_order_modules():
|
||||
for entry in proc.load_order_modules():
|
||||
|
||||
yield (0, (proc.UniqueProcessId,
|
||||
proc.ImageFileName.cast("string", max_length = proc.ImageFileName.vol.count,
|
||||
errors = 'replace'),
|
||||
format_hints.Hex(entry.DllBase), format_hints.Hex(entry.SizeOfImage),
|
||||
entry.BaseDllName.String, entry.FullDllName.String))
|
||||
BaseDllName = FullDllName = ""
|
||||
try:
|
||||
BaseDllName = entry.BaseDllName.String
|
||||
# We assume that if the BaseDllName points to an invalid buffer, so will FullDllName
|
||||
FullDllName = entry.FullDllName.String
|
||||
except exceptions.InvalidAddressException:
|
||||
pass
|
||||
|
||||
yield (0, (proc.UniqueProcessId,
|
||||
proc.ImageFileName.cast("string", max_length = proc.ImageFileName.vol.count,
|
||||
errors = 'replace'),
|
||||
format_hints.Hex(entry.DllBase), format_hints.Hex(entry.SizeOfImage),
|
||||
BaseDllName, FullDllName))
|
||||
|
||||
def run(self):
|
||||
|
||||
plugin = pslist.PsList(self.context, "plugins.DllList")
|
||||
|
||||
return renderers.TreeGrid([("PID", int),
|
||||
("Process", str),
|
||||
("Base", format_hints.Hex),
|
||||
("Size", format_hints.Hex),
|
||||
("Name", str),
|
||||
("Path", str)],
|
||||
self._generator(plugin.list_processes()))
|
||||
("Process", str),
|
||||
("Base", format_hints.Hex),
|
||||
("Size", format_hints.Hex),
|
||||
("Name", str),
|
||||
("Path", str)],
|
||||
self._generator(plugin.list_processes()))
|
||||
|
||||
Reference in New Issue
Block a user