@@ -400,8 +400,12 @@ def _parse_module_exports(self, module):
400
400
def _setup_modules (self ):
401
401
minidump_module : minidump .MinidumpModule
402
402
for minidump_module in self ._minidump .modules .modules :
403
- module = self .modules .add (minidump_module .baseaddress , minidump_module .size , minidump_module .name )
404
- header = self .read (module .base , PAGE_SIZE )
403
+ base = minidump_module .baseaddress
404
+ size = minidump_module .size
405
+ path = minidump_module .name
406
+
407
+ # Parse the header to dump the sections from memory
408
+ header = self .read (base , PAGE_SIZE )
405
409
pe = PE (data = header , fast_load = True )
406
410
image_size = pe .OPTIONAL_HEADER .SizeOfImage
407
411
section_alignment = pe .OPTIONAL_HEADER .SectionAlignment
@@ -412,7 +416,7 @@ def _setup_modules(self):
412
416
mask = section_alignment - 1
413
417
rva = (section .VirtualAddress + mask ) & ~ mask
414
418
size = self .memory .align_page (section .Misc_VirtualSize )
415
- va = module . base + rva
419
+ va = base + rva
416
420
for page in range (va , va + size , PAGE_SIZE ):
417
421
region = self .memory .find_commit (page )
418
422
if region is not None :
@@ -421,17 +425,15 @@ def _setup_modules(self):
421
425
data = self .read (va , size )
422
426
mapped_data [rva :size ] = data
423
427
except UcError :
424
- self .error (f"Failed to read section { name } from module { module . path } " )
428
+ self .error (f"Failed to read section { name } from module { path } " )
425
429
# Load the PE dumped from memory
426
430
pe = PE (data = mapped_data , fast_load = True )
427
431
# Hack to adjust pefile to accept in-memory modules
428
432
for section in pe .sections :
429
433
# Potentially interesting members: Misc_PhysicalAddress, Misc_VirtualSize, SizeOfRawData
430
434
section .PointerToRawData = section .VirtualAddress
431
435
section .PointerToRawData_adj = section .VirtualAddress
432
- # Extract the relevant information from the PE
433
- module .parse_pe (pe )
434
-
436
+ self .modules .add (pe , path )
435
437
436
438
def _setup_syscalls (self ):
437
439
# Load the ntdll module from memory
@@ -816,9 +818,7 @@ def map_module(self, file_data: bytes, file_path: str = "", requested_base: int
816
818
self .write (va , data )
817
819
818
820
# Add the module to the module manager
819
- module = self .modules .add (image_base , image_size , file_path )
820
- module .parse_pe (pe )
821
- return module
821
+ return self .modules .add (pe , file_path )
822
822
823
823
def load_dll (self , file_name : str , file_data : bytes ):
824
824
self .handles .map_file ("\\ ??\\ " + file_name , FileObject (file_name , file_data ))
0 commit comments