@@ -46,7 +46,7 @@ def __init__(self):
4646 winproxy .AddVectoredExceptionHandler (0 , self .callback_vectored )
4747 self .setup_hxbp_callback_vectored = winexception .VectoredException (self .setup_hxbp_callback )
4848 self .hxbp_info = None
49- self .code = windows .native_exec .create_function ("\xcc \xc3 " , [PVOID ])
49+ self .code = windows .native_exec .create_function (b "\xcc \xc3 " , [PVOID ])
5050 self .veh_depth = 0
5151 self .current_exception = None
5252 self .exceptions_stack = [None ]
@@ -128,7 +128,7 @@ def handle_exception(self, exc):
128128 bp , single_step = self ._reput_breakpoint [windows .current_thread .tid ]
129129 self ._memory_save [bp ._addr ] = windows .current_process .read_memory (bp ._addr , 1 )
130130 with windows .utils .VirtualProtected (bp ._addr , 1 , PAGE_EXECUTE_READWRITE ):
131- windows .current_process .write_memory (bp ._addr , "\xcc " )
131+ windows .current_process .write_memory (bp ._addr , b "\xcc " )
132132 del self ._reput_breakpoint [windows .current_thread .tid ]
133133 if single_step :
134134 return self .on_exception (exc )
@@ -184,7 +184,7 @@ def add_bp(self, bp, target=None):
184184 self .breakpoints [addr ] = bp
185185 self ._memory_save [addr ] = windows .current_process .read_memory (addr , 1 )
186186 with windows .utils .VirtualProtected (addr , 1 , PAGE_EXECUTE_READWRITE ):
187- windows .current_process .write_memory (addr , "\xcc " )
187+ windows .current_process .write_memory (addr , b "\xcc " )
188188 return
189189
190190 def add_bp_hxbp (self , bp , targets = None ):
@@ -204,16 +204,18 @@ def add_bp_hxbp(self, bp, targets=None):
204204 def setup_hxbp_callback (self , exc ):
205205 with self .NewCurrentException (exc ):
206206 exp_code = self .get_exception_code ()
207+ if exp_code != windef .EXCEPTION_BREAKPOINT :
208+ return windef .EXCEPTION_CONTINUE_SEARCH
207209 context = self .get_exception_context ()
208210 exp_addr = context .pc
209211 hxbp_used = self .setup_hxbp_in_context (context , self .data )
210- windows .current_process .write_memory (exp_addr , "\x90 " )
212+ windows .current_process .write_memory (exp_addr , b "\x90 " )
211213 # Raising in the VEH is a bad idea..
212214 # So better give the information to triggerer..
213215 if hxbp_used is not None :
214- self .get_exception_context ().Eax = exp_addr
216+ self .get_exception_context ().func_result = exp_addr
215217 else :
216- self .get_exception_context ().Eax = 0
218+ self .get_exception_context ().func_result = 0
217219 return windef .EXCEPTION_CONTINUE_EXECUTION
218220
219221 def remove_hxbp_callback (self , exc ):
@@ -222,7 +224,7 @@ def remove_hxbp_callback(self, exc):
222224 context = self .get_exception_context ()
223225 exp_addr = context .pc
224226 hxbp_used = self .remove_hxbp_in_context (context , self .data )
225- windows .current_process .write_memory (exp_addr , "\x90 " )
227+ windows .current_process .write_memory (exp_addr , b "\x90 " )
226228 # Raising in the VEH is a bad idea..
227229 # So better give the information to triggerer..
228230 if hxbp_used is not None :
@@ -267,7 +269,7 @@ def setup_hxbp_self_thread(self, addr):
267269 x = self .code ()
268270 if x is None :
269271 raise ValueError ("Could not setup HXBP" )
270- windows .current_process .write_memory (x , "\xcc " )
272+ windows .current_process .write_memory (x , b "\xcc " )
271273 return
272274
273275 def setup_hxbp_other_thread (self , addr , thread ):
@@ -290,7 +292,7 @@ def remove_hxbp_self_thread(self, addr):
290292 x = self .code ()
291293 if x is None :
292294 raise ValueError ("Could not remove HXBP" )
293- windows .current_process .write_memory (x , "\xcc " )
295+ windows .current_process .write_memory (x , b "\xcc " )
294296 return
295297
296298 def remove_hxbp_other_thread (self , addr , thread ):
0 commit comments