Module: wine Branch: refs/heads/master Commit: 329ab98940515fdcd880f6897f3c0ad920fd883e URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=329ab98940515fdcd880f689...
Author: Eric Pouech eric.pouech@wanadoo.fr Date: Wed Jan 11 12:32:19 2006 +0100
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 c927037..09c3081 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; + } + status = NtSetInformationThread( hThread, ThreadAffinityMask, + &dwThreadAffinityMask, + sizeof(dwThreadAffinityMask)); + if (status) + { + SetLastError( RtlNtStatusToDosError(status) ); + return 0; } - SERVER_END_REQ; - return ret; + return tbi.AffinityMask; }
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c index 9896703..a267acd 100644 --- a/dlls/ntdll/thread.c +++ b/dlls/ntdll/thread.c @@ -982,10 +982,23 @@ NTSTATUS WINAPI NtSetInformationThread( 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: