From 3f40590e93826d7b549b714ca5ab3b7d27da271b Mon Sep 17 00:00:00 2001 From: Alexander Yaworsky Date: Wed, 22 Sep 2004 02:54:13 +0000 Subject: [PATCH] Moved code from CreateThread to CreateRemoteThread. --- dlls/kernel/thread.c | 53 ++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/dlls/kernel/thread.c b/dlls/kernel/thread.c index 128032a218b..cbdc7c777fe 100644 --- a/dlls/kernel/thread.c +++ b/dlls/kernel/thread.c @@ -120,6 +120,32 @@ static void CALLBACK THREAD_Start( void *ptr ) HANDLE WINAPI CreateThread( SECURITY_ATTRIBUTES *sa, SIZE_T stack, LPTHREAD_START_ROUTINE start, LPVOID param, DWORD flags, LPDWORD id ) +{ + return CreateRemoteThread( GetCurrentProcess(), + sa, stack, start, param, flags, id ); +} + + +/*************************************************************************** + * CreateRemoteThread (KERNEL32.@) + * + * Creates a thread that runs in the address space of another process + * + * PARAMS + * + * RETURNS + * Success: Handle to the new thread. + * Failure: NULL. Use GetLastError() to find the error cause. + * + * BUGS + * Improper memory allocation: there's no ability to free new_thread_info + * in other process. + * Bad start address for RtlCreateUserThread because the library + * may be loaded at different address in other process. + */ +HANDLE WINAPI CreateRemoteThread( HANDLE hProcess, SECURITY_ATTRIBUTES *sa, SIZE_T stack, + LPTHREAD_START_ROUTINE start, LPVOID param, + DWORD flags, LPDWORD id ) { HANDLE handle; CLIENT_ID client_id; @@ -138,7 +164,7 @@ HANDLE WINAPI CreateThread( SECURITY_ATTRIBUTES *sa, SIZE_T stack, if (flags & STACK_SIZE_PARAM_IS_A_RESERVATION) stack_reserve = stack; else stack_commit = stack; - status = RtlCreateUserThread( GetCurrentProcess(), NULL, (flags & CREATE_SUSPENDED) != 0, + status = RtlCreateUserThread( hProcess, NULL, (flags & CREATE_SUSPENDED) != 0, NULL, stack_reserve, stack_commit, THREAD_Start, info, &handle, &client_id ); if (status == STATUS_SUCCESS) @@ -157,31 +183,6 @@ HANDLE WINAPI CreateThread( SECURITY_ATTRIBUTES *sa, SIZE_T stack, } -/*************************************************************************** - * CreateRemoteThread (KERNEL32.@) - * - * Creates a thread that runs in the address space of another process - * - * PARAMS - * - * RETURNS - * Success: Handle to the new thread. - * Failure: NULL. Use GetLastError() to find the error cause. - * - * BUGS - * Unimplemented - */ -HANDLE WINAPI CreateRemoteThread( HANDLE hProcess, SECURITY_ATTRIBUTES *sa, SIZE_T stack, - LPTHREAD_START_ROUTINE start, LPVOID param, - DWORD flags, LPDWORD id ) -{ - FIXME("(): stub, Write Me.\n"); - - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return NULL; -} - - /*********************************************************************** * OpenThread [KERNEL32.@] Retrieves a handle to a thread from its thread id */