http://bugs.winehq.org/show_bug.cgi?id=20230
Summary: GetThreadTimes() and the Actual and Pseudo Current Thread Handles Product: Wine Version: 1.1.30 Platform: PC URL: http://rh-software.com OS/Version: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: ntdll AssignedTo: wine-bugs@winehq.org ReportedBy: ray@pobox.co.uk
Some time ago I had an issue with SIV being unable to read the thread CPU time usage when using GetThreadTimes(). I tracked down to the following and then did a work-a-round.
The "Current Thread" effectively has 2 current thread handles, these are the actual thread handle and the ~0 pseudo handle as returned by GetCurrentThread(). When a call is made to GetThreadTimes() this calls NtQueryInformationThread( ThreadTimes ) which contains the test "if (handle == GetCurrentThread())". As a result of this when GetThreadTimes() is called with the actual thread handle no data is returned.
\WINE-1.1.30\dlls\ntdll\thread.c(1011): if (handle == GetCurrentThread())
I suspect the code should be changed to allow both the pseudo and actual thread handles to be used as a minimum, better still would, when possible, be to implement this function for any thread.
While searching the source I also noticed:
NTSTATUS WINAPI NtSetInformationThread( HANDLE handle, THREADINFOCLASS class, LPCVOID data, ULONG length ) { NTSTATUS status; switch(class) { case ThreadZeroTlsCell: if (handle == GetCurrentThread())
And suspect that code would benefit from a similar fix.