blob: 210a96c1d5a442152137c14594695dd1402ea168 [file] [log] [blame]
Alexandre Julliard9ea19e51997-01-01 17:29:55 +00001/*
2 * Thread definitions
3 *
4 * Copyright 1996 Alexandre Julliard
Alexandre Julliard0799c1a2002-03-09 23:29:33 +00005 *
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
Alexandre Julliard9ea19e51997-01-01 17:29:55 +000019 */
20
21#ifndef __WINE_THREAD_H
22#define __WINE_THREAD_H
23
Alexandre Julliarde37c6e12003-09-05 23:08:26 +000024#include <stdarg.h>
25#include <windef.h>
26#include <winbase.h>
27#include <winreg.h>
Alexandre Julliard7df1b9e2003-08-28 19:57:35 +000028#define WINE_NO_TEB
Dimitrie O. Paun53f9c212003-08-28 21:43:34 +000029#include <winternl.h>
30#include <wine/windef16.h>
Alexandre Julliard9ea19e51997-01-01 17:29:55 +000031
Patrik Stridvall6cc47d42000-03-08 18:26:56 +000032struct _SECURITY_ATTRIBUTES;
33struct tagSYSLEVEL;
Alexandre Julliard86113532000-08-29 03:54:30 +000034struct server_buffer_info;
Alexandre Julliard9e8e5ff2002-12-17 21:06:25 +000035struct fiber_data;
Alexandre Julliarda11d7b11998-03-01 20:05:02 +000036
Alexandre Julliardaee989a2003-08-21 21:34:33 +000037struct 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
Juergen Schmied74341022000-01-15 22:22:27 +000045/* 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*/
Alexandre Julliard7df1b9e2003-08-28 19:57:35 +000059#ifndef WINE_TEB_DEFINED
60#define WINE_TEB_DEFINED
Alexandre Julliard9ea19e51997-01-01 17:29:55 +000061typedef struct _TEB
62{
Alexandre Julliardb91e9cb2003-08-28 03:44:41 +000063 NT_TIB Tib; /* 12- 00 Thread information block */
Alexandre Julliarda45931c2004-04-15 05:04:53 +000064 PVOID EnvironmentPointer; /* 12- 1c EnvironmentPointer (win95: tib flags + win16 mutex count) */
Alexandre Julliard02f28132003-08-27 23:14:29 +000065 CLIENT_ID ClientId; /* -2- 20 Process and thread id (win95: debug context) */
Juergen Schmied74341022000-01-15 22:22:27 +000066 HQUEUE16 queue; /* 1!- 28 Message queue (NT: DWORD ActiveRpcHandle)*/
67 WORD pad1; /* --n 2a */
Alexandre Julliard02f28132003-08-27 23:14:29 +000068 PVOID ThreadLocalStoragePointer; /* 1-- 2c Pointer to TLS array */
Alexandre Julliard6bc50912003-05-22 03:44:01 +000069 PEB *Peb; /* 12- 30 owning process PEB */
Alexandre Julliard9e73f552003-11-25 01:53:23 +000070 DWORD LastErrorValue; /* -2- 34 Last error code */
Juergen Schmied74341022000-01-15 22:22:27 +000071 DWORD exit_code; /* 1-- 38 Termination status */
72 WORD teb_sel; /* 1-- 3c Selector to TEB */
73 WORD emu_sel; /* 1-n 3e 80387 emulator selector */
74 DWORD unknown1; /* --n 40 */
75 DWORD unknown2; /* --n 44 */
Alexandre Julliardaee989a2003-08-21 21:34:33 +000076 DWORD unknown3; /* --n 48 */
Juergen Schmied74341022000-01-15 22:22:27 +000077 int thread_errno; /* --3 4c Per-thread errno (was: ring0_thread) */
78 int thread_h_errno; /* --3 50 Per-thread h_errno (was: ptr to tdbx structure) */
Alexandre Julliard8824c38e2003-10-22 03:26:53 +000079 void *stack_base; /* 1-n 54 Stack base (unused) */
Alexandre Julliard9e8e5ff2002-12-17 21:06:25 +000080 void *exit_stack; /* 1-n 58 Exit stack */
Juergen Schmied74341022000-01-15 22:22:27 +000081 void *emu_data; /* --n 5c Related to 80387 emulation */
82 DWORD last_error; /* 1-- 60 Last error code */
Ulrich Weigand7d43bce2000-01-30 21:16:45 +000083 HANDLE debug_cb; /* 1-n 64 Debugger context block */
Juergen Schmied74341022000-01-15 22:22:27 +000084 DWORD debug_thread; /* 1-n 68 Thread debugging this one (?) */
85 void *pcontext; /* 1-n 6c Thread register context */
86 DWORD cur_stack; /* --3 70 Current stack (was: unknown) */
87 DWORD ThunkConnect; /* 1-n 74 */
88 DWORD NegStackBase; /* 1-n 78 */
89 WORD current_ss; /* 1-n 7c Another 16-bit stack selector */
90 WORD pad2; /* --n 7e */
91 void *ss_table; /* --n 80 Pointer to info about 16-bit stack */
Alexandre Julliardb91e9cb2003-08-28 03:44:41 +000092 WORD stack_sel; /* --3 84 16-bit stack selector */
93 HTASK16 htask16; /* --3 86 Win16 task handle */
Juergen Schmied74341022000-01-15 22:22:27 +000094 DWORD pad4[15]; /* --n 88 */
Juergen Schmied79d850f2000-06-12 21:56:02 +000095 ULONG CurrentLocale; /* -2- C4 */
Juergen Schmied74341022000-01-15 22:22:27 +000096 DWORD pad5[48]; /* --n C8 */
97 DWORD delta_priority; /* 1-n 188 Priority delta */
98 DWORD unknown4[7]; /* d-n 18c Unknown */
99 void *create_data; /* d-n 1a8 Pointer to creation structure */
100 DWORD suspend_count; /* d-n 1ac SuspendThread() counter */
Alexandre Julliard6281d822003-11-25 03:42:05 +0000101 DWORD unknown5[6]; /* --n 1b0 Unknown */
Juergen Schmied74341022000-01-15 22:22:27 +0000102 DWORD sys_count[4]; /* --3 1c8 Syslevel mutex entry counters */
Patrik Stridvall6cc47d42000-03-08 18:26:56 +0000103 struct tagSYSLEVEL *sys_mutex[4]; /* --3 1d8 Syslevel mutex pointers */
Juergen Schmied74341022000-01-15 22:22:27 +0000104 DWORD unknown6[5]; /* --n 1e8 Unknown */
105
106 /* The following are Wine-specific fields (NT: GDI stuff) */
Alexandre Julliard66e31832002-08-15 23:18:47 +0000107 UINT code_page; /* --3 1fc Thread code page */
Alexandre Julliard551797b2003-02-27 21:11:13 +0000108 DWORD unused[2]; /* --3 200 Was server buffer */
109 DWORD gs_sel; /* --3 208 %gs selector for this thread */
Alexandre Julliard8859d772001-03-01 22:13:49 +0000110 int request_fd; /* --3 20c fd for sending server requests */
111 int reply_fd; /* --3 210 fd for receiving server replies */
Alexandre Julliarde5dedb12001-03-08 01:16:41 +0000112 int wait_fd[2]; /* --3 214 fd for sleeping server requests */
Alexandre Julliardaee989a2003-08-21 21:34:33 +0000113 struct debug_info *debug_info; /* --3 21c Info for debugstr functions */
Alexandre Julliarde5dedb12001-03-08 01:16:41 +0000114 void *pthread_data; /* --3 220 Data for pthread emulation */
Michael McCormack1c32a462001-03-22 20:09:34 +0000115 struct async_private *pending_list; /* --3 224 list of pending async operations */
Alexandre Julliard43230042001-05-16 19:52:29 +0000116 void *driver_data; /* --3 228 Graphics driver private data */
Jukka Heinonenae906922003-06-16 01:18:26 +0000117 DWORD dpmi_vif; /* --3 22c Protected mode virtual interrupt flag */
Ove Kaaven6e33f632001-06-21 00:39:34 +0000118 DWORD vm86_pending; /* --3 230 Data for vm86 mode */
119 void *vm86_ptr; /* --3 234 Data for vm86 mode */
Juergen Schmied74341022000-01-15 22:22:27 +0000120 /* here is plenty space for wine specific fields (don't forget to change pad6!!) */
121
122 /* the following are nt specific fields */
Ove Kaaven4eb0beb2002-01-04 21:57:04 +0000123 DWORD pad6[624]; /* --n 238 */
Juergen Schmied74341022000-01-15 22:22:27 +0000124 UNICODE_STRING StaticUnicodeString; /* -2- bf8 used by advapi32 */
Alexandre Julliard20e73d72003-10-09 04:59:03 +0000125 WCHAR StaticUnicodeBuffer[261]; /* -2- c00 used by advapi32 */
Alexandre Julliard02f28132003-08-27 23:14:29 +0000126 PVOID DeallocationStack; /* -2- e0c Base of the stack */
127 LPVOID TlsSlots[64]; /* -2- e10 Thread local storage */
Alexandre Julliard2eb5d8b2003-09-08 19:02:01 +0000128 LIST_ENTRY TlsLinks; /* -2- f10 */
129 DWORD pad8[1]; /* --n f18 */
Juergen Schmied74341022000-01-15 22:22:27 +0000130 PVOID ReservedForNtRpc; /* -2- f1c used by rpcrt4 */
131 DWORD pad9[24]; /* --n f20 */
Alexandre Julliard02f28132003-08-27 23:14:29 +0000132 PVOID ReservedForOle; /* -2- f80 used by ole32 (IErrorInfo*) */
Eric Pouech64af08e2004-05-10 19:58:48 +0000133 PVOID pad10[4]; /* --n f84 */
134 PVOID TlsExpansionSlots; /* -2- f94 */
Alexandre Julliard9ea19e51997-01-01 17:29:55 +0000135} TEB;
Alexandre Julliard7df1b9e2003-08-28 19:57:35 +0000136#endif /* WINE_TEB_DEFINED */
Alexandre Julliard9ea19e51997-01-01 17:29:55 +0000137
Alexandre Julliard186b4192004-04-16 00:10:03 +0000138
139/* The thread information for 16-bit threads */
140/* NtCurrentTeb()->SubSystemTib points to this */
141typedef struct
142{
143 void *unknown; /* 00 unknown */
144 UNICODE_STRING *exe_name; /* 04 exe module name */
145
146 /* the following fields do not exist under Windows */
147 UNICODE_STRING exe_str; /* exe name string pointed to by exe_name */
Alexandre Julliarddfcfc982004-04-16 05:00:46 +0000148 CURDIR curdir; /* current directory */
Alexandre Julliard186b4192004-04-16 00:10:03 +0000149 WCHAR curdir_buffer[MAX_PATH];
150} WIN16_SUBSYSTEM_TIB;
151
Alexandre Julliard02e90081998-01-04 17:49:09 +0000152/* scheduler/thread.c */
Alexandre Julliard9ee9eff2001-02-28 05:29:50 +0000153extern TEB *THREAD_InitStack( TEB *teb, DWORD stack_size );
Alexandre Julliard02e90081998-01-04 17:49:09 +0000154
Alexandre Julliard9ea19e51997-01-01 17:29:55 +0000155#endif /* __WINE_THREAD_H */