Make the paged exceptions more useful at knowing how big an area is unavailable.

This commit is contained in:
Mike Auty
2016-11-18 11:40:48 +00:00
parent f688af529b
commit 096e2f4610
2 changed files with 15 additions and 4 deletions
+11
View File
@@ -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"""
+4 -4
View File
@@ -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)