ReactOS 0.4.17-dev-1196-gb6224c3
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/* INCLUDES *******************************************************************/
11
12#include <k32.h>
13
14#define NDEBUG
15#include <debug.h>
16
17#define SXS_SUPPORT_FIXME
18
20
21#define THREAD_ALL_ACCESS_NT6 (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xFFFF)
22
23/* FUNCTIONS ******************************************************************/
24
29{
30 BASE_API_MESSAGE ApiMessage;
31 PBASE_CREATE_THREAD CreateThreadRequest = &ApiMessage.Data.CreateThreadRequest;
32
33 DPRINT("BasepNotifyCsrOfThread: Thread: %p, Handle %p\n",
34 ClientId->UniqueThread, ThreadHandle);
35
36 /* Fill out the request */
37 CreateThreadRequest->ClientId = *ClientId;
38 CreateThreadRequest->ThreadHandle = ThreadHandle;
39
40 /* Call CSR */
42 NULL,
44 sizeof(*CreateThreadRequest));
45 if (!NT_SUCCESS(ApiMessage.Status))
46 {
47 DPRINT1("Failed to tell CSRSS about new thread: %lx\n", ApiMessage.Status);
48 return ApiMessage.Status;
49 }
50
51 /* Return Success */
52 return STATUS_SUCCESS;
53}
54
56VOID
59 _In_ LPTHREAD_START_ROUTINE lpStartAddress,
60 _In_ LPVOID lpParameter)
61{
62 /* Attempt to call the Thread Start Address */
64 {
65 /* Legacy check which is still used today for Win32 threads */
66 if (NtCurrentTeb()->NtTib.Version == (30 << 8)) // OS/2 V3.0 ("Cruiser")
67 {
68 /* This registers the termination port with CSRSS */
70 }
71
72 /* Get the exit code from the Thread Start */
73 ExitThread(lpStartAddress(lpParameter));
74 }
76 {
77 /* Get the Exit code from the SEH Handler */
79 {
80 /* Kill the whole process, usually */
82 }
83 else
84 {
85 /* If running inside CSRSS, kill just this thread */
87 }
88 }
90}
91
92VOID
96 IN PACTIVATION_CONTEXT ActivationContext)
97{
98 RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME ActivationFrame;
99
100 /* Setup the activation context */
101 ActivationFrame.Size = sizeof(ActivationFrame);
103
104 /* Check if caller wanted one */
105 if (ActivationContext == INVALID_ACTIVATION_CONTEXT)
106 {
107 /* Do the APC directly */
109 return;
110 }
111
112 /* Then activate it */
113 RtlActivateActivationContextUnsafeFast(&ActivationFrame, ActivationContext);
114
115 /* Call the routine under SEH */
117 {
119 }
121 {
122
123 }
124 _SEH2_END;
125
126 /* Now de-activate and release the activation context */
127 RtlDeactivateActivationContextUnsafeFast(&ActivationFrame);
128 RtlReleaseActivationContext(ActivationContext);
129}
130
131/* PUBLIC FUNCTIONS ***********************************************************/
132
133/*
134 * @implemented
135 */
136HANDLE
137WINAPI
140 IN DWORD dwStackSize,
141 IN LPTHREAD_START_ROUTINE lpStartAddress,
142 IN LPVOID lpParameter,
143 IN DWORD dwCreationFlags,
144 OUT LPDWORD lpThreadId)
145{
146 /* Act as if we're going to create a remote thread in ourselves */
148 lpThreadAttributes,
149 dwStackSize,
150 lpStartAddress,
151 lpParameter,
152 dwCreationFlags,
153 lpThreadId);
154}
155
156/*
157 * @implemented
158 */
159HANDLE
160WINAPI
162 IN LPSECURITY_ATTRIBUTES lpThreadAttributes,
163 IN DWORD dwStackSize,
164 IN LPTHREAD_START_ROUTINE lpStartAddress,
165 IN LPVOID lpParameter,
166 IN DWORD dwCreationFlags,
167 OUT LPDWORD lpThreadId)
168{
170 INITIAL_TEB InitialTeb;
173 OBJECT_ATTRIBUTES LocalObjectAttributes;
176 ULONG Dummy;
177 PTEB Teb;
178 THREAD_BASIC_INFORMATION ThreadBasicInfo;
179 PACTIVATION_CONTEXT_STACK ActivationContextStack = NULL;
180 ACTIVATION_CONTEXT_BASIC_INFORMATION ActCtxInfo;
183 SIZE_T ReturnSize;
184
185 DPRINT("CreateRemoteThread: hProcess: %p dwStackSize: %lu lpStartAddress"
186 ": %p lpParameter: %p, dwCreationFlags: %lx\n", hProcess,
187 dwStackSize, lpStartAddress, lpParameter, dwCreationFlags);
188
189 /* Clear the Context */
190 RtlZeroMemory(&Context, sizeof(Context));
191
192 /* Write PID */
194
195 /* Create the Stack */
197 (dwCreationFlags & STACK_SIZE_PARAM_IS_A_RESERVATION) ?
198 0 : dwStackSize,
199 (dwCreationFlags & STACK_SIZE_PARAM_IS_A_RESERVATION) ?
200 dwStackSize : 0,
201 &InitialTeb);
202 if (!NT_SUCCESS(Status))
203 {
205 return NULL;
206 }
207
208 /* Create the Initial Context */
210 lpParameter,
211 lpStartAddress,
212 InitialTeb.StackBase,
213 1);
214
215 /* Initialize the attributes for the thread object */
216 ObjectAttributes = BaseFormatObjectAttributes(&LocalObjectAttributes,
217 lpThreadAttributes,
218 NULL);
219
220 /* Create the Kernel Thread Object */
224 hProcess,
225 &ClientId,
226 &Context,
227 &InitialTeb,
228 TRUE);
229 if (!NT_SUCCESS(Status))
230 {
231 /* Fail the kernel create */
232 BaseFreeThreadStack(hProcess, &InitialTeb);
234 return NULL;
235 }
236
237 /* Are we in the same process? */
238 if (hProcess == NtCurrentProcess())
239 {
240 /* Get the TEB */
243 &ThreadBasicInfo,
244 sizeof(ThreadBasicInfo),
245 &ReturnLength);
246 if (!NT_SUCCESS(Status))
247 {
248 /* Fail */
249 DPRINT1("SXS: %s - Failing thread create because "
250 "NtQueryInformationThread() failed with status %08lx\n",
252 goto Quit;
253 }
254
255 /* Allocate the Activation Context Stack */
256 Status = RtlAllocateActivationContextStack(&ActivationContextStack);
257 if (!NT_SUCCESS(Status))
258 {
259 /* Fail */
260 DPRINT1("SXS: %s - Failing thread create because "
261 "RtlAllocateActivationContextStack() failed with status %08lx\n",
263 goto Quit;
264 }
265
266 /* Save it */
267 Teb = ThreadBasicInfo.TebBaseAddress;
268 Teb->ActivationContextStackPointer = ActivationContextStack;
269
270 /* Query the Context */
272 NULL,
273 0,
274 ActivationContextBasicInformation,
275 &ActCtxInfo,
276 sizeof(ActCtxInfo),
277 &ReturnSize);
278 if (!NT_SUCCESS(Status))
279 {
280 /* Fail */
281 DPRINT1("SXS: %s - Failing thread create because "
282 "RtlQueryInformationActivationContext() failed with status %08lx\n",
284 goto Quit;
285 }
286
287 /* Does it need to be activated? */
288 if ((ActCtxInfo.hActCtx) && !(ActCtxInfo.dwFlags & 1))
289 {
290 /* Activate it */
292 Teb,
293 ActCtxInfo.hActCtx,
294 &Cookie);
295 if (!NT_SUCCESS(Status))
296 {
297 /* Fail */
298 DPRINT1("SXS: %s - Failing thread create because "
299 "RtlActivateActivationContextEx() failed with status %08lx\n",
301 goto Quit;
302 }
303 }
304
305 /* Sync the service tag with the parent thread's one */
306 Teb->SubProcessTag = NtCurrentTeb()->SubProcessTag;
307 }
308
309 /* Notify CSR */
311 {
313 }
314 else
315 {
316 if (hProcess != NtCurrentProcess())
317 {
319
320 /* Get the direct CSRSRV export */
323 "CsrCreateRemoteThread");
325 {
326 /* Call it instead of going through LPC */
328 }
329 }
330 }
331
332Quit:
333 if (!NT_SUCCESS(Status))
334 {
335 /* Failed to create the thread */
336
337 /* Free the activation context stack */
338 if (ActivationContextStack)
339 RtlFreeActivationContextStack(ActivationContextStack);
340
342 // FIXME: Wait for the thread to terminate?
343 BaseFreeThreadStack(hProcess, &InitialTeb);
345
347 return NULL;
348 }
349
350 /* Success */
351 if (lpThreadId)
352 *lpThreadId = HandleToUlong(ClientId.UniqueThread);
353
354 /* Resume the thread if asked */
355 if (!(dwCreationFlags & CREATE_SUSPENDED))
356 NtResumeThread(hThread, &Dummy);
357
358 /* Return handle to thread */
359 return hThread;
360}
361
362/*
363 * @implemented
364 */
365VOID
366WINAPI
368{
371 PRTL_CRITICAL_SECTION LoaderLock;
372
373 /* Make sure loader lock isn't held */
374 LoaderLock = NtCurrentPeb()->LoaderLock;
375 if (LoaderLock) ASSERT(NtCurrentTeb()->ClientId.UniqueThread != LoaderLock->OwningThread);
376
377 /*
378 * Terminate process if this is the last thread
379 * of the current process
380 */
383 &LastThread,
384 sizeof(LastThread),
385 NULL);
386 if ((NT_SUCCESS(Status)) && (LastThread)) ExitProcess(uExitCode);
387
388 /* Notify DLLs and TLS Callbacks of termination */
390#if (NTDDI_VERSION < NTDDI_LONGHORN)
391 /* Tell the Kernel to free the Stack */
392 NtCurrentTeb()->FreeStackOnTermination = TRUE;
393#endif
394 NtTerminateThread(NULL, uExitCode);
395
396 /* We should never reach this place */
397 ERROR_FATAL("It should not happen\n");
398 while (TRUE); /* 'noreturn' function */
399}
400
401/*
402 * @implemented
403 */
404HANDLE
405WINAPI
406OpenThread(IN DWORD dwDesiredAccess,
409{
411 HANDLE ThreadHandle;
414
417
419 NULL,
421 NULL,
422 NULL);
423
424 Status = NtOpenThread(&ThreadHandle,
425 dwDesiredAccess,
427 &ClientId);
428 if (!NT_SUCCESS(Status))
429 {
431 return NULL;
432 }
433
434 return ThreadHandle;
435}
436
437/*
438 * @implemented
439 */
440PTEB
442{
443 return NtCurrentTeb();
444}
445
446/*
447 * @implemented
448 */
449BOOL
450WINAPI
452{
454}
455
456
457/*
458 * @implemented
459 */
460DWORD
461WINAPI
463{
465}
466
467/*
468 * @implemented
469 */
470BOOL
471NTAPI
473 OUT LPFILETIME lpCreationTime,
474 OUT LPFILETIME lpExitTime,
475 OUT LPFILETIME lpKernelTime,
476 OUT LPFILETIME lpUserTime)
477{
478 KERNEL_USER_TIMES KernelUserTimes;
480
483 &KernelUserTimes,
484 sizeof(KERNEL_USER_TIMES),
485 NULL);
486 if (!NT_SUCCESS(Status))
487 {
489 return FALSE;
490 }
491
492 *lpCreationTime = *(LPFILETIME)&KernelUserTimes.CreateTime;
493 *lpExitTime = *(LPFILETIME)&KernelUserTimes.ExitTime;
494 *lpKernelTime = *(LPFILETIME)&KernelUserTimes.KernelTime;
495 *lpUserTime = *(LPFILETIME)&KernelUserTimes.UserTime;
496 return TRUE;
497}
498
499/*
500 * @implemented
501 */
502BOOL
503WINAPI
505 OUT LPCONTEXT lpContext)
506{
508
509 Status = NtGetContextThread(hThread, lpContext);
510 if (!NT_SUCCESS(Status))
511 {
513 return FALSE;
514 }
515
516 return TRUE;
517}
518
519/*
520 * @implemented
521 */
522BOOL
523WINAPI
525 IN CONST CONTEXT *lpContext)
526{
528
530 if (!NT_SUCCESS(Status))
531 {
533 return FALSE;
534 }
535
536 return TRUE;
537}
538
539/*
540 * @implemented
541 */
542BOOL
543WINAPI
545 OUT LPDWORD lpExitCode)
546{
547 THREAD_BASIC_INFORMATION ThreadBasic;
549
552 &ThreadBasic,
554 NULL);
555 if (!NT_SUCCESS(Status))
556 {
558 return FALSE;
559 }
560
561 *lpExitCode = ThreadBasic.ExitStatus;
562 return TRUE;
563}
564
565/*
566 * @implemented
567 */
568DWORD
569WINAPI
571{
572 ULONG PreviousResumeCount;
574
575 Status = NtResumeThread(hThread, &PreviousResumeCount);
576 if (!NT_SUCCESS(Status))
577 {
579 return -1;
580 }
581
582 return PreviousResumeCount;
583}
584
585/*
586 * @implemented
587 */
588BOOL
589WINAPI
591 IN DWORD dwExitCode)
592{
594#if DBG
595 PRTL_CRITICAL_SECTION LoaderLock;
597#endif /* DBG */
598
599 /* Check for invalid thread handle */
600 if (!hThread)
601 {
602 /* Fail if one was passed */
604 return FALSE;
605 }
606
607#if DBG
608 /* Get the loader lock */
609 LoaderLock = NtCurrentPeb()->LoaderLock;
610 if (LoaderLock)
611 {
612 /* Get our TID */
615 &ThreadInfo,
616 sizeof(ThreadInfo),
617 NULL);
618 if (NT_SUCCESS(Status))
619 {
620 /* If terminating the current thread, we must not hold the loader lock */
621 if (NtCurrentTeb()->ClientId.UniqueThread == ThreadInfo.ClientId.UniqueThread)
623 }
624 }
625#endif /* DBG */
626
627 /* Now terminate the thread */
628 Status = NtTerminateThread(hThread, dwExitCode);
629 if (!NT_SUCCESS(Status))
630 {
631 /* Fail */
633 return FALSE;
634 }
635
636 /* All done */
637 return TRUE;
638}
639
640/*
641 * @implemented
642 */
643DWORD
644WINAPI
646{
647 ULONG PreviousSuspendCount;
649
650 Status = NtSuspendThread(hThread, &PreviousSuspendCount);
651 if (!NT_SUCCESS(Status))
652 {
654 return -1;
655 }
656
657 return PreviousSuspendCount;
658}
659
660/*
661 * @implemented
662 */
664WINAPI
666 IN DWORD_PTR dwThreadAffinityMask)
667{
668 THREAD_BASIC_INFORMATION ThreadBasic;
669 KAFFINITY AffinityMask;
671
672 AffinityMask = (KAFFINITY)dwThreadAffinityMask;
673
676 &ThreadBasic,
678 NULL);
679 if (!NT_SUCCESS(Status))
680 {
682 return 0;
683 }
684
687 &AffinityMask,
688 sizeof(KAFFINITY));
689 if (!NT_SUCCESS(Status))
690 {
692 ThreadBasic.AffinityMask = 0;
693 }
694
695 return ThreadBasic.AffinityMask;
696}
697
698#define THEONLYGROUP 0 // Fake support for a single group
699
700/*
701 * @implemented
702 */
703BOOL
704WINAPI
707{
709 THREAD_BASIC_INFORMATION ThreadBasic;
710
711 STUB; // FIXME: Real group support
714 &ThreadBasic,
715 sizeof(ThreadBasic),
716 NULL);
717 if (!NT_SUCCESS(Status))
718 {
720 return FALSE;
721 }
722 ZeroMemory(GroupAffinity, sizeof(*GroupAffinity)); // For Reserved
723 GroupAffinity->Mask = ThreadBasic.AffinityMask;
725 return TRUE;
726}
727
728/*
729 * @implemented
730 */
731BOOL
732WINAPI
735 OUT OPTIONAL PGROUP_AFFINITY PreviousGroupAffinity)
736{
737 DWORD_PTR OldMask;
738
739 STUB; // FIXME: Real group support
741 {
743 return FALSE;
744 }
745
747 if (OldMask && PreviousGroupAffinity)
748 {
749 ZeroMemory(PreviousGroupAffinity, sizeof(*PreviousGroupAffinity)); // For Reserved
750 PreviousGroupAffinity->Mask = OldMask;
751 PreviousGroupAffinity->Group = THEONLYGROUP;
752 }
753 return OldMask != 0;
754}
755
756/*
757 * @implemented
758 */
759BOOL
760WINAPI
762 IN int nPriority)
763{
764 LONG Prio = nPriority;
766
767 /* Check if values forcing saturation should be used */
769 {
770 /* This is 16 */
771 Prio = (HIGH_PRIORITY + 1) / 2;
772 }
773 else if (Prio == THREAD_PRIORITY_IDLE)
774 {
775 /* This is -16 */
776 Prio = -((HIGH_PRIORITY + 1) / 2);
777 }
778
779 /* Set the Base Priority */
782 &Prio,
783 sizeof(LONG));
784 if (!NT_SUCCESS(Status))
785 {
786 /* Failure */
788 return FALSE;
789 }
790
791 /* Return */
792 return TRUE;
793}
794
795/*
796 * @implemented
797 */
798int
799WINAPI
801{
802 THREAD_BASIC_INFORMATION ThreadBasic;
804
805 /* Query the Base Priority Increment */
808 &ThreadBasic,
810 NULL);
811 if (!NT_SUCCESS(Status))
812 {
813 /* Failure */
816 }
817
818 /* Do some conversions for saturation values */
819 if (ThreadBasic.BasePriority == ((HIGH_PRIORITY + 1) / 2))
820 {
821 /* Win32 calls this "time critical" */
823 }
824 else if (ThreadBasic.BasePriority == -((HIGH_PRIORITY + 1) / 2))
825 {
826 /* Win32 calls this "idle" */
828 }
829
830 /* Return the final result */
831 return ThreadBasic.BasePriority;
832}
833
834/*
835 * @implemented
836 */
837BOOL
838WINAPI
840 OUT PBOOL pDisablePriorityBoost)
841{
844
848 sizeof(ULONG),
849 NULL);
850 if (!NT_SUCCESS(Status))
851 {
853 return FALSE;
854 }
855
856 *pDisablePriorityBoost = PriorityBoost;
857 return TRUE;
858}
859
860/*
861 * @implemented
862 */
863BOOL
864NTAPI
866 IN BOOL bDisablePriorityBoost)
867{
870
871 PriorityBoost = bDisablePriorityBoost != FALSE;
872
876 sizeof(ULONG));
877 if (!NT_SUCCESS(Status))
878 {
880 return FALSE;
881 }
882
883 return TRUE;
884}
885
886/*
887 * @implemented
888 */
889BOOL
890WINAPI
892 IN DWORD dwSelector,
893 OUT LPLDT_ENTRY lpSelectorEntry)
894{
895#ifdef _M_IX86
896 DESCRIPTOR_TABLE_ENTRY DescriptionTableEntry;
898
899 /* Set the selector and do the query */
900 DescriptionTableEntry.Selector = dwSelector;
903 &DescriptionTableEntry,
904 sizeof(DESCRIPTOR_TABLE_ENTRY),
905 NULL);
906 if (!NT_SUCCESS(Status))
907 {
908 /* Fail */
910 return FALSE;
911 }
912
913 /* Success, return the selector */
914 *lpSelectorEntry = DescriptionTableEntry.Descriptor;
915 return TRUE;
916#else
917 DPRINT1("Calling GetThreadSelectorEntry!\n");
918 return FALSE;
919#endif
920}
921
922/*
923 * @implemented
924 */
925DWORD
926WINAPI
928 IN DWORD dwIdealProcessor)
929{
931
934 &dwIdealProcessor,
935 sizeof(ULONG));
936 if (!NT_SUCCESS(Status))
937 {
939 return -1;
940 }
941
942 return (DWORD)Status;
943}
944
945/*
946 * @implemented
947 */
948DWORD
949WINAPI
951{
952 THREAD_BASIC_INFORMATION ThreadBasic;
954
957 &ThreadBasic,
959 NULL);
960 if (!NT_SUCCESS(Status))
961 {
963 return 0;
964 }
965
966 return HandleToUlong(ThreadBasic.ClientId.UniqueProcess);
967}
968
969/*
970 * @implemented
971 */
972DWORD
973WINAPI
975{
976 THREAD_BASIC_INFORMATION ThreadBasic;
978
981 &ThreadBasic,
983 NULL);
984 if (!NT_SUCCESS(Status))
985 {
987 return 0;
988 }
989
990 return HandleToUlong(ThreadBasic.ClientId.UniqueThread);
991}
992
993/*
994 * @unimplemented
995 */
996LANGID
997WINAPI
999{
1000#if (NTDDI_VERSION < NTDDI_LONGHORN)
1001 /* We only support LangId == 0, for selecting a language
1002 * identifier that best supports the NT Console. */
1003 if (LangId != 0)
1004 {
1006 return 0;
1007 }
1008#endif
1009
1011
1012 return LANGIDFROMLCID(NtCurrentTeb()->CurrentLocale);
1013}
1014
1015/*
1016 * @implemented
1017 */
1018DWORD
1019WINAPI
1023{
1025 ACTIVATION_CONTEXT_BASIC_INFORMATION ActCtxInfo;
1026
1027 /* Zero the activation context and query information on it */
1028 RtlZeroMemory(&ActCtxInfo, sizeof(ActCtxInfo));
1030 NULL,
1031 0,
1032 ActivationContextBasicInformation,
1033 &ActCtxInfo,
1034 sizeof(ActCtxInfo),
1035 NULL);
1036 if (!NT_SUCCESS(Status))
1037 {
1038 /* Fail due to SxS */
1039 DbgPrint("SXS: %s failing because RtlQueryInformationActivationContext()"
1040 "returned status %08lx\n", __FUNCTION__, Status);
1042 return FALSE;
1043 }
1044
1045 /* Queue the APC */
1048 pfnAPC,
1049 (PVOID)dwData,
1050 (ActCtxInfo.dwFlags & 1) ?
1051 INVALID_ACTIVATION_CONTEXT : ActCtxInfo.hActCtx);
1052 if (!NT_SUCCESS(Status))
1053 {
1055 return FALSE;
1056 }
1057
1058 /* All good */
1059 return TRUE;
1060}
1061
1062/*
1063 * @unimplemented
1064 */
1065BOOL
1066WINAPI
1068{
1069 PTEB Teb = NtCurrentTeb();
1070 ULONG GuaranteedStackBytes;
1072
1073 if (!StackSizeInBytes)
1074 {
1076 return FALSE;
1077 }
1078
1079 AllocationSize = *StackSizeInBytes;
1080
1081 /* Retrieve the current stack size */
1082 GuaranteedStackBytes = Teb->GuaranteedStackBytes;
1083
1084 /* Return the size of the previous stack */
1085 *StackSizeInBytes = GuaranteedStackBytes;
1086
1087 /*
1088 * If the new stack size is either zero or is less than the current size,
1089 * the previous stack size is returned and we return success.
1090 */
1091 if ((AllocationSize == 0) || (AllocationSize < GuaranteedStackBytes))
1092 {
1093 return TRUE;
1094 }
1095
1096 // FIXME: Unimplemented!
1098
1099 // Temporary HACK for supporting applications!
1100 return TRUE; // FALSE;
1101}
1102
1103/*
1104 * @implemented
1105 */
1106BOOL
1107WINAPI
1109 OUT PBOOL lpIOIsPending)
1110{
1111 ULONG IoPending;
1113
1114 /* Query the flag */
1117 &IoPending,
1118 sizeof(IoPending),
1119 NULL);
1120 if (NT_SUCCESS(Status))
1121 {
1122 /* Return the flag */
1123 *lpIOIsPending = IoPending ? TRUE : FALSE;
1124 return TRUE;
1125 }
1126
1127 /* Fail */
1129 return FALSE;
1130}
1131
1132/*
1133 * @implemented
1134 */
1135BOOL
1136WINAPI
1139 IN ULONG Flags)
1140{
1142
1143 /* NOTE: Rtl needs to safely call the function using a trampoline */
1145 if (!NT_SUCCESS(Status))
1146 {
1147 /* Failed */
1149 return FALSE;
1150 }
1151
1152 /* All good */
1153 return TRUE;
1154}
1155
1156/*
1157 * @implemented
1158 */
1159DWORD
1160WINAPI
1162{
1163 ULONG Index;
1164 PTEB Teb;
1165 PPEB Peb;
1166
1167 /* Get the PEB and TEB, lock the PEB */
1168 Teb = NtCurrentTeb();
1171
1172 /* Try to get regular TEB slot */
1174 if (Index != 0xFFFFFFFF)
1175 {
1176 /* Clear the value. */
1177 Teb->TlsSlots[Index] = 0;
1179 return Index;
1180 }
1181
1182 /* If it fails, try to find expansion TEB slot. */
1184 if (Index != 0xFFFFFFFF)
1185 {
1186 /* Is there no expansion slot yet? */
1187 if (!Teb->TlsExpansionSlots)
1188 {
1189 /* Allocate an array */
1190 Teb->TlsExpansionSlots = RtlAllocateHeap(RtlGetProcessHeap(),
1193 sizeof(PVOID));
1194 }
1195
1196 /* Did we get an array? */
1197 if (!Teb->TlsExpansionSlots)
1198 {
1199 /* Fail */
1201 Index = 0xFFFFFFFF;
1203 }
1204 else
1205 {
1206 /* Clear the value. */
1207 Teb->TlsExpansionSlots[Index] = 0;
1209 }
1210 }
1211 else
1212 {
1213 /* Fail */
1215 }
1216
1217 /* Release the lock and return */
1219 return Index;
1220}
1221
1222/*
1223 * @implemented
1224 */
1225BOOL
1226WINAPI
1228{
1229 BOOL BitSet;
1230 PPEB Peb;
1232 PVOID TlsBitmap;
1234
1235 /* Acquire the PEB lock and grab the PEB */
1236 Peb = NtCurrentPeb();
1238
1239 /* Check if the index is too high */
1241 {
1242 /* Check if it can fit in the expansion slots */
1245 {
1246 /* It's invalid */
1249 return FALSE;
1250 }
1251 else
1252 {
1253 /* Use the expansion bitmap */
1254 TlsBitmap = Peb->TlsExpansionBitmap;
1255 Index = TlsIndex;
1256 }
1257 }
1258 else
1259 {
1260 /* Use the normal bitmap */
1261 TlsBitmap = Peb->TlsBitmap;
1262 }
1263
1264 /* Check if the index was set */
1265 BitSet = RtlAreBitsSet(TlsBitmap, Index, 1);
1266 if (BitSet)
1267 {
1268 /* Tell the kernel to free the TLS cells */
1271 &Index,
1272 sizeof(DWORD));
1273 if (!NT_SUCCESS(Status))
1274 {
1277 return FALSE;
1278 }
1279
1280 /* Clear the bit */
1281 RtlClearBits(TlsBitmap, Index, 1);
1282 }
1283 else
1284 {
1285 /* Fail */
1288 return FALSE;
1289 }
1290
1291 /* Done! */
1293 return TRUE;
1294}
1295
1296/*
1297 * @implemented
1298 */
1299LPVOID
1300WINAPI
1302{
1303 PTEB Teb;
1304
1305 /* Get the TEB and clear the last error */
1306 Teb = NtCurrentTeb();
1307 Teb->LastErrorValue = 0;
1308
1309 /* Check for simple TLS index */
1311 {
1312 /* Return it */
1313 return Teb->TlsSlots[Index];
1314 }
1315
1316 /* Check for valid index */
1318 {
1319 /* Fail */
1321 return NULL;
1322 }
1323
1324 /* The expansion slots are allocated on demand, so check for it. */
1325 Teb->LastErrorValue = 0;
1326 if (!Teb->TlsExpansionSlots) return NULL;
1327
1328 /* Return the value from the expansion slots */
1330}
1331
1332/*
1333 * @implemented
1334 */
1335BOOL
1336WINAPI
1338 IN LPVOID Value)
1339{
1341 PTEB Teb = NtCurrentTeb();
1342
1343 /* Check for simple TLS index */
1345 {
1346 /* Return it */
1347 Teb->TlsSlots[Index] = Value;
1348 return TRUE;
1349 }
1350
1351 /* Check if this is an expansion slot */
1354 {
1355 /* Fail */
1357 return FALSE;
1358 }
1359
1360 /* Do we not have expansion slots? */
1361 if (!Teb->TlsExpansionSlots)
1362 {
1363 /* Get the PEB lock to see if we still need them */
1365 if (!Teb->TlsExpansionSlots)
1366 {
1367 /* Allocate them */
1368 Teb->TlsExpansionSlots = RtlAllocateHeap(RtlGetProcessHeap(),
1371 sizeof(PVOID));
1372 if (!Teb->TlsExpansionSlots)
1373 {
1374 /* Fail */
1377 return FALSE;
1378 }
1379 }
1380
1381 /* Release the lock */
1383 }
1384
1385 /* Write the value */
1387
1388 /* Success */
1389 return TRUE;
1390}
1391
1392/* EOF */
#define NtCurrentPeb()
Definition: FLS.c:22
_In_ PVOID _In_ ULONG _Out_ PVOID _In_ ULONG _Inout_ PULONG ReturnLength
#define DECLSPEC_HOTPATCH
Definition: _mingw.h:240
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
@ BasepCreateThread
Definition: basemsg.h:22
#define BASESRV_SERVERDLL_INDEX
Definition: basemsg.h:15
#define HandleToUlong(h)
Definition: basetsd.h:73
#define ULongToHandle(h)
Definition: basetsd.h:75
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:616
_In_ CDROM_SCAN_FOR_SPECIAL_INFO _In_ PCDROM_SCAN_FOR_SPECIAL_HANDLER Function
Definition: cdrom.h:1156
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
NTSTATUS NTAPI CsrCreateRemoteThread(IN HANDLE hThread, IN PCLIENT_ID ClientId)
Definition: thredsup.c:569
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
#define RtlAreBitsSet
Definition: dbgbitmap.h:328
#define RtlClearBits
Definition: dbgbitmap.h:331
#define RtlFindClearBitsAndSet
Definition: dbgbitmap.h:333
_In_ ULONG AllocationSize
Definition: dispmprt.h:712
_In_ D3DDDI_VIDEO_PRESENT_TARGET_ID _In_ ULONG _In_ ULONG Flags
Definition: dispmprt.h:245
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define NTSTATUS
Definition: precomp.h:19
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
ULONG_PTR KAFFINITY
Definition: compat.h:85
#define SetLastError(x)
Definition: compat.h:752
#define GetProcAddress(x, y)
Definition: compat.h:753
@ ThreadDescriptorTableEntry
Definition: compat.h:941
@ ThreadAmILastThread
Definition: compat.h:947
@ ThreadTimes
Definition: compat.h:936
@ ThreadIdealProcessor
Definition: compat.h:948
@ ThreadAffinityMask
Definition: compat.h:939
@ ThreadBasePriority
Definition: compat.h:938
@ ThreadBasicInformation
Definition: compat.h:935
@ ThreadPriorityBoost
Definition: compat.h:949
@ ThreadIsIoPending
Definition: compat.h:951
@ ThreadZeroTlsCell
Definition: compat.h:945
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
PPEB Peb
Definition: dllmain.c:27
BOOLEAN BaseRunningInServerProcess
Definition: dllmain.c:20
LONG WINAPI UnhandledExceptionFilter(IN PEXCEPTION_POINTERS ExceptionInfo)
Definition: except.c:269
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1382
DWORD WINAPI QueueUserAPC(IN PAPCFUNC pfnAPC, IN HANDLE hThread, IN ULONG_PTR dwData)
Definition: thread.c:1020
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1301
DWORD WINAPI ResumeThread(IN HANDLE hThread)
Definition: thread.c:570
BOOL WINAPI SetThreadPriority(IN HANDLE hThread, IN int nPriority)
Definition: thread.c:761
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:161
VOID NTAPI BaseDispatchApc(IN PAPCFUNC ApcRoutine, IN PVOID Data, IN PACTIVATION_CONTEXT ActivationContext)
Definition: thread.c:94
BOOL WINAPI SetThreadGroupAffinity(IN HANDLE hThread, IN const GROUP_AFFINITY *GroupAffinity, OUT OPTIONAL PGROUP_AFFINITY PreviousGroupAffinity)
Definition: thread.c:733
DWORD_PTR WINAPI SetThreadAffinityMask(IN HANDLE hThread, IN DWORD_PTR dwThreadAffinityMask)
Definition: thread.c:665
DECLSPEC_NORETURN VOID WINAPI BaseThreadStartup(_In_ LPTHREAD_START_ROUTINE lpStartAddress, _In_ LPVOID lpParameter)
Definition: thread.c:58
BOOL WINAPI SetThreadContext(IN HANDLE hThread, IN CONST CONTEXT *lpContext)
Definition: thread.c:524
DWORD WINAPI SuspendThread(IN HANDLE hThread)
Definition: thread.c:645
BOOL NTAPI GetThreadTimes(IN HANDLE hThread, OUT LPFILETIME lpCreationTime, OUT LPFILETIME lpExitTime, OUT LPFILETIME lpKernelTime, OUT LPFILETIME lpUserTime)
Definition: thread.c:472
LANGID WINAPI SetThreadUILanguage(IN LANGID LangId)
Definition: thread.c:998
VOID WINAPI ExitThread(IN DWORD uExitCode)
Definition: thread.c:367
HANDLE WINAPI OpenThread(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwThreadId)
Definition: thread.c:406
BOOL WINAPI QueueUserWorkItem(IN LPTHREAD_START_ROUTINE Function, IN PVOID Context, IN ULONG Flags)
Definition: thread.c:1137
DWORD WINAPI GetProcessIdOfThread(IN HANDLE Thread)
Definition: thread.c:950
BOOL WINAPI TlsSetValue(IN DWORD Index, IN LPVOID Value)
Definition: thread.c:1337
BOOL WINAPI GetThreadSelectorEntry(IN HANDLE hThread, IN DWORD dwSelector, OUT LPLDT_ENTRY lpSelectorEntry)
Definition: thread.c:891
DWORD WINAPI SetThreadIdealProcessor(IN HANDLE hThread, IN DWORD dwIdealProcessor)
Definition: thread.c:927
PTEB GetTeb(VOID)
Definition: thread.c:441
NTSTATUS(NTAPI * PCSR_CREATE_REMOTE_THREAD)(IN HANDLE ThreadHandle, IN PCLIENT_ID ClientId)
Definition: thread.c:19
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:139
BOOL WINAPI TerminateThread(IN HANDLE hThread, IN DWORD dwExitCode)
Definition: thread.c:590
NTSTATUS WINAPI BasepNotifyCsrOfThread(IN HANDLE ThreadHandle, IN PCLIENT_ID ClientId)
Definition: thread.c:27
BOOL WINAPI TlsFree(IN DWORD Index)
Definition: thread.c:1227
BOOL WINAPI SetThreadStackGuarantee(IN OUT PULONG StackSizeInBytes)
Definition: thread.c:1067
DWORD WINAPI GetThreadId(IN HANDLE Thread)
Definition: thread.c:974
BOOL WINAPI GetThreadPriorityBoost(IN HANDLE hThread, OUT PBOOL pDisablePriorityBoost)
Definition: thread.c:839
#define THREAD_ALL_ACCESS_NT6
Definition: thread.c:21
BOOL NTAPI SetThreadPriorityBoost(IN HANDLE hThread, IN BOOL bDisablePriorityBoost)
Definition: thread.c:865
int WINAPI GetThreadPriority(IN HANDLE hThread)
Definition: thread.c:800
BOOL WINAPI GetThreadGroupAffinity(IN HANDLE hThread, OUT PGROUP_AFFINITY GroupAffinity)
Definition: thread.c:705
BOOL WINAPI GetThreadIOPendingFlag(IN HANDLE hThread, OUT PBOOL lpIOIsPending)
Definition: thread.c:1108
BOOL WINAPI GetExitCodeThread(IN HANDLE hThread, OUT LPDWORD lpExitCode)
Definition: thread.c:544
#define THEONLYGROUP
Definition: thread.c:698
BOOL WINAPI GetThreadContext(IN HANDLE hThread, OUT LPCONTEXT lpContext)
Definition: thread.c:504
NTSTATUS WINAPI BaseCreateStack(_In_ HANDLE hProcess, _In_opt_ SIZE_T StackCommit, _In_opt_ SIZE_T StackReserve, _Out_ PINITIAL_TEB InitialTeb)
Definition: utils.c:381
VOID WINAPI BaseInitializeContext(IN PCONTEXT Context, IN PVOID Parameter, IN PVOID StartAddress, IN PVOID StackAddress, IN ULONG ContextType)
Definition: utils.c:540
POBJECT_ATTRIBUTES WINAPI BaseFormatObjectAttributes(OUT POBJECT_ATTRIBUTES ObjectAttributes, IN PSECURITY_ATTRIBUTES SecurityAttributes OPTIONAL, IN PUNICODE_STRING ObjectName)
Definition: utils.c:331
VOID WINAPI BaseFreeThreadStack(_In_ HANDLE hProcess, _In_ PINITIAL_TEB InitialTeb)
Definition: utils.c:522
DWORD WINAPI DECLSPEC_HOTPATCH TlsAlloc(void)
Definition: thread.c:657
BOOL WINAPI DECLSPEC_HOTPATCH SwitchToThread(void)
Definition: thread.c:639
#define DECLSPEC_NORETURN
Definition: corecrt.h:131
#define __FUNCTION__
Definition: types.h:116
DWORD dwThreadId
Definition: fdebug.c:31
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
Status
Definition: gdiplustypes.h:24
#define DbgPrint
Definition: hal.h:12
#define TLS_EXPANSION_SLOTS
Definition: pstypes.h:336
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
#define HIGH_PRIORITY
#define NtCurrentTeb
#define STUB
Definition: kernel32.h:27
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE _In_ PVOID Context
Definition: kse.h:81
USHORT LANGID
Definition: mui.h:9
struct _FILETIME * LPFILETIME
Definition: time.c:29
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:71
#define ZeroMemory
Definition: minwinbase.h:31
PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE
Definition: minwinbase.h:124
BOOL * PBOOL
Definition: minwindef.h:137
struct _ThreadInfo ThreadInfo
#define ASSERT(a)
Definition: mode.c:44
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:115
_In_opt_ HANDLE _In_opt_ PIO_APC_ROUTINE ApcRoutine
Definition: iofuncs.h:726
VOID(NTAPI * PKNORMAL_ROUTINE)(IN PVOID NormalContext OPTIONAL, IN PVOID SystemArgument1 OPTIONAL, IN PVOID SystemArgument2 OPTIONAL)
Definition: ketypes.h:888
NTSYSAPI NTSTATUS NTAPI RtlQueueWorkItem(_In_ WORKERCALLBACKFUNC Function, _In_opt_ PVOID Context, _In_ ULONG Flags)
#define RTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_FORMAT_WHISTLER
Definition: rtltypes.h:109
#define RTL_ACTIVATE_ACTIVATION_CONTEXT_EX_FLAG_RELEASE_ON_STACK_DEALLOCATION
Definition: rtltypes.h:114
#define RTL_QUERY_ACTIVATION_CONTEXT_FLAG_USE_ACTIVE_ACTIVATION_CONTEXT
Definition: rtltypes.h:124
VOID(NTAPI * WORKERCALLBACKFUNC)(_In_ PVOID Context)
Definition: rtltypes.h:518
HANDLE hThread
Definition: wizard.c:28
#define _In_
Definition: no_sal2.h:158
NTSTATUS NtTerminateThread(IN HANDLE ThreadHandle OPTIONAL, IN NTSTATUS ExitStatus)
Definition: kill.c:1315
#define NtCurrentProcess()
Definition: nt_native.h:1660
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3434
NTSYSAPI NTSTATUS NTAPI NtCreateThread(OUT PHANDLE phThread, IN ACCESS_MASK AccessMask, IN POBJECT_ATTRIBUTES ObjectAttributes, IN HANDLE hProcess, OUT PCLIENT_ID pClientId, IN PCONTEXT pContext, OUT PSTACKINFO pStackInfo, IN BOOLEAN bSuspended)
static HANDLE ULONG_PTR dwData
Definition: pipe.c:111
static BOOL bInheritHandle
Definition: pipe.c:110
NTSTATUS NTAPI NtSetContextThread(IN HANDLE ThreadHandle, IN PCONTEXT ThreadContext)
Definition: debug.c:387
NTSTATUS NTAPI NtGetContextThread(IN HANDLE ThreadHandle, IN OUT PCONTEXT ThreadContext)
Definition: debug.c:350
NTSTATUS NTAPI NtQueryInformationThread(_In_ HANDLE ThreadHandle, _In_ THREADINFOCLASS ThreadInformationClass, _Out_writes_bytes_to_opt_(ThreadInformationLength, *ReturnLength) PVOID ThreadInformation, _In_ ULONG ThreadInformationLength, _Out_opt_ PULONG ReturnLength)
Definition: query.c:3017
NTSTATUS NTAPI NtSetInformationThread(_In_ HANDLE ThreadHandle, _In_ THREADINFOCLASS ThreadInformationClass, _In_reads_bytes_(ThreadInformationLength) PVOID ThreadInformation, _In_ ULONG ThreadInformationLength)
Definition: query.c:2301
NTSTATUS NTAPI NtQueueApcThread(IN HANDLE ThreadHandle, IN PKNORMAL_ROUTINE ApcRoutine, IN PVOID NormalContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: state.c:600
NTSTATUS NTAPI NtResumeThread(IN HANDLE ThreadHandle, OUT PULONG SuspendCount OPTIONAL)
Definition: state.c:290
NTSTATUS NTAPI NtSuspendThread(IN HANDLE ThreadHandle, OUT PULONG PreviousSuspendCount OPTIONAL)
Definition: state.c:352
NTSTATUS NTAPI NtOpenThread(OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN PCLIENT_ID ClientId OPTIONAL)
Definition: thread.c:1037
#define STATUS_NO_YIELD_PERFORMED
Definition: ntstatus.h:225
#define CONST
Definition: pedump.c:81
long LONG
Definition: pedump.c:60
PETHREAD LastThread
Definition: pinsup.c:109
#define OBJ_INHERIT
Definition: winternl.h:225
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:204
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:104
#define _SEH2_GetExceptionInformation()
Definition: pseh2_64.h:203
#define _SEH2_END
Definition: pseh2_64.h:194
#define _SEH2_TRY
Definition: pseh2_64.h:93
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:167
#define LANGIDFROMLCID(l)
Definition: nls.h:18
#define ERROR_FATAL(...)
Definition: debug.h:238
NTSTATUS NTAPI CsrNewThread(VOID)
Definition: api.c:26
NTSTATUS NTAPI CsrClientCallServer(_Inout_ PCSR_API_MESSAGE ApiMessage, _Inout_opt_ PCSR_CAPTURE_BUFFER CaptureBuffer, _In_ CSR_API_NUMBER ApiNumber, _In_ ULONG DataLength)
Definition: connect.c:368
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
#define TLS_MINIMUM_AVAILABLE
Definition: ntddk_ex.h:236
NTSTATUS Status
Definition: basemsg.h:279
BASE_CREATE_THREAD CreateThreadRequest
Definition: basemsg.h:284
union _BASE_API_MESSAGE::@4362 Data
HANDLE ThreadHandle
Definition: basemsg.h:104
CLIENT_ID ClientId
Definition: basemsg.h:105
HANDLE UniqueThread
Definition: compat.h:826
HANDLE UniqueProcess
Definition: compat.h:825
$USHORT Group
Definition: ntbasedef.h:673
KAFFINITY Mask
Definition: ntbasedef.h:672
PVOID StackBase
Definition: pstypes.h:757
LARGE_INTEGER UserTime
Definition: winternl.h:2377
LARGE_INTEGER CreateTime
Definition: winternl.h:2374
LARGE_INTEGER KernelTime
Definition: winternl.h:2376
LARGE_INTEGER ExitTime
Definition: winternl.h:2375
Definition: compat.h:777
PVOID TlsBitmap
Definition: ntddk_ex.h:259
PRTL_BITMAP TlsExpansionBitmap
Definition: winternl.h:538
Definition: compat.h:836
PVOID ActivationContextStackPointer
Definition: compat.h:854
PVOID SubProcessTag
Definition: winternl.h:662
PVOID * TlsExpansionSlots
Definition: compat.h:894
ULONG GuaranteedStackBytes
Definition: winternl.h:668
PVOID TlsSlots[64]
Definition: compat.h:879
PPEB ProcessEnvironmentBlock
Definition: ntddk_ex.h:337
ULONG LastErrorValue
Definition: compat.h:843
KPRIORITY BasePriority
Definition: compat.h:932
KAFFINITY AffinityMask
Definition: compat.h:930
uint32_t * PULONG
Definition: typedefs.h:59
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define UNIMPLEMENTED_ONCE
Definition: typedefs.h:30
#define NTAPI
Definition: typedefs.h:36
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t * LPDWORD
Definition: typedefs.h:59
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
_In_ WDFREQUEST _In_ NTSTATUS _In_ CCHAR PriorityBoost
Definition: wdfrequest.h:1016
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:462
#define STACK_SIZE_PARAM_IS_A_RESERVATION
Definition: winbase.h:225
#define CREATE_SUSPENDED
Definition: winbase.h:183
#define THREAD_PRIORITY_TIME_CRITICAL
Definition: winbase.h:306
#define THREAD_PRIORITY_ERROR_RETURN
Definition: winbase.h:307
#define THREAD_PRIORITY_IDLE
Definition: winbase.h:303
#define WINAPI
Definition: msvc.h:6
NTSYSAPI void WINAPI RtlReleasePebLock(void)
Definition: libsupp.c:95
NTSYSAPI void WINAPI RtlAcquirePebLock(void)
Definition: libsupp.c:85
NTSYSAPI NTSTATUS WINAPI NtYieldExecution(void)
Definition: thrdschd.c:887
NTSYSAPI NTSTATUS WINAPI RtlActivateActivationContextEx(ULONG, TEB *, HANDLE, ULONG_PTR *)
Definition: actctx.c:5697
NTSYSAPI void WINAPI RtlReleaseActivationContext(HANDLE)
Definition: actctx.c:5664
#define NtCurrentThread()
Definition: winternl.h:5372
NTSYSAPI void WINAPI LdrShutdownThread(void)
Definition: ldrinit.c:1095
NTSYSAPI NTSTATUS WINAPI RtlQueryInformationActivationContext(ULONG, HANDLE, PVOID, ULONG, PVOID, SIZE_T, SIZE_T *)
Definition: actctx.c:5833
NTSYSAPI void WINAPI RtlFreeActivationContextStack(ACTIVATION_CONTEXT_STACK *)
Definition: actctx.c:5774
#define TlsIndex
Definition: ws2_32p.h:277
_In_opt_ PVOID _Out_ PLARGE_INTEGER Cookie
Definition: cmfuncs.h:14
_Out_ PGROUP_AFFINITY GroupAffinity
Definition: iofuncs.h:2506
_Out_ PCLIENT_ID ClientId
Definition: kefuncs.h:1151