ReactOS  0.4.10-dev-19-g39281f0
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  DPRINT("CreateRemoteThread: hProcess: %p dwStackSize: %lu lpStartAddress"
180  ": %p lpParameter: %p, dwCreationFlags: %lx\n", hProcess,
181  dwStackSize, lpStartAddress, lpParameter, dwCreationFlags);
182 
183  /* Clear the Context */
184  RtlZeroMemory(&Context, sizeof(CONTEXT));
185 
186  /* Write PID */
187  ClientId.UniqueProcess = hProcess;
188 
189  /* Create the Stack */
190  Status = BaseCreateStack(hProcess,
191  dwStackSize,
192  dwCreationFlags & STACK_SIZE_PARAM_IS_A_RESERVATION ?
193  dwStackSize : 0,
194  &InitialTeb);
195  if (!NT_SUCCESS(Status))
196  {
197  BaseSetLastNTError(Status);
198  return NULL;
199  }
200 
201  /* Create Initial Context */
202  BaseInitializeContext(&Context,
203  lpParameter,
204  lpStartAddress,
205  InitialTeb.StackBase,
206  1);
207 
208  /* initialize the attributes for the thread object */
209  ObjectAttributes = BaseFormatObjectAttributes(&LocalObjectAttributes,
210  lpThreadAttributes,
211  NULL);
212 
213  /* Create the Kernel Thread Object */
214  Status = NtCreateThread(&hThread,
216  ObjectAttributes,
217  hProcess,
218  &ClientId,
219  &Context,
220  &InitialTeb,
221  TRUE);
222  if (!NT_SUCCESS(Status))
223  {
224  /* Fail the kernel create */
225  BaseFreeThreadStack(hProcess, &InitialTeb);
226  BaseSetLastNTError(Status);
227  return NULL;
228  }
229 
230  /* Are we in the same process? */
231  if (hProcess == NtCurrentProcess())
232  {
233  /* Get the TEB */
234  Status = NtQueryInformationThread(hThread,
236  &ThreadBasicInfo,
237  sizeof(ThreadBasicInfo),
238  &ReturnLength);
239  if (!NT_SUCCESS(Status))
240  {
241  /* Fail */
242  ERROR_DBGBREAK("SXS: %s - Failing thread create because "
243  "NtQueryInformationThread() failed with status %08lx\n",
244  __FUNCTION__, Status);
245  return NULL;
246  }
247 
248  /* Allocate the Activation Context Stack */
249  Status = RtlAllocateActivationContextStack(&ActivationContextStack);
250  if (!NT_SUCCESS(Status))
251  {
252  /* Fail */
253  ERROR_DBGBREAK("SXS: %s - Failing thread create because "
254  "RtlAllocateActivationContextStack() failed with status %08lx\n",
255  __FUNCTION__, Status);
256  return NULL;
257  }
258 
259  /* Save it */
260  Teb = ThreadBasicInfo.TebBaseAddress;
261  Teb->ActivationContextStackPointer = ActivationContextStack;
262 
263  /* Query the Context */
265  NULL,
266  0,
267  ActivationContextBasicInformation,
268  &ActCtxInfo,
269  sizeof(ActCtxInfo),
270  &ReturnLength);
271  if (!NT_SUCCESS(Status))
272  {
273  /* Fail */
274  ERROR_DBGBREAK("SXS: %s - Failing thread create because "
275  "RtlQueryInformationActivationContext() failed with status %08lx\n",
276  __FUNCTION__, Status);
277 
278  /* Free the activation context stack */
279  // RtlFreeThreadActivationContextStack();
281 
282  return NULL;
283  }
284 
285  /* Does it need to be activated? */
286  if ((ActCtxInfo.hActCtx) && !(ActCtxInfo.dwFlags & 1))
287  {
288  /* Activate it */
290  Teb,
291  ActCtxInfo.hActCtx,
292  &Cookie);
293  if (!NT_SUCCESS(Status))
294  {
295  /* Fail */
296  ERROR_DBGBREAK("SXS: %s - Failing thread create because "
297  "RtlActivateActivationContextEx() failed with status %08lx\n",
298  __FUNCTION__, Status);
299 
300  /* Free the activation context stack */
301  // RtlFreeThreadActivationContextStack();
303 
304  return NULL;
305  }
306  }
307  }
308 
309  /* Notify CSR */
311  {
312  Status = BasepNotifyCsrOfThread(hThread, &ClientId);
313  ASSERT(NT_SUCCESS(Status));
314  }
315  else
316  {
317  if (hProcess != NtCurrentProcess())
318  {
320 
321  /* Get the direct CSRSRV export */
322  CsrCreateRemoteThread = (PCSR_CREATE_REMOTE_THREAD)
324  "CsrCreateRemoteThread");
325  if (CsrCreateRemoteThread)
326  {
327  /* Call it instead of going through LPC */
328  Status = CsrCreateRemoteThread(hThread, &ClientId);
329  ASSERT(NT_SUCCESS(Status));
330  }
331  }
332  }
333 
334  /* Success */
335  if (lpThreadId) *lpThreadId = HandleToUlong(ClientId.UniqueThread);
336 
337  /* Resume it if asked */
338  if (!(dwCreationFlags & CREATE_SUSPENDED)) NtResumeThread(hThread, &Dummy);
339 
340  /* Return handle to thread */
341  return hThread;
342 }
343 
344 /*
345  * @implemented
346  */
347 VOID
348 WINAPI
349 ExitThread(IN DWORD uExitCode)
350 {
353  PRTL_CRITICAL_SECTION LoaderLock;
354 
355  /* Make sure loader lock isn't held */
356  LoaderLock = NtCurrentPeb()->LoaderLock;
357  if (LoaderLock) ASSERT(NtCurrentTeb()->ClientId.UniqueThread != LoaderLock->OwningThread);
358 
359  /*
360  * Terminate process if this is the last thread
361  * of the current process
362  */
365  &LastThread,
366  sizeof(LastThread),
367  NULL);
368  if ((NT_SUCCESS(Status)) && (LastThread)) ExitProcess(uExitCode);
369 
370  /* Notify DLLs and TLS Callbacks of termination */
372 
373  /* Tell the Kernel to free the Stack */
374  NtCurrentTeb()->FreeStackOnTermination = TRUE;
375  NtTerminateThread(NULL, uExitCode);
376 
377  /* We should never reach this place */
378  ERROR_FATAL("It should not happen\n");
379  while (TRUE); /* 'noreturn' function */
380 }
381 
382 /*
383  * @implemented
384  */
385 HANDLE
386 WINAPI
387 OpenThread(IN DWORD dwDesiredAccess,
390 {
392  HANDLE ThreadHandle;
395 
396  ClientId.UniqueProcess = 0;
397  ClientId.UniqueThread = ULongToHandle(dwThreadId);
398 
399  InitializeObjectAttributes(&ObjectAttributes,
400  NULL,
401  (bInheritHandle ? OBJ_INHERIT : 0),
402  NULL,
403  NULL);
404 
405  Status = NtOpenThread(&ThreadHandle,
406  dwDesiredAccess,
407  &ObjectAttributes,
408  &ClientId);
409  if (!NT_SUCCESS(Status))
410  {
411  BaseSetLastNTError(Status);
412  return NULL;
413  }
414 
415  return ThreadHandle;
416 }
417 
418 /*
419  * @implemented
420  */
421 PTEB
423 {
424  return NtCurrentTeb();
425 }
426 
427 /*
428  * @implemented
429  */
430 BOOL
431 WINAPI
433 {
435 }
436 
437 
438 /*
439  * @implemented
440  */
441 DWORD
442 WINAPI
444 {
446 }
447 
448 /*
449  * @implemented
450  */
451 BOOL
452 NTAPI
454  OUT LPFILETIME lpCreationTime,
455  OUT LPFILETIME lpExitTime,
456  OUT LPFILETIME lpKernelTime,
457  OUT LPFILETIME lpUserTime)
458 {
459  KERNEL_USER_TIMES KernelUserTimes;
461 
462  Status = NtQueryInformationThread(hThread,
463  ThreadTimes,
464  &KernelUserTimes,
465  sizeof(KERNEL_USER_TIMES),
466  NULL);
467  if (!NT_SUCCESS(Status))
468  {
469  BaseSetLastNTError(Status);
470  return FALSE;
471  }
472 
473  *lpCreationTime = *(LPFILETIME)&KernelUserTimes.CreateTime;
474  *lpExitTime = *(LPFILETIME)&KernelUserTimes.ExitTime;
475  *lpKernelTime = *(LPFILETIME)&KernelUserTimes.KernelTime;
476  *lpUserTime = *(LPFILETIME)&KernelUserTimes.UserTime;
477  return TRUE;
478 }
479 
480 /*
481  * @implemented
482  */
483 BOOL
484 WINAPI
486  OUT LPCONTEXT lpContext)
487 {
489 
490  Status = NtGetContextThread(hThread, lpContext);
491  if (!NT_SUCCESS(Status))
492  {
493  BaseSetLastNTError(Status);
494  return FALSE;
495  }
496 
497  return TRUE;
498 }
499 
500 /*
501  * @implemented
502  */
503 BOOL
504 WINAPI
506  IN CONST CONTEXT *lpContext)
507 {
509 
510  Status = NtSetContextThread(hThread, (PCONTEXT)lpContext);
511  if (!NT_SUCCESS(Status))
512  {
513  BaseSetLastNTError(Status);
514  return FALSE;
515  }
516 
517  return TRUE;
518 }
519 
520 /*
521  * @implemented
522  */
523 BOOL
524 WINAPI
526  OUT LPDWORD lpExitCode)
527 {
528  THREAD_BASIC_INFORMATION ThreadBasic;
530 
531  Status = NtQueryInformationThread(hThread,
533  &ThreadBasic,
534  sizeof(THREAD_BASIC_INFORMATION),
535  NULL);
536  if (!NT_SUCCESS(Status))
537  {
538  BaseSetLastNTError(Status);
539  return FALSE;
540  }
541 
542  *lpExitCode = ThreadBasic.ExitStatus;
543  return TRUE;
544 }
545 
546 /*
547  * @implemented
548  */
549 DWORD
550 WINAPI
552 {
553  ULONG PreviousResumeCount;
555 
556  Status = NtResumeThread(hThread, &PreviousResumeCount);
557  if (!NT_SUCCESS(Status))
558  {
559  BaseSetLastNTError(Status);
560  return -1;
561  }
562 
563  return PreviousResumeCount;
564 }
565 
566 /*
567  * @implemented
568  */
569 BOOL
570 WINAPI
572  IN DWORD dwExitCode)
573 {
575 #if DBG
576  PRTL_CRITICAL_SECTION LoaderLock;
578 #endif /* DBG */
579 
580  /* Check for invalid thread handle */
581  if (!hThread)
582  {
583  /* Fail if one was passed */
585  return FALSE;
586  }
587 
588 #if DBG
589  /* Get the loader lock */
590  LoaderLock = NtCurrentPeb()->LoaderLock;
591  if (LoaderLock)
592  {
593  /* Get our TID */
594  Status = NtQueryInformationThread(hThread,
596  &ThreadInfo,
597  sizeof(ThreadInfo),
598  NULL);
599  if (NT_SUCCESS(Status))
600  {
601  /* If terminating the current thread, we must not hold the loader lock */
604  }
605  }
606 #endif /* DBG */
607 
608  /* Now terminate the thread */
609  Status = NtTerminateThread(hThread, dwExitCode);
610  if (!NT_SUCCESS(Status))
611  {
612  /* Fail */
613  BaseSetLastNTError(Status);
614  return FALSE;
615  }
616 
617  /* All done */
618  return TRUE;
619 }
620 
621 /*
622  * @implemented
623  */
624 DWORD
625 WINAPI
627 {
628  ULONG PreviousSuspendCount;
630 
631  Status = NtSuspendThread(hThread, &PreviousSuspendCount);
632  if (!NT_SUCCESS(Status))
633  {
634  BaseSetLastNTError(Status);
635  return -1;
636  }
637 
638  return PreviousSuspendCount;
639 }
640 
641 /*
642  * @implemented
643  */
644 DWORD_PTR
645 WINAPI
647  IN DWORD_PTR dwThreadAffinityMask)
648 {
649  THREAD_BASIC_INFORMATION ThreadBasic;
650  KAFFINITY AffinityMask;
652 
653  AffinityMask = (KAFFINITY)dwThreadAffinityMask;
654 
655  Status = NtQueryInformationThread(hThread,
657  &ThreadBasic,
658  sizeof(THREAD_BASIC_INFORMATION),
659  NULL);
660  if (!NT_SUCCESS(Status))
661  {
662  BaseSetLastNTError(Status);
663  return 0;
664  }
665 
666  Status = NtSetInformationThread(hThread,
668  &AffinityMask,
669  sizeof(KAFFINITY));
670  if (!NT_SUCCESS(Status))
671  {
672  BaseSetLastNTError(Status);
673  ThreadBasic.AffinityMask = 0;
674  }
675 
676  return ThreadBasic.AffinityMask;
677 }
678 
679 /*
680  * @implemented
681  */
682 BOOL
683 WINAPI
685  IN int nPriority)
686 {
687  LONG Prio = nPriority;
689 
690  /* Check if values forcing saturation should be used */
691  if (Prio == THREAD_PRIORITY_TIME_CRITICAL)
692  {
693  /* This is 16 */
694  Prio = (HIGH_PRIORITY + 1) / 2;
695  }
696  else if (Prio == THREAD_PRIORITY_IDLE)
697  {
698  /* This is -16 */
699  Prio = -((HIGH_PRIORITY + 1) / 2);
700  }
701 
702  /* Set the Base Priority */
703  Status = NtSetInformationThread(hThread,
705  &Prio,
706  sizeof(LONG));
707  if (!NT_SUCCESS(Status))
708  {
709  /* Failure */
710  BaseSetLastNTError(Status);
711  return FALSE;
712  }
713 
714  /* Return */
715  return TRUE;
716 }
717 
718 /*
719  * @implemented
720  */
721 int
722 WINAPI
724 {
725  THREAD_BASIC_INFORMATION ThreadBasic;
727 
728  /* Query the Base Priority Increment */
729  Status = NtQueryInformationThread(hThread,
731  &ThreadBasic,
732  sizeof(THREAD_BASIC_INFORMATION),
733  NULL);
734  if (!NT_SUCCESS(Status))
735  {
736  /* Failure */
737  BaseSetLastNTError(Status);
739  }
740 
741  /* Do some conversions for saturation values */
742  if (ThreadBasic.BasePriority == ((HIGH_PRIORITY + 1) / 2))
743  {
744  /* Win32 calls this "time critical" */
746  }
747  else if (ThreadBasic.BasePriority == -((HIGH_PRIORITY + 1) / 2))
748  {
749  /* Win32 calls this "idle" */
750  ThreadBasic.BasePriority = THREAD_PRIORITY_IDLE;
751  }
752 
753  /* Return the final result */
754  return ThreadBasic.BasePriority;
755 }
756 
757 /*
758  * @implemented
759  */
760 BOOL
761 WINAPI
763  OUT PBOOL pDisablePriorityBoost)
764 {
767 
768  Status = NtQueryInformationThread(hThread,
770  &PriorityBoost,
771  sizeof(ULONG),
772  NULL);
773  if (!NT_SUCCESS(Status))
774  {
775  BaseSetLastNTError(Status);
776  return FALSE;
777  }
778 
779  *pDisablePriorityBoost = PriorityBoost;
780  return TRUE;
781 }
782 
783 /*
784  * @implemented
785  */
786 BOOL
787 NTAPI
789  IN BOOL bDisablePriorityBoost)
790 {
793 
794  PriorityBoost = bDisablePriorityBoost != FALSE;
795 
796  Status = NtSetInformationThread(hThread,
798  &PriorityBoost,
799  sizeof(ULONG));
800  if (!NT_SUCCESS(Status))
801  {
802  BaseSetLastNTError(Status);
803  return FALSE;
804  }
805 
806  return TRUE;
807 }
808 
809 /*
810  * @implemented
811  */
812 BOOL
813 WINAPI
815  IN DWORD dwSelector,
816  OUT LPLDT_ENTRY lpSelectorEntry)
817 {
818 #ifdef _M_IX86
819  DESCRIPTOR_TABLE_ENTRY DescriptionTableEntry;
821 
822  /* Set the selector and do the query */
823  DescriptionTableEntry.Selector = dwSelector;
824  Status = NtQueryInformationThread(hThread,
826  &DescriptionTableEntry,
827  sizeof(DESCRIPTOR_TABLE_ENTRY),
828  NULL);
829  if (!NT_SUCCESS(Status))
830  {
831  /* Fail */
832  BaseSetLastNTError(Status);
833  return FALSE;
834  }
835 
836  /* Success, return the selector */
837  *lpSelectorEntry = DescriptionTableEntry.Descriptor;
838  return TRUE;
839 #else
840  DPRINT1("Calling GetThreadSelectorEntry!\n");
841  return FALSE;
842 #endif
843 }
844 
845 /*
846  * @implemented
847  */
848 DWORD
849 WINAPI
851  IN DWORD dwIdealProcessor)
852 {
854 
855  Status = NtSetInformationThread(hThread,
857  &dwIdealProcessor,
858  sizeof(ULONG));
859  if (!NT_SUCCESS(Status))
860  {
861  BaseSetLastNTError(Status);
862  return -1;
863  }
864 
865  return (DWORD)Status;
866 }
867 
868 /*
869  * @implemented
870  */
871 DWORD
872 WINAPI
874 {
875  THREAD_BASIC_INFORMATION ThreadBasic;
877 
878  Status = NtQueryInformationThread(Thread,
880  &ThreadBasic,
881  sizeof(THREAD_BASIC_INFORMATION),
882  NULL);
883  if (!NT_SUCCESS(Status))
884  {
885  BaseSetLastNTError(Status);
886  return 0;
887  }
888 
889  return HandleToUlong(ThreadBasic.ClientId.UniqueProcess);
890 }
891 
892 /*
893  * @implemented
894  */
895 DWORD
896 WINAPI
898 {
899  THREAD_BASIC_INFORMATION ThreadBasic;
901 
902  Status = NtQueryInformationThread(Thread,
904  &ThreadBasic,
905  sizeof(THREAD_BASIC_INFORMATION),
906  NULL);
907  if (!NT_SUCCESS(Status))
908  {
909  BaseSetLastNTError(Status);
910  return 0;
911  }
912 
913  return HandleToUlong(ThreadBasic.ClientId.UniqueThread);
914 }
915 
916 /*
917  * @unimplemented
918  */
919 LANGID
920 WINAPI
922 {
924  return (LANGID)NtCurrentTeb()->CurrentLocale;
925 }
926 
927 /*
928  * @implemented
929  */
930 DWORD
931 WINAPI
933  IN HANDLE hThread,
935 {
937  ACTIVATION_CONTEXT_BASIC_INFORMATION ActCtxInfo;
938 
939  /* Zero the activation context and query information on it */
940  RtlZeroMemory(&ActCtxInfo, sizeof(ActCtxInfo));
942  NULL,
943  0,
944  ActivationContextBasicInformation,
945  &ActCtxInfo,
946  sizeof(ActCtxInfo),
947  NULL);
948  if (!NT_SUCCESS(Status))
949  {
950  /* Fail due to SxS */
951  DbgPrint("SXS: %s failing because RtlQueryInformationActivationContext()"
952  "returned status %08lx\n", __FUNCTION__, Status);
953  BaseSetLastNTError(Status);
954  return FALSE;
955  }
956 
957  /* Queue the APC */
958  Status = NtQueueApcThread(hThread,
960  pfnAPC,
961  (PVOID)dwData,
962  (ActCtxInfo.dwFlags & 1) ?
963  INVALID_ACTIVATION_CONTEXT : ActCtxInfo.hActCtx);
964  if (!NT_SUCCESS(Status))
965  {
966  BaseSetLastNTError(Status);
967  return FALSE;
968  }
969 
970  /* All good */
971  return TRUE;
972 }
973 
974 /*
975  * @implemented
976  */
977 BOOL
978 WINAPI
980 {
981  static int once;
982  if (once++ == 0)
983  DPRINT1("SetThreadStackGuarantee(%p): stub\n", StackSizeInBytes);
984  return TRUE;
985 }
986 
987 /*
988  * @implemented
989  */
990 BOOL
991 WINAPI
993  OUT PBOOL lpIOIsPending)
994 {
995  ULONG IoPending;
997 
998  /* Query the flag */
999  Status = NtQueryInformationThread(hThread,
1001  &IoPending,
1002  sizeof(IoPending),
1003  NULL);
1004  if (NT_SUCCESS(Status))
1005  {
1006  /* Return the flag */
1007  *lpIOIsPending = IoPending ? TRUE : FALSE;
1008  return TRUE;
1009  }
1010 
1011  /* Fail */
1012  BaseSetLastNTError(Status);
1013  return FALSE;
1014 }
1015 
1016 /*
1017  * @implemented
1018  */
1019 BOOL
1020 WINAPI
1022  IN PVOID Context,
1023  IN ULONG Flags)
1024 {
1025  NTSTATUS Status;
1026 
1027  /* NOTE: Rtl needs to safely call the function using a trampoline */
1028  Status = RtlQueueWorkItem((WORKERCALLBACKFUNC)Function, Context, Flags);
1029  if (!NT_SUCCESS(Status))
1030  {
1031  /* Failed */
1032  BaseSetLastNTError(Status);
1033  return FALSE;
1034  }
1035 
1036  /* All good */
1037  return TRUE;
1038 }
1039 
1040 /*
1041  * @implemented
1042  */
1043 DWORD
1044 WINAPI
1046 {
1047  ULONG Index;
1048  PTEB Teb;
1049  PPEB Peb;
1050 
1051  /* Get the PEB and TEB, lock the PEB */
1052  Teb = NtCurrentTeb();
1053  Peb = Teb->ProcessEnvironmentBlock;
1055 
1056  /* Try to get regular TEB slot */
1057  Index = RtlFindClearBitsAndSet(Peb->TlsBitmap, 1, 0);
1058  if (Index != 0xFFFFFFFF)
1059  {
1060  /* Clear the value. */
1061  Teb->TlsSlots[Index] = 0;
1063  return Index;
1064  }
1065 
1066  /* If it fails, try to find expansion TEB slot. */
1067  Index = RtlFindClearBitsAndSet(Peb->TlsExpansionBitmap, 1, 0);
1068  if (Index != 0xFFFFFFFF)
1069  {
1070  /* Is there no expansion slot yet? */
1071  if (!Teb->TlsExpansionSlots)
1072  {
1073  /* Allocate an array */
1074  Teb->TlsExpansionSlots = RtlAllocateHeap(RtlGetProcessHeap(),
1077  sizeof(PVOID));
1078  }
1079 
1080  /* Did we get an array? */
1081  if (!Teb->TlsExpansionSlots)
1082  {
1083  /* Fail */
1084  RtlClearBits(Peb->TlsExpansionBitmap, Index, 1);
1085  Index = 0xFFFFFFFF;
1087  }
1088  else
1089  {
1090  /* Clear the value. */
1091  Teb->TlsExpansionSlots[Index] = 0;
1092  Index += TLS_MINIMUM_AVAILABLE;
1093  }
1094  }
1095  else
1096  {
1097  /* Fail */
1099  }
1100 
1101  /* Release the lock and return */
1103  return Index;
1104 }
1105 
1106 /*
1107  * @implemented
1108  */
1109 BOOL
1110 WINAPI
1112 {
1113  BOOL BitSet;
1114  PPEB Peb;
1115  ULONG TlsIndex;
1116  PVOID TlsBitmap;
1117  NTSTATUS Status;
1118 
1119  /* Acquire the PEB lock and grab the PEB */
1120  Peb = NtCurrentPeb();
1122 
1123  /* Check if the index is too high */
1124  if (Index >= TLS_MINIMUM_AVAILABLE)
1125  {
1126  /* Check if it can fit in the expansion slots */
1127  TlsIndex = Index - TLS_MINIMUM_AVAILABLE;
1128  if (TlsIndex >= TLS_EXPANSION_SLOTS)
1129  {
1130  /* It's invalid */
1133  return FALSE;
1134  }
1135  else
1136  {
1137  /* Use the expansion bitmap */
1138  TlsBitmap = Peb->TlsExpansionBitmap;
1139  Index = TlsIndex;
1140  }
1141  }
1142  else
1143  {
1144  /* Use the normal bitmap */
1145  TlsBitmap = Peb->TlsBitmap;
1146  }
1147 
1148  /* Check if the index was set */
1149  BitSet = RtlAreBitsSet(TlsBitmap, Index, 1);
1150  if (BitSet)
1151  {
1152  /* Tell the kernel to free the TLS cells */
1155  &Index,
1156  sizeof(DWORD));
1157  if (!NT_SUCCESS(Status))
1158  {
1161  return FALSE;
1162  }
1163 
1164  /* Clear the bit */
1165  RtlClearBits(TlsBitmap, Index, 1);
1166  }
1167  else
1168  {
1169  /* Fail */
1172  return FALSE;
1173  }
1174 
1175  /* Done! */
1177  return TRUE;
1178 }
1179 
1180 /*
1181  * @implemented
1182  */
1183 LPVOID
1184 WINAPI
1186 {
1187  PTEB Teb;
1188 
1189  /* Get the TEB and clear the last error */
1190  Teb = NtCurrentTeb();
1191  Teb->LastErrorValue = 0;
1192 
1193  /* Check for simple TLS index */
1194  if (Index < TLS_MINIMUM_AVAILABLE)
1195  {
1196  /* Return it */
1197  return Teb->TlsSlots[Index];
1198  }
1199 
1200  /* Check for valid index */
1202  {
1203  /* Fail */
1205  return NULL;
1206  }
1207 
1208  /* The expansion slots are allocated on demand, so check for it. */
1209  Teb->LastErrorValue = 0;
1210  if (!Teb->TlsExpansionSlots) return NULL;
1211 
1212  /* Return the value from the expansion slots */
1213  return Teb->TlsExpansionSlots[Index - TLS_MINIMUM_AVAILABLE];
1214 }
1215 
1216 /*
1217  * @implemented
1218  */
1219 BOOL
1220 WINAPI
1222  IN LPVOID Value)
1223 {
1224  DWORD TlsIndex;
1225  PTEB Teb = NtCurrentTeb();
1226 
1227  /* Check for simple TLS index */
1228  if (Index < TLS_MINIMUM_AVAILABLE)
1229  {
1230  /* Return it */
1231  Teb->TlsSlots[Index] = Value;
1232  return TRUE;
1233  }
1234 
1235  /* Check if this is an expansion slot */
1236  TlsIndex = Index - TLS_MINIMUM_AVAILABLE;
1237  if (TlsIndex >= TLS_EXPANSION_SLOTS)
1238  {
1239  /* Fail */
1241  return FALSE;
1242  }
1243 
1244  /* Do we not have expansion slots? */
1245  if (!Teb->TlsExpansionSlots)
1246  {
1247  /* Get the PEB lock to see if we still need them */
1249  if (!Teb->TlsExpansionSlots)
1250  {
1251  /* Allocate them */
1252  Teb->TlsExpansionSlots = RtlAllocateHeap(RtlGetProcessHeap(),
1255  sizeof(PVOID));
1256  if (!Teb->TlsExpansionSlots)
1257  {
1258  /* Fail */
1261  return FALSE;
1262  }
1263  }
1264 
1265  /* Release the lock */
1267  }
1268 
1269  /* Write the value */
1271 
1272  /* Success */
1273  return TRUE;
1274 }
1275 
1276 /* EOF */
DWORD *typedef PVOID
Definition: winlogon.h:52
PRTL_BITMAP TlsExpansionBitmap
Definition: winternl.h:333
LANGID WINAPI SetThreadUILanguage(IN LANGID LangId)
Definition: thread.c:921
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:453
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1339
BOOL WINAPI SwitchToThread(VOID)
Definition: thread.c:432
#define TRUE
Definition: types.h:120
BOOL WINAPI SetThreadContext(IN HANDLE hThread, IN CONST CONTEXT *lpContext)
Definition: thread.c:505
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:571
KAFFINITY AffinityMask
Definition: compat.h:579
#define DbgPrint
Definition: loader.c:25
BOOL WINAPI TlsSetValue(IN DWORD Index, IN LPVOID Value)
Definition: thread.c:1221
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:1050
#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:897
struct _ThreadInfo ThreadInfo
WORD LANGID
Definition: typedefs.h:79
BOOL WINAPI GetThreadIOPendingFlag(IN HANDLE hThread, OUT PBOOL lpIOIsPending)
Definition: thread.c:992
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:75
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:1048
#define ERROR_FATAL(...)
Definition: debug.h:236
BOOL WINAPI GetExitCodeThread(IN HANDLE hThread, OUT LPDWORD lpExitCode)
Definition: thread.c:525
BOOL WINAPI GetThreadContext(IN HANDLE hThread, OUT LPCONTEXT lpContext)
Definition: thread.c:485
_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:932
#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:788
LONG WINAPI UnhandledExceptionFilter(IN PEXCEPTION_POINTERS ExceptionInfo)
Definition: except.c:259
VOID(NTAPI * WORKERCALLBACKFUNC)(_In_ PVOID Context)
Definition: rtltypes.h:509
_In_ CCHAR PriorityBoost
Definition: iofuncs.h:763
#define ERROR_DBGBREAK(...)
Definition: debug.h:219
#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:646
PVOID StackBase
Definition: pstypes.h:678
void DPRINT(...)
Definition: polytest.cpp:61
BOOL WINAPI GetThreadPriorityBoost(IN HANDLE hThread, OUT PBOOL pDisablePriorityBoost)
Definition: thread.c:762
#define RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_FORMAT_WHISTLER
Definition: rtltypes.h:101
VOID WINAPI ExitThread(IN DWORD uExitCode)
Definition: thread.c:349
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:1969
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:443
#define CONST
Definition: compiler.h:170
BOOL WINAPI SetThreadPriority(IN HANDLE hThread, IN int nPriority)
Definition: thread.c:684
#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:1111
#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:1047
#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:979
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:850
NTSTATUS NTAPI NtQueryInformationThread(IN HANDLE ThreadHandle, IN THREADINFOCLASS ThreadInformationClass, OUT PVOID ThreadInformation, IN ULONG ThreadInformationLength, OUT PULONG ReturnLength OPTIONAL)
Definition: query.c:2452
_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:1021
#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:626
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:387
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:818
DWORD WINAPI TlsAlloc(VOID)
Definition: thread.c:1045
PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER
Definition: winbase.h:1406
PTEB GetTeb(VOID)
Definition: thread.c:422
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
Definition: compat.h:484
NTSTATUS WINAPI BasepNotifyCsrOfThread(IN HANDLE ThreadHandle, IN PCLIENT_ID ClientId)
Definition: proc.c:511
DWORD *typedef HANDLE
Definition: winlogon.h:52
_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:873
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:814
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:1185
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:551
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:156
#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:1015
PVOID TlsBitmap
Definition: ntddk_ex.h:263
LARGE_INTEGER KernelTime
Definition: winternl.h:1049
int WINAPI GetThreadPriority(IN HANDLE hThread)
Definition: thread.c:723
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