Store the winsock per-thread data in NtCurrentTeb()->WinSockData
[wine] / include / thread.h
1 /*
2  * Thread definitions
3  *
4  * Copyright 1996 Alexandre Julliard
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #ifndef __WINE_THREAD_H
22 #define __WINE_THREAD_H
23
24 #include <stdarg.h>
25 #include <windef.h>
26 #include <winbase.h>
27 #include <winreg.h>
28 #define WINE_NO_TEB
29 #include <winternl.h>
30 #include <wine/windef16.h>
31
32 struct _SECURITY_ATTRIBUTES;
33 struct tagSYSLEVEL;
34 struct server_buffer_info;
35 struct fiber_data;
36
37 struct debug_info
38 {
39     char *str_pos;       /* current position in strings buffer */
40     char *out_pos;       /* current position in output buffer */
41     char  strings[1024]; /* buffer for temporary strings */
42     char  output[1024];  /* current output line */
43 };
44
45 /* Thread exception block
46
47   flags in the comment:
48   1-- win95 field
49   d-- win95 debug version
50   -2- nt field
51   --3 wine special
52   --n wine unused
53   !-- or -!- likely or observed  collision
54   more problems (collected from mailing list):
55   psapi.dll 0x10/0x30 (expects nt fields)
56   ie4       0x40
57   PESHiELD  0x23/0x30 (win95)
58 */
59 #ifndef WINE_TEB_DEFINED
60 #define WINE_TEB_DEFINED
61 typedef struct _TEB
62 {
63     NT_TIB       Tib;            /* 12-  00 Thread information block */
64     PVOID        EnvironmentPointer; /* 12-  1c EnvironmentPointer (win95: tib flags + win16 mutex count) */
65     CLIENT_ID    ClientId;       /* -2-  20 Process and thread id (win95: debug context) */
66     PVOID        ActiveRpcHandle;              /* 028 */
67     PVOID        ThreadLocalStoragePointer;    /* 02c Pointer to TLS array */
68     PEB         *Peb;                          /* 030 owning process PEB */
69     DWORD        LastErrorValue;               /* 034 Last error code */
70     ULONG        CountOfOwnedCriticalSections; /* 038 */
71     PVOID        CsrClientThread;              /* 03c */
72     PVOID        Win32ThreadInfo;              /* 040 */
73     ULONG        Win32ClientInfo[0x1f];        /* 044 */
74     PVOID        WOW32Reserved;                /* 0c0 */
75     ULONG        CurrentLocale;  /* -2-  C4 */
76     DWORD        pad5[48];       /* --n  C8 */
77     DWORD        delta_priority; /* 1-n 188 Priority delta */
78     DWORD        unknown4[7];    /* d-n 18c Unknown */
79     void        *create_data;    /* d-n 1a8 Pointer to creation structure */
80     DWORD        suspend_count;  /* d-n 1ac SuspendThread() counter */
81     DWORD        unknown5[6];    /* --n 1b0 Unknown */
82     DWORD        sys_count[4];   /* --3 1c8 Syslevel mutex entry counters */
83     struct tagSYSLEVEL *sys_mutex[4];   /* --3 1d8 Syslevel mutex pointers */
84     DWORD        unknown6[5];    /* --n 1e8 Unknown */
85
86     /* The following are Wine-specific fields (NT: GDI stuff) */
87     UINT         code_page;      /* --3 1fc Thread code page */
88     DWORD        cur_stack;      /* --3 200 Current stack */
89     DWORD        teb_sel;        /* --3 204 Selector to TEB */
90     DWORD        gs_sel;         /* --3 208 %gs selector for this thread */
91     int          request_fd;     /* --3 20c fd for sending server requests */
92     int          reply_fd;       /* --3 210 fd for receiving server replies */
93     int          wait_fd[2];     /* --3 214 fd for sleeping server requests */
94     struct debug_info *debug_info;        /* --3 21c Info for debugstr functions */
95     void        *pthread_data;   /* --3 220 Data for pthread emulation */
96     DWORD        num_async_io;   /* --3 224 number of pending async I/O in the server */
97     void        *driver_data;    /* --3 228 Graphics driver private data */
98     DWORD        dpmi_vif;       /* --3 22c Protected mode virtual interrupt flag */
99     DWORD        vm86_pending;   /* --3 230 Data for vm86 mode */
100     void        *vm86_ptr;       /* --3 234 Data for vm86 mode */
101     WORD         stack_sel;      /* --3 238 16-bit stack selector */
102     HTASK16      htask16;        /* --3 23a Win16 task handle */
103     /* here is plenty space for wine specific fields (don't forget to change pad6!!) */
104
105     /* the following are nt specific fields */
106     DWORD        pad6[622];                  /* --n 23c */
107     ULONG        LastStatusValue;            /* -2- bf4 */
108     UNICODE_STRING StaticUnicodeString;      /* -2- bf8 used by advapi32 */
109     WCHAR        StaticUnicodeBuffer[261];   /* -2- c00 used by advapi32 */
110     PVOID        DeallocationStack;          /* -2- e0c Base of the stack */
111     LPVOID       TlsSlots[64];               /* -2- e10 Thread local storage */
112     LIST_ENTRY   TlsLinks;                   /* -2- f10 */
113     PVOID        Vdm;                        /* f18 */
114     PVOID        ReservedForNtRpc;           /* f1c */
115     PVOID        DbgSsReserved[2];           /* f20 */
116     ULONG        HardErrorDisabled;          /* f28 */
117     PVOID        Instrumentation[16];        /* f2c */
118     PVOID        WinSockData;                /* f6c */
119     ULONG        GdiBatchCount;              /* f70 */
120     ULONG        Spare2;                     /* f74 */
121     ULONG        Spare3;                     /* f78 */
122     ULONG        Spare4;                     /* f7c */
123     PVOID        ReservedForOle;             /* f80 */
124     ULONG        WaitingOnLoaderLock;        /* f84 */
125     PVOID        Reserved5[3];               /* f88 */
126     PVOID       *TlsExpansionSlots;          /* f94 */
127 } TEB;
128 #endif /* WINE_TEB_DEFINED */
129
130
131 /* The thread information for 16-bit threads */
132 /* NtCurrentTeb()->SubSystemTib points to this */
133 typedef struct
134 {
135     void           *unknown;    /* 00 unknown */
136     UNICODE_STRING *exe_name;   /* 04 exe module name */
137
138     /* the following fields do not exist under Windows */
139     UNICODE_STRING  exe_str;    /* exe name string pointed to by exe_name */
140     CURDIR          curdir;     /* current directory */
141     WCHAR           curdir_buffer[MAX_PATH];
142 } WIN16_SUBSYSTEM_TIB;
143
144 /* scheduler/thread.c */
145 extern TEB *THREAD_InitStack( TEB *teb, DWORD stack_size );
146
147 #endif  /* __WINE_THREAD_H */