diff options
| author | serpilliere <devnull@localhost> | 2012-02-20 10:57:08 +0100 |
|---|---|---|
| committer | serpilliere <devnull@localhost> | 2012-02-20 10:57:08 +0100 |
| commit | 8334044b43aa619c44af5e5de4999f48df38b1c7 (patch) | |
| tree | 3e478f46b1d4f344eafb41771ac18b480d8e5fd8 | |
| parent | 7cd05b55b9171a8e54859cb88a51ab9d24aa4cca (diff) | |
| download | miasm-8334044b43aa619c44af5e5de4999f48df38b1c7.tar.gz miasm-8334044b43aa619c44af5e5de4999f48df38b1c7.zip | |
fix win api
Diffstat (limited to '')
| -rw-r--r-- | miasm/tools/pe_helper.py | 7 | ||||
| -rw-r--r-- | miasm/tools/win_api.py | 9 |
2 files changed, 12 insertions, 4 deletions
diff --git a/miasm/tools/pe_helper.py b/miasm/tools/pe_helper.py index 09b341e7..4f5373cf 100644 --- a/miasm/tools/pe_helper.py +++ b/miasm/tools/pe_helper.py @@ -384,6 +384,7 @@ class libimp: self.lib_imp2ad = {} self.lib_imp2dstad = {} self.fad2cname = {} + self.fad2info = {} def lib_get_add_base(self, name): name = name.lower() @@ -430,6 +431,7 @@ class libimp: name_inv = dict([(x[1], x[0]) for x in self.name2off.items()]) c_name = canon_libname_libfunc(name_inv[libad], imp_ord_or_name) self.fad2cname[ad] = c_name + self.fad2info[ad] = libad, imp_ord_or_name return ad def check_dst_ad(self): @@ -496,9 +498,10 @@ class libimp: name_inv = dict([(x[1], x[0]) for x in self.name2off.items()]) c_name = canon_libname_libfunc(name_inv[libad], imp_ord_or_name) self.fad2cname[ad] = c_name + self.fad2info[ad] = libad, imp_ord_or_name - def gen_new_lib(self, e): + def gen_new_lib(self, e, filter=lambda x: True): new_lib = [] for n, ad in self.name2off.items(): out_ads = dict() @@ -507,6 +510,8 @@ class libimp: out_ads[v] = k all_ads = self.lib_imp2dstad[ad].values() all_ads = reduce(lambda x,y:x+list(y), all_ads, []) + all_ads = [x for x in all_ads if filter(x)] + print [hex(x) for x in all_ads] all_ads.sort() #first, drop None if not all_ads: diff --git a/miasm/tools/win_api.py b/miasm/tools/win_api.py index f38522fd..cb562503 100644 --- a/miasm/tools/win_api.py +++ b/miasm/tools/win_api.py @@ -906,8 +906,11 @@ def kernel32_CreateMutex(funcname, get_str): print whoami(), hex(ret_ad), hex(mutexattr), hex(initowner), hex(lpname) - name = get_str(lpname) - print repr(name) + if lpname: + name = get_str(lpname) + print repr(name) + else: + name = None if name in winobjs.mutex: ret = 0 else: @@ -1030,7 +1033,7 @@ def kernel32_LoadLibraryW(): print whoami(), hex(ret_ad), hex(dllname) - libname = get_str_unic(dllname, 0x100) + libname = get_str_unic(dllname, 0x100)[::2] print repr(libname) eax = winobjs.runtime_dll.lib_get_add_base(libname) |