about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCamille Mougey <commial@gmail.com>2015-02-10 13:30:01 +0100
committerCamille Mougey <commial@gmail.com>2015-02-10 13:30:01 +0100
commit541a89120f963a1a5cb7bc4e9808c33da982dfd2 (patch)
treeddc51b6a469ad77792f501f4f83c4ed734e617be
parentb9c7954bc3ec3ca237cdaee5fa9c859df3954383 (diff)
parentadd2aed8428f8bf1c92ee705222e496fc06cad07 (diff)
downloadmiasm-541a89120f963a1a5cb7bc4e9808c33da982dfd2.tar.gz
miasm-541a89120f963a1a5cb7bc4e9808c33da982dfd2.zip
Merge pull request #58 from serpilliere/fix_loader
Fix loader
-rw-r--r--miasm2/jitter/loader/pe.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/miasm2/jitter/loader/pe.py b/miasm2/jitter/loader/pe.py
index 6b19fc16..0b63583d 100644
--- a/miasm2/jitter/loader/pe.py
+++ b/miasm2/jitter/loader/pe.py
@@ -164,8 +164,9 @@ def vm_load_pe(vm, fdata, align_s=True, load_hdr=True, **kargs):
         # Update min and max addresses
         if min_addr is None or section.addr < min_addr:
             min_addr = section.addr
-        if max_addr is None or section.addr + section.size > max_addr:
-            max_addr = section.addr + max(section.size, len(section.data))
+        max_section_len = max(section.size, len(section.data))
+        if max_addr is None or section.addr + max_section_len > max_addr:
+            max_addr = section.addr + max_section_len
 
     min_addr = pe.rva2virt(min_addr)
     max_addr = pe.rva2virt(max_addr)
@@ -179,8 +180,8 @@ def vm_load_pe(vm, fdata, align_s=True, load_hdr=True, **kargs):
 
     # Copy each sections content in memory
     for section in pe.SHList:
-        log.debug('Map 0x%x bytes to 0x%x' % (len(s.data), pe.rva2virt(s.addr)))
-        vm.set_mem(pe.rva2virt(s.addr), str(s.data))
+        log.debug('Map 0x%x bytes to 0x%x' % (len(section.data), pe.rva2virt(section.addr)))
+        vm.set_mem(pe.rva2virt(section.addr), str(section.data))
 
     return pe