22 #include <winpr/assert.h>
23 #include <winpr/config.h>
25 #include <winpr/crt.h>
26 #include <winpr/library.h>
27 #include <winpr/wlog.h>
29 #include <winpr/endian.h>
32 #define TAG WINPR_TAG("nt")
37 #include <winpr/crt.h>
39 #include "../handle/handle.h"
41 static pthread_once_t sTebOnceControl = PTHREAD_ONCE_INIT;
42 static pthread_key_t sTebKey;
44 static void sTebDestruct(
void* teb)
49 static void sTebInitOnce(
void)
51 pthread_key_create(&sTebKey, sTebDestruct);
54 PTEB NtCurrentTeb(
void)
58 if (pthread_once(&sTebOnceControl, sTebInitOnce) == 0)
60 if ((teb = pthread_getspecific(sTebKey)) == NULL)
62 teb = calloc(1,
sizeof(TEB));
64 pthread_setspecific(sTebKey, teb);