From 9cb6e2255852d4cbcf1fd821df186bdf63a7b740 Mon Sep 17 00:00:00 2001 From: Fabrice Desclaux Date: Mon, 2 Nov 2020 17:16:46 +0100 Subject: [PATCH] Add load resolved module --- miasm/analysis/sandbox.py | 2 +- miasm/jitter/loader/pe.py | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/miasm/analysis/sandbox.py b/miasm/analysis/sandbox.py index b145c48ca..e97b1d5f2 100644 --- a/miasm/analysis/sandbox.py +++ b/miasm/analysis/sandbox.py @@ -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 diff --git a/miasm/jitter/loader/pe.py b/miasm/jitter/loader/pe.py index a2ff96afb..10133de92 100644 --- a/miasm/jitter/loader/pe.py +++ b/miasm/jitter/loader/pe.py @@ -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: