[1/3] server: Add a process flag indicating whether the process is terminating, use it to block thread creation in a being terminated process.
Dmitry Timoshkov
dmitry at baikal.ru
Mon May 6 01:39:27 CDT 2013
---
dlls/kernel32/tests/loader.c | 1 -
server/process.c | 3 +++
server/process.h | 1 +
server/thread.c | 6 ++++++
4 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c
index d119196..e4176b5 100644
--- a/dlls/kernel32/tests/loader.c
+++ b/dlls/kernel32/tests/loader.c
@@ -1525,7 +1525,6 @@ static void child_process(const char *dll_name, DWORD target_offset)
SetLastError(0xdeadbeef);
thread = CreateThread(NULL, 0, noop_thread_proc, &dummy, 0, &ret);
-todo_wine
ok(!thread || broken(thread != 0) /* before win7 */, "CreateThread should fail\n");
if (!thread)
ok(GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
diff --git a/server/process.c b/server/process.c
index 74a289a..89c08dc 100644
--- a/server/process.c
+++ b/server/process.c
@@ -323,6 +323,7 @@ struct thread *create_process( int fd, struct thread *parent_thread, int inherit
process->suspend = 0;
process->is_system = 0;
process->debug_children = 0;
+ process->is_terminating = 0;
process->console = NULL;
process->startup_state = STARTUP_IN_PROGRESS;
process->startup_info = NULL;
@@ -570,6 +571,8 @@ static void terminate_process( struct process *process, struct thread *skip, int
struct thread *thread;
grab_object( process ); /* make sure it doesn't get freed when threads die */
+ process->is_terminating = 1;
+
restart:
LIST_FOR_EACH_ENTRY( thread, &process->thread_list, struct thread, proc_entry )
{
diff --git a/server/process.h b/server/process.h
index f216ecd..a50b537 100644
--- a/server/process.h
+++ b/server/process.h
@@ -74,6 +74,7 @@ struct process
int suspend; /* global process suspend count */
unsigned int is_system:1; /* is it a system process? */
unsigned int debug_children:1;/* also debug all child processes */
+ unsigned int is_terminating:1;/* is process terminating? */
struct list locks; /* list of file locks owned by the process */
struct list classes; /* window classes owned by the process */
struct console_input*console; /* console input */
diff --git a/server/thread.c b/server/thread.c
index 69d547c..b54b3b1 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -214,6 +214,12 @@ struct thread *create_thread( int fd, struct process *process )
{
struct thread *thread;
+ if (process->is_terminating)
+ {
+ set_error( STATUS_PROCESS_IS_TERMINATING );
+ return NULL;
+ }
+
if (!(thread = alloc_object( &thread_ops ))) return NULL;
init_thread_structure( thread );
--
1.8.2.2
More information about the wine-patches
mailing list