Dmitry Timoshkov : ntdll: Refuse to create new thread if the target process is being terminated.
Alexandre Julliard
julliard at winehq.org
Mon Apr 22 14:29:18 CDT 2013
Module: wine
Branch: master
Commit: 59a23fb42f0bd431d06ece753437187f6cbab264
URL: http://source.winehq.org/git/wine.git/?a=commit;h=59a23fb42f0bd431d06ece753437187f6cbab264
Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date: Mon Apr 22 18:33:22 2013 +0900
ntdll: Refuse to create new thread if the target process is being terminated.
---
dlls/kernel32/tests/loader.c | 17 +++++++----------
dlls/ntdll/thread.c | 2 ++
2 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c
index 8d26678..38c059c 100644
--- a/dlls/kernel32/tests/loader.c
+++ b/dlls/kernel32/tests/loader.c
@@ -1183,7 +1183,6 @@ static BOOL WINAPI dll_entry_point(HINSTANCE hinst, DWORD reason, LPVOID param)
/* manual call to LdrShutdownProcess doesn't prevent thread creation */
if (param && test_dll_phase != 4)
{
-todo_wine
ok(!handle || broken(handle != 0) /* before win7 */, "CreateThread should fail\n");
if (!handle)
ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
@@ -1192,16 +1191,15 @@ todo_wine
}
else
{
- ok(handle != 0, "CreateThread error %d\n", GetLastError());
- ret = WaitForSingleObject(handle, 1000);
/* FIXME: remove once Wine is fixed */
if (test_dll_phase == 4) todo_wine
{
- ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#x\n", ret);
- ok(!noop_thread_started || broken(noop_thread_started) /* XP64 */, "thread shouldn't start yet\n");
+ ok(handle != 0, "CreateThread error %d\n", GetLastError());
}
else
{
+ ok(handle != 0, "CreateThread error %d\n", GetLastError());
+ ret = WaitForSingleObject(handle, 1000);
ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#x\n", ret);
ok(!noop_thread_started || broken(noop_thread_started) /* XP64 */, "thread shouldn't start yet\n");
}
@@ -1218,7 +1216,6 @@ todo_wine
/* manual call to LdrShutdownProcess doesn't prevent thread creation */
if (param && test_dll_phase != 4)
{
-todo_wine
ok(!handle || broken(handle != 0) /* before win7 */, "CreateRemoteThread should fail\n");
if (!handle)
ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
@@ -1227,19 +1224,19 @@ todo_wine
}
else
{
- ok(handle != 0, "CreateRemoteThread error %d\n", GetLastError());
- ret = WaitForSingleObject(handle, 1000);
/* FIXME: remove once Wine is fixed */
if (test_dll_phase == 4) todo_wine
{
- ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#x\n", ret);
- ok(!noop_thread_started || broken(noop_thread_started) /* XP64 */, "thread shouldn't start yet\n");
+ ok(handle != 0, "CreateRemoteThread error %d\n", GetLastError());
}
else
{
+ ok(handle != 0, "CreateRemoteThread error %d\n", GetLastError());
+ ret = WaitForSingleObject(handle, 1000);
ok(ret == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %#x\n", ret);
ok(!noop_thread_started || broken(noop_thread_started) /* XP64 */, "thread shouldn't start yet\n");
}
+ CloseHandle(handle);
}
SetLastError(0xdeadbeef);
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index 01a8026..4499afa 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -461,6 +461,8 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, const SECURITY_DESCRIPTOR *
return result.create_thread.status;
}
+ if (RtlDllShutdownInProgress()) return STATUS_ACCESS_DENIED;
+
if (server_pipe( request_pipe ) == -1) return STATUS_TOO_MANY_OPENED_FILES;
wine_server_send_fd( request_pipe[0] );
More information about the wine-cvs
mailing list