Always create a suspended thread in CreateThread and resume it if

CREATE_SUSPENDED flag is not set as Windows does.
This commit is contained in:
Dmitry Timoshkov 2004-12-01 15:37:26 +00:00 committed by Alexandre Julliard
parent 95c3d9b2a5
commit fafe030e9a
1 changed files with 12 additions and 1 deletions

View File

@ -164,7 +164,7 @@ HANDLE WINAPI CreateRemoteThread( HANDLE hProcess, SECURITY_ATTRIBUTES *sa, SIZE
if (flags & STACK_SIZE_PARAM_IS_A_RESERVATION) stack_reserve = stack;
else stack_commit = stack;
status = RtlCreateUserThread( hProcess, NULL, (flags & CREATE_SUSPENDED) != 0,
status = RtlCreateUserThread( hProcess, NULL, TRUE,
NULL, stack_reserve, stack_commit,
THREAD_Start, info, &handle, &client_id );
if (status == STATUS_SUCCESS)
@ -172,6 +172,17 @@ HANDLE WINAPI CreateRemoteThread( HANDLE hProcess, SECURITY_ATTRIBUTES *sa, SIZE
if (id) *id = (DWORD)client_id.UniqueThread;
if (sa && (sa->nLength >= sizeof(*sa)) && sa->bInheritHandle)
SetHandleInformation( handle, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT );
if (!(flags & CREATE_SUSPENDED))
{
ULONG ret;
if (NtResumeThread( handle, &ret ))
{
NtClose( handle );
RtlFreeHeap( GetProcessHeap(), 0, info );
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
handle = 0;
}
}
}
else
{