From 329ab98940515fdcd880f6897f3c0ad920fd883e Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Wed, 11 Jan 2006 12:32:19 +0100 Subject: [PATCH] ntdll: Implemented ntdll.NtSetInformationThread(ThreadAffinityMask). Reimplemented kernel32.SetThreadAffinityMask on top of it. --- dlls/kernel/thread.c | 26 +++++++++++++++++--------- dlls/ntdll/thread.c | 15 ++++++++++++++- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/dlls/kernel/thread.c b/dlls/kernel/thread.c index c9270376991..09c3081e080 100644 --- a/dlls/kernel/thread.c +++ b/dlls/kernel/thread.c @@ -443,17 +443,25 @@ BOOL WINAPI SetThreadPriorityBoost( */ DWORD WINAPI SetThreadAffinityMask( HANDLE hThread, DWORD dwThreadAffinityMask ) { - DWORD ret; - SERVER_START_REQ( set_thread_info ) + NTSTATUS status; + THREAD_BASIC_INFORMATION tbi; + + status = NtQueryInformationThread( hThread, ThreadBasicInformation, + &tbi, sizeof(tbi), NULL ); + if (status) { - req->handle = hThread; - req->affinity = dwThreadAffinityMask; - req->mask = SET_THREAD_INFO_AFFINITY; - ret = !wine_server_call_err( req ); - /* FIXME: should return previous value */ + SetLastError( RtlNtStatusToDosError(status) ); + return 0; } - SERVER_END_REQ; - return ret; + status = NtSetInformationThread( hThread, ThreadAffinityMask, + &dwThreadAffinityMask, + sizeof(dwThreadAffinityMask)); + if (status) + { + SetLastError( RtlNtStatusToDosError(status) ); + return 0; + } + return tbi.AffinityMask; } diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c index 9896703aaa2..a267acd2f5f 100644 --- a/dlls/ntdll/thread.c +++ b/dlls/ntdll/thread.c @@ -982,10 +982,23 @@ NTSTATUS WINAPI NtSetInformationThread( HANDLE handle, THREADINFOCLASS class, SERVER_END_REQ; } return status; + case ThreadAffinityMask: + { + const DWORD *paff = data; + if (length != sizeof(DWORD)) return STATUS_INVALID_PARAMETER; + SERVER_START_REQ( set_thread_info ) + { + req->handle = handle; + req->affinity = *paff; + req->mask = SET_THREAD_INFO_AFFINITY; + status = wine_server_call( req ); + } + SERVER_END_REQ; + } + return status; case ThreadBasicInformation: case ThreadTimes: case ThreadPriority: - case ThreadAffinityMask: case ThreadDescriptorTableEntry: case ThreadEnableAlignmentFaultFixup: case ThreadEventPair_Reusable: