2 * Unit tests for the debugger facility
4 * Copyright (c) 2007 Francois Gouget for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "wine/test.h"
29 #ifndef STATUS_DEBUGGER_INACTIVE
30 #define STATUS_DEBUGGER_INACTIVE ((NTSTATUS) 0xC0000354)
34 #define PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
36 #define PRINTF_ATTR(fmt,args)
39 #define child_ok (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : test_child_ok
44 static BOOL (WINAPI
*pCheckRemoteDebuggerPresent
)(HANDLE
,PBOOL
);
45 static BOOL (WINAPI
*pDebugActiveProcessStop
)(DWORD
);
46 static BOOL (WINAPI
*pDebugSetProcessKillOnExit
)(BOOL
);
47 static BOOL (WINAPI
*pIsDebuggerPresent
)(void);
48 static struct _TEB
* (WINAPI
*pNtCurrentTeb
)(void);
50 static LONG child_failures
;
52 static void PRINTF_ATTR(2, 3) test_child_ok(int condition
, const char *msg
, ...)
56 va_start(valist
, msg
);
57 winetest_vok(condition
, msg
, valist
);
59 if (!condition
) ++child_failures
;
62 /* Copied from the process test */
63 static void get_file_name(char* buf
)
68 GetTempPathA(sizeof(path
), path
);
69 GetTempFileNameA(path
, "wt", 0, buf
);
72 typedef struct tag_reg_save_value
80 static DWORD
save_value(HKEY hkey
, const char *value
, reg_save_value
*saved
)
86 ret
=RegQueryValueExA(hkey
, value
, NULL
, &saved
->type
, NULL
, &saved
->size
);
87 if (ret
== ERROR_SUCCESS
)
89 saved
->data
=HeapAlloc(GetProcessHeap(), 0, saved
->size
);
90 RegQueryValueExA(hkey
, value
, NULL
, &saved
->type
, saved
->data
, &saved
->size
);
95 static void restore_value(HKEY hkey
, reg_save_value
*saved
)
99 RegSetValueExA(hkey
, saved
->name
, 0, saved
->type
, saved
->data
, saved
->size
);
100 HeapFree(GetProcessHeap(), 0, saved
->data
);
103 RegDeleteValueA(hkey
, saved
->name
);
106 static void get_events(const char* name
, HANDLE
*start_event
, HANDLE
*done_event
)
108 const char* basename
;
111 basename
=strrchr(name
, '\\');
112 basename
=(basename
? basename
+1 : name
);
113 event_name
=HeapAlloc(GetProcessHeap(), 0, 6+strlen(basename
)+1);
115 sprintf(event_name
, "start_%s", basename
);
116 *start_event
=CreateEvent(NULL
, 0,0, event_name
);
117 sprintf(event_name
, "done_%s", basename
);
118 *done_event
=CreateEvent(NULL
, 0,0, event_name
);
119 HeapFree(GetProcessHeap(), 0, event_name
);
122 static void save_blackbox(const char* logfile
, void* blackbox
, int size
)
127 hFile
=CreateFileA(logfile
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, 0);
128 if (hFile
== INVALID_HANDLE_VALUE
)
130 WriteFile(hFile
, blackbox
, size
, &written
, NULL
);
134 static int load_blackbox(const char* logfile
, void* blackbox
, int size
)
140 hFile
=CreateFileA(logfile
, GENERIC_READ
, 0, NULL
, OPEN_EXISTING
, 0, 0);
141 if (hFile
== INVALID_HANDLE_VALUE
)
143 ok(0, "unable to open '%s'\n", logfile
);
146 SetLastError(0xdeadbeef);
147 ret
=ReadFile(hFile
, blackbox
, size
, &read
, NULL
);
148 ok(ret
, "ReadFile failed: %d\n", GetLastError());
149 ok(read
== size
, "wrong size for '%s': read=%d\n", logfile
, read
);
159 static void doCrash(int argc
, char** argv
)
163 /* make sure the exception gets to the debugger */
165 SetUnhandledExceptionFilter( NULL
);
169 crash_blackbox_t blackbox
;
170 blackbox
.pid
=GetCurrentProcessId();
171 save_blackbox(argv
[3], &blackbox
, sizeof(blackbox
));
175 trace("child: crashing...\n");
192 } debugger_blackbox_t
;
194 static void doDebugger(int argc
, char** argv
)
197 debugger_blackbox_t blackbox
;
198 HANDLE start_event
= 0, done_event
= 0, debug_event
;
201 logfile
=(argc
>= 4 ? argv
[3] : NULL
);
202 blackbox
.pid
=(argc
>= 5 ? atol(argv
[4]) : 0);
204 blackbox
.attach_err
=0;
205 if (strstr(myARGV
[2], "attach"))
207 blackbox
.attach_rc
=DebugActiveProcess(blackbox
.pid
);
208 if (!blackbox
.attach_rc
)
209 blackbox
.attach_err
=GetLastError();
212 blackbox
.attach_rc
=TRUE
;
214 debug_event
=(argc
>= 6 ? (HANDLE
)(INT_PTR
)atol(argv
[5]) : NULL
);
215 blackbox
.debug_err
=0;
216 if (debug_event
&& strstr(myARGV
[2], "event"))
218 blackbox
.debug_rc
=SetEvent(debug_event
);
219 if (!blackbox
.debug_rc
)
220 blackbox
.debug_err
=GetLastError();
223 blackbox
.debug_rc
=TRUE
;
227 get_events(logfile
, &start_event
, &done_event
);
230 if (strstr(myARGV
[2], "order"))
232 trace("debugger: waiting for the start signal...\n");
233 WaitForSingleObject(start_event
, INFINITE
);
236 blackbox
.nokill_err
=0;
237 if (strstr(myARGV
[2], "nokill"))
239 blackbox
.nokill_rc
=pDebugSetProcessKillOnExit(FALSE
);
240 if (!blackbox
.nokill_rc
)
241 blackbox
.nokill_err
=GetLastError();
244 blackbox
.nokill_rc
=TRUE
;
246 blackbox
.detach_err
=0;
247 if (strstr(myARGV
[2], "detach"))
249 blackbox
.detach_rc
=pDebugActiveProcessStop(blackbox
.pid
);
250 if (!blackbox
.detach_rc
)
251 blackbox
.detach_err
=GetLastError();
254 blackbox
.detach_rc
=TRUE
;
258 save_blackbox(logfile
, &blackbox
, sizeof(blackbox
));
260 trace("debugger: done debugging...\n");
261 SetEvent(done_event
);
263 /* Just exit with a known value */
264 ExitProcess(0xdeadbeef);
267 static void crash_and_debug(HKEY hkey
, const char* argv0
, const char* dbgtasks
)
270 HANDLE start_event
, done_event
;
272 char dbglog
[MAX_PATH
];
273 char childlog
[MAX_PATH
];
274 PROCESS_INFORMATION info
;
275 STARTUPINFOA startup
;
277 crash_blackbox_t crash_blackbox
;
278 debugger_blackbox_t dbg_blackbox
;
280 ret
=RegSetValueExA(hkey
, "auto", 0, REG_SZ
, (BYTE
*)"1", 2);
281 ok(ret
== ERROR_SUCCESS
, "unable to set AeDebug/auto: ret=%d\n", ret
);
283 get_file_name(dbglog
);
284 get_events(dbglog
, &start_event
, &done_event
);
285 cmd
=HeapAlloc(GetProcessHeap(), 0, strlen(argv0
)+10+strlen(dbgtasks
)+1+strlen(dbglog
)+34+1);
286 sprintf(cmd
, "%s debugger %s %s %%ld %%ld", argv0
, dbgtasks
, dbglog
);
287 ret
=RegSetValueExA(hkey
, "debugger", 0, REG_SZ
, (BYTE
*)cmd
, strlen(cmd
)+1);
288 ok(ret
== ERROR_SUCCESS
, "unable to set AeDebug/debugger: ret=%d\n", ret
);
289 HeapFree(GetProcessHeap(), 0, cmd
);
291 get_file_name(childlog
);
292 cmd
=HeapAlloc(GetProcessHeap(), 0, strlen(argv0
)+16+strlen(dbglog
)+1);
293 sprintf(cmd
, "%s debugger crash %s", argv0
, childlog
);
295 memset(&startup
, 0, sizeof(startup
));
296 startup
.cb
= sizeof(startup
);
297 startup
.dwFlags
= STARTF_USESHOWWINDOW
;
298 startup
.wShowWindow
= SW_SHOWNORMAL
;
299 ret
=CreateProcessA(NULL
, cmd
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &startup
, &info
);
300 ok(ret
, "CreateProcess: err=%d\n", GetLastError());
301 HeapFree(GetProcessHeap(), 0, cmd
);
302 CloseHandle(info
.hThread
);
304 /* The process exits... */
305 trace("waiting for child exit...\n");
306 ok(WaitForSingleObject(info
.hProcess
, 60000) == WAIT_OBJECT_0
, "Timed out waiting for the child to crash\n");
307 ok(GetExitCodeProcess(info
.hProcess
, &exit_code
), "GetExitCodeProcess failed: err=%d\n", GetLastError());
308 if (strstr(dbgtasks
, "code2"))
310 /* If, after attaching to the debuggee, the debugger exits without
311 * detaching, then the debuggee gets a special exit code.
313 ok(exit_code
== STATUS_DEBUGGER_INACTIVE
||
314 broken(exit_code
== STATUS_ACCESS_VIOLATION
) || /* Intermittent Vista+ */
315 broken(exit_code
== 0xffffffff) || /* Win9x */
316 broken(exit_code
== WAIT_ABANDONED
), /* NT4, W2K */
317 "wrong exit code : %08x\n", exit_code
);
320 ok(exit_code
== STATUS_ACCESS_VIOLATION
||
321 broken(exit_code
== WAIT_ABANDONED
) || /* NT4, W2K, W2K3 */
322 broken(exit_code
== 0xffffffff), /* Win9x, WinME */
323 "wrong exit code : %08x\n", exit_code
);
324 CloseHandle(info
.hProcess
);
326 /* ...before the debugger */
327 if (strstr(dbgtasks
, "order"))
328 ok(SetEvent(start_event
), "SetEvent(start_event) failed\n");
330 trace("waiting for the debugger...\n");
331 ok(WaitForSingleObject(done_event
, 60000) == WAIT_OBJECT_0
, "Timed out waiting for the debugger\n");
333 assert(load_blackbox(childlog
, &crash_blackbox
, sizeof(crash_blackbox
)));
334 assert(load_blackbox(dbglog
, &dbg_blackbox
, sizeof(dbg_blackbox
)));
336 ok(dbg_blackbox
.argc
== 6, "wrong debugger argument count: %d\n", dbg_blackbox
.argc
);
337 ok(dbg_blackbox
.pid
== crash_blackbox
.pid
, "the child and debugged pids don't match: %d != %d\n", crash_blackbox
.pid
, dbg_blackbox
.pid
);
338 ok(dbg_blackbox
.debug_rc
, "debugger: SetEvent(debug_event) failed err=%d\n", dbg_blackbox
.debug_err
);
339 ok(dbg_blackbox
.attach_rc
, "DebugActiveProcess(%d) failed err=%d\n", dbg_blackbox
.pid
, dbg_blackbox
.attach_err
);
340 ok(dbg_blackbox
.nokill_rc
, "DebugSetProcessKillOnExit(FALSE) failed err=%d\n", dbg_blackbox
.nokill_err
);
341 ok(dbg_blackbox
.detach_rc
, "DebugActiveProcessStop(%d) failed err=%d\n", dbg_blackbox
.pid
, dbg_blackbox
.detach_err
);
343 assert(DeleteFileA(dbglog
) != 0);
344 assert(DeleteFileA(childlog
) != 0);
347 static void crash_and_winedbg(HKEY hkey
, const char* argv0
)
351 PROCESS_INFORMATION info
;
352 STARTUPINFOA startup
;
355 ret
=RegSetValueExA(hkey
, "auto", 0, REG_SZ
, (BYTE
*)"1", 2);
356 ok(ret
== ERROR_SUCCESS
, "unable to set AeDebug/auto: ret=%d\n", ret
);
358 cmd
=HeapAlloc(GetProcessHeap(), 0, strlen(argv0
)+15+1);
359 sprintf(cmd
, "%s debugger crash", argv0
);
361 memset(&startup
, 0, sizeof(startup
));
362 startup
.cb
= sizeof(startup
);
363 startup
.dwFlags
= STARTF_USESHOWWINDOW
;
364 startup
.wShowWindow
= SW_SHOWNORMAL
;
365 ret
=CreateProcessA(NULL
, cmd
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &startup
, &info
);
366 ok(ret
, "CreateProcess: err=%d\n", GetLastError());
367 HeapFree(GetProcessHeap(), 0, cmd
);
368 CloseHandle(info
.hThread
);
370 trace("waiting for child exit...\n");
371 ok(WaitForSingleObject(info
.hProcess
, 60000) == WAIT_OBJECT_0
, "Timed out waiting for the child to crash\n");
372 ok(GetExitCodeProcess(info
.hProcess
, &exit_code
), "GetExitCodeProcess failed: err=%d\n", GetLastError());
373 ok(exit_code
== STATUS_ACCESS_VIOLATION
, "exit code = %08x\n", exit_code
);
374 CloseHandle(info
.hProcess
);
377 static void test_ExitCode(void)
379 static const char* AeDebug
="Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug";
380 static const char* WineDbg
="Software\\Wine\\WineDbg";
381 char test_exe
[MAX_PATH
];
385 reg_save_value auto_value
;
386 reg_save_value debugger_value
;
388 GetModuleFileNameA(GetModuleHandle(NULL
), test_exe
, sizeof(test_exe
));
389 if (GetFileAttributes(test_exe
) == INVALID_FILE_ATTRIBUTES
)
390 strcat(test_exe
, ".so");
391 if (GetFileAttributesA(test_exe
) == INVALID_FILE_ATTRIBUTES
)
393 ok(0, "could not find the test executable '%s'\n", test_exe
);
397 ret
=RegCreateKeyExA(HKEY_LOCAL_MACHINE
, AeDebug
, 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_ALL_ACCESS
, NULL
, &hkey
, &disposition
);
398 if (ret
== ERROR_SUCCESS
)
400 save_value(hkey
, "auto", &auto_value
);
401 save_value(hkey
, "debugger", &debugger_value
);
402 trace("HKLM\\%s\\debugger is set to '%s'\n", AeDebug
, debugger_value
.data
);
404 else if (ret
== ERROR_ACCESS_DENIED
)
406 skip("not enough privileges to change the debugger\n");
409 else if (ret
!= ERROR_FILE_NOT_FOUND
)
411 ok(0, "could not open the AeDebug key: %d\n", ret
);
415 if (debugger_value
.data
&& debugger_value
.type
== REG_SZ
&&
416 strstr((char*)debugger_value
.data
, "winedbg --auto"))
419 ret
=RegCreateKeyA(HKEY_CURRENT_USER
, WineDbg
, &hkeyWinedbg
);
420 if (ret
== ERROR_SUCCESS
)
423 reg_save_value crash_dlg_value
;
424 save_value(hkeyWinedbg
, "ShowCrashDialog", &crash_dlg_value
);
425 RegSetValueExA(hkeyWinedbg
, "ShowCrashDialog", 0, REG_DWORD
, (BYTE
*)&zero
, sizeof(DWORD
));
426 crash_and_winedbg(hkey
, test_exe
);
427 restore_value(hkeyWinedbg
, &crash_dlg_value
);
428 RegCloseKey(hkeyWinedbg
);
431 ok(0, "Couldn't access WineDbg Key - error %u\n", ret
);
434 if (winetest_interactive
)
435 /* Since the debugging process never sets the debug event, it isn't recognized
436 as a valid debugger and, after the debugger exits, Windows will show a dialog box
437 asking the user what to do */
438 crash_and_debug(hkey
, test_exe
, "dbg,none");
440 skip("\"none\" debugger test needs user interaction\n");
441 if (disposition
== REG_CREATED_NEW_KEY
)
442 win_skip("'dbg,event,order' test doesn't finish on Win9x/WinMe\n");
444 crash_and_debug(hkey
, test_exe
, "dbg,event,order");
445 crash_and_debug(hkey
, test_exe
, "dbg,attach,event,code2");
446 if (pDebugSetProcessKillOnExit
)
447 crash_and_debug(hkey
, test_exe
, "dbg,attach,event,nokill");
449 win_skip("DebugSetProcessKillOnExit is not available\n");
450 if (pDebugActiveProcessStop
)
451 crash_and_debug(hkey
, test_exe
, "dbg,attach,event,detach");
453 win_skip("DebugActiveProcessStop is not available\n");
455 if (disposition
== REG_CREATED_NEW_KEY
)
458 RegDeleteKeyA(HKEY_LOCAL_MACHINE
, AeDebug
);
462 restore_value(hkey
, &auto_value
);
463 restore_value(hkey
, &debugger_value
);
468 static void test_RemoteDebugger(void)
471 if(!pCheckRemoteDebuggerPresent
)
473 win_skip("CheckRemoteDebuggerPresent is not available\n");
477 SetLastError(0xdeadbeef);
478 bret
= pCheckRemoteDebuggerPresent(GetCurrentProcess(),&present
);
479 ok(bret
, "expected CheckRemoteDebuggerPresent to succeed\n");
480 ok(0xdeadbeef == GetLastError(),
481 "expected error to be unchanged, got %d/%x\n",GetLastError(), GetLastError());
484 SetLastError(0xdeadbeef);
485 bret
= pCheckRemoteDebuggerPresent(NULL
,&present
);
486 ok(!bret
, "expected CheckRemoteDebuggerPresent to fail\n");
487 ok(present
, "expected parameter to be unchanged\n");
488 ok(ERROR_INVALID_PARAMETER
== GetLastError(),
489 "expected error ERROR_INVALID_PARAMETER, got %d/%x\n",GetLastError(), GetLastError());
491 SetLastError(0xdeadbeef);
492 bret
= pCheckRemoteDebuggerPresent(GetCurrentProcess(),NULL
);
493 ok(!bret
, "expected CheckRemoteDebuggerPresent to fail\n");
494 ok(ERROR_INVALID_PARAMETER
== GetLastError(),
495 "expected error ERROR_INVALID_PARAMETER, got %d/%x\n",GetLastError(), GetLastError());
498 struct child_blackbox
503 static void doChild(int argc
, char **argv
)
505 struct child_blackbox blackbox
;
506 const char *blackbox_file
;
512 blackbox_file
= argv
[4];
513 sscanf(argv
[3], "%08x", &ppid
);
515 parent
= OpenProcess(PROCESS_QUERY_INFORMATION
, FALSE
, ppid
);
516 child_ok(!!parent
, "OpenProcess failed, last error %#x.\n", GetLastError());
518 ret
= pCheckRemoteDebuggerPresent(parent
, &debug
);
519 child_ok(ret
, "CheckRemoteDebuggerPresent failed, last error %#x.\n", GetLastError());
520 child_ok(!debug
, "Expected debug == 0, got %#x.\n", debug
);
522 ret
= DebugActiveProcess(ppid
);
523 child_ok(ret
, "DebugActiveProcess failed, last error %#x.\n", GetLastError());
525 ret
= pCheckRemoteDebuggerPresent(parent
, &debug
);
526 child_ok(ret
, "CheckRemoteDebuggerPresent failed, last error %#x.\n", GetLastError());
527 child_ok(debug
, "Expected debug != 0, got %#x.\n", debug
);
529 ret
= pDebugActiveProcessStop(ppid
);
530 child_ok(ret
, "DebugActiveProcessStop failed, last error %#x.\n", GetLastError());
532 ret
= pCheckRemoteDebuggerPresent(parent
, &debug
);
533 child_ok(ret
, "CheckRemoteDebuggerPresent failed, last error %#x.\n", GetLastError());
534 child_ok(!debug
, "Expected debug == 0, got %#x.\n", debug
);
536 ret
= CloseHandle(parent
);
537 child_ok(ret
, "CloseHandle failed, last error %#x.\n", GetLastError());
539 ret
= pIsDebuggerPresent();
540 child_ok(ret
, "Expected ret != 0, got %#x.\n", ret
);
541 ret
= pCheckRemoteDebuggerPresent(GetCurrentProcess(), &debug
);
542 child_ok(ret
, "CheckRemoteDebuggerPresent failed, last error %#x.\n", GetLastError());
543 child_ok(debug
, "Expected debug != 0, got %#x.\n", debug
);
547 pNtCurrentTeb()->Peb
->BeingDebugged
= FALSE
;
549 ret
= pIsDebuggerPresent();
550 child_ok(!ret
, "Expected ret != 0, got %#x.\n", ret
);
551 ret
= pCheckRemoteDebuggerPresent(GetCurrentProcess(), &debug
);
552 child_ok(ret
, "CheckRemoteDebuggerPresent failed, last error %#x.\n", GetLastError());
553 child_ok(debug
, "Expected debug != 0, got %#x.\n", debug
);
555 pNtCurrentTeb()->Peb
->BeingDebugged
= TRUE
;
558 blackbox
.failures
= child_failures
;
559 save_blackbox(blackbox_file
, &blackbox
, sizeof(blackbox
));
562 static void test_debug_loop(int argc
, char **argv
)
564 const char *arguments
= " debugger child ";
565 struct child_blackbox blackbox
;
566 char blackbox_file
[MAX_PATH
];
567 PROCESS_INFORMATION pi
;
574 if (!pDebugActiveProcessStop
|| !pCheckRemoteDebuggerPresent
)
576 win_skip("DebugActiveProcessStop or CheckRemoteDebuggerPresent not available, skipping test.\n");
580 pid
= GetCurrentProcessId();
581 ret
= DebugActiveProcess(pid
);
582 ok(!ret
, "DebugActiveProcess() succeeded on own process.\n");
584 get_file_name(blackbox_file
);
585 cmd
= HeapAlloc(GetProcessHeap(), 0, strlen(argv
[0]) + strlen(arguments
) + strlen(blackbox_file
) + 10);
586 sprintf(cmd
, "%s%s%08x %s", argv
[0], arguments
, pid
, blackbox_file
);
588 memset(&si
, 0, sizeof(si
));
590 ret
= CreateProcessA(NULL
, cmd
, NULL
, NULL
, FALSE
, DEBUG_PROCESS
, NULL
, NULL
, &si
, &pi
);
591 ok(ret
, "CreateProcess failed, last error %#x.\n", GetLastError());
593 HeapFree(GetProcessHeap(), 0, cmd
);
595 ret
= pCheckRemoteDebuggerPresent(pi
.hProcess
, &debug
);
596 ok(ret
, "CheckRemoteDebuggerPresent failed, last error %#x.\n", GetLastError());
597 ok(debug
, "Expected debug != 0, got %#x.\n", debug
);
603 ret
= WaitForDebugEvent(&ev
, INFINITE
);
604 ok(ret
, "WaitForDebugEvent failed, last error %#x.\n", GetLastError());
607 if (ev
.dwDebugEventCode
== EXIT_PROCESS_DEBUG_EVENT
) break;
609 ret
= ContinueDebugEvent(ev
.dwProcessId
, ev
.dwThreadId
, DBG_CONTINUE
);
610 ok(ret
, "ContinueDebugEvent failed, last error %#x.\n", GetLastError());
614 ret
= CloseHandle(pi
.hThread
);
615 ok(ret
, "CloseHandle failed, last error %#x.\n", GetLastError());
616 ret
= CloseHandle(pi
.hProcess
);
617 ok(ret
, "CloseHandle failed, last error %#x.\n", GetLastError());
619 load_blackbox(blackbox_file
, &blackbox
, sizeof(blackbox
));
620 ok(!blackbox
.failures
, "Got %d failures from child process.\n", blackbox
.failures
);
622 ret
= DeleteFileA(blackbox_file
);
623 ok(ret
, "DeleteFileA failed, last error %#x.\n", GetLastError());
630 hdll
=GetModuleHandle("kernel32.dll");
631 pCheckRemoteDebuggerPresent
=(void*)GetProcAddress(hdll
, "CheckRemoteDebuggerPresent");
632 pDebugActiveProcessStop
=(void*)GetProcAddress(hdll
, "DebugActiveProcessStop");
633 pDebugSetProcessKillOnExit
=(void*)GetProcAddress(hdll
, "DebugSetProcessKillOnExit");
634 pIsDebuggerPresent
=(void*)GetProcAddress(hdll
, "IsDebuggerPresent");
635 hdll
=GetModuleHandle("ntdll.dll");
636 if (hdll
) pNtCurrentTeb
= (void*)GetProcAddress(hdll
, "NtCurrentTeb");
638 myARGC
=winetest_get_mainargs(&myARGV
);
639 if (myARGC
>= 3 && strcmp(myARGV
[2], "crash") == 0)
641 doCrash(myARGC
, myARGV
);
643 else if (myARGC
>= 3 && strncmp(myARGV
[2], "dbg,", 4) == 0)
645 doDebugger(myARGC
, myARGV
);
647 else if (myARGC
>= 5 && !strcmp(myARGV
[2], "child"))
649 doChild(myARGC
, myARGV
);
654 test_RemoteDebugger();
655 test_debug_loop(myARGC
, myARGV
);