Skip to content

Commit 93c6a62

Browse files
atcunoikelos
authored andcommitted
Detect attempts to fix the image base for LARGEADDRESSAWARE executables and provide the user with a warning. #332
1 parent d63aef5 commit 93c6a62

File tree

1 file changed

+12
-2
lines changed
  • volatility/framework/symbols/windows/extensions

1 file changed

+12
-2
lines changed

volatility/framework/symbols/windows/extensions/pe.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
#
44

55
from typing import Generator, Tuple
6+
import logging
67

78
from volatility.framework import constants
89
from volatility.framework import objects, interfaces
910
from volatility.framework.renderers import conversion
1011

12+
vollog = logging.getLogger(__name__)
1113

1214
class IMAGE_DOS_HEADER(objects.StructType):
1315

@@ -74,8 +76,16 @@ def fix_image_base(self, raw_data: bytes, nt_header: interfaces.objects.ObjectIn
7476
image_base_offset = nt_header.OptionalHeader.ImageBase.vol.offset - self.vol.offset
7577
image_base_type = nt_header.OptionalHeader.ImageBase.vol.type_name
7678
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
7989

8090
def reconstruct(self) -> Generator[Tuple[int, bytes], None, None]:
8191
"""This method generates the content necessary to reconstruct a PE file

0 commit comments

Comments
 (0)