From 096e2f4610a0bf0faa2e92dab28e252511546924 Mon Sep 17 00:00:00 2001 From: Mike Auty Date: Fri, 18 Nov 2016 11:40:48 +0000 Subject: [PATCH] Make the paged exceptions more useful at knowing how big an area is unavailable. --- volatility/framework/exceptions.py | 11 +++++++++++ volatility/framework/layers/intel.py | 8 ++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/volatility/framework/exceptions.py b/volatility/framework/exceptions.py index e936b6ec0..cb3dbe6e1 100644 --- a/volatility/framework/exceptions.py +++ b/volatility/framework/exceptions.py @@ -22,6 +22,17 @@ class InvalidAddressException(VolatilityException): self.layer_name = layer_name +class PagedInvalidAddressException(InvalidAddressException): + """Thrown when an address is not valid in the paged space in which it was request + + Includes the invalid address and the number of bits of the address that are invalid + """ + + def __init__(self, layer_name, invalid_address, invalid_bits, *args, **kwargs): + super().__init__(layer_name, invalid_address, *args, **kwargs) + self.invalid_bits = invalid_bits + + class SymbolSpaceError(VolatilityException): """Thrown when an error occurs dealing with Symbols and Symbolspaces""" diff --git a/volatility/framework/layers/intel.py b/volatility/framework/layers/intel.py index 025ffaf88..5ee64a166 100644 --- a/volatility/framework/layers/intel.py +++ b/volatility/framework/layers/intel.py @@ -72,8 +72,8 @@ class Intel(interfaces.layers.TranslationLayerInterface): for (name, size, large_page) in self._structure: # Check we're valid if not self._page_is_valid(entry): - raise exceptions.InvalidAddressException(self.name, offset, - "Page Fault at entry " + hex(entry) + " in table " + name) + raise exceptions.PagedInvalidAddressException(self.name, offset, position + 1, + "Page Fault at entry " + hex(entry) + " in table " + name) # Check if we're a large page if large_page and (entry & (1 << 7)): # We're a large page, the rest is finished below @@ -94,8 +94,8 @@ class Intel(interfaces.layers.TranslationLayerInterface): # Now we're done if not self._page_is_valid(entry): - raise exceptions.InvalidAddressException(self.name, offset, - "Page Fault at entry " + hex(entry) + " in page entry") + raise exceptions.PagedInvalidAddressException(self.name, offset, position + 1, + "Page Fault at entry {} in page entry".format(hex(entry))) page = self._mask(entry, self._maxphyaddr - 1, position + 1) | self._mask(offset, position, 0) return page, 1 << (position + 1)