about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorPierre LALET <pierre.lalet@cea.fr>2015-06-28 18:13:58 +0200
committerPierre LALET <pierre.lalet@cea.fr>2015-06-28 18:19:06 +0200
commit5055ac3ae8c6c2a7a65d44d1a46ff964d63e8b41 (patch)
tree0495661f91edce5d899d07053b152b73e92e1171
parent1bb328a8922f8b2220529f0a61c1f50f94bbc367 (diff)
downloadmiasm-5055ac3ae8c6c2a7a65d44d1a46ff964d63e8b41.tar.gz
miasm-5055ac3ae8c6c2a7a65d44d1a46ff964d63e8b41.zip
os_dep: PEP8 compliance
-rw-r--r--miasm2/os_dep/common.py8
-rw-r--r--miasm2/os_dep/win_api_x86_32.py87
2 files changed, 50 insertions, 45 deletions
diff --git a/miasm2/os_dep/common.py b/miasm2/os_dep/common.py
index 9f0d2fa2..7f8caed1 100644
--- a/miasm2/os_dep/common.py
+++ b/miasm2/os_dep/common.py
@@ -9,7 +9,7 @@ def get_str_ansi(jitter, ad_str, max_char=None):
     l = 0
     tmp = ad_str
     while ((max_char is None or l < max_char) and
-        jitter.vm.get_mem(tmp, 1) != "\x00"):
+           jitter.vm.get_mem(tmp, 1) != "\x00"):
         tmp += 1
         l += 1
     return jitter.vm.get_mem(ad_str, l)
@@ -19,7 +19,7 @@ def get_str_unic(jitter, ad_str, max_char=None):
     l = 0
     tmp = ad_str
     while ((max_char is None or l < max_char) and
-        jitter.vm.get_mem(tmp, 2) != "\x00\x00"):
+           jitter.vm.get_mem(tmp, 2) != "\x00\x00"):
         tmp += 2
         l += 2
     s = jitter.vm.get_mem(ad_str, l)
@@ -36,13 +36,14 @@ def set_str_unic(s):
     # TODO: real unicode encoding
     return "\x00".join(list(s)) + '\x00' * 3
 
+
 class heap(object):
     "Light heap simulation"
 
     addr = 0x20000000
     align = 0x1000
     size = 32
-    mask = (1<< size) - 1
+    mask = (1 << size) - 1
 
     def next_addr(self, size):
         """
@@ -54,7 +55,6 @@ class heap(object):
         self.addr &= self.mask ^ (self.align - 1)
         return ret
 
-
     def alloc(self, jitter, size):
         """
         @jitter: a jitter instance
diff --git a/miasm2/os_dep/win_api_x86_32.py b/miasm2/os_dep/win_api_x86_32.py
index f54cc8ea..e30ff21f 100644
--- a/miasm2/os_dep/win_api_x86_32.py
+++ b/miasm2/os_dep/win_api_x86_32.py
@@ -712,15 +712,16 @@ def kernel32_VirtualAlloc(jitter):
     ret_ad, args = jitter.func_args_stdcall(['lpvoid', 'dwsize',
                                              'alloc_type', 'flprotect'])
 
-    access_dict = {0x0: 0,
-                   0x1: 0,
-                   0x2: PAGE_READ,
-                   0x4: PAGE_READ | PAGE_WRITE,
-                   0x10: PAGE_EXEC,
-                   0x20: PAGE_EXEC | PAGE_READ,
-                   0x40: PAGE_EXEC | PAGE_READ | PAGE_WRITE,
-                   0x100: 0
-                       }
+    access_dict = {
+        0x0: 0,
+        0x1: 0,
+        0x2: PAGE_READ,
+        0x4: PAGE_READ | PAGE_WRITE,
+        0x10: PAGE_EXEC,
+        0x20: PAGE_EXEC | PAGE_READ,
+        0x40: PAGE_EXEC | PAGE_READ | PAGE_WRITE,
+        0x100: 0,
+    }
 
     # access_dict_inv = dict([(x[1], x[0]) for x in access_dict.items()])
 
@@ -767,13 +768,13 @@ def kernel32_GetModuleFileName(jitter, funcname, set_str):
     if args.hmodule in [0, winobjs.hcurmodule]:
         p = winobjs.module_path[:]
     elif (winobjs.runtime_dll and
-        args.hmodule in winobjs.runtime_dll.name2off.values()):
+          args.hmodule in winobjs.runtime_dll.name2off.values()):
         name_inv = dict([(x[1], x[0])
                         for x in winobjs.runtime_dll.name2off.items()])
         p = name_inv[args.hmodule]
     else:
-        log.warning(('Unknown module 0x%x.' + \
-                        'Set winobjs.hcurmodule and retry'), args.hmodule)
+        log.warning(('Unknown module 0x%x.' +
+                     'Set winobjs.hcurmodule and retry'), args.hmodule)
         p = None
 
     if p is None:
@@ -1682,15 +1683,16 @@ def ntdll_ZwAllocateVirtualMemory(jitter):
     # ad = upck32(jitter.vm.get_mem(args.lppvoid, 4))
     dwsize = upck32(jitter.vm.get_mem(args.pdwsize, 4))
 
-    access_dict = {0x0: 0,
-                   0x1: 0,
-                   0x2: PAGE_READ,
-                   0x4: PAGE_READ | PAGE_WRITE,
-                   0x10: PAGE_EXEC,
-                   0x20: PAGE_EXEC | PAGE_READ,
-                   0x40: PAGE_EXEC | PAGE_READ | PAGE_WRITE,
-                   0x100: 0
-                       }
+    access_dict = {
+        0x0: 0,
+        0x1: 0,
+        0x2: PAGE_READ,
+        0x4: PAGE_READ | PAGE_WRITE,
+        0x10: PAGE_EXEC,
+        0x20: PAGE_EXEC | PAGE_READ,
+        0x40: PAGE_EXEC | PAGE_READ | PAGE_WRITE,
+        0x100: 0,
+    }
 
     # access_dict_inv = dict([(x[1], x[0]) for x in access_dict.items()])
 
@@ -2203,15 +2205,16 @@ def kernel32_MapViewOfFile(jitter):
     length = len(data)
 
     log.debug('mapp total: %x', len(data))
-    access_dict = {0x0: 0,
-                   0x1: 0,
-                   0x2: PAGE_READ,
-                   0x4: PAGE_READ | PAGE_WRITE,
-                   0x10: PAGE_EXEC,
-                   0x20: PAGE_EXEC | PAGE_READ,
-                   0x40: PAGE_EXEC | PAGE_READ | PAGE_WRITE,
-                   0x100: 0
-                       }
+    access_dict = {
+        0x0: 0,
+        0x1: 0,
+        0x2: PAGE_READ,
+        0x4: PAGE_READ | PAGE_WRITE,
+        0x10: PAGE_EXEC,
+        0x20: PAGE_EXEC | PAGE_READ,
+        0x40: PAGE_EXEC | PAGE_READ | PAGE_WRITE,
+        0x100: 0,
+    }
     # access_dict_inv = dict([(x[1], x[0]) for x in access_dict.items()])
 
     if not args.flprotect in access_dict:
@@ -2289,15 +2292,16 @@ def kernel32_GetDiskFreeSpaceW(jitter):
 def kernel32_VirtualQuery(jitter):
     ret_ad, args = jitter.func_args_stdcall(["ad", "lpbuffer", "dwl"])
 
-    access_dict = {0x0: 0,
-                   0x1: 0,
-                   0x2: PAGE_READ,
-                   0x4: PAGE_READ | PAGE_WRITE,
-                   0x10: PAGE_EXEC,
-                   0x20: PAGE_EXEC | PAGE_READ,
-                   0x40: PAGE_EXEC | PAGE_READ | PAGE_WRITE,
-                   0x100: 0
-               }
+    access_dict = {
+        0x0: 0,
+        0x1: 0,
+        0x2: PAGE_READ,
+        0x4: PAGE_READ | PAGE_WRITE,
+        0x10: PAGE_EXEC,
+        0x20: PAGE_EXEC | PAGE_READ,
+        0x40: PAGE_EXEC | PAGE_READ | PAGE_WRITE,
+        0x100: 0,
+    }
     access_dict_inv = dict([(x[1], x[0]) for x in access_dict.iteritems()])
 
     all_mem = jitter.vm.get_all_memory()
@@ -2721,15 +2725,16 @@ def msvcrt_myfopen(jitter, func):
         #pdw(0x11112222)
         jitter.vm.set_mem(alloc_addr, pp)
 
-
     else:
-        raise ValueError('unknown access mode %s'%rw)
+        raise ValueError('unknown access mode %s' % rw)
 
     jitter.func_ret_cdecl(ret_ad, alloc_addr)
 
+
 def msvcrt__wfopen(jitter):
     msvcrt_myfopen(jitter, get_str_unic)
 
+
 def msvcrt_fopen(jitter):
     msvcrt_myfopen(jitter, get_str_ansi)