about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--miasm2/analysis/sandbox.py2
-rw-r--r--miasm2/core/utils.py13
-rw-r--r--miasm2/jitter/jitload.py16
-rw-r--r--miasm2/jitter/loader/pe.py3
-rw-r--r--miasm2/os_dep/common.py5
-rw-r--r--miasm2/os_dep/win_api_x86_32_seh.py7
6 files changed, 25 insertions, 21 deletions
diff --git a/miasm2/analysis/sandbox.py b/miasm2/analysis/sandbox.py
index aae8aac1..5132406c 100644
--- a/miasm2/analysis/sandbox.py
+++ b/miasm2/analysis/sandbox.py
@@ -164,7 +164,7 @@ class OS_Win(OS):
     ALL_IMP_DLL = ["ntdll.dll", "kernel32.dll", "user32.dll",
                    "ole32.dll", "urlmon.dll",
                    "ws2_32.dll", 'advapi32.dll', "psapi.dll",
-               ]
+                   ]
     modules_path = "win_dll"
 
     def __init__(self, custom_methods, *args, **kwargs):
diff --git a/miasm2/core/utils.py b/miasm2/core/utils.py
index 0512f4aa..35ddbb82 100644
--- a/miasm2/core/utils.py
+++ b/miasm2/core/utils.py
@@ -13,10 +13,12 @@ pck32 = lambda x: struct.pack('I', x)
 pck64 = lambda x: struct.pack('Q', x)
 
 
-pck = {8:pck8,
-       16:pck16,
-       32:pck32,
-       64:pck64}
+pck = {8: pck8,
+       16: pck16,
+       32: pck32,
+       64: pck64}
+
+
 def get_caller_name(caller_num=0):
     """Get the nth caller's name
     @caller_num: 0 = the caller of get_caller_name, 1 = next parent, ..."""
@@ -63,6 +65,7 @@ class keydefaultdict(collections.defaultdict):
 
 
 class BoundedDict(UserDict.DictMixin):
+
     """Limited in size dictionary.
 
     To reduce combinatory cost, once an upper limit @max_size is reached,
@@ -104,7 +107,7 @@ class BoundedDict(UserDict.DictMixin):
                         self._delete_cb(key)
 
                 # Keep only the most @_min_size used
-                self._data = {key:self._data[key]
+                self._data = {key: self._data[key]
                               for key, _ in most_common[:self._min_size - 1]}
                 self._size = self._min_size
 
diff --git a/miasm2/jitter/jitload.py b/miasm2/jitter/jitload.py
index 312dcb2e..05a8575e 100644
--- a/miasm2/jitter/jitload.py
+++ b/miasm2/jitter/jitload.py
@@ -21,7 +21,6 @@ log_func.addHandler(hnd)
 log_func.setLevel(logging.CRITICAL)
 
 
-
 try:
     from miasm2.jitter.jitcore_tcc import JitCore_Tcc
 except ImportError:
@@ -60,10 +59,11 @@ def named_arguments(func):
             arg_vals = namedtuple("args", args)(*arg_vals)
             # func_name(arguments) return address
             log_func.info('%s(%s) ret addr: %s',
-                get_caller_name(1),
-                ', '.join("%s=0x%x" % (field, value)
-                          for field, value in arg_vals._asdict().iteritems()),
-                hex(ret_ad))
+                          get_caller_name(1),
+                          ', '.join("%s=0x%x" % (field, value)
+                                    for field, value in arg_vals._asdict(
+                                    ).iteritems()),
+                         hex(ret_ad))
             return ret_ad, namedtuple("args", args)(*arg_vals)
         else:
             ret_ad, arg_vals = func(self, args)
@@ -233,7 +233,6 @@ class jitter:
         self.stack_size = 0x10000
         self.stack_base = 0x1230000
 
-
         # Init callback handler
         self.breakpoints_handler = CallbackHandler()
         self.exceptions_handler = CallbackHandlerBitflag()
@@ -270,7 +269,6 @@ class jitter:
         self.jit.addr_mod = interval([(addr, addr)])
         self.jit.updt_automod_code(self.vm)
 
-
     def set_breakpoint(self, addr, *args):
         """Set callbacks associated with addr.
         @addr: breakpoint address
@@ -383,7 +381,7 @@ class jitter:
         l = 0
         tmp = addr
         while ((max_char is None or l < max_char) and
-            self.vm.get_mem(tmp, 1) != "\x00"):
+               self.vm.get_mem(tmp, 1) != "\x00"):
             tmp += 1
             l += 1
         return self.vm.get_mem(addr, l)
@@ -395,7 +393,7 @@ class jitter:
         l = 0
         tmp = addr
         while ((max_char is None or l < max_char) and
-            self.vm.get_mem(tmp, 2) != "\x00\x00"):
+               self.vm.get_mem(tmp, 2) != "\x00\x00"):
             tmp += 2
             l += 2
         s = self.vm.get_mem(addr, l)
diff --git a/miasm2/jitter/loader/pe.py b/miasm2/jitter/loader/pe.py
index c40e8e38..2d80c8df 100644
--- a/miasm2/jitter/loader/pe.py
+++ b/miasm2/jitter/loader/pe.py
@@ -485,7 +485,8 @@ def vm_load_pe_and_dependencies(vm, fname, name2module, runtime_lib,
             try:
                 with open(fname) as fstream:
                     log.info('Loading module name %r', fname)
-                    pe_obj = vm_load_pe(vm, fstream.read(), name=fname, **kwargs)
+                    pe_obj = vm_load_pe(
+                        vm, fstream.read(), name=fname, **kwargs)
             except IOError:
                 log.error('Cannot open %s' % fname)
                 name2module[name] = None
diff --git a/miasm2/os_dep/common.py b/miasm2/os_dep/common.py
index 9c0377a9..ecb6d821 100644
--- a/miasm2/os_dep/common.py
+++ b/miasm2/os_dep/common.py
@@ -39,6 +39,7 @@ def set_str_unic(s):
 
 
 class heap(object):
+
     "Light heap simulation"
 
     addr = 0x20000000
@@ -56,7 +57,7 @@ class heap(object):
         self.addr &= self.mask ^ (self.align - 1)
         return ret
 
-    def alloc(self, jitter, size, perm=PAGE_READ|PAGE_WRITE):
+    def alloc(self, jitter, size, perm=PAGE_READ | PAGE_WRITE):
         """
         @jitter: a jitter instance
         @size: the size to allocate
@@ -64,7 +65,7 @@ class heap(object):
         """
         return self.vm_alloc(jitter.vm, size, perm)
 
-    def vm_alloc(self, vm, size, perm=PAGE_READ|PAGE_WRITE):
+    def vm_alloc(self, vm, size, perm=PAGE_READ | PAGE_WRITE):
         """
         @vm: a VmMngr instance
         @size: the size to allocate
diff --git a/miasm2/os_dep/win_api_x86_32_seh.py b/miasm2/os_dep/win_api_x86_32_seh.py
index 68a694f8..f90198f9 100644
--- a/miasm2/os_dep/win_api_x86_32_seh.py
+++ b/miasm2/os_dep/win_api_x86_32_seh.py
@@ -279,14 +279,14 @@ def create_modules_chain(jitter, name2module):
         m_o += "\x00" * 3
         jitter.vm.add_memory_page(
             addr + offset_name, PAGE_READ | PAGE_WRITE, m_o,
-        "Module name %r" % bname_str)
+            "Module name %r" % bname_str)
 
         m_o = ""
         m_o += "\x00".join(bpath) + "\x00"
         m_o += "\x00" * 3
         jitter.vm.add_memory_page(
             addr + offset_path, PAGE_READ | PAGE_WRITE, m_o,
-        "Module path %r" % bname_str)
+            "Module path %r" % bname_str)
 
     return modules_info
 
@@ -306,7 +306,8 @@ def fix_InLoadOrderModuleList(jitter, modules_info):
     dummy_pe = modules_info.name2module.get("", None)
     special_modules = [main_pe, kernel32_pe, ntdll_pe, dummy_pe]
     if not all(special_modules):
-        log.warn('No main pe, ldr data will be unconsistant %r', special_modules)
+        log.warn(
+            'No main pe, ldr data will be unconsistant %r', special_modules)
         loaded_modules = modules_info.modules
     else:
         loaded_modules = [module for module in modules_info.modules