From 484602ec143ce75ddfdda5f634e2a320339baf85 Mon Sep 17 00:00:00 2001 From: Ajax Date: Thu, 23 Jun 2016 17:14:19 +0200 Subject: Repercut EIP modification to PC (as 64 bits) --- miasm2/arch/x86/jit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miasm2/arch/x86/jit.py b/miasm2/arch/x86/jit.py index 5a9886c5..c4f6f128 100644 --- a/miasm2/arch/x86/jit.py +++ b/miasm2/arch/x86/jit.py @@ -81,7 +81,7 @@ class jitter_x86_32(jitter): return ret_ad, args def func_ret_stdcall(self, ret_addr, ret_value1=None, ret_value2=None): - self.cpu.EIP = ret_addr + self.pc = self.cpu.EIP = ret_addr if ret_value1 is not None: self.cpu.EAX = ret_value1 if ret_value2 is not None: -- cgit 1.4.1 From 655f7ec3f52ceb375b43a0f22f9a9af9ff1113ae Mon Sep 17 00:00:00 2001 From: Ajax Date: Thu, 23 Jun 2016 17:19:07 +0200 Subject: Allow breakpoints to act as generator This act likes a basic Python 3 `yield from...`. For instance, one can obtain a "stepping" breakpoint, yielding while a given condition is not resolved and then blocking the execution at a given state --- miasm2/jitter/jitload.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/miasm2/jitter/jitload.py b/miasm2/jitter/jitload.py index cc92b0cf..abc31840 100644 --- a/miasm2/jitter/jitload.py +++ b/miasm2/jitter/jitload.py @@ -2,7 +2,7 @@ import logging from functools import wraps -from collections import Sequence, namedtuple +from collections import Sequence, namedtuple, Iterator from miasm2.jitter.csts import * from miasm2.core.utils import * @@ -309,6 +309,12 @@ class jitter: old_pc = self.pc for res in self.breakpoints_handler.call_callbacks(self.pc, self): if res is not True: + if isinstance(res, collections.Iterator): + # If the breakpoint is a generator, yield it step by step + for tmp in res: + yield tmp + else: + yield res yield res # If a callback changed pc, re call every callback -- cgit 1.4.1 From aaa58042e3c7fc75e97ed7b9eaf4e4ce07b75d7d Mon Sep 17 00:00:00 2001 From: Ajax Date: Thu, 23 Jun 2016 17:26:15 +0200 Subject: Handle exceptions due to breakpoint side effects For instance, a `set_mem` may raise an automod handler --- miasm2/jitter/jitload.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/miasm2/jitter/jitload.py b/miasm2/jitter/jitload.py index abc31840..2371067d 100644 --- a/miasm2/jitter/jitload.py +++ b/miasm2/jitter/jitload.py @@ -315,6 +315,11 @@ class jitter: yield tmp else: yield res + + # Check exceptions (raised by breakpoints) + exception_flag = self.get_exception() + for res in self.exceptions_handler(exception_flag, self): + if res is not True: yield res # If a callback changed pc, re call every callback @@ -327,7 +332,7 @@ class jitter: # Run the bloc at PC self.pc = self.runbloc(self.pc) - # Check exceptions + # Check exceptions (raised by the execution of the block) exception_flag = self.get_exception() for res in self.exceptions_handler(exception_flag, self): if res is not True: -- cgit 1.4.1