ReactOS  0.4.10-dev-486-g11b7619
thread.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS system libraries
4  * FILE: dll/win32/kernel32/client/thread.c
5  * PURPOSE: Thread functions
6  * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7  * Ariadne (ariadne@xs4all.nl)
8  *
9  */
10 
11 /* INCLUDES *******************************************************************/
12 
13 #include <k32.h>
14 
15 #define NDEBUG
16 #include <debug.h>
17 
18 #define SXS_SUPPORT_FIXME
19 
21 
23 WINAPI
24 BasepNotifyCsrOfThread(IN HANDLE ThreadHandle,
26 
27 /* FUNCTIONS ******************************************************************/
28 
29 static
31 {
32  LONG ExceptionDisposition = EXCEPTION_EXECUTE_HANDLER;
34 
36  if (RealFilter != NULL)
37  {
38  _SEH2_TRY
39  {
40  ExceptionDisposition = RealFilter(ExceptionInfo);
41  }
43  {
44  ExceptionDisposition = UnhandledExceptionFilter(ExceptionInfo);
45  }
46  _SEH2_END;
47  }
48 
49  return ExceptionDisposition;
50 }
51 
52 __declspec(noreturn)
53 VOID
54 WINAPI
55 BaseThreadStartup(IN LPTHREAD_START_ROUTINE lpStartAddress,
57 {
58  /* Attempt to call the Thread Start Address */
59  _SEH2_TRY
60  {
61  /* Legacy check which is still used today for Win32 threads */
62  if (NtCurrentTeb()->NtTib.Version == (30 << 8)) // OS/2 V3.0 ("Cruiser")
63  {
64  /* This registers the termination port with CSRSS */
66  }
67 
68  /* Get the exit code from the Thread Start */
69  ExitThread((lpStartAddress)((PVOID)lpParameter));
70  }
72  {
73  /* Get the Exit code from the SEH Handler */
75  {
76  /* Kill the whole process, usually */
78  }
79  else
80  {
81  /* If running inside CSRSS, kill just this thread */
83  }
84  }
85  _SEH2_END;
86 }
87 
88 VOID
89 NTAPI
91  IN PVOID Data,
92  IN PACTIVATION_CONTEXT ActivationContext)
93 {
94  RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME ActivationFrame;
95 
96  /* Setup the activation context */
97  ActivationFrame.Size = sizeof(ActivationFrame);
99 
100  /* Check if caller wanted one */
101  if (ActivationContext == INVALID_ACTIVATION_CONTEXT)
102  {
103  /* Do the APC directly */
104  ApcRoutine((ULONG_PTR)Data);
105  return;
106  }
107 
108  /* Then activate it */
109  RtlActivateActivationContextUnsafeFast(&ActivationFrame, ActivationContext);
110 
111  /* Call the routine under SEH */
112  _SEH2_TRY
113  {
114  ApcRoutine((ULONG_PTR)Data);
115  }
117  {
118 
119  }
120  _SEH2_END;
121 
122  /* Now de-activate and release the activation context */
124  RtlReleaseActivationContext(ActivationContext);
125 }
126 
127 /* PUBLIC FUNCTIONS ***********************************************************/
128 
129 /*
130  * @implemented
131  */
132 HANDLE
133 WINAPI
136  IN DWORD dwStackSize,
137  IN LPTHREAD_START_ROUTINE lpStartAddress,
139  IN DWORD dwCreationFlags,
140  OUT LPDWORD lpThreadId)
141 {
142  /* Act as if we're going to create a remote thread in ourselves */
144  lpThreadAttributes,
145  dwStackSize,
146  lpStartAddress,
147  lpParameter,
148  dwCreationFlags,
149  lpThreadId);
150 }
151 
152 /*
153  * @implemented
154  */
155 HANDLE
156 WINAPI
158  IN LPSECURITY_ATTRIBUTES lpThreadAttributes,
159  IN DWORD dwStackSize,
160  IN LPTHREAD_START_ROUTINE lpStartAddress,
162  IN DWORD dwCreationFlags,
163  OUT LPDWORD lpThreadId)
164 {
166  INITIAL_TEB InitialTeb;
169  OBJECT_ATTRIBUTES LocalObjectAttributes;
171  HANDLE hThread;
172  ULONG Dummy;
173  PTEB Teb;
174  THREAD_BASIC_INFORMATION ThreadBasicInfo;
175  PACTIVATION_CONTEXT_STACK ActivationContextStack = NULL;
176  ACTIVATION_CONTEXT_BASIC_INFORMATION ActCtxInfo;
179  SIZE_T ReturnSize;
180  DPRINT("CreateRemoteThread: hProcess: %p dwStackSize: %lu lpStartAddress"
181  ": %p lpParameter: %p, dwCreationFlags: %lx\n", hProcess,
182  dwStackSize, lpStartAddress, lpParameter, dwCreationFlags);
183 
184  /* Clear the Context */
185  RtlZeroMemory(&Context, sizeof(CONTEXT));
186 
187  /* Write PID */
188  ClientId.UniqueProcess = hProcess;
189 
190  /* Create the Stack */
191  Status = BaseCreateStack(hProcess,
192  dwStackSize,
193  dwCreationFlags & STACK_SIZE_PARAM_IS_A_RESERVATION ?
194  dwStackSize : 0,
195  &InitialTeb);
196  if (!NT_SUCCESS(Status))
197  {
198  BaseSetLastNTError(Status);
199  return NULL;
200  }
201 
202  /* Create Initial Context */
203  BaseInitializeContext(&Context,
204  lpParameter,
205  lpStartAddress,
206  InitialTeb.StackBase,
207  1);
208 
209  /* initialize the attributes for the thread object */
210  ObjectAttributes = BaseFormatObjectAttributes(&LocalObjectAttributes,
211  lpThreadAttributes,
212  NULL);
213 
214  /* Create the Kernel Thread Object */
215  Status = NtCreateThread(&hThread,
217  ObjectAttributes,
218  hProcess,
219  &ClientId,
220  &Context,
221  &InitialTeb,
222  TRUE);
223  if (!NT_SUCCESS(Status))
224  {
225  /* Fail the kernel create */
226  BaseFreeThreadStack(hProcess, &InitialTeb);
227  BaseSetLastNTError(Status);
228  return NULL;
229  }
230 
231  /* Are we in the same process? */
232  if (hProcess == NtCurrentProcess())
233  {
234  /* Get the TEB */
235  Status = NtQueryInformationThread(hThread,
237  &ThreadBasicInfo,
238  sizeof(ThreadBasicInfo),
239  &ReturnLength);
240  if (!NT_SUCCESS(Status))
241  {
242  /* Fail */
243  ERROR_DBGBREAK("SXS: %s - Failing thread create because "
244  "NtQueryInformationThread() failed with status %08lx\n",
245  __FUNCTION__, Status);
246  return NULL;
247  }
248 
249  /* Allocate the Activation Context Stack */
250  Status = RtlAllocateActivationContextStack(&ActivationContextStack);
251  if (!NT_SUCCESS(Status))
252  {
253  /* Fail */
254  ERROR_DBGBREAK("SXS: %s - Failing thread create because "
255  "RtlAllocateActivationContextStack() failed with status %08lx\n",
256  __FUNCTION__, Status);
257  return NULL;
258  }
259 
260  /* Save it */
261  Teb = ThreadBasicInfo.TebBaseAddress;
262  Teb->ActivationContextStackPointer = ActivationContextStack;
263 
264  /* Query the Context */
266  NULL,
267  0,
268  ActivationContextBasicInformation,
269  &ActCtxInfo,
270  sizeof(ActCtxInfo),
271  &ReturnSize);
272  if (!NT_SUCCESS(Status))
273  {
274  /* Fail */
275  ERROR_DBGBREAK("SXS: %s - Failing thread create because "
276  "RtlQueryInformationActivationContext() failed with status %08lx\n",
277  __FUNCTION__, Status);
278 
279  /* Free the activation context stack */
280  // RtlFreeThreadActivationContextStack();
282 
283  return NULL;
284  }
285 
286  /* Does it need to be activated? */
287  if ((ActCtxInfo.hActCtx) && !(ActCtxInfo.dwFlags & 1))
288  {
289  /* Activate it */
291  Teb,
292  ActCtxInfo.hActCtx,
293  &Cookie);
294  if (!NT_SUCCESS(Status))
295  {
296  /* Fail */
297  ERROR_DBGBREAK("SXS: %s - Failing thread create because "
298  "RtlActivateActivationContextEx() failed with status %08lx\n",
299  __FUNCTION__, Status);
300 
301  /* Free the activation context stack */
302  // RtlFreeThreadActivationContextStack();
304 
305  return NULL;
306  }
307  }
308  }
309 
310  /* Notify CSR */
312  {
313  Status = BasepNotifyCsrOfThread(hThread, &ClientId);
314  ASSERT(NT_SUCCESS(Status));
315  }
316  else
317  {
318  if (hProcess != NtCurrentProcess())
319  {
321 
322  /* Get the direct CSRSRV export */
323  CsrCreateRemoteThread = (PCSR_CREATE_REMOTE_THREAD)
325  "CsrCreateRemoteThread");
326  if (CsrCreateRemoteThread)
327  {
328  /* Call it instead of going through LPC */
329  Status = CsrCreateRemoteThread(hThread, &ClientId);
330  ASSERT(NT_SUCCESS(Status));
331  }
332  }
333  }
334 
335  /* Success */
336  if (lpThreadId) *lpThreadId = HandleToUlong(ClientId.UniqueThread);
337 
338  /* Resume it if asked */
339  if (!(dwCreationFlags & CREATE_SUSPENDED)) NtResumeThread(hThread, &Dummy);
340 
341  /* Return handle to thread */
342  return hThread;
343 }
344 
345 /*
346  * @implemented
347  */
348 VOID
349 WINAPI
350 ExitThread(IN DWORD uExitCode)
351 {
354  PRTL_CRITICAL_SECTION LoaderLock;
355 
356  /* Make sure loader lock isn't held */
357  LoaderLock = NtCurrentPeb()->LoaderLock;
358  if (LoaderLock) ASSERT(NtCurrentTeb()->ClientId.UniqueThread != LoaderLock->OwningThread);
359 
360  /*
361  * Terminate process if this is the last thread
362  * of the current process
363  */
366  &LastThread,
367  sizeof(LastThread),
368  NULL);
369  if ((NT_SUCCESS(Status)) && (LastThread)) ExitProcess(uExitCode);
370 
371  /* Notify DLLs and TLS Callbacks of termination */
373 
374  /* Tell the Kernel to free the Stack */
375  NtCurrentTeb()->FreeStackOnTermination = TRUE;
376  NtTerminateThread(NULL, uExitCode);
377 
378  /* We should never reach this place */
379  ERROR_FATAL("It should not happen\n");
380  while (TRUE); /* 'noreturn' function */
381 }
382 
383 /*
384  * @implemented
385  */
386 HANDLE
387 WINAPI
388 OpenThread(IN DWORD dwDesiredAccess,
391 {
393  HANDLE ThreadHandle;
396 
397  ClientId.UniqueProcess = 0;
398  ClientId.UniqueThread = ULongToHandle(dwThreadId);
399 
400  InitializeObjectAttributes(&ObjectAttributes,
401  NULL,
402  (bInheritHandle ? OBJ_INHERIT : 0),
403  NULL,
404  NULL);
405 
406  Status = NtOpenThread(&ThreadHandle,
407  dwDesiredAccess,
408  &ObjectAttributes,
409  &ClientId);
410  if (!NT_SUCCESS(Status))
411  {
412  BaseSetLastNTError(Status);
413  return NULL;
414  }
415 
416  return ThreadHandle;
417 }
418 
419 /*
420  * @implemented
421  */
422 PTEB
424 {
425  return NtCurrentTeb();
426 }
427 
428 /*
429  * @implemented
430  */
431 BOOL
432 WINAPI
434 {
436 }
437 
438 
439 /*
440  * @implemented
441  */
442 DWORD
443 WINAPI
445 {
447 }
448 
449 /*
450  * @implemented
451  */
452 BOOL
453 NTAPI
455  OUT LPFILETIME lpCreationTime,
456  OUT LPFILETIME lpExitTime,
457  OUT LPFILETIME lpKernelTime,
458  OUT LPFILETIME lpUserTime)
459 {
460  KERNEL_USER_TIMES KernelUserTimes;
462 
463  Status = NtQueryInformationThread(hThread,
464  ThreadTimes,
465  &KernelUserTimes,
466  sizeof(KERNEL_USER_TIMES),
467  NULL);
468  if (!NT_SUCCESS(Status))
469  {
470  BaseSetLastNTError(Status);
471  return FALSE;
472  }
473 
474  *lpCreationTime = *(LPFILETIME)&KernelUserTimes.CreateTime;
475  *lpExitTime = *(LPFILETIME)&KernelUserTimes.ExitTime;
476  *lpKernelTime = *(LPFILETIME)&KernelUserTimes.KernelTime;
477  *lpUserTime = *(LPFILETIME)&KernelUserTimes.UserTime;
478  return TRUE;
479 }
480 
481 /*
482  * @implemented
483  */
484 BOOL
485 WINAPI
487  OUT LPCONTEXT lpContext)
488 {
490 
491  Status = NtGetContextThread(hThread, lpContext);
492  if (!NT_SUCCESS(Status))
493  {
494  BaseSetLastNTError(Status);
495  return FALSE;
496  }
497 
498  return TRUE;
499 }
500 
501 /*
502  * @implemented
503  */
504 BOOL
505 WINAPI
507  IN CONST CONTEXT *lpContext)
508 {
510 
511  Status = NtSetContextThread(hThread, (PCONTEXT)lpContext);
512  if (!NT_SUCCESS(Status))
513  {
514  BaseSetLastNTError(Status);
515  return FALSE;
516  }
517 
518  return TRUE;
519 }
520 
521 /*
522  * @implemented
523  */
524 BOOL
525 WINAPI
527  OUT LPDWORD lpExitCode)
528 {
529  THREAD_BASIC_INFORMATION ThreadBasic;
531 
532  Status = NtQueryInformationThread(hThread,
534  &ThreadBasic,
535  sizeof(THREAD_BASIC_INFORMATION),
536  NULL);
537  if (!NT_SUCCESS(Status))
538  {
539  BaseSetLastNTError(Status);
540  return FALSE;
541  }
542 
543  *lpExitCode = ThreadBasic.ExitStatus;
544  return TRUE;
545 }
546 
547 /*
548  * @implemented
549  */
550 DWORD
551 WINAPI
553 {
554  ULONG PreviousResumeCount;
556 
557  Status = NtResumeThread(hThread, &PreviousResumeCount);
558  if (!NT_SUCCESS(Status))
559  {
560  BaseSetLastNTError(Status);
561  return -1;
562  }
563 
564  return PreviousResumeCount;
565 }
566 
567 /*
568  * @implemented
569  */
570 BOOL
571 WINAPI
573  IN DWORD dwExitCode)
574 {
576 #if DBG
577  PRTL_CRITICAL_SECTION LoaderLock;
579 #endif /* DBG */
580 
581  /* Check for invalid thread handle */
582  if (!hThread)
583  {
584  /* Fail if one was passed */
586  return FALSE;
587  }
588 
589 #if DBG
590  /* Get the loader lock */
591  LoaderLock = NtCurrentPeb()->LoaderLock;
592  if (LoaderLock)
593  {
594  /* Get our TID */
595  Status = NtQueryInformationThread(hThread,
597  &ThreadInfo,
598  sizeof(ThreadInfo),
599  NULL);
600  if (NT_SUCCESS(Status))
601  {
602  /* If terminating the current thread, we must not hold the loader lock */
605  }
606  }
607 #endif /* DBG */
608 
609  /* Now terminate the thread */
610  Status = NtTerminateThread(hThread, dwExitCode);
611  if (!NT_SUCCESS(Status))
612  {
613  /* Fail */
614  BaseSetLastNTError(Status);
615  return FALSE;
616  }
617 
618  /* All done */
619  return TRUE;
620 }
621 
622 /*
623  * @implemented
624  */
625 DWORD
626 WINAPI
628 {
629  ULONG PreviousSuspendCount;
631 
632  Status = NtSuspendThread(hThread, &PreviousSuspendCount);
633  if (!NT_SUCCESS(Status))
634  {
635  BaseSetLastNTError(Status);
636  return -1;
637  }
638 
639  return PreviousSuspendCount;
640 }
641 
642 /*
643  * @implemented
644  */
645 DWORD_PTR
646 WINAPI
648  IN DWORD_PTR dwThreadAffinityMask)
649 {
650  THREAD_BASIC_INFORMATION ThreadBasic;
651  KAFFINITY AffinityMask;
653 
654  AffinityMask = (KAFFINITY)dwThreadAffinityMask;
655 
656  Status = NtQueryInformationThread(hThread,
658  &ThreadBasic,
659  sizeof(THREAD_BASIC_INFORMATION),
660  NULL);
661  if (!NT_SUCCESS(Status))
662  {
663  BaseSetLastNTError(Status);
664  return 0;
665  }
666 
667  Status = NtSetInformationThread(hThread,
669  &AffinityMask,
670  sizeof(KAFFINITY));
671  if (!NT_SUCCESS(Status))
672  {
673  BaseSetLastNTError(Status);
674  ThreadBasic.AffinityMask = 0;
675  }
676 
677  return ThreadBasic.AffinityMask;
678 }
679 
680 /*
681  * @implemented
682  */
683 BOOL
684 WINAPI
686  IN int nPriority)
687 {
688  LONG Prio = nPriority;
690 
691  /* Check if values forcing saturation should be used */
692  if (Prio == THREAD_PRIORITY_TIME_CRITICAL)
693  {
694  /* This is 16 */
695  Prio = (HIGH_PRIORITY + 1) / 2;
696  }
697  else if (Prio == THREAD_PRIORITY_IDLE)
698  {
699  /* This is -16 */
700  Prio = -((HIGH_PRIORITY + 1) / 2);
701  }
702 
703  /* Set the Base Priority */
704  Status = NtSetInformationThread(hThread,
706  &Prio,
707  sizeof(LONG));
708  if (!NT_SUCCESS(Status))
709  {
710  /* Failure */
711  BaseSetLastNTError(Status);
712  return FALSE;
713  }
714 
715  /* Return */
716  return TRUE;
717 }
718 
719 /*
720  * @implemented
721  */
722 int
723 WINAPI
725 {
726  THREAD_BASIC_INFORMATION ThreadBasic;
728 
729  /* Query the Base Priority Increment */
730  Status = NtQueryInformationThread(hThread,
732  &ThreadBasic,
733  sizeof(THREAD_BASIC_INFORMATION),
734  NULL);
735  if (!NT_SUCCESS(Status))
736  {
737  /* Failure */
738  BaseSetLastNTError(Status);
740  }
741 
742  /* Do some conversions for saturation values */
743  if (ThreadBasic.BasePriority == ((HIGH_PRIORITY + 1) / 2))
744  {
745  /* Win32 calls this "time critical" */
747  }
748  else if (ThreadBasic.BasePriority == -((HIGH_PRIORITY + 1) / 2))
749  {
750  /* Win32 calls this "idle" */
751  ThreadBasic.BasePriority = THREAD_PRIORITY_IDLE;
752  }
753 
754  /* Return the final result */
755  return ThreadBasic.BasePriority;
756 }
757 
758 /*
759  * @implemented
760  */
761 BOOL
762 WINAPI
764  OUT PBOOL pDisablePriorityBoost)
765 {
768 
769  Status = NtQueryInformationThread(hThread,
771  &PriorityBoost,
772  sizeof(ULONG),
773  NULL);
774  if (!NT_SUCCESS(Status))
775  {
776  BaseSetLastNTError(Status);
777  return FALSE;
778  }
779 
780  *pDisablePriorityBoost = PriorityBoost;
781  return TRUE;
782 }
783 
784 /*
785  * @implemented
786  */
787 BOOL
788 NTAPI
790  IN BOOL bDisablePriorityBoost)
791 {
794 
795  PriorityBoost = bDisablePriorityBoost != FALSE;
796 
797  Status = NtSetInformationThread(hThread,
799  &PriorityBoost,
800  sizeof(ULONG));
801  if (!NT_SUCCESS(Status))
802  {
803  BaseSetLastNTError(Status);
804  return FALSE;
805  }
806 
807  return TRUE;
808 }
809 
810 /*
811  * @implemented
812  */
813 BOOL
814 WINAPI
816  IN DWORD dwSelector,
817  OUT LPLDT_ENTRY lpSelectorEntry)
818 {
819 #ifdef _M_IX86
820  DESCRIPTOR_TABLE_ENTRY DescriptionTableEntry;
822 
823  /* Set the selector and do the query */
824  DescriptionTableEntry.Selector = dwSelector;
825  Status = NtQueryInformationThread(hThread,
827  &DescriptionTableEntry,
828  sizeof(DESCRIPTOR_TABLE_ENTRY),
829  NULL);
830  if (!NT_SUCCESS(Status))
831  {
832  /* Fail */
833  BaseSetLastNTError(Status);
834  return FALSE;
835  }
836 
837  /* Success, return the selector */
838  *lpSelectorEntry = DescriptionTableEntry.Descriptor;
839  return TRUE;
840 #else
841  DPRINT1("Calling GetThreadSelectorEntry!\n");
842  return FALSE;
843 #endif
844 }
845 
846 /*
847  * @implemented
848  */
849 DWORD
850 WINAPI
852  IN DWORD dwIdealProcessor)
853 {
855 
856  Status = NtSetInformationThread(hThread,
858  &dwIdealProcessor,
859  sizeof(ULONG));
860  if (!NT_SUCCESS(Status))
861  {
862  BaseSetLastNTError(Status);
863  return -1;
864  }
865 
866  return (DWORD)Status;
867 }
868 
869 /*
870  * @implemented
871  */
872 DWORD
873 WINAPI
875 {
876  THREAD_BASIC_INFORMATION ThreadBasic;
878 
879  Status = NtQueryInformationThread(Thread,
881  &ThreadBasic,
882  sizeof(THREAD_BASIC_INFORMATION),
883  NULL);
884  if (!NT_SUCCESS(Status))
885  {
886  BaseSetLastNTError(Status);
887  return 0;
888  }
889 
890  return HandleToUlong(ThreadBasic.ClientId.UniqueProcess);
891 }
892 
893 /*
894  * @implemented
895  */
896 DWORD
897 WINAPI
899 {
900  THREAD_BASIC_INFORMATION ThreadBasic;
902 
903  Status = NtQueryInformationThread(Thread,
905  &ThreadBasic,
906  sizeof(THREAD_BASIC_INFORMATION),
907  NULL);
908  if (!NT_SUCCESS(Status))
909  {
910  BaseSetLastNTError(Status);
911  return 0;
912  }
913 
914  return HandleToUlong(ThreadBasic.ClientId.UniqueThread);
915 }
916 
917 /*
918  * @unimplemented
919  */
920 LANGID
921 WINAPI
923 {
925  return (LANGID)NtCurrentTeb()->CurrentLocale;
926 }
927 
928 /*
929  * @implemented
930  */
931 DWORD
932 WINAPI
934  IN HANDLE hThread,
936 {
938  ACTIVATION_CONTEXT_BASIC_INFORMATION ActCtxInfo;
939 
940  /* Zero the activation context and query information on it */
941  RtlZeroMemory(&ActCtxInfo, sizeof(ActCtxInfo));
943  NULL,
944  0,
945  ActivationContextBasicInformation,
946  &ActCtxInfo,
947  sizeof(ActCtxInfo),
948  NULL);
949  if (!NT_SUCCESS(Status))
950  {
951  /* Fail due to SxS */
952  DbgPrint("SXS: %s failing because RtlQueryInformationActivationContext()"
953  "returned status %08lx\n", __FUNCTION__, Status);
954  BaseSetLastNTError(Status);
955  return FALSE;
956  }
957 
958  /* Queue the APC */
959  Status = NtQueueApcThread(hThread,
961  pfnAPC,
962  (PVOID)dwData,
963  (ActCtxInfo.dwFlags & 1) ?
964  INVALID_ACTIVATION_CONTEXT : ActCtxInfo.hActCtx);
965  if (!NT_SUCCESS(Status))
966  {
967  BaseSetLastNTError(Status);
968  return FALSE;
969  }
970 
971  /* All good */
972  return TRUE;
973 }
974 
975 /*
976  * @implemented
977  */
978 BOOL
979 WINAPI
981 {
982  static int once;
983  if (once++ == 0)
984  DPRINT1("SetThreadStackGuarantee(%p): stub\n", StackSizeInBytes);
985  return TRUE;
986 }
987 
988 /*
989  * @implemented
990  */
991 BOOL
992 WINAPI
994  OUT PBOOL lpIOIsPending)
995 {
996  ULONG IoPending;
998 
999  /* Query the flag */
1000  Status = NtQueryInformationThread(hThread,
1002  &IoPending,
1003  sizeof(IoPending),
1004  NULL);
1005  if (NT_SUCCESS(Status))
1006  {
1007  /* Return the flag */
1008  *lpIOIsPending = IoPending ? TRUE : FALSE;
1009  return TRUE;
1010  }
1011 
1012  /* Fail */
1013  BaseSetLastNTError(Status);
1014  return FALSE;
1015 }
1016 
1017 /*
1018  * @implemented
1019  */
1020 BOOL
1021 WINAPI
1023  IN PVOID Context,
1024  IN ULONG Flags)
1025 {
1026  NTSTATUS Status;
1027 
1028  /* NOTE: Rtl needs to safely call the function using a trampoline */
1029  Status = RtlQueueWorkItem((WORKERCALLBACKFUNC)Function, Context, Flags);
1030  if (!NT_SUCCESS(Status))
1031  {
1032  /* Failed */
1033  BaseSetLastNTError(Status);
1034  return FALSE;
1035  }
1036 
1037  /* All good */
1038  return TRUE;
1039 }
1040 
1041 /*
1042  * @implemented
1043  */
1044 DWORD
1045 WINAPI
1047 {
1048  ULONG Index;
1049  PTEB Teb;
1050  PPEB Peb;
1051 
1052  /* Get the PEB and TEB, lock the PEB */
1053  Teb = NtCurrentTeb();
1054  Peb = Teb->ProcessEnvironmentBlock;
1056 
1057  /* Try to get regular TEB slot */
1058  Index = RtlFindClearBitsAndSet(Peb->TlsBitmap, 1, 0);
1059  if (Index != 0xFFFFFFFF)
1060  {
1061  /* Clear the value. */
1062  Teb->TlsSlots[Index] = 0;
1064  return Index;
1065  }
1066 
1067  /* If it fails, try to find expansion TEB slot. */
1068  Index = RtlFindClearBitsAndSet(Peb->TlsExpansionBitmap, 1, 0);
1069  if (Index != 0xFFFFFFFF)
1070  {
1071  /* Is there no expansion slot yet? */
1072  if (!Teb->TlsExpansionSlots)
1073  {
1074  /* Allocate an array */
1075  Teb->TlsExpansionSlots = RtlAllocateHeap(RtlGetProcessHeap(),
1078  sizeof(PVOID));
1079  }
1080 
1081  /* Did we get an array? */
1082  if (!Teb->TlsExpansionSlots)
1083  {
1084  /* Fail */
1085  RtlClearBits(Peb->TlsExpansionBitmap, Index, 1);
1086  Index = 0xFFFFFFFF;
1088  }
1089  else
1090  {
1091  /* Clear the value. */
1092  Teb->TlsExpansionSlots[Index] = 0;
1093  Index += TLS_MINIMUM_AVAILABLE;
1094  }
1095  }
1096  else
1097  {
1098  /* Fail */
1100  }
1101 
1102  /* Release the lock and return */
1104  return Index;
1105 }
1106 
1107 /*
1108  * @implemented
1109  */
1110 BOOL
1111 WINAPI
1113 {
1114  BOOL BitSet;
1115  PPEB Peb;
1116  ULONG TlsIndex;
1117  PVOID TlsBitmap;
1118  NTSTATUS Status;
1119 
1120  /* Acquire the PEB lock and grab the PEB */
1121  Peb = NtCurrentPeb();
1123 
1124  /* Check if the index is too high */
1125  if (Index >= TLS_MINIMUM_AVAILABLE)
1126  {
1127  /* Check if it can fit in the expansion slots */
1128  TlsIndex = Index - TLS_MINIMUM_AVAILABLE;
1129  if (TlsIndex >= TLS_EXPANSION_SLOTS)
1130  {
1131  /* It's invalid */
1134  return FALSE;
1135  }
1136  else
1137  {
1138  /* Use the expansion bitmap */
1139  TlsBitmap = Peb->TlsExpansionBitmap;
1140  Index = TlsIndex;
1141  }
1142  }
1143  else
1144  {
1145  /* Use the normal bitmap */
1146  TlsBitmap = Peb->TlsBitmap;
1147  }
1148 
1149  /* Check if the index was set */
1150  BitSet = RtlAreBitsSet(TlsBitmap, Index, 1);
1151  if (BitSet)
1152  {
1153  /* Tell the kernel to free the TLS cells */
1156  &Index,
1157  sizeof(DWORD));
1158  if (!NT_SUCCESS(Status))
1159  {
1162  return FALSE;
1163  }
1164 
1165  /* Clear the bit */
1166  RtlClearBits(TlsBitmap, Index, 1);
1167  }
1168  else
1169  {
1170  /* Fail */
1173  return FALSE;
1174  }
1175 
1176  /* Done! */
1178  return TRUE;
1179 }
1180 
1181 /*
1182  * @implemented
1183  */
1184 LPVOID
1185 WINAPI
1187 {
1188  PTEB Teb;
1189 
1190  /* Get the TEB and clear the last error */
1191  Teb = NtCurrentTeb();
1192  Teb->LastErrorValue = 0;
1193 
1194  /* Check for simple TLS index */
1195  if (Index < TLS_MINIMUM_AVAILABLE)
1196  {
1197  /* Return it */
1198  return Teb->TlsSlots[Index];
1199  }
1200 
1201  /* Check for valid index */
1203  {
1204  /* Fail */
1206  return NULL;
1207  }
1208 
1209  /* The expansion slots are allocated on demand, so check for it. */
1210  Teb->LastErrorValue = 0;
1211  if (!Teb->TlsExpansionSlots) return NULL;
1212 
1213  /* Return the value from the expansion slots */
1214  return Teb->TlsExpansionSlots[Index - TLS_MINIMUM_AVAILABLE];
1215 }
1216 
1217 /*
1218  * @implemented
1219  */
1220 BOOL
1221 WINAPI
1223  IN LPVOID Value)
1224 {
1225  DWORD TlsIndex;
1226  PTEB Teb = NtCurrentTeb();
1227 
1228  /* Check for simple TLS index */
1229  if (Index < TLS_MINIMUM_AVAILABLE)
1230  {
1231  /* Return it */
1232  Teb->TlsSlots[Index] = Value;
1233  return TRUE;
1234  }
1235 
1236  /* Check if this is an expansion slot */
1237  TlsIndex = Index - TLS_MINIMUM_AVAILABLE;
1238  if (TlsIndex >= TLS_EXPANSION_SLOTS)
1239  {
1240  /* Fail */
1242  return FALSE;
1243  }
1244 
1245  /* Do we not have expansion slots? */
1246  if (!Teb->TlsExpansionSlots)
1247  {
1248  /* Get the PEB lock to see if we still need them */
1250  if (!Teb->TlsExpansionSlots)
1251  {
1252  /* Allocate them */
1253  Teb->TlsExpansionSlots = RtlAllocateHeap(RtlGetProcessHeap(),
1256  sizeof(PVOID));
1257  if (!Teb->TlsExpansionSlots)
1258  {
1259  /* Fail */
1262  return FALSE;
1263  }
1264  }
1265 
1266  /* Release the lock */
1268  }
1269 
1270  /* Write the value */
1272 
1273  /* Success */
1274  return TRUE;
1275 }
1276 
1277 /* EOF */
DWORD *typedef PVOID
Definition: winlogon.h:60
PRTL_BITMAP TlsExpansionBitmap
Definition: winternl.h:346
LANGID WINAPI SetThreadUILanguage(IN LANGID LangId)
Definition: thread.c:922
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:39
#define IN
Definition: typedefs.h:38
NTSYSAPI void WINAPI RtlClearBits(PRTL_BITMAP, ULONG, ULONG)
#define ULongToHandle(h)
Definition: basetsd.h:81
VOID WINAPI BaseInitializeContext(IN PCONTEXT Context, IN PVOID Parameter, IN PVOID StartAddress, IN PVOID StackAddress, IN ULONG ContextType)
Definition: utils.c:503
BOOL NTAPI GetThreadTimes(IN HANDLE hThread, OUT LPFILETIME lpCreationTime, OUT LPFILETIME lpExitTime, OUT LPFILETIME lpKernelTime, OUT LPFILETIME lpUserTime)
Definition: thread.c:454
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1339
BOOL WINAPI SwitchToThread(VOID)
Definition: thread.c:433
#define TRUE
Definition: types.h:120
BOOL WINAPI SetThreadContext(IN HANDLE hThread, IN CONST CONTEXT *lpContext)
Definition: thread.c:506
NTSTATUS NTAPI NtOpenThread(OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN PCLIENT_ID ClientId OPTIONAL)
Definition: thread.c:1013
PPEB Peb
Definition: dllmain.c:27
PPEB ProcessEnvironmentBlock
Definition: ntddk_ex.h:341
BOOL WINAPI TerminateThread(IN HANDLE hThread, IN DWORD dwExitCode)
Definition: thread.c:572
KAFFINITY AffinityMask
Definition: compat.h:579
#define DbgPrint
Definition: loader.c:25
BOOL WINAPI TlsSetValue(IN DWORD Index, IN LPVOID Value)
Definition: thread.c:1222
NTSYSAPI void WINAPI RtlReleaseActivationContext(HANDLE)
Definition: actctx.c:5197
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
struct _FILETIME * LPFILETIME
Definition: time.c:29
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_NO_YIELD_PERFORMED
Definition: ntstatus.h:150
#define TLS_EXPANSION_SLOTS
Definition: pstypes.h:294
IN OUT PIRP IN ULONG IN WMIENABLEDISABLECONTROL Function
Definition: wmilib.h:37
#define THREAD_PRIORITY_ERROR_RETURN
Definition: winbase.h:279
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
LARGE_INTEGER UserTime
Definition: winternl.h:1063
#define HandleToUlong(h)
Definition: basetsd.h:79
#define NtCurrentThread()
NTSYSAPI NTSTATUS NTAPI RtlQueueWorkItem(_In_ WORKERCALLBACKFUNC Function, _In_opt_ PVOID Context, _In_ ULONG Flags)
__declspec(noreturn)
Definition: thread.c:52
static HANDLE ULONG_PTR dwData
Definition: file.c:35
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1544
NTSYSAPI PVOID WINAPI RtlDecodePointer(PVOID)
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
VOID NTAPI RtlReleasePebLock(VOID)
Definition: libsupp.c:82
DWORD WINAPI GetThreadId(IN HANDLE Thread)
Definition: thread.c:898
struct _ThreadInfo ThreadInfo
WORD LANGID
Definition: typedefs.h:79
BOOL WINAPI GetThreadIOPendingFlag(IN HANDLE hThread, OUT PBOOL lpIOIsPending)
Definition: thread.c:993
NTSTATUS NTAPI NtSuspendThread(IN HANDLE ThreadHandle, OUT PULONG PreviousSuspendCount OPTIONAL)
Definition: state.c:352
HANDLE UniqueProcess
Definition: compat.h:474
#define RTL_ACTIVATE_ACTIVATION_CONTEXT_EX_FLAG_RELEASE_ON_STACK_DEALLOCATION
Definition: rtltypes.h:106
NTSTATUS NTAPI NtQueueApcThread(IN HANDLE ThreadHandle, IN PKNORMAL_ROUTINE ApcRoutine, IN PVOID NormalContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: state.c:500
DWORD DWORD
Definition: winlogon.h:83
KPRIORITY BasePriority
Definition: compat.h:581
_SEH2_TRY
Definition: create.c:4250
uint32_t ULONG_PTR
Definition: typedefs.h:63
LARGE_INTEGER ExitTime
Definition: winternl.h:1061
#define ERROR_FATAL(...)
Definition: debug.h:238
BOOL WINAPI GetExitCodeThread(IN HANDLE hThread, OUT LPDWORD lpExitCode)
Definition: thread.c:526
BOOL WINAPI GetThreadContext(IN HANDLE hThread, OUT LPCONTEXT lpContext)
Definition: thread.c:486
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
DWORD WINAPI QueueUserAPC(IN PAPCFUNC pfnAPC, IN HANDLE hThread, IN ULONG_PTR dwData)
Definition: thread.c:933
#define CREATE_SUSPENDED
Definition: winbase.h:178
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define FALSE
Definition: types.h:117
static BOOL bInheritHandle
Definition: pipe.c:82
long LONG
Definition: pedump.c:60
BOOL NTAPI SetThreadPriorityBoost(IN HANDLE hThread, IN BOOL bDisablePriorityBoost)
Definition: thread.c:789
LONG WINAPI UnhandledExceptionFilter(IN PEXCEPTION_POINTERS ExceptionInfo)
Definition: except.c:262
VOID(NTAPI * WORKERCALLBACKFUNC)(_In_ PVOID Context)
Definition: rtltypes.h:509
_In_ CCHAR PriorityBoost
Definition: iofuncs.h:763
#define ERROR_DBGBREAK(...)
Definition: debug.h:221
#define _SEH2_GetExceptionInformation()
Definition: pseh2_64.h:11
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:135
smooth NULL
Definition: ftsmooth.c:416
DWORD_PTR WINAPI SetThreadAffinityMask(IN HANDLE hThread, IN DWORD_PTR dwThreadAffinityMask)
Definition: thread.c:647
PVOID StackBase
Definition: pstypes.h:678
void DPRINT(...)
Definition: polytest.cpp:61
BOOL WINAPI GetThreadPriorityBoost(IN HANDLE hThread, OUT PBOOL pDisablePriorityBoost)
Definition: thread.c:763
#define RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_FORMAT_WHISTLER
Definition: rtltypes.h:101
VOID WINAPI ExitThread(IN DWORD uExitCode)
Definition: thread.c:350
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
NTSTATUS NTAPI NtSetInformationThread(IN HANDLE ThreadHandle, IN THREADINFOCLASS ThreadInformationClass, IN PVOID ThreadInformation, IN ULONG ThreadInformationLength)
Definition: query.c:1967
DWORD(WINAPI * LPTHREAD_START_ROUTINE)(LPVOID)
Definition: winbase.h:707
BOOL * PBOOL
Definition: windef.h:161
#define HIGH_PRIORITY
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:444
#define CONST
Definition: compiler.h:170
BOOL WINAPI SetThreadPriority(IN HANDLE hThread, IN int nPriority)
Definition: thread.c:685
#define NtCurrentProcess()
Definition: nt_native.h:1657
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
#define DECLSPEC_HOTPATCH
Definition: _mingw.h:224
static LONG BaseThreadExceptionFilter(EXCEPTION_POINTERS *ExceptionInfo)
Definition: thread.c:30
NTSTATUS NtTerminateThread(IN HANDLE ThreadHandle OPTIONAL, IN NTSTATUS ExitStatus)
Definition: kill.c:1278
NTSTATUS NTAPI NtResumeThread(IN HANDLE ThreadHandle, OUT PULONG SuspendCount OPTIONAL)
Definition: state.c:290
unsigned int BOOL
Definition: ntddk_ex.h:94
_Out_ PCLIENT_ID ClientId
Definition: kefuncs.h:1176
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN BaseRunningInServerProcess
Definition: dllmain.c:20
BOOL WINAPI TlsFree(IN DWORD Index)
Definition: thread.c:1112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
VOID NTAPI BaseDispatchApc(IN PAPCFUNC ApcRoutine, IN PVOID Data, IN PACTIVATION_CONTEXT ActivationContext)
Definition: thread.c:90
NTSTATUS NTAPI NtYieldExecution(VOID)
Definition: thrdschd.c:744
LARGE_INTEGER CreateTime
Definition: winternl.h:1060
#define OBJ_INHERIT
Definition: winternl.h:225
#define STACK_SIZE_PARAM_IS_A_RESERVATION
Definition: winbase.h:558
_In_opt_ PVOID _Out_ PLARGE_INTEGER Cookie
Definition: cmfuncs.h:13
BOOL WINAPI SetThreadStackGuarantee(IN OUT PULONG StackSizeInBytes)
Definition: thread.c:980
static const UCHAR Index[8]
Definition: usbohci.c:11
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
PRTL_ACTIVATION_CONTEXT_STACK_FRAME FASTCALL RtlDeactivateActivationContextUnsafeFast(IN PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame)
Definition: actctx.c:5864
#define SetLastError(x)
Definition: compat.h:409
VOID(NTAPI * PKNORMAL_ROUTINE)(IN PVOID NormalContext OPTIONAL, IN PVOID SystemArgument1 OPTIONAL, IN PVOID SystemArgument2 OPTIONAL)
Definition: ketypes.h:632
DWORD WINAPI SetThreadIdealProcessor(IN HANDLE hThread, IN DWORD dwIdealProcessor)
Definition: thread.c:851
NTSTATUS NTAPI NtQueryInformationThread(IN HANDLE ThreadHandle, IN THREADINFOCLASS ThreadInformationClass, OUT PVOID ThreadInformation, IN ULONG ThreadInformationLength, OUT PULONG ReturnLength OPTIONAL)
Definition: query.c:2450
_In_opt_ HANDLE _In_opt_ PIO_APC_ROUTINE ApcRoutine
Definition: iofuncs.h:719
HANDLE UniqueThread
Definition: compat.h:475
BOOL WINAPI QueueUserWorkItem(IN LPTHREAD_START_ROUTINE Function, IN PVOID Context, IN ULONG Flags)
Definition: thread.c:1022
#define THREAD_PRIORITY_TIME_CRITICAL
Definition: winbase.h:278
NTSTATUS NTAPI CsrCreateRemoteThread(IN HANDLE hThread, IN PCLIENT_ID ClientId)
Definition: thredsup.c:568
DWORD dwThreadId
Definition: fdebug.c:31
#define THREAD_PRIORITY_IDLE
Definition: winbase.h:275
DWORD WINAPI SuspendThread(IN HANDLE hThread)
Definition: thread.c:627
NTSTATUS WINAPI BaseCreateStack(HANDLE hProcess, SIZE_T StackCommit, SIZE_T StackReserve, PINITIAL_TEB InitialTeb)
Definition: utils.c:353
LPVOID lpParameter
Definition: kernel32.h:232
HANDLE WINAPI OpenThread(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwThreadId)
Definition: thread.c:388
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
DWORD WINAPI TlsAlloc(VOID)
Definition: thread.c:1046
PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER
Definition: winbase.h:1406
PTEB GetTeb(VOID)
Definition: thread.c:423
NTSYSAPI ULONG WINAPI RtlFindClearBitsAndSet(PRTL_BITMAP, ULONG, ULONG)
uint32_t DWORD_PTR
Definition: typedefs.h:63
#define TlsIndex
Definition: ws2_32p.h:267
#define WINAPI
Definition: msvc.h:20
UINTN UINT8 Value
Definition: acefiex.h:751
POBJECT_ATTRIBUTES WINAPI BaseFormatObjectAttributes(OUT POBJECT_ATTRIBUTES ObjectAttributes, IN PSECURITY_ATTRIBUTES SecurityAttributes OPTIONAL, IN PUNICODE_STRING ObjectName)
Definition: utils.c:304
static NTSTATUS(WINAPI *pNtQueryInformationThread)(HANDLE
PVOID PACTIVATION_CONTEXT
Definition: ldrtypes.h:108
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI CsrNewThread(VOID)
Definition: api.c:27
PETHREAD LastThread
Definition: pinsup.c:109
Definition: compat.h:428
ULONG_PTR SIZE_T
Definition: typedefs.h:78
Definition: compat.h:484
NTSTATUS WINAPI BasepNotifyCsrOfThread(IN HANDLE ThreadHandle, IN PCLIENT_ID ClientId)
Definition: proc.c:511
DWORD *typedef HANDLE
Definition: winlogon.h:60
_SEH2_END
Definition: create.c:4424
NTSYSAPI BOOLEAN WINAPI RtlAreBitsSet(PCRTL_BITMAP, ULONG, ULONG)
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
DWORD WINAPI GetProcessIdOfThread(IN HANDLE Thread)
Definition: thread.c:874
NTSTATUS(NTAPI * PCSR_CREATE_REMOTE_THREAD)(IN HANDLE ThreadHandle, IN PCLIENT_ID ClientId)
Definition: thread.c:20
ULONG_PTR KAFFINITY
Definition: compat.h:75
BOOL WINAPI GetThreadSelectorEntry(IN HANDLE hThread, IN DWORD dwSelector, OUT LPLDT_ENTRY lpSelectorEntry)
Definition: thread.c:815
NTSTATUS NTAPI NtSetContextThread(IN HANDLE ThreadHandle, IN PCONTEXT ThreadContext)
Definition: debug.c:371
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
unsigned int * PULONG
Definition: retypes.h:1
NTSTATUS NTAPI NtCreateThread(OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN HANDLE ProcessHandle, OUT PCLIENT_ID ClientId, IN PCONTEXT ThreadContext, IN PINITIAL_TEB InitialTeb, IN BOOLEAN CreateSuspended)
Definition: thread.c:941
NTSYSAPI NTSTATUS WINAPI RtlQueryInformationActivationContext(ULONG, HANDLE, PVOID, ULONG, PVOID, SIZE_T, SIZE_T *)
Definition: actctx.c:5368
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
HANDLE hThread
Definition: wizard.c:27
VOID NTAPI RtlAcquirePebLock(VOID)
Definition: libsupp.c:72
#define RTL_QUERY_ACTIVATION_CONTEXT_FLAG_USE_ACTIVE_ACTIVATION_CONTEXT
Definition: rtltypes.h:116
#define DPRINT1
Definition: precomp.h:8
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1186
PRTL_ACTIVATION_CONTEXT_STACK_FRAME FASTCALL RtlActivateActivationContextUnsafeFast(IN PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame, IN PVOID Context)
Definition: actctx.c:5787
NTSTATUS NTAPI RtlActivateActivationContextEx(ULONG flags, PTEB tebAddress, HANDLE handle, PULONG_PTR cookie)
Definition: actctx.c:5221
#define OUT
Definition: typedefs.h:39
NTSTATUS NTAPI RtlAllocateActivationContextStack(IN PACTIVATION_CONTEXT_STACK *Stack)
Definition: actctx.c:5759
uint32_t * LPDWORD
Definition: typedefs.h:57
DWORD WINAPI ResumeThread(IN HANDLE hThread)
Definition: thread.c:552
ULONG LastErrorValue
Definition: compat.h:492
struct tagContext Context
Definition: acpixf.h:1014
unsigned int ULONG
Definition: retypes.h:1
LPTOP_LEVEL_EXCEPTION_FILTER GlobalTopLevelExceptionFilter
Definition: except.c:158
#define UNIMPLEMENTED
Definition: debug.h:114
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define GetProcAddress(x, y)
Definition: compat.h:410
PVOID TlsSlots[64]
Definition: compat.h:528
PVOID * TlsExpansionSlots
Definition: compat.h:543
#define __FUNCTION__
Definition: compiler.h:205
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
PVOID ActivationContextStackPointer
Definition: compat.h:503
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
NTSTATUS NTAPI LdrShutdownThread(VOID)
Definition: ldrinit.c:1067
PVOID TlsBitmap
Definition: ntddk_ex.h:263
LARGE_INTEGER KernelTime
Definition: winternl.h:1062
int WINAPI GetThreadPriority(IN HANDLE hThread)
Definition: thread.c:724
NTSTATUS NTAPI NtGetContextThread(IN HANDLE ThreadHandle, IN OUT PCONTEXT ThreadContext)
Definition: debug.c:334
#define NtCurrentPeb()
Definition: rtlfuncs.h:1073
#define TLS_MINIMUM_AVAILABLE
Definition: ntddk_ex.h:240
HANDLE WINAPI CreateRemoteThread(IN HANDLE hProcess, IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:157
VOID WINAPI BaseFreeThreadStack(IN HANDLE hProcess, IN PINITIAL_TEB InitialTeb)
Definition: utils.c:486
VOID NTAPI RtlFreeActivationContextStack(IN PACTIVATION_CONTEXT_STACK Stack)
Definition: actctx.c:5293