|
3 | 3 | # |
4 | 4 |
|
5 | 5 | from typing import Generator, Tuple |
| 6 | +import logging |
6 | 7 |
|
7 | 8 | from volatility.framework import constants |
8 | 9 | from volatility.framework import objects, interfaces |
9 | 10 | from volatility.framework.renderers import conversion |
10 | 11 |
|
| 12 | +vollog = logging.getLogger(__name__) |
11 | 13 |
|
12 | 14 | class IMAGE_DOS_HEADER(objects.StructType): |
13 | 15 |
|
@@ -74,8 +76,16 @@ def fix_image_base(self, raw_data: bytes, nt_header: interfaces.objects.ObjectIn |
74 | 76 | image_base_offset = nt_header.OptionalHeader.ImageBase.vol.offset - self.vol.offset |
75 | 77 | image_base_type = nt_header.OptionalHeader.ImageBase.vol.type_name |
76 | 78 | member_size = self._context.symbol_space.get_type(image_base_type).size |
77 | | - newval = objects.convert_value_to_data(self.vol.offset, int, nt_header.OptionalHeader.ImageBase.vol.data_format) |
78 | | - return raw_data[:image_base_offset] + newval + raw_data[image_base_offset + member_size:] |
| 79 | + try: |
| 80 | + newval = objects.convert_value_to_data(self.vol.offset, int, nt_header.OptionalHeader.ImageBase.vol.data_format) |
| 81 | + new_pe = raw_data[:image_base_offset] + newval + raw_data[image_base_offset + member_size:] |
| 82 | + except OverflowError: |
| 83 | + vollog.warning("Volatility was unable to fix the image base for the PE file at base address {:#x}. " \ |
| 84 | + "This will cause issues with many static analysis tools if you do not inform the " \ |
| 85 | + "tool of the in-memory load address.".format(self.vol.offset)) |
| 86 | + new_pe = raw_data |
| 87 | + |
| 88 | + return new_pe |
79 | 89 |
|
80 | 90 | def reconstruct(self) -> Generator[Tuple[int, bytes], None, None]: |
81 | 91 | """This method generates the content necessary to reconstruct a PE file |
|
0 commit comments