Skip to content

Commit

Permalink
Add load resolved module
Browse files Browse the repository at this point in the history
  • Loading branch information
serpilliere committed Jan 7, 2021
1 parent b591cb9 commit 9cb6e22
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion miasm/analysis/sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def load_main_pe(self, options):
from miasm.jitter.loader.pe import vm_load_pe
from miasm.os_dep.win_api_x86_32 import winobjs

module_image_base = self.loader.load_module(options.filename)
module_image_base = self.loader.load_resolved_module(options.filename, options.filename)
name = self.loader.module_base_address_to_name[module_image_base]
self.pe = self.loader.module_name_to_module[name]
winobjs.current_pe = self.pe
Expand Down
14 changes: 11 additions & 3 deletions miasm/jitter/loader/pe.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,16 +499,24 @@ def resolve_function(self, module_name, imp_ord_or_name, parent=None, dst_ad=Non

def load_module(self, name):
"""
Load module and it's dependencies
Resolve the path of @name and load module and it's dependencies
Return image base address of the module
"""
name = name.lower()
fname = self.find_module_path(name)
if fname is None:
raise RuntimeError("Cannot find module %r" % fname)
return self.load_resolved_module(name, fname)

def load_resolved_module(self, name, fname):
"""
Load module @name using its @fname path and it's dependencies
Return image base address of the module
"""
if name in self.unresolved_modules_names:
return self.module_name_to_base_address[name]
if fname is None:
raise RuntimeError("Cannot find module %r" % fname)

module_address = self.module_name_to_base_address.get(name, None)
if module_address is not None:
Expand Down

0 comments on commit 9cb6e22

Please sign in to comment.