diff options
| -rw-r--r-- | example/disasm/full.py | 2 | ||||
| -rw-r--r-- | miasm/arch/aarch64/sem.py | 1 | ||||
| -rw-r--r-- | miasm/arch/x86/arch.py | 2 | ||||
| -rw-r--r-- | miasm/arch/x86/sem.py | 2 | ||||
| -rw-r--r-- | miasm/core/asmblock.py | 5 | ||||
| -rw-r--r-- | miasm/expression/expression.py | 5 | ||||
| -rw-r--r-- | miasm/jitter/llvmconvert.py | 4 | ||||
| -rw-r--r-- | miasm/jitter/loader/utils.py | 2 | ||||
| -rw-r--r-- | miasm/os_dep/win_api_x86_32.py | 6 | ||||
| -rw-r--r-- | test/analysis/unssa.py | 1 | ||||
| -rw-r--r-- | test/arch/x86/arch.py | 4 | ||||
| -rw-r--r-- | test/expression/simplifications.py | 7 |
12 files changed, 31 insertions, 10 deletions
diff --git a/example/disasm/full.py b/example/disasm/full.py index f7268ad0..a28d548e 100644 --- a/example/disasm/full.py +++ b/example/disasm/full.py @@ -279,7 +279,7 @@ if args.gen_ir: raise RuntimeError("Your graph should have only one head") ssa = SSADiGraph(ircfg_a) ssa.transform(head) - open("ssa.dot", "wb").write(ircfg_a.dot()) + open("ssa.dot", "w").write(ircfg_a.dot()) if args.propagexpr: diff --git a/miasm/arch/aarch64/sem.py b/miasm/arch/aarch64/sem.py index e7db4782..e9088bde 100644 --- a/miasm/arch/aarch64/sem.py +++ b/miasm/arch/aarch64/sem.py @@ -1502,3 +1502,4 @@ class ir_aarch64b(ir_aarch64l): self.pc = PC self.sp = SP self.IRDst = ExprId('IRDst', 64) + self.addrsize = 64 diff --git a/miasm/arch/x86/arch.py b/miasm/arch/x86/arch.py index 3a797d0b..8a19ed61 100644 --- a/miasm/arch/x86/arch.py +++ b/miasm/arch/x86/arch.py @@ -3795,6 +3795,8 @@ addop("movmskps", [bs8(0x0f), bs8(0x50), no_xmm_pref] + addop("movmskpd", [bs8(0x0f), bs8(0x50), pref_66] + rmmod(reg_modrm, rm_arg_xmm_reg)) +addop("movnti", [bs8(0x0f), bs8(0xc3)] + rmmod(rmreg), [rm_arg, rmreg]) + addop("addss", [bs8(0x0f), bs8(0x58), pref_f3] + rmmod(xmm_reg, rm_arg_xmm_m32)) addop("addsd", [bs8(0x0f), bs8(0x58), pref_f2] + rmmod(xmm_reg, rm_arg_xmm_m64)) diff --git a/miasm/arch/x86/sem.py b/miasm/arch/x86/sem.py index e59a9b18..69e412b9 100644 --- a/miasm/arch/x86/sem.py +++ b/miasm/arch/x86/sem.py @@ -5786,7 +5786,7 @@ class ir_x86_16(IntermediateRepresentation): instr.name.lower()](self, instr, *args) self.mod_pc(instr, instr_ir, extra_ir) instr.additional_info.except_on_instr = False - if instr.additional_info.g1.value & 6 == 0 or \ + if instr.additional_info.g1.value & 14 == 0 or \ not instr.name in repeat_mn: return instr_ir, extra_ir if instr.name == "MOVSD" and len(instr.args) == 2: diff --git a/miasm/core/asmblock.py b/miasm/core/asmblock.py index 591f8e9a..a92e5bf9 100644 --- a/miasm/core/asmblock.py +++ b/miasm/core/asmblock.py @@ -1585,7 +1585,7 @@ class disasmEngine(object): warnings.warn('DEPRECATION WARNING: use "dis_block" instead of "dis_bloc"') return self.dis_block(offset) - def dis_multiblock(self, offset, blocks=None): + def dis_multiblock(self, offset, blocks=None, job_done=None): """Disassemble every block reachable from @offset regarding specific disasmEngine conditions Return an AsmCFG instance containing disassembled blocks @@ -1594,7 +1594,8 @@ class disasmEngine(object): merge with """ log_asmblock.info("dis block all") - job_done = set() + if job_done is None: + job_done = set() if blocks is None: blocks = AsmCFG(self.loc_db) todo = [offset] diff --git a/miasm/expression/expression.py b/miasm/expression/expression.py index 6f171d93..93094979 100644 --- a/miasm/expression/expression.py +++ b/miasm/expression/expression.py @@ -654,7 +654,10 @@ class ExprLoc(Expr): return str(self._loc_key) def get_r(self, mem_read=False, cst_read=False): - return set() + if cst_read: + return set([self]) + else: + return set() def get_w(self): return set() diff --git a/miasm/jitter/llvmconvert.py b/miasm/jitter/llvmconvert.py index d23f075b..e3a0e8c2 100644 --- a/miasm/jitter/llvmconvert.py +++ b/miasm/jitter/llvmconvert.py @@ -1210,7 +1210,9 @@ class LLVMFunction(object): if isinstance(expr, ExprMem): addr = self.add_ir(expr.ptr) - return self.llvm_context.memory_lookup(self, addr, expr.size) + ret = self.llvm_context.memory_lookup(self, addr, expr.size) + self.update_cache(expr, ret) + return ret if isinstance(expr, ExprCond): # Compute cond diff --git a/miasm/jitter/loader/utils.py b/miasm/jitter/loader/utils.py index d03adc8a..b165960d 100644 --- a/miasm/jitter/loader/utils.py +++ b/miasm/jitter/loader/utils.py @@ -13,7 +13,7 @@ log.setLevel(logging.DEBUG) def canon_libname_libfunc(libname, libfunc): assert isinstance(libname, basestring) - assert isinstance(libfunc, basestring) or isinstance(libfunc, int) + assert isinstance(libfunc, basestring) or isinstance(libfunc, int_types) dn = libname.split('.')[0] if isinstance(libfunc, int_types): return str(dn), libfunc diff --git a/miasm/os_dep/win_api_x86_32.py b/miasm/os_dep/win_api_x86_32.py index 051cedb5..7abd03b7 100644 --- a/miasm/os_dep/win_api_x86_32.py +++ b/miasm/os_dep/win_api_x86_32.py @@ -868,14 +868,14 @@ def kernel32_CreateMutex(jitter, funcname, get_str): raise NotImplementedError("Untested case") # ret = 0 else: - winobjs.mutex[name] = id(name) + winobjs.mutex[name] = id(name) & 0xFFFFFFFF ret = winobjs.mutex[name] else: if name in winobjs.mutex: raise NotImplementedError("Untested case") # ret = 0 else: - winobjs.mutex[name] = id(name) + winobjs.mutex[name] = id(name) & 0xFFFFFFFF ret = winobjs.mutex[name] jitter.func_ret_stdcall(ret_ad, ret) @@ -1670,7 +1670,7 @@ def my_CreateEvent(jitter, funcname, get_str): winobjs.events_pool[s] = (args.bmanualreset, args.binitialstate) else: log.warning('WARNING: known event') - jitter.func_ret_stdcall(ret_ad, id(s)) + jitter.func_ret_stdcall(ret_ad, id(s) & 0xFFFFFFFF) def kernel32_CreateEventA(jitter): diff --git a/test/analysis/unssa.py b/test/analysis/unssa.py index 55ceac9e..2bfe9254 100644 --- a/test/analysis/unssa.py +++ b/test/analysis/unssa.py @@ -82,6 +82,7 @@ class IRATest(ira): super(IRATest, self).__init__(arch, 32, loc_db) self.IRDst = IRDst self.ret_reg = r + self.addrsize = 32 def get_out_regs(self, xx): out = set() diff --git a/test/arch/x86/arch.py b/test/arch/x86/arch.py index 68a14036..0455462d 100644 --- a/test/arch/x86/arch.py +++ b/test/arch/x86/arch.py @@ -1538,6 +1538,10 @@ reg_tests = [ (m64, "00000000 MOVSXD R8, EAX", "4c63c0"), + (m32, "XXXXXXXX MOVNTI DWORD PTR [ECX + 0xFFFFFFFC], EDX", + "0fc351fc"), + (m64, "XXXXXXXX MOVNTI QWORD PTR [RCX + 0xFFFFFFFFFFFFFFFC], R10", + "4C0FC351FC"), (m32, "00000000 MUL BYTE PTR [EAX]", "f620"), diff --git a/test/expression/simplifications.py b/test/expression/simplifications.py index e0b666da..de059075 100644 --- a/test/expression/simplifications.py +++ b/test/expression/simplifications.py @@ -515,6 +515,13 @@ to_test = [ ExprOp(TOK_EQUAL, a , i3) ), + + ( + ExprOp(TOK_EQUAL, ExprOp("^", a, b, i2), i1), + ExprOp(TOK_EQUAL, a^b , i3) + ), + + (ExprOp(TOK_INF_SIGNED, i1, i2), ExprInt(1, 1)), (ExprOp(TOK_INF_UNSIGNED, i1, i2), ExprInt(1, 1)), (ExprOp(TOK_INF_EQUAL_SIGNED, i1, i2), ExprInt(1, 1)), |