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
)
35 /* Is threading code initialized? */
36 BOOL THREAD_InitDone
= FALSE
;
38 /* THDB of the initial thread */
39 static THDB initial_thdb
;
41 /* Global thread list (FIXME: not thread-safe) */
42 THDB
*THREAD_First
= &initial_thdb
;
44 /***********************************************************************
47 * Return the current thread THDB pointer.
49 THDB
*THREAD_Current(void)
51 if (!THREAD_InitDone
) return NULL
;
52 return (THDB
*)((char *)NtCurrentTeb() - (int)&((THDB
*)0)->teb
);
55 /***********************************************************************
58 BOOL
THREAD_IsWin16( THDB
*thdb
)
60 return !thdb
|| !(thdb
->teb
.flags
& TEBF_WIN32
);
63 /***********************************************************************
66 * Convert a thread id to a THDB, making sure it is valid.
68 THDB
*THREAD_IdToTHDB( DWORD id
)
70 THDB
*thdb
= THREAD_First
;
72 if (!id
) return THREAD_Current();
75 if ((DWORD
)thdb
->server_tid
== id
) return thdb
;
78 /* Allow task handles to be used; convert to main thread */
81 TDB
*pTask
= (TDB
*)GlobalLock16( id
);
82 if (pTask
) return pTask
->thdb
;
84 SetLastError( ERROR_INVALID_PARAMETER
);
89 /***********************************************************************
92 * Initialization of a newly created THDB.
94 static BOOL
THREAD_InitTHDB( THDB
*thdb
, DWORD stack_size
, BOOL alloc_stack16
,
95 LPSECURITY_ATTRIBUTES sa
)
99 /* Allocate the stack */
102 * If stacksize smaller than 1 MB, allocate 1MB
103 * (one program wanted only 10 kB, which is recommendable, but some WINE
104 * functions, noteably in the files subdir, push HUGE structures and
105 * arrays on the stack. They probably shouldn't.)
106 * If stacksize larger than 16 MB, warn the user. (We could shrink the stack
107 * but this could give more or less unexplainable crashes.)
109 if (stack_size
<1024*1024)
110 stack_size
= 1024 * 1024;
111 if (stack_size
>= 16*1024*1024)
112 WARN("Thread stack size is %ld MB.\n",stack_size
/1024/1024);
113 thdb
->stack_base
= VirtualAlloc(NULL
, stack_size
+ SIGNAL_STACK_SIZE
+
114 (alloc_stack16
? 0x10000 : 0),
115 MEM_COMMIT
, PAGE_EXECUTE_READWRITE
);
116 if (!thdb
->stack_base
) goto error
;
117 /* Set a guard page at the bottom of the stack */
118 VirtualProtect( thdb
->stack_base
, 1, PAGE_EXECUTE_READWRITE
| PAGE_GUARD
,
120 thdb
->teb
.stack_top
= (char *)thdb
->stack_base
+ stack_size
;
121 thdb
->teb
.stack_low
= thdb
->stack_base
;
122 thdb
->signal_stack
= thdb
->teb
.stack_top
; /* start of signal stack */
124 /* Allocate the 16-bit stack selector */
128 thdb
->teb
.stack_sel
= SELECTOR_AllocBlock( thdb
->teb
.stack_top
,
129 0x10000, SEGMENT_DATA
,
131 if (!thdb
->teb
.stack_sel
) goto error
;
132 thdb
->cur_stack
= PTR_SEG_OFF_TO_SEGPTR( thdb
->teb
.stack_sel
,
133 0x10000 - sizeof(STACK16FRAME
) );
134 thdb
->signal_stack
= (char *)thdb
->signal_stack
+ 0x10000;
137 /* Create the thread event */
139 if (!(thdb
->event
= CreateEventA( NULL
, FALSE
, FALSE
, NULL
))) goto error
;
140 thdb
->event
= ConvertToGlobalHandle( thdb
->event
);
144 if (thdb
->event
) CloseHandle( thdb
->event
);
145 if (thdb
->teb
.stack_sel
) SELECTOR_FreeBlock( thdb
->teb
.stack_sel
, 1 );
146 if (thdb
->stack_base
) VirtualFree( thdb
->stack_base
, 0, MEM_RELEASE
);
151 /***********************************************************************
154 * Free data structures associated with a thread.
155 * Must be called from the context of another thread.
157 void CALLBACK
THREAD_FreeTHDB( ULONG_PTR arg
)
159 THDB
*thdb
= (THDB
*)arg
;
160 THDB
**pptr
= &THREAD_First
;
162 TRACE("(%p) called\n", thdb
);
163 SERVICE_Delete( thdb
->cleanup
);
165 PROCESS_CallUserSignalProc( USIG_THREAD_EXIT
, 0, 0 );
167 CloseHandle( thdb
->event
);
168 while (*pptr
&& (*pptr
!= thdb
)) pptr
= &(*pptr
)->next
;
169 if (*pptr
) *pptr
= thdb
->next
;
171 /* Free the associated memory */
173 if (thdb
->teb
.stack_sel
) SELECTOR_FreeBlock( thdb
->teb
.stack_sel
, 1 );
174 SELECTOR_FreeBlock( thdb
->teb_sel
, 1 );
175 close( thdb
->socket
);
176 VirtualFree( thdb
->stack_base
, 0, MEM_RELEASE
);
177 HeapFree( SystemHeap
, HEAP_NO_SERIALIZE
, thdb
);
181 /***********************************************************************
182 * THREAD_CreateInitialThread
184 * Create the initial thread.
186 THDB
*THREAD_CreateInitialThread( PDB
*pdb
, int server_fd
)
188 initial_thdb
.process
= pdb
;
189 initial_thdb
.teb
.except
= (void *)-1;
190 initial_thdb
.teb
.self
= &initial_thdb
.teb
;
191 initial_thdb
.teb
.flags
= /* TEBF_WIN32 */ 0;
192 initial_thdb
.teb
.tls_ptr
= initial_thdb
.tls_array
;
193 initial_thdb
.teb
.process
= pdb
;
194 initial_thdb
.exit_code
= 0x103; /* STILL_ACTIVE */
195 initial_thdb
.socket
= server_fd
;
197 /* Allocate the TEB selector (%fs register) */
199 if (!(initial_thdb
.teb_sel
= SELECTOR_AllocBlock( &initial_thdb
.teb
, 0x1000,
200 SEGMENT_DATA
, TRUE
, FALSE
)))
202 MESSAGE("Could not allocate fs register for initial thread\n" );
205 SET_CUR_THREAD( &initial_thdb
);
206 THREAD_InitDone
= TRUE
;
208 /* Now proceed with normal initialization */
210 if (CLIENT_InitThread()) return NULL
;
211 if (!THREAD_InitTHDB( &initial_thdb
, 0, TRUE
, NULL
)) return NULL
;
212 return &initial_thdb
;
216 /***********************************************************************
219 THDB
*THREAD_Create( PDB
*pdb
, DWORD flags
, DWORD stack_size
, BOOL alloc_stack16
,
220 LPSECURITY_ATTRIBUTES sa
, int *server_handle
)
222 struct new_thread_request request
;
223 struct new_thread_reply reply
= { NULL
, -1 };
226 THDB
*thdb
= HeapAlloc( SystemHeap
, HEAP_ZERO_MEMORY
, sizeof(THDB
) );
227 if (!thdb
) return NULL
;
229 thdb
->teb
.except
= (void *)-1;
230 thdb
->teb
.htask16
= pdb
->task
;
231 thdb
->teb
.self
= &thdb
->teb
;
232 thdb
->teb
.flags
= (pdb
->flags
& PDB32_WIN16_PROC
)? 0 : TEBF_WIN32
;
233 thdb
->teb
.tls_ptr
= thdb
->tls_array
;
234 thdb
->teb
.process
= pdb
;
235 thdb
->exit_code
= 0x103; /* STILL_ACTIVE */
239 /* Allocate the TEB selector (%fs register) */
241 thdb
->teb_sel
= SELECTOR_AllocBlock( &thdb
->teb
, 0x1000, SEGMENT_DATA
,
243 if (!thdb
->teb_sel
) goto error
;
245 /* Create the socket pair for server communication */
247 if (socketpair( AF_UNIX
, SOCK_STREAM
, 0, fd
) == -1)
249 SetLastError( ERROR_TOO_MANY_OPEN_FILES
); /* FIXME */
252 thdb
->socket
= fd
[0];
253 fcntl( fd
[0], F_SETFD
, 1 ); /* set close on exec flag */
255 /* Create the thread on the server side */
257 request
.pid
= thdb
->process
->server_pid
;
258 request
.suspend
= ((thdb
->flags
& CREATE_SUSPENDED
) != 0);
259 request
.inherit
= (sa
&& (sa
->nLength
>=sizeof(*sa
)) && sa
->bInheritHandle
);
260 CLIENT_SendRequest( REQ_NEW_THREAD
, fd
[1], 1, &request
, sizeof(request
) );
261 if (CLIENT_WaitSimpleReply( &reply
, sizeof(reply
), NULL
)) goto error
;
262 thdb
->server_tid
= reply
.tid
;
263 *server_handle
= reply
.handle
;
265 /* Do the rest of the initialization */
267 if (!THREAD_InitTHDB( thdb
, stack_size
, alloc_stack16
, sa
)) goto error
;
268 thdb
->next
= THREAD_First
;
271 /* Install cleanup handler */
273 thdb
->cleanup
= SERVICE_AddObject( *server_handle
,
274 THREAD_FreeTHDB
, (ULONG_PTR
)thdb
);
278 if (reply
.handle
!= -1) CloseHandle( reply
.handle
);
279 if (thdb
->teb_sel
) SELECTOR_FreeBlock( thdb
->teb_sel
, 1 );
280 HeapFree( SystemHeap
, 0, thdb
);
281 if (thdb
->socket
!= -1) close( thdb
->socket
);
286 /***********************************************************************
289 * Start execution of a newly created thread. Does not return.
291 static void THREAD_Start(void)
293 THDB
*thdb
= THREAD_Current();
294 LPTHREAD_START_ROUTINE func
= (LPTHREAD_START_ROUTINE
)thdb
->entry_point
;
295 PROCESS_CallUserSignalProc( USIG_THREAD_INIT
, 0, 0 );
297 MODULE_DllThreadAttach( NULL
);
299 if (thdb
->process
->flags
& PDB32_DEBUGGED
) DEBUG_SendCreateThreadEvent( func
);
301 ExitThread( func( thdb
->entry_arg
) );
305 /***********************************************************************
306 * CreateThread (KERNEL32.63)
308 HANDLE WINAPI
CreateThread( SECURITY_ATTRIBUTES
*sa
, DWORD stack
,
309 LPTHREAD_START_ROUTINE start
, LPVOID param
,
310 DWORD flags
, LPDWORD id
)
313 THDB
*thread
= THREAD_Create( PROCESS_Current(), flags
, stack
, TRUE
, sa
, &handle
);
314 if (!thread
) return INVALID_HANDLE_VALUE
;
315 thread
->teb
.flags
|= TEBF_WIN32
;
316 thread
->entry_point
= start
;
317 thread
->entry_arg
= param
;
318 thread
->startup
= THREAD_Start
;
319 if (SYSDEPS_SpawnThread( thread
) == -1)
321 CloseHandle( handle
);
322 return INVALID_HANDLE_VALUE
;
324 if (id
) *id
= (DWORD
)thread
->server_tid
;
329 /***********************************************************************
330 * ExitThread [KERNEL32.215] Ends a thread
335 void WINAPI
ExitThread( DWORD code
) /* [in] Exit code for this thread */
337 MODULE_DllThreadDetach( NULL
);
338 TerminateThread( GetCurrentThread(), code
);
342 /***********************************************************************
343 * GetCurrentThread [KERNEL32.200] Gets pseudohandle for current thread
346 * Pseudohandle for the current thread
348 HANDLE WINAPI
GetCurrentThread(void)
350 return CURRENT_THREAD_PSEUDOHANDLE
;
354 /***********************************************************************
355 * GetCurrentThreadId [KERNEL32.201] Returns thread identifier.
358 * Thread identifier of calling thread
360 DWORD WINAPI
GetCurrentThreadId(void)
362 THDB
*thdb
= THREAD_Current();
364 assert( thdb
->server_tid
);
365 return (DWORD
)thdb
->server_tid
;
369 /**********************************************************************
370 * GetLastError [KERNEL.148] [KERNEL32.227] Returns last-error code.
373 * Calling thread's last error code value.
375 DWORD WINAPI
GetLastError(void)
377 THDB
*thread
= THREAD_Current();
378 DWORD ret
= thread
->last_error
;
379 TRACE("0x%lx\n",ret
);
384 /**********************************************************************
385 * SetLastError [KERNEL.147] [KERNEL32.497] Sets the last-error code.
390 void WINAPI
SetLastError(
391 DWORD error
) /* [in] Per-thread error code */
393 THDB
*thread
= THREAD_Current();
394 /* This one must work before we have a thread (FIXME) */
396 TRACE("%p error=0x%lx\n",thread
,error
);
399 thread
->last_error
= error
;
403 /**********************************************************************
404 * SetLastErrorEx [USER32.485] Sets the last-error code.
409 void WINAPI
SetLastErrorEx(
410 DWORD error
, /* [in] Per-thread error code */
411 DWORD type
) /* [in] Error type */
413 TRACE("(0x%08lx, 0x%08lx)\n", error
,type
);
420 /* Fall through for now */
422 FIXME("(error=%08lx, type=%08lx): Unhandled type\n", error
,type
);
425 SetLastError( error
);
429 /**********************************************************************
430 * TlsAlloc [KERNEL32.530] Allocates a TLS index.
432 * Allocates a thread local storage index
436 * Failure: 0xFFFFFFFF
438 DWORD WINAPI
TlsAlloc( void )
440 THDB
*thread
= THREAD_Current();
441 DWORD i
, mask
, ret
= 0;
442 DWORD
*bits
= thread
->process
->tls_bits
;
443 EnterCriticalSection( &thread
->process
->crit_section
);
444 if (*bits
== 0xffffffff)
448 if (*bits
== 0xffffffff)
450 LeaveCriticalSection( &thread
->process
->crit_section
);
451 SetLastError( ERROR_NO_MORE_ITEMS
);
455 for (i
= 0, mask
= 1; i
< 32; i
++, mask
<<= 1) if (!(*bits
& mask
)) break;
457 LeaveCriticalSection( &thread
->process
->crit_section
);
462 /**********************************************************************
463 * TlsFree [KERNEL32.531] Releases a TLS index.
465 * Releases a thread local storage index, making it available for reuse
472 DWORD index
) /* [in] TLS Index to free */
475 THDB
*thread
= THREAD_Current();
476 DWORD
*bits
= thread
->process
->tls_bits
;
479 SetLastError( ERROR_INVALID_PARAMETER
);
482 EnterCriticalSection( &thread
->process
->crit_section
);
483 if (index
>= 32) bits
++;
484 mask
= (1 << (index
& 31));
485 if (!(*bits
& mask
)) /* already free? */
487 LeaveCriticalSection( &thread
->process
->crit_section
);
488 SetLastError( ERROR_INVALID_PARAMETER
);
492 thread
->tls_array
[index
] = 0;
493 /* FIXME: should zero all other thread values */
494 LeaveCriticalSection( &thread
->process
->crit_section
);
499 /**********************************************************************
500 * TlsGetValue [KERNEL32.532] Gets value in a thread's TLS slot
503 * Success: Value stored in calling thread's TLS slot for index
504 * Failure: 0 and GetLastError returns NO_ERROR
506 LPVOID WINAPI
TlsGetValue(
507 DWORD index
) /* [in] TLS index to retrieve value for */
509 THDB
*thread
= THREAD_Current();
512 SetLastError( ERROR_INVALID_PARAMETER
);
515 SetLastError( ERROR_SUCCESS
);
516 return thread
->tls_array
[index
];
520 /**********************************************************************
521 * TlsSetValue [KERNEL32.533] Stores a value in the thread's TLS slot.
527 BOOL WINAPI
TlsSetValue(
528 DWORD index
, /* [in] TLS index to set value for */
529 LPVOID value
) /* [in] Value to be stored */
531 THDB
*thread
= THREAD_Current();
534 SetLastError( ERROR_INVALID_PARAMETER
);
537 thread
->tls_array
[index
] = value
;
542 /***********************************************************************
543 * SetThreadContext [KERNEL32.670] Sets context of thread.
549 BOOL WINAPI
SetThreadContext(
550 HANDLE handle
, /* [in] Handle to thread with context */
551 CONTEXT
*context
) /* [out] Address of context structure */
553 FIXME("not implemented\n" );
557 /***********************************************************************
558 * GetThreadContext [KERNEL32.294] Retrieves context of thread.
564 BOOL WINAPI
GetThreadContext(
565 HANDLE handle
, /* [in] Handle to thread with context */
566 CONTEXT
*context
) /* [out] Address of context structure */
570 FIXME("returning dummy info\n" );
572 /* make up some plausible values for segment registers */
585 /**********************************************************************
586 * GetThreadPriority [KERNEL32.296] Returns priority for thread.
589 * Success: Thread's priority level.
590 * Failure: THREAD_PRIORITY_ERROR_RETURN
592 INT WINAPI
GetThreadPriority(
593 HANDLE hthread
) /* [in] Handle to thread */
595 struct get_thread_info_request req
;
596 struct get_thread_info_reply reply
;
597 req
.handle
= hthread
;
598 CLIENT_SendRequest( REQ_GET_THREAD_INFO
, -1, 1, &req
, sizeof(req
) );
599 if (CLIENT_WaitSimpleReply( &reply
, sizeof(reply
), NULL
))
600 return THREAD_PRIORITY_ERROR_RETURN
;
601 return reply
.priority
;
605 /**********************************************************************
606 * SetThreadPriority [KERNEL32.514] Sets priority for thread.
612 BOOL WINAPI
SetThreadPriority(
613 HANDLE hthread
, /* [in] Handle to thread */
614 INT priority
) /* [in] Thread priority level */
616 struct set_thread_info_request req
;
617 req
.handle
= hthread
;
618 req
.priority
= priority
;
619 req
.mask
= SET_THREAD_INFO_PRIORITY
;
620 CLIENT_SendRequest( REQ_SET_THREAD_INFO
, -1, 1, &req
, sizeof(req
) );
621 return !CLIENT_WaitReply( NULL
, NULL
, 0 );
625 /**********************************************************************
626 * SetThreadAffinityMask (KERNEL32.669)
628 DWORD WINAPI
SetThreadAffinityMask( HANDLE hThread
, DWORD dwThreadAffinityMask
)
630 struct set_thread_info_request req
;
631 req
.handle
= hThread
;
632 req
.affinity
= dwThreadAffinityMask
;
633 req
.mask
= SET_THREAD_INFO_AFFINITY
;
634 CLIENT_SendRequest( REQ_SET_THREAD_INFO
, -1, 1, &req
, sizeof(req
) );
635 if (CLIENT_WaitReply( NULL
, NULL
, 0 )) return 0;
636 return 1; /* FIXME: should return previous value */
640 /**********************************************************************
641 * TerminateThread [KERNEL32.685] Terminates a thread
647 BOOL WINAPI
TerminateThread(
648 HANDLE handle
, /* [in] Handle to thread */
649 DWORD exitcode
) /* [in] Exit code for thread */
651 struct terminate_thread_request req
;
653 req
.exit_code
= exitcode
;
654 CLIENT_SendRequest( REQ_TERMINATE_THREAD
, -1, 1, &req
, sizeof(req
) );
655 return !CLIENT_WaitReply( NULL
, NULL
, 0 );
659 /**********************************************************************
660 * GetExitCodeThread [KERNEL32.???] Gets termination status of thread.
666 BOOL WINAPI
GetExitCodeThread(
667 HANDLE hthread
, /* [in] Handle to thread */
668 LPDWORD exitcode
) /* [out] Address to receive termination status */
670 struct get_thread_info_request req
;
671 struct get_thread_info_reply reply
;
672 req
.handle
= hthread
;
673 CLIENT_SendRequest( REQ_GET_THREAD_INFO
, -1, 1, &req
, sizeof(req
) );
674 if (CLIENT_WaitSimpleReply( &reply
, sizeof(reply
), NULL
)) return FALSE
;
675 if (exitcode
) *exitcode
= reply
.exit_code
;
680 /**********************************************************************
681 * ResumeThread [KERNEL32.587] Resumes a thread.
683 * Decrements a thread's suspend count. When count is zero, the
684 * execution of the thread is resumed.
687 * Success: Previous suspend count
688 * Failure: 0xFFFFFFFF
691 DWORD WINAPI
ResumeThread(
692 HANDLE hthread
) /* [in] Identifies thread to restart */
694 struct resume_thread_request req
;
695 struct resume_thread_reply reply
;
696 req
.handle
= hthread
;
697 CLIENT_SendRequest( REQ_RESUME_THREAD
, -1, 1, &req
, sizeof(req
) );
698 if (CLIENT_WaitSimpleReply( &reply
, sizeof(reply
), NULL
)) return 0xffffffff;
703 /**********************************************************************
704 * SuspendThread [KERNEL32.681] Suspends a thread.
707 * Success: Previous suspend count
708 * Failure: 0xFFFFFFFF
710 DWORD WINAPI
SuspendThread(
711 HANDLE hthread
) /* [in] Handle to the thread */
713 struct suspend_thread_request req
;
714 struct suspend_thread_reply reply
;
715 req
.handle
= hthread
;
716 CLIENT_SendRequest( REQ_SUSPEND_THREAD
, -1, 1, &req
, sizeof(req
) );
717 if (CLIENT_WaitSimpleReply( &reply
, sizeof(reply
), NULL
)) return 0xffffffff;
722 /***********************************************************************
723 * QueueUserAPC (KERNEL32.566)
725 DWORD WINAPI
QueueUserAPC( PAPCFUNC func
, HANDLE hthread
, ULONG_PTR data
)
727 struct queue_apc_request req
;
728 req
.handle
= hthread
;
730 req
.param
= (void *)data
;
731 CLIENT_SendRequest( REQ_QUEUE_APC
, -1, 1, &req
, sizeof(req
) );
732 return !CLIENT_WaitReply( NULL
, NULL
, 0 );
736 /**********************************************************************
737 * GetThreadTimes [KERNEL32.???] Obtains timing information.
740 * What are the fields where these values are stored?
746 BOOL WINAPI
GetThreadTimes(
747 HANDLE thread
, /* [in] Specifies the thread of interest */
748 LPFILETIME creationtime
, /* [out] When the thread was created */
749 LPFILETIME exittime
, /* [out] When the thread was destroyed */
750 LPFILETIME kerneltime
, /* [out] Time thread spent in kernel mode */
751 LPFILETIME usertime
) /* [out] Time thread spent in user mode */
753 FIXME("(0x%08x): stub\n",thread
);
754 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
759 /**********************************************************************
760 * AttachThreadInput [KERNEL32.8] Attaches input of 1 thread to other
762 * Attaches the input processing mechanism of one thread to that of
770 * 1. Reset the Key State (currenly per thread key state is not maintained)
772 BOOL WINAPI
AttachThreadInput(
773 DWORD idAttach
, /* [in] Thread to attach */
774 DWORD idAttachTo
, /* [in] Thread to attach to */
775 BOOL fAttach
) /* [in] Attach or detach */
777 MESSAGEQUEUE
*pSrcMsgQ
= 0, *pTgtMsgQ
= 0;
780 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
782 /* A thread cannot attach to itself */
783 if ( idAttach
== idAttachTo
)
786 /* According to the docs this method should fail if a
787 * "Journal record" hook is installed. (attaches all input queues together)
789 if ( HOOK_IsHooked( WH_JOURNALRECORD
) )
792 /* Retrieve message queues corresponding to the thread id's */
793 pTgtMsgQ
= (MESSAGEQUEUE
*)QUEUE_Lock( GetThreadQueue16( idAttach
) );
794 pSrcMsgQ
= (MESSAGEQUEUE
*)QUEUE_Lock( GetThreadQueue16( idAttachTo
) );
796 /* Ensure we have message queues and that Src and Tgt threads
797 * are not system threads.
799 if ( !pSrcMsgQ
|| !pTgtMsgQ
|| !pSrcMsgQ
->pQData
|| !pTgtMsgQ
->pQData
)
802 if (fAttach
) /* Attach threads */
804 /* Only attach if currently detached */
805 if ( pTgtMsgQ
->pQData
!= pSrcMsgQ
->pQData
)
807 /* First release the target threads perQData */
808 PERQDATA_Release( pTgtMsgQ
->pQData
);
810 /* Share a reference to the source threads perQDATA */
811 PERQDATA_Addref( pSrcMsgQ
->pQData
);
812 pTgtMsgQ
->pQData
= pSrcMsgQ
->pQData
;
815 else /* Detach threads */
817 /* Only detach if currently attached */
818 if ( pTgtMsgQ
->pQData
== pSrcMsgQ
->pQData
)
820 /* First release the target threads perQData */
821 PERQDATA_Release( pTgtMsgQ
->pQData
);
823 /* Give the target thread its own private perQDATA once more */
824 pTgtMsgQ
->pQData
= PERQDATA_CreateInstance();
828 /* TODO: Reset the Key State */
830 bRet
= 1; /* Success */
834 /* Unlock the queues before returning */
836 QUEUE_Unlock( pSrcMsgQ
);
838 QUEUE_Unlock( pTgtMsgQ
);
843 /**********************************************************************
844 * VWin32_BoostThreadGroup [KERNEL.535]
846 VOID WINAPI
VWin32_BoostThreadGroup( DWORD threadId
, INT boost
)
848 FIXME("(0x%08lx,%d): stub\n", threadId
, boost
);
851 /**********************************************************************
852 * VWin32_BoostThreadStatic [KERNEL.536]
854 VOID WINAPI
VWin32_BoostThreadStatic( DWORD threadId
, INT boost
)
856 FIXME("(0x%08lx,%d): stub\n", threadId
, boost
);
859 /**********************************************************************
860 * SetThreadLocale [KERNEL32.671] Sets the calling threads current locale.
867 * Implemented in NT only (3.1 and above according to MS
869 BOOL WINAPI
SetThreadLocale(
870 LCID lcid
) /* [in] Locale identifier */
872 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);