Release 980628
[wine/multimedia.git] / scheduler / thread.c
blob1137d35c6ee45d4be08ec8af8051cde62d923144
1 /*
2 * Win32 threads
4 * Copyright 1996 Alexandre Julliard
5 */
7 #include <assert.h>
8 #include <signal.h>
9 #include <unistd.h>
10 #include "thread.h"
11 #include "process.h"
12 #include "winerror.h"
13 #include "heap.h"
14 #include "selectors.h"
15 #include "miscemu.h"
16 #include "winnt.h"
17 #include "debug.h"
19 #ifndef __i386__
20 THDB *pCurrentThread;
21 #endif
23 static BOOL32 THREAD_Signaled( K32OBJ *obj, DWORD thread_id );
24 static BOOL32 THREAD_Satisfied( K32OBJ *obj, DWORD thread_id );
25 static void THREAD_AddWait( K32OBJ *obj, DWORD thread_id );
26 static void THREAD_RemoveWait( K32OBJ *obj, DWORD thread_id );
27 static void THREAD_Destroy( K32OBJ *obj );
29 const K32OBJ_OPS THREAD_Ops =
31 THREAD_Signaled, /* signaled */
32 THREAD_Satisfied, /* satisfied */
33 THREAD_AddWait, /* add_wait */
34 THREAD_RemoveWait, /* remove_wait */
35 NULL, /* read */
36 NULL, /* write */
37 THREAD_Destroy /* destroy */
40 /* The pseudohandle used for the current thread, see GetCurrentThread */
41 #define CURRENT_THREAD_PSEUDOHANDLE 0xfffffffe
43 /* Is threading code initialized? */
44 BOOL32 THREAD_InitDone = FALSE;
46 /**********************************************************************
47 * THREAD_GetPtr
49 * Return a pointer to a thread object. The object count must be decremented
50 * when no longer used.
52 THDB *THREAD_GetPtr( HANDLE32 handle, DWORD access )
54 THDB *thread;
56 if (handle == CURRENT_THREAD_PSEUDOHANDLE) /* Self-thread handle */
58 thread = THREAD_Current();
59 K32OBJ_IncCount( &thread->header );
61 else thread = (THDB *)HANDLE_GetObjPtr( PROCESS_Current(), handle,
62 K32OBJ_THREAD, access );
63 return thread;
67 /***********************************************************************
68 * THREAD_Current
70 * Return the current thread THDB pointer.
72 THDB *THREAD_Current(void)
74 if (!THREAD_InitDone) return NULL;
75 return (THDB *)((char *)NtCurrentTeb() - (int)&((THDB *)0)->teb);
79 /***********************************************************************
80 * THREAD_AddQueue
82 * Add a thread to a queue.
84 void THREAD_AddQueue( THREAD_QUEUE *queue, THDB *thread )
86 THREAD_ENTRY *entry = HeapAlloc( SystemHeap, HEAP_NO_SERIALIZE,
87 sizeof(*entry) );
88 assert(entry);
89 SYSTEM_LOCK();
90 entry->thread = thread;
91 if (*queue)
93 entry->next = (*queue)->next;
94 (*queue)->next = entry;
96 else entry->next = entry;
97 *queue = entry;
98 SYSTEM_UNLOCK();
101 /***********************************************************************
102 * THREAD_RemoveQueue
104 * Remove a thread from a queue.
106 void THREAD_RemoveQueue( THREAD_QUEUE *queue, THDB *thread )
108 THREAD_ENTRY *entry = *queue;
109 SYSTEM_LOCK();
110 if (entry->next == entry) /* Only one element in the queue */
112 assert( entry->thread == thread );
113 *queue = NULL;
115 else
117 THREAD_ENTRY *next;
118 while (entry->next->thread != thread)
120 entry = entry->next;
121 assert( entry != *queue ); /* Have we come all the way around? */
123 if ((next = entry->next) == *queue) *queue = entry;
124 entry->next = entry->next->next;
125 entry = next; /* This is the one we want to free */
127 HeapFree( SystemHeap, 0, entry );
128 SYSTEM_UNLOCK();
132 /***********************************************************************
133 * THREAD_Create
135 THDB *THREAD_Create( PDB32 *pdb, DWORD stack_size, BOOL32 alloc_stack16,
136 LPTHREAD_START_ROUTINE start_addr, LPVOID param )
138 DWORD old_prot;
139 WORD cs, ds;
141 THDB *thdb = HeapAlloc( SystemHeap, HEAP_ZERO_MEMORY, sizeof(THDB) );
142 if (!thdb) return NULL;
143 thdb->header.type = K32OBJ_THREAD;
144 thdb->header.refcount = 1;
145 thdb->process = pdb;
146 thdb->teb.except = (void *)-1;
147 thdb->teb.htask16 = 0; /* FIXME */
148 thdb->teb.self = &thdb->teb;
149 thdb->teb.tls_ptr = thdb->tls_array;
150 thdb->teb.process = pdb;
151 thdb->wait_list = &thdb->wait_struct;
152 thdb->exit_code = 0x103; /* STILL_ACTIVE */
153 thdb->entry_point = start_addr;
154 thdb->entry_arg = param;
156 /* Allocate the stack */
158 /* FIXME:
159 * If stacksize smaller than 1 MB, allocate 1MB
160 * (one program wanted only 10 kB, which is recommendable, but some WINE
161 * functions, noteably in the files subdir, push HUGE structures and
162 * arrays on the stack. They probably shouldn't.)
163 * If stacksize larger than 16 MB, warn the user. (We could shrink the stack
164 * but this could give more or less unexplainable crashes.)
166 if (stack_size<1024*1024)
167 stack_size = 1024 * 1024;
168 if (stack_size >= 16*1024*1024)
169 WARN(thread,"Thread stack size is %ld MB.\n",stack_size/1024/1024);
170 thdb->stack_base = VirtualAlloc(NULL,
171 stack_size + (alloc_stack16 ? 0x10000 : 0),
172 MEM_COMMIT, PAGE_EXECUTE_READWRITE );
173 if (!thdb->stack_base) goto error;
174 /* Set a guard page at the bottom of the stack */
175 VirtualProtect( thdb->stack_base, 1, PAGE_EXECUTE_READWRITE | PAGE_GUARD,
176 &old_prot );
177 thdb->teb.stack_top = (char *)thdb->stack_base + stack_size;
178 thdb->teb.stack_low = thdb->stack_base;
179 thdb->exit_stack = thdb->teb.stack_top;
181 /* Allocate the TEB selector (%fs register) */
183 thdb->teb_sel = SELECTOR_AllocBlock( &thdb->teb, 0x1000, SEGMENT_DATA,
184 TRUE, FALSE );
185 if (!thdb->teb_sel) goto error;
187 /* Allocate the 16-bit stack selector */
189 if (alloc_stack16)
191 thdb->teb.stack_sel = SELECTOR_AllocBlock( thdb->teb.stack_top,
192 0x10000, SEGMENT_DATA,
193 FALSE, FALSE );
194 if (!thdb->teb.stack_sel) goto error;
195 thdb->cur_stack = PTR_SEG_OFF_TO_SEGPTR( thdb->teb.stack_sel, 0xfffc );
198 /* Allocate the event */
200 if (!(thdb->event = EVENT_Create( TRUE, FALSE ))) goto error;
202 /* Initialize the thread context */
204 GET_CS(cs);
205 GET_DS(ds);
206 thdb->pcontext = &thdb->context;
207 thdb->context.SegCs = cs;
208 thdb->context.SegDs = ds;
209 thdb->context.SegEs = ds;
210 thdb->context.SegGs = ds;
211 thdb->context.SegSs = ds;
212 thdb->context.SegFs = thdb->teb_sel;
213 thdb->context.Eip = (DWORD)start_addr;
214 thdb->context.Esp = (DWORD)thdb->teb.stack_top;
215 PE_InitTls( thdb );
216 return thdb;
218 error:
219 if (thdb->event) K32OBJ_DecCount( thdb->event );
220 if (thdb->teb.stack_sel) SELECTOR_FreeBlock( thdb->teb.stack_sel, 1 );
221 if (thdb->teb_sel) SELECTOR_FreeBlock( thdb->teb_sel, 1 );
222 if (thdb->stack_base) VirtualFree( thdb->stack_base, 0, MEM_RELEASE );
223 HeapFree( SystemHeap, 0, thdb );
224 return NULL;
228 /***********************************************************************
229 * THREAD_Signaled
231 static BOOL32 THREAD_Signaled( K32OBJ *obj, DWORD thread_id )
233 THDB *thdb = (THDB *)obj;
234 assert( obj->type == K32OBJ_THREAD );
235 return K32OBJ_OPS( thdb->event )->signaled( thdb->event, thread_id );
239 /***********************************************************************
240 * THREAD_Satisfied
242 * Wait on this object has been satisfied.
244 static BOOL32 THREAD_Satisfied( K32OBJ *obj, DWORD thread_id )
246 THDB *thdb = (THDB *)obj;
247 assert( obj->type == K32OBJ_THREAD );
248 return K32OBJ_OPS( thdb->event )->satisfied( thdb->event, thread_id );
252 /***********************************************************************
253 * THREAD_AddWait
255 * Add thread to object wait queue.
257 static void THREAD_AddWait( K32OBJ *obj, DWORD thread_id )
259 THDB *thdb = (THDB *)obj;
260 assert( obj->type == K32OBJ_THREAD );
261 return K32OBJ_OPS( thdb->event )->add_wait( thdb->event, thread_id );
265 /***********************************************************************
266 * THREAD_RemoveWait
268 * Remove thread from object wait queue.
270 static void THREAD_RemoveWait( K32OBJ *obj, DWORD thread_id )
272 THDB *thdb = (THDB *)obj;
273 assert( obj->type == K32OBJ_THREAD );
274 return K32OBJ_OPS( thdb->event )->remove_wait( thdb->event, thread_id );
278 /***********************************************************************
279 * THREAD_Destroy
281 static void THREAD_Destroy( K32OBJ *ptr )
283 THDB *thdb = (THDB *)ptr;
285 assert( ptr->type == K32OBJ_THREAD );
286 ptr->type = K32OBJ_UNKNOWN;
288 /* Free the associated memory */
290 #ifdef __i386__
292 /* Check if we are deleting the current thread */
293 WORD fs;
294 GET_FS( fs );
295 if (fs == thdb->teb_sel)
297 GET_DS( fs );
298 SET_FS( fs );
301 #endif
302 K32OBJ_DecCount( thdb->event );
303 SELECTOR_FreeBlock( thdb->teb_sel, 1 );
304 if (thdb->teb.stack_sel) SELECTOR_FreeBlock( thdb->teb.stack_sel, 1 );
305 HeapFree( SystemHeap, 0, thdb );
310 /***********************************************************************
311 * CreateThread (KERNEL32.63)
313 HANDLE32 WINAPI CreateThread( SECURITY_ATTRIBUTES *sa, DWORD stack,
314 LPTHREAD_START_ROUTINE start, LPVOID param,
315 DWORD flags, LPDWORD id )
317 HANDLE32 handle;
318 BOOL32 inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
320 THDB *thread = THREAD_Create( PROCESS_Current(), stack,
321 TRUE, start, param );
322 if (!thread) return INVALID_HANDLE_VALUE32;
323 handle = HANDLE_Alloc( PROCESS_Current(), &thread->header,
324 THREAD_ALL_ACCESS, inherit );
325 if (handle == INVALID_HANDLE_VALUE32) goto error;
326 if (SYSDEPS_SpawnThread( thread ) == -1) goto error;
327 *id = THDB_TO_THREAD_ID( thread );
328 return handle;
330 error:
331 K32OBJ_DecCount( &thread->header );
332 return INVALID_HANDLE_VALUE32;
336 /***********************************************************************
337 * ExitThread [KERNEL32.215] Ends a thread
339 * RETURNS
340 * None
342 void WINAPI ExitThread(
343 DWORD code) /* [in] Exit code for this thread */
345 THDB *thdb = THREAD_Current();
346 LONG count;
348 SYSTEM_LOCK();
349 thdb->exit_code = code;
350 EVENT_Set( thdb->event );
352 /* Abandon all owned mutexes */
353 while (thdb->mutex_list) MUTEX_Abandon( thdb->mutex_list );
355 /* FIXME: should free the stack somehow */
356 #if 0
357 /* FIXME: We cannot do this; once the current thread is destroyed,
358 synchronization primitives do not work properly. */
359 K32OBJ_DecCount( &thdb->header );
360 #endif
361 /* Completely unlock the system lock just in case */
362 count = SYSTEM_LOCK_COUNT();
363 while (count--) SYSTEM_UNLOCK();
364 SYSDEPS_ExitThread();
368 /***********************************************************************
369 * GetCurrentThread [KERNEL32.200] Gets pseudohandle for current thread
371 * RETURNS
372 * Pseudohandle for the current thread
374 HANDLE32 WINAPI GetCurrentThread(void)
376 return CURRENT_THREAD_PSEUDOHANDLE;
380 /***********************************************************************
381 * GetCurrentThreadId [KERNEL32.201] Returns thread identifier.
383 * RETURNS
384 * Thread identifier of calling thread
386 DWORD WINAPI GetCurrentThreadId(void)
388 return THDB_TO_THREAD_ID( THREAD_Current() );
392 /**********************************************************************
393 * GetLastError [KERNEL.148] [KERNEL32.227] Returns last-error code.
395 * RETURNS
396 * Calling thread's last error code value.
398 DWORD WINAPI GetLastError(void)
400 THDB *thread = THREAD_Current();
401 return thread->last_error;
405 /**********************************************************************
406 * SetLastError [KERNEL.147] [KERNEL32.497] Sets the last-error code.
408 * RETURNS
409 * None.
411 void WINAPI SetLastError(
412 DWORD error) /* [in] Per-thread error code */
414 THDB *thread = THREAD_Current();
415 /* This one must work before we have a thread (FIXME) */
416 if (thread) thread->last_error = error;
420 /**********************************************************************
421 * SetLastErrorEx [USER32.485] Sets the last-error code.
423 * RETURNS
424 * None.
426 void WINAPI SetLastErrorEx(
427 DWORD error, /* [in] Per-thread error code */
428 DWORD type) /* [in] Error type */
430 TRACE(thread, "(%08lx, %08lx)\n", error,type);
431 switch(type) {
432 case 0:
433 break;
434 case SLE_ERROR:
435 case SLE_MINORERROR:
436 case SLE_WARNING:
437 /* Fall through for now */
438 default:
439 FIXME(thread, "(error=%08lx, type=%08lx): Unhandled type\n", error,type);
440 break;
442 SetLastError( error );
446 /**********************************************************************
447 * THREAD_TlsAlloc
449 DWORD THREAD_TlsAlloc(THDB *thread)
451 DWORD i, mask, ret = 0;
452 DWORD *bits = thread->process->tls_bits;
453 EnterCriticalSection( &thread->process->crit_section );
454 if (*bits == 0xffffffff)
456 bits++;
457 ret = 32;
458 if (*bits == 0xffffffff)
460 LeaveCriticalSection( &thread->process->crit_section );
461 SetLastError( ERROR_NO_MORE_ITEMS );
462 return 0xffffffff;
465 for (i = 0, mask = 1; i < 32; i++, mask <<= 1) if (!(*bits & mask)) break;
466 *bits |= mask;
467 LeaveCriticalSection( &thread->process->crit_section );
468 return ret + i;
472 /**********************************************************************
473 * TlsAlloc [KERNEL32.530] Allocates a TLS index.
475 * Allocates a thread local storage index
477 * RETURNS
478 * Success: TLS Index
479 * Failure: 0xFFFFFFFF
481 DWORD WINAPI TlsAlloc(void)
483 return THREAD_TlsAlloc(THREAD_Current());
487 /**********************************************************************
488 * TlsFree [KERNEL32.531] Releases a TLS index.
490 * Releases a thread local storage index, making it available for reuse
492 * RETURNS
493 * Success: TRUE
494 * Failure: FALSE
496 BOOL32 WINAPI TlsFree(
497 DWORD index) /* [in] TLS Index to free */
499 DWORD mask;
500 THDB *thread = THREAD_Current();
501 DWORD *bits = thread->process->tls_bits;
502 if (index >= 64)
504 SetLastError( ERROR_INVALID_PARAMETER );
505 return FALSE;
507 EnterCriticalSection( &thread->process->crit_section );
508 if (index >= 32) bits++;
509 mask = (1 << (index & 31));
510 if (!(*bits & mask)) /* already free? */
512 LeaveCriticalSection( &thread->process->crit_section );
513 SetLastError( ERROR_INVALID_PARAMETER );
514 return FALSE;
516 *bits &= ~mask;
517 thread->tls_array[index] = 0;
518 /* FIXME: should zero all other thread values */
519 LeaveCriticalSection( &thread->process->crit_section );
520 return TRUE;
524 /**********************************************************************
525 * TlsGetValue [KERNEL32.532] Gets value in a thread's TLS slot
527 * RETURNS
528 * Success: Value stored in calling thread's TLS slot for index
529 * Failure: 0 and GetLastError returns NO_ERROR
531 LPVOID WINAPI TlsGetValue(
532 DWORD index) /* [in] TLS index to retrieve value for */
534 THDB *thread = THREAD_Current();
535 if (index >= 64)
537 SetLastError( ERROR_INVALID_PARAMETER );
538 return NULL;
540 SetLastError( ERROR_SUCCESS );
541 return thread->tls_array[index];
545 /**********************************************************************
546 * TlsSetValue [KERNEL32.533] Stores a value in the thread's TLS slot.
548 * RETURNS
549 * Success: TRUE
550 * Failure: FALSE
552 BOOL32 WINAPI TlsSetValue(
553 DWORD index, /* [in] TLS index to set value for */
554 LPVOID value) /* [in] Value to be stored */
556 THDB *thread = THREAD_Current();
557 if (index >= 64)
559 SetLastError( ERROR_INVALID_PARAMETER );
560 return FALSE;
562 thread->tls_array[index] = value;
563 return TRUE;
567 /***********************************************************************
568 * SetThreadContext [KERNEL32.670] Sets context of thread.
570 * RETURNS
571 * Success: TRUE
572 * Failure: FALSE
574 BOOL32 WINAPI SetThreadContext(
575 HANDLE32 handle, /* [in] Handle to thread with context */
576 CONTEXT *context) /* [out] Address of context structure */
578 THDB *thread = THREAD_GetPtr( handle, THREAD_GET_CONTEXT );
579 if (!thread) return FALSE;
580 *context = thread->context;
581 K32OBJ_DecCount( &thread->header );
582 return TRUE;
585 /***********************************************************************
586 * GetThreadContext [KERNEL32.294] Retrieves context of thread.
588 * RETURNS
589 * Success: TRUE
590 * Failure: FALSE
592 BOOL32 WINAPI GetThreadContext(
593 HANDLE32 handle, /* [in] Handle to thread with context */
594 CONTEXT *context) /* [out] Address of context structure */
596 THDB *thread = THREAD_GetPtr( handle, THREAD_GET_CONTEXT );
597 if (!thread) return FALSE;
598 *context = thread->context;
599 K32OBJ_DecCount( &thread->header );
600 return TRUE;
604 /**********************************************************************
605 * GetThreadPriority [KERNEL32.296] Returns priority for thread.
607 * RETURNS
608 * Success: Thread's priority level.
609 * Failure: THREAD_PRIORITY_ERROR_RETURN
611 INT32 WINAPI GetThreadPriority(
612 HANDLE32 hthread) /* [in] Handle to thread */
614 THDB *thread;
615 INT32 ret;
617 if (!(thread = THREAD_GetPtr( hthread, THREAD_QUERY_INFORMATION )))
618 return THREAD_PRIORITY_ERROR_RETURN;
619 ret = thread->delta_priority;
620 K32OBJ_DecCount( &thread->header );
621 return ret;
625 /**********************************************************************
626 * SetThreadPriority [KERNEL32.514] Sets priority for thread.
628 * RETURNS
629 * Success: TRUE
630 * Failure: FALSE
632 BOOL32 WINAPI SetThreadPriority(
633 HANDLE32 hthread, /* [in] Handle to thread */
634 INT32 priority) /* [in] Thread priority level */
636 THDB *thread;
638 if (!(thread = THREAD_GetPtr( hthread, THREAD_SET_INFORMATION )))
639 return FALSE;
640 thread->delta_priority = priority;
641 K32OBJ_DecCount( &thread->header );
642 return TRUE;
646 /**********************************************************************
647 * TerminateThread [KERNEL32.???] Terminates a thread
649 * RETURNS
650 * Success: TRUE
651 * Failure: FALSE
653 BOOL32 WINAPI TerminateThread(
654 HANDLE32 handle, /* [in] Handle to thread */
655 DWORD exitcode) /* [in] Exit code for thread */
657 FIXME(thread,"(0x%08x,%ld): stub\n",handle,exitcode);
658 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
659 return TRUE;
663 /**********************************************************************
664 * GetExitCodeThread [KERNEL32.???] Gets termination status of thread.
666 * RETURNS
667 * Success: TRUE
668 * Failure: FALSE
670 BOOL32 WINAPI GetExitCodeThread(
671 HANDLE32 hthread, /* [in] Handle to thread */
672 LPDWORD exitcode) /* [out] Address to receive termination status */
674 THDB *thread;
676 if (!(thread = THREAD_GetPtr( hthread, THREAD_QUERY_INFORMATION )))
677 return FALSE;
678 if (exitcode) *exitcode = thread->exit_code;
679 K32OBJ_DecCount( &thread->header );
680 return TRUE;
684 /**********************************************************************
685 * ResumeThread [KERNEL32.587] Resumes a thread.
687 * Decrements a thread's suspend count. When count is zero, the
688 * execution of the thread is resumed.
690 * RETURNS
691 * Success: Previous suspend count
692 * Failure: 0xFFFFFFFF
693 * Already running: 0
695 DWORD WINAPI ResumeThread(
696 HANDLE32 hthread) /* [in] Indentifies thread to restart */
698 THDB *thread;
699 DWORD oldcount;
701 SYSTEM_LOCK();
702 if (!(thread = THREAD_GetPtr( hthread, THREAD_QUERY_INFORMATION )))
704 SYSTEM_UNLOCK();
705 WARN(thread, "Invalid thread handle\n");
706 return 0xFFFFFFFF;
708 if ((oldcount = thread->suspend_count) != 0)
710 if (!--thread->suspend_count)
712 if (kill(thread->unix_pid, SIGCONT))
714 WARN(thread, "Unable to CONTinue pid: %04x\n",
715 thread->unix_pid);
716 oldcount = 0xFFFFFFFF;
720 K32OBJ_DecCount(&thread->header);
721 SYSTEM_UNLOCK();
722 return oldcount;
726 /**********************************************************************
727 * SuspendThread [KERNEL32.681] Suspends a thread.
729 * RETURNS
730 * Success: Previous suspend count
731 * Failure: 0xFFFFFFFF
733 DWORD WINAPI SuspendThread(
734 HANDLE32 hthread) /* [in] Handle to the thread */
736 THDB *thread;
737 DWORD oldcount;
739 SYSTEM_LOCK();
740 if (!(thread = THREAD_GetPtr( hthread, THREAD_QUERY_INFORMATION )))
742 SYSTEM_UNLOCK();
743 WARN(thread, "Invalid thread handle\n");
744 return 0xFFFFFFFF;
747 if (!(oldcount = thread->suspend_count))
749 if (thread->unix_pid == getpid())
750 WARN(thread, "Attempting to suspend myself\n" );
751 else
753 if (kill(thread->unix_pid, SIGSTOP))
755 WARN(thread, "Unable to STOP pid: %04x\n",
756 thread->unix_pid);
757 oldcount = 0xFFFFFFFF;
759 else thread->suspend_count++;
762 else thread->suspend_count++;
763 K32OBJ_DecCount( &thread->header );
764 SYSTEM_UNLOCK();
765 return oldcount;
770 /**********************************************************************
771 * GetThreadTimes [KERNEL32.???] Obtains timing information.
773 * NOTES
774 * What are the fields where these values are stored?
776 * RETURNS
777 * Success: TRUE
778 * Failure: FALSE
780 BOOL32 WINAPI GetThreadTimes(
781 HANDLE32 thread, /* [in] Specifies the thread of interest */
782 LPFILETIME creationtime, /* [out] When the thread was created */
783 LPFILETIME exittime, /* [out] When the thread was destroyed */
784 LPFILETIME kerneltime, /* [out] Time thread spent in kernel mode */
785 LPFILETIME usertime) /* [out] Time thread spent in user mode */
787 FIXME(thread,"(0x%08x): stub\n",thread);
788 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
789 return FALSE;
793 /**********************************************************************
794 * AttachThreadInput [KERNEL32.8] Attaches input of 1 thread to other
796 * Attaches the input processing mechanism of one thread to that of
797 * another thread.
799 * RETURNS
800 * Success: TRUE
801 * Failure: FALSE
803 BOOL32 WINAPI AttachThreadInput(
804 DWORD idAttach, /* [in] Thread to attach */
805 DWORD idAttachTo, /* [in] Thread to attach to */
806 BOOL32 fAttach) /* [in] Attach or detach */
808 BOOL32 ret;
810 FIXME(thread, "(0x%08lx,0x%08lx,%d): stub\n",idAttach,idAttachTo,fAttach);
811 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
812 if (fAttach) {
813 /* Attach threads */
814 ret = FALSE;
816 else {
817 /* Detach threads */
818 ret = FALSE;
820 return ret;