@@ -86,7 +86,7 @@ def __del__(self):
8686
8787 def get_last_breakpoint_address (self ):
8888 addr = c_ulonglong ()
89- if self .dll .get_last_breakpoint_address (byref (addr )) != 0 :
89+ if self .dll .get_last_breakpoint_address (byref (addr ), None ) != 0 :
9090 raise DebugAdapter .GeneralError ("retrieving last breakpoint address" )
9191 return addr .value
9292
@@ -102,7 +102,7 @@ def get_last_exception_info(self):
102102 # DWORD64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
103103 #} EXCEPTION_RECORD64, *PEXCEPTION_RECORD64;
104104 record = create_string_buffer (4 + 4 + 8 + 8 + 4 + 4 + 8 * 15 )
105- self .dll .get_exception_record64 (record )
105+ self .dll .get_exception_record64 (record , None )
106106 (ExceptionCode , ExceptionFlags , ExceptionRecord , ExceptionAddress , NumberParameters ) = \
107107 unpack ('<IIQQI' , record [0 :28 ])
108108
@@ -115,7 +115,7 @@ def get_last_exception_info(self):
115115
116116 def get_exec_status (self ):
117117 status = c_ulong ()
118- if self .dll .get_exec_status (byref (status )) != 0 :
118+ if self .dll .get_exec_status (byref (status ), None ) != 0 :
119119 raise DebugAdapter .GeneralError ("retrieving execution status" )
120120 return DEBUG_STATUS (status .value )
121121
@@ -152,7 +152,7 @@ def thunk_stop_reason(self):
152152
153153 if status == DEBUG_STATUS .NO_DEBUGGEE :
154154 code = c_ulong ()
155- if self .dll .get_exit_code (byref (code )) != 0 :
155+ if self .dll .get_exit_code (byref (code ), None ) != 0 :
156156 raise DebugAdapter .GeneralError ("retrieving exit code" )
157157 return (DebugAdapter .STOP_REASON .PROCESS_EXITED , code .value )
158158
@@ -165,6 +165,8 @@ def thunk_stop_reason(self):
165165
166166 # session start/stop
167167 def exec (self , fpath , args , terminal = False ):
168+ errmsg = create_string_buffer (4096 )
169+
168170 def enclose (s ):
169171 return s if s .startswith ('"' ) and s .endswith ('"' ) else '"%s"' % s
170172
@@ -178,31 +180,31 @@ def enclose(s):
178180
179181 # ask dll to create process
180182 cmdline_ = c_char_p (cmdline .encode ('utf-8' ))
181- rc = self .dll .process_start (cmdline_ )
183+ rc = self .dll .process_start (cmdline_ , byref ( errmsg ) )
182184 if rc :
183- raise DebugAdapter .ProcessStartError ('dbgeng adapter returned %d' % rc )
185+ raise DebugAdapter .ProcessStartError (errmsg . value . decode ( 'utf-8' ) )
184186
185187 self .target_path_ = fpath
186188
187189 def attach (self , pid ):
188- if self .dll .process_attach (target ):
190+ if self .dll .process_attach (target , None ):
189191 raise Exception ('unable to attach to pid %d' % pid )
190192
191193 def detach (self ):
192- self .dll .process_detach ()
194+ self .dll .process_detach (None )
193195
194196 def quit (self ):
195197 status = self .get_exec_status ()
196198
197199 if status == DEBUG_STATUS .NO_DEBUGGEE :
198200 pass
199201 elif status == DEBUG_STATUS .BREAK :
200- self .dll .quit ()
202+ self .dll .quit (None )
201203 else :
202204 # targets waiting on I/O have considerable time before interrupt
203205 # request moves them to BREAK state
204206 for i in range (20 ):
205- self .dll .break_into ()
207+ self .dll .break_into (None )
206208 time .sleep (.1 )
207209 if self .get_exec_status () == DEBUG_STATUS .BREAK :
208210 break
@@ -212,7 +214,7 @@ def quit(self):
212214 # target info
213215 def target_arch (self ):
214216 proc_type = c_ulong ()
215- if self .dll .get_executing_processor_type (byref (proc_type )) != 0 :
217+ if self .dll .get_executing_processor_type (byref (proc_type ), None ) != 0 :
216218 raise Exception ('unable to get executing processor type' )
217219 proc_type = proc_type .value
218220
@@ -232,41 +234,41 @@ def target_path(self):
232234
233235 def target_pid (self ):
234236 pid = c_ulong ();
235- if self .dll .get_pid (byref (pid )) != 0 :
237+ if self .dll .get_pid (byref (pid ), None ) != 0 :
236238 raise DebugAdapter .GeneralError ("retrieving process id" )
237239 return pid .value
238240
239241 def target_base (self ):
240242 base = c_ulonglong ();
241- if self .dll .get_image_base (byref (base )) != 0 :
243+ if self .dll .get_image_base (byref (base ), None ) != 0 :
242244 raise DebugAdapter .GeneralError ("retrieving image base" )
243245 return base .value
244246
245247 # threads
246248 def thread_list (self ):
247- threads_n = self .dll .get_number_threads ()
249+ threads_n = self .dll .get_number_threads (None )
248250 if threads_n < 0 :
249251 raise DebugAdapter .GeneralError ("retrieving thread list" )
250252 return list (range (threads_n ))
251253
252254 def thread_selected (self ):
253- tid = self .dll .get_current_thread ()
255+ tid = self .dll .get_current_thread (None )
254256 if tid < 0 :
255257 raise DebugAdapter .GeneralError ("retrieving selected thread" )
256258 return tid
257259
258260 def thread_select (self , tid ):
259- rc = self .dll .set_current_thread (tid )
261+ rc = self .dll .set_current_thread (tid , None )
260262 if rc < 0 :
261263 raise DebugAdapter .GeneralError ("selecting thread" )
262264
263265 # breakpoints
264266 def breakpoint_set (self , addr ):
265267 pfunc = self .dll .breakpoint_set
266268 pfunc .restype = c_int
267- pfunc .argtypes = [c_ulonglong , POINTER (c_ulong )]
269+ pfunc .argtypes = [c_ulonglong , POINTER (c_ulong ), c_char_p ]
268270 bpid = c_ulong ();
269- rc = pfunc (addr , byref (bpid ))
271+ rc = pfunc (addr , byref (bpid ), None )
270272 if rc != 0 :
271273 raise DebugAdapter .BreakpointSetError ('bp at 0x%X, dll returned %d' % (addr , rc ))
272274 self .bp_addr_to_id [addr ] = bpid .value
@@ -275,7 +277,7 @@ def breakpoint_clear(self, addr):
275277 if not addr in self .bp_addr_to_id :
276278 raise DebugAdapter .BreakpointClearError ('bp at addr not 0x%X found' % addr )
277279 bpid = self .bp_addr_to_id [addr ]
278- self .dll .breakpoint_clear (bpid )
280+ self .dll .breakpoint_clear (bpid , None )
279281 del self .bp_addr_to_id [addr ]
280282
281283 def breakpoint_list (self ):
@@ -286,25 +288,25 @@ def reg_read(self, name):
286288 if name == 'rflags' or name == 'eflags' :
287289 name = 'efl'
288290 val = c_ulonglong ()
289- if self .dll .reg_read (c_char_p (name .encode ('utf-8' )), byref (val )) != 0 :
291+ if self .dll .reg_read (c_char_p (name .encode ('utf-8' )), byref (val ), None ) != 0 :
290292 raise DebugAdapter .GeneralError ("reading register %s" % name )
291293 return val .value
292294
293295 def reg_write (self , name , value ):
294296 value = c_ulonglong (value )
295- if self .dll .reg_write (c_char_p (name .encode ('utf-8' )), value ) != 0 :
297+ if self .dll .reg_write (c_char_p (name .encode ('utf-8' )), value , None ) != 0 :
296298 raise DebugAdapter .GeneralError ("writing register %s" % name )
297299
298300 def reg_list (self ):
299301 regcount = c_int ()
300- if self .dll .reg_count (byref (regcount )):
302+ if self .dll .reg_count (byref (regcount ), None ):
301303 raise DebugAdapter .GeneralError ("retrieving register count" )
302304 regcount = regcount .value
303305 regname = create_string_buffer (512 );
304306
305307 result = []
306308 for regidx in range (regcount ):
307- if self .dll .reg_name (regidx , regname ) != 0 :
309+ if self .dll .reg_name (regidx , regname , None ) != 0 :
308310 raise DebugAdapter .GeneralError ("translating register index to name" )
309311 result .append (regname .value .decode ('utf-8' ))
310312
@@ -313,11 +315,11 @@ def reg_list(self):
313315 def reg_bits (self , name ):
314316 name = c_char_p (name .encode ('utf-8' ))
315317 val = c_int ()
316- if self .dll .reg_read (name , byref (val )) != 0 :
318+ if self .dll .reg_read (name , byref (val ), None ) != 0 :
317319 raise DebugAdapter .GeneralError ("reading register" )
318320
319321 result = c_int ()
320- if self .dll .reg_width (name , byref (result )) != 0 :
322+ if self .dll .reg_width (name , byref (result ), None ) != 0 :
321323 raise DebugAdapter .GeneralError ("retrieving register width" )
322324 return result .value
323325
@@ -327,9 +329,9 @@ def mem_read(self, address, length):
327329
328330 pfunc = self .dll .mem_read
329331 pfunc .restype = c_int
330- pfunc .argtypes = [c_ulonglong , c_ulong , POINTER (c_uint8 )]
332+ pfunc .argtypes = [c_ulonglong , c_ulong , POINTER (c_uint8 ), c_char_p ]
331333
332- rc = pfunc (address , length , result )
334+ rc = pfunc (address , length , result , None )
333335 if rc != 0 :
334336 raise DebugAdapter .GeneralError ("reading from address 0x%X" % address )
335337
@@ -342,8 +344,8 @@ def mem_write(self, address, data):
342344
343345 pfunc = self .dll .mem_write
344346 pfunc .restype = c_int
345- pfunc .argtypes = [c_ulonglong , POINTER (c_uint8 ), c_ulong ]
346- rc = pfunc (address , u8_arr , len (data ))
347+ pfunc .argtypes = [c_ulonglong , POINTER (c_uint8 ), c_ulong , c_char_p ]
348+ rc = pfunc (address , u8_arr , len (data ), None )
347349 if rc != 0 :
348350 raise DebugAdapter .GeneralError ("writing to address 0x%X" % address )
349351
@@ -353,38 +355,38 @@ def mem_modules(self, cache_ok=True):
353355 module2addr = {}
354356
355357 modules_n = c_int ()
356- if self .dll .module_num (byref (modules_n )) != 0 :
358+ if self .dll .module_num (byref (modules_n ), None ) != 0 :
357359 raise DebugAdapter .GeneralError ("retrieving module list size" )
358360 modules_n = modules_n .value
359361
360362 image_path = create_string_buffer (4096 ) # or MAX_PATH, whatever
361363 image_addr = c_ulonglong ()
362364 for idx in range (modules_n ):
363- if self .dll .module_get (idx , byref (image_path ), byref (image_addr )) != 0 :
365+ if self .dll .module_get (idx , byref (image_path ), byref (image_addr ), None ) != 0 :
364366 raise DebugAdapter .GeneralError ("retrieving module name" )
365367 module2addr [image_path .value .decode ('utf-8' )] = image_addr .value
366368
367369 return module2addr
368370
369371 # break
370372 def break_into (self ):
371- self .dll .break_into ()
373+ self .dll .break_into (None )
372374
373375 # execution control, all return:
374376 # returns (STOP_REASON.XXX, <extra_info>)
375377 def go (self ):
376378 # TODO: Handle output
377- self .dll .go ()
379+ self .dll .go (None )
378380 return self .thunk_stop_reason ()
379381
380382 def step_into (self ):
381383 self .stop_reason_fallback = DebugAdapter .STOP_REASON .SINGLE_STEP
382- self .dll .step_into ()
384+ self .dll .step_into (None )
383385 return self .thunk_stop_reason ()
384386
385387 def step_over (self ):
386388 self .stop_reason_fallback = DebugAdapter .STOP_REASON .SINGLE_STEP
387- self .dll .step_over ()
389+ self .dll .step_over (None )
388390 return self .thunk_stop_reason ()
389391
390392 # testing
0 commit comments