4 * Copyright 1996 Alexandre Julliard
10 #include <sys/socket.h>
12 #include "wine/winbase16.h"
20 #include "selectors.h"
24 #include "stackframe.h"
25 #include "debugtools.h"
29 DEFAULT_DEBUG_CHANNEL(thread
)
31 /* THDB of the initial thread */
32 static THDB initial_thdb
;
34 /* Global thread list (FIXME: not thread-safe) */
35 THDB
*THREAD_First
= &initial_thdb
;
37 /***********************************************************************
40 BOOL
THREAD_IsWin16( THDB
*thdb
)
42 return !thdb
|| !(thdb
->teb
.flags
& TEBF_WIN32
);
45 /***********************************************************************
48 * Convert a thread id to a THDB, making sure it is valid.
50 THDB
*THREAD_IdToTHDB( DWORD id
)
52 THDB
*thdb
= THREAD_First
;
54 if (!id
) return THREAD_Current();
57 if ((DWORD
)thdb
->teb
.tid
== id
) return thdb
;
60 /* Allow task handles to be used; convert to main thread */
63 TDB
*pTask
= (TDB
*)GlobalLock16( id
);
64 if (pTask
) return pTask
->thdb
;
66 SetLastError( ERROR_INVALID_PARAMETER
);
71 /***********************************************************************
74 * Initialization of a newly created THDB.
76 static BOOL
THREAD_InitTHDB( THDB
*thdb
, DWORD stack_size
, BOOL alloc_stack16
,
77 LPSECURITY_ATTRIBUTES sa
)
81 /* Allocate the stack */
84 * If stacksize smaller than 1 MB, allocate 1MB
85 * (one program wanted only 10 kB, which is recommendable, but some WINE
86 * functions, noteably in the files subdir, push HUGE structures and
87 * arrays on the stack. They probably shouldn't.)
88 * If stacksize larger than 16 MB, warn the user. (We could shrink the stack
89 * but this could give more or less unexplainable crashes.)
91 if (stack_size
<1024*1024)
92 stack_size
= 1024 * 1024;
93 if (stack_size
>= 16*1024*1024)
94 WARN("Thread stack size is %ld MB.\n",stack_size
/1024/1024);
95 thdb
->stack_base
= VirtualAlloc(NULL
, stack_size
+ SIGNAL_STACK_SIZE
+
96 (alloc_stack16
? 0x10000 : 0),
97 MEM_COMMIT
, PAGE_EXECUTE_READWRITE
);
98 if (!thdb
->stack_base
) goto error
;
99 /* Set a guard page at the bottom of the stack */
100 VirtualProtect( thdb
->stack_base
, 1, PAGE_EXECUTE_READWRITE
| PAGE_GUARD
,
102 thdb
->teb
.stack_top
= (char *)thdb
->stack_base
+ stack_size
;
103 thdb
->teb
.stack_low
= thdb
->stack_base
;
104 thdb
->signal_stack
= thdb
->teb
.stack_top
; /* start of signal stack */
106 /* Allocate the 16-bit stack selector */
110 thdb
->teb
.stack_sel
= SELECTOR_AllocBlock( thdb
->teb
.stack_top
,
111 0x10000, SEGMENT_DATA
,
113 if (!thdb
->teb
.stack_sel
) goto error
;
114 thdb
->cur_stack
= PTR_SEG_OFF_TO_SEGPTR( thdb
->teb
.stack_sel
,
115 0x10000 - sizeof(STACK16FRAME
) );
116 thdb
->signal_stack
= (char *)thdb
->signal_stack
+ 0x10000;
119 /* Create the thread event */
121 if (!(thdb
->event
= CreateEventA( NULL
, FALSE
, FALSE
, NULL
))) goto error
;
122 thdb
->event
= ConvertToGlobalHandle( thdb
->event
);
126 if (thdb
->event
) CloseHandle( thdb
->event
);
127 if (thdb
->teb
.stack_sel
) SELECTOR_FreeBlock( thdb
->teb
.stack_sel
, 1 );
128 if (thdb
->stack_base
) VirtualFree( thdb
->stack_base
, 0, MEM_RELEASE
);
133 /***********************************************************************
136 * Free data structures associated with a thread.
137 * Must be called from the context of another thread.
139 void CALLBACK
THREAD_FreeTHDB( ULONG_PTR arg
)
141 THDB
*thdb
= (THDB
*)arg
;
142 THDB
**pptr
= &THREAD_First
;
144 TRACE("(%p) called\n", thdb
);
145 SERVICE_Delete( thdb
->cleanup
);
147 PROCESS_CallUserSignalProc( USIG_THREAD_EXIT
, 0 );
149 CloseHandle( thdb
->event
);
150 while (*pptr
&& (*pptr
!= thdb
)) pptr
= &(*pptr
)->next
;
151 if (*pptr
) *pptr
= thdb
->next
;
153 /* Free the associated memory */
155 if (thdb
->teb
.stack_sel
) SELECTOR_FreeBlock( thdb
->teb
.stack_sel
, 1 );
156 SELECTOR_FreeBlock( thdb
->teb_sel
, 1 );
157 close( thdb
->socket
);
158 VirtualFree( thdb
->stack_base
, 0, MEM_RELEASE
);
159 HeapFree( SystemHeap
, HEAP_NO_SERIALIZE
, thdb
);
163 /***********************************************************************
164 * THREAD_CreateInitialThread
166 * Create the initial thread.
168 THDB
*THREAD_CreateInitialThread( PDB
*pdb
, int server_fd
)
170 initial_thdb
.process
= pdb
;
171 initial_thdb
.teb
.except
= (void *)-1;
172 initial_thdb
.teb
.self
= &initial_thdb
.teb
;
173 initial_thdb
.teb
.flags
= /* TEBF_WIN32 */ 0;
174 initial_thdb
.teb
.tls_ptr
= initial_thdb
.tls_array
;
175 initial_thdb
.teb
.process
= pdb
;
176 initial_thdb
.exit_code
= 0x103; /* STILL_ACTIVE */
177 initial_thdb
.socket
= server_fd
;
179 /* Allocate the TEB selector (%fs register) */
181 if (!(initial_thdb
.teb_sel
= SELECTOR_AllocBlock( &initial_thdb
.teb
, 0x1000,
182 SEGMENT_DATA
, TRUE
, FALSE
)))
184 MESSAGE("Could not allocate fs register for initial thread\n" );
187 SYSDEPS_SetCurThread( &initial_thdb
);
189 /* Now proceed with normal initialization */
191 if (CLIENT_InitThread()) return NULL
;
192 if (!THREAD_InitTHDB( &initial_thdb
, 0, TRUE
, NULL
)) return NULL
;
193 return &initial_thdb
;
197 /***********************************************************************
200 THDB
*THREAD_Create( PDB
*pdb
, DWORD flags
, DWORD stack_size
, BOOL alloc_stack16
,
201 LPSECURITY_ATTRIBUTES sa
, int *server_handle
)
203 struct new_thread_request request
;
204 struct new_thread_reply reply
= { NULL
, -1 };
206 HANDLE cleanup_object
;
208 THDB
*thdb
= HeapAlloc( SystemHeap
, HEAP_ZERO_MEMORY
, sizeof(THDB
) );
209 if (!thdb
) return NULL
;
211 thdb
->teb
.except
= (void *)-1;
212 thdb
->teb
.htask16
= pdb
->task
;
213 thdb
->teb
.self
= &thdb
->teb
;
214 thdb
->teb
.flags
= (pdb
->flags
& PDB32_WIN16_PROC
)? 0 : TEBF_WIN32
;
215 thdb
->teb
.tls_ptr
= thdb
->tls_array
;
216 thdb
->teb
.process
= pdb
;
217 thdb
->exit_code
= 0x103; /* STILL_ACTIVE */
221 /* Allocate the TEB selector (%fs register) */
223 thdb
->teb_sel
= SELECTOR_AllocBlock( &thdb
->teb
, 0x1000, SEGMENT_DATA
,
225 if (!thdb
->teb_sel
) goto error
;
227 /* Create the socket pair for server communication */
229 if (socketpair( AF_UNIX
, SOCK_STREAM
, 0, fd
) == -1)
231 SetLastError( ERROR_TOO_MANY_OPEN_FILES
); /* FIXME */
234 thdb
->socket
= fd
[0];
235 fcntl( fd
[0], F_SETFD
, 1 ); /* set close on exec flag */
237 /* Create the thread on the server side */
239 request
.pid
= thdb
->process
->server_pid
;
240 request
.suspend
= ((thdb
->flags
& CREATE_SUSPENDED
) != 0);
241 request
.inherit
= (sa
&& (sa
->nLength
>=sizeof(*sa
)) && sa
->bInheritHandle
);
242 CLIENT_SendRequest( REQ_NEW_THREAD
, fd
[1], 1, &request
, sizeof(request
) );
243 if (CLIENT_WaitSimpleReply( &reply
, sizeof(reply
), NULL
)) goto error
;
244 thdb
->teb
.tid
= reply
.tid
;
245 *server_handle
= reply
.handle
;
247 /* Do the rest of the initialization */
249 if (!THREAD_InitTHDB( thdb
, stack_size
, alloc_stack16
, sa
)) goto error
;
250 thdb
->next
= THREAD_First
;
253 /* Install cleanup handler */
254 if ( !DuplicateHandle( GetCurrentProcess(), *server_handle
,
255 GetCurrentProcess(), &cleanup_object
,
256 0, FALSE
, DUPLICATE_SAME_ACCESS
) ) goto error
;
257 thdb
->cleanup
= SERVICE_AddObject( cleanup_object
, THREAD_FreeTHDB
, (ULONG_PTR
)thdb
);
262 if (reply
.handle
!= -1) CloseHandle( reply
.handle
);
263 if (thdb
->teb_sel
) SELECTOR_FreeBlock( thdb
->teb_sel
, 1 );
264 HeapFree( SystemHeap
, 0, thdb
);
265 if (thdb
->socket
!= -1) close( thdb
->socket
);
270 /***********************************************************************
273 * Start execution of a newly created thread. Does not return.
275 static void THREAD_Start(void)
277 THDB
*thdb
= THREAD_Current();
278 LPTHREAD_START_ROUTINE func
= (LPTHREAD_START_ROUTINE
)thdb
->entry_point
;
279 PROCESS_CallUserSignalProc( USIG_THREAD_INIT
, 0 );
281 MODULE_DllThreadAttach( NULL
);
283 if (thdb
->process
->flags
& PDB32_DEBUGGED
) DEBUG_SendCreateThreadEvent( func
);
285 ExitThread( func( thdb
->entry_arg
) );
289 /***********************************************************************
290 * CreateThread (KERNEL32.63)
292 HANDLE WINAPI
CreateThread( SECURITY_ATTRIBUTES
*sa
, DWORD stack
,
293 LPTHREAD_START_ROUTINE start
, LPVOID param
,
294 DWORD flags
, LPDWORD id
)
297 THDB
*thread
= THREAD_Create( PROCESS_Current(), flags
, stack
, TRUE
, sa
, &handle
);
298 if (!thread
) return INVALID_HANDLE_VALUE
;
299 thread
->teb
.flags
|= TEBF_WIN32
;
300 thread
->entry_point
= start
;
301 thread
->entry_arg
= param
;
302 thread
->startup
= THREAD_Start
;
303 if (SYSDEPS_SpawnThread( thread
) == -1)
305 CloseHandle( handle
);
306 return INVALID_HANDLE_VALUE
;
308 if (id
) *id
= (DWORD
)thread
->teb
.tid
;
313 /***********************************************************************
314 * ExitThread [KERNEL32.215] Ends a thread
319 void WINAPI
ExitThread( DWORD code
) /* [in] Exit code for this thread */
321 MODULE_DllThreadDetach( NULL
);
322 TerminateThread( GetCurrentThread(), code
);
326 /***********************************************************************
327 * GetCurrentThread [KERNEL32.200] Gets pseudohandle for current thread
330 * Pseudohandle for the current thread
332 HANDLE WINAPI
GetCurrentThread(void)
334 return CURRENT_THREAD_PSEUDOHANDLE
;
338 /***********************************************************************
339 * GetCurrentThreadId [KERNEL32.201] Returns thread identifier.
342 * Thread identifier of calling thread
344 DWORD WINAPI
GetCurrentThreadId(void)
346 return (DWORD
)CURRENT()->tid
;
350 /**********************************************************************
351 * GetLastError [KERNEL.148] [KERNEL32.227] Returns last-error code.
354 * Calling thread's last error code value.
356 DWORD WINAPI
GetLastError(void)
358 THDB
*thread
= THREAD_Current();
359 DWORD ret
= thread
->last_error
;
360 TRACE("0x%lx\n",ret
);
365 /**********************************************************************
366 * SetLastError [KERNEL.147] [KERNEL32.497] Sets the last-error code.
371 void WINAPI
SetLastError(
372 DWORD error
) /* [in] Per-thread error code */
374 THDB
*thread
= THREAD_Current();
375 TRACE("%p error=0x%lx\n",thread
,error
);
376 thread
->last_error
= error
;
380 /**********************************************************************
381 * SetLastErrorEx [USER32.485] Sets the last-error code.
386 void WINAPI
SetLastErrorEx(
387 DWORD error
, /* [in] Per-thread error code */
388 DWORD type
) /* [in] Error type */
390 TRACE("(0x%08lx, 0x%08lx)\n", error
,type
);
397 /* Fall through for now */
399 FIXME("(error=%08lx, type=%08lx): Unhandled type\n", error
,type
);
402 SetLastError( error
);
406 /**********************************************************************
407 * TlsAlloc [KERNEL32.530] Allocates a TLS index.
409 * Allocates a thread local storage index
413 * Failure: 0xFFFFFFFF
415 DWORD WINAPI
TlsAlloc( void )
417 THDB
*thread
= THREAD_Current();
418 DWORD i
, mask
, ret
= 0;
419 DWORD
*bits
= thread
->process
->tls_bits
;
420 EnterCriticalSection( &thread
->process
->crit_section
);
421 if (*bits
== 0xffffffff)
425 if (*bits
== 0xffffffff)
427 LeaveCriticalSection( &thread
->process
->crit_section
);
428 SetLastError( ERROR_NO_MORE_ITEMS
);
432 for (i
= 0, mask
= 1; i
< 32; i
++, mask
<<= 1) if (!(*bits
& mask
)) break;
434 LeaveCriticalSection( &thread
->process
->crit_section
);
439 /**********************************************************************
440 * TlsFree [KERNEL32.531] Releases a TLS index.
442 * Releases a thread local storage index, making it available for reuse
449 DWORD index
) /* [in] TLS Index to free */
452 THDB
*thread
= THREAD_Current();
453 DWORD
*bits
= thread
->process
->tls_bits
;
456 SetLastError( ERROR_INVALID_PARAMETER
);
459 EnterCriticalSection( &thread
->process
->crit_section
);
460 if (index
>= 32) bits
++;
461 mask
= (1 << (index
& 31));
462 if (!(*bits
& mask
)) /* already free? */
464 LeaveCriticalSection( &thread
->process
->crit_section
);
465 SetLastError( ERROR_INVALID_PARAMETER
);
469 thread
->tls_array
[index
] = 0;
470 /* FIXME: should zero all other thread values */
471 LeaveCriticalSection( &thread
->process
->crit_section
);
476 /**********************************************************************
477 * TlsGetValue [KERNEL32.532] Gets value in a thread's TLS slot
480 * Success: Value stored in calling thread's TLS slot for index
481 * Failure: 0 and GetLastError returns NO_ERROR
483 LPVOID WINAPI
TlsGetValue(
484 DWORD index
) /* [in] TLS index to retrieve value for */
486 THDB
*thread
= THREAD_Current();
489 SetLastError( ERROR_INVALID_PARAMETER
);
492 SetLastError( ERROR_SUCCESS
);
493 return thread
->tls_array
[index
];
497 /**********************************************************************
498 * TlsSetValue [KERNEL32.533] Stores a value in the thread's TLS slot.
504 BOOL WINAPI
TlsSetValue(
505 DWORD index
, /* [in] TLS index to set value for */
506 LPVOID value
) /* [in] Value to be stored */
508 THDB
*thread
= THREAD_Current();
511 SetLastError( ERROR_INVALID_PARAMETER
);
514 thread
->tls_array
[index
] = value
;
519 /***********************************************************************
520 * SetThreadContext [KERNEL32.670] Sets context of thread.
526 BOOL WINAPI
SetThreadContext(
527 HANDLE handle
, /* [in] Handle to thread with context */
528 CONTEXT
*context
) /* [out] Address of context structure */
530 FIXME("not implemented\n" );
534 /***********************************************************************
535 * GetThreadContext [KERNEL32.294] Retrieves context of thread.
541 BOOL WINAPI
GetThreadContext(
542 HANDLE handle
, /* [in] Handle to thread with context */
543 CONTEXT
*context
) /* [out] Address of context structure */
547 FIXME("returning dummy info\n" );
549 /* make up some plausible values for segment registers */
562 /**********************************************************************
563 * GetThreadPriority [KERNEL32.296] Returns priority for thread.
566 * Success: Thread's priority level.
567 * Failure: THREAD_PRIORITY_ERROR_RETURN
569 INT WINAPI
GetThreadPriority(
570 HANDLE hthread
) /* [in] Handle to thread */
572 struct get_thread_info_request req
;
573 struct get_thread_info_reply reply
;
574 req
.handle
= hthread
;
575 CLIENT_SendRequest( REQ_GET_THREAD_INFO
, -1, 1, &req
, sizeof(req
) );
576 if (CLIENT_WaitSimpleReply( &reply
, sizeof(reply
), NULL
))
577 return THREAD_PRIORITY_ERROR_RETURN
;
578 return reply
.priority
;
582 /**********************************************************************
583 * SetThreadPriority [KERNEL32.514] Sets priority for thread.
589 BOOL WINAPI
SetThreadPriority(
590 HANDLE hthread
, /* [in] Handle to thread */
591 INT priority
) /* [in] Thread priority level */
593 struct set_thread_info_request req
;
594 req
.handle
= hthread
;
595 req
.priority
= priority
;
596 req
.mask
= SET_THREAD_INFO_PRIORITY
;
597 CLIENT_SendRequest( REQ_SET_THREAD_INFO
, -1, 1, &req
, sizeof(req
) );
598 return !CLIENT_WaitReply( NULL
, NULL
, 0 );
602 /**********************************************************************
603 * SetThreadAffinityMask (KERNEL32.669)
605 DWORD WINAPI
SetThreadAffinityMask( HANDLE hThread
, DWORD dwThreadAffinityMask
)
607 struct set_thread_info_request req
;
608 req
.handle
= hThread
;
609 req
.affinity
= dwThreadAffinityMask
;
610 req
.mask
= SET_THREAD_INFO_AFFINITY
;
611 CLIENT_SendRequest( REQ_SET_THREAD_INFO
, -1, 1, &req
, sizeof(req
) );
612 if (CLIENT_WaitReply( NULL
, NULL
, 0 )) return 0;
613 return 1; /* FIXME: should return previous value */
617 /**********************************************************************
618 * TerminateThread [KERNEL32.685] Terminates a thread
624 BOOL WINAPI
TerminateThread(
625 HANDLE handle
, /* [in] Handle to thread */
626 DWORD exitcode
) /* [in] Exit code for thread */
628 struct terminate_thread_request req
;
630 req
.exit_code
= exitcode
;
631 CLIENT_SendRequest( REQ_TERMINATE_THREAD
, -1, 1, &req
, sizeof(req
) );
632 return !CLIENT_WaitReply( NULL
, NULL
, 0 );
636 /**********************************************************************
637 * GetExitCodeThread [KERNEL32.???] Gets termination status of thread.
643 BOOL WINAPI
GetExitCodeThread(
644 HANDLE hthread
, /* [in] Handle to thread */
645 LPDWORD exitcode
) /* [out] Address to receive termination status */
647 struct get_thread_info_request req
;
648 struct get_thread_info_reply reply
;
649 req
.handle
= hthread
;
650 CLIENT_SendRequest( REQ_GET_THREAD_INFO
, -1, 1, &req
, sizeof(req
) );
651 if (CLIENT_WaitSimpleReply( &reply
, sizeof(reply
), NULL
)) return FALSE
;
652 if (exitcode
) *exitcode
= reply
.exit_code
;
657 /**********************************************************************
658 * ResumeThread [KERNEL32.587] Resumes a thread.
660 * Decrements a thread's suspend count. When count is zero, the
661 * execution of the thread is resumed.
664 * Success: Previous suspend count
665 * Failure: 0xFFFFFFFF
668 DWORD WINAPI
ResumeThread(
669 HANDLE hthread
) /* [in] Identifies thread to restart */
671 struct resume_thread_request req
;
672 struct resume_thread_reply reply
;
673 req
.handle
= hthread
;
674 CLIENT_SendRequest( REQ_RESUME_THREAD
, -1, 1, &req
, sizeof(req
) );
675 if (CLIENT_WaitSimpleReply( &reply
, sizeof(reply
), NULL
)) return 0xffffffff;
680 /**********************************************************************
681 * SuspendThread [KERNEL32.681] Suspends a thread.
684 * Success: Previous suspend count
685 * Failure: 0xFFFFFFFF
687 DWORD WINAPI
SuspendThread(
688 HANDLE hthread
) /* [in] Handle to the thread */
690 struct suspend_thread_request req
;
691 struct suspend_thread_reply reply
;
692 req
.handle
= hthread
;
693 CLIENT_SendRequest( REQ_SUSPEND_THREAD
, -1, 1, &req
, sizeof(req
) );
694 if (CLIENT_WaitSimpleReply( &reply
, sizeof(reply
), NULL
)) return 0xffffffff;
699 /***********************************************************************
700 * QueueUserAPC (KERNEL32.566)
702 DWORD WINAPI
QueueUserAPC( PAPCFUNC func
, HANDLE hthread
, ULONG_PTR data
)
704 struct queue_apc_request req
;
705 req
.handle
= hthread
;
707 req
.param
= (void *)data
;
708 CLIENT_SendRequest( REQ_QUEUE_APC
, -1, 1, &req
, sizeof(req
) );
709 return !CLIENT_WaitReply( NULL
, NULL
, 0 );
713 /**********************************************************************
714 * GetThreadTimes [KERNEL32.???] Obtains timing information.
717 * What are the fields where these values are stored?
723 BOOL WINAPI
GetThreadTimes(
724 HANDLE thread
, /* [in] Specifies the thread of interest */
725 LPFILETIME creationtime
, /* [out] When the thread was created */
726 LPFILETIME exittime
, /* [out] When the thread was destroyed */
727 LPFILETIME kerneltime
, /* [out] Time thread spent in kernel mode */
728 LPFILETIME usertime
) /* [out] Time thread spent in user mode */
730 FIXME("(0x%08x): stub\n",thread
);
731 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
736 /**********************************************************************
737 * AttachThreadInput [KERNEL32.8] Attaches input of 1 thread to other
739 * Attaches the input processing mechanism of one thread to that of
747 * 1. Reset the Key State (currenly per thread key state is not maintained)
749 BOOL WINAPI
AttachThreadInput(
750 DWORD idAttach
, /* [in] Thread to attach */
751 DWORD idAttachTo
, /* [in] Thread to attach to */
752 BOOL fAttach
) /* [in] Attach or detach */
754 MESSAGEQUEUE
*pSrcMsgQ
= 0, *pTgtMsgQ
= 0;
757 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
759 /* A thread cannot attach to itself */
760 if ( idAttach
== idAttachTo
)
763 /* According to the docs this method should fail if a
764 * "Journal record" hook is installed. (attaches all input queues together)
766 if ( HOOK_IsHooked( WH_JOURNALRECORD
) )
769 /* Retrieve message queues corresponding to the thread id's */
770 pTgtMsgQ
= (MESSAGEQUEUE
*)QUEUE_Lock( GetThreadQueue16( idAttach
) );
771 pSrcMsgQ
= (MESSAGEQUEUE
*)QUEUE_Lock( GetThreadQueue16( idAttachTo
) );
773 /* Ensure we have message queues and that Src and Tgt threads
774 * are not system threads.
776 if ( !pSrcMsgQ
|| !pTgtMsgQ
|| !pSrcMsgQ
->pQData
|| !pTgtMsgQ
->pQData
)
779 if (fAttach
) /* Attach threads */
781 /* Only attach if currently detached */
782 if ( pTgtMsgQ
->pQData
!= pSrcMsgQ
->pQData
)
784 /* First release the target threads perQData */
785 PERQDATA_Release( pTgtMsgQ
->pQData
);
787 /* Share a reference to the source threads perQDATA */
788 PERQDATA_Addref( pSrcMsgQ
->pQData
);
789 pTgtMsgQ
->pQData
= pSrcMsgQ
->pQData
;
792 else /* Detach threads */
794 /* Only detach if currently attached */
795 if ( pTgtMsgQ
->pQData
== pSrcMsgQ
->pQData
)
797 /* First release the target threads perQData */
798 PERQDATA_Release( pTgtMsgQ
->pQData
);
800 /* Give the target thread its own private perQDATA once more */
801 pTgtMsgQ
->pQData
= PERQDATA_CreateInstance();
805 /* TODO: Reset the Key State */
807 bRet
= 1; /* Success */
811 /* Unlock the queues before returning */
813 QUEUE_Unlock( pSrcMsgQ
);
815 QUEUE_Unlock( pTgtMsgQ
);
820 /**********************************************************************
821 * VWin32_BoostThreadGroup [KERNEL.535]
823 VOID WINAPI
VWin32_BoostThreadGroup( DWORD threadId
, INT boost
)
825 FIXME("(0x%08lx,%d): stub\n", threadId
, boost
);
828 /**********************************************************************
829 * VWin32_BoostThreadStatic [KERNEL.536]
831 VOID WINAPI
VWin32_BoostThreadStatic( DWORD threadId
, INT boost
)
833 FIXME("(0x%08lx,%d): stub\n", threadId
, boost
);
836 /**********************************************************************
837 * SetThreadLocale [KERNEL32.671] Sets the calling threads current locale.
844 * Implemented in NT only (3.1 and above according to MS
846 BOOL WINAPI
SetThreadLocale(
847 LCID lcid
) /* [in] Locale identifier */
849 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);